Debian Codegraph @

python/CFWorld.py

raw
1 #CFWorld.py
2 #A small module for checking where is bigworld an object is if it's in bigworld.
3 import Crossfire
4
5 world_prefix = "/world/world_"
6 world_prefix_len = len(world_prefix)
7 world_len = len(world_prefix) + len('xxx_xxx')
8 world_sep = '_'
9 bigmapxsize = 50
10 bigmapysize = 50
11
12 #Return an x,y tuple of where in bigworld an object is. Return false if not in bigworld. In current bigworld, values range from 5000 to 6499.
13 def loc_from_ob(ob):
14 cfmap = ob.Map
15 if ((cfmap.Path.find(world_prefix) != 0) or (len(cfmap.Path) != world_len)):
16 return False
17 strloc = cfmap.Path[world_prefix_len:].split(world_sep)
18 x = (int(strloc[0]) * bigmapxsize) + ob.X
19 y = (int(strloc[1]) * bigmapysize) + ob.Y
20 return (x, y)