Merge branch 'master' of https://github.com/EQEmu/Server into lsid

This commit is contained in:
Akkadius
2019-07-03 01:18:23 -05:00
2357 changed files with 37362 additions and 461725 deletions
+2
View File
@@ -8,6 +8,7 @@ SET(world_sources
clientlist.cpp
console.cpp
eql_config.cpp
eqemu_api_world_data_service.cpp
launcher_link.cpp
launcher_list.cpp
lfplist.cpp
@@ -35,6 +36,7 @@ SET(world_headers
clientlist.h
console.h
eql_config.h
eqemu_api_world_data_service.h
launcher_link.h
launcher_list.h
lfplist.h
+76 -1
View File
@@ -1452,4 +1452,79 @@ void ClientList::OnTick(EQ::Timer *t)
}
web_interface.SendEvent(out);
}
}
/**
* @param response
*/
void ClientList::GetClientList(Json::Value &response)
{
LinkedListIterator<ClientListEntry *> Iterator(clientlist);
Iterator.Reset();
while (Iterator.MoreElements()) {
ClientListEntry *cle = Iterator.GetData();
Json::Value row;
row["account_id"] = cle->AccountID();
row["account_name"] = cle->AccountName();
row["admin"] = cle->Admin();
row["id"] = cle->GetID();
row["ip"] = cle->GetIP();
row["loginserver_account_id"] = cle->LSAccountID();
row["loginserver_id"] = cle->LSID();
row["loginserver_name"] = cle->LSName();
row["online"] = cle->Online();
row["world_admin"] = cle->WorldAdmin();
auto server = cle->Server();
if (server) {
row["server"]["client_address"] = server->GetCAddress();
row["server"]["client_local_address"] = server->GetCLocalAddress();
row["server"]["client_port"] = server->GetCPort();
row["server"]["compile_time"] = server->GetCompileTime();
row["server"]["id"] = server->GetID();
row["server"]["instance_id"] = server->GetInstanceID();
row["server"]["ip"] = server->GetIP();
row["server"]["is_booting"] = server->IsBootingUp();
row["server"]["launch_name"] = server->GetLaunchName();
row["server"]["launched_name"] = server->GetLaunchedName();
row["server"]["number_players"] = server->NumPlayers();
row["server"]["port"] = server->GetPort();
row["server"]["previous_zone_id"] = server->GetPrevZoneID();
row["server"]["static_zone"] = server->IsStaticZone();
row["server"]["uui"] = server->GetUUID();
row["server"]["zone_id"] = server->GetZoneID();
row["server"]["zone_long_name"] = server->GetZoneLongName();
row["server"]["zone_name"] = server->GetZoneName();
row["server"]["zone_os_pid"] = server->GetZoneOSProcessID();
}
else {
row["server"] = Json::Value();
}
row["anon"] = cle->Anon();
row["character_id"] = cle->CharID();
row["class"] = cle->class_();
row["client_version"] = cle->GetClientVersion();
row["gm"] = cle->GetGM();
row["guild_id"] = cle->GuildID();
row["instance"] = cle->instance();
row["is_local_client"] = cle->IsLocalClient();
row["level"] = cle->level();
row["lfg"] = cle->LFG();
row["lfg_comments"] = cle->GetLFGComments();
row["lfg_from_level"] = cle->GetLFGFromLevel();
row["lfg_match_filter"] = cle->GetLFGMatchFilter();
row["lfg_to_level"] = cle->GetLFGToLevel();
row["name"] = cle->name();
row["race"] = cle->race();
row["tells_off"] = cle->TellsOff();
row["zone"] = cle->zone();
response.append(row);
Iterator.Advance();
}
}
+4
View File
@@ -3,6 +3,7 @@
#include "../common/eq_packet_structs.h"
#include "../common/linked_list.h"
#include "../common/json/json.h"
#include "../common/timer.h"
#include "../common/rulesys.h"
#include "../common/servertalk.h"
@@ -67,6 +68,8 @@ public:
int GetClientCount();
void GetClients(const char *zone_name, std::vector<ClientListEntry *> &into);
void GetClientList(Json::Value &response);
private:
void OnTick(EQ::Timer *t);
inline uint32 GetNextCLEID() { return NextCLEID++; }
@@ -79,6 +82,7 @@ private:
uint32 NextCLEID;
LinkedList<ClientListEntry *> clientlist;
std::unique_ptr<EQ::Timer> m_tick;
};
+525 -126
View File
@@ -1,3 +1,23 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2019 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 "console.h"
#include "clientlist.h"
#include "login_server.h"
@@ -9,12 +29,20 @@
#include "zoneserver.h"
#include "../common/string_util.h"
#include "../common/md5.h"
#include "eqemu_api_world_data_service.h"
#include <fmt/format.h>
extern ClientList client_list;
extern ZSList zoneserver_list;
extern ClientList client_list;
extern ZSList zoneserver_list;
extern LoginServerList loginserverlist;
struct EQ::Net::ConsoleLoginStatus CheckLogin(const std::string& username, const std::string& password) {
/**
* @param username
* @param password
* @return
*/
struct EQ::Net::ConsoleLoginStatus CheckLogin(const std::string &username, const std::string &password)
{
struct EQ::Net::ConsoleLoginStatus ret;
std::string prefix = "eqemu";
std::string raw_user = "";
@@ -31,31 +59,103 @@ struct EQ::Net::ConsoleLoginStatus CheckLogin(const std::string& username, const
database.GetAccountName(ret.account_id, account_name);
ret.account_name = account_name;
ret.status = database.CheckStatus(ret.account_id);
ret.status = database.CheckStatus(ret.account_id);
return ret;
}
void ConsoleNull(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleNull(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
}
void ConsoleWhoami(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleApi(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
Json::Value root;
Json::Value response;
BenchTimer timer;
timer.reset();
EQEmuApiWorldDataService::get(response, args);
std::string method = args[0];
root["execution_time"] = std::to_string(timer.elapsed());
root["method"] = method;
root["data"] = response;
std::stringstream payload;
payload << root;
connection->SendLine(payload.str());
}
/**
* @param connection
* @param command
* @param args
*/
void ConsoleWhoami(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
connection->SendLine(fmt::format("You are logged in as '{0}'", connection->UserName()));
connection->SendLine(fmt::format("You are known as '*{0}'", connection->UserName()));
connection->SendLine(fmt::format("AccessLevel: '{0}'", connection->Admin()));
}
void ConsoleZoneStatus(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleZoneStatus(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
WorldConsoleTCPConnection console_connection(connection);
zoneserver_list.SendZoneStatus(0, connection->Admin(), &console_connection);
}
void ConsoleWho(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleWho(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
Who_All_Struct whom;
memset(&whom, 0, sizeof(whom));
whom.lvllow = 0xFFFF;
whom.lvlhigh = 0xFFFF;
whom.wclass = 0xFFFF;
whom.wrace = 0xFFFF;
whom.lvllow = 0xFFFF;
whom.lvlhigh = 0xFFFF;
whom.wclass = 0xFFFF;
whom.wrace = 0xFFFF;
whom.gmlookup = 0xFFFF;
for (auto &arg : args) {
@@ -64,13 +164,15 @@ void ConsoleWho(EQ::Net::ConsoleServerConnection* connection, const std::string&
}
else if (StringIsNumber(arg)) {
if (whom.lvllow == 0xFFFF) {
whom.lvllow = atoi(arg.c_str());
whom.lvllow = atoi(arg.c_str());
whom.lvlhigh = whom.lvllow;
}
else if (atoi(arg.c_str()) > int(whom.lvllow))
else if (atoi(arg.c_str()) > int(whom.lvllow)) {
whom.lvlhigh = atoi(arg.c_str());
else
}
else {
whom.lvllow = atoi(arg.c_str());
}
}
else {
strn0cpy(whom.whom, arg.c_str(), sizeof(whom.whom));
@@ -81,21 +183,33 @@ void ConsoleWho(EQ::Net::ConsoleServerConnection* connection, const std::string&
client_list.ConsoleSendWhoAll(0, connection->Admin(), &whom, &console_connection);
}
void ConsoleUptime(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleUptime(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
if (StringIsNumber(args[0]) && atoi(args[0].c_str()) > 0) {
auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct));
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer;
auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct));
ServerUptime_Struct *sus = (ServerUptime_Struct *) pack->pBuffer;
snprintf(sus->adminname, sizeof(sus->adminname), "*%s", connection->UserName().c_str());
sus->zoneserverid = atoi(args[0].c_str());
ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
if (zs)
ZoneServer *zs = zoneserver_list.FindByID(sus->zoneserverid);
if (zs) {
zs->SendPacket(pack);
else
}
else {
connection->SendLine("Zoneserver not found.");
}
delete pack;
}
else {
@@ -104,78 +218,167 @@ void ConsoleUptime(EQ::Net::ConsoleServerConnection* connection, const std::stri
}
}
void ConsoleMd5(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleMd5(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
uint8 md5[16];
MD5::Generate((const uchar*)args[0].c_str(), strlen(args[0].c_str()), md5);
connection->SendLine(StringFormat("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
md5[0], md5[1], md5[2], md5[3], md5[4], md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13], md5[14], md5[15]));
MD5::Generate((const uchar *) args[0].c_str(), strlen(args[0].c_str()), md5);
connection->SendLine(
StringFormat(
"MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
md5[0],
md5[1],
md5[2],
md5[3],
md5[4],
md5[5],
md5[6],
md5[7],
md5[8],
md5[9],
md5[10],
md5[11],
md5[12],
md5[13],
md5[14],
md5[15]
));
}
void ConsoleEmote(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleEmote(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 3) {
return;
}
auto join_args = args;
join_args.erase(join_args.begin(), join_args.begin() + 2);
if (strcasecmp(args[0].c_str(), "world") == 0)
if (strcasecmp(args[0].c_str(), "world") == 0) {
zoneserver_list.SendEmoteMessageRaw(0, 0, 0, atoi(args[1].c_str()), JoinString(join_args, " ").c_str());
}
else {
ZoneServer* zs = zoneserver_list.FindByName(args[0].c_str());
if (zs != 0)
ZoneServer *zs = zoneserver_list.FindByName(args[0].c_str());
if (zs != 0) {
zs->SendEmoteMessageRaw(0, 0, 0, atoi(args[1].c_str()), JoinString(join_args, " ").c_str());
else
zoneserver_list.SendEmoteMessageRaw(args[0].c_str(), 0, 0, atoi(args[1].c_str()), JoinString(join_args, " ").c_str());
}
else {
zoneserver_list.SendEmoteMessageRaw(
args[0].c_str(),
0,
0,
atoi(args[1].c_str()),
JoinString(join_args, " ").c_str());
}
}
}
void ConsoleAcceptMessages(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleAcceptMessages(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
connection->SendLine("Usage: acceptmessages [on/off]");
return;
}
if (strcasecmp(args[0].c_str(), "on") == 0)
if (strcasecmp(args[0].c_str(), "on") == 0) {
connection->SetAcceptMessages(true);
else if (strcasecmp(args[0].c_str(), "off") == 0)
}
else if (strcasecmp(args[0].c_str(), "off") == 0) {
connection->SetAcceptMessages(false);
else
}
else {
connection->SendLine("Usage: acceptmessages [on/off]");
}
}
void ConsoleTell(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleTell(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 2) {
return;
}
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
std::string to = args[0];
auto join_args = args;
join_args.erase(join_args.begin(), join_args.begin() + 1);
zoneserver_list.SendChannelMessage(tmpname, to.c_str(), 7, 0, JoinString(join_args, " ").c_str());
}
void ConsoleBroadcast(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleBroadcast(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, JoinString(args, " ").c_str());
}
void ConsoleGMSay(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleGMSay(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
@@ -186,7 +389,17 @@ void ConsoleGMSay(EQ::Net::ConsoleServerConnection* connection, const std::strin
zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, JoinString(args, " ").c_str());
}
void ConsoleOOC(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleOOC(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
@@ -197,7 +410,17 @@ void ConsoleOOC(EQ::Net::ConsoleServerConnection* connection, const std::string&
zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, JoinString(args, " ").c_str());
}
void ConsoleAuction(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleAuction(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
@@ -208,19 +431,29 @@ void ConsoleAuction(EQ::Net::ConsoleServerConnection* connection, const std::str
zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, JoinString(args, " ").c_str());
}
void ConsoleKick(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleKick(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
auto pack = new ServerPacket;
pack->opcode = ServerOP_KickPlayer;
pack->size = sizeof(ServerKickPlayer_Struct);
pack->opcode = ServerOP_KickPlayer;
pack->size = sizeof(ServerKickPlayer_Struct);
pack->pBuffer = new uchar[pack->size];
ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*)pack->pBuffer;
ServerKickPlayer_Struct *skp = (ServerKickPlayer_Struct *) pack->pBuffer;
strcpy(skp->adminname, tmpname);
strcpy(skp->name, args[0].c_str());
skp->adminrank = connection->Admin();
@@ -228,7 +461,17 @@ void ConsoleKick(EQ::Net::ConsoleServerConnection* connection, const std::string
delete pack;
}
void ConsoleLock(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleLock(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
WorldConfig::LockWorld();
if (loginserverlist.Connected()) {
loginserverlist.SendStatus();
@@ -239,7 +482,17 @@ void ConsoleLock(EQ::Net::ConsoleServerConnection* connection, const std::string
}
}
void ConsoleUnlock(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleUnlock(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
WorldConfig::UnlockWorld();
if (loginserverlist.Connected()) {
loginserverlist.SendStatus();
@@ -250,12 +503,22 @@ void ConsoleUnlock(EQ::Net::ConsoleServerConnection* connection, const std::stri
}
}
void ConsoleZoneShutdown(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleZoneShutdown(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
connection->SendLine("Usage: zoneshutdown zoneshortname");
return;
}
if (args[0].length() == 0) {
connection->SendLine("Usage: zoneshutdown zoneshortname");
}
@@ -265,35 +528,52 @@ void ConsoleZoneShutdown(EQ::Net::ConsoleServerConnection* connection, const std
strcpy(&tmpname[1], connection->UserName().c_str());
auto pack = new ServerPacket;
pack->size = sizeof(ServerZoneStateChange_struct);
pack->size = sizeof(ServerZoneStateChange_struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, sizeof(ServerZoneStateChange_struct));
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer;
ServerZoneStateChange_struct *s = (ServerZoneStateChange_struct *) pack->pBuffer;
pack->opcode = ServerOP_ZoneShutdown;
strcpy(s->adminname, tmpname);
if (StringIsNumber(args[0]))
if (StringIsNumber(args[0])) {
s->ZoneServerID = atoi(args[0].c_str());
else
}
else {
s->zoneid = database.GetZoneID(args[0].c_str());
}
ZoneServer* zs = 0;
if (s->ZoneServerID != 0)
ZoneServer *zs = 0;
if (s->ZoneServerID != 0) {
zs = zoneserver_list.FindByID(s->ZoneServerID);
else if (s->zoneid != 0)
}
else if (s->zoneid != 0) {
zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid));
else
}
else {
connection->SendLine("Error: ZoneShutdown: neither ID nor name specified");
}
if (zs == 0)
if (zs == 0) {
connection->SendLine("Error: ZoneShutdown: zoneserver not found");
else
}
else {
zs->SendPacket(pack);
}
delete pack;
}
}
void ConsoleZoneBootup(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleZoneBootup(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 2) {
return;
}
@@ -306,10 +586,19 @@ void ConsoleZoneBootup(EQ::Net::ConsoleServerConnection* connection, const std::
tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str());
Log(Logs::Detail, Logs::World_Server, "Console ZoneBootup: %s, %s, %s", tmpname, args[1].c_str(), args[0].c_str());
Log(Logs::Detail,
Logs::World_Server,
"Console ZoneBootup: %s, %s, %s",
tmpname,
args[1].c_str(),
args[0].c_str());
if (args.size() > 2) {
zoneserver_list.SOPZoneBootup(tmpname, atoi(args[0].c_str()), args[1].c_str(), (bool)(strcasecmp(args[1].c_str(), "static") == 0));
zoneserver_list.SOPZoneBootup(
tmpname,
atoi(args[0].c_str()),
args[1].c_str(),
(bool) (strcasecmp(args[1].c_str(), "static") == 0));
}
else {
zoneserver_list.SOPZoneBootup(tmpname, atoi(args[0].c_str()), args[1].c_str(), false);
@@ -317,11 +606,21 @@ void ConsoleZoneBootup(EQ::Net::ConsoleServerConnection* connection, const std::
}
}
void ConsoleZoneLock(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleZoneLock(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 1) {
return;
}
if (strcasecmp(args[0].c_str(), "list") == 0) {
WorldConsoleTCPConnection console_connection(connection);
zoneserver_list.ListLockedZones(0, &console_connection);
@@ -333,28 +632,34 @@ void ConsoleZoneLock(EQ::Net::ConsoleServerConnection* connection, const std::st
uint16 tmp = database.GetZoneID(args[1].c_str());
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, true))
if (zoneserver_list.SetLockedZone(tmp, true)) {
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(tmp));
else
}
else {
connection->SendLine("Failed to change lock");
}
}
else
else {
connection->SendLine("Usage: #zonelock lock [zonename]");
}
}
else if (strcasecmp(args[0].c_str(), "unlock") == 0 && connection->Admin() >= 101) {
if (args.size() < 2) {
return;
}
uint16 tmp = database.GetZoneID(args[1].c_str());
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, false))
if (zoneserver_list.SetLockedZone(tmp, false)) {
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(tmp));
else
}
else {
connection->SendLine("Failed to change lock");
}
}
else
else {
connection->SendLine("Usage: #zonelock unlock [zonename]");
}
}
else {
connection->SendLine("#zonelock sub-commands");
@@ -366,25 +671,48 @@ void ConsoleZoneLock(EQ::Net::ConsoleServerConnection* connection, const std::st
}
}
void ConsoleFlag(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleFlag(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 2) {
return;
}
if (args[1].length() == 0 || !StringIsNumber(args[0]))
if (args[1].length() == 0 || !StringIsNumber(args[0])) {
connection->SendLine("Usage: flag [status] [accountname]");
else
{
if (atoi(args[0].c_str()) > connection->Admin())
}
else {
if (atoi(args[0].c_str()) > connection->Admin()) {
connection->SendLine("You cannot set people's status to higher than your own");
else if (!database.SetAccountStatus(args[1].c_str(), atoi(args[0].c_str())))
}
else if (!database.SetAccountStatus(args[1].c_str(), atoi(args[0].c_str()))) {
connection->SendLine("Unable to flag account!");
else
}
else {
connection->SendLine("Account Flaged");
}
}
}
void ConsoleSetPass(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleSetPass(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() != 2) {
connection->SendLine("Format: setpass accountname password");
}
@@ -398,33 +726,58 @@ void ConsoleSetPass(EQ::Net::ConsoleServerConnection* connection, const std::str
uint32 tmpid = database.GetAccountIDByName(raw_user.c_str(), prefix.c_str(), &tmpstatus);
if (!tmpid)
connection->SendLine("Error: Account not found");
else if (tmpstatus > connection->Admin())
}
else if (tmpstatus > connection->Admin()) {
connection->SendLine("Cannot change password: Account's status is higher than yours");
else if (database.SetLocalPassword(tmpid, args[1].c_str()))
}
else if (database.SetLocalPassword(tmpid, args[1].c_str())) {
connection->SendLine("Password changed.");
else
}
else {
connection->SendLine("Error changing password.");
}
}
}
void ConsoleVersion(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleVersion(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
connection->SendLine(StringFormat("Current version information."));
connection->SendLine(StringFormat(" %s", CURRENT_VERSION));
connection->SendLine(StringFormat(" Compiled on: %s at %s", COMPILE_DATE, COMPILE_TIME));
connection->SendLine(StringFormat(" Last modified on: %s", LAST_MODIFIED));
}
void ConsoleWorldShutdown(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleWorldShutdown(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() == 2) {
int32 time, interval;
if (StringIsNumber(args[0]) && StringIsNumber(args[1]) && ((time = atoi(args[0].c_str()))>0) && ((interval = atoi(args[1].c_str()))>0)) {
if (StringIsNumber(args[0]) && StringIsNumber(args[1]) && ((time = atoi(args[0].c_str())) > 0) &&
((interval = atoi(args[1].c_str())) > 0)) {
zoneserver_list.WorldShutDown(time, interval);
}
else {
connection->SendLine("Usage: worldshutdown [now] [disable] ([time] [interval])");
}
}
else if(args.size() == 1) {
else if (args.size() == 1) {
if (strcasecmp(args[0].c_str(), "now") == 0) {
zoneserver_list.WorldShutDown(0, 0);
}
@@ -443,74 +796,120 @@ void ConsoleWorldShutdown(EQ::Net::ConsoleServerConnection* connection, const st
}
}
void ConsoleIpLookup(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleIpLookup(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() > 0) {
WorldConsoleTCPConnection console_connection(connection);
client_list.SendCLEList(connection->Admin(), 0, &console_connection, args[0].c_str());
}
}
void ConsoleSignalCharByName(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleSignalCharByName(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
if (args.size() < 2) {
return;
}
connection->SendLine(StringFormat("Signal Sent to %s with ID %i", (char*) args[0].c_str(), atoi(args[1].c_str())));
uint32 message_len = strlen((char*) args[0].c_str()) + 1;
auto pack = new ServerPacket(ServerOP_CZSignalClientByName,
sizeof(CZClientSignalByName_Struct) + message_len);
CZClientSignalByName_Struct* CZSC = (CZClientSignalByName_Struct*) pack->pBuffer;
strn0cpy(CZSC->Name, (char*) args[0].c_str(), 64);
connection->SendLine(StringFormat("Signal Sent to %s with ID %i", (char *) args[0].c_str(), atoi(args[1].c_str())));
uint32 message_len = strlen((char *) args[0].c_str()) + 1;
auto pack = new ServerPacket(
ServerOP_CZSignalClientByName,
sizeof(CZClientSignalByName_Struct) + message_len
);
CZClientSignalByName_Struct *CZSC = (CZClientSignalByName_Struct *) pack->pBuffer;
strn0cpy(CZSC->Name, (char *) args[0].c_str(), 64);
CZSC->data = atoi(args[1].c_str());
zoneserver_list.SendPacket(pack);
safe_delete(pack);
}
void ConsoleReloadWorld(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleReloadWorld(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
connection->SendLine("Reloading World...");
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
ReloadWorld_Struct* RW = (ReloadWorld_Struct*)pack->pBuffer;
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
ReloadWorld_Struct *RW = (ReloadWorld_Struct *) pack->pBuffer;
RW->Option = 1;
zoneserver_list.SendPacket(pack);
safe_delete(pack);
}
void ConsoleQuit(EQ::Net::ConsoleServerConnection* connection, const std::string& command, const std::vector<std::string>& args) {
/**
* @param connection
* @param command
* @param args
*/
void ConsoleQuit(
EQ::Net::ConsoleServerConnection *connection,
const std::string &command,
const std::vector<std::string> &args
)
{
connection->SendLine("Exiting...");
connection->Close();
}
/**
* @param console
*/
void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console)
{
console->RegisterLogin(std::bind(CheckLogin, std::placeholders::_1, std::placeholders::_2));
console->RegisterCall("whoami", 50, "whoami", std::bind(ConsoleWhoami, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("who", 50, "who", std::bind(ConsoleWho, 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("uptime", 50, "uptime [zoneID#]", std::bind(ConsoleUptime, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("md5", 50, "md5", std::bind(ConsoleMd5, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("emote", 50, "emote [zonename or charname or world] [type] [message]", std::bind(ConsoleEmote, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("echo", 50, "echo [on/off]", std::bind(ConsoleNull, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("acceptmessages", 50, "acceptmessages [on/off]", std::bind(ConsoleAcceptMessages, 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("broadcast", 50, "broadcast [message]", std::bind(ConsoleBroadcast, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("gmsay", 50, "gmsay [message]", std::bind(ConsoleGMSay, 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("api", 200, "api", std::bind(ConsoleApi, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("auction", 50, "auction [message]", std::bind(ConsoleAuction, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("broadcast", 50, "broadcast [message]", std::bind(ConsoleBroadcast, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("echo", 50, "echo [on/off]", std::bind(ConsoleNull, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("emote", 50, "emote [zonename or charname or world] [type] [message]", std::bind(ConsoleEmote, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("flag", 200, "flag [status] [accountname]", std::bind(ConsoleFlag, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("gmsay", 50, "gmsay [message]", std::bind(ConsoleGMSay, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("iplookup", 50, "IPLookup [name]", std::bind(ConsoleIpLookup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("kick", 150, "kick [charname]", std::bind(ConsoleKick, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("lock", 150, "lock", std::bind(ConsoleLock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("lsreconnect", 50, "LSReconnect", std::bind(ConsoleNull, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
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("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));
console->RegisterCall("zoneshutdown", 150, "zoneshutdown [zonename or ZoneServerID]", std::bind(ConsoleZoneShutdown, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("uptime", 50, "uptime [zoneID#]", std::bind(ConsoleUptime, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("version", 50, "version", std::bind(ConsoleVersion, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
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("flag", 200, "flag [status] [accountname]", std::bind(ConsoleFlag, 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("version", 50, "version", std::bind(ConsoleVersion, 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("iplookup", 50, "IPLookup [name]", std::bind(ConsoleIpLookup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
console->RegisterCall("lsreconnect", 50, "LSReconnect", std::bind(ConsoleNull, 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("reloadworld", 200, "reloadworld", std::bind(ConsoleReloadWorld, 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("zoneshutdown", 150, "zoneshutdown [zonename or ZoneServerID]", 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));
}
+74
View File
@@ -0,0 +1,74 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2019 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 "clientlist.h"
#include "cliententry.h"
#include "eqemu_api_world_data_service.h"
#include "zoneserver.h"
#include "zonelist.h"
extern ZSList zoneserver_list;
extern ClientList client_list;
void callGetZoneList(Json::Value &response)
{
for (auto &zone : zoneserver_list.getZoneServerList()) {
Json::Value row;
row["booting_up"] = zone->IsBootingUp();
row["client_address"] = zone->GetCAddress();
row["client_local_address"] = zone->GetCLocalAddress();
row["client_port"] = zone->GetCPort();
row["compile_time"] = zone->GetCompileTime();
row["id"] = zone->GetID();
row["instance_id"] = zone->GetInstanceID();
row["ip"] = zone->GetIP();
row["is_static_zone"] = zone->IsStaticZone();
row["launch_name"] = zone->GetLaunchName();
row["launched_name"] = zone->GetLaunchedName();
row["number_players"] = zone->NumPlayers();
row["port"] = zone->GetPort();
row["previous_zone_id"] = zone->GetPrevZoneID();
row["uuid"] = zone->GetUUID();
row["zone_id"] = zone->GetZoneID();
row["zone_long_name"] = zone->GetZoneLongName();
row["zone_name"] = zone->GetZoneName();
row["zone_os_pid"] = zone->GetZoneOSProcessID();
response.append(row);
}
}
void callGetClientList(Json::Value &response)
{
client_list.GetClientList(response);
}
void EQEmuApiWorldDataService::get(Json::Value &response, const std::vector<std::string> &args)
{
std::string method = args[0];
if (method == "get_zone_list") {
callGetZoneList(response);
}
if (method == "get_client_list") {
callGetClientList(response);
}
}
+32
View File
@@ -0,0 +1,32 @@
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2019 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_API_WORLD_DATA_SERVICE_H
#define EQEMU_API_WORLD_DATA_SERVICE_H
#include "../common/json/json.h"
class EQEmuApiWorldDataService {
public:
static void get(Json::Value &response, const std::vector<std::string> &args);
};
#endif //EQEMU_API_WORLD_DATA_SERVICE_H
+2 -2
View File
@@ -19,8 +19,8 @@
#define LAUNCHERLINK_H_
#include "../common/timer.h"
#include "../net/servertalk_server_connection.h"
#include "../event/timer.h"
#include "../common/net/servertalk_server_connection.h"
#include "../common/event/timer.h"
#include <memory>
#include <string>
#include <vector>
+1 -1
View File
@@ -19,7 +19,7 @@
#define LAUNCHERLIST_H_
#include "../common/types.h"
#include "../net/servertalk_server_connection.h"
#include "../common/net/servertalk_server_connection.h"
#include <map>
#include <vector>
#include <string>
+4 -2
View File
@@ -24,11 +24,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/version.h"
#include "../common/servertalk.h"
#include "../common/misc_functions.h"
#include "login_server.h"
#include "login_server_list.h"
#include "../common/eq_packet_structs.h"
#include "../common/packet_dump.h"
#include "../common/string_util.h"
#include "../common/eqemu_logsys.h"
#include "../common/eqemu_logsys_fmt.h"
#include "login_server.h"
#include "login_server_list.h"
#include "zoneserver.h"
#include "worlddb.h"
#include "zonelist.h"
+4 -2
View File
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/string_util.h"
#include "../common/eqemu_logsys.h"
#include "../common/eqemu_logsys_fmt.h"
#include "../common/queue.h"
#include "../common/timer.h"
#include "../common/eq_packet.h"
@@ -502,11 +503,12 @@ int main(int argc, char** argv) {
web_interface.RemoveConnection(connection);
});
EQ::Net::EQStreamManagerOptions opts(9000, false, false);
EQStreamManagerInterfaceOptions opts(9000, false, false);
opts.daybreak_options.resend_delay_ms = RuleI(Network, ResendDelayBaseMS);
opts.daybreak_options.resend_delay_factor = RuleR(Network, ResendDelayFactor);
opts.daybreak_options.resend_delay_min = RuleI(Network, ResendDelayMinMS);
opts.daybreak_options.resend_delay_max = RuleI(Network, ResendDelayMaxMS);
opts.daybreak_options.outgoing_data_rate = RuleR(Network, ClientDataRate);
EQ::Net::EQStreamManager eqsm(opts);
@@ -525,7 +527,7 @@ int main(int argc, char** argv) {
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
stream_identifier.AddStream(stream);
LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->GetRemoteIP(), ntohs(stream->GetRemotePort()));
});
while (RunLoops) {
+51 -46
View File
@@ -67,16 +67,16 @@ void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) {
}
void ZSList::Add(ZoneServer* zoneserver) {
list.push_back(std::unique_ptr<ZoneServer>(zoneserver));
zone_server_list.push_back(std::unique_ptr<ZoneServer>(zoneserver));
zoneserver->SendGroupIDs();
}
void ZSList::Remove(const std::string &uuid)
{
auto iter = list.begin();
while (iter != list.end()) {
auto iter = zone_server_list.begin();
while (iter != zone_server_list.end()) {
if ((*iter)->GetUUID().compare(uuid) == 0) {
list.erase(iter);
zone_server_list.erase(iter);
return;
}
iter++;
@@ -84,10 +84,10 @@ void ZSList::Remove(const std::string &uuid)
}
void ZSList::KillAll() {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
(*iterator)->Disconnect();
iterator = list.erase(iterator);
iterator = zone_server_list.erase(iterator);
}
}
@@ -110,8 +110,8 @@ void ZSList::Process() {
}
bool ZSList::SendPacket(ServerPacket* pack) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
(*iterator)->SendPacket(pack);
iterator++;
}
@@ -119,8 +119,8 @@ bool ZSList::SendPacket(ServerPacket* pack) {
}
bool ZSList::SendPacket(uint32 ZoneID, ServerPacket* pack) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetZoneID() == ZoneID) {
ZoneServer* tmp = (*iterator).get();
tmp->SendPacket(pack);
@@ -134,8 +134,8 @@ bool ZSList::SendPacket(uint32 ZoneID, ServerPacket* pack) {
bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
if (instanceID != 0)
{
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetInstanceID() == instanceID) {
ZoneServer* tmp = (*iterator).get();
tmp->SendPacket(pack);
@@ -146,8 +146,8 @@ bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
}
else
{
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetZoneID() == ZoneID
&& (*iterator)->GetInstanceID() == 0) {
ZoneServer* tmp = (*iterator).get();
@@ -161,8 +161,8 @@ bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
}
ZoneServer* ZSList::FindByName(const char* zonename) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if (strcasecmp((*iterator)->GetZoneName(), zonename) == 0) {
ZoneServer* tmp = (*iterator).get();
return tmp;
@@ -173,8 +173,8 @@ ZoneServer* ZSList::FindByName(const char* zonename) {
}
ZoneServer* ZSList::FindByID(uint32 ZoneID) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetID() == ZoneID) {
ZoneServer* tmp = (*iterator).get();
return tmp;
@@ -185,8 +185,8 @@ ZoneServer* ZSList::FindByID(uint32 ZoneID) {
}
ZoneServer* ZSList::FindByZoneID(uint32 ZoneID) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
ZoneServer* tmp = (*iterator).get();
if (tmp->GetZoneID() == ZoneID && tmp->GetInstanceID() == 0) {
return tmp;
@@ -197,8 +197,8 @@ ZoneServer* ZSList::FindByZoneID(uint32 ZoneID) {
}
ZoneServer* ZSList::FindByPort(uint16 port) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetCPort() == port) {
ZoneServer* tmp = (*iterator).get();
return tmp;
@@ -210,8 +210,8 @@ ZoneServer* ZSList::FindByPort(uint16 port) {
ZoneServer* ZSList::FindByInstanceID(uint32 InstanceID)
{
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetInstanceID() == InstanceID) {
ZoneServer* tmp = (*iterator).get();
return tmp;
@@ -289,8 +289,8 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
ZoneServer* zone_server_data = 0;
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
zone_server_data = (*iterator).get();
auto addr = zone_server_data->GetIP();
@@ -540,8 +540,8 @@ void ZSList::SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const cha
void ZSList::RebootZone(const char* ip1, uint16 port, const char* ip2, uint32 skipid, uint32 zoneid) {
// get random zone
uint32 x = 0;
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
x++;
iterator++;
}
@@ -550,8 +550,8 @@ void ZSList::RebootZone(const char* ip1, uint16 port, const char* ip2, uint32 sk
auto tmp = new ZoneServer *[x];
uint32 y = 0;
iterator = list.begin();
while (iterator != list.end()) {
iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if (!strcmp((*iterator)->GetCAddress(), ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) {
tmp[y++] = (*iterator).get();
}
@@ -605,8 +605,8 @@ uint16 ZSList::GetAvailableZonePort()
uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
if (iInstanceID > 0)
{
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetInstanceID() == iInstanceID)
{
return (*iterator)->GetID();
@@ -614,8 +614,8 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
iterator++;
}
iterator = list.begin();
while (iterator != list.end()) {
iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) {
ZoneServer* zone = (*iterator).get();
zone->TriggerBootup(iZoneID, iInstanceID);
@@ -627,8 +627,8 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
}
else
{
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0)
{
return (*iterator)->GetID();
@@ -636,8 +636,8 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
iterator++;
}
iterator = list.begin();
while (iterator != list.end()) {
iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) {
ZoneServer* zone = (*iterator).get();
zone->TriggerBootup(iZoneID);
@@ -650,8 +650,8 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
}
void ZSList::SendLSZones() {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
ZoneServer* zs = (*iterator).get();
zs->LSBootUpdate(zs->GetZoneID(), true);
iterator++;
@@ -659,12 +659,12 @@ void ZSList::SendLSZones() {
}
int ZSList::GetZoneCount() {
return(list.size());
return(zone_server_list.size());
}
void ZSList::GetZoneIDList(std::vector<uint32> &zones) {
auto iterator = list.begin();
while (iterator != list.end()) {
auto iterator = zone_server_list.begin();
while (iterator != zone_server_list.end()) {
ZoneServer* zs = (*iterator).get();
zones.push_back(zs->GetID());
iterator++;
@@ -718,7 +718,7 @@ void ZSList::OnTick(EQ::Timer *t)
out["event"] = "EQW::ZoneUpdate";
out["data"] = Json::Value();
for (auto &zone : list)
for (auto &zone : zone_server_list)
{
Json::Value outzone;
@@ -750,7 +750,12 @@ void ZSList::OnTick(EQ::Timer *t)
void ZSList::OnKeepAlive(EQ::Timer *t)
{
for (auto &zone : list) {
for (auto &zone : zone_server_list) {
zone->SendKeepAlive();
}
}
const std::list<std::unique_ptr<ZoneServer>> &ZSList::getZoneServerList() const
{
return zone_server_list;
}
+40 -34
View File
@@ -21,57 +21,63 @@ public:
ZSList();
~ZSList();
ZoneServer* FindByName(const char* zonename);
ZoneServer* FindByID(uint32 ZoneID);
ZoneServer* FindByZoneID(uint32 ZoneID);
ZoneServer* FindByPort(uint16 port);
ZoneServer* FindByInstanceID(uint32 InstanceID);
void SendChannelMessage(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message, ...);
void SendChannelMessageRaw(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message);
void SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...);
void SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message);
bool IsZoneLocked(uint16 iZoneID);
bool SendPacket(ServerPacket *pack);
bool SendPacket(uint32 zoneid, ServerPacket *pack);
bool SendPacket(uint32 zoneid, uint16 instanceid, ServerPacket *pack);
bool SetLockedZone(uint16 iZoneID, bool iLock);
void SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection);
void SendTimeSync();
void Add(ZoneServer* zoneserver);
void Remove(const std::string &uuid);
void Process();
void KillAll();
bool SendPacket(ServerPacket* pack);
bool SendPacket(uint32 zoneid, ServerPacket* pack);
bool SendPacket(uint32 zoneid, uint16 instanceid, ServerPacket* pack);
inline uint32 GetNextID() { return NextID++; }
void RebootZone(const char* ip1,uint16 port, const char* ip2, uint32 skipid, uint32 zoneid = 0);
uint32 TriggerBootup(uint32 iZoneID, uint32 iInstanceID = 0);
void SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const char* zonename, bool iMakeStatic = false);
EQTime worldclock;
bool SetLockedZone(uint16 iZoneID, bool iLock);
bool IsZoneLocked(uint16 iZoneID);
void ListLockedZones(const char* to, WorldTCPConnection* connection);
Timer* shutdowntimer;
Timer* reminder;
void NextGroupIDs(uint32 &start, uint32 &end);
void SendLSZones();
uint16 GetAvailableZonePort();
void UpdateUCSServerAvailable(bool ucss_available = true);
EQTime worldclock;
inline uint32 GetNextID() { return NextID++; }
int GetZoneCount();
Timer *reminder;
Timer *shutdowntimer;
uint16 GetAvailableZonePort();
uint32 TriggerBootup(uint32 iZoneID, uint32 iInstanceID = 0);
void Add(ZoneServer *zoneserver);
void GetZoneIDList(std::vector<uint32> &zones);
void KillAll();
void ListLockedZones(const char *to, WorldTCPConnection *connection);
void NextGroupIDs(uint32 &start, uint32 &end);
void Process();
void RebootZone(const char *ip1, uint16 port, const char *ip2, uint32 skipid, uint32 zoneid = 0);
void Remove(const std::string &uuid);
void SendChannelMessage(const char *from, const char *to, uint8 chan_num, uint8 language, const char *message, ...);
void SendChannelMessageRaw(const char *from, const char *to, uint8 chan_num, uint8 language, const char *message);
void SendEmoteMessage(const char *to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char *message, ...);
void SendEmoteMessageRaw(const char *to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char *message);
void SendLSZones();
void SendTimeSync();
void SendZoneStatus(const char *to, int16 admin, WorldTCPConnection *connection);
void SOPZoneBootup(const char *adminname, uint32 ZoneServerID, const char *zonename, bool iMakeStatic = false);
void UpdateUCSServerAvailable(bool ucss_available = true);
void WorldShutDown(uint32 time, uint32 interval);
ZoneServer* FindByPort(uint16 port);
ZoneServer* FindByID(uint32 ZoneID);
ZoneServer* FindByInstanceID(uint32 InstanceID);
ZoneServer* FindByName(const char* zonename);
ZoneServer* FindByZoneID(uint32 ZoneID);
const std::list<std::unique_ptr<ZoneServer>> &getZoneServerList() const;
private:
void OnTick(EQ::Timer *t);
void OnKeepAlive(EQ::Timer *t);
uint32 NextID;
std::list<std::unique_ptr<ZoneServer>> list;
uint16 pLockedZones[MaxLockedZones];
uint32 CurGroupID;
uint16 LastAllocatedPort;
std::unique_ptr<EQ::Timer> m_tick;
std::unique_ptr<EQ::Timer> m_keepalive;
std::list<std::unique_ptr<ZoneServer>> zone_server_list;
};
#endif /*ZONELIST_H_*/
+3 -3
View File
@@ -19,9 +19,9 @@
#define ZONESERVER_H
#include "world_tcp_connection.h"
#include "../net/servertalk_server.h"
#include "../event/timer.h"
#include "../timer.h"
#include "../common/net/servertalk_server.h"
#include "../common/event/timer.h"
#include "../common/timer.h"
#include "console.h"
#include <string.h>
#include <string>