forked from github/server
cppcheck: reduce variable scope.
This commit is contained in:
parent
6dd3783ecb
commit
d802f6ea67
3 changed files with 21 additions and 22 deletions
|
@ -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;
|
unit *u;
|
||||||
econ_request *o;
|
econ_request *o;
|
||||||
unsigned int norders = 0;
|
int norders = 0;
|
||||||
|
|
||||||
/* Alle Units ohne production haben ein -1, alle units mit orders haben ein
|
/* Alle Units ohne production haben ein -1, alle units mit orders haben ein
|
||||||
* 0 hier stehen */
|
* 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);
|
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) {
|
for (req = rec->requests; req; req = req->next) {
|
||||||
unit *u = req->unit;
|
unit *u = req->unit;
|
||||||
const race *rc = u_race(u); /* race is set in recruit() */
|
const race *rc = u_race(u); /* race is set in recruit() */
|
||||||
int number, dec;
|
int number;
|
||||||
double multi = 2.0 * rc->recruit_multi;
|
double multi = 2.0 * rc->recruit_multi;
|
||||||
|
|
||||||
number = (int)(get / multi);
|
number = (int)(get / multi);
|
||||||
|
@ -359,7 +359,7 @@ static int do_recruiting(recruitment * recruits, int available)
|
||||||
}
|
}
|
||||||
add_recruits(u, number, req->qty);
|
add_recruits(u, number, req->qty);
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
dec = (int)(number * multi);
|
int dec = (int)(number * multi);
|
||||||
if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) {
|
if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) {
|
||||||
recruited += dec;
|
recruited += dec;
|
||||||
}
|
}
|
||||||
|
@ -388,8 +388,7 @@ void free_recruitments(recruitment * recruits)
|
||||||
/* Rekrutierung */
|
/* Rekrutierung */
|
||||||
static void expandrecruit(region * r, econ_request * recruitorders)
|
static void expandrecruit(region * r, econ_request * recruitorders)
|
||||||
{
|
{
|
||||||
recruitment *recruits = NULL;
|
recruitment *recruits;
|
||||||
|
|
||||||
int orc_total = 0;
|
int orc_total = 0;
|
||||||
|
|
||||||
/* peasant limited: */
|
/* 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)
|
static void recruit(unit * u, struct order *ord, econ_request ** recruitorders)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
plane *pl;
|
|
||||||
econ_request *o;
|
econ_request *o;
|
||||||
int recruitcost = -1;
|
int recruitcost = -1;
|
||||||
const faction *f = u->faction;
|
const faction *f = u->faction;
|
||||||
const struct race *rc = u_race(u);
|
const struct race *rc = u_race(u);
|
||||||
const char *str;
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
init_order_depr(ord);
|
init_order_depr(ord);
|
||||||
|
@ -447,6 +444,8 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders)
|
||||||
|
|
||||||
if (u->number == 0) {
|
if (u->number == 0) {
|
||||||
char token[128];
|
char token[128];
|
||||||
|
const char *str;
|
||||||
|
|
||||||
str = gettoken(token, sizeof(token));
|
str = gettoken(token, sizeof(token));
|
||||||
if (str && str[0]) {
|
if (str && str[0]) {
|
||||||
/* Monsters can RECRUIT 15 DRACOID
|
/* Monsters can RECRUIT 15 DRACOID
|
||||||
|
@ -506,7 +505,7 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recruitcost) {
|
if (recruitcost) {
|
||||||
pl = getplane(r);
|
plane *pl = getplane(r);
|
||||||
if (pl && fval(pl, PFL_NORECRUITS)) {
|
if (pl && fval(pl, PFL_NORECRUITS)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_pflnorecruit", ""));
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_pflnorecruit", ""));
|
||||||
return;
|
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);
|
skill = effskill(u, sk, 0);
|
||||||
if (skill == 0) {
|
if (skill == 0) {
|
||||||
add_message(&u->faction->msgs,
|
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);
|
const item_type *itype = resource2item(rtype);
|
||||||
rawmaterial *rm = rm_get(r, rtype);
|
rawmaterial *rm = rm_get(r, rtype);
|
||||||
int need;
|
|
||||||
bool first = true;
|
|
||||||
|
|
||||||
if (rm != NULL) {
|
if (rm != NULL) {
|
||||||
|
int need;
|
||||||
|
bool first = true;
|
||||||
do {
|
do {
|
||||||
int avail = rm->amount;
|
int avail = rm->amount;
|
||||||
int nreq = 0;
|
int nreq = 0;
|
||||||
|
@ -1302,7 +1301,6 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
int m = INT_MAX;
|
int m = INT_MAX;
|
||||||
const char *s;
|
const char *s;
|
||||||
const struct locale *lang = u->faction->locale;
|
const struct locale *lang = u->faction->locale;
|
||||||
char ibuf[16];
|
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
|
|
||||||
kwd = init_order_depr(ord);
|
kwd = init_order_depr(ord);
|
||||||
|
@ -1310,6 +1308,7 @@ int make_cmd(unit * u, struct order *ord)
|
||||||
s = gettoken(token, sizeof(token));
|
s = gettoken(token, sizeof(token));
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
|
char ibuf[16];
|
||||||
m = atoip(s);
|
m = atoip(s);
|
||||||
sprintf(ibuf, "%d", m);
|
sprintf(ibuf, "%d", m);
|
||||||
if (!strcmp(ibuf, (const char *)s)) {
|
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)
|
static void expandselling(region * r, econ_request * sellorders, int limit)
|
||||||
{
|
{
|
||||||
int money, price, max_products;
|
int money, max_products;
|
||||||
unsigned int j, norders;
|
int norders;
|
||||||
/* int m, n = 0; */
|
/* int m, n = 0; */
|
||||||
int maxsize = 0, maxeffsize = 0;
|
int maxsize = 0, maxeffsize = 0;
|
||||||
int taxcollected = 0;
|
int taxcollected = 0;
|
||||||
|
@ -1754,11 +1753,12 @@ static void expandselling(region * r, econ_request * sellorders, int limit)
|
||||||
|
|
||||||
norders = expandorders(r, sellorders);
|
norders = expandorders(r, sellorders);
|
||||||
if (norders > 0) {
|
if (norders > 0) {
|
||||||
|
int j;
|
||||||
for (j = 0; j != norders; j++) {
|
for (j = 0; j != norders; j++) {
|
||||||
const luxury_type *search = NULL;
|
const luxury_type *search = NULL;
|
||||||
const luxury_type *ltype = g_requests[j]->type.trade.ltype;
|
const luxury_type *ltype = g_requests[j]->type.trade.ltype;
|
||||||
int multi = r_demand(r, ltype);
|
int multi = r_demand(r, ltype);
|
||||||
int i;
|
int i, price;
|
||||||
int use = 0;
|
int use = 0;
|
||||||
for (i = 0, search = luxurytypes; search != ltype; search = search->next) {
|
for (i = 0, search = luxurytypes; search != ltype; search = search->next) {
|
||||||
/* TODO: this is slow and lame! */
|
/* TODO: this is slow and lame! */
|
||||||
|
@ -2339,13 +2339,13 @@ static void research_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
static void expandentertainment(region * r)
|
static void expandentertainment(region * r)
|
||||||
{
|
{
|
||||||
unit *u;
|
|
||||||
int m = entertainmoney(r);
|
int m = entertainmoney(r);
|
||||||
econ_request *o;
|
econ_request *o;
|
||||||
|
|
||||||
for (o = &entertainers[0]; o != nextentertainer; ++o) {
|
for (o = &entertainers[0]; o != nextentertainer; ++o) {
|
||||||
double part = m / (double)entertaining;
|
double part = m / (double)entertaining;
|
||||||
u = o->unit;
|
unit *u = o->unit;
|
||||||
|
|
||||||
if (entertaining <= m)
|
if (entertaining <= m)
|
||||||
u->n = o->qty;
|
u->n = o->qty;
|
||||||
else
|
else
|
||||||
|
|
|
@ -71,7 +71,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);
|
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);
|
||||||
|
|
|
@ -49,8 +49,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
void expandstealing(region * r, econ_request * stealorders)
|
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;
|
int norders, j;
|
||||||
unsigned int norders;
|
|
||||||
econ_request **requests;
|
econ_request **requests;
|
||||||
|
|
||||||
assert(rsilver);
|
assert(rsilver);
|
||||||
|
|
Loading…
Reference in a new issue