Skip to content

Commit

Permalink
Use PlayerUpdateManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Oct 4, 2024
1 parent 2b81fb3 commit af57d8a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 49 deletions.
35 changes: 20 additions & 15 deletions Internal/RSClient.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
33 changes: 0 additions & 33 deletions Internal/RSGameInstance.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Internal/RSPlayer.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions Internal/RSPlayerUpdateManager.simba
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions Internal/RSStructures.simba
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type

RSLocalPlayer = type RSPlayer;

RSPlayerUpdateManager = type RSType;

RSNameInfo = type RSType;

RSCombatInfoList = type RSType;
Expand Down
1 change: 1 addition & 0 deletions Internal/Reflection.simba
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit af57d8a

Please sign in to comment.