Continuing cleanup of misc.c.

This commit is contained in:
Eric S. Raymond 2017-06-07 16:39:59 -04:00
parent 1d3a087c39
commit beac8d7f41

84
misc.c
View file

@ -306,8 +306,6 @@ long ALPH1, ALPH2, BYTE, DIV, I, W;
* as is. any other value for case is the same as 0 but also causes * as is. any other value for case is the same as 0 but also causes
* trailing blanks to be included (in anticipation of subsequent * trailing blanks to be included (in anticipation of subsequent
* additional text). */ * additional text). */
ALPH1=13*CASE+24; ALPH1=13*CASE+24;
ALPH2=26*labs(CASE)+ALPH1; ALPH2=26*labs(CASE)+ALPH1;
if(labs(CASE) > 1)ALPH1=ALPH2; if(labs(CASE) > 1)ALPH1=ALPH2;
@ -488,73 +486,68 @@ L3: LEXEME=KTAB[I];
return(LEXEME); return(LEXEME);
} }
void DSTROY(long OBJECT) { void DSTROY(long object)
/* Permanently eliminate "OBJECT" by moving to a non-existent location. */ /* Permanently eliminate "object" by moving to a non-existent location. */
{
MOVE(OBJECT,0); MOVE(object,0);
return;
} }
void JUGGLE(long OBJECT) { void JUGGLE(long object)
long I, J;
/* Juggle an object by picking it up and putting it down again, the purpose /* Juggle an object by picking it up and putting it down again, the purpose
* being to get the object to the front of the chain of things at its loc. */ * being to get the object to the front of the chain of things at its loc. */
{
long i, j;
I=game.place[OBJECT]; i=game.place[object];
J=game.fixed[OBJECT]; j=game.fixed[object];
MOVE(OBJECT,I); MOVE(object,i);
MOVE(OBJECT+NOBJECTS,J); MOVE(object+NOBJECTS,j);
return;
} }
void MOVE(long OBJECT, long WHERE) { void MOVE(long object, long where)
long FROM; /* Place any object anywhere by picking it up and dropping it. May
* already be toting, in which case the carry is a no-op. Mustn't
* pick up objects which are not at any loc, since carry wants to
* remove objects from game.atloc chains. */
{
long from;
/* Place any object anywhere by picking it up and dropping it. May already be if(object > NOBJECTS) goto L1;
* toting, in which case the carry is a no-op. Mustn't pick up objects which from=game.place[object];
* are not at any loc, since carry wants to remove objects from game.atloc chains. */
if(OBJECT > NOBJECTS) goto L1;
FROM=game.place[OBJECT];
goto L2; goto L2;
L1: {long x = OBJECT-NOBJECTS; FROM=game.fixed[x];} L1: from=game.fixed[object-NOBJECTS];
L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM); L2: if(from > 0 && from <= 300)
DROP(OBJECT,WHERE); CARRY(object,from);
return; DROP(object,where);
} }
long PUT(long OBJECT, long WHERE, long PVAL) { long PUT(long object, long where, long pval)
long X;
/* PUT is the same as MOVE, except it returns a value used to set up the /* PUT is the same as MOVE, except it returns a value used to set up the
* negated game.prop values for the repository objects. */ * negated game.prop values for the repository objects. */
{
MOVE(OBJECT,WHERE); MOVE(object,where);
X=(-1)-PVAL; return (-1)-pval;;
return(X);
} }
void CARRY(long OBJECT, long WHERE) { void CARRY(long object, long where) {
long TEMP; long TEMP;
/* Start toting an object, removing it from the list of things at its former /* Start toting an object, removing it from the list of things at its former
* location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS * location. Incr holdng unless it was already being toted. If object>NOBJECTS
* (moving "fixed" second loc), don't change game.place or game.holdng. */ * (moving "fixed" second loc), don't change game.place or game.holdng. */
if(OBJECT > NOBJECTS) goto L5; if(object > NOBJECTS) goto L5;
if(game.place[OBJECT] == -1)return; if(game.place[object] == -1)return;
game.place[OBJECT]= -1; game.place[object]= -1;
game.holdng=game.holdng+1; game.holdng=game.holdng+1;
L5: if(game.atloc[WHERE] != OBJECT) goto L6; L5: if(game.atloc[where] != object) goto L6;
game.atloc[WHERE]=game.link[OBJECT]; game.atloc[where]=game.link[object];
return; return;
L6: TEMP=game.atloc[WHERE]; L6: TEMP=game.atloc[where];
L7: if(game.link[TEMP] == OBJECT) goto L8; L7: if(game.link[TEMP] == object) goto L8;
TEMP=game.link[TEMP]; TEMP=game.link[TEMP];
goto L7; goto L7;
L8: game.link[TEMP]=game.link[OBJECT]; L8: game.link[TEMP]=game.link[object];
return; return;
} }
@ -830,7 +823,6 @@ L20: printf("\nFile name: ");
L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F)); L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F));
if(!IN)fwrite(ARR,sizeof(long),250,F); if(!IN)fwrite(ARR,sizeof(long),250,F);
return; return;
} }
void DATIME(long* D, long* T) void DATIME(long* D, long* T)