Ticket #47828

Counters: "User City Counter"

오픈 날짜: 2023-04-10 10:30 마지막 업데이트: 2024-02-24 11:48

Reporter:
소유자:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
9

Details

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)

Ticket History (3/25 Histories)

2023-04-10 10:30 Updated by: cazfi
  • New Ticket "Counters: "User City Counter"" created
2023-06-23 01:34 Updated by: lachu
  • File 0002-OSDN-47828-Implementation.patch (File ID: 12687) is attached
2023-06-23 01:34 Updated by: lachu
  • File 0002-OSDN-47828-Implementation.patch (File ID: 12687) is deleted
2023-06-23 01:37 Updated by: lachu
댓글 올리기

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)

0001-OSDN-47828-Implementation.patch(2KB)
Implementation part

0002-OSDN-47828-TEST.patch(1KB)

Test patch

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.

2023-06-23 21:15 Updated by: lachu
댓글 올리기

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-Implementation-2.patch(5KB)
Move increase/zero counter value to server + sends update to clients once changed

This version of implementation was quite better.

2023-06-23 21:21 Updated by: lachu

File 0001-OSDN-47828-Check.patch (File ID: 12702) is attached

Sanity checks, if needed. I am trying answer my own question, if we need to is_user_counter function in lua?

(Edited, 2023-06-23 21:22 Updated by: lachu)
2023-08-25 04:04 Updated by: lachu
댓글 올리기

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)

Implementation-3(5KB)
New version of implementation.
2024-01-02 05:50 Updated by: 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.

2024-01-13 02:55 Updated by: lachu
댓글 올리기

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 }}}

0001-OSDN-47828-S-awomir-Lach-slawek-lach.art.pl.patch(5KB)
Repair coding style

-> #endif /* FCAPI_GAME_COUNTERS_H */ api_server_counters.c should be added to Meson based build too.

2024-01-13 03:01 Updated by: lachu
댓글 올리기

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.

0001-OSDN-47828-S-awomir-Lach-slawek-lach.art.pl.patch(5KB)
Fulfill @cazfi request
2024-01-13 05:10 Updated by: 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("[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.

2024-01-13 21:20 Updated by: lachu
댓글 올리기

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:

0001-OSDN-47828-S-awomir-Lach-slawek-lach.art.pl.patch(6KB)
Repair compilation/link errors
2024-02-18 03:33 Updated by: lachu
댓글 올리기

Hi. I see this change on main branch, but this ticket has no resolution.

2024-02-18 03:33 Updated by: lachu
댓글 올리기
(This comment has been deleted)
2024-02-18 03:33 Updated by: lachu
댓글 올리기
(This comment has been deleted)
2024-02-18 03:48 Updated by: cazfi
댓글 올리기

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.

2024-02-18 03:56 Updated by: cazfi
  • 소유자 Update from (None) to cazfi
  • Resolution Update from None to Accepted
2024-02-24 11:48 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Attachment File List

Edit

Please login to add comment to this ticket » Login