Merge branch 'NetHack-3.7'

This commit is contained in:
nhmall
2019-12-13 17:41:03 -05:00
133 changed files with 8267 additions and 18459 deletions
-20
View File
@@ -6,8 +6,6 @@
#include "hack.h"
#include "artifact.h"
#include "artilist.h"
#include "sfproto.h"
/*
* Note: both artilist[] and artiexist[] have a dummy element #0,
@@ -85,15 +83,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
bwrite(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
}
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < (1 + NROFARTIFACTS + 1); ++i)
sfo_boolean(nhfp, &g.artiexist[i], "artifacts", "g.artiexist", 1);
for (i = 0; i < NROFARTIFACTS; ++i)
sfo_xchar(nhfp, &g.artidisco[i], "artifacts", "g.artidisco", 1);
}
}
void
@@ -104,15 +93,6 @@ NHFILE *nhfp;
mread(nhfp->fd, (genericptr_t) g.artiexist, sizeof g.artiexist);
mread(nhfp->fd, (genericptr_t) g.artidisco, sizeof g.artidisco);
}
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < (1 + NROFARTIFACTS + 1); ++i)
sfi_boolean(nhfp, &g.artiexist[i], "artifacts", "g.artiexist", 1);
for (i = 0; i < NROFARTIFACTS; ++i)
sfi_xchar(nhfp, &g.artidisco[i], "artifacts", "g.artidisco", 1);
}
hack_artifacts(); /* redo non-saved special cases */
}
-15
View File
@@ -5,7 +5,6 @@
#include "hack.h"
#include "lev.h"
#include "sfproto.h"
#ifdef MFLOPPY
@@ -555,10 +554,6 @@ struct obj *corpse;
bwrite(nhfp->fd, (genericptr_t) &c, sizeof c);
bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */
}
if (nhfp->fieldlevel) {
sfo_char(nhfp, &c, "bones", "bones_count", 1);
sfo_char(nhfp, bonesid, "bones", "bonesid", (int) c);
}
savefruitchn(nhfp);
if (nhfp->structlevel)
bflush(nhfp->fd);
@@ -582,11 +577,6 @@ struct obj *corpse;
bwrite(nhfp->fd, (genericptr_t) bonesid, (unsigned) c); /* DD.nnn */
savefruitchn(nhfp);
}
if (nhfp->fieldlevel) {
sfo_char(nhfp, &c, "bones", "bones_count", 1);
sfo_char(nhfp, bonesid, "bones", "bonesid", (int) c); /* DD.nnn */
savefruitchn(nhfp);
}
update_mlstmv(); /* update monsters for eventual restoration */
savelev(nhfp, ledger_no(&u.uz));
close_nhfile(nhfp);
@@ -640,11 +630,6 @@ getbones()
mread(nhfp->fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */
mread(nhfp->fd, (genericptr_t) oldbonesid, (unsigned) c); /* DD.nnn */
}
if (nhfp->fieldlevel) {
sfi_char(nhfp, &c, "bones", "bones_count", 1); /* length incl. '\0' */
for (i = 0; i < (int) c; ++i)
sfi_char(nhfp, &oldbonesid[i], "bones", "bonesid", 1);
}
if (strcmp(bonesid, oldbonesid) != 0
/* from 3.3.0 through 3.6.0, bones in the quest branch stored
a bogus bonesid in the file; 3.6.1 fixed that, but for
+4 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1575245052 2019/12/02 00:04:12 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.350 $ */
/* NetHack 3.6 cmd.c $NHDT-Date: 1576201761 2019/12/13 01:49:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.383 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -946,6 +946,8 @@ wiz_load_lua(VOID_ARGS)
{
if (wizard) {
char buf[BUFSZ];
buf[0] = '\0';
getlin("Load which lua file?", buf);
if (buf[0] == '\033' || buf[0] == '\0')
return 0;
@@ -965,6 +967,7 @@ wiz_load_splua(VOID_ARGS)
char buf[BUFSZ];
int ridx;
buf[0] = '\0';
getlin("Load which des lua file?", buf);
if (buf[0] == '\033' || buf[0] == '\0')
return 0;
+3
View File
@@ -695,6 +695,9 @@ const struct instance_globals g_init = {
DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */
DUMMY, /* lua_copyright[LUA_COPYRIGHT_BUFSIZ] */
/* per-level glyph mapping flags */
0L, /* glyphmap_perlevel_flags */
IVMAGIC /* used to validate that structure layout has been preserved */
};
+19 -6
View File
@@ -1279,15 +1279,22 @@ boolean at_stairs, falling, portal;
* -1 11.46 12.50 12.5
* -2 5.21 4.17 0.0
* -3 2.08 0.0 0.0
*
* 3.7.0: the chance for the "mysterious force" to kick in goes down
* as it kicks in, starting at 25% per climb attempt and dropping off
* gradually but substantially. The drop off is greater when hero is
* sent down farther so benefits lawfuls more than chaotics this time.
*/
if (Inhell && up && u.uhave.amulet && !newdungeon && !portal
&& (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) {
if (!rn2(4)) {
if (!rn2(4 + g.context.mysteryforce)) {
int odds = 3 + (int) u.ualign.type, /* 2..4 */
diff = odds <= 1 ? 0 : rn2(odds); /* paranoia */
diff = (odds <= 1) ? 0 : rn2(odds); /* paranoia */
if (diff != 0) {
assign_rnd_level(newlevel, &u.uz, diff);
/* assign_rnd_level() may have used a value less than diff */
diff = u.uz.dlevel - newlevel->dlevel; /* actual descent */
/* if inside the tower, stay inside */
if (was_in_W_tower && !On_W_tower_level(newlevel))
diff = 0;
@@ -1295,15 +1302,20 @@ boolean at_stairs, falling, portal;
if (diff == 0)
assign_level(newlevel, &u.uz);
new_ledger = ledger_no(newlevel);
pline("A mysterious force momentarily surrounds you...");
/* each time it kicks in, the chance of doing so again may drop;
that drops faster, on average, when being sent down farther so
while the impact is reduced for everybody compared to earlier
versions, it is reduced least for chaotics, most for lawfuls */
g.context.mysteryforce += rn2(diff + 2); /* L:0-4, N:0-3, C:0-2 */
if (on_level(newlevel, &u.uz)) {
(void) safe_teleds(FALSE);
(void) next_to_u();
return;
} else
at_stairs = g.at_ladder = FALSE;
}
new_ledger = ledger_no(newlevel);
at_stairs = g.at_ladder = FALSE;
}
}
@@ -1578,6 +1590,7 @@ boolean at_stairs, falling, portal;
/* Reset the screen. */
vision_reset(); /* reset the blockages */
g.glyphmap_perlevel_flags = 0L; /* force per-level mapglyph() changes */
docrt(); /* does a full vision recalc */
flush_screen(-1);
+57 -51
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 do_wear.c $NHDT-Date: 1575214670 2019/12/01 15:37:50 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.116 $ */
/* NetHack 3.6 do_wear.c $NHDT-Date: 1575768410 2019/12/08 01:26:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.126 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1464,11 +1464,11 @@ struct obj *obj;
return 0;
}
reset_remarm(); /* clear g.context.takeoff.mask and g.context.takeoff.what */
reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */
(void) select_off(obj);
if (!g.context.takeoff.mask)
return 0;
/* none of armoroff()/Ring_/Amulet/Blindf_off() use g.context.takeoff.mask */
/* none of armoroff()/Ring_/Amulet/Blindf_off() use context.takeoff.mask */
reset_remarm();
if (obj->owornmask & W_ARMOR) {
@@ -1584,70 +1584,76 @@ struct obj *otmp;
if (delay) {
nomul(delay);
g.multi_reason = "disrobing";
if (is_helmet(otmp)) {
what = helm_simple_name(otmp);
g.afternmv = Helmet_off;
} else if (is_gloves(otmp)) {
what = gloves_simple_name(otmp);
g.afternmv = Gloves_off;
} else if (is_boots(otmp)) {
what = c_boots;
g.afternmv = Boots_off;
} else if (is_suit(otmp)) {
switch (objects[otmp->otyp].oc_armcat) {
case ARM_SUIT:
what = suit_simple_name(otmp);
g.afternmv = Armor_off;
} else if (is_cloak(otmp)) {
break;
case ARM_SHIELD:
what = shield_simple_name(otmp);
g.afternmv = Shield_off;
break;
case ARM_HELM:
what = helm_simple_name(otmp);
g.afternmv = Helmet_off;
break;
case ARM_GLOVES:
what = gloves_simple_name(otmp);
g.afternmv = Gloves_off;
break;
case ARM_BOOTS:
what = boots_simple_name(otmp);
g.afternmv = Boots_off;
break;
case ARM_CLOAK:
what = cloak_simple_name(otmp);
g.afternmv = Cloak_off;
} else if (is_shield(otmp)) {
what = c_shield;
g.afternmv = Shield_off;
} else if (is_shirt(otmp)) {
what = c_shirt;
break;
case ARM_SHIRT:
what = shirt_simple_name(otmp);
g.afternmv = Shirt_off;
} else {
break;
default:
impossible("Taking off unknown armor (%d: %d), delay %d",
otmp->otyp, objects[otmp->otyp].oc_armcat, delay);
break;
}
if (what) {
/* sizeof offdelaybuf == 60; increase it if this becomes longer */
Sprintf(offdelaybuf, "You finish taking off your %s.", what);
g.nomovemsg = offdelaybuf;
}
} else {
/* Be warned! We want off_msg after removing the item to
* avoid "You were wearing ____ (being worn)." However, an
* item which grants fire resistance might cause some trouble
* if removed in Hell and lifesaving puts it back on; in this
* case the message will be printed at the wrong time (after
* the messages saying you died and were lifesaved). Luckily,
* no cloak, shield, or fast-removable armor grants fire
* resistance, so we can safely do the off_msg afterwards.
* Rings do grant fire resistance, but for rings we want the
* off_msg before removal anyway so there's no problem. Take
* care in adding armors granting fire resistance; this code
* might need modification.
* 3.2 (actually 3.1 even): that comment is obsolete since
* fire resistance is not required for Gehennom so setworn()
* doesn't force the resistance granting item to be re-worn
* after being lifesaved anymore.
*/
if (is_cloak(otmp))
(void) Cloak_off();
else if (is_shield(otmp))
(void) Shield_off();
else if (is_helmet(otmp))
(void) Helmet_off();
else if (is_gloves(otmp))
(void) Gloves_off();
else if (is_boots(otmp))
(void) Boots_off();
else if (is_shirt(otmp))
(void) Shirt_off();
else if (is_suit(otmp))
/* no delay so no '(*afternmv)()' or 'nomovemsg' */
switch (objects[otmp->otyp].oc_armcat) {
case ARM_SUIT:
(void) Armor_off();
else
break;
case ARM_SHIELD:
(void) Shield_off();
break;
case ARM_HELM:
(void) Helmet_off();
break;
case ARM_GLOVES:
(void) Gloves_off();
break;
case ARM_BOOTS:
(void) Boots_off();
break;
case ARM_CLOAK:
(void) Cloak_off();
break;
case ARM_SHIRT:
(void) Shirt_off();
break;
default:
impossible("Taking off unknown armor (%d: %d), no delay",
otmp->otyp, objects[otmp->otyp].oc_armcat);
break;
}
/* We want off_msg() after removing the item to
avoid "You were wearing ____ (being worn)." */
off_msg(otmp);
}
g.context.takeoff.mask = g.context.takeoff.what = 0L;
-75
View File
@@ -7,8 +7,6 @@
#include "dgn_file.h"
#include "dlb.h"
#include "lev.h"
#include "sfproto.h"
#define DUNGEON_FILE "dungeon.lua"
@@ -149,26 +147,14 @@ boolean perform_write, free_data;
bwrite(nhfp->fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology);
bwrite(nhfp->fd, (genericptr_t) g.tune, sizeof tune);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &g.n_dgns, "dungeon", "dungeon_count", 1);
for (i = 0; i < g.n_dgns; ++i)
sfo_dungeon(nhfp, &g.dungeons[i], "dungeon", "dungeon", 1);
sfo_dgn_topology(nhfp, &g.dungeon_topology, "dungeon", "g.dungeon_topology", 1);
for (i = 0; i < (int) sizeof tune; ++i)
sfo_char(nhfp, &g.tune[i], "dungeon", "tune", 1);
}
for (count = 0, curr = g.branches; curr; curr = curr->next)
count++;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "dungeon", "branch_count", 1);
for (curr = g.branches; curr; curr = curr->next) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) curr, sizeof(branch));
if (nhfp->fieldlevel)
sfo_branch(nhfp, curr, "dungeon", "branch", 1);
}
count = maxledgerno();
if (nhfp->structlevel) {
@@ -177,20 +163,12 @@ boolean perform_write, free_data;
(unsigned) count * sizeof(struct linfo));
bwrite(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &count, "dungeon", "level_info_count", 1);
for (i = 0; i < count; ++i)
sfo_linfo(nhfp, &g.level_info[i], "dungeon", "g.level_info", 1);
sfo_nhcoord(nhfp, &g.inv_pos, "dungeon", "g.inv_pos", 1);
}
for (count = 0, curr_ms = g.mapseenchn; curr_ms;
curr_ms = curr_ms->next)
count++;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "dungeon", "mapseen_count", 1);
for (curr_ms = g.mapseenchn; curr_ms; curr_ms = curr_ms->next) {
save_mapseen(nhfp, curr_ms);
@@ -230,27 +208,15 @@ NHFILE *nhfp;
mread(nhfp->fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology);
mread(nhfp->fd, (genericptr_t) g.tune, sizeof tune);
}
if (nhfp->fieldlevel) {
sfi_int(nhfp, &g.n_dgns, "dungeon", "dungeon_count", 1);
for (i = 0; i < g.n_dgns; ++i)
sfi_dungeon(nhfp, &g.dungeons[i], "dungeon", "dungeon", 1);
sfi_dgn_topology(nhfp, &g.dungeon_topology, "dungeon", "g.dungeon_topology", 1);
for (i = 0; i < (int) sizeof tune; ++i)
sfi_char(nhfp, &g.tune[i], "dungeon", "tune", 1);
}
last = g.branches = (branch *) 0;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "dungeon", "branch_count", 1);
for (i = 0; i < count; i++) {
curr = (branch *) alloc(sizeof(branch));
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) curr, sizeof(branch));
if (nhfp->fieldlevel)
sfi_branch(nhfp, curr, "dungeon", "branch", 1);
curr->next = (branch *) 0;
if (last)
last->next = curr;
@@ -261,8 +227,6 @@ NHFILE *nhfp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "dungeon", "level_info_count", 1);
if (count >= MAXLINFO)
panic("level information count larger (%d) than allocated size",
@@ -270,18 +234,11 @@ NHFILE *nhfp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) g.level_info,
(unsigned) count * sizeof(struct linfo));
if (nhfp->fieldlevel)
for (i = 0; i < count; ++i)
sfi_linfo(nhfp, &g.level_info[i], "dungeon", "g.level_info", 1);
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos);
mread(nhfp->fd, (genericptr_t) &count, sizeof(count));
}
if (nhfp->fieldlevel) {
sfi_nhcoord(nhfp, &g.inv_pos, "dungeon", "inv_pos", 1);
sfi_int(nhfp, &count, "dungeon", "mapseen_count", 1);
}
last_ms = (mapseen *) 0;
for (i = 0; i < count; i++) {
@@ -2446,8 +2403,6 @@ mapseen *mptr;
break;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &brindx, sizeof brindx);
if (nhfp->fieldlevel)
sfo_int(nhfp, &brindx, "mapseen", "branch_index", 1);
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &mptr->lev, sizeof mptr->lev);
@@ -2455,29 +2410,15 @@ mapseen *mptr;
bwrite(nhfp->fd, (genericptr_t) &mptr->flags, sizeof mptr->flags);
bwrite(nhfp->fd, (genericptr_t) &mptr->custom_lth, sizeof mptr->custom_lth);
}
if (nhfp->fieldlevel) {
sfo_d_level(nhfp, &mptr->lev, "mapseen", "d_level", 1);
sfo_mapseen_feat(nhfp, &mptr->feat, "mapseen", "feat", 1);
sfo_mapseen_flags(nhfp, &mptr->flags, "mapseen", "flags", 1);
sfo_unsigned(nhfp, &mptr->custom_lth, "mapseen", "custom_lth", 1);
}
if (mptr->custom_lth) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) mptr->custom, mptr->custom_lth);
}
if (nhfp->fieldlevel) {
for (i = 0; i < (int) mptr->custom_lth; ++i)
sfo_char(nhfp, &mptr->custom[i], "mapseen", "custom", 1);
}
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &mptr->msrooms, sizeof mptr->msrooms);
}
if (nhfp->fieldlevel) {
for (i = 0; i < ((MAXNROFROOMS + 1) * 2); ++i)
sfo_mapseen_rooms(nhfp, &mptr->msrooms[i], "mapseen", "msrooms", 1);
}
savecemetery(nhfp, &mptr->final_resting_place);
}
@@ -2493,8 +2434,6 @@ NHFILE *nhfp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &branchnum, sizeof branchnum);
if (nhfp->fieldlevel)
sfi_int(nhfp, &branchnum, "mapseen", "branch_index", 1);
for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx)
if (brindx == branchnum)
break;
@@ -2506,12 +2445,6 @@ NHFILE *nhfp;
mread(nhfp->fd, (genericptr_t) &load->flags, sizeof load->flags);
mread(nhfp->fd, (genericptr_t) &load->custom_lth, sizeof load->custom_lth);
}
if (nhfp->fieldlevel) {
sfi_d_level(nhfp, &load->lev, "mapseen", "d_level", 1);
sfi_mapseen_feat(nhfp, &load->feat, "mapseen", "feat", 1);
sfi_mapseen_flags(nhfp, &load->flags, "mapseen", "flags", 1);
sfi_unsigned(nhfp, &load->custom_lth, "mapseen", "custom_lth", 1);
}
if (load->custom_lth) {
/* length doesn't include terminator (which isn't saved & restored) */
@@ -2519,20 +2452,12 @@ NHFILE *nhfp;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) load->custom, load->custom_lth);
}
if (nhfp->fieldlevel) {
for (i = 0; i < (int) load->custom_lth; ++i)
sfi_char(nhfp, &load->custom[i], "mapseen", "custom", 1);
}
load->custom[load->custom_lth] = '\0';
} else
load->custom = 0;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &load->msrooms, sizeof load->msrooms);
}
if (nhfp->fieldlevel) {
for (i = 0; i < ((MAXNROFROOMS + 1) * 2); ++i)
sfi_mapseen_rooms(nhfp, &load->msrooms[i], "mapseen", "msrooms", 1);
}
restcemetery(nhfp, &load->final_resting_place);
return load;
}
-5
View File
@@ -15,7 +15,6 @@
#include <limits.h>
#endif
#include "dlb.h"
#include "sfproto.h"
/* add b to long a, convert wraparound to max value */
@@ -2153,8 +2152,6 @@ NHFILE *nhfp;
for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo));
if (nhfp->fieldlevel)
sfo_kinfo(nhfp, kptr, "killers", "kinfo", 1);
}
}
if (release_data(nhfp)) {
@@ -2175,8 +2172,6 @@ NHFILE *nhfp;
for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo));
if (nhfp->fieldlevel)
sfi_kinfo(nhfp, kptr, "killers", "kinfo", 1);
if (kptr->next) {
kptr->next = (struct kinfo *) alloc(sizeof (struct kinfo));
}
-16
View File
@@ -5,8 +5,6 @@
#include "hack.h"
#include "lev.h"
#include "sfproto.h"
static NEARDATA struct engr *head_engr;
static const char *NDECL(blengr);
@@ -1194,11 +1192,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t)&(ep->engr_lth), sizeof(ep->engr_lth));
bwrite(nhfp->fd, (genericptr_t)ep, sizeof(struct engr) + ep->engr_lth);
}
if (nhfp->fieldlevel) {
sfo_unsigned(nhfp, &(ep->engr_lth), "engravings", "engr_lth", 1);
sfo_engr(nhfp, ep, "engravings", "engr", 1);
sfo_str(nhfp, ep->engr_txt, "engravings", "engr_txt", ep->engr_lth);
}
}
if (release_data(nhfp))
dealloc_engr(ep);
@@ -1206,8 +1199,6 @@ NHFILE *nhfp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)&no_more_engr, sizeof no_more_engr);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &no_more_engr, "engravings", "engr_lth", 1);
}
if (release_data(nhfp))
head_engr = 0;
@@ -1224,8 +1215,6 @@ NHFILE *nhfp;
while (1) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &lth, sizeof(unsigned));
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &lth, "engravings", "engr_lth", 1);
if (lth == 0)
return;
@@ -1233,11 +1222,6 @@ NHFILE *nhfp;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) ep, sizeof(struct engr) + lth);
}
if (nhfp->fieldlevel) {
sfi_engr(nhfp, ep, "engravings", "engr", 1);
ep->engr_txt = (char *) (ep + 1);
sfi_str(nhfp, ep->engr_txt, "engravings", "engr_txt", lth);
}
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
+7 -184
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1574116097 2019/11/18 22:28:17 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.272 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1576096997 2019/12/11 20:43:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.301 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -8,8 +8,6 @@
#include "hack.h"
#include "dlb.h"
#include <ctype.h>
#include "sfproto.h"
#include "sfprocs.h"
#include "lev.h"
#ifdef TTY_GRAPHICS
@@ -451,18 +449,6 @@ NHFILE *nhfp;
if (nhfp) {
if (nhfp->structlevel && nhfp->fd != -1)
(void) nhclose(nhfp->fd), nhfp->fd = -1;
if (nhfp->fieldlevel) {
if (nhfp->fpdef) {
(void) fclose(nhfp->fpdef);
nhfp->fpdef = (FILE *) 0;
}
}
if (nhfp->fplog)
(void) fprintf(nhfp->fplog, "# closing\n");
if (nhfp->fplog)
(void) fclose(nhfp->fplog);
if (nhfp->fpdebug)
(void) fclose(nhfp->fpdebug);
zero_nhfile(nhfp);
free_nhfile(nhfp);
}
@@ -479,13 +465,6 @@ NHFILE *nhfp;
(void) lseek(nhfp->fd, (off_t) 0, 0);
#endif
}
if (nhfp->fieldlevel) {
if (nhfp->fpdef) {
rewind(nhfp->fpdef);
nhfp->count = 0L;
nhfp->eof = FALSE;
}
}
}
static
@@ -497,25 +476,10 @@ NHFILE *nhfp;
the pointer to the nethack file descriptor */
if (nhfp) {
/* check for no open file at all,
* not a structlevel legacy file,
* nor a fieldlevel file.
* not a structlevel legacy file
*/
if (((nhfp->fd == -1) && !nhfp->fpdef)
|| (nhfp->structlevel && nhfp->fd < 0)
|| (nhfp->fieldlevel && !nhfp->fpdef)) {
if (nhfp->structlevel && nhfp->fd < 0) {
/* not viable, start the cleanup */
if (nhfp->fieldlevel) {
if (nhfp->fpdef) {
(void) fclose(nhfp->fpdef);
nhfp->fpdef = (FILE *) 0;
}
if (nhfp->fplog) {
(void) fprintf(nhfp->fplog, "# closing, not viable\n");
(void) fclose(nhfp->fplog);
}
if (nhfp->fpdebug)
(void) fclose(nhfp->fpdebug);
}
zero_nhfile(nhfp);
free_nhfile(nhfp);
nhfp = (NHFILE *) 0;
@@ -795,8 +759,6 @@ d_level *lev;
Sprintf(eos(dptr), ".%d", lev->dlevel);
#ifdef SYSCF
idx = sysopt.bonesformat[0];
if (idx > historical && idx <= ascii)
Strcat(dptr, sfoprocs[idx].ext);
#endif
#ifdef VMS
Strcat(dptr, ";1");
@@ -847,26 +809,6 @@ char errbuf[];
nhfp->fieldlevel = FALSE;
nhfp->ftype = NHF_BONESFILE;
nhfp->mode = WRITING;
#ifdef SYSCF
if (sysopt.bonesformat[0] > historical &&
sysopt.bonesformat[0] <= ascii) {
nhfp->structlevel = FALSE;
nhfp->fieldlevel = TRUE;
nhfp->addinfo = TRUE;
nhfp->style.deflt = TRUE;
nhfp->style.binary = (sysopt.bonesformat[0] != ascii);
nhfp->fnidx = sysopt.bonesformat[0];
nhfp->fd = -1;
nhfp->fpdef = fopen(file, nhfp->style.binary ? WRBMODE : WRTMODE);
if (nhfp->fpdef) {
#ifdef SAVEFILE_DEBUGGING
nhfp->fpdebug = fopen("create_bonesfile-debug.log", "a");
#endif
} else {
failed = errno;
}
}
#endif /* SYSCF */
if (nhfp->structlevel) {
#if defined(MICRO) || defined(WIN32)
/* Use O_TRUNC to force the file to be shortened if it already
@@ -962,26 +904,6 @@ char **bonesid;
nhfp->fieldlevel = FALSE;
nhfp->ftype = NHF_BONESFILE;
nhfp->mode = READING;
#ifdef SYSCF
if (sysopt.bonesformat[0] > historical &&
sysopt.bonesformat[0] <= ascii) {
nhfp->structlevel = FALSE;
nhfp->fieldlevel = TRUE;
nhfp->addinfo = TRUE;
nhfp->style.deflt = TRUE;
nhfp->style.binary = (sysopt.bonesformat[0] != ascii);
nhfp->fnidx = sysopt.bonesformat[0];
nhfp->fd = -1;
nhfp->fpdef = fopen(fq_bones, nhfp->style.binary ? RDBMODE : RDTMODE);
if (nhfp->fpdef) {
#ifdef SAVEFILE_DEBUGGING
nhfp->fpdebug = fopen("open_bonesfile-debug.log", "a");
#endif
} else {
failed = errno;
}
}
#endif /* SYSCF */
if (nhfp->structlevel) {
#ifdef MAC
nhfp->fd = macopen(fq_bones, O_RDONLY | O_BINARY, BONE_TYPE);
@@ -1022,16 +944,11 @@ void
set_savefile_name(regularize_it)
boolean regularize_it;
{
int idx = 0, regoffset = 0, overflow = 0,
int idx = historical, regoffset = 0, overflow = 0,
indicator_spot = 0; /* 0=no indicator, 1=before ext, 2=after ext */
const char *postappend = (const char *) 0,
*sfindicator = (const char *) 0;
#ifdef SYSCF
idx = sysopt.saveformat[0];
if (idx > historical && idx <= ascii)
sfindicator = sfoprocs[idx].ext;
#endif
if (g.program_state.in_self_recover) {
/* self_recover needs to be done as historical
structlevel content until that process is
@@ -1041,7 +958,6 @@ boolean regularize_it;
place it into the save file.
*/
idx = historical;
sfindicator = sfoprocs[idx].ext;
}
#ifdef VMS
Sprintf(g.SAVEF, "[.save]%d%s", getuid(), g.plname);
@@ -1112,15 +1028,7 @@ boolean regularize_it;
if (strlen(g.SAVEF) + strlen(SAVE_EXTENSION) < (SAVESIZE - 1)) {
Strcat(g.SAVEF, SAVE_EXTENSION);
#ifdef MSDOS
#ifdef SYSCF
if (idx >= historical && idx <= ascii) {
/* we did leave room for the extra char in SAVE_EXTENSION */
g.SAVEF[strlen(g.SAVEF)-1] =
(idx == lendian) ? 'l' :
(idx == ascii) ? 'a' : '\0';
}
sfindicator = (g.program_state.in_self_recover) ? "" : sfoprocs[idx].ext;
#endif
sfindicator = "";
#endif
} else
overflow = 3;
@@ -1140,8 +1048,8 @@ boolean regularize_it;
}
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
if (overflow)
impossible("set_savefile_name() couldn't complete without overlow %d",
overflow);
impossible("set_savefile_name() couldn't complete without overflow %d",
overflow);
#endif
}
@@ -1152,8 +1060,6 @@ NHFILE *nhfp;
{
if (nhfp->structlevel)
(void) write(nhfp->fd, (genericptr_t) g.SAVEF, sizeof(g.SAVEF));
if (nhfp->fieldlevel)
sfo_str(nhfp, g.SAVEF, "savefile_name", "g.savef", sizeof(g.SAVEF));
}
#endif
@@ -1212,23 +1118,6 @@ create_savefile()
nhfp->fd = -1;
nhfp->fpdef = (FILE *) 0;
}
if (!do_historical) {
nhfp->structlevel = FALSE;
nhfp->fieldlevel = TRUE;
nhfp->addinfo = TRUE;
nhfp->style.deflt = TRUE;
nhfp->style.binary = (sysopt.saveformat[0] != ascii);
nhfp->fnidx = sysopt.saveformat[0];
nhfp->fd = -1;
nhfp->fpdef = fopen(fq_save, nhfp->style.binary ? WRBMODE : WRTMODE);
if (nhfp->fpdef) {
#ifdef SAVEFILE_DEBUGGING
nhfp->fpdebug = fopen("create_savefile-debug.log", "a");
#endif
} else {
failed = errno;
}
}
if (nhfp->structlevel) {
#if defined(MICRO) || defined(WIN32)
nhfp->fd = open(fq_save, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK);
@@ -1274,11 +1163,6 @@ open_savefile()
nhfp->fieldlevel = FALSE;
nhfp->ftype = NHF_SAVEFILE;
nhfp->mode = READING;
#ifdef SYSCF
if (sysopt.saveformat[0] > historical &&
sysopt.saveformat[0] <= ascii)
do_historical = FALSE;
#endif /* SYSCF */
if (g.program_state.in_self_recover) {
do_historical = TRUE; /* force it */
nhfp->structlevel = TRUE;
@@ -1290,23 +1174,6 @@ open_savefile()
nhfp->fd = -1;
nhfp->fpdef = (FILE *) 0;
}
if (!do_historical) {
nhfp->structlevel = FALSE;
nhfp->fieldlevel = TRUE;
nhfp->addinfo = TRUE;
nhfp->style.deflt = TRUE;
nhfp->style.binary = (sysopt.saveformat[0] < ascii);
nhfp->fnidx = sysopt.saveformat[0];
nhfp->fd = -1;
nhfp->fpdef = fopen(fq_save, nhfp->style.binary ? RDBMODE : RDTMODE);
if (nhfp->fpdef) {
#ifdef SAVEFILE_DEBUGGING
nhfp->fpdebug = fopen("open_savefile-debug.log", "a");
#endif
} else {
failed = errno;
}
}
if (nhfp->structlevel) {
#ifdef MAC
nhfp->fd = macopen(fq_save, O_RDONLY | O_BINARY, SAVE_TYPE);
@@ -1345,10 +1212,6 @@ restore_saved_game()
nh_uncompress(fq_save);
if ((nhfp = open_savefile()) != 0) {
if (nhfp && nhfp->fieldlevel && nhfp->fplog)
(void) fprintf(nhfp->fplog, "# just opened\n");
if (nhfp->fieldlevel && nhfp->addinfo)
sfi_addinfo(nhfp, "NetHack", "start", "savefile", 0);
if (validate(nhfp, fq_save) != 0) {
close_nhfile(nhfp);
nhfp = (NHFILE *)0;
@@ -4051,15 +3914,6 @@ recover_savefile()
*/
/*
* Things are different now. We could be in a situation
* where the default save file format is not structlevel.
* self-recover is currently written to use copy_bytes()
* to move content from the level files into the savefile.
* Until the code is updated to use something other than
* copy_bytes, what we need to do is force the recovery
* save to be structlevel, finish creating it, then read
* it back in. The save after that can be fieldlevel again.
*
* Set a flag for the savefile routines to know the
* circumstances and act accordingly:
* g.program_state.in_self_recover
@@ -4088,29 +3942,11 @@ recover_savefile()
*/
/*store_formatindicator(snhfp); */
store_version(snhfp);
#if 0
if (snhfp->structlevel) {
if (write(snhfp->fd, (genericptr_t) &version_data, sizeof version_data)
!= sizeof version_data)
savewrite_failure = "version_info";
}
if (snhfp->fieldlevel) {
sfo_version_info(snhfp, (struct version_info *) &version_data,
"version", "version_info", 1);
savewrite_failure = (const char *) 0;
}
if (savewrite_failure)
goto cleanup;
#endif
if (snhfp->structlevel) {
if (write(snhfp->fd, (genericptr_t) &sfi, sizeof sfi) != sizeof sfi)
savewrite_failure = "savefileinfo";
}
if (snhfp->fieldlevel) {
sfo_savefile_info(snhfp, &sfsaveinfo, "savefileinfo", "savefile_info", 1);
savewrite_failure = (const char *) 0;
}
if (savewrite_failure)
goto cleanup;
@@ -4119,10 +3955,6 @@ recover_savefile()
!= sizeof pltmpsiz)
savewrite_failure = "player name size";
}
if (snhfp->fieldlevel) {
sfo_int(snhfp, &pltmpsiz, "plname", "plname_size", 1);
savewrite_failure = (const char *) 0;
}
if (savewrite_failure)
goto cleanup;
@@ -4130,18 +3962,9 @@ recover_savefile()
if (write(snhfp->fd, (genericptr_t) &tmpplbuf, pltmpsiz) != pltmpsiz)
savewrite_failure = "player name";
}
if (snhfp->fieldlevel) {
sfo_str(snhfp, tmpplbuf, "plname", "tmpplbuf", pltmpsiz);
savewrite_failure = (const char *) 0;
}
if (savewrite_failure)
goto cleanup;
/*
* copy_bytes isn't good enough anymore.
* We could be reading from a structlevel file but
* writing into a fieldlevel save file. Yikes!
*/
if (!copy_bytes(lnhfp->fd, snhfp->fd)) {
close_nhfile(gnhfp);
close_nhfile(snhfp);
-13
View File
@@ -4,8 +4,6 @@
#include "hack.h"
#include "lev.h" /* for checking save modes */
#include "sfproto.h"
/*
* Mobile light sources.
@@ -326,9 +324,6 @@ int range;
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &count, sizeof count);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &count, "lightsources", "lightsource_count", 1);
}
actual = maybe_write_ls(nhfp, range, TRUE);
if (actual != count)
panic("counted %d light sources, wrote %d! [range=%d]", count,
@@ -379,15 +374,11 @@ NHFILE *nhfp;
/* restore elements */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "lightsources", "lightsource_count", 1);
while (count-- > 0) {
ls = (light_source *) alloc(sizeof(light_source));
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfi_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
ls->next = g.light_base;
g.light_base = ls;
}
@@ -529,8 +520,6 @@ light_source *ls;
if (ls->flags & LSF_NEEDS_FIXUP) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfo_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
} else {
/* replace object pointer with id for write, then put back */
arg_save = ls->id;
@@ -552,8 +541,6 @@ light_source *ls;
ls->flags |= LSF_NEEDS_FIXUP;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ls, sizeof(light_source));
if (nhfp->fieldlevel)
sfo_ls_t(nhfp, ls, "lightsources", "lightsource", 1);
ls->id = arg_save;
ls->flags &= ~LSF_NEEDS_FIXUP;
}
+77 -7
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mapglyph.c $NHDT-Date: 1573943501 2019/11/16 22:31:41 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.51 $ */
/* NetHack 3.6 mapglyph.c $NHDT-Date: 1575830186 2019/12/08 18:36:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.60 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
@@ -9,9 +9,11 @@
#include "color.h"
#define HI_DOMESTIC CLR_WHITE /* monst.c */
#if 0
#if !defined(TTY_GRAPHICS)
#define has_color(n) TRUE
#endif
#endif
#ifdef TEXTCOLOR
static const int explcolors[] = {
@@ -57,6 +59,10 @@ static const int explcolors[] = {
#define is_objpile(x,y) (!Hallucination && g.level.objects[(x)][(y)] \
&& g.level.objects[(x)][(y)]->nexthere)
#define GMAP_SET 0x00000001
#define GMAP_ROGUELEVEL 0x00000002
#define GMAP_ALTARCOLOR 0x00000004
/*ARGSUSED*/
int
mapglyph(glyph, ochar, ocolor, ospecial, x, y, mgflags)
@@ -75,6 +81,21 @@ unsigned mgflags;
has_rogue_color = (has_rogue_ibm_graphics
&& g.symset[g.currentgraphics].nocolor == 0);
if (!g.glyphmap_perlevel_flags) {
/*
* GMAP_SET 0x00000001
* GMAP_ROGUELEVEL 0x00000002
* GMAP_ALTARCOLOR 0x00000004
*/
g.glyphmap_perlevel_flags |= GMAP_SET;
if (Is_rogue_level(&u.uz)) {
g.glyphmap_perlevel_flags |= GMAP_ROGUELEVEL;
} else if ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) {
g.glyphmap_perlevel_flags |= GMAP_ALTARCOLOR;
}
}
/*
* Map the glyph back to a character and color.
*
@@ -138,8 +159,54 @@ unsigned mgflags;
if they use the same symbol and color is disabled */
} else if (!iflags.use_color && offset == S_lava
&& (g.showsyms[idx] == g.showsyms[S_pool + SYM_OFF_P]
|| g.showsyms[idx] == g.showsyms[S_water + SYM_OFF_P])) {
|| g.showsyms[idx]
== g.showsyms[S_water + SYM_OFF_P])) {
special |= MG_BW_LAVA;
} else if (offset == S_altar && iflags.use_color) {
int amsk = altarmask_at(x, y); /* might be a mimic */
if ((g.glyphmap_perlevel_flags & GMAP_ALTARCOLOR)
&& (amsk & AM_SHRINE) != 0) {
/* high altar */
color = CLR_BRIGHT_MAGENTA;
} else {
switch (amsk & AM_MASK) {
#if 0 /*
* On OSX with TERM=xterm-color256 these render as
* white -> tty: gray, curses: ok
* gray -> both tty and curses: black
* black -> both tty and curses: blue
* red -> both tty and curses: ok.
* Since the colors have specific associations (with the
* unicorns matched with each alignment), we shouldn't use
* scrambled colors and we don't have sufficient information
* to handle platform-specific color variations.
*/
case AM_LAWFUL: /* 4 */
color = CLR_WHITE;
break;
case AM_NEUTRAL: /* 2 */
color = CLR_GRAY;
break;
case AM_CHAOTIC: /* 1 */
color = CLR_BLACK;
break;
#else /* !0: TEMP? */
case AM_LAWFUL: /* 4 */
case AM_NEUTRAL: /* 2 */
case AM_CHAOTIC: /* 1 */
cmap_color(S_altar); /* gray */
break;
#endif /* 0 */
case AM_NONE: /* 0 */
color = CLR_RED;
break;
default: /* 3, 5..7 -- shouldn't happen but 3 was possible
* prior to 3.6.3 (due to faulty sink polymorph) */
color = NO_COLOR;
break;
}
}
} else {
cmap_color(offset);
}
@@ -229,14 +296,16 @@ unsigned mgflags;
if ((special & MG_PET) != 0) {
ovidx = SYM_PET_OVERRIDE + SYM_OFF_X;
if (Is_rogue_level(&u.uz) ? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
if ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL)
? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
idx = ovidx;
}
if (is_you) {
ovidx = SYM_HERO_OVERRIDE + SYM_OFF_X;
if (Is_rogue_level(&u.uz) ? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
if ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL)
? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
idx = ovidx;
}
}
@@ -244,7 +313,8 @@ unsigned mgflags;
ch = g.showsyms[idx];
#ifdef TEXTCOLOR
/* Turn off color if no color defined, or rogue level w/o PC graphics. */
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_color))
if (!has_color(color) ||
((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) && !has_rogue_color))
#endif
color = NO_COLOR;
*ochar = (int) ch;
-20
View File
@@ -6,8 +6,6 @@
#include "hack.h"
#include "sp_lev.h"
#include "lev.h" /* save & restore info */
#include "sfproto.h"
static int FDECL(iswall, (int, int));
static int FDECL(iswall_or_stone, (int, int));
@@ -1579,18 +1577,9 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &g.xmax, sizeof(int));
bwrite(nhfp->fd, (genericptr_t) &g.ymax, sizeof(int));
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &n, "waterlevel", "bubble_count", 1);
sfo_int(nhfp, &g.xmin, "waterlevel", "g.xmin", 1);
sfo_int(nhfp, &g.ymin, "waterlevel", "g.ymin", 1);
sfo_int(nhfp, &g.xmax, "waterlevel", "g.xmax", 1);
sfo_int(nhfp, &g.ymax, "waterlevel", "g.ymax", 1);
}
for (b = g.bbubbles; b; b = b->next) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) b, sizeof(struct bubble));
if (nhfp->fieldlevel)
sfo_bubble(nhfp, b, "waterlevel", "bubble", 1);
}
}
if (release_data(nhfp))
@@ -1623,20 +1612,11 @@ NHFILE *nhfp;
mread(nhfp->fd,(genericptr_t)&g.xmax,sizeof(int));
mread(nhfp->fd,(genericptr_t)&g.ymax,sizeof(int));
}
if (nhfp->fieldlevel) {
sfi_int(nhfp, &n, "waterlevel", "bubble_count", 1);
sfi_int(nhfp, &g.xmin, "waterlevel", "g.xmin", 1);
sfi_int(nhfp, &g.ymin, "waterlevel", "g.ymin", 1);
sfi_int(nhfp, &g.xmax, "waterlevel", "g.xmax", 1);
sfi_int(nhfp, &g.ymax, "waterlevel", "g.ymax", 1);
}
for (i = 0; i < n; i++) {
btmp = b;
b = (struct bubble *) alloc(sizeof(struct bubble));
if (nhfp->structlevel)
mread(nhfp->fd,(genericptr_t) b, sizeof(struct bubble));
if (nhfp->fieldlevel)
sfi_bubble(nhfp, b, "waterlevel", "bubble", 1);
if (g.bbubbles) {
btmp->next = b;
b->prev = btmp;
-10
View File
@@ -16,8 +16,6 @@
*/
#include "hack.h"
#include "sfproto.h"
static boolean FDECL(isbig, (struct mkroom *));
static struct mkroom *FDECL(pick_room, (BOOLEAN_P));
@@ -811,8 +809,6 @@ struct mkroom *r;
*/
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) r, sizeof (struct mkroom));
if (nhfp->fieldlevel)
sfo_mkroom(nhfp, r, "room", "mkroom", 1);
for (i = 0; i < r->nsubrooms; i++) {
save_room(nhfp, r->sbrooms[i]);
}
@@ -830,8 +826,6 @@ NHFILE *nhfp;
/* First, write the number of rooms */
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom));
if (nhfp->fieldlevel)
sfo_int(nhfp, &g.nroom, "room", "g.nroom", 1);
for (i = 0; i < g.nroom; i++)
save_room(nhfp, &g.rooms[i]);
}
@@ -845,8 +839,6 @@ struct mkroom *r;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) r, sizeof(struct mkroom));
if (nhfp->fieldlevel)
sfi_mkroom(nhfp, r, "room", "mkroom", 1);
for (i = 0; i < r->nsubrooms; i++) {
r->sbrooms[i] = &g.subrooms[g.nsubroom];
@@ -867,8 +859,6 @@ NHFILE *nhfp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom));
if (nhfp->fieldlevel)
sfi_int(nhfp, &g.nroom, "room", "g.nroom", 1);
g.nsubroom = 0;
for (i = 0; i < g.nroom; i++) {
+440
View File
@@ -0,0 +1,440 @@
/* NetHack 3.7 nhlobj.c $NHDT-Date: 1576097301 2019/12/11 20:48:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $ */
/* Copyright (c) 2019 by Pasi Kallinen */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "sp_lev.h"
struct _lua_obj {
int state; /* UNUSED */
struct obj *obj;
};
struct _lua_obj *
l_obj_check(L, index)
lua_State *L;
int index;
{
struct _lua_obj *lo;
luaL_checktype(L, index, LUA_TUSERDATA);
lo = (struct _lua_obj *)luaL_checkudata(L, index, "obj");
if (!lo)
nhl_error(L, "Obj error");
return lo;
}
static int
l_obj_gc(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
if (lo && lo->obj) {
/* free-floating objects are deallocated */
if (lo->obj->where == OBJ_FREE) {
if (Has_contents(lo->obj)) {
struct obj *otmp;
while ((otmp = lo->obj->cobj) != 0) {
obj_extract_self(otmp);
dealloc_obj(otmp);
}
}
dealloc_obj(lo->obj);
}
lo->obj = NULL;
}
return 0;
}
static struct _lua_obj *
l_obj_push(L, otmp)
lua_State *L;
struct obj *otmp;
{
struct _lua_obj *lo = (struct _lua_obj *)lua_newuserdata(L, sizeof(struct _lua_obj));
luaL_getmetatable(L, "obj");
lua_setmetatable(L, -2);
lo->state = 0;
lo->obj = otmp;
return lo;
}
/* local o = obj.new("large chest");
local cobj = o:contents(); */
static int
l_obj_getcontents(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
struct obj *obj = lo->obj;
if (!obj)
nhl_error(L, "l_obj_getcontents: no obj");
if (!obj->cobj)
nhl_error(L, "l_obj_getcontents: no cobj");
(void) l_obj_push(L, obj->cobj);
return 1;
}
/* local box = obj.new("large chest");
box.addcontent(obj.new("rock"));
*/
static int
l_obj_add_to_container(L)
lua_State *L;
{
struct _lua_obj *lobox = l_obj_check(L, 1);
struct _lua_obj *lo = l_obj_check(L, 2);
struct obj *otmp;
if (!lo->obj || !lobox->obj)
nhl_error(L, "l_obj_add_to_container: no obj");
if (!Is_container(lobox->obj))
nhl_error(L, "l_obj_add_to_container: not a container");
otmp = add_to_container(lobox->obj, lo->obj);
/* was lo->obj merged? FIXME: causes problems if both lo->obj and
the one it merged with are handled by lua. Use lo->state? */
if (otmp != lo->obj)
lo->obj = otmp;
return 0;
}
/* Get a table of object class data. */
/* local odata = obj.class(otbl.otyp); */
/* local odata = obj.class(obj.new("rock")); */
static int
l_obj_objects_to_table(L)
lua_State *L;
{
int argc = lua_gettop(L);
int otyp = -1;
struct objclass *o;
if (argc != 1) {
nhl_error(L, "l_obj_objects_to_table: Wrong args");
return 0;
}
if (lua_type(L, 1) == LUA_TNUMBER) {
otyp = luaL_checkinteger(L, 1);
} else if (lua_type(L, 1) == LUA_TUSERDATA) {
struct _lua_obj *lo = l_obj_check(L, 1);
if (lo && lo->obj)
otyp = lo->obj->otyp;
}
lua_pop(L, 1);
if (otyp == -1) {
nhl_error(L, "l_obj_objects_to_table: Wrong args");
return 0;
}
o = &objects[otyp];
lua_newtable(L);
if (OBJ_NAME(objects[otyp]))
nhl_add_table_entry_str(L, "name", OBJ_NAME(objects[otyp]));
if (OBJ_DESCR(objects[otyp]))
nhl_add_table_entry_str(L, "descr",
OBJ_DESCR(objects[otyp]));
if (o->oc_uname)
nhl_add_table_entry_str(L, "uname", o->oc_uname);
nhl_add_table_entry_int(L, "name_known", o->oc_name_known);
nhl_add_table_entry_int(L, "merge", o->oc_merge);
nhl_add_table_entry_int(L, "uses_known", o->oc_uses_known);
nhl_add_table_entry_int(L, "pre_discovered", o->oc_pre_discovered);
nhl_add_table_entry_int(L, "magic", o->oc_magic);
nhl_add_table_entry_int(L, "charged", o->oc_charged);
nhl_add_table_entry_int(L, "unique", o->oc_unique);
nhl_add_table_entry_int(L, "nowish", o->oc_nowish);
nhl_add_table_entry_int(L, "big", o->oc_big);
/* TODO: oc_bimanual, oc_bulky */
nhl_add_table_entry_int(L, "tough", o->oc_tough);
nhl_add_table_entry_int(L, "dir", o->oc_dir); /* TODO: convert to text */
nhl_add_table_entry_int(L, "material", o->oc_material); /* TODO: convert to text */
/* TODO: oc_subtyp, oc_skill, oc_armcat */
nhl_add_table_entry_int(L, "oprop", o->oc_oprop);
nhl_add_table_entry_char(L, "class",
def_oc_syms[(uchar) o->oc_class].sym);
nhl_add_table_entry_int(L, "delay", o->oc_delay);
nhl_add_table_entry_int(L, "color", o->oc_color); /* TODO: text? */
nhl_add_table_entry_int(L, "prob", o->oc_prob);
nhl_add_table_entry_int(L, "weight", o->oc_weight);
nhl_add_table_entry_int(L, "cost", o->oc_cost);
nhl_add_table_entry_int(L, "damage_small", o->oc_wsdam);
nhl_add_table_entry_int(L, "damage_large", o->oc_wldam);
/* TODO: oc_oc1, oc_oc2, oc_hitbon, a_ac, a_can, oc_level */
nhl_add_table_entry_int(L, "nutrition", o->oc_nutrition);
return 1;
}
/* Create a lua table representation of the object, unpacking all the
object fields.
local o = obj.new("rock");
local otbl = o:totable(); */
static int
l_obj_to_table(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
struct obj *obj = lo->obj;
lua_newtable(L);
if (!obj) {
nhl_add_table_entry_int(L, "NO_OBJ", 1);
return 1;
}
nhl_add_table_entry_int(L, "has_contents", Has_contents(obj));
nhl_add_table_entry_int(L, "is_container", Is_container(obj));
nhl_add_table_entry_int(L, "o_id", obj->o_id);
nhl_add_table_entry_int(L, "ox", obj->ox);
nhl_add_table_entry_int(L, "oy", obj->oy);
nhl_add_table_entry_int(L, "otyp", obj->otyp);
if (OBJ_NAME(objects[obj->otyp]))
nhl_add_table_entry_str(L, "otyp_name", OBJ_NAME(objects[obj->otyp]));
if (OBJ_DESCR(objects[obj->otyp]))
nhl_add_table_entry_str(L, "otyp_descr",
OBJ_DESCR(objects[obj->otyp]));
nhl_add_table_entry_int(L, "owt", obj->owt);
nhl_add_table_entry_int(L, "quan", obj->quan);
nhl_add_table_entry_int(L, "spe", obj->spe);
if (obj->otyp == STATUE) {
nhl_add_table_entry_int(L, "historic", (obj->spe & STATUE_HISTORIC));
nhl_add_table_entry_int(L, "statue_male", (obj->spe & STATUE_MALE));
nhl_add_table_entry_int(L, "statue_female", (obj->spe & STATUE_FEMALE));
}
nhl_add_table_entry_char(L, "oclass",
def_oc_syms[(uchar) obj->oclass].sym);
nhl_add_table_entry_char(L, "invlet", obj->invlet);
/* TODO: nhl_add_table_entry_char(L, "oartifact", obj->oartifact);*/
nhl_add_table_entry_int(L, "where", obj->where);
/* TODO: nhl_add_table_entry_int(L, "timed", obj->timed); */
nhl_add_table_entry_int(L, "cursed", obj->cursed);
nhl_add_table_entry_int(L, "blessed", obj->blessed);
nhl_add_table_entry_int(L, "unpaid", obj->unpaid);
nhl_add_table_entry_int(L, "no_charge", obj->no_charge);
nhl_add_table_entry_int(L, "known", obj->known);
nhl_add_table_entry_int(L, "dknown", obj->dknown);
nhl_add_table_entry_int(L, "bknown", obj->bknown);
nhl_add_table_entry_int(L, "rknown", obj->rknown);
if (obj->oclass == POTION_CLASS)
nhl_add_table_entry_int(L, "odiluted", obj->odiluted);
else
nhl_add_table_entry_int(L, "oeroded", obj->oeroded);
nhl_add_table_entry_int(L, "oeroded2", obj->oeroded2);
/* TODO: orotten, norevive */
nhl_add_table_entry_int(L, "oerodeproof", obj->oerodeproof);
nhl_add_table_entry_int(L, "olocked", obj->olocked);
nhl_add_table_entry_int(L, "obroken", obj->obroken);
if (is_poisonable(obj))
nhl_add_table_entry_int(L, "opoisoned", obj->opoisoned);
else
nhl_add_table_entry_int(L, "otrapped", obj->otrapped);
/* TODO: degraded_horn */
nhl_add_table_entry_int(L, "recharged", obj->recharged);
/* TODO: on_ice */
nhl_add_table_entry_int(L, "lamplit", obj->lamplit);
nhl_add_table_entry_int(L, "globby", obj->globby);
nhl_add_table_entry_int(L, "greased", obj->greased);
nhl_add_table_entry_int(L, "nomerge", obj->nomerge);
nhl_add_table_entry_int(L, "was_thrown", obj->was_thrown);
nhl_add_table_entry_int(L, "in_use", obj->in_use);
nhl_add_table_entry_int(L, "bypass", obj->bypass);
nhl_add_table_entry_int(L, "cknown", obj->cknown);
nhl_add_table_entry_int(L, "lknown", obj->lknown);
nhl_add_table_entry_int(L, "corpsenm", obj->corpsenm);
if (obj->corpsenm != NON_PM
&& (obj->otyp == TIN || obj->otyp == CORPSE || obj->otyp == EGG
|| obj->otyp == FIGURINE || obj->otyp == STATUE))
nhl_add_table_entry_str(L, "corpsenm_name", mons[obj->corpsenm].mname);
/* TODO: leashmon, fromsink, novelidx, record_achieve_special */
nhl_add_table_entry_int(L, "usecount", obj->usecount);
/* TODO: spestudied */
nhl_add_table_entry_int(L, "oeaten", obj->oeaten);
nhl_add_table_entry_int(L, "age", obj->age);
nhl_add_table_entry_int(L, "owornmask", obj->owornmask);
/* TODO: more of oextra */
nhl_add_table_entry_int(L, "has_oname", has_oname(obj));
if (has_oname(obj))
nhl_add_table_entry_str(L, "oname", ONAME(obj));
return 1;
}
/* create a new object via wishing routine */
/* local o = obj.new("rock"); */
static int
l_obj_new_readobjnam(L)
lua_State *L;
{
int argc = lua_gettop(L);
if (argc == 1) {
char buf[BUFSZ];
struct obj *otmp;
Sprintf(buf, "%s", luaL_checkstring(L, 1));
lua_pop(L, 1);
otmp = readobjnam(buf, NULL);
(void) l_obj_push(L, otmp);
return 1;
} else
nhl_error(L, "l_obj_new_readobjname: Wrong args");
return 0;
}
/* Get the topmost object on the map at x,y */
/* local o = obj.at(x, y); */
static int
l_obj_at(L)
lua_State *L;
{
int argc = lua_gettop(L);
if (argc == 2) {
int x, y;
x = luaL_checkinteger(L, 1);
y = luaL_checkinteger(L, 2);
lua_pop(L, 2);
(void) l_obj_push(L, g.level.objects[x][y]);
return 1;
} else
nhl_error(L, "l_obj_at: Wrong args");
return 0;
}
/* Place an object on the map at (x,y).
local o = obj.new("rock");
o:placeobj(u.ux, u.uy); */
static int
l_obj_placeobj(L)
lua_State *L;
{
int argc = lua_gettop(L);
struct _lua_obj *lo = l_obj_check(L, 1);
if (argc != 3)
nhl_error(L, "l_obj_placeobj: Wrong args");
if (lo && lo->obj) {
int x, y;
x = luaL_checkinteger(L, 2);
y = luaL_checkinteger(L, 3);
lua_pop(L, 3);
place_object(lo->obj, x, y);
} else
nhl_error(L, "l_obj_placeobj: Wrong args");
return 0;
}
/* Get the next object in the object chain */
/* local o = obj.at(x, y);
local o2 = o:next();
*/
static int
l_obj_nextobj(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
if (lo && lo->obj)
(void) l_obj_push(L, lo->obj->where == OBJ_FLOOR ? lo->obj->nexthere : lo->obj->nobj);
return 1;
}
/* Get the container object is in */
/* local box = o:container(); */
static int
l_obj_container(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
if (lo && lo->obj && lo->obj->where == OBJ_CONTAINED) {
(void) l_obj_push(L, lo->obj->ocontainer);
return 1;
}
(void) l_obj_push(L, NULL);
return 1;
}
/* Is the object a null? */
/* local badobj = o:isnull(); */
static int
l_obj_isnull(L)
lua_State *L;
{
struct _lua_obj *lo = l_obj_check(L, 1);
lua_pushboolean(L, lo && lo->obj);
return 1;
}
static const struct luaL_Reg l_obj_methods[] = {
{ "new", l_obj_new_readobjnam },
{ "isnull", l_obj_isnull },
{ "at", l_obj_at },
{ "next", l_obj_nextobj },
{ "totable", l_obj_to_table },
{ "class", l_obj_objects_to_table },
{ "placeobj", l_obj_placeobj },
{ "container", l_obj_container },
{ "contents", l_obj_getcontents },
{ "addcontent", l_obj_add_to_container },
{ NULL, NULL }
};
static const luaL_Reg l_obj_meta[] = {
{ "__gc", l_obj_gc },
{ NULL, NULL }
};
int
l_obj_register(L)
lua_State *L;
{
int lib_id, meta_id;
/* newclass = {} */
lua_createtable(L, 0, 0);
lib_id = lua_gettop(L);
/* metatable = {} */
luaL_newmetatable(L, "obj");
meta_id = lua_gettop(L);
luaL_setfuncs(L, l_obj_meta, 0);
/* metatable.__index = _methods */
luaL_newlib(L, l_obj_methods);
lua_setfield(L, meta_id, "__index");
/* metatable.__metatable = _meta */
luaL_newlib(L, l_obj_meta);
lua_setfield(L, meta_id, "__metatable");
/* class.__metatable = metatable */
lua_setmetatable(L, lib_id);
/* _G["obj"] = newclass */
lua_setglobal(L, "obj");
return 0;
}
+15
View File
@@ -114,6 +114,19 @@ int value;
lua_rawset(L, -3);
}
void
nhl_add_table_entry_char(L, name, value)
lua_State *L;
const char *name;
char value;
{
char buf[2];
Sprintf(buf, "%c", value);
lua_pushstring(L, name);
lua_pushstring(L, buf);
lua_rawset(L, -3);
}
void
nhl_add_table_entry_str(L, name, value)
lua_State *L;
@@ -874,6 +887,8 @@ nhl_init()
l_selection_register(L);
l_register_des(L);
l_obj_register(L);
if (!nhl_loadlua(L, "nhlib.lua")) {
lua_close(L);
return (lua_State *) 0;
-31
View File
@@ -5,8 +5,6 @@
#include "hack.h"
#include "lev.h" /* save & restore info */
#include "sfproto.h"
static void FDECL(setgemprobs, (d_level *));
static void FDECL(shuffle, (int, int, BOOLEAN_P));
@@ -301,14 +299,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t)objects,
sizeof(struct objclass) * NUM_OBJECTS);
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAXOCLASSES; ++i)
sfo_int(nhfp, &g.bases[i], "names", "g.bases", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfo_short(nhfp, &g.disco[i], "names", "g.disco", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfo_objclass(nhfp, &objects[i], "names", "objclass", 1);
}
}
/* as long as we use only one version of Hack we
need not save oc_name and oc_descr, but we must save
@@ -321,11 +311,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t)&len, sizeof len);
bwrite(nhfp->fd, (genericptr_t)objects[i].oc_uname, len);
}
if (nhfp->fieldlevel) {
sfo_unsigned(nhfp, &len, "names", "len", 1);
for (j = 0; (unsigned) j < len; ++j)
sfo_char(nhfp, &objects[i].oc_uname[j], "names", "oc_uname", 1);
}
}
if (release_data(nhfp)) {
free((genericptr_t) objects[i].oc_uname);
@@ -347,31 +332,15 @@ NHFILE *nhfp;
mread(nhfp->fd, (genericptr_t) objects,
sizeof(struct objclass) * NUM_OBJECTS);
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAXOCLASSES; ++i)
sfi_int(nhfp, &g.bases[i], "names", "g.bases", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfi_short(nhfp, &g.disco[i], "names", "g.disco", 1);
for (i = 0; i < NUM_OBJECTS; ++i)
sfi_objclass(nhfp, &objects[i], "names", "objclass", 1);
}
for (i = 0; i < NUM_OBJECTS; i++) {
if (objects[i].oc_uname) {
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &len, sizeof len);
}
if (nhfp->fieldlevel) {
sfi_unsigned(nhfp, &len, "names", "len", 1);
}
objects[i].oc_uname = (char *) alloc(len);
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t)objects[i].oc_uname, len);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < len; ++j)
sfi_char(nhfp, &objects[i].oc_uname[j],
"names", "oc_uname", 1);
}
}
}
#ifdef USE_TILES
+60 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 objnam.c $NHDT-Date: 1575245076 2019/12/02 00:04:36 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.255 $ */
/* NetHack 3.7 objnam.c $NHDT-Date: 1575768412 2019/12/08 01:26:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.273 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4241,6 +4241,65 @@ struct obj *gloves;
return "gloves";
}
/* boots vs shoes; depends upon discovery state */
const char *
boots_simple_name(boots)
struct obj *boots;
{
static const char shoes[] = "shoes";
if (boots && boots->dknown) {
int otyp = boots->otyp;
struct objclass *ocl = &objects[otyp];
const char *actualn = OBJ_NAME(*ocl),
*descrpn = OBJ_DESCR(*ocl);
if (strstri(descrpn, shoes)
|| (objects[otyp].oc_name_known && strstri(actualn, shoes)))
return shoes;
}
return "boots";
}
/* simplified shield for messages */
const char *
shield_simple_name(shield)
struct obj *shield;
{
if (shield) {
/* xname() describes unknown (unseen) reflection as smooth */
if (shield->otyp == SHIELD_OF_REFLECTION)
return shield->dknown ? "silver shield" : "smooth shield";
/*
* We might distinguish between wooden vs metallic or
* light vs heavy to give small benefit to spell casters.
* Fighter types probably care more about the former for
* vulnerability to fire or rust.
*
* We could do that both ways: light wooden shield, light
* metallic shield (there aren't any), heavy wooden shield,
* and heavy metallic shield but that's getting away from
* "simple name" which is intended to be shorter as well
* as less detailed than xname().
*/
#if 0
/* spellcasting uses a division like this */
return (weight(shield) > (int) objects[SMALL_SHIELD].oc_weight)
? "heavy shield"
: "light shield";
#endif
}
return "shield";
}
/* for completness */
const char *
shirt_simple_name(shirt)
struct obj *shirt UNUSED;
{
return "shirt";
}
const char *
mimic_obj_name(mtmp)
struct monst *mtmp;
-3
View File
@@ -18,7 +18,6 @@ NEARDATA struct instance_flags iflags; /* provide linkage */
#include "tcap.h"
#include <ctype.h>
#endif
#include "sfprocs.h"
#define BACKWARD_COMPAT
@@ -698,8 +697,6 @@ initoptions_init()
if (boolopt[i].addr)
*(boolopt[i].addr) = boolopt[i].initvalue;
}
/* initialize the function pointers for fieldlevel saves */
sf_init();
#ifdef SYSFLAGS
Strcpy(sysflags.sysflagsid, "sysflags");
+3 -6
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pager.c $NHDT-Date: 1574722864 2019/11/25 23:01:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.162 $ */
/* NetHack 3.6 pager.c $NHDT-Date: 1575830188 2019/12/08 18:36:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.175 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -483,11 +483,8 @@ char *buf, *monbuf;
switch (glyph_to_cmap(glyph)) {
case S_altar:
amsk = ((mtmp = m_at(x, y)) != 0 && has_mcorpsenm(mtmp)
&& M_AP_TYPE(mtmp) == M_AP_FURNITURE
&& mtmp->mappearance == S_altar) ? MCORPSENM(mtmp)
: levl[x][y].altarmask;
algn = Amask2align(amsk & ~AM_SHRINE);
amsk = altarmask_at(x, y);
algn = Amask2align(amsk & AM_MASK);
Sprintf(buf, "%s %saltar",
/* like endgame high priests, endgame high altars
are only recognizable when immediately adjacent */
+27 -7
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pray.c $NHDT-Date: 1573346192 2019/11/10 00:36:32 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.118 $ */
/* NetHack 3.6 pray.c $NHDT-Date: 1575830189 2019/12/08 18:36:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.134 $ */
/* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1384,6 +1384,7 @@ dosacrifice()
/* curse the lawful/neutral altar */
pline_The("altar is stained with %s blood.", g.urace.adj);
levl[u.ux][u.uy].altarmask = AM_CHAOTIC;
newsym(u.ux, u.uy); /* in case Invisible to self */
angry_priest();
} else {
struct monst *dmon;
@@ -1640,15 +1641,16 @@ dosacrifice()
a_gname());
if (rn2(8 + u.ulevel) > 5) {
struct monst *pri;
boolean shrine;
You_feel("the power of %s increase.", u_gname());
exercise(A_WIS, TRUE);
change_luck(1);
/* Yes, this is supposed to be &=, not |= */
levl[u.ux][u.uy].altarmask &= AM_SHRINE;
/* the following accommodates stupid compilers */
levl[u.ux][u.uy].altarmask =
levl[u.ux][u.uy].altarmask
| (Align2amask(u.ualign.type));
shrine = on_shrine();
levl[u.ux][u.uy].altarmask = Align2amask(u.ualign.type);
if (shrine)
levl[u.ux][u.uy].altarmask |= AM_SHRINE;
newsym(u.ux, u.uy); /* in case Invisible to self */
if (!Blind)
pline_The("altar glows %s.",
hcolor((u.ualign.type == A_LAWFUL)
@@ -2075,6 +2077,24 @@ doturn()
return 1;
}
int
altarmask_at(x, y)
int x, y;
{
int res = 0;
if (isok(x, y)) {
struct monst *mon = m_at(x, y);
if (mon && M_AP_TYPE(mon) == M_AP_FURNITURE
&& mon->mappearance == S_altar)
res = has_mcorpsenm(mon) ? MCORPSENM(mon) : 0;
else if (IS_ALTAR(levl[x][y].typ))
res = levl[x][y].altarmask;
}
return res;
}
const char *
a_gname()
{
+6 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 questpgr.c $NHDT-Date: 1574634383 2019/11/24 22:26:23 $ $NHDT-Branch: paxed-quest-lua $:$NHDT-Revision: 1.63 $ */
/* NetHack 3.6 questpgr.c $NHDT-Date: 1575830005 2019/12/08 18:33:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.67 $ */
/* Copyright 1991, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */
@@ -489,7 +489,9 @@ const char *msgid;
nelems = (int) lua_tointeger(L, -1);
lua_pop(L, 1);
if (nelems < 2) {
impossible("com_pager: questtext[%s][%s] in %s in not an array of strings", section, msgid, QTEXT_FILE);
impossible(
"com_pager: questtext[%s][%s] in %s in not an array of strings",
section, msgid, QTEXT_FILE);
lua_close(L);
return FALSE;
}
@@ -511,12 +513,13 @@ const char *msgid;
if (synopsis) {
char in_line[BUFSZ], out_line[BUFSZ];
Strcpy(in_line, synopsis);
convert_line(in_line, out_line);
putmsghistory(out_line, FALSE);
free(synopsis);
}
free(synopsis);
free(text);
lua_close(L);
return TRUE;
+1 -91
View File
@@ -4,8 +4,6 @@
#include "hack.h"
#include "lev.h"
#include "sfproto.h"
/*
* This should really go into the level structure, but
@@ -641,64 +639,40 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof (g.moves)); /* timestamp */
bwrite(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
}
if (nhfp->fieldlevel) {
sfo_long(nhfp, &g.moves, "regions", "tmstamp", 1);
sfo_int(nhfp, &g.n_regions, "regions", "region_count", 1);
}
for (i = 0; i < g.n_regions; i++) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
}
if (nhfp->fieldlevel) {
sfo_nhrect(nhfp, &g.regions[i]->bounding_box, "g.regions", "bounding_box", 1);
sfo_short(nhfp, &g.regions[i]->nrects, "g.regions", "nrects", 1);
}
for (j = 0; j < g.regions[i]->nrects; j++) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
if (nhfp->fieldlevel)
sfo_nhrect(nhfp, &g.regions[i]->rects[j], "g.regions", "rect", 1);
}
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
if (nhfp->fieldlevel)
sfo_boolean(nhfp, &g.regions[i]->attach_2_u, "g.regions", "attach_2_u", 1);
n = 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.regions[i]->attach_2_m, "g.regions", "attach_2_m", 1);
n = g.regions[i]->enter_msg != (const char *)0 ?
strlen(g.regions[i]->enter_msg) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &n, "g.regions", "enter_msg_length", 1);
if (n > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->enter_msg, n);
if (nhfp->fieldlevel)
sfo_char(nhfp, g.regions[i]->enter_msg, "g.regions", "enter_msg", 1);
}
n = g.regions[i]->leave_msg != (const char *)0 ?
strlen(g.regions[i]->leave_msg) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &n, "g.regions", "leave_msg_length", 1);
if (n > 0) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) g.regions[i]->leave_msg, n);
}
if (nhfp->fieldlevel) {
for (j = 0; j < (int) n; ++j)
sfo_char(nhfp, &g.regions[i]->leave_msg[j], "g.regions", "leave_msg", 1);
}
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
@@ -711,34 +685,16 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags, sizeof (unsigned int));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
}
if (nhfp->fieldlevel) {
sfo_long(nhfp, &g.regions[i]->ttl, "g.regions", "ttl", 1);
sfo_short(nhfp, &g.regions[i]->expire_f, "g.regions", "expire_f", 1);
sfo_short(nhfp, &g.regions[i]->can_enter_f, "g.regions", "can_enter_f", 1);
sfo_short(nhfp, &g.regions[i]->enter_f, "g.regions", "enter_f", 1);
sfo_short(nhfp, &g.regions[i]->can_leave_f, "g.regions", "can_leave_f", 1);
sfo_short(nhfp, &g.regions[i]->leave_f, "g.regions", "leave_f", 1);
sfo_short(nhfp, &g.regions[i]->inside_f, "g.regions", "inside_f", 1);
sfo_unsigned(nhfp, &g.regions[i]->player_flags, "g.regions", "player_flags", 1);
sfo_short(nhfp, &g.regions[i]->n_monst, "g.regions", "monster_count", 1);
}
for (j = 0; j < g.regions[i]->n_monst; j++) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->monsters[j],
sizeof (unsigned));
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.regions[i]->monsters[j], "g.regions", "monster", 1);
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
bwrite(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
}
if (nhfp->fieldlevel) {
sfo_boolean(nhfp, &g.regions[i]->visible, "g.regions", "visible", 1);
sfo_int(nhfp, &g.regions[i]->glyph, "g.regions", "glyph", 1);
sfo_any(nhfp, &g.regions[i]->arg, "g.regions", "arg", 1);
}
}
skip_lots:
@@ -759,8 +715,6 @@ boolean ghostly; /* If a bones file restore */
clear_regions(); /* Just for security */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &tmstamp, sizeof (tmstamp));
if (nhfp->fieldlevel)
sfi_long(nhfp, &tmstamp, "regions", "tmstamp", 1);
if (ghostly)
tmstamp = 0;
else
@@ -768,8 +722,6 @@ boolean ghostly; /* If a bones file restore */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions));
if (nhfp->fieldlevel)
sfi_int(nhfp, &g.n_regions, "regions", "region_count", 1);
g.max_regions = g.n_regions;
if (g.n_regions > 0)
@@ -780,41 +732,25 @@ boolean ghostly; /* If a bones file restore */
mread(nhfp->fd, (genericptr_t) &g.regions[i]->bounding_box, sizeof (NhRect));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->nrects, sizeof (short));
}
if (nhfp->fieldlevel) {
sfi_nhrect(nhfp, &g.regions[i]->bounding_box, "g.regions", "bounding box", 1);
sfi_short(nhfp, &g.regions[i]->nrects, "g.regions", "nrects", 1);
}
if (g.regions[i]->nrects > 0)
g.regions[i]->rects = (NhRect *)
alloc(sizeof (NhRect) * g.regions[i]->nrects);
for (j = 0; j < g.regions[i]->nrects; j++) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->rects[j], sizeof (NhRect));
if (nhfp->fieldlevel)
sfi_nhrect(nhfp, &g.regions[i]->rects[j], "g.regions", "rect", 1);
}
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_u, sizeof (boolean));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->attach_2_m, sizeof (unsigned));
}
if (nhfp->fieldlevel) {
sfi_boolean(nhfp, &g.regions[i]->attach_2_u, "g.regions", "attach_2_u", 1);
sfi_unsigned(nhfp, &g.regions[i]->attach_2_m, "g.regions", "attach_2_m", 1);
}
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &n, "g.regions", "enter_msg_length", 1);
if (n > 0) {
msg_buf = (char *) alloc(n + 1);
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) msg_buf, n);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < n; ++j)
sfi_char(nhfp, &msg_buf[j], "g.regions", "enter_msg", 1);
}
msg_buf[n] = '\0';
g.regions[i]->enter_msg = (const char *) msg_buf;
} else
@@ -822,17 +758,11 @@ boolean ghostly; /* If a bones file restore */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &n, sizeof n);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &n, "g.regions", "leave_msg_length", 1);
if (n > 0) {
if (n > 0) {
msg_buf = (char *) alloc(n + 1);
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) msg_buf, n);
}
if (nhfp->fieldlevel) {
for (j = 0; (unsigned) j < n; ++j)
sfi_char(nhfp, &msg_buf[j], "g.regions", "leave_msg", 1);
}
msg_buf[n] = '\0';
g.regions[i]->leave_msg = (const char *) msg_buf;
} else
@@ -840,8 +770,6 @@ boolean ghostly; /* If a bones file restore */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->ttl, sizeof (long));
if (nhfp->fieldlevel)
sfi_long(nhfp, &g.regions[i]->ttl, "g.regions", "ttl", 1);
/* check for expired region */
if (g.regions[i]->ttl >= 0L)
g.regions[i]->ttl =
@@ -862,23 +790,12 @@ boolean ghostly; /* If a bones file restore */
mread(nhfp->fd, (genericptr_t) &g.regions[i]->player_flags,
sizeof (unsigned int));
}
if (nhfp->fieldlevel) {
sfi_short(nhfp, &g.regions[i]->expire_f, "g.regions", "expire_f", 1);
sfi_short(nhfp, &g.regions[i]->can_enter_f, "g.regions", "can_enter_f", 1);
sfi_short(nhfp, &g.regions[i]->enter_f, "g.regions", "enter_f", 1);
sfi_short(nhfp, &g.regions[i]->can_leave_f, "g.regions", "can_leave_f", 1);
sfi_short(nhfp, &g.regions[i]->leave_f, "g.regions", "leave_f", 1);
sfi_short(nhfp, &g.regions[i]->inside_f, "g.regions", "inside_f", 1);
sfi_unsigned(nhfp, &g.regions[i]->player_flags, "g.regions", "player_flags", 1);
}
if (ghostly) { /* settings pertained to old player */
clear_hero_inside(g.regions[i]);
clear_heros_fault(g.regions[i]);
}
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->n_monst, sizeof (short));
if (nhfp->fieldlevel)
sfi_short(nhfp, &g.regions[i]->n_monst, "g.regions", "monster_count", 1);
if (g.regions[i]->n_monst > 0)
g.regions[i]->monsters =
(unsigned *) alloc(sizeof (unsigned) * g.regions[i]->n_monst);
@@ -889,19 +806,12 @@ boolean ghostly; /* If a bones file restore */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.regions[i]->monsters[j],
sizeof (unsigned));
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &g.regions[i]->monsters[j], "g.regions", "monster", 1);
}
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) &g.regions[i]->visible, sizeof (boolean));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->glyph, sizeof (int));
mread(nhfp->fd, (genericptr_t) &g.regions[i]->arg, sizeof (anything));
}
if (nhfp->fieldlevel) {
sfi_boolean(nhfp, &g.regions[i]->visible, "g.regions", "visible", 1);
sfi_int(nhfp, &g.regions[i]->glyph, "g.regions", "glyph", 1);
sfi_any(nhfp, &g.regions[i]->arg, "g.regions", "arg", 1);
}
}
/* remove expired regions, do not trigger the expire_f callback (yet!);
also update monster lists if this data is coming from a bones file */
-184
View File
@@ -6,9 +6,6 @@
#include "hack.h"
#include "lev.h"
#include "tcap.h" /* for TERMLIB and ASCIIGRAPH */
#include "sfproto.h"
#if defined(MICRO)
extern int dotcnt; /* shared with save */
@@ -128,15 +125,11 @@ NHFILE *nhfp;
g.sp_levchn = (s_level *) 0;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &cnt, sizeof(int));
if (nhfp->fieldlevel)
sfi_int(nhfp, &cnt, "levchn", "lev_count", 1);
for (; cnt > 0; cnt--) {
tmplev = (s_level *) alloc(sizeof(s_level));
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) tmplev, sizeof(s_level));
if (nhfp->fieldlevel)
sfi_s_level(nhfp, tmplev, "levchn", "s_level", 1);
if (!g.sp_levchn)
g.sp_levchn = tmplev;
@@ -160,8 +153,6 @@ boolean ghostly;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &dmgcount, sizeof(dmgcount));
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &dmgcount, "damage", "damage_count", 1);
counter = (int) dmgcount;
if (!counter)
@@ -172,8 +163,6 @@ boolean ghostly;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) tmp_dam, sizeof(*tmp_dam));
if (nhfp->fieldlevel)
sfi_damage(nhfp, tmp_dam, "damage", "damage", 1);
if (ghostly)
tmp_dam->when += (g.monstermoves - g.omoves);
@@ -212,8 +201,6 @@ struct obj *otmp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) otmp, sizeof(struct obj));
if (nhfp->fieldlevel)
sfi_obj(nhfp, otmp, "obj", "obj", 1);
/* next object pointers are invalid; otmp->cobj needs to be left
as is--being non-null is key to restoring container contents */
@@ -225,22 +212,16 @@ struct obj *otmp;
/* oname - object's name */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "oname_length", 1);
if (buflen > 0) { /* includes terminating '\0' */
new_oname(otmp, buflen);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) ONAME(otmp), buflen);
if (nhfp->fieldlevel)
sfi_str(nhfp, ONAME(otmp), "obj", "oname", buflen);
}
/* omonst - corpse or statue might retain full monster details */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "omonst_length", 1);
if (buflen > 0) {
newomonst(otmp);
/* this is actually a monst struct, so we
@@ -251,42 +232,30 @@ struct obj *otmp;
/* omid - monster id number, connecting corpse to ghost */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "omid_length", 1);
if (buflen > 0) {
newomid(otmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) OMID(otmp), buflen);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, OMID(otmp), "obj", "omid", 1);
}
/* olong - temporary gold */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "olong_length", 1);
if (buflen > 0) {
newolong(otmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) OLONG(otmp), buflen);
if (nhfp->fieldlevel)
sfi_long(nhfp, OLONG(otmp), "obj", "olong", 1);
}
/* omailcmd - feedback mechanism for scroll of mail */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "omailcmd_length", 1);
if (buflen > 0) {
char *omailcmd = (char *) alloc(buflen);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) omailcmd, buflen);
if (nhfp->fieldlevel)
sfi_str(nhfp, omailcmd, "obj", "omailcmd", buflen);
new_omailcmd(otmp, omailcmd);
free((genericptr_t) omailcmd);
}
@@ -305,8 +274,6 @@ boolean ghostly, frozen;
while (1) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "obj", "obj_length", 1);
if (buflen == -1)
break;
@@ -393,8 +360,6 @@ struct monst *mtmp;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) mtmp, sizeof(struct monst));
if (nhfp->fieldlevel)
sfi_monst(nhfp, mtmp, "mon", "monst_length", 1);
/* next monster pointer is invalid */
mtmp->nmon = (struct monst *) 0;
@@ -405,82 +370,56 @@ struct monst *mtmp;
/* mname - monster's name */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "mname_length", 1);
if (buflen > 0) { /* includes terminating '\0' */
new_mname(mtmp, buflen);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) MNAME(mtmp), buflen);
if (nhfp->fieldlevel)
sfi_str(nhfp, MNAME(mtmp), "mon", "mname", buflen);
}
/* egd - vault guard */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "egd_length", 1);
if (buflen > 0) {
newegd(mtmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) EGD(mtmp), sizeof(struct egd));
if (nhfp->fieldlevel)
sfi_egd(nhfp, EGD(mtmp), "mon", "egd", 1);
}
/* epri - temple priest */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "epri_length", 1);
if (buflen > 0) {
newepri(mtmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) EPRI(mtmp), sizeof(struct epri));
if (nhfp->fieldlevel)
sfi_epri(nhfp, EPRI(mtmp), "mon", "epri", 1);
}
/* eshk - shopkeeper */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "eshk_length", 1);
if (buflen > 0) {
neweshk(mtmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) ESHK(mtmp), sizeof(struct eshk));
if (nhfp->fieldlevel)
sfi_eshk(nhfp, ESHK(mtmp), "mon", "eshk", 1);
}
/* emin - minion */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "emin_length", 1);
if (buflen > 0) {
newemin(mtmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) EMIN(mtmp), sizeof(struct emin));
if (nhfp->fieldlevel)
sfi_emin(nhfp, EMIN(mtmp), "mon", "emin", 1);
}
/* edog - pet */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "edog_length", 1);
if (buflen > 0) {
newedog(mtmp);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) EDOG(mtmp), sizeof(struct edog));
if (nhfp->fieldlevel)
sfi_edog(nhfp, EDOG(mtmp), "mon", "edog", 1);
}
/* mcorpsenm - obj->corpsenm for mimic posing as corpse or
statue (inline int rather than pointer to something) */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &MCORPSENM(mtmp), sizeof MCORPSENM(mtmp));
if (nhfp->fieldlevel)
sfi_int(nhfp, &MCORPSENM(mtmp), "mon", "mcorpsenm", 1);
} /* mextra */
}
@@ -496,8 +435,6 @@ boolean ghostly;
while (1) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &buflen, sizeof(buflen));
if (nhfp->fieldlevel)
sfi_int(nhfp, &buflen, "mon", "monst_length", 1);
if (buflen == -1)
break;
@@ -572,8 +509,6 @@ NHFILE *nhfp;
fnext = newfruit();
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t)fnext, sizeof *fnext);
if (nhfp->fieldlevel)
sfi_fruit(nhfp, fnext, "fruit", "fruit", 1);
if (fnext->fid != 0) {
fnext->nextf = flist;
flist = fnext;
@@ -636,13 +571,8 @@ unsigned int *stuckid, *steedid;
unsigned long uid = 0;
boolean defer_perm_invent;
if (nhfp->fieldlevel && nhfp->addinfo)
sfi_addinfo(nhfp, "gamestate", "start", "", 0);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &uid, sizeof uid);
if (nhfp->fieldlevel)
sfi_ulong(nhfp, &uid, "gamestate", "uid", 1);
if (SYSOPT_CHECK_SAVE_UID
&& uid != (unsigned long) getuid()) { /* strange ... */
@@ -656,8 +586,6 @@ unsigned int *stuckid, *steedid;
newgamecontext = g.context; /* copy statically init'd context */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.context, sizeof (struct context_info));
if (nhfp->fieldlevel)
sfi_context_info(nhfp, &g.context, "gamestate", "g.context", 1);
g.context.warntype.species = (g.context.warntype.speciesidx >= LOW_PM)
? &mons[g.context.warntype.speciesidx]
: (struct permonst *) 0;
@@ -671,8 +599,6 @@ unsigned int *stuckid, *steedid;
newgameflags = flags;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &flags, sizeof (struct flag));
if (nhfp->fieldlevel)
sfi_flag(nhfp, &flags, "gamestate", "flags", 1);
/* avoid keeping permanent inventory window up to date during restore
(setworn() calls update_inventory); attempting to include the cost
@@ -699,9 +625,6 @@ unsigned int *stuckid, *steedid;
newgamesysflags = sysflags;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
if (nhfp->fieldlevel)
sfi_sysflag(nhfp, &sysflags, "gamestate", "sysflags", 1);
mread(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
#endif
role_init(); /* Reset the initial role, race, gender, and alignment */
@@ -710,25 +633,17 @@ unsigned int *stuckid, *steedid;
#endif
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &u, sizeof(struct you));
if (nhfp->fieldlevel)
sfi_you(nhfp, &u, "gamestate", "you", 1);
g.youmonst.cham = u.mcham;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) timebuf, 14);
if (nhfp->fieldlevel)
sfi_str(nhfp, timebuf, "gamestate", "ubirthday", 14);
timebuf[14] = '\0';
ubirthday = time_from_yyyymmddhhmmss(timebuf);
if (nhfp->structlevel)
mread(nhfp->fd, &urealtime.realtime, sizeof urealtime.realtime);
if (nhfp->fieldlevel)
sfi_long(nhfp, &urealtime.realtime, "gamestate", "realtime", 1);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) timebuf, 14);
if (nhfp->fieldlevel)
sfi_str(nhfp, timebuf, "gamestate", "start_timing", 14);
timebuf[14] = '\0';
urealtime.start_timing = time_from_yyyymmddhhmmss(timebuf);
@@ -767,8 +682,6 @@ unsigned int *stuckid, *steedid;
restore_timers(nhfp, RANGE_GLOBAL, FALSE, 0L);
restore_light_sources(nhfp);
if (nhfp->fieldlevel && nhfp->addinfo)
sfi_addinfo(nhfp, "objchain", "start", "invent", 0);
g.invent = restobjchn(nhfp, FALSE, FALSE);
/* restore dangling (not on floor or in inventory) ball and/or chain */
@@ -787,12 +700,6 @@ unsigned int *stuckid, *steedid;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) g.mvitals, sizeof g.mvitals);
}
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < NUMMONS; ++i)
sfi_mvitals(nhfp, &g.mvitals[i], "gamestate", "g.mvitals", 1);
}
/*
* There are some things after this that can have unintended display
@@ -824,41 +731,20 @@ unsigned int *stuckid, *steedid;
mread(nhfp->fd, (genericptr_t) &g.quest_status, sizeof (struct q_score));
mread(nhfp->fd, (genericptr_t) g.spl_book, (MAXSPELL + 1) * sizeof (struct spell));
}
if (nhfp->fieldlevel) {
int i;
struct spell *sptmp;
sfi_long(nhfp, &g.moves, "gamestate", "g.moves", 1);
sfi_long(nhfp, &g.monstermoves, "gamestate", "g.monstermoves", 1);
sfi_q_score(nhfp, &g.quest_status, "gamestate", "g.quest_status", 1);
sptmp = g.spl_book;
for (i = 0; i < (MAXSPELL + 1); ++i)
sfi_spell(nhfp, sptmp++, "gamestate", "g.spl_book", 1);
}
restore_artifacts(nhfp);
restore_oracles(nhfp);
if (u.ustuck) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) stuckid, sizeof *stuckid);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, stuckid, "gamestate", "ustuck_id", 1);
}
if (u.usteed) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) steedid, sizeof *steedid);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, steedid, "gamestate", "usteed_id", 1);
}
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) g.pl_character, sizeof g.pl_character);
mread(nhfp->fd, (genericptr_t) g.pl_fruit, sizeof g.pl_fruit);
}
if (nhfp->fieldlevel) {
sfi_char(nhfp, g.pl_character, "gamestate", "g.pl_character",
sizeof g.pl_character);
sfi_char(nhfp, g.pl_fruit, "gamestate", "g.pl_fruit",
sizeof g.pl_fruit);
}
freefruitchn(g.ffruit); /* clean up fruit(s) made by initoptions() */
g.ffruit = loadfruitchn(nhfp);
@@ -1039,11 +925,6 @@ NHFILE *nhfp;
if (restoreinfo.mread_flags == -1)
break;
}
if (nhfp->fieldlevel) {
sfi_xchar(nhfp, &ltmp, "gamestate", "level_number", 1);
if (nhfp->eof)
break;
}
getlev(nhfp, 0, ltmp, FALSE);
#ifdef MICRO
curs(WIN_MAP, 1 + dotcnt++, dotrow);
@@ -1061,9 +942,6 @@ NHFILE *nhfp;
return rtmp; /* dorecover called recursively */
}
restoreinfo.mread_flags = 0;
if (nhfp->fieldlevel && nhfp->addinfo)
sfi_addinfo(nhfp, "NetHack", "end", "savefile", 0);
rewind_nhfile(nhfp); /* return to beginning of file */
(void) validate(nhfp, (char *) 0);
get_plname_from_file(nhfp, g.plname);
@@ -1130,16 +1008,12 @@ struct cemetery **cemeteryaddr;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &cflag, sizeof cflag);
if (nhfp->fieldlevel)
sfi_int(nhfp, &cflag, "cemetery", "cemetery_flag", 1);
if (cflag == 0) {
bonesaddr = cemeteryaddr;
do {
bonesinfo = (struct cemetery *) alloc(sizeof *bonesinfo);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) bonesinfo, sizeof *bonesinfo);
if (nhfp->fieldlevel)
sfi_cemetery(nhfp, bonesinfo, "bones", "bonesinfo", 1);
*bonesaddr = bonesinfo;
bonesaddr = &(*bonesaddr)->next;
} while (*bonesaddr);
@@ -1175,10 +1049,6 @@ boolean rlecomp;
mread(nhfp->fd, (genericptr_t) &len, sizeof(uchar));
mread(nhfp->fd, (genericptr_t) &r, sizeof(struct rm));
}
if (nhfp->fieldlevel) {
sfi_uchar(nhfp, &len, "room", "levl", 1);
sfi_rm(nhfp, &r, "room", "rm", 1);
}
}
}
j = 0;
@@ -1192,13 +1062,6 @@ boolean rlecomp;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) levl, sizeof levl);
}
if (nhfp->fieldlevel) {
int c, r;
for (c = 0; c < COLNO; ++c)
for (r = 0; r < ROWNO; ++r)
sfi_rm(nhfp, &levl[c][r], "room", "levl", 1);
}
}
void
@@ -1246,21 +1109,15 @@ boolean ghostly;
/* First some sanity checks */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &hpid, sizeof(hpid));
if (nhfp->fieldlevel)
sfi_int(nhfp, &hpid, "gamestate", "g.hackpid", 1);
/* CHECK: This may prevent restoration */
#ifdef TOS
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &tlev, sizeof(tlev));
if (nhfp->fieldlevel)
sfi_short(nhfp, &tlev, "gamestate", "tlev", 1);
dlvl = tlev & 0x00ff;
#else
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &dlvl, sizeof(dlvl));
if (nhfp->fieldlevel)
sfi_xchar(nhfp, &dlvl, "gamestate", "dlvl", 1);
#endif
if ((pid && pid != hpid) || (lev && dlvl != lev)) {
char trickbuf[BUFSZ];
@@ -1281,16 +1138,6 @@ boolean ghostly;
mread(nhfp->fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp));
mread(nhfp->fd, (genericptr_t) &g.omoves, sizeof(g.omoves));
}
if (nhfp->fieldlevel) {
int c, r;
for (c = 0; c < COLNO; ++c)
for (r = 0; r < ROWNO; ++r)
sfi_schar(nhfp, &g.lastseentyp[c][r],
"lev", "g.lastseentyp", 1);
sfi_long(nhfp, &g.omoves, "lev", "timestmp", 1);
}
elapsed = g.monstermoves - g.omoves;
if (nhfp->structlevel) {
@@ -1304,20 +1151,6 @@ boolean ghostly;
mread(nhfp->fd, (genericptr_t)&g.level.flags, sizeof(g.level.flags));
mread(nhfp->fd, (genericptr_t)g.doors, sizeof(g.doors));
}
if (nhfp->fieldlevel) {
int i;
sfi_stairway(nhfp, &g.upstair, "lev", "g.upstair", 1);
sfi_stairway(nhfp, &g.dnstair, "lev", "g.dnstair", 1);
sfi_stairway(nhfp, &g.upladder, "lev", "g.upladder", 1);
sfi_stairway(nhfp, &g.dnladder, "lev", "g.dnladder", 1);
sfi_stairway(nhfp, &g.sstairs, "lev", "g.sstairs", 1);
sfi_dest_area(nhfp, &g.updest, "lev", "g.updest", 1);
sfi_dest_area(nhfp, &g.dndest, "lev", "g.dndest", 1);
sfi_levelflags(nhfp, &g.level.flags, "lev", "g.level.flags", 1);
for (i = 0; i < DOORMAX; ++i)
sfi_nhcoord(nhfp, &g.doors[i], "lev", "g.doors", 1);
}
rest_rooms(nhfp); /* No joke :-) */
if (g.nroom)
g.doorindex = g.rooms[g.nroom - 1].fdoor + g.rooms[g.nroom - 1].doorct;
@@ -1336,8 +1169,6 @@ boolean ghostly;
trap = newtrap();
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t)trap, sizeof(struct trap));
if (nhfp->fieldlevel)
sfi_trap(nhfp, trap, "trap", "trap", 1);
if (trap->tx != 0) {
trap->ntrap = g.ftrap;
g.ftrap = trap;
@@ -1461,10 +1292,6 @@ char *plbuf;
(void) read(nhfp->fd, (genericptr_t) &pltmpsiz, sizeof(pltmpsiz));
(void) read(nhfp->fd, (genericptr_t) plbuf, pltmpsiz);
}
if (nhfp->fieldlevel) {
sfi_int(nhfp, &pltmpsiz, "plname", "plname_size", 1);
sfi_str(nhfp, plbuf, "plname", "g.plname", pltmpsiz);
}
return;
}
@@ -1478,16 +1305,12 @@ NHFILE *nhfp;
while (1) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &msgsize, sizeof(msgsize));
if (nhfp->fieldlevel)
sfi_int(nhfp, &msgsize, "msghistory", "msghistory_length", 1);
if (msgsize == -1)
break;
if (msgsize > (BUFSZ - 1))
panic("restore_msghistory: msg too big (%d)", msgsize);
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) msg, msgsize);
if (nhfp->fieldlevel)
sfi_str(nhfp, msg, "msghistory", "msg", msgsize);
msg[msgsize] = '\0';
putmsghistory(msg, TRUE);
++msgcount;
@@ -1671,21 +1494,14 @@ const char *name;
if (nhfp->structlevel)
utdflags |= UTD_CHECKSIZES;
if (nhfp->fieldlevel)
utdflags |= UTD_CHECKFIELDCOUNTS |
UTD_SKIP_SANITY1 | UTD_SKIP_SAVEFILEINFO;
if (!(reslt = uptodate(nhfp, name, utdflags))) return 1;
if ((nhfp->mode & WRITING) == 0) {
if (nhfp->structlevel)
rlen = read(nhfp->fd, (genericptr_t) &sfi, sizeof sfi);
if (nhfp->fieldlevel)
sfi_savefile_info(nhfp, &sfi, "savefileinfo", "savefile_info", 1);
} else {
if (nhfp->structlevel)
rlen = read(nhfp->fd, (genericptr_t) &sfi, sizeof sfi);
if (nhfp->fieldlevel)
sfi_savefile_info(nhfp, &sfi, "savefileinfo", "savefile_info", 1);
minit(); /* ZEROCOMP */
if (rlen == 0) {
if (verbose) {
-14
View File
@@ -6,8 +6,6 @@
#include "hack.h"
#include "lev.h"
#include "dlb.h"
#include "sfproto.h"
/* [note: this comment is fairly old, but still accurate for 3.1]
* Rumors have been entirely rewritten to speed up the access. This is
@@ -393,16 +391,10 @@ NHFILE *nhfp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.oracle_cnt, "oracles", "g.oracle_cnt", 1);
if (g.oracle_cnt) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t)g.oracle_loc, g.oracle_cnt * sizeof (long));
}
if (nhfp->fieldlevel) {
for (i = 0; (unsigned) i < g.oracle_cnt; ++i)
sfo_ulong(nhfp, &g.oracle_loc[i], "oracles", "oracle loc", 1);
}
}
}
if (release_data(nhfp)) {
@@ -420,18 +412,12 @@ NHFILE *nhfp;
int i;
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (nhfp->fieldlevel)
sfi_unsigned(nhfp, &g.oracle_cnt, "oracles", "g.oracle_cnt", 1);
if (g.oracle_cnt) {
g.oracle_loc = (unsigned long *) alloc(g.oracle_cnt * sizeof(long));
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof (long));
}
if (nhfp->fieldlevel) {
for (i = 0; (unsigned) i < g.oracle_cnt; ++i)
sfi_ulong(nhfp, &g.oracle_loc[i], "oracles", "g.oracle_loc", 1);
}
g.oracle_flg = 1; /* no need to call init_oracles() */
}
}
-182
View File
@@ -5,8 +5,6 @@
#include "hack.h"
#include "lev.h"
#include "sfproto.h"
#ifndef NO_SIGNAL
#include <signal.h>
@@ -149,10 +147,6 @@ dosave0()
(void) delete_savefile(); /* ab@unido */
return 0;
}
#ifdef SAVEFILE_DEBUGGING
if (nhfp && nhfp->fieldlevel && nhfp->fplog)
(void) fprintf(nhfp->fplog, "# just opened\n");
#endif
vision_recalc(2); /* shut down vision to prevent problems
in the event of an impossible() call */
@@ -202,9 +196,6 @@ dosave0()
}
#endif /* MFLOPPY */
if (nhfp->fieldlevel && nhfp->addinfo && (nhfp->mode & WRITING))
sfo_addinfo(nhfp, "NetHack", "start", "savefile", 0);
nhfp->mode = WRITING | FREEING;
store_version(nhfp);
store_savefileinfo(nhfp);
@@ -259,8 +250,6 @@ dosave0()
close_nhfile(onhfp);
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &ltmp, sizeof ltmp); /* level number*/
if (nhfp->fieldlevel)
sfo_xchar(nhfp, &ltmp, "gamestate", "level_number", 1); /* xchar */
savelev(nhfp, ltmp); /* actual level*/
delete_levelfile(ltmp);
}
@@ -294,14 +283,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &flags, sizeof flags);
#ifdef SYSFLAGS
bwrite(nhfp->fd, (genericptr_t) &sysflags, sysflags);
#endif
}
if (nhfp->fieldlevel) {
sfo_ulong(nhfp, &uid, "gamestate", "uid", 1);
sfo_context_info(nhfp, &g.context, "gamestate", "g.context", 1);
sfo_flag(nhfp, &flags, "gamestate" , "flags", 1);
#ifdef SYSFLAGS
sfo_flag(nhfp, &sysflags, "gamestate" , "sysflags", 1);
#endif
}
urealtime.finish_time = getnow();
@@ -318,12 +299,6 @@ NHFILE *nhfp;
sizeof urealtime.realtime);
bwrite(nhfp->fd, yyyymmddhhmmss(urealtime.start_timing), 14);
}
if (nhfp->fieldlevel) {
sfo_you(nhfp, &u, "gamestate", "you", 1);
sfo_str(nhfp, yyyymmddhhmmss(ubirthday), "gamestate", "ubirthday", 14);
sfo_long(nhfp, &urealtime.realtime, "gamestate", "realtime", 1);
sfo_str(nhfp, yyyymmddhhmmss(urealtime.start_timing), "gamestate", "start_timing", 14);
}
/* this is the value to use for the next update of urealtime.realtime */
urealtime.start_timing = urealtime.finish_time;
save_killers(nhfp);
@@ -355,12 +330,6 @@ NHFILE *nhfp;
}
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) g.mvitals, sizeof g.mvitals);
if (nhfp->fieldlevel) {
int i;
for (i = 0; i < NUMMONS; ++i)
sfo_mvitals(nhfp, &g.mvitals[i], "gamestate", "g.mvitals", 1);
}
save_dungeon(nhfp, (boolean) !!perform_bwrite(nhfp),
(boolean) !!release_data(nhfp));
savelevchn(nhfp);
@@ -371,39 +340,20 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) g.spl_book,
sizeof (struct spell) * (MAXSPELL + 1));
}
if (nhfp->fieldlevel) {
int i;
struct spell *sptmp;
sfo_long(nhfp, &g.moves, "gamestate", "g.moves", 1);
sfo_long(nhfp, &g.monstermoves, "gamestate", "g.monstermoves", 1);
sfo_q_score(nhfp, &g.quest_status, "gamestate", "g.quest_status", 1);
sptmp = g.spl_book;
for (i = 0; i < (MAXSPELL + 1); ++i)
sfo_spell(nhfp, sptmp++, "gamestate", "g.spl_book", 1);
}
save_artifacts(nhfp);
save_oracles(nhfp);
if (g.ustuck_id) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.ustuck_id, sizeof g.ustuck_id);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.ustuck_id, "gamestate", "g.ustuck_id", 1);
}
if (g.usteed_id) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.usteed_id, sizeof g.usteed_id);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &g.usteed_id, "gamestate", "g.usteed_id", 1);
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) g.pl_character, sizeof g.pl_character);
bwrite(nhfp->fd, (genericptr_t) g.pl_fruit, sizeof g.pl_fruit);
}
if (nhfp->fieldlevel) {
sfo_char(nhfp, g.pl_character, "gamestate", "g.pl_character", sizeof g.pl_character);
sfo_char(nhfp, g.pl_fruit, "gamestate", "g.pl_fruit", sizeof g.pl_fruit);
}
savefruitchn(nhfp);
savenames(nhfp);
save_waterlevel(nhfp);
@@ -478,15 +428,11 @@ savestateinlock()
nhfp->mode = WRITING;
if (nhfp->structlevel)
(void) write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof g.hackpid);
if (nhfp->fieldlevel)
sfo_int(nhfp, &g.hackpid, "gamestate", "g.hackpid", 1);
if (flags.ins_chkpt) {
int currlev = ledger_no(&u.uz);
if (nhfp->structlevel)
(void) write(nhfp->fd, (genericptr_t) &currlev, sizeof currlev);
if (nhfp->fieldlevel)
sfo_int(nhfp, &currlev, "gamestate", "savestateinlock", 1);
save_savefile_name(nhfp);
store_version(nhfp);
store_savefileinfo(nhfp);
@@ -582,20 +528,14 @@ xchar lev;
g.level_info[lev].flags |= VISITED;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.hackpid, sizeof g.hackpid);
if (nhfp->fieldlevel)
sfo_int(nhfp, &g.hackpid, "gamestate", "g.hackpid", 1);
#ifdef TOS
tlev = lev;
tlev &= 0x00ff;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &tlev, sizeof tlev);
if (nhfp->fieldlevel)
sfo_short(nhfp, &tlev, "gamestate", "tlev", 1);
#else
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &lev, sizeof lev);
if (nhfp->fieldlevel)
sfo_xchar(nhfp, &lev, "gamestate", "dlvl", 1);
#endif
}
@@ -623,24 +563,6 @@ xchar lev;
bwrite(nhfp->fd, (genericptr_t) &g.level.flags, sizeof g.level.flags);
bwrite(nhfp->fd, (genericptr_t) g.doors, sizeof g.doors);
}
if (nhfp->fieldlevel) {
int i, c, r;
for (c = 0; c < COLNO; ++c)
for (r = 0; r < ROWNO; ++r)
sfo_schar(nhfp, &g.lastseentyp[c][r], "lev", "g.lastseentyp", 1);
sfo_long(nhfp, &g.monstermoves, "lev", "timestmp", 1);
sfo_stairway(nhfp, &g.upstair, "lev", "g.upstair", 1);
sfo_stairway(nhfp, &g.dnstair, "lev", "g.dnstair", 1);
sfo_stairway(nhfp, &g.upladder, "lev", "g.upladder", 1);
sfo_stairway(nhfp, &g.dnladder, "lev", "g.dnladder", 1);
sfo_stairway(nhfp, &g.sstairs, "lev", "g.sstairs", 1);
sfo_dest_area(nhfp, &g.updest, "lev", "g.updest", 1);
sfo_dest_area(nhfp, &g.dndest, "lev", "g.dndest", 1);
sfo_levelflags(nhfp, &g.level.flags, "lev", "g.level.flags", 1);
for (i = 0; i < DOORMAX; ++i)
sfo_nhcoord(nhfp, &g.doors[i], "lev", "door", 1);
}
save_rooms(nhfp); /* no dynamic memory to reclaim */
/* from here on out, saving also involves allocated memory cleanup */
@@ -719,10 +641,6 @@ boolean rlecomp;
bwrite(nhfp->fd, (genericptr_t) &match, sizeof (uchar));
bwrite(nhfp->fd, (genericptr_t) rgrm, sizeof (struct rm));
}
if (nhfp->fieldlevel) {
sfo_uchar(nhfp, &match, "levl", "match", 1);
sfo_rm(nhfp, rgrm, "levl", "rgrm", 1);
}
/* start encoding again. we have at least 1 rm
in the next run, viz. this one. */
match = 1;
@@ -735,10 +653,6 @@ boolean rlecomp;
bwrite(nhfp->fd, (genericptr_t) &match, sizeof (uchar));
bwrite(nhfp->fd, (genericptr_t) rgrm, sizeof (struct rm));
}
if (nhfp->fieldlevel) {
sfo_uchar(nhfp, &match, "levl", "match", 1);
sfo_rm(nhfp, rgrm, "levl", "rgrm", 1);
}
}
return;
}
@@ -748,13 +662,6 @@ boolean rlecomp;
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) levl, sizeof levl);
}
if (nhfp->fieldlevel) {
int c, r;
for (c = 0; c < COLNO; ++c)
for (r = 0; r < ROWNO; ++r)
sfo_rm(nhfp, &g.level.locations[c][r], "room", "levl", 1);
}
}
/* used when saving a level and also when saving dungeon overview data */
@@ -770,8 +677,6 @@ struct cemetery **cemeteryaddr;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &flag, sizeof flag);
if (nhfp->fieldlevel)
sfo_int(nhfp, &flag, "cemetery", "cemetery_flag", 1);
}
nextbones = *cemeteryaddr;
while ((thisbones = nextbones) != 0) {
@@ -779,8 +684,6 @@ struct cemetery **cemeteryaddr;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) thisbones, sizeof *thisbones);
if (nhfp->fieldlevel)
sfo_cemetery(nhfp, thisbones, "cemetery", "cemetery", 1);
}
if (release_data(nhfp))
free((genericptr_t) thisbones);
@@ -802,15 +705,11 @@ NHFILE *nhfp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &xl, sizeof xl);
if (nhfp->fieldlevel)
sfo_unsigned(nhfp, &xl, "damage", "damage_count", 1);
}
while (xl--) {
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) damageptr, sizeof *damageptr);
if (nhfp->fieldlevel)
sfo_damage(nhfp, damageptr, "damage", "damage", 1);
}
tmp_dam = damageptr;
damageptr = damageptr->next;
@@ -833,22 +732,14 @@ struct obj *otmp;
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
bwrite(nhfp->fd, (genericptr_t) otmp, buflen);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &buflen, "obj", "obj_length", 1);
sfo_obj(nhfp, otmp, "obj", "obj", 1);
}
if (otmp->oextra) {
buflen = ONAME(otmp) ? (int) strlen(ONAME(otmp)) + 1 : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "obj", "oname_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ONAME(otmp), buflen);
if (nhfp->fieldlevel)
sfo_str(nhfp, ONAME(otmp), "obj", "oname", buflen);
}
/* defer to savemon() for this one */
if (OMONST(otmp)) {
@@ -856,43 +747,29 @@ struct obj *otmp;
} else {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &zerobuf, sizeof zerobuf);
if (nhfp->fieldlevel)
sfo_int(nhfp, &zerobuf, "obj", "omonst_length", 1);
}
buflen = OMID(otmp) ? (int) sizeof (unsigned) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "obj", "omid_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) OMID(otmp), buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "obj", "omid_length", 1);
}
/* TODO: post 3.6.x, get rid of this */
buflen = OLONG(otmp) ? (int) sizeof (long) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "obj", "olong_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) OLONG(otmp), buflen);
if (nhfp->fieldlevel)
sfo_long(nhfp, OLONG(otmp), "obj", "olong", 1);
}
buflen = OMAILCMD(otmp) ? (int) strlen(OMAILCMD(otmp)) + 1 : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "obj", "omailcmd_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) OMAILCMD(otmp), buflen);
if (nhfp->fieldlevel)
sfo_str(nhfp, OMAILCMD(otmp), "obj", "omailcmd", buflen);
}
}
}
@@ -943,8 +820,6 @@ register struct obj *otmp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &minusone, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &minusone, "obj", "obj_length", 1);
}
}
@@ -962,83 +837,53 @@ struct monst *mtmp;
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
bwrite(nhfp->fd, (genericptr_t) mtmp, buflen);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &buflen, "mon", "monst_length", 1);
sfo_monst(nhfp, mtmp, "mon", "monst", 1);
}
if (mtmp->mextra) {
buflen = MNAME(mtmp) ? (int) strlen(MNAME(mtmp)) + 1 : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "mname_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) MNAME(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_str(nhfp, MNAME(mtmp), "mon", "mname", buflen);
}
buflen = EGD(mtmp) ? (int) sizeof (struct egd) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "egd_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) EGD(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_egd(nhfp, EGD(mtmp), "mon", "egd", 1);
}
buflen = EPRI(mtmp) ? (int) sizeof (struct epri) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "epri_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) EPRI(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_epri(nhfp, EPRI(mtmp), "mon", "epri", 1);
}
buflen = ESHK(mtmp) ? (int) sizeof (struct eshk) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "eshk_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) ESHK(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_eshk(nhfp, ESHK(mtmp), "mon", "eshk", 1);
}
buflen = EMIN(mtmp) ? (int) sizeof (struct emin) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "emin_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) EMIN(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_emin(nhfp, EMIN(mtmp), "mon", "emin", 1);
}
buflen = EDOG(mtmp) ? (int) sizeof (struct edog) : 0;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &buflen, "mon", "edog_length", 1);
if (buflen > 0) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) EDOG(mtmp), buflen);
if (nhfp->fieldlevel)
sfo_edog(nhfp, EDOG(mtmp), "mon", "edog", 1);
}
/* mcorpsenm is inline int rather than pointer to something,
so doesn't need to be preceded by a length field */
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &MCORPSENM(mtmp), sizeof MCORPSENM(mtmp));
if (nhfp->fieldlevel)
sfo_int(nhfp, &MCORPSENM(mtmp), "mon", "mcorpsenm", 1);
}
}
@@ -1073,8 +918,6 @@ register struct monst *mtmp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &minusone, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &minusone, "mon", "monst_length", 1);
}
}
@@ -1092,8 +935,6 @@ register struct trap *trap;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) trap, sizeof *trap);
if (nhfp->fieldlevel)
sfo_trap(nhfp, trap, "trap", "trap", 1);
}
if (release_data(nhfp))
dealloc_trap(trap);
@@ -1102,8 +943,6 @@ register struct trap *trap;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &zerotrap, sizeof zerotrap);
if (nhfp->fieldlevel)
sfo_trap(nhfp, &zerotrap, "trap", "trap", 1);
}
}
@@ -1125,8 +964,6 @@ NHFILE *nhfp;
if (f1->fid >= 0 && perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) f1, sizeof *f1);
if (nhfp->fieldlevel)
sfo_fruit(nhfp, f1, "fruit", "fruit", 1);
}
if (release_data(nhfp))
dealloc_fruit(f1);
@@ -1135,8 +972,6 @@ NHFILE *nhfp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &zerofruit, sizeof zerofruit);
if (nhfp->fieldlevel)
sfo_fruit(nhfp, &zerofruit, "fruit", "terminator", 1);
}
if (release_data(nhfp))
g.ffruit = 0;
@@ -1156,16 +991,12 @@ NHFILE *nhfp;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &cnt, sizeof cnt);
if (nhfp->fieldlevel)
sfo_int(nhfp, &cnt, "levchn", "lev_count", 1);
}
for (tmplev = g.sp_levchn; tmplev; tmplev = tmplev2) {
tmplev2 = tmplev->next;
if (perform_bwrite(nhfp)) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) tmplev, sizeof *tmplev);
if (nhfp->fieldlevel)
sfo_s_level(nhfp, tmplev, "levchn", "s_level", 1);
}
if (release_data(nhfp))
free((genericptr_t) tmplev);
@@ -1187,10 +1018,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) g.plname, plsiztmp);
bufon(nhfp->fd);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &plsiztmp, "plname", "plname_size", 1);
sfo_str(nhfp, g.plname, "plname", "g.plname", plsiztmp);
}
return;
}
@@ -1218,16 +1045,10 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &msglen, sizeof msglen);
bwrite(nhfp->fd, (genericptr_t) msg, msglen);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &msglen, "msghistory", "msghistory_length", 1);
sfo_str(nhfp, msg, "msghistory", "msg", msglen);
}
++msgcount;
}
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &minusone, sizeof (int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &minusone, "msghistory", "msghistory_length", 1);
}
debugpline1("Stored %d messages into savefile.", msgcount);
/* note: we don't attempt to handle release_data() here */
@@ -1254,9 +1075,6 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &sfsaveinfo, (unsigned) sizeof sfsaveinfo);
bufon(nhfp->fd);
}
if (nhfp->fieldlevel) {
sfo_savefile_info(nhfp, &sfsaveinfo, "savefileinfo", "savefile_info", 1);
}
return;
}
-1233
View File
File diff suppressed because it is too large Load Diff
-646
View File
@@ -1,646 +0,0 @@
/* NetHack 3.7 sf_base.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* Copyright (c) Michael Allison, 2019. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "integer.h"
#include "sfprocs.h"
struct sf_procs sfoprocs[4], sfiprocs[4],
zerosfoprocs = {0}, zerosfiprocs = {0};
void FDECL(sfi_log, (NHFILE *, const char *, const char *, const char *, int));
/*
*----------------------------------------------------------------------------
* initialize the function pointers. These are called from initoptions_init().
*----------------------------------------------------------------------------
*/
void
sf_init()
{
sfoprocs[invalid] = zerosfoprocs;
sfiprocs[invalid] = zerosfiprocs;
sfoprocs[historical] = zerosfoprocs;
sfiprocs[historical] = zerosfiprocs;
sfoprocs[lendian] = lendian_sfo_procs;
sfiprocs[lendian] = lendian_sfi_procs;
sfoprocs[ascii] = ascii_sfo_procs;
sfiprocs[ascii] = ascii_sfi_procs;
}
/*
*----------------------------------------
* routines called from engine core and
* from functions in generated sfdata.c
*----------------------------------------
*/
void
sfo_any(nhfp, d_any, myparent, myname, cnt)
NHFILE *nhfp;
union any *d_any;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_any)(nhfp, d_any, myparent, myname, cnt);
}
void
sfo_aligntyp(nhfp, d_aligntyp, myparent, myname, cnt)
NHFILE *nhfp;
aligntyp *d_aligntyp;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_aligntyp)(nhfp, d_aligntyp, myparent, myname, cnt);
}
void
sfo_bitfield(nhfp, d_bitfield, myparent, myname, cnt)
NHFILE *nhfp;
uint8_t *d_bitfield;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_bitfield)(nhfp, d_bitfield, myparent, myname, cnt);
}
void
sfo_boolean(nhfp, d_boolean, myparent, myname, cnt)
NHFILE *nhfp;
boolean *d_boolean;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_boolean)(nhfp, d_boolean, myparent, myname, cnt);
}
void
sfo_char(nhfp, d_char, myparent, myname, cnt)
NHFILE *nhfp;
char *d_char;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_char)(nhfp, d_char, myparent, myname, cnt);
}
void
sfo_genericptr(nhfp, d_genericptr, myparent, myname, cnt)
NHFILE *nhfp;
genericptr_t d_genericptr;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_genericptr)(nhfp, d_genericptr, myparent, myname, cnt);
}
void
sfo_int(nhfp, d_int, myparent, myname, cnt)
NHFILE *nhfp;
int *d_int;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_int)(nhfp, d_int, myparent, myname, cnt);
}
void
sfo_long(nhfp, d_long, myparent, myname, cnt)
NHFILE *nhfp;
long *d_long;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_long)(nhfp, d_long, myparent, myname, cnt);
}
void
sfo_schar(nhfp, d_schar, myparent, myname, cnt)
NHFILE *nhfp;
schar *d_schar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_schar)(nhfp, d_schar, myparent, myname, cnt);
}
void
sfo_short(nhfp, d_short, myparent, myname, cnt)
NHFILE *nhfp;
short *d_short;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_short)(nhfp, d_short, myparent, myname, cnt);
}
void
sfo_size_t(nhfp, d_size_t, myparent, myname, cnt)
NHFILE *nhfp;
size_t *d_size_t;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_size_t)(nhfp, d_size_t, myparent, myname, cnt);
}
void
sfo_time_t(nhfp, d_time_t, myparent, myname, cnt)
NHFILE *nhfp;
time_t *d_time_t;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_time_t)(nhfp, d_time_t, myparent, myname, cnt);
}
void
sfo_unsigned(nhfp, d_unsigned, myparent, myname, cnt)
NHFILE *nhfp;
unsigned *d_unsigned;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_unsigned)(nhfp, d_unsigned, myparent, myname, cnt);
}
void
sfo_uchar(nhfp, d_uchar, myparent, myname, cnt)
NHFILE *nhfp;
unsigned char *d_uchar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_uchar)(nhfp, d_uchar, myparent, myname, cnt);
}
void
sfo_uint(nhfp, d_uint, myparent, myname, cnt)
NHFILE *nhfp;
unsigned int *d_uint;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_uint)(nhfp, d_uint, myparent, myname, cnt);
}
void
sfo_ulong(nhfp, d_ulong, myparent, myname, cnt)
NHFILE *nhfp;
unsigned long *d_ulong;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_ulong)(nhfp, d_ulong, myparent, myname, cnt);
}
void
sfo_ushort(nhfp, d_ushort, myparent, myname, cnt)
NHFILE *nhfp;
unsigned short *d_ushort;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_ushort)(nhfp, d_ushort, myparent, myname, cnt);
}
void
sfo_xchar(nhfp, d_xchar, myparent, myname, cnt)
NHFILE *nhfp;
xchar *d_xchar;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_xchar)(nhfp, d_xchar, myparent, myname, cnt);
}
void
sfo_str(nhfp, d_str, myparent, myname, cnt)
NHFILE *nhfp;
char *d_str;
const char *myparent;
const char *myname;
int cnt;
{
(*sfoprocs[nhfp->fnidx].fn.sf_str)(nhfp, d_str, myparent, myname, cnt);
}
void
sfo_addinfo(nhfp, parent, action, myname, index)
NHFILE *nhfp;
const char *parent, *action, *myname;
int index;
{
(*sfoprocs[nhfp->fnidx].fn.sf_addinfo)(nhfp, parent, action, myname, index);
}
/*
*----------------------------------------------------------------------------
* routines called from core and from functions in generated sfi_data.c
*----------------------------------------------------------------------------
*/
void
sfi_any(nhfp, d_any, myparent, myname, cnt)
NHFILE *nhfp;
union any *d_any;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "any";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_any)(nhfp, d_any, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%ld)\n", d_any->a_long);
#endif
}
void
sfi_aligntyp(nhfp, d_aligntyp, myparent, myname, cnt)
NHFILE *nhfp;
aligntyp *d_aligntyp;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "aligntyp";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_aligntyp)(nhfp, d_aligntyp, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%d)\n", *d_aligntyp);
#endif
}
void
sfi_bitfield(nhfp, d_bitfield, myparent, myname, cnt)
NHFILE *nhfp;
uint8_t *d_bitfield;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "bitfield";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_bitfield)(nhfp, d_bitfield, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", *d_bitfield);
#endif
}
void
sfi_boolean(nhfp, d_boolean, myparent, myname, cnt)
NHFILE *nhfp;
boolean *d_boolean;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "boolean";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_boolean)(nhfp, d_boolean, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", (*d_boolean) ? "true" : "false");
#endif
}
void
sfi_char(nhfp, d_char, myparent, myname, cnt)
NHFILE *nhfp;
char *d_char;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "char";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_char)(nhfp, d_char, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", d_char ? d_char : "");
#endif
}
void
sfi_genericptr(nhfp, d_genericptr, myparent, myname, cnt)
NHFILE *nhfp;
genericptr_t d_genericptr;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "genericptr";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_genericptr)(nhfp, d_genericptr, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", (d_genericptr) ? "set" : "null");
#endif
}
void
sfi_int(nhfp, d_int, myparent, myname, cnt)
NHFILE *nhfp;
int *d_int;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "int";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_int)(nhfp, d_int, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%d)\n", *d_int);
#endif
}
void
sfi_long(nhfp, d_long, myparent, myname, cnt)
NHFILE *nhfp;
long *d_long;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "long";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_long)(nhfp, d_long, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%ld)\n", *d_long);
#endif
}
void
sfi_schar(nhfp, d_schar, myparent, myname, cnt)
NHFILE *nhfp;
schar *d_schar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "schar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_schar)(nhfp, d_schar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", (short) *d_schar);
#endif
}
void
sfi_short(nhfp, d_short, myparent, myname, cnt)
NHFILE *nhfp;
short *d_short;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "short";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_short)(nhfp, d_short, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", *d_short);
#endif
}
void
sfi_size_t(nhfp, d_size_t, myparent, myname, cnt)
NHFILE *nhfp;
size_t *d_size_t;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "size_t";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_size_t)(nhfp, d_size_t, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%lu)\n", (unsigned long) *d_size_t);
#endif
}
void
sfi_time_t(nhfp, d_time_t, myparent, myname, cnt)
NHFILE *nhfp;
time_t *d_time_t;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "time_t";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_time_t)(nhfp, d_time_t, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%s)\n", yyyymmddhhmmss(*d_time_t));
#endif
}
void
sfi_unsigned(nhfp, d_unsigned, myparent, myname, cnt)
NHFILE *nhfp;
unsigned *d_unsigned;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "unsigned";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_unsigned)(nhfp, d_unsigned, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%u)\n", *d_unsigned);
#endif
}
void
sfi_uchar(nhfp, d_uchar, myparent, myname, cnt)
NHFILE *nhfp;
unsigned char *d_uchar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "uchar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_uchar)(nhfp, d_uchar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hu)\n", (unsigned short) *d_uchar);
#endif
}
void
sfi_uint(nhfp, d_uint, myparent, myname, cnt)
NHFILE *nhfp;
unsigned int *d_uint;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "uint";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_uint)(nhfp, d_uint, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%u)\n", *d_uint);
#endif
}
void
sfi_ulong(nhfp, d_ulong, myparent, myname, cnt)
NHFILE *nhfp;
unsigned long *d_ulong;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "ulong";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_ulong)(nhfp, d_ulong, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%lu)\n", *d_ulong);
#endif
}
void
sfi_ushort(nhfp, d_ushort, myparent, myname, cnt)
NHFILE *nhfp;
unsigned short *d_ushort;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "ushort";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_ushort)(nhfp, d_ushort, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hu)\n", *d_ushort);
#endif
}
void
sfi_xchar(nhfp, d_xchar, myparent, myname, cnt)
NHFILE *nhfp;
xchar *d_xchar;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "xchar";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_xchar)(nhfp, d_xchar, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(%hd)\n", (short) *d_xchar);
#endif
}
void
sfi_str(nhfp, d_str, myparent, myname, cnt)
NHFILE *nhfp;
char *d_str;
const char *myparent;
const char *myname;
int cnt;
{
const char *parent = "str";
sfi_log(nhfp, myparent, myname, parent, cnt);
(*sfiprocs[nhfp->fnidx].fn.sf_str)(nhfp, d_str, myparent, myname, cnt);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
fprintf(nhfp->fpdebug, "(\"%s\")\n", d_str);
#endif
}
void
sfi_addinfo(nhfp, myparent, action, myname, index)
NHFILE *nhfp;
const char *myparent, *action, *myname;
int index;
{
if (nhfp) {
if (nhfp->fplog)
(void) fprintf(nhfp->fplog, "# %s %s %s %d\n", myparent, action, myname, index);
#ifdef DO_DEBUG
if (nhfp->fpdebug)
(void) fprintf(nhfp->fpdebug, "# %s %s %s %d\n", myparent, action, myname, index);
#endif
}
(*sfiprocs[nhfp->fnidx].fn.sf_addinfo)(nhfp, myparent, action, myname, index);
}
void
sfi_log(nhfp, t1, t2, t3, cnt)
NHFILE *nhfp;
const char *t1, *t2, *t3;
int cnt;
{
#ifdef DO_DEBUG
#ifdef SAVEFILE_DEBUGGING
if (nhfp) {
if (nhfp->fplog)
(void) fprintf(nhfp->fplog, "%s %s %s cnt=%d\n", t1, t2, t3, cnt);
if (nhfp->fpdebug)
(void) fprintf(nhfp->fpdebug, "%s %s %s cnt=%d ", t1, t2, t3, cnt);
}
#endif
#else
nhUse(nhfp);
nhUse(t1);
nhUse(t2);
nhUse(t3);
nhUse(cnt);
#endif
}
-6052
View File
File diff suppressed because it is too large Load Diff
-1339
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -2655,6 +2655,7 @@ lua_State *L;
tmpobj.recharged = 0;
tmpobj.greased = 0;
tmpobj.broken = 0;
tmpobj.containment = 0;
if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) {
const char *paramstr = luaL_checkstring(L, 1);
+7 -2
View File
@@ -260,8 +260,13 @@ teleok(x, y, trapok)
register int x, y;
boolean trapok;
{
if (!trapok && t_at(x, y))
return FALSE;
if (!trapok) {
/* allow teleportation onto vibrating square, it's not a real trap */
struct trap *trap = t_at(x, y);
if (trap && trap->ttyp != VIBRATING_SQUARE) {
return FALSE;
}
}
if (!goodpos(x, y, &g.youmonst, 0))
return FALSE;
if (!tele_jump_ok(u.ux, u.uy, x, y))
-22
View File
@@ -5,8 +5,6 @@
#include "hack.h"
#include "lev.h" /* for checking save modes */
#include "sfproto.h"
static void NDECL(stoned_dialogue);
static void NDECL(vomiting_dialogue);
@@ -2165,16 +2163,12 @@ timer_element *timer;
/* assume no pointers in arg */
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
break;
case TIMER_OBJECT:
if (timer->needs_fixup) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
} else {
/* replace object pointer with id */
arg_save.a_obj = timer->arg.a_obj;
@@ -2183,8 +2177,6 @@ timer_element *timer;
timer->needs_fixup = 1;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
timer->arg.a_obj = arg_save.a_obj;
timer->needs_fixup = 0;
}
@@ -2194,8 +2186,6 @@ timer_element *timer;
if (timer->needs_fixup) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
} else {
/* replace monster pointer with id */
arg_save.a_monst = timer->arg.a_monst;
@@ -2204,8 +2194,6 @@ timer_element *timer;
timer->needs_fixup = 1;
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t)timer, sizeof(timer_element));
if (nhfp->fieldlevel)
sfo_fe(nhfp, timer, "timers", "timer", 1);
timer->arg.a_monst = arg_save.a_monst;
timer->needs_fixup = 0;
}
@@ -2343,14 +2331,10 @@ int range;
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &g.timer_id, sizeof(g.timer_id));
if (nhfp->fieldlevel)
sfo_ulong(nhfp, &g.timer_id, "timers", "g.timer_id", 1);
}
count = maybe_write_timer(nhfp, range, FALSE);
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "timers", "timer_count", 1);
(void) maybe_write_timer(nhfp, range, TRUE);
}
@@ -2389,22 +2373,16 @@ long adjust; /* how much to adjust timeout */
if (range == RANGE_GLOBAL) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &g.timer_id, sizeof g.timer_id);
if (nhfp->fieldlevel)
sfi_ulong(nhfp, &g.timer_id, "timers", "g.timer_id", 1);
}
/* restore elements */
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof count);
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "timers", "timer_count", 1);
while (count-- > 0) {
curr = (timer_element *) alloc(sizeof(timer_element));
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) curr, sizeof(timer_element));
if (nhfp->fieldlevel)
sfi_fe(nhfp, curr, "timers", "timer", 1);
if (ghostly)
curr->timeout += adjust;
insert_timer(curr);
+7 -33
View File
@@ -7,7 +7,6 @@
#include "dlb.h"
#include "date.h"
#include "lev.h"
#include "sfproto.h"
/*
* All the references to the contents of patchlevel.h have been moved
@@ -399,26 +398,17 @@ unsigned long utdflags;
if (rlen == 0)
return FALSE;
}
if (nhfp->fieldlevel) {
sfi_char(nhfp, &indicator, "indicate", "format", 1);
sfi_int(nhfp, &filecmc, "validate", "critical_members_count", 1);
cmc = critical_members_count();
}
if (cmc != filecmc)
return FALSE;
if (nhfp->fieldlevel && (nhfp->fnidx > historical)) {
sfi_version_info(nhfp, &vers_info, "version", "version_info", 1);
} else {
rlen = read(nhfp->fd, (genericptr_t) &vers_info, sizeof vers_info);
minit(); /* ZEROCOMP */
if (rlen == 0) {
if (verbose) {
pline("File \"%s\" is empty?", name);
wait_synch();
}
return FALSE;
rlen = read(nhfp->fd, (genericptr_t) &vers_info, sizeof vers_info);
minit(); /* ZEROCOMP */
if (rlen == 0) {
if (verbose) {
pline("File \"%s\" is empty?", name);
wait_synch();
}
return FALSE;
}
if (!check_version(&vers_info, name, verbose, utdflags)) {
@@ -437,17 +427,6 @@ NHFILE *nhfp;
int cmc = 0;
if (nhfp->mode & WRITING) {
if (nhfp->fieldlevel) {
indicate = (nhfp->fnidx == ascii) ? 'a' : 'l';
sfo_char(nhfp, &indicate, "indicate", "format", 1);
cmc = critical_members_count();
{
#if 0
pline("critical-members=%d.", cmc);
#endif
}
sfo_int(nhfp, &cmc, "validate", "critical_members_count", 1);
}
if (nhfp->structlevel) {
indicate = 'h'; /* historical */
bwrite(nhfp->fd, (genericptr_t) &indicate, sizeof indicate);
@@ -485,11 +464,6 @@ NHFILE *nhfp;
(unsigned) (sizeof version_data));
bufon(nhfp->fd);
}
if (nhfp->fieldlevel) {
store_formatindicator(nhfp);
sfo_version_info(nhfp, (struct version_info *) &version_data,
"version", "version_info", 1);
}
return;
}
-22
View File
@@ -5,8 +5,6 @@
#include "hack.h"
#include "lev.h"
#include "sfproto.h"
#define newseg() (struct wseg *) alloc(sizeof (struct wseg))
#define dealloc_seg(wseg) free((genericptr_t) (wseg))
@@ -493,8 +491,6 @@ NHFILE *nhfp;
/* Save number of segments */
if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &count, sizeof(int));
if (nhfp->fieldlevel)
sfo_int(nhfp, &count, "worm", "segment_count", 1);
/* Save segment locations of the monster. */
if (count) {
for (curr = wtails[i]; curr; curr = curr->nseg) {
@@ -502,20 +498,12 @@ NHFILE *nhfp;
bwrite(nhfp->fd, (genericptr_t) &(curr->wx), sizeof(xchar));
bwrite(nhfp->fd, (genericptr_t) &(curr->wy), sizeof(xchar));
}
if (nhfp->fieldlevel) {
sfo_xchar(nhfp, &(curr->wx), "worm", "wx", 1);
sfo_xchar(nhfp, &(curr->wy), "worm", "wy", 1);
}
}
}
}
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAX_NUM_WORMS; ++i)
sfo_long(nhfp, &wgrowtime[i], "worm", "wgrowtime", 1);
}
}
if (release_data(nhfp)) {
@@ -550,8 +538,6 @@ NHFILE *nhfp;
for (i = 1; i < MAX_NUM_WORMS; i++) {
if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &count, sizeof(int));
if (nhfp->fieldlevel)
sfi_int(nhfp, &count, "worm", "segment_count", 1);
/* Get the segments. */
for (curr = (struct wseg *) 0, j = 0; j < count; j++) {
@@ -561,10 +547,6 @@ NHFILE *nhfp;
mread(nhfp->fd, (genericptr_t) &(temp->wx), sizeof(xchar));
mread(nhfp->fd, (genericptr_t) &(temp->wy), sizeof(xchar));
}
if (nhfp->fieldlevel) {
sfi_xchar(nhfp, &(temp->wx), "worm", "wx", 1);
sfi_xchar(nhfp, &(temp->wy), "worm", "wy", 1);
}
if (curr)
curr->nseg = temp;
else
@@ -576,10 +558,6 @@ NHFILE *nhfp;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) wgrowtime, sizeof(wgrowtime));
}
if (nhfp->fieldlevel) {
for (i = 0; i < MAX_NUM_WORMS; ++i)
sfi_long(nhfp, &wgrowtime[i], "worm", "wgrowtime", 1);
}
}
/*