restore.c globals moved to instance_globals.
This commit is contained in:
@@ -454,12 +454,23 @@ struct instance_globals {
|
|||||||
messages in artifact_hit() */
|
messages in artifact_hit() */
|
||||||
/* botl.c */
|
/* botl.c */
|
||||||
int mrank_sz; /* loaded by max_rank_sz */
|
int mrank_sz; /* loaded by max_rank_sz */
|
||||||
|
|
||||||
/* dog.c */
|
/* dog.c */
|
||||||
int petname_used; /* user preferred pet name has been used */
|
int petname_used; /* user preferred pet name has been used */
|
||||||
|
|
||||||
/* muse.c */
|
/* muse.c */
|
||||||
boolean m_using; /* kludge to use mondided instead of killed */
|
boolean m_using; /* kludge to use mondided instead of killed */
|
||||||
|
|
||||||
/* pickup.c */
|
/* pickup.c */
|
||||||
int oldcap; /* last encumberance */
|
int oldcap; /* last encumberance */
|
||||||
|
|
||||||
|
/* restore.c */
|
||||||
|
int n_ids_mapped;
|
||||||
|
struct bucket *id_map;
|
||||||
|
boolean restoring;
|
||||||
|
struct fruit *oldfruit;
|
||||||
|
long omoves;
|
||||||
|
|
||||||
/* rumors.c */
|
/* rumors.c */
|
||||||
long true_rumor_size; /* rumor size variables are signed so that value -1
|
long true_rumor_size; /* rumor size variables are signed so that value -1
|
||||||
can be used as a flag */
|
can be used as a flag */
|
||||||
@@ -473,6 +484,7 @@ struct instance_globals {
|
|||||||
int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */
|
int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */
|
||||||
unsigned oracle_cnt; /* oracles are handled differently from rumors... */
|
unsigned oracle_cnt; /* oracles are handled differently from rumors... */
|
||||||
unsigned long *oracle_loc;
|
unsigned long *oracle_loc;
|
||||||
|
|
||||||
/* save.c */
|
/* save.c */
|
||||||
boolean havestate;
|
boolean havestate;
|
||||||
unsigned ustuck_id; /* need to preserve during save */
|
unsigned ustuck_id; /* need to preserve during save */
|
||||||
|
|||||||
+1
-1
@@ -536,7 +536,7 @@ long wp_mask;
|
|||||||
* that can print a message--need to guard against being printed
|
* that can print a message--need to guard against being printed
|
||||||
* when restoring a game
|
* when restoring a game
|
||||||
*/
|
*/
|
||||||
(void) make_hallucinated((long) !on, restoring ? FALSE : TRUE,
|
(void) make_hallucinated((long) !on, g.restoring ? FALSE : TRUE,
|
||||||
wp_mask);
|
wp_mask);
|
||||||
}
|
}
|
||||||
if (spfx & SPFX_ESP) {
|
if (spfx & SPFX_ESP) {
|
||||||
|
|||||||
+19
@@ -332,16 +332,29 @@ const struct instance_globals g_init = {
|
|||||||
0, /* jumping_is_magic */
|
0, /* jumping_is_magic */
|
||||||
-1, /* polearm_range_min */
|
-1, /* polearm_range_min */
|
||||||
-1, /* polearm_range_max */
|
-1, /* polearm_range_max */
|
||||||
|
|
||||||
/* artifact.c */
|
/* artifact.c */
|
||||||
0, /* spec_dbon_applies */
|
0, /* spec_dbon_applies */
|
||||||
|
|
||||||
/* botl.c */
|
/* botl.c */
|
||||||
0, /* mrank_sz */
|
0, /* mrank_sz */
|
||||||
|
|
||||||
/* dog.c */
|
/* dog.c */
|
||||||
0, /* petname_used */
|
0, /* petname_used */
|
||||||
|
|
||||||
/* mused.c */
|
/* mused.c */
|
||||||
FALSE, /* m_using */
|
FALSE, /* m_using */
|
||||||
|
|
||||||
/* pickup.c */
|
/* pickup.c */
|
||||||
0, /* oldcap */
|
0, /* oldcap */
|
||||||
|
|
||||||
|
/* restore.c */
|
||||||
|
0, /* n_ids_mapped */
|
||||||
|
0, /* id_map */
|
||||||
|
FALSE, /* restoring */
|
||||||
|
UNDEFINED_PTR, /* oldfruit */
|
||||||
|
UNDEFINED_VALUE, /* omoves */
|
||||||
|
|
||||||
/* rumors.c */
|
/* rumors.c */
|
||||||
0, /* true_rumor_size */
|
0, /* true_rumor_size */
|
||||||
0, /* false_rumor_size */
|
0, /* false_rumor_size */
|
||||||
@@ -352,21 +365,27 @@ const struct instance_globals g_init = {
|
|||||||
0, /* oracle_flag */
|
0, /* oracle_flag */
|
||||||
0, /* oracle_cnt */
|
0, /* oracle_cnt */
|
||||||
NULL, /* oracle_loc */
|
NULL, /* oracle_loc */
|
||||||
|
|
||||||
/* save.c */
|
/* save.c */
|
||||||
TRUE, /* havestate*/
|
TRUE, /* havestate*/
|
||||||
0, /* ustuck_id */
|
0, /* ustuck_id */
|
||||||
0, /* usteed_id */
|
0, /* usteed_id */
|
||||||
|
|
||||||
/* trap.c */
|
/* trap.c */
|
||||||
0, /* force_mintrap */
|
0, /* force_mintrap */
|
||||||
|
|
||||||
/* u_init.c */
|
/* u_init.c */
|
||||||
STRANGE_OBJECT, /* nocreate */
|
STRANGE_OBJECT, /* nocreate */
|
||||||
STRANGE_OBJECT, /* nocreate2 */
|
STRANGE_OBJECT, /* nocreate2 */
|
||||||
STRANGE_OBJECT, /* nocreate3 */
|
STRANGE_OBJECT, /* nocreate3 */
|
||||||
STRANGE_OBJECT, /* nocreate4 */
|
STRANGE_OBJECT, /* nocreate4 */
|
||||||
|
|
||||||
/* uhitm.c */
|
/* uhitm.c */
|
||||||
UNDEFINED_VALUE, /* override_confirmation */
|
UNDEFINED_VALUE, /* override_confirmation */
|
||||||
|
|
||||||
/* weapon.c */
|
/* weapon.c */
|
||||||
UNDEFINED_PTR, /* propellor */
|
UNDEFINED_PTR, /* propellor */
|
||||||
|
|
||||||
/* zap.c */
|
/* zap.c */
|
||||||
UNDEFINED_VALUE, /* poly_zap */
|
UNDEFINED_VALUE, /* poly_zap */
|
||||||
UNDEFINED_VALUE, /* obj_zapped */
|
UNDEFINED_VALUE, /* obj_zapped */
|
||||||
|
|||||||
+1
-1
@@ -1200,7 +1200,7 @@ unsigned doname_flags;
|
|||||||
}
|
}
|
||||||
/* treat 'restoring' like suppress_price because shopkeeper and
|
/* treat 'restoring' like suppress_price because shopkeeper and
|
||||||
bill might not be available yet while restore is in progress */
|
bill might not be available yet while restore is in progress */
|
||||||
if (!iflags.suppress_price && !restoring && is_unpaid(obj)) {
|
if (!iflags.suppress_price && !g.restoring && is_unpaid(obj)) {
|
||||||
long quotedprice = unpaid_cost(obj, TRUE);
|
long quotedprice = unpaid_cost(obj, TRUE);
|
||||||
|
|
||||||
Sprintf(eos(bp), " (%s, %ld %s)",
|
Sprintf(eos(bp), " (%s, %ld %s)",
|
||||||
|
|||||||
+29
-36
@@ -58,7 +58,7 @@ static struct restore_procs {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Save a mapping of IDs from ghost levels to the current level. This
|
* Save a mapping of IDs from ghost levels to the current level. This
|
||||||
* map is used by the timer routines when restoring ghost levels.
|
* map is used by the timer routines when g.restoring ghost levels.
|
||||||
*/
|
*/
|
||||||
#define N_PER_BUCKET 64
|
#define N_PER_BUCKET 64
|
||||||
struct bucket {
|
struct bucket {
|
||||||
@@ -72,9 +72,6 @@ struct bucket {
|
|||||||
STATIC_DCL void NDECL(clear_id_mapping);
|
STATIC_DCL void NDECL(clear_id_mapping);
|
||||||
STATIC_DCL void FDECL(add_id_mapping, (unsigned, unsigned));
|
STATIC_DCL void FDECL(add_id_mapping, (unsigned, unsigned));
|
||||||
|
|
||||||
static int n_ids_mapped = 0;
|
|
||||||
static struct bucket *id_map = 0;
|
|
||||||
|
|
||||||
#ifdef AMII_GRAPHICS
|
#ifdef AMII_GRAPHICS
|
||||||
void FDECL(amii_setpens, (int)); /* use colors from save file */
|
void FDECL(amii_setpens, (int)); /* use colors from save file */
|
||||||
extern int amii_numcolors;
|
extern int amii_numcolors;
|
||||||
@@ -82,10 +79,6 @@ extern int amii_numcolors;
|
|||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
boolean restoring = FALSE;
|
|
||||||
static NEARDATA struct fruit *oldfruit;
|
|
||||||
static NEARDATA long omoves;
|
|
||||||
|
|
||||||
#define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE)
|
#define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE)
|
||||||
|
|
||||||
/* Recalculate level.objects[x][y], since this info was not saved. */
|
/* Recalculate level.objects[x][y], since this info was not saved. */
|
||||||
@@ -179,11 +172,11 @@ boolean ghostly;
|
|||||||
|
|
||||||
mread(fd, (genericptr_t) tmp_dam, sizeof(*tmp_dam));
|
mread(fd, (genericptr_t) tmp_dam, sizeof(*tmp_dam));
|
||||||
if (ghostly)
|
if (ghostly)
|
||||||
tmp_dam->when += (monstermoves - omoves);
|
tmp_dam->when += (monstermoves - g.omoves);
|
||||||
Strcpy(damaged_shops,
|
Strcpy(damaged_shops,
|
||||||
in_rooms(tmp_dam->place.x, tmp_dam->place.y, SHOPBASE));
|
in_rooms(tmp_dam->place.x, tmp_dam->place.y, SHOPBASE));
|
||||||
if (u.uz.dlevel) {
|
if (u.uz.dlevel) {
|
||||||
/* when restoring, there are two passes over the current
|
/* when g.restoring, there are two passes over the current
|
||||||
* level. the first time, u.uz isn't set, so neither is
|
* level. the first time, u.uz isn't set, so neither is
|
||||||
* shop_keeper(). just wait and process the damage on
|
* shop_keeper(). just wait and process the damage on
|
||||||
* the second pass.
|
* the second pass.
|
||||||
@@ -216,7 +209,7 @@ struct obj *otmp;
|
|||||||
mread(fd, (genericptr_t) otmp, sizeof(struct obj));
|
mread(fd, (genericptr_t) otmp, sizeof(struct obj));
|
||||||
|
|
||||||
/* next object pointers are invalid; otmp->cobj needs to be left
|
/* next object pointers are invalid; otmp->cobj needs to be left
|
||||||
as is--being non-null is key to restoring container contents */
|
as is--being non-null is key to g.restoring container contents */
|
||||||
otmp->nobj = otmp->nexthere = (struct obj *) 0;
|
otmp->nobj = otmp->nexthere = (struct obj *) 0;
|
||||||
/* non-null oextra needs to be reconstructed */
|
/* non-null oextra needs to be reconstructed */
|
||||||
if (otmp->oextra) {
|
if (otmp->oextra) {
|
||||||
@@ -293,7 +286,7 @@ boolean ghostly, frozen;
|
|||||||
* immediately after old player died.
|
* immediately after old player died.
|
||||||
*/
|
*/
|
||||||
if (ghostly && !frozen && !age_is_relative(otmp))
|
if (ghostly && !frozen && !age_is_relative(otmp))
|
||||||
otmp->age = monstermoves - omoves + otmp->age;
|
otmp->age = monstermoves - g.omoves + otmp->age;
|
||||||
|
|
||||||
/* get contents of a container or statue */
|
/* get contents of a container or statue */
|
||||||
if (Has_contents(otmp)) {
|
if (Has_contents(otmp)) {
|
||||||
@@ -513,7 +506,7 @@ register struct obj *otmp;
|
|||||||
{
|
{
|
||||||
register struct fruit *oldf;
|
register struct fruit *oldf;
|
||||||
|
|
||||||
for (oldf = oldfruit; oldf; oldf = oldf->nextf)
|
for (oldf = g.oldfruit; oldf; oldf = oldf->nextf)
|
||||||
if (oldf->fid == otmp->spe)
|
if (oldf->fid == otmp->spe)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -797,7 +790,7 @@ register int fd;
|
|||||||
int rtmp;
|
int rtmp;
|
||||||
struct obj *otmp;
|
struct obj *otmp;
|
||||||
|
|
||||||
restoring = TRUE;
|
g.restoring = TRUE;
|
||||||
get_plname_from_file(fd, plname);
|
get_plname_from_file(fd, plname);
|
||||||
getlev(fd, 0, (xchar) 0, FALSE);
|
getlev(fd, 0, (xchar) 0, FALSE);
|
||||||
if (!restgamestate(fd, &stuckid, &steedid)) {
|
if (!restgamestate(fd, &stuckid, &steedid)) {
|
||||||
@@ -805,7 +798,7 @@ register int fd;
|
|||||||
savelev(-1, 0, FREE_SAVE); /* discard current level */
|
savelev(-1, 0, FREE_SAVE); /* discard current level */
|
||||||
(void) nhclose(fd);
|
(void) nhclose(fd);
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
restoring = FALSE;
|
g.restoring = FALSE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
restlevelstate(stuckid, steedid);
|
restlevelstate(stuckid, steedid);
|
||||||
@@ -921,7 +914,7 @@ register int fd;
|
|||||||
|
|
||||||
run_timers(); /* expire all timers that have gone off while away */
|
run_timers(); /* expire all timers that have gone off while away */
|
||||||
docrt();
|
docrt();
|
||||||
restoring = FALSE;
|
g.restoring = FALSE;
|
||||||
clear_nhwindow(WIN_MESSAGE);
|
clear_nhwindow(WIN_MESSAGE);
|
||||||
|
|
||||||
/* Success! */
|
/* Success! */
|
||||||
@@ -1025,10 +1018,10 @@ boolean ghostly;
|
|||||||
setmode(fd, O_BINARY);
|
setmode(fd, O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
/* Load the old fruit info. We have to do it first, so the
|
/* Load the old fruit info. We have to do it first, so the
|
||||||
* information is available when restoring the objects.
|
* information is available when g.restoring the objects.
|
||||||
*/
|
*/
|
||||||
if (ghostly)
|
if (ghostly)
|
||||||
oldfruit = loadfruitchn(fd);
|
g.oldfruit = loadfruitchn(fd);
|
||||||
|
|
||||||
/* First some sanity checks */
|
/* First some sanity checks */
|
||||||
mread(fd, (genericptr_t) &hpid, sizeof(hpid));
|
mread(fd, (genericptr_t) &hpid, sizeof(hpid));
|
||||||
@@ -1055,8 +1048,8 @@ boolean ghostly;
|
|||||||
rest_levl(fd,
|
rest_levl(fd,
|
||||||
(boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP));
|
(boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP));
|
||||||
mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp));
|
mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp));
|
||||||
mread(fd, (genericptr_t) &omoves, sizeof(omoves));
|
mread(fd, (genericptr_t) &g.omoves, sizeof(g.omoves));
|
||||||
elapsed = monstermoves - omoves;
|
elapsed = monstermoves - g.omoves;
|
||||||
mread(fd, (genericptr_t) &upstair, sizeof(stairway));
|
mread(fd, (genericptr_t) &upstair, sizeof(stairway));
|
||||||
mread(fd, (genericptr_t) &dnstair, sizeof(stairway));
|
mread(fd, (genericptr_t) &dnstair, sizeof(stairway));
|
||||||
mread(fd, (genericptr_t) &upladder, sizeof(stairway));
|
mread(fd, (genericptr_t) &upladder, sizeof(stairway));
|
||||||
@@ -1132,7 +1125,7 @@ boolean ghostly;
|
|||||||
rest_regions(fd, ghostly);
|
rest_regions(fd, ghostly);
|
||||||
if (ghostly) {
|
if (ghostly) {
|
||||||
/* Now get rid of all the temp fruits... */
|
/* Now get rid of all the temp fruits... */
|
||||||
freefruitchn(oldfruit), oldfruit = 0;
|
freefruitchn(g.oldfruit), g.oldfruit = 0;
|
||||||
|
|
||||||
if (lev > ledger_no(&medusa_level)
|
if (lev > ledger_no(&medusa_level)
|
||||||
&& lev < ledger_no(&stronghold_level) && xdnstair == 0) {
|
&& lev < ledger_no(&stronghold_level) && xdnstair == 0) {
|
||||||
@@ -1229,11 +1222,11 @@ clear_id_mapping()
|
|||||||
{
|
{
|
||||||
struct bucket *curr;
|
struct bucket *curr;
|
||||||
|
|
||||||
while ((curr = id_map) != 0) {
|
while ((curr = g.id_map) != 0) {
|
||||||
id_map = curr->next;
|
g.id_map = curr->next;
|
||||||
free((genericptr_t) curr);
|
free((genericptr_t) curr);
|
||||||
}
|
}
|
||||||
n_ids_mapped = 0;
|
g.n_ids_mapped = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a mapping to the ID map. */
|
/* Add a mapping to the ID map. */
|
||||||
@@ -1243,18 +1236,18 @@ unsigned gid, nid;
|
|||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
idx = n_ids_mapped % N_PER_BUCKET;
|
idx = g.n_ids_mapped % N_PER_BUCKET;
|
||||||
/* idx is zero on first time through, as well as when a new bucket is */
|
/* idx is zero on first time through, as well as when a new bucket is */
|
||||||
/* needed */
|
/* needed */
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket));
|
struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket));
|
||||||
gnu->next = id_map;
|
gnu->next = g.id_map;
|
||||||
id_map = gnu;
|
g.id_map = gnu;
|
||||||
}
|
}
|
||||||
|
|
||||||
id_map->map[idx].gid = gid;
|
g.id_map->map[idx].gid = gid;
|
||||||
id_map->map[idx].nid = nid;
|
g.id_map->map[idx].nid = nid;
|
||||||
n_ids_mapped++;
|
g.n_ids_mapped++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1269,11 +1262,11 @@ unsigned gid, *nidp;
|
|||||||
int i;
|
int i;
|
||||||
struct bucket *curr;
|
struct bucket *curr;
|
||||||
|
|
||||||
if (n_ids_mapped)
|
if (g.n_ids_mapped)
|
||||||
for (curr = id_map; curr; curr = curr->next) {
|
for (curr = g.id_map; curr; curr = curr->next) {
|
||||||
/* first bucket might not be totally full */
|
/* first bucket might not be totally full */
|
||||||
if (curr == id_map) {
|
if (curr == g.id_map) {
|
||||||
i = n_ids_mapped % N_PER_BUCKET;
|
i = g.n_ids_mapped % N_PER_BUCKET;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
i = N_PER_BUCKET;
|
i = N_PER_BUCKET;
|
||||||
} else
|
} else
|
||||||
@@ -1623,10 +1616,10 @@ register unsigned int len;
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
pline("Read %d instead of %u bytes.", rlen, len);
|
pline("Read %d instead of %u bytes.", rlen, len);
|
||||||
if (restoring) {
|
if (g.restoring) {
|
||||||
(void) nhclose(fd);
|
(void) nhclose(fd);
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
error("Error restoring old game.");
|
error("Error g.restoring old game.");
|
||||||
}
|
}
|
||||||
panic("Error reading level file.");
|
panic("Error reading level file.");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -3171,7 +3171,6 @@ void
|
|||||||
tty_cliparound(x, y)
|
tty_cliparound(x, y)
|
||||||
int x, y;
|
int x, y;
|
||||||
{
|
{
|
||||||
extern boolean restoring;
|
|
||||||
int oldx = clipx, oldy = clipy;
|
int oldx = clipx, oldy = clipy;
|
||||||
|
|
||||||
if (!clipping)
|
if (!clipping)
|
||||||
@@ -3191,7 +3190,7 @@ int x, y;
|
|||||||
clipy = clipymax - (LI - 3);
|
clipy = clipymax - (LI - 3);
|
||||||
}
|
}
|
||||||
if (clipx != oldx || clipy != oldy) {
|
if (clipx != oldx || clipy != oldy) {
|
||||||
if (on_level(&u.uz0, &u.uz) && !restoring)
|
if (on_level(&u.uz0, &u.uz) && !g.restoring)
|
||||||
(void) doredraw();
|
(void) doredraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user