mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +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:
+55
-57
@@ -75,12 +75,12 @@ And then at then end of embparser.cpp, add:
|
||||
#include "../common/rulesys.h"
|
||||
#include "qglobals.h"
|
||||
#include "quest_parser_collection.h"
|
||||
|
||||
#include "queryserv.h"
|
||||
#ifdef BOTS
|
||||
#include "bot.h"
|
||||
#endif
|
||||
|
||||
|
||||
extern QueryServ* QServ;
|
||||
extern Zone* zone;
|
||||
extern WorldServer worldserver;
|
||||
extern EntityList entity_list;
|
||||
@@ -172,8 +172,7 @@ void QuestManager::EndQuest() {
|
||||
cur = QTimerList.erase(cur);
|
||||
else
|
||||
++cur;
|
||||
}
|
||||
|
||||
}
|
||||
run.owner->Depop();
|
||||
}
|
||||
quests_running_.pop();
|
||||
@@ -1294,33 +1293,29 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
int qgNpcid = owner->GetNPCTypeID();
|
||||
|
||||
/* options value determines the availability of global variables to NPCs when a quest begins
|
||||
------------------------------------------------------------------
|
||||
value npcid player zone
|
||||
------------------------------------------------------------------
|
||||
0 this this this
|
||||
1 all this this
|
||||
2 this all this
|
||||
3 all all this
|
||||
4 this this all
|
||||
5 all this all
|
||||
6 this all all
|
||||
7 all all all
|
||||
------------------------------------------------------------------
|
||||
value npcid player zone
|
||||
------------------------------------------------------------------
|
||||
0 this this this
|
||||
1 all this this
|
||||
2 this all this
|
||||
3 all all this
|
||||
4 this this all
|
||||
5 all this all
|
||||
6 this all all
|
||||
7 all all all
|
||||
*/
|
||||
if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved
|
||||
{
|
||||
qgCharid=initiator->CharacterID();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (initiator && initiator->IsClient()){ // some events like waypoint and spawn don't have a player involved
|
||||
qgCharid=initiator->CharacterID();
|
||||
}
|
||||
else {
|
||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||
}
|
||||
if (options < 0 || options > 7)
|
||||
{
|
||||
if (options < 0 || options > 7) {
|
||||
std::cerr << "Invalid options for global var " << varname << " using defaults" << std::endl;
|
||||
} // default = 0 (only this npcid,player and zone)
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (options & 1)
|
||||
qgNpcid=0;
|
||||
if (options & 2)
|
||||
@@ -1330,30 +1325,32 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
}
|
||||
|
||||
InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, newvalue, QGVarDuration(duration));
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Update :: qglobal:%s to qvalue:%s zoneid:%i instid:%i", varname, newvalue, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Inserts global variable into quest_globals table */
|
||||
int QuestManager::InsertQuestGlobal(
|
||||
int charid, int npcid, int zoneid,
|
||||
const char *varname, const char *varvalue,
|
||||
int duration)
|
||||
{
|
||||
int QuestManager::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varname, const char *varvalue, int duration) {
|
||||
char *query = 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
|
||||
// Make duration string either "unix_timestamp(now()) + xxx" or "NULL"
|
||||
std::stringstream duration_ss;
|
||||
if (duration == INT_MAX)
|
||||
{
|
||||
std::stringstream duration_ss;
|
||||
if (duration == INT_MAX) {
|
||||
duration_ss << "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
duration_ss << "unix_timestamp(now()) + " << duration;
|
||||
}
|
||||
|
||||
//NOTE: this should be escaping the contents of arglist
|
||||
//npcwise a malicious script can arbitrarily alter the DB
|
||||
/*
|
||||
NOTE: this should be escaping the contents of arglist
|
||||
npcwise a malicious script can arbitrarily alter the DB
|
||||
*/
|
||||
uint32 last_id = 0;
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"REPLACE INTO quest_globals (charid, npcid, zoneid, name, value, expdate)"
|
||||
@@ -1365,9 +1362,8 @@ int QuestManager::InsertQuestGlobal(
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if(zone)
|
||||
{
|
||||
//first delete our global
|
||||
if(zone) {
|
||||
/* Delete existing qglobal data and update zone processes */
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct));
|
||||
ServerQGlobalDelete_Struct *qgd = (ServerQGlobalDelete_Struct*)pack->pBuffer;
|
||||
qgd->npc_id = npcid;
|
||||
@@ -1383,18 +1379,16 @@ int QuestManager::InsertQuestGlobal(
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
//then create a new one with the new id
|
||||
/* Create new qglobal data and update zone processes */
|
||||
pack = new ServerPacket(ServerOP_QGlobalUpdate, sizeof(ServerQGlobalUpdate_Struct));
|
||||
ServerQGlobalUpdate_Struct *qgu = (ServerQGlobalUpdate_Struct*)pack->pBuffer;
|
||||
qgu->npc_id = npcid;
|
||||
qgu->char_id = charid;
|
||||
qgu->zone_id = zoneid;
|
||||
if(duration == INT_MAX)
|
||||
{
|
||||
if(duration == INT_MAX) {
|
||||
qgu->expdate = 0xFFFFFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
qgu->expdate = Timer::GetTimeSeconds() + duration;
|
||||
}
|
||||
strcpy((char*)qgu->name, varname);
|
||||
@@ -1420,8 +1414,7 @@ int QuestManager::InsertQuestGlobal(
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QuestManager::targlobal(const char *varname, const char *value, const char *duration, int qgNpcid, int qgCharid, int qgZoneid)
|
||||
{
|
||||
void QuestManager::targlobal(const char *varname, const char *value, const char *duration, int qgNpcid, int qgCharid, int qgZoneid) {
|
||||
InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, value, QGVarDuration(duration));
|
||||
}
|
||||
|
||||
@@ -1432,15 +1425,24 @@ void QuestManager::delglobal(const char *varname) {
|
||||
int qgZoneid=zone->GetZoneID();
|
||||
int qgCharid=0;
|
||||
int qgNpcid=owner->GetNPCTypeID();
|
||||
|
||||
|
||||
|
||||
if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved
|
||||
{
|
||||
qgCharid=initiator->CharacterID();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||
}
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
|
||||
if (!database.RunQuery(query,
|
||||
MakeAnyLenString(&query,
|
||||
"DELETE FROM quest_globals WHERE name='%s'"
|
||||
@@ -1451,8 +1453,7 @@ void QuestManager::delglobal(const char *varname) {
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if(zone)
|
||||
{
|
||||
if(zone) {
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct));
|
||||
ServerQGlobalDelete_Struct *qgu = (ServerQGlobalDelete_Struct*)pack->pBuffer;
|
||||
|
||||
@@ -1701,17 +1702,14 @@ void QuestManager::showgrid(int grid) {
|
||||
pts.push_back(pt);
|
||||
|
||||
// Retrieve all waypoints for this grid
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `x`,`y`,`z` FROM grid_entries WHERE `gridid`=%i AND `zoneid`=%i ORDER BY `number`",grid,zone->GetZoneID()),errbuf,&result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `x`,`y`,`z` FROM grid_entries WHERE `gridid`=%i AND `zoneid`=%i ORDER BY `number`",grid,zone->GetZoneID()),errbuf,&result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
pt.x = atof(row[0]);
|
||||
pt.y = atof(row[1]);
|
||||
pt.z = atof(row[2]);
|
||||
pts.push_back(pt);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
|
||||
mysql_free_result(result);
|
||||
initiator->SendPathPacket(pts);
|
||||
}
|
||||
else // DB query error!
|
||||
|
||||
Reference in New Issue
Block a user