- Changed a couple of compiler-settings

- Removed a bunch of warnings (shadowing variables)
This commit is contained in:
Enno Rehling 2008-04-22 10:40:20 +00:00
parent 2557e013fa
commit 5d731316c3
13 changed files with 158 additions and 144 deletions

View file

@ -68,9 +68,10 @@ CCFLAGS += -Wwrite-strings
-Wpointer-arith
# -Wshadow
# -Wcast-qual
# -Wcast-align
-Wcast-align
# -Wconversion
# -Wunreachable-code
-Werror
;
# this require the latet luabind from CVS
@ -139,8 +140,8 @@ rule TargetDirectory
LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(path) ;
SOURCE_GRIST = $(path) ;
if $(DEBUG) = 1 {
SubDirCcFlags -ggdb ;
SubDirC++Flags -ggdb ;
SubDirCcFlags -ggdb -DDEBUG=1 ;
SubDirC++Flags -ggdb -DDEBUG=1 ;
OPTIM = -O0 ;
}
else {

View file

@ -41,19 +41,19 @@ use_skillpotion(struct unit * u, const struct item_type * itype, int amount, str
* currently saved, it doesn't look likely (can't make eressea::list
* from them)
*/
int i;
for (i=0;i!=amount;++i) {
skill * sv = u->skills;
while (sv!=u->skills+u->skill_size) {
int i;
for (i=0;i!=3;++i) learn_skill(u, sv->id, 1.0);
++sv;
}
}
int n;
for (n=0;n!=amount;++n) {
skill * sv = u->skills;
while (sv!=u->skills+u->skill_size) {
int i;
for (i=0;i!=3;++i) learn_skill(u, sv->id, 1.0);
++sv;
}
}
ADDMSG(&u->faction->msgs, msg_message("skillpotion_use", "unit", u));
res_changeitem(u, itype->rtype, -amount);
return 0;
res_changeitem(u, itype->rtype, -amount);
return 0;
}
static int

View file

@ -73,36 +73,36 @@ const attrib_type at_kick = { "kick",
static attrib *
make_kick(void)
{
return a_new(&at_kick);
return a_new(&at_kick);
}
void
add_kick(attrib * a, const faction * f)
static void
add_kick(attrib * a, faction * f)
{
faction_list * flist = (faction_list*)a->data.v;
while (flist && flist->data!=f) flist = flist->next;
if (flist) return;
flist = calloc(1, sizeof(faction_list));
flist->data = (void*)f;
flist->next = (faction_list*)a->data.v;
a->data.v = flist;
faction_list * flist = (faction_list*)a->data.v;
while (flist && flist->data!=f) flist = flist->next;
if (flist) return;
flist = calloc(1, sizeof(faction_list));
flist->data = (void*)f;
flist->next = (faction_list*)a->data.v;
a->data.v = flist;
}
static void
alliance_kick(const tnode * tnext, void * data, struct order * ord)
{
unit * u = (unit*)data;
faction * f = findfaction(getid());
attrib * a;
unused(tnext);
if (f==NULL || f->alliance!=u->faction->alliance) {
/* does not belong to our alliance */
return;
}
a = a_find(f->attribs, &at_kick);
if (a==NULL) a = a_add(&f->attribs, make_kick());
add_kick(a, f);
unit * u = (unit*)data;
faction * f = findfaction(getid());
attrib * a;
unused(tnext);
if (f==NULL || f->alliance!=u->faction->alliance) {
/* does not belong to our alliance */
return;
}
a = a_find(f->attribs, &at_kick);
if (a==NULL) a = a_add(&f->attribs, make_kick());
add_kick(a, f);
}
static void

View file

@ -25,26 +25,19 @@
extern "C" {
#endif
/*
* Features enabled:
* If you are lacking the settings.h, create a new file common/settings.h,
* and write #include <settings-eressea.h> (or whatever settings you want
* your game to use) in there.
* !!! DO NOT COMMIT THE SETTINGS.H FILE TO CVS !!!
*/
/* this should always be the first thing included after config.h */
#include "types.h"
#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))
/* experimental gameplay features (that don't affect the savefile) */
/* experimental gameplay features (that don't affect the savefile) */
/* TODO: move these settings to settings.h or into configuration files */
#define GOBLINKILL /* Goblin-Spezialklau kann tödlich enden */
#define HERBS_ROT /* herbs owned by units have a chance to rot. */
#define SHIPDAMAGE /* Schiffsbeschädigungen */
#define INSECT_POTION /* Spezialtrank für Insekten */
#define ORCIFICATION /* giving snotlings to the peasants gets counted */
#undef TROLLSAVE /* saving throw for dead trolls */
#include <settings.h>
#undef TROLLSAVE /* saving throw for dead trolls */
#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))
#ifndef MAXREGIONS
# define MAXREGIONS 262139 /* must be prime for hashing. 262139=last<2^18 */

View file

@ -21,6 +21,15 @@
#ifndef ERESSEA_TYPES_H
#define ERESSEA_TYPES_H
/*
* Features enabled:
* If you are lacking the settings.h, create a new file common/settings.h,
* and write #include <settings-eressea.h> (or whatever settings you want
* your game to use) in there.
* !!! DO NOT COMMIT THE SETTINGS.H FILE TO CVS !!!
* settings.h should always be the first thing you include (after config.h).
*/
#include <settings.h>
#include <util/variant.h>
typedef short terrain_t;

View file

@ -78,22 +78,22 @@ static region * tower_region[6];
static region * start_region[6];
static region *
arena_region(int magic)
arena_region(int school)
{
return tower_region[magic];
return tower_region[school];
}
static building *
arena_tower(int magic)
arena_tower(int school)
{
return arena_region(magic)->buildings;
return arena_region(school)->buildings;
}
static int
leave_fail(unit * u)
{
ADDMSG(&u->faction->msgs, msg_message("arena_leave_fail", "unit", u));
return 1;
return 1;
}
static int
@ -167,25 +167,25 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord)
static int
use_wand_of_tears(unit * user, const struct item_type * itype, int amount, order * ord)
{
int i;
unused(ord);
for (i=0;i!=amount;++i) {
unit * u;
for (u=user->region->units;u;u=u->next) {
if (u->faction != user->faction) {
int i;
for (i=0;i!=u->skill_size;++i) {
if (rng_int()%3) reduce_skill(u, u->skills+i, 1);
}
ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect",
"unit", u));
}
}
}
ADDMSG(&user->region->msgs, msg_message("wand_of_tears_usage",
"unit", user));
return 0;
int n;
unused(ord);
for (n=0;n!=amount;++n) {
unit * u;
for (u=user->region->units;u;u=u->next) {
if (u->faction != user->faction) {
int i;
for (i=0;i!=u->skill_size;++i) {
if (rng_int()%3) reduce_skill(u, u->skills+i, 1);
}
ADDMSG(&u->faction->msgs, msg_message("wand_of_tears_effect",
"unit", u));
}
}
}
ADDMSG(&user->region->msgs, msg_message("wand_of_tears_usage",
"unit", user));
return 0;
}
/**

View file

@ -104,7 +104,7 @@ f_nolux(const region * r)
}
int
fix_demand(region *r)
fix_demand(region *rd)
{
region_list *rl, *rlist = NULL;
static const struct luxury_type **mlux = 0, ** ltypes;
@ -113,7 +113,7 @@ fix_demand(region *r)
int maxluxuries = get_maxluxuries();
if (maxluxuries==0) return 0;
recurse_regions(r, &rlist, f_nolux);
recurse_regions(rd, &rlist, f_nolux);
if (mlux==0) {
int i = 0;
mlux = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));

View file

@ -281,16 +281,16 @@ gm_teleport(const tnode * tnext, void * data, struct order * ord)
static void
gm_messageplane(const tnode * tnext, void * data, struct order * ord)
{
unit * u = (unit*)data;
const struct plane * p = rplane(u->region);
unit * gm = (unit*)data;
const struct plane * p = rplane(gm->region);
const char * zmsg = getstrtoken();
if (p==NULL) {
mistake(u, ord, "In diese Ebene kann keine Nachricht gesandt werden.");
mistake(gm, ord, "In diese Ebene kann keine Nachricht gesandt werden.");
} else {
/* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
attrib * permissions = a_find(gm->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
mistake(u, ord, "permission denied.");
mistake(gm, ord, "permission denied.");
}
else {
message * msg = msg_message("msg_event", "string", zmsg);
@ -316,14 +316,14 @@ gm_messageplane(const tnode * tnext, void * data, struct order * ord)
static void
gm_messagefaction(const tnode * tnext, void * data, struct order * ord)
{
unit * u = (unit*)data;
unit * gm = (unit*)data;
int n = getid();
faction * f = findfaction(n);
const char * msg = getstrtoken();
plane * p = rplane(u->region);
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
plane * p = rplane(gm->region);
attrib * permissions = a_find(gm->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
mistake(u, ord, "permission denied.");
mistake(gm, ord, "permission denied.");
return;
}
if (f!=NULL) {
@ -336,7 +336,7 @@ gm_messagefaction(const tnode * tnext, void * data, struct order * ord)
}
}
}
mistake(u, ord, "cannot send messages to this faction.");
mistake(gm, ord, "cannot send messages to this faction.");
}
/**
@ -705,12 +705,12 @@ gm_addfaction(const char * email, plane * p, region * r)
f->options = want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN);
{
faction * xist;
int i = atoi36("gm00")-1;
int id = atoi36("gm00")-1;
do {
xist = findfaction(++i);
xist = findfaction(++id);
} while (xist);
f->no = i;
f->no = id;
addlist(&factions, f);
fhash(f);
}

View file

@ -67,11 +67,11 @@ score(void)
{
FILE *scoreFP;
region *r;
faction *f;
faction *fc;
int allscores = 0;
char path[MAX_PATH];
for (f = factions; f; f = f->next) f->score = 0;
for (fc = factions; fc; fc = fc->next) fc->score = 0;
for (r = regions; r; r = r->next) {
unit * u;
@ -108,9 +108,9 @@ score(void)
}
}
for (s = r->ships; s; s = s->next) {
unit * u = shipowner(s);
if (u && u->faction) {
u->faction->score += s->size * 2;
unit * cap = shipowner(s);
if (cap && cap->faction) {
cap->faction->score += s->size * 2;
}
}
for (u = r->units; u; u = u->next) {
@ -154,10 +154,10 @@ score(void)
}
}
for (f = factions; f; f = f->next) {
f->score = f->score / 5;
if (f->no != MONSTER_FACTION && f->race != new_race[RC_TEMPLATE]) {
allscores += f->score;
for (fc = factions; fc; fc = fc->next) {
fc->score = fc->score / 5;
if (fc->no != MONSTER_FACTION && fc->race != new_race[RC_TEMPLATE]) {
allscores += fc->score;
}
}
if (allscores == 0) {
@ -168,6 +168,7 @@ score(void)
scoreFP = fopen(path, "w");
if (scoreFP) {
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf };
faction * f;
fwrite(utf8_bom, 1, 3, scoreFP);
for (f = factions; f; f = f->next) if (f->num_total != 0) {
fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n",
@ -193,6 +194,7 @@ score(void)
for (a = alliances; a; a = a->next) {
int alliance_score = 0, alliance_number = 0, alliance_factions = 0;
int grails = 0;
faction * f;
for (f = factions; f; f = f->next) {
if (f->alliance && f->alliance->id == a->id) {

View file

@ -38,11 +38,20 @@
#define ROW_FACTOR 3 /* factor for combat row advancement rule */
#define HEROES
#define SCORE_MODULE
#undef MUSEUM_MODULE
#undef ARENA_MODULE
#undef WORMHOLE_MODULE
#undef XECMD_MODULE
/* optional game components. TODO: These should either be
* configuration variables (XML), script extensions (lua),
* or both. We don't want separate binaries for different games
*/
#define SCORE_MODULE 1
#define MUSEUM_MODULE 0
#define ARENA_MODULE 0
#define WORMHOLE_MODULE 0
#define XECMD_MODULE 0
#define KARMA_MODULE 0
#define DUNGEON_MODULE 0
#define INFOCMD_MODULE 0
#define CHANGED_CROSSBOWS 0 /* use the WTF_ARMORPIERCING flag */
#define GLOBAL_WARMING 0 /* number of turns before global warming sets in */
#define SIMPLE_COMBAT
#define SIMPLE_ESCAPE

