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

Hotfixes for GameLobby #1206

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/ui/lobby/UnitsAnalyzer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ local function stringPad(text, spaces)
end

local function init(value)
return value > 1 and value or 0
return value >= 1 and value or 0
end

--- Gets Economy stats for unit/enhancement blueprint and calculates production yield
Expand Down
13 changes: 13 additions & 0 deletions lua/ui/lobby/data/watchedvalue/watchedvaluetable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ local nextUnbox = function(t, k)
return nextKey, nextValue()
end

LoggingEnabled = false
LoggedChanges = {}

-- A flat, fixed-keyset table eagerly populated with WatchedValues.
WatchedValueTable = Class() {
__init = function(self, initialMapping)
-- Where the values are really stored (__index and friends only apply if the keys are absent)
-- We hide this away in the closure of the metatable.
local _store = {}
if LoggingEnabled then
table.print(initialMapping, 'WatchedValueTable initialMapping' )
end

-- Explicitly track the keyset so we can iterate our keys without having to worry about
-- iterating over closures. Also hidden away in closures to avoid changing the keyset
Expand All @@ -35,6 +41,13 @@ WatchedValueTable = Class() {
local WatchedMetaTable = {
-- Get a value from a WatchedValueTable
__index = function(wvt, key)
local msg = 'WatchedValueTable __index function(wvt, '
.. repr(key).. ') ' .. tostring(_store[key])
-- limit logging only to changes of the WatchedValueTable
if LoggingEnabled and not LoggedChanges[msg] then
LoggedChanges[msg] = true
LOG(msg)
end
return _store[key]()
end,

Expand Down
9 changes: 9 additions & 0 deletions lua/ui/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,14 @@ function GetPlayerDisplayName(playerInfo)
end
end

local WVT = import('/lua/ui/lobby/data/watchedvalue/watchedvaluetable.lua')

-- update the data in a player slot
-- TODO: With lazyvars, this function should be eliminated. Lazy-value-callbacks should be used
-- instead to incrementaly update things.
function SetSlotInfo(slotNum, playerInfo)
LOG('lobby.SetSlotInfo slotNum = ' .. tostring(slotNum))
table.print(playerInfo, 'lobby.SetSlotInfo playerInfo = ')
-- Remove the ConnectDialog. It probably makes more sense to do this when we get the game state.
if GUI.connectdialog then
GUI.connectdialog:Close()
Expand Down Expand Up @@ -732,6 +736,11 @@ function SetSlotInfo(slotNum, playerInfo)
--
-- The predicate was getting unpleasantly long to read.
local function teamSelectionEnabled(autoTeams, ready, locallyOwned, isHost)
LOG('lobby.teamSelectionEnabled autoTeams = ' .. tostring(autoTeams) ..
', ready = ' .. tostring(ready) ..
', locallyOwned = ' .. tostring(locallyOwned) ..
', isHost = ' .. tostring(isHost) )
WVT.LoggingEnabled = true
if isHost and not playerInfo.Human then
return true
end
Expand Down