forked from github/server
Noch einmal Strassen reparieren.
This commit is contained in:
parent
032cc5eadf
commit
70413bb43c
|
@ -296,11 +296,15 @@ do_siege(void)
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_road(unit *u, int n, struct order * ord)
|
destroy_road(unit *u, int nmax, struct order * ord)
|
||||||
{
|
{
|
||||||
direction_t d = getdirection(u->faction->locale);
|
direction_t d = getdirection(u->faction->locale);
|
||||||
unit *u2;
|
unit *u2;
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
|
short n = (short)nmax;
|
||||||
|
|
||||||
|
if (nmax>SHRT_MAX) n = SHRT_MAX;
|
||||||
|
else if (nmax<0) n = 0;
|
||||||
|
|
||||||
for (u2=r->units;u2;u2=u2->next) {
|
for (u2=r->units;u2;u2=u2->next) {
|
||||||
if (u2->faction!=u->faction && getguard(u2)&GUARD_TAX
|
if (u2->faction!=u->faction && getguard(u2)&GUARD_TAX
|
||||||
|
@ -314,22 +318,18 @@ destroy_road(unit *u, int n, struct order * ord)
|
||||||
if (d==NODIRECTION) {
|
if (d==NODIRECTION) {
|
||||||
cmistake(u, ord, 71, MSG_PRODUCE);
|
cmistake(u, ord, 71, MSG_PRODUCE);
|
||||||
} else {
|
} else {
|
||||||
#if 0
|
short road = rroad(r, d);
|
||||||
int salvage, divy = 2;
|
road = min(n, road);
|
||||||
#endif
|
if (road!=0) {
|
||||||
int willdo = min(n, eff_skill(u, SK_ROAD_BUILDING, r)*u->number);
|
region * r2 = rconnect(r,d);
|
||||||
int road = rroad(r, d);
|
int willdo = eff_skill(u, SK_ROAD_BUILDING, r)*u->number;
|
||||||
region * r2 = rconnect(r,d);
|
willdo = min(willdo, road);
|
||||||
willdo = min(willdo, road);
|
if (willdo==0) {
|
||||||
if (willdo==0) {
|
/* TODO: error message */
|
||||||
/* TODO: error message */
|
}
|
||||||
}
|
if (willdo>SHRT_MAX) road = 0;
|
||||||
#if 0
|
else road = road - (short)willdo;
|
||||||
salvage = willdo / divy;
|
rsetroad(r, d, road);
|
||||||
change_item(u, I_STONE, salvage);
|
|
||||||
#endif
|
|
||||||
rsetroad(r, d, road - willdo);
|
|
||||||
if (road!=0 && road <= willdo) {
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("destroy_road",
|
ADDMSG(&u->faction->msgs, msg_message("destroy_road",
|
||||||
"unit from to", u, r, r2));
|
"unit from to", u, r, r2));
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ build_road(region * r, unit * u, int size, direction_t d)
|
||||||
/* n is now modified by several special effects, so we have to
|
/* n is now modified by several special effects, so we have to
|
||||||
* minimize it again to make sure the road will not grow beyond
|
* minimize it again to make sure the road will not grow beyond
|
||||||
* maximum. */
|
* maximum. */
|
||||||
rsetroad(r, d, rroad(r, d) + min(n, left));
|
rsetroad(r, d, rroad(r, d) + (short)min(n, left));
|
||||||
|
|
||||||
if (u->race == new_race[RC_STONEGOLEM]){
|
if (u->race == new_race[RC_STONEGOLEM]){
|
||||||
int golemsused = n / GOLEM_STONE;
|
int golemsused = n / GOLEM_STONE;
|
||||||
|
|
|
@ -567,9 +567,8 @@ attrib_type at_road = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
rsetroad(region * r, direction_t d, int val)
|
rsetroad(region * r, direction_t d, short val)
|
||||||
{
|
{
|
||||||
int rval;
|
|
||||||
border * b;
|
border * b;
|
||||||
region * r2 = rconnect(r, d);
|
region * r2 = rconnect(r, d);
|
||||||
|
|
||||||
|
@ -577,15 +576,11 @@ rsetroad(region * r, direction_t d, int val)
|
||||||
b = get_borders(r, r2);
|
b = get_borders(r, r2);
|
||||||
while (b && b->type!=&bt_road) b = b->next;
|
while (b && b->type!=&bt_road) b = b->next;
|
||||||
if (!b) b = new_border(&bt_road, r, r2);
|
if (!b) b = new_border(&bt_road, r, r2);
|
||||||
rval = b->data.i;
|
if (r==b->from) b->data.sa[0] = val;
|
||||||
if (b->from==r)
|
else b->data.sa[1] = val;
|
||||||
rval = (rval & 0xFFFF) | (val<<16);
|
|
||||||
else
|
|
||||||
rval = (rval & 0xFFFF0000) | val;
|
|
||||||
b->data.i = rval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
short
|
||||||
rroad(const region * r, direction_t d)
|
rroad(const region * r, direction_t d)
|
||||||
{
|
{
|
||||||
int rval;
|
int rval;
|
||||||
|
@ -597,11 +592,8 @@ rroad(const region * r, direction_t d)
|
||||||
while (b && b->type!=&bt_road) b = b->next;
|
while (b && b->type!=&bt_road) b = b->next;
|
||||||
if (!b) return 0;
|
if (!b) return 0;
|
||||||
rval = b->data.i;
|
rval = b->data.i;
|
||||||
if (b->to==r)
|
if (r==b->from) return b->data.sa[0];
|
||||||
rval = (rval & 0xFFFF);
|
return b->data.sa[1];
|
||||||
else
|
|
||||||
rval = (rval & 0xFFFF0000) >> 16;
|
|
||||||
return rval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
|
@ -189,8 +189,8 @@ void chaoscounts(struct region * r, int delta);
|
||||||
|
|
||||||
void setluxuries(struct region * r, const struct luxury_type * sale);
|
void setluxuries(struct region * r, const struct luxury_type * sale);
|
||||||
|
|
||||||
int rroad(const struct region * r, direction_t d);
|
short rroad(const struct region * r, direction_t d);
|
||||||
void rsetroad(struct region * r, direction_t d, int value);
|
void rsetroad(struct region * r, direction_t d, short value);
|
||||||
|
|
||||||
int is_coastregion(struct region *r);
|
int is_coastregion(struct region *r);
|
||||||
|
|
||||||
|
|
|
@ -1659,13 +1659,13 @@ sp_create_stonegolem(castorder *co)
|
||||||
* (FARCASTING | REGIONSPELL | TESTRESISTANCE)
|
* (FARCASTING | REGIONSPELL | TESTRESISTANCE)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
destroy_all_roads(region *r, int val)
|
destroy_all_roads(region *r)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < MAXDIRECTIONS; i++){
|
for(i = 0; i < MAXDIRECTIONS; i++){
|
||||||
rsetroad(r,(direction_t)i, val);
|
rsetroad(r,(direction_t)i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1710,17 +1710,17 @@ sp_great_drought(castorder *co)
|
||||||
switch(rterrain(r)){
|
switch(rterrain(r)){
|
||||||
case T_PLAIN:
|
case T_PLAIN:
|
||||||
rsetterrain(r, T_GRASSLAND);
|
rsetterrain(r, T_GRASSLAND);
|
||||||
destroy_all_roads(r, 0);
|
destroy_all_roads(r);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_SWAMP:
|
case T_SWAMP:
|
||||||
rsetterrain(r, T_GRASSLAND);
|
rsetterrain(r, T_GRASSLAND);
|
||||||
destroy_all_roads(r, 0);
|
destroy_all_roads(r);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_GRASSLAND:
|
case T_GRASSLAND:
|
||||||
rsetterrain(r, T_DESERT);
|
rsetterrain(r, T_DESERT);
|
||||||
destroy_all_roads(r, 0);
|
destroy_all_roads(r);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_GLACIER:
|
case T_GLACIER:
|
||||||
|
@ -1730,9 +1730,9 @@ sp_great_drought(castorder *co)
|
||||||
#endif
|
#endif
|
||||||
if (rand() % 100 < 50){
|
if (rand() % 100 < 50){
|
||||||
rsetterrain(r, T_SWAMP);
|
rsetterrain(r, T_SWAMP);
|
||||||
destroy_all_roads(r, 0);
|
destroy_all_roads(r);
|
||||||
} else { /* Ozean */
|
} else { /* Ozean */
|
||||||
destroy_all_roads(r, 0);
|
destroy_all_roads(r);
|
||||||
rsetterrain(r, T_OCEAN);
|
rsetterrain(r, T_OCEAN);
|
||||||
/* Einheiten dürfen hier auf keinen Fall gelöscht werden! */
|
/* Einheiten dürfen hier auf keinen Fall gelöscht werden! */
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ typedef struct terraindata_t {
|
||||||
/* ist NULL, wenn kein Strassenbau möglich */
|
/* ist NULL, wenn kein Strassenbau möglich */
|
||||||
|
|
||||||
int quarries; /* abbaubare Steine pro Runde */
|
int quarries; /* abbaubare Steine pro Runde */
|
||||||
int roadreq; /* Steine fuer Strasse (-1 = nicht machbar) */
|
short roadreq; /* Steine fuer Strasse (-1 = nicht machbar) */
|
||||||
int production_max; /* bebaubare Parzellen (10 Leute pro Parzelle) */
|
int production_max; /* bebaubare Parzellen (10 Leute pro Parzelle) */
|
||||||
/* Achtung: Produktion wird durch Flueche (zB Duerre) beeinflusst.
|
/* Achtung: Produktion wird durch Flueche (zB Duerre) beeinflusst.
|
||||||
* Die Funktion production(struct region *r) in economic.c ermittelt den
|
* Die Funktion production(struct region *r) in economic.c ermittelt den
|
||||||
|
|
|
@ -1023,7 +1023,7 @@ fix_attribflags(void)
|
||||||
while (a) {
|
while (a) {
|
||||||
if (a->type==&at_guard) {
|
if (a->type==&at_guard) {
|
||||||
fset(u, UFL_GUARD);
|
fset(u, UFL_GUARD);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ region_getresource(const region& r, const char * type)
|
||||||
static void
|
static void
|
||||||
region_setroad(region& r, int dir, lua_Number size)
|
region_setroad(region& r, int dir, lua_Number size)
|
||||||
{
|
{
|
||||||
rsetroad(&r, (direction_t)dir, (int)(terrain[rterrain(&r)].roadreq * size));
|
rsetroad(&r, (direction_t)dir, (short)(terrain[rterrain(&r)].roadreq * size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static lua_Number
|
static lua_Number
|
||||||
|
|
Loading…
Reference in New Issue