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

Function sync_all_monsters

Source/sync.cpp:253–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251} // namespace
252
253uint32_t sync_all_monsters(byte *pbBuf, uint32_t dwMaxLen)
254{
255 if (ActiveMonsterCount < 1) {
256 return dwMaxLen;
257 }
258 if (dwMaxLen < sizeof(TSyncHeader) + sizeof(TSyncMonster)) {
259 return dwMaxLen;
260 }
261 if (MyPlayer->_pLvlChanging) {
262 return dwMaxLen;
263 }
264
265 auto *pHdr = (TSyncHeader *)pbBuf;
266 pbBuf += sizeof(TSyncHeader);
267 dwMaxLen -= sizeof(TSyncHeader);
268
269 pHdr->bCmd = CMD_SYNCDATA;
270 pHdr->bLevel = GetLevelForMultiplayer(*MyPlayer);
271 pHdr->wLen = 0;
272 SyncPlrInv(pHdr);
273 assert(dwMaxLen <= 0xffff);
274 SyncOneMonster();
275
276 for (size_t i = 0; i < ActiveMonsterCount && dwMaxLen >= sizeof(TSyncMonster); i++) {
277 auto &monsterSync = *reinterpret_cast<TSyncMonster *>(pbBuf);
278 bool sync = false;
279 if (i < 2) {
280 sync = SyncMonsterActive2(monsterSync);
281 }
282 if (!sync) {
283 sync = SyncMonsterActive(monsterSync);
284 }
285 if (!sync) {
286 break;
287 }
288 pbBuf += sizeof(TSyncMonster);
289 pHdr->wLen += sizeof(TSyncMonster);
290 dwMaxLen -= sizeof(TSyncMonster);
291 }
292 pHdr->wLen = SDL_SwapLE16(pHdr->wLen);
293
294 return dwMaxLen;
295}
296
297uint32_t OnSyncData(const TCmd *pCmd, size_t pnum)
298{

Callers 1

NetSendHiPriFunction · 0.85

Calls 5

GetLevelForMultiplayerFunction · 0.85
SyncPlrInvFunction · 0.85
SyncOneMonsterFunction · 0.85
SyncMonsterActive2Function · 0.85
SyncMonsterActiveFunction · 0.85

Tested by

no test coverage detected