bugfix old lua versions

removing some instances of oldterrain() calls

kingdoms: removing assert on missing old races
kingdoms: handling missing potions gracefully
This commit is contained in:
Enno Rehling 2005-11-25 23:52:53 +00:00
parent aa4fda7e26
commit 3ae0abad4b
9 changed files with 24 additions and 27 deletions

View File

@ -1875,7 +1875,7 @@ buy(unit * u, request ** buyorders, struct order * ord)
if (u->race == new_race[RC_INSECT]) {
/* entweder man ist insekt, oder... */
if (rterrain(r) != T_SWAMP && rterrain(r) != T_DESERT && !rbuildings(r)) {
if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT && !rbuildings(r)) {
cmistake(u, ord, 119, MSG_COMMERCE);
return;
}
@ -2165,7 +2165,7 @@ sell(unit * u, request ** sellorders, struct order * ord)
/* In der Region muß es eine Burg geben. */
if (u->race == new_race[RC_INSECT]) {
if (rterrain(r) != T_SWAMP && rterrain(r) != T_DESERT && !rbuildings(r)) {
if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT && !rbuildings(r)) {
cmistake(u, ord, 119, MSG_COMMERCE);
return false;
}

View File

@ -1379,7 +1379,7 @@ randomevents(void)
set_string(&u->name, "Seeschlange");
}
if ((rterrain(r) == T_GLACIER || rterrain(r) == T_SWAMP || rterrain(r) == T_DESERT) && rand() % 10000 < (5 + 100 * chaosfactor(r)))
if ((rterrain(r) == T_GLACIER || r->terrain == newterrain(T_SWAMP) || rterrain(r) == T_DESERT) && rand() % 10000 < (5 + 100 * chaosfactor(r)))
{
if (chance(0.80)) {
u = createunit(r, findfaction(MONSTER_FACTION), nrand(60, 20) + 1, new_race[RC_FIREDRAGON]);

View File

@ -460,7 +460,6 @@ void
build_road(region * r, unit * u, int size, direction_t d)
{
int n, left;
terrain_t rt = rterrain(r);
region * rn = rconnect(r,d);
if (!eff_skill(u, SK_ROAD_BUILDING, r)) {
@ -482,7 +481,7 @@ build_road(region * r, unit * u, int size, direction_t d)
return;
}
if (rt == T_SWAMP) {
if (r->terrain == newterrain(T_SWAMP)) {
/* wenn kein Damm existiert */
static const struct building_type * bt_dam;
if (!bt_dam) bt_dam = bt_find("dam");
@ -491,7 +490,7 @@ build_road(region * r, unit * u, int size, direction_t d)
cmistake(u, u->thisorder, 132, MSG_PRODUCE);
return;
}
} else if (rt == T_DESERT) {
} else if (r->terrain == newterrain(T_DESERT)) {
static const struct building_type * bt_caravan;
if (!bt_caravan) bt_caravan = bt_find("caravan");
assert(bt_caravan);
@ -500,7 +499,7 @@ build_road(region * r, unit * u, int size, direction_t d)
cmistake(u, u->thisorder, 133, MSG_PRODUCE);
return;
}
} else if (rt == T_GLACIER) {
} else if (r->terrain == newterrain(T_GLACIER)) {
static const struct building_type * bt_tunnel;
if (!bt_tunnel) bt_tunnel = bt_find("tunnel");
assert(bt_tunnel);

View File

@ -176,15 +176,14 @@ skill_mod(const race * rc, skill_t sk, const struct terrain_type * terrain)
if (rc == new_race[RC_DWARF]) {
if (sk==SK_TACTICS) {
terrain_t t = oldterrain(terrain);
if (t == T_MOUNTAIN || t == T_GLACIER || t == T_ICEBERG_SLEEP) ++result;
if (terrain == newterrain(T_MOUNTAIN) || fval(terrain, ARCTIC_REGION))
++result;
}
}
else if (rc == new_race[RC_INSECT]) {
terrain_t t = oldterrain(terrain);
if (t == T_MOUNTAIN || t == T_GLACIER || t == T_ICEBERG_SLEEP || t == T_ICEBERG)
if (terrain == newterrain(T_MOUNTAIN) || fval(terrain, ARCTIC_REGION))
--result;
else if (t == T_DESERT || t == T_SWAMP)
else if (terrain == newterrain(T_DESERT) || terrain == newterrain(T_SWAMP))
++result;
}

View File

@ -138,7 +138,7 @@ init_terrains(void)
if (newterrain!=NULL) {
newterrains[t] = newterrain;
} else {
log_error(("missing classic terrain %s\n", terraindata[t]));
log_warning(("missing classic terrain %s\n", terraindata[t]));
}
}
}

View File

@ -565,7 +565,6 @@ race_compat(void)
}
} else {
log_error(("could not find old race %s\n", oldracenames[i]));
assert(rc);
}
}
}

