I have come across a map who's tiling seemed quite messed up.
Aparently the plan was to have a square of 3x3 repeated infinitely like this:
456 123 789 ... 456 . 456 . 456 123 . 123 . 123 789 . 789 . 789 ... 456 123 789
I like the idea, but instead there were several maps which pointed to the wrong map (like map 1 pointing to map 4 to the north AND to the west, but map 4 pointing to 5 east and 1 south).
The error I got while running the server with -d was:
object_update() called for object out of map!
Follow-up with a debugger threw this backtrace:
Program received signal SIGSEGV, Segmentation fault. 0x000000000048091f in get_map_flags (oldmap=0x1c71990, newmap=newmap@entry=0x7fffffffdd68, x=x@entry=13, y=y@entry=19, nx=nx@entry=0x7fffffffdd64, ny=ny@entry=0x7fffffffdd66) at map.c:333 333 retval |= mp->spaces[newx+mp->width*newy].flags; (gdb) bt #0 0x000000000048091f in get_map_flags (oldmap=0x1c71990, newmap=newmap@entry=0x7fffffffdd68, x=x@entry=13, y=y@entry=19, nx=nx@entry=0x7fffffffdd64, ny=ny@entry=0x7fffffffdd66) at map.c:333 #1 0x000000000041a913 in monster_stand_in_light (op=0x2f55dd0) at monster.c:2461 #2 0x000000000041aa38 in monster_can_see_enemy (op=op@entry=0x32d93a0, enemy=enemy@entry=0x2f55dd0) at monster.c:2534 #3 0x000000000041aba2 in monster_can_detect_enemy (op=op@entry=0x32d93a0, enemy=enemy@entry=0x2f55dd0, rv=rv@entry=0x7fffffffdf10) at monster.c:2316 #4 0x00000000004216f7 in get_nearest_player (mon=mon@entry=0x32d93a0) at player.c:563 #5 0x000000000041c0a5 in monster_find_enemy (rv=0x7fffffffdf90, npc=0x32d93a0) at monster.c:285 #6 monster_move (op=op@entry=0x32d93a0) at monster.c:641 #7 0x0000000000444462 in process_object (op=op@entry=0x32d93a0) at time.c:790 #8 0x00000000004050f1 in process_events () at server.c:1140 #9 0x0000000000405989 in server_main (argc=<optimized out>, argv=<optimized out>) at server.c:1442 #10 0x00007ffff6c82a15 in __libc_start_main () from /usr/lib/libc.so.6 #11 0x0000000000403511 in _start ()
newx+mp->width*newy = 963
But trying to access mp->spaces[newx+mp->width*newy].flags gives:
The value of 'mp->spaces[newx+mp->width*newy].flags' is of type 'uint8' which is a typedef of type 'unsigned char' Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 0x1a5b0: Error occurred in Python command: Cannot access memory at address 0x1a5b0
Which caused the segfault.
I think there should be some check for correct tiling when the map is first loaded, verifying that the pointed map points back to us. Maybe also checking with (or height) are the same?
Doing this check in gridarta may not be enough since we are talking about different files and some of them may not get to svn in the right version (this is unpleasant to say and you can argue it, but still).
I post a bug report because (for now) I have no idea on how to do this.
I'll fix the map itself, altough this won't keep us away from future messy maps.
Log in to post a comment.