fixing a few crashes when new_race[i] is null.

error handling for missing seenspells.
This commit is contained in:
Enno Rehling 2006-01-02 08:38:46 +00:00
parent a032e94382
commit bf6dbe4b26
4 changed files with 36 additions and 22 deletions

View File

@ -2845,10 +2845,13 @@ report_summary(summary * s, summary * o, boolean full)
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos); fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
} }
for (i = 0; i < MAXRACES; i++) if (s->factionrace[i] && playerrace(new_race[i]) for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->factionrace[i] && rc && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) { && i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%14svölker: %s\n", fprintf(F, "%14svölker: %s\n", LOC(default_locale, rc_name(rc, 3)),
LOC(default_locale, rc_name(new_race[i], 3)), pcomp(s->factionrace[i], o->factionrace[i])); pcomp(s->factionrace[i], o->factionrace[i]));
}
} }
if(full) { if(full) {
@ -2869,16 +2872,22 @@ report_summary(summary * s, summary * o, boolean full)
fprintf(F, "\n"); fprintf(F, "\n");
if (full) { if (full) {
for (i = 0; i < MAXRACES; i++) if (s->poprace[i]) { for (i = 0; i < MAXRACES; i++) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(new_race[i], 1)), const race * rc = new_race[i];
if (s->poprace[i]) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i])); rcomp(s->poprace[i], o->poprace[i]));
} }
}
} else { } else {
for (i = 0; i < MAXRACES; i++) if (s->poprace[i] && playerrace(new_race[i]) for (i = 0; i < MAXRACES; i++) {
const race * rc = new_race[i];
if (s->poprace[i] && playerrace(rc)
&& i != RC_TEMPLATE && i != RC_CLONE) { && i != RC_TEMPLATE && i != RC_CLONE) {
fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(new_race[i], 1)), fprintf(F, "%20s: %s\n", LOC(default_locale, rc_name(rc, 1)),
rcomp(s->poprace[i], o->poprace[i])); rcomp(s->poprace[i], o->poprace[i]));
} }
}
} }
if (full) { if (full) {

View File

@ -154,7 +154,7 @@ addplayer(region *r, faction * f)
race_t urc; race_t urc;
do { do {
urc = (race_t)(rand() % MAXRACES); urc = (race_t)(rand() % MAXRACES);
} while (urc == RC_DAEMON || !playerrace(new_race[urc])); } while (new_race[urc]==NULL || urc == RC_DAEMON || !playerrace(new_race[urc]));
u->irace = new_race[urc]; u->irace = new_race[urc];
} }

View File

@ -375,6 +375,10 @@ read_seenspell(attrib * a, FILE * f)
fscanf(f, "%d", &mtype); fscanf(f, "%d", &mtype);
sp = find_spell((magic_t)mtype, buf); sp = find_spell((magic_t)mtype, buf);
} }
if (sp==NULL) {
log_error(("could not find seenspell '%s'\n", buf));
return AT_READ_FAIL;
}
a->data.v = sp; a->data.v = sp;
return AT_READ_OK; return AT_READ_OK;
} }

View File

@ -3,6 +3,7 @@ extern "C" {
#include <lua50/lauxlib.h> #include <lua50/lauxlib.h>
#include <lua50/lualib.h> #include <lua50/lualib.h>
} }
#include <boost/version.hpp>
#if BOOST_VERSION < 103300 #if BOOST_VERSION < 103300
# define LUABIND_OLD # define LUABIND_OLD
#endif #endif