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

Performance patch for MainSpoonerUpdates thread call #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
92 changes: 46 additions & 46 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ local KeepSelfInDb = true
local FocusTarget
local FocusTargetPos
local FreeFocus = false
local MessageRate = 70
local MessageInterval = true
local showEntityHandles = false

local SpoonerPrompts, ClearTasksPrompt, DetachPrompt
Expand Down Expand Up @@ -324,29 +326,21 @@ function GetInView(x1, y1, z1, pitch, roll, yaw)
end

function GetModelName(model)
for _, name in ipairs(Peds) do
if model == GetHashKey(name) then
return name
end
end
if PedsHashLookup[model] then
return PedsHashLookup[model]
end

for _, name in ipairs(Vehicles) do
if model == GetHashKey(name) then
return name
end
end
if VehiclesHashLookup[model] then
return VehiclesHashLookup[model]
end

for _, name in ipairs(Objects) do
if model == GetHashKey(name) then
return name
end
end
if ObjectsHashLookup[model] then
return ObjectsHashLookup[model]
end

for _, name in ipairs(Pickups) do
if model == GetHashKey(name) then
return name
end
end
if PickupsHashLookup[model] then
return PickupsHashLookup[model]
end

return tostring(model)
end
Expand Down Expand Up @@ -2775,32 +2769,38 @@ function MainSpoonerUpdates()
elseif FocusTarget and not FreeFocus then
entity = FocusTarget
end

SendNUIMessage({
type = 'updateSpoonerHud',
entity = entity,
netId = NetworkGetEntityIsNetworked(entity) and ObjToNet(entity),
entityType = GetSpoonerEntityType(entity),
modelName = GetModelName(GetSpoonerEntityModel(entity)),
attachedEntity = AttachedEntity,
speed = string.format('%.2f', Speed),
currentSpawn = CurrentSpawn and CurrentSpawn.modelName,
rotateMode = RotateMode,
adjustMode = AdjustMode,
speedMode = SpeedMode,
placeOnGround = PlaceOnGround,
adjustSpeed = AdjustSpeed,
rotateSpeed = RotateSpeed,
cursorX = string.format('%.2f', spawnPos.x),
cursorY = string.format('%.2f', spawnPos.y),
cursorZ = string.format('%.2f', spawnPos.z),
camX = string.format('%.2f', x2),
camY = string.format('%.2f', y2),
camZ = string.format('%.2f', z2),
camHeading = string.format('%.2f', yaw2),
focusTarget = FocusTarget,
freeFocus = FreeFocus
})
if MessageInterval then
MessageInterval = false
CreateThread(function()
Wait(MessageRate)
MessageInterval = true
end)
SendNUIMessage({
type = 'updateSpoonerHud',
entity = entity,
netId = NetworkGetEntityIsNetworked(entity) and ObjToNet(entity),
entityType = GetSpoonerEntityType(entity),
modelName = GetModelName(GetSpoonerEntityModel(entity)),
attachedEntity = AttachedEntity,
speed = string.format('%.2f', Speed),
currentSpawn = CurrentSpawn and CurrentSpawn.modelName,
rotateMode = RotateMode,
adjustMode = AdjustMode,
speedMode = SpeedMode,
placeOnGround = PlaceOnGround,
adjustSpeed = AdjustSpeed,
rotateSpeed = RotateSpeed,
cursorX = string.format('%.2f', spawnPos.x),
cursorY = string.format('%.2f', spawnPos.y),
cursorZ = string.format('%.2f', spawnPos.z),
camX = string.format('%.2f', x2),
camY = string.format('%.2f', y2),
camZ = string.format('%.2f', z2),
camHeading = string.format('%.2f', yaw2),
focusTarget = FocusTarget,
freeFocus = FreeFocus
})
end

if CheckControls(IsDisabledControlPressed, 0, Config.IncreaseSpeedControl) then
if SpeedMode == 0 then
Expand Down
3 changes: 3 additions & 0 deletions data/gta5/objects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18503,3 +18503,6 @@ Objects = {
"xs3_prop_int_xmas_tree_01",
"zprop_bin_01a_old",
}

ObjectsHashLookup = {}
for _, name in ipairs(Objects) do ObjectsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/gta5/peds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -934,3 +934,6 @@ Peds = {
"U_M_Y_Ushi",
"U_M_Y_Zombie_01",
}

PedsHashLookup = {}
for _, name in ipairs(Peds) do PedsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/gta5/pickups.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Pickups = {
}

PickupsHashLookup = {}
for _, name in ipairs(Pickups) do PickupsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/gta5/vehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,6 @@ Vehicles = {
"zr3803",
"Ztype",
}

VehiclesHashLookup = {}
for _, name in ipairs(Vehicles) do VehiclesHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/rdr3/objects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16948,3 +16948,6 @@ Objects = {
"yarrow03_p",
"yarrow04_p",
}

ObjectsHashLookup = {}
for _, name in ipairs(Objects) do ObjectsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/rdr3/peds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1982,3 +1982,6 @@ Peds = {
"western_saddle_03",
"western_saddle_04",
}

PedsHashLookup = {}
for _, name in ipairs(Peds) do PedsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/rdr3/pickups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ Pickups = {
"PICKUP_WEAPON_THROWN_TOMAHAWK_IMPROVED",
"PICKUP_WEAPON_THROWN_TOMAHAWK_MP",
}

PickupsHashLookup = {}
for _, name in ipairs(Pickups) do PickupsHashLookup[GetHashKey(name)] = name; end
3 changes: 3 additions & 0 deletions data/rdr3/vehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ Vehicles = {
"wintercoalcar",
"winterSteamer",
}

VehiclesHashLookup = {}
for _, name in ipairs(Vehicles) do VehiclesHashLookup[GetHashKey(name)] = name; end