mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
basic protocol 953 support, logging in real tibia!
This commit is contained in:
@@ -223,6 +223,32 @@ uint64 FileStream::getU64()
|
||||
return v;
|
||||
}
|
||||
|
||||
std::string FileStream::getString()
|
||||
{
|
||||
std::string str;
|
||||
int len = getU16();
|
||||
if(len > 0 && len < 8192) {
|
||||
char buffer[8192];
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
else
|
||||
str = std::string(buffer, len);
|
||||
} else {
|
||||
if(m_cacheReadPos+len > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
return 0;
|
||||
}
|
||||
|
||||
str = std::string((char*)&m_cacheBuffer[m_cacheReadPos], len);
|
||||
m_cacheReadPos += len;
|
||||
}
|
||||
} else {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void FileStream::addU8(uint8 v)
|
||||
{
|
||||
if(PHYSFS_write(m_fileHandle, &v, 1, 1) != 1)
|
||||
|
@@ -53,6 +53,7 @@ public:
|
||||
uint16 getU16();
|
||||
uint32 getU32();
|
||||
uint64 getU64();
|
||||
std::string getString();
|
||||
void addU8(uint8 v);
|
||||
void addU16(uint8 v);
|
||||
void addU32(uint8 v);
|
||||
|
@@ -124,9 +124,17 @@ void Protocol::internalRecvData(uint8* buffer, uint16 size)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_xteaEncryptionEnabled && !xteaDecrypt(m_inputMessage)) {
|
||||
logTraceError("failed to decrypt message");
|
||||
return;
|
||||
if(m_xteaEncryptionEnabled) {
|
||||
if(!xteaDecrypt(m_inputMessage)) {
|
||||
logTraceError("failed to decrypt message");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int size = m_inputMessage.getU16();
|
||||
if(size != m_inputMessage.getUnreadSize()) {
|
||||
logTraceError("invalid message size");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
onRecv(m_inputMessage);
|
||||
|
Reference in New Issue
Block a user