View file

@ -2736,7 +2736,7 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
display chunk addresses, sizes, bins, and other instrumentation.
*/
static void do_check_malloc_state()
static void do_check_malloc_state(void)
{
mstate av = get_malloc_state();
int i;

View file

@ -753,18 +753,18 @@ handlekey(state * st, int c)
if (regions!=NULL) {
map_region * mr = cursor_region(&st->display, cursor);
region * first = mr->r;
region * r = (first&&first->next)?first->next:regions;
while (r!=first) {
region * cur = (first&&first->next)?first->next:regions;
while (cur!=first) {
coordinate coord;
region2coord(r, &coord);
region2coord(cur, &coord);
if (tagged_region(st->selected, &coord)) {
st->cursor = coord;
st->wnd_info->update |= 1;
st->wnd_status->update |= 1;
break;
}
r = r->next;
if (!r && first) r = regions;
cur = cur->next;
if (!cur && first) cur = regions;
}
}
break;
@ -773,16 +773,16 @@ handlekey(state * st, int c)
if (regions!=NULL) {
map_region * mr = cursor_region(&st->display, cursor);
if (mr->r) {
region * r = mr->r;
if (r->planep==NULL) {
r = r_standard_to_astral(r);
region * cur = mr->r;
if (cur->planep==NULL) {
cur = r_standard_to_astral(cur);
} else if (r->planep==get_astralplane()) {
r = r_astral_to_standard(r);
cur = r_astral_to_standard(cur);
} else {
r = NULL;
cur = NULL;
}
if (r!=NULL) {
region2coord(r, &st->cursor);
if (cur!=NULL) {
region2coord(cur, &st->cursor);
} else {
beep();
}

View file

@ -183,12 +183,12 @@ verify_owners(boolean bOnce)
/* make sure that this is done only once! */
static void
do_once(const char * magic, int (*fptr)(void))
do_once(const char * magic_id, int (*fptr)(void))
{
attrib * a = find_key(global.attribs, atoi36(magic));
attrib * a = find_key(global.attribs, atoi36(magic_id));
if (!a) {
log_warning(("[do_once] a unique fix %d=\"%s\" was applied.\n", atoi36(magic), magic));
if (fptr() == 0) a_add(&global.attribs, make_key(atoi36(magic)));
log_warning(("[do_once] a unique fix %d=\"%s\" was applied.\n", atoi36(magic_id), magic_id));
if (fptr() == 0) a_add(&global.attribs, make_key(atoi36(magic_id)));
}
}
@ -442,7 +442,7 @@ fix_undead(void)
skill * sa = get_skill(u, SK_HERBALISM);
if (sm && sa) {
int level = sm->level;
int lvl = sm->level;
attrib * a = a_find(u->attribs, &at_mage);
if (a) {
a_remove(&u->attribs, a);
@ -451,14 +451,14 @@ fix_undead(void)
u->skills = 0;
u->skill_size = 0;
log_warning(("fixing skills for %s %s, level %d.\n", u->race->_name[0], itoa36(u->no), level));
log_warning(("fixing skills for %s %s, level %d.\n", u->race->_name[0], itoa36(u->no), lvl));
if (level>0) {
if (lvl>0) {
const race * rc = u->race;
skill_t sk;
for (sk=0;sk!=MAXSKILLS;++sk) {
if (rc->bonus[sk]>0) {
set_level(u, sk, level);
set_level(u, sk, lvl);
}
}
}
@ -483,12 +483,12 @@ fix_gates(void)
while (t && t->type!= &tt_gate) t=t->next;
if (t!=NULL) {
gate_data * gd = (gate_data*)t->data.v;
struct building * b = gd->gate;
struct building * bgate = gd->gate;
struct region * rtarget = gd->target;
if (r!=b->region) {
add_trigger(&b->attribs, "timer", trigger_gate(b, rtarget));
add_trigger(&b->attribs, "create", trigger_unguard(b));
fset(b, BLD_UNGUARDED);
if (r!=bgate->region) {
add_trigger(&bgate->attribs, "timer", trigger_gate(bgate, rtarget));
add_trigger(&bgate->attribs, "create", trigger_unguard(bgate));
fset(bgate, BLD_UNGUARDED);
}
}
remove_triggers(&u->attribs, "timer", &tt_gate);
@ -502,14 +502,14 @@ fix_gates(void)
while (t && t->type!= &tt_gate) t=t->next;
if (t!=NULL) {
gate_data * gd = (gate_data*)t->data.v;
struct building * b = gd->gate;
struct building * bgate = gd->gate;
struct region * rtarget = gd->target;
remove_triggers(&b->attribs, "timer", &tt_gate);
remove_triggers(&b->attribs, "create", &tt_unguard);
if (r!=b->region) {
add_trigger(&b->attribs, "timer", trigger_gate(b, rtarget));
add_trigger(&b->attribs, "create", trigger_unguard(b));
fset(b, BLD_UNGUARDED);
remove_triggers(&bgate->attribs, "timer", &tt_gate);
remove_triggers(&bgate->attribs, "create", &tt_unguard);
if (r!=bgate->region) {
add_trigger(&bgate->attribs, "timer", trigger_gate(bgate, rtarget));
add_trigger(&bgate->attribs, "create", trigger_unguard(bgate));
fset(bgate, BLD_UNGUARDED);
}
}
}
@ -654,7 +654,7 @@ static int
fix_astralplane(void)
{
plane * astralplane = get_astralplane();
region * r;
region * rs;
region_list * rlist = NULL;
faction * monsters = findfaction(MONSTER_FACTION);
@ -664,15 +664,15 @@ fix_astralplane(void)
freset(astralplane, PFL_NOFEED);
set_ursprung(monsters, astralplane->id, 0, 0);
for (r=regions;r;r=r->next) if (rplane(r)==astralplane) {
region * ra = r_standard_to_astral(r);
for (rs=regions;rs;rs=rs->next) if (rplane(rs)==astralplane) {
region * ra = r_standard_to_astral(rs);
if (ra==NULL) continue;
if (rterrain(r)!=T_FIREWALL) continue;
if (rterrain(rs)!=T_FIREWALL) continue;
if (rterrain(ra)==T_ASTRALB) continue;
if (ra->units!=NULL) {
add_regionlist(&rlist, ra);
}
log_printf("protecting firewall in %s by blocking astral space in %s.\n", regionname(r, NULL), regionname(ra, NULL));
log_printf("protecting firewall in %s by blocking astral space in %s.\n", regionname(rs, NULL), regionname(ra, NULL));
terraform(ra, T_ASTRALB);
}
while (rlist!=NULL) {
@ -718,11 +718,11 @@ fix_road_borders(void)
int i = 0;
if (incomplete_data) return;
for(hash=0; hash<BMAXHASH && i!=MAXDEL; hash++) {
border * bhash;
for (bhash=borders[hash];bhash && i!=MAXDEL;bhash=bhash->nexthash) {
for (hash=0; hash<BMAXHASH && i!=MAXDEL; hash++) {
border * blist;
for (blist=borders[hash];blist && i!=MAXDEL;blist=blist->nexthash) {
border * b;
for (b=bhash;b && i!=MAXDEL;b=b->next) {
for (b=blist;b && i!=MAXDEL;b=b->next) {
if (b->type == &bt_road) {
short x1, x2, y1, y2;
region *r1, *r2;