From 97feda46e00b2cb4b849506544332c7b8baadbe6 Mon Sep 17 00:00:00 2001 From: Bart House Date: Fri, 23 Nov 2018 12:43:38 -0800 Subject: [PATCH] Moved sex_change_ok to instance_globals. --- include/decl.h | 5 +++++ src/decl.c | 3 +++ src/polyself.c | 12 ++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/decl.h b/include/decl.h index 83ed50095..b41eab5df 100644 --- a/include/decl.h +++ b/include/decl.h @@ -464,6 +464,11 @@ struct instance_globals { /* pickup.c */ int oldcap; /* last encumberance */ + /* polyself.c */ + int sex_change_ok; /* controls whether taking on new form or becoming new + man can also change sex (ought to be an arg to + polymon() and newman() instead) */ + /* potion.c */ boolean notonhead; /* for long worms */ int potion_nothing; diff --git a/src/decl.c b/src/decl.c index 8302d7804..d9db42982 100644 --- a/src/decl.c +++ b/src/decl.c @@ -348,6 +348,9 @@ const struct instance_globals g_init = { /* pickup.c */ 0, /* oldcap */ + /* polyself.c */ + 0, /* sex_change_ok */ + /* potion.c */ FALSE, /* notonhead */ UNDEFINED_VALUE, /* potion_nothing */ diff --git a/src/polyself.c b/src/polyself.c index e136d1898..15fe3d3ce 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -33,10 +33,6 @@ STATIC_DCL void NDECL(polysense); STATIC_VAR const char no_longer_petrify_resistant[] = "No longer petrify-resistant, you"; -/* controls whether taking on new form or becoming new man can also - change sex (ought to be an arg to polymon() and newman() instead) */ -STATIC_VAR int sex_change_ok = 0; - /* update the youmonst.data structure pointer and intrinsics */ void set_uasmon() @@ -296,7 +292,7 @@ newman() u.ulevelmax = newlvl; u.ulevel = newlvl; - if (sex_change_ok && !rn2(10)) + if (g.sex_change_ok && !rn2(10)) change_sex(); adjabil(oldlvl, (int) u.ulevel); @@ -573,14 +569,14 @@ int psflags; /* The below polyok() fails either if everything is genocided, or if * we deliberately chose something illegal to force newman(). */ - sex_change_ok++; + g.sex_change_ok++; if (!polyok(&mons[mntmp]) || (!forcecontrol && !rn2(5)) || your_race(&mons[mntmp])) { newman(); } else { (void) polymon(mntmp); } - sex_change_ok--; /* reset */ + g.sex_change_ok--; /* reset */ made_change: new_light = emits_light(youmonst.data); @@ -650,7 +646,7 @@ int mntmp; if (!flags.female) dochange = TRUE; } else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) { - if (sex_change_ok && !rn2(10)) + if (g.sex_change_ok && !rn2(10)) dochange = TRUE; }