forked from github/server
addendum to BUG 2383 (5a0a1f): read irace correctly
This commit is contained in:
parent
396705f492
commit
6e53f15a1c
|
@ -509,7 +509,7 @@ unit *read_unit(gamedata *data)
|
||||||
u_setrace(u, rc);
|
u_setrace(u, rc);
|
||||||
|
|
||||||
READ_TOK(data->store, rname, sizeof(rname));
|
READ_TOK(data->store, rname, sizeof(rname));
|
||||||
if (rname[0] && skill_enabled(SK_STEALTH))
|
if (rname[0])
|
||||||
u->irace = rc_find(rname);
|
u->irace = rc_find(rname);
|
||||||
else
|
else
|
||||||
u->irace = NULL;
|
u->irace = NULL;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
|
#include <kernel/race.h>
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/gamedata.h>
|
#include <util/gamedata.h>
|
||||||
#include <attributes/key.h>
|
#include <attributes/key.h>
|
||||||
|
@ -51,6 +52,7 @@ static void test_readwrite_unit(CuTest * tc)
|
||||||
struct unit *u;
|
struct unit *u;
|
||||||
struct region *r;
|
struct region *r;
|
||||||
struct faction *f;
|
struct faction *f;
|
||||||
|
struct race *irace;
|
||||||
int fno;
|
int fno;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
|
@ -60,6 +62,12 @@ static void test_readwrite_unit(CuTest * tc)
|
||||||
u = test_create_unit(f, r);
|
u = test_create_unit(f, r);
|
||||||
unit_setname(u, " Hodor ");
|
unit_setname(u, " Hodor ");
|
||||||
CuAssertStrEquals(tc, " Hodor ", u->_name);
|
CuAssertStrEquals(tc, " Hodor ", u->_name);
|
||||||
|
enable_skill(SK_STEALTH, false);
|
||||||
|
irace = test_create_race("halfling");
|
||||||
|
CuAssertTrue(tc, playerrace(irace));
|
||||||
|
u->irace = irace;
|
||||||
|
CuAssertTrue(tc, irace == u_irace(u));
|
||||||
|
|
||||||
mstream_init(&data.strm);
|
mstream_init(&data.strm);
|
||||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
write_unit(&data, u);
|
write_unit(&data, u);
|
||||||
|
@ -74,6 +82,7 @@ static void test_readwrite_unit(CuTest * tc)
|
||||||
CuAssertPtrNotNull(tc, u);
|
CuAssertPtrNotNull(tc, u);
|
||||||
CuAssertPtrEquals(tc, f, u->faction);
|
CuAssertPtrEquals(tc, f, u->faction);
|
||||||
CuAssertStrEquals(tc, "Hodor", u->_name);
|
CuAssertStrEquals(tc, "Hodor", u->_name);
|
||||||
|
CuAssertTrue(tc, irace == u_irace(u));
|
||||||
CuAssertPtrEquals(tc, 0, u->region);
|
CuAssertPtrEquals(tc, 0, u->region);
|
||||||
|
|
||||||
mstream_done(&data.strm);
|
mstream_done(&data.strm);
|
||||||
|
|
Loading…
Reference in New Issue