Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Science dialog not refreshed when getting a tech from a hut #2405

Closed
lmoureaux opened this issue Oct 15, 2024 · 5 comments · Fixed by #2408
Closed

Science dialog not refreshed when getting a tech from a hut #2405

lmoureaux opened this issue Oct 15, 2024 · 5 comments · Fixed by #2408
Labels
bug Something isn't working gui This issue requires changes to the user interface
Milestone

Comments

@lmoureaux
Copy link
Contributor

Describe the bug
When getting at tech from a hut, the science dialog and the top bar are not refreshed properly

To Reproduce
Steps to reproduce the behavior:

  1. Load hut-bug.tar.gz
  2. Take Goyaalé
  3. Use the knight to enter the hut at 74,113 (in Japanese territory)
  4. You get Leadership for free
  5. Check the science report

Expected behavior
The science shows that you got Leadership

Screenshots
image

Platform and version (please complete the following information):

  • OS: Linux
  • Freeciv21 version: 7d1b0fc
  • Ruleset/Longturn game (if applicable): classic

Additional context
Add any other context about the problem here.

@lmoureaux lmoureaux added bug Something isn't working gui This issue requires changes to the user interface labels Oct 15, 2024
@lmoureaux lmoureaux added this to the v3.1-stable milestone Oct 15, 2024
@blabber
Copy link
Collaborator

blabber commented Oct 16, 2024

Entering the hut yields a random result. Apply this patch to make sure that you get the tech on entering the hut:

diff --git a/data/default/default.lua b/data/default/default.lua
index f5cfc7f433..0e0532de82 100644
--- a/data/default/default.lua
+++ b/data/default/default.lua
@@ -126,30 +126,7 @@ end
 
 -- Randomly choose a hut event
 function _deflua_hut_enter_callback(unit)
-  local chance = random(0, 11)
-  local alive = true
-
-  if chance == 0 then
-    _deflua_hut_get_gold(unit, 25)
-  elseif chance == 1 or chance == 2 or chance == 3 then
-    _deflua_hut_get_gold(unit, 50)
-  elseif chance == 4 then
-    _deflua_hut_get_gold(unit, 100)
-  elseif chance == 5 or chance == 6 or chance == 7 then
-    _deflua_hut_get_tech(unit)
-  elseif chance == 8 or chance == 9 then
-    if not _deflua_hut_get_mercenaries(unit) then
-      _deflua_hut_consolation_prize(unit)
-    end
-  elseif chance == 10 then
-    alive = _deflua_hut_get_barbarians(unit)
-  elseif chance == 11 then
-    if not _deflua_hut_get_city(unit) then
-      _deflua_hut_consolation_prize(unit)
-    end
-  end
-
-  -- continue processing if unit is alive
+   _deflua_hut_get_tech(unit)
   return (not alive)
 end
 

@blabber
Copy link
Collaborator

blabber commented Oct 16, 2024

Just a note: I suspected that this was another regression introduced by 24e44b9, but according to my tests this isn't true.

@lmoureaux
Copy link
Contributor Author

Oh, we may need to override the Lua random to make this reproducible.

In my test it was also happening with techs from treaties, which is easier to test.

@blabber
Copy link
Collaborator

blabber commented Oct 20, 2024

This reproducible in v3.0-patch.4 too.

@lmoureaux
Copy link
Contributor Author

The server sends an update with Leadership completed and the current research still set to Leadership. It should be A_UNSET instead.

lmoureaux added a commit to lmoureaux/freeciv21 that referenced this issue Oct 20, 2024
* Remove a special case when there are no bulbs left to research (this
  shouldn't happen but did in longturn#2405)
* Simplify setting an empty string for observers
lmoureaux added a commit to lmoureaux/freeciv21 that referenced this issue Oct 20, 2024
Upon getting a free tech, the server was sending the updated research
before it was done updating the struct. The client received
contradicting information (in longturn#2405, that the tech was both fully
researched and still the current tech goal).

Closes longturn#2405.
jwrober pushed a commit that referenced this issue Oct 23, 2024
* Remove a special case when there are no bulbs left to research (this
  shouldn't happen but did in #2405)
* Simplify setting an empty string for observers
jwrober pushed a commit that referenced this issue Oct 23, 2024
Upon getting a free tech, the server was sending the updated research
before it was done updating the struct. The client received
contradicting information (in #2405, that the tech was both fully
researched and still the current tech goal).

Closes #2405.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gui This issue requires changes to the user interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants