I've made compatible my old sro stuffs with vSro client 1.188 and coalesced into this small library. It provides hooking packet receive, sending packet and some utility functions.
static void BeginInitialize()
Begins to initialize the library, hook register functions should be called after that.
Exceptions
std::logic_error("SroPP is already initialized or initializing")
static void EndInitialize()
Applies all hooks and patches to client. Library should be initialized before running client. Otherwise, packet receive hook and WorkQueue class won't perform action at all, and consequently you won't be able to call sro-related functions safely.
Exceptions
std::logic_error("SroPP is not in initialization mode")
static void PostWork<Func>(Func func)
-Posts a lambda/function to silkroad's main thread, posted works are guaranteed to be processed in same order they are invoked and in single thread. All of sro-related functions should be called through this function unless you are calling them in hooked functions. Otherwise, it will lead to random crashes.
Arguments
func: A lambda/function that will be called from sro main thread.
Ver 1.1
static std::vector<char> MakeVector(T &val)
-Serializes specified value to vector<char>
static void RegisterReceive<Func>(Func func)
Registers the function that will be called when packet is received. Only in game packets are captured, starts with character data packet. If you previously registered a function, it will be replaced.
Arguments
func: A lambda/function that suitable for bool(const SroPP::Packet& packet) call.
Return value of "func" argument: If you return true, that means you've handled packet and don't let client to handle it. Hereby you can add your own packet for specific purposes. Else client will handle packet.
Ver 1.1
static void RegisterSendLoginRequest<Func>(Func func)
Registers the function that will be called when login packet (0x6102) is written. Allows you to append custom data(e.g. HWID) to end of the login packet. If you previously registered a function, it will be replaced.
Arguments
func: A lambda/function that suitable for vector<char>() call.
Return value of "func" argument: The data that will be appended to end of the login packet (0x6102)
static void WriteChat(ChatGroup group, wchar_t* message, uint32_t color)
Writes a message to chatbox with specified group and color.
static const wchar_t* GetUIText(const wchar_t* codename)
Loads string from text data files by codename. If there aren't any matches, it will return empty string "".
You shouldn't call this function before media.pk2 file gets loaded.
Ver 1.1
static std::vector<char> MakeVector(T &val)
-Serializes specified value to vector<char>
Arguments
val: Value to be serialized.
Templates
T: A non-pointer and pod type.
Quote:
Ver 1.1
static void RegisterSendLoginRequest<Func>(Func func)
Registers the function that will be called when login packet (0x6102) is written. Allows you to append custom data(e.g. HWID) to end of the login packet. If you previously registered a function, it will be replaced.
Arguments
func: A lambda/function that suitable for vector<char>() call.
Return value of "func" argument: The data that will be appended to end of the login packet (0x6102)
Quote:
Example code for appending data to end of the login packet: