separate MAIL functionality from MAIL-related structure inclusion

With 3.7+ aspirations of improving savefile interoperability between 32-bit
and 64-bit builds, as well as between platforms, it is better to not have
the underlying struct/array content be conditional.

This splits off some of the MAIL code into MAIL_STRUCTURES code. In theory,
since MAIL_STRUCTURES is unconditionally included, the macro could
just go away and leave that code unconditional, but this commit doesn't
go that far.
This commit is contained in:
nhmall
2019-11-09 16:19:05 -05:00
parent e6bafb3f90
commit 75d22a2dbf
20 changed files with 41 additions and 29 deletions

View File

@@ -352,6 +352,14 @@ struct savefile_info {
#define MAXMONNO 120 /* extinct monst after this number created */
#define MHPMAX 500 /* maximum monster hp */
/*
* Version 3.7.x has aspirations of portable file formats. We
* make a distinction between MAIL functionality and MAIL_STRUCTURES
* so that the underlying structures are consistent, whether MAIL is
* defined or not.
*/
#define MAIL_STRUCTURES
/* PANICTRACE: Always defined for NH_DEVEL_STATUS != NH_STATUS_RELEASED
but only for supported platforms. */
#ifdef UNIX

View File

@@ -135,7 +135,7 @@ boolean restore;
if (otmp->otyp == SLIME_MOLD) {
goodfruit(otmp->spe);
#ifdef MAIL
#ifdef MAIL_STRUCTURES
} else if (otmp->otyp == SCR_MAIL) {
/* 0: delivered in-game via external event;
1: from bones or wishing; 2: written with marker */

View File

@@ -432,7 +432,7 @@ int udist;
} else {
if ((obj = g.level.objects[omx][omy]) != 0
&& !index(nofetch, obj->oclass)
#ifdef MAIL
#ifdef MAIL_STRUCTURES
&& obj->otyp != SCR_MAIL
#endif
) {

View File

@@ -2104,7 +2104,7 @@ eatspecial()
return;
}
if (objects[otmp->otyp].oc_material == PAPER) {
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (otmp->otyp == SCR_MAIL)
/* no nutrition */
pline("This junk mail is less than satisfying.");
@@ -2550,7 +2550,7 @@ doeat()
/* oc_nutrition is usually weight anyway */
else
basenutrit = objects[otmp->otyp].oc_nutrition;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (otmp->otyp == SCR_MAIL) {
basenutrit = 0;
nodelicious = TRUE;

View File

@@ -128,7 +128,7 @@ register int nk;
if (mtmp->m_lev > 8)
tmp += 50;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
/* Mail daemons put up no fight. */
if (mtmp->data == &mons[PM_MAIL_DAEMON])
tmp = 1;

View File

@@ -10,8 +10,12 @@
# include <fcntl.h>
# include <errno.h>
#endif /* SIMPLE_MAIL */
#endif /* MAIL */
#ifdef MAIL_STRUCTURES
#include "mail.h"
#endif
#ifdef MAIL
/*
* Notify user when new mail has arrived. Idea by Merlyn Leroy.
*

View File

@@ -1623,7 +1623,7 @@ int mndx, mvflagsmask, genomask;
return FALSE;
if (is_placeholder(ptr))
return FALSE;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
/* special levels might ask for random demon type; reject this one */
if (ptr == &mons[PM_MAIL_DAEMON])
return FALSE;

View File

@@ -980,7 +980,7 @@ boolean artif;
break;
case POTION_CLASS: /* note: potions get some additional init below */
case SCROLL_CLASS:
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (otmp->otyp != SCR_MAIL)
#endif
blessorcurse(otmp, 4);

View File

@@ -2038,7 +2038,7 @@ register struct monst *mtmp;
/* if it's a (possibly polymorphed) quest leader, mark him as dead */
if (mtmp->m_id == g.quest_status.leader_m_id)
g.quest_status.leader_is_dead = TRUE;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
/* if the mail daemon dies, no more mail delivery. -3. */
if (tmp == PM_MAIL_DAEMON)
g.mvitals[tmp].mvflags |= G_GENOD;
@@ -2412,7 +2412,7 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
if (nocorpse || LEVEL_SPECIFIC_NOCORPSE(mdat))
goto cleanup;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (mdat == &mons[PM_MAIL_DAEMON]) {
stackobj(mksobj_at(SCR_MAIL, x, y, FALSE, FALSE));
}

View File

@@ -925,7 +925,7 @@ register int after;
mmoved = 0;
}
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (ptr == &mons[PM_MAIL_DAEMON]) {
if (!Deaf && canseemon(mtmp))
verbalize("I'm late!");

View File

@@ -2589,7 +2589,7 @@ struct permonst _mons2[] = {
M3_INFRAVISIBLE | M3_INFRAVISION | M3_DISPLACES, 34, HI_LORD),
/* other demons
*/
#ifdef MAIL
#ifdef MAIL_STRUCTURES
MON("mail daemon", S_DEMON, LVL(56, 24, 10, 127, 0),
(G_NOGEN | G_NOCORPSE),
A(NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK),

View File

@@ -876,7 +876,7 @@ SCROLL(None, "STRC PRST SKRZ KRK", 1, 0, 100), /* Czech and Slovak
tongue-twister */
/* These must come last because they have special fixed descriptions.
*/
#ifdef MAIL
#ifdef MAIL_STRUCTURES
SCROLL("mail", "stamped", 0, 0, 0),
#endif
SCROLL("blank paper", "unlabeled", 0, 28, 60),

View File

@@ -1013,7 +1013,7 @@ unsigned doname_flags;
|| ((!known || !objects[obj->otyp].oc_charged
|| obj->oclass == ARMOR_CLASS
|| obj->oclass == RING_CLASS)
#ifdef MAIL
#ifdef MAIL_STRUCTURES
&& obj->otyp != SCR_MAIL
#endif
&& obj->otyp != FAKE_AMULET_OF_YENDOR
@@ -1326,7 +1326,7 @@ struct obj *otmp;
return FALSE; /* always fully ID'd */
/* check fundamental ID hallmarks first */
if (!otmp->known || !otmp->dknown
#ifdef MAIL
#ifdef MAIL_STRUCTURES
|| (!otmp->bknown && otmp->otyp != SCR_MAIL)
#else
|| !otmp->bknown
@@ -3861,7 +3861,7 @@ struct obj *no_wish;
case STATUE:
/* otmp->cobj already done in mksobj() */
break;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
case SCR_MAIL:
/* 0: delivered in-game via external event (or randomly for fake mail);
1: from bones or wishing; 2: written with marker */
@@ -3909,7 +3909,7 @@ struct obj *no_wish;
break;
case FIGURINE:
if (!(mons[mntmp].geno & G_UNIQ) && !is_human(&mons[mntmp])
#ifdef MAIL
#ifdef MAIL_STRUCTURES
&& mntmp != PM_MAIL_DAEMON
#endif
)

View File

@@ -151,7 +151,7 @@ static const struct Bool_Opt {
{ "legacy", &flags.legacy, TRUE, DISP_IN_GAME },
{ "lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME },
{ "lootabc", &flags.lootabc, FALSE, SET_IN_GAME },
#ifdef MAIL
#ifdef MAIL_STRUCTURES
{ "mail", &flags.biff, TRUE, SET_IN_GAME },
#else
{ "mail", (boolean *) 0, TRUE, SET_IN_FILE },

View File

@@ -2084,7 +2084,7 @@ struct monst *mtmp;
return "Aloha"; /* Hawaiian */
case PM_VALKYRIE:
return
#ifdef MAIL
#ifdef MAIL_STRUCTURES
(mtmp && mtmp->data == &mons[PM_MAIL_DAEMON]) ? "Hallo" :
#endif
"Velkommen"; /* Norse */

View File

@@ -3455,7 +3455,7 @@ struct obj *obj;
grease_protect(obj, (char *) 0, victim);
} else if (obj->oclass == SCROLL_CLASS && obj->otyp != SCR_BLANK_PAPER) {
if (obj->otyp != SCR_BLANK_PAPER
#ifdef MAIL
#ifdef MAIL_STRUCTURES
&& obj->otyp != SCR_MAIL
#endif
) {
@@ -3531,7 +3531,7 @@ boolean force;
return ER_NOTHING;
} else if (obj->oclass == SCROLL_CLASS) {
if (obj->otyp == SCR_BLANK_PAPER
#ifdef MAIL
#ifdef MAIL_STRUCTURES
|| obj->otyp == SCR_MAIL
#endif
) return 0;

View File

@@ -18,7 +18,7 @@ register struct obj *otmp;
return (10 * objects[otmp->otyp].oc_level);
switch (otmp->otyp) {
#ifdef MAIL
#ifdef MAIL_STRUCTURES
case SCR_MAIL:
return 2;
#endif
@@ -333,7 +333,7 @@ found:
}
new_obj->blessed = (curseval > 0);
new_obj->cursed = (curseval < 0);
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (new_obj->otyp == SCR_MAIL)
/* 0: delivered in-game via external event (or randomly for fake mail);
1: from bones or wishing; 2: written with marker */

View File

@@ -1231,7 +1231,7 @@ int mat, minwt;
continue;
if (obj_resists(otmp, 0, 0))
continue; /* preserve unique objects */
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (otmp->otyp == SCR_MAIL)
continue;
#endif
@@ -1358,7 +1358,7 @@ struct obj *obj;
{
long i;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
if (obj->otyp == SCR_MAIL)
return;
#endif
@@ -1456,7 +1456,7 @@ int id;
/* preserve inventory letter if in inventory */
if (obj_location == OBJ_INVENT)
otmp->invlet = obj->invlet;
#ifdef MAIL
#ifdef MAIL_STRUCTURES
/* You can't send yourself 100 mail messages and then
* polymorph them into useful scrolls
*/

View File

@@ -1111,7 +1111,7 @@ make_version()
version.feature_set = (unsigned long) (0L
/* levels and/or topology (0..4) */
/* monsters (5..9) */
#ifdef MAIL
#ifdef MAIL_STRUCTURES
| (1L << 6)
#endif
/* objects (10..14) */
@@ -1561,7 +1561,7 @@ static const char *build_opts[] = {
#ifdef PANICLOG
"errors and warnings log file",
#endif
#ifdef MAIL
#ifdef MAIL_STRUCTURES
"mail daemon",
#endif
#ifdef GNUDOS

View File

@@ -54,7 +54,7 @@ struct conditionals {
#ifndef CHARON /* not supported yet */
{ MON_GLYPH, PM_CROESUS, "Charon" },
#endif
#ifndef MAIL
#ifndef MAIL_STRUCTURES
{ MON_GLYPH, PM_FAMINE, "mail daemon" },
#endif
/* commented out in monst.c at present */
@@ -69,7 +69,7 @@ struct conditionals {
/* allow slime mold to look like slice of pizza, since we
* don't know what a slime mold should look like when renamed anyway
*/
#ifndef MAIL
#ifndef MAIL_STRUCTURES
{ OBJ_GLYPH, SCR_STINKING_CLOUD + EXTRA_SCROLL_DESCR_COUNT,
"stamped / mail" },
#endif