forked from github/server
last commit caused a crash. Also cleaning up the NR order writing a bit.
This commit is contained in:
parent
c0fcf15184
commit
fb7937a37d
|
@ -3802,6 +3802,9 @@ defaultorders (void)
|
||||||
skip_token(); /* skip the keyword */
|
skip_token(); /* skip the keyword */
|
||||||
cmd = strdup(getstrtoken());
|
cmd = strdup(getstrtoken());
|
||||||
new_order = parse_order(cmd, u->faction->locale);
|
new_order = parse_order(cmd, u->faction->locale);
|
||||||
|
*ordp = ord->next;
|
||||||
|
ord->next = NULL;
|
||||||
|
free_order(ord);
|
||||||
#ifdef LASTORDER
|
#ifdef LASTORDER
|
||||||
if (new_order) set_order(&u->lastorder, new_order);
|
if (new_order) set_order(&u->lastorder, new_order);
|
||||||
#else
|
#else
|
||||||
|
@ -3810,13 +3813,11 @@ defaultorders (void)
|
||||||
remove_exclusive(&u->orders);
|
remove_exclusive(&u->orders);
|
||||||
remove_exclusive(&u->old_orders);
|
remove_exclusive(&u->old_orders);
|
||||||
neworders = true;
|
neworders = true;
|
||||||
|
ordp = &u->orders; /* we could have broken ordp */
|
||||||
}
|
}
|
||||||
if (new_order) addlist(&u->old_orders, new_order);
|
if (new_order) addlist(&u->old_orders, new_order);
|
||||||
#endif
|
#endif
|
||||||
free(cmd);
|
free(cmd);
|
||||||
*ordp = ord->next;
|
|
||||||
ord->next = NULL;
|
|
||||||
free_order(ord);
|
|
||||||
}
|
}
|
||||||
else ordp = &ord->next;
|
else ordp = &ord->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,10 +165,10 @@ report_item(const unit * owner, const item * i, const faction * viewer, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define ORDERS_IN_NR 1
|
||||||
static size_t
|
static size_t
|
||||||
buforder(char * bufp, size_t size, const order * ord)
|
buforder(char * bufp, size_t size, const order * ord, int mode)
|
||||||
{
|
{
|
||||||
char * cmd = getcommand(ord);
|
|
||||||
size_t tsize = 0, rsize;
|
size_t tsize = 0, rsize;
|
||||||
|
|
||||||
rsize = strlcpy(bufp, ", \"", size);
|
rsize = strlcpy(bufp, ", \"", size);
|
||||||
|
@ -176,8 +176,13 @@ buforder(char * bufp, size_t size, const order * ord)
|
||||||
if (rsize>size) rsize = size-1;
|
if (rsize>size) rsize = size-1;
|
||||||
size -= rsize;
|
size -= rsize;
|
||||||
bufp += rsize;
|
bufp += rsize;
|
||||||
|
if (mode<ORDERS_IN_NR) {
|
||||||
rsize = strlcpy(bufp, cmd, size);
|
char * cmd = getcommand(ord);
|
||||||
|
rsize = strlcpy(bufp, cmd, size);
|
||||||
|
free(cmd);
|
||||||
|
} else {
|
||||||
|
rsize = strlcpy(bufp, "...", size);
|
||||||
|
}
|
||||||
tsize += rsize;
|
tsize += rsize;
|
||||||
if (rsize>size) rsize = size-1;
|
if (rsize>size) rsize = size-1;
|
||||||
size -= rsize;
|
size -= rsize;
|
||||||
|
@ -187,7 +192,6 @@ buforder(char * bufp, size_t size, const order * ord)
|
||||||
strcpy(bufp, "\"");
|
strcpy(bufp, "\"");
|
||||||
++tsize;
|
++tsize;
|
||||||
}
|
}
|
||||||
free(cmd);
|
|
||||||
return tsize;
|
return tsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +593,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
}
|
}
|
||||||
#ifdef LASTORDER
|
#ifdef LASTORDER
|
||||||
if (!isbattle && u->lastorder) {
|
if (!isbattle && u->lastorder) {
|
||||||
rsize = buforder(bufp, size, u->lastorder);
|
rsize = buforder(bufp, size, u->lastorder, 0);
|
||||||
if (rsize>size) rsize = size-1;
|
if (rsize>size) rsize = size-1;
|
||||||
size -= rsize;
|
size -= rsize;
|
||||||
bufp += rsize;
|
bufp += rsize;
|
||||||
|
@ -597,26 +601,24 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
#else
|
#else
|
||||||
if (!isbattle) {
|
if (!isbattle) {
|
||||||
boolean printed = 0;
|
boolean printed = 0;
|
||||||
int i;
|
order * ord;;
|
||||||
for (i=0;i!=2;++i) {
|
for (ord=u->old_orders;ord;ord=ord->next) {
|
||||||
order * ord = (i==0)?u->old_orders:u->orders;
|
if (is_repeated(ord)) {
|
||||||
while (ord) {
|
if (printed<ORDERS_IN_NR) {
|
||||||
if (is_repeated(ord)) {
|
rsize = buforder(bufp, size, ord, printed++);
|
||||||
if (printed==0) {
|
|
||||||
rsize = buforder(bufp, size, ord);
|
|
||||||
} else if (printed==1) {
|
|
||||||
rsize = strlcpy(bufp, ", ...", size);
|
|
||||||
}
|
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
size -= rsize;
|
||||||
bufp += rsize;
|
bufp += rsize;
|
||||||
++printed;
|
} else break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
if (printed) break; /* ein DEFAULT reicht */
|
if (printed<ORDERS_IN_NR) for (ord=u->orders;ord;ord=ord->next) {
|
||||||
ord=ord->next;
|
if (is_repeated(ord)) {
|
||||||
|
if (printed<ORDERS_IN_NR) {
|
||||||
|
rsize = buforder(bufp, size, ord, printed++);
|
||||||
|
size -= rsize;
|
||||||
|
bufp += rsize;
|
||||||
|
} else break;
|
||||||
}
|
}
|
||||||
if (u->old_orders) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue