Einheit verhungert und Gegenstände gehen verloren

Aauflösen von Einheiten vereinheitlicht, und einige alte #defines mitsamt Code entfernt.
This commit is contained in:
Enno Rehling 2005-09-08 19:03:42 +00:00
parent c1b275dad9
commit 8276a63c1e
10 changed files with 72 additions and 132 deletions

View File

@ -896,7 +896,6 @@ demographics(void)
if (rterrain(r) != T_OCEAN) { if (rterrain(r) != T_OCEAN) {
/* die Nachfrage nach Produkten steigt. */ /* die Nachfrage nach Produkten steigt. */
#ifdef NEW_ITEMS
struct demand * dmd; struct demand * dmd;
if (r->land) for (dmd=r->land->demands;dmd;dmd=dmd->next) { if (r->land) for (dmd=r->land->demands;dmd;dmd=dmd->next) {
if (dmd->value>0 && dmd->value < MAXDEMAND) { if (dmd->value>0 && dmd->value < MAXDEMAND) {
@ -905,24 +904,6 @@ demographics(void)
if (rand() % 100 < rise) dmd->value++; if (rand() % 100 < rise) dmd->value++;
} }
} }
#else
item_t n;
for (n = 0; n != MAXLUXURIES; n++) {
int d = rdemand(r, n);
if (d > 0 && d < MAXDEMAND) {
if (buildingtype_exists(r, &bt_harbour)) {
if (rand() % 100 < DMRISEHAFEN) {
d++;
}
} else {
if (rand() % 100 < DMRISE) {
d++;
}
}
}
rsetdemand(r, n, (char)d);
}
#endif
/* Seuchen erst nachdem die Bauern sich vermehrt haben /* Seuchen erst nachdem die Bauern sich vermehrt haben
* und gewandert sind */ * und gewandert sind */
@ -2737,7 +2718,6 @@ instant_orders(void)
for (f = factions; f; f = f->next) { for (f = factions; f; f = f->next) {
attrib *a; attrib *a;
#ifdef NEW_ITEMS
a = a_find(f->attribs, &at_showitem); a = a_find(f->attribs, &at_showitem);
while(a!=NULL) { while(a!=NULL) {
const item_type * itype = (const item_type *)a->data.v; const item_type * itype = (const item_type *)a->data.v;
@ -2750,13 +2730,6 @@ instant_orders(void)
a = n; a = n;
} else a = a->nexttype; } else a = a->nexttype;
} }
#else
a = a_find(f->attribs, &at_show_item_description);
while (a!=NULL) {
display_item(f, NULL, (item_t)(a->data.i));
a_remove(&f->attribs, a);
}
#endif
} }
parse(K_GROUP, group_cmd, false); parse(K_GROUP, group_cmd, false);

View File

@ -1178,11 +1178,7 @@ describe(FILE * F, const region * r, int partial, faction * f)
if (rhorses(r)) { if (rhorses(r)) {
bufp += sprintf(bufp, ", %d ", rhorses(r)); bufp += sprintf(bufp, ", %d ", rhorses(r));
#ifdef NEW_ITEMS
bufp += strxcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0))); bufp += strxcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0)));
#else
bufp += strxcpy(bufp, itemdata[I_HORSE].name[rhorses(r) > 1]);
#endif
} }
strcpy(bufp++, "."); strcpy(bufp++, ".");
@ -1916,9 +1912,6 @@ static int
report(FILE *F, faction * f, struct seen_region ** seen, const faction_list * addresses, report(FILE *F, faction * f, struct seen_region ** seen, const faction_list * addresses,
const char * pzTime) const char * pzTime)
{ {
#ifndef NEW_ITEMS
potion_t potion;
#endif
int flag = 0; int flag = 0;
char ch; char ch;
int dh; int dh;

View File

@ -205,10 +205,6 @@ extern void read_laen(struct region * r, int laen);
#define MAXPEASANTS_PER_AREA 10 #define MAXPEASANTS_PER_AREA 10
#if !defined(NEW_ITEMS)
# define NEW_ITEMS
#endif
/* So lange kann die Partei nicht angegriffen werden */ /* So lange kann die Partei nicht angegriffen werden */
#undef STUDY_IF_NOT_WORKING #undef STUDY_IF_NOT_WORKING

View File

@ -191,66 +191,7 @@ destroyfaction(faction * f)
for (u=f->units;u;u=u->nextF) { for (u=f->units;u;u=u->nextF) {
region * r = u->region; region * r = u->region;
unit * au; distribute_items(u);
int number = 0;
struct friend {
struct friend * next;
int number;
faction * faction;
unit * unit;
} * friends = NULL;
for (au=r->units;au;au=au->next) if (au->faction!=f) {
if (alliedunit(u, au->faction, HELP_ALL)) {
struct friend * nf, ** fr = &friends;
while (*fr && (*fr)->faction->no<au->faction->no) fr = &(*fr)->next;
nf = *fr;
if (nf==NULL || nf->faction!=au->faction) {
nf = calloc(sizeof(struct friend), 1);
nf->next = *fr;
nf->faction = au->faction;
nf->unit = au;
*fr = nf;
}
nf->number += au->number;
number += au->number;
}
}
if (friends && number) {
struct friend * nf = friends;
while (nf) {
unit * u2 = nf->unit;
#ifdef NEW_ITEMS
item * itm = u->items;
while(itm){
const item_type * itype = itm->type;
item * itn = itm->next;
int n = itm->number;
n = n * nf->number / number;
if (n>0) {
i_change(&u->items, itype, -n);
i_change(&u2->items, itype, n);
}
itm = itn;
}
#else
resource_t res;
for (res = 0; res <= R_SILVER; ++res) {
int n = get_resource(u, res);
if (n<=0) continue;
n = n * nf->number / number;
if (n<=0) continue;
change_resource(u, res, -n);
change_resource(u2, res, n);
}
#endif
number -= nf->number;
nf = nf->next;
free(friends);
friends = nf;
}
friends = NULL;
}
if (rterrain(r) != T_OCEAN && !!playerrace(u->race)) { if (rterrain(r) != T_OCEAN && !!playerrace(u->race)) {
const race * rc = u->race; const race * rc = u->race;
int p = rpeasants(u->region); int p = rpeasants(u->region);

View File

@ -114,8 +114,69 @@ dfindhash(int no)
unit * udestroy = NULL; unit * udestroy = NULL;
#undef DESTROY /** distributes a unit's posessions to friendly units
/* Einheiten werden nicht wirklich zerstört. */ * this happens when units die and no own units are in the region
*/
void
distribute_items(unit * u)
{
faction * f = u->faction;
region * r = u->region;
unit * au;
int number = 0;
struct friend {
struct friend * next;
int number;
faction * faction;
unit * unit;
} * friends = NULL;
if (u->items==NULL) return;
for (au=r->units;au;au=au->next) if (au->faction!=f) {
if (alliedunit(u, au->faction, HELP_ALL)) {
struct friend * nf, ** fr = &friends;
while (*fr && (*fr)->faction->no<au->faction->no) fr = &(*fr)->next;
nf = *fr;
if (nf==NULL || nf->faction!=au->faction) {
nf = malloc(sizeof(struct friend));
nf->next = *fr;
nf->faction = au->faction;
nf->unit = au;
nf->number = 0;
*fr = nf;
}
nf->number += au->number;
number += au->number;
}
}
if (friends && number) {
struct friend * nf = friends;
while (nf) {
unit * u2 = nf->unit;
item * itm = u->items;
while (itm!=NULL) {
const item_type * itype = itm->type;
item * itn = itm->next;
int n = itm->number;
n = n * nf->number / number;
if (n>0) {
i_change(&u->items, itype, -n);
i_change(&u2->items, itype, n);
}
itm = itn;
}
number -= nf->number;
nf = nf->next;
free(friends);
friends = nf;
}
friends = NULL;
}
}
void void
destroy_unit(unit * u) destroy_unit(unit * u)
{ {
@ -156,6 +217,7 @@ destroy_unit(unit * u)
} }
if (*p_item == item) p_item=&item->next; if (*p_item == item) p_item=&item->next;
} }
if (u->items) distribute_items(u);
} }
/* Wir machen das erst nach dem Löschen der Items. Der Klon darf keine /* Wir machen das erst nach dem Löschen der Items. Der Klon darf keine

View File

@ -186,10 +186,9 @@ extern int eff_skill_study(const struct unit * u, skill_t sk, const struct regio
extern int get_modifier(const struct unit * u, skill_t sk, int lvl, const struct region * r, boolean noitem); extern int get_modifier(const struct unit * u, skill_t sk, int lvl, const struct region * r, boolean noitem);
#undef DESTROY
/* Einheiten werden nicht wirklich zerstört. */ /* Einheiten werden nicht wirklich zerstört. */
extern void destroy_unit(struct unit * u); extern void destroy_unit(struct unit * u);
extern void distribute_items(struct unit * u);
/* see resolve.h */ /* see resolve.h */
extern void * resolve_unit(variant data); extern void * resolve_unit(variant data);

View File

@ -139,9 +139,9 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord)
if (get_level(u, sk)>1 && enter_fail(u)) return -1; if (get_level(u, sk)>1 && enter_fail(u)) return -1;
} }
for (u2=r->units;u2;u2=u2->next) if (u2->faction==u->faction) break; for (u2=r->units;u2;u2=u2->next) if (u2->faction==u->faction) break;
#ifdef NEW_ITEMS
assert(!"not implemented"); assert(!"not implemented");
#else /*
for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) {
int x = get_resource(u, res); int x = get_resource(u, res);
if (x) { if (x) {
@ -152,7 +152,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord)
else if (enter_fail(u)) return -1; else if (enter_fail(u)) return -1;
} }
} }
#endif */
if (get_money(u) > fee) { if (get_money(u) > fee) {
if (u2) change_money(u2, get_money(u) - fee); if (u2) change_money(u2, get_money(u) - fee);
else if (enter_fail(u)) return -1; else if (enter_fail(u)) return -1;

View File

@ -1236,7 +1236,7 @@ shift(void)
t_queue_len--; t_queue_len--;
return r; return r;
} }
#ifdef NEW_ITEMS
static const luxury_type * tradegood = NULL; static const luxury_type * tradegood = NULL;
void void
@ -1260,22 +1260,6 @@ settg(region *r)
} }
} }
#else
int tradegood;
void
settg(region *r)
{
int i;
for(i=0; i <= MAXLUXURIES; i++) {
rsetdemand(r, i, 1+rand()%5);
}
rsetdemand(r, tradegood, 0);
if(rand()%100 < 20) tradegood = rand()%7;
}
#endif
boolean boolean
Create_Island(region *r, int * n, terrain_t t, int x, int y) { Create_Island(region *r, int * n, terrain_t t, int x, int y) {
if (!r) return false; if (!r) return false;
@ -1303,11 +1287,7 @@ create_island(region *r, int n, terrain_t t)
for(r2=regions; r2; r2=r2->next) { for(r2=regions; r2; r2=r2->next) {
r2->msgs = (void *)0; r2->msgs = (void *)0;
} }
#ifdef NEW_ITEMS
tradegood = NULL; tradegood = NULL;
#else
tradegood = rand()%7;
#endif
terraform(r,t); terraform(r,t);
if(r->land) settg(r); if(r->land) settg(r);
r->msgs = (void *)(rand()%6); r->msgs = (void *)(rand()%6);

View File

@ -179,7 +179,6 @@ input_string(const char * text, char * result, size_t len) {
return res; return res;
} }
#ifdef NEW_ITEMS
static boolean i_modif = false; static boolean i_modif = false;
static void static void
@ -200,7 +199,6 @@ chg_item(selection * s, void * data) {
s->str = strdup(buf); s->str = strdup(buf);
} }
} }
#endif
boolean boolean
modify_items(unit * u) modify_items(unit * u)
@ -456,9 +454,7 @@ modify_unit(region * r, unit * modunit)
int q, a, x, y, zt, zg; int q, a, x, y, zt, zg;
char modif = 0; char modif = 0;
int at; int at;
#ifdef NEW_ITEMS
const item * itm; const item * itm;
#endif
wclear(mywin); wclear(mywin);
sprintf(buf, "< Einheit modifizieren: %s,%s >", sprintf(buf, "< Einheit modifizieren: %s,%s >",

View File

@ -1608,7 +1608,7 @@
<text locale="en">damage</text> <text locale="en">damage</text>
</string> </string>
<string name="nr_youaredead"> <string name="nr_youaredead">
<text locale="en">Your faction has been eliminated. We hope you had a good time anyways, and encourage you to sign up you for another game.</text> <text locale="en">Your faction has been eliminated. We hope that you had a good time, and if you liked the game, you should sign up and play again.</text>
</string> </string>
<!-- TODO: calendar ist noch komplexer --> <!-- TODO: calendar ist noch komplexer -->
<string name="nr_skills"> <string name="nr_skills">