[CF-Devel] patch for generators to create special ability mo

Mark Wedel mwedel at sonic.net
Thu Apr 18 00:22:23 CDT 2002


Norbert Irmer wrote:

>
     
      Norbert Irmer wrote:
     
     >
     
     
     
>
     
      Program received signal SIGSEGV, Segmentation fault.
     
     >
     
      0x80a05d0 in get_map_from_coord (m=0x0, x=0xbfbff6b0, y=0xbfbff6b4)
     
     >
     
         at map.c:1845
     
     >
     
      1845        if (*x>=0 && *x<MAP_WIDTH(m) && *y>=0 && *y < MAP_HEIGHT(m))
     
     >
     
      (gdb) info stack
     
     >
     
      #0  0x80a05d0 in get_map_from_coord (m=0x0, x=0xbfbff6b0, y=0xbfbff6b4)
     
     >
     
         at map.c:1845
     
     >
     
      #1  0x809da4d in blocked (m=0x0, x=0, y=-1) at map.c:315
     
     >
     
      #2  0x809dc6a in arch_blocked (at=0x8283400, m=0x0, x=0, y=-1) at map.c:438
     
     >
     
      #3  0x80a3539 in find_free_spot (at=0x8283400, m=0x0, x=0, y=0, start=1,
     
     >
     
         stop=9) at object.c:1935
     
     >
     
      #4  0x8086b10 in generate_monster (gen=0x8bb2c44) at time.c:119
     
     >
     
      #5  0x8088ac2 in process_object (op=0x8bb2c44) at time.c:1186
     
     >
     
      #6  0x8066ba9 in process_events (map=0x0) at main.c:922
     
     >
     
      #7  0x806713d in main (argc=1, argv=0xbfbffc28) at main.c:1147
     
     >
     
      #8  0x8049d45 in _start ()
     
     >
     
     
     >
     
      As mark wrote in a previous mail, the problem is caused by process_object
     
     >
     
      processing the object in the inventory of the generator.
     
     >
     
      But a top level check in process_object like
     
     >
     
       if op->type==monster && op->map==NULL continue
     
     >
     
      is no solution, as the fog example shows.
     
     

  Probably because the fog type is not a monster.

  IT is unclear to me why you want to put fog in the inventory of a generator - 
the only reason somethign needs to be in the inventory are if you are changing 
the values.  If you are just using the standard fog arch, then you should use 
the other_arch.


>
     
     
     >
     
      I would propose to change 'find_free_spot' or even better 
     
     >
     
      'arch_out_of_map',
     
     >
     
      which is called by 'find_free_spot', so that false is returned if 
     
     >
     
      map==NULL.
     
     

  The change should be higher up - in generator monster in this case.

  Changing find_free_spot or arch_out_of_map is not the right place - that will 
mask other programming problems in the future.  Certain programming practices 
should be caught with errors.  If find_free_spot is passed a null map, IMO, it 
should crash - the code calling it should make sure it is doing the right thing. 
  One reason I say this is that in some cases, if find_free_spot returns that 
there is no space available, it may be use other fallback code.



    
    


More information about the crossfire mailing list