static int rd_history(void) { u32b tmp32u; size_t i; history_clear(); rd_u32b(&tmp32u); for (i = 0; i < tmp32u; i++) { s32b turn; s16b dlev, clev; u16b type; byte art_name; char text[80]; rd_u16b(&type); rd_s32b(&turn); rd_s16b(&dlev); rd_s16b(&clev); rd_byte(&art_name); rd_string(text, sizeof(text)); history_add_full(type, art_name, dlev, clev, turn, text); } return 0; }
/** * Add an entry with text `event` to the history list, with type `type` * ("HIST_xxx" in player-history.h), and artifact number `id` (0 for * everything else). * * Return true on success. */ bool history_add(const char *event, int type, struct artifact *artifact) { bitflag h[HIST_SIZE]; hist_wipe(h); hist_on(h, type); return history_add_full(h, artifact, player->depth, player->lev, player->total_energy / 100, event); }
/** * Add an entry to the history ledger with specified bitflags. */ static bool history_add_with_flags(struct player *p, const char *text, bitflag flags[HIST_SIZE], const struct artifact *artifact) { return history_add_full(p, flags, artifact ? artifact->aidx : 0, p->depth, p->lev, p->total_energy / 100, text); }
/** * Adding artifacts to the history list is trickier than other operations. * This is a wrapper function that gets some of the logic out of places * where it really doesn't belong. Call this to add an artifact to the history * list or make the history entry visible--history_add_artifact will make that * determination depending on what object_is_known returns for the artifact. */ bool history_add_artifact(struct artifact *artifact, bool known, bool found) { struct object body = { 0 }, known_body = { 0 }; struct object *fake = &body, *known_obj = &known_body; char o_name[80]; char buf[80]; assert(artifact); /* Make fake artifact for description purposes */ make_fake_artifact(fake, artifact); fake->known = known_obj; known_obj->artifact = (struct artifact *) 1; known_obj->kind = fake->kind; object_desc(o_name, sizeof(o_name), fake, ODESC_PREFIX | ODESC_BASE | ODESC_SPOIL); object_wipe(known_obj); object_wipe(fake); strnfmt(buf, sizeof(buf), (found)?"Found %s":"Missed %s", o_name); /* Known objects gets different treatment */ if (known) { /* Try revealing any existing artifact, otherwise log it */ if (history_is_artifact_logged(artifact)) history_know_artifact(artifact); else history_add(buf, HIST_ARTIFACT_KNOWN, artifact); } else { if (!history_is_artifact_logged(artifact)) { bitflag type[HIST_SIZE]; hist_wipe(type); hist_on(type, HIST_ARTIFACT_UNKNOWN); if (!found) hist_on(type, HIST_ARTIFACT_LOST); history_add_full(type, artifact, player->depth, player->lev, player->total_energy / 100, buf); } else { return false; } } return true; }
/* * Add an entry with text `event` to the history list, with type `type` * ("HISTORY_xxx" in defines.h), and artifact number `id` (0 for everything * else). * * Returne TRUE on success. */ bool history_add(const char *event, u16b type, byte a_idx) { return history_add_full(type, a_idx, p_ptr->depth, p_ptr->lev, turn, event); }