forked from github/server
nullpointerexception abgefangen
This commit is contained in:
parent
4a5c670d99
commit
9caaab514d
|
@ -194,7 +194,9 @@ find_cursetype(curse_t id)
|
||||||
boolean
|
boolean
|
||||||
is_normalcurse(curse_t id)
|
is_normalcurse(curse_t id)
|
||||||
{
|
{
|
||||||
const curse_type *ct = find_cursetype(id);
|
curse_type *ct = find_cursetype(id);
|
||||||
|
|
||||||
|
if (!ct) return false;
|
||||||
|
|
||||||
if (ct->typ == CURSETYP_NORM)
|
if (ct->typ == CURSETYP_NORM)
|
||||||
return true;
|
return true;
|
||||||
|
@ -205,7 +207,9 @@ is_normalcurse(curse_t id)
|
||||||
boolean
|
boolean
|
||||||
is_curseunit(curse_t id)
|
is_curseunit(curse_t id)
|
||||||
{
|
{
|
||||||
const curse_type *ct = find_cursetype(id);
|
curse_type *ct = find_cursetype(id);
|
||||||
|
|
||||||
|
if (!ct) return false;
|
||||||
|
|
||||||
if (ct->typ == CURSETYP_UNIT)
|
if (ct->typ == CURSETYP_UNIT)
|
||||||
return true;
|
return true;
|
||||||
|
@ -216,7 +220,9 @@ is_curseunit(curse_t id)
|
||||||
boolean
|
boolean
|
||||||
is_curseskill(curse_t id)
|
is_curseskill(curse_t id)
|
||||||
{
|
{
|
||||||
const curse_type *ct = find_cursetype(id);
|
curse_type *ct = find_cursetype(id);
|
||||||
|
|
||||||
|
if (!ct) return false;
|
||||||
|
|
||||||
if (ct->typ == CURSETYP_SKILL)
|
if (ct->typ == CURSETYP_SKILL)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1357,6 +1357,7 @@ curse_write(const attrib * a,FILE * f) {
|
||||||
int flag;
|
int flag;
|
||||||
int mage_no;
|
int mage_no;
|
||||||
curse * c = (curse*)a->data.v;
|
curse * c = (curse*)a->data.v;
|
||||||
|
curse_type * ct = c->type;
|
||||||
|
|
||||||
flag = (c->flag & ~(CURSE_ISNEW));
|
flag = (c->flag & ~(CURSE_ISNEW));
|
||||||
|
|
||||||
|
@ -1366,7 +1367,7 @@ curse_write(const attrib * a,FILE * f) {
|
||||||
mage_no = -1;
|
mage_no = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "%d %d %d %d %d %d %d ", c->no, (int)c->cspellid, flag,
|
fprintf(f, "%d %d %d %d %d %d %d ", c->no, (int)ct->cspellid, flag,
|
||||||
c->duration, c->vigour, mage_no, c->effect);
|
c->duration, c->vigour, mage_no, c->effect);
|
||||||
|
|
||||||
switch(c->type->typ){
|
switch(c->type->typ){
|
||||||
|
@ -1393,6 +1394,7 @@ curse_read(attrib * a, FILE * f) {
|
||||||
int cspellid;
|
int cspellid;
|
||||||
int mageid;
|
int mageid;
|
||||||
curse * c = (curse*)a->data.v;
|
curse * c = (curse*)a->data.v;
|
||||||
|
curse_type * ct;
|
||||||
|
|
||||||
if (global.data_version < CURSE_NO_VERSION){
|
if (global.data_version < CURSE_NO_VERSION){
|
||||||
fscanf(f, "%d %d %d %d %d %d ",&cspellid, &c->flag, &c->duration,
|
fscanf(f, "%d %d %d %d %d %d ",&cspellid, &c->flag, &c->duration,
|
||||||
|
@ -1403,7 +1405,9 @@ curse_read(attrib * a, FILE * f) {
|
||||||
&c->duration, &c->vigour, &mageid, &c->effect);
|
&c->duration, &c->vigour, &mageid, &c->effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->type = find_cursetype((curse_t)cspellid);
|
ct = find_cursetype((curse_t)cspellid);
|
||||||
|
|
||||||
|
c->type = ct;
|
||||||
c->cspellid = (curse_t)cspellid;
|
c->cspellid = (curse_t)cspellid;
|
||||||
|
|
||||||
/* beim Einlesen sind noch nicht alle units da, muss also
|
/* beim Einlesen sind noch nicht alle units da, muss also
|
||||||
|
|
Loading…
Reference in New Issue