View File

@ -1523,7 +1523,7 @@ sp_create_irongolem(castorder *co)
int number = lovar(force*8*RESOURCE_QUANTITY);
if (number<1) number = 1;
if (rterrain(r) == T_SWAMP) {
if (r->terrain == newterrain(T_SWAMP)) {
cmistake(mage, co->order, 188, MSG_MAGIC);
return 0;
}
@ -1585,7 +1585,7 @@ sp_create_stonegolem(castorder *co)
int number = lovar(co->force*5*RESOURCE_QUANTITY);
if (number<1) number = 1;
if (rterrain(r) == T_SWAMP) {
if (r->terrain == newterrain(T_SWAMP)) {
cmistake(mage, co->order, 188, MSG_MAGIC);
return 0;
}
@ -1724,7 +1724,7 @@ sp_great_drought(castorder *co)
cansee(u->faction, r, mage, 0)? unitname(mage) : "Jemand",
regionname(r, u->faction));
if (!fval(r->terrain, SEA_REGION)){
if(rterrain(r) == T_SWAMP && terraform){
if (r->terrain == newterrain(T_SWAMP) && terraform) {
scat(" Eis schmilzt und verwandelt sich in Morast. Reißende "
"Ströme spülen die mageren Felder weg und ersäufen "
"Mensch und Tier. Was an Bauten nicht den Fluten zum Opfer "
@ -2676,7 +2676,7 @@ sp_summondragon(castorder *co)
f = findfaction(MONSTER_FACTION);
if(rterrain(r) != T_SWAMP && rterrain(r) != T_DESERT
if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT
&& rterrain(r) != T_GLACIER){
report_failure(mage, co->order);
return 0;

View File

@ -687,7 +687,7 @@ road_decay(void)
for (r=regions;r;r=r->next) {
boolean half = false;
if (rterrain(r) == T_SWAMP) {
if (r->terrain == newterrain(T_SWAMP)) {
/* wenn kein Damm existiert */
if (!buildingtype_exists(r, bt_dam)) {
half = true;

View File

@ -457,23 +457,23 @@ usage(const char * prog, const char * arg)
static void
setLuaString(lua_State * luaState, const char * name, const char * value)
{
#ifdef LUBIND_OLD
luabind::object globals = luabind::get_globals(luaState);
#ifdef LUABIND_OLD
luabind::object g = luabind::get_globals(luaState);
#else
luabind::object globals = luabind::globals(luaState);
luabind::object g = luabind::globals(luaState);
#endif
globals[name] = value;
g[name] = value;
}
static void
setLuaNumber(lua_State * luaState, const char * name, double value)
{
#if BOOST_VERSION > 103002
luabind::object globals = luabind::globals(luaState);
#ifdef LUABIND_OLD
luabind::object g = luabind::get_globals(luaState);
#else
luabind::object globals = luabind::get_globals(luaState);
luabind::object g = luabind::globals(luaState);
#endif
globals[name] = value;
g[name] = value;
}
static int