Steinbauer bekommen Steinbruchbonus obwohl Gebäude zu klein
  Personen, die gerade erst in ein Schiff oder Gebaeude neu hineinkommen, werden jetzt UNTEN an die existierenden Personen dransortiert.
This commit is contained in:
Enno Rehling 2006-05-25 13:09:10 +00:00
parent 8cd3685b56
commit 42ede42656
1 changed files with 122 additions and 72 deletions

View File

@ -1156,23 +1156,26 @@ leave_cmd(unit * u, struct order * ord)
} }
static boolean static boolean
entership(unit * u, ship * sh, struct order * ord, boolean lasttry) enter_ship(unit * u, struct order * ord, int id, boolean report)
{ {
region * r = u->region;
ship * sh;
/* Muß abgefangen werden, sonst könnten Schwimmer an /* Muß abgefangen werden, sonst könnten Schwimmer an
* Bord von Schiffen an Land gelangen. */ * Bord von Schiffen an Land gelangen. */
if( !fval(u->race, RCF_WALK) && if (!fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) {
!fval(u->race, RCF_FLY)) {
cmistake(u, ord, 233, MSG_MOVE); cmistake(u, ord, 233, MSG_MOVE);
return false; return false;
} }
if (!sh) { sh = findship(id);
if (lasttry) cmistake(u, ord, 20, MSG_MOVE); if (sh == NULL || sh->region!=r) {
if (report) cmistake(u, ord, 20, MSG_MOVE);
return false; return false;
} }
if (sh==u->ship) return true; if (sh==u->ship) return true;
if (!mayboard(u, sh)) { if (!mayboard(u, sh)) {
if (lasttry) cmistake(u, ord, 34, MSG_MOVE); if (report) cmistake(u, ord, 34, MSG_MOVE);
return false; return false;
} }
if (CheckOverload()) { if (CheckOverload()) {
@ -1186,7 +1189,7 @@ entership(unit * u, ship * sh, struct order * ord, boolean lasttry)
sweight = ((sweight+99) / 100) * 100; /* Silberreste aufrunden */ sweight = ((sweight+99) / 100) * 100; /* Silberreste aufrunden */
if (sweight > mweight || scabins > mcabins) { if (sweight > mweight || scabins > mcabins) {
if (lasttry) cmistake(u, ord, 34, MSG_MOVE); if (report) cmistake(u, ord, 34, MSG_MOVE);
return false; return false;
} }
} }
@ -1195,9 +1198,59 @@ entership(unit * u, ship * sh, struct order * ord, boolean lasttry)
leave(u->region, u); leave(u->region, u);
u->ship = sh; u->ship = sh;
if (shipowner(sh) == 0) { if (shipowner(sh) == NULL) {
fset(u, UFL_OWNER); fset(u, UFL_OWNER);
} }
fset(u, UFL_ENTER);
return true;
}
static boolean
enter_building(unit * u, order * ord, int id, boolean report)
{
region * r = u->region;
building * b;
/* Schwimmer können keine Gebäude betreten, außer diese sind
* auf dem Ozean */
if (!fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) {
if (!fval(r->terrain, SEA_REGION)) {
if (report) {
cmistake(u, ord, 232, MSG_MOVE);
}
return false;
}
}
b = findbuilding(id);
if (b==NULL || b->region!=r) {
if (report) {
cmistake(u, ord, 6, MSG_MOVE);
}
return false;
}
if (!mayenter(r, u, b)) {
if (report) {
sprintf(buf, "Der Eintritt in %s wurde verwehrt",
buildingname(b));
mistake(u, ord, buf, MSG_MOVE);
}
return false;
}
if (!slipthru(r, u, b)) {
if (report) {
sprintf(buf, "%s wird belagert", buildingname(b));
mistake(u, ord, buf, MSG_MOVE);
}
return false;
}
leave(r, u);
u->building = b;
if (buildingowner(r, b) == 0) {
fset(u, UFL_OWNER);
}
fset(u, UFL_ENTER);
return true; return true;
} }
@ -1205,93 +1258,90 @@ void
do_misc(boolean lasttry) do_misc(boolean lasttry)
{ {
region *r; region *r;
ship *sh;
building *b;
/* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */ /* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit *u; unit **uptr, *uc;
for (u = r->units; u; u = u->next) { for (uc = r->units; uc; uc = uc->next) {
order * ord; order * ord;
for (ord = u->orders; ord; ord = ord->next) { for (ord = uc->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) { switch (get_keyword(ord)) {
case K_CONTACT: case K_CONTACT:
contact_cmd(u, ord, lasttry); contact_cmd(uc, ord, lasttry);
break; break;
} }
} }
} }
for (u = r->units; u; u = u->next) { for (uptr = &r->units; *uptr;) {
unit * u = *uptr;
order ** ordp = &u->orders; order ** ordp = &u->orders;
while (*ordp) { while (*ordp) {
order * ord = *ordp; order * ord = *ordp;
if (get_keyword(ord) == K_ENTER) { if (get_keyword(ord) == K_ENTER) {
param_t p;
int id;
unit * ulast = NULL;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
switch (getparam(u->faction->locale)) { p = getparam(u->faction->locale);
id = getid();
switch (p) {
case P_BUILDING: case P_BUILDING:
case P_GEBAEUDE: case P_GEBAEUDE:
/* Schwimmer können keine Gebäude betreten, außer diese sind if (u->building && u->building->no==id) break;
* auf dem Ozean */ if (enter_building(u, ord, id, lasttry)) {
if( !fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) { unit *ub;
if (!fval(r->terrain, SEA_REGION)) { for (ub=u;ub;ub=ub->next) {
if (lasttry) cmistake(u, ord, 232, MSG_MOVE); if (ub->building==u->building) {
break; ulast = ub;
}
} }
} }
b = getbuilding(r);
if (!b) {
if(lasttry) cmistake(u, ord, 6, MSG_MOVE);
break;
}
if (!mayenter(r, u, b)) {
if(lasttry) {
sprintf(buf, "Der Eintritt in %s wurde verwehrt",
buildingname(b));
mistake(u, ord, buf, MSG_MOVE);
}
break;
}
if (!slipthru(r, u, b)) {
if(lasttry) {
sprintf(buf, "%s wird belagert", buildingname(b));
mistake(u, ord, buf, MSG_MOVE);
}
break;
}
/* Wenn wir hier angekommen sind, war der Befehl
* erfolgreich und wir löschen ihn, damit er im
* zweiten Versuch nicht nochmal ausgeführt wird. */
*ordp = ord->next;
ord->next = NULL;
free_order(ord);
leave(r, u);
u->building = b;
if (buildingowner(r, b) == 0) {
fset(u, UFL_OWNER);
}
fset(u, UFL_ENTER);
break; break;
case P_SHIP: case P_SHIP:
sh = getship(r); if (u->ship && u->ship->no==id) break;
entership(u, sh, ord, lasttry); if (enter_ship(u, ord, id, lasttry)) {
fset(u, UFL_ENTER); unit *ub;
ulast = u;
for (ub=u;ub;ub=ub->next) {
if (ub->ship==u->ship) {
ulast = ub;
}
}
}
break; break;
default: default:
if (lasttry) cmistake(u, ord, 79, MSG_MOVE); if (lasttry) cmistake(u, ord, 79, MSG_MOVE);
} }
if (ulast!=NULL) {
/* Wenn wir hier angekommen sind, war der Befehl
* erfolgreich und wir löschen ihn, damit er im
* zweiten Versuch nicht nochmal ausgeführt wird. */
*ordp = ord->next;
ord->next = NULL;
free_order(ord);
if (ulast!=u) {
/* put u behind ulast so it's the last unit in the building */
*uptr = u->next;
u->next = ulast->next;
ulast->next = u;
}
break;
}
} }
if (*ordp==ord) ordp = &ord->next; if (*ordp==ord) ordp = &ord->next;
} }
if (*uptr==u) uptr = &u->next;
} }
} }
} }