forked from github/server
we can do this reading of orders from the savefile much faster if we remember how lists should be used.
This commit is contained in:
parent
200201b384
commit
f33c875756
|
@ -1027,6 +1027,7 @@ readunit(FILE * F)
|
||||||
potion_t potion;
|
potion_t potion;
|
||||||
unit * u;
|
unit * u;
|
||||||
int number, n, p;
|
int number, n, p;
|
||||||
|
order ** orderp;
|
||||||
|
|
||||||
n = rid(F);
|
n = rid(F);
|
||||||
u = findunit(n);
|
u = findunit(n);
|
||||||
|
@ -1117,12 +1118,14 @@ readunit(FILE * F)
|
||||||
free_orders(&u->orders);
|
free_orders(&u->orders);
|
||||||
freadstr(F, buf, sizeof(buf));
|
freadstr(F, buf, sizeof(buf));
|
||||||
p = n = 0;
|
p = n = 0;
|
||||||
|
orderp = &u->orders;
|
||||||
while (*buf != 0) {
|
while (*buf != 0) {
|
||||||
order * ord = parse_order(buf, u->faction->locale);
|
order * ord = parse_order(buf, u->faction->locale);
|
||||||
if (ord!=NULL) {
|
if (ord!=NULL) {
|
||||||
if (++n<MAXORDERS) {
|
if (++n<MAXORDERS) {
|
||||||
if (!is_persistent(ord) || ++p<MAXPERSISTENT) {
|
if (!is_persistent(ord) || ++p<MAXPERSISTENT) {
|
||||||
addlist(&u->orders, ord);
|
*orderp = ord;
|
||||||
|
orderp = &ord->next;
|
||||||
} else if (p==MAXPERSISTENT) {
|
} else if (p==MAXPERSISTENT) {
|
||||||
log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT));
|
log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue