Ticket #45889

Send initial counter values to client

Eröffnet am: 2022-10-17 20:08 Letztes Update: 2023-01-05 21:23

Auswertung:
Verantwortlicher:
(Keine)
Typ:
Status:
Offen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Keine
Datei:
2

Details

City counter value updates are sent to client by #45429, but we will need to send also initial values, e.g., when a client reconnects, or game has been loaded from a saved game. Basically when ever full city info gets sent to the client for the first time (note, that if it makes implementation easier; it should be ok to "send" them to the delta protocol layer unconditionally when ever full city info gets sent. Delta protocol would notice itself if there's nothing to update/send)

Ticket-Verlauf (3/22 Historien)

2022-10-17 20:08 Aktualisiert von: cazfi
  • New Ticket "Send initial counter values to client" created
2022-10-28 01:00 Aktualisiert von: lachu
Kommentar

@cazfi. I will look if it is real necessary, but I probably allocates counters inside routine creating city (both on client and server). As far, as I remember, default value of counter (not initial for city) was send in ruleset packet.

2022-10-28 21:41 Aktualisiert von: cazfi
Kommentar

Reply To lachu

@cazfi. I will look if it is real necessary, but I probably allocates counters inside routine creating city (both on client and server). As far, as I remember, default value of counter (not initial for city) was send in ruleset packet.

Yes, memory is allocated when the city is created, and the client knows the default counter value. What it currently does not know after connecting to the server is the counter's current value, until there's a change to it.

2022-10-29 00:24 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

@cazfi. I will look if it is real necessary, but I probably allocates counters inside routine creating city (both on client and server). As far, as I remember, default value of counter (not initial for city) was send in ruleset packet.

Yes, memory is allocated when the city is created, and the client knows the default counter value. What it currently does not know after connecting to the server is the counter's current value, until there's a change to it.

Ah, yes - client can connect in middle of the game or server could load savegame. Thanks for clarification.

2022-10-30 01:37 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

@cazfi. I will look if it is real necessary, but I probably allocates counters inside routine creating city (both on client and server). As far, as I remember, default value of counter (not initial for city) was send in ruleset packet.

Yes, memory is allocated when the city is created, and the client knows the default counter value. What it currently does not know after connecting to the server is the counter's current value, until there's a change to it.

Done and tested: firstly wrote the patch and test - reconnects and load savegame. In next step, do git format-patch, reset ==hard HEAD~1 and retest.

2022-12-01 12:28 Aktualisiert von: cazfi
Kommentar

I think that information should be sent always when the full city packet gets sent for the first time, not only when the client reconnects. I don't think the current implementation works, e.g., when one conquers an enemy city (well, we only have the "owned" counter at the moment, and that's zeroed at conquest anyway, but in the general case the new owner should get correct counter values). Correct me if that gets handled somehow.

2022-12-04 22:57 Aktualisiert von: lachu
Kommentar

Reply To cazfi

I think that information should be sent always when the full city packet gets sent for the first time, not only when the client reconnects. I don't think the current implementation works, e.g., when one conquers an enemy city (well, we only have the "owned" counter at the moment, and that's zeroed at conquest anyway, but in the general case the new owner should get correct counter values). Correct me if that gets handled somehow.

I will look inside srv_main.c, but I remember there exist check counter was changed and it will be resend in this case. That mean, if city get conquered, new value will be send to the new owner, but it is handled only on turn-player-switch. So, I must repair current code - you're right.

2022-12-09 01:54 Aktualisiert von: lachu
2022-12-09 01:54 Aktualisiert von: lachu
  • File 0001-Send-city-counter-updates-to-client.patch (File ID: 11061) is deleted
2022-12-09 01:56 Aktualisiert von: lachu
Kommentar

Reply To cazfi

I think that information should be sent always when the full city packet gets sent for the first time, not only when the client reconnects. I don't think the current implementation works, e.g., when one conquers an enemy city (well, we only have the "owned" counter at the moment, and that's zeroed at conquest anyway, but in the general case the new owner should get correct counter values). Correct me if that gets handled somehow.

0001-Send-city-counter-updates-to-client.patch(5KB)
Not done yet - send counter value when city transfer

You are right. in srv_main.c we send only value, when counter change, so on end of each turn. We must also send value to new owner (and observers), when city owner's changed.

2022-12-17 00:36 Aktualisiert von: lachu
Kommentar

Reply To cazfi

