+
+ def free_pos():
+ i = 0
+ while 1:
+ err = "Space to put thing on too hard to find. Map too small?"
+ while 1:
+ y = rand.next() % world_db["MAP_LENGTH"]
+ x = rand.next() % world_db["MAP_LENGTH"]
+ if "." == chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]):
+ break
+ i += 1
+ if i == 65535:
+ raise SystemExit(err)
+ # Replica of C code, wrongly ignores animatedness of new Thing.
+ pos_clear = (0 == len([id for id in world_db["Things"]
+ if world_db["Things"][id]["T_LIFEPOINTS"]
+ if world_db["Things"][id]["T_POSY"] == y
+ if world_db["Things"][id]["T_POSX"] == x]))
+ if pos_clear:
+ break
+ return (y, x)
+