Ticket #45488

City celebrated counter

Eröffnet am: 2022-08-28 08:07 Letztes Update: 2022-12-13 01:33

Auswertung:
Verantwortlicher:
Typ:
Status:
Geschlossen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Gefixt
Datei:
9

Details

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

Ticket-Verlauf (3/26 Historien)

2022-08-28 08:07 Aktualisiert von: cazfi
  • New Ticket "City celebrated counter" created
2022-09-26 22:20 Aktualisiert von: lachu
Kommentar

@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 Aktualisiert von: lachu)
2022-12-01 12:29 Aktualisiert von: cazfi
  • Details Updated
2022-12-01 12:41 Aktualisiert von: cazfi
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: lachu
Kommentar

(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 Aktualisiert von: lachu
Kommentar

(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 Aktualisiert von: cazfi
Kommentar

- 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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: cazfi
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: lachu
Kommentar

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 Aktualisiert von: cazfi
  • Verantwortlicher Update from (Keine) to cazfi
  • Lösung Update from Keine to Accepted
2022-12-13 01:33 Aktualisiert von: cazfi
  • Status Update from Offen to Geschlossen
  • Lösung Update from Accepted to Gefixt

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden