setting RF_COMBATDEBUG (bit 14) in a region triggers a summary of the weapons/skills in the battle

This commit is contained in:
Enno Rehling 2004-05-30 12:09:45 +00:00
parent 1ed345b5bc
commit cc21a19831
4 changed files with 132 additions and 55 deletions

View File

@ -3581,6 +3581,62 @@ init_battle(region * r, battle **bp)
return fighting;
}
static void
battle_stats(FILE * F, battle * b)
{
typedef struct stat_info {
struct stat_info * next;
weapon * wp;
int level;
int number;
} stat_info;
side * s;
cv_foreach(s, b->sides) {
fighter * df;
stat_info * stats = NULL, * stat;
cv_foreach(df, s->fighters) {
unit *du = df->unit;
troop dt;
stat_info * slast = NULL;
dt.fighter = df;
for (dt.index=0;dt.index!=du->number;++dt.index) {
weapon * wp = preferred_weapon(dt, true);
int level = wp->attackskill;
stat_info ** slist = &stats;
if (slast && slast->wp==wp && slast->level==level) {
++slast->number;
continue;
}
while (*slist && (*slist)->wp!=wp) {
slist = &(*slist)->next;
}
while (*slist && (*slist)->wp==wp && (*slist)->level>level) {
slist = &(*slist)->next;
}
stat = *slist;
if (stat->wp!=wp || stat->level!=level) {
stat = calloc(1, sizeof(stat_info));
stat->wp = wp;
stat->level = level;
stat->next = *slist;
*slist = stat;
}
slast = stat;
++slast->number;
}
} cv_next(df);
fprintf(F, "##STATS## Heer %u - %s:\n", s->index, factionname(s->bf->faction));
for (stat=stats;stat!=NULL;stat=stat->next) {
const weapon_type * wtype = stat->wp->type;
fprintf(F, "%s %u : %u\n", wtype->itype->rtype->_name[0], stat->level, stat->number);
}
freelist(stats);
} cv_next(s);
}
void
do_battle(void)
{
@ -3631,6 +3687,8 @@ do_battle(void)
b->has_tactics_turn = false;
}
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
/* PRECOMBATSPELLS */
do_combatmagic(b, DO_PRECOMBATSPELL);

View File

@ -78,7 +78,7 @@ extern "C" {
# define E_ENEMY 1
# define E_ATTACKING 2
int enemy[128];
struct side * enemies[128];
struct side * enemies[128];
cvector fighters; /* vector der Einheiten dieser Fraktion */
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */

View File

@ -1,7 +1,7 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
@ -23,22 +23,25 @@ extern "C" {
#define FAST_CONNECT
#define RF_CHAOTIC (1<<0)
#define RF_MALLORN (1<<1)
#define RF_BLOCKED (1<<2)
#define RF_CHAOTIC (1<<0)
#define RF_MALLORN (1<<1)
#define RF_BLOCKED (1<<2)
#define RF_BLOCK_NORTHWEST (1<<3)
#define RF_BLOCK_NORTHEAST (1<<4)
#define RF_BLOCK_EAST (1<<5)
#define RF_BLOCK_SOUTHEAST (1<<6)
#define RF_BLOCK_SOUTHWEST (1<<7)
#define RF_BLOCK_WEST (1<<8)
#define RF_BLOCK_NORTHWEST (1<<3)
#define RF_BLOCK_NORTHEAST (1<<4)
#define RF_BLOCK_EAST (1<<5)
#define RF_BLOCK_SOUTHEAST (1<<6)
#define RF_BLOCK_SOUTHWEST (1<<7)
#define RF_BLOCK_WEST (1<<8)
#define RF_ENCOUNTER (1<<9)
#define RF_MIGRATION (1<<10)
#define RF_UNUSED_1 (1<<11)
#define RF_ORCIFIED (1<<12)
#define RF_DH (1<<18)
#define RF_ENCOUNTER (1<<9)
#define RF_MIGRATION (1<<10)
#define RF_UNUSED_1 (1<<11)
#define RF_ORCIFIED (1<<12)
#define RF_COMBATDEBUG (1<<14)
#define RF_DH (1<<18)
#define RF_ALL 0xFFFFFF
@ -48,54 +51,54 @@ struct message_list;
struct rawmaterial;
typedef struct land_region {
char *name;
/* TODO: demand kann nach Konvertierung entfernt werden. */
struct demand {
struct demand * next;
const struct luxury_type * type;
int value;
} * demands;
const struct herb_type * herbtype;
short herbs;
char *name;
/* TODO: demand kann nach Konvertierung entfernt werden. */
struct demand {
struct demand * next;
const struct luxury_type * type;
int value;
} * demands;
const struct herb_type * herbtype;
short herbs;
#if GROWING_TREES
int trees[3]; /* 0 -> Samen, 1 -> Sprößlinge, 2 -> Bäume */
int trees[3]; /* 0 -> Samen, 1 -> Sprößlinge, 2 -> Bäume */
#else
int trees;
int trees;
#endif
int horses;
int peasants;
int newpeasants;
int money;
int horses;
int peasants;
int newpeasants;
int money;
#if NEW_RESOURCEGROWTH == 0
int iron;
int iron;
#endif
} land_region;
typedef struct region {
struct region *next;
struct land_region *land;
struct unit *units;
struct ship *ships;
struct building *buildings;
int x, y;
struct plane *planep;
char *display;
unsigned int flags;
unsigned short age;
struct message_list *msgs;
struct individual_message {
struct individual_message * next;
const struct faction * viewer;
struct message_list *msgs;
} * individual_messages;
struct attrib *attribs;
struct region *nexthash;
terrain_t terrain;
struct region *next;
struct land_region *land;
struct unit *units;
struct ship *ships;
struct building *buildings;
int x, y;
struct plane *planep;
char *display;
unsigned int flags;
unsigned short age;
struct message_list *msgs;
struct individual_message {
struct individual_message * next;
const struct faction * viewer;
struct message_list *msgs;
} * individual_messages;
struct attrib *attribs;
struct region *nexthash;
terrain_t terrain;
#ifdef WEATHER
weather_t weathertype;
weather_t weathertype;
#endif
#if NEW_RESOURCEGROWTH
struct rawmaterial * resources;
struct rawmaterial * resources;
#endif
#ifdef FAST_CONNECT
struct region * connect[MAXDIRECTIONS];
@ -120,7 +123,7 @@ typedef struct spec_direction {
} spec_direction;
typedef struct {
direction_t dir;
direction_t dir;
} moveblock;
#define region_hashkey(r) (abs((r)->x + 0x100 * (r)->y))

View File

@ -89,6 +89,20 @@ operator==(const region& a, const region&b)
return a.x==b.x && a.y==b.y;
}
static bool
region_getflag(const region& r, int bit)
{
if (r.flags & (1<<bit)) return true;
return false;
}
static void
region_setflag(region& r, int bit, bool set)
{
if (set) r.flags |= (1<<bit);
else r.flags &= ~(1<<bit);
}
void
bind_region(lua_State * L)
{
@ -103,6 +117,8 @@ bind_region(lua_State * L)
.property("info", &region_getinfo, &region_setinfo)
.property("terrain", &region_getterrain)
.def("add_notice", &region_addnotice)
.def("get_flag", &region_setflag)
.def("set_flag", &region_getflag)
.def_readonly("x", &region::x)
.def_readonly("y", &region::y)
.def_readwrite("age", &region::age)