Skip to content

Commit

Permalink
Remove usage of PlayerNumber in Lua: GAMESTATE GetCurrentSteps
Browse files Browse the repository at this point in the history
the use for it was removed a long time ago and im just going to go ahead and make it consistent in all lua now
  • Loading branch information
poco0317 committed Jan 26, 2021
1 parent 2b0dc35 commit 2eea76a
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function scoreBoard(pn, position)
SetCommand = function(self)
local rate = SCREENMAN:GetTopScreen():GetReplayRate()
if not rate then rate = getCurRateValue() end
local meter = GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(rate, 1)
local meter = GAMESTATE:GetCurrentSteps():GetMSD(rate, 1)
self:settextf("%5.2f", meter)
self:diffuse(byMSD(meter))
end
Expand Down Expand Up @@ -320,7 +320,7 @@ function scoreBoard(pn, position)
self:queuecommand("Set")
end,
SetCommand = function(self)
local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
local steps = GAMESTATE:GetCurrentSteps()
local diff = getDifficulty(steps:GetDifficulty())
self:settext(getShortDifficulty(diff))
self:diffuse(getDifficultyColor(GetCustomDifficulty(steps:GetStepsType(), steps:GetDifficulty())))
Expand Down Expand Up @@ -753,7 +753,7 @@ function scoreBoard(pn, position)
local cbm = 0
local tst = ms.JudgeScalers
local tso = tst[judge]
local ncol = GAMESTATE:GetCurrentSteps(PLAYER_1):GetNumColumns() - 1
local ncol = GAMESTATE:GetCurrentSteps():GetNumColumns() - 1
local middleCol = ncol/2

for i = 1, #devianceTable do
Expand Down Expand Up @@ -809,7 +809,7 @@ function scoreBoard(pn, position)
-- basic per-hand stats to be expanded on later
local tst = ms.JudgeScalers
local tso = tst[judge]
local ncol = GAMESTATE:GetCurrentSteps(PLAYER_1):GetNumColumns() - 1 -- cpp indexing -mina
local ncol = GAMESTATE:GetCurrentSteps():GetNumColumns() - 1 -- cpp indexing -mina
local middleCol = ncol/2

if devianceTable then
Expand Down Expand Up @@ -962,7 +962,7 @@ end
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state =
"MSD: " ..
string.format("%05.2f", GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(), 1)) ..
string.format("%05.2f", GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1)) ..
" - " ..
string.format("%05.2f%%", notShit.floor(score:GetWifeScore() * 10000) / 100) ..
" " .. THEME:GetString("Grade", ToEnumShortString(score:GetWifeGrade()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ local t =
self:xy(PlayerFrameX + 90, PlayerFrameY + 24):halign(0):zoom(0.45):maxwidth(120):diffuse(getMainColor("positive"))
end,
SetCommand = function(self)
self:settext(getDifficulty(GAMESTATE:GetCurrentSteps(PLAYER_1):GetDifficulty()))
self:settext(getDifficulty(GAMESTATE:GetCurrentSteps():GetDifficulty()))
self:diffuse(
getDifficultyColor(
GetCustomDifficulty(
GAMESTATE:GetCurrentSteps(PLAYER_1):GetStepsType(),
GAMESTATE:GetCurrentSteps(PLAYER_1):GetDifficulty()
GAMESTATE:GetCurrentSteps():GetStepsType(),
GAMESTATE:GetCurrentSteps():GetDifficulty()
)
)
)
Expand All @@ -46,7 +46,7 @@ local t =
self:xy(PlayerFrameX + 52, PlayerFrameY + 28):halign(0):zoom(0.75):maxwidth(50)
end,
SetCommand = function(self)
local meter = GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(), 1)
local meter = GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1)
self:settextf("%05.2f", meter)
self:diffuse(byMSD(meter))
end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ local t =
end
-- truncated to 128 characters(discord hard limit)
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state = "MSD: " .. string.format("%05.2f", GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(), 1))
local state = "MSD: " .. string.format("%05.2f", GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1))
local endTime = os.time() + GetPlayableTime()
GAMESTATE:UpdateDiscordPresence(largeImageTooltip, detail, state, endTime)

