Speedups:

- side::alive und battle::alive wird kontinuierlich mitgeführt - Aufpassen!
- erste Ideen für FAST_GETUNITROW -- klappt aber noch nicht mit nonblockers, d.h. es disabled sich ist in Kämpfen mit denen selbsttätig
This commit is contained in:
Enno Rehling 2001-02-14 09:17:56 +00:00
parent 1f0e649185
commit e211a578eb
13 changed files with 48 additions and 39 deletions

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: alchemy.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: battle.c,v 1.13 2001/02/14 08:35:12 katze Exp $
* $Id: battle.c,v 1.14 2001/02/14 09:17:56 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -22,11 +22,8 @@
typedef enum combatmagic {
DO_PRECOMBATSPELL,
DO_POSTCOMBATSPELL
} combatmagic_t;
@ -461,6 +458,11 @@ get_unitrow(const fighter * af)
int front = 0;
size_t bsize;
#ifdef FAST_GETUNITROW
if (!b->nonblockers && b->alive==af->row.alive) {
return af->row.cached;
}
#endif
bsize = cv_size(&b->sides);
if (csize<bsize) {
@ -504,6 +506,10 @@ get_unitrow(const fighter * af)
*/
result = max(FIRST_ROW, row - retreat);
#ifdef FAST_GETUNITROW
af->row.alive = b->alive;
af->row.cached = result;
#endif
return result;
}
@ -797,6 +803,8 @@ rmtroop(troop dt)
side *ds = df->side;
--df->alive;
--df->side->alive;
--df->side->battle->alive;
assert(dt.index >= 0 && dt.index < df->unit->number);
assert(df->alive < df->unit->number);
df->person[dt.index] = df->person[df->alive - df->removed];
@ -2162,16 +2170,23 @@ aftermath(battle * b)
#ifdef TROLLSAVE
/* Trolle können regenerieren */
if (df->alive > 0 && dead && du->race == RC_TROLL)
for (i = 0; i != dead; ++i)
if (chance(TROLL_REGENERATION))
for (i = 0; i != dead; ++i) {
if (chance(TROLL_REGENERATION)) {
++df->alive;
++df->side->alive;
++df->side->battle->alive;
}
}
trollsave[df->side->index] += dead - du->number + df->alive;
#endif
/* Regeneration durch PR_MERCY */
if (dead && pr_mercy)
for (i = 0; i != dead; ++i)
if (rand()%100 < pr_mercy)
if (rand()%100 < pr_mercy) {
++df->alive;
++df->side->alive;
++df->side->battle->alive;
}
/* Tote, die wiederbelebt werde können */
if (!nonplayer(df->unit)) {
@ -2212,7 +2227,6 @@ aftermath(battle * b)
if (s->bf->lastturn+(b->has_tactics_turn?1:0)>1) {
relevant = true;
}
s->alive = 0;
s->flee = 0;
s->dead = 0;
@ -2235,7 +2249,6 @@ aftermath(battle * b)
s->dead += dead;
s->flee += df->run_number;
s->alive += df->alive;
if (df->alive == du->number) continue; /* nichts passiert */
@ -2707,6 +2720,8 @@ make_fighter(battle * b, unit * u, boolean attack)
fig->status = u->status;
fig->side = s1;
fig->alive = u->number;
fig->side->alive += u->number;
fig->side->battle->alive += u->number;
fig->catmsg = -1;
/* Freigeben nicht vergessen! */
@ -2838,6 +2853,9 @@ make_fighter(battle * b, unit * u, boolean attack)
s1->size[SUM_ROW] += u->number;
if (race[u->race].battle_flags & BF_NOBLOCK) {
s1->nonblockers[fig->status + FIGHT_ROW] += u->number;
#ifdef FAST_GETUNITROW
b->nonblockers = true;
#endif
}
if (race[fig->unit->race].flags & RCF_HORSE) {
@ -3094,14 +3112,6 @@ battle_report(battle * b)
bfaction *bf;
buf[0] = 0;
for_each(s, b->sides) {
fighter *f;
s->alive = 0;
for_each(f, s->fighters) {
s->alive += f->alive;
} next(f);
} next(s);
for_each(s, b->sides) {
for_each(s2, b->sides) {

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: battle.h,v 1.3 2001/02/14 01:38:50 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -15,11 +14,18 @@
#ifndef BATTLE_H
#define BATTLE_H
/** new code defines **/
#define FAST_GETUNITROW
#define FASTENEMY
/** more defines **/
#define FS_ENEMY 1
#define FS_HELP 2
#define NUMROWS 5 /* Eressea hat 4 Verteidigungslinien. 1 ist
* * * vorn */
/***** Verteidigungslinien.
* Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthält Summen
*/
#define NUMROWS 5
#define SUM_ROW 0
#define FIGHT_ROW 1
#define BEHIND_ROW 2
@ -51,7 +57,11 @@ typedef struct battle {
int keeploot;
boolean reelarrow;
int dh;
int alive;
boolean small;
#ifdef FAST_GETUNITROW
boolean nonblockers;
#endif
} battle;
typedef struct tactics {
@ -66,7 +76,6 @@ typedef struct side {
struct faction *faction; /* Die Partei, die hier kämpft */
struct bfaction * bf; /* Die Partei, die hier kämpft */
const struct group * group;
#define FASTENEMY
#ifdef FASTENEMY
# define E_ENEMY 1
# define E_ATTACKING 2
@ -168,6 +177,12 @@ typedef struct fighter {
int run_hp; /* accumulated hp of fleeing people */
struct region *run_to; /* destination of fleeing people */
int action_counter; /* number of active actions the struct unit did in the fight */
#ifdef FAST_GETUNITROW
struct {
int alive;
int cached;
} row;
#endif
} fighter;
typedef struct troop {

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: build.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: building.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: curse.h,v 1.4 2001/02/03 13:45:32 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: eressea.h,v 1.17 2001/02/12 22:39:56 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: faction.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: group.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: item.h,v 1.5 2001/02/14 07:44:57 enno Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)

View File

@ -155,18 +155,10 @@ SOURCE=.\building.h
# End Source File
# Begin Source File
SOURCE=.\creation.h
# End Source File
# Begin Source File
SOURCE=.\curse.h
# End Source File
# Begin Source File
SOURCE=.\economy.h
# End Source File
# Begin Source File
SOURCE=.\eressea.h
# End Source File
# Begin Source File

Binary file not shown.

View File

@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Za /W4 /GX /Z7 /O2 /I ".." /I "../common" /I "../common/util" /I "../common/kernel" /I "../common/gamecode" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "NDEBUG" /D "CONVERT_TRIGGER" /YX /FD /c
# ADD CPP /nologo /Za /W4 /GX /Z7 /O2 /I ".." /I "../common" /I "../common/util" /I "../common/kernel" /I "../common/gamecode" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "NDEBUG" /D "CONVERT_TRIGGER" /FR /YX /FD /c
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe