Skip to content

Commit

Permalink
tweak(gamestate/server): Parse CPickupCreationDataNode
Browse files Browse the repository at this point in the history
(Incomplete) Parsing for CPickupCreationDataNode to return a (custom) model hash for pickups on 'GetModelHash'.
  • Loading branch information
tens0rfl0w committed Nov 18, 2024
1 parent 4f7d5fa commit 2b648f7
Showing 1 changed file with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,51 @@ struct CPedSectorPosMapNode : GenericSerializeDataNode<CPedSectorPosMapNode>
struct CPedSectorPosNavMeshNode { };
struct CPedInventoryDataNode { };
struct CPedTaskSequenceDataNode { };
struct CPickupCreationDataNode { };

struct CPickupCreationDataNode
{
bool hasPlacement;
uint32_t pickupHash;
uint32_t amount;
uint32_t customModelHash;

bool Parse(SyncParseState& state)
{
hasPlacement = state.buffer.ReadBit();
if (hasPlacement)
{
// CGameScriptObjInfo
const uint32_t scriptObjectId = state.buffer.Read<uint32_t>(32);
const int hostTokenLength = state.buffer.ReadBit() ? 16 : 3;
const uint32_t hostToken = state.buffer.Read<uint32_t>(hostTokenLength);
}
else
{
pickupHash = state.buffer.Read<uint32_t>(32);
}

if(state.buffer.ReadBit())
{
amount = state.buffer.Read<uint32_t>(32);
}
else
{
amount = 0;
}

if (state.buffer.ReadBit())
{
customModelHash = state.buffer.Read<uint32_t>(32);
}
else
{
customModelHash = 0;
}

return true;
}
};

struct CPickupScriptGameStateNode { };
struct CPickupSectorPosNode { };

Expand Down Expand Up @@ -4138,6 +4182,14 @@ struct SyncTree : public SyncTreeBaseImpl<TNode, false>
return true;
}

auto [hasPicn, pickupCreationNode] = this->template GetData<CPickupCreationDataNode>();

if (hasPicn)
{
*modelHash = pickupCreationNode->customModelHash;
return true;
}

return false;
}

Expand Down

0 comments on commit 2b648f7

Please sign in to comment.