| 101 | } |
| 102 | |
| 103 | void CharacterSyncCustomStats(esv::Character * character, eoc::CustomStatsComponent * stats, |
| 104 | FixedString statKey, int statValue) |
| 105 | { |
| 106 | eocnet::CustomStatsSyncMessage statSyncMsg; |
| 107 | if (stats == nullptr) { |
| 108 | statSyncMsg.MessageId = NetMessage::NETMSG_CUSTOM_STATS_CREATE; |
| 109 | } else { |
| 110 | statSyncMsg.MessageId = NetMessage::NETMSG_CUSTOM_STATS_UPDATE; |
| 111 | } |
| 112 | |
| 113 | // FIXME - memory leak! |
| 114 | statSyncMsg.Stats.Set.Buf = GameAlloc<eocnet::CustomStatsSyncInfo>(1); |
| 115 | statSyncMsg.Stats.Set.Capacity = 1; |
| 116 | statSyncMsg.Stats.Set.Size = 1; |
| 117 | |
| 118 | auto entityWorld = GetEntityWorld(); |
| 119 | auto netComponent = entityWorld->GetNetComponentByEntityHandle(character->Base.EntityObjectHandle); |
| 120 | |
| 121 | auto & stat = statSyncMsg.Stats.Set.Buf[0]; |
| 122 | stat.NetId = netComponent->NetID; |
| 123 | stat.Stats.Init(0x25); |
| 124 | |
| 125 | if (stats != nullptr) { |
| 126 | stats->StatValues.Iterate([&stat](FixedString key, int value) { |
| 127 | stat.Stats.Add(key, value); |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | stat.Stats.Add(statKey, statValue); |
| 132 | |
| 133 | ProcessCustomStatsMessage(&statSyncMsg); |
| 134 | } |
| 135 | |
| 136 | void CharacterSetCustomStat(OsiArgumentDesc const & args) |
| 137 | { |
no test coverage detected