mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-01 11:36:36 +00:00
Merge of a monster
This commit is contained in:
+61
-57
@@ -1,19 +1,19 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
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 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.
|
||||
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
|
||||
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 "../common/global_define.h"
|
||||
@@ -35,7 +35,7 @@
|
||||
extern LauncherList launcher_list;
|
||||
|
||||
LauncherLink::LauncherLink(int id, std::shared_ptr<EQ::Net::ServertalkServerConnection> c)
|
||||
: ID(id),
|
||||
: ID(id),
|
||||
tcpc(c),
|
||||
authenticated(false),
|
||||
m_name(""),
|
||||
@@ -71,7 +71,7 @@ void LauncherLink::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
|
||||
ServerPacket tpack(opcode, p);
|
||||
ServerPacket *pack = &tpack;
|
||||
|
||||
switch(opcode) {
|
||||
switch (opcode) {
|
||||
case 0:
|
||||
break;
|
||||
case ServerOP_KeepAlive: {
|
||||
@@ -79,65 +79,65 @@ void LauncherLink::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuth: {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str());
|
||||
Log(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str());
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherConnectInfo: {
|
||||
const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer;
|
||||
if(HasName()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name);
|
||||
const LauncherConnectInfo *it = (const LauncherConnectInfo *)pack->pBuffer;
|
||||
if (HasName()) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name);
|
||||
break;
|
||||
}
|
||||
m_name = it->name;
|
||||
|
||||
|
||||
EQLConfig *config = launcher_list.GetConfig(m_name.c_str());
|
||||
if(config == nullptr) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name);
|
||||
if (config == nullptr) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name);
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name);
|
||||
|
||||
|
||||
Log(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name);
|
||||
|
||||
std::vector<LauncherZone> result;
|
||||
//database.GetLauncherZones(it->name, result);
|
||||
config->GetZones(result);
|
||||
|
||||
|
||||
std::vector<LauncherZone>::iterator cur, end;
|
||||
cur = result.begin();
|
||||
end = result.end();
|
||||
ZoneState zs;
|
||||
for(; cur != end; cur++) {
|
||||
for (; cur != end; cur++) {
|
||||
zs.port = cur->port;
|
||||
zs.up = false;
|
||||
zs.starts = 0;
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port);
|
||||
Log(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port);
|
||||
m_states[cur->name] = zs;
|
||||
}
|
||||
|
||||
|
||||
//now we add all the dynamics.
|
||||
BootDynamics(config->GetDynamicCount());
|
||||
|
||||
|
||||
m_bootTimer.Start();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneStatus: {
|
||||
const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer;
|
||||
const LauncherZoneStatus *it = (const LauncherZoneStatus *)pack->pBuffer;
|
||||
std::map<std::string, ZoneState>::iterator res;
|
||||
res = m_states.find(it->short_name);
|
||||
if(res == m_states.end()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name);
|
||||
if (res == m_states.end()) {
|
||||
Log(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name);
|
||||
break;
|
||||
}
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count);
|
||||
Log(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running ? "STARTED" : "STOPPED", it->start_count);
|
||||
res->second.up = it->running;
|
||||
res->second.starts = it->start_count;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size);
|
||||
Log(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d", pack->opcode, pack->size);
|
||||
DumpPacket(pack->pBuffer, pack->size);
|
||||
break;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ void LauncherLink::BootZone(const char *short_name, uint16 port) {
|
||||
zs.port = port;
|
||||
zs.up = false;
|
||||
zs.starts = 0;
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), short_name, zs.port);
|
||||
Log(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), short_name, zs.port);
|
||||
m_states[short_name] = zs;
|
||||
|
||||
StartZone(short_name, port);
|
||||
@@ -165,7 +165,7 @@ void LauncherLink::StartZone(const char *short_name) {
|
||||
|
||||
void LauncherLink::StartZone(const char *short_name, uint16 port) {
|
||||
auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest));
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer;
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer;
|
||||
|
||||
strn0cpy(s->short_name, short_name, 32);
|
||||
s->command = ZR_Start;
|
||||
@@ -177,7 +177,7 @@ void LauncherLink::StartZone(const char *short_name, uint16 port) {
|
||||
|
||||
void LauncherLink::RestartZone(const char *short_name) {
|
||||
auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest));
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer;
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer;
|
||||
|
||||
strn0cpy(s->short_name, short_name, 32);
|
||||
s->command = ZR_Restart;
|
||||
@@ -189,7 +189,7 @@ void LauncherLink::RestartZone(const char *short_name) {
|
||||
|
||||
void LauncherLink::StopZone(const char *short_name) {
|
||||
auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest));
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer;
|
||||
LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer;
|
||||
|
||||
strn0cpy(s->short_name, short_name, 32);
|
||||
s->command = ZR_Stop;
|
||||
@@ -200,11 +200,11 @@ void LauncherLink::StopZone(const char *short_name) {
|
||||
}
|
||||
|
||||
void LauncherLink::BootDynamics(uint8 new_count) {
|
||||
if(m_dynamicCount == new_count)
|
||||
if (m_dynamicCount == new_count)
|
||||
return;
|
||||
|
||||
ZoneState zs;
|
||||
if(m_dynamicCount < new_count) {
|
||||
if (m_dynamicCount < new_count) {
|
||||
//we are booting more dynamics.
|
||||
|
||||
zs.port = 0;
|
||||
@@ -215,11 +215,11 @@ void LauncherLink::BootDynamics(uint8 new_count) {
|
||||
char nbuf[20];
|
||||
uint8 index;
|
||||
//"for each zone we need to boot"
|
||||
for(r = m_dynamicCount; r < new_count; r++) {
|
||||
for (r = m_dynamicCount; r < new_count; r++) {
|
||||
//find an idle ID
|
||||
for(index = m_dynamicCount+1; index < 255; index++) {
|
||||
for (index = m_dynamicCount + 1; index < 255; index++) {
|
||||
sprintf(nbuf, "dynamic_%02d", index);
|
||||
if(m_states.find(nbuf) != m_states.end())
|
||||
if (m_states.find(nbuf) != m_states.end())
|
||||
continue;
|
||||
m_states[nbuf] = zs;
|
||||
StartZone(nbuf);
|
||||
@@ -227,15 +227,17 @@ void LauncherLink::BootDynamics(uint8 new_count) {
|
||||
}
|
||||
}
|
||||
m_dynamicCount = new_count;
|
||||
} else if(new_count == 0) {
|
||||
}
|
||||
else if (new_count == 0) {
|
||||
//kill all zones...
|
||||
std::map<std::string, ZoneState>::iterator cur, end;
|
||||
cur = m_states.begin();
|
||||
end = m_states.end();
|
||||
for(; cur != end; cur++) {
|
||||
for (; cur != end; cur++) {
|
||||
StopZone(cur->first.c_str());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//need to get rid of some zones...
|
||||
|
||||
//quick and dirty way to do this.. should do better (like looking for idle zones)
|
||||
@@ -243,12 +245,13 @@ void LauncherLink::BootDynamics(uint8 new_count) {
|
||||
std::map<std::string, ZoneState>::iterator cur, end;
|
||||
cur = m_states.begin();
|
||||
end = m_states.end();
|
||||
for(; cur != end; cur++) {
|
||||
if(cur->first.find("dynamic_") == 0) {
|
||||
if(found >= new_count) {
|
||||
for (; cur != end; cur++) {
|
||||
if (cur->first.find("dynamic_") == 0) {
|
||||
if (found >= new_count) {
|
||||
//this zone exceeds the number of allowed booted zones.
|
||||
StopZone(cur->first.c_str());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
found++;
|
||||
}
|
||||
}
|
||||
@@ -264,25 +267,26 @@ void LauncherLink::GetZoneList(std::vector<std::string> &l) {
|
||||
std::map<std::string, ZoneState>::iterator cur, end;
|
||||
cur = m_states.begin();
|
||||
end = m_states.end();
|
||||
for(; cur != end; cur++) {
|
||||
for (; cur != end; cur++) {
|
||||
l.push_back(cur->first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherLink::GetZoneDetails(const char *short_name, std::map<std::string,std::string> &res) {
|
||||
void LauncherLink::GetZoneDetails(const char *short_name, std::map<std::string, std::string> &res) {
|
||||
res.clear();
|
||||
|
||||
std::map<std::string, ZoneState>::iterator r;
|
||||
r = m_states.find(short_name);
|
||||
if(r == m_states.end()) {
|
||||
if (r == m_states.end()) {
|
||||
res["error"] = "Zone Not Found";
|
||||
res["name"] = short_name;
|
||||
res["up"] = "0";
|
||||
res["starts"] = "0";
|
||||
res["port"] = "0";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res["name"] = r->first;
|
||||
res["up"] = r->second.up?"1":"0";
|
||||
res["up"] = r->second.up ? "1" : "0";
|
||||
res["starts"] = itoa(r->second.starts);
|
||||
res["port"] = itoa(r->second.port);
|
||||
}
|
||||
@@ -292,4 +296,4 @@ void LauncherLink::Shutdown() {
|
||||
auto pack = new ServerPacket(ServerOP_ShutdownAll);
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user