Skip to content

Commit

Permalink
Show selected unit in legacy build menu pre-game (#3963)
Browse files Browse the repository at this point in the history
* Show selected unit in legacy build menu pre-game

- Use correct lookup table: `units.unitName` is always empty, but there is a table local to this file that can be used.
- Do not invert the build command ID, the names are keyed by positive ID.

* Remove unused unitName

Table was not initialized nor referenced

---------

Co-authored-by: Rhys van der Waerden <>
  • Loading branch information
rhys-vdw authored Nov 27, 2024
1 parent c433f41 commit 1f33e01
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
3 changes: 1 addition & 2 deletions luaui/Widgets/gui_buildmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,8 @@ function widget:DrawScreen()

if Spring.GetGameFrame() == 0 and WG['pregame-build'] then
activeCmd = WG["pregame-build"] and WG["pregame-build"].getPreGameDefID()
activeCmd = activeCmd and -activeCmd
if activeCmd then
activeCmd = units.unitName[activeCmd]
activeCmd = unitName[activeCmd]
end
else
activeCmd = select(4, spGetActiveCommand())
Expand Down
3 changes: 0 additions & 3 deletions luaui/configs/unit_buildmenu_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
---


local unitName = {}
local unitEnergyCost = {}
local unitMetalCost = {}
local unitGroup = {}
Expand Down Expand Up @@ -163,8 +162,6 @@ local minWaterUnitDepth = -11
------------------------------------

return {

unitName = unitName,
unitEnergyCost = unitEnergyCost,
unitMetalCost = unitMetalCost,
unitGroup = unitGroup,
Expand Down

0 comments on commit 1f33e01

Please sign in to comment.