From 599efb2e764190cd4934dcefc355a8d91b5c7e18 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Nov 2017 20:24:57 +0100 Subject: [PATCH] remove lomem code, it was a bad idea --- src/battle.h | 12 ------- src/kernel/config.c | 1 - src/kernel/config.h | 1 - src/kernel/messages.c | 2 +- src/kernel/save.c | 83 ++++++++++++++++--------------------------- src/main.c | 2 -- 6 files changed, 32 insertions(+), 69 deletions(-) diff --git a/src/battle.h b/src/battle.h index 3c86c2c8d..f7e84ea6b 100644 --- a/src/battle.h +++ b/src/battle.h @@ -172,17 +172,6 @@ extern "C" { int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */ struct person { int hp; /* Trefferpunkte der Personen */ -#ifdef LOMEM - int attack : 8; /* (Magie) Attackenbonus der Personen */ - int defence : 8; /* (Magie) Paradenbonus der Personen */ - int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */ - int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */ - int flags : 8; /* (Magie) Diverse Flags auf Kaempfern */ - int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */ - int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss. - * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ - int last_action : 4; /* In welcher Runde haben wir zuletzt etwas getan */ -#else int attack; int defence; int damage; @@ -191,7 +180,6 @@ extern "C" { int speed; int reload; int last_action; -#endif struct weapon *missile; /* missile weapon */ struct weapon *melee; /* melee weapon */ } *person; diff --git a/src/kernel/config.c b/src/kernel/config.c index 566b9fc88..24f86a978 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -95,7 +95,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. struct settings global; -bool lomem = false; int turn = 0; const char *parameters[MAXPARAMS] = { diff --git a/src/kernel/config.h b/src/kernel/config.h index 4cf0650ff..e0ad682c6 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -141,7 +141,6 @@ extern "C" { extern const char *parameters[]; extern settings global; - extern bool lomem; /* save memory */ extern int turn; #ifdef __cplusplus diff --git a/src/kernel/messages.c b/src/kernel/messages.c index f2a175269..ebcce80f2 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -291,7 +291,7 @@ void free_messagelist(mlist *msgs) message *add_message(message_list ** pm, message * m) { assert(m && m->type); - if (!lomem && m != NULL) { + if (m != NULL) { struct mlist *mnew = malloc(sizeof(struct mlist)); if (*pm == NULL) { *pm = malloc(sizeof(message_list)); diff --git a/src/kernel/save.c b/src/kernel/save.c index 5adfea77d..96ffe0352 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -487,16 +487,11 @@ unit *read_unit(gamedata *data) log_warning("trim unit %s name to '%s'", itoa36(u->no), obuf); } u->_name = obuf[0] ? strdup(obuf) : 0; - if (lomem) { - READ_STR(data->store, NULL, 0); - } - else { - READ_STR(data->store, obuf, sizeof(obuf)); - if (unicode_utf8_trim(obuf)!=0) { - log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); - } - u->display = obuf[0] ? strdup(obuf) : 0; + READ_STR(data->store, obuf, sizeof(obuf)); + if (unicode_utf8_trim(obuf)!=0) { + log_warning("trim unit %s info to '%s'", itoa36(u->no), obuf); } + u->display = obuf[0] ? strdup(obuf) : 0; READ_INT(data->store, &number); set_number(u, number); @@ -557,24 +552,23 @@ unit *read_unit(gamedata *data) p = n = 0; orderp = &u->orders; while (obuf[0]) { - if (!lomem) { - order *ord = parse_order(obuf, u->faction->locale); + order *ord = parse_order(obuf, u->faction->locale); + if (ord != NULL) { + if (++n < MAXORDERS) { + if (!is_persistent(ord) || ++p < MAXPERSISTENT) { + *orderp = ord; + orderp = &ord->next; + ord = NULL; + } + else if (p == MAXPERSISTENT) { + log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT); + } + } + else if (n == MAXORDERS) { + log_info("%s had %d or more orders", unitname(u), MAXORDERS); + } if (ord != NULL) { - if (++n < MAXORDERS) { - if (!is_persistent(ord) || ++p < MAXPERSISTENT) { - *orderp = ord; - orderp = &ord->next; - ord = NULL; - } - else if (p == MAXPERSISTENT) { - log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT); - } - } - else if (n == MAXORDERS) { - log_info("%s had %d or more orders", unitname(u), MAXORDERS); - } - if (ord != NULL) - free_order(ord); + free_order(ord); } } READ_STR(data->store, obuf, sizeof(obuf)); @@ -659,14 +653,9 @@ void write_unit(gamedata *data, const unit * u) } static void read_regioninfo(gamedata *data, const region *r, char *info, size_t len) { - if (lomem) { - READ_STR(data->store, NULL, 0); - } - else { - READ_STR(data->store, info, len); - if (unicode_utf8_trim(info) != 0) { - log_warning("trim region %d info to '%s'", r->uid, info); - } + READ_STR(data->store, info, len); + if (unicode_utf8_trim(info) != 0) { + log_warning("trim region %d info to '%s'", r->uid, info); } } @@ -1288,16 +1277,11 @@ struct building *read_building(gamedata *data) { log_warning("trim building %s name to '%s'", itoa36(b->no), name); } b->name = strdup(name); - if (lomem) { - READ_STR(store, NULL, 0); - } - else { - READ_STR(store, name, sizeof(name)); - if (unicode_utf8_trim(name)!=0) { - log_warning("trim building %s info to '%s'", itoa36(b->no), name); - } - b->display = strdup(name); + READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim building %s info to '%s'", itoa36(b->no), name); } + b->display = strdup(name); READ_INT(store, &b->size); READ_STR(store, name, sizeof(name)); b->type = bt_find(name); @@ -1347,16 +1331,11 @@ ship *read_ship(gamedata *data) log_warning("trim ship %s name to '%s'", itoa36(sh->no), name); } sh->name = strdup(name); - if (lomem) { - READ_STR(store, NULL, 0); - } - else { - READ_STR(store, name, sizeof(name)); - if (unicode_utf8_trim(name)!=0) { - log_warning("trim ship %s info to '%s'", itoa36(sh->no), name); - } - sh->display = strdup(name); + READ_STR(store, name, sizeof(name)); + if (unicode_utf8_trim(name)!=0) { + log_warning("trim ship %s info to '%s'", itoa36(sh->no), name); } + sh->display = strdup(name); READ_STR(store, name, sizeof(name)); sh->type = st_find(name); if (sh->type == NULL) { diff --git a/src/main.c b/src/main.c index 0c171f219..7af3e0769 100644 --- a/src/main.c +++ b/src/main.c @@ -62,7 +62,6 @@ static void load_inifile(void) set_datapath(str); } - lomem = config_get_int("game.lomem", lomem) ? 1 : 0; verbosity = config_get_int("game.verbose", 2); memdebug = config_get_int("game.memcheck", memdebug); #ifdef USE_CURSES @@ -79,7 +78,6 @@ static const char * valid_keys[] = { "game.locale", "game.verbose", "game.report", - "game.lomem", "game.memcheck", "game.email", "game.mailcmd",