forked from github/server
remove a lot of struct copying in the stupid expand function.
This commit is contained in:
parent
e1d33e55a4
commit
6f7c8743b3
4 changed files with 149 additions and 140 deletions
265
src/economy.c
265
src/economy.c
|
@ -88,7 +88,7 @@ static econ_request entertainers[1024];
|
||||||
static econ_request *nextentertainer;
|
static econ_request *nextentertainer;
|
||||||
static int entertaining;
|
static int entertaining;
|
||||||
|
|
||||||
static econ_request *g_requests; /* TODO: no need for this to be module-global */
|
static econ_request **g_requests; /* TODO: no need for this to be module-global */
|
||||||
|
|
||||||
#define RECRUIT_MERGE 1
|
#define RECRUIT_MERGE 1
|
||||||
static int rules_recruit = -1;
|
static int rules_recruit = -1;
|
||||||
|
@ -141,7 +141,7 @@ static void scramble(void *data, unsigned int n, size_t width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int expand_production(region * r, econ_request * requests, econ_request **results)
|
unsigned int expand_production(region * r, econ_request * requests, econ_request ***results)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
econ_request *o;
|
econ_request *o;
|
||||||
|
@ -161,24 +161,28 @@ unsigned int expand_production(region * r, econ_request * requests, econ_request
|
||||||
|
|
||||||
if (norders > 0) {
|
if (norders > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
econ_request *split;
|
econ_request **split;
|
||||||
split = (econ_request *)calloc(norders, sizeof(econ_request));
|
split = calloc(norders, sizeof(econ_request *));
|
||||||
for (o = requests; o; o = o->next) {
|
for (o = requests; o; o = o->next) {
|
||||||
if (o->qty > 0) {
|
if (o->qty > 0) {
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
for (j = o->qty; j; j--) {
|
for (j = o->qty; j; j--) {
|
||||||
split[i] = *o;
|
split[i] = o;
|
||||||
split[i].unit->n = 0;
|
o->unit->n = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scramble(split, norders, sizeof(econ_request));
|
scramble(split, norders, sizeof(econ_request *));
|
||||||
*results = split;
|
*results = split;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*results = NULL;
|
*results = NULL;
|
||||||
}
|
}
|
||||||
|
return norders;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_requests(econ_request *requests) {
|
||||||
while (requests) {
|
while (requests) {
|
||||||
econ_request *req = requests->next;
|
econ_request *req = requests->next;
|
||||||
if (requests->ord) {
|
if (requests->ord) {
|
||||||
|
@ -187,7 +191,6 @@ unsigned int expand_production(region * r, econ_request * requests, econ_request
|
||||||
free(requests);
|
free(requests);
|
||||||
requests = req;
|
requests = req;
|
||||||
}
|
}
|
||||||
return norders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int expandorders(region * r, econ_request * requests) {
|
static unsigned int expandorders(region * r, econ_request * requests) {
|
||||||
|
@ -1479,54 +1482,54 @@ static void expandbuying(region * r, econ_request * buyorders)
|
||||||
* G<EFBFBD>ter pro Monat ist. j sind die Befehle, i der Index des
|
* G<EFBFBD>ter pro Monat ist. j sind die Befehle, i der Index des
|
||||||
* gehandelten Produktes. */
|
* gehandelten Produktes. */
|
||||||
if (max_products > 0) {
|
if (max_products > 0) {
|
||||||
unsigned int j;
|
|
||||||
unsigned int norders = expandorders(r, buyorders);
|
unsigned int norders = expandorders(r, buyorders);
|
||||||
if (!norders)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (j = 0; j != norders; j++) {
|
if (norders) {
|
||||||
int price, multi;
|
unsigned int j;
|
||||||
ltype = g_requests[j].type.trade.ltype;
|
for (j = 0; j != norders; j++) {
|
||||||
trade = trades;
|
int price, multi;
|
||||||
while (trade->type && trade->type != ltype)
|
ltype = g_requests[j]->type.trade.ltype;
|
||||||
++trade;
|
trade = trades;
|
||||||
multi = trade->multi;
|
while (trade->type && trade->type != ltype)
|
||||||
price = ltype->price * multi;
|
++trade;
|
||||||
|
multi = trade->multi;
|
||||||
|
price = ltype->price * multi;
|
||||||
|
|
||||||
if (get_pooled(g_requests[j].unit, rsilver, GET_DEFAULT,
|
if (get_pooled(g_requests[j]->unit, rsilver, GET_DEFAULT,
|
||||||
price) >= price) {
|
price) >= price) {
|
||||||
item *items;
|
item *items;
|
||||||
/* litems z<>hlt die G<>ter, die verkauft wurden, u->n das Geld, das
|
/* litems z<>hlt die G<>ter, die verkauft wurden, u->n das Geld, das
|
||||||
* verdient wurde. Dies mu<EFBFBD> gemacht werden, weil der Preis st<EFBFBD>ndig sinkt,
|
* verdient wurde. Dies mu<EFBFBD> gemacht werden, weil der Preis st<EFBFBD>ndig sinkt,
|
||||||
* man sich also das verdiente Geld und die verkauften Produkte separat
|
* man sich also das verdiente Geld und die verkauften Produkte separat
|
||||||
* merken mu<EFBFBD>. */
|
* merken mu<EFBFBD>. */
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
|
||||||
u = g_requests[j].unit;
|
u = g_requests[j]->unit;
|
||||||
a = a_find(u->attribs, &at_luxuries);
|
a = a_find(u->attribs, &at_luxuries);
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(&u->attribs, a_new(&at_luxuries));
|
a = a_add(&u->attribs, a_new(&at_luxuries));
|
||||||
|
}
|
||||||
|
items = a->data.v;
|
||||||
|
|
||||||
|
i_change(&items, ltype->itype, 1);
|
||||||
|
a->data.v = items;
|
||||||
|
i_change(&g_requests[j]->unit->items, ltype->itype, 1);
|
||||||
|
use_pooled(u, rsilver, GET_DEFAULT, price);
|
||||||
|
if (u->n < 0)
|
||||||
|
u->n = 0;
|
||||||
|
u->n += price;
|
||||||
|
|
||||||
|
rsetmoney(r, rmoney(r) + price);
|
||||||
|
|
||||||
|
/* Falls mehr als max_products Bauern ein Produkt verkauft haben, steigt
|
||||||
|
* der Preis Multiplikator f<EFBFBD>r das Produkt um den Faktor 1. Der Z<EFBFBD>hler
|
||||||
|
* wird wieder auf 0 gesetzt. */
|
||||||
|
if (++trade->number == max_products) {
|
||||||
|
trade->number = 0;
|
||||||
|
++trade->multi;
|
||||||
|
}
|
||||||
|
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
}
|
}
|
||||||
items = a->data.v;
|
|
||||||
|
|
||||||
i_change(&items, ltype->itype, 1);
|
|
||||||
a->data.v = items;
|
|
||||||
i_change(&g_requests[j].unit->items, ltype->itype, 1);
|
|
||||||
use_pooled(u, rsilver, GET_DEFAULT, price);
|
|
||||||
if (u->n < 0)
|
|
||||||
u->n = 0;
|
|
||||||
u->n += price;
|
|
||||||
|
|
||||||
rsetmoney(r, rmoney(r) + price);
|
|
||||||
|
|
||||||
/* Falls mehr als max_products Bauern ein Produkt verkauft haben, steigt
|
|
||||||
* der Preis Multiplikator f<EFBFBD>r das Produkt um den Faktor 1. Der Z<EFBFBD>hler
|
|
||||||
* wird wieder auf 0 gesetzt. */
|
|
||||||
if (++trade->number == max_products) {
|
|
||||||
trade->number = 0;
|
|
||||||
++trade->multi;
|
|
||||||
}
|
|
||||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(g_requests);
|
free(g_requests);
|
||||||
|
@ -1754,79 +1757,77 @@ static void expandselling(region * r, econ_request * sellorders, int limit)
|
||||||
* Runde erweitert werden kann. */
|
* Runde erweitert werden kann. */
|
||||||
|
|
||||||
norders = expandorders(r, sellorders);
|
norders = expandorders(r, sellorders);
|
||||||
if (norders == 0) {
|
if (norders > 0) {
|
||||||
return;
|
for (j = 0; j != norders; j++) {
|
||||||
}
|
const luxury_type *search = NULL;
|
||||||
|
const luxury_type *ltype = g_requests[j]->type.trade.ltype;
|
||||||
for (j = 0; j != norders; j++) {
|
int multi = r_demand(r, ltype);
|
||||||
const luxury_type *search = NULL;
|
int i;
|
||||||
const luxury_type *ltype = g_requests[j].type.trade.ltype;
|
int use = 0;
|
||||||
int multi = r_demand(r, ltype);
|
for (i = 0, search = luxurytypes; search != ltype; search = search->next) {
|
||||||
int i;
|
/* TODO: this is slow and lame! */
|
||||||
int use = 0;
|
++i;
|
||||||
for (i = 0, search = luxurytypes; search != ltype; search = search->next) {
|
|
||||||
/* TODO: this is slow and lame! */
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
if (counter[i] >= limit)
|
|
||||||
continue;
|
|
||||||
if (counter[i] + 1 > max_products && multi > 1)
|
|
||||||
--multi;
|
|
||||||
price = ltype->price * multi;
|
|
||||||
|
|
||||||
if (money >= price) {
|
|
||||||
item *itm;
|
|
||||||
attrib *a;
|
|
||||||
u = g_requests[j].unit;
|
|
||||||
a = a_find(u->attribs, &at_luxuries);
|
|
||||||
if (!a) {
|
|
||||||
a = a_add(&u->attribs, a_new(&at_luxuries));
|
|
||||||
}
|
|
||||||
itm = (item *)a->data.v;
|
|
||||||
i_change(&itm, ltype->itype, 1);
|
|
||||||
a->data.v = itm;
|
|
||||||
++use;
|
|
||||||
if (u->n < 0) {
|
|
||||||
u->n = 0;
|
|
||||||
}
|
}
|
||||||
|
if (counter[i] >= limit)
|
||||||
|
continue;
|
||||||
|
if (counter[i] + 1 > max_products && multi > 1)
|
||||||
|
--multi;
|
||||||
|
price = ltype->price * multi;
|
||||||
|
|
||||||
if (hafenowner) {
|
if (money >= price) {
|
||||||
if (hafenowner->faction != u->faction) {
|
item *itm;
|
||||||
int abgezogenhafen = price / 10;
|
attrib *a;
|
||||||
hafencollected += abgezogenhafen;
|
u = g_requests[j]->unit;
|
||||||
price -= abgezogenhafen;
|
a = a_find(u->attribs, &at_luxuries);
|
||||||
money -= abgezogenhafen;
|
if (!a) {
|
||||||
|
a = a_add(&u->attribs, a_new(&at_luxuries));
|
||||||
|
}
|
||||||
|
itm = (item *)a->data.v;
|
||||||
|
i_change(&itm, ltype->itype, 1);
|
||||||
|
a->data.v = itm;
|
||||||
|
++use;
|
||||||
|
if (u->n < 0) {
|
||||||
|
u->n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hafenowner) {
|
||||||
|
if (hafenowner->faction != u->faction) {
|
||||||
|
int abgezogenhafen = price / 10;
|
||||||
|
hafencollected += abgezogenhafen;
|
||||||
|
price -= abgezogenhafen;
|
||||||
|
money -= abgezogenhafen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maxb) {
|
||||||
|
if (maxowner->faction != u->faction) {
|
||||||
|
int abgezogensteuer = price * tax_per_size[maxeffsize] / 100;
|
||||||
|
taxcollected += abgezogensteuer;
|
||||||
|
price -= abgezogensteuer;
|
||||||
|
money -= abgezogensteuer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u->n += price;
|
||||||
|
change_money(u, price);
|
||||||
|
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
|
|
||||||
|
/* r->money -= price; --- dies wird eben nicht ausgef<65>hrt, denn die
|
||||||
|
* Produkte k<EFBFBD>nnen auch als Steuern eingetrieben werden. In der Region
|
||||||
|
* wurden Silberst<EFBFBD>cke gegen Luxusg<EFBFBD>ter des selben Wertes eingetauscht!
|
||||||
|
* Falls mehr als max_products Kunden ein Produkt gekauft haben, sinkt
|
||||||
|
* die Nachfrage f<EFBFBD>r das Produkt um 1. Der Z<EFBFBD>hler wird wieder auf 0
|
||||||
|
* gesetzt. */
|
||||||
|
|
||||||
|
if (++counter[i] > max_products) {
|
||||||
|
int d = r_demand(r, ltype);
|
||||||
|
if (d > 1) {
|
||||||
|
r_setdemand(r, ltype, d - 1);
|
||||||
|
}
|
||||||
|
counter[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxb) {
|
if (use > 0) {
|
||||||
if (maxowner->faction != u->faction) {
|
use_pooled(g_requests[j]->unit, ltype->itype->rtype, GET_DEFAULT, use);
|
||||||
int abgezogensteuer = price * tax_per_size[maxeffsize] / 100;
|
|
||||||
taxcollected += abgezogensteuer;
|
|
||||||
price -= abgezogensteuer;
|
|
||||||
money -= abgezogensteuer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
u->n += price;
|
|
||||||
change_money(u, price);
|
|
||||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
|
||||||
|
|
||||||
/* r->money -= price; --- dies wird eben nicht ausgef<65>hrt, denn die
|
|
||||||
* Produkte k<EFBFBD>nnen auch als Steuern eingetrieben werden. In der Region
|
|
||||||
* wurden Silberst<EFBFBD>cke gegen Luxusg<EFBFBD>ter des selben Wertes eingetauscht!
|
|
||||||
* Falls mehr als max_products Kunden ein Produkt gekauft haben, sinkt
|
|
||||||
* die Nachfrage f<EFBFBD>r das Produkt um 1. Der Z<EFBFBD>hler wird wieder auf 0
|
|
||||||
* gesetzt. */
|
|
||||||
|
|
||||||
if (++counter[i] > max_products) {
|
|
||||||
int d = r_demand(r, ltype);
|
|
||||||
if (d > 1) {
|
|
||||||
r_setdemand(r, ltype, d - 1);
|
|
||||||
}
|
|
||||||
counter[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (use > 0) {
|
|
||||||
use_pooled(g_requests[j].unit, ltype->itype->rtype, GET_DEFAULT, use);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(g_requests);
|
free(g_requests);
|
||||||
|
@ -2520,8 +2521,8 @@ static void expandloot(region * r, econ_request * lootorders)
|
||||||
int startmoney = rmoney(r);
|
int startmoney = rmoney(r);
|
||||||
|
|
||||||
for (i = 0; i != norders && startmoney > looted + TAXFRACTION * 2; i++) {
|
for (i = 0; i != norders && startmoney > looted + TAXFRACTION * 2; i++) {
|
||||||
change_money(g_requests[i].unit, TAXFRACTION);
|
change_money(g_requests[i]->unit, TAXFRACTION);
|
||||||
g_requests[i].unit->n += TAXFRACTION;
|
g_requests[i]->unit->n += TAXFRACTION;
|
||||||
/*Looting destroys double the money*/
|
/*Looting destroys double the money*/
|
||||||
looted += TAXFRACTION * 2;
|
looted += TAXFRACTION * 2;
|
||||||
}
|
}
|
||||||
|
@ -2554,8 +2555,8 @@ void expandtax(region * r, econ_request * taxorders)
|
||||||
if (norders > 0) {
|
if (norders > 0) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i != norders && rmoney(r) > TAXFRACTION; i++) {
|
for (i = 0; i != norders && rmoney(r) > TAXFRACTION; i++) {
|
||||||
change_money(g_requests[i].unit, TAXFRACTION);
|
change_money(g_requests[i]->unit, TAXFRACTION);
|
||||||
g_requests[i].unit->n += TAXFRACTION;
|
g_requests[i]->unit->n += TAXFRACTION;
|
||||||
rsetmoney(r, rmoney(r) - TAXFRACTION);
|
rsetmoney(r, rmoney(r) - TAXFRACTION);
|
||||||
}
|
}
|
||||||
free(g_requests);
|
free(g_requests);
|
||||||
|
@ -2938,18 +2939,23 @@ void produce(struct region *r)
|
||||||
if (!rule_autowork()) {
|
if (!rule_autowork()) {
|
||||||
expandwork(r, workers, nextworker, region_maxworkers(r));
|
expandwork(r, workers, nextworker, region_maxworkers(r));
|
||||||
}
|
}
|
||||||
if (taxorders)
|
if (taxorders) {
|
||||||
expandtax(r, taxorders);
|
expandtax(r, taxorders);
|
||||||
|
free_requests(taxorders);
|
||||||
|
}
|
||||||
|
|
||||||
if (lootorders)
|
if (lootorders) {
|
||||||
expandloot(r, lootorders);
|
expandloot(r, lootorders);
|
||||||
|
free_requests(lootorders);
|
||||||
|
}
|
||||||
/* An erster Stelle Kaufen (expandbuying), die Bauern so Geld bekommen, um
|
/* An erster Stelle Kaufen (expandbuying), die Bauern so Geld bekommen, um
|
||||||
* nachher zu beim Verkaufen (expandselling) den Spielern abkaufen zu
|
* nachher zu beim Verkaufen (expandselling) den Spielern abkaufen zu
|
||||||
* k<EFBFBD>nnen. */
|
* k<EFBFBD>nnen. */
|
||||||
|
|
||||||
if (buyorders)
|
if (buyorders) {
|
||||||
expandbuying(r, buyorders);
|
expandbuying(r, buyorders);
|
||||||
|
free_requests(buyorders);
|
||||||
|
}
|
||||||
|
|
||||||
if (sellorders) {
|
if (sellorders) {
|
||||||
int limit = rpeasants(r) / TRADE_FRACTION;
|
int limit = rpeasants(r) / TRADE_FRACTION;
|
||||||
|
@ -2957,13 +2963,16 @@ void produce(struct region *r)
|
||||||
&& buildingtype_exists(r, caravan_bt, true))
|
&& buildingtype_exists(r, caravan_bt, true))
|
||||||
limit *= 2;
|
limit *= 2;
|
||||||
expandselling(r, sellorders, limited ? limit : INT_MAX);
|
expandselling(r, sellorders, limited ? limit : INT_MAX);
|
||||||
|
free_requests(sellorders);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Die Spieler sollen alles Geld verdienen, bevor sie beklaut werden
|
/* Die Spieler sollen alles Geld verdienen, bevor sie beklaut werden
|
||||||
* (expandstealing). */
|
* (expandstealing). */
|
||||||
|
|
||||||
if (stealorders)
|
if (stealorders) {
|
||||||
expandstealing(r, stealorders);
|
expandstealing(r, stealorders);
|
||||||
|
free_requests(stealorders);
|
||||||
|
}
|
||||||
|
|
||||||
assert(rmoney(r) >= 0);
|
assert(rmoney(r) >= 0);
|
||||||
assert(rpeasants(r) >= 0);
|
assert(rpeasants(r) >= 0);
|
||||||
|
|
|
@ -69,7 +69,7 @@ extern "C" {
|
||||||
void produce(struct region *r);
|
void produce(struct region *r);
|
||||||
void auto_work(struct region *r);
|
void auto_work(struct region *r);
|
||||||
|
|
||||||
unsigned int expand_production(struct region * r, struct econ_request * requests, struct econ_request **results);
|
unsigned int expand_production(struct region * r, struct econ_request * requests, struct econ_request ***results);
|
||||||
|
|
||||||
typedef enum income_t { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT } income_t;
|
typedef enum income_t { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT } income_t;
|
||||||
void add_income(struct unit * u, income_t type, int want, int qty);
|
void add_income(struct unit * u, income_t type, int want, int qty);
|
||||||
|
|
|
@ -722,7 +722,7 @@ static void test_loot(CuTest *tc) {
|
||||||
|
|
||||||
static void test_expand_production(CuTest *tc) {
|
static void test_expand_production(CuTest *tc) {
|
||||||
econ_request *orders;
|
econ_request *orders;
|
||||||
econ_request *results = NULL;
|
econ_request **results = NULL;
|
||||||
region *r;
|
region *r;
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
|
@ -735,8 +735,8 @@ static void test_expand_production(CuTest *tc) {
|
||||||
u->n = 1; /* will be overwritten */
|
u->n = 1; /* will be overwritten */
|
||||||
CuAssertIntEquals(tc, 2, expand_production(r, orders, &results));
|
CuAssertIntEquals(tc, 2, expand_production(r, orders, &results));
|
||||||
CuAssertPtrNotNull(tc, results);
|
CuAssertPtrNotNull(tc, results);
|
||||||
CuAssertPtrEquals(tc, u, results[0].unit);
|
CuAssertPtrEquals(tc, u, results[0]->unit);
|
||||||
CuAssertPtrEquals(tc, u, results[1].unit);
|
CuAssertPtrEquals(tc, u, results[1]->unit);
|
||||||
CuAssertIntEquals(tc, 0, u->n);
|
CuAssertIntEquals(tc, 0, u->n);
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
16
src/steal.c
16
src/steal.c
|
@ -51,7 +51,7 @@ void expandstealing(region * r, econ_request * stealorders)
|
||||||
const resource_type *rsilver = get_resourcetype(R_SILVER);
|
const resource_type *rsilver = get_resourcetype(R_SILVER);
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
unsigned int norders;
|
unsigned int norders;
|
||||||
econ_request *requests;
|
econ_request **requests;
|
||||||
|
|
||||||
assert(rsilver);
|
assert(rsilver);
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ void expandstealing(region * r, econ_request * stealorders)
|
||||||
unit *u;
|
unit *u;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
if (requests[j].unit->n > requests[j].unit->wants) {
|
if (requests[j]->unit->n > requests[j]->unit->wants) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u = findunitg(requests[j].type.steal.no, r);
|
u = findunitg(requests[j]->type.steal.no, r);
|
||||||
|
|
||||||
if (u && u->region == r) {
|
if (u && u->region == r) {
|
||||||
n = get_pooled(u, rsilver, GET_ALL, INT_MAX);
|
n = get_pooled(u, rsilver, GET_ALL, INT_MAX);
|
||||||
|
@ -82,16 +82,16 @@ void expandstealing(region * r, econ_request * stealorders)
|
||||||
n = 10;
|
n = 10;
|
||||||
}
|
}
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int w = requests[j].unit->wants;
|
int w = requests[j]->unit->wants;
|
||||||
if (n > w) n = w;
|
if (n > w) n = w;
|
||||||
use_pooled(u, rsilver, GET_ALL, n);
|
use_pooled(u, rsilver, GET_ALL, n);
|
||||||
requests[j].unit->n = n;
|
requests[j]->unit->n = n;
|
||||||
change_money(requests[j].unit, n);
|
change_money(requests[j]->unit, n);
|
||||||
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount",
|
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount",
|
||||||
u, u->region, n));
|
u, u->region, n));
|
||||||
}
|
}
|
||||||
add_income(requests[j].unit, IC_STEAL, requests[j].unit->wants, requests[j].unit->n);
|
add_income(requests[j]->unit, IC_STEAL, requests[j]->unit->wants, requests[j]->unit->n);
|
||||||
fset(requests[j].unit, UFL_LONGACTION | UFL_NOTMOVING);
|
fset(requests[j]->unit, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
}
|
}
|
||||||
free(requests);
|
free(requests);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue