diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 0780a537a..c217b3eb9 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -468,7 +468,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders) if (rc == new_race[RC_INSECT]) { gamedate date; get_gamedate(turn, &date); - if (date.season == 0 && rterrain(r) != T_DESERT) { + if (date.season == 0 && r->terrain != newterrain(T_DESERT)) { #ifdef INSECT_POTION boolean usepotion = false; unit *u2; @@ -1984,7 +1984,7 @@ buy(unit * u, request ** buyorders, struct order * ord) if (u->race == new_race[RC_INSECT]) { /* entweder man ist insekt, oder... */ - if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT && !rbuildings(r)) { + if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT) && !rbuildings(r)) { cmistake(u, ord, 119, MSG_COMMERCE); return; } @@ -2113,7 +2113,7 @@ expandselling(region * r, request * sellorders, int limit) max_products = rpeasants(r) / TRADE_FRACTION; if (max_products <= 0) return; - if (rterrain(r) == T_DESERT && buildingtype_exists(r, bt_find("caravan"))) { + if (r->terrain == newterrain(T_DESERT) && buildingtype_exists(r, bt_find("caravan"))) { max_products = rpeasants(r) * 2 / TRADE_FRACTION; } /* Verkauf: so programmiert, dass er leicht auf mehrere Gueter pro @@ -2255,7 +2255,7 @@ static boolean if (findparam(s, u->faction->locale) == P_ANY) { unlimited = false; n = rpeasants(r) / TRADE_FRACTION; - if (rterrain(r) == T_DESERT && buildingtype_exists(r, bt_find("caravan"))) + if (r->terrain == newterrain(T_DESERT) && buildingtype_exists(r, bt_find("caravan"))) n *= 2; if (n==0) { cmistake(u, ord, 303, MSG_COMMERCE); @@ -2278,7 +2278,7 @@ static boolean /* In der Region muß es eine Burg geben. */ if (u->race == new_race[RC_INSECT]) { - if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT && !rbuildings(r)) { + if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT) && !rbuildings(r)) { cmistake(u, ord, 119, MSG_COMMERCE); return false; } @@ -3269,7 +3269,7 @@ produce(void) if (sellorders) { int limit = rpeasants(r) / TRADE_FRACTION; - if (rterrain(r) == T_DESERT && buildingtype_exists(r, bt_find("caravan"))) + if (r->terrain == newterrain(T_DESERT) && buildingtype_exists(r, bt_find("caravan"))) limit *= 2; expandselling(r, sellorders, limited?limit:INT_MAX); } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index e2dd7beb1..c2cfefdc9 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -408,7 +408,7 @@ calculate_emigration(region *r) int rp = rpeasants(r); int max_immigrants = MAX_IMMIGRATION(maxp-rp); - if (rterrain(r) == T_VOLCANO || rterrain(r) == T_VOLCANO_SMOKING) { + if (r->terrain == newterrain(T_VOLCANO) || r->terrain == newterrain(T_VOLCANO_SMOKING)) { max_immigrants = max_immigrants/10; } diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index b5b9e0a99..e02ad5dd6 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -1063,7 +1063,7 @@ spawn_dragons(void) equip_unit(u, get_equipment("monster_seaserpent")); } - if ((rterrain(r) == T_GLACIER || r->terrain == newterrain(T_SWAMP) || rterrain(r) == T_DESERT) && rng_int() % 10000 < (5 + 100 * chaosfactor(r))) + if ((r->terrain == newterrain(T_GLACIER) || r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT)) && rng_int() % 10000 < (5 + 100 * chaosfactor(r))) { if (chance(0.80)) { u = createunit(r, monsters, nrand(60, 20) + 1, new_race[RC_FIREDRAGON]); diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 8895db307..c5e1be227 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -491,7 +491,7 @@ chaos(region * r) while (r->buildings) { remove_building(&r->buildings, r->buildings); } - terraform(r, T_OCEAN); + terraform_region(r, newterrain(T_OCEAN)); } } else { direction_t dir; @@ -778,7 +778,7 @@ melt_iceberg(region *r) } /* in Ozean wandeln */ - terraform(r, T_OCEAN); + terraform_region(r, newterrain(T_OCEAN)); /* Einheiten, die nicht schwimmen können oder in Schiffen sind, * ertrinken */ @@ -904,7 +904,7 @@ move_icebergs(void) region *r; for (r=regions; r; r=r->next) { - if (rterrain(r) == T_ICEBERG && !fval(r, RF_SELECT)) { + if (r->terrain == newterrain(T_ICEBERG) && !fval(r, RF_SELECT)) { int select = rng_int() % 10; if (select < 4) { /* 4% chance */ @@ -925,7 +925,7 @@ create_icebergs(void) region *r; for (r=regions; r; r=r->next) { - if (rterrain(r) == T_ICEBERG_SLEEP && chance(0.05)) { + if (r->terrain == newterrain(T_ICEBERG_SLEEP) && chance(0.05)) { boolean has_ocean_neighbour = false; direction_t dir; region *rc; @@ -1216,7 +1216,7 @@ randomevents(void) /* Vulkane qualmen, brechen aus ... */ for (r = regions; r; r = r->next) { - if (rterrain(r)==T_VOLCANO_SMOKING && a_find(r->attribs, &at_reduceproduction)) { + if (r->terrain == newterrain(T_VOLCANO_SMOKING) && a_find(r->attribs, &at_reduceproduction)) { ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); rsetterrain(r, T_VOLCANO); } else switch(rterrain(r)) { diff --git a/src/common/gamecode/summary.c b/src/common/gamecode/summary.c index 49bccda40..0f963c4c5 100644 --- a/src/common/gamecode/summary.c +++ b/src/common/gamecode/summary.c @@ -348,9 +348,9 @@ make_summary(void) if (fval(r, RF_ORCIFIED)) { s->orkifizierte_regionen++; } - if (rterrain(r) == T_VOLCANO) { + if (r->terrain == newterrain(T_VOLCANO)) { s->inactive_volcanos++; - } else if(rterrain(r) == T_VOLCANO_SMOKING) { + } else if (r->terrain == newterrain(T_VOLCANO_SMOKING)) { s->active_volcanos++; } } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 4817fa8e6..675bedc02 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -3523,9 +3523,9 @@ static void flee(const troop dt) { fighter * fig = dt.fighter; + unit * u = fig->unit; #ifndef SIMPLE_ESCAPE - unit * u = fig->unit; int carry = personcapacity(u) - u->race->weight; int money; diff --git a/src/common/kernel/move.c b/src/common/kernel/move.c index f33720276..5d3640f83 100644 --- a/src/common/kernel/move.c +++ b/src/common/kernel/move.c @@ -1783,8 +1783,10 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep) } if (sh->damage>=sh->size * DAMAGE_SCALE) { - ADDMSG(&f->msgs, msg_message("shipsink", "ship", sh)); - remove_ship(&sh->region->ships, sh); + if (sh->region) { + ADDMSG(&f->msgs, msg_message("shipsink", "ship", sh)); + remove_ship(&sh->region->ships, sh); + } sh = NULL; } diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 22cdeede3..94d6d10c3 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -1046,12 +1046,6 @@ setluxuries(region * r, const luxury_type * sale) } } -void -terraform(region * r, terrain_t t) -{ - terraform_region(r, newterrain(t)); -} - void terraform_region(region * r, const terrain_type * terrain) { diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index 2a8961a8f..4ffb77959 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -222,7 +222,6 @@ extern const char * write_regionname(const struct region * r, const struct facti extern struct region * new_region(short x, short y, unsigned int uid); extern void remove_region(region ** rlist, region * r); -extern void terraform(struct region * r, terrain_t terrain); extern void terraform_region(struct region * r, const struct terrain_type * terrain); extern const short delta_x[MAXDIRECTIONS]; diff --git a/src/common/kernel/terrain.c b/src/common/kernel/terrain.c index 299d2bbb7..32ce66d3b 100644 --- a/src/common/kernel/terrain.c +++ b/src/common/kernel/terrain.c @@ -145,8 +145,6 @@ init_terrains(void) newterrain = get_terrain(terraindata[t]); if (newterrain!=NULL) { newterrains[t] = newterrain; - } else { - log_warning(("missing classic terrain %s\n", terraindata[t])); } } } diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 58cfe0f37..3acd815b3 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -291,14 +291,15 @@ read_newfactions(const char * filename) extern int numnewbies; -static terrain_t +static const terrain_type * preferred_terrain(const struct race * rc) { - if (rc==rc_find("dwarf")) return T_MOUNTAIN; - if (rc==rc_find("insect")) return T_DESERT; - if (rc==rc_find("halfling")) return T_SWAMP; - if (rc==rc_find("troll")) return T_MOUNTAIN; - return T_PLAIN; + terrain_t t = T_PLAIN; + if (rc==rc_find("dwarf")) t = T_MOUNTAIN; + if (rc==rc_find("insect")) t = T_DESERT; + if (rc==rc_find("halfling")) t = T_SWAMP; + if (rc==rc_find("troll")) t = T_MOUNTAIN; + return newterrain(t); } #define REGIONS_PER_FACTION 2 @@ -413,20 +414,20 @@ free_newfaction(newfaction * nf) * returns the number of players placed on the new island. */ static void -frame_regions(int age, terrain_t terrain) +frame_regions(int age, const terrain_type * terrain) { region * r = regions; for (r=regions;r;r=r->next) { direction_t d; if (r->ageplanep) continue; - if (rterrain(r)==terrain) continue; + if (r->terrain == terrain) continue; for (d=0;d!=MAXDIRECTIONS;++d) { region * rn = rconnect(r, d); if (rn==NULL) { rn = new_region(r->x+delta_x[d], r->y+delta_y[d], 0); - terraform(rn, terrain); + terraform_region(rn, terrain); rn->age=r->age; } } @@ -475,7 +476,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) int psize = 0; /* players on this island */ const terrain_type * volcano_terrain = get_terrain("volcano"); - frame_regions(16, T_FIREWALL); + frame_regions(16, newterrain(T_FIREWALL)); if (listlen(*players)next) { struct plane * p = r->planep; - if (r->age<=max_agediff && rterrain(r)==T_OCEAN && p==NULL && virgin_region(r)) { + if (r->age<=max_agediff && r->terrain == newterrain(T_OCEAN) && p==NULL && virgin_region(r)) { direction_t d; for (d=0;d!=MAXDIRECTIONS;++d) { region * rn = rconnect(r, d); @@ -533,7 +534,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) */ for (r=regions;r;r=r->next) { struct plane * p = r->planep; - if (rterrain(r)==T_OCEAN && p==0 && (rmin==NULL || r->age<=max_agediff)) { + if (r->terrain == newterrain(T_OCEAN) && p==0 && (rmin==NULL || r->age<=max_agediff)) { direction_t d; for (d=0;d!=MAXDIRECTIONS;++d) { region * rn = rconnect(r, d); @@ -554,7 +555,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) x = rmin->x + delta_x[dmin]; y = rmin->y + delta_y[dmin]; r = new_region(x, y, 0); - terraform(r, T_OCEAN); /* we change the terrain later */ + terraform_region(r, newterrain(T_OCEAN)); } } if (r!=NULL) { @@ -580,7 +581,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) if (rn && fval(rn, RF_MARK)) continue; if (rn==NULL) { rn = new_region(r->x + delta_x[d], r->y + delta_y[d], 0); - terraform(rn, T_OCEAN); + terraform_region(rn, newterrain(T_OCEAN)); } if (virgin_region(rn)) { add_regionlist(&rlist, rn); @@ -596,7 +597,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) unit * u; isize += REGIONS_PER_FACTION; - terraform(r, preferred_terrain(nextf->race)); + terraform_region(r, preferred_terrain(nextf->race)); prepare_starting_region(r); ++tsize; assert(r->land && r->units==0); @@ -689,7 +690,7 @@ autoseed(newfaction ** players, int nsize, int max_agediff) if (i!=MAXFILLDIST) { while (--i) { region * rn = new_region(r->x + i*delta_x[d], r->y + i*delta_y[d], 0); - terraform(rn, T_OCEAN); + terraform_region(rn, newterrain(T_OCEAN)); } } } diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index e46f9c4a3..89eb551c5 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -643,11 +643,11 @@ gm_addquest(const char * email, const char * name, short radius, unsigned int fl freset(r, RF_ENCOUNTER); r->planep = p; if (distance(r, center)==radius) { - terraform(r, T_FIREWALL); + terraform_region(r, newterrain(T_FIREWALL)); } else if (r==center) { - terraform(r, T_PLAIN); + terraform_region(r, newterrain(T_PLAIN)); } else { - terraform(r, T_OCEAN); + terraform_region(r, newterrain(T_OCEAN)); } } } @@ -757,11 +757,11 @@ gm_addplane(short radius, unsigned int flags, const char * name) freset(r, RF_ENCOUNTER); r->planep = p; if (distance(r, center)==radius) { - terraform(r, T_FIREWALL); + terraform_region(r, newterrain(T_FIREWALL)); } else if (r==center) { - terraform(r, T_PLAIN); + terraform_region(r, newterrain(T_PLAIN)); } else { - terraform(r, T_OCEAN); + terraform_region(r, newterrain(T_OCEAN)); } } } diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 6c53e97d2..d92fcc1e7 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -2135,7 +2135,7 @@ sp_ironkeeper(castorder *co) int cast_level = co->level; message * msg; - if (rterrain(r) != T_MOUNTAIN && rterrain(r) != T_GLACIER) { + if (r->terrain != newterrain(T_MOUNTAIN) && r->terrain != newterrain(T_GLACIER)) { report_failure(mage, co->order); return 0; } @@ -2547,8 +2547,8 @@ sp_summondragon(castorder *co) f = get_monsters(); - if (r->terrain != newterrain(T_SWAMP) && rterrain(r) != T_DESERT - && rterrain(r) != T_GLACIER) { + if (r->terrain != newterrain(T_SWAMP) && r->terrain != newterrain(T_DESERT) + && r->terrain != newterrain(T_GLACIER)) { report_failure(mage, co->order); return 0; } diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 2a82f0f00..54ead0d81 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -97,7 +97,7 @@ curse_emptiness(void) unit * u = r->units; if (r->land==NULL) continue; if (fval(r, RF_CHAOTIC)) continue; - if (rterrain(r)==T_GLACIER) continue; + if (r->terrain == newterrain(T_GLACIER)) continue; if (r->age<=200) continue; if (get_curse(r->attribs, ct)) continue; while (u && is_monsters(u->faction)) u=u->next; @@ -440,13 +440,13 @@ road_decay(void) half = true; } } - else if (rterrain(r) == T_DESERT) { + else if (r->terrain == newterrain(T_DESERT)) { /* wenn keine Karawanserei existiert */ if (!buildingtype_exists(r, bt_caravan)) { half = true; } } - else if (rterrain(r) == T_GLACIER) { + else if (r->terrain == newterrain(T_GLACIER)) { /* wenn kein Tunnel existiert */ if (!buildingtype_exists(r, bt_tunnel)) { half = true; @@ -484,7 +484,7 @@ iceberg(region * r) } } if (d==MAXDIRECTIONS) { - terraform(r, T_ICEBERG_SLEEP); + terraform_region(r, newterrain(T_ICEBERG_SLEEP)); } } @@ -528,9 +528,9 @@ fix_astralplane(void) while (*rs_p) { region * rs = *rs_p; - if (rterrain(rs)==T_FIREWALL && rplane(rs)==NULL) { + if (rs->terrain == newterrain(T_FIREWALL) && rplane(rs)==NULL) { region * ra = r_standard_to_astral(rs); - if (ra && rterrain(ra)!=T_ASTRALB) { + if (ra && ra->terrain != newterrain(T_ASTRALB)) { unit * u; ++fixes; for (u=ra->units;u;u=u->next) { @@ -544,7 +544,7 @@ fix_astralplane(void) remove_unit(&ra->units, ra->units); } log_printf("protecting firewall in %s by blocking astral space in %s.\n", regionname(rs, NULL), regionname(ra, NULL)); - terraform(ra, T_ASTRALB); + terraform_region(ra, newterrain(T_ASTRALB)); } } } @@ -747,8 +747,8 @@ fix_astral_firewalls(void) { region * r; for (r = regions; r; r=r->next) { - if (r->planep==get_astralplane() && rterrain(r)==T_FIREWALL) { - terraform(r, T_ASTRALB); + if (r->planep==get_astralplane() && r->terrain == newterrain(T_FIREWALL)) { + terraform_region(r, newterrain(T_ASTRALB)); } } return 0; diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index 2bf7c8e18..fff9a9e6d 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -169,7 +169,7 @@ static eressea::list building_units(const building& b) { region * r = b.region; unit * u = r->units; - while (u!=NULL && u->building!=&b) u=u->next; + while (u!=NULL && (!u->building || u->building->no!=b.no)) u=u->next; return eressea::list(u); } diff --git a/src/res/eressea/strings.xml b/src/res/eressea/strings.xml index e3f4d4f99..9fc4249c7 100644 --- a/src/res/eressea/strings.xml +++ b/src/res/eressea/strings.xml @@ -358,6 +358,10 @@ + + Adamantium + adamantium + Adamantium adamantium diff --git a/src/scripts/eressea/tunnels.lua b/src/scripts/eressea/tunnels.lua index 592f6a101..f1cb88744 100644 --- a/src/scripts/eressea/tunnels.lua +++ b/src/scripts/eressea/tunnels.lua @@ -1,6 +1,9 @@ -local function tunnel_travellers(b) - local units = {} +local function tunnel_travelers(b) + local units = nil for u in b.units do + if units==nil then + units = {} + end units[u] = u end return units @@ -10,6 +13,7 @@ targets = nil ntargets = 0 local function get_target(param) + -- print("finding targets: " .. param) if targets == nil then targets = {} local r @@ -17,6 +21,7 @@ local function get_target(param) if r:get_key(param) then targets[ntargets] = r ntargets = ntargets + 1 + -- print("target: " .. tostring(r)) end end end @@ -30,12 +35,12 @@ end -- export, will be called from lc_age() function tunnel_action(b, param) local r = nil - print("Tunnel from " .. tostring(b) .. " [" .. param .. "]") if tonumber(param)~=nil then r = get_region_by_id(tonumber(param)) end - if r~=nil then - local units = tunnel_travelers(b) + local units = tunnel_travelers(b) + if units~=nil then + print("Tunnel from " .. tostring(b) .. " [" .. param .. "]") for key, u in pairs(units) do local rto = r if r==nil then