MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / PackNetPlayer

Function PackNetPlayer

Source/pack.cpp:218–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void PackNetPlayer(PlayerNetPack &packed, const Player &player)
219{
220 packed.plrlevel = player.plrlevel;
221 packed.px = player.position.tile.x;
222 packed.py = player.position.tile.y;
223 CopyUtf8(packed.pName, player._pName, sizeof(packed.pName));
224 packed.pClass = static_cast<uint8_t>(player._pClass);
225 packed.pBaseStr = player._pBaseStr;
226 packed.pBaseMag = player._pBaseMag;
227 packed.pBaseDex = player._pBaseDex;
228 packed.pBaseVit = player._pBaseVit;
229 packed.pLevel = player._pLevel;
230 packed.pStatPts = player._pStatPts;
231 packed.pExperience = SDL_SwapLE32(player._pExperience);
232 packed.pHPBase = SDL_SwapLE32(player._pHPBase);
233 packed.pMaxHPBase = SDL_SwapLE32(player._pMaxHPBase);
234 packed.pManaBase = SDL_SwapLE32(player._pManaBase);
235 packed.pMaxManaBase = SDL_SwapLE32(player._pMaxManaBase);
236 packed.pMemSpells = SDL_SwapLE64(player._pMemSpells);
237
238 for (int i = 0; i < MAX_SPELLS; i++)
239 packed.pSplLvl[i] = player._pSplLvl[i];
240
241 for (int i = 0; i < NUM_INVLOC; i++)
242 PackNetItem(player.InvBody[i], packed.InvBody[i]);
243
244 packed._pNumInv = player._pNumInv;
245 for (int i = 0; i < packed._pNumInv; i++)
246 PackNetItem(player.InvList[i], packed.InvList[i]);
247
248 for (int i = 0; i < InventoryGridCells; i++)
249 packed.InvGrid[i] = player.InvGrid[i];
250
251 for (int i = 0; i < MaxBeltItems; i++)
252 PackNetItem(player.SpdList[i], packed.SpdList[i]);
253
254 packed.wReflections = SDL_SwapLE16(player.wReflections);
255 packed.pDiabloKillLevel = player.pDiabloKillLevel;
256 packed.pManaShield = player.pManaShield;
257 packed.friendlyMode = player.friendlyMode ? 1 : 0;
258 packed.isOnSetLevel = player.plrIsOnSetLevel;
259
260 packed.pStrength = SDL_SwapLE32(player._pStrength);
261 packed.pMagic = SDL_SwapLE32(player._pMagic);
262 packed.pDexterity = SDL_SwapLE32(player._pDexterity);
263 packed.pVitality = SDL_SwapLE32(player._pVitality);
264 packed.pHitPoints = SDL_SwapLE32(player._pHitPoints);
265 packed.pMaxHP = SDL_SwapLE32(player._pMaxHP);
266 packed.pMana = SDL_SwapLE32(player._pMana);
267 packed.pMaxMana = SDL_SwapLE32(player._pMaxMana);
268 packed.pDamageMod = SDL_SwapLE32(player._pDamageMod);
269 packed.pBaseToBlk = SDL_SwapLE32(player._pBaseToBlk);
270 packed.pIMinDam = SDL_SwapLE32(player._pIMinDam);
271 packed.pIMaxDam = SDL_SwapLE32(player._pIMaxDam);
272 packed.pIAC = SDL_SwapLE32(player._pIAC);
273 packed.pIBonusDam = SDL_SwapLE32(player._pIBonusDam);
274 packed.pIBonusToHit = SDL_SwapLE32(player._pIBonusToHit);
275 packed.pIBonusAC = SDL_SwapLE32(player._pIBonusAC);

Callers 2

TestNetPackValidationFunction · 0.85
SendPlayerInfoFunction · 0.85

Calls 2

CopyUtf8Function · 0.85
PackNetItemFunction · 0.85

Tested by 1

TestNetPackValidationFunction · 0.68