Counters: "User City Counter"
Reply To cazfi
New city counter behavior: "User City Counter". Depends on #47827 This counter type gets adjusted by new lua methods. E.g. (there might be better API):
- Counter:increase(City)
- Counter:zero(City)
0002-OSDN-47828-TEST.patch(1KB)
Test patch add love king effect depending on building ruler have built in city. When city was conquered, effect was zeroed. Mooders can enhance this behavior by limiting improvements type, which will increase counter.
Reply To cazfi
New city counter behavior: "User City Counter". Depends on #47827 This counter type gets adjusted by new lua methods. E.g. (there might be better API):
- Counter:increase(City)
- Counter:zero(City)
This version of implementation was quite better.
2023-06-23 21:21 Updated by: lachu
Sanity checks, if needed. I am trying answer my own question, if we need to is_user_counter function in lua?
+void api_counter_increase(lua_State *L,Counter *c, City *city)
Add space between comma and "Counter". There are several cases like this in the patch
fc_assert_ret_msg(CB_USER == c->type, "Lua: cannot change non-user counter");
This should not be an asserting engine (C-code) behavior, as the lua-script can very well trigger it. Should have a regular check, and error message, against illegal lua-script input.
+#endif
-> #endif /* FCAPI_GAME_COUNTERS_H */
api_server_counters.c should be added to Meson based build too.
Reply To cazfi
{{{ +void api_counter_increase(lua_State *L,Counter *c, City *city) }}} Add space between comma and "Counter". There are several cases like this in the patch {{{ fc_assert_ret_msg(CB_USER == c->type, "Lua: cannot change non-user counter"); }}} This should not be an asserting engine (C-code) behavior, as the lua-script can very well trigger it. Should have a regular check, and error message, against illegal lua-script input. {{{ +#endif }}}
-> #endif /* FCAPI_GAME_COUNTERS_H */ api_server_counters.c should be added to Meson based build too.
Reply To cazfi
{{{ +void api_counter_increase(lua_State *L,Counter *c, City *city) }}} Add space between comma and "Counter". There are several cases like this in the patch {{{ fc_assert_ret_msg(CB_USER == c->type, "Lua: cannot change non-user counter"); }}} This should not be an asserting engine (C-code) behavior, as the lua-script can very well trigger it. Should have a regular check, and error message, against illegal lua-script input. {{{ +#endif }}} -> #endif /* FCAPI_GAME_COUNTERS_H */ api_server_counters.c should be added to Meson based build too.
meson build (though I assume autotools build to have the same warnings):
[206/645] Compiling C object libfc_server.a.p/meson-generated_tolua_server_gen.c.o FAILED: libfc_server.a.p/meson-generated_tolua_server_gen.c.o ccache cc -Ilibfc_server.a.p -I. -I../src -I../src/dependencies/luasql/src -I../src/dependencies/tinycthread -I../src/dependencies/tolua-5.2/include -I../src/dependencies/cvercmp -I../src/utility -I../src/common -I../src/common/networking -I../src/common/scriptcore -I../src/common/aicore -I../src/server -I../src/server/advisors -I../src/server/scripting -I../src/server/generator -I../src/server/ruleset -I../src/server/savegame -I../src/ai -I../src/ai/classic -I/usr/include/lua5.4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O0 -g -Wno-nonnull-compare -Wnested-externs -Wall -Wmissing-declarations -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wformat -Wformat-security -Wshadow -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wimplicit-fallthrough -Wshadow -DHAVE_CONFIG_H -fPIC -MD -MQ libfc_server.a.p/meson-generated_tolua_server_gen.c.o -MF libfc_server.a.p/meson-generated_tolua_server_gen.c.o.d -o libfc_server.a.p/meson-generated_tolua_server_gen.c.o -c libfc_server.a.p/tolua_server_gen.c libfc_server.a.p/tolua_server_gen.c: In function ‘tolua_tolua_server_Counter_increase00’: libfc_server.a.p/tolua_server_gen.c:212:3: error: implicit declaration of function ‘api_counter_increase’ [-Werror=implicit-function-declaration] 212 | api_counter_increase(L,c,city); | ^~~~~~~~~~~~~~~~~~~~ libfc_server.a.p/tolua_server_gen.c:212:3: error: nested extern declaration of ‘api_counter_increase’ [-Werror=nested-externs] libfc_server.a.p/tolua_server_gen.c: In function ‘tolua_tolua_server_Counter_zero00’: libfc_server.a.p/tolua_server_gen.c:241:3: error: implicit declaration of function ‘api_counter_zero’ [-Werror=implicit-function-declaration] 241 | api_counter_zero(L,c,city); | ^~~~~~~~~~~~~~~~ libfc_server.a.p/tolua_server_gen.c:241:3: error: nested extern declaration of ‘api_counter_zero’ [-Werror=nested-externs] cc1: all warnings being treated as errors [226/645] Compiling C object libfc_server.a.p/server_scripting_api_server_counters.c.o FAILED: libfc_server.a.p/server_scripting_api_server_counters.c.o ccache cc -Ilibfc_server.a.p -I. -I../src -I../src/dependencies/luasql/src -I../src/dependencies/tinycthread -I../src/dependencies/tolua-5.2/include -I../src/dependencies/cvercmp -I../src/utility -I../src/common -I../src/common/networking -I../src/common/scriptcore -I../src/common/aicore -I../src/server -I../src/server/advisors -I../src/server/scripting -I../src/server/generator -I../src/server/ruleset -I../src/server/savegame -I../src/ai -I../src/ai/classic -I/usr/include/lua5.4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O0 -g -Wno-nonnull-compare -Wnested-externs -Wall -Wmissing-declarations -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wformat -Wformat-security -Wshadow -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wimplicit-fallthrough -Wshadow -DHAVE_CONFIG_H -fPIC -MD -MQ libfc_server.a.p/server_scripting_api_server_counters.c.o -MF libfc_server.a.p/server_scripting_api_server_counters.c.o.d -o libfc_server.a.p/server_scripting_api_server_counters.c.o -c ../src/server/scripting/api_server_counters.c ../src/server/scripting/api_server_counters.c: In function ‘api_counter_increase’: ../src/server/scripting/api_server_counters.c:40:5: error: implicit declaration of function ‘fc_print’; did you mean ‘fc_isprint’? [-Werror=implicit-function-declaration] 40 | fc_print("[CB_USER == c->type] Lua: cannot change non-user counter"); | ^~~~~~~~ | fc_isprint ../src/server/scripting/api_server_counters.c:40:5: error: nested extern declaration of ‘fc_print’ [-Werror=nested-externs] cc1: all warnings being treated as errors [239/645] Compiling C object libfc_server.a.p/server_savegame_savegame3.c.o ninja: build stopped: subcommand failed.
Reply To cazfi
meson build (though I assume autotools build to have the same warnings): {{{ 206/645 Compiling C object libfc_server.a.p/meson-generated_tolua_server_gen.c.o FAILED: libfc_server.a.p/meson-generated_tolua_server_gen.c.o ccache cc -Ilibfc_server.a.p -I. -I../src -I../src/dependencies/luasql/src -I../src/dependencies/tinycthread -I../src/dependencies/tolua-5.2/include -I../src/dependencies/cvercmp -I../src/utility -I../src/common -I../src/common/networking -I../src/common/scriptcore -I../src/common/aicore -I../src/server -I../src/server/advisors -I../src/server/scripting -I../src/server/generator -I../src/server/ruleset -I../src/server/savegame -I../src/ai -I../src/ai/classic -I/usr/include/lua5.4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O0 -g -Wno-nonnull-compare -Wnested-externs -Wall -Wmissing-declarations -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wformat -Wformat-security -Wshadow -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wimplicit-fallthrough -Wshadow -DHAVE_CONFIG_H -fPIC -MD -MQ libfc_server.a.p/meson-generated_tolua_server_gen.c.o -MF libfc_server.a.p/meson-generated_tolua_server_gen.c.o.d -o libfc_server.a.p/meson-generated_tolua_server_gen.c.o -c libfc_server.a.p/tolua_server_gen.c libfc_server.a.p/tolua_server_gen.c: In function ‘tolua_tolua_server_Counter_increase00’: libfc_server.a.p/tolua_server_gen.c:212:3: error: implicit declaration of function ‘api_counter_increase’ -Werror=implicit-function-declaration 212 | api_counter_increase(L,c,city); |
~libfc_server.a.p/tolua_server_gen.c:212:3: error: nested extern declaration of ‘api_counter_increase’ -Werror=nested-externs libfc_server.a.p/tolua_server_gen.c: In function ‘tolua_tolua_server_Counter_zero00’: libfc_server.a.p/tolua_server_gen.c:241:3: error: implicit declaration of function ‘api_counter_zero’ -Werror=implicit-function-declaration 241 | api_counter_zero(L,c,city); |~libfc_server.a.p/tolua_server_gen.c:241:3: error: nested extern declaration of ‘api_counter_zero’ -Werror=nested-externs cc1: all warnings being treated as errors 226/645 Compiling C object libfc_server.a.p/server_scripting_api_server_counters.c.o FAILED: libfc_server.a.p/server_scripting_api_server_counters.c.o ccache cc -Ilibfc_server.a.p -I. -I../src -I../src/dependencies/luasql/src -I../src/dependencies/tinycthread -I../src/dependencies/tolua-5.2/include -I../src/dependencies/cvercmp -I../src/utility -I../src/common -I../src/common/networking -I../src/common/scriptcore -I../src/common/aicore -I../src/server -I../src/server/advisors -I../src/server/scripting -I../src/server/generator -I../src/server/ruleset -I../src/server/savegame -I../src/ai -I../src/ai/classic -I/usr/include/lua5.4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O0 -g -Wno-nonnull-compare -Wnested-externs -Wall -Wmissing-declarations -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wformat -Wformat-security -Wshadow -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wimplicit-fallthrough -Wshadow -DHAVE_CONFIG_H -fPIC -MD -MQ libfc_server.a.p/server_scripting_api_server_counters.c.o -MF libfc_server.a.p/server_scripting_api_server_counters.c.o.d -o libfc_server.a.p/server_scripting_api_server_counters.c.o -c ../src/server/scripting/api_server_counters.c ../src/server/scripting/api_server_counters.c: In function ‘api_counter_increase’: ../src/server/scripting/api_server_counters.c:40:5: error: implicit declaration of function ‘fc_print’; did you mean ‘fc_isprint’? -Werror=implicit-function-declaration 40 | fc_print("== c->type Lua: cannot change non-user counter"); |~| fc_isprint ../src/server/scripting/api_server_counters.c:40:5: error: nested extern declaration of ‘fc_print’ -Werror=nested-externs cc1: all warnings being treated as errors 239/645 Compiling C object libfc_server.a.p/server_savegame_savegame3.c.o ninja: build stopped: subcommand failed. }}}
Sorry. I must tell I do not test previous patch. I though it was too small change, It won't broke anythink. Current patch was compiled:
Hi. I see this change on main branch, but this ticket has no resolution.
Reply To lachu
Hi. I see this change on main branch, but this ticket has no resolution.
It's not in freeciv repo, Likely you have cherry-picked or applied to your local main branch.
New city counter behavior: "User City Counter".
Depends on #47827
This counter type gets adjusted by new lua methods. E.g. (there might be better API):
- Counter:increase(City)
- Counter:zero(City)