Improve slightly on Peje's L12 patch, changing documentation to match.
This commit is contained in:
parent
804e60ccff
commit
3bdab31a0d
3 changed files with 100 additions and 90 deletions
4
TODO
4
TODO
|
@ -7,9 +7,7 @@ remain to be cleaned up:
|
||||||
rather promiscuously to pass around information that ought to be function
|
rather promiscuously to pass around information that ought to be function
|
||||||
arguments in a modern language.
|
arguments in a modern language.
|
||||||
|
|
||||||
* Remaining unstructured gotos in playermove() and do_command(). The goto L12
|
* Remaining unstructured gotos in do_command().
|
||||||
in playermove() is particularly horrible, jumping backwards into the
|
|
||||||
middle of a loop.
|
|
||||||
|
|
||||||
* The program is still pretty much typeless - full of magic numbers being
|
* The program is still pretty much typeless - full of magic numbers being
|
||||||
sliced and diced in cryptic ways. Some attempt has been made to introduce
|
sliced and diced in cryptic ways. Some attempt has been made to introduce
|
||||||
|
|
16
main.c
16
main.c
|
@ -399,6 +399,10 @@ static bool dwarfmove(void)
|
||||||
game.dloc[PIRATE]=game.chloc;
|
game.dloc[PIRATE]=game.chloc;
|
||||||
game.odloc[PIRATE]=game.chloc;
|
game.odloc[PIRATE]=game.chloc;
|
||||||
game.dseen[PIRATE]=false;
|
game.dseen[PIRATE]=false;
|
||||||
|
/* C doesn't have what the Structured rogramming
|
||||||
|
* Theorem says we need here - multi-level loop
|
||||||
|
* breakout. We simulate with a goto. Irreducible, alas.
|
||||||
|
*/
|
||||||
goto jumpout;
|
goto jumpout;
|
||||||
}
|
}
|
||||||
if (HERE(j))
|
if (HERE(j))
|
||||||
|
@ -606,7 +610,13 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
||||||
}
|
}
|
||||||
LL=LL/1000;
|
LL=LL/1000;
|
||||||
|
|
||||||
L12:
|
do {
|
||||||
|
/*
|
||||||
|
* (ESR) This special-travel loop may have to be repeated if it includes
|
||||||
|
* the plover passage. Same deal for any future cases wgerw we beed to
|
||||||
|
* block travel and then redo it once the blocking condition has been
|
||||||
|
* removed.
|
||||||
|
*/
|
||||||
for (;;) {
|
for (;;) {
|
||||||
game.newloc=LL/1000;
|
game.newloc=LL/1000;
|
||||||
motion=MOD(game.newloc,100);
|
motion=MOD(game.newloc,100);
|
||||||
|
@ -660,7 +670,7 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
||||||
game.newloc=labs(TRAVEL[KK])/1000;
|
game.newloc=labs(TRAVEL[KK])/1000;
|
||||||
} while
|
} while
|
||||||
(game.newloc == LL);
|
(game.newloc == LL);
|
||||||
goto L12;
|
continue; /* back to top of do/while loop */
|
||||||
case 3:
|
case 3:
|
||||||
/* Travel 303. Troll bridge. Must be done only as special
|
/* Travel 303. Troll bridge. Must be done only as special
|
||||||
* motion so that dwarves won't wander across and encounter
|
* motion so that dwarves won't wander across and encounter
|
||||||
|
@ -696,6 +706,8 @@ static bool playermove(FILE *cmdin, token_t verb, int motion)
|
||||||
}
|
}
|
||||||
BUG(20);
|
BUG(20);
|
||||||
}
|
}
|
||||||
|
} while
|
||||||
|
(false);
|
||||||
RSPEAK(game.newloc-500);
|
RSPEAK(game.newloc-500);
|
||||||
game.newloc=game.loc;
|
game.newloc=game.loc;
|
||||||
return true;
|
return true;
|
||||||
|
|
10
notes.adoc
10
notes.adoc
|
@ -81,7 +81,7 @@ against a comprehesive test suite that we built first and verified with
|
||||||
coverage tools. This is what you are running when you do "make check".
|
coverage tools. This is what you are running when you do "make check".
|
||||||
|
|
||||||
This move entailed some structural changes. The most important was
|
This move entailed some structural changes. The most important was
|
||||||
the refactoring of 354 gotos into if/loop/break structures. We
|
the refactoring of 355 gotos into if/loop/break structures. We
|
||||||
also abolished almost all shared globals; the main one left is a
|
also abolished almost all shared globals; the main one left is a
|
||||||
struct holding the game's saveable/restorable state.
|
struct holding the game's saveable/restorable state.
|
||||||
|
|
||||||
|
@ -108,10 +108,10 @@ ways:
|
||||||
and the choice to refrain will make forward translation into future
|
and the choice to refrain will make forward translation into future
|
||||||
languages easier.
|
languages easier.
|
||||||
|
|
||||||
* There are 20 gotos left that resist restructuring; all but one of
|
* There are 19 gotos left that resist restructuring; all of these are
|
||||||
these are in the principal command interpreter function implementing
|
in the principal command interpreter function implementing its state
|
||||||
its state machine. A 21st, a two-level loop breakout, is not reducible
|
machine. A 21st, a two-level loop breakout, is not reducible even
|
||||||
even in principle.
|
in principle.
|
||||||
|
|
||||||
* Linked lists (for objects at a location) are implemented using an array
|
* Linked lists (for objects at a location) are implemented using an array
|
||||||
of link indices. This is a surviving FORTRANism that is quite unlike
|
of link indices. This is a surviving FORTRANism that is quite unlike
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue