Changeset 636

Show
Ignore:
Timestamp:
12/23/07 18:14:14 (10 months ago)
Author:
takkaria
Message:

Commit the history/notes patch by J.D. White. (closes #10)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/Makefile.src

    r631 r636  
    6969        game-event.o \ 
    7070        generate.o \ 
     71        history.o \ 
    7172        init1.o \ 
    7273        init2.o \ 
  • trunk/src/birth.c

    r617 r636  
    19381938        } 
    19391939 
     1940 
     1941        /* Clear old messages, add new starting message */ 
     1942        history_clear(); 
     1943        history_add("Began the quest to destroy Morgoth.", HISTORY_PLAYER_BIRTH, 0); 
     1944 
    19401945        /* Note player birth in the message recall */ 
    19411946        message_add(" ", MSG_GENERIC); 
  • trunk/src/cmd1.c

    r633 r636  
    285285        } 
    286286 
     287        /* Log if picking up an artifact. */ 
     288        if (artifact_p(o_ptr)) 
     289                history_add_artifact(o_ptr->name1, object_known_p(o_ptr)); 
     290 
    287291        /* Delete the object */ 
    288292        delete_object_idx(o_idx); 
  • trunk/src/cmd4.c

    r606 r636  
    2020#include "option.h" 
    2121#include "ui.h" 
     22#include "externs.h" 
    2223#include "ui-menu.h" 
    2324 
     
    40634064} 
    40644065 
     4066static void do_cmd_knowledge_history(void *obj, const char *name) 
     4067{ 
     4068        history_display();       
     4069} 
     4070 
     4071 
    40654072/* 
    40664073 * Definition of the "player knowledge" menu. 
     
    40754082        {{0, "Display self-knowledge", do_cmd_self_knowledge, 0}, 'f'}, 
    40764083        {{0, "Display hall of fame", do_cmd_knowledge_scores, 0}, 'g'}, 
     4084        {{0, "Display character history", do_cmd_knowledge_history, 0}, 'h'}, 
    40774085}; 
    40784086 
     
    42544262        /* Add the note to the message recall */ 
    42554263        msg_format("Note: %s", tmp); 
     4264 
     4265        /* Add a history entry */ 
     4266        history_add(tmp, HISTORY_USER_INPUT, 0); 
    42564267} 
    42574268 
  • trunk/src/death.c

    r632 r636  
    374374 
    375375/* 
     376 * Menu command: view character history. 
     377 */ 
     378static void death_history(void *unused, const char *title) 
     379{ 
     380        (void)unused; 
     381        (void)title; 
     382 
     383        history_display(); 
     384} 
     385 
     386 
     387/* 
    376388 * Menu structures for the death menu. 
    377389 */ 
     
    384396        { 'v', "View scores",   death_scores,   NULL }, 
    385397        { 'x', "Examine items", death_examine,  NULL }, 
     398        { 'h', "History",       death_history,  NULL }, 
    386399        { 'q', "Quit",          death_examine,  NULL }, 
    387400}; 
     
    422435        menu_type *menu; 
    423436        const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' }; 
    424         const region area = { 51, 2, 0, 6 }; 
     437        const region area = { 51, 2, 0, 7 }; 
    425438 
    426439        int cursor = 0; 
     
    473486                c = menu_select(&death_menu, &cursor, 0); 
    474487 
    475                 if (c.key == ESCAPE || cursor == 5
     488                if (c.key == ESCAPE || cursor == 6
    476489                { 
    477490                        if (get_check("Do you want to quit? ")) 
  • trunk/src/defines.h

    r550 r636  
    212212 */ 
    213213#define AUTOINSCRIPTIONS_MAX 216 
     214 
     215/* History message types */ 
     216#define HISTORY_PLAYER_BIRTH     0x0001 /* Player was born */ 
     217#define HISTORY_ARTIFACT_UNKNOWN 0x0002 /* Player found but not IDd an artifact */ 
     218#define HISTORY_ARTIFACT_KNOWN   0x0004 /* Player has IDed an artifact */ 
     219#define HISTORY_ARTIFACT_LOST    0x0008 /* Player had an artifact and lost it */ 
     220#define HISTORY_PLAYER_DEATH     0x0010 /* Player has been slain */ 
     221#define HISTORY_SLAY_UNIQUE      0x0020 /* Player has slain a unique monster */ 
     222#define HISTORY_USER_INPUT       0x0040 /* User-added note */ 
     223#define HISTORY_SAVEFILE_IMPORT  0x0080 /* Added when an older version savefile is imported */ 
     224#define HISTORY_GAIN_LEVEL       0x0100 /* Player gained a level */ 
     225#define HISTORY_GENERIC          0x0200 /* Anything else not covered here (unused) */ 
    214226 
    215227 
  • trunk/src/externs.h

    r631 r636  
    246246extern u16b inscriptions_count; 
    247247 
     248/* history.c */ 
     249extern history_info *history_list; 
     250 
    248251/* squelch.c */ 
    249252extern byte squelch_level[SQUELCH_BYTES]; 
     
    341344/* generate.c */ 
    342345extern void generate_cave(void); 
     346 
     347/* history.c */ 
     348void history_clear(void); 
     349size_t history_get_num(void); 
     350bool history_add_full(u16b type, byte a_idx, s16b dlev, s16b clev, s32b turn, const char *text); 
     351bool history_add(const char *event, u16b type, byte a_idx); 
     352bool history_add_artifact(byte a_idx, bool known); 
     353void history_unmask_unknown(void); 
     354bool history_lose_artifact(byte a_idx); 
     355void history_display(void); 
    343356 
    344357/* init2.c */ 
  • trunk/src/load.c

    r581 r636  
    20502050        u32b o_x_check, o_v_check; 
    20512051 
     2052        char buf[80]; 
    20522053 
    20532054        /* Mention the savefile version */ 
     
    22582259        } 
    22592260 
     2261        /* Read in the history list if the savefile is new enough */ 
     2262        if (!older_than(3, 0, 11)) 
     2263        { 
     2264                size_t i; 
     2265 
     2266                history_clear(); 
     2267 
     2268                rd_u32b(&tmp32u); 
     2269                for (i = 0; i < tmp32u; i++) 
     2270                { 
     2271                        s32b turn; 
     2272                        s16b dlev, clev; 
     2273                        u16b type; 
     2274                        byte art_name; 
     2275                        char text[80]; 
     2276 
     2277                        rd_u16b(&type); 
     2278                        rd_s32b(&turn); 
     2279                        rd_s16b(&dlev); 
     2280                        rd_s16b(&clev); 
     2281                        rd_byte(&art_name); 
     2282                        rd_string(text, sizeof(text)); 
     2283 
     2284                        history_add_full(type, art_name, dlev, clev, turn, text); 
     2285                } 
     2286        } 
     2287 
     2288        /* 
     2289         * Savefile is from an older version: 
     2290         * Still have to initialize the variables correctly. 
     2291         * Then the game should correctly log future history entries. 
     2292         */ 
     2293        else 
     2294        { 
     2295                history_clear(); 
     2296                strnfmt(buf, sizeof(buf), "Imported an Angband %d.%d.%d savefile", 
     2297                        sf_major, sf_minor, sf_patch); 
     2298                history_add(buf, HISTORY_SAVEFILE_IMPORT, 0); 
     2299        } 
    22602300 
    22612301        /* Save the checksum */ 
  • trunk/src/object2.c

    r617 r636  
    464464                                a_info[o_ptr->name1].cur_num = 0; 
    465465                } 
     466 
     467                /* Mark artifacts as lost in logs */ 
     468                if (artifact_p(o_ptr)) 
     469                        history_lose_artifact(o_ptr->name1); 
    466470 
    467471                /* Monster */ 
  • trunk/src/save.c

    r531 r636  
    814814 
    815815        u16b tmp16u; 
    816  
     816        u32b tmp32u; 
    817817 
    818818        /* Guess at the current time */ 
     
    996996        } 
    997997 
     998        /* NEW (jdw): dumping history entries */ 
     999        /* Dump the number of history entries */ 
     1000        tmp32u = history_get_num(); 
     1001        wr_u32b(tmp32u); 
     1002 
     1003        /* Dump the history entries one-by-one */ 
     1004        for (i = 0; i < tmp32u; i++) 
     1005        { 
     1006                wr_u16b(history_list[i].type); 
     1007                wr_s32b(history_list[i].turn); 
     1008                wr_s16b(history_list[i].dlev); 
     1009                wr_s16b(history_list[i].clev); 
     1010                wr_byte(history_list[i].a_idx); 
     1011                wr_string(history_list[i].event); 
     1012        } 
     1013 
    9981014 
    9991015        /* Write the "value check-sum" */ 
  • trunk/src/spells2.c

    r633 r636  
    36903690        } 
    36913691 
     3692        /* Log artifacts to the history list. */ 
     3693        if (artifact_p(o_ptr)) 
     3694                history_add_artifact(o_ptr->name1, TRUE); 
     3695 
    36923696        /* Describe */ 
    36933697        if (item >= INVEN_WIELD) 
  • trunk/src/store.c

    r633 r636  
    10781078        } 
    10791079 
     1080        /* Is the item an artifact? Mark it as lost if the player has it in history list */ 
     1081        if (artifact_p(o_ptr)) 
     1082                history_lose_artifact(o_ptr->name1); 
     1083 
    10801084        /* Delete the item */ 
    10811085        store_item_increase(st, what, -num); 
     
    22252229                object_known(o_ptr); 
    22262230 
     2231                /* Update the auto-history if selling an artifact that was previously un-IDed. (Ouch!) */ 
     2232                if (artifact_p(o_ptr)) 
     2233                        history_add_artifact(o_ptr->name1, TRUE); 
     2234 
    22272235                /* Combine / Reorder the pack (later) */ 
    22282236                p_ptr->notice |= (PN_COMBINE | PN_REORDER); 
  • trunk/src/types.h

    r589 r636  
    9191typedef struct start_item start_item; 
    9292typedef struct autoinscription autoinscription; 
     93typedef struct history_info history_info; 
    9394 
    9495 
     
    10351036        s16b pspeed;            /* Current speed */ 
    10361037 
    1037     /* Generation fields (for quick start) */ 
     1038       /* Generation fields (for quick start) */ 
    10381039        s32b au_birth;          /* Birth gold */ 
    10391040        s16b stat_birth[A_MAX]; /* Birth "natural" stat values */ 
     
    11151116}; 
    11161117 
     1118 
     1119struct history_info 
     1120{ 
     1121        u16b type;                      /* Kind of history item */ 
     1122        s16b dlev;                      /* Dungeon level when this item was recorded */ 
     1123        s16b clev;                      /* Character level when this item was recorded */ 
     1124        byte a_idx;                     /* Artifact this item relates to */ 
     1125        s32b turn;                      /* Turn this item was recorded on */ 
     1126        char event[80]; /* The text of the item */ 
     1127}; 
    11171128 
    11181129enum grid_light_level 
  • trunk/src/xtra2.c

    r622 r636  
    992992                               p_ptr->expfact / 100L))) 
    993993        { 
     994                char buf[80]; 
     995                 
    994996                /* Gain a level */ 
    995997                p_ptr->lev++; 
    996998 
    997999                /* Save the highest level */ 
    998                 if (p_ptr->lev > p_ptr->max_lev) p_ptr->max_lev = p_ptr->lev; 
    999  
     1000                if (p_ptr->lev > p_ptr->max_lev)  
     1001                { 
     1002                        p_ptr->max_lev = p_ptr->lev; 
     1003 
     1004                        /* Log level updates (TODO: perhaps only every other level or every 5) */ 
     1005                        strnfmt(buf, sizeof(buf), "Reached level %d", p_ptr->lev); 
     1006                        history_add(buf, HISTORY_GAIN_LEVEL, 0); 
     1007                         
     1008                } 
     1009                         
    10001010                /* Message */ 
    10011011                message_format(MSG_LEVEL, p_ptr->lev, "Welcome to level %d.", p_ptr->lev); 
     
    14091419        { 
    14101420                char m_name[80]; 
     1421                char buf[80]; 
    14111422 
    14121423                /* Assume normal death sound */ 
     
    14741485                } 
    14751486 
     1487                /* When the player kills a Unique, it stays dead */ 
     1488                if (r_ptr->flags1 & (RF1_UNIQUE)) 
     1489                { 
     1490                        char unique_name[80]; 
     1491                        r_ptr->max_num = 0; 
     1492                         
     1493                        /* This gets the correct name if we slay an invisible unique and don't have See Invisible. */ 
     1494                        monster_desc(unique_name, sizeof(unique_name), m_ptr, 0x88); 
     1495 
     1496                        /* Log the slaying of a unique */ 
     1497                        strnfmt(buf, sizeof(buf), "Killed %s", unique_name); 
     1498                        history_add(buf, HISTORY_SLAY_UNIQUE, 0); 
     1499                } 
     1500                         
    14761501                /* Gain experience */ 
    14771502                gain_exp(new_exp);