From 6778cbe4836a25ac268b2fd38f42cba759279509 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 May 2017 15:25:13 +0200 Subject: [PATCH] assert that we do not add new ship types after the per-language lookup is initialized. --- src/kernel/ship.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 518c3ce0c..88c0f31e7 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -53,8 +53,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -selist *shiptypes = NULL; -static critbit_tree cb_shiptypes; +selist *shiptypes = NULL; /* do not use this list for searching*/ +static critbit_tree cb_shiptypes; /* use this trie instead */ static local_names *snames; @@ -63,9 +63,7 @@ const ship_type *findshiptype(const char *name, const struct locale *lang) local_names *sn = snames; variant var; - while (sn) { - if (sn->lang == lang) - break; + while (sn && sn->lang != lang) { sn = sn->next; } if (!sn) { @@ -111,6 +109,7 @@ const ship_type *st_find(const char *name) { ship_type *st_get_or_create(const char * name) { ship_type * st = st_find_i(name); + assert(!snames); if (!st) { size_t len; char data[64];