fixing a couple of bugs that appeaerd when trying to run E2 with the E3

codebase
This commit is contained in:
Enno Rehling 2009-10-01 22:06:34 +00:00
parent 012cdf5066
commit e429e9304d
10 changed files with 16 additions and 13 deletions

View File

@ -1872,7 +1872,6 @@ do_extra_spell(troop at, const att *a)
{
const spell *sp = a->data.sp;
fighter *fi = at.fighter;
unit *au = fi->unit;
double power;
power = sp->level * MagicPower();

View File

@ -93,7 +93,7 @@ getplanebyname(const char * name)
plane *p;
for (p=planes; p; p=p->next)
if (!strcmp(p->name, name))
if (p->name && !strcmp(p->name, name))
return p;
return NULL;
}

View File

@ -204,7 +204,7 @@ r_insectstalled(const region * r)
const char *
rc_name(const race * rc, int n)
{
return mkname("race", rc->_name[n]);
return rc?mkname("race", rc->_name[n]):NULL;
}
const char *

View File

@ -303,7 +303,7 @@ report_race(const struct unit * u, const char ** name, const char ** illusion)
{
if (illusion) {
const race * irace = u_irace(u);
if (irace!=u->race) {
if (irace && irace!=u->race) {
*illusion = irace->_name[0];
}
else {

View File

@ -853,7 +853,7 @@ write_unit(struct storage * store, const unit * u)
store->w_int(store, u->number);
store->w_int(store, u->age);
store->w_tok(store, u->race->_name[0]);
store->w_tok(store, irace!=u->race?u->irace->_name[0]:"");
store->w_tok(store, (irace && irace!=u->race)?irace->_name[0]:"");
write_building_reference(u->building, store);
write_ship_reference(u->ship, store);
store->w_int(store, u->status);

View File

@ -1733,7 +1733,7 @@ scale_number (unit * u, int n)
const struct race * u_irace(const struct unit * u)
{
if (skill_enabled[SK_STEALTH]) {
if (u->irace && skill_enabled[SK_STEALTH]) {
return u->irace;
}
return u->race;

View File

@ -164,10 +164,12 @@ tolua_building_create(lua_State* L)
const char * bname = tolua_tostring(L, 2, 0);
if (bname) {
const building_type * btype = bt_find(bname);
if (btype) {
building * b = new_building(btype, r, NULL);
tolua_pushusertype(L, (void*)b, TOLUA_CAST "building");
return 1;
}
}
return 0;
}

View File

@ -664,7 +664,7 @@ static void
unit_setship(unit * u, ship * s)
{
leave(u, true);
if (u->region!=s->region) {
if (s && u->region!=s->region) {
move_unit(u, s->region, NULL);
}
u->ship = s;

View File

@ -0,0 +1 @@
maxnmrs = 500

View File

@ -625,12 +625,13 @@ function test_leave()
b2.size = 10
local u = unit.create(f, r, 1)
u.building = b1
assert(u.building~=nil)
u:add_item("money", u.number * 100)
u:clear_orders()
u:add_order("BETRETE BURG " .. itoa36(b2.id))
update_owners()
process_orders()
assert(u.building==b1)
assert(u.building.id==b1.id) -- region owners may not leave
end
function test_mallorn()
@ -787,7 +788,7 @@ mytests = {
["owners"] = test_owners
}
fail = 0
for k, v in pairs(mytests) do
for k, v in pairs(tests) do
local status, err = pcall(v)
if not status then
fail = fail + 1