declutter config.h, use it sparingly.

This commit is contained in:
Enno Rehling 2016-11-17 10:38:09 +01:00
parent f371a0c5f3
commit cbb18edb8f
11 changed files with 66 additions and 104 deletions

View File

@ -19,7 +19,6 @@ without prior permission by the authors of Eressea.
#include <kernel/alliance.h>
#include <kernel/faction.h>
#include <kernel/config.h>
#include <kernel/unit.h>
#include <kernel/item.h>
#include <kernel/faction.h>
@ -38,6 +37,23 @@ without prior permission by the authors of Eressea.
#include <tolua.h>
#include <string.h>
typedef struct helpmode {
const char *name;
int status;
} helpmode;
static helpmode helpmodes[] = {
{ "all", HELP_ALL },
{ "money", HELP_MONEY },
{ "fight", HELP_FIGHT },
{ "observe", HELP_OBSERVE },
{ "give", HELP_GIVE },
{ "guard", HELP_GUARD },
{ "stealth", HELP_FSTEALTH },
{ "travel", HELP_TRAVEL },
{ NULL, 0 }
};
int tolua_factionlist_next(lua_State * L)
{
faction **faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1));

View File

@ -1,6 +1,4 @@
#include <platform.h>
#include <kernel/config.h>
#include "spells.h"
/* kernel includes */

View File

@ -1,5 +1,4 @@
#include <platform.h>
#include <kernel/config.h>
/* kernel includes */
#include <kernel/order.h>

View File

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "bind_storage.h"
#include <kernel/save.h>

View File

