forked from github/server
Schiffe können, wenn CHECK_OVERLOAD_ON_ENTER defined ist, nicht betreten werden wenn das die Kapazität sprengt.
This commit is contained in:
parent
69dcc7c17b
commit
76b0371100
|
@ -837,7 +837,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere, int mode)
|
|||
cmistake(u, S->s, notfound_error, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
if (u == u2){
|
||||
if (u == u2) {
|
||||
cmistake(u, S->s, 8, MSG_COMMERCE);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ can_contact(const region * r, const unit * u, const unit * u2)
|
|||
|
||||
|
||||
static void
|
||||
set_contact(const region * r, unit * u, char try)
|
||||
set_contact(const region * r, unit * u, boolean try)
|
||||
{
|
||||
|
||||
/* unit u kontaktiert unit u2. Dies setzt den contact einfach auf 1 -
|
||||
|
@ -1027,10 +1027,10 @@ mayenter(region * r, unit * u, building * b)
|
|||
}
|
||||
|
||||
static int
|
||||
mayboard(region * r, unit * u, ship * sh)
|
||||
mayboard(const unit * u, const ship * sh)
|
||||
{
|
||||
unit *u2;
|
||||
u2 = shipowner(r, sh);
|
||||
u2 = shipowner(sh->region, sh);
|
||||
|
||||
return (!u2
|
||||
|| ucontact(u2, u)
|
||||
|
@ -1091,15 +1091,57 @@ do_leave(void)
|
|||
}
|
||||
}
|
||||
|
||||
static boolean
|
||||
entership(unit * u, ship * sh, const char * cmd, boolean lasttry)
|
||||
{
|
||||
/* Muß abgefangen werden, sonst könnten Schwimmer an
|
||||
* Bord von Schiffen an Land gelangen. */
|
||||
if( !fval(u->race, RCF_WALK) &&
|
||||
!fval(u->race, RCF_FLY)) {
|
||||
cmistake(u, cmd, 233, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sh) {
|
||||
if (lasttry) cmistake(u, cmd, 20, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
if (!mayboard(u, sh)) {
|
||||
if (lasttry) cmistake(u, cmd, 34, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
#ifdef CHECK_OVERLOAD_ON_ENTER
|
||||
{
|
||||
int sweight, scabins;
|
||||
getshipweight(sh, &sweight, &scabins);
|
||||
sweight += weight(u);
|
||||
scabins += u->number;
|
||||
|
||||
if (sweight > shipcapacity(sh) || scabins > sh->type->cabins) {
|
||||
if (lasttry) cmistake(u, cmd, 34, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
leave(u->region, u);
|
||||
u->ship = sh;
|
||||
|
||||
if (shipowner(u->region, sh) == 0) {
|
||||
fset(u, FL_OWNER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
do_misc(char try)
|
||||
do_misc(boolean lasttry)
|
||||
{
|
||||
region *r;
|
||||
strlist *S, *Snext;
|
||||
ship *sh;
|
||||
building *b;
|
||||
|
||||
/* try: Fehler nur im zweiten Versuch melden. Sonst konfus. */
|
||||
/* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit *u;
|
||||
|
@ -1108,7 +1150,7 @@ do_misc(char try)
|
|||
for (S = u->orders; S; S = S->next) {
|
||||
switch (igetkeyword(S->s, u->faction->locale)) {
|
||||
case K_CONTACT:
|
||||
set_contact(r, u, try);
|
||||
set_contact(r, u, lasttry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1129,7 +1171,7 @@ do_misc(char try)
|
|||
* auf dem Ozean */
|
||||
if( !fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) {
|
||||
if (rterrain(r) != T_OCEAN){
|
||||
if (try) cmistake(u, S->s, 232, MSG_MOVE);
|
||||
if (lasttry) cmistake(u, S->s, 232, MSG_MOVE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1137,17 +1179,17 @@ do_misc(char try)
|
|||
b = getbuilding(r);
|
||||
|
||||
if (!b) {
|
||||
if(try) cmistake(u, S->s, 6, MSG_MOVE);
|
||||
if(lasttry) cmistake(u, S->s, 6, MSG_MOVE);
|
||||
break;
|
||||
}
|
||||
/* Gebäude auf dem Ozean sollte man betreten dürfen
|
||||
if(rterrain(r) == T_OCEAN) {
|
||||
if (try) cmistake(u, S->s, 297, MSG_MOVE);
|
||||
if (lasttry) cmistake(u, S->s, 297, MSG_MOVE);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
if (!mayenter(r, u, b)) {
|
||||
if(try) {
|
||||
if(lasttry) {
|
||||
sprintf(buf, "Der Eintritt in %s wurde verwehrt",
|
||||
buildingname(b));
|
||||
mistake(u, S->s, buf, MSG_MOVE);
|
||||
|
@ -1155,7 +1197,7 @@ do_misc(char try)
|
|||
break;
|
||||
}
|
||||
if (!slipthru(r, u, b)) {
|
||||
if(try) {
|
||||
if(lasttry) {
|
||||
sprintf(buf, "%s wird belagert", buildingname(b));
|
||||
mistake(u, S->s, buf, MSG_MOVE);
|
||||
}
|
||||
|
@ -1175,44 +1217,17 @@ do_misc(char try)
|
|||
break;
|
||||
|
||||
case P_SHIP:
|
||||
|
||||
/* Muß abgefangen werden, sonst könnten Schwimmer an
|
||||
* Bord von Schiffen an Land gelangen. */
|
||||
|
||||
if( !fval(u->race, RCF_WALK) &&
|
||||
!fval(u->race, RCF_FLY)) {
|
||||
cmistake(u, S->s, 233, MSG_MOVE);
|
||||
S = Snext;
|
||||
continue;
|
||||
}
|
||||
|
||||
sh = getship(r);
|
||||
|
||||
if (!sh) {
|
||||
if(try) cmistake(u, S->s, 20, MSG_MOVE);
|
||||
break;
|
||||
}
|
||||
if (!mayboard(r, u, sh)) {
|
||||
if(try) cmistake(u, S->s, 34, 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. */
|
||||
removelist(&u->orders, S);
|
||||
|
||||
leave(r, u);
|
||||
u->ship = sh;
|
||||
/* Wozu sollte das gut sein? */
|
||||
/* freset(u, FL_LEFTSHIP); */
|
||||
if (shipowner(r, sh) == 0) {
|
||||
fset(u, FL_OWNER);
|
||||
if (entership(u, sh, S->s, lasttry)) {
|
||||
/* Wenn wir hier angekommen sind, war der Befehl
|
||||
* erfolgreich und wir löschen ihn, damit er im
|
||||
* zweiten Versuch nicht nochmal ausgeführt wird. */
|
||||
removelist(&u->orders, S);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if(try) cmistake(u, S->s, 79, MSG_MOVE);
|
||||
if(lasttry) cmistake(u, S->s, 79, MSG_MOVE);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ struct ship *getship(const struct region * r);
|
|||
|
||||
void remove_contacts(void);
|
||||
void do_leave(void);
|
||||
void do_misc(char try);
|
||||
void do_misc(boolean try);
|
||||
|
||||
void reportevent(struct region * r, char *s);
|
||||
|
||||
|
|
|
@ -361,28 +361,6 @@ count_skill(faction * f, skill_t sk)
|
|||
return n;
|
||||
}
|
||||
|
||||
int
|
||||
shipcapacity (const ship * sh)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* sonst ist construction:: size nicht ship_type::maxsize */
|
||||
assert(!sh->type->construction || sh->type->construction->improvement==NULL);
|
||||
|
||||
if (sh->type->construction && sh->size!=sh->type->construction->maxsize)
|
||||
return 0;
|
||||
|
||||
#ifdef SHIPDAMAGE
|
||||
i = ((sh->size * DAMAGE_SCALE - sh->damage) / DAMAGE_SCALE)
|
||||
* sh->type->cargo / sh->size;
|
||||
i += ((sh->size * DAMAGE_SCALE - sh->damage) % DAMAGE_SCALE)
|
||||
* sh->type->cargo / (sh->size*DAMAGE_SCALE);
|
||||
#else
|
||||
i = sh->type->cargo;
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
|
||||
int quiet = 0;
|
||||
|
||||
FILE *debug;
|
||||
|
|
|
@ -735,7 +735,6 @@ enum {
|
|||
|
||||
#define MAXSPEED 21
|
||||
|
||||
int shipcapacity(const struct ship * sh);
|
||||
int shipspeed(struct ship * sh, const struct unit * u);
|
||||
|
||||
/* MAXSPEED setzt die groesse fuer den Array, der die Kuesten Beschreibungen
|
||||
|
|
|
@ -355,18 +355,13 @@ boolean
|
|||
cansail(const region * r, ship * sh)
|
||||
{
|
||||
int n = 0, p = 0;
|
||||
unit *u;
|
||||
|
||||
/* sonst ist construction:: size nicht ship_type::maxsize */
|
||||
assert(!sh->type->construction || sh->type->construction->improvement==NULL);
|
||||
|
||||
if (sh->type->construction && sh->size!=sh->type->construction->maxsize)
|
||||
return false;
|
||||
for (u = r->units; u; u = u->next)
|
||||
if (u->ship == sh) {
|
||||
n += weight(u);
|
||||
p += u->number;
|
||||
}
|
||||
getshipweight(sh, &n, &p);
|
||||
|
||||
if( is_cursed(sh->attribs, C_SHIP_FLYING, 0) ) {
|
||||
if (sh->type->cargo>500*100)
|
||||
|
|
|
@ -195,6 +195,41 @@ shipname(const ship * sh)
|
|||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
shipcapacity (const ship * sh)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* sonst ist construction:: size nicht ship_type::maxsize */
|
||||
assert(!sh->type->construction || sh->type->construction->improvement==NULL);
|
||||
|
||||
if (sh->type->construction && sh->size!=sh->type->construction->maxsize)
|
||||
return 0;
|
||||
|
||||
#ifdef SHIPDAMAGE
|
||||
i = ((sh->size * DAMAGE_SCALE - sh->damage) / DAMAGE_SCALE)
|
||||
* sh->type->cargo / sh->size;
|
||||
i += ((sh->size * DAMAGE_SCALE - sh->damage) % DAMAGE_SCALE)
|
||||
* sh->type->cargo / (sh->size*DAMAGE_SCALE);
|
||||
#else
|
||||
i = sh->type->cargo;
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
getshipweight(const ship * sh, int *sweight, int *scabins)
|
||||
{
|
||||
unit * u;
|
||||
*sweight = 0;
|
||||
*scabins = 0;
|
||||
for (u = sh->region->units; u; u = u->next)
|
||||
if (u->ship == sh) {
|
||||
*sweight += weight(u);
|
||||
*scabins += u->number;
|
||||
}
|
||||
}
|
||||
|
||||
unit *
|
||||
shipowner(const region * r, const ship * sh)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,8 @@ typedef struct ship {
|
|||
extern void damage_ship(ship *sh, double percent);
|
||||
extern struct unit *captain(ship *sh, struct region *r);
|
||||
extern struct unit *shipowner(const struct region * r, const struct ship * sh);
|
||||
extern int shipcapacity(const struct ship * sh);
|
||||
extern void getshipweight(const struct ship * sh, int *weight, int *cabins);
|
||||
|
||||
extern ship *new_ship(const struct ship_type * stype, struct region * r);
|
||||
extern const char *shipname(const struct ship * sh);
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#define TEACHDIFFERENCE 2
|
||||
#define GIVERESTRICTION 3
|
||||
|
||||
#undef CHECK_OVERLOAD_ON_ENTER
|
||||
|
||||
#define MUSEUM_MODULE
|
||||
#define ARENA_MODULE
|
||||
|
||||
|
|
Loading…
Reference in New Issue