forked from github/server
null-pointer crashes
This commit is contained in:
parent
be8765a4e5
commit
aa76baab1c
|
@ -3586,7 +3586,7 @@ battle_stats(FILE * F, battle * b)
|
||||||
{
|
{
|
||||||
typedef struct stat_info {
|
typedef struct stat_info {
|
||||||
struct stat_info * next;
|
struct stat_info * next;
|
||||||
weapon * wp;
|
const weapon_type * wtype;
|
||||||
int level;
|
int level;
|
||||||
int number;
|
int number;
|
||||||
} stat_info;
|
} stat_info;
|
||||||
|
@ -3603,22 +3603,23 @@ battle_stats(FILE * F, battle * b)
|
||||||
for (dt.index=0;dt.index!=du->number;++dt.index) {
|
for (dt.index=0;dt.index!=du->number;++dt.index) {
|
||||||
weapon * wp = preferred_weapon(dt, true);
|
weapon * wp = preferred_weapon(dt, true);
|
||||||
int level = wp?wp->attackskill:0;
|
int level = wp?wp->attackskill:0;
|
||||||
|
const weapon_type * wtype = wp?wp->type:NULL;
|
||||||
stat_info ** slist = &stats;
|
stat_info ** slist = &stats;
|
||||||
|
|
||||||
if (slast && slast->wp==wp && slast->level==level) {
|
if (slast && slast->wtype==wtype && slast->level==level) {
|
||||||
++slast->number;
|
++slast->number;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while (*slist && (*slist)->wp!=wp) {
|
while (*slist && (*slist)->wtype!=wtype) {
|
||||||
slist = &(*slist)->next;
|
slist = &(*slist)->next;
|
||||||
}
|
}
|
||||||
while (*slist && (*slist)->wp==wp && (*slist)->level>level) {
|
while (*slist && (*slist)->wtype==wtype && (*slist)->level>level) {
|
||||||
slist = &(*slist)->next;
|
slist = &(*slist)->next;
|
||||||
}
|
}
|
||||||
stat = *slist;
|
stat = *slist;
|
||||||
if (stat==NULL || stat->wp!=wp || stat->level!=level) {
|
if (stat==NULL || stat->wtype!=wtype || stat->level!=level) {
|
||||||
stat = calloc(1, sizeof(stat_info));
|
stat = calloc(1, sizeof(stat_info));
|
||||||
stat->wp = wp;
|
stat->wtype = wtype;
|
||||||
stat->level = level;
|
stat->level = level;
|
||||||
stat->next = *slist;
|
stat->next = *slist;
|
||||||
*slist = stat;
|
*slist = stat;
|
||||||
|
@ -3630,8 +3631,7 @@ battle_stats(FILE * F, battle * b)
|
||||||
|
|
||||||
fprintf(F, "##STATS## Heer %u - %s:\n", s->index, factionname(s->bf->faction));
|
fprintf(F, "##STATS## Heer %u - %s:\n", s->index, factionname(s->bf->faction));
|
||||||
for (stat=stats;stat!=NULL;stat=stat->next) {
|
for (stat=stats;stat!=NULL;stat=stat->next) {
|
||||||
const weapon_type * wtype = stat->wp?stat->wp->type:NULL;
|
fprintf(F, "%s %u : %u\n", stat->wtype?stat->wtype->itype->rtype->_name[0]:"none", stat->level, stat->number);
|
||||||
fprintf(F, "%s %u : %u\n", wtype?wtype->itype->rtype->_name[0]:"none", stat->level, stat->number);
|
|
||||||
}
|
}
|
||||||
freelist(stats);
|
freelist(stats);
|
||||||
} cv_next(s);
|
} cv_next(s);
|
||||||
|
|
Loading…
Reference in New Issue