diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 215a65648..3c4a00780 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -973,6 +973,7 @@ maintain(building * b, boolean first) return true; } +#ifdef COLLAPSE_CHANCE static void gebaeude_stuerzt_ein(region * r, building * b) { @@ -990,11 +991,13 @@ gebaeude_stuerzt_ein(region * r, building * b) freset(u, UFL_OWNER); leave(r,u); n = u->number; +#ifdef COLLAPSE_SURVIVAL for (i = 0; i < n; i++) { if (rng_double() >= COLLAPSE_SURVIVAL) { ++loss; } } +#endif scale_number(u, u->number - loss); opfer += loss; } @@ -1012,6 +1015,7 @@ gebaeude_stuerzt_ein(region * r, building * b) msg_release(msg); remove_building(&r->buildings, b); } +#endif void maintain_buildings(region * r, boolean crash) @@ -1023,10 +1027,13 @@ maintain_buildings(region * r, boolean crash) /* the second time, send a message */ if (crash) { +#ifdef COLLAPSE_CHANCE if (!maintained && (rng_double() < COLLAPSE_CHANCE)) { gebaeude_stuerzt_ein(r, b); continue; - } else if (!fval(b, BLD_WORKING)) { + } +#endif + if (!fval(b, BLD_WORKING)) { unit * u = buildingowner(r, b); const char * msgtype = maintained?"maintenance_nowork":"maintenance_none"; struct message * msg = msg_message(msgtype, "building", b); diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 0b93b9146..21a27bbe5 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -66,13 +66,15 @@ extern "C" { #define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCOST 30 /* Heilkosten */ -/** Monster */ +/* Chance of a monster attack */ +#define MONSTERATTACK 0.4F -#define MONSTERATTACK 0.4F /* Chance für Monsterangriff */ - -/** Gebäude */ -#define COLLAPSE_CHANCE 0.4F /* Chance für Einsturz bei unversorgtem Gebaeude */ -#define COLLAPSE_SURVIVAL 0.5F /* Soviele % überleben den Einsturz */ +/** Chance of an unmaintained building crashing */ +/* #define COLLAPSE_CHANCE 0.4F */ +#undef COLLAPSE_CHANCE +/** chance to survive the crash of a building */ +/* #define COLLAPSE_SURVIVAL 0.5F */ +#undef COLLAPSE_SURVIVAL /* Magiesystem */ #define NIGHT_EYE_TALENT 5 diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index fff9a9e6d..87977c84b 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -56,9 +56,9 @@ lc_age(struct attrib * a) try { if (fparam) { std::string param(fparam); - retval = luabind::call_function(L, fname, *b, param); + retval = luabind::call_function(L, fname, b, param); } else { - retval = luabind::call_function(L, fname, *b); + retval = luabind::call_function(L, fname, b); } } catch (luabind::error& e) { @@ -166,10 +166,10 @@ public: static eressea::list -building_units(const building& b) { - region * r = b.region; +building_units(const building * b) { + region * r = b->region; unit * u = r->units; - while (u!=NULL && (!u->building || u->building->no!=b.no)) u=u->next; + while (u!=NULL && (!u->building || u->building->no!=b->no)) u=u->next; return eressea::list(u); } diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index ce7b4995e..73eda48f1 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -317,9 +317,9 @@ unit_hpmax(const unit& u) } static void -unit_setregion(unit& u, region& r) +unit_setregion(unit * u, region * r) { - move_unit(&u, &r, NULL); + move_unit(u, r, NULL); } static region * @@ -329,13 +329,13 @@ unit_getregion(const unit& u) } static void -unit_setship(unit& u, ship& s) +unit_setship(unit& u, const ship& s) { leave(u.region, &u); if (u.region!=s.region) { - unit_setregion(u, *s.region); + move_unit(&u, s.region, NULL); } - u.ship = &s; + u.ship = findship(s.no); } static ship * @@ -345,13 +345,14 @@ unit_getship(const unit& u) } static void -unit_setbuilding(unit& u, building& b) +unit_setbuilding(unit * u, building * b) { - leave(u.region, &u); - if (u.region!=b.region) { - unit_setregion(u, *b.region); + leave(u->region, u); + if (u->region!=b->region) { + move_unit(u, b->region, NULL); } - u.building = &b; + assert(b==findbuilding(b->no)); + u->building = b; } static building *