From 390bf522f7f0d3ed3d052aa676b3561bae632ae7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 20 May 2008 14:28:31 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=1428 - there are no roads in astral space --- src/common/kernel/move.c | 4 ++-- src/common/kernel/xmlreader.c | 3 ++- src/eressea/lua/region.cpp | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/kernel/move.c b/src/common/kernel/move.c index fbfc2c103..25051383a 100644 --- a/src/common/kernel/move.c +++ b/src/common/kernel/move.c @@ -1126,8 +1126,8 @@ roadto(const region * r, direction_t dir) if (get_curse(r2->attribs, roads_ct)!=NULL) return true; } - if (r->terrain->max_road == 0) return false; - if (r2->terrain->max_road == 0) return false; + if (r->terrain->max_road <= 0) return false; + if (r2->terrain->max_road <= 0) return false; if (rroad(r, dir) < r->terrain->max_road) return false; if (rroad(r2, dir_invert(dir)) < r2->terrain->max_road) return false; return true; diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index bc1b033bb..ccb838214 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -1667,7 +1667,8 @@ parse_terrains(xmlDocPtr doc) terrain->_name = strdup((const char *)propValue); xmlFree(propValue); - terrain->max_road = (short)xml_ivalue(node, "road", -1); + terrain->max_road = (short)xml_ivalue(node, "road", 0); + assert(terrain->max_road>=0); terrain->size = xml_ivalue(node, "size", 0); if (xml_bvalue(node, "forbidden", false)) terrain->flags |= FORBIDDEN_REGION; diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index f1607cfda..5a9739155 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -195,13 +195,16 @@ region_setresource(region& r, const char * type, int value) static void region_setroad(region& r, int dir, lua_Number size) { - rsetroad(&r, (direction_t)dir, (short)(r.terrain->max_road * size)); + if (r.terrain->max_road>0) { + rsetroad(&r, (direction_t)dir, (short)(r.terrain->max_road * size)); + } } static lua_Number region_getroad(region& r, int dir) { lua_Number result = rroad(&r, (direction_t)dir); + if (r.terrain->max_road<=0 || result<=0) return 0; return r.terrain->max_road / result; }