Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Help] Update ar.h and ar.cpp issue

Initiate Mage
Joined
Nov 2, 2020
Messages
4
Reaction score
2
I'm currently learning and use Ketchup's source [V19] K18 since last year
and I'm facing the issue in sending a packet that's <vector>
I've noticed that in my ar.h and ar.cpp is an old version
that doesn't contain <vector> type of operator as seen below

[V19] K18 version of ar.h
Code:
[COLOR=#D4D4D4][COLOR=#6a9955]    // insertion operations[/COLOR]
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#4ec9b0]BYTE[/COLOR] [COLOR=#9cdcfe]by[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#4ec9b0]WORD[/COLOR] [COLOR=#9cdcfe]w[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#4ec9b0]LONG[/COLOR] [COLOR=#9cdcfe]l[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#4ec9b0]DWORD[/COLOR] [COLOR=#9cdcfe]dw[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]float[/COLOR] [COLOR=#9cdcfe]f[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]double[/COLOR] [COLOR=#9cdcfe]d[/COLOR]);

    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]int[/COLOR] [COLOR=#9cdcfe]i[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]short[/COLOR] [COLOR=#9cdcfe]w[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]char[/COLOR] [COLOR=#9cdcfe]ch[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]unsigned[/COLOR] [COLOR=#9cdcfe]u[/COLOR]);

[COLOR=#6a9955]    // extraction operations[/COLOR]
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]BYTE[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]by[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]WORD[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]w[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]DWORD[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]dw[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]LONG[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]l[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#569cd6]float&[/COLOR] [COLOR=#9cdcfe]f[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#569cd6]double&[/COLOR] [COLOR=#9cdcfe]d[/COLOR]);

    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#569cd6]int&[/COLOR] [COLOR=#9cdcfe]i[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#569cd6]short&[/COLOR] [COLOR=#9cdcfe]w[/COLOR]);
    [COLOR=#4ec9b0]CAr[/COLOR][COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#569cd6]char&[/COLOR] [COLOR=#9cdcfe]ch[/COLOR]);
[/COLOR][COLOR=#4EC9B0]    CAr[/COLOR][COLOR=#569CD6]&[/COLOR][COLOR=#C586C0]operator>>[/COLOR][COLOR=#D4D4D4]([/COLOR][COLOR=#569CD6]unsigned&[/COLOR][COLOR=#9CDCFE]u[/COLOR][COLOR=#D4D4D4]);
[/COLOR]

compare to a newer version of [V22] K18 that can handle more of a variable type of data
Code:
[COLOR=#D4D4D4]    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR], [COLOR=#569cd6]size_t[/COLOR] [COLOR=#4ec9b0]N[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]const[/COLOR] [COLOR=#4ec9b0]T[/COLOR]([COLOR=#569cd6]&[/COLOR][COLOR=#9cdcfe]t[/COLOR])[N]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]const[/COLOR] [COLOR=#4ec9b0]T[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]t[/COLOR]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]const[/COLOR] [COLOR=#4ec9b0]std[/COLOR]::[COLOR=#4ec9b0]vector[/COLOR]<[COLOR=#4ec9b0]T[/COLOR]> [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]v[/COLOR]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR], [COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]U[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator<<[/COLOR]([COLOR=#569cd6]const[/COLOR] [COLOR=#4ec9b0]map[/COLOR]<[COLOR=#4ec9b0]T[/COLOR], [COLOR=#4ec9b0]U[/COLOR]> [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]m[/COLOR]);

    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR], [COLOR=#569cd6]size_t[/COLOR] [COLOR=#4ec9b0]N[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]T[/COLOR]([COLOR=#569cd6]&[/COLOR][COLOR=#9cdcfe]t[/COLOR])[N]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]T[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]t[/COLOR]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]vector[/COLOR]<[COLOR=#4ec9b0]T[/COLOR]> [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]v[/COLOR]);
    [COLOR=#569cd6]template[/COLOR]<[COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]T[/COLOR], [COLOR=#569cd6]typename[/COLOR] [COLOR=#4ec9b0]U[/COLOR]>
    [COLOR=#4ec9b0]CAr[/COLOR] [COLOR=#569cd6]&[/COLOR] [COLOR=#c586c0]operator>>[/COLOR]([COLOR=#4ec9b0]map[/COLOR]<[COLOR=#4ec9b0]T[/COLOR], [COLOR=#4ec9b0]U[/COLOR]> [COLOR=#569cd6]&[/COLOR] [COLOR=#9cdcfe]m[/COLOR]);[/COLOR]

If I want to update my ar.h and ar.cpp, can I just replace my old ar.h and ar.cpp with the new one from [V22] K18 source?
I've tried that already but seem like there's some packet that my client cannot recieve after the update (for example: player cannot recieve buff from BuffPang successfully)

I wonder that maybe if I want to update the packet system. Are there somewhere more in the code that I have to update?

Thank for the help :(:



oh I'm so sorry, I just realized I'm posting in the wrong sub-forum.

big sorry to the moderator.
 
Initiate Mage
Joined
Nov 2, 2020
Messages
4
Reaction score
2
UPDATE : I tried debugging and kind of assume that
the problem might come from SNAPSHOT sending and receiving
not PACKET

Seem like some SNAPSHOT is not corrected as seen in the debugging picture below
cadenzatb - [Help] Update ar.h and ar.cpp issue - RaGEZONE Forums

cadenzatb - [Help] Update ar.h and ar.cpp issue - RaGEZONE Forums


5EEmch - [Help] Update ar.h and ar.cpp issue - RaGEZONE Forums


as you can see the 'hdr' value in the bottom left of the picture is = 65280 which is way too high for SNAPSHOTTYPE_DOAPPLYUSESKIL which normally has the value of = 215 or (WORD)0x00d7

that means some how with the new ar.h and ar.cpp packet is effect and cause the packet to get change from 215 to 65280 along the way before receiving in Neuz.exe client

I'm not sure where should I dig next to find where the packet got changed. Please help.
 

Attachments

You must be registered for see attachments list
Last edited:
Upvote 0
Initiate Mage
Joined
Sep 8, 2011
Messages
67
Reaction score
252
So, your issue sounds like you've altered an existing system or you have something custom interfering. The edits within ketchup's does work. What it sounds like is that an expected data type on the client in one of the snapshots being sent over is being read incorrectly and as another data type causing a size and i/o mismatch.

Also, it really depends on what you want to edit or rewrite with networking? There's quite a few things that could be done. All template's do is generate a version of the class / function based on the T param. For instance, with the Ar file, You could pretty much sum it up in C++17 using enable_if_t and in C++ 20 using concepts.

Essentially, Ar = Archiver. It is building on to the buffer.
PHP:
CAr::CAr(void* lpBuf, u_int nBufSize)
{
	if (lpBuf) // If the buffer already exists
	{
		m_nMode = load; // its loading
		m_lpBufStart = static_cast<LPBYTE>(lpBuf); // a poitner to denoted as the start of the buffer 
		m_nBufSize = nBufSize; // length / size of buffer
	}
	else
	{
		m_nMode = store;
		m_lpBufStart = new BYTE[nGrowSize]; // creates unsgined char array on heap that is the size of nGrowSize and stores the pointer to start.
		m_nBufSize = nGrowSize;
	}
	m_lpBufMax = m_lpBufStart + m_nBufSize; // add the start pointer with the size is the last offset.
	m_lpBufCur = m_lpBufStart; // current read / write offset = start
}
After putting Hungarian notation aside, you can be left with some clear reading English. if you're interested in rewriting you could document it to understand it all.

Anyway some C++ 20 examples that are not yet tested as I've made them for something else. This doesnt have the function to grow the buffer being used so do not use this copy paste as it wont work lol
PHP:
template <typename T> using DeRefPtr = std::remove_const_t<std::remove_pointer_t<T>>;
template <class T> inline constexpr bool isCharArr = std::is_pointer_v<T> && std::is_same_v<char, DeRefPtr<T>>;

template <typename> struct GetArrSizeT;
template <typename T, size_t N> struct GetArrSizeT<std::array<T, N>> { constexpr static size_t size = N; };
template <typename T> concept IsStdArray = std::is_same_v<T, std::array<typename T::value_type, GetArrSizeT<T>::size>>;
template <typename T> concept IsStdString = std::is_same_v<std::string, T>;
template <typename T> concept IsStdVector = std::is_same_v<T, std::vector<typename T::value_type, typename T::allocator_type>>;
template <typename T> concept IsStdMap = std::same_as<T, std::map<typename T::key_type, typename T::mapped_type, typename T::key_compare, typename T::allocator_type>>;
template <typename T> concept IsStdHashMap = std::same_as<T, std::unordered_map<typename T::key_type, typename T::mapped_type, typename T::hasher, typename T::key_equal, 
	typename T::allocator_type>>;
template <typename T> concept IsAnyStdMap = IsStdHashMap<T> || IsStdMap<T>;


/**
 *	@brief	An interface that states an object can be
 *			serialized with an archiver.
 */
class ISerializer
{
	public:
		virtual ~ISerializer() = default;
		virtual void Read() = 0;

		virtual void Write() = 0;
		virtual void Serialize(CAr& ar) = 0;
		virtual void Deserialize(CAr& ar) = 0;
		virtual size_t SerializableSize() = 0;
};
template <typename T> concept HasSerializerInterface = std::is_convertible_v<T, ISerializer>;


		template <typename T>  CAr & operator<<(const T& values) requires(IsStdArray<T> || IsStdVector<T> || IsAnyStdMap<T> || IsStdString<T>)
		{
			const size_t containerSize = values.size();
			for (auto begin = values.begin(); begin != values.end(); ++begin)
			{
				if constexpr (IsAnyStdMap<T>)
					Add(containerSize, values.first, values.second);
				else
					Add(containerSize, values);
			}
			return *this;
		}
		template <typename T> CAr & operator<<(const T& data) requires (isCharArr<T> || std::is_arithmetic_v<T>)
		{
			const size_t size = CheckBuff<T>(data);
			if constexpr (isCharArr<T>) 
			{
				for (int i = 0; i < size; ++i)
					*reinterpret_cast<__unaligned DeRefPtr<T>*>(m_lpBufCur + i) = data[i];
			}
			else if constexpr (std::is_arithmetic_v<T>) 
				*reinterpret_cast<__unaligned T*>(m_lpBufCur) = data;
			m_lpBufCur += size;
			return *this;
		}
		template <typename T, size_t N> requires std::is_array_v<T[N]> CAr& operator<<(T(&a)[N])
		{
			const size_t size = CheckBuff<T, N>(*a);
			for (size_t i = 0; i < N; ++i)
				*reinterpret_cast<__unaligned DeRefPtr<T>*>(m_lpBufCur + i) = a[i];
			m_lpBufCur += size;
			return *this;
		}
		template <typename E> CAr& CAr::operator<<(E e) requires (std::is_enum_v<E>) 
		{
			return *this << std::to_underlying(e);
		}
		template <typename ...Args> CAr& Add(Args... arg)
		{
			((*this << arg), ...);
			return *this;
		}
		template <typename T> CAr& operator<<(T& t) requires (HasSerializerInterface<T>)
		{
			t.Serialize(*this);
			return *this;
		}
 
Upvote 0
Back
Top