diff --git a/src/economy.c b/src/economy.c index 82890888e..670036b16 100644 --- a/src/economy.c +++ b/src/economy.c @@ -141,11 +141,11 @@ static void scramble(void *data, unsigned int n, size_t width) } } -unsigned int expand_production(region * r, econ_request * requests, econ_request ***results) +int expand_production(region * r, econ_request * requests, econ_request ***results) { unit *u; econ_request *o; - unsigned int norders = 0; + int norders = 0; /* Alle Units ohne production haben ein -1, alle units mit orders haben ein * 0 hier stehen */ @@ -190,7 +190,7 @@ static void free_requests(econ_request *requests) { } } -static unsigned int expandorders(region * r, econ_request * requests) { +static int expandorders(region * r, econ_request * requests) { return expand_production(r, requests, &g_requests); } @@ -333,7 +333,7 @@ static int do_recruiting(recruitment * recruits, int available) for (req = rec->requests; req; req = req->next) { unit *u = req->unit; const race *rc = u_race(u); /* race is set in recruit() */ - int number, dec; + int number; double multi = 2.0 * rc->recruit_multi; number = (int)(get / multi); @@ -359,7 +359,7 @@ static int do_recruiting(recruitment * recruits, int available) } add_recruits(u, number, req->qty); if (number > 0) { - dec = (int)(number * multi); + int dec = (int)(number * multi); if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) { recruited += dec; } @@ -388,8 +388,7 @@ void free_recruitments(recruitment * recruits) /* Rekrutierung */ static void expandrecruit(region * r, econ_request * recruitorders) { - recruitment *recruits = NULL; - + recruitment *recruits; int orc_total = 0; /* peasant limited: */ @@ -430,12 +429,10 @@ static int recruit_cost(const faction * f, const race * rc) static void recruit(unit * u, struct order *ord, econ_request ** recruitorders) { region *r = u->region; - plane *pl; econ_request *o; int recruitcost = -1; const faction *f = u->faction; const struct race *rc = u_race(u); - const char *str; int n; init_order_depr(ord); @@ -447,6 +444,8 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders) if (u->number == 0) { char token[128]; + const char *str; + str = gettoken(token, sizeof(token)); if (str && str[0]) { /* Monsters can RECRUIT 15 DRACOID @@ -506,7 +505,7 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders) } if (recruitcost) { - pl = getplane(r); + plane *pl = getplane(r); if (pl && fval(pl, PFL_NORECRUITS)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_pflnorecruit", "")); return; @@ -1006,7 +1005,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) } } - assert(sk != NOSKILL || "limited resource needs a required skill for making it"); + assert(sk != NOSKILL || !"limited resource needs a required skill for making it"); skill = effskill(u, sk, 0); if (skill == 0) { add_message(&u->faction->msgs, @@ -1075,10 +1074,10 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist) { const item_type *itype = resource2item(rtype); rawmaterial *rm = rm_get(r, rtype); - int need; - bool first = true; if (rm != NULL) { + int need; + bool first = true; do { int avail = rm->amount; int nreq = 0; @@ -1302,7 +1301,6 @@ int make_cmd(unit * u, struct order *ord) int m = INT_MAX; const char *s; const struct locale *lang = u->faction->locale; - char ibuf[16]; keyword_t kwd; kwd = init_order_depr(ord); @@ -1310,6 +1308,7 @@ int make_cmd(unit * u, struct order *ord) s = gettoken(token, sizeof(token)); if (s) { + char ibuf[16]; m = atoip(s); sprintf(ibuf, "%d", m); if (!strcmp(ibuf, (const char *)s)) { @@ -1676,8 +1675,8 @@ static int tax_per_size[7] = { 0, 6, 12, 18, 24, 30, 36 }; static void expandselling(region * r, econ_request * sellorders, int limit) { - int money, price, max_products; - unsigned int j, norders; + int money, max_products; + int norders; /* int m, n = 0; */ int maxsize = 0, maxeffsize = 0; int taxcollected = 0; @@ -1754,11 +1753,12 @@ static void expandselling(region * r, econ_request * sellorders, int limit) norders = expandorders(r, sellorders); if (norders > 0) { + int j; for (j = 0; j != norders; j++) { const luxury_type *search = NULL; const luxury_type *ltype = g_requests[j]->type.trade.ltype; int multi = r_demand(r, ltype); - int i; + int i, price; int use = 0; for (i = 0, search = luxurytypes; search != ltype; search = search->next) { /* TODO: this is slow and lame! */ @@ -2339,13 +2339,13 @@ static void research_cmd(unit * u, struct order *ord) static void expandentertainment(region * r) { - unit *u; int m = entertainmoney(r); econ_request *o; for (o = &entertainers[0]; o != nextentertainer; ++o) { double part = m / (double)entertaining; - u = o->unit; + unit *u = o->unit; + if (entertaining <= m) u->n = o->qty; else diff --git a/src/economy.h b/src/economy.h index ec12ae0ca..d3e8f0aa0 100644 --- a/src/economy.h +++ b/src/economy.h @@ -71,7 +71,7 @@ extern "C" { void produce(struct region *r); void auto_work(struct region *r); - unsigned int expand_production(struct region * r, struct econ_request * requests, struct econ_request ***results); + 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; void add_income(struct unit * u, income_t type, int want, int qty); diff --git a/src/steal.c b/src/steal.c index 65316f1dd..9403b4fd8 100644 --- a/src/steal.c +++ b/src/steal.c @@ -49,8 +49,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. void expandstealing(region * r, econ_request * stealorders) { const resource_type *rsilver = get_resourcetype(R_SILVER); - unsigned int j; - unsigned int norders; + int norders, j; econ_request **requests; assert(rsilver);