Ticket #45488

City celebrated counter

Open Date: 2022-08-28 08:07 Last Update: 2022-12-13 01:33

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

Details

Add counter_behavior "Celebrated" - increased if city celebrates at turn change, otherwise zeroed.

Ticket History (3/26 Histories)

2022-08-28 08:07 Updated by: cazfi
  • New Ticket "City celebrated counter" created
2022-09-26 22:20 Updated by: lachu
Comment

@cazfi :

0001-OSDN-Ticket-45488-S-awomir-Lach-slawek-lach.art.pl.patch(1KB)
Code part - first iteration

0002-OSDN-Ticket-45488-S-awomir-Lach-slawek-lach.art.pl.patch(1KB)

Example part - first iteration - depends on code part

I do not known it is exactly, what you expected. On srv_main, we have: if (pcity->was_happy) {

pcity->counter_values\[pcount->index\]++;
}

But there is routine city_celebrating, which uses base_city_celebrating. I guess you would like to remove hard-coded city celebrating routines, so I do not use city_celebrating.

(Edited, 2022-09-26 22:20 Updated by: lachu)
2022-12-01 12:29 Updated by: cazfi
  • Details Updated
2022-12-01 12:41 Updated by: cazfi
Comment

With this patch you are checking if the city is happy, not if it's celebrating. Former can lead to latter, but it's not the same thing.

I would put the counter increase inside update_city_activity() where the server determines if the city celebrates this turn - there's already a "if () {} else {}" -blocks there for sending notifications about celebration. Having all the counter updates in one place would have its benefits, but that's going to be impossible with some counter anyway (anything that's being updated more frequently than once a turn)

2022-12-04 23:11 Updated by: lachu
Comment

Reply To cazfi

With this patch you are checking if the city is happy, not if it's celebrating. Former can lead to latter, but it's not the same thing. I would put the counter increase inside update_city_activity() where the server determines if the city celebrates this turn - there's already a "if () {} else {}" -blocks there for sending notifications about celebration. Having all the counter updates in one place would have its benefits, but that's going to be impossible with some counter anyway (anything that's being updated more frequently than once a turn)

I wonder, why you check city_is_build to check if it is celebrating. Maybe reason is city with anarchy do not build anything? I decide to ask.

2022-12-05 21:53 Updated by: lachu
Comment

It is done, but client crash, when new city is built. After load savegame or reconnect, everything seems worked. I must investigate, why.

One question. Should I send counter' values inside broadcast_city_info and send_city_info_at_tile? These routines seems to be called once per turn for each city.

2022-12-05 22:22 Updated by: lachu
Comment

(1): Patch. Sorry for mixing data and code, I will split these part.

(2): Patch to test celebrating patch

I got, where I made mistake. It was fairy straightforward. I send counters, before send create city packet. Problem was, when I debug client, pcity was not NULL.

2022-12-05 22:45 Updated by: lachu
Comment

(3): Done. This patch is only for celebrating, so rest part of previous patch marked as code-data is removed.

2022-12-06 12:06 Updated by: cazfi
Comment

- I don't see CB_CITY_CELEBRATION_TURNS defined
- Changes to srv_main.c seem extranous (isn't it only duplicating existing code?)

2022-12-06 15:37 Updated by: lachu
Comment

Reply To cazfi

- I don't see CB_CITY_CELEBRATION_TURNS defined
- Changes to srv_main.c seem extranous (isn't it only duplicating existing code?)

I saw another patch in my repo delivers cb_city_celebration_turns, but i do not see ticket for it. I do squash and send result.

Yes changes in srv_main.c is not needed.

2022-12-06 21:32 Updated by: lachu
Comment

Reply To cazfi

- I don't see CB_CITY_CELEBRATION_TURNS defined
- Changes to srv_main.c seem extranous (isn't it only duplicating existing code?)

Hi. Does commit message apply to commit hash? The changes was inside 72d30f9486f10a0f2b669775d0c812d0f32ea4c8 in my local logs, but I have odd commit message. I edit the history and I probably change commit message. I will prepare new patch for this ticket in near future with changes suggested by you.

2022-12-06 22:52 Updated by: lachu
Comment

Reply To cazfi

- I don't see CB_CITY_CELEBRATION_TURNS defined
- Changes to srv_main.c seem extranous (isn't it only duplicating existing code?)

0001-OSDN-TICKET-45488-S-awomir-Lach-slawek-lach.art.pl.patch(3KB)
Remove not-related code from srv_main.c and add missing constant (preprocessor)

Sorry for these mistakes. I think this version may be considered as working.

2022-12-07 16:36 Updated by: cazfi
Comment

Doesn't compile. (You really should test that before submitting a patch)

You have double definition of CB_CITY_OWNED_TURNS, and still no CB_CITY_CELEBRATION_TURNS defined.

From your patch file:

---
#define SPECENUM_NAME counter_behaviour
#define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS
#define SPECENUM_VALUE1NAME "Owned"

+#define SPECENUM_VALUE2 CB_CITY_OWNED_TURNS
+#define SPECENUM_VALUE2NAME "Celebration"

#define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST
2022-12-07 19:11 Updated by: lachu
Comment

Reply To cazfi

Doesn't compile. (You really should test that before submitting a patch) You have double definition of CB_CITY_OWNED_TURNS, and still no CB_CITY_CELEBRATION_TURNS defined. From your patch file: --- #define SPECENUM_NAME counter_behaviour
#define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS
#define SPECENUM_VALUE1NAME "Owned"
+#define SPECENUM_VALUE2 CB_CITY_OWNED_TURNS
+#define SPECENUM_VALUE2NAME "Celebration"

#define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST

I tested (compile and test patch) and I send patch placed at right-bottom of open file window. I do but known, what goes wrong, but sorry.

2022-12-07 22:36 Updated by: lachu
Comment

Reply To cazfi

Doesn't compile. (You really should test that before submitting a patch) You have double definition of CB_CITY_OWNED_TURNS, and still no CB_CITY_CELEBRATION_TURNS defined. From your patch file: --- #define SPECENUM_NAME counter_behaviour
#define SPECENUM_VALUE1 CB_CITY_OWNED_TURNS
#define SPECENUM_VALUE1NAME "Owned"
+#define SPECENUM_VALUE2 CB_CITY_OWNED_TURNS
+#define SPECENUM_VALUE2NAME "Celebration"

#define SPECENUM_COUNT COUNTER_BEHAVIOUR_LAST

0001-OSDN-TICKET-45488-S-awomir-Lach-slawek-lach.art.pl.patch(2KB)
This patch should be properl.

Sorry for wasting your time.

2022-12-09 15:03 Updated by: cazfi
  • Owner Update from (None) to cazfi
  • Resolution Update from None to Accepted
2022-12-13 01:33 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Edit

Please login to add comment to this ticket » Login