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

Function recv_plrinfo

Source/multi.cpp:864–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv)
865{
866 char *szEvent;
867
868 if (myplr == pnum) {
869 return;
870 }
871 /// ASSERT: assert((DWORD)pnum < MAX_PLRS);
872
873 if (sgwPackPlrOffsetTbl[pnum] != p->wOffset) {
874 sgwPackPlrOffsetTbl[pnum] = 0;
875 if (p->wOffset != 0) {
876 return;
877 }
878 }
879 if (!recv && sgwPackPlrOffsetTbl[pnum] == 0) {
880 multi_send_pinfo(pnum, CMD_ACK_PLRINFO);
881 }
882
883 memcpy((char *)&netplr[pnum] + p->wOffset, &p[1], p->wBytes); /* todo: cast? */
884 sgwPackPlrOffsetTbl[pnum] += p->wBytes;
885 if (sgwPackPlrOffsetTbl[pnum] != sizeof(*netplr)) {
886 return;
887 }
888
889 sgwPackPlrOffsetTbl[pnum] = 0;
890 multi_player_left_msg(pnum, 0);
891 plr[pnum]._pGFXLoad = 0;
892 UnPackPlayer(&netplr[pnum], pnum, TRUE);
893
894 if (!recv) {
895 return;
896 }
897
898 plr[pnum].plractive = TRUE;
899 gbActivePlayers++;
900
901 if (sgbPlayerTurnBitTbl[pnum] != 0) {
902 szEvent = "Player '%s' (level %d) just joined the game";
903 } else {
904 szEvent = "Player '%s' (level %d) is already in the game";
905 }
906 EventPlrMsg(szEvent, plr[pnum]._pName, plr[pnum]._pLevel);
907
908 LoadPlrGFX(pnum, PFILE_STAND);
909 SyncInitPlr(pnum);
910
911 if (plr[pnum].plrlevel == currlevel) {
912 if (plr[pnum]._pHitPoints >> 6 > 0) {
913 StartStand(pnum, 0);
914 } else {
915 plr[pnum]._pgfxnum = 0;
916 LoadPlrGFX(pnum, PFILE_DEATH);
917 plr[pnum]._pmode = PM_DEATH;
918 NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth);
919 plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1;
920 plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen;
921 dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER;

Callers 1

On_SEND_PLRINFOFunction · 0.85

Calls 8

multi_send_pinfoFunction · 0.85
multi_player_left_msgFunction · 0.85
UnPackPlayerFunction · 0.85
EventPlrMsgFunction · 0.85
LoadPlrGFXFunction · 0.85
SyncInitPlrFunction · 0.85
StartStandFunction · 0.85
NewPlrAnimFunction · 0.85

Tested by

no test coverage detected