Skip to content

Commit 7787c95

Browse files
authored
Merge pull request #112 from acidlabsdev/main
fix(Misc): miscellaneous fixes
2 parents 96591c3 + 3a2d076 commit 7787c95

7 files changed

Lines changed: 328 additions & 185 deletions

File tree

SSV2/includes/features/EntityForge.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ end
13221322

13231323
---@param data any Base64 XOR-encrypted json
13241324
function EntityForge:ImportCreation(data)
1325-
if (not data or not Serializer:IsBase64(data)) then
1325+
if (not data or not Serializer:IsEncrypted(data)) then
13261326
Notifier:ShowError(
13271327
"EntityForge",
13281328
"Import Error: Incorrect data type!",

SSV2/includes/features/Mastermind.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ end
116116

117117
function Mastermind:ReadPropertyData()
118118
ThreadManager:Run(function()
119-
while (Game.IsInTransition()) do
119+
while (Game.IsInNetworkTransition()) do
120120
yield()
121121
end
122122

SSV2/includes/frontend/casino_ui.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,13 @@ local function drawHeistTab()
398398
end
399399

400400
local function DrawDunk()
401-
if (not Game.IsOnline() or not Backend:IsUpToDate()) then
402-
ImGui.Text(_T("GENERIC_OFFLINE_OR_OUTDATED"))
401+
if (not Game.IsOnline()) then
402+
ImGui.Text(_T("GENERIC_UNAVAILABLE_SP"))
403+
return
404+
end
405+
406+
if (not Backend:IsUpToDate()) then
407+
ImGui.Text(_T("GENERIC_OUTDATED"))
403408
return
404409
end
405410

SSV2/includes/frontend/mastermind_ui.lua

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
88

99

10-
local Mastermind = require("SSV2.includes.features.Mastermind"):init()
10+
local Mastermind = require("includes.features.Mastermind"):init()
1111
local SGSL = require("includes.services.SGSL")
1212
local secondary_targets = { "Cash", "Weed", "Coke", "Gold" }
1313
local cayo_secondary_target_i, cayo_secondary_target_c
1414

1515
local heistNames <const> = { -- https://github.com/root-cause/v-labels/blob/master/labels.json
16-
CluckinBellFarmRaid = "AWT_1026",
17-
KnoWayOut = "DLCC_AVIM",
18-
DontFuckWithDre = "AWT_973",
16+
CluckinBellFarmRaid = "AWT_1026",
17+
KnoWayOut = "DLCC_AVIM",
18+
DontFuckWithDre = "AWT_973",
1919
OscarGuzmanFliesAgain = "HACK24_MFM_STR",
20-
FleecaJob = "HTITLE_TUT",
21-
PrisonBreak = "HTITLE_PRISON",
22-
HumaneLabsRaid = "HTITLE_HUMANE",
23-
SeriesAFunding = "HTITLE_NARC",
24-
PacificStandardJob = "HTITLE_ORNATE",
25-
DataBreaches = "HPSTRAND_IAAb",
26-
BogdanProblem = "HPSTRAND_SUBb",
27-
DoomsdayScenario = "HPSTRAND_MSILb",
20+
FleecaJob = "HTITLE_TUT",
21+
PrisonBreak = "HTITLE_PRISON",
22+
HumaneLabsRaid = "HTITLE_HUMANE",
23+
SeriesAFunding = "HTITLE_NARC",
24+
PacificStandardJob = "HTITLE_ORNATE",
25+
DataBreaches = "HPSTRAND_IAAb",
26+
BogdanProblem = "HPSTRAND_SUBb",
27+
DoomsdayScenario = "HPSTRAND_MSILb",
2828
}
2929
local tabNames <const> = { --
3030
"YH_BASIC_TAB", -- Basic
@@ -152,8 +152,8 @@ local function drawCayoTab()
152152
end
153153

154154
local request_kosatka = SGSL:Get(SGSL.data.request_services_global):AsGlobal():At(613)
155-
local sub_requested = request_kosatka:ReadInt() == 1
156-
local sub_spawned = not sub.coords:is_zero()
155+
local sub_requested = request_kosatka:ReadInt() == 1
156+
local sub_spawned = not sub.coords:is_zero()
157157

158158
ImGui.BeginDisabled(not sub_spawned)
159159
if (GUI:Button(_T("GENERIC_TELEPORT"))) then
@@ -191,7 +191,6 @@ local function drawCayoTab()
191191
local cayo_heist_weapons = stats.get_int("MPX_H4CNF_WEAPONS")
192192
local cayo_cooldown = stats.get_int("MPX_H4_COOLDOWN")
193193
local cayo_cooldown_hard = stats.get_int("MPX_H4_COOLDOWN_HARD")
194-
195194
local posix_now = Time.Epoch()
196195
local cooldown_seconds_left = cayo_cooldown - posix_now
197196
local cooldown_hard_seconds_left = cayo_cooldown_hard - posix_now
@@ -330,7 +329,6 @@ local function drawDDayTab()
330329

331330
local dday_status = stats.get_int("MPX_GANGOPS_HEIST_STATUS")
332331
local dday_cooldown = stats.get_int("MPX_GANGOPS_LAUNCH_TIME")
333-
334332
local posix_now = Time.Epoch()
335333
local cooldown_seconds_left = dday_cooldown - posix_now
336334
local on_cooldown = cooldown_seconds_left > 0
@@ -401,25 +399,26 @@ local tabCallbacks <const> = {
401399
}
402400

403401
local function HeistUI()
404-
if (not Game.IsOnline() or not Backend:IsUpToDate()) then
402+
if (not Game.IsOnline()) then
405403
ImGui.Text(_T("GENERIC_UNAVAILABLE_SP"))
406404
return
407405
end
408406

409-
cayo_secondary_target_i, cayo_secondary_target_c = Mastermind:GetCayoSecTargets()
407+
if (not Backend:IsUpToDate()) then
408+
ImGui.Text(_T("GENERIC_OUTDATED"))
409+
return
410+
end
410411

411-
if (ImGui.BeginTabBar("##funkBar")) then
412-
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, 10, 10)
412+
cayo_secondary_target_i, cayo_secondary_target_c = Mastermind:GetCayoSecTargets()
413413

414+
if (ImGui.BeginTabBar("##mastermind")) then
414415
for i = 1, #tabNames do
415416
local name = tabNames[i]
416417
if ImGui.BeginTabItem(name) then
417418
tabCallbacks[i]()
418419
ImGui.EndTabItem()
419420
end
420421
end
421-
422-
ImGui.PopStyleVar()
423422
ImGui.EndTabBar()
424423
end
425424
end

SSV2/includes/lib/utils.lua

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,9 +931,34 @@ table.copy = function(t, seen)
931931
return out
932932
end
933933

934+
---@param src table
935+
---@param dest table
936+
---@param path string?
937+
---@param seen table?
938+
function table.merge(src, dest, path, seen)
939+
seen = seen or {}
940+
if (seen[src]) then
941+
return
942+
end
943+
seen[src] = true
944+
945+
for k, v in pairs(src) do
946+
if (dest[k] == nil) then
947+
dest[k] = v
948+
elseif (type(v) == "table" and type(dest[k]) == "table") then
949+
local current_path = path and (path .. "." .. tostring(k)) or tostring(k)
950+
table.merge(v, dest[k], current_path, seen)
951+
end
952+
end
953+
end
954+
934955
---@param inTable table
935956
---@param outTable table
936957
function table.swap(inTable, outTable)
958+
if (inTable == outTable) then
959+
return
960+
end
961+
937962
local temp = {}
938963

939964
for k, v in pairs(inTable) do
@@ -960,11 +985,16 @@ function table.overwrite(t, src, seen)
960985
seen[src] = true
961986

962987
for k in pairs(t) do
963-
t[k] = nil
988+
if (src[k] == nil) then
989+
t[k] = nil
990+
end
964991
end
965992

966993
for k, v in pairs(src) do
967-
if (type(v) == "table" and type(t[k]) == "table") then
994+
if (type(v) == "table") then
995+
if (type(t[k]) ~= "table") then
996+
t[k] = {}
997+
end
968998
table.overwrite(t[k], v, seen)
969999
else
9701000
t[k] = v
@@ -1228,6 +1258,16 @@ string.isvalid = function(str)
12281258
and not str:iswhitespace()
12291259
end
12301260

1261+
---@param str string
1262+
---@return boolean
1263+
function string.is_base64(str)
1264+
if (not string.isvalid(str)) then
1265+
return false
1266+
end
1267+
1268+
return (#str % 4 == 0) and (str:match("^[A-Za-z0-9+/]+=?=?$") ~= nil)
1269+
end
1270+
12311271
-- Returns whether a string starts with the provided prefix.
12321272
---@param str string
12331273
---@param prefix string

SSV2/includes/modules/Game.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ function Game.IsEnhanced()
105105
end
106106

107107
---@return boolean
108-
function Game.IsInTransition()
109-
return NETWORK.NETWORK_IS_IN_TRANSITION() or Backend:IsPlayerSwitchInProgress()
108+
function Game.IsInNetworkTransition()
109+
-- PlayerSwitch is invalid here as it will return true in Single Player
110+
return script.is_active("maintransition")
110111
end
111112

112113
---@return boolean
113114
function Game.IsOnline()
114-
return network.is_session_started() and not Game.IsInTransition()
115+
return network.is_session_started() and not Game.IsInNetworkTransition()
115116
end
116117

117118
---@param handle integer

0 commit comments

Comments
 (0)