From 7d927094dddbb9618d2979ae0a291fa74045a789 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Jan 2004 23:52:57 +0000 Subject: [PATCH] Bugfix crashbug bei Astraler Wirbel --- src/common/gamecode/report.c | 8 ++++++-- src/common/kernel/eressea.h | 24 ++++++++++++------------ src/common/kernel/movement.c | 19 ++++++++++--------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 82d777a4a..5280df44a 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -3849,8 +3849,12 @@ eval_direction(struct opstack ** stack, const void * userdata) { const faction * report = (const faction*)userdata; int i = opop(stack, int); - - const char * c = LOC(report->locale, directions[i]); + const char * c; + if (i>=0) { + c = LOC(report->locale, directions[i]); + } else { + c = LOC(report->locale, "unknown_direction"); + } opush(stack, strcpy(balloc(strlen(c)+1), c)); } diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 40776a0a4..5b4b90ba4 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -37,20 +37,20 @@ extern "C" { /* #define MSG_LEVELS -- msg-levels active */ /* basic types used in the eressea "kernel" */ -typedef unsigned char order_t; -typedef char terrain_t; -typedef char direction_t; -typedef int race_t; -typedef int magic_t; +typedef short order_t; +typedef short terrain_t; +typedef short direction_t; +typedef short race_t; +typedef short magic_t; typedef short skill_t; typedef short typ_t; -typedef int herb_t; -typedef int potion_t; -typedef int luxury_t; -typedef int weapon_t; -typedef int item_t; -typedef int resource_t; -typedef int spellid_t; +typedef short herb_t; +typedef short potion_t; +typedef short luxury_t; +typedef short weapon_t; +typedef short item_t; +typedef short resource_t; +typedef short spellid_t; struct plane; struct spell; diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 08aa819bb..00310e617 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -1058,7 +1058,7 @@ travel(region * first, unit * u, region * next, int flucht) direction_t dir = reldirection(current, next); border * b = get_borders(current, next); - while (b) { + while (b!=NULL) { if (b->type==&bt_wisps) { wall_data * wd = (wall_data*)b->data; if (wd->active) { @@ -1081,15 +1081,17 @@ travel(region * first, unit * u, region * next, int flucht) k -= BP_NORMAL; if (k<0) break; /* r2 -> Zielregion, r3 -> Momentane Region */ - if (move_blocked(u, current, reldirection(current, next)) + if (dir>=0 && move_blocked(u, current, dir) || curse_active(get_curse(current->attribs, fogtrap_ct))) { ADDMSG(&u->faction->msgs, msg_message("leavefail", - "unit region", u, next)); + "unit region", + u, next)); } - if (!entrance_allowed(u, next)) { + if (!entrance_allowed(u, next)) { ADDMSG(&u->faction->msgs, msg_message("regionowned", - "unit region target", u, current, next)); + "unit region target", + u, current, next)); break; } if ((wache = bewegung_blockiert_von(u, current)) != (unit *) NULL @@ -1116,10 +1118,9 @@ travel(region * first, unit * u, region * next, int flucht) if (rterrain(next) == T_OCEAN && !canswim(u)) { plane *pl = getplane(next); - if(pl && fval(pl, PFL_NOCOORDS)) { + if (pl!=NULL && fval(pl, PFL_NOCOORDS)) { add_message(&u->faction->msgs, new_message(u->faction, - "detectoceandir%u:unit%i:direction", u, - reldirection(current, next))); + "detectoceandir%u:unit%i:direction", u, dir)); } else { add_message(&u->faction->msgs, new_message(u->faction, "detectocean%u:unit%r:region", u, next)); @@ -1131,7 +1132,7 @@ travel(region * first, unit * u, region * next, int flucht) plane *pl = getplane(next); if(pl && fval(pl, PFL_NOCOORDS)) { add_message(&u->faction->msgs, new_message(u->faction, - "detectforbiddendir%u:unit%i:direction", u, reldirection(current, next))); + "detectforbiddendir%u:unit%i:direction", u, dir)); } else { add_message(&u->faction->msgs, new_message(u->faction, "detectforbidden%u:unit%r:region", u, next));