@ -85,7 +85,7 @@ static const terrain_type *chaosterrain(void)
if (numtypes == 0) {
const terrain_type *terrain;
for (terrain = terrains(); terrain != NULL; terrain = terrain->next) {
if (fval(terrain, LAND_REGION) && terrain->herbs) {
if ((terrain->flags & LAND_REGION) && terrain->herbs) {
++numtypes;
}
}
@ -93,7 +93,7 @@ static const terrain_type *chaosterrain(void)
types = malloc(sizeof(terrain_type *) * numtypes);
numtypes = 0;
for (terrain = terrains(); terrain != NULL; terrain = terrain->next) {
if (fval(terrain, LAND_REGION) && terrain->herbs) {
if ((terrain->flags & LAND_REGION) && terrain->herbs) {
types[numtypes++] = terrain;
}
}
@ -139,7 +139,7 @@ static void chaos(region * r)
if (rng_int() % 100 < 8) {
switch (rng_int() % 3) {
case 0: /* Untote */
if (!fval(r->terrain, SEA_REGION)) {
if (!(r->terrain->flags & SEA_REGION)) {
unit *u = random_unit(r);
if (u && playerrace(u_race(u))) {
ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
@ -161,29 +161,28 @@ static void chaos(region * r)
break;
case 1:
mfac = 500;
u =
create_unit(r, get_monsters(), rng_int() % 4 + 1,
u = create_unit(r, get_monsters(), rng_int() % 4 + 1,
get_race(RC_DRAGON), 0, NULL, NULL);
break;
default:
mfac = 1000;
u =
create_unit(r, get_monsters(), rng_int() % 2 + 1,
u = create_unit(r, get_monsters(), rng_int() % 2 + 1,
get_race(RC_WYRM), 0, NULL, NULL);
break;
}
if (mfac)
if (mfac) {
set_money(u, u->number * (rng_int() % mfac));
fset(u, UFL_ISNEW | UFL_MOVED);
}
u->flags |= (UFL_ISNEW | UFL_MOVED);
}
break;
case 2: /* Terrainveränderung */
if (!fval(r->terrain, FORBIDDEN_REGION)) {
if (!fval(r->terrain, SEA_REGION)) {
case 2: /* Terrainver<EFBFBD>nderung */
if (!(r->terrain->flags & FORBIDDEN_REGION)) {
if (!(r->terrain->flags & SEA_REGION)) {
direction_t dir;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
region *rn = rconnect(r, dir);
if (rn && fval(rn->terrain, SEA_REGION))
if (rn && (rn->terrain->flags & SEA_REGION))
break;
}
if (dir != MAXDIRECTIONS) {
@ -224,7 +223,7 @@ static void chaos(region * r)
direction_t dir;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
region *rn = rconnect(r, dir);
if (rn && fval(rn->terrain, SEA_REGION))
if (rn && (rn->terrain->flags & SEA_REGION))
break;
}
if (dir != MAXDIRECTIONS) {
@ -242,7 +241,7 @@ void chaos_update(void) {
for (r = regions; r; r = r->next) {
int i;
if (fval(r, RF_CHAOTIC)) {
if ((r->flags & RF_CHAOTIC)) {
chaos(r);
}
i = get_chaoscount(r);

View File

@ -105,26 +105,6 @@ FILE *logfile;
bool battledebug = false;
int turn = -1;
helpmode helpmodes[] = {
{ "all", HELP_ALL }
,
{ "money", HELP_MONEY }
,
{ "fight", HELP_FIGHT }
,
{ "observe", HELP_OBSERVE }
,
{ "give", HELP_GIVE }
,
{ "guard", HELP_GUARD }
,
{ "stealth", HELP_FSTEALTH }
,
{ "travel", HELP_TRAVEL }
,
{ NULL, 0 }
};
const char *parameters[MAXPARAMS] = {
"LOCALE",
"ALLES",
@ -148,7 +128,7 @@ const char *parameters[MAXPARAMS] = {
"TEMP",
"FLIEHE",
"GEBAEUDE",
"GIB", /* Für HELFE */
"GIB", /* F<EFBFBD>r HELFE */
"KAEMPFE",
"DURCHREISE",
"BEWACHE",
@ -172,43 +152,6 @@ const char *parameters[MAXPARAMS] = {
"ALLIANZ"
};
const char *report_options[MAX_MSG] = {
"Kampf",
"Ereignisse",
"Bewegung",
"Einkommen",
"Handel",
"Produktion",
"Orkvermehrung",
"Zauber",
"",
""
};
const char *message_levels[ML_MAX] = {
"Wichtig",
"Debug",
"Fehler",
"Warnungen",
"Infos"
};
const char *options[MAXOPTIONS] = {
"AUSWERTUNG",
"COMPUTER",
"ZUGVORLAGE",
NULL,
"STATISTIK",
"DEBUG",
"ZIPPED",
"ZEITUNG", /* Option hat Sonderbehandlung! */
NULL,
"ADRESSEN",
"BZIP2",
"PUNKTE",
"SHOWSKCHANGE"
};
FILE *debug;
void
@ -711,8 +654,8 @@ char *_strdup(const char *s)
}
#endif
/* Lohn bei den einzelnen Burgstufen für Normale Typen, Orks, Bauern,
* Modifikation für Städter. */
/* Lohn bei den einzelnen Burgstufen f<EFBFBD>r Normale Typen, Orks, Bauern,
* Modifikation f<EFBFBD>r St<EFBFBD>dter. */
static const int wagetable[7][4] = {
{ 10, 10, 11, -7 }, /* Baustelle */
@ -929,7 +872,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
wage = _max(0, wage - 10);
}
/* Bei einer Dürre verdient man nur noch ein Viertel */
/* Bei einer D<EFBFBD>rre verdient man nur noch ein Viertel */
if (drought_ct) {
curse *c = get_curse(r->attribs, drought_ct);
if (curse_active(c))
@ -953,7 +896,7 @@ minimum_wage(const region * r, const faction * f, const race * rc, int in_turn)
return default_wage(r, f, rc, in_turn);
}
/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für
/* Gibt Arbeitslohn f<EFBFBD>r entsprechende Rasse zur<75>ck, oder f<>r
* die Bauern wenn f == NULL. */
int wage(const region * r, const faction * f, const race * rc, int in_turn)
{

View File

@ -27,17 +27,12 @@ extern "C" {
#include "types.h"
struct param;
#define DISPLAYSIZE 8192 /* max. Länge einer Beschreibung, incl trailing 0 */
#define DISPLAYSIZE 8192 /* max. L<EFBFBD>nge einer Beschreibung, incl trailing 0 */
#define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */
#define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */
#define IDSIZE 16 /* max. Länge einer no (als String), incl trailing 0 */
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die
* von struct unitname, etc. zurückgegeben werden. ohne die 0 */
/* ----------------- Befehle ----------------------------------- */
#define want(option) (1<<option)
/* ------------------------------------------------------------- */
#define NAMESIZE 128 /* max. L<>nge eines Namens, incl trailing 0 */
#define IDSIZE 16 /* max. L<>nge einer no (als String), incl trailing 0 */
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L<>nge der Strings, die
* von struct unitname, etc. zur<EFBFBD>ckgegeben werden. ohne die 0 */
#define i2b(i) ((bool)((i)?(true):(false)))
@ -110,7 +105,7 @@ struct param;
#define GF_SPECIFIC 16
/* der, die, das vs. ein, eine */
#define GF_DETAILED 32
/* mehr Informationen. z.b. straße zu 50% */
/* mehr Informationen. z.b. stra<EFBFBD>e zu 50% */
#define GF_PURE 64
/* untranslated */
@ -144,11 +139,6 @@ struct param;
} functions;
} settings;
typedef struct helpmode {
const char *name;
int status;
} helpmode;
void set_param(struct param **p, const char *key, const char *value);
const char *get_param(const struct param *p, const char *key);
int get_param_int(const struct param *p, const char *key, int def);
@ -173,7 +163,6 @@ struct param;
void free_gamedata(void);
void free_config(void);
extern struct helpmode helpmodes[];
extern const char *parameters[];
extern const char *localenames[];
extern settings global;
@ -184,8 +173,6 @@ struct param;
extern int turn;
extern bool getunitpeasants;
extern const char *options[MAXOPTIONS]; /* report options */
#ifdef __cplusplus
}
#endif

View File

@ -42,10 +42,10 @@ extern "C" {
#define FFL_DEFENDER (1<<10)
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
#define FFL_MARK (1<<23) /* für markierende algorithmen, die das
* hinterher auch wieder löschen ssen!
#define FFL_MARK (1<<23) /* f<EFBFBD>r markierende algorithmen, die das
* hinterher auch wieder l<EFBFBD>schen m<EFBFBD>ssen!
* (FFL_SELECT muss man vorher initialisieren,
* FL_MARK hinterher löschen) */
* FL_MARK hinterher l<EFBFBD>schen) */
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED)
@ -101,6 +101,8 @@ extern "C" {
extern struct faction *factions;
#define want(option) (1<<option)
void fhash(struct faction *f);
void funhash(struct faction *f);

View File

@ -31,6 +31,8 @@ extern "C" {
struct spellbook;
struct unit;
struct building;
struct faction;
struct region;
struct ship;
struct gamedata;

View File

@ -105,6 +105,22 @@ const char *coasts[MAXDIRECTIONS] = {
"coast::w"
};
const char *options[MAXOPTIONS] = {
"AUSWERTUNG",
"COMPUTER",
"ZUGVORLAGE",
NULL,
"STATISTIK",
"DEBUG",
"ZIPPED",
"ZEITUNG", /* Option hat Sonderbehandlung! */
NULL,
"ADRESSEN",
"BZIP2",
"PUNKTE",
"SHOWSKCHANGE"
};
bool omniscient(const faction *f)
{
static const race *rc_template, *rc_illusion;

View File

@ -43,6 +43,7 @@ extern "C" {
extern bool nocr;
extern bool noreports;
extern const char *visibility[];
extern const char *options[MAXOPTIONS]; /* report options */
void reports_done(void);