From d6626a88ff2a4c011e2b74b29a5c9a8be833912a Mon Sep 17 00:00:00 2001 From: Winkarst-cpu Date: Fri, 24 May 2024 13:19:30 +0300 Subject: [PATCH] Revert "Replace ents.GetAll and player.GetAll" This reverts commit ed923199e3a8c8d30ad103049f80cb3bea8f43ed. --- gamemode/config/sh_config.lua | 4 ++-- gamemode/core/hooks/sv_hooks.lua | 12 ++++++------ gamemode/core/libs/sh_chatbox.lua | 2 +- gamemode/core/libs/sh_class.lua | 2 +- gamemode/core/meta/sh_character.lua | 4 ++-- gamemode/core/meta/sh_entity.lua | 4 ++-- gamemode/core/meta/sh_inventory.lua | 4 ++-- gamemode/core/meta/sh_item.lua | 2 +- gamemode/core/sh_commands.lua | 26 +++++++++++++------------- gamemode/core/sh_util.lua | 2 +- plugins/area/sv_hooks.lua | 2 +- plugins/doors/derma/cl_door.lua | 2 +- plugins/doors/sv_plugin.lua | 2 +- plugins/observer.lua | 2 +- plugins/pac.lua | 4 ++-- plugins/recognition.lua | 2 +- plugins/typing.lua | 2 +- 17 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gamemode/config/sh_config.lua b/gamemode/config/sh_config.lua index 678944961..6816d69cc 100644 --- a/gamemode/config/sh_config.lua +++ b/gamemode/config/sh_config.lua @@ -96,7 +96,7 @@ ix.config.Add("saveInterval", 300, "How often characters save in seconds.", nil, category = "characters" }) ix.config.Add("walkSpeed", 130, "How fast a player normally walks.", function(oldValue, newValue) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do v:SetWalkSpeed(newValue) end end, { @@ -104,7 +104,7 @@ end, { category = "characters" }) ix.config.Add("runSpeed", 235, "How fast a player normally runs.", function(oldValue, newValue) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do v:SetRunSpeed(newValue) end end, { diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index c7dc232ee..1572eb34e 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -71,7 +71,7 @@ function GM:PlayerInitialSpawn(client) client.ixLoaded = true client:SetData("intro", true) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetCharacter()) then v:GetCharacter():Sync(client) end @@ -451,7 +451,7 @@ local function CalcPlayerCanHearPlayersVoice(listener) listener.ixVoiceHear = listener.ixVoiceHear or {} local eyePos = listener:EyePos() - for _, speaker in player.Iterator() do + for _, speaker in ipairs(player.GetAll()) do local speakerEyePos = speaker:EyePos() listener.ixVoiceHear[speaker] = eyePos:DistToSqr(speakerEyePos) < voiceDistance end @@ -465,7 +465,7 @@ function GM:InitializedConfig() end function GM:VoiceToggled(bAllowVoice) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do local uniqueID = v:SteamID64() .. "ixCanHearPlayersVoice" if (bAllowVoice) then @@ -724,7 +724,7 @@ function GM:PlayerDisconnected(client) return end - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (!v.ixVoiceHear) then continue end @@ -771,7 +771,7 @@ function GM:ShutDown() hook.Run("SaveData") - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do v:SaveData() if (v:GetCharacter()) then @@ -877,7 +877,7 @@ function GM:CharacterPreSave(character) end timer.Create("ixLifeGuard", 1, 0, function() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetCharacter() and v:Alive() and hook.Run("ShouldPlayerDrowned", v) != false) then if (v:WaterLevel() >= 3) then if (!v.drowningTime) then diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 8edea49b6..ebadff4ee 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -318,7 +318,7 @@ if (SERVER) then if (class.CanHear and !receivers) then receivers = {} - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetCharacter() and class:CanHear(speaker, v, data) != false) then receivers[#receivers + 1] = v end diff --git a/gamemode/core/libs/sh_class.lua b/gamemode/core/libs/sh_class.lua index 93c5ea4c2..913e1d8be 100644 --- a/gamemode/core/libs/sh_class.lua +++ b/gamemode/core/libs/sh_class.lua @@ -124,7 +124,7 @@ end function ix.class.GetPlayers(class) local players = {} - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do local char = v:GetCharacter() if (char and char:GetClass() == class) then diff --git a/gamemode/core/meta/sh_character.lua b/gamemode/core/meta/sh_character.lua index 38b58ea40..5928a222f 100644 --- a/gamemode/core/meta/sh_character.lua +++ b/gamemode/core/meta/sh_character.lua @@ -100,7 +100,7 @@ if (SERVER) then function CHAR:Sync(receiver) -- Broadcast the character information if receiver is not set. if (receiver == nil) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do self:Sync(v) end -- Send all character information if the receiver is the character's owner. @@ -250,7 +250,7 @@ function CHAR:GetPlayer() elseif (self.steamID) then local steamID = self.steamID - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:SteamID64() == steamID) then self.player = v diff --git a/gamemode/core/meta/sh_entity.lua b/gamemode/core/meta/sh_entity.lua index 31637dfbb..0e7e48591 100644 --- a/gamemode/core/meta/sh_entity.lua +++ b/gamemode/core/meta/sh_entity.lua @@ -121,7 +121,7 @@ if (SERVER) then self.ignoreUse = false self.ixIsMuted = false - for _, v in ents.Iterator() do + for _, v in ipairs(ents.GetAll()) do if (v:GetParent() == self) then v:SetNotSolid(false) v:SetNoDraw(false) @@ -150,7 +150,7 @@ if (SERVER) then dummy:SetBodygroup(v.id, self:GetBodygroup(v.id)) end - for _, v in ents.Iterator() do + for _, v in ipairs(ents.GetAll()) do if (v:GetParent() == self) then v:SetNotSolid(true) v:SetNoDraw(true) diff --git a/gamemode/core/meta/sh_inventory.lua b/gamemode/core/meta/sh_inventory.lua index c0613ddb7..9dcf9590c 100644 --- a/gamemode/core/meta/sh_inventory.lua +++ b/gamemode/core/meta/sh_inventory.lua @@ -150,7 +150,7 @@ end -- @treturn[1] Player Owning player -- @treturn[2] nil If no connected player owns this inventory function META:GetOwner() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetCharacter() and v:GetCharacter().id == self.owner) then return v end @@ -170,7 +170,7 @@ function META:SetOwner(owner, fullUpdate) if (SERVER) then if (fullUpdate) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetNetVar("char") == owner) then self:Sync(v, true) diff --git a/gamemode/core/meta/sh_item.lua b/gamemode/core/meta/sh_item.lua index 25e6df8af..767b7c44a 100644 --- a/gamemode/core/meta/sh_item.lua +++ b/gamemode/core/meta/sh_item.lua @@ -305,7 +305,7 @@ function ITEM:GetOwner() local id = self:GetID() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do local character = v:GetCharacter() if (character and character:GetInventory():GetItemByID(id)) then diff --git a/gamemode/core/sh_commands.lua b/gamemode/core/sh_commands.lua index 9e09e3ddd..fe62f8840 100644 --- a/gamemode/core/sh_commands.lua +++ b/gamemode/core/sh_commands.lua @@ -100,7 +100,7 @@ ix.command.Add("CharGiveFlag", { target:GiveFlags(flags) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("flagGive", client:GetName(), target:GetName(), flags) end @@ -125,7 +125,7 @@ ix.command.Add("CharTakeFlag", { target:TakeFlags(flags) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("flagTake", client:GetName(), flags, target:GetName()) end @@ -155,7 +155,7 @@ ix.command.Add("CharSetModel", { target:SetModel(model) target:GetPlayer():SetupHands() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("cChangeModel", client:GetName(), target:GetName(), model) end @@ -174,7 +174,7 @@ ix.command.Add("CharSetSkin", { target:SetData("skin", skin) target:GetPlayer():SetSkin(skin or 0) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("cChangeSkin", client:GetName(), target:GetName(), skin or 0) end @@ -267,7 +267,7 @@ ix.command.Add("CharSetName", { end, target:GetName()) end - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("cChangeName", client:GetName(), target:GetName(), newName) end @@ -322,7 +322,7 @@ ix.command.Add("CharKick", { target:Kick() end) - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("charKick", client:GetName(), target:GetName()) end @@ -346,7 +346,7 @@ ix.command.Add("CharBan", { target:Ban(minutes) target:Save() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("charBan", client:GetName(), target:GetName()) end @@ -372,7 +372,7 @@ ix.command.Add("CharUnban", { return "@charNotBanned" end - for _, v2 in player.Iterator() do + for _, v2 in ipairs(player.GetAll()) do if (self:OnCheckAccess(v2) or v2 == v:GetPlayer()) then v2:NotifyLocalized("charUnBan", client:GetName(), v:GetName()) end @@ -409,7 +409,7 @@ ix.command.Add("CharUnban", { updateQuery:Where("id", characterID) updateQuery:Execute() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v)) then v:NotifyLocalized("charUnBan", client:GetName(), name) end @@ -529,7 +529,7 @@ ix.command.Add("PlyWhitelist", { if (faction) then if (target:SetWhitelisted(faction.index, true)) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target) then v:NotifyLocalized("whitelist", client:GetName(), target:GetName(), L(faction.name, v)) end @@ -590,7 +590,7 @@ ix.command.Add("PlyUnwhitelist", { local targetPlayer = ix.util.FindPlayer(target) if (IsValid(targetPlayer) and targetPlayer:SetWhitelisted(faction.index, false)) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == targetPlayer) then v:NotifyLocalized("unwhitelist", client:GetName(), targetPlayer:GetName(), L(faction.name, v)) end @@ -617,7 +617,7 @@ ix.command.Add("PlyUnwhitelist", { updateQuery:Where("steamid", steamID64) updateQuery:Execute() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v)) then v:NotifyLocalized("unwhitelist", client:GetName(), target, L(faction.name, v)) end @@ -739,7 +739,7 @@ ix.command.Add("PlyTransfer", { faction:OnTransferred(target) end - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (self:OnCheckAccess(v) or v == target:GetPlayer()) then v:NotifyLocalized("cChangeFaction", client:GetName(), target:GetName(), L(faction.name, v)) end diff --git a/gamemode/core/sh_util.lua b/gamemode/core/sh_util.lua index 87f583ef0..6f436dc6e 100644 --- a/gamemode/core/sh_util.lua +++ b/gamemode/core/sh_util.lua @@ -251,7 +251,7 @@ function ix.util.FindPlayer(identifier, bAllowPatterns) identifier = string.PatternSafe(identifier) end - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (ix.util.StringMatches(v:Name(), identifier)) then return v end diff --git a/plugins/area/sv_hooks.lua b/plugins/area/sv_hooks.lua index 33197d59e..df81a4d67 100644 --- a/plugins/area/sv_hooks.lua +++ b/plugins/area/sv_hooks.lua @@ -38,7 +38,7 @@ function PLUGIN:PlayerSpawn(client) end function PLUGIN:AreaThink() - for _, client in player.Iterator() do + for _, client in ipairs(player.GetAll()) do local character = client:GetCharacter() if (!client:Alive() or !character) then diff --git a/plugins/doors/derma/cl_door.lua b/plugins/doors/derma/cl_door.lua index 81f063e49..b30fc70ad 100644 --- a/plugins/doors/derma/cl_door.lua +++ b/plugins/doors/derma/cl_door.lua @@ -48,7 +48,7 @@ function PANEL:SetDoor(door, access, door2) self.accessData = access self.door = door - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v != LocalPlayer() and v:GetCharacter()) then self.access:AddLine(v:Name(), L(ACCESS_LABELS[access[v] or 0])).player = v end diff --git a/plugins/doors/sv_plugin.lua b/plugins/doors/sv_plugin.lua index 4c193b400..210a4ad80 100644 --- a/plugins/doors/sv_plugin.lua +++ b/plugins/doors/sv_plugin.lua @@ -107,7 +107,7 @@ function PLUGIN:SaveDoorData() local data = {} local doors = {} - for _, v in ents.Iterator() do + for _, v in ipairs(ents.GetAll()) do if (v:IsDoor()) then doors[v:MapCreationID()] = v end diff --git a/plugins/observer.lua b/plugins/observer.lua index 628e41024..84fc2aa94 100644 --- a/plugins/observer.lua +++ b/plugins/observer.lua @@ -35,7 +35,7 @@ if (CLIENT) then !client:InVehicle() and CAMI.PlayerHasAccess(client, "Helix - Observer", nil)) then local scrW, scrH = ScrW(), ScrH() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v == client or !v:GetCharacter() or client:GetAimVector():Dot((v:GetPos() - client:GetPos()):GetNormal()) < 0.65) then continue end diff --git a/plugins/pac.lua b/plugins/pac.lua index a7ac31dc5..7185323c8 100644 --- a/plugins/pac.lua +++ b/plugins/pac.lua @@ -207,7 +207,7 @@ else end if (IsValid(pac.LocalPlayer)) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do local character = v:GetCharacter() if (character) then @@ -302,7 +302,7 @@ else end if (class:find("HL2MPRagdoll")) then - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v:GetRagdollEntity() == entity) then entity.objCache = v end diff --git a/plugins/recognition.lua b/plugins/recognition.lua index d29e7edb3..441deb131 100644 --- a/plugins/recognition.lua +++ b/plugins/recognition.lua @@ -170,7 +170,7 @@ else class = ix.chat.classes[class] - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (client != v and v:GetCharacter() and class:CanHear(client, v)) then targets[#targets + 1] = v end diff --git a/plugins/typing.lua b/plugins/typing.lua index 8a0402945..85fff867f 100644 --- a/plugins/typing.lua +++ b/plugins/typing.lua @@ -115,7 +115,7 @@ if (CLIENT) then local client = LocalPlayer() local position = client:GetPos() - for _, v in player.Iterator() do + for _, v in ipairs(player.GetAll()) do if (v == client) then continue end