Skip to content

Commit

Permalink
switched internal uworld.h WorldIterator to Pos class (polserver#429)
Browse files Browse the repository at this point in the history
removed >< operator to avoid missunderstandings
fixed helperscripts checkmembers/checkmethods
  • Loading branch information
turleypol authored Sep 21, 2021
1 parent f211e16 commit bf27f27
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 352 deletions.
4 changes: 2 additions & 2 deletions doctools/checkmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parseMemberDec():

def parseMemberDef(decs):
defs=dict()
with open('../pol-core/bscript/parser.cpp','r') as f:
with open('../pol-core/bscript/objaccess.cpp','r') as f:
in_def=False
for l in f.readlines():
l=l.strip();
Expand All @@ -32,7 +32,7 @@ def parseMemberDef(decs):
continue
if not in_def:
continue
if l.startswith('{MBR_'):
if l.startswith('{ MBR_'):
l=l.replace('{','').replace('"','')
l=[_.strip() for _ in l.split(',')]
for d in decs:
Expand Down
15 changes: 11 additions & 4 deletions doctools/checkmethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parseMethodDec():

def parseMethodDef(decs):
defs=dict()
with open('../pol-core/bscript/parser.cpp','r') as f:
with open('../pol-core/bscript/objaccess.cpp','r') as f:
in_def=False
for l in f.readlines():
l=l.strip();
Expand All @@ -32,7 +32,7 @@ def parseMethodDef(decs):
continue
if not in_def:
continue
if l.startswith('{MTH_'):
if l.startswith('{ MTH_'):
l=l.replace('{','').replace('"','')
l=[_.strip() for _ in l.split(',')]
for d in decs:
Expand Down Expand Up @@ -69,6 +69,10 @@ def parseFile(file,defs,methods):
l=l[:l.find('::call_method')]
active=l.split()[-1]
in_d=True
elif not in_d and '::call_polmethod' in l:
l=l[:l.find('::call_polmethod')]
active=l.split()[-1]
in_d=True
elif not in_d and '::script_method_id' in l:
l=l[:l.find('::script_method_id')]
active=l.split()[-1]
Expand Down Expand Up @@ -105,8 +109,11 @@ def parseFile(file,defs,methods):
print(linec)
raise
if 'if ( stricmp' in l:
m=l.split('"')[1]
supported.append(m)
try:
m=l.split('"')[1]
supported.append(m)
except:
pass
if 'CallPropertyListMethod' in l:
supported.append('!CPROP!')
return methods
Expand Down
116 changes: 2 additions & 114 deletions pol-core/pol/base/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,6 @@ bool Pos2d::operator!=( const Pos2d& other ) const
{
return !( *this == other );
}
bool Pos2d::operator<( const Pos2d& other ) const
{
if ( _x == other._x )
return _y < other._y;
return _x < other._x;
}
bool Pos2d::operator>( const Pos2d& other ) const
{
if ( _x == other._x )
return _y > other._y;
return _x > other._x;
}
bool Pos2d::operator<=( const Pos2d& other ) const
{
return *this == other || *this < other;
}
bool Pos2d::operator>=( const Pos2d& other ) const
{
return *this == other || *this > other;
}

Pos2d& Pos2d::operator-=( const Vec2d& other )
{
Expand Down Expand Up @@ -201,26 +181,6 @@ bool Pos3d::operator!=( const Pos3d& other ) const
{
return !( *this == other );
}
bool Pos3d::operator<( const Pos3d& other ) const
{
if ( _xy == other._xy )
return _z < other._z;
return _xy < other._xy;
}
bool Pos3d::operator>( const Pos3d& other ) const
{
if ( _xy == other._xy )
return _z > other._z;
return _xy > other._xy;
}
bool Pos3d::operator<=( const Pos3d& other ) const
{
return *this == other || *this < other;
}
bool Pos3d::operator>=( const Pos3d& other ) const
{
return *this == other || *this > other;
}
bool Pos3d::operator==( const Pos2d& other ) const
{
return _xy == other;
Expand All @@ -229,22 +189,6 @@ bool Pos3d::operator!=( const Pos2d& other ) const
{
return _xy != other;
}
bool Pos3d::operator<( const Pos2d& other ) const
{
return _xy < other;
}
bool Pos3d::operator>( const Pos2d& other ) const
{
return _xy > other;
}
bool Pos3d::operator<=( const Pos2d& other ) const
{
return _xy <= other;
}
bool Pos3d::operator>=( const Pos2d& other ) const
{
return _xy >= other;
}

Pos3d& Pos3d::operator-=( const Vec2d& other )
{
Expand Down Expand Up @@ -336,7 +280,7 @@ Pos3d& Pos3d::crop( const Realms::Realm* realm )

fmt::Writer& operator<<( fmt::Writer& w, const Pos3d& v )
{
w << "( " << v.x() << ", " << v.y() << ", " << v.z() << " )";
w << "( " << v.x() << ", " << v.y() << ", " << (int)v.z() << " )";
return w;
}

Expand All @@ -362,30 +306,6 @@ bool Pos4d::operator!=( const Pos4d& other ) const
{
return !( *this == other );
}
bool Pos4d::operator<( const Pos4d& other ) const
{
if ( _realm != other._realm )
return false;
return _xyz < other._xyz;
}
bool Pos4d::operator>( const Pos4d& other ) const
{
if ( _realm != other._realm )
return false;
return _xyz > other._xyz;
}
bool Pos4d::operator<=( const Pos4d& other ) const
{
if ( _realm != other._realm )
return false;
return _xyz <= other._xyz;
}
bool Pos4d::operator>=( const Pos4d& other ) const
{
if ( _realm != other._realm )
return false;
return _xyz >= other._xyz;
}
bool Pos4d::operator==( const Pos3d& other ) const
{
return _xyz == other;
Expand All @@ -394,22 +314,6 @@ bool Pos4d::operator!=( const Pos3d& other ) const
{
return !( *this == other );
}
bool Pos4d::operator<( const Pos3d& other ) const
{
return _xyz < other;
}
bool Pos4d::operator>( const Pos3d& other ) const
{
return _xyz > other;
}
bool Pos4d::operator<=( const Pos3d& other ) const
{
return _xyz <= other;
}
bool Pos4d::operator>=( const Pos3d& other ) const
{
return _xyz >= other;
}
bool Pos4d::operator==( const Pos2d& other ) const
{
return _xyz.xy() == other;
Expand All @@ -418,22 +322,6 @@ bool Pos4d::operator!=( const Pos2d& other ) const
{
return !( *this == other );
}
bool Pos4d::operator<( const Pos2d& other ) const
{
return _xyz.xy() < other;
}
bool Pos4d::operator>( const Pos2d& other ) const
{
return _xyz.xy() > other;
}
bool Pos4d::operator<=( const Pos2d& other ) const
{
return _xyz.xy() <= other;
}
bool Pos4d::operator>=( const Pos2d& other ) const
{
return _xyz.xy() >= other;
}

Pos4d& Pos4d::operator-=( const Vec2d& other )
{
Expand Down Expand Up @@ -538,7 +426,7 @@ bool Pos4d::in_range( const Pos2d& other, u16 range ) const

fmt::Writer& operator<<( fmt::Writer& w, const Pos4d& v )
{
w << "( " << v.x() << ", " << v.y() << ", " << v.z()
w << "( " << v.x() << ", " << v.y() << ", " << (int)v.z() << ", "
<< ( v.realm() != nullptr ? v.realm()->name() : "null" ) << " )";
return w;
}
Expand Down
24 changes: 0 additions & 24 deletions pol-core/pol/base/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class Pos2d

bool operator==( const Pos2d& other ) const;
bool operator!=( const Pos2d& other ) const;
bool operator<( const Pos2d& other ) const;
bool operator>( const Pos2d& other ) const;
bool operator<=( const Pos2d& other ) const;
bool operator>=( const Pos2d& other ) const;

Pos2d& operator-=( const Vec2d& other );
Pos2d& operator+=( const Vec2d& other );
Expand Down Expand Up @@ -99,17 +95,9 @@ class Pos3d

bool operator==( const Pos3d& other ) const;
bool operator!=( const Pos3d& other ) const;
bool operator<( const Pos3d& other ) const;
bool operator>( const Pos3d& other ) const;
bool operator<=( const Pos3d& other ) const;
bool operator>=( const Pos3d& other ) const;

bool operator==( const Pos2d& other ) const;
bool operator!=( const Pos2d& other ) const;
bool operator<( const Pos2d& other ) const;
bool operator>( const Pos2d& other ) const;
bool operator<=( const Pos2d& other ) const;
bool operator>=( const Pos2d& other ) const;

Pos3d& operator-=( const Vec2d& other );
Pos3d& operator+=( const Vec2d& other );
Expand Down Expand Up @@ -162,24 +150,12 @@ class Pos4d

bool operator==( const Pos4d& other ) const;
bool operator!=( const Pos4d& other ) const;
bool operator<( const Pos4d& other ) const;
bool operator>( const Pos4d& other ) const;
bool operator<=( const Pos4d& other ) const;
bool operator>=( const Pos4d& other ) const;

bool operator==( const Pos3d& other ) const;
bool operator!=( const Pos3d& other ) const;
bool operator<( const Pos3d& other ) const;
bool operator>( const Pos3d& other ) const;
bool operator<=( const Pos3d& other ) const;
bool operator>=( const Pos3d& other ) const;

bool operator==( const Pos2d& other ) const;
bool operator!=( const Pos2d& other ) const;
bool operator<( const Pos2d& other ) const;
bool operator>( const Pos2d& other ) const;
bool operator<=( const Pos2d& other ) const;
bool operator>=( const Pos2d& other ) const;

Pos4d& operator-=( const Vec2d& other );
Pos4d& operator+=( const Vec2d& other );
Expand Down
3 changes: 2 additions & 1 deletion pol-core/pol/base/range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Range2dItr Range2d::end() const

bool Range2d::contains( const Pos2d& other ) const
{
return _nw <= other && _se >= other;
return _nw.x() <= other.x() && _nw.y() <= other.y() && other.x() <= _se.x() &&
other.y() <= _se.y();
}

bool Range2d::intersect( const Range2d& other ) const
Expand Down
56 changes: 0 additions & 56 deletions pol-core/pol/base/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,6 @@ bool Vec2d::operator!=( const Vec2d& other ) const
{
return !( *this == other );
}
bool Vec2d::operator<( const Vec2d& other ) const
{
if ( _x == other._x )
return _y < other._y;
return _x < other._x;
}
bool Vec2d::operator>( const Vec2d& other ) const
{
if ( _x == other._x )
return _y > other._y;
return _x > other._x;
}
bool Vec2d::operator<=( const Vec2d& other ) const
{
return *this == other || *this < other;
}
bool Vec2d::operator>=( const Vec2d& other ) const
{
return *this == other || *this > other;
}

Vec2d& Vec2d::operator-=( const Vec2d& other )
{
Expand Down Expand Up @@ -84,26 +64,6 @@ bool Vec3d::operator!=( const Vec3d& other ) const
{
return !( *this == other );
}
bool Vec3d::operator<( const Vec3d& other ) const
{
if ( _xy == other._xy )
return _z < other._z;
return _xy < other._xy;
}
bool Vec3d::operator>( const Vec3d& other ) const
{
if ( _xy == other._xy )
return _z > other._z;
return _xy > other._xy;
}
bool Vec3d::operator<=( const Vec3d& other ) const
{
return *this == other || *this < other;
}
bool Vec3d::operator>=( const Vec3d& other ) const
{
return *this == other || *this > other;
}
bool Vec3d::operator==( const Vec2d& other ) const
{
return _xy == other;
Expand All @@ -112,22 +72,6 @@ bool Vec3d::operator!=( const Vec2d& other ) const
{
return _xy != other;
}
bool Vec3d::operator<( const Vec2d& other ) const
{
return _xy < other;
}
bool Vec3d::operator>( const Vec2d& other ) const
{
return _xy > other;
}
bool Vec3d::operator<=( const Vec2d& other ) const
{
return _xy <= other;
}
bool Vec3d::operator>=( const Vec2d& other ) const
{
return _xy >= other;
}

Vec3d& Vec3d::operator-=( const Vec3d& other )
{
Expand Down
Loading

0 comments on commit bf27f27

Please sign in to comment.