mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Changed zone process window title format, example: 'crushbone :: clients: 6 inst_id: 1 inst_ver: 0 :: port: 7015'
Most of the following changes are QueryServ related, fully implemented its original functionality to be able to offload
intensive or metric based logging to a remote server process that could exist on another server entirely
Implemented Player Event Logging Types (Go to table `qs_player_events`):
1 = Player_Log_Quest,
2 = Player_Log_Zoning,
3 = Player_Log_Deaths,
4 = Player_Log_Connect_State,
5 = Player_Log_Levels,
6 = Player_Log_Keyring_Addition,
7 = Player_Log_QGlobal_Update,
8 = Player_Log_Task_Updates,
9 = Player_Log_AA_Purchases,
10 = Player_Log_Trade_Skill_Events,
11 = Player_Log_Issued_Commands,
12 = Player_Log_Money_Transactions,
13 = Player_Log_Alternate_Currency_Transactions,
- All QueryServ logging will be implemented with a front end in EoC 2.0 very soon
Changed all QS Error related logging to 'QUERYSERV__ERROR'
(Natedog) (Crash Fix) Legacy MySQL bug revert for loading AA's COALESCE( from COALESCE (
Implemented Perl Quest objects (LUA still needed to be exported):
- quest::qs_send_query("MySQL query") - Will send a raw query to the QueryServ process, useful for custom logging
- quest::qs_player_event(char_id, event_desc); - Will process a quest type event to table `qs_player_events`
Added MySQL Tables:
- `qs_player_aa_rate_hourly`
- `qs_player_events`
- Source table structures from:
- utils\sql\git\queryserv\required\08_23_2014_player_events_and_player_aa_rate_hourly
To get the complete QueryServ schema, source from here:
- utils\sql\git\queryserv\required\Complete_QueryServ_Table_Structures.sql
Added rules for each logging type, source rules here with them enabled by default:
- utils\sql\git\queryserv\required\Complete_QueryServ_Rules_Enabled.sql
Spawn related logging cleanup
General code cleanup
Added queryserv.cpp and queryserv.h with QueryServ class
This commit is contained in:
+53
-71
@@ -23,12 +23,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errmsg.h>
|
||||
#include <errmsg.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
// Disgrace: for windows compile
|
||||
#ifdef _WINDOWS
|
||||
@@ -95,42 +96,7 @@ Close the connection to the database
|
||||
Database::~Database()
|
||||
{
|
||||
}
|
||||
|
||||
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (!RunQuery(query,MakeAnyLenString(&query, "select `value` from `variables` where `varname`='%s'", varname), errbuf, &result)) {
|
||||
|
||||
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query, errbuf);
|
||||
|
||||
safe_delete_array(query);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
safe_delete_array(query);
|
||||
|
||||
if (mysql_num_rows(result) != 1) {
|
||||
|
||||
mysql_free_result(result);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
row = mysql_fetch_row(result);
|
||||
|
||||
snprintf(varvalue, varvalue_len, "%s", row[0]);
|
||||
|
||||
mysql_free_result(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Database::AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
@@ -143,8 +109,8 @@ void Database::AddSpeech(const char* from, const char* to, const char* message,
|
||||
DoEscapeString(S3, message, strlen(message));
|
||||
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_speech` SET `from`='%s', `to`='%s', `message`='%s', `minstatus`='%i', `guilddbid`='%i', `type`='%i'", S1, S2, S3, minstatus, guilddbid, type), errbuf, 0, 0)) {
|
||||
_log(NET__WORLD, "Failed Speech Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Speech Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
safe_delete_array(query);
|
||||
@@ -164,8 +130,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
||||
QS->char1_id, QS->char1_money.platinum, QS->char1_money.gold, QS->char1_money.silver, QS->char1_money.copper, QS->char1_count,
|
||||
QS->char2_id, QS->char2_money.platinum, QS->char2_money.gold, QS->char2_money.silver, QS->char2_money.copper, QS->char2_count),
|
||||
errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed Trade Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Trade Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
if(Items > 0) {
|
||||
@@ -176,15 +142,14 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
||||
lastid, QS->items[i].from_id, QS->items[i].from_slot, QS->items[i].to_id, QS->items[i].to_slot, QS->items[i].item_id,
|
||||
QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5,
|
||||
errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed Trade Log Record Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Trade Log Record Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
||||
|
||||
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
uint32 lastid = 0;
|
||||
@@ -194,8 +159,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
||||
QS->quest_id, QS->char_id, QS->char_money.platinum, QS->char_money.gold, QS->char_money.silver, QS->char_money.copper, QS->char_count,
|
||||
QS->npc_id, QS->npc_money.platinum, QS->npc_money.gold, QS->npc_money.silver, QS->npc_money.copper, QS->npc_count),
|
||||
errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed Handin Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Handin Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
if(Items > 0) {
|
||||
@@ -206,8 +171,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
||||
lastid, QS->items[i].action_type, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges,
|
||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5,
|
||||
errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed Handin Log Record Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Handin Log Record Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,15 +183,15 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
||||
char* query = 0;
|
||||
uint32 lastid = 0;
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_npc_kill_record` SET `npc_id`='%i', `type`='%i', `zone_id`='%i', `time`=NOW()", QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID), errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed NPC Kill Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed NPC Kill Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
if(Members > 0){
|
||||
for (int i = 0; i < Members; i++) {
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_npc_kill_record_entries` SET `event_id`='%i', `char_id`='%i'", lastid, QS->Chars[i].char_id, errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed NPC Kill Log Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed NPC Kill Log Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,8 +206,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
||||
"`char_id`='%i', `stack_size`='%i', `char_items`='%i'",
|
||||
QS->char_id, QS->stack_size, QS->char_count, QS->char_count),
|
||||
errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed Delete Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Delete Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
if(Items > 0) {
|
||||
@@ -253,15 +218,15 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
||||
lastid, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1,
|
||||
QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5,
|
||||
errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed Delete Log Record Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Delete Log Record Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
||||
|
||||
void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
||||
/* These are item moves */
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
uint32 lastid = 0;
|
||||
@@ -269,10 +234,9 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
||||
"`char_id`='%i', `from_slot`='%i', `to_slot`='%i', `stack_size`='%i', `char_items`='%i', `postaction`='%i'",
|
||||
QS->char_id, QS->from_slot, QS->to_slot, QS->stack_size, QS->char_count, QS->postaction),
|
||||
errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed Move Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
}
|
||||
|
||||
_log(QUERYSERV__ERROR, "Failed Move Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
if(Items > 0) {
|
||||
for(int i = 0; i < Items; i++) {
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_move_record_entries` SET `event_id`='%i', "
|
||||
@@ -281,16 +245,15 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
||||
QS->items[i].from_slot, QS->items[i].to_slot, QS->items[i].item_id, QS->items[i].charges,
|
||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5,
|
||||
errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed Move Log Record Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Move Log Record Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items) {
|
||||
// Merchant transactions are from the perspective of the merchant, not the player -U
|
||||
|
||||
/* Merchant transactions are from the perspective of the merchant, not the player -U */
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
uint32 lastid = 0;
|
||||
@@ -300,8 +263,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3
|
||||
QS->zone_id, QS->merchant_id, QS->merchant_money.platinum, QS->merchant_money.gold, QS->merchant_money.silver, QS->merchant_money.copper, QS->merchant_count,
|
||||
QS->char_id, QS->char_money.platinum, QS->char_money.gold, QS->char_money.silver, QS->char_money.copper, QS->char_count),
|
||||
errbuf, 0, 0, &lastid)) {
|
||||
_log(NET__WORLD, "Failed Transaction Log Record Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Transaction Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
|
||||
if(Items > 0) {
|
||||
@@ -312,10 +275,29 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3
|
||||
lastid, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1,
|
||||
QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5,
|
||||
errbuf, 0, 0))) {
|
||||
_log(NET__WORLD, "Failed Transaction Log Record Entry Insert: %s", errbuf);
|
||||
_log(NET__WORLD, "%s", query);
|
||||
_log(QUERYSERV__ERROR, "Failed Transaction Log Record Entry Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
}
|
||||
}
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
void Database::GeneralQueryReceive(ServerPacket *pack) {
|
||||
/*
|
||||
These are general queries passed from anywhere in zone instead of packing structures and breaking them down again and again
|
||||
*/
|
||||
char *Query = nullptr;
|
||||
Query = new char[pack->ReadUInt32() + 1];
|
||||
pack->ReadString(Query);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
uint32 lastid = 0;
|
||||
if (!RunQuery(query, MakeAnyLenString(&query, Query), errbuf, 0, 0, &lastid)) {
|
||||
_log(QUERYSERV__ERROR, "Failed Delete Log Record Insert: %s", errbuf);
|
||||
_log(QUERYSERV__ERROR, "%s", query);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
safe_delete(pack);
|
||||
safe_delete(Query);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
~Database();
|
||||
|
||||
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
|
||||
void AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type);
|
||||
void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items);
|
||||
void LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items);
|
||||
@@ -50,6 +49,7 @@ public:
|
||||
void LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items);
|
||||
void LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items);
|
||||
void LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items);
|
||||
void GeneralQueryReceive(ServerPacket *pack);
|
||||
protected:
|
||||
void HandleMysqlError(uint32 errnum);
|
||||
private:
|
||||
|
||||
@@ -22,7 +22,7 @@ PlayerLookingForGuild::PlayerLookingForGuild(char *Name, char *Comments, uint32
|
||||
|
||||
GuildLookingForPlayers::GuildLookingForPlayers(char *Name, char *Comments, uint32 FromLevel, uint32 ToLevel, uint32 Classes, uint32 AACount, uint32 Timezone, uint32 TimePosted)
|
||||
{
|
||||
this->Name = Name;
|
||||
this->Name = Name;
|
||||
this->Comments = Comments;
|
||||
this->FromLevel = FromLevel;
|
||||
this->ToLevel = ToLevel;
|
||||
|
||||
+31
-37
@@ -33,56 +33,47 @@
|
||||
|
||||
volatile bool RunLoops = true;
|
||||
|
||||
uint32 MailMessagesSent = 0;
|
||||
uint32 ChatMessagesSent = 0;
|
||||
|
||||
TimeoutManager timeout_manager;
|
||||
|
||||
Database database;
|
||||
LFGuildManager lfguildmanager;
|
||||
std::string WorldShortName;
|
||||
|
||||
const queryservconfig *Config;
|
||||
|
||||
WorldServer *worldserver = 0;
|
||||
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
|
||||
RunLoops = false;
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
RunLoops = false;
|
||||
if(worldserver)
|
||||
worldserver->Disconnect();
|
||||
}
|
||||
|
||||
int main() {
|
||||
RegisterExecutablePlatform(ExePlatformQueryServ);
|
||||
set_exception_handler();
|
||||
|
||||
Timer LFGuildExpireTimer(60000);
|
||||
|
||||
set_exception_handler();
|
||||
Timer LFGuildExpireTimer(60000);
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
|
||||
|
||||
/* Load XML from eqemu_config.xml
|
||||
<qsdatabase>
|
||||
<host>127.0.0.1</host>
|
||||
<port>3306</port>
|
||||
<username>user</username>
|
||||
<password>password</password>
|
||||
<db>dbname</db>
|
||||
</qsdatabase>
|
||||
*/
|
||||
|
||||
_log(QUERYSERV__INIT, "Starting EQEmu QueryServ.");
|
||||
|
||||
if (!queryservconfig::LoadConfig()) {
|
||||
|
||||
_log(QUERYSERV__INIT, "Loading server configuration failed.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Config = queryservconfig::get();
|
||||
|
||||
if(!load_log_settings(Config->LogSettingsFile.c_str()))
|
||||
_log(QUERYSERV__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str());
|
||||
else
|
||||
_log(QUERYSERV__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str());
|
||||
|
||||
WorldShortName = Config->ShortName;
|
||||
Config = queryservconfig::get();
|
||||
WorldShortName = Config->ShortName;
|
||||
|
||||
_log(QUERYSERV__INIT, "Connecting to MySQL...");
|
||||
|
||||
|
||||
/* MySQL Connection */
|
||||
if (!database.Connect(
|
||||
Config->QSDatabaseHost.c_str(),
|
||||
Config->QSDatabaseUsername.c_str(),
|
||||
@@ -93,6 +84,12 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize Logging */
|
||||
if (!load_log_settings(Config->LogSettingsFile.c_str()))
|
||||
_log(QUERYSERV__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str());
|
||||
else
|
||||
_log(QUERYSERV__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str());
|
||||
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
_log(QUERYSERV__ERROR, "Could not set signal handler");
|
||||
return 1;
|
||||
@@ -102,16 +99,15 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initial Connection to Worldserver */
|
||||
worldserver = new WorldServer;
|
||||
worldserver->Connect();
|
||||
|
||||
worldserver->Connect();
|
||||
|
||||
/* Load Looking For Guild Manager */
|
||||
lfguildmanager.LoadDatabase();
|
||||
|
||||
while(RunLoops) {
|
||||
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
while(RunLoops) {
|
||||
Timer::SetCurrentTime();
|
||||
if(LFGuildExpireTimer.Check())
|
||||
lfguildmanager.ExpireEntries();
|
||||
|
||||
@@ -119,10 +115,8 @@ int main() {
|
||||
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
||||
worldserver->AsyncConnect();
|
||||
}
|
||||
worldserver->Process();
|
||||
|
||||
timeout_manager.CheckTimeouts();
|
||||
|
||||
worldserver->Process();
|
||||
timeout_manager.CheckTimeouts();
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
+45
-58
@@ -56,122 +56,109 @@ void WorldServer::OnConnected()
|
||||
|
||||
void WorldServer::Process()
|
||||
{
|
||||
WorldConnection::Process();
|
||||
|
||||
WorldConnection::Process();
|
||||
if (!Connected())
|
||||
return;
|
||||
|
||||
ServerPacket *pack = 0;
|
||||
|
||||
ServerPacket *pack = 0;
|
||||
while((pack = tcpc.PopPacket()))
|
||||
{
|
||||
_log(QUERYSERV__TRACE, "Received Opcode: %4X", pack->opcode);
|
||||
|
||||
switch(pack->opcode)
|
||||
{
|
||||
_log(QUERYSERV__TRACE, "Received Opcode: %4X", pack->opcode);
|
||||
switch(pack->opcode) {
|
||||
case 0: {
|
||||
break;
|
||||
}
|
||||
case ServerOP_KeepAlive:
|
||||
{
|
||||
case ServerOP_KeepAlive: {
|
||||
break;
|
||||
}
|
||||
case ServerOP_Speech:
|
||||
{
|
||||
Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer;
|
||||
|
||||
case ServerOP_Speech: {
|
||||
Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer;
|
||||
std::string tmp1 = SSS->from;
|
||||
std::string tmp2 = SSS->to;
|
||||
|
||||
std::string tmp2 = SSS->to;
|
||||
database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogTrades:
|
||||
{
|
||||
case ServerOP_QSPlayerLogTrades: {
|
||||
QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char1_count + QS->char2_count;
|
||||
database.LogPlayerTrade(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogHandins:
|
||||
{
|
||||
case ServerOP_QSPlayerLogHandins: {
|
||||
QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count + QS->npc_count;
|
||||
database.LogPlayerHandin(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogNPCKills:
|
||||
{
|
||||
case ServerOP_QSPlayerLogNPCKills: {
|
||||
QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer;
|
||||
uint32 Members = pack->size - sizeof(QSPlayerLogNPCKill_Struct);
|
||||
if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct);
|
||||
database.LogPlayerNPCKill(QS, Members);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogDeletes:
|
||||
{
|
||||
case ServerOP_QSPlayerLogDeletes: {
|
||||
QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count;
|
||||
database.LogPlayerDelete(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSPlayerLogMoves:
|
||||
{
|
||||
case ServerOP_QSPlayerLogMoves: {
|
||||
QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count;
|
||||
database.LogPlayerMove(QS, Items);
|
||||
break;
|
||||
}
|
||||
case ServerOP_QSMerchantLogTransactions:
|
||||
{
|
||||
case ServerOP_QSPlayerLogMerchantTransactions: {
|
||||
QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)pack->pBuffer;
|
||||
uint32 Items = QS->char_count + QS->merchant_count;
|
||||
database.LogMerchantTransaction(QS, Items);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case ServerOP_QueryServGeneric:
|
||||
{
|
||||
// The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets
|
||||
// each time we add functionality to queryserv.
|
||||
//
|
||||
// A ServerOP_QueryServGeneric packet has the following format:
|
||||
//
|
||||
// uint32 SourceZoneID
|
||||
// uint32 SourceInstanceID
|
||||
// char OriginatingCharacterName[0] // Null terminated name of the character this packet came from. This could be just
|
||||
// // an empty string if it has no meaning in the context of a particular packet.
|
||||
// uint32 Type
|
||||
//
|
||||
// The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added
|
||||
// to queryserv would use 1, etc.
|
||||
//
|
||||
// Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The
|
||||
// 'Generic' in the name of this ServerOP code relates to the four header fields.
|
||||
case ServerOP_QueryServGeneric: {
|
||||
/*
|
||||
The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets
|
||||
each time we add functionality to queryserv.
|
||||
|
||||
A ServerOP_QueryServGeneric packet has the following format:
|
||||
|
||||
uint32 SourceZoneID
|
||||
uint32 SourceInstanceID
|
||||
char OriginatingCharacterName[0]
|
||||
- Null terminated name of the character this packet came from. This could be just
|
||||
- an empty string if it has no meaning in the context of a particular packet.
|
||||
uint32 Type
|
||||
|
||||
The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added
|
||||
to queryserv would use 1, etc.
|
||||
|
||||
Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The
|
||||
'Generic' in the name of this ServerOP code relates to the four header fields.
|
||||
*/
|
||||
|
||||
char From[64];
|
||||
pack->SetReadPosition(8);
|
||||
pack->ReadString(From);
|
||||
uint32 Type = pack->ReadUInt32();
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
case QSG_LFGuild:
|
||||
{
|
||||
lfguildmanager.HandlePacket(pack);
|
||||
switch(Type) {
|
||||
case QSG_LFGuild:{
|
||||
lfguildmanager.HandlePacket(pack);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
_log(QUERYSERV__ERROR, "Received unhandled ServerOP_QueryServGeneric", Type);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case ServerOP_QSSendQuery: {
|
||||
/* Process all packets here */
|
||||
database.GeneralQueryReceive(pack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
safe_delete(pack);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user