Files
Sun1602/Server/Common/TempServerSession.cpp
git 9cb257e7ae Add GameClients drops and keep current 1602 source work.
CN1602 is the local client. KR is the official tree with unpacked Data, System, and Sound. Packed .wpk files stay off git.
2026-08-30 23:24:31 +03:00

73 lines
2.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "./TempServerSession.h"
#include <ServerGlobal.h>
#include <PacketStruct_ServerCommon.h>
#include "./ServerFrame.h"
//==================================================================================================
__IMPL_CUSTOMPOOL_PTR(TempServerSession);
//==================================================================================================
TempServerSession::TempServerSession(void)
{
}
TempServerSession::~TempServerSession(void)
{
}
void TempServerSession::Init()
{
ServerSession::Init();
m_bFirst = TRUE;
}
void TempServerSession::OnRecv(BYTE* msg, WORD msg_size)
{
ASSERT(m_bFirst != false);
m_bFirst = false;
// NOTE: f110617.1L, After using dual buffer for reception, ... hummmm. ...
MSG_SERVER_TYPE* recv_msg = (MSG_SERVER_TYPE *)msg;
const bool valid_message = recv_msg->m_byCategory == SERVERCOMMON &&
recv_msg->m_byProtocol == SERVERCOMMON_SERVERTYPE &&
sizeof(*recv_msg) == msg_size;
if (valid_message == false)
{
SUNLOG(eCRITICAL_LOG,
_T("|["__FUNCTION__"]|Msg=unexpected first message, ")
_T("C:P=%03d:%03d, size=%d|"),
recv_msg->m_byCategory, recv_msg->m_byProtocol, msg_size);
return;
};
//----------------------------------------------------------------------------------------------
ServerFrame* const server_frame = GetFrame();
// <Waverix> [9/8/2006]
// ??·?∑? ??? GameServer?? ∑? ServerType ??? ∑??? ????? ??? ??????.
// ??ǎ? ?∽?í ?【?々 ∑???? ?????? ∑??·? ????. 【】·【??... ·?【】ⅴ? ??? ??ǎ???
ServerSession* new_session = NULL;
const eSERVER_TYPE server_type = static_cast<eSERVER_TYPE>(recv_msg->m_byServerType);
if (DWORD(server_type) < DWORD(MAX_SERVER)) {
new_session = server_frame->AllocServerSession(server_type);
};
if (new_session == NULL)
{
Disconnect();
SUNLOG(eCRITICAL_LOG, _T("|["__FUNCTION__"]|Msg=unknown server type (%d)"), server_type);
return;
}
//
Redirect(new_session);
//
// TempServerSession?? ????ì? ??·?? ? ??ⅴō?í??!
DWORD session_index = GetSessionIndex();
server_frame->RemoveSession(session_index);
server_frame->FreeServerSession(this);
//
new_session->OnRedirect(session_index, recv_msg);
}