Fix for launcher not actually sending static ports when set in the db

This commit is contained in:
KimLS 2015-07-11 13:28:09 -07:00
parent 7909270527
commit 8dd362a101
8 changed files with 87 additions and 77 deletions

View File

@ -760,6 +760,7 @@ typedef enum {
struct LauncherZoneRequest {
uint8 command;
char short_name[33];
uint16 port;
};
struct LauncherZoneStatus {

View File

@ -102,8 +102,6 @@ int main(int argc, char *argv[]) {
Log.Out(Logs::Detail, Logs::Launcher, "Starting main loop...");
// zones["test"] = new ZoneLaunch(&world, "./zone", "dynamic_1");
ProcLauncher *launch = ProcLauncher::get();
RunLoops = true;
while(RunLoops) {

View File

@ -86,14 +86,13 @@ void WorldServer::Process() {
}
const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer;
switch(ZoneRequestCommands(lzr->command)) {
case ZR_Start: {
if(m_zones.find(lzr->short_name) != m_zones.end()) {
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name);
} else {
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name);
ZoneLaunch *l = new ZoneLaunch(this, m_name, lzr->short_name, m_config);
ZoneLaunch *l = new ZoneLaunch(this, m_name, lzr->short_name, lzr->port, m_config);
m_zones[lzr->short_name] = l;
}
break;

View File

@ -34,10 +34,11 @@ void ZoneLaunch::InitStartTimer() {
}
ZoneLaunch::ZoneLaunch(WorldServer *world, const char *launcher_name,
const char *zone_name, const EQEmuConfig *config)
const char *zone_name, uint16 port, const EQEmuConfig *config)
: m_state(StateStartPending),
m_world(world),
m_zone(zone_name),
m_port(port),
m_launcherName(launcher_name),
m_config(config),
m_timer(config->RestartWait),
@ -61,10 +62,14 @@ void ZoneLaunch::SendStatus() const {
void ZoneLaunch::Start() {
ProcLauncher::Spec *spec = new ProcLauncher::Spec();
spec->program = m_config->ZoneExe;
// if(m_zone.substr(0,7) == "dynamic")
// spec->args.push_back(".");
// else
spec->args.push_back(m_zone);
if(m_port) {
std::string arg = m_zone + std::string(":") + std::to_string(m_port);
spec->args.push_back(arg);
} else {
spec->args.push_back(m_zone);
}
spec->args.push_back(m_launcherName);
spec->handler = this;
spec->logFile = m_config->LogPrefix + m_zone + m_config->LogSuffix;

View File

@ -28,7 +28,7 @@ class EQEmuConfig;
class ZoneLaunch : protected ProcLauncher::EventHandler {
public:
ZoneLaunch(WorldServer *world, const char *launcher_name,
const char *zone_name, const EQEmuConfig *config);
const char *zone_name, uint16 port, const EQEmuConfig *config);
virtual ~ZoneLaunch();
void Stop(bool graceful = true);
@ -63,6 +63,7 @@ protected:
const std::string m_zone;
const char *const m_launcherName;
const EQEmuConfig *const m_config;
const uint16 m_port;
Timer m_timer;
ProcLauncher::ProcRef m_ref;

View File

@ -60,7 +60,7 @@ bool LauncherLink::Process() {
end = m_states.end();
for(; cur != end; ++cur) {
if(!cur->second.up) {
StartZone(cur->first.c_str());
StartZone(cur->first.c_str(), cur->second.port);
}
}
m_bootTimer.Disable();
@ -184,14 +184,6 @@ bool LauncherLink::Process() {
bool LauncherLink::ContainsZone(const char *short_name) const {
return(m_states.find(short_name) != m_states.end());
/*
* std::map<std::string, bool>::const_iterator cur, end;
cur = m_states.begin();
end = m_states.end();
for(; cur != end; cur++) {
if(
}*/
}
void LauncherLink::BootZone(const char *short_name, uint16 port) {
@ -202,15 +194,20 @@ void LauncherLink::BootZone(const char *short_name, uint16 port) {
Log.Out(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);
StartZone(short_name, port);
}
void LauncherLink::StartZone(const char *short_name) {
StartZone(short_name, 0);
}
void LauncherLink::StartZone(const char *short_name, uint16 port) {
auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest));
LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer;
strn0cpy(s->short_name, short_name, 32);
s->command = ZR_Start;
s->port = port;
SendPacket(pack);
delete pack;
@ -222,6 +219,7 @@ void LauncherLink::RestartZone(const char *short_name) {
strn0cpy(s->short_name, short_name, 32);
s->command = ZR_Restart;
s->port = 0;
SendPacket(pack);
delete pack;
@ -233,6 +231,7 @@ void LauncherLink::StopZone(const char *short_name) {
strn0cpy(s->short_name, short_name, 32);
s->command = ZR_Stop;
s->port = 0;
SendPacket(pack);
delete pack;
@ -332,35 +331,3 @@ void LauncherLink::Shutdown() {
SendPacket(pack);
delete pack;
}

View File

@ -50,6 +50,7 @@ public:
void Shutdown();
void BootZone(const char *short_name, uint16 port);
void StartZone(const char *short_name);
void StartZone(const char *short_name, uint16 port);
void RestartZone(const char *short_name);
void StopZone(const char *short_name);
void BootDynamics(uint8 new_total);

View File

@ -28,7 +28,6 @@
#include "../common/eq_packet_structs.h"
#include "../common/mutex.h"
#include "../common/version.h"
#include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h"
#include "../common/guilds.h"
@ -57,17 +56,14 @@
#include "titles.h"
#include "guild_mgr.h"
#include "tasks.h"
#include "quest_parser_collection.h"
#include "embparser.h"
#include "lua_parser.h"
#include "questmgr.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
@ -116,28 +112,77 @@ int main(int argc, char** argv) {
RegisterExecutablePlatform(ExePlatformZone);
Log.LoadLogSettingsDefaults();
set_exception_handler();
const char *zone_name;
QServ = new QueryServ;
if(argc == 3) {
Log.Out(Logs::General, Logs::Zone_Server, "Loading server configuration..");
if(!ZoneConfig::LoadConfig()) {
Log.Out(Logs::General, Logs::Error, "Loading server configuration failed.");
return 1;
}
const ZoneConfig *Config = ZoneConfig::get();
const char *zone_name;
uint32 instance_id = 0;
std::string z_name;
if(argc == 4) {
instance_id = atoi(argv[3]);
worldserver.SetLauncherName(argv[2]);
worldserver.SetLaunchedName(argv[1]);
if(strncmp(argv[1], "dynamic_", 8) == 0) {
//dynamic zone with a launcher name correlation
auto zone_port = SplitString(argv[1], ':');
if(zone_port.size() > 0) {
z_name = zone_port[0];
}
if(zone_port.size() > 1) {
std::string p_name = zone_port[1];
Config->SetZonePort(atoi(p_name.c_str()));
}
worldserver.SetLaunchedName(z_name.c_str());
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
zone_name = ".";
}
else {
zone_name = z_name.c_str();
}
} else if(argc == 3) {
worldserver.SetLauncherName(argv[2]);
auto zone_port = SplitString(argv[1], ':');
if(zone_port.size() > 0) {
z_name = zone_port[0];
}
if(zone_port.size() > 1) {
std::string p_name = zone_port[1];
Config->SetZonePort(atoi(p_name.c_str()));
}
worldserver.SetLaunchedName(z_name.c_str());
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
zone_name = ".";
} else {
zone_name = argv[1];
worldserver.SetLaunchedName(zone_name);
zone_name = z_name.c_str();
}
} else if (argc == 2) {
worldserver.SetLauncherName("NONE");
worldserver.SetLaunchedName(argv[1]);
if(strncmp(argv[1], "dynamic_", 8) == 0) {
//dynamic zone with a launcher name correlation
auto zone_port = SplitString(argv[1], ':');
if(zone_port.size() > 0) {
z_name = zone_port[0];
}
if(zone_port.size() > 1) {
std::string p_name = zone_port[1];
Config->SetZonePort(atoi(p_name.c_str()));
}
worldserver.SetLaunchedName(z_name.c_str());
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
zone_name = ".";
} else {
zone_name = argv[1];
worldserver.SetLaunchedName(zone_name);
}
else {
zone_name = z_name.c_str();
}
} else {
zone_name = ".";
@ -145,13 +190,6 @@ int main(int argc, char** argv) {
worldserver.SetLauncherName("NONE");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading server configuration..");
if (!ZoneConfig::LoadConfig()) {
Log.Out(Logs::General, Logs::Error, "Loading server configuration failed.");
return 1;
}
const ZoneConfig *Config = ZoneConfig::get();
worldserver.SetPassword(Config->SharedKey.c_str());
Log.Out(Logs::General, Logs::Zone_Server, "Connecting to MySQL...");
@ -312,7 +350,7 @@ int main(int argc, char** argv) {
#endif
if (!strlen(zone_name) || !strcmp(zone_name,".")) {
Log.Out(Logs::General, Logs::Zone_Server, "Entering sleep mode");
} else if (!Zone::Bootup(database.GetZoneID(zone_name), 0, true)) { //todo: go above and fix this to allow cmd line instance
} else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) {
Log.Out(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup");
zone = 0;
}