The g? structs had a mix of variables that were written to
the savefile, and those that were not.
For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.
This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.
Details:
gb.bases -> svb.bases
gb.bbubbles -> svb.bbubbles
gb.branches -> svb.branches
gc.context -> svc.context
gd.disco -> svd.disco
gd.dndest -> svd.dndest
gd.doors -> svd.doors
gd.doors_alloc -> svd.doors_alloc
gd.dungeon_topology -> svd.dungeon_topology
gd.dungeons -> svd.dungeons
ge.exclusion_zones -> sve.exclusion_zones
gh.hackpid -> svh.hackpid
gi.inv_pos -> svi.inv_pos
gk.killer -> svk.killer
gl.lastseentyp -> svl.lastseentyp
gl.level -> svl.level
gl.level_info -> svl.level_info
gm.mapseenchn -> svm.mapseenchn
gm.moves -> svm.moves
gm.mvitals -> svm.mvitals
gn.n_dgns -> svn.n_dgns
gn.n_regions -> svn.n_regions
gn.nroom -> svn.nroom
go.oracle_cnt -> svo.oracle_cnt
gp.pl_character -> svp.pl_character
gp.pl_fruit -> svp.pl_fruit
gp.plname -> svp.plname
gp.program_state -> svp.program_state
gq.quest_status -> svq.quest_status
gr.rooms -> svr.rooms
gs.sp_levchn -> svs.sp_levchn
gs.spl_book -> svs.spl_book
gt.timer_id -> svt.timer_id
gt.tune -> svt.tune
gu.updest -> svu.updest
gx.xmax -> svx.xmax
gx.xmin -> svx.xmin
gy.ymax -> svy.ymax
gy.ymin -> svy.ymin
Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
gf.ftrap, gl.light_base, gt.timer_base
166 lines
5.6 KiB
C
166 lines
5.6 KiB
C
/* NetHack 3.7 rip.c $NHDT-Date: 1597967808 2020/08/20 23:56:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.33 $ */
|
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/*-Copyright (c) Robert Patrick Rankin, 2017. */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#include "hack.h"
|
|
|
|
/* Defining TEXT_TOMBSTONE causes genl_outrip() to exist, but it doesn't
|
|
necessarily have to be used by a binary with multiple window-ports */
|
|
|
|
#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
|
|
|| defined(DUMPLOG) || defined(CURSES_GRAPHICS) || defined(SHIM_GRAPHICS)
|
|
#define TEXT_TOMBSTONE
|
|
#endif
|
|
#if defined(mac) || defined(__BEOS__)
|
|
#ifndef TEXT_TOMBSTONE
|
|
#define TEXT_TOMBSTONE
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef TEXT_TOMBSTONE
|
|
staticfn void center(int, char *);
|
|
|
|
#ifndef NH320_DEDICATION
|
|
/* A normal tombstone for end of game display. */
|
|
static const char *const rip_txt[] = {
|
|
" ----------",
|
|
" / \\",
|
|
" / REST \\",
|
|
" / IN \\",
|
|
" / PEACE \\",
|
|
" / \\",
|
|
" | |", /* Name of player */
|
|
" | |", /* Amount of $ */
|
|
" | |", /* Type of death */
|
|
" | |", /* . */
|
|
" | |", /* . */
|
|
" | |", /* . */
|
|
" | 1001 |", /* Real year of death */
|
|
" *| * * * | *",
|
|
" _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______", 0
|
|
};
|
|
#define STONE_LINE_CENT 28 /* char[] element of center of stone face */
|
|
#else /* NH320_DEDICATION */
|
|
/* NetHack 3.2.x displayed a dual tombstone as a tribute to Izchak. */
|
|
static const char *const rip_txt[] = {
|
|
" ---------- ----------",
|
|
" / \\ / \\",
|
|
" / REST \\ / This \\",
|
|
" / IN \\ / release of \\",
|
|
" / PEACE \\ / NetHack is \\",
|
|
" / \\ / dedicated to \\",
|
|
" | | | the memory of |",
|
|
" | | | |",
|
|
" | | | Izchak Miller |",
|
|
" | | | 1935 - 1994 |",
|
|
" | | | |",
|
|
" | | | Ascended |",
|
|
" | 1001 | | |",
|
|
" * | * * * | * * | * * * | *",
|
|
" _____)/\\|\\__//(\\/(/\\)/\\//\\/|_)________)/|\\\\_/_/(\\/(/\\)/\\/\\/|_)____",
|
|
0
|
|
};
|
|
#define STONE_LINE_CENT 19 /* char[] element of center of stone face */
|
|
#endif /* NH320_DEDICATION */
|
|
#define STONE_LINE_LEN 16 /* # chars that fit on one line
|
|
* (note 1 ' ' border) */
|
|
#define NAME_LINE 6 /* *char[] line # for player name */
|
|
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
|
|
#define DEATH_LINE 8 /* *char[] line # for death description */
|
|
#define YEAR_LINE 12 /* *char[] line # for year */
|
|
|
|
staticfn void
|
|
center(int line, char *text)
|
|
{
|
|
char *ip, *op;
|
|
ip = text;
|
|
op = &gr.rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)];
|
|
while (*ip)
|
|
*op++ = *ip++;
|
|
}
|
|
|
|
void
|
|
genl_outrip(winid tmpwin, int how, time_t when)
|
|
{
|
|
char **dp;
|
|
char *dpx;
|
|
char buf[BUFSZ];
|
|
int x;
|
|
int line, year;
|
|
long cash;
|
|
|
|
gr.rip = dp = (char **) alloc(sizeof(rip_txt));
|
|
for (x = 0; rip_txt[x]; ++x)
|
|
dp[x] = dupstr(rip_txt[x]);
|
|
dp[x] = (char *) 0;
|
|
|
|
/* Put name on stone */
|
|
Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, svp.plname);
|
|
center(NAME_LINE, buf);
|
|
|
|
/* Put $ on stone */
|
|
cash = max(gd.done_money, 0L);
|
|
/* arbitrary upper limit; practical upper limit is quite a bit less */
|
|
if (cash > 999999999L)
|
|
cash = 999999999L;
|
|
Sprintf(buf, "%ld Au", cash);
|
|
center(GOLD_LINE, buf);
|
|
|
|
/* Put together death description */
|
|
formatkiller(buf, sizeof buf, how, FALSE);
|
|
|
|
/* Put death type on stone */
|
|
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
|
|
char tmpchar;
|
|
int i, i0 = (int) strlen(dpx);
|
|
|
|
if (i0 > STONE_LINE_LEN) {
|
|
for (i = STONE_LINE_LEN; (i > 0) && (i0 > STONE_LINE_LEN); --i)
|
|
if (dpx[i] == ' ')
|
|
i0 = i;
|
|
if (!i)
|
|
i0 = STONE_LINE_LEN;
|
|
}
|
|
tmpchar = dpx[i0];
|
|
dpx[i0] = 0;
|
|
center(line, dpx);
|
|
if (tmpchar != ' ') {
|
|
dpx[i0] = tmpchar;
|
|
dpx = &dpx[i0];
|
|
} else
|
|
dpx = &dpx[i0 + 1];
|
|
}
|
|
|
|
/* Put year on stone */
|
|
year = (int) ((yyyymmdd(when) / 10000L) % 10000L);
|
|
Sprintf(buf, "%4d", year);
|
|
center(YEAR_LINE, buf);
|
|
|
|
#ifdef DUMPLOG
|
|
if (tmpwin == 0)
|
|
dump_forward_putstr(0, 0, "Game over:", TRUE);
|
|
else
|
|
#endif
|
|
putstr(tmpwin, 0, "");
|
|
|
|
for (; *dp; dp++)
|
|
putstr(tmpwin, 0, *dp);
|
|
|
|
putstr(tmpwin, 0, "");
|
|
#ifdef DUMPLOG
|
|
if (tmpwin != 0)
|
|
#endif
|
|
putstr(tmpwin, 0, "");
|
|
|
|
for (x = 0; rip_txt[x]; x++) {
|
|
free((genericptr_t) gr.rip[x]);
|
|
}
|
|
free((genericptr_t) gr.rip);
|
|
gr.rip = 0;
|
|
}
|
|
|
|
#endif /* TEXT_TOMBSTONE */
|
|
|
|
/*rip.c*/
|