bug in fishing-code

This commit is contained in:
Enno Rehling 2010-02-10 06:30:47 +00:00
parent 8553d0083b
commit 5415d3bf20
2 changed files with 14 additions and 14 deletions
src/common
gamecode
kernel

View file

@ -221,7 +221,7 @@ get_food(region *r)
* jede Einheit genug Silber für ihren Unterhalt hat. */ * jede Einheit genug Silber für ihren Unterhalt hat. */
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
int style = lifestyle(u); int style = INCOME_FISHING;
int need = style; int need = style;
/* Erstmal zurücksetzen */ /* Erstmal zurücksetzen */
@ -230,22 +230,20 @@ get_food(region *r)
if (u->ship && (u->ship->flags&SF_FISHING)) { if (u->ship && (u->ship->flags&SF_FISHING)) {
unit * v; unit * v;
int c = 2; int c = 2;
for (v=r->units;c>0 && v;v=v->next) { for (v=u;c>0 && v;v=v->next) {
if (v->ship==u->ship) { if (v->ship==u->ship) {
if (u==v) { int get = 0;
int get = 0; if (v->number==c) {
if (u->number==c) { get = need;
get = need; } else {
} else { int x = MIN(c, v->number);
int x = MIN(c, u->number); get = (style * x) / v->number;
get = (style * x) / u->number; }
} if (get) {
if (get) { change_money(v, get);
change_money(u, get);
}
} }
c -= v->number;
} }
c -= v->number;
} }
u->ship->flags -= SF_FISHING; u->ship->flags -= SF_FISHING;
} }

View file

@ -75,6 +75,8 @@ extern void st_register(const ship_type * type);
#define SF_SELECT 1<<3 /* previously FL_DH */ #define SF_SELECT 1<<3 /* previously FL_DH */
#define SF_FISHING 1<<4 /* was on an ocean, can fish */ #define SF_FISHING 1<<4 /* was on an ocean, can fish */
#define INCOME_FISHING 10
typedef struct ship { typedef struct ship {
struct ship *next; struct ship *next;
struct ship *nexthash; struct ship *nexthash;