forked from github/server
when free_gamedata, also unhash all factions. speed up is_monsters().
This commit is contained in:
parent
d1f7fb571c
commit
e9084d9678
3 changed files with 8 additions and 4 deletions
|
@ -68,6 +68,7 @@ faction *factions;
|
|||
*/
|
||||
void free_faction(faction * f)
|
||||
{
|
||||
funhash(f);
|
||||
if (f->msgs)
|
||||
free_messagelist(f->msgs);
|
||||
while (f->battles) {
|
||||
|
@ -113,9 +114,12 @@ void funhash(faction * f)
|
|||
{
|
||||
int index = f->no % FMAXHASH;
|
||||
faction **fp = factionhash + index;
|
||||
while (*fp && (*fp) != f)
|
||||
while (*fp && (*fp) != f) {
|
||||
fp = &(*fp)->nexthash;
|
||||
*fp = f->nexthash;
|
||||
}
|
||||
if (*fp == f) {
|
||||
*fp = f->nexthash;
|
||||
}
|
||||
}
|
||||
|
||||
static faction *ffindhash(int no)
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
|
||||
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_DBENTRY|FFL_NOIDLEOUT)
|
||||
|
||||
#define is_monsters(f) (f && f==get_monsters())
|
||||
#define is_monsters(f) (f && fval(f, FFL_NPC) && f==get_monsters())
|
||||
|
||||
typedef struct faction {
|
||||
struct faction *next;
|
||||
|
|
|
@ -733,7 +733,7 @@ void set_level(unit * u, skill_t sk, int value)
|
|||
{
|
||||
skill *sv = u->skills;
|
||||
|
||||
assert(sk != SK_MAGIC || !u->faction || is_monsters(u->faction) || u->number == 1);
|
||||
assert(sk != SK_MAGIC || !u->faction || u->number == 1 || is_monsters(u->faction));
|
||||
if (!skill_enabled(sk))
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue