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

Function sync_all_monsters

Source/sync.cpp:11–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9int sgnSyncPInv;
10
11DWORD sync_all_monsters(const BYTE *pbBuf, DWORD dwMaxLen)
12{
13 TSyncHeader *pHdr;
14 int i;
15 BOOL sync;
16
17 if (nummonsters < 1) {
18 return dwMaxLen;
19 }
20 if (dwMaxLen < sizeof(*pHdr) + sizeof(TSyncMonster)) {
21 return dwMaxLen;
22 }
23
24 pHdr = (TSyncHeader *)pbBuf;
25 pbBuf += sizeof(*pHdr);
26 dwMaxLen -= sizeof(*pHdr);
27
28 pHdr->bCmd = CMD_SYNCDATA;
29 pHdr->bLevel = currlevel;
30 pHdr->wLen = 0;
31 SyncPlrInv(pHdr);
32 /// ASSERT: assert(dwMaxLen <= 0xffff);
33 sync_one_monster();
34
35 for (i = 0; i < nummonsters && dwMaxLen >= sizeof(TSyncMonster); i++) {
36 sync = FALSE;
37 if (i < 2) {
38 sync = sync_monster_active2((TSyncMonster *)pbBuf);
39 }
40 if (!sync) {
41 sync = sync_monster_active((TSyncMonster *)pbBuf);
42 }
43 if (!sync) {
44 break;
45 }
46 pbBuf += sizeof(TSyncMonster);
47 pHdr->wLen += sizeof(TSyncMonster);
48 dwMaxLen -= sizeof(TSyncMonster);
49 }
50
51 return dwMaxLen;
52}
53
54void sync_one_monster()
55{

Callers 1

NetSendHiPriFunction · 0.85

Calls 4

SyncPlrInvFunction · 0.85
sync_one_monsterFunction · 0.85
sync_monster_active2Function · 0.85
sync_monster_activeFunction · 0.85

Tested by

no test coverage detected