diff --git a/Source/Contents/Effects/EffectPrim.h b/Source/Contents/Effects/EffectPrim.h index 0c3ed849..7c2138fa 100644 --- a/Source/Contents/Effects/EffectPrim.h +++ b/Source/Contents/Effects/EffectPrim.h @@ -16,7 +16,7 @@ struct CEffectPrim : CRenderObject { bool UpdateStoneCurse(); void Prim3DCircle(); bool Prim3DParticle(); - bool UpdateCoin(); + bool Prim3DParticleGravity(); bool Prim3DParticleNoMaster(); bool Prim3DParticleOrbit(); bool Prim3DParticleSpline(); diff --git a/Source/Contents/Effects/EffectPrimitiveMotion.cpp b/Source/Contents/Effects/EffectPrimitiveMotion.cpp index 1f583fa1..d2adee68 100644 --- a/Source/Contents/Effects/EffectPrimitiveMotion.cpp +++ b/Source/Contents/Effects/EffectPrimitiveMotion.cpp @@ -2389,7 +2389,7 @@ bool CEffectPrim::Prim3DParticle() { // OFFSET: 0x00BB75B0 // FUNCTION: fn_19780 -bool CEffectPrim::UpdateCoin() { +bool CEffectPrim::Prim3DParticleGravity() { CGameMode* mode = static_cast(g_modeMgr.GetGameMode()); const CRagEffect* master = this->state.master; this->state.origin.z = master->render.position.z + this->state.velocity.z; diff --git a/Source/Network/Connection/Connection.cpp b/Source/Network/Connection/Connection.cpp index e1b631b5..53da3535 100644 --- a/Source/Network/Connection/Connection.cpp +++ b/Source/Network/Connection/Connection.cpp @@ -15,9 +15,9 @@ // OFFSET: 0x00C7C110 // FUNCTION: fn_20382 CConnection::CConnection() : m_socket(INVALID_SOCKET), m_deferred(0), m_sendDeadline(0) { - this->m_input.Reset(0xA000); - this->m_output.Reset(0xA000); - this->m_pending.Reset(0xA000); + this->m_input.Init(0xA000); + this->m_output.Init(0xA000); + this->m_pending.Init(0xA000); } // OFFSET: 0x00C7C280 @@ -37,16 +37,16 @@ CRagConnection::CRagConnection() : unknown_006C(0) { bool CConnection::Connect(const ConnectionEndpoint& endpoint) { this->m_deferred = 0; - while (this->m_pending.Available() != 0) { - const int bytes = this->m_pending.Available(); - this->m_output.Append(bytes, this->m_pending.Data()); - this->m_pending.Consume(bytes); + while (this->m_pending.GetSize() != 0) { + const int bytes = this->m_pending.GetSize(); + this->m_output.InsertData(bytes, this->m_pending.Data()); + this->m_pending.RemoveData(bytes); this->Flush(); } - this->m_input.Reset(0xA000); - this->m_output.Reset(0xA000); - this->m_pending.Reset(0xA000); + this->m_input.Init(0xA000); + this->m_output.Init(0xA000); + this->m_pending.Init(0xA000); this->m_socket = socket(AF_INET, SOCK_STREAM, 0); if (this->m_socket == INVALID_SOCKET) { @@ -101,8 +101,8 @@ void CConnection::Close() { if (this->m_socket != INVALID_SOCKET) { closesocket(this->m_socket); this->m_socket = INVALID_SOCKET; - this->m_output.Reset(0xA000); - this->m_pending.Reset(0xA000); + this->m_output.Init(0xA000); + this->m_pending.Init(0xA000); } this->m_status = 0; @@ -130,7 +130,7 @@ bool CConnection::Receive() { continue; } } else if (bytes > 0) { - this->m_input.Append(bytes, data); + this->m_input.InsertData(bytes, data); continue; } @@ -143,7 +143,7 @@ bool CConnection::Receive() { // FUNCTION: fn_20398 bool CConnection::Flush() { while (this->m_sendDeadline < timeGetTime()) { - if (this->m_output.Available() == 0) { + if (this->m_output.GetSize() == 0) { return true; } @@ -158,9 +158,9 @@ bool CConnection::Flush() { return true; } - const int sent = g_connectionSend(this->m_socket, this->m_output.Data(), this->m_output.Available(), 0); + const int sent = g_connectionSend(this->m_socket, this->m_output.Data(), this->m_output.GetSize(), 0); if (sent != SOCKET_ERROR) { - this->m_output.Consume(sent); + this->m_output.RemoveData(sent); } else { const int error = WSAGetLastError(); if (error != WSAEWOULDBLOCK && error != WSAENOTCONN) { @@ -212,7 +212,7 @@ void CConnection::Send(int bytes, const void* data) { return; } - this->m_output.Append(bytes, data); + this->m_output.InsertData(bytes, data); this->Flush(); } @@ -220,11 +220,11 @@ void CConnection::Send(int bytes, const void* data) { // FUNCTION: fn_20401 int CConnection::Read(void* output, int bytes, unsigned char exact) { if (exact != 0) { - return this->m_input.Read(bytes, output) ? bytes : 0; + return this->m_input.GetData(bytes, output) ? bytes : 0; } - const int available = std::min(bytes, this->m_input.Available()); - this->m_input.Read(available, output); + const int available = std::min(bytes, this->m_input.GetSize()); + this->m_input.GetData(available, output); return available; } @@ -232,7 +232,7 @@ int CConnection::Read(void* output, int bytes, unsigned char exact) { // FUNCTION: fn_20402 bool CConnection::ReadPacket(void* output, unsigned short* bytes, const PacketLengths& lengths) { unsigned short id; - if (!this->m_input.Peek(2, &id)) { + if (!this->m_input.PeekData(2, &id)) { return false; } @@ -241,14 +241,14 @@ bool CConnection::ReadPacket(void* output, unsigned short* bytes, const PacketLe size = static_cast(lengths.FixedLength(id)); } else { unsigned header; - if (!this->m_input.Peek(4, &header)) { + if (!this->m_input.PeekData(4, &header)) { return false; } size = static_cast(header >> 16); } - if (!this->m_input.Read(size, output)) { + if (!this->m_input.GetData(size, output)) { return false; } @@ -268,29 +268,29 @@ void CConnection::Prepend(int bytes, const void* data) { // OFFSET: 0x00C7CDB0 // FUNCTION: fn_20403 void CConnection::ResetDeferred() { - this->m_pending.Reset(0xA000); + this->m_pending.Init(0xA000); } // OFFSET: 0x00C7CDC0 // FUNCTION: fn_20404 void CConnection::ResetQueue() { - this->m_input.Reset(0xA000); - this->m_output.Reset(0xA000); - this->m_pending.Reset(0xA000); + this->m_input.Init(0xA000); + this->m_output.Init(0xA000); + this->m_pending.Init(0xA000); } // OFFSET: 0x00C7CED0 // FUNCTION: fn_20407 -void CConnection::SetDeferred(unsigned char value) { +void CConnection::SetBlock(unsigned char value) { this->m_deferred = value; if (value != 0) { return; } - while (this->m_pending.Available() != 0) { - const int bytes = this->m_pending.Available(); - this->m_output.Append(bytes, this->m_pending.Data()); - this->m_pending.Consume(bytes); + while (this->m_pending.GetSize() != 0) { + const int bytes = this->m_pending.GetSize(); + this->m_output.InsertData(bytes, this->m_pending.Data()); + this->m_pending.RemoveData(bytes); this->Flush(); } } diff --git a/Source/Network/Connection/Connection.h b/Source/Network/Connection/Connection.h index 3cb4cfbb..0074f769 100644 --- a/Source/Network/Connection/Connection.h +++ b/Source/Network/Connection/Connection.h @@ -1,7 +1,7 @@ #ifndef RAGNAROK_SOURCE_NETWORK_CONNECTION_CONNECTION_H #define RAGNAROK_SOURCE_NETWORK_CONNECTION_CONNECTION_H -#include "Network/Connection/ConnectionBuffer.h" +#include "Network/Connection/PacketQueue.h" #include @@ -30,14 +30,14 @@ public: void Prepend(int bytes, const void* data); void ResetDeferred(); void ResetQueue(); - void SetDeferred(unsigned char value); + void SetBlock(unsigned char value); // INLINED SOCKET NativeSocket() const { return this->m_socket; } // INLINED - ConnectionBuffer& Input() { + CPacketQueue& Input() { return this->m_input; } // INLINED @@ -51,9 +51,9 @@ protected: /* 0018 */ unsigned char m_deferred; /* 001C */ unsigned m_sendDeadline; /* 0020 */ int m_status; - /* 0024 */ ConnectionBuffer m_output; - /* 003C */ ConnectionBuffer m_input; - /* 0054 */ ConnectionBuffer m_pending; + /* 0024 */ CPacketQueue m_output; + /* 003C */ CPacketQueue m_input; + /* 0054 */ CPacketQueue m_pending; }; class CRagConnection : public CConnection { diff --git a/Source/Network/Connection/ConnectionBuffer.h b/Source/Network/Connection/ConnectionBuffer.h deleted file mode 100644 index e21fc2bb..00000000 --- a/Source/Network/Connection/ConnectionBuffer.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef RAGNAROK_SOURCE_NETWORK_CONNECTION_CONNECTIONBUFFER_H -#define RAGNAROK_SOURCE_NETWORK_CONNECTION_CONNECTIONBUFFER_H - -#include - -class ConnectionBuffer { -public: - ConnectionBuffer(); - ~ConnectionBuffer(); - void Reset(unsigned bytes); - int Available() const; - void Append(int bytes, const void* source); - void Prepend(int bytes, const void* source); - bool Read(int bytes, void* destination); - bool Peek(int bytes, void* destination) const; - bool Consume(int bytes); - - // INLINED - char* Data() const { - return this->m_data + this->m_read; - } - unsigned Size() const { - return static_cast(this->m_storage.size()); - } - -private: - /* 0000 */ char* m_data; - /* 0004 */ int m_read; - /* 0008 */ int m_write; - /* 000C */ std::vector m_storage; - ConnectionBuffer(const ConnectionBuffer&) = delete; - ConnectionBuffer& operator=(const ConnectionBuffer&) = delete; -}; - -#if defined(_WIN32) && !defined(_WIN64) -static_assert(sizeof(ConnectionBuffer) == 24); -#endif - -#endif diff --git a/Source/Network/Connection/ConnectionBuffer.cpp b/Source/Network/Connection/PacketQueue.cpp similarity index 72% rename from Source/Network/Connection/ConnectionBuffer.cpp rename to Source/Network/Connection/PacketQueue.cpp index fb7f5820..4206d447 100644 --- a/Source/Network/Connection/ConnectionBuffer.cpp +++ b/Source/Network/Connection/PacketQueue.cpp @@ -1,20 +1,20 @@ -#include "Network/Connection/ConnectionBuffer.h" +#include "Network/Connection/PacketQueue.h" #include #include // OFFSET: 0x00C7EF60 // FUNCTION: fn_20418 -ConnectionBuffer::ConnectionBuffer() : m_data(nullptr) { +CPacketQueue::CPacketQueue() : m_data(nullptr) { } // OFFSET: 0x00C7EFC0 // FUNCTION: fn_20419 -ConnectionBuffer::~ConnectionBuffer() = default; +CPacketQueue::~CPacketQueue() = default; // OFFSET: 0x00C7F060 // FUNCTION: fn_20422 -void ConnectionBuffer::Reset(unsigned bytes) { +void CPacketQueue::Init(unsigned bytes) { this->m_read = 0; this->m_write = 0; this->m_storage.resize(bytes); @@ -23,23 +23,23 @@ void ConnectionBuffer::Reset(unsigned bytes) { // OFFSET: 0x00C7F050 // FUNCTION: fn_20421 -int ConnectionBuffer::Available() const { +int CPacketQueue::GetSize() const { return this->m_write - this->m_read; } // OFFSET: 0x00C7F0E0 // FUNCTION: fn_20423 -void ConnectionBuffer::Append(int bytes, const void* source) { +void CPacketQueue::InsertData(int bytes, const void* source) { const int size = static_cast(this->m_storage.size()); if ((this->m_write + bytes) > size) { - const int required = (this->Available() + bytes); + const int required = (this->GetSize() + bytes); if (required > size) { this->m_storage.resize(static_cast(required) * 2u); this->m_data = this->m_storage.data(); } - std::memmove(this->m_data, this->m_data + this->m_read, this->Available()); - this->m_write = this->Available(); + std::memmove(this->m_data, this->m_data + this->m_read, this->GetSize()); + this->m_write = this->GetSize(); this->m_read = 0; } @@ -49,8 +49,8 @@ void ConnectionBuffer::Append(int bytes, const void* source) { // OFFSET: 0x00C7F160 // FUNCTION: fn_20424 -void ConnectionBuffer::Prepend(int bytes, const void* source) { - const int available = this->Available(); +void CPacketQueue::Prepend(int bytes, const void* source) { + const int available = this->GetSize(); const int required = (bytes + available); std::vector storage(static_cast(std::max(required, static_cast(this->m_storage.size())))); std::memcpy(storage.data(), source, bytes); @@ -63,8 +63,8 @@ void ConnectionBuffer::Prepend(int bytes, const void* source) { // OFFSET: 0x00C7F010 // FUNCTION: fn_20420 -bool ConnectionBuffer::Read(int bytes, void* destination) { - if (this->Available() < bytes) { +bool CPacketQueue::GetData(int bytes, void* destination) { + if (this->GetSize() < bytes) { return false; } @@ -75,7 +75,7 @@ bool ConnectionBuffer::Read(int bytes, void* destination) { // OFFSET: 0x00C7F2B0 // FUNCTION: fn_20425 -bool ConnectionBuffer::Peek(int bytes, void* destination) const { +bool CPacketQueue::PeekData(int bytes, void* destination) const { if (this->m_write - this->m_read < bytes) { return false; } @@ -86,7 +86,7 @@ bool ConnectionBuffer::Peek(int bytes, void* destination) const { // OFFSET: 0x00C7F2E0 // FUNCTION: fn_20426 -bool ConnectionBuffer::Consume(int bytes) { +bool CPacketQueue::RemoveData(int bytes) { if (this->m_write - this->m_read < bytes) { return false; } diff --git a/Source/Network/Connection/PacketQueue.h b/Source/Network/Connection/PacketQueue.h new file mode 100644 index 00000000..5a1fb35e --- /dev/null +++ b/Source/Network/Connection/PacketQueue.h @@ -0,0 +1,39 @@ +#ifndef RAGNAROK_SOURCE_NETWORK_CONNECTION_PACKETQUEUE_H +#define RAGNAROK_SOURCE_NETWORK_CONNECTION_PACKETQUEUE_H + +#include + +class CPacketQueue { +public: + CPacketQueue(); + ~CPacketQueue(); + void Init(unsigned bytes); + int GetSize() const; + void InsertData(int bytes, const void* source); + void Prepend(int bytes, const void* source); + bool GetData(int bytes, void* destination); + bool PeekData(int bytes, void* destination) const; + bool RemoveData(int bytes); + + // INLINED + char* Data() const { + return this->m_data + this->m_read; + } + unsigned Size() const { + return static_cast(this->m_storage.size()); + } + +private: + /* 0000 */ char* m_data; + /* 0004 */ int m_read; + /* 0008 */ int m_write; + /* 000C */ std::vector m_storage; + CPacketQueue(const CPacketQueue&) = delete; + CPacketQueue& operator=(const CPacketQueue&) = delete; +}; + +#if defined(_WIN32) && !defined(_WIN64) +static_assert(sizeof(CPacketQueue) == 24); +#endif + +#endif diff --git a/data/compile.json b/data/compile.json index b7f39375..f329d388 100644 --- a/data/compile.json +++ b/data/compile.json @@ -482,7 +482,7 @@ "Source/Network/ClientKeepalive.cpp": 0, "Source/Network/ClientOptionPacket.cpp": 0, "Source/Network/Connection/Connection.cpp": 0, - "Source/Network/Connection/ConnectionBuffer.cpp": 0, + "Source/Network/Connection/PacketQueue.cpp": 0, "Source/Network/Connection/ConnectionRuntime.cpp": 0, "Source/Network/Http/CURLMgr.cpp": 0, "Source/Network/Http/CURLPostHander.cpp": 0,