Changeset 262

Show
Ignore:
Timestamp:
07/04/07 11:39:56 (1 year ago)
Author:
takkaria
Message:

Fix #188:

  • Up the maximum # of objects on the level to 1024.
  • When compression happens, first destroy gold and squelched items.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/edit/limits.txt

    r157 r262  
    5252 
    5353# Maximum number of objects on the level 
    54 M:O:512 
     54M:O:1024 
    5555 
    5656# Maximum number of monsters on the level 
  • trunk/src/externs.h

    r250 r262  
    599599void autoinscribe_pack(void); 
    600600 
     601bool squelch_item_ok(const object_type *o_ptr); 
    601602void squelch_set(object_type *o_ptr); 
    602603bool squelch_hide_item(object_type *o_ptr); 
  • trunk/src/object2.c

    r259 r262  
    287287 
    288288/* 
    289  * Compact and Reorder the object list 
     289 * Compact and reorder the object list 
    290290 * 
    291291 * This function can be very dangerous, use with caution! 
    292292 * 
    293  * When actually "compacting" objects, we base the saving throw on a 
    294  * combination of object level, distance from player, and current 
    295  * "desperation". 
    296  * 
    297  * After "compacting" (if needed), we "reorder" the objects into a more 
    298  * compact order, and we reset the allocation info, and the "live" array. 
     293 * When compacting objects, we first destroy gold, on the basis that by the 
     294 * time item compaction becomes an issue, the player really won't care. 
     295 * We also nuke items marked as squelch. 
     296 * 
     297 * When compacting other objects, we base the saving throw on a combination of 
     298 * object level, distance from player, and current "desperation". 
     299 * 
     300 * After compacting, we "reorder" the objects into a more compact order, and we 
     301 * reset the allocation info, and the "live" array. 
    299302 */ 
    300303void compact_objects(int size) 
     
    303306        int px = p_ptr->px; 
    304307 
    305         int i, y, x, num, cnt; 
     308        int i, y, x, cnt; 
    306309 
    307310        int cur_lev, cur_dis, chance; 
    308311 
    309312 
    310         /* Compact */ 
    311         if (size) 
    312         { 
    313                 /* Message */ 
    314                 msg_print("Compacting objects..."); 
    315  
    316                 /* Redraw map */ 
    317                 p_ptr->redraw |= (PR_MAP); 
    318  
    319                 /* Window stuff */ 
    320                 p_ptr->window |= (PW_OVERHEAD | PW_MAP); 
     313        /* Reorder objects when not passed a size */ 
     314        if (!size) 
     315        { 
     316                /* Excise dead objects (backwards!) */ 
     317                for (i = o_max - 1; i >= 1; i--) 
     318                { 
     319                        object_type *o_ptr = &o_list[i]; 
     320 
     321                        /* Skip real objects */ 
     322                        if (o_ptr->k_idx) continue; 
     323 
     324                        /* Move last object into open hole */ 
     325                        compact_objects_aux(o_max - 1, i); 
     326 
     327                        /* Compress "o_max" */ 
     328                        o_max--; 
     329                } 
     330 
     331                return; 
     332        } 
     333 
     334 
     335        /* Message */ 
     336        msg_print("Compacting objects..."); 
     337 
     338        /* Redraw map */ 
     339        p_ptr->redraw |= (PR_MAP); 
     340 
     341        /* Window stuff */ 
     342        p_ptr->window |= (PW_OVERHEAD | PW_MAP); 
     343 
     344 
     345 
     346 
     347        /*** Try destroying objects ***/ 
     348 
     349        /* First do gold */ 
     350        for (i = 1; (i < o_max) && (size); i++) 
     351        { 
     352                object_type *o_ptr = &o_list[i]; 
     353 
     354                /* Nuke gold or squelched items */ 
     355                if (o_ptr->tval == TV_GOLD || squelch_item_ok(o_ptr)) 
     356                { 
     357                        delete_object_idx(i); 
     358                        size--; 
     359                } 
    321360        } 
    322361 
    323362 
    324363        /* Compact at least 'size' objects */ 
    325         for (num = 0, cnt = 1; num < size; cnt++) 
     364        for (cnt = 1; size; cnt++) 
    326365        { 
    327366                /* Get more vicious each iteration */ 
     
    332371 
    333372                /* Examine the objects */ 
    334                 for (i = 1; i < o_max; i++) 
     373                for (i = 1; (i < o_max) && (size); i++) 
    335374                { 
    336375                        object_type *o_ptr = &o_list[i]; 
    337  
    338376                        object_kind *k_ptr = &k_info[o_ptr->k_idx]; 
    339377 
     
    377415                        chance = 90; 
    378416 
    379                         /* Squelched items get compacted */ 
    380                         if (k_ptr->aware && k_ptr->squelch) chance = 0; 
    381  
    382417 
    383418                        /* Hack -- only compact artifacts in emergencies */ 
     
    389424                        /* Delete the object */ 
    390425                        delete_object_idx(i); 
    391  
    392                         /* Count it */ 
    393                         num++; 
    394                 } 
    395         } 
    396  
    397  
    398         /* Excise dead objects (backwards!) */ 
    399         for (i = o_max - 1; i >= 1; i--) 
    400         { 
    401                 object_type *o_ptr = &o_list[i]; 
    402  
    403                 /* Skip real objects */ 
    404                 if (o_ptr->k_idx) continue; 
    405  
    406                 /* Move last object into open hole */ 
    407                 compact_objects_aux(o_max - 1, i); 
    408  
    409                 /* Compress "o_max" */ 
    410                 o_max--; 
    411         } 
     426                        size--; 
     427                } 
     428        } 
     429 
     430 
     431        /* Reorder objects */ 
     432        compact_objects(0); 
    412433} 
    413434 
  • trunk/src/snd-sdl.c

    r166 r262  
    5858static void close_audio(void) 
    5959{ 
    60         size_t i, j; 
     60        size_t i; 
     61        int j; 
    6162 
    6263        /* Free all the sample data*/ 
     
    123124        char path[2048]; 
    124125        char buffer[2048]; 
    125         int i; 
    126126        FILE *fff; 
    127         Mix_Chunk *wave = NULL;          
    128127 
    129128 
  • trunk/src/squelch.c

    r245 r262  
    316316 * Determines if an object is eligable for squelching. 
    317317 */ 
    318 static bool squelch_item_ok(const object_type *o_ptr) 
     318bool squelch_item_ok(const object_type *o_ptr) 
    319319{ 
    320320        size_t i; 
  • trunk/src/ui.c

    r256 r262  
    9696void stop_event_loop() 
    9797{ 
    98         event_type stop = { EVT_STOP }; 
     98        event_type stop = { EVT_STOP, 0, 0, 0, 0 }; 
    9999 
    100100        /* Stop right away! */ 
     
    647647        { 
    648648                /* TODO: need a panel dispatcher here, not a generic target */ 
    649                 event_target t = { { 0, 0, 0, 0 }, FALSE, 0 /* menu->target.observers */}; 
     649                event_target t = { EVENT_EMPTY, FALSE, 0 /* menu->target.observers */}; 
    650650                t.observers = menu->target.observers; 
    651651                out = run_event_loop(&t, FALSE, in);