Spezialfall: Einheiten, die nicht laufen können.

LUA: Rasse ändern ändert auch irace.
This commit is contained in:
Enno Rehling 2005-12-31 16:13:20 +00:00
parent 90e8fb11fd
commit 9bf60a5451
2 changed files with 24 additions and 16 deletions

View File

@ -1302,12 +1302,29 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order
/* check movement from/to oceans. /* check movement from/to oceans.
* aquarian special, flying units, horses, the works */ * aquarian special, flying units, horses, the works */
if ((u->race->flags & RCF_FLY) == 0) { if ((u->race->flags & RCF_FLY) == 0) {
if (fval(current->terrain, SEA_REGION) && !fval(next->terrain, SEA_REGION)) { if (!fval(next->terrain, SEA_REGION)) {
int moving = u->race->flags & (RCF_SWIM|RCF_WALK|RCF_COASTAL); /* next region is land */
/* Die Einheit kann nicht fliegen, ist im Ozean, und will an Land */ if (fval(current->terrain, SEA_REGION)) {
if (moving != (RCF_SWIM|RCF_WALK) && (moving|RCF_COASTAL) == 0) { int moving = u->race->flags & (RCF_SWIM|RCF_WALK|RCF_COASTAL);
/* can't swim+walk and isn't allowed to enter coast from sea */ /* Die Einheit kann nicht fliegen, ist im Ozean, und will an Land */
if (ord!=NULL) cmistake(u, ord, 44, MSG_MOVE); if (moving != (RCF_SWIM|RCF_WALK) && (moving|RCF_COASTAL) == 0) {
/* can't swim+walk and isn't allowed to enter coast from sea */
if (ord!=NULL) cmistake(u, ord, 44, MSG_MOVE);
break;
}
} else if ((u->race->flags & RCF_WALK) == 0) {
/* Spezialeinheiten, die nicht laufen können. */
int moving = u->race->flags & (RCF_SWIM|RCF_WALK|RCF_COASTAL);
ADDMSG(&u->faction->msgs, msg_message("detectocean",
"unit region", u, next));
break;
}
} else {
/* Ozeanfelder können nur von Einheiten mit Schwimmen und ohne
* Pferde betreten werden. */
if (!(canswim(u) || canfly(u))) {
ADDMSG(&u->faction->msgs, msg_message("detectocean",
"unit region", u, next));
break; break;
} }
} }
@ -1321,16 +1338,6 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order
} }
} }
/* Ozeanfelder können nur von Einheiten mit Schwimmen und ohne
* Pferde betreten werden. */
if (fval(next->terrain, SEA_REGION)) {
if (!(canswim(u) || canfly(u))) {
ADDMSG(&u->faction->msgs, msg_message("detectocean",
"unit region", u, next));
break;
}
}
} }
/* movement blocked by a wall */ /* movement blocked by a wall */

View File

@ -175,6 +175,7 @@ unit_setrace(unit& u, const char * rcname)
{ {
race * rc = rc_find(rcname); race * rc = rc_find(rcname);
if (rc!=NULL) { if (rc!=NULL) {
if (u.irace==u.race) u.irace = rc;
u.race = rc; u.race = rc;
} }
} }