"ID zu groß"
- fixed parameters for some lua functions (pointers/objects)
This commit is contained in:
Enno Rehling 2008-07-08 21:54:50 +00:00
parent 7c65bfc5f7
commit cf789999cf
4 changed files with 32 additions and 22 deletions

View File

@ -973,6 +973,7 @@ maintain(building * b, boolean first)
return true; return true;
} }
#ifdef COLLAPSE_CHANCE
static void static void
gebaeude_stuerzt_ein(region * r, building * b) gebaeude_stuerzt_ein(region * r, building * b)
{ {
@ -990,11 +991,13 @@ gebaeude_stuerzt_ein(region * r, building * b)
freset(u, UFL_OWNER); freset(u, UFL_OWNER);
leave(r,u); leave(r,u);
n = u->number; n = u->number;
#ifdef COLLAPSE_SURVIVAL
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (rng_double() >= COLLAPSE_SURVIVAL) { if (rng_double() >= COLLAPSE_SURVIVAL) {
++loss; ++loss;
} }
} }
#endif
scale_number(u, u->number - loss); scale_number(u, u->number - loss);
opfer += loss; opfer += loss;
} }
@ -1012,6 +1015,7 @@ gebaeude_stuerzt_ein(region * r, building * b)
msg_release(msg); msg_release(msg);
remove_building(&r->buildings, b); remove_building(&r->buildings, b);
} }
#endif
void void
maintain_buildings(region * r, boolean crash) maintain_buildings(region * r, boolean crash)
@ -1023,10 +1027,13 @@ maintain_buildings(region * r, boolean crash)
/* the second time, send a message */ /* the second time, send a message */
if (crash) { if (crash) {
#ifdef COLLAPSE_CHANCE
if (!maintained && (rng_double() < COLLAPSE_CHANCE)) { if (!maintained && (rng_double() < COLLAPSE_CHANCE)) {
gebaeude_stuerzt_ein(r, b); gebaeude_stuerzt_ein(r, b);
continue; continue;
} else if (!fval(b, BLD_WORKING)) { }
#endif
if (!fval(b, BLD_WORKING)) {
unit * u = buildingowner(r, b); unit * u = buildingowner(r, b);
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none"; const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
struct message * msg = msg_message(msgtype, "building", b); struct message * msg = msg_message(msgtype, "building", b);

View File

@ -66,13 +66,15 @@ extern "C" {
#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */ #define PLAGUE_HEALCOST 30 /* Heilkosten */
/** Monster */ /* Chance of a monster attack */
#define MONSTERATTACK 0.4F
#define MONSTERATTACK 0.4F /* Chance für Monsterangriff */ /** Chance of an unmaintained building crashing */
/* #define COLLAPSE_CHANCE 0.4F */
/** Gebäude */ #undef COLLAPSE_CHANCE
#define COLLAPSE_CHANCE 0.4F /* Chance für Einsturz bei unversorgtem Gebaeude */ /** chance to survive the crash of a building */
#define COLLAPSE_SURVIVAL 0.5F /* Soviele % überleben den Einsturz */ /* #define COLLAPSE_SURVIVAL 0.5F */
#undef COLLAPSE_SURVIVAL
/* Magiesystem */ /* Magiesystem */
#define NIGHT_EYE_TALENT 5 #define NIGHT_EYE_TALENT 5

View File

@ -56,9 +56,9 @@ lc_age(struct attrib * a)
try { try {
if (fparam) { if (fparam) {
std::string param(fparam); std::string param(fparam);
retval = luabind::call_function<int>(L, fname, *b, param); retval = luabind::call_function<int>(L, fname, b, param);
} else { } else {
retval = luabind::call_function<int>(L, fname, *b); retval = luabind::call_function<int>(L, fname, b);
} }
} }
catch (luabind::error& e) { catch (luabind::error& e) {
@ -166,10 +166,10 @@ public:
static eressea::list<unit *, unit *, buildingunit> static eressea::list<unit *, unit *, buildingunit>
building_units(const building& b) { building_units(const building * b) {
region * r = b.region; region * r = b->region;
unit * u = r->units; 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<unit *, unit *, buildingunit>(u); return eressea::list<unit *, unit *, buildingunit>(u);
} }

View File

@ -317,9 +317,9 @@ unit_hpmax(const unit& u)
} }
static void 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 * static region *
@ -329,13 +329,13 @@ unit_getregion(const unit& u)
} }
static void static void
unit_setship(unit& u, ship& s) unit_setship(unit& u, const ship& s)
{ {
leave(u.region, &u); leave(u.region, &u);
if (u.region!=s.region) { 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 * static ship *
@ -345,13 +345,14 @@ unit_getship(const unit& u)
} }
static void static void
unit_setbuilding(unit& u, building& b) unit_setbuilding(unit * u, building * b)
{ {
leave(u.region, &u); leave(u->region, u);
if (u.region!=b.region) { if (u->region!=b->region) {
unit_setregion(u, *b.region); move_unit(u, b->region, NULL);
} }
u.building = &b; assert(b==findbuilding(b->no));
u->building = b;
} }
static building * static building *