forked from metin2/server
Fixed network handling of phase change, players can log ingame, but get disconnected after a few minutes with a sequence error.
This commit is contained in:
parent
181f37cccd
commit
8c40c9f92e
|
@ -699,7 +699,7 @@ enum EMisc2
|
||||||
INVENTORY_AND_EQUIP_SLOT_MAX = BELT_INVENTORY_SLOT_END,
|
INVENTORY_AND_EQUIP_SLOT_MAX = BELT_INVENTORY_SLOT_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef struct SItemPos
|
typedef struct SItemPos
|
||||||
{
|
{
|
||||||
|
@ -778,6 +778,6 @@ typedef enum
|
||||||
SHOP_COIN_TYPE_SECONDARY_COIN,
|
SHOP_COIN_TYPE_SECONDARY_COIN,
|
||||||
} EShopCoinType;
|
} EShopCoinType;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,7 +37,7 @@ void DescReadHandler(bufferevent *bev, void *ctx) {
|
||||||
d->SetPhase(PHASE_CLOSE);
|
d->SetPhase(PHASE_CLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (d->ProcessInput() < 0)
|
else if (!d->ProcessInput())
|
||||||
{
|
{
|
||||||
d->SetPhase(PHASE_CLOSE);
|
d->SetPhase(PHASE_CLOSE);
|
||||||
}
|
}
|
||||||
|
@ -277,42 +277,41 @@ bool DESC::Setup(event_base * evbase, evutil_socket_t fd, const sockaddr * c_rSo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DESC::ProcessInput()
|
bool DESC::ProcessInput()
|
||||||
{
|
{
|
||||||
evbuffer *input = bufferevent_get_input(m_bufevent);
|
evbuffer *input = bufferevent_get_input(m_bufevent);
|
||||||
if (input == nullptr) {
|
if (input == nullptr) {
|
||||||
sys_err("DESC::ProcessInput : nil input buffer");
|
sys_err("DESC::ProcessInput : nil input buffer");
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bytes_read = evbuffer_get_length(input);
|
if (!m_pInputProcessor) {
|
||||||
|
sys_err("no input processor");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (bytes_read < 0)
|
// If CInputProcessor::Process returns false, then we switched to another phase, and we can continue reading
|
||||||
return -1;
|
bool doContinue = true;
|
||||||
else if (bytes_read == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!m_pInputProcessor)
|
do {
|
||||||
sys_err("no input processor");
|
size_t bytes_read = evbuffer_get_length(input);
|
||||||
|
|
||||||
|
// No data to read, we can continue
|
||||||
|
if (bytes_read == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
// Get the received data
|
// Get the received data
|
||||||
void * data = evbuffer_pullup(input, bytes_read);
|
void * data = evbuffer_pullup(input, bytes_read);
|
||||||
|
|
||||||
int iBytesProceed = 0;
|
int iBytesProceed = 0; // The number of bytes that have been processed
|
||||||
|
doContinue = m_pInputProcessor->Process(this, data, bytes_read, iBytesProceed);
|
||||||
|
|
||||||
// false가 리턴 되면 다른 phase로 바뀐 것이므로 다시 프로세스로 돌입한다!
|
|
||||||
while (!m_pInputProcessor->Process(this, data, bytes_read, iBytesProceed))
|
|
||||||
{
|
|
||||||
// Flush the read bytes from the network buffer
|
// Flush the read bytes from the network buffer
|
||||||
evbuffer_drain(input, iBytesProceed);
|
evbuffer_drain(input, iBytesProceed);
|
||||||
iBytesProceed = 0;
|
iBytesProceed = 0;
|
||||||
}
|
} while(!doContinue);
|
||||||
|
|
||||||
// Flush the read bytes from the network buffer
|
return true;
|
||||||
evbuffer_drain(input, iBytesProceed);
|
|
||||||
|
|
||||||
return bytes_read;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DESC::RawPacket(const void * c_pvData, int iSize)
|
bool DESC::RawPacket(const void * c_pvData, int iSize)
|
||||||
|
|
|
@ -95,7 +95,7 @@ class DESC
|
||||||
bool RawPacket(const void * c_pvData, int iSize);
|
bool RawPacket(const void * c_pvData, int iSize);
|
||||||
void Packet(const void * c_pvData, int iSize);
|
void Packet(const void * c_pvData, int iSize);
|
||||||
|
|
||||||
int ProcessInput(); // returns -1 if error
|
bool ProcessInput(); // returns false if error
|
||||||
|
|
||||||
CInputProcessor * GetInputProcessor() { return m_pInputProcessor; }
|
CInputProcessor * GetInputProcessor() { return m_pInputProcessor; }
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes,
|
||||||
{
|
{
|
||||||
lpDesc->push_seq(bHeader, bSeq);
|
lpDesc->push_seq(bHeader, bSeq);
|
||||||
lpDesc->SetNextSequence();
|
lpDesc->SetNextSequence();
|
||||||
//sys_err("SEQUENCE %x match %u next %u header %u", lpDesc, bSeq, lpDesc->GetSequence(), bHeader);
|
sys_err("SEQUENCE %x match %u next %u header %u", lpDesc, bSeq, lpDesc->GetSequence(), bHeader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2311,4 +2311,5 @@ typedef struct SPacketGCStateCheck
|
||||||
} TPacketGCStateCheck;
|
} TPacketGCStateCheck;
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue