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

Function PackPlayer

Source/pack.cpp:150–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void PackPlayer(PlayerPack &packed, const Player &player)
151{
152 memset(&packed, 0, sizeof(packed));
153 packed.destAction = player.destAction;
154 packed.destParam1 = player.destParam1;
155 packed.destParam2 = player.destParam2;
156 packed.plrlevel = player.plrlevel;
157 packed.px = player.position.tile.x;
158 packed.py = player.position.tile.y;
159 if (gbVanilla) {
160 packed.targx = player.position.tile.x;
161 packed.targy = player.position.tile.y;
162 }
163 CopyUtf8(packed.pName, player._pName, sizeof(packed.pName));
164 packed.pClass = static_cast<uint8_t>(player._pClass);
165 packed.pBaseStr = player._pBaseStr;
166 packed.pBaseMag = player._pBaseMag;
167 packed.pBaseDex = player._pBaseDex;
168 packed.pBaseVit = player._pBaseVit;
169 packed.pLevel = player._pLevel;
170 packed.pStatPts = player._pStatPts;
171 packed.pExperience = SDL_SwapLE32(player._pExperience);
172 packed.pGold = SDL_SwapLE32(player._pGold);
173 packed.pHPBase = SDL_SwapLE32(player._pHPBase);
174 packed.pMaxHPBase = SDL_SwapLE32(player._pMaxHPBase);
175 packed.pManaBase = SDL_SwapLE32(player._pManaBase);
176 packed.pMaxManaBase = SDL_SwapLE32(player._pMaxManaBase);
177 packed.pMemSpells = SDL_SwapLE64(player._pMemSpells);
178
179 for (int i = 0; i < 37; i++) // Should be MAX_SPELLS but set to 37 to make save games compatible
180 packed.pSplLvl[i] = player._pSplLvl[i];
181 for (int i = 37; i < 47; i++)
182 packed.pSplLvl2[i - 37] = player._pSplLvl[i];
183
184 for (int i = 0; i < NUM_INVLOC; i++)
185 PackItem(packed.InvBody[i], player.InvBody[i], gbIsHellfire);
186
187 packed._pNumInv = player._pNumInv;
188 for (int i = 0; i < packed._pNumInv; i++)
189 PackItem(packed.InvList[i], player.InvList[i], gbIsHellfire);
190
191 for (int i = 0; i < InventoryGridCells; i++)
192 packed.InvGrid[i] = player.InvGrid[i];
193
194 for (int i = 0; i < MaxBeltItems; i++)
195 PackItem(packed.SpdList[i], player.SpdList[i], gbIsHellfire);
196
197 packed.wReflections = SDL_SwapLE16(player.wReflections);
198 packed.pDamAcFlags = SDL_SwapLE32(static_cast<uint32_t>(player.pDamAcFlags));
199 packed.pDiabloKillLevel = SDL_SwapLE32(player.pDiabloKillLevel);
200 packed.bIsHellfire = gbIsHellfire ? 1 : 0;
201}
202
203void PackNetItem(const Item &item, ItemNetPack &packedItem)
204{

Callers 2

pfile_write_heroFunction · 0.85
pfile_ui_save_createFunction · 0.85

Calls 2

CopyUtf8Function · 0.85
PackItemFunction · 0.85

Tested by

no test coverage detected