#include "LoginServ.h" #include "../../src/ConfigLoader.h" #define LsAddClientOpcode(name, handler) AddOpcode(&config, name, handler) #define LsAddServerOpcode(name) AddOpcodeServer(&config, name) void AddOpcode(ConfigLoader *pConfigLoad, char *pName, int (*handler)(Packet* pck, GwClient* pClient)); void AddOpcodeServer(ConfigLoader *pConfigLoad, char* pName); //Handler declarations int HandleOpcodeCLIENT_VERSION(Packet* pck, GwClient* pClient); int HandleOpcodeCLIENT_SEED(Packet* pck, GwClient* pClient); int HandleOpcodeLS_COMPUTER_USER(Packet* pck, GwClient* pClient); int HandleOpcodeLS_COMPUTER_HASH(Packet* pck, GwClient* pClient); int HandleOpcodeKEEP_ALIVE(Packet* pck, GwClient* pClient); int HandleOpcodeLS_CLIENT_ID(Packet* pck, GwClient* pClient); int HandleOpcodeVERIFY_SERIAL(Packet* pck, GwClient* pClient); int HandleOpcodeCREATE_ACCOUNT(Packet* pck, GwClient* pClient); int HandleOpcodeACCOUNT_LOGIN(Packet* pck, GwClient* pClient); int HandleOpcodeLS_COMPUTER_HARDWARE(Packet* pck, GwClient* pClient); int HandleOpcodeLS_REQUEST_RESPONSE(Packet* pck, GwClient* pClient); int HandleOpcodeEXIT_GAME(Packet* pck, GwClient* pClient); int HandleOpcodeACCOUNT_LOGOUT(Packet* pck, GwClient* pClient); int HandleOpcodeCHARACTER_DELETE(Packet* pck, GwClient* pClient); int HandleOpcodeINTERFACE_DATA(Packet* pck, GwClient* pClient); int PopulateLsOpcodeTable() { ConfigLoader config; if (config.Load("Data/LoginOpcodes.ini")!=0) { return -1; } //Login server: client to server opcodes LsAddClientOpcode("CLIENT_SEED", HandleOpcodeCLIENT_SEED); LsAddClientOpcode("CLIENT_VERSION", HandleOpcodeCLIENT_VERSION); LsAddClientOpcode("ACCOUNT_LOGIN", HandleOpcodeACCOUNT_LOGIN); LsAddClientOpcode("ACCOUNT_LOGOUT", HandleOpcodeACCOUNT_LOGOUT); LsAddClientOpcode("ACCOUNT_DATA_FROM_CC", HandleOpcodeINTERFACE_DATA); LsAddClientOpcode("PLAYCREATE_CHARACTER", NULL); LsAddClientOpcode("CHARACTER_DELETE", HandleOpcodeCHARACTER_DELETE); LsAddClientOpcode("CHARACTER_PLAYNAME", NULL); LsAddClientOpcode("COMPUTER_USER", HandleOpcodeLS_COMPUTER_USER); LsAddClientOpcode("KEEP_ALIVE", HandleOpcodeKEEP_ALIVE); LsAddClientOpcode("LS_CLIENT_ID", HandleOpcodeLS_CLIENT_ID); LsAddClientOpcode("VERIFY_SERIAL", HandleOpcodeVERIFY_SERIAL); LsAddClientOpcode("CREATE_ACCOUNT", HandleOpcodeCREATE_ACCOUNT); LsAddClientOpcode("LS_COMPUTER_HARDWARE", HandleOpcodeLS_COMPUTER_HARDWARE); LsAddClientOpcode("EXIT_GAME", HandleOpcodeEXIT_GAME); LsAddClientOpcode("LAST_CHARACTER_INFO", NULL); LsAddClientOpcode("LS_COMPUTER_HASH", HandleOpcodeLS_COMPUTER_HASH); LsAddClientOpcode("LS_REQUEST_RESPONSE", HandleOpcodeLS_REQUEST_RESPONSE); //Server opcodes LsAddServerOpcode("NO_UPDATES" ); LsAddServerOpcode("SERVER_SEED" ); LsAddServerOpcode("ACCOUNT_DATA" ); LsAddServerOpcode("ACCOUNT_FRIENDSLIST_END" ); LsAddServerOpcode("STREAM_TERMINATOR" );//ACCOUNT_LOGIN_FAIL LsAddServerOpcode("ACCOUNT_PERMISSIONS" ); LsAddServerOpcode("CHARACTER_INFO" ); LsAddServerOpcode("COMPUTER_INFO_REPLY" ); LsAddServerOpcode("P12B_REPLY" ); LsAddServerOpcode("REFER_TO_GAMESERV" );//10 LsAddServerOpcode("STREAM_TERMINATOR" ); LsAddServerOpcode("SERIAL_KEY_INFORMATION" ); LsAddServerOpcode("LS_SEND_RESPONSE" ); if (config.ErrorOccurred()) { return -2; } config.CleanUp(); return 0; } void AddOpcode(ConfigLoader *pConfigLoad, char *pName, int (*handler)(Packet* pck, GwClient* pClient)) { ushort opcode=0; pConfigLoad->GetDataAsShortX(pName, &opcode); gLoginServer.mpLoginServer->RegisterOpcode(pName, opcode, handler); } void AddOpcodeServer(ConfigLoader *pConfigLoad, char* pName) { ushort opcode=0; pConfigLoad->GetDataAsShortX(pName, &opcode); typedef std::pair spair; gLoginServer.mServerOpcodesTable.insert(spair(pName, opcode)); }