Ticket #19: dtrap-vanilla.v1.diff

File dtrap-vanilla.v1.diff, 11.9 kB (added by takkaria, 1 year ago)

Old patch as a basis for future work

  • src-3.0.6/src/cave.c

    old new  
    38833883                { 
    38843884                        /* Process the grid */ 
    38853885                        cave_info[y][x] &= ~(CAVE_MARK); 
     3886                        cave_info2[y][x] &= ~(CAVE2_DTRAP); 
    38863887                } 
    38873888        } 
    38883889 
  • src-3.0.6/src/cmd1.c

    old new  
    12311231        int y, x; 
    12321232 
    12331233 
     1234        bool old_dtrap, new_dtrap; 
     1235 
     1236 
    12341237        /* Find the result of moving */ 
    12351238        y = py + ddy[dir]; 
    12361239        x = px + ddx[dir]; 
     
    13301333                /* Sound XXX XXX XXX */ 
    13311334                /* sound(MSG_WALK); */ 
    13321335 
    1333                 /* Move player */ 
    1334                 monster_swap(py, px, y, x); 
     1336                /* See if trap detection status will change */ 
     1337                old_dtrap = ((cave_info2[py][px] & (CAVE2_DTRAP)) != 0); 
     1338                new_dtrap = ((cave_info2[y][x] & (CAVE2_DTRAP)) != 0); 
     1339 
     1340                /* Note the change in the detect status */ 
     1341                if (old_dtrap != new_dtrap) p_ptr->redraw |= (PR_DTRAP); 
     1342 
     1343                /* Disturb player if the player is about to leave the detect area XXX */ 
     1344                if (disturb_detect && p_ptr->running && old_dtrap && !new_dtrap) 
     1345                { 
     1346                        /* Disturb the player */ 
     1347                        disturb(0, 0); 
     1348 
     1349                        /* Done XXX */ 
     1350                        return; 
     1351                } 
     1352 
     1353                /* Move player */ 
     1354                monster_swap(py, px, y, x); 
     1355   
     1356 
    13351357 
    13361358                /* New location */ 
    13371359                y = py = p_ptr->py; 
  • src-3.0.6/src/defines.h

    old new  
    531531#define ROW_STATE               (Term->hgt - 1) 
    532532#define COL_STATE               38      /* <state> */ 
    533533 
     534#define ROW_DTRAP               (Term->hgt - 1) 
     535#define COL_DTRAP               49      /* "DTrap" */ 
     536 
    534537#define ROW_SPEED               (Term->hgt - 1) 
    535 #define COL_SPEED               49    /* "Slow (-NN)" or "Fast (+NN)" */ 
     538#define COL_SPEED               55    /* "Slow (-NN)" or "Fast (+NN)" */ 
    536539 
    537540#define ROW_STUDY               (Term->hgt - 1) 
    538 #define COL_STUDY               64    /* "Study" */ 
     541#define COL_STUDY               66    /* "Study" */ 
    539542 
    540543#define ROW_DEPTH               (Term->hgt - 1) 
    541 #define COL_DEPTH               70    /* "Lev NNN" / "NNNN ft" */ 
     544#define COL_DEPTH               72    /* "Lev NNN" / "NNNN ft" */ 
    542545 
    543546#define ROW_OPPOSE_ELEMENTS     (Term->hgt - 1) 
    544547#define COL_OPPOSE_ELEMENTS     80      /* "Acid Elec Fire Cold Pois" */ 
     
    16181621#define PR_CUT                  0x00001000L     /* Display Extra (Cut) */ 
    16191622#define PR_STUN                 0x00002000L     /* Display Extra (Stun) */ 
    16201623#define PR_HUNGER               0x00004000L     /* Display Extra (Hunger) */ 
    1621 /* xxx */ 
     1624#define PR_DTRAP               0x00008000L /* Display Extra (Trap detection) */ 
    16221625#define PR_BLIND                0x00010000L     /* Display Extra (Blind) */ 
    16231626#define PR_CONFUSED             0x00020000L     /* Display Extra (Confused) */ 
    16241627#define PR_AFRAID               0x00040000L     /* Display Extra (Afraid) */ 
     
    16791682#define CAVE_TEMP               0x40    /* temp flag */ 
    16801683#define CAVE_WALL               0x80    /* wall flag */ 
    16811684 
     1685#define CAVE2_DTRAP             0x01    /* trap detected grid */ 
    16821686 
    16831687 
    16841688/*** Object flags ***/ 
     
    24182422#define OPT_run_use_corners                     19 
    24192423#define OPT_disturb_move                        20 
    24202424#define OPT_disturb_near                        21 
    2421 #define OPT_disturb_panel                     22 
     2425#define OPT_disturb_detect                    22 
    24222426#define OPT_disturb_state                       23 
    24232427#define OPT_disturb_minor                       24 
    24242428/* xxx OPT_disturb_other */ 
     
    25382542#define run_use_corners                 op_ptr->opt[OPT_run_use_corners] 
    25392543#define disturb_move                    op_ptr->opt[OPT_disturb_move] 
    25402544#define disturb_near                    op_ptr->opt[OPT_disturb_near] 
    2541 #define disturb_panel                  op_ptr->opt[OPT_disturb_panel
     2545#define disturb_detect                 op_ptr->opt[OPT_disturb_detect
    25422546#define disturb_state                   op_ptr->opt[OPT_disturb_state] 
    25432547#define disturb_minor                   op_ptr->opt[OPT_disturb_minor] 
    25442548/* xxx disturb_other */ 
  • src-3.0.6/src/externs.h

    old new  
    147147extern byte *temp_y; 
    148148extern byte *temp_x; 
    149149extern byte (*cave_info)[256]; 
     150extern byte (*cave_info2)[256]; 
    150151extern byte (*cave_feat)[DUNGEON_WID]; 
    151152extern s16b (*cave_o_idx)[DUNGEON_WID]; 
    152153extern s16b (*cave_m_idx)[DUNGEON_WID]; 
  • src-3.0.6/src/generate.c

    old new  
    33833383                        { 
    33843384                                /* No flags */ 
    33853385                                cave_info[y][x] = 0; 
     3386                                cave_info2[y][x] = 0; 
    33863387 
    33873388                                /* No features */ 
    33883389                                cave_feat[y][x] = 0; 
  • src-3.0.6/src/init2.c

    old new  
    13731373 
    13741374        /* Padded into array */ 
    13751375        C_MAKE(cave_info, DUNGEON_HGT, byte_256); 
     1376        C_MAKE(cave_info2, DUNGEON_HGT, byte_256); 
    13761377 
    13771378        /* Feature array */ 
    13781379        C_MAKE(cave_feat, DUNGEON_HGT, byte_wid); 
     
    21032104        FREE(cave_o_idx); 
    21042105        FREE(cave_m_idx); 
    21052106        FREE(cave_feat); 
     2107        FREE(cave_info2); 
    21062108        FREE(cave_info); 
    21072109 
    21082110        /* Free the "update_view()" array */ 
  • src-3.0.6/src/load.c

    old new  
    15011501                } 
    15021502        } 
    15031503 
     1504        /* Load the dungeon data */ 
     1505        for (x = y = 0; y < DUNGEON_HGT; ) 
     1506        { 
     1507                /* Grab RLE info */ 
     1508                rd_byte(&count); 
     1509                rd_byte(&tmp8u); 
     1510 
     1511                /* Apply the RLE info */ 
     1512                for (i = count; i > 0; i--) 
     1513                { 
     1514                        /* Extract "info" */ 
     1515                        cave_info2[y][x] = tmp8u; 
     1516 
     1517                        /* Advance/Wrap */ 
     1518                        if (++x >= DUNGEON_WID) 
     1519                        { 
     1520                                /* Wrap */ 
     1521                                x = 0; 
     1522 
     1523                                /* Advance/Wrap */ 
     1524                                if (++y >= DUNGEON_HGT) break; 
     1525                        } 
     1526                } 
     1527        } 
     1528 
    15041529 
    15051530        /*** Run length decoding ***/ 
    15061531 
  • src-3.0.6/src/monster2.c

    old new  
    13291329                p_ptr->py = y2; 
    13301330                p_ptr->px = x2; 
    13311331 
     1332                /* Update the trap detection status */ 
     1333                p_ptr->redraw |= (PR_DTRAP); 
     1334 
    13321335                /* Update the panel */ 
    13331336                p_ptr->update |= (PU_PANEL); 
    13341337 
     
    13621365                p_ptr->py = y1; 
    13631366                p_ptr->px = x1; 
    13641367 
     1368                /* Update the trap detection status */ 
     1369                p_ptr->redraw |= (PR_DTRAP); 
     1370 
    13651371                /* Update the panel */ 
    13661372                p_ptr->update |= (PU_PANEL); 
    13671373 
  • src-3.0.6/src/save.c

    old new  
    12561256                wr_byte((byte)prev_char); 
    12571257        } 
    12581258 
     1259        /** Now dump the cave_info2[][] stuff **/ 
     1260 
     1261        /* Note that this will induce two wasted bytes */ 
     1262        count = 0; 
     1263        prev_char = 0; 
     1264 
     1265        /* Dump the cave */ 
     1266        for (y = 0; y < DUNGEON_HGT; y++) 
     1267        { 
     1268                for (x = 0; x < DUNGEON_WID; x++) 
     1269                { 
     1270                        /* Keep all the information from info2 */ 
     1271                        tmp8u = cave_info2[y][x]; 
     1272 
     1273                        /* If the run is broken, or too full, flush it */ 
     1274                        if ((tmp8u != prev_char) || (count == MAX_UCHAR)) 
     1275                        { 
     1276                                wr_byte((byte)count); 
     1277                                wr_byte((byte)prev_char); 
     1278                                prev_char = tmp8u; 
     1279                                count = 1; 
     1280                        } 
     1281 
     1282                        /* Continue the run */ 
     1283                        else 
     1284                        { 
     1285                                count++; 
     1286                        } 
     1287                } 
     1288        } 
     1289 
     1290        /* Flush the data (if any) */ 
     1291        if (count) 
     1292        { 
     1293                wr_byte((byte)count); 
     1294                wr_byte((byte)prev_char); 
     1295        } 
     1296 
    12591297 
    12601298        /*** Simple "Run-Length-Encoding" of cave ***/ 
    12611299 
  • src-3.0.6/src/spells2.c

    old new  
    999999                                /* Redraw */ 
    10001000                                lite_spot(y, x); 
    10011001 
    1002                                 /* Obvious */ 
     1002                                /* We found something to detect */ 
    10031003                                detect = TRUE; 
    10041004                        } 
     1005 
     1006                        /* Mark as trap-detected */ 
     1007                        cave_info2[y][x] |= (CAVE2_DTRAP); 
    10051008                } 
    10061009        } 
    10071010 
    10081011        /* Describe */ 
    10091012        if (detect) 
    1010         { 
    10111013                msg_print("You sense the presence of traps!"); 
    1012         } 
     1014 
     1015        /* Mark the redraw flag */ 
     1016        p_ptr->redraw |= (PR_DTRAP); 
    10131017 
    10141018        /* Result */ 
    1015         return (detect); 
     1019        return (TRUE); 
    10161020} 
    10171021 
    10181022 
  • src-3.0.6/src/tables.c

    old new  
    14181418        "run_use_corners",                      /* OPT_run_use_corners */ 
    14191419        "disturb_move",                         /* OPT_disturb_move */ 
    14201420        "disturb_near",                         /* OPT_disturb_near */ 
    1421         "disturb_panel",                       /* OPT_disturb_panel */ 
     1421        "disturb_detect",                      /* OPT_disturb_detect */ 
    14221422        "disturb_state",                        /* OPT_disturb_state */ 
    14231423        "disturb_minor",                        /* OPT_disturb_minor */ 
    14241424        NULL,                                           /* xxx disturb_other */ 
     
    16821682        "When running, use corners",                            /* OPT_run_use_corners */ 
    16831683        "Disturb whenever any monster moves",           /* OPT_disturb_move */ 
    16841684        "Disturb whenever viewable monster moves",      /* OPT_disturb_near */ 
    1685         "Disturb whenever map panel changes",          /* OPT_disturb_panel */ 
     1685        "Disturb whenever leaving trap detected area", /* OPT_disturb_detect */ 
    16861686        "Disturb whenever player state changes",        /* OPT_disturb_state */ 
    16871687        "Disturb whenever boring things happen",        /* OPT_disturb_minor */ 
    16881688        NULL,                                                                           /* xxx disturb_other */ 
     
    19461946        TRUE,           /* OPT_run_use_corners */ 
    19471947        TRUE,           /* OPT_disturb_move */ 
    19481948        TRUE,           /* OPT_disturb_near */ 
    1949         TRUE,           /* OPT_disturb_panel */ 
     1949        TRUE,           /* OPT_disturb_detect */ 
    19501950        TRUE,           /* OPT_disturb_state */ 
    19511951        TRUE,           /* OPT_disturb_minor */ 
    19521952        FALSE,          /* xxx disturb_other */ 
     
    22222222                OPT_run_use_corners, 
    22232223                OPT_disturb_move, 
    22242224                OPT_disturb_near, 
    2225                 OPT_disturb_panel
     2225                OPT_disturb_detect
    22262226                OPT_disturb_state, 
    22272227                OPT_disturb_minor, 
    22282228                OPT_verify_destroy, 
  • src-3.0.6/src/variable.c

    old new  
    396396/* 
    397397 * Array[DUNGEON_HGT][256] of cave grid info flags (padded) 
    398398 * 
    399  * This array is padded to a width of 256 to allow fast access to elements 
     399 * These arrays are padded to a width of 256 to allow fast access to elements 
    400400 * in the array via "grid" values (see the GRID() macros). 
    401401 */ 
    402402byte (*cave_info)[256]; 
     403byte (*cave_info2)[256]; 
    403404 
    404405/* 
    405406 * Array[DUNGEON_HGT][DUNGEON_WID] of cave grid feature codes 
  • src-3.0.6/src/xtra1.c

    old new  
    625625 
    626626 
    627627/* 
     628 * Prints trap detection status 
     629 * 
     630 * One could use another p_ptr flag to divorce this function from 
     631 * cave_info[][], with codes to update it properly in some places. 
     632 * I can't decide which is better. -- pelpel 
     633 */ 
     634static void prt_dtrap(int row, int col) 
     635{ 
     636        byte info = cave_info2[p_ptr->py][p_ptr->px]; 
     637 
     638        /* The player is in a trap-detected grid */ 
     639        if (info & (CAVE2_DTRAP)) 
     640        { 
     641                c_put_str(TERM_GREEN, "DTrap", row, col); 
     642        } 
     643 
     644        /* Not in a trap-detected grid */ 
     645        else 
     646        { 
     647                put_str("     ", row, col); 
     648        } 
     649} 
     650 
     651 
     652/* 
    628653 * Prints the speed of a character.                     -CJS- 
    629654 */ 
    630655static void prt_speed(int row, int col) 
     
    652677        } 
    653678 
    654679        /* Display the speed */ 
    655         c_put_str(attr, format("%-14s", buf), row, col); 
     680        c_put_str(attr, format("%-10s", buf), row, col); 
    656681} 
    657682 
    658683 
     
    11541179        /* State */ 
    11551180        prt_state(row, COL_STATE); 
    11561181 
     1182        /* Trap detection */ 
     1183        prt_dtrap(row, COL_DTRAP); 
     1184 
    11571185        /* Speed */ 
    11581186        prt_speed(row, COL_SPEED); 
    11591187 
     
    30913119                prt_state(ROW_STATE, COL_STATE); 
    30923120        } 
    30933121 
     3122        if (p_ptr->redraw & (PR_DTRAP)) 
     3123        { 
     3124                p_ptr->redraw &= ~(PR_DTRAP); 
     3125                prt_dtrap(ROW_DTRAP, COL_DTRAP); 
     3126        } 
     3127 
    30943128        if (p_ptr->redraw & (PR_SPEED)) 
    30953129        { 
    30963130                p_ptr->redraw &= ~(PR_SPEED);