Fix carts in E3.

Store fighters in a quicklist, not a cvector.
This commit is contained in:
Enno Rehling 2011-02-27 12:04:29 -08:00
parent 1898dbe13a
commit 7d4205a3d1
3 changed files with 61 additions and 60 deletions

View File

@ -1,5 +1,11 @@
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010 # Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea", "src\eressea.vcxproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meropis", "..\meropis\src\meropis.vcxproj", "{52764450-41CA-11E0-B2EC-3136E0D72085}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "..\example\src\example.vcxproj", "{4A17DAEE-2261-4E2C-96F6-BA4132A09551}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kernel", "..\shared\src\kernel.vcxproj", "{6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kernel", "..\shared\src\kernel.vcxproj", "{6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gamecode", "..\shared\src\gamecode.vcxproj", "{1E8BFF9E-3044-0742-992F-C5765B80FE65}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gamecode", "..\shared\src\gamecode.vcxproj", "{1E8BFF9E-3044-0742-992F-C5765B80FE65}"
@ -10,12 +16,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-bindings", "..\shared\s
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "..\external\external.vcxproj", "{F9AE4586-8F65-486B-9666-744839E40A54}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "..\external\external.vcxproj", "{F9AE4586-8F65-486B-9666-744839E40A54}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea", "src\eressea.vcxproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "..\example\src\example.vcxproj", "{4A17DAEE-2261-4E2C-96F6-BA4132A09551}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "atlantis", "..\meropis\src\meropis.vcxproj", "{52764450-41CA-11E0-B2EC-3136E0D72085}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32

View File

@ -2,6 +2,7 @@
<resources xmlns:xi="http://www.w3.org/2001/XInclude"> <resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains resources that can be mined in some way (anything with a resourcelimit) --> <!-- this file contains resources that can be mined in some way (anything with a resourcelimit) -->
<xi:include href="eressea:///core/resources/cart.xml"/>
<xi:include href="eressea:///core/resources/horse.xml"/> <xi:include href="eressea:///core/resources/horse.xml"/>
<xi:include href="eressea:///core/resources/hp.xml"/> <xi:include href="eressea:///core/resources/hp.xml"/>
<xi:include href="eressea:///core/resources/laen.xml"/> <xi:include href="eressea:///core/resources/laen.xml"/>

View File

@ -34,6 +34,7 @@
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/quicklist.h>
#include <util/rand.h> #include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
@ -253,20 +254,30 @@ sp_stun(fighter * fi, int level, double power, spell * sp)
return level; return level;
} }
/* ------------------------------------------------------------- */ /** randomly shuffle an array
/* Für Sprüche 'get_scrambled_list_of_enemys_in_row', so daß man diese * for correctness, see Donald E. Knuth, The Art of Computer Programming
* Liste nur noch einmal durchlaufen muss, um Flächenzauberwirkungen */
* abzuarbeiten */ static void
scramble_fighters(quicklist * ql)
{
int qi, qlen = ql_length(ql);
for (qi=0;qi!=qlen;++qi) {
int qj = qi + (rng_int() % (qlen-qi));
void * a = ql_get(ql, qi);
void * b = ql_replace(ql, qj, a);
ql_replace(ql, qi, b);
}
}
/* Rosthauch */ /* Rosthauch */
int int
sp_combatrosthauch(fighter * fi, int level, double power, spell * sp) sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
cvector *fgs; quicklist *ql, *fgs;
void **fig;
int force = lovar(power * 15); int force = lovar(power * 15);
int k = 0; int qi, k = 0;
/* Immer aus der ersten Reihe nehmen */ /* Immer aus der ersten Reihe nehmen */
unused(sp); unused(sp);
@ -279,10 +290,10 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
} }
fgs = fighters(b, fi->side, FIGHT_ROW, BEHIND_ROW-1, FS_ENEMY); fgs = fighters(b, fi->side, FIGHT_ROW, BEHIND_ROW-1, FS_ENEMY);
v_scramble(fgs->begin, fgs->end); scramble_fighters(fgs);
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = *fig; fighter *df = (fighter *)ql_get(ql, qi);
if (df->alive==0) continue; if (df->alive==0) continue;
if (force<=0) break; if (force<=0) break;
@ -328,8 +339,7 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
} }
} }
} }
cv_kill(fgs); ql_free(fgs);
free(fgs);
if (k == 0) { if (k == 0) {
/* keine Waffen mehr da, die zerstört werden könnten */ /* keine Waffen mehr da, die zerstört werden könnten */
@ -637,11 +647,9 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
troop at; troop at;
int force; int force, qi, killed = 0;
int killed = 0;
const char *damage; const char *damage;
cvector *fgs; quicklist *fgs, *ql;
void **fig;
message * m; message * m;
/* 2d4 HP */ /* 2d4 HP */
@ -660,8 +668,8 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
at.index = 0; at.index = 0;
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY); fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY);
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = *fig; fighter *df = (fighter *)ql_get(ql, qi);
int n = df->alive-df->removed; int n = df->alive-df->removed;
troop dt; troop dt;
@ -673,8 +681,7 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
} }
if (force==0) break; if (force==0) break;
} }
cv_kill(fgs); ql_free(fgs);
free(fgs);
m = msg_message("battle::combatspell", "mage spell killed", fi->unit, sp, killed); m = msg_message("battle::combatspell", "mage spell killed", fi->unit, sp, killed);
message_all(b, m); message_all(b, m);
@ -875,11 +882,10 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
unit *mage = fi->unit; unit *mage = fi->unit;
cvector *fgs; quicklist *fgs, *ql;
void **fig;
message * m; message * m;
const char * mtype; const char * mtype;
int k = 0; int qi, k = 0;
if (!count_enemies(b, fi, FIGHT_ROW, NUMROWS, SELECT_ADVANCE|SELECT_FIND)) { if (!count_enemies(b, fi, FIGHT_ROW, NUMROWS, SELECT_ADVANCE|SELECT_FIND)) {
m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp); m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
@ -892,10 +898,10 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
else power = get_force(power, 5); else power = get_force(power, 5);
fgs = fighters(b, fi->side, FIGHT_ROW, NUMROWS, FS_ENEMY); fgs = fighters(b, fi->side, FIGHT_ROW, NUMROWS, FS_ENEMY);
v_scramble(fgs->begin, fgs->end); scramble_fighters(fgs);
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = *fig; fighter *df = (fighter *)ql_get(ql, qi);
int n = df->unit->number; int n = df->unit->number;
if (df->alive==0) continue; if (df->alive==0) continue;
@ -936,8 +942,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
} }
power = MAX(0, power-n); power = MAX(0, power-n);
} }
cv_kill(fgs); ql_free(fgs);
free(fgs);
if (sp->id==SPL_CHAOSROW) { if (sp->id==SPL_CHAOSROW) {
mtype = (k>0) ? "sp_chaosrow_effect_1" : "sp_chaosrow_effect_0"; mtype = (k>0) ? "sp_chaosrow_effect_1" : "sp_chaosrow_effect_0";
@ -958,9 +963,8 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
unit *mage = fi->unit; unit *mage = fi->unit;
cvector *fgs; quicklist *fgs, *ql;
void **fig; int force, n, qi;
int force, n;
int panik = 0; int panik = 0;
message * msg; message * msg;
@ -986,10 +990,11 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
} }
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY); fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY);
v_scramble(fgs->begin, fgs->end); scramble_fighters(fgs);
for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = (fighter *)ql_get(ql, qi);
for (fig = fgs->begin; fig != fgs->end; ++fig) {
fighter *df = *fig;
for (n=0; n!=df->alive; ++n) { for (n=0; n!=df->alive; ++n) {
if (force < 0) if (force < 0)
break; break;
@ -1009,8 +1014,7 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
} }
} }
} }
cv_kill(fgs); ql_free(fgs);
free(fgs);
msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik); msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik);
message_all(b, msg); message_all(b, msg);
@ -1496,14 +1500,13 @@ sp_keeploot(fighter * fi, int level, double power, spell * sp)
} }
static int static int
heal_fighters(cvector *fgs, int * power, boolean heal_monsters) heal_fighters(quicklist *fgs, int * power, boolean heal_monsters)
{ {
int healhp = *power; int healhp = *power, healed = 0, qi;
int healed = 0; quicklist *ql;
void **fig;
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = *fig; fighter *df = (fighter *)ql_get(ql, qi);
if (healhp<=0) break; if (healhp<=0) break;
@ -1542,7 +1545,7 @@ sp_healing(fighter * fi, int level, double power, spell * sp)
unit *mage = fi->unit; unit *mage = fi->unit;
int j = 0; int j = 0;
int healhp = (int)power * 200; int healhp = (int)power * 200;
cvector *fgs; quicklist *fgs;
message * msg; message * msg;
boolean use_item = get_item(mage, I_AMULET_OF_HEALING) > 0; boolean use_item = get_item(mage, I_AMULET_OF_HEALING) > 0;
@ -1557,11 +1560,10 @@ sp_healing(fighter * fi, int level, double power, spell * sp)
* bis zu verteilende HP aufgebraucht sind */ * bis zu verteilende HP aufgebraucht sind */
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_HELP); fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_HELP);
v_scramble(fgs->begin, fgs->end); scramble_fighters(fgs);
j += heal_fighters(fgs, &healhp, false); j += heal_fighters(fgs, &healhp, false);
j += heal_fighters(fgs, &healhp, true); j += heal_fighters(fgs, &healhp, true);
cv_kill(fgs); ql_free(fgs);
free(fgs);
if (j <= 0) { if (j <= 0) {
level = j; level = j;
@ -1583,19 +1585,18 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
battle *b = fi->side->battle; battle *b = fi->side->battle;
unit *mage = fi->unit; unit *mage = fi->unit;
region *r = b->region; region *r = b->region;
cvector *fgs; quicklist *fgs, *ql;
void **fig; int qi, n, undead = 0;
int n, undead = 0;
message * msg; message * msg;
int force = (int)get_force(power,0); int force = (int)get_force(power,0);
double c = 0.50 + 0.02 * power; double c = 0.50 + 0.02 * power;
/* Liste aus allen Kämpfern */ /* Liste aus allen Kämpfern */
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP ); fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP );
v_scramble(fgs->begin, fgs->end); scramble_fighters(fgs);
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (qi=0,ql=fgs; ql; ql_advance(&ql, &qi, 1)) {
fighter *df = *fig; fighter *df = (fighter *)ql_get(ql, qi);
unit *du = df->unit; unit *du = df->unit;
if (force<=0) break; if (force<=0) break;
@ -1644,8 +1645,7 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
} }
} }
} }
cv_kill(fgs); ql_free(fgs);
free(fgs);
level = MIN(level, undead); level = MIN(level, undead);
if (undead == 0) { if (undead == 0) {