projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typo in COPYING.
[open-adventure.git]
/
misc.c
diff --git
a/misc.c
b/misc.c
index 111848e1d5231eb7a9d00b59f3b9dfe4485e9bc4..3aca465d0d5bd960095249db46e98449018057f2 100644
(file)
--- a/
misc.c
+++ b/
misc.c
@@
-2,6
+2,7
@@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/time.h>
#include "main.h"
#include "share.h" /* for SETUP */
#include "misc.h"
#include "main.h"
#include "share.h" /* for SETUP */
#include "misc.h"
@@
-777,31
+778,33
@@
long randrange(long range)
#undef RNDVOC
long fRNDVOC(long CHAR, long FORCE) {
#undef RNDVOC
long fRNDVOC(long CHAR, long FORCE) {
-long DIV, I, J, RNDVOC;
-
/* Searches the vocabulary for a word whose second character is char, and
* changes that word such that each of the other four characters is a
* random letter. If force is non-zero, it is used as the new word.
* Returns the new word. */
/* Searches the vocabulary for a word whose second character is char, and
* changes that word such that each of the other four characters is a
* random letter. If force is non-zero, it is used as the new word.
* Returns the new word. */
+ long RNDVOC;
RNDVOC=FORCE;
RNDVOC=FORCE;
- if(RNDVOC != 0) goto L3;
- for (I=1; I<=5; I++) {
- J=11+randrange(26);
- if(I == 2)J=CHAR;
- RNDVOC=RNDVOC*64+J;
- } /* end loop */
-L3: J=10000;
- DIV=64L*64L*64L;
- for (I=1; I<=TABSIZ; I++) {
- J=J+7;
- if(MOD((ATAB[I]-J*J)/DIV,64L) == CHAR) goto L8;
- /*etc*/ ;
- } /* end loop */
- BUG(5);
-L8: ATAB[I]=RNDVOC+J*J;
+ if (RNDVOC == 0) {
+ for (int I = 1; I <= 5; I++) {
+ long J = 11 + randrange(26);
+ if (I == 2)
+ J = CHAR;
+ RNDVOC = RNDVOC * 64 + J;
+ }
+ }
+
+ long DIV = 64L * 64L * 64L;
+ for (int I = 1; I <= TABSIZ; I++) {
+ if (MOD(ATAB[I]/DIV, 64L) == CHAR)
+ {
+ ATAB[I] = RNDVOC;
+ break;
+ }
+ }
+
return(RNDVOC);
}
return(RNDVOC);
}
@@
-895,7
+898,7
@@
long I, VAL;
IGNORE(fputs(rawbuf, stdout));
strcpy(INLINE+1, rawbuf);
LNLENG=0;
IGNORE(fputs(rawbuf, stdout));
strcpy(INLINE+1, rawbuf);
LNLENG=0;
- for (I=1; I<=sizeof(INLINE) && INLINE[I]!=0; I++) {
+ for (I=1; I<=
(long)
sizeof(INLINE) && INLINE[I]!=0; I++) {
VAL=INLINE[I]+1;
INLINE[I]=MAP1[VAL];
if(INLINE[I] != 0)LNLENG=I;
VAL=INLINE[I]+1;
INLINE[I]=MAP1[VAL];
if(INLINE[I] != 0)LNLENG=I;
@@
-934,7
+937,7
@@
L10: if(MAP2[1] == 0)MPINIT();
#undef MPINIT
void fMPINIT(void) {
long FIRST, I, J, LAST, VAL;
#undef MPINIT
void fMPINIT(void) {
long FIRST, I, J, LAST, VAL;
-static long RUNS[7][2] = {
32,34, 39,46, 65,90, 97,122, 37,37, 48,57, 0,126
};
+static long RUNS[7][2] = {
{32,34}, {39,46}, {65,90}, {97,122}, {37,37}, {48,57}, {0,126}
};
for (I=1; I<=128; I++) {
for (I=1; I<=128; I++) {
@@
-1002,5
+1005,11
@@
L30: if(IN)IGNORE(fread(ARR,sizeof(long),250,F));
+void DATIME(long* D, long* T) {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ *D = (long) tv.tv_sec;
+ *T = (long) tv.tv_usec;
+}
long fIABS(N)long N; {return(N<0? -N : N);}
long fMOD(N,M)long N, M; {return(N%M);}
long fIABS(N)long N; {return(N<0? -N : N);}
long fMOD(N,M)long N, M; {return(N%M);}