diff --git a/.gitignore b/.gitignore index e5cf00375..8ca35c107 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ out/ .vscode/ *.orig eressea.ini +CMakeUserPresets.json Debug Release diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..843d8b0b4 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "vcpkg", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + } + ] +} \ No newline at end of file diff --git a/src/bindings.c b/src/bindings.c index f4028b272..480602e69 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -830,6 +830,26 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti const char *arg; size_t len = strlen(section); + /* defaults */ + arg = config_get("config.install"); + if (arg) { + lua_pushstring(L, "install"); + lua_pushstring(L, arg); + lua_rawset(L, -3); + } + lua_pushstring(L, "basepath"); + lua_pushstring(L, basepath()); + lua_rawset(L, -3); + lua_pushstring(L, "reportpath"); + lua_pushstring(L, reportpath()); + lua_rawset(L, -3); + arg = config_get("config.rules"); + if (arg) { + lua_pushstring(L, "rules"); + lua_pushstring(L, arg); + lua_rawset(L, -3); + } + for (i = 0; d && i != d->n; ++i) { const char *key = d->key[i]; if (strncmp(section, key, len) == 0 && key[len] == ':') { @@ -846,20 +866,6 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti lua_rawset(L, -3); } } - - /* special case */ - lua_pushstring(L, "basepath"); - lua_pushstring(L, basepath()); - lua_rawset(L, -3); - lua_pushstring(L, "reportpath"); - lua_pushstring(L, reportpath()); - lua_rawset(L, -3); - arg = config_get("config.rules"); - if (arg) { - lua_pushstring(L, "rules"); - lua_pushstring(L, arg); - lua_rawset(L, -3); - } } static int lua_rng_default(lua_State *L) { diff --git a/src/economy.c b/src/economy.c index ea95523da..752d72825 100644 --- a/src/economy.c +++ b/src/economy.c @@ -948,13 +948,17 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist) for (al = alist; al; al = al->next) { if (avail > 0) { int want = required(al->want, al->save); - int x = avail * want / nreq; - int rx = (avail * want) % nreq; + long long dx = (long long)avail * want / nreq; + int x, rx = (avail * want) % nreq; + + assert(dx < INT_MAX && dx >= 0); + x = (int)dx; /* Wenn Rest, dann wuerfeln, ob ich was bekomme: */ if (rx > 0 && rng_int() % nreq < rx) ++x; avail -= x; nreq -= want; al->get = x * al->save.sa[1] / al->save.sa[0]; + assert(al->get >= 0); if (al->want < al->get) al->get = al->want; if (!rtype->raw) { int use = required(al->get, al->save); diff --git a/src/main.c b/src/main.c index 766171bde..209ea50d6 100644 --- a/src/main.c +++ b/src/main.c @@ -199,6 +199,10 @@ static int parse_args(int argc, char **argv) case 'D': config_set("config.debug", "1"); break; + case 'i': + i = get_arg(argc, argv, 2, i, &arg, 0); + config_set("config.install", arg); + break; case 'c': i = get_arg(argc, argv, 2, i, &arg, 0); config_set("config.path", arg);