From aac3605463e6115402ff6d90095742eed4fe6bfb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 9 Jul 2004 14:05:14 +0000 Subject: [PATCH] =?UTF-8?q?Fehler=20bei=20letzter=20=C3=84nderung=20in=20g?= =?UTF-8?q?etunit()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/kernel/eressea.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 5d3ea9f80..09525f13d 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1654,16 +1654,13 @@ boolean getunitpeasants; unit * getunitg(const region * r, const faction * f) { - int n; - getunitpeasants = 0; - - n = read_unitid(f, r); + int n = read_unitid(f, r); if (n == 0) { getunitpeasants = 1; return NULL; } - + getunitpeasants = 0; if (n < 0) return 0; return findunit(n); @@ -1672,28 +1669,26 @@ getunitg(const region * r, const faction * f) unit * getunit(const region * r, const faction * f) { - int n; + int n = read_unitid(f, r);; unit *u2; - getunitpeasants = 0; - n = read_unitid(f, r); if (n == 0) { getunitpeasants = 1; return NULL; } + getunitpeasants = 0; if (n < 0) return 0; - for (u2 = r->units; u2; u2 = u2->next) { - if (u2->no == n) { - /* there used to be a '|| u2->number>0' condition here, but it got - * removed because of a bug that made units disappear: - * http://eressea.upb.de/mantis/bug_view_page.php?bug_id=0000172 - */ - if (u2->flags & UFL_ISNEW) return u2; - } + u2 = findunit(n); + if (u2!=NULL && u2->region==r) { + /* there used to be a 'u2->flags & UFL_ISNEW || u2->number>0' condition + * here, but it got removed because of a bug that made units disappear: + * http://eressea.upb.de/mantis/bug_view_page.php?bug_id=0000172 + */ + return u2; } - return 0; + return NULL; } /* - String Listen --------------------------------------------- */