main() reorganization (trunk only)

Move some internals-related code out of port-specific main so that
it isn't duplicated a bunch of times.  One minor side-effect of this
change is that if you auto-pickup something at the very start of a game,
it will happen after any full moon/new moon/Friday 13th message rather
than before.  There's a second change for some:  the shared main() used
by several of the micro ports had a small difference in game play--if you
saved a game while on an engraving, it would automatically be read when
you resume--that will now occur for everybody [Elbereth weenies rejoice!].
pcmain() was also calling update_inventory() at start of play.  That's
unnecessary for new games, where inventory initialization triggers a call
to it for each item added to your pack; but I wasn't sure about restored
games, so everybody gets it there now.

     The Mac and BeOS ports evidently haven't been touched it some time;
they still referenced flags.move which got replaced by context.move quite
a while back.  The Windows GUI code has a declaration for mswin_moveloop()
which appears to be non-existant, but I left it alone.  I assume that the
Qt interface uses the existing main() routines; at least I couldn't find
any start of game code specific to it.  vmsmain's revised main() is the
only one which has been tested.
This commit is contained in:
nethack.rankin
2006-04-02 07:35:30 +00:00
parent 8ed2748d52
commit 2c0a072ef1
9 changed files with 94 additions and 108 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)allmain.c 3.5 2003/04/02 */
/* SCCS Id: @(#)allmain.c 3.5 2006/04/01 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -15,7 +15,8 @@ STATIC_DCL void NDECL(do_positionbar);
#endif
void
moveloop()
moveloop(resuming)
boolean resuming;
{
#if defined(MICRO) || defined(WIN32)
char ch;
@@ -24,22 +25,6 @@ moveloop()
int moveamt = 0, wtcap = 0, change = 0;
boolean didmove = FALSE, monscanmove = FALSE;
flags.moonphase = phase_of_the_moon();
if(flags.moonphase == FULL_MOON) {
You("are lucky! Full moon tonight.");
change_luck(1);
} else if(flags.moonphase == NEW_MOON) {
pline("Be careful! New moon tonight.");
}
flags.friday13 = friday_13th();
if (flags.friday13) {
pline("Watch out! Bad things can happen on Friday the 13th.");
change_luck(-1);
}
initrack();
/* Note: these initializers don't do anything except guarantee that
we're linked properly.
*/
@@ -52,14 +37,38 @@ moveloop()
if (wizard) add_debug_extended_commands();
#endif
/* side-effects from the real world */
flags.moonphase = phase_of_the_moon();
if(flags.moonphase == FULL_MOON) {
You("are lucky! Full moon tonight.");
change_luck(1);
} else if(flags.moonphase == NEW_MOON) {
pline("Be careful! New moon tonight.");
}
flags.friday13 = friday_13th();
if (flags.friday13) {
pline("Watch out! Bad things can happen on Friday the 13th.");
change_luck(-1);
}
if (!resuming) { /* new game */
set_wear(); /* handle side-effects of worn starting gear */
(void) pickup(1); /* autopickup at initial location */
} else {
update_inventory(); /* for perm_invent */
read_engr_at(u.ux, u.uy); /* subset of pickup() */
}
(void) encumber_msg(); /* in case they auto-picked up something */
if (defer_see_monsters) {
defer_see_monsters = FALSE;
see_monsters();
}
initrack();
u.uz0.dlevel = u.uz.dlevel;
youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */
context.move = 0;
for(;;) {
get_nh_event();