distinguish global variables that get written to savefile

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
This commit is contained in:
nhmall
2024-07-13 14:57:50 -04:00
parent 0e4083153c
commit 6c0ae092c6
174 changed files with 3502 additions and 3305 deletions

326
src/eat.c
View File

@@ -264,7 +264,7 @@ choke(struct obj *food)
morehungry(Hunger ? (u.uhunger - 60) : 1000); /* you just got *very* sick! */
vomit();
} else {
gk.killer.format = KILLED_BY_AN;
svk.killer.format = KILLED_BY_AN;
/*
* Note all "killer"s below read "Choked on %s" on the
* high score list & tombstone. So plan accordingly.
@@ -272,14 +272,14 @@ choke(struct obj *food)
if (food) {
You("choke over your %s.", foodword(food));
if (food->oclass == COIN_CLASS) {
Strcpy(gk.killer.name, "very rich meal");
Strcpy(svk.killer.name, "very rich meal");
} else {
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, killer_xname(food));
svk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, killer_xname(food));
}
} else {
You("choke over it.");
Strcpy(gk.killer.name, "quick snack");
Strcpy(svk.killer.name, "quick snack");
}
You("die...");
done(CHOKING);
@@ -290,7 +290,7 @@ choke(struct obj *food)
staticfn void
recalc_wt(void)
{
struct obj *piece = gc.context.victual.piece;
struct obj *piece = svc.context.victual.piece;
if (!piece) {
impossible("recalc_wt without piece");
@@ -298,7 +298,7 @@ recalc_wt(void)
}
debugpline1("Old weight = %d", piece->owt);
debugpline2("Used time = %d, Req'd time = %d",
gc.context.victual.usedtime, gc.context.victual.reqtime);
svc.context.victual.usedtime, svc.context.victual.reqtime);
piece->owt = weight(piece);
debugpline1("New weight = %d", piece->owt);
}
@@ -310,9 +310,9 @@ reset_eat(void)
/* we only set a flag here - the actual reset process is done after
* the round is spent eating.
*/
if (gc.context.victual.eating && !gc.context.victual.doreset) {
if (svc.context.victual.eating && !svc.context.victual.doreset) {
debugpline0("reset_eat...");
gc.context.victual.doreset = 1;
svc.context.victual.doreset = 1;
}
return;
}
@@ -336,9 +336,9 @@ obj_nutrition(struct obj *otmp)
staticfn int
adj_victual_nutrition(void)
{
int otyp = gc.context.victual.piece->otyp;
int otyp = svc.context.victual.piece->otyp;
/* note: adj_victual_nutrition() is only called when 'nmod' is negative */
int nut = -gc.context.victual.nmod; /* convert 'nmod' to positive */
int nut = -svc.context.victual.nmod; /* convert 'nmod' to positive */
assert(nut > 0);
if (otyp == LEMBAS_WAFER) {
@@ -394,8 +394,8 @@ touchfood(struct obj *otmp)
void
food_disappears(struct obj *obj)
{
if (obj == gc.context.victual.piece)
gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
if (obj == svc.context.victual.piece)
svc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
if (obj->timed)
obj_stop_timers(obj);
@@ -407,13 +407,13 @@ food_disappears(struct obj *obj)
void
food_substitution(struct obj *old_obj, struct obj *new_obj)
{
if (old_obj == gc.context.victual.piece) {
gc.context.victual.piece = new_obj;
gc.context.victual.o_id = new_obj->o_id;
if (old_obj == svc.context.victual.piece) {
svc.context.victual.piece = new_obj;
svc.context.victual.o_id = new_obj->o_id;
}
if (old_obj == gc.context.tin.tin) {
gc.context.tin.tin = new_obj;
gc.context.tin.o_id = new_obj->o_id;
if (old_obj == svc.context.tin.tin) {
svc.context.tin.tin = new_obj;
svc.context.tin.o_id = new_obj->o_id;
}
}
@@ -421,20 +421,20 @@ staticfn void
do_reset_eat(void)
{
debugpline0("do_reset_eat...");
if (gc.context.victual.piece) {
if (svc.context.victual.piece) {
struct obj *otmp;
gc.context.victual.o_id = 0;
otmp = touchfood(gc.context.victual.piece);
gc.context.victual.piece = otmp;
svc.context.victual.o_id = 0;
otmp = touchfood(svc.context.victual.piece);
svc.context.victual.piece = otmp;
if (otmp) {
gc.context.victual.o_id = otmp->o_id;
svc.context.victual.o_id = otmp->o_id;
recalc_wt();
}
}
gc.context.victual.fullwarn
= gc.context.victual.eating
= gc.context.victual.doreset
svc.context.victual.fullwarn
= svc.context.victual.eating
= svc.context.victual.doreset
= 0;
/* Do not set canchoke to FALSE; if we continue eating the same object
* we need to know if canchoke was set when they started eating it the
@@ -477,7 +477,7 @@ eating_dangerous_corpse(int res)
int mnum;
if (go.occupation == eatfood
&& (food = gc.context.victual.piece) != 0
&& (food = svc.context.victual.piece) != 0
&& food->otyp == CORPSE
&& (mnum = food->corpsenm) >= LOW_PM
&& (carried(food) || obj_here(food, u.ux, u.uy))) {
@@ -517,7 +517,7 @@ maybe_extend_timed_resist(int prop)
staticfn int
eatfood(void)
{
struct obj *food = gc.context.victual.piece;
struct obj *food = svc.context.victual.piece;
if (food && !carried(food) && !obj_here(food, u.ux, u.uy))
food = 0;
@@ -526,10 +526,10 @@ eatfood(void)
do_reset_eat();
return 0;
}
if (!gc.context.victual.eating)
if (!svc.context.victual.eating)
return 0;
if (++gc.context.victual.usedtime <= gc.context.victual.reqtime) {
if (++svc.context.victual.usedtime <= svc.context.victual.reqtime) {
if (bite())
return 0;
return 1; /* still busy */
@@ -542,7 +542,7 @@ eatfood(void)
staticfn void
done_eating(boolean message)
{
struct obj *piece = gc.context.victual.piece;
struct obj *piece = svc.context.victual.piece;
piece->in_use = TRUE;
go.occupation = 0; /* do this early, so newuhs() knows we're done */
@@ -568,7 +568,7 @@ done_eating(boolean message)
else
useupf(piece, 1L);
gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
svc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
}
void
@@ -660,9 +660,9 @@ eat_brains(
return M_ATTK_MISS;
} else if (is_rider(pd)) {
pline("Ingesting that is fatal.");
Sprintf(gk.killer.name, "unwisely ate the brain of %s",
Sprintf(svk.killer.name, "unwisely ate the brain of %s",
pmname(pd, Mgender(mdef)));
gk.killer.format = NO_KILLER_PREFIX;
svk.killer.format = NO_KILLER_PREFIX;
done(DIED);
/* life-saving needed to reach here */
exercise(A_WIS, FALSE);
@@ -692,8 +692,8 @@ eat_brains(
static NEARDATA const char brainlessness[] = "brainlessness";
if (Lifesaved) {
Strcpy(gk.killer.name, brainlessness);
gk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, brainlessness);
svk.killer.format = KILLED_BY;
done(DIED);
/* amulet of life saving has now been used up */
pline("Unfortunately your brain is still gone.");
@@ -703,8 +703,8 @@ eat_brains(
} else {
Your("last thought fades away.");
}
Strcpy(gk.killer.name, brainlessness);
gk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, brainlessness);
svk.killer.format = KILLED_BY;
done(DIED);
/* can only get here when in wizard or explore mode and user has
explicitly chosen not to die; arbitrarily boost intelligence */
@@ -756,9 +756,9 @@ maybe_cannibal(int pm, boolean allowmsg)
/* when poly'd into a mind flayer, multiple tentacle hits in one
turn cause multiple digestion checks to occur; avoid giving
multiple luck penalties for the same attack */
if (gm.moves == ate_brains)
if (svm.moves == ate_brains)
return FALSE;
ate_brains = gm.moves; /* ate_anything, not just brains... */
ate_brains = svm.moves; /* ate_anything, not just brains... */
if (!CANNIBAL_ALLOWED()
/* non-cannibalistic heroes shouldn't eat own species ever
@@ -788,13 +788,13 @@ cprefx(int pm)
if (!Stone_resistance
&& !(poly_when_stoned(gy.youmonst.data)
&& polymon(PM_STONE_GOLEM))) {
Sprintf(gk.killer.name, "tasting %s meat",
Sprintf(svk.killer.name, "tasting %s meat",
mons[pm].pmnames[NEUTRAL]);
gk.killer.format = KILLED_BY;
svk.killer.format = KILLED_BY;
You("turn to stone.");
done(STONING);
if (gc.context.victual.piece)
gc.context.victual.eating = 0;
if (svc.context.victual.piece)
svc.context.victual.eating = 0;
return; /* lifesaved */
}
}
@@ -821,9 +821,9 @@ cprefx(int pm)
case PM_PESTILENCE:
case PM_FAMINE: {
pline("Eating that is instantly fatal.");
Sprintf(gk.killer.name, "unwisely ate the body of %s",
Sprintf(svk.killer.name, "unwisely ate the body of %s",
mons[pm].pmnames[NEUTRAL]);
gk.killer.format = NO_KILLER_PREFIX;
svk.killer.format = NO_KILLER_PREFIX;
done(DIED);
/* life-saving needed to reach here */
exercise(A_WIS, FALSE);
@@ -831,10 +831,10 @@ cprefx(int pm)
3.7: this used to assume that such tins were impossible but
they can be wished for in wizard mode; they can't make it
to normal play though because bones creation empties them */
if (gc.context.victual.piece /* Null for tins */
&& gc.context.victual.piece->otyp == CORPSE /* paranoia */
&& revive_corpse(gc.context.victual.piece))
gc.context.victual = zero_victual; /* victual.piece=0, .o_id=0 */
if (svc.context.victual.piece /* Null for tins */
&& svc.context.victual.piece->otyp == CORPSE /* paranoia */
&& revive_corpse(svc.context.victual.piece))
svc.context.victual = zero_victual; /* victual.piece=0, .o_id=0 */
return;
}
case PM_GREEN_SLIME:
@@ -1357,18 +1357,18 @@ violated_vegetarian(void)
return;
}
/* common code to check and possibly charge for 1 gc.context.tin.tin,
* will split() gc.context.tin.tin if necessary */
/* common code to check and possibly charge for 1 svc.context.tin.tin,
* will split() svc.context.tin.tin if necessary */
staticfn struct obj *
costly_tin(int alter_type) /* COST_xxx */
{
struct obj *tin = gc.context.tin.tin;
struct obj *tin = svc.context.tin.tin;
if (carried(tin) ? tin->unpaid
: (costly_spot(tin->ox, tin->oy) && !tin->no_charge)) {
if (tin->quan > 1L) {
tin = gc.context.tin.tin = splitobj(tin, 1L);
gc.context.tin.o_id = tin->o_id;
tin = svc.context.tin.tin = splitobj(tin, 1L);
svc.context.tin.o_id = tin->o_id;
}
costly_alteration(tin, alter_type);
}
@@ -1490,7 +1490,7 @@ consume_tin(const char *mesg)
{
const char *what;
int which, mnum, r;
struct obj *tin = gc.context.tin.tin;
struct obj *tin = svc.context.tin.tin;
r = tin_variety(tin, FALSE);
if (tin->otrapped || (tin->cursed && r != HOMEMADE_TIN && !rn2(8))) {
@@ -1540,7 +1540,7 @@ consume_tin(const char *mesg)
}
/* in case stop_occupation() was called on previous meal */
gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
svc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
You("consume %s %s.", tintxts[r].txt, mons[mnum].pmnames[NEUTRAL]);
@@ -1622,8 +1622,8 @@ consume_tin(const char *mesg)
useup(tin);
else
useupf(tin, 1L);
gc.context.tin.tin = (struct obj *) 0;
gc.context.tin.o_id = 0;
svc.context.tin.tin = (struct obj *) 0;
svc.context.tin.o_id = 0;
}
/* called during each move whilst opening a tin */
@@ -1631,15 +1631,15 @@ staticfn int
opentin(void)
{
/* perhaps it was stolen (although that should cause interruption) */
if (!carried(gc.context.tin.tin)
&& (!obj_here(gc.context.tin.tin, u.ux, u.uy)
if (!carried(svc.context.tin.tin)
&& (!obj_here(svc.context.tin.tin, u.ux, u.uy)
|| !can_reach_floor(TRUE)))
return 0; /* %% probably we should use tinoid */
if (gc.context.tin.usedtime++ >= 50) {
if (svc.context.tin.usedtime++ >= 50) {
You("give up your attempt to open the tin.");
return 0;
}
if (gc.context.tin.usedtime < gc.context.tin.reqtime)
if (svc.context.tin.usedtime < svc.context.tin.reqtime)
return 1; /* still busy */
consume_tin("You succeed in opening the tin.");
@@ -1711,13 +1711,13 @@ start_tin(struct obj *otmp)
tmp = rn1(1 + 500 / ((int) (ACURR(A_DEX) + ACURRSTR)), 10);
}
gc.context.tin.tin = otmp;
gc.context.tin.o_id = otmp->o_id;
svc.context.tin.tin = otmp;
svc.context.tin.o_id = otmp->o_id;
if (!tmp) {
consume_tin(mesg); /* begin immediately */
} else {
gc.context.tin.reqtime = tmp;
gc.context.tin.usedtime = 0;
svc.context.tin.reqtime = tmp;
svc.context.tin.usedtime = 0;
set_occupation(opentin, "opening the tin", 0);
}
return;
@@ -1811,7 +1811,7 @@ eatcorpse(struct obj *otmp)
if (!nonrotting_corpse(mnum)) {
long age = peek_at_iced_corpse_age(otmp);
rotted = (gm.moves - age) / (10L + rn2(20));
rotted = (svm.moves - age) / (10L + rn2(20));
if (otmp->cursed)
rotted += 2L;
else if (otmp->blessed)
@@ -1870,7 +1870,7 @@ eatcorpse(struct obj *otmp)
}
/* delay is weight dependent */
gc.context.victual.reqtime
svc.context.victual.reqtime
= 3 + ((!glob ? mons[mnum].cwt : otmp->owt) >> 6);
if (!tp && !nonrotting_corpse(mnum) && (otmp->orotten || !rn2(7))) {
@@ -1956,17 +1956,17 @@ start_eating(struct obj *otmp, boolean already_partly_eaten)
several such so we don't need to copy the first result
before calling it a second time */
fmt_ptr((genericptr_t) otmp),
fmt_ptr((genericptr_t) gc.context.victual.piece));
debugpline1("reqtime = %d", gc.context.victual.reqtime);
fmt_ptr((genericptr_t) svc.context.victual.piece));
debugpline1("reqtime = %d", svc.context.victual.reqtime);
debugpline1("(original reqtime = %d)", objects[otmp->otyp].oc_delay);
debugpline1("nmod = %d", gc.context.victual.nmod);
debugpline1("nmod = %d", svc.context.victual.nmod);
debugpline1("oeaten = %d", otmp->oeaten);
gc.context.victual.fullwarn = gc.context.victual.doreset = 0;
gc.context.victual.eating = 1;
svc.context.victual.fullwarn = svc.context.victual.doreset = 0;
svc.context.victual.eating = 1;
if (otmp->otyp == CORPSE || otmp->globby) {
cprefx(gc.context.victual.piece->corpsenm);
if (!gc.context.victual.piece || !gc.context.victual.eating) {
cprefx(svc.context.victual.piece->corpsenm);
if (!svc.context.victual.piece || !svc.context.victual.eating) {
/* rider revived, or hero died and was lifesaved */
return;
}
@@ -1976,7 +1976,7 @@ start_eating(struct obj *otmp, boolean already_partly_eaten)
if (bite()) {
/* survived choking, finish off food that's nearly done;
need this to handle cockatrice eggs, fortune cookies, etc */
if (++gc.context.victual.usedtime >= gc.context.victual.reqtime) {
if (++svc.context.victual.usedtime >= svc.context.victual.reqtime) {
/* don't want done_eating() to issue gn.nomovemsg if it
is due to vomit() called by bite() */
save_nomovemsg = gn.nomovemsg;
@@ -1989,9 +1989,9 @@ start_eating(struct obj *otmp, boolean already_partly_eaten)
return;
}
if (++gc.context.victual.usedtime >= gc.context.victual.reqtime) {
if (++svc.context.victual.usedtime >= svc.context.victual.reqtime) {
/* print "finish eating" message if they just resumed -dlc */
done_eating((gc.context.victual.reqtime > 1
done_eating((svc.context.victual.reqtime > 1
|| already_partly_eaten) ? TRUE : FALSE);
return;
}
@@ -2004,7 +2004,7 @@ start_eating(struct obj *otmp, boolean already_partly_eaten)
boolean
eating_glob(struct obj *glob)
{
return (go.occupation == eatfood && glob == gc.context.victual.piece);
return (go.occupation == eatfood && glob == svc.context.victual.piece);
}
/* scare nearby monster when hero eats garlic */
@@ -2065,7 +2065,7 @@ fprefx(struct obj *otmp)
/* not cannibalism, but we use similar criteria
for deciding whether to be sickened by this meal */
if (rn2(2) && !CANNIBAL_ALLOWED())
make_vomiting((long) rn1(gc.context.victual.reqtime, 14),
make_vomiting((long) rn1(svc.context.victual.reqtime, 14),
FALSE);
}
break;
@@ -2085,14 +2085,14 @@ fprefx(struct obj *otmp)
goto give_feedback;
case CLOVE_OF_GARLIC:
if (is_undead(gy.youmonst.data)) {
make_vomiting((long) rn1(gc.context.victual.reqtime, 5), FALSE);
make_vomiting((long) rn1(svc.context.victual.reqtime, 5), FALSE);
break;
}
iter_mons(garlic_breath);
/*FALLTHRU*/
default:
if (otmp->otyp == SLIME_MOLD && !otmp->cursed
&& otmp->spe == gc.context.current_fruit) {
&& otmp->spe == svc.context.current_fruit) {
pline("My, this is a %s %s!",
Hallucination ? "primo" : "yummy",
singular(otmp, xname));
@@ -2335,13 +2335,13 @@ eataccessory(struct obj *otmp)
staticfn void
eatspecial(void)
{
struct obj *otmp = gc.context.victual.piece;
struct obj *otmp = svc.context.victual.piece;
/* lesshungry wants an occupation to handle choke messages correctly */
set_occupation(eatfood, "eating non-food", 0);
lesshungry(gc.context.victual.nmod);
lesshungry(svc.context.victual.nmod);
go.occupation = 0;
gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
svc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
if (otmp->oclass == COIN_CLASS) {
if (carried(otmp))
@@ -2471,8 +2471,8 @@ fpostfx(struct obj *otmp)
setuhpmax(u.uhpmax + 1);
u.uhp = u.uhpmax;
} else if (u.uhp <= 0) {
gk.killer.format = KILLED_BY_AN;
Strcpy(gk.killer.name, "rotten lump of royal jelly");
svk.killer.format = KILLED_BY_AN;
Strcpy(svk.killer.name, "rotten lump of royal jelly");
done(POISONING);
}
}
@@ -2486,9 +2486,9 @@ fpostfx(struct obj *otmp)
&& !(poly_when_stoned(gy.youmonst.data)
&& polymon(PM_STONE_GOLEM))) {
if (!Stoned) {
Sprintf(gk.killer.name, "%s egg",
Sprintf(svk.killer.name, "%s egg",
mons[otmp->corpsenm].pmnames[NEUTRAL]);
make_stoned(5L, (char *) 0, KILLED_BY_AN, gk.killer.name);
make_stoned(5L, (char *) 0, KILLED_BY_AN, svk.killer.name);
}
}
/* note: no "tastes like chicken" message for eggs */
@@ -2577,7 +2577,7 @@ edibility_prompts(struct obj *otmp)
/* worst case rather than random
in this calculation to force prompt */
rotted = (gm.moves - age) / (10L + 0 /* was rn2(20) */);
rotted = (svm.moves - age) / (10L + 0 /* was rn2(20) */);
if (otmp->cursed)
rotted += 2L;
else if (otmp->blessed)
@@ -2659,12 +2659,12 @@ doeat_nonfood(struct obj *otmp)
boolean nodelicious = FALSE;
int material;
gc.context.victual.reqtime = 1;
gc.context.victual.piece = otmp;
gc.context.victual.o_id = otmp->o_id;
svc.context.victual.reqtime = 1;
svc.context.victual.piece = otmp;
svc.context.victual.o_id = otmp->o_id;
/* Don't split it, we don't need to if it's 1 move */
gc.context.victual.usedtime = 0;
gc.context.victual.canchoke = (u.uhs == SATIATED);
svc.context.victual.usedtime = 0;
svc.context.victual.canchoke = (u.uhs == SATIATED);
/* Note: gold weighs 1 pt. for each 1000 pieces (see
pickup.c) so gold and non-gold is consistent. */
if (otmp->oclass == COIN_CLASS)
@@ -2681,8 +2681,8 @@ doeat_nonfood(struct obj *otmp)
nodelicious = TRUE;
}
#endif
gc.context.victual.nmod = basenutrit;
gc.context.victual.eating = 1; /* needed for lesshungry() */
svc.context.victual.nmod = basenutrit;
svc.context.victual.eating = 1; /* needed for lesshungry() */
if (!u.uconduct.food++) {
ll_conduct++;
@@ -2841,9 +2841,9 @@ doeat(void)
return doeat_nonfood(otmp);
if (otmp == gc.context.victual.piece) {
if (otmp == svc.context.victual.piece) {
boolean one_bite_left
= (gc.context.victual.usedtime + 1 >= gc.context.victual.reqtime);
= (svc.context.victual.usedtime + 1 >= svc.context.victual.reqtime);
/* If they weren't able to choke, they don't suddenly become able to
* choke just because they were interrupted. On the other hand, if
@@ -2851,12 +2851,12 @@ doeat(void)
* they shouldn't be able to choke now.
*/
if (u.uhs != SATIATED)
gc.context.victual.canchoke = 0;
gc.context.victual.o_id = 0;
svc.context.victual.canchoke = 0;
svc.context.victual.o_id = 0;
otmp = touchfood(otmp);
if (otmp) {
gc.context.victual.piece = otmp;
gc.context.victual.o_id = otmp->o_id;
svc.context.victual.piece = otmp;
svc.context.victual.o_id = otmp->o_id;
} else {
do_reset_eat();
}
@@ -2889,9 +2889,9 @@ doeat(void)
already_partly_eaten = otmp->oeaten ? TRUE : FALSE;
otmp = touchfood(otmp);
if (otmp) {
gc.context.victual.piece = otmp;
gc.context.victual.o_id = otmp->o_id;
gc.context.victual.usedtime = 0;
svc.context.victual.piece = otmp;
svc.context.victual.o_id = otmp->o_id;
svc.context.victual.usedtime = 0;
} else {
do_reset_eat();
return ECMD_TIME;
@@ -2907,7 +2907,7 @@ doeat(void)
if (tmp == 2) {
/* used up */
gc.context.victual = zero_victual; /* victual.piece=0, .o_id=0 */
svc.context.victual = zero_victual; /* victual.piece=0, .o_id=0 */
return ECMD_TIME;
} else if (tmp)
dont_start = TRUE;
@@ -2944,10 +2944,10 @@ doeat(void)
break;
}
gc.context.victual.reqtime = objects[otmp->otyp].oc_delay;
svc.context.victual.reqtime = objects[otmp->otyp].oc_delay;
if (otmp->otyp != FORTUNE_COOKIE
&& (otmp->cursed || (!nonrotting_food(otmp->otyp)
&& (gm.moves - otmp->age)
&& (svm.moves - otmp->age)
> (otmp->blessed ? 50L : 30L)
&& (otmp->orotten || !rn2(7))))) {
if (rottenfood(otmp)) {
@@ -2962,7 +2962,7 @@ doeat(void)
}
} else {
You("%s %s.",
(gc.context.victual.reqtime == 1) ? "eat" : "begin eating",
(svc.context.victual.reqtime == 1) ? "eat" : "begin eating",
doname(otmp));
}
}
@@ -2972,30 +2972,30 @@ doeat(void)
debugpline3(
"before rounddiv: victual.reqtime == %d, oeaten == %d, basenutrit == %d",
gc.context.victual.reqtime, otmp->oeaten, basenutrit);
svc.context.victual.reqtime, otmp->oeaten, basenutrit);
gc.context.victual.reqtime
svc.context.victual.reqtime
= (basenutrit == 0) ? 0
: rounddiv(gc.context.victual.reqtime * (long) otmp->oeaten,
: rounddiv(svc.context.victual.reqtime * (long) otmp->oeaten,
basenutrit);
debugpline1("after rounddiv: victual.reqtime == %d",
gc.context.victual.reqtime);
svc.context.victual.reqtime);
/*
* calculate the modulo value (nutrit. units per round eating)
* note: this isn't exact - you actually lose a little nutrition due
* to this method.
* TODO: add in a "remainder" value to be given at the end of the meal.
*/
if (gc.context.victual.reqtime == 0 || otmp->oeaten == 0)
if (svc.context.victual.reqtime == 0 || otmp->oeaten == 0)
/* possible if most has been eaten before */
gc.context.victual.nmod = 0;
else if ((int) otmp->oeaten >= gc.context.victual.reqtime)
gc.context.victual.nmod = -((int) otmp->oeaten
/ gc.context.victual.reqtime);
svc.context.victual.nmod = 0;
else if ((int) otmp->oeaten >= svc.context.victual.reqtime)
svc.context.victual.nmod = -((int) otmp->oeaten
/ svc.context.victual.reqtime);
else
gc.context.victual.nmod = gc.context.victual.reqtime % otmp->oeaten;
gc.context.victual.canchoke = (u.uhs == SATIATED);
svc.context.victual.nmod = svc.context.victual.reqtime % otmp->oeaten;
svc.context.victual.canchoke = (u.uhs == SATIATED);
if (!dont_start)
start_eating(otmp, already_partly_eaten);
@@ -3054,25 +3054,25 @@ staticfn int
bite(void)
{
/* hack to pacify static analyzer incorporated into gcc 12.2 */
sa_victual(&gc.context.victual);
sa_victual(&svc.context.victual);
if (gc.context.victual.canchoke && u.uhunger >= 2000) {
choke(gc.context.victual.piece);
if (svc.context.victual.canchoke && u.uhunger >= 2000) {
choke(svc.context.victual.piece);
return 1;
}
if (gc.context.victual.doreset) {
if (svc.context.victual.doreset) {
do_reset_eat();
return 0;
}
gf.force_save_hs = TRUE;
if (gc.context.victual.nmod < 0) {
lesshungry(adj_victual_nutrition(/*-gc.context.victual.nmod*/));
consume_oeaten(gc.context.victual.piece,
gc.context.victual.nmod); /* -= -nmod */
} else if (gc.context.victual.nmod > 0
&& (gc.context.victual.usedtime % gc.context.victual.nmod)) {
if (svc.context.victual.nmod < 0) {
lesshungry(adj_victual_nutrition(/*-svc.context.victual.nmod*/));
consume_oeaten(svc.context.victual.piece,
svc.context.victual.nmod); /* -= -nmod */
} else if (svc.context.victual.nmod > 0
&& (svc.context.victual.usedtime % svc.context.victual.nmod)) {
lesshungry(1);
consume_oeaten(gc.context.victual.piece, -1); /* -= 1 */
consume_oeaten(svc.context.victual.piece, -1); /* -= 1 */
}
gf.force_save_hs = FALSE;
recalc_wt();
@@ -3109,7 +3109,7 @@ gethungry(void)
* Also causes melee-induced hunger to vary from turn-based hunger
* instead of just replicating that.
*/
accessorytime = rn2(20); /* rn2(20) replaces (int) (gm.moves % 20L) */
accessorytime = rn2(20); /* rn2(20) replaces (int) (svm.moves % 20L) */
if (accessorytime % 2) { /* odd */
/* Regeneration uses up food, unless due to an artifact */
if ((HRegeneration & ~FROMFORM)
@@ -3215,12 +3215,12 @@ lesshungry(int num)
debugpline1("lesshungry(%d)", num);
u.uhunger += num;
if (u.uhunger >= 2000) {
if (!iseating || gc.context.victual.canchoke) {
if (!iseating || svc.context.victual.canchoke) {
if (iseating) {
choke(gc.context.victual.piece);
choke(svc.context.victual.piece);
reset_eat();
} else {
choke((go.occupation == opentin) ? gc.context.tin.tin : 0);
choke((go.occupation == opentin) ? svc.context.tin.tin : 0);
/* no reset_eat() */
}
}
@@ -3229,18 +3229,18 @@ lesshungry(int num)
* warns when you're about to choke.
*/
if (u.uhunger >= 1500 && !Hunger
&& (!gc.context.victual.eating
|| (gc.context.victual.eating
&& !gc.context.victual.fullwarn))) {
&& (!svc.context.victual.eating
|| (svc.context.victual.eating
&& !svc.context.victual.fullwarn))) {
pline("You're having a hard time getting all of it down.");
gn.nomovemsg = "You're finally finished.";
if (!gc.context.victual.eating) {
if (!svc.context.victual.eating) {
gm.multi = -2;
} else {
gc.context.victual.fullwarn = 1;
if (gc.context.victual.canchoke
&& (gc.context.victual.reqtime
- gc.context.victual.usedtime) > 1) {
svc.context.victual.fullwarn = 1;
if (svc.context.victual.canchoke
&& (svc.context.victual.reqtime
- svc.context.victual.usedtime) > 1) {
/* food with one bite left will not survive a stop */
if (!paranoid_query(ParanoidEating, "Continue eating?")) {
reset_eat();
@@ -3360,8 +3360,8 @@ newuhs(boolean incr)
disp.botl = TRUE;
bot();
You("die from starvation.");
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, "starvation");
svk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, "starvation");
done(STARVING);
/* if we return, we lifesaved, and that calls newuhs */
return;
@@ -3425,8 +3425,8 @@ newuhs(boolean incr)
bot();
if ((Upolyd ? u.mh : u.uhp) < 1) {
You("die from hunger and exhaustion.");
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, "exhaustion");
svk.killer.format = KILLED_BY;
Strcpy(svk.killer.name, "exhaustion");
done(STARVING);
return;
}
@@ -3562,10 +3562,10 @@ floorfood(
pline("%s but you %s eat them.", qbuf,
nodig ? "cannot" : "are too full to");
} else {
Strcat(qbuf, ((!gc.context.digging.chew
|| gc.context.digging.pos.x != u.ux
|| gc.context.digging.pos.y != u.uy
|| !on_level(&gc.context.digging.level, &u.uz))
Strcat(qbuf, ((!svc.context.digging.chew
|| svc.context.digging.pos.x != u.ux
|| svc.context.digging.pos.y != u.uy
|| !on_level(&svc.context.digging.level, &u.uz))
? "; eat them?"
: "; resume eating them?"));
c = yn_function(qbuf, ynqchars, 'n', TRUE);
@@ -3593,7 +3593,7 @@ floorfood(
}
/* Is there some food (probably a heavy corpse) here on the ground? */
for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
for (otmp = svl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) {
if (corpsecheck
? (otmp->otyp == CORPSE
&& (corpsecheck == 1 || tinnable(otmp)))
@@ -3752,7 +3752,7 @@ consume_oeaten(struct obj *obj, int amt)
* victual handling mechanism from scratch using a less complex
* model. Alternatively, this routine could call done_eating()
* or food_disappears() but its callers would need revisions to
* cope with gc.context.victual.piece unexpectedly going away.
* cope with svc.context.victual.piece unexpectedly going away.
*
* Multi-turn eating operates by setting the food's oeaten field
* to its full nutritional value and then running a counter which
@@ -3786,8 +3786,8 @@ consume_oeaten(struct obj *obj, int amt)
/* mustn't let partly-eaten drop all the way to 0 or the item would
become restored to untouched; set to no bites left */
if (obj->oeaten == 0) {
if (obj == gc.context.victual.piece) /* always true unless wishing */
gc.context.victual.reqtime = gc.context.victual.usedtime;
if (obj == svc.context.victual.piece) /* always true unless wishing */
svc.context.victual.reqtime = svc.context.victual.usedtime;
obj->oeaten = 1; /* smallest possible positive value */
}
}
@@ -3799,10 +3799,10 @@ maybe_finished_meal(boolean stopping)
{
/* in case consume_oeaten() has decided that the food is all gone */
if (go.occupation == eatfood
&& gc.context.victual.usedtime >= gc.context.victual.reqtime) {
&& svc.context.victual.usedtime >= svc.context.victual.reqtime) {
if (stopping)
go.occupation = 0; /* for do_reset_eat */
/* eatfood() calls done_eating() to use up gc.context.victual.piece */
/* eatfood() calls done_eating() to use up svc.context.victual.piece */
(void) eatfood();
return TRUE;
}
@@ -3820,9 +3820,9 @@ cant_finish_meal(struct obj *corpse)
* left for another bite. revive() needs continued access to the
* corpse and will delete it when done.
*/
if (go.occupation == eatfood && gc.context.victual.piece == corpse) {
if (go.occupation == eatfood && svc.context.victual.piece == corpse) {
/* normally performed by done_eating() */
gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
svc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */
if (!corpse->oeaten)
corpse->oeaten = 1; /* [see consume_oeaten()] */
@@ -3845,7 +3845,7 @@ Popeye(int threat)
if (go.occupation != opentin)
return FALSE;
otin = gc.context.tin.tin;
otin = svc.context.tin.tin;
/* make sure hero still has access to tin */
if (!carried(otin)
&& (!obj_here(otin, u.ux, u.uy) || !can_reach_floor(TRUE)))