From af57d8abe8743814ac167ff0ed04dc0e6b1d4ade Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 4 Oct 2024 13:19:10 -0400 Subject: [PATCH] Use PlayerUpdateManager --- Internal/RSClient.simba | 35 ++++++++++++++++------------ Internal/RSGameInstance.simba | 33 -------------------------- Internal/RSPlayer.simba | 2 +- Internal/RSPlayerUpdateManager.simba | 34 +++++++++++++++++++++++++++ Internal/RSStructures.simba | 2 ++ Internal/Reflection.simba | 1 + 6 files changed, 58 insertions(+), 49 deletions(-) create mode 100644 Internal/RSPlayerUpdateManager.simba diff --git a/Internal/RSClient.simba b/Internal/RSClient.simba index 6f95bb7..19e5297 100644 --- a/Internal/RSClient.simba +++ b/Internal/RSClient.simba @@ -9,6 +9,11 @@ begin Result.ref := RGetStaticObject(R_EIOS, CLIENT_GAMEINSTANCE); end; +Function RSClient.PlayerUpdateManager: RSPlayerUpdateManager; static; +begin + Result.ref := RGetStaticObject(R_EIOS, CLIENT_PLAYERUPDATEMANAGER); +end; + Function RSClient.LoopCycle: Int32; static; begin Result := RGetStaticInt(R_EIOS, CLIENT_LOOPCYCLE); @@ -149,37 +154,37 @@ end; Function RSClient.PlayerIndices(PlayerCount: Int32): Array of Int32; static; var - GameInstance: RSGameInstance; + PlayerManager: RSPlayerUpdateManager; begin - GameInstance := RSClient.GameInstance; - if GameInstance.ref <> nil then + PlayerManager := RSClient.PlayerUpdateManager; + if PlayerManager.ref <> nil then begin - Result := GameInstance.PlayerIndices(PlayerCount); - GameInstance.Free; + Result := PlayerManager.PlayerIndices(PlayerCount); + PlayerManager.Free; end; end; Function RSClient.PlayerIndices: Array of Int32; static; overload; var - GameInstance: RSGameInstance; + PlayerManager: RSPlayerUpdateManager; begin - GameInstance := RSClient.GameInstance; - if GameInstance.ref <> nil then + PlayerManager := RSClient.PlayerUpdateManager; + if PlayerManager.ref <> nil then begin - Result := GameInstance.PlayerIndices(); - GameInstance.Free; + Result := PlayerManager.PlayerIndices(); + PlayerManager.Free; end; end; Function RSClient.PlayerCount: Int32; static; var - GameInstance: RSGameInstance; + PlayerManager: RSPlayerUpdateManager; begin - GameInstance := RSClient.GameInstance; - if GameInstance.ref <> nil then + PlayerManager := RSClient.PlayerUpdateManager; + if PlayerManager.ref <> nil then begin - Result := GameInstance.PlayerCount(); - GameInstance.Free; + Result := PlayerManager.PlayerCount(); + PlayerManager.Free; end; end; diff --git a/Internal/RSGameInstance.simba b/Internal/RSGameInstance.simba index b22a8e2..6b53168 100644 --- a/Internal/RSGameInstance.simba +++ b/Internal/RSGameInstance.simba @@ -4,11 +4,6 @@ {$include_once RSCombatInfo.simba} {$include_once RSTile.simba} -Function RSGameInstance.PlayerCount: Int32; constref; -begin - Result := RGetInt(R_EIOS, ref, GAMEINSTANCE_PLAYERCOUNT); -end; - Function RSGameInstance.Players: Array of RSPlayer; var Players: Pointer; @@ -37,34 +32,6 @@ begin SetLength(Result, J); end; -Function RSGameInstance.PlayerIndices(PlayerCount: Int32): Array of Int32; -var - Indices: Pointer; - IndicesSize: SizeUInt; -begin - IndicesSize := 0; - Indices := RGetArray(R_EIOS, ref, IndicesSize, GAMEINSTANCE_PLAYERINDICES); - if Indices = nil then - Exit; - - Result := RGetIntArray(R_EIOS, Indices, 0, Min(PlayerCount, IndicesSize)); - RFreeObject(R_EIOS, Indices); -end; - -Function RSGameInstance.PlayerIndices: Array of Int32; overload; -var - Indices: Pointer; - IndicesSize: SizeUInt; -begin - IndicesSize := 0; - Indices := RGetArray(R_EIOS, ref, IndicesSize, GAMEINSTANCE_PLAYERINDICES); - if Indices = nil then - Exit; - - Result := RGetIntArray(R_EIOS, Indices, 0, IndicesSize); - RFreeObject(R_EIOS, Indices); -end; - Function RSGameInstance.NPCCount: Int32; constref; begin Result := RGetInt(R_EIOS, ref, GAMEINSTANCE_NPCCOUNT); diff --git a/Internal/RSPlayer.simba b/Internal/RSPlayer.simba index c063742..627cd93 100644 --- a/Internal/RSPlayer.simba +++ b/Internal/RSPlayer.simba @@ -25,7 +25,7 @@ begin if GameInstance.ref = nil then Exit; - Indices := GameInstance.PlayerIndices(); + Indices := RSClient.PlayerIndices(); if Length(Indices) < 1 then begin GameInstance.Free; diff --git a/Internal/RSPlayerUpdateManager.simba b/Internal/RSPlayerUpdateManager.simba new file mode 100644 index 0000000..3cd76de --- /dev/null +++ b/Internal/RSPlayerUpdateManager.simba @@ -0,0 +1,34 @@ +{$include_once RSStructures.simba} + +Function RSPlayerUpdateManager.PlayerCount: Int32; constref; +begin + Result := RGetInt(R_EIOS, ref, PLAYERUPDATEMANAGER_PLAYERCOUNT); +end; + +Function RSPlayerUpdateManager.PlayerIndices(PlayerCount: Int32): Array of Int32; +var + Indices: Pointer; + IndicesSize: SizeUInt; +begin + IndicesSize := 0; + Indices := RGetArray(R_EIOS, ref, IndicesSize, PLAYERUPDATEMANAGER_PLAYERINDICES); + if Indices = nil then + Exit; + + Result := RGetIntArray(R_EIOS, Indices, 0, Min(PlayerCount, IndicesSize)); + RFreeObject(R_EIOS, Indices); +end; + +Function RSPlayerUpdateManager.PlayerIndices: Array of Int32; overload; +var + Indices: Pointer; + IndicesSize: SizeUInt; +begin + IndicesSize := 0; + Indices := RGetArray(R_EIOS, ref, IndicesSize, PLAYERUPDATEMANAGER_PLAYERINDICES); + if Indices = nil then + Exit; + + Result := RGetIntArray(R_EIOS, Indices, 0, IndicesSize); + RFreeObject(R_EIOS, Indices); +end; diff --git a/Internal/RSStructures.simba b/Internal/RSStructures.simba index 1360e36..0513f0d 100644 --- a/Internal/RSStructures.simba +++ b/Internal/RSStructures.simba @@ -68,6 +68,8 @@ type RSLocalPlayer = type RSPlayer; + RSPlayerUpdateManager = type RSType; + RSNameInfo = type RSType; RSCombatInfoList = type RSType; diff --git a/Internal/Reflection.simba b/Internal/Reflection.simba index 9c4223c..0799363 100644 --- a/Internal/Reflection.simba +++ b/Internal/Reflection.simba @@ -20,6 +20,7 @@ {$include_once RSPlayerDefinition.simba} {$include_once RSPlayer.simba} {$include_once RSLocalPlayer.simba} +{$include_once RSPlayerUpdateManager.simba} {$include_once RSNPCDefinition.simba} {$include_once RSNPC.simba} {$include_once RSCamera.simba}