Added better sanity check for entity object accesses
This commit is contained in:
1 parent
522aa99465
commit
82d255c5d0
2 files changed
+11
-4
No files matched your search
+10
-3
@@ -652,8 +652,10 @@ end
|
|||||||
|
|
||||||
-- check if an entity is part of the describable entities
|
-- check if an entity is part of the describable entities
|
||||||
function EID:hasDescription(entity)
|
function EID:hasDescription(entity)
|
||||||
if entity and EID:IsGridEntity(entity) then
|
if not EID:EntitySanityCheck(entity) then return false end
|
||||||
if entity and EID.GridEntityWhitelist[entity:GetType()] then
|
|
||||||
|
if EID:IsGridEntity(entity) then
|
||||||
|
if EID.GridEntityWhitelist[entity:GetType()] then
|
||||||
for _, func in ipairs(EID.GridEntityWhitelist[entity:GetType()]) do
|
for _, func in ipairs(EID.GridEntityWhitelist[entity:GetType()]) do
|
||||||
if func(entity) then
|
if func(entity) then
|
||||||
return true
|
return true
|
||||||
@@ -1431,7 +1433,7 @@ function EID:getScreenSize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function EID:getEntityData(entity, str)
|
function EID:getEntityData(entity, str)
|
||||||
if entity ~= nil and not EID:IsGridEntity(entity) and entity:GetData() ~= nil then
|
if EID:EntitySanityCheck(entity) and not EID:IsGridEntity(entity) and entity:GetData() ~= nil then
|
||||||
return entity:GetData()[str]
|
return entity:GetData()[str]
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
@@ -1927,6 +1929,11 @@ function EID:IsGridEntity(entity)
|
|||||||
return entity.Type == nil
|
return entity.Type == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns true, if the given entity is a valid game object and actually is something useful to process. Sometimes the game sends weird shit so this function is needed to catch bullshit
|
||||||
|
function EID:EntitySanityCheck(entity)
|
||||||
|
return entity ~= nil and type(entity) == "userdata"
|
||||||
|
end
|
||||||
|
|
||||||
-- returns true if the given pill color was used at least once in this game
|
-- returns true if the given pill color was used at least once in this game
|
||||||
function EID:WasPillUsed(pillColor)
|
function EID:WasPillUsed(pillColor)
|
||||||
return EID.UsedPillColors[tostring(pillColor)] ~= nil
|
return EID.UsedPillColors[tostring(pillColor)] ~= nil
|
||||||
|
|||||||
+1
-1
@@ -899,7 +899,7 @@ EID.ItemPoolTypeToMarkup = { [0] = "{{ItemPoolTreasure}}", "{{ItemPoolShop}}", "
|
|||||||
-- If a function returns a value, it will be used as the offset
|
-- If a function returns a value, it will be used as the offset
|
||||||
EID.LocalModePositionOffset = {
|
EID.LocalModePositionOffset = {
|
||||||
Default = Vector(0, 20),
|
Default = Vector(0, 20),
|
||||||
Shop = function(entity) if entity and not EID:IsGridEntity(entity) and entity:ToPickup() and entity:ToPickup():IsShopItem() then return Vector(0, 35) end end,
|
Shop = function(entity) if EID:EntitySanityCheck(entity) and not EID:IsGridEntity(entity) and entity:ToPickup() and entity:ToPickup():IsShopItem() then return Vector(0, 35) end end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Character IDs that aren't allowed to have Red Health: ???, The Lost, The Soul
|
-- Character IDs that aren't allowed to have Red Health: ???, The Lost, The Soul
|
||||||
|
|||||||
Reference in new issue
Block a user