From 53662878aa0988fc2dc1c370886c125369a968cf Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Mar 2019 10:19:02 +0200 Subject: [PATCH 1/6] minor cleanup --- src/kernel/gamedata.h | 2 -- src/kernel/save.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/kernel/gamedata.h b/src/kernel/gamedata.h index e14c0a551..b4c3e4a5f 100644 --- a/src/kernel/gamedata.h +++ b/src/kernel/gamedata.h @@ -63,6 +63,4 @@ void gamedata_close(gamedata *data); gamedata *gamedata_open(const char *filename, const char *mode, int version); int gamedata_openfile(gamedata *data, const char *filename, const char *mode, int version); -#define STREAM_VERSION 2 /* internal encoding of binary files */ - #endif diff --git a/src/kernel/save.c b/src/kernel/save.c index 45da22a7c..b1e518c9f 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -613,6 +613,26 @@ static void read_regioninfo(gamedata *data, const region *r, char *info, size_t } } +static void fix_baselevel(region *r) { + struct terrain_production *p; + for (p = r->terrain->production; p->type; ++p) { + char *end; + long start = (int)strtol(p->startlevel, &end, 10); + if (*end == '\0') { + rawmaterial *res; + for (res = r->resources; res; res = res->next) { + if (p->type == res->rtype) { + if (start != res->startlevel) { + log_debug("setting resource start level for %s in %s to %d", + res->rtype->_name, regionname(r, NULL), start); + res->startlevel = start; + } + } + } + } + } +} + static region *readregion(gamedata *data, int x, int y) { region *r; From b48b69bc943c42ab5b96b2a0d4ae14709a2ac190 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 3 Apr 2019 18:27:29 +0200 Subject: [PATCH 2/6] Let's apply the relaxed E3 hunger rules to E2. --- conf/e2/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 4da247263..cc480b2e2 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -41,7 +41,8 @@ "nmr.timeout": 5, "nmr.removenewbie": false, "GiveRestriction": 3, - "hunger.long": true, + "hunger.long": false, + "hunger.damage": "1d9+9", "init_spells": 0, "game.era": 2, "game.start": 184, From df746dd342904e7c1db693803b66cf663d5a53c1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 5 Apr 2019 17:14:28 +0200 Subject: [PATCH 3/6] Newbie islands should not have volcano terrain. --- src/bind_gmtool.c | 2 +- src/gmtool.c | 2 +- src/modules/autoseed.c | 36 +++++++++++++++++------------------- src/modules/autoseed.h | 4 +--- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index d0a023a5b..5901ccf1d 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -160,7 +160,7 @@ static int tolua_make_island(lua_State * L) int y = (int)tolua_tonumber(L, 2, 0); int s = (int)tolua_tonumber(L, 3, 0); - s = build_island_e3(x, y, s, NULL, 0); + s = build_island(x, y, s, NULL, 0); lua_pushinteger(L, s); return 1; } diff --git a/src/gmtool.c b/src/gmtool.c index 0ab31854e..3ec464a3f 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -1143,7 +1143,7 @@ static void handlekey(state * st, int c) else { n = minpop; } - build_island_e3(nx, ny, n, NULL, 0); + build_island(nx, ny, n, NULL, 0); st->modified = 1; st->wnd_info->update |= 1; st->wnd_status->update |= 1; diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 65d4b1dfc..a59567dd4 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -49,7 +49,7 @@ #include #include -const terrain_type *random_terrain(const terrain_type * terrains[], +static const terrain_type *random_terrain_select(const terrain_type * terrains[], int distribution[], int size) { int ndistribution = size; @@ -583,7 +583,7 @@ int autoseed(newfaction ** players, int nsize, int max_agediff) break; } else { - terraform_region(r, random_terrain(terrainarr, distribution, nterrains)); + terraform_region(r, random_terrain_select(terrainarr, distribution, nterrains)); --isize; } } @@ -619,7 +619,7 @@ int autoseed(newfaction ** players, int nsize, int max_agediff) pnormalize(&x, &y, pl); rn = new_region(x, y, pl, 0); if (rng_int() % SPECIALCHANCE < special) { - terrain = random_terrain(terrainarr, distribution, nterrains); + terrain = random_terrain_select(terrainarr, distribution, nterrains); special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */ } else { @@ -698,23 +698,21 @@ region *regionqueue_pop(region_list ** rlist) return 0; } -#define GEOMAX 8 +#define GEOMAX 7 static struct geo { int distribution; terrain_t type; } geography_e3[GEOMAX] = { - { - 8, T_OCEAN }, { - 3, T_SWAMP }, { - 1, T_VOLCANO }, { - 3, T_DESERT }, { - 4, T_HIGHLAND }, { - 3, T_MOUNTAIN }, { - 2, T_GLACIER }, { - 1, T_PLAIN } + { 8, T_OCEAN }, + { 3, T_SWAMP }, + { 3, T_DESERT }, + { 4, T_HIGHLAND }, + { 3, T_MOUNTAIN }, + { 2, T_GLACIER }, + { 1, T_PLAIN } }; -const terrain_type *random_terrain_e3(direction_t dir) +const terrain_type *random_terrain(direction_t dir) { static const terrain_type **terrainarr = 0; static int *distribution = 0; @@ -731,7 +729,7 @@ const terrain_type *random_terrain_e3(direction_t dir) distribution[n] = geography_e3[n].distribution; } } - return random_terrain(terrainarr, distribution, GEOMAX); + return random_terrain_select(terrainarr, distribution, GEOMAX); } static int @@ -864,8 +862,8 @@ static void starting_region(newfaction ** players, region * r, region * rn[]) } } -/* E3A island generation */ -int build_island_e3(int x, int y, int minsize, newfaction ** players, int numfactions) +/* island generator */ +int build_island(int x, int y, int minsize, newfaction ** players, int numfactions) { #define MIN_QUALITY 1000 int nfactions = 0; @@ -881,14 +879,14 @@ int build_island_e3(int x, int y, int minsize, newfaction ** players, int numfac r = new_region(x, y, pl, 0); } do { - terraform_region(r, random_terrain_e3(NODIRECTION)); + terraform_region(r, random_terrain(NODIRECTION)); } while (!r->land); while (r) { fset(r, RF_MARK); if (r->land) { if (nsize < minsize) { - nsize += random_neighbours(r, &rlist, &random_terrain_e3, minsize - nsize); + nsize += random_neighbours(r, &rlist, &random_terrain, minsize - nsize); } else { nsize += random_neighbours(r, &rlist, &get_ocean, minsize - nsize); diff --git a/src/modules/autoseed.h b/src/modules/autoseed.h index b78a2df55..cec42ba4a 100644 --- a/src/modules/autoseed.h +++ b/src/modules/autoseed.h @@ -33,10 +33,8 @@ extern "C" { extern int autoseed(newfaction ** players, int nsize, int max_agediff); extern newfaction *read_newfactions(const char *filename); - extern const struct terrain_type *random_terrain(const struct terrain_type - *terrains[], int distribution[], int size); - extern int build_island_e3(int x, int y, int minsize, newfaction **players, int numfactions); + extern int build_island(int x, int y, int minsize, newfaction **players, int numfactions); #ifdef __cplusplus } From 65dee13592a38915c3fa329ee6241ed80eb68fcb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Apr 2019 11:29:19 +0200 Subject: [PATCH 4/6] I am moving my library dependency folder to c:\libraries build.bat needed to know that. --- CMakeLists.txt | 7 ++----- cmake/Modules/FindToLua.cmake | 4 +++- vs2017-build.bat | 11 +++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b91565da..aa4e746c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,6 @@ ELSE (HAVE_LIBBSD) CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT) ENDIF(HAVE_LIBBSD) -endif (MSVC) - -if (MSVC) find_package (PDCurses) SET(CURSES_FOUND ${PDCURSES_FOUND}) SET(CURSES_LIBRARIES ${PDCURSES_LIBRARY}) @@ -42,7 +39,8 @@ else (MSVC) find_package (Curses) endif (MSVC) -find_package (Readline) +# find_package (Readline) +find_package (EXPAT REQUIRED) if (ERESSEA_DB STREQUAL "db") find_package (BerkeleyDB REQUIRED QUIET) @@ -50,7 +48,6 @@ else() find_package (SQLite3 REQUIRED QUIET) endif() -find_package(EXPAT REQUIRED) find_package (ToLua REQUIRED) if (TOLUA_FOUND) if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2") diff --git a/cmake/Modules/FindToLua.cmake b/cmake/Modules/FindToLua.cmake index 52c721112..92732981b 100644 --- a/cmake/Modules/FindToLua.cmake +++ b/cmake/Modules/FindToLua.cmake @@ -58,7 +58,9 @@ elseif(TOLUA_INCLUDE_DIR AND EXISTS "${TOLUA_INCLUDE_DIR}/tolua.h") string(REGEX REPLACE "^#define[\t ]+TOLUA_VERSION[\t ]+\"tolua ([^\"]*)\".*" "\\1" TOLUA_VERSION_STRING "${tolua_version_str}") unset(tolua_version_str) -endif() +else(PC_TOLUA_VERSION) +message(ERROR "TOLUA_VERSION_STRING cannot be determined") +endif(PC_TOLUA_VERSION) # handle the QUIETLY and REQUIRED arguments and set TOLUA_FOUND to TRUE if # all listed variables are TRUE diff --git a/vs2017-build.bat b/vs2017-build.bat index 7503153fe..22e153874 100644 --- a/vs2017-build.bat +++ b/vs2017-build.bat @@ -1,13 +1,16 @@ @ECHO OFF +IF "%WIN32_DEV%" == "" SET WIN32_DEV="C:\Libraries" +SET CMAKE_ROOT=%ProgramFiles%\CMake +IF "%LUA_DEV%" == "" SET LUA_DEV="%ProgramFiles(x86)%/Lua/5.1" SET VSVERSION=15 SET SRCDIR=%CD% -CD .. -SET ERESSEA=%CD% +REM CD .. +REM SET ERESSEA=%CD% +REM CD %SRCDIR% -CD %SRCDIR% IF exist build-vs%VSVERSION% goto HAVEDIR mkdir build-vs%VSVERSION% :HAVEDIR cd build-vs%VSVERSION% -"%ProgramFiles%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. +"%CMAKE_ROOT%\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%LUA_DEV%;%WIN32_DEV%" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. PAUSE From 102a0e0e27463d1b222a23a6be36993a4de6eb8b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Apr 2019 11:41:56 +0200 Subject: [PATCH 5/6] fix cmake syntax. --- CMakeLists.txt | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4e746c0..2d2635f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,41 +6,38 @@ FILE(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH ) endif(WIN32) project (eressea-server C) -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH}) +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") if (MSVC) -include(MSVC) +find_package (PDCurses) +set (CURSES_FOUND ${PDCURSES_FOUND}) +set (CURSES_LIBRARIES ${PDCURSES_LIBRARY}) +set (CURSES_INCLUDE_DIR ${PDCURSES_INCLUDE_DIR}) set (HAVE_STRDUP 0) set (HAVE_STRLCAT 0) set (HAVE_LIBBSD 0) set (HAVE_SIGNAL_H 0) set (HAVE_EXECINFO_H 0) +include (MSVC) else (MSVC) -INCLUDE (CheckIncludeFile) +find_package (Curses) +include (CheckIncludeFile) CHECK_INCLUDE_FILE(signal.h HAVE_SIGNAL_H) CHECK_INCLUDE_FILE(execinfo.h HAVE_EXECINFO_H) CHECK_INCLUDE_FILE(bsd/string.h HAVE_LIBBSD) -INCLUDE (CheckFunctionExists) +include (CheckFunctionExists) CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP) -IF (HAVE_LIBBSD) -INCLUDE (CheckLibraryExists) +if (HAVE_LIBBSD) +include (CheckLibraryExists) CHECK_LIBRARY_EXISTS(bsd strlcat "bsd/string.h" HAVE_STRLCAT) -ELSE (HAVE_LIBBSD) +else (HAVE_LIBBSD) CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT) -ENDIF(HAVE_LIBBSD) - -find_package (PDCurses) -SET(CURSES_FOUND ${PDCURSES_FOUND}) -SET(CURSES_LIBRARIES ${PDCURSES_LIBRARY}) -SET(CURSES_INCLUDE_DIR ${PDCURSES_INCLUDE_DIR}) -else (MSVC) -find_package (Curses) +endif (HAVE_LIBBSD) endif (MSVC) -# find_package (Readline) -find_package (EXPAT REQUIRED) +find_package (Readline) if (ERESSEA_DB STREQUAL "db") find_package (BerkeleyDB REQUIRED QUIET) @@ -48,6 +45,7 @@ else() find_package (SQLite3 REQUIRED QUIET) endif() +find_package(EXPAT REQUIRED) find_package (ToLua REQUIRED) if (TOLUA_FOUND) if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2") From 510b6c2628541495a1af8c12cbd6d0dc269d2366 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Apr 2019 19:00:59 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Zeige=20keine=20Luxusg=C3=BCter-Statistik?= =?UTF-8?q?=20im=20Ozean.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/report.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/report.c b/src/report.c index ae9607736..961f5227e 100644 --- a/src/report.c +++ b/src/report.c @@ -1216,14 +1216,14 @@ static void statistics(struct stream *out, const region * r, const faction * f) if (!markets_module()) { if (buildingtype_exists(r, bt_find("caravan"), true)) { - m = msg_message("nr_stat_luxuries", "max", (p * 2) / TRADE_FRACTION); + p *= 2; } - else { + if (p >= TRADE_FRACTION) { m = msg_message("nr_stat_luxuries", "max", p / TRADE_FRACTION); + nr_render(m, f->locale, buf, sizeof(buf), f); + paragraph(out, buf, 2, 2, 0); + msg_release(m); } - nr_render(m, f->locale, buf, sizeof(buf), f); - paragraph(out, buf, 2, 2, 0); - msg_release(m); } /* count */