Hook up world to its own api data service

This commit is contained in:
Akkadius 2019-03-10 01:09:04 -06:00
parent 6cb9271e7e
commit e5512f05b5
7 changed files with 671 additions and 164 deletions

View File

@ -8,6 +8,7 @@ SET(world_sources
clientlist.cpp clientlist.cpp
console.cpp console.cpp
eql_config.cpp eql_config.cpp
eqemu_api_world_data_service.cpp
launcher_link.cpp launcher_link.cpp
launcher_list.cpp launcher_list.cpp
lfplist.cpp lfplist.cpp
@ -35,6 +36,7 @@ SET(world_headers
clientlist.h clientlist.h
console.h console.h
eql_config.h eql_config.h
eqemu_api_world_data_service.h
launcher_link.h launcher_link.h
launcher_list.h launcher_list.h
lfplist.h lfplist.h

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 "console.h"
#include "clientlist.h" #include "clientlist.h"
#include "login_server.h" #include "login_server.h"
@ -9,12 +29,19 @@
#include "zoneserver.h" #include "zoneserver.h"
#include "../common/string_util.h" #include "../common/string_util.h"
#include "../common/md5.h" #include "../common/md5.h"
#include "eqemu_api_world_data_service.h"
extern ClientList client_list; extern ClientList client_list;
extern ZSList zoneserver_list; extern ZSList zoneserver_list;
extern LoginServerList loginserverlist; 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; struct EQ::Net::ConsoleLoginStatus ret;
ret.account_id = database.CheckLogin(username.c_str(), password.c_str()); ret.account_id = database.CheckLogin(username.c_str(), password.c_str());
if (ret.account_id == 0) { if (ret.account_id == 0) {
@ -25,31 +52,103 @@ struct EQ::Net::ConsoleLoginStatus CheckLogin(const std::string& username, const
database.GetAccountName(ret.account_id, account_name); database.GetAccountName(ret.account_id, account_name);
ret.account_name = account_name; ret.account_name = account_name;
ret.status = database.CheckStatus(ret.account_id); ret.status = database.CheckStatus(ret.account_id);
return ret; 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 logged in as '{0}'", connection->UserName()));
connection->SendLine(fmt::format("You are known as '*{0}'", connection->UserName())); connection->SendLine(fmt::format("You are known as '*{0}'", connection->UserName()));
connection->SendLine(fmt::format("AccessLevel: '{0}'", connection->Admin())); 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); WorldConsoleTCPConnection console_connection(connection);
zoneserver_list.SendZoneStatus(0, connection->Admin(), &console_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; Who_All_Struct whom;
memset(&whom, 0, sizeof(whom)); memset(&whom, 0, sizeof(whom));
whom.lvllow = 0xFFFF; whom.lvllow = 0xFFFF;
whom.lvlhigh = 0xFFFF; whom.lvlhigh = 0xFFFF;
whom.wclass = 0xFFFF; whom.wclass = 0xFFFF;
whom.wrace = 0xFFFF; whom.wrace = 0xFFFF;
whom.gmlookup = 0xFFFF; whom.gmlookup = 0xFFFF;
for (auto &arg : args) { for (auto &arg : args) {
@ -58,13 +157,15 @@ void ConsoleWho(EQ::Net::ConsoleServerConnection* connection, const std::string&
} }
else if (StringIsNumber(arg)) { else if (StringIsNumber(arg)) {
if (whom.lvllow == 0xFFFF) { if (whom.lvllow == 0xFFFF) {
whom.lvllow = atoi(arg.c_str()); whom.lvllow = atoi(arg.c_str());
whom.lvlhigh = whom.lvllow; 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()); whom.lvlhigh = atoi(arg.c_str());
else }
else {
whom.lvllow = atoi(arg.c_str()); whom.lvllow = atoi(arg.c_str());
}
} }
else { else {
strn0cpy(whom.whom, arg.c_str(), sizeof(whom.whom)); strn0cpy(whom.whom, arg.c_str(), sizeof(whom.whom));
@ -75,21 +176,33 @@ void ConsoleWho(EQ::Net::ConsoleServerConnection* connection, const std::string&
client_list.ConsoleSendWhoAll(0, connection->Admin(), &whom, &console_connection); 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) { if (args.size() < 1) {
return; return;
} }
if (StringIsNumber(args[0]) && atoi(args[0].c_str()) > 0) { if (StringIsNumber(args[0]) && atoi(args[0].c_str()) > 0) {
auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct)); auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct));
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer; ServerUptime_Struct *sus = (ServerUptime_Struct *) pack->pBuffer;
snprintf(sus->adminname, sizeof(sus->adminname), "*%s", connection->UserName().c_str()); snprintf(sus->adminname, sizeof(sus->adminname), "*%s", connection->UserName().c_str());
sus->zoneserverid = atoi(args[0].c_str()); sus->zoneserverid = atoi(args[0].c_str());
ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); ZoneServer *zs = zoneserver_list.FindByID(sus->zoneserverid);
if (zs) if (zs) {
zs->SendPacket(pack); zs->SendPacket(pack);
else }
else {
connection->SendLine("Zoneserver not found."); connection->SendLine("Zoneserver not found.");
}
delete pack; delete pack;
} }
else { else {
@ -98,78 +211,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) { if (args.size() < 1) {
return; return;
} }
uint8 md5[16]; uint8 md5[16];
MD5::Generate((const uchar*)args[0].c_str(), strlen(args[0].c_str()), md5); 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", connection->SendLine(
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])); 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) { if (args.size() < 3) {
return; return;
} }
auto join_args = args; auto join_args = args;
join_args.erase(join_args.begin(), join_args.begin() + 2); 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()); zoneserver_list.SendEmoteMessageRaw(0, 0, 0, atoi(args[1].c_str()), JoinString(join_args, " ").c_str());
}
else { else {
ZoneServer* zs = zoneserver_list.FindByName(args[0].c_str()); ZoneServer *zs = zoneserver_list.FindByName(args[0].c_str());
if (zs != 0) if (zs != 0) {
zs->SendEmoteMessageRaw(0, 0, 0, atoi(args[1].c_str()), JoinString(join_args, " ").c_str()); 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) { if (args.size() < 1) {
connection->SendLine("Usage: acceptmessages [on/off]"); connection->SendLine("Usage: acceptmessages [on/off]");
return; return;
} }
if (strcasecmp(args[0].c_str(), "on") == 0) if (strcasecmp(args[0].c_str(), "on") == 0) {
connection->SetAcceptMessages(true); connection->SetAcceptMessages(true);
else if (strcasecmp(args[0].c_str(), "off") == 0) }
else if (strcasecmp(args[0].c_str(), "off") == 0) {
connection->SetAcceptMessages(false); connection->SetAcceptMessages(false);
else }
else {
connection->SendLine("Usage: acceptmessages [on/off]"); 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) { if (args.size() < 2) {
return; return;
} }
char tmpname[64]; char tmpname[64];
tmpname[0] = '*'; tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str()); strcpy(&tmpname[1], connection->UserName().c_str());
std::string to = args[0]; std::string to = args[0];
auto join_args = args; auto join_args = args;
join_args.erase(join_args.begin(), join_args.begin() + 1); join_args.erase(join_args.begin(), join_args.begin() + 1);
zoneserver_list.SendChannelMessage(tmpname, to.c_str(), 7, 0, JoinString(join_args, " ").c_str()); 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) { if (args.size() < 1) {
return; return;
} }
char tmpname[64]; char tmpname[64];
tmpname[0] = '*'; tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str()); strcpy(&tmpname[1], connection->UserName().c_str());
zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, JoinString(args, " ").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) { if (args.size() < 1) {
return; return;
} }
@ -180,7 +382,17 @@ void ConsoleGMSay(EQ::Net::ConsoleServerConnection* connection, const std::strin
zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, JoinString(args, " ").c_str()); 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) { if (args.size() < 1) {
return; return;
} }
@ -191,7 +403,17 @@ void ConsoleOOC(EQ::Net::ConsoleServerConnection* connection, const std::string&
zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, JoinString(args, " ").c_str()); 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) { if (args.size() < 1) {
return; return;
} }
@ -202,19 +424,29 @@ void ConsoleAuction(EQ::Net::ConsoleServerConnection* connection, const std::str
zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, JoinString(args, " ").c_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) { if (args.size() < 1) {
return; return;
} }
char tmpname[64]; char tmpname[64];
tmpname[0] = '*'; tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str()); strcpy(&tmpname[1], connection->UserName().c_str());
auto pack = new ServerPacket; auto pack = new ServerPacket;
pack->opcode = ServerOP_KickPlayer; pack->opcode = ServerOP_KickPlayer;
pack->size = sizeof(ServerKickPlayer_Struct); pack->size = sizeof(ServerKickPlayer_Struct);
pack->pBuffer = new uchar[pack->size]; 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->adminname, tmpname);
strcpy(skp->name, args[0].c_str()); strcpy(skp->name, args[0].c_str());
skp->adminrank = connection->Admin(); skp->adminrank = connection->Admin();
@ -222,7 +454,17 @@ void ConsoleKick(EQ::Net::ConsoleServerConnection* connection, const std::string
delete pack; 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(); WorldConfig::LockWorld();
if (loginserverlist.Connected()) { if (loginserverlist.Connected()) {
loginserverlist.SendStatus(); loginserverlist.SendStatus();
@ -233,7 +475,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(); WorldConfig::UnlockWorld();
if (loginserverlist.Connected()) { if (loginserverlist.Connected()) {
loginserverlist.SendStatus(); loginserverlist.SendStatus();
@ -244,12 +496,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) { if (args.size() < 1) {
connection->SendLine("Usage: zoneshutdown zoneshortname"); connection->SendLine("Usage: zoneshutdown zoneshortname");
return; return;
} }
if (args[0].length() == 0) { if (args[0].length() == 0) {
connection->SendLine("Usage: zoneshutdown zoneshortname"); connection->SendLine("Usage: zoneshutdown zoneshortname");
} }
@ -259,35 +521,52 @@ void ConsoleZoneShutdown(EQ::Net::ConsoleServerConnection* connection, const std
strcpy(&tmpname[1], connection->UserName().c_str()); strcpy(&tmpname[1], connection->UserName().c_str());
auto pack = new ServerPacket; auto pack = new ServerPacket;
pack->size = sizeof(ServerZoneStateChange_struct); pack->size = sizeof(ServerZoneStateChange_struct);
pack->pBuffer = new uchar[pack->size]; pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, sizeof(ServerZoneStateChange_struct)); 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; pack->opcode = ServerOP_ZoneShutdown;
strcpy(s->adminname, tmpname); strcpy(s->adminname, tmpname);
if (StringIsNumber(args[0])) if (StringIsNumber(args[0])) {
s->ZoneServerID = atoi(args[0].c_str()); s->ZoneServerID = atoi(args[0].c_str());
else }
else {
s->zoneid = database.GetZoneID(args[0].c_str()); s->zoneid = database.GetZoneID(args[0].c_str());
}
ZoneServer* zs = 0; ZoneServer *zs = 0;
if (s->ZoneServerID != 0) if (s->ZoneServerID != 0) {
zs = zoneserver_list.FindByID(s->ZoneServerID); zs = zoneserver_list.FindByID(s->ZoneServerID);
else if (s->zoneid != 0) }
else if (s->zoneid != 0) {
zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid)); zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid));
else }
else {
connection->SendLine("Error: ZoneShutdown: neither ID nor name specified"); connection->SendLine("Error: ZoneShutdown: neither ID nor name specified");
}
if (zs == 0) if (zs == 0) {
connection->SendLine("Error: ZoneShutdown: zoneserver not found"); connection->SendLine("Error: ZoneShutdown: zoneserver not found");
else }
else {
zs->SendPacket(pack); zs->SendPacket(pack);
}
delete 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) { if (args.size() < 2) {
return; return;
} }
@ -300,10 +579,19 @@ void ConsoleZoneBootup(EQ::Net::ConsoleServerConnection* connection, const std::
tmpname[0] = '*'; tmpname[0] = '*';
strcpy(&tmpname[1], connection->UserName().c_str()); 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) { 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 { else {
zoneserver_list.SOPZoneBootup(tmpname, atoi(args[0].c_str()), args[1].c_str(), false); zoneserver_list.SOPZoneBootup(tmpname, atoi(args[0].c_str()), args[1].c_str(), false);
@ -311,11 +599,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) { if (args.size() < 1) {
return; return;
} }
if (strcasecmp(args[0].c_str(), "list") == 0) { if (strcasecmp(args[0].c_str(), "list") == 0) {
WorldConsoleTCPConnection console_connection(connection); WorldConsoleTCPConnection console_connection(connection);
zoneserver_list.ListLockedZones(0, &console_connection); zoneserver_list.ListLockedZones(0, &console_connection);
@ -327,28 +625,34 @@ void ConsoleZoneLock(EQ::Net::ConsoleServerConnection* connection, const std::st
uint16 tmp = database.GetZoneID(args[1].c_str()); uint16 tmp = database.GetZoneID(args[1].c_str());
if (tmp) { 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)); zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(tmp));
else }
else {
connection->SendLine("Failed to change lock"); connection->SendLine("Failed to change lock");
}
} }
else else {
connection->SendLine("Usage: #zonelock lock [zonename]"); connection->SendLine("Usage: #zonelock lock [zonename]");
}
} }
else if (strcasecmp(args[0].c_str(), "unlock") == 0 && connection->Admin() >= 101) { else if (strcasecmp(args[0].c_str(), "unlock") == 0 && connection->Admin() >= 101) {
if (args.size() < 2) { if (args.size() < 2) {
return; return;
} }
uint16 tmp = database.GetZoneID(args[1].c_str()); uint16 tmp = database.GetZoneID(args[1].c_str());
if (tmp) { 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)); zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(tmp));
else }
else {
connection->SendLine("Failed to change lock"); connection->SendLine("Failed to change lock");
}
} }
else else {
connection->SendLine("Usage: #zonelock unlock [zonename]"); connection->SendLine("Usage: #zonelock unlock [zonename]");
}
} }
else { else {
connection->SendLine("#zonelock sub-commands"); connection->SendLine("#zonelock sub-commands");
@ -360,60 +664,108 @@ 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) { if (args.size() < 2) {
return; return;
} }
if (args[1].length() == 0 || !StringIsNumber(args[0])) if (args[1].length() == 0 || !StringIsNumber(args[0])) {
connection->SendLine("Usage: flag [status] [accountname]"); connection->SendLine("Usage: flag [status] [accountname]");
else }
{ else {
if (atoi(args[0].c_str()) > connection->Admin()) if (atoi(args[0].c_str()) > connection->Admin()) {
connection->SendLine("You cannot set people's status to higher than your own"); 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!"); connection->SendLine("Unable to flag account!");
else }
else {
connection->SendLine("Account Flaged"); 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) { if (args.size() != 2) {
connection->SendLine("Format: setpass accountname password"); connection->SendLine("Format: setpass accountname password");
} }
else { else {
int16 tmpstatus = 0; int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(args[0].c_str(), &tmpstatus); uint32 tmpid = database.GetAccountIDByName(args[0].c_str(), &tmpstatus);
if (!tmpid) if (!tmpid) {
connection->SendLine("Error: Account not found"); 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"); 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."); connection->SendLine("Password changed.");
else }
else {
connection->SendLine("Error changing password."); 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("Current version information."));
connection->SendLine(StringFormat(" %s", CURRENT_VERSION)); connection->SendLine(StringFormat(" %s", CURRENT_VERSION));
connection->SendLine(StringFormat(" Compiled on: %s at %s", COMPILE_DATE, COMPILE_TIME)); connection->SendLine(StringFormat(" Compiled on: %s at %s", COMPILE_DATE, COMPILE_TIME));
connection->SendLine(StringFormat(" Last modified on: %s", LAST_MODIFIED)); 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) { if (args.size() == 2) {
int32 time, interval; 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); zoneserver_list.WorldShutDown(time, interval);
} }
else { else {
connection->SendLine("Usage: worldshutdown [now] [disable] ([time] [interval])"); 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) { if (strcasecmp(args[0].c_str(), "now") == 0) {
zoneserver_list.WorldShutDown(0, 0); zoneserver_list.WorldShutDown(0, 0);
} }
@ -432,74 +784,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) { if (args.size() > 0) {
WorldConsoleTCPConnection console_connection(connection); WorldConsoleTCPConnection console_connection(connection);
client_list.SendCLEList(connection->Admin(), 0, &console_connection, args[0].c_str()); 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) { if (args.size() < 2) {
return; return;
} }
connection->SendLine(StringFormat("Signal Sent to %s with ID %i", (char*) args[0].c_str(), atoi(args[1].c_str()))); 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; uint32 message_len = strlen((char *) args[0].c_str()) + 1;
auto pack = new ServerPacket(ServerOP_CZSignalClientByName, auto pack = new ServerPacket(
sizeof(CZClientSignalByName_Struct) + message_len); ServerOP_CZSignalClientByName,
CZClientSignalByName_Struct* CZSC = (CZClientSignalByName_Struct*) pack->pBuffer; sizeof(CZClientSignalByName_Struct) + message_len
strn0cpy(CZSC->Name, (char*) args[0].c_str(), 64); );
CZClientSignalByName_Struct *CZSC = (CZClientSignalByName_Struct *) pack->pBuffer;
strn0cpy(CZSC->Name, (char *) args[0].c_str(), 64);
CZSC->data = atoi(args[1].c_str()); CZSC->data = atoi(args[1].c_str());
zoneserver_list.SendPacket(pack); zoneserver_list.SendPacket(pack);
safe_delete(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..."); connection->SendLine("Reloading World...");
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct)); auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
ReloadWorld_Struct* RW = (ReloadWorld_Struct*)pack->pBuffer; ReloadWorld_Struct *RW = (ReloadWorld_Struct *) pack->pBuffer;
RW->Option = 1; RW->Option = 1;
zoneserver_list.SendPacket(pack); zoneserver_list.SendPacket(pack);
safe_delete(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->SendLine("Exiting...");
connection->Close(); connection->Close();
} }
/**
* @param console
*/
void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console) void RegisterConsoleFunctions(std::unique_ptr<EQ::Net::ConsoleServer>& console)
{ {
console->RegisterLogin(std::bind(CheckLogin, std::placeholders::_1, std::placeholders::_2)); 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("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("api", 200, "api", std::bind(ConsoleApi, 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("auction", 50, "auction [message]", std::bind(ConsoleAuction, 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("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("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("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("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("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("zoneshutdown", 150, "zoneshutdown [zonename or ZoneServerID]", std::bind(ConsoleZoneShutdown, 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("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("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("quit", 50, "quit", std::bind(ConsoleQuit, 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)); console->RegisterCall("exit", 50, "exit", std::bind(ConsoleQuit, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
} }

View File

@ -0,0 +1,64 @@
/**
* 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 "eqemu_api_world_data_service.h"
#include "zoneserver.h"
#include "zonelist.h"
extern ZSList zoneserver_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 EQEmuApiWorldDataService::get(Json::Value &response, const std::vector<std::string> &args)
{
std::string method = args[0];
if (method == "get_zone_list") {
callGetZoneList(response);
}
}

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

View File

@ -754,3 +754,8 @@ void ZSList::OnKeepAlive(EQ::Timer *t)
zone->SendKeepAlive(); zone->SendKeepAlive();
} }
} }
const std::list<std::unique_ptr<ZoneServer>> &ZSList::getZoneServerList() const
{
return list;
}

View File

@ -21,57 +21,63 @@ public:
ZSList(); ZSList();
~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, ...); bool IsZoneLocked(uint16 iZoneID);
void SendChannelMessageRaw(const char* from, const char* to, uint8 chan_num, uint8 language, const char* message); bool SendPacket(ServerPacket *pack);
void SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...); bool SendPacket(uint32 zoneid, ServerPacket *pack);
void SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message); bool SendPacket(uint32 zoneid, uint16 instanceid, ServerPacket *pack);
bool SetLockedZone(uint16 iZoneID, bool iLock);
void SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection); EQTime worldclock;
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);
inline uint32 GetNextID() { return NextID++; }
int GetZoneCount(); 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 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); 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: private:
void OnTick(EQ::Timer *t); void OnTick(EQ::Timer *t);
void OnKeepAlive(EQ::Timer *t); void OnKeepAlive(EQ::Timer *t);
uint32 NextID; uint32 NextID;
std::list<std::unique_ptr<ZoneServer>> list;
uint16 pLockedZones[MaxLockedZones]; uint16 pLockedZones[MaxLockedZones];
uint32 CurGroupID; uint32 CurGroupID;
uint16 LastAllocatedPort; uint16 LastAllocatedPort;
std::unique_ptr<EQ::Timer> m_tick; std::unique_ptr<EQ::Timer> m_tick;
std::unique_ptr<EQ::Timer> m_keepalive; std::unique_ptr<EQ::Timer> m_keepalive;
std::list<std::unique_ptr<ZoneServer>> list;
}; };
#endif /*ZONELIST_H_*/ #endif /*ZONELIST_H_*/

View File

@ -675,4 +675,4 @@ void EQEmuApiZoneDataService::get(Json::Value &response, const std::vector<std::
if (method == "get_zone_attributes") { if (method == "get_zone_attributes") {
callGetZoneAttributes(response); callGetZoneAttributes(response);
} }
} }