Expand Down Expand Up @@ -1297,7 +1297,7 @@ mc = Def.ActorFrame {
self:x(200)
self:y(200)

local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
local steps = GAMESTATE:GetCurrentSteps()
local loot = steps:GetNPSPerMeasure(1)

local peak = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ local function getPlayerBPM(pn)
return bpm
end

local function getMaxDisplayBPM(pn)
local pn = GAMESTATE:GetMasterPlayerNumber()
local function getMaxDisplayBPM()
local song = GAMESTATE:GetCurrentSong()
local steps = GAMESTATE:GetCurrentSteps(pn)
local steps = GAMESTATE:GetCurrentSteps()
if steps:GetDisplayBPMType() ~= "DisplayBPM_Random" then
return steps:GetDisplayBpms()[2]
else
Expand All @@ -64,7 +63,7 @@ local function getSpeed(pn)
elseif po:CMod() ~= nil then
return po:CMod()
elseif po:MMod() ~= nil then
return po:MMod() * (getPlayerBPM(pn) / getMaxDisplayBPM(pn))
return po:MMod() * (getPlayerBPM(pn) / getMaxDisplayBPM())
else
return getPlayerBPM(pn)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if isMulti then
onlineScores[i] = scoreUsingMultiScore(i)
end
else
onlineScores = DLMAN:GetChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey())
onlineScores = DLMAN:GetChartLeaderBoard(GAMESTATE:GetCurrentSteps():GetChartKey())
end
local sortFunction = function(h1, h2)
return h1[CRITERIA](h1) > h2[CRITERIA](h2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function scoreBoard(pn, position)
self:queuecommand("Set")
end,
SetCommand = function(self)
local meter = GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(), 1)
local meter = GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1)
self:settextf("%5.2f", meter)
self:diffuse(byMSD(meter))
end
Expand Down Expand Up @@ -200,7 +200,7 @@ function scoreBoard(pn, position)
self:queuecommand("Set")
end,
SetCommand = function(self)
local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
local steps = GAMESTATE:GetCurrentSteps()
local diff = getDifficulty(steps:GetDifficulty())
self:settext(getShortDifficulty(diff))
self:diffuse(getDifficultyColor(GetCustomDifficulty(steps:GetStepsType(), steps:GetDifficulty())))
Expand Down Expand Up @@ -551,7 +551,7 @@ local detail =
detail = #detail < 128 and detail or string.sub(detail, 1, 124) .. "..."
local state =
"MSD: " ..
string.format("%05.2f", GAMESTATE:GetCurrentSteps(PLAYER_1):GetMSD(getCurRateValue(), 1)) ..
string.format("%05.2f", GAMESTATE:GetCurrentSteps():GetMSD(getCurRateValue(), 1)) ..
" - " ..
string.format("%05.2f%%", notShit.floor(pssP1:GetWifeScore() * 10000) / 100) ..
" " .. THEME:GetString("Grade", ToEnumShortString(score:GetWifeGrade()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ local t =
self:queuecommand("On")
self:visible(true)
song = GAMESTATE:GetCurrentSong()
steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
steps = GAMESTATE:GetCurrentSteps()

--Find max MSD value, store MSD values in meter[]
-- I plan to have c++ store the highest msd value as a separate variable to aid in the filter process so this won't be needed afterwards - mina
Expand Down Expand Up @@ -194,7 +194,7 @@ t[#t + 1] =
self:xy(frameX + offsetX, frameY + offsetY + 50):zoom(0.5):halign(0)
end,
SetCommand = function(self)
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
if steps ~= nil then
local diff = getDifficulty(steps:GetDifficulty())
local stype = ToEnumShortString(steps:GetStepsType()):gsub("%_", " ")
Expand All @@ -215,7 +215,7 @@ t[#t + 1] =
self:xy(frameX + offsetX, frameY + 60):zoom(0.4):halign(0)
end,
SetCommand = function(self)
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
--local song = GAMESTATE:GetCurrentSong()
local notecount = 0
local length = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ local function updateLeaderBoardForCurrentChart()
local top = SCREENMAN:GetTopScreen()
if top:GetName() == "ScreenSelectMusic" or top:GetName() == "ScreenNetSelectMusic" then
if top:GetMusicWheel():IsSettled() and ((getTabIndex() == 2 and nestedTab == 2) or collapsed) then
local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
local steps = GAMESTATE:GetCurrentSteps()
if steps then
local leaderboardAttempt = DLMAN:GetChartLeaderboard(steps:GetChartKey())
if leaderboardAttempt ~= nil and #leaderboardAttempt > 0 then
Expand Down Expand Up @@ -190,8 +190,8 @@ local ret =
DelayedChartUpdateMessageCommand = function(self)
local leaderboardEnabled =
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()
if GAMESTATE:GetCurrentSteps(PLAYER_1) then
local chartkey = GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()
if GAMESTATE:GetCurrentSteps() then
local chartkey = GAMESTATE:GetCurrentSteps():GetChartKey()
if leaderboardEnabled then
DLMAN:RequestChartLeaderBoardFromOnline(
chartkey,
Expand Down Expand Up @@ -434,7 +434,7 @@ local l =
if score:GetWifeScore() == 0 then
self:settext("")
else
local ss = GAMESTATE:GetCurrentSteps(PLAYER_1):GetRelevantSkillsetsByMSDRank(getCurRateValue(), 1)
local ss = GAMESTATE:GetCurrentSteps():GetRelevantSkillsetsByMSDRank(getCurRateValue(), 1)
if ss ~= "" then
self:settext(THEME:GetString("Skillsets", ss))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ t[#t + 1] =
self:xy(frameX + frameWidth - offsetX, frameY + offsetY + 10):zoom(0.5):halign(1)
end,
SetCommand = function(self)
local steps = GAMESTATE:GetCurrentSteps(pn)
local steps = GAMESTATE:GetCurrentSteps()
if steps ~= nil and update then
local diff = getDifficulty(steps:GetDifficulty())
local stype = ToEnumShortString(steps:GetStepsType()):gsub("%_", " ")
Expand All @@ -171,7 +171,7 @@ t[#t + 1] =
self:xy(frameX + frameWidth - offsetX, frameY + offsetY + 23):zoom(0.4):halign(1)
end,
SetCommand = function(self)
local steps = GAMESTATE:GetCurrentSteps(pn)
local steps = GAMESTATE:GetCurrentSteps()
local song = GAMESTATE:GetCurrentSong()
local notecount = 0
local length = 1
Expand Down Expand Up @@ -376,7 +376,7 @@ for k, v in ipairs(radarValues) do
end,
SetCommand = function(self)
local song = GAMESTATE:GetCurrentSong()
local steps = GAMESTATE:GetCurrentSteps(pn)
local steps = GAMESTATE:GetCurrentSteps()
local count = 0
if song ~= nil and steps ~= nil and update then
count = steps:GetRadarValues(pn):GetValue(v[1])
Expand Down Expand Up @@ -460,7 +460,7 @@ t[#t + 1] =
SetCommand = function(self)
if update then
local pn = GAMESTATE:GetEnabledPlayers()[1]
local step = GAMESTATE:GetCurrentSteps(pn)
local step = GAMESTATE:GetCurrentSteps()
if song ~= nil then
self:diffuse(color("#FFFFFF"))
self:settext(SHA1FileHex(step:GetFilename()))
Expand Down Expand Up @@ -512,7 +512,7 @@ t[#t + 1] =
SetCommand = function(self)
if update then
local pn = GAMESTATE:GetEnabledPlayers()[1]
local step = GAMESTATE:GetCurrentSteps(pn)
local step = GAMESTATE:GetCurrentSteps()
if song ~= nil then
self:diffuse(color("#FFFFFF"))
self:settext(MD5FileHex(step:GetFilename()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ local sd =
DelayedChartUpdateMessageCommand = function(self)
local leaderboardEnabled =
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled and DLMAN:IsLoggedIn()
if leaderboardEnabled and GAMESTATE:GetCurrentSteps(PLAYER_1) then
local chartkey = GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()
if leaderboardEnabled and GAMESTATE:GetCurrentSteps() then
local chartkey = GAMESTATE:GetCurrentSteps():GetChartKey()
if SCREENMAN:GetTopScreen():GetMusicWheel():IsSettled() then
DLMAN:RequestChartLeaderBoardFromOnline(
chartkey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local t =
if getTabIndex() == 9 then
self:visible(true)
song = GAMESTATE:GetCurrentSong()
steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
steps = GAMESTATE:GetCurrentSteps()
onTab = true
MESSAGEMAN:Broadcast("RefreshTags")
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ t[#t + 1] =
MintyFreshCommand = function(self)
if song then
ptags = tags:get_data().playerTags
steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
steps = GAMESTATE:GetCurrentSteps()
chartKey = steps:GetChartKey()
ctags = {}
for k, v in pairs(ptags) do
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/_calcdisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ end
-- responsible for updating all relevant values and then triggering the display message(s)
local function updateCoolStuff()
song = GAMESTATE:GetCurrentSong()
steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
steps = GAMESTATE:GetCurrentSteps()
if song then
-- account for rate separately
-- double the output because intervals are half seconds
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/_chartpreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ local t = Def.ActorFrame {
YReverseOffsetPixels = 100,

InitCommand = function(self)
local s = GAMESTATE:GetCurrentSteps(PLAYER_1)
local s = GAMESTATE:GetCurrentSteps()
if s ~= nil then
self:LoadNoteData(s)
end
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/_chorddensitygraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local function getColorForDensity(density, ncol)
end

local function updateGraphMultiVertex(parent, realgraph)
local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
local steps = GAMESTATE:GetCurrentSteps()
if steps then
local ncol = steps:GetNumColumns()
local rate = math.max(1, getCurRateValue())
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/offsetplot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local ctt = {}
local ntt = {}
local wuab = {}
local finalSecond = GAMESTATE:GetCurrentSteps():GetLastSecond()
local td = GAMESTATE:GetCurrentSteps(PLAYER_1):GetTimingData()
local td = GAMESTATE:GetCurrentSteps():GetTimingData()
local oddColumns = false
local middleColumn = 1.5 -- middle column for 4k but accounting for trackvector indexing at 0

Expand Down
4 changes: 2 additions & 2 deletions Themes/Til Death/BGAnimations/superscoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ local o =
end,
GetFilteredLeaderboardCommand = function(self)
if GAMESTATE:GetCurrentSong() then
scoretable = DLMAN:GetChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey(), currentCountry)
scoretable = DLMAN:GetChartLeaderBoard(GAMESTATE:GetCurrentSteps():GetChartKey(), currentCountry)
ind = 0
self:playcommand("Update")
end
Expand Down Expand Up @@ -566,7 +566,7 @@ local function makeScoreDisplay(i)
end
end,
DisplayCommand = function(self)
if GAMESTATE:GetCurrentSteps(PLAYER_1) then
if GAMESTATE:GetCurrentSteps() then
if hs:HasReplayData() then
self:settext(translated_info["Watch"])
else
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Scripts/ClearType.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function getClearTypeFromScore(pn, score, ret)
return getClearTypeItem(13, ret)
end
song = GAMESTATE:GetCurrentSong()
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
profile = GetPlayerOrMachineProfile(pn)
if not isScoreValid(pn, steps, score) then
return getClearTypeItem(12, ret)
Expand Down
4 changes: 2 additions & 2 deletions Themes/_fallback/Scripts/00 Utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function getBPMChangeCount(bpmChanges)
return count
end
--- Returns a string of the form "(KeyCount)K" like "4K"
-- Uses GAMESTATE:GetCurrentSteps(PLAYER_1):GetStepsType()
-- Uses GAMESTATE:GetCurrentSteps():GetStepsType()
-- @treturn string keymode
function getCurrentKeyMode()
local keys = {
Expand All @@ -306,7 +306,7 @@ function getCurrentKeyMode()
StepsType_Bm_Double5 = "12K",
StepsType_Bm_Double7 = "16K",
}
local stepstype = GAMESTATE:GetCurrentSteps(PLAYER_1):GetStepsType()
local stepstype = GAMESTATE:GetCurrentSteps():GetStepsType()
return keys[stepstype]
end

Expand Down
6 changes: 3 additions & 3 deletions Themes/_fallback/Scripts/10 Scores.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function getMaxNotes(pn)
local song = GAMESTATE:GetCurrentSong()
local steps
if GAMESTATE:IsPlayerEnabled(pn) then
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
if steps ~= nil then
if GAMESTATE:GetCurrentGame():CountNotesSeparately() then
return steps:GetRadarValues(pn):GetValue("RadarCategory_Notes") or 0
Expand All @@ -138,7 +138,7 @@ function getMaxHolds(pn)
local song = GAMESTATE:GetCurrentSong()
local steps
if GAMESTATE:IsPlayerEnabled(pn) then
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
if steps ~= nil then
return (steps:GetRadarValues(pn):GetValue("RadarCategory_Holds") +
steps:GetRadarValues(pn):GetValue("RadarCategory_Rolls")) or 0
Expand Down Expand Up @@ -376,7 +376,7 @@ function getScoresByKey(pn)
local steps
if GAMESTATE:IsPlayerEnabled(pn) then
profile = GetPlayerOrMachineProfile(pn)
steps = GAMESTATE:GetCurrentSteps(pn)
steps = GAMESTATE:GetCurrentSteps()
if profile ~= nil and steps ~= nil and song ~= nil then
return SCOREMAN:GetScoresByKey(steps:GetChartKey())
end
Expand Down
Loading

0 comments on commit 2eea76a

Please sign in to comment.