I think that information should be sent always when the full city packet gets sent for the first time, not only when the client reconnects. I don't think the current implementation works, e.g., when one conquers an enemy city (well, we only have the "owned" counter at the moment, and that's zeroed at conquest anyway, but in the general case the new owner should get correct counter values). Correct me if that gets handled somehow.

I messed up. I look at 4cab5d9a0e2fa958213fe3060569b4efec2dc55d and see this Ticket is implemented by it. Does not it?

2022-12-19 12:48 Aktualisiert von: cazfi
Kommentar

Reply To lachu

I messed up. I look at 4cab5d9a0e2fa958213fe3060569b4efec2dc55d and see this Ticket is implemented by it. Does not it?

Is the code in there for the generic case? I have to recheck.

2022-12-20 17:18 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

I messed up. I look at 4cab5d9a0e2fa958213fe3060569b4efec2dc55d and see this Ticket is implemented by it. Does not it?

Is the code in there for the generic case? I have to recheck.

Not for any kind of counter, but for owned and possibly other already implemented counter. Generic case is hard to handle, because when to send counter of any type? In this thread you suggest, owned should been send on sending city information. Should I send each counter on turn end also@

2022-12-20 19:07 Aktualisiert von: cazfi
Kommentar

Reply To lachu

should been send on sending city information.

That just seems obvious to me - city counter values *are* part of city related information, aren't they?

As for trying to figure out what counters to send on each situation, on some high level functions; 1) delta network protocol already automatically makes it so that not-changed values are not actually sent. 2) Implementing it on high level will only bring very complex code, with lots of bugs, high maintenance, and all the special case handling code making bigger NEGATIVE performance impact than what one would save in avoiding refreshing some field.

2022-12-22 02:40 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

should been send on sending city information.

That just seems obvious to me - city counter values *are* part of city related information, aren't they? As for trying to figure out what counters to send on each situation, on some high level functions; 1) delta network protocol already automatically makes it so that not-changed values are not actually sent. 2) Implementing it on high level will only bring very complex code, with lots of bugs, high maintenance, and all the special case handling code making bigger NEGATIVE performance impact than what one would save in avoiding refreshing some field.

I think I do not fully understood you. I wonder what means send counter information, when client disconnects. In this thread you wrote, that better place for owned/celebrated/disorder counter should be send with rest of city information. Currently, we supports only these three type of counters. My question is: for what this ticket exists? Do I implement this ticket in patches applied from other ticket?

2022-12-25 09:04 Aktualisiert von: cazfi
Kommentar

Reply To lachu

In this thread you wrote, that better place for owned/celebrated/disorder counter should be send with rest of city information. Currently, we supports only these three type of counters.

We want to build support for further counters, not just those three.

2023-01-02 23:04 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

In this thread you wrote, that better place for owned/celebrated/disorder counter should be send with rest of city information. Currently, we supports only these three type of counters.

We want to build support for further counters, not just those three.

Hi. How does delta protocol recognized similar packed. I mean, there is need to select key field, so changes in key field do not mess up. For example - I send PLAYER_ONE COUNTER_0 COUNTER_VALUE=50 and next PLAYER_TWO COUNTER_0 COUNTER_VALUE=100 and lastly PLAYER_ONE COUNTER_0 COUNTER_VALUE=100 . First message should be removed from memory and do not compared again, so when I try to send PLAYER_ONE COUNTER_0 COUNTER_VALUE=50, it was send.

2023-01-02 23:26 Aktualisiert von: cazfi
Kommentar

Ok. Seems that counters network protocol isn't in the shape I though it would be. Will open a new ticket about reworking that. Shouldn't block this ticket, though (just means that the protocol isn't as efficient as it should)

2023-01-04 01:04 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Ok. Seems that counters network protocol isn't in the shape I though it would be. Will open a new ticket about reworking that. Shouldn't block this ticket, though (just means that the protocol isn't as efficient as it should)

Should I still use delta protocol? How it works?

2023-01-04 01:14 Aktualisiert von: cazfi
Kommentar

Reply To lachu

Should I still use delta protocol? How it works?

It's a low level protocol in the network packet management code. You've been using it all the time.

2023-01-05 21:23 Aktualisiert von: lachu
Kommentar

Reply To cazfi

Reply To lachu

Should I still use delta protocol? How it works?

It's a low level protocol in the network packet management code. You've been using it all the time.

I put some little changes into https://osdn.net/projects/freeciv/ticket/45890 . I do not known, where to put them - no ticket opened, but it seems changes are related, but topic do not describe changes in last two patch.

Dateianhangliste

Bearbeiten

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