CyberEngineTweaks icon indicating copy to clipboard operation
CyberEngineTweaks copied to clipboard

Components bug related to props

Open WSSDude opened this issue 3 years ago • 3 comments

Reported by @striderxfossility inside #497


Also there is a BUG in these components related to props.

For example:

local tpp = player:FindComponentByName(CName.new("TPPRepresentation"))
print(tpp.detachedObjectInfo[1].itemTDBID) -- prints "Items.PlayerFppHead" CName
tpp.detachedObjectInfo[1].itemTDBID = TweakDBID.new("Items.PlayerWaTppHead")

print(tpp.detachedObjectInfo[1].itemTDBID) -- Still prints "Items.PlayerFppHead" CName

WORKAROUND FOR NOW:

local tpp     = player:FindComponentByName(CName.new("TPPRepresentation"))
local obj     = NewObject('gameFppRepDetachedObjectInfo')
obj.slotID    = TweakDBID.new("TppHead")
obj.itemTDBID = TweakDBID.new("Items.PlayerWaTppHead")

tpp.detachedObjectInfo = {obj}

print(tpp.detachedObjectInfo[1].itemTDBID) -- now prints "Items.PlayerWaTppHead" CName

WSSDude avatar Feb 17 '21 11:02 WSSDude

This has to do with the fact that we copy by value arrays in ToLua, it's a broader project where we need to wrap internal arrays instead of converting to Lua arrays

maximegmd avatar Feb 17 '21 16:02 maximegmd

If you ever decide to "wrap internal arrays instead of converting to Lua arrays": TweakDB::GetFlat can return an array, It shouldn't be wrapped. A Flat shouldn't be modified outside of TweakDB::SetFlat https://github.com/yamashi/CyberEngineTweaks/blob/47f04d660b521467f5d1279986c48717079430cb/src/reverse/TweakDB.cpp#L176-L193

0xSombra avatar Feb 18 '21 01:02 0xSombra

Got it, thanks for the info :)

maximegmd avatar Feb 18 '21 01:02 maximegmd