diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-13 14:55:49 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-27 11:29:45 -0700 |
commit | 9951ad78c80e144c166a7d476cad7ffdf84332a9 (patch) | |
tree | 9f5498a9a3c23b62dc928288e72081e99f958f46 /src/map/mapflag.py | |
parent | 749fec734c4583153fb2dbc80f1d21db2c2ab457 (diff) | |
download | tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.gz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.bz2 tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.tar.xz tmwa-9951ad78c80e144c166a7d476cad7ffdf84332a9.zip |
Debug debugging
Diffstat (limited to 'src/map/mapflag.py')
-rw-r--r-- | src/map/mapflag.py | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/src/map/mapflag.py b/src/map/mapflag.py index fec8c05..fe5b016 100644 --- a/src/map/mapflag.py +++ b/src/map/mapflag.py @@ -1,6 +1,4 @@ class MapFlags(object): - ''' print a set of map flags - ''' __slots__ = ('_value') name = 'tmwa::MapFlags' enabled = True @@ -11,29 +9,38 @@ class MapFlags(object): def to_string(self): i = int(self._value) s = [] - for n, v in [ - ('ALIAS', 21), - ('NOMEMO', 0), + for n, v in MapFlags.junk: + v = 1 << v + if i & v: + i -= v + s.append(n) + if i or not s: + s.append('%#08x' % i) + return 'MapFlags(%s)' % (' | '.join(s)) + + junk = [ + #('ALIAS', 21), + #('NOMEMO', 0), ('NOTELEPORT', 1), ('NORETURN', 22), ('MONSTER_NOTELEPORT', 23), ('NOSAVE', 2), - ('NOBRANCH', 3), + #('NOBRANCH', 3), ('NOPENALTY', 4), ('PVP', 6), ('PVP_NOPARTY', 7), - ('PVP_NOGUILD', 8), - ('PVP_NIGHTMAREDROP', 24), + #('PVP_NOGUILD', 8), + #('PVP_NIGHTMAREDROP', 24), ('PVP_NOCALCRANK', 25), - ('GVG', 9), - ('GVG_NOPARTY', 10), - ('NOZENYPENALTY', 5), - ('NOTRADE', 11), - ('NOSKILL', 12), + #('GVG', 9), + #('GVG_NOPARTY', 10), + #('NOZENYPENALTY', 5), + #('NOTRADE', 11), + #('NOSKILL', 12), ('NOWARP', 13), ('NOWARPTO', 26), ('NOPVP', 14), - ('NOICEWALL', 15), + #('NOICEWALL', 15), ('SNOW', 16), ('FOG', 17), ('SAKURA', 18), @@ -43,11 +50,14 @@ class MapFlags(object): ('TOWN', 28), ('OUTSIDE', 29), ('RESAVE', 30), - ]: - v = 1 << v - if i & v: - i -= v - s.append(n) - if i or not s: - s.append('%#08x' % i) - return 'MapFlags(%s)' % (' | '.join(s)) + ] + tests = [ + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0x80000000))', 'MapFlags(0x80000000)'), + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(0xf0000000))', 'MapFlags(TOWN | OUTSIDE | RESAVE | 0x80000000)'), + ] + [ + ('tmwa::MapFlags(); value.set(tmwa::MapFlag::%s, true)' % n, 'MapFlags(%s)' % n) + for (n, _) in junk + ] + [ + ('reinterpret_cast<const tmwa::MapFlags&>(static_cast<const unsigned int&>(1 << %d))' % i, 'MapFlags(%s)' % n) + for (n, i) in junk + ] |