mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-01 19:56:38 +00:00
- Add Zone Process ID (OS PID) as information passed back to world, ultimately with the ability to display it in the telnet console under 'zonestatus'
- Refactored some zoneserver/worldserver code for readability
This commit is contained in:
+75
-41
@@ -283,57 +283,84 @@ void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
|
||||
}
|
||||
|
||||
void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) {
|
||||
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
struct in_addr in;
|
||||
|
||||
iterator.Reset();
|
||||
char locked[4];
|
||||
if (WorldConfig::get()->Locked == true)
|
||||
if (WorldConfig::get()->Locked == true){
|
||||
strcpy(locked, "Yes");
|
||||
else
|
||||
}
|
||||
else {
|
||||
strcpy(locked, "No");
|
||||
}
|
||||
|
||||
char* output = 0;
|
||||
uint32 outsize = 0, outlen = 0;
|
||||
if (connection->IsConsole())
|
||||
|
||||
if (connection->IsConsole()){
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s\r\n", locked);
|
||||
else
|
||||
}
|
||||
else{
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s^", locked);
|
||||
if (connection->IsConsole())
|
||||
}
|
||||
if (connection->IsConsole()){
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:\r\n");
|
||||
else
|
||||
}
|
||||
else{
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:^");
|
||||
// connection->SendEmoteMessage(to, 0, 0, 0, "World Locked: %s", locked);
|
||||
// connection->SendEmoteMessage(to, 0, 0, 0, "Zoneservers online:");
|
||||
int v=0, w=0, x=0, y=0, z=0;
|
||||
char tmpStatic[2] = { 0, 0 }, tmpZone[64];
|
||||
memset(tmpZone, 0, sizeof(tmpZone));
|
||||
ZoneServer* zs = 0;
|
||||
while(iterator.MoreElements()) {
|
||||
zs = iterator.GetData();
|
||||
in.s_addr = zs->GetIP();
|
||||
}
|
||||
|
||||
if(zs->IsStaticZone())
|
||||
int v = 0, w = 0, x = 0, y = 0, z = 0;
|
||||
char is_static_string[2] = { 0, 0 }, zone_data_string[64];
|
||||
memset(zone_data_string, 0, sizeof(zone_data_string));
|
||||
|
||||
ZoneServer* zone_server_data = 0;
|
||||
|
||||
while (iterator.MoreElements()) {
|
||||
zone_server_data = iterator.GetData();
|
||||
in.s_addr = zone_server_data->GetIP();
|
||||
|
||||
if (zone_server_data->IsStaticZone()){
|
||||
z++;
|
||||
else if (zs->GetZoneID() != 0)
|
||||
}
|
||||
else if (zone_server_data->GetZoneID() != 0){
|
||||
w++;
|
||||
else if(zs->GetZoneID() == 0 && !zs->IsBootingUp())
|
||||
}
|
||||
else if (zone_server_data->GetZoneID() == 0 && !zone_server_data->IsBootingUp()){
|
||||
v++;
|
||||
}
|
||||
|
||||
if (zs->IsStaticZone())
|
||||
tmpStatic[0] = 'S';
|
||||
if (zone_server_data->IsStaticZone())
|
||||
is_static_string[0] = 'S';
|
||||
else
|
||||
tmpStatic[0] = ' ';
|
||||
is_static_string[0] = 'D';
|
||||
|
||||
if (admin >= 150) {
|
||||
if (zs->GetZoneID())
|
||||
snprintf(tmpZone, sizeof(tmpZone), "%s (%i)", zs->GetZoneName(), zs->GetZoneID());
|
||||
else if (zs->IsBootingUp())
|
||||
strcpy(tmpZone, "...");
|
||||
else
|
||||
tmpZone[0] = 0;
|
||||
if (zone_server_data->GetZoneID()){
|
||||
snprintf(zone_data_string, sizeof(zone_data_string), "%s (%i)", zone_server_data->GetZoneName(), zone_server_data->GetZoneID());
|
||||
}
|
||||
else if (zone_server_data->IsBootingUp()){
|
||||
strcpy(zone_data_string, "...");
|
||||
}
|
||||
else{
|
||||
zone_data_string[0] = 0;
|
||||
}
|
||||
|
||||
AppendAnyLenString(&output, &outsize, &outlen, " #%-3i %s %15s:%-5i %2i %s:%i %s", zs->GetID(), tmpStatic, inet_ntoa(in), zs->GetPort(), zs->NumPlayers(), zs->GetCAddress(), zs->GetCPort(), tmpZone);
|
||||
AppendAnyLenString(&output, &outsize, &outlen,
|
||||
"#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)",
|
||||
zone_server_data->GetID(),
|
||||
is_static_string,
|
||||
inet_ntoa(in),
|
||||
zone_server_data->GetPort(),
|
||||
zone_server_data->NumPlayers(),
|
||||
zone_server_data->GetCAddress(),
|
||||
zone_server_data->GetCPort(),
|
||||
zone_data_string,
|
||||
zone_server_data->GetZoneOSProcessID()
|
||||
);
|
||||
|
||||
if (outlen >= 3584) {
|
||||
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
|
||||
safe_delete(output);
|
||||
@@ -348,12 +375,12 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
|
||||
}
|
||||
x++;
|
||||
}
|
||||
else if (zs->GetZoneID() != 0) {
|
||||
if (zs->GetZoneID())
|
||||
strcpy(tmpZone, zs->GetZoneName());
|
||||
else if (zone_server_data->GetZoneID() != 0) {
|
||||
if (zone_server_data->GetZoneID())
|
||||
strcpy(zone_data_string, zone_server_data->GetZoneName());
|
||||
else
|
||||
tmpZone[0] = 0;
|
||||
AppendAnyLenString(&output, &outsize, &outlen, " #%i %s %s", zs->GetID(), tmpStatic, tmpZone);
|
||||
zone_data_string[0] = 0;
|
||||
AppendAnyLenString(&output, &outsize, &outlen, " #%i %s %s", zone_server_data->GetID(), is_static_string, zone_data_string);
|
||||
if (outlen >= 3584) {
|
||||
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
|
||||
safe_delete(output);
|
||||
@@ -361,25 +388,32 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
|
||||
outlen = 0;
|
||||
}
|
||||
else {
|
||||
if (connection->IsConsole())
|
||||
if (connection->IsConsole()){
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
|
||||
else
|
||||
}
|
||||
else{
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "^");
|
||||
}
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
iterator.Advance();
|
||||
}
|
||||
if (connection->IsConsole())
|
||||
|
||||
if (connection->IsConsole()){
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.\r\n", x, y);
|
||||
else
|
||||
}
|
||||
else {
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.^", x, y);
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.",z,w,v);
|
||||
// connection->SendEmoteMessage(to, 0, 0, "%i servers listed. %i servers online.", x, y);
|
||||
// connection->SendEmoteMessage(to,0,0,"%i zones are static zones, %i zones are booted zones, %i zones available.",z,w,v);
|
||||
if (output)
|
||||
}
|
||||
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.", z, w, v);
|
||||
|
||||
if (output){
|
||||
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
|
||||
}
|
||||
|
||||
safe_delete(output);
|
||||
}
|
||||
|
||||
|
||||
+44
-36
@@ -49,20 +49,24 @@ extern QueryServConnection QSLink;
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
ZoneServer::ZoneServer(EmuTCPConnection* itcpc)
|
||||
: WorldTCPConnection(), tcpc(itcpc), ls_zboot(5000) {
|
||||
ID = zoneserver_list.GetNextID();
|
||||
: WorldTCPConnection(), tcpc(itcpc), zone_boot_timer(5000) {
|
||||
|
||||
/* Set Process tracking variable defaults */
|
||||
|
||||
memset(zone_name, 0, sizeof(zone_name));
|
||||
memset(compiled, 0, sizeof(compiled));
|
||||
zoneID = 0;
|
||||
instanceID = 0;
|
||||
memset(client_address, 0, sizeof(client_address));
|
||||
memset(client_local_address, 0, sizeof(client_local_address));
|
||||
|
||||
memset(clientaddress, 0, sizeof(clientaddress));
|
||||
memset(clientlocaladdress, 0, sizeof(clientlocaladdress));
|
||||
clientport = 0;
|
||||
BootingUp = false;
|
||||
authenticated = false;
|
||||
staticzone = false;
|
||||
pNumPlayers = 0;
|
||||
zone_server_id = zoneserver_list.GetNextID();
|
||||
zone_server_zone_id = 0;
|
||||
instance_id = 0;
|
||||
zone_os_process_id = 0;
|
||||
client_port = 0;
|
||||
is_booting_up = false;
|
||||
is_authenticated = false;
|
||||
is_static_zone = false;
|
||||
zone_player_count = 0;
|
||||
}
|
||||
|
||||
ZoneServer::~ZoneServer() {
|
||||
@@ -72,7 +76,7 @@ ZoneServer::~ZoneServer() {
|
||||
}
|
||||
|
||||
bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
||||
BootingUp = false;
|
||||
is_booting_up = false;
|
||||
|
||||
const char* zn = MakeLowerString(database.GetZoneName(iZoneID));
|
||||
char* longname;
|
||||
@@ -81,17 +85,17 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Setting to '%s' (%d:%d)%s",(zn) ? zn : "",iZoneID, iInstanceID,
|
||||
iStaticZone ? " (Static)" : "");
|
||||
|
||||
zoneID = iZoneID;
|
||||
instanceID = iInstanceID;
|
||||
zone_server_zone_id = iZoneID;
|
||||
instance_id = iInstanceID;
|
||||
if(iZoneID!=0)
|
||||
oldZoneID = iZoneID;
|
||||
if (zoneID == 0) {
|
||||
zone_server_previous_zone_id = iZoneID;
|
||||
if (zone_server_zone_id == 0) {
|
||||
client_list.CLERemoveZSRef(this);
|
||||
pNumPlayers = 0;
|
||||
zone_player_count = 0;
|
||||
LSSleepUpdate(GetPrevZoneID());
|
||||
}
|
||||
|
||||
staticzone = iStaticZone;
|
||||
is_static_zone = iStaticZone;
|
||||
|
||||
if (zn)
|
||||
{
|
||||
@@ -111,7 +115,7 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
||||
}
|
||||
|
||||
client_list.ZoneBootup(this);
|
||||
ls_zboot.Start();
|
||||
zone_boot_timer.Start();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -172,19 +176,19 @@ void ZoneServer::LSSleepUpdate(uint32 zoneid){
|
||||
bool ZoneServer::Process() {
|
||||
if (!tcpc->Connected())
|
||||
return false;
|
||||
if(ls_zboot.Check()){
|
||||
if(zone_boot_timer.Check()){
|
||||
LSBootUpdate(GetZoneID(), true);
|
||||
ls_zboot.Disable();
|
||||
zone_boot_timer.Disable();
|
||||
}
|
||||
ServerPacket *pack = 0;
|
||||
while((pack = tcpc->PopPacket())) {
|
||||
if (!authenticated) {
|
||||
if (!is_authenticated) {
|
||||
if (WorldConfig::get()->SharedKey.length() > 0) {
|
||||
if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) {
|
||||
uint8 tmppass[16];
|
||||
MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
|
||||
if (memcmp(pack->pBuffer, tmppass, 16) == 0)
|
||||
authenticated = true;
|
||||
is_authenticated = true;
|
||||
else {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetIP();
|
||||
@@ -210,7 +214,7 @@ bool ZoneServer::Process() {
|
||||
else
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
|
||||
authenticated = true;
|
||||
is_authenticated = true;
|
||||
}
|
||||
}
|
||||
switch(pack->opcode) {
|
||||
@@ -582,29 +586,33 @@ bool ZoneServer::Process() {
|
||||
ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer;
|
||||
|
||||
if (!sci->port) {
|
||||
clientport = zoneserver_list.GetAvailableZonePort();
|
||||
client_port = zoneserver_list.GetAvailableZonePort();
|
||||
|
||||
ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
|
||||
memset(p.pBuffer,0,sizeof(ServerConnectInfo));
|
||||
ServerConnectInfo* sci = (ServerConnectInfo*) p.pBuffer;
|
||||
sci->port = clientport;
|
||||
sci->port = client_port;
|
||||
SendPacket(&p);
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Auto zone port configuration. Telling zone to use port %d",clientport);
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Auto zone port configuration. Telling zone to use port %d",client_port);
|
||||
} else {
|
||||
clientport = sci->port;
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Zone specified port %d.",clientport);
|
||||
client_port = sci->port;
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Zone specified port %d.",client_port);
|
||||
}
|
||||
|
||||
if(sci->address[0]) {
|
||||
strn0cpy(clientaddress, sci->address, 250);
|
||||
strn0cpy(client_address, sci->address, 250);
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Zone specified address %s.", sci->address);
|
||||
}
|
||||
|
||||
if(sci->local_address[0]) {
|
||||
strn0cpy(clientlocaladdress, sci->local_address, 250);
|
||||
strn0cpy(client_local_address, sci->local_address, 250);
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Zone specified local address %s.", sci->address);
|
||||
}
|
||||
|
||||
if (sci->process_id){
|
||||
zone_os_process_id = sci->process_id;
|
||||
}
|
||||
|
||||
}
|
||||
case ServerOP_SetLaunchName: {
|
||||
if(pack->size != sizeof(LaunchName_Struct))
|
||||
@@ -1411,13 +1419,13 @@ void ZoneServer::ChangeWID(uint32 iCharID, uint32 iWID) {
|
||||
|
||||
|
||||
void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* adminname, bool iMakeStatic) {
|
||||
BootingUp = true;
|
||||
zoneID = iZoneID;
|
||||
instanceID = iInstanceID;
|
||||
is_booting_up = true;
|
||||
zone_server_zone_id = iZoneID;
|
||||
instance_id = iInstanceID;
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_ZoneBootup, sizeof(ServerZoneStateChange_struct));
|
||||
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
|
||||
s->ZoneServerID = ID;
|
||||
s->ZoneServerID = zone_server_id;
|
||||
if (adminname != 0)
|
||||
strcpy(s->adminname, adminname);
|
||||
|
||||
@@ -1434,7 +1442,7 @@ void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* a
|
||||
}
|
||||
|
||||
void ZoneServer::IncomingClient(Client* client) {
|
||||
BootingUp = true;
|
||||
is_booting_up = true;
|
||||
auto pack = new ServerPacket(ServerOP_ZoneIncClient, sizeof(ServerZoneIncomingClient_Struct));
|
||||
ServerZoneIncomingClient_Struct* s = (ServerZoneIncomingClient_Struct*) pack->pBuffer;
|
||||
s->zoneid = GetZoneID();
|
||||
|
||||
+29
-25
@@ -44,7 +44,7 @@ public:
|
||||
void LSBootUpdate(uint32 zoneid, uint32 iInstanceID = 0, bool startup = false);
|
||||
void LSSleepUpdate(uint32 zoneid);
|
||||
void LSShutDownUpdate(uint32 zoneid);
|
||||
uint32 GetPrevZoneID() { return oldZoneID; }
|
||||
uint32 GetPrevZoneID() { return zone_server_previous_zone_id; }
|
||||
void ChangeWID(uint32 iCharID, uint32 iWID);
|
||||
void SendGroupIDs();
|
||||
|
||||
@@ -52,41 +52,45 @@ public:
|
||||
inline const char* GetZoneLongName() const { return long_name; }
|
||||
const char* GetCompileTime() const{ return compiled; }
|
||||
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
|
||||
inline uint32 GetZoneID() const { return zoneID; }
|
||||
inline uint32 GetZoneID() const { return zone_server_zone_id; }
|
||||
inline uint32 GetIP() const { return tcpc->GetrIP(); }
|
||||
inline uint16 GetPort() const { return tcpc->GetrPort(); }
|
||||
inline const char* GetCAddress() const { return clientaddress; }
|
||||
inline const char* GetCLocalAddress() const { return clientlocaladdress; }
|
||||
inline uint16 GetCPort() const { return clientport; }
|
||||
inline uint32 GetID() const { return ID; }
|
||||
inline bool IsBootingUp() const { return BootingUp; }
|
||||
inline bool IsStaticZone() const{ return staticzone; }
|
||||
inline uint32 NumPlayers() const { return pNumPlayers; }
|
||||
inline void AddPlayer() { pNumPlayers++; }
|
||||
inline void RemovePlayer() { pNumPlayers--; }
|
||||
inline const char* GetCAddress() const { return client_address; }
|
||||
inline const char* GetCLocalAddress() const { return client_local_address; }
|
||||
inline uint16 GetCPort() const { return client_port; }
|
||||
inline uint32 GetID() const { return zone_server_id; }
|
||||
inline bool IsBootingUp() const { return is_booting_up; }
|
||||
inline bool IsStaticZone() const{ return is_static_zone; }
|
||||
inline uint32 NumPlayers() const { return zone_player_count; }
|
||||
inline void AddPlayer() { zone_player_count++; }
|
||||
inline void RemovePlayer() { zone_player_count--; }
|
||||
inline const char * GetLaunchName() const { return(launcher_name.c_str()); }
|
||||
inline const char * GetLaunchedName() const { return(launched_name.c_str()); }
|
||||
|
||||
inline uint32 GetInstanceID() { return instanceID; }
|
||||
inline void SetInstanceID(uint32 i) { instanceID = i; }
|
||||
inline uint32 GetInstanceID() { return instance_id; }
|
||||
inline void SetInstanceID(uint32 i) { instance_id = i; }
|
||||
|
||||
inline uint32 GetZoneOSProcessID() { return zone_os_process_id; }
|
||||
|
||||
private:
|
||||
EmuTCPConnection* const tcpc;
|
||||
|
||||
uint32 ID;
|
||||
char clientaddress[250];
|
||||
char clientlocaladdress[250];
|
||||
uint16 clientport;
|
||||
bool BootingUp;
|
||||
bool staticzone;
|
||||
bool authenticated;
|
||||
uint32 pNumPlayers;
|
||||
uint32 zone_server_id;
|
||||
char client_address[250];
|
||||
char client_local_address[250];
|
||||
uint16 client_port;
|
||||
bool is_booting_up;
|
||||
bool is_static_zone;
|
||||
bool is_authenticated;
|
||||
uint32 zone_player_count;
|
||||
char compiled[25];
|
||||
char zone_name[32];
|
||||
char long_name[256];
|
||||
uint32 zoneID;
|
||||
uint32 oldZoneID;
|
||||
Timer ls_zboot;
|
||||
uint32 instanceID; //instance ids contain a zone id, and a zone version
|
||||
uint32 zone_server_zone_id;
|
||||
uint32 zone_server_previous_zone_id;
|
||||
Timer zone_boot_timer;
|
||||
uint32 instance_id; //instance ids contain a zone id, and a zone version
|
||||
uint32 zone_os_process_id;
|
||||
std::string launcher_name; //the launcher which started us
|
||||
std::string launched_name; //the name of the zone we launched.
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user