[rogueclone-cvs] rogue/src hit.c, 1.5, 1.6 init.c, 1.8, 1.9 machdep.c, 1.6, 1.7 monster.c, 1.5, 1.6
Brought to you by:
mlehotay
From: Michael L. <mle...@us...> - 2008-06-16 04:42:19
|
Update of /cvsroot/rogueclone/rogue/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv27902 Modified Files: hit.c init.c machdep.c monster.c object.c play.c rogue.h use.c Log Message: steve_ued's known items patch Index: use.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/use.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** use.c 13 Jun 2008 00:19:06 -0000 1.7 --- use.c 16 Jun 2008 04:42:04 -0000 1.8 *************** *** 95,98 **** --- 95,103 ---- return; } + + #ifdef KNOWN_ITEMS + known_items_add_new_known_item(obj->what_is, obj->which_kind); + #endif + switch(obj->which_kind) { case INCREASE_STRENGTH: *************** *** 211,214 **** --- 216,224 ---- return; } + + #ifdef KNOWN_ITEMS + known_items_add_new_known_item(obj->what_is, obj->which_kind); + #endif + switch(obj->which_kind) { case SCARE_MONSTER: *************** *** 396,400 **** --- 406,415 ---- id_table = get_id_table(obj); id_table[obj->which_kind].id_status = IDENTIFIED; + + #ifdef KNOWN_ITEMS + known_items_add_new_known_item(obj->what_is, obj->which_kind); + #endif } + get_desc(obj, desc); message(desc, 0); Index: init.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/init.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** init.c 14 Jun 2008 02:38:02 -0000 1.8 --- init.c 16 Jun 2008 04:42:04 -0000 1.9 *************** *** 95,98 **** --- 95,103 ---- do_args(argc, argv); + #ifdef KNOWN_ITEMS + known_items_initialize(); + known_monsters_initialize(); + #endif + if (!score_only && !rest_file) { FILE *fp; Index: rogue.h =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/rogue.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** rogue.h 13 Jun 2008 00:19:06 -0000 1.8 --- rogue.h 16 Jun 2008 04:42:04 -0000 1.9 *************** *** 510,513 **** --- 510,516 ---- #define MIN_ROW 1 + #ifdef KNOWN_ITEMS + #define MAX_KNOWN_ITEM_STRING_LENGTH 60 + #endif /* external routine declarations. *************** *** 636,639 **** --- 639,645 ---- /* invent.c */ + #ifdef KNOWN_ITEMS + extern char *press_space; + #endif void inventory(object *pack, const unsigned short mask); void id_com(void); *************** *** 647,651 **** void id_type(void); - /* level.c */ void make_level(void); --- 653,656 ---- *************** *** 680,683 **** --- 685,691 ---- /* message.c */ + #ifdef KNOWN_ITEMS + extern char *more; + #endif void message(char *msg, const boolean intrpt); void remessage(short c); *************** *** 710,714 **** boolean mon_sees(const object *monster, const short row, const short col); void mv_aquatars(void); ! /* move.c */ --- 718,726 ---- boolean mon_sees(const object *monster, const short row, const short col); void mv_aquatars(void); ! #ifdef KNOWN_ITEMS ! void known_monsters_initialize(void); ! void known_monsters_add_killed_monster(const char *monster_name); ! void known_monsters_print_known_monsters(void); ! #endif /* move.c */ *************** *** 744,748 **** void discovery(void); #endif ! /* pack.c */ --- 756,766 ---- void discovery(void); #endif ! #ifdef KNOWN_ITEMS ! void known_items_initialize(void); ! void known_items_add_new_known_item(const unsigned short tmp_known_item_what_type, ! const unsigned short item_type); ! void do_show_items_known(void); ! void known_items_print_known_items(void); ! #endif /* pack.c */ Index: object.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/object.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** object.c 14 Jun 2008 02:48:28 -0000 1.7 --- object.c 16 Jun 2008 04:42:04 -0000 1.8 *************** *** 891,892 **** --- 891,1146 ---- } #endif + + #ifdef KNOWN_ITEMS + /* + * Patch [ 1079744 ] Known Items + * Submitted By: steve_ued + */ + + struct known_items_struct_details + { + unsigned short is_known; /* 0 if not known, if >= 1 then this is the + number of times this item is known (e.g., so you + could use this as the number of times this item + was used */ + + unsigned short known_item_what_is; /* what type of object (wand, scroll, potion, etc) */ + unsigned short known_item_type; /* subtype type of the item */ + char printable_string[MAX_KNOWN_ITEM_STRING_LENGTH + 1]; /* user friendly printable string */ + }; + + typedef struct known_items_struct_details known_items_struct; + + #define MAX_KNOWN_ITEMS 250 + + static known_items_struct known_items_list[MAX_KNOWN_ITEMS]; + static unsigned int number_of_known_items = 0; + + /*-------------------------------------------------------------------------------------------*/ + static void known_items_initialize_single_item( + const unsigned short tmp_known_item_what_is, + const unsigned short tmp_known_item_type, + const char *tmp_item_printable_string) + { + known_items_struct *tmp; + + /* make sure that there is room to add the item to the list */ + if (number_of_known_items == MAX_KNOWN_ITEMS) + { + return; /*do nothing - this should eventually cause some error message */ + } + + /* make sure that printable string length is not too long */ + + + tmp = &known_items_list[number_of_known_items]; + + ++number_of_known_items; + + tmp->is_known = 0; + tmp->known_item_what_is = tmp_known_item_what_is; + tmp->known_item_type = tmp_known_item_type; + + strncpy(tmp->printable_string, tmp_item_printable_string, MAX_KNOWN_ITEM_STRING_LENGTH); + + tmp->printable_string[ MAX_KNOWN_ITEM_STRING_LENGTH ] = 0; /* force the null termination of string*/ + } + + + + /*-------------------------------------------------------------------------------------------*/ + void known_items_initialize(void) + { + known_items_initialize_single_item(SCROL, PROTECT_ARMOR, "Scroll of Protect Armor"); + known_items_initialize_single_item(SCROL, HOLD_MONSTER, "Scroll of Hold Monster"); + known_items_initialize_single_item(SCROL, ENCH_WEAPON, "Scroll of Enchant Weapon"); + known_items_initialize_single_item(SCROL, ENCH_ARMOR, "Scroll of Enchant Armor"); + known_items_initialize_single_item(SCROL, IDENTIFY, "Scroll of Identify"); + known_items_initialize_single_item(SCROL, TELEPORT, "Scroll of Teleport"); + known_items_initialize_single_item(SCROL, SLEEP, "Scroll of Sleep"); + known_items_initialize_single_item(SCROL, SCARE_MONSTER, "Scroll of Scare Monster"); + known_items_initialize_single_item(SCROL, REMOVE_CURSE, "Scroll of Remove Curse"); + known_items_initialize_single_item(SCROL, CREATE_MONSTER, "Scroll of Create Monster"); + known_items_initialize_single_item(SCROL, AGGRAVATE_MONSTER, "Scroll of Aggravate Monster"); + known_items_initialize_single_item(SCROL, MAGIC_MAPPING, "Scroll of Magic Mapping"); + known_items_initialize_single_item(SCROL, CON_MON, "Scroll of Confuse Monster"); + + known_items_initialize_single_item(POTION, INCREASE_STRENGTH, "Potion of Increase Strength"); + known_items_initialize_single_item(POTION, RESTORE_STRENGTH, "Potion of Restore Strength"); + known_items_initialize_single_item(POTION, HEALING, "Potion of Healing"); + known_items_initialize_single_item(POTION, EXTRA_HEALING, "Potion of Extra Healing"); + known_items_initialize_single_item(POTION, POISON, "Potion of Poison"); + known_items_initialize_single_item(POTION, RAISE_LEVEL, "Potion of Raise Level"); + known_items_initialize_single_item(POTION, BLINDNESS, "Potion of Blindness"); + known_items_initialize_single_item(POTION, HALLUCINATION, "Potion of Hallucination"); + known_items_initialize_single_item(POTION, DETECT_MONSTER, "Potion of Detect Monsters"); + known_items_initialize_single_item(POTION, DETECT_OBJECTS, "Potion of Detect Objects"); + known_items_initialize_single_item(POTION, CONFUSION, "Potion of Confusion"); + known_items_initialize_single_item(POTION, LEVITATION, "Potion of Levitation"); + known_items_initialize_single_item(POTION, HASTE_SELF, "Potion of Haste Self"); + known_items_initialize_single_item(POTION, SEE_INVISIBLE, "Potion of See Invisible"); + + known_items_initialize_single_item(WAND, TELE_AWAY, "Wand of Teleport Away"); + known_items_initialize_single_item(WAND, SLOW_MONSTER, "Wand of Slow Monster"); + known_items_initialize_single_item(WAND, INVISIBILITY, "Wand of Invisibility"); + known_items_initialize_single_item(WAND, POLYMORPH, "Wand of Polymorph"); + known_items_initialize_single_item(WAND, HASTE_MONSTER, "Wand of Haste Monster"); + known_items_initialize_single_item(WAND, MAGIC_MISSILE, "Wand of Magic Missile"); + known_items_initialize_single_item(WAND, CANCELLATION, "Wand of Cancellation"); + known_items_initialize_single_item(WAND, DO_NOTHING, "Wand of Do Nothing"); + known_items_initialize_single_item(WAND, DRAIN_LIFE, "Wand of Drain Life"); + known_items_initialize_single_item(WAND, COLD, "Wand of Cold"); + known_items_initialize_single_item(WAND, FIRE, "Wand of Fire"); + + known_items_initialize_single_item(RING, STEALTH, "Ring of Stealth"); + known_items_initialize_single_item(RING, R_TELEPORT, "Ring of Teleport"); + known_items_initialize_single_item(RING, REGENERATION, "Ring of Regeneration"); + known_items_initialize_single_item(RING, SLOW_DIGEST, "Ring of Slow Digestion"); + known_items_initialize_single_item(RING, ADD_STRENGTH, "Ring of Add Strength"); + known_items_initialize_single_item(RING, SUSTAIN_STRENGTH, "Ring of Sustain Strength"); + known_items_initialize_single_item(RING, DEXTERITY, "Ring of Dexterity"); + known_items_initialize_single_item(RING, ADORNMENT, "Ring of Adornment"); + known_items_initialize_single_item(RING, R_SEE_INVISIBLE, "Ring of See Invisible"); + known_items_initialize_single_item(RING, MAINTAIN_ARMOR, "Ring of Maintain Armor"); + known_items_initialize_single_item(RING, SEARCHING, "Ring of Searching"); + } + + + /*----------------------------------------------------------------*/ + void known_items_add_new_known_item(const unsigned short what_is, + const unsigned short item_type) + { + unsigned int ctr; + unsigned short tmp_what_is; + + /*we only want the item type what is field for usable items*/ + + tmp_what_is = what_is & (SCROL | POTION | WEAPON | ARMOR | WAND | RING); + + for (ctr = 0; ctr < number_of_known_items; ctr++) + { + if (known_items_list[ctr].known_item_what_is == tmp_what_is) + if (known_items_list[ctr].known_item_type == item_type) + { + known_items_list[ctr].is_known++; + return; + } + } + /*-------------------------------------------------*/ + /*should never get here*/ + } + + + void do_show_items_known() + { + short current_row_number, row_ctr, col_ctr, something_is_known; + unsigned int ctr; + color_char save[DROWS][DCOLS]; + + something_is_known = 0; + for (ctr = 0; ctr < number_of_known_items; ctr++) + { + if (known_items_list[ctr].is_known) + { + something_is_known = 1; + break; + } + } + + + if (something_is_known == 0) + { + check_message(); + message("You have not found anything yet...", 0); + refresh(); + return; + } + + /*save current screen*/ + for (row_ctr = 0; row_ctr < DROWS; row_ctr++) + { + for (col_ctr = 0; col_ctr < DCOLS; col_ctr++) + { + save[row_ctr][col_ctr] = mvincch(row_ctr, col_ctr); + } + } + + + clear(); /*clear entire screen*/ + + check_message(); + message("List of things known...", 0); + + current_row_number = 0; + + for (ctr = 0; ctr < number_of_known_items; ctr++) + { + if (known_items_list[ctr].is_known) + { + char *p = known_items_list[ctr].printable_string; + + ++current_row_number; + mvaddstr(current_row_number, 5, p); + + if ((current_row_number == DROWS) || (ctr + 1 == number_of_known_items)) + { /*give a more prompt*/ + char *m = more; + if (ctr + 1 == number_of_known_items) + m = press_space; + + mvaddstr(current_row_number, 0, m); + current_row_number = 0; + + refresh(); + wait_for_ack(); + + if (rgetchar() == CANCEL) + break; + + clear(); /*clear entire screen*/ + } + } + } + + /*-------------------------------------------------*/ + if (current_row_number > 0) + { /*new items known on screen - need to give 'press space to contiue' prompt*/ + ++current_row_number; + mvaddstr(current_row_number, 0, press_space); + + refresh(); + wait_for_ack(); + } + + clear(); + for (row_ctr = 0; row_ctr < DROWS; row_ctr++) + { + move(row_ctr, 0); + + for (col_ctr = 0; col_ctr < DCOLS; col_ctr++) + { + addcch(save[row_ctr][col_ctr]); + } + } + + redraw(); /*redraw screen*/ + } + + + + + /*----------------------------------------------------------------*/ + void known_items_print_known_items(void) + { + unsigned int ctr; + + for (ctr = 0; ctr < number_of_known_items; ctr++) + { + if (known_items_list[ctr].is_known) + { + printf(known_items_list[ctr].printable_string); + printf("\n"); + } + } + } + #endif /* KNOWN_ITEMS */ Index: play.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/play.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** play.c 11 Jun 2008 06:16:35 -0000 1.6 --- play.c 16 Jun 2008 04:42:04 -0000 1.7 *************** *** 187,190 **** --- 187,195 ---- id_com(); break; + #ifdef KNOWN_ITEMS + case '\\': + do_show_items_known(); + break; + #endif case '!': do_shell(); Index: monster.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/monster.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** monster.c 13 Jun 2008 00:19:06 -0000 1.5 --- monster.c 16 Jun 2008 04:42:04 -0000 1.6 *************** *** 888,889 **** --- 888,981 ---- } } + + #ifdef KNOWN_ITEMS + /*---------------------------------------------------------------*/ + + struct known_monsters_type_struct + { + unsigned short is_known; /* 0 if not known, if >= 1 then this is the + number of times this item is known (e.g., so you + could use this as the number of times this item + was used */ + + char monster_name[MAX_KNOWN_ITEM_STRING_LENGTH + 1]; /* user friendly printable string */ + }; + + typedef struct known_monsters_type_struct KNOWN_MONSTERS_STRUCT; + + static KNOWN_MONSTERS_STRUCT KNOWN_MONSTERS[MONSTERS]; + + + /*---------------------------------------------------------------*/ + void known_monsters_initialize(void) + { + extern char *m_names[]; + + char *monster_names_list_tmp[MONSTERS]; + int ctr; + + /* create a temporary list of monster names and then sort */ + + for (ctr = 0; ctr < MONSTERS; ctr++) + monster_names_list_tmp[ctr] = m_names[ctr]; + + for (ctr = 0; ctr < MONSTERS -1;ctr++) + { + int ctr2; + for (ctr2 = ctr + 1; ctr2 < MONSTERS;ctr2++) + { + const int c = strcmp(monster_names_list_tmp[ctr], monster_names_list_tmp[ctr2]); + + if (c > 0) + { + char *p = monster_names_list_tmp[ctr]; + + monster_names_list_tmp[ctr] = monster_names_list_tmp[ctr2]; + monster_names_list_tmp[ctr2] = p; + } + } + } + + + /*------------------------------------------------------*/ + for (ctr = 0; ctr < MONSTERS; ctr++) + { + KNOWN_MONSTERS[ctr].is_known = 0; + + strncpy(KNOWN_MONSTERS[ctr].monster_name, monster_names_list_tmp[ctr], MAX_KNOWN_ITEM_STRING_LENGTH); + } + + } + + /*---------------------------------------------------------------*/ + void known_monsters_add_killed_monster(const char *monster_name) + { + int ctr; + + for (ctr = 0;ctr < MONSTERS; ctr++) + { + if (strcmp(monster_name, KNOWN_MONSTERS[ctr].monster_name) == 0) + { + KNOWN_MONSTERS[ctr].is_known++; + } + + } + } + + + /*-------------------------------------------------------*/ + void known_monsters_print_known_monsters(void) + { + int ctr; + + for (ctr = 0;ctr < MONSTERS;ctr++) + { + const unsigned short killed_count = KNOWN_MONSTERS[ctr].is_known; + + if (killed_count > 0) + { + printf("%s, %u killed\n", KNOWN_MONSTERS[ctr].monster_name, killed_count); + } + } + } + #endif /* KNOWN_ITEMS */ Index: machdep.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/machdep.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** machdep.c 13 Jun 2008 00:19:06 -0000 1.6 --- machdep.c 16 Jun 2008 04:42:04 -0000 1.7 *************** *** 439,442 **** --- 439,447 ---- void md_exit(int status) { + #ifdef KNOWN_ITEMS + known_items_print_known_items(); + known_monsters_print_known_monsters(); + #endif + exit(status); } Index: hit.c =================================================================== RCS file: /cvsroot/rogueclone/rogue/src/hit.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hit.c 11 Jun 2008 06:16:35 -0000 1.5 --- hit.c 16 Jun 2008 04:42:04 -0000 1.6 *************** *** 297,300 **** --- 297,305 ---- cough_up(monster); mn = mon_name(monster); + + #ifdef KNOWN_ITEMS + known_monsters_add_killed_monster(mn); /*add killed monster*/ + #endif + sprintf(hit_message+strlen(hit_message), "defeated the %s", mn); message(hit_message, 1); |