From 6f5f1651c7a1f86358929c1ebe404f310f5e6e17 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 9 Sep 2018 07:41:30 +0200 Subject: [PATCH] fix crashes when trying to trade on ocean. fix missing message sections. --- res/core/messages.xml | 6 +++--- src/economy.c | 5 +++-- src/kernel/region.c | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index d566c82e6..7e55e05f9 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -30,7 +30,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -46,7 +46,7 @@ - + diff --git a/src/economy.c b/src/economy.c index 3bb7b1066..4a6aa5672 100644 --- a/src/economy.c +++ b/src/economy.c @@ -1660,7 +1660,7 @@ static void buy(unit * u, econ_request ** buyorders, struct order *ord) return; } } - if (r_demand(r, ltype)) { + if (!r->land || r_demand(r, ltype)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "luxury_notsold", "")); return; } @@ -1702,6 +1702,7 @@ static void expandselling(region * r, econ_request * sellorders, int limit) static int bt_cache; static const struct building_type *castle_bt, *harbour_bt, *caravan_bt; + assert(r->land); if (bt_changed(&bt_cache)) { castle_bt = bt_find("castle"); harbour_bt = bt_find("harbour"); @@ -1971,7 +1972,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord) econ_request *o; int k, available; - if (!r_demand(r, ltype)) { + if (!r->land || !r_demand(r, ltype)) { cmistake(u, ord, 263, MSG_COMMERCE); return false; } diff --git a/src/kernel/region.c b/src/kernel/region.c index 7cb52c201..29f7222e1 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -716,7 +716,10 @@ const item_type *r_luxury(const region * r) int r_demand(const region * r, const luxury_type * ltype) { - struct demand *d = r->land->demands; + struct demand *d; + + assert(r && r->land); + d = r->land->demands; while (d && d->type != ltype) d = d->next; if (!d)