-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPacketProcResult.cpp
91 lines (80 loc) · 2.03 KB
/
CPacketProcResult.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "CPacketProcResult.h"
#include "ext.h"
//> public >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BOOL CPacketProcResult::Init(CNetworkSession *pNWSess, CPacketProcPhase* pPrevPhase)
{
if (!CPacketProcPhase::Init(pNWSess, pPrevPhase))
return FALSE;
m_eGamePhase = GAME_PHASE_RESULT;
// 接続済みユーザの状態を切り替える
int cnt=0;
int nSearchIndex = 0;
for(ptype_session pSess=pNWSess->GetSessionFirst(&nSearchIndex);
pSess;
pSess=pNWSess->GetSessionNext(&nSearchIndex))
{
// 認証済みか
if (pSess->connect_state != CONN_STATE_AUTHED) continue;
pSess->frame_count = 0;
// 切り替え
pSess->obj_state = OBJ_STATE_RESULT_CONFIRMING;
}
return TRUE;
}
//> private >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//> 受信パケット処理
BOOL CPacketProcResult::PacketProc(BYTE *data, ptype_session sess)
{
BOOL ret = FALSE;
// 認証済み以外処理しない
if (sess->connect_state != CONN_STATE_AUTHED)
return ret;
switch ( data[PACKET_HEADER_INDEX] )
{
case PK_CMD_CONFIRM:
ret = SetConfirmed(sess);
break;
default:
break;
}
return ret;
}
//< 受信パケット処理
//> 切断処理
BOOL CPacketProcResult::DisconnectSession(ptype_session sess)
{
BOOL ret = CPacketProcPhase::DisconnectSession(sess);
sess->entity = 0;
sess->frame_count = 0;
sess->game_ready = 0;
sess->live_count = 0;
return ret;
}
//< 切断処理
// 結果確認パケット処理
BOOL CPacketProcResult::SetConfirmed(ptype_session sess)
{
// WCHAR msglog[1024];
// SafePrintf(msglog, 1023, L"[%d]LoadComplete", sess->obj_no);
// AddMessageLog(msglog);
if (sess->connect_state != CONN_STATE_AUTHED)
return FALSE;
sess->obj_state = OBJ_STATE_RESULT_CONFIRMED;
BOOL bAllConfirmed = TRUE;
int nSearchIndex = 0;
for(ptype_session pSess=p_pNWSess->GetSessionFirst(&nSearchIndex);
pSess;
pSess=p_pNWSess->GetSessionNext(&nSearchIndex))
{
// 認証済みか
if (pSess->connect_state != CONN_STATE_AUTHED) continue;
if (pSess->obj_state != OBJ_STATE_RESULT_CONFIRMED)
{
bAllConfirmed = FALSE;
break;
}
}
if (bAllConfirmed)
m_eGamePhase = GAME_PHASE_ROOM;
return TRUE;
}