// *************************************************************** // Function: LoadPacketOpcodes.cpp // *************************************************************** #include "Main.h" #include "LocalData.h" #define LsAddClientOpcode(name, handler) AddOpcode2(&gClientOpcodesTable, &gClientOpcodeList, &config, name, handler) #define LsAddServerOpcode(name, handler) AddOpcode2(&gServerOpcodesTable, &gServerOpcodeList, &config, name, handler) #define FsAddOpcode(name, handler) AddOpcode2(&gFileServerOpcodes,NULL, &config, name, handler) void AddOpcode2(hash_map *pHashMap, vector* pVector, ConfigLoader *pConfigLoad, char *pName, int (*handler)(NetMessage *, LOCAL_DATA*)); hash_map gClientOpcodesTable; hash_map gServerOpcodesTable; hash_map gFileServerOpcodes; vector gClientOpcodeList; vector gServerOpcodeList; //Handler function declarations //File Server int HandleOpcode_UPDATE_CHECK(NetMessage *pData, LOCAL_DATA *lir); //Login Server int HandleOpcode_CLIENT_VERSION(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_CLIENT_SEED(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_COMPUTER_USER(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_LS_CLIENT_ID(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_ACCOUNT_LOGIN(NetMessage *pData, LOCAL_DATA* lir); int HandleOpcode_VERIFY_SERIAL(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_CREATE_ACCOUNT(NetMessage *pData, LOCAL_DATA* lir); int HandleOpcode_PLAYCREATE_CHARACTER(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_CHARACTER_PLAYNAME(NetMessage *pData, LOCAL_DATA* lir); int HandleOpcode_CHARACTER_DELETE(NetMessage *pData, LOCAL_DATA* lir); int HandleOpcode_INTERFACE_POSITION_DATA(NetMessage *pData, LOCAL_DATA* lir); int HandleOpcode_ACCOUNT_LOGOUT(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_KEEP_ALIVE(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_ACCOUNT_LOGIN_AUTO(NetMessage *pData, LOCAL_DATA *lir); int HandleOpcode_LS_COMPUTER_HASH(NetMessage* pData, LOCAL_DATA* pLir); int HandleOpcode_LS_COMPUTER_HARDWARE(NetMessage* pData, LOCAL_DATA* pLir); int HandleOpcode_EXIT_GAME(NetMessage* pData, LOCAL_DATA* pLir); int HandleOpcode_LAST_CHARACTER_INFO(NetMessage* pData, LOCAL_DATA* pLir); int HandleOpcode_LS_REQUEST_RESPONSE(NetMessage* pData, LOCAL_DATA* pLir); //************************************ // Name: PopulateOpcodeTable // // Populates the opcode tables for the file server, server client, and server. // // Parameters: // // Return: // true - no errors // false - errors //************************************ bool PopulateOpcodeTable() { gCoreLog.Section("Loading Packet Headers..."); ConfigLoader config; if (config.Load("Data/LoginHeaders.ini", &gCoreLog)!=0) { gCoreLog.SectionFail(); return false; } //File server: opcodes FsAddOpcode("UPDATE_CHECK", HandleOpcode_UPDATE_CHECK); //Login server: client to server opcodes LsAddClientOpcode("CLIENT_SEED", HandleOpcode_CLIENT_SEED); LsAddClientOpcode("CLIENT_VERSION", HandleOpcode_CLIENT_VERSION); LsAddClientOpcode("ACCOUNT_LOGIN", HandleOpcode_ACCOUNT_LOGIN); LsAddClientOpcode("ACCOUNT_LOGOUT", HandleOpcode_ACCOUNT_LOGOUT); LsAddClientOpcode("ACCOUNT_DATA_FROM_CC", HandleOpcode_INTERFACE_POSITION_DATA); LsAddClientOpcode("PLAYCREATE_CHARACTER", HandleOpcode_PLAYCREATE_CHARACTER); LsAddClientOpcode("CHARACTER_DELETE", HandleOpcode_CHARACTER_DELETE); LsAddClientOpcode("CHARACTER_PLAYNAME", HandleOpcode_CHARACTER_PLAYNAME); LsAddClientOpcode("COMPUTER_USER", HandleOpcode_COMPUTER_USER); LsAddClientOpcode("KEEP_ALIVE", HandleOpcode_KEEP_ALIVE); LsAddClientOpcode("LS_CLIENT_ID", HandleOpcode_LS_CLIENT_ID); LsAddClientOpcode("VERIFY_SERIAL", HandleOpcode_VERIFY_SERIAL); LsAddClientOpcode("CREATE_ACCOUNT", HandleOpcode_CREATE_ACCOUNT); LsAddClientOpcode("LS_COMPUTER_HARDWARE", HandleOpcode_LS_COMPUTER_HARDWARE); LsAddClientOpcode("EXIT_GAME", HandleOpcode_EXIT_GAME); LsAddClientOpcode("LAST_CHARACTER_INFO", HandleOpcode_LAST_CHARACTER_INFO); LsAddClientOpcode("LS_COMPUTER_HASH", HandleOpcode_LS_COMPUTER_HASH); LsAddClientOpcode("LS_REQUEST_RESPONSE", HandleOpcode_LS_REQUEST_RESPONSE); //DO NOT CHANGE THE ORDER BELOW //Login server: server to client opcodes -- DO NOT CHANGE ORDER LsAddServerOpcode("NO_UPDATES", NULL); LsAddServerOpcode("SERVER_SEED", NULL); LsAddServerOpcode("ACCOUNT_DATA", NULL); LsAddServerOpcode("ACCOUNT_FRIENDSLIST_END", NULL); LsAddServerOpcode("STREAM_TERMINATOR", NULL);//ACCOUNT_LOGIN_FAIL LsAddServerOpcode("ACCOUNT_PERMISSIONS", NULL); LsAddServerOpcode("CHARACTER_INFO", NULL); LsAddServerOpcode("COMPUTER_INFO_REPLY", NULL); LsAddServerOpcode("P12B_REPLY", NULL); LsAddServerOpcode("REFER_TO_GAMESERV", NULL);//10 LsAddServerOpcode("STREAM_TERMINATOR", NULL); LsAddServerOpcode("SERIAL_KEY_INFORMATION", NULL); LsAddServerOpcode("LS_SEND_RESPONSE", NULL); //Output a reference list if needed if (true) { ofstream fout("opcodes.txt"); fout << "FROM CLIENT!\n\n"; for (unsigned int i=0; i* pHashMap, vector* pVector, ConfigLoader *pConfigLoad, char *pName, int (*handler)(NetMessage *, LOCAL_DATA*)) { OPCODE o; pConfigLoad->GetDataAsShortX(pName, &o.opcode); strcpy(o.name, pName); o.handler=handler; typedef pair opair; pHashMap->insert(opair(o.opcode, o)); if (pVector!=NULL) { pVector->push_back(o.opcode); } }