This commit is contained in:
Enno Rehling 2009-09-23 17:06:58 +00:00
parent 3d76ec6882
commit 685bf6f4e0
3 changed files with 25 additions and 14 deletions

View File

@ -1509,7 +1509,7 @@ report_computer(const char * filename, report_context * ctx, const char * charse
int int
crwritemap(const char * filename) crwritemap(const char * filename)
{ {
FILE * F = fopen(filename, "w+"); FILE * F = fopen(filename, "w");
region * r; region * r;
fprintf(F, "VERSION %d\n", C_REPORT_VERSION); fprintf(F, "VERSION %d\n", C_REPORT_VERSION);

View File

@ -1565,20 +1565,26 @@ select_enemy(fighter * af, int minrow, int maxrow, int select)
} }
static int static int
get_tactics(side * s) get_tactics(const side * as, const side * ds)
{ {
battle * b = s->battle; battle * b = as->battle;
side *stac; side *stac;
int result = 0; int result = 0;
int defense = 0;
if (b->max_tactics > 0) { if (b->max_tactics > 0) {
for (stac=b->sides;stac!=b->sides+b->nsides;++stac) { for (stac=b->sides;stac!=b->sides+b->nsides;++stac) {
if (stac->leader.value >result && helping(stac, s)) { if (stac->leader.value > result && helping(stac, as)) {
assert(ds==NULL || !helping(stac, ds));
result = stac->leader.value; result = stac->leader.value;
} }
if (ds && stac->leader.value > defense && helping(stac, ds)) {
assert(!helping(stac, as));
defense = stac->leader.value;
}
} }
} }
return result; return result - defense;
} }
static troop static troop
@ -1603,14 +1609,19 @@ select_opponent(battle * b, troop at, int mindist, int maxdist)
tactics_formula = get_param_int(global.parameters, "rules.tactics.formula", 0); tactics_formula = get_param_int(global.parameters, "rules.tactics.formula", 0);
} }
if (tactics_formula==1) { if (tactics_formula==1) {
int tactics = get_tactics(dt.fighter->side); int tactics = get_tactics(at.fighter->side, dt.fighter->side);
/* percentage chance to get this attack */ /* percentage chance to get this attack */
double tacch = 0.1 * (b->max_tactics - tactics); if (tactics>0) {
if (fval(b->region->terrain, SEA_REGION)) { double tacch = 0.1 * tactics;
ship * sh = at.fighter->unit->ship; if (fval(b->region->terrain, SEA_REGION)) {
if (sh) tacch *= sh->type->tac_bonus; ship * sh = at.fighter->unit->ship;
} if (sh) tacch *= sh->type->tac_bonus;
if (!chance(tacch)) { }
if (!chance(tacch)) {
dt.fighter = NULL;
}
} else {
dt.fighter = NULL; dt.fighter = NULL;
} }
} }
@ -4200,7 +4211,7 @@ battle_attacks(battle * b)
/* Taktikrunde: */ /* Taktikrunde: */
if (b->turn == 0) { if (b->turn == 0) {
int tactics = get_tactics(s); int tactics = get_tactics(s, NULL);
if (b->max_tactics > 0 && tactics == b->max_tactics) { if (b->max_tactics > 0 && tactics == b->max_tactics) {
break; break;
} }

View File

@ -152,7 +152,7 @@ locale_string(const locale * lang, const char * key)
s = locale_string(default_locale, key); s = locale_string(default_locale, key);
} }
if (s_logfile) { if (s_logfile) {
s_debug = s_debug?s_debug:fopen(s_logfile, "w+"); s_debug = s_debug?s_debug:fopen(s_logfile, "w");
if (s_debug) { if (s_debug) {
fprintf(s_debug, "%s;%s;%s\n", key, lang->name, s); fprintf(s_debug, "%s;%s;%s\n", key, lang->name, s);
fflush(s_debug); fflush(s_debug);