Lange Befehle erscheinen wieder im NR.

This commit is contained in:
Enno Rehling 2005-05-20 22:26:41 +00:00
parent 0f9353eaaf
commit 9515363c56
2 changed files with 48 additions and 9 deletions

View File

@ -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. */

View File

@ -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
}