WIP: implementing hash tables for flagpiles. flag code done, need to wrap all walks of flagpiles with foreach_bucket()
This commit is contained in:
parent
10fd3bc440
commit
9fcbceb8c6
9
ai.c
9
ai.c
|
@ -3387,9 +3387,12 @@ int aispellok(lifeform_t *lf, enum OBTYPE spellid, lifeform_t *victim, enum FLAG
|
|||
}
|
||||
}
|
||||
if (ot->id == OT_S_WEAKEN) {
|
||||
flag_t *lff;
|
||||
for (lff = lf->flags->first; lff ; lff = lff->next) {
|
||||
if ((lff->id == F_ATTRMOD) && (lff->val[0] == A_STR) && (lff->obfrom == OT_S_WEAKEN)) {
|
||||
int nretflags,i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
|
||||
getflags(lf->flags, retflag, &nretflags, F_ATTRMOD, F_NONE);
|
||||
for (i=0; i< nretflags; i++) {
|
||||
if ((retflag[i]->id == F_ATTRMOD) && (retflag[i]->val[0] == A_STR) && (retflag[i]->obfrom == OT_S_WEAKEN)) {
|
||||
specificcheckok = B_FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
13
data.c
13
data.c
|
@ -46,13 +46,14 @@ extern objecttype_t *lastot;
|
|||
extern condset_t ccwalkable;
|
||||
|
||||
void addbonustext(flagpile_t *fp, enum FLAG fid, char *text) {
|
||||
int idx = -1;
|
||||
flag_t *f;
|
||||
int idx = -1, i;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags = 0;
|
||||
getflags(fp, retflag, &nretflags, fid, F_NONE);
|
||||
|
||||
// find last index
|
||||
for (f = fp->first ; f; f = f->next) {
|
||||
if (f->id == fid) {
|
||||
if (f->val[0] > idx) idx = f->val[0];
|
||||
}
|
||||
for (i=0; i< nretflags; i++) {
|
||||
if (retflag[i]->val[0] > idx) idx = retflag[i]->val[0];
|
||||
}
|
||||
addflag(fp, fid, idx+1, NA, NA, text);
|
||||
}
|
||||
|
|
6
defs.h
6
defs.h
|
@ -11,10 +11,14 @@
|
|||
#define OBNOS1(o) (o->amt == 1) ? "" : "s"
|
||||
|
||||
#define ISINRANGE(a,min,max) ((a >= min) && (a <= max))
|
||||
#define foreach_bucket(a) for (a=0; a<NHASHBUCKETS; a++)
|
||||
|
||||
// #define PRACTICETIME 15 // #attempts it takes to learn new weapon skill
|
||||
|
||||
|
||||
// for flags hashtable
|
||||
#define NHASHBUCKETS (5)
|
||||
|
||||
// how much your str/agi/etc goes up every few levels
|
||||
#define STATAMTPERLEVEL 5
|
||||
|
||||
|
@ -5313,7 +5317,7 @@ typedef struct obpile_s {
|
|||
typedef struct flagpile_s {
|
||||
lifeform_t *owner;
|
||||
struct object_s *ob;
|
||||
struct flag_s *first,*last;
|
||||
struct flag_s *first[NHASHBUCKETS],*last[NHASHBUCKETS];
|
||||
|
||||
struct flag_s *item[MAXFLAGS];
|
||||
int nitems;
|
||||
|
|
182
flag.c
182
flag.c
|
@ -59,6 +59,14 @@ flag_t *addtempflag(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
return addflag_real(fp, id, val1, val2, val3, text, timeleft, B_KNOWN, -1);
|
||||
}
|
||||
|
||||
int getflaghash(enum FLAG fid) {
|
||||
int h;
|
||||
h = (int) fid % NHASHBUCKETS;
|
||||
assert(h >= 0);
|
||||
assert(h < NHASHBUCKETS);
|
||||
return h;
|
||||
}
|
||||
|
||||
flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3, char *text, int lifetime, int known, long obfromid) {
|
||||
lifeform_t *lf;
|
||||
flag_t *f = NULL;
|
||||
|
@ -67,6 +75,7 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
int redrawstatatend = B_FALSE;
|
||||
int i;
|
||||
int rv;
|
||||
int hash;
|
||||
enum { NONE, FIRST, FIRST2, MIDDLE, LAST } fml = NONE;
|
||||
|
||||
checkflagpile(fp);
|
||||
|
@ -168,17 +177,21 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
*/
|
||||
//if (gamemode == GM_GAMESTARTED) checkmapflags(player->cell->map); // debugging
|
||||
|
||||
|
||||
// determine bucket
|
||||
hash = getflaghash(id);
|
||||
|
||||
////////////////////////////////
|
||||
// ACTUAL FLAG ADDITION IS HERE
|
||||
////////////////////////////////
|
||||
|
||||
if (fp->first == NULL) {
|
||||
fp->first = (flag_t *)calloc(1, sizeof(flag_t));
|
||||
f = fp->first;
|
||||
if (fp->first[hash] == NULL) {
|
||||
fp->first[hash] = (flag_t *)calloc(1, sizeof(flag_t));
|
||||
f = fp->first[hash];
|
||||
f->prev = NULL;
|
||||
|
||||
// also the last
|
||||
fp->last = f;
|
||||
fp->last[hash] = f;
|
||||
f->next = NULL;
|
||||
|
||||
fml = FIRST;
|
||||
|
@ -186,7 +199,7 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
flag_t *ff,*insertbefore = NULL,*insertafter = NULL;
|
||||
// we will keep flags sorted.
|
||||
// find correct position in list...
|
||||
ff = fp->first;
|
||||
ff = fp->first[hash];
|
||||
while (ff && (ff->id < id)) {
|
||||
ff = ff->next;
|
||||
}
|
||||
|
@ -223,8 +236,8 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
} else {
|
||||
// first one
|
||||
//fp->first = (flag_t *)calloc(1, sizeof(flag_t));
|
||||
fp->first = newone;
|
||||
assert(fp->first != NULL);
|
||||
fp->first[hash] = newone;
|
||||
assert(fp->first[hash] != NULL);
|
||||
//f = fp->first;
|
||||
f = newone;
|
||||
fml = FIRST2;
|
||||
|
@ -238,11 +251,11 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
ff->prev = f;
|
||||
} else {
|
||||
// last one. insert at end of list.
|
||||
f = fp->last;
|
||||
f = fp->last[hash];
|
||||
f->next = (flag_t *)malloc(sizeof(flag_t)); /// <- died here!
|
||||
f->next->prev = f;
|
||||
f = f->next;
|
||||
fp->last = f;
|
||||
fp->last[hash] = f;
|
||||
f->next = NULL;
|
||||
|
||||
fml = LAST;
|
||||
|
@ -463,13 +476,16 @@ flag_t *addflag_real(flagpile_t *fp, enum FLAG id, int val1, int val2, int val3,
|
|||
}
|
||||
|
||||
flagpile_t *addflagpile(lifeform_t *owner, object_t *ob) {
|
||||
int i;
|
||||
flagpile_t *fp;
|
||||
fp = malloc(sizeof(flagpile_t));
|
||||
fp->first = NULL;
|
||||
fp->last = NULL;
|
||||
foreach_bucket(i) {
|
||||
fp->first[i] = NULL;
|
||||
fp->last[i] = NULL;
|
||||
fp->nitems = 0;
|
||||
}
|
||||
fp->owner = owner;
|
||||
fp->ob = ob;
|
||||
fp->nitems = 0;
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
@ -552,12 +568,16 @@ void checkflagpile(flagpile_t *fp) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// TODO: remove this function
|
||||
int fpisbad(flagpile_t *fp) {
|
||||
flag_t *f;
|
||||
int i;
|
||||
|
||||
if (!flagcheck) return B_FALSE;
|
||||
|
||||
for (f = fp->first ; f ; f = f->next) {
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = f->next) {
|
||||
if (f->next) {
|
||||
if(f->next->prev != f) {
|
||||
dblog("flag after %d is bad! its prev = 0x%x, should be this flag (0x%x)",f->id, f->next->prev, f);
|
||||
|
@ -569,6 +589,7 @@ int fpisbad(flagpile_t *fp) {
|
|||
return B_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return B_FALSE;
|
||||
}
|
||||
|
||||
|
@ -576,10 +597,11 @@ int fpisbad(flagpile_t *fp) {
|
|||
// returns # of flags copied
|
||||
int copyflag(flagpile_t *dst, flagpile_t *src, enum FLAG id) {
|
||||
flag_t *f;
|
||||
int ndone = 0;
|
||||
for (f = src->first ; f ; f = f->next) {
|
||||
int ndone = 0, i;
|
||||
foreach_bucket(i) {
|
||||
for (f = src->first[i] ; f ; f = f->next) {
|
||||
// gone past the requrested id's number - ie. it's not there.
|
||||
if (f->id > id) break;
|
||||
//if (f->id > id) break;
|
||||
if (f->id == id) {
|
||||
flag_t *newf;
|
||||
newf = addflag_real(dst, f->id, f->val[0], f->val[1], f->val[2], f->text,
|
||||
|
@ -597,12 +619,15 @@ int copyflag(flagpile_t *dst, flagpile_t *src, enum FLAG id) {
|
|||
ndone++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ndone;
|
||||
}
|
||||
|
||||
void copyflags(flagpile_t *dst, flagpile_t *src, int lifetime) {
|
||||
flag_t *f,*newf;
|
||||
for (f = src->first ; f ; f = f->next) {
|
||||
int i;
|
||||
foreach_bucket(i) {
|
||||
for (f = src->first[i] ; f ; f = f->next) {
|
||||
// omit certain flags
|
||||
if (lifetime == FROMBRAND) {
|
||||
if ((f->id == F_ONLYFOROBTYPE) ||
|
||||
|
@ -629,31 +654,39 @@ void copyflags(flagpile_t *dst, flagpile_t *src, int lifetime) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int countflags(flagpile_t *fp) {
|
||||
flag_t *f;
|
||||
int count = 0;
|
||||
for (f = fp->first ; f ; f = f->next) {
|
||||
int count = 0, i;
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = f->next) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int countflagsofid(flagpile_t *fp, enum FLAG fid) {
|
||||
flag_t *f;
|
||||
int count = 0;
|
||||
for (f = fp->first ; f ; f = f->next) {
|
||||
int count = 0, i;
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = f->next) {
|
||||
if (f->id == fid) count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void dumpflags(flagpile_t *fp) {
|
||||
flag_t *f;
|
||||
dblog("START FLAGDUMP");
|
||||
for (f = fp->first ; f ; f = f->next) {
|
||||
dblog("fid=%d, v0=%d v1=%d v2=%d text=[%s]",
|
||||
f->id, f->val[0], f->val[1], f->val[2], f->text);
|
||||
int i;
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = f->next) {
|
||||
dblog("[b=%d] fid=%d, v0=%d v1=%d v2=%d text=[%s]",
|
||||
i, f->id, f->val[0], f->val[1], f->val[2], f->text);
|
||||
}
|
||||
}
|
||||
dblog("END FLAGDUMP");
|
||||
}
|
||||
|
@ -817,19 +850,11 @@ flag_t *hasflagknown(flagpile_t *fp, int id) {
|
|||
return hasflag_real(fp, id, B_TRUE, NULL, NA);
|
||||
}
|
||||
|
||||
flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception, int lifetimeexception) {
|
||||
flag_t *f,*foundflag = NULL, *searchfrom = NULL;
|
||||
lifeform_t *owner;
|
||||
flag_t *flag_bsearch(flagpile_t *fp, int id, int *iterp) {
|
||||
flag_t *f,*searchfrom = NULL;
|
||||
int pos;
|
||||
int iter = 0;
|
||||
int l,r;
|
||||
int iter = 0,subiter = 0;
|
||||
int db = B_FALSE;
|
||||
|
||||
owner = fp->owner;
|
||||
|
||||
if (flagdb) db = B_TRUE;
|
||||
|
||||
if (db) dblog("hasflag %d in flagpile with %d entries", id, fp->nitems);
|
||||
// binary search for this flag id.
|
||||
l = 0;
|
||||
r = fp->nitems-1;
|
||||
|
@ -870,11 +895,48 @@ flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception, i
|
|||
}
|
||||
iter++;
|
||||
}
|
||||
if (iterp) *iterp += iter;
|
||||
return searchfrom;
|
||||
}
|
||||
|
||||
flag_t *flag_hsearch(flagpile_t *fp, int id, int *iterp) {
|
||||
flag_t *f,*searchfrom = NULL;
|
||||
int hash;
|
||||
int iter = 0;
|
||||
|
||||
hash = getflaghash(id);
|
||||
for (f = fp->first[hash]; f ; f=f->next) {
|
||||
iter++;
|
||||
if (f->id == id) {
|
||||
searchfrom = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (iterp) *iterp += iter;
|
||||
return searchfrom;
|
||||
}
|
||||
|
||||
flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception, int lifetimeexception) {
|
||||
flag_t *f,*foundflag = NULL, *searchfrom = NULL;
|
||||
lifeform_t *owner;
|
||||
int iter = 0,subiter = 0;
|
||||
int db = B_FALSE;
|
||||
|
||||
owner = fp->owner;
|
||||
|
||||
if (flagdb) db = B_TRUE;
|
||||
|
||||
if (db) dblog("call to hasflag %d in flagpile with %d entries", id, fp->nitems);
|
||||
|
||||
// find first occurence of this id
|
||||
//searchfrom = flag_bsearch(fp, id, &iter);
|
||||
searchfrom = flag_hsearch(fp, id, &iter);
|
||||
|
||||
// now find a valid one
|
||||
f = searchfrom;
|
||||
while (f && (f->id == id)) {
|
||||
//while (f && (f->id == id)) { for binary search
|
||||
while (f) {
|
||||
if (f->id == id) {
|
||||
int valid = B_TRUE;
|
||||
if (f == exception) valid = B_FALSE;
|
||||
if ((lifetimeexception != NA) && (f->lifetime == lifetimeexception)) valid = B_FALSE;
|
||||
|
@ -890,6 +952,7 @@ flag_t *hasflag_real(flagpile_t *fp, int id, int wantknown, flag_t *exception, i
|
|||
subiter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (db) dblog("finished - %s - iter=%d, subiter=%d", foundflag ? "found it" : "NOT FOUND",iter,subiter);
|
||||
return foundflag;
|
||||
|
@ -1131,7 +1194,7 @@ void real_killflag(flag_t *f, int wantannounce) {
|
|||
cell_t *redolos = NULL;
|
||||
int redostat = B_FALSE;
|
||||
int redoscreen = B_FALSE;
|
||||
int i,dopleasegod[MAXGODS];
|
||||
int i,hash,dopleasegod[MAXGODS];
|
||||
flagpile_t *newflags = NULL;
|
||||
|
||||
|
||||
|
@ -1261,6 +1324,8 @@ void real_killflag(flag_t *f, int wantannounce) {
|
|||
}
|
||||
checkflagpile(pile);
|
||||
|
||||
// determine bucket
|
||||
hash = getflaghash(f->id);
|
||||
/////////////////////////////////////////////
|
||||
// now we are actually removing the flag.
|
||||
/////////////////////////////////////////////
|
||||
|
@ -1284,13 +1349,13 @@ void real_killflag(flag_t *f, int wantannounce) {
|
|||
if (nextone != NULL) {
|
||||
nextone->prev = f->prev;
|
||||
} else { /* last */
|
||||
f->pile->last = f->prev;
|
||||
f->pile->last[hash] = f->prev;
|
||||
}
|
||||
|
||||
if (f->prev == NULL) {
|
||||
/* first */
|
||||
nextone = f->next;
|
||||
f->pile->first = nextone;
|
||||
f->pile->first[hash] = nextone;
|
||||
free(f);
|
||||
} else {
|
||||
lastone = f->prev;
|
||||
|
@ -1362,13 +1427,16 @@ void real_killflag(flag_t *f, int wantannounce) {
|
|||
}
|
||||
|
||||
void killflagpile(flagpile_t *fp) {
|
||||
int i;
|
||||
if (fp->ob && !fp->ob->dying) {
|
||||
assert(0 == "calling killflagpile on non-dying object");
|
||||
}
|
||||
|
||||
//checkflagpile(fp);
|
||||
while (fp->first) {
|
||||
killflag(fp->first);
|
||||
foreach_bucket(i) {
|
||||
while (fp->first[i]) {
|
||||
killflag(fp->first[i]);
|
||||
}
|
||||
}
|
||||
//checkflagpile(fp);
|
||||
free(fp);
|
||||
|
@ -1376,29 +1444,32 @@ void killflagpile(flagpile_t *fp) {
|
|||
|
||||
int killtransitoryflags(flagpile_t *fp, enum FLAG fid) {
|
||||
flag_t *f,*nextf;
|
||||
int nkilled = 0;
|
||||
for (f = fp->first ; f ; f = nextf) {
|
||||
int nkilled = 0, i;
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = nextf) {
|
||||
nextf = f->next;
|
||||
|
||||
// gone past the requrested id's number - ie. it's not there.
|
||||
if (f->id > fid) break;
|
||||
//if (f->id > fid) break;
|
||||
|
||||
if (istransitoryflag(f) && (f->id == fid)) {
|
||||
killflag(f);
|
||||
nkilled++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nkilled;
|
||||
}
|
||||
|
||||
int killtransitoryflagvals(flagpile_t *fp, enum FLAG fid, int val1, int val2, int val3, char *text) {
|
||||
flag_t *f, *nextf;
|
||||
int nkilled = 0;
|
||||
for (f = fp->first ; f ; f = nextf) {
|
||||
int nkilled = 0, i;
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = nextf) {
|
||||
nextf = f->next;
|
||||
|
||||
// gone past the requrested id's number - ie. it's not there.
|
||||
if (f->id > fid) break;
|
||||
//if (f->id > fid) break;
|
||||
|
||||
if (istransitoryflag(f) && (f->id == fid)) {
|
||||
if ( ((val1 == NA) || (f->val[0] == val1)) &&
|
||||
|
@ -1410,6 +1481,7 @@ int killtransitoryflagvals(flagpile_t *fp, enum FLAG fid, int val1, int val2, in
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nkilled;
|
||||
}
|
||||
|
||||
|
@ -1661,13 +1733,15 @@ char *getflagtext(flagpile_t *fp, enum FLAG fid) {
|
|||
}
|
||||
|
||||
void getmaxflags(flagpile_t *fp, int id, int *max0, int *max1, int *max2) {
|
||||
int i;
|
||||
flag_t *f;
|
||||
if (max0) *max0 = 0;
|
||||
if (max1) *max1 = 0;
|
||||
if (max2) *max2 = 0;
|
||||
for (f = fp->first ; f ; f = f->next) {
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = f->next) {
|
||||
// gone past the requrested id's number - ie. it's not there.
|
||||
if (f->id > id) break;
|
||||
//if (f->id > id) break;
|
||||
|
||||
if (f->id == id) {
|
||||
if (max0 && (f->val[0] > *max0)) *max0 = f->val[0];
|
||||
|
@ -1676,6 +1750,7 @@ void getmaxflags(flagpile_t *fp, int id, int *max0, int *max1, int *max2) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flag_t *getrandomflag(flagpile_t *fp, enum FLAG fid) {
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
|
@ -1758,9 +1833,11 @@ void sumflags(flagpile_t *fp, enum FLAG id, int *val0, int *val1, int *val2) {
|
|||
void timeeffectsflags(flagpile_t *fp) {
|
||||
flag_t *f,*nextf;
|
||||
enum FLAG thisid;
|
||||
int i;
|
||||
|
||||
|
||||
for (f = fp->first ; f ; f = nextf) {
|
||||
foreach_bucket(i) {
|
||||
for (f = fp->first[i] ; f ; f = nextf) {
|
||||
nextf = f->next;
|
||||
thisid = f->id;
|
||||
timeeffectsflag(f, 1);
|
||||
|
@ -1768,11 +1845,14 @@ void timeeffectsflags(flagpile_t *fp) {
|
|||
// flag 'thisid'
|
||||
checkflagpile(fp);
|
||||
}
|
||||
}
|
||||
//checkflagpile(fp);
|
||||
}
|
||||
|
||||
// generate an index
|
||||
void updatefpindex(flagpile_t *fp) {
|
||||
return;
|
||||
/*
|
||||
flag_t *f;
|
||||
|
||||
fp->nitems = 0;
|
||||
|
@ -1784,5 +1864,5 @@ void updatefpindex(flagpile_t *fp) {
|
|||
fp->nitems++;
|
||||
assert(fp->nitems < MAXFLAGS);
|
||||
}
|
||||
//checkflagpile(fp);
|
||||
*/
|
||||
}
|
||||
|
|
3
flag.h
3
flag.h
|
@ -21,6 +21,8 @@ void copyflags(flagpile_t *dst, flagpile_t *src, int lifetime);
|
|||
int countflags(flagpile_t *fp);
|
||||
int countflagsofid(flagpile_t *fp, enum FLAG fid );
|
||||
void dumpflags(flagpile_t *fp);
|
||||
flag_t *flag_bsearch(flagpile_t *fp, int id, int *iterp);
|
||||
flag_t *flag_hsearch(flagpile_t *fp, int id, int *iterp);
|
||||
int flagcausesinterrupt(flag_t *f, enum GAINORLOSS gol);
|
||||
int flagcausesloscalc(enum FLAG fid);
|
||||
int flagcausesredraw(lifeform_t *lf, enum FLAG fid);
|
||||
|
@ -30,6 +32,7 @@ int flagstacks(enum FLAG fid);
|
|||
int flagtomaxhp(flag_t *f);
|
||||
cell_t *getflagpilelocation(flagpile_t *fp);
|
||||
int getflags(flagpile_t *fp, flag_t **retflag, int *nretflags, ... );
|
||||
int getflaghash(enum FLAG fid);
|
||||
char *getflagtext(flagpile_t *fp, enum FLAG fid);
|
||||
void getmaxflags(flagpile_t *fp, int id, int *max0, int *max1, int *max2);
|
||||
flag_t *getrandomflag(flagpile_t *fp, enum FLAG fid);
|
||||
|
|
6
god.c
6
god.c
|
@ -166,7 +166,7 @@ void angergod(enum RACE rid, int amt, enum GODANGERREASON why) {
|
|||
object_t *o;
|
||||
flag_t *f;
|
||||
int isflag[MAXCANDIDATES];
|
||||
int nposs = 0;
|
||||
int nposs = 0, b;
|
||||
enum ATTRIB a;
|
||||
// lose at least one god gift
|
||||
for (o = player->pack->first ; o ; o = o->next) {
|
||||
|
@ -177,13 +177,15 @@ void angergod(enum RACE rid, int amt, enum GODANGERREASON why) {
|
|||
}
|
||||
}
|
||||
|
||||
for (f = player->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = player->flags->first[b] ; f ; f = f->next) {
|
||||
if ((f->lifetime == FROMGODGIFT) && (f->obfrom == god->race->id)) {
|
||||
poss[nposs] = f;
|
||||
isflag[nposs] = B_TRUE;
|
||||
nposs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nposs) {
|
||||
int sel;
|
||||
msg("\"You are unworthy of my gifts, mortal!\"");
|
||||
|
|
42
io.c
42
io.c
|
@ -6239,7 +6239,7 @@ char *makedesc_ob(object_t *o, char *retbuf) {
|
|||
char buf3[BUFLEN];
|
||||
recipe_t *rec;
|
||||
flag_t *f;
|
||||
int obknown,i,throwrange;
|
||||
int obknown,i,throwrange, b;
|
||||
flag_t *retflag[MAXCANDIDATES];
|
||||
int nretflags;
|
||||
object_t *compareob = NULL;
|
||||
|
@ -7053,12 +7053,14 @@ char *makedesc_ob(object_t *o, char *retbuf) {
|
|||
// skip line
|
||||
strncat(retbuf, "\n", HUGEBUFLEN);
|
||||
|
||||
for (f = o->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = o->flags->first[b] ; f ; f = f->next) {
|
||||
if ((f->id == F_HITCONFER) && (f->val[0] == F_POISONED) && (f->lifetime == FROMOBMOD)) {
|
||||
sprintf(buf, "It has been coated with poison.\n");
|
||||
strncat(retbuf, buf, HUGEBUFLEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// physical properties
|
||||
|
@ -7211,7 +7213,8 @@ char *makedesc_ob(object_t *o, char *retbuf) {
|
|||
}
|
||||
|
||||
// if known, show what it confers
|
||||
for (f = o->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = o->flags->first[b] ; f ; f = f->next) {
|
||||
if ((f->id == F_HOLDCONFER) || (f->id == F_EQUIPCONFER) || (f->id == F_ACTIVATECONFER)) {
|
||||
if (obknown && f->known) {
|
||||
objecttype_t *ot;
|
||||
|
@ -7633,11 +7636,13 @@ char *makedesc_ob(object_t *o, char *retbuf) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// requirements
|
||||
i = B_FALSE;
|
||||
for (f = o->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = o->flags->first[b] ; f ; f = f->next) {
|
||||
if (f->id == F_ATTREQ) {
|
||||
enum COLOUR col;
|
||||
int pctmod;
|
||||
|
@ -7702,6 +7707,7 @@ char *makedesc_ob(object_t *o, char *retbuf) {
|
|||
i = B_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// blank line
|
||||
strncat(retbuf, "\n", HUGEBUFLEN);
|
||||
|
@ -7816,7 +7822,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
race_t *r;
|
||||
char buf[HUGEBUFLEN];
|
||||
flag_t *retflag[MAXCANDIDATES],*f;
|
||||
int nretflags,i;
|
||||
int nretflags,i,b;
|
||||
flagpile_t *doneflags;
|
||||
enum SKILLLEVEL lorelev;
|
||||
|
||||
|
@ -7982,7 +7988,8 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
}
|
||||
|
||||
// auto bonuses from flags
|
||||
for (f = r->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = r->flags->first[b] ; f ; f = f->next) {
|
||||
char *p;
|
||||
strcpy(buf, "");
|
||||
switch (f->id) {
|
||||
|
@ -8124,6 +8131,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
curidx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curidx == 0) {
|
||||
strncat(retbuf, "^n@None known.\n", HUGEBUFLEN);
|
||||
|
@ -8157,7 +8165,8 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
}
|
||||
|
||||
// auto penalties from flags
|
||||
for (f = r->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = r->flags->first[b] ; f ; f = f->next) {
|
||||
material_t *mt;
|
||||
strcpy(buf, "");
|
||||
switch (f->id) {
|
||||
|
@ -8255,6 +8264,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
curidx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curidx == 0) {
|
||||
strncat(retbuf, "^n@None known.\n", HUGEBUFLEN);
|
||||
|
@ -8265,7 +8275,8 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
//////////////////////////////////////////////
|
||||
|
||||
// auto misc from flags
|
||||
for (f = r->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = r->flags->first[b] ; f ; f = f->next) {
|
||||
char buf2[BUFLEN];
|
||||
strcpy(buf, "");
|
||||
switch (f->id) {
|
||||
|
@ -8296,6 +8307,7 @@ char *makedesc_race(enum RACE rid, char *retbuf, int showextra, int forplayersel
|
|||
curidx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (donemischeading && (curidx == 0)) {
|
||||
strncat(retbuf, "^n@None known.\n", HUGEBUFLEN);
|
||||
}
|
||||
|
@ -12454,7 +12466,7 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
int nweps = 0;
|
||||
objecttype_t *ot;
|
||||
int first;
|
||||
int i;
|
||||
int i,b;
|
||||
int dammod;
|
||||
//int accmod;
|
||||
enum BODYPART bp;
|
||||
|
@ -13411,7 +13423,8 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
}
|
||||
// fleeing?
|
||||
if (showall) {
|
||||
for (f = lf->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = lf->flags->first[b] ; f ; f = f->next) {
|
||||
if (f->id == F_FLEEFROM) {
|
||||
lifeform_t *lf2;
|
||||
lf2 = findlf(NULL, f->val[0]);
|
||||
|
@ -13422,6 +13435,7 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// diff materials?
|
||||
if (getlfmaterial(lf) != MT_FLESH) {
|
||||
|
@ -13855,7 +13869,8 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
}
|
||||
// spells
|
||||
nfound = 0;
|
||||
for (f = lf->flags->first ; f ; f = f->next) {
|
||||
foreach_bucket(b) {
|
||||
for (f = lf->flags->first[b] ; f ; f = f->next) {
|
||||
if (f->id == F_BOOSTSPELL) {
|
||||
objecttype_t *sp;
|
||||
sp = findot(f->val[0]);
|
||||
|
@ -13881,6 +13896,7 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (nfound)
|
||||
// obvious physical effects first.
|
||||
f = lfhasknownflag(lf, F_BEINGSTONED);
|
||||
|
@ -14659,7 +14675,8 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s receive enhanced knowledge about the world.%s", you(lf),source);
|
||||
|
||||
}
|
||||
for (f = lf->flags->first ; f ; f = f->next ){
|
||||
foreach_bucket(b) {
|
||||
for (f = lf->flags->first[b] ; f ; f = f->next) {
|
||||
if (f->known && (f->id == F_POISONED)) {
|
||||
int knownfatal = B_FALSE;
|
||||
poisontype_t *pt;
|
||||
|
@ -14699,6 +14716,7 @@ void showlfstats(lifeform_t *lf, int showall) {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
f = lfhasflag(lf, F_MUTABLE);
|
||||
if (f && (f->known)) {
|
||||
effectline(&stopnow, &count, offset, &nextoffset, headinglines, mainwin, &y, &x, 0, "%s body is receptive to mutations.", your(lf), isplayer(lf) ? "is" : "are");
|
||||
|
|
Loading…
Reference in New Issue