From 251be32bce39d6b954d818e668556f4c6e72b0fc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 8 Mar 2003 20:57:38 +0000 Subject: [PATCH] Dumpfbackenbrot, Wahrnehmungscheck. Einheitlicher "Einheit nicht gefunden" Fehler (63, nicht 64) --- src/common/gamecode/economy.c | 4 ++-- src/common/gamecode/laws.c | 6 ++--- src/common/gamecode/spy.c | 2 +- src/common/kernel/battle.c | 32 ++++++++++++++++++++------- src/common/kernel/battle.h | 2 ++ src/common/kernel/item.c | 5 ++++- src/common/kernel/movement.c | 8 +++---- src/config.h | 1 - src/eressea/main.c | 10 ++++----- src/res/de/messages.xml | 20 +++++++---------- src/res/en/messages.xml | 41 ----------------------------------- 11 files changed, 52 insertions(+), 79 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 79137b2af..91fbadbeb 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -715,7 +715,7 @@ giveunit(region * r, unit * u, unit * u2, strlist * S) givemen(u->number, u, NULL, S->s); cmistake(u, S->s, 153, MSG_COMMERCE); } else { - cmistake(u, S->s, 64, MSG_COMMERCE); + cmistake(u, S->s, 63, MSG_COMMERCE); } return; } @@ -2921,7 +2921,7 @@ steal(region * r, unit * u, request ** stealorders) } if (!u2) { - cmistake(u, findorder(u, u->thisorder), 64, MSG_INCOME); + cmistake(u, findorder(u, u->thisorder), 63, MSG_INCOME); return; } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 9c8a785b0..87233a50e 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1572,7 +1572,7 @@ set_name(region * r, unit * u, strlist * S) if (foreign == true) { unit *u2 = getunit(r, u->faction); if (!u2 || !cansee(u->faction, r, u2, 0)) { - cmistake(u, S->s, 64, MSG_EVENT); + cmistake(u, S->s, 63, MSG_EVENT); break; } if (!fval(u,FL_UNNAMED)) { @@ -1677,7 +1677,7 @@ mailunit(region * r, unit * u, int n, strlist * S, const char * s) deliverMail(u2->faction, r, u, s, u2); } else - cmistake(u, S->s, 64, MSG_MESSAGE); + cmistake(u, S->s, 63, MSG_MESSAGE); /* Immer eine Meldung - sonst könnte man so getarnte EHs enttarnen: * keine Meldung -> EH hier. */ } @@ -1767,7 +1767,7 @@ distributeMail(region * r, unit * u, strlist * S) } if(see == false) { - cmistake(u, S->s, 64, MSG_MESSAGE); + cmistake(u, S->s, 63, MSG_MESSAGE); return; } diff --git a/src/common/gamecode/spy.c b/src/common/gamecode/spy.c index 729f2cb0e..3e83a4700 100644 --- a/src/common/gamecode/spy.c +++ b/src/common/gamecode/spy.c @@ -63,7 +63,7 @@ spy(region * r, unit * u) target = getunit(r, u->faction); if (!target) { - cmistake(u, findorder(u, u->thisorder), 64, MSG_EVENT); + cmistake(u, findorder(u, u->thisorder), 63, MSG_EVENT); return; } if (!can_contact(r, u, target)) { diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index d3f31794b..32aee0e0b 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -584,15 +584,22 @@ reportcasualties(battle * b, fighter * fig, int dead) bfaction * bf; if (fig->alive == fig->unit->number) return; +#ifndef NO_RUNNING if (fig->run.region == NULL) { fig->run.region = fleeregion(fig->unit); if (fig->run.region == NULL) fig->run.region = b->region; } +#endif fbattlerecord(fig->unit->faction, b->region, " "); for (bf = b->factions;bf;bf=bf->next) { faction * f = bf->faction; +#ifdef NO_RUNNING + struct message * m = msg_message("casualties", "unit runto run alive fallen", + fig->unit, NULL, fig->run.number, fig->alive, dead); +#else struct message * m = msg_message("casualties", "unit runto run alive fallen", fig->unit, fig->run.region, fig->run.number, fig->alive, dead); +#endif brecord(f, b->region, m); msg_release(m); } @@ -2251,6 +2258,7 @@ loot_items(fighter * corpse) } } +#ifndef NO_RUNNING static void loot_fleeing(fighter* fig, unit* runner) { @@ -2266,6 +2274,7 @@ merge_fleeloot(fighter* fig, unit* u) { i_merge(&u->items, &fig->run.items); } +#endif static boolean seematrix(const faction * f, const side * s) @@ -2398,8 +2407,8 @@ aftermath(battle * b) assert(du->number >= 0); if (df->run.hp) { +#ifndef NO_RUNNING if (df->alive == 0) { - /* Report the casualties */ reportcasualties(b, df, dead); @@ -2422,11 +2431,15 @@ aftermath(battle * b) travel(r, du, df->run.region, 1); df->run.region = du->region; } - } else { + } else +#endif + { /* nur teilweise geflohene Einheiten mergen sich wieder */ df->alive += df->run.number; sum_hp += df->run.hp; +#ifndef NO_RUNNING merge_fleeloot(df, du); +#endif df->run.number = 0; df->run.hp = 0; /* df->run.region = NULL;*/ @@ -2441,7 +2454,9 @@ aftermath(battle * b) /* alle sind tot, niemand geflohen. Einheit auflösen */ df->run.number = 0; df->run.hp = 0; +#ifndef NO_RUNNING df->run.region = NULL; +#endif /* Report the casualties */ reportcasualties(b, df, dead); @@ -3327,11 +3342,12 @@ void flee(const troop dt) { fighter * fig = dt.fighter; +#ifndef NO_RUNNING unit * u = fig->unit; int carry = personcapacity(u) - u->race->weight; int money; - item ** ip = &u->items; + while (*ip) { item * itm = *ip; const item_type * itype = itm->type; @@ -3370,6 +3386,7 @@ flee(const troop dt) i_change(&u->items, i_silver, -money); i_change(&fig->run.items, i_silver, +money); } +#endif fig->run.hp += fig->person[dt.index].hp; ++fig->run.number; @@ -3488,7 +3505,7 @@ do_battle(void) /* Fehler: "Die Einheit wurde nicht gefunden" */ if (!u2 || fval(u2, FL_MOVED) || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) { - cmistake(u, sl->s, 64, MSG_BATTLE); + cmistake(u, sl->s, 63, MSG_BATTLE); list_continue(sl); } /* Fehler: "Die Einheit ist eine der unsrigen" */ @@ -3648,14 +3665,13 @@ do_battle(void) /* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ int runhp = min(600,(int)(0.9+unit_max_hp(u)*hpflee(u->status))); side *side = fig->side; - region *r = NULL; if (fval(u->race, RCF_UNDEAD) || old_race(u->race) == RC_SHADOWKNIGHT) continue; if (u->ship) continue; dt.fighter = fig; +#ifndef NO_RUNNING if (!fig->run.region) fig->run.region = fleeregion(u); - r = fig->run.region; - if (!r) - continue; + if (!fig->run.region) continue; +#endif dt.index = fig->alive - fig->removed; while (side->size[SUM_ROW] && dt.index != 0) { --dt.index; diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h index 1edc29f66..cf72d9146 100644 --- a/src/common/kernel/battle.h +++ b/src/common/kernel/battle.h @@ -163,8 +163,10 @@ typedef struct fighter { struct { int number; /* number of people who have flown */ int hp; /* accumulated hp of fleeing people */ +#ifndef NO_RUNNING struct region *region; /* destination of fleeing people */ struct item * items; /* items they take */ +#endif } run; int action_counter; /* number of active actions the struct unit did in the fight */ #ifdef SHOW_KILLS diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 683293272..1bc66968f 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -1947,7 +1947,10 @@ use_foolpotion(struct unit *u, int targetno, const struct item_type *itype, int cmistake(u, cmd, 63, MSG_EVENT); return ECUSTOM; } - /* TODO: wahrnehmung-check */ + if (effskill(u, SK_STEALTH)<=effskill(target, SK_OBSERVATION)) { + cmistake(u, cmd, 63, MSG_EVENT); + return ECUSTOM; + } ADDMSG(&u->faction->msgs, msg_message("givedumb", "unit recipient amount", u, target, amount)); assert(oldpotiontype[P_FOOL]->itype==itype); diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 108e99ade..eaf9bcded 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -817,7 +817,7 @@ init_drive(void) boolean found = false; ut = getunit(r, u->faction); if(!ut) { - cmistake(u, findorder(u, u->thisorder), 64, MSG_MOVE); + cmistake(u, findorder(u, u->thisorder), 63, MSG_MOVE); continue; } for (S = ut->orders; S; S = S->next) { @@ -832,7 +832,7 @@ init_drive(void) if(cansee(u->faction, r, ut, 0)) { cmistake(u, findorder(u, u->thisorder), 286, MSG_MOVE); } else { - cmistake(u, findorder(u, u->thisorder), 64, MSG_MOVE); + cmistake(u, findorder(u, u->thisorder), 63, MSG_MOVE); } } } @@ -1243,12 +1243,12 @@ travel(region * first, unit * u, region * next, int flucht) if(cansee(u->faction, u->region, ut, 0)) { cmistake(u, findorder(u, u->thisorder), 90, MSG_MOVE); } else { - cmistake(u, findorder(u, u->thisorder), 64, MSG_MOVE); + cmistake(u, findorder(u, u->thisorder), 63, MSG_MOVE); } } } else { if (ut) { - cmistake(u, findorder(u, u->thisorder), 64, MSG_MOVE); + cmistake(u, findorder(u, u->thisorder), 63, MSG_MOVE); } else { cmistake(u, findorder(u, u->thisorder), 99, MSG_MOVE); } diff --git a/src/config.h b/src/config.h index ca219a0d6..ad4569382 100644 --- a/src/config.h +++ b/src/config.h @@ -22,7 +22,6 @@ #ifndef CONFIG_H #define CONFIG_H - /**** **** ** Debugging Libraries ** **** ****/ diff --git a/src/eressea/main.c b/src/eressea/main.c index 4f573490f..f1e716040 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -381,17 +381,15 @@ game_done(void) #include "magic.h" -#if (defined(_MSC_VER)) -# define MALLOCDBG 1 -#endif - #if MALLOCDBG -static void +void init_malloc_debug(void) { #if (defined(_MSC_VER)) # if MALLOCDBG == 2 # define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF) +# elif MALLOCDBG == 3 +# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & 0) # elif MALLOCDBG == 1 # define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF) # endif @@ -640,7 +638,7 @@ main(int argc, char *argv[]) return -1; } #endif -#if MALLOCDBG +#if 0 init_malloc_debug(); #endif diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index 2612b9789..ecfb79aae 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -1209,30 +1209,25 @@ - + - - - "$unit($unit) in $region($region): '$command' - Die Einheit wurde nicht gefunden." - + "$unit($unit) in $region($region): '$command' - Die Einheit wurde nicht gefunden." + "$unit($unit) in $region($region): '$command' - The unit could not be found." - + - - - "$unit($unit) in $region($region): '$command' - Die Einheit wurde nicht gefunden." - - + "$unit($unit) in $region($region): '$command' - $unit($unit) ist nicht ausreichend getarnt." + "$unit($unit) in $region($region): '$command' - $unit($unit) is not sufficiently stealthy." @@ -6949,7 +6944,8 @@ - "$unit($unit) verlor $int($fallen) Personen$if($alive,", $int($alive) überlebten","")$if($run," und $int($run) flohen nach $region($runto)","")." + "$unit($unit) verlor $int($fallen) Personen$if($alive,", $int($alive) überlebten","")$if($run," und $int($run) flohen$if($isnull($runto),""," nach $region($runto)"),"")." + "$unit($unit) lost $int($fallen) people: $int($alive) survived$if($run," and $int($run) fled$if($isnull($runto),""," to $region($runto)"),"")." diff --git a/src/res/en/messages.xml b/src/res/en/messages.xml index 0ec2632b3..8ecb01fc0 100644 --- a/src/res/en/messages.xml +++ b/src/res/en/messages.xml @@ -727,32 +727,6 @@ - - - - - - - - - "$unit($unit) in $region($region): '$command' - The unit could not be found." - - - - - - - - - - - - - "$unit($unit) in $region($region): '$command' - The unit could not be found." - - - - @@ -3904,21 +3878,6 @@ - - - - - - - - - - - "$unit($unit) lost $int($fallen) people: $int($alive) survived and $int($run) fled to $region($runto)." - - - -