Beginning of hot reload work

This commit is contained in:
Akkadius 2020-01-31 20:25:06 -06:00
parent 6dee837f67
commit 158d8a011f
11 changed files with 201 additions and 13 deletions

View File

@ -124,6 +124,8 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
log_settings[Logs::Loginserver].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::HeadlessClient].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
/**
* RFC 5424

View File

@ -114,6 +114,7 @@ namespace Logs {
EntityManagement,
Flee,
Aura,
HotReload,
MaxCategoryID /* Don't Remove this */
};
@ -187,6 +188,7 @@ namespace Logs {
"Entity Management",
"Flee",
"Aura",
"HotReload",
};
}

View File

@ -561,6 +561,16 @@
OutF(LogSys, Logs::Detail, Logs::Aura, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogHotReload(message, ...) do {\
if (LogSys.log_settings[Logs::HotReload].is_category_enabled == 1)\
OutF(LogSys, Logs::General, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogHotReloadDetail(message, ...) do {\
if (LogSys.log_settings[Logs::HotReload].is_category_enabled == 1)\
OutF(LogSys, Logs::Detail, Logs::HotReload, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define Log(debug_level, log_category, message, ...) do {\
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@ -894,6 +904,12 @@
#define LogAuraDetail(message, ...) do {\
} while (0)
#define LogHotReload(message, ...) do {\
} while (0)
#define LogHotReloadDetail(message, ...) do {\
} while (0)
#define Log(debug_level, log_category, message, ...) do {\
} while (0)

View File

@ -197,7 +197,11 @@
#define ServerOP_CZSetEntityVariableByClientName 0x4012
#define ServerOP_UCSServerStatusRequest 0x4013
#define ServerOP_UCSServerStatusReply 0x4014
/* Query Server OP Codes */
#define ServerOP_HotReloadQuests 0x4015
/**
* QueryServer
*/
#define ServerOP_QSPlayerLogTrades 0x5010
#define ServerOP_QSPlayerLogHandins 0x5011
#define ServerOP_QSPlayerLogNPCKills 0x5012
@ -1349,12 +1353,16 @@ struct CZSetEntVarByClientName_Struct {
char m_var[256];
};
struct ReloadWorld_Struct{
struct ReloadWorld_Struct {
uint32 Option;
};
struct HotReloadQuestsStruct {
char zone_short_name[200];
};
struct ServerRequestTellQueue_Struct {
char name[64];
char name[64];
};
struct UCSServerStatus_Struct {

View File

@ -802,9 +802,9 @@ void ConsoleIpLookup(
const std::vector<std::string> &args
)
{
if (args.size() > 0) {
if (!args.empty()) {
WorldConsoleTCPConnection console_connection(connection);
client_list.SendCLEList(connection->Admin(), 0, &console_connection, args[0].c_str());
client_list.SendCLEList(connection->Admin(), nullptr, &console_connection, args[0].c_str());
}
}
@ -855,6 +855,34 @@ void ConsoleReloadWorld(
safe_delete(pack);
}
/**
* @param connection
* @param command
* @param args
*/
void ConsoleReloadZoneQuests(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.empty()) {
connection->SendLine("[zone_short_name] required as argument");
return;
}
std::string zone_short_name = args[0];
connection->SendLine(fmt::format("Reloading Zone [{}]...", zone_short_name));
auto pack = new ServerPacket(ServerOP_HotReloadQuests, sizeof(HotReloadQuestsStruct));
auto *hot_reload_quests = (HotReloadQuestsStruct *) pack->pBuffer;
strn0cpy(hot_reload_quests->zone_short_name, (char *) zone_short_name.c_str(), 200);
zoneserver_list.SendPacket(pack);
safe_delete(pack);
}
/**
* @param connection
* @param command
@ -892,7 +920,8 @@ void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console)
console->RegisterCall("md5", 50, "md5", std::bind(ConsoleMd5, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("ooc", 50, "ooc [message]", std::bind(ConsoleOOC, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("reloadworld", 200, "reloadworld", std::bind(ConsoleReloadWorld, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("setpass", 200, "setpass [accountname] [newpass]", std::bind(ConsoleSetPass, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("reloadzonequests", 200, "reloadzonequests [zone_short_name]", std::bind(ConsoleReloadZoneQuests, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("setpass", 200, "setpass [account_name] [new_password]", std::bind(ConsoleSetPass, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("signalcharbyname", 50, "signalcharbyname charname ID", std::bind(ConsoleSignalCharByName, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("tell", 50, "tell [name] [message]", std::bind(ConsoleTell, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("unlock", 150, "unlock", std::bind(ConsoleUnlock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
@ -901,9 +930,9 @@ void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console)
console->RegisterCall("who", 50, "who", std::bind(ConsoleWho, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("whoami", 50, "whoami", std::bind(ConsoleWhoami, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("worldshutdown", 200, "worldshutdown", std::bind(ConsoleWorldShutdown, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zonebootup", 150, "zonebootup [ZoneServerID] [zonename]", std::bind(ConsoleZoneBootup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zonelock", 150, "zonelock [list|lock|unlock] [zonename]", std::bind(ConsoleZoneLock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zoneshutdown", 150, "zoneshutdown [zonename or ZoneServerID]", std::bind(ConsoleZoneShutdown, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zonebootup", 150, "zonebootup [zone_server_id] [zone_short_name]", std::bind(ConsoleZoneBootup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zonelock", 150, "zonelock [list|lock|unlock] [zone_short_name]", std::bind(ConsoleZoneLock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zoneshutdown", 150, "zoneshutdown [zone_short_name or zone_server_id]", std::bind(ConsoleZoneShutdown, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("zonestatus", 50, "zonestatus", std::bind(ConsoleZoneStatus, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));console->RegisterCall("ping", 50, "ping", std::bind(ConsoleNull, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("quit", 50, "quit", std::bind(ConsoleQuit, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("exit", 50, "exit", std::bind(ConsoleQuit, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

View File

@ -141,6 +141,7 @@ SET(zone_sources
zone.cpp
zone_config.cpp
zonedb.cpp
zone_reload.cpp
zoning.cpp
)
@ -247,7 +248,8 @@ SET(zone_headers
zone.h
zone_config.h
zonedb.h
zonedump.h)
zonedump.h
zone_reload.h )
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})

View File

@ -51,6 +51,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "worldserver.h"
#include "zone.h"
#include "zone_config.h"
#include "zone_reload.h"
extern EntityList entity_list;
@ -1930,15 +1931,40 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
iter++;
}
}
case ServerOP_ReloadWorld:
{
ReloadWorld_Struct* RW = (ReloadWorld_Struct*)pack->pBuffer;
auto* reload_world = (ReloadWorld_Struct*)pack->pBuffer;
if (zone) {
zone->ReloadWorld(RW->Option);
zone->ReloadWorld(reload_world->Option);
}
break;
}
case ServerOP_HotReloadQuests:
{
if (!zone) {
break;
}
auto *hot_reload_quests = (HotReloadQuestsStruct *) pack->pBuffer;
LogHotReloadDetail(
"Receiving request [HotReloadQuests] | request_zone [{}] current_zone [{}]",
hot_reload_quests->zone_short_name,
zone->GetShortName()
);
std::string request_zone_short_name = hot_reload_quests->zone_short_name;
std::string local_zone_short_name = zone->GetShortName();
if (request_zone_short_name == local_zone_short_name || request_zone_short_name == "all"){
zone->SetQuestHotReloadQueued(true);
}
break;
}
case ServerOP_ChangeSharedMem:
{
std::string hotfix_name = std::string((char*)pack->pBuffer);

View File

@ -55,6 +55,7 @@
#include "mob_movement_manager.h"
#include "npc_scale_manager.h"
#include "../common/data_verification.h"
#include "zone_reload.h"
#include <time.h>
#include <ctime>
@ -771,6 +772,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
clientauth_timer(AUTHENTICATION_TIMEOUT * 1000),
spawn2_timer(1000),
hot_reload_timer(1000),
qglobal_purge_timer(30000),
hotzone_timer(120000),
m_SafePoint(0.0f,0.0f,0.0f),
@ -874,6 +876,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
mMovementManager = &MobMovementManager::Get();
SetNpcPositionUpdateDistance(0);
SetQuestHotReloadQueued(false);
}
Zone::~Zone() {
@ -1231,6 +1234,24 @@ bool Zone::Process() {
}
}
if (hot_reload_timer.Check() && IsQuestHotReloadQueued()) {
LogHotReloadDetail("Hot reload timer check...");
bool perform_reload = true;
for (auto &it : entity_list.GetClientList()) {
auto client = it.second;
if (client->GetAggroCount() > 0) {
perform_reload = false;
break;
}
}
if (perform_reload) {
ZoneReload::HotReloadQuests();
}
}
if(initgrids_timer.Check()) {
//delayed grid loading stuff.
initgrids_timer.Disable();
@ -1540,7 +1561,6 @@ void Zone::RepopClose(const glm::vec4& client_position, uint32 repop_distance)
void Zone::Repop(uint32 delay)
{
if (!Depop()) {
return;
}
@ -2422,3 +2442,13 @@ void Zone::CalculateNpcUpdateDistanceSpread()
combined_spread
);
}
bool Zone::IsQuestHotReloadQueued() const
{
return quest_hot_reload_queued;
}
void Zone::SetQuestHotReloadQueued(bool in_quest_hot_reload_queued)
{
quest_hot_reload_queued = in_quest_hot_reload_queued;
}

View File

@ -204,6 +204,7 @@ public:
time_t weather_timer;
Timer spawn2_timer;
Timer hot_reload_timer;
uint8 weather_intensity;
uint8 zone_weather;
@ -270,6 +271,9 @@ public:
void UpdateQGlobal(uint32 qid, QGlobal newGlobal);
void weatherSend(Client *client = nullptr);
bool IsQuestHotReloadQueued() const;
void SetQuestHotReloadQueued(bool in_quest_hot_reload_queued);
WaterMap *watermap;
ZonePoint *GetClosestZonePoint(const glm::vec3 &location, uint32 to, Client *client, float max_distance = 40000.0f);
ZonePoint *GetClosestZonePointWithoutZone(float x, float y, float z, Client *client, float max_distance = 40000.0f);
@ -340,6 +344,9 @@ private:
bool m_ucss_available;
bool staticzone;
bool zone_has_current_time;
bool quest_hot_reload_queued;
private:
double max_movement_update_range;
char *long_name;
char *map_name;

35
zone/zone_reload.cpp Normal file
View File

@ -0,0 +1,35 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "zone_reload.h"
#include "quest_parser_collection.h"
void ZoneReload::HotReloadQuests()
{
BenchTimer timer;
timer.reset();
entity_list.ClearAreas();
parse->ReloadQuests();
zone->Repop(0);
zone->SetQuestHotReloadQueued(false);
LogHotReload("[Quests] Reloading scripts in zone [{}] Time [{:.2f}]", zone->GetShortName(), timer.elapsed());
}

31
zone/zone_reload.h Normal file
View File

@ -0,0 +1,31 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef EQEMU_ZONE_RELOAD_H
#define EQEMU_ZONE_RELOAD_H
class ZoneReload {
public:
static void HotReloadQuests();
};
#endif //EQEMU_ZONE_RELOAD_H