forked from github/server
Deutliche Beschleunigung von Geldspenden.
This commit is contained in:
parent
8d5700a38b
commit
5c9e9f7b9a
|
@ -73,15 +73,13 @@
|
||||||
# include <items/seed.h>
|
# include <items/seed.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* - static global symbols ------------------------------------- */
|
typedef struct donation {
|
||||||
typedef struct spende {
|
struct donation *next;
|
||||||
struct spende *next;
|
|
||||||
struct faction *f1, *f2;
|
struct faction *f1, *f2;
|
||||||
struct region *region;
|
int amount;
|
||||||
int betrag;
|
} donation;
|
||||||
} spende;
|
|
||||||
static spende *spenden;
|
static donation *donations = 0;
|
||||||
/* ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
typedef struct request {
|
typedef struct request {
|
||||||
struct request * next;
|
struct request * next;
|
||||||
|
@ -846,41 +844,42 @@ forget_cmd(unit * u, order * ord)
|
||||||
void
|
void
|
||||||
report_donations(void)
|
report_donations(void)
|
||||||
{
|
{
|
||||||
spende * sp;
|
region * r;
|
||||||
for (sp = spenden; sp; sp = sp->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
region * r = sp->region;
|
donation * sp;
|
||||||
if (sp->betrag > 0) {
|
for (sp = r->donations; sp; sp = sp->next) {
|
||||||
|
if (sp->amount > 0) {
|
||||||
struct message * msg = msg_message("donation",
|
struct message * msg = msg_message("donation",
|
||||||
"from to amount", sp->f1, sp->f2, sp->betrag);
|
"from to amount", sp->f1, sp->f2, sp->amount);
|
||||||
r_addmessage(r, sp->f1, msg);
|
r_addmessage(r, sp->f1, msg);
|
||||||
r_addmessage(r, sp->f2, msg);
|
r_addmessage(r, sp->f2, msg);
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
add_spende(faction * f1, faction * f2, int betrag, region * r)
|
add_spende(faction * f1, faction * f2, int amount, region * r)
|
||||||
{
|
{
|
||||||
spende *sp;
|
donation *sp;
|
||||||
|
|
||||||
sp = spenden;
|
sp = r->donations;
|
||||||
|
|
||||||
while (sp) {
|
while (sp) {
|
||||||
if (sp->f1 == f1 && sp->f2 == f2 && sp->region == r) {
|
if (sp->f1 == f1 && sp->f2 == f2) {
|
||||||
sp->betrag += betrag;
|
sp->amount += amount;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sp = sp->next;
|
sp = sp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp = calloc(1, sizeof(spende));
|
sp = calloc(1, sizeof(donation));
|
||||||
sp->f1 = f1;
|
sp->f1 = f1;
|
||||||
sp->f2 = f2;
|
sp->f2 = f2;
|
||||||
sp->region = r;
|
sp->amount = amount;
|
||||||
sp->betrag = betrag;
|
sp->next = r->donations;
|
||||||
sp->next = spenden;
|
r->donations = sp;
|
||||||
spenden = sp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
|
|
|
@ -56,6 +56,7 @@ extern "C" {
|
||||||
struct message;
|
struct message;
|
||||||
struct message_list;
|
struct message_list;
|
||||||
struct rawmaterial;
|
struct rawmaterial;
|
||||||
|
struct donation;
|
||||||
|
|
||||||
typedef struct land_region {
|
typedef struct land_region {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -100,6 +101,7 @@ typedef struct region {
|
||||||
} * individual_messages;
|
} * individual_messages;
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
struct region *nexthash;
|
struct region *nexthash;
|
||||||
|
struct donation * donations;
|
||||||
terrain_t terrain;
|
terrain_t terrain;
|
||||||
#if NEW_RESOURCEGROWTH
|
#if NEW_RESOURCEGROWTH
|
||||||
struct rawmaterial * resources;
|
struct rawmaterial * resources;
|
||||||
|
|
Loading…
Reference in New Issue