Decouple zone calls, cleanup logic

This commit is contained in:
Akkadius
2020-04-19 04:36:39 -05:00
parent ebda1cf601
commit 373fb3f0e7
57 changed files with 705 additions and 467 deletions
+2
View File
@@ -24,6 +24,7 @@ SET(world_sources
world_console_connection.cpp
world_server_command_handler.cpp
worlddb.cpp
world_store.cpp
zonelist.cpp
zoneserver.cpp
)
@@ -54,6 +55,7 @@ SET(world_headers
world_tcp_connection.h
world_server_command_handler.h
worlddb.h
world_store.h
zonelist.h
zoneserver.h
)
+3 -2
View File
@@ -11,6 +11,7 @@
#include "zonelist.h"
#include "clientlist.h"
#include "cliententry.h"
#include "world_store.h"
extern ZSList zoneserver_list;
extern ClientList client_list;
@@ -143,7 +144,7 @@ bool Adventure::Process()
bool Adventure::CreateInstance()
{
uint32 zone_id = content_db.GetZoneID(adventure_template->zone);
uint32 zone_id = ZoneID(adventure_template->zone);
if(!zone_id)
{
return false;
@@ -362,7 +363,7 @@ void Adventure::Finished(AdventureWinStatus ws)
afe.points = 0;
}
adventure_manager.AddFinishedEvent(afe);
database.UpdateAdventureStatsEntry(database.GetCharacterID((*iter).c_str()), GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
}
++iter;
+2 -1
View File
@@ -10,6 +10,7 @@
#include "zonelist.h"
#include "clientlist.h"
#include "cliententry.h"
#include "world_store.h"
#include <sstream>
#include <stdio.h>
@@ -771,7 +772,7 @@ void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int do
sizeof(ServerPlayerClickedAdventureDoorReply_Struct));
ServerPlayerClickedAdventureDoorReply_Struct *sr = (ServerPlayerClickedAdventureDoorReply_Struct*)pack->pBuffer;
strcpy(sr->player, player);
sr->zone_id = content_db.GetZoneID(t->zone);
sr->zone_id = ZoneID(t->zone);
sr->instance_id = (*iter)->GetInstanceID();
sr->x = t->dest_x;
sr->y = t->dest_y;
+40 -39
View File
@@ -46,6 +46,7 @@
#include "clientlist.h"
#include "wguild_mgr.h"
#include "sof_char_create_data.h"
#include "world_store.h"
#include <iostream>
#include <iomanip>
@@ -64,7 +65,7 @@
#include <winsock2.h>
#include <windows.h>
#else
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
#include <sys/types.h>
#endif
@@ -109,7 +110,7 @@ Client::Client(EQStreamInterface* ieqs)
m_ClientVersion = eqs->ClientVersion();
m_ClientVersionBit = EQEmu::versions::ConvertClientVersionToClientVersionBit(m_ClientVersion);
numclients++;
}
@@ -171,7 +172,7 @@ void Client::SendEnterWorld(std::string name)
void Client::SendExpansionInfo() {
auto outapp = new EQApplicationPacket(OP_ExpansionInfo, sizeof(ExpansionInfo_Struct));
ExpansionInfo_Struct *eis = (ExpansionInfo_Struct*)outapp->pBuffer;
if (RuleB(World, UseClientBasedExpansionSettings)) {
eis->Expansions = EQEmu::expansions::ConvertClientVersionToExpansionsMask(eqs->ClientVersion());
}
@@ -430,7 +431,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
if (!is_player_zoning) {
// Track who is in and who is out of the game
char *inout= (char *) "";
if (cle->GetOnline() == CLE_Status::Never){
// Desktop -> Char Select
inout = (char *) "In";
@@ -439,21 +440,21 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
// Game -> Char Select
inout=(char *) "Out";
}
// Always at Char select at this point.
// Either from a fresh client launch or coming back from the game.
// Exiting the game entirely does not come through here.
// Could use a Logging Out Completely message somewhere.
cle->SetOnline(CLE_Status::CharSelect);
LogInfo("Account ({}) Logging({}) to character select :: LSID [{}] ", cle->AccountName(), inout, cle->LSID());
}
else {
cle->SetOnline();
}
const WorldConfig *Config=WorldConfig::get();
if(Config->UpdateStats) {
auto pack = new ServerPacket;
pack->opcode = ServerOP_LSPlayerJoinWorld;
@@ -466,10 +467,10 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
loginserverlist.SendPacket(pack);
safe_delete(pack);
}
if (!is_player_zoning)
SendGuildList();
SendLogServer();
SendApproveWorld();
SendEnterWorld(cle->name());
@@ -509,18 +510,18 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app)
outapp->size = 1;
bool valid = false;
if(!database.CheckNameFilter(char_name)) {
valid = false;
if(!database.CheckNameFilter(char_name)) {
valid = false;
}
/* Name must begin with an upper-case letter. */
else if (islower(char_name[0])) {
valid = false;
}
else if (database.ReserveName(GetAccountID(), char_name)) {
valid = true;
else if (islower(char_name[0])) {
valid = false;
}
else {
valid = false;
else if (database.ReserveName(GetAccountID(), char_name)) {
valid = true;
}
else {
valid = false;
}
outapp->pBuffer[0] = valid? 1 : 0;
@@ -690,7 +691,7 @@ bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) {
return true;
}
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
if (GetAccountID() == 0) {
LogInfo("Enter world with no logged in account");
eqs->Close();
@@ -785,7 +786,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
if (tutorial_enabled) {
zone_id = RuleI(World, TutorialZoneID);
database.MoveCharacterToZone(charid, content_db.GetZoneName(zone_id));
database.MoveCharacterToZone(charid, zone_id);
}
else {
LogInfo("[{}] is trying to go to tutorial but are not allowed", char_name);
@@ -796,9 +797,9 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
}
}
if (zone_id == 0 || !content_db.GetZoneName(zone_id)) {
if (zone_id == 0 || !ZoneName(zone_id)) {
// This is to save people in an invalid zone, once it's removed from the DB
database.MoveCharacterToZone(charid, "arena");
database.MoveCharacterToZone(charid, ZoneID("arena"));
LogInfo("Zone not found in database zone_id=[{}], moveing char to arena character:[{}]", zone_id, char_name);
}
@@ -856,7 +857,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
}
QueuePacket(outapp);
safe_delete(outapp);
// set mailkey - used for duration of character session
int MailKey = emu_random.Int(1, INT_MAX);
@@ -1154,7 +1155,7 @@ void Client::EnterWorld(bool TryBootup) {
else
zone_server = zoneserver_list.FindByZoneID(zone_id);
const char *zone_name = content_db.GetZoneName(zone_id, true);
const char *zone_name = ZoneName(zone_id, true);
if (zone_server) {
if (false == enter_world_triggered) {
//Drop any clients we own in other zones.
@@ -1204,9 +1205,9 @@ void Client::EnterWorld(bool TryBootup) {
LogInfo(
"({}) [{}] [{}] (Zone ID [{}]: Instance ID: [{}]) ",
char_name,
(seen_character_select ? "Zoning from character select" : "Zoning to"),
zone_name,
zone_id,
(seen_character_select ? "Zoning from character select" : "Zoning to"),
zone_name,
zone_id,
instance_id
);
@@ -1267,7 +1268,7 @@ void Client::Clearance(int8 response)
return;
}
const char* zonename = content_db.GetZoneName(zone_id);
const char* zonename = ZoneName(zone_id);
if (zonename == 0) {
LogInfo("zonename is nullptr in Client::Clearance!!");
TellClientZoneUnavailable();
@@ -1322,7 +1323,7 @@ void Client::Clearance(int8 response)
void Client::TellClientZoneUnavailable() {
auto outapp = new EQApplicationPacket(OP_ZoneUnavail, sizeof(ZoneUnavail_Struct));
ZoneUnavail_Struct* ua = (ZoneUnavail_Struct*)outapp->pBuffer;
const char* zonename = content_db.GetZoneName(zone_id);
const char* zonename = ZoneName(zone_id);
if (zonename)
strcpy(ua->zonename, zonename);
QueuePacket(outapp);
@@ -1502,7 +1503,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
// strcpy(pp.servername, WorldConfig::get()->ShortName.c_str());
memset(pp.spell_book, 0xFF, (sizeof(uint32) * EQEmu::spells::SPELLBOOK_SIZE));
memset(pp.mem_spells, 0xFF, (sizeof(uint32) * EQEmu::spells::SPELL_GEM_COUNT));
for(i = 0; i < BUFF_COUNT; i++)
@@ -1522,11 +1523,11 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
else {
LogInfo("Found 'TitaniumStartZoneID' rule setting: [{}]", RuleI(World, TitaniumStartZoneID));
if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */
pp.zone_id = RuleI(World, TitaniumStartZoneID);
cc->start_zone = pp.zone_id;
}
}
}
/* use normal starting zone logic to either get defaults, or if startzone was set, load that from the db table.*/
bool ValidStartZone = content_db.GetStartZone(&pp, cc, m_ClientVersionBit & EQEmu::versions::maskTitaniumAndEarlier);
@@ -1568,7 +1569,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
/* Overrides if we have the tutorial flag set! */
if (cc->tutorial && RuleB(World, EnableTutorialButton)) {
pp.zone_id = RuleI(World, TutorialZoneID);
content_db.GetSafePoints(pp.zone_id, 0, &pp.x, &pp.y, &pp.z);
content_db.GetSafePoints(ZoneName(pp.zone_id), 0, &pp.x, &pp.y, &pp.z);
}
/* Will either be the same as home or tutorial if enabled. */
@@ -1581,11 +1582,11 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
}
Log(Logs::Detail, Logs::WorldServer, "Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f",
content_db.GetZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading);
ZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading);
Log(Logs::Detail, Logs::WorldServer, "Bind location: %s (%d) %0.2f, %0.2f, %0.2f",
content_db.GetZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z);
ZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z);
Log(Logs::Detail, Logs::WorldServer, "Home location: %s (%d) %0.2f, %0.2f, %0.2f",
content_db.GetZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z);
ZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z);
/* Starting Items inventory */
content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin());
@@ -2090,7 +2091,7 @@ bool Client::StoreCharacter(
return false;
}
const char *zone_name = content_db.GetZoneName(p_player_profile_struct->zone_id);
const char *zone_name = ZoneName(p_player_profile_struct->zone_id);
if (zone_name == nullptr) {
/* Zone not in the DB, something to prevent crash... */
strn0cpy(zone, "qeynos", 49);
@@ -2134,4 +2135,4 @@ bool Client::StoreCharacter(
}
return true;
}
}
+13 -12
View File
@@ -33,6 +33,7 @@
#include "../common/event_sub.h"
#include "web_interface.h"
#include "wguild_mgr.h"
#include "world_store.h"
#include <set>
extern WebInterfaceList web_interface;
@@ -107,7 +108,7 @@ void ClientList::GetCLEIP(uint32 iIP) {
iterator.Reset();
while(iterator.MoreElements()) {
countCLEIPs = iterator.GetData();
countCLEIPs = iterator.GetData();
if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // If the IP matches, and the connection admin status is below the exempt status, or exempt status is less than 0 (no-one is exempt)
IPInstances++; // Increment the occurences of this IP address
LogClientLogin("Account ID: [{}] Account Name: [{}] IP: [{}]", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
@@ -129,7 +130,7 @@ void ClientList::GetCLEIP(uint32 iIP) {
if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If the number of connections exceeds the lower limit
if (RuleB(World, MaxClientsSetByStatus)) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules
LogClientLogin("Account ID: [{}] Account Name: [{}] IP: [{}] IP Instances: [{}] Max IP Instances: [{}]", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin());
if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP
if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP
if(RuleB(World, IPLimitDisconnectAll)) {
LogClientLogin("Disconnect: All accounts on IP [{}]", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
@@ -142,7 +143,7 @@ void ClientList::GetCLEIP(uint32 iIP) {
}
}
} else if ((countCLEIPs->Admin() < RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0)) { // Else if the Admin status of the connection is not eligible for the higher limit, or there is no higher limit (AddMaxClientStatus < 0)
if(RuleB(World, IPLimitDisconnectAll)) {
if(RuleB(World, IPLimitDisconnectAll)) {
LogClientLogin("Disconnect: All accounts on IP [{}]", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
return;
@@ -152,7 +153,7 @@ void ClientList::GetCLEIP(uint32 iIP) {
iterator.RemoveCurrent();
continue;
}
} else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that
} else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that
if(RuleB(World, IPLimitDisconnectAll)) {
LogClientLogin("Disconnect: All accounts on IP [{}]", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
@@ -293,7 +294,7 @@ void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnect
if (cle->LSID())
AppendAnyLenString(&output, &outsize, &outlen, "%s LSID: %i LSName: %s WorldAdmin: %i", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin());
if (cle->CharID())
AppendAnyLenString(&output, &outsize, &outlen, "%s CharID: %i CharName: %s Zone: %s (%i)", newline, cle->CharID(), cle->name(), content_db.GetZoneName(cle->zone()), cle->zone());
AppendAnyLenString(&output, &outsize, &outlen, "%s CharID: %i CharName: %s Zone: %s (%i)", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone());
if (outlen >= 3072) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
safe_delete(output);
@@ -500,7 +501,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
countclients.Reset();
while(countclients.MoreElements()){
countcle = countclients.GetData();
const char* tmpZone = content_db.GetZoneName(countcle->zone());
const char* tmpZone = ZoneName(countcle->zone());
if (
(countcle->Online() >= CLE_Status::Zoning) &&
(!countcle->GetGM() || countcle->Anon() != 1 || admin >= countcle->Admin()) &&
@@ -580,7 +581,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
while(iterator.MoreElements()) {
cle = iterator.GetData();
const char* tmpZone = content_db.GetZoneName(cle->zone());
const char* tmpZone = ZoneName(cle->zone());
if (
(cle->Online() >= CLE_Status::Zoning) &&
(!cle->GetGM() || cle->Anon() != 1 || admin >= cle->Admin()) &&
@@ -965,7 +966,7 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
iterator.Reset();
while (iterator.MoreElements()) {
cle = iterator.GetData();
const char* tmpZone = content_db.GetZoneName(cle->zone());
const char* tmpZone = ZoneName(cle->zone());
if (
(cle->Online() >= CLE_Status::Zoning)
&& (whom == 0 || (
@@ -1086,7 +1087,7 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
else
AppendAnyLenString(&output, &outsize, &outlen, "\n");
//console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen);
}
if (output)
@@ -1282,7 +1283,7 @@ void ClientList::GetClients(const char *zone_name, std::vector<ClientListEntry *
iterator.Advance();
}
} else {
uint32 zoneid = content_db.GetZoneID(zone_name);
uint32 zoneid = ZoneID(zone_name);
while(iterator.MoreElements()) {
ClientListEntry* tmp = iterator.GetData();
if(tmp->zone() == zoneid)
@@ -1358,7 +1359,7 @@ void ClientList::SendClientVersionSummary(const char *Name)
}
zoneserver_list.SendEmoteMessage(Name, 0, 0, 13, "There are %i Titanium, %i SoF, %i SoD, %i UF, %i RoF, %i RoF2 clients currently connected.",
ClientTitaniumCount, ClientSoFCount, ClientSoDCount, ClientUnderfootCount, ClientRoFCount, ClientRoF2Count);
ClientTitaniumCount, ClientSoFCount, ClientSoDCount, ClientUnderfootCount, ClientRoFCount, ClientRoF2Count);
}
void ClientList::OnTick(EQ::Timer *t)
@@ -1378,7 +1379,7 @@ void ClientList::OnTick(EQ::Timer *t)
while (Iterator.MoreElements())
{
ClientListEntry* cle = Iterator.GetData();
Json::Value outclient;
outclient["Online"] = cle->Online();
+8 -7
View File
@@ -30,6 +30,7 @@
#include "../common/string_util.h"
#include "../common/md5.h"
#include "eqemu_api_world_data_service.h"
#include "world_store.h"
#include <fmt/format.h>
extern ClientList client_list;
@@ -541,7 +542,7 @@ void ConsoleZoneShutdown(
s->ZoneServerID = atoi(args[0].c_str());
}
else {
s->zoneid = content_db.GetZoneID(args[0].c_str());
s->zoneid = ZoneID(args[0].c_str());
}
ZoneServer *zs = 0;
@@ -549,7 +550,7 @@ void ConsoleZoneShutdown(
zs = zoneserver_list.FindByID(s->ZoneServerID);
}
else if (s->zoneid != 0) {
zs = zoneserver_list.FindByName(content_db.GetZoneName(s->zoneid));
zs = zoneserver_list.FindByName(ZoneName(s->zoneid));
}
else {
connection->SendLine("Error: ZoneShutdown: neither ID nor name specified");
@@ -633,10 +634,10 @@ void ConsoleZoneLock(
return;
}
uint16 tmp = content_db.GetZoneID(args[1].c_str());
uint16 tmp = ZoneID(args[1].c_str());
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, true)) {
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", content_db.GetZoneName(tmp));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", ZoneName(tmp));
}
else {
connection->SendLine("Failed to change lock");
@@ -651,10 +652,10 @@ void ConsoleZoneLock(
return;
}
uint16 tmp = content_db.GetZoneID(args[1].c_str());
uint16 tmp = ZoneID(args[1].c_str());
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, false)) {
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", content_db.GetZoneName(tmp));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", ZoneName(tmp));
}
else {
connection->SendLine("Failed to change lock");
@@ -936,4 +937,4 @@ void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console)
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));
}
}
+11 -11
View File
@@ -230,7 +230,7 @@ bool Console::Process() {
std::string connecting_ip = inet_ntoa(in);
SendMessage(2, StringFormat("Establishing connection from IP: %s Port: %d", inet_ntoa(in), GetPort()).c_str());
if (connecting_ip.find("127.0.0.1") != std::string::npos) {
SendMessage(2, StringFormat("Connecting established from local host, auto assuming admin").c_str());
state = CONSOLE_STATE_CONNECTED;
@@ -244,7 +244,7 @@ bool Console::Process() {
}
prompt_timer.Disable();
}
if (timeout_timer.Check()) {
@@ -269,7 +269,7 @@ bool Console::Process() {
LogInfo("New launcher from [{}]:[{}]", inet_ntoa(in), GetPort());
launcher_list.Add(tcpc);
tcpc = 0;
}
}
else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS)
{
LogInfo("New UCS Connection from [{}]:[{}]", inet_ntoa(in), GetPort());
@@ -281,7 +281,7 @@ bool Console::Process() {
LogInfo("New QS Connection from [{}]:[{}]", inet_ntoa(in), GetPort());
QSLink.SetConnection(tcpc);
tcpc = 0;
}
}
else {
LogInfo("Unsupported packet mode from [{}]:[{}]", inet_ntoa(in), GetPort());
}
@@ -616,7 +616,7 @@ void Console::ProcessCommand(const char* command) {
if(sep.arg[1][0]==0 || sep.arg[2][0] == 0)
SendMessage(1, "Usage: movechar [charactername] [zonename]");
else {
if (!content_db.GetZoneID(sep.arg[2]))
if (!ZoneID(sep.arg[2]))
SendMessage(1, "Error: Zone '%s' not found", sep.arg[2]);
else if (!database.CheckUsedName((char*) sep.arg[1])) {
if (!database.MoveCharacterToZone((char*) sep.arg[1], (char*) sep.arg[2]))
@@ -711,13 +711,13 @@ void Console::ProcessCommand(const char* command) {
if (sep.arg[1][0] >= '0' && sep.arg[1][0] <= '9')
s->ZoneServerID = atoi(sep.arg[1]);
else
s->zoneid = content_db.GetZoneID(sep.arg[1]);
s->zoneid = ZoneID(sep.arg[1]);
ZoneServer* zs = 0;
if (s->ZoneServerID != 0)
zs = zoneserver_list.FindByID(s->ZoneServerID);
else if (s->zoneid != 0)
zs = zoneserver_list.FindByName(content_db.GetZoneName(s->zoneid));
zs = zoneserver_list.FindByName(ZoneName(s->zoneid));
else
SendMessage(1, "Error: ZoneShutdown: neither ID nor name specified");
@@ -828,10 +828,10 @@ void Console::ProcessCommand(const char* command) {
zoneserver_list.ListLockedZones(0, this);
}
else if (strcasecmp(sep.arg[1], "lock") == 0 && admin >= 101) {
uint16 tmp = content_db.GetZoneID(sep.arg[2]);
uint16 tmp = ZoneID(sep.arg[2]);
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, true))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", content_db.GetZoneName(tmp));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", ZoneName(tmp));
else
SendMessage(1, "Failed to change lock");
}
@@ -839,10 +839,10 @@ void Console::ProcessCommand(const char* command) {
SendMessage(1, "Usage: #zonelock lock [zonename]");
}
else if (strcasecmp(sep.arg[1], "unlock") == 0 && admin >= 101) {
uint16 tmp = content_db.GetZoneID(sep.arg[2]);
uint16 tmp = ZoneID(sep.arg[2]);
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, false))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", content_db.GetZoneName(tmp));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", ZoneName(tmp));
else
SendMessage(1, "Failed to change lock");
}
+3 -2
View File
@@ -21,6 +21,7 @@
#include "launcher_link.h"
#include "launcher_list.h"
#include "../common/string_util.h"
#include "world_store.h"
#include <cstdlib>
#include <cstring>
@@ -156,7 +157,7 @@ void EQLConfig::StartZone(Const_char *zone_ref) {
bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(content_db.GetZoneID(short_name) == 0)
if(ZoneID(short_name) == 0)
return false;
//database update
@@ -191,7 +192,7 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(content_db.GetZoneID(short_name) == 0)
if(ZoneID(short_name) == 0)
return false;
//check internal state
+1 -1
View File
@@ -188,7 +188,7 @@ std::map<std::string,std::string> EQW::GetPlayerDetails(Const_char *char_name) {
res["character"] = cle->name();
res["account"] = cle->AccountName();
res["account_id"] = itoa(cle->AccountID());
res["location_short"] = cle->zone()?content_db.GetZoneName(cle->zone()):"No Zone";
res["location_short"] = cle->zone()?ZoneName(cle->zone()):"No Zone";
res["location_long"] = res["location_short"];
res["location_id"] = itoa(cle->zone());
res["ip"] = long2ip(cle->GetIP());
+3 -3
View File
@@ -94,7 +94,9 @@ union semun {
#include "world_server_command_handler.h"
#include "../common/content/world_content_service.h"
#include "../common/repositories/merchantlist_temp_repository.h"
#include "world_store.h"
WorldStore world_store;
ClientList client_list;
GroupLFPList LFPGroupList;
ZSList zoneserver_list;
@@ -329,9 +331,7 @@ int main(int argc, char** argv) {
LogInfo("Loading zones");
// Load to both context for now... this needs to be cleaned up as this has always been cludgy
content_db.LoadZoneNames();
database.zonename_array = content_db.zonename_array;
world_store.LoadZones();
LogInfo("Clearing groups");
database.ClearGroup();
+132
View File
@@ -0,0 +1,132 @@
/**
* 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 "world_store.h"
WorldStore::WorldStore() = default;
WorldStore::~WorldStore()= default;
void WorldStore::LoadZones()
{
zones = ZoneRepository::All();
}
uint32 WorldStore::GetZoneID(const char *in_zone_name)
{
if (in_zone_name == nullptr) {
return 0;
}
std::string zone_name = in_zone_name;
return GetZoneID(zone_name);
}
uint32 WorldStore::GetZoneID(std::string zone_name)
{
for (auto &z: zones) {
if (z.short_name == zone_name) {
return z.zoneidnumber;
}
}
return 0;
}
/**
* @param zone_id
* @param error_unknown
* @return
*/
const char *WorldStore::GetZoneName(uint32 zone_id, bool error_unknown)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name.c_str();
}
}
if (error_unknown) {
return "UNKNOWN";
}
return nullptr;
}
/**
* @param zone_id
* @return
*/
std::string WorldStore::GetZoneName(uint32 zone_id)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.short_name;
}
}
return std::string();
}
/**
* @param zone_id
* @return
*/
std::string WorldStore::GetZoneLongName(uint32 zone_id)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.long_name;
}
}
return std::string();
}
/**
* @param zone_id
* @param version
* @return
*/
ZoneRepository::Zone WorldStore::GetZone(uint32 zone_id, int version)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id && z.version == version) {
return z;
}
}
return ZoneRepository::Zone();
}
/**
* @param in_zone_name
* @return
*/
ZoneRepository::Zone WorldStore::GetZone(const char *in_zone_name)
{
for (auto &z: zones) {
if (z.short_name == in_zone_name) {
return z;
}
}
return ZoneRepository::Zone();
}
+64
View File
@@ -0,0 +1,64 @@
/**
* 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_WORLD_STORE_H
#define EQEMU_WORLD_STORE_H
#include "worlddb.h"
#include "../common/repositories/zone_repository.h"
class WorldStore {
public:
WorldStore();
virtual ~WorldStore();
std::vector<ZoneRepository::Zone> zones{};
void LoadZones();
ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0);
ZoneRepository::Zone GetZone(const char *in_zone_name);
uint32 GetZoneID(const char *in_zone_name);
uint32 GetZoneID(std::string zone_name);
std::string GetZoneName(uint32 zone_id);
std::string GetZoneLongName(uint32 zone_id);
const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
};
extern WorldStore world_store;
/**
* Global helpers
*/
inline uint32 ZoneID(const char *in_zone_name) { return world_store.GetZoneID(in_zone_name); }
inline uint32 ZoneID(std::string zone_name) { return world_store.GetZoneID(zone_name); }
inline const char *ZoneName(uint32 zone_id, bool error_unknown = false)
{
return world_store.GetZoneName(
zone_id,
error_unknown
);
}
inline const char *ZoneLongName(uint32 zone_id) { return world_store.GetZoneLongName(zone_id).c_str(); }
inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return world_store.GetZone(zone_id, version); };
inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return world_store.GetZone(in_zone_name); };
#endif //EQEMU_WORLD_STORE_H
+33 -5
View File
@@ -26,6 +26,7 @@
#include <vector>
#include "sof_char_create_data.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "world_store.h"
WorldDatabase database;
WorldDatabase content_db;
@@ -209,7 +210,13 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o
/* If a bind_id is specified, make them start there */
if (atoi(row_d[1]) != 0) {
player_profile_struct.binds[4].zoneId = (uint32) atoi(row_d[1]);
GetSafePoints(player_profile_struct.binds[4].zoneId, 0, &player_profile_struct.binds[4].x, &player_profile_struct.binds[4].y, &player_profile_struct.binds[4].z);
content_db.GetSafePoints(
ZoneName(player_profile_struct.binds[4].zoneId),
0,
&player_profile_struct.binds[4].x,
&player_profile_struct.binds[4].y,
&player_profile_struct.binds[4].z
);
}
/* Otherwise, use the zone and coordinates given */
else {
@@ -217,7 +224,15 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o
float x = atof(row_d[2]);
float y = atof(row_d[3]);
float z = atof(row_d[4]);
if (x == 0 && y == 0 && z == 0) { content_db.GetSafePoints(player_profile_struct.binds[4].zoneId, 0, &x, &y, &z); }
if (x == 0 && y == 0 && z == 0) {
content_db.GetSafePoints(
ZoneName(player_profile_struct.binds[4].zoneId),
0,
&x,
&y,
&z
);
}
player_profile_struct.binds[4].x = x;
player_profile_struct.binds[4].y = y;
player_profile_struct.binds[4].z = z;
@@ -459,11 +474,24 @@ bool WorldDatabase::GetStartZone(
}
if (p_player_profile_struct->x == 0 && p_player_profile_struct->y == 0 && p_player_profile_struct->z == 0) {
content_db.GetSafePoints(p_player_profile_struct->zone_id, 0, &p_player_profile_struct->x, &p_player_profile_struct->y, &p_player_profile_struct->z);
content_db.GetSafePoints(
ZoneName(p_player_profile_struct->zone_id),
0,
&p_player_profile_struct->x,
&p_player_profile_struct->y,
&p_player_profile_struct->z
);
}
if (p_player_profile_struct->binds[0].x == 0 && p_player_profile_struct->binds[0].y == 0 && p_player_profile_struct->binds[0].z == 0) {
content_db.GetSafePoints(p_player_profile_struct->binds[0].zoneId, 0, &p_player_profile_struct->binds[0].x, &p_player_profile_struct->binds[0].y, &p_player_profile_struct->binds[0].z);
if (p_player_profile_struct->binds[0].x == 0 && p_player_profile_struct->binds[0].y == 0 &&
p_player_profile_struct->binds[0].z == 0) {
content_db.GetSafePoints(
ZoneName(p_player_profile_struct->binds[0].zoneId),
0,
&p_player_profile_struct->binds[0].x,
&p_player_profile_struct->binds[0].y,
&p_player_profile_struct->binds[0].z
);
}
return true;
+3 -2
View File
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/json/json.h"
#include "../common/event_sub.h"
#include "web_interface.h"
#include "world_store.h"
extern uint32 numzones;
extern bool holdzones;
@@ -263,7 +264,7 @@ void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
int x = 0;
for (auto &zone : pLockedZones) {
if (zone) {
connection->SendEmoteMessageRaw(to, 0, 0, 0, content_db.GetZoneName(zone, true));
connection->SendEmoteMessageRaw(to, 0, 0, 0, ZoneName(zone, true));
x++;
}
}
@@ -529,7 +530,7 @@ void ZSList::SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const cha
ZoneServer* zs = 0;
ZoneServer* zs2 = 0;
uint32 zoneid;
if (!(zoneid = content_db.GetZoneID(zonename)))
if (!(zoneid = ZoneID(zonename)))
SendEmoteMessage(adminname, 0, 0, 0, "Error: SOP_ZoneBootup: zone '%s' not found in 'zone' table. Typo protection=ON.", zonename);
else {
if (ZoneServerID != 0)
+7 -6
View File
@@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "adventure_manager.h"
#include "ucs.h"
#include "queryserv.h"
#include "world_store.h"
extern ClientList client_list;
extern GroupLFPList LFPGroupList;
@@ -86,7 +87,7 @@ ZoneServer::~ZoneServer() {
bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
is_booting_up = false;
const char* zn = MakeLowerString(content_db.GetZoneName(iZoneID));
const char* zn = MakeLowerString(ZoneName(iZoneID));
char* longname;
if (iZoneID)
@@ -566,7 +567,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer;
if (szs->zoneid != 0) {
if (content_db.GetZoneName(szs->zoneid))
if (ZoneName(szs->zoneid))
SetZone(szs->zoneid, szs->instanceid, szs->staticzone);
else
SetZone(0);
@@ -648,7 +649,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
if (s->ZoneServerID != 0)
zs = zoneserver_list.FindByID(s->ZoneServerID);
else if (s->zoneid != 0)
zs = zoneserver_list.FindByName(content_db.GetZoneName(s->zoneid));
zs = zoneserver_list.FindByName(ZoneName(s->zoneid));
else
zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified");
@@ -660,7 +661,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
}
case ServerOP_ZoneBootup: {
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer;
zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, content_db.GetZoneName(s->zoneid), s->makestatic);
zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, ZoneName(s->zoneid), s->makestatic);
break;
}
case ServerOP_ZoneStatus: {
@@ -1018,13 +1019,13 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
break;
case 1:
if (zoneserver_list.SetLockedZone(s->zoneID, true))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", content_db.GetZoneName(s->zoneID));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", ZoneName(s->zoneID));
else
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
break;
case 2:
if (zoneserver_list.SetLockedZone(s->zoneID, false))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", content_db.GetZoneName(s->zoneID));
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", ZoneName(s->zoneID));
else
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
break;