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;
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue