From 5b61f895a2f6dddb1667fdd53175720a9334d917 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 3 Feb 2018 20:52:24 +0100 Subject: [PATCH] further reduce teh amount of temporary storage required by the economy module. --- src/economy.c | 8 ++------ src/economy.h | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/economy.c b/src/economy.c index 62094e5df..82890888e 100644 --- a/src/economy.c +++ b/src/economy.c @@ -185,9 +185,6 @@ unsigned int expand_production(region * r, econ_request * requests, econ_request static void free_requests(econ_request *requests) { while (requests) { econ_request *req = requests->next; - if (requests->ord) { - free_order(requests->ord); - } free(requests); requests = req; } @@ -347,7 +344,7 @@ static int do_recruiting(recruitment * recruits, int available) if (number > afford) number = afford; } if (u->number + number > UNIT_MAXSIZE) { - ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size", + ADDMSG(&u->faction->msgs, msg_feedback(u, req->type.recruit.ord, "error_unit_size", "maxsize", UNIT_MAXSIZE)); number = UNIT_MAXSIZE - u->number; assert(number >= 0); @@ -382,7 +379,6 @@ void free_recruitments(recruitment * recruits) while (rec->requests) { econ_request *req = rec->requests; rec->requests = req->next; - free_order(req->ord); free(req); } free(rec); @@ -560,7 +556,7 @@ static void recruit(unit * u, struct order *ord, econ_request ** recruitorders) o = (econ_request *)calloc(1, sizeof(econ_request)); o->qty = n; o->unit = u; - o->ord = copy_order(ord); + o->type.recruit.ord = ord; addlist(recruitorders, o); } diff --git a/src/economy.h b/src/economy.h index 99558bf80..ec12ae0ca 100644 --- a/src/economy.h +++ b/src/economy.h @@ -49,9 +49,11 @@ extern "C" { typedef struct econ_request { struct econ_request *next; struct unit *unit; - struct order *ord; int qty; union { + struct { + struct order *ord; + } recruit; struct { int no; bool goblin; /* stealing */