From 9515363c56fcd0408c155e1e13cae94899c5f76d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 20 May 2005 22:26:41 +0000 Subject: [PATCH] Lange Befehle erscheinen wieder im NR. --- src/common/gamecode/laws.c | 15 +++++++++---- src/common/kernel/reports.c | 42 ++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 16bbd385b..55a777a87 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -3489,15 +3489,17 @@ setdefaults (void) for (u = r->units; u; u = u->next) { order *ord; boolean trade = false; + boolean hunger = LongHunger(u); - if (LongHunger(u)) { + if (hunger) { /* Hungernde Einheiten führen NUR den default-Befehl aus */ set_order(&u->thisorder, default_order(u->faction->locale)); - continue; } #ifdef LASTORDER - /* by default the default long order becomes the new long order. */ - u->thisorder = copy_order(u->lastorder); + else { + /* by default the default long order becomes the new long order. */ + u->thisorder = copy_order(u->lastorder); + } #endif /* check all orders for a potential new long order this round: */ for (ord = u->orders; ord; ord = ord->next) { @@ -3505,8 +3507,11 @@ setdefaults (void) if (u->old_orders && is_repeated(ord)) { /* this new order will replace the old defaults */ free_orders(&u->old_orders); + if (hunger) break; } #endif + if (hunger) continue; + if (is_exclusive(ord)) { /* Über dieser Zeile nur Befehle, die auch eine idle Faction machen darf */ if (idle(u->faction)) { @@ -3546,6 +3551,8 @@ setdefaults (void) } } + if (hunger) continue; + /* Wenn die Einheit handelt, muß der Default-Befehl gelöscht * werden. */ diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index ebe039f84..452393312 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -165,6 +165,22 @@ report_item(const unit * owner, const item * i, const faction * viewer, const ch } } + +size_t +buforder(char * bufp, size_t size, const order * ord) +{ + char * cmd = getcommand(ord); + size_t len = 0; + len += strlcpy(bufp+len, ", \"", size); + len += strlcpy(bufp+len, cmd, size-len); + if (len>=2) { + strcpy(bufp+len, "\""); + ++len; + } + free(cmd); + return len; +} + int bufunit(const faction * f, const unit * u, int indent, int mode) { @@ -408,11 +424,27 @@ bufunit(const faction * f, const unit * u, int indent, int mode) } #ifdef LASTORDER if (!isbattle && u->lastorder) { - char * cmd = getcommand(u->lastorder); - bufp += strlcpy(bufp, ", \"", sizeof(buf)-(bufp-buf)); - bufp += strlcpy(bufp, cmd, sizeof(buf)-(bufp-buf)); - strcpy(bufp++, "\""); - free(cmd); + bufp += buforder(bufp, sizeof(buf)-(bufp-buf), u->lastorder); + } +#else + if (!isbattle) { + boolean printed = 0; + int i; + for (i=0;i!=2;++i) { + order * ord = (i==0)?u->old_orders:u->orders; + while (ord) { + if (is_repeated(ord)) { + if (printed==0) { + bufp += buforder(bufp, sizeof(buf)-(bufp-buf), ord); + } else if (printed==1) { + bufp += strlcpy(bufp, ", ...", sizeof(buf)-(bufp-buf)); + } + ++printed; + break; + } + ord=ord->next; + } + } } #endif }