Browse Source

Add connection state and player state enums

pull/831/head^2
Anders Jenbo 6 years ago
parent
commit
8272a37aea
  1. 7
      3rdParty/Storm/Source/storm.h
  2. 2
      Source/monster.cpp
  3. 2
      Source/msg.cpp
  4. 18
      Source/multi.cpp

7
3rdParty/Storm/Source/storm.h vendored

@ -86,6 +86,13 @@ struct CCritSect {
#define GAMESTATE_STARTED 0x08
#define GAMESTATE_REPLAY 0x80
#define PS_CONNECTED 0x10000
#define PS_TURN_ARRIVED 0x20000
#define PS_ACTIVE 0x40000
#define LEAVE_ENDING 0x40000004
#define LEAVE_DROP 0x40000006
#if defined(__GNUC__) || defined(__cplusplus)
extern "C" {
#endif

2
Source/monster.cpp

@ -2534,7 +2534,7 @@ void DoEnding()
int musicVolume;
if (gbMaxPlayers > 1) {
SNetLeaveGame(0x40000004);
SNetLeaveGame(LEAVE_ENDING);
}
music_stop();

2
Source/msg.cpp

@ -1135,7 +1135,7 @@ DWORD ParseCmd(int pnum, TCmd *pCmd)
}
if (pCmd->bCmd < CMD_DLEVEL_0 || pCmd->bCmd > CMD_DLEVEL_END) {
SNetDropPlayer(pnum, 0x40000006);
SNetDropPlayer(pnum, LEAVE_DROP);
return 0;
}

18
Source/multi.cpp

@ -215,7 +215,7 @@ void multi_msg_countdown()
int i;
for (i = 0; i < MAX_PLRS; i++) {
if (player_state[i] & 0x20000) {
if (player_state[i] & PS_TURN_ARRIVED) {
if (gdwMsgLenTbl[i] == 4)
multi_parse_turn(i, *(DWORD *)glpMsgTbl[i]);
}
@ -242,7 +242,7 @@ void multi_handle_turn_upper_bit(int pnum)
int i;
for (i = 0; i < MAX_PLRS; i++) {
if (player_state[i] & 0x10000 && i != pnum)
if (player_state[i] & PS_CONNECTED && i != pnum)
break;
}
@ -290,11 +290,11 @@ void multi_player_left_msg(int pnum, int left)
if (left) {
pszFmt = "Player '%s' just left the game";
switch (sgdwPlayerLeftReasonTbl[pnum]) {
case 0x40000004:
case LEAVE_ENDING:
pszFmt = "Player '%s' killed Diablo and left the game!";
gbSomebodyWonGameKludge = TRUE;
break;
case 0x40000006:
case LEAVE_DROP:
pszFmt = "Player '%s' dropped due to timeout";
break;
}
@ -397,11 +397,11 @@ void multi_begin_timeout()
bGroupCount = 0;
for (i = 0; i < MAX_PLRS; i++) {
nState = player_state[i];
if (nState & 0x10000) {
if (nState & PS_CONNECTED) {
if (nLowestPlayer == -1) {
nLowestPlayer = i;
}
if (nState & 0x40000) {
if (nState & PS_ACTIVE) {
bGroupPlayers++;
if (nLowestActive == -1) {
nLowestActive = i;
@ -444,8 +444,8 @@ void multi_check_drop_player()
int i;
for (i = 0; i < MAX_PLRS; i++) {
if (!(player_state[i] & 0x40000) && player_state[i] & 0x10000) {
SNetDropPlayer(i, 0x40000006);
if (!(player_state[i] & PS_ACTIVE) && player_state[i] & PS_CONNECTED) {
SNetDropPlayer(i, LEAVE_DROP);
}
}
}
@ -665,7 +665,7 @@ void __stdcall multi_handle_events(_SNETEVENT *pEvt)
if (data && (DWORD)pEvt->databytes >= 4)
LeftReason = data[0];
sgdwPlayerLeftReasonTbl[pEvt->playerid] = LeftReason;
if (LeftReason == 0x40000004)
if (LeftReason == LEAVE_ENDING)
gbSomebodyWonGameKludge = TRUE;
sgbSendDeltaTbl[pEvt->playerid] = FALSE;
dthread_remove_player(pEvt->playerid);

Loading…
Cancel
Save