mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 04:11:30 +00:00
Added two other commands to let you do shared reloading on your own without the hotfix command. Also changed how world determines a zone's address
This commit is contained in:
parent
9f1f36cca6
commit
b7cd0b223f
@ -546,6 +546,7 @@ struct ServerLSPeerConnect {
|
||||
|
||||
struct ServerConnectInfo {
|
||||
char address[250];
|
||||
char local_address[250];
|
||||
uint16 port;
|
||||
};
|
||||
|
||||
|
||||
@ -1217,30 +1217,31 @@ void Client::Clearance(int8 response)
|
||||
return;
|
||||
}
|
||||
|
||||
// @bp This is the chat server
|
||||
/*
|
||||
char packetData[] = "64.37.148.34.9876,MyServer,Testchar,23cd2c95";
|
||||
outapp = new EQApplicationPacket(OP_0x0282, sizeof(packetData));
|
||||
strcpy((char*)outapp->pBuffer, packetData);
|
||||
QueuePacket(outapp);
|
||||
delete outapp;
|
||||
*/
|
||||
|
||||
// Send zone server IP data
|
||||
outapp = new EQApplicationPacket(OP_ZoneServerInfo, sizeof(ZoneServerInfo_Struct));
|
||||
ZoneServerInfo_Struct* zsi = (ZoneServerInfo_Struct*)outapp->pBuffer;
|
||||
const char *zs_addr=zs->GetCAddress();
|
||||
if (!zs_addr[0]) {
|
||||
if (cle->IsLocalClient()) {
|
||||
|
||||
const char *zs_addr = nullptr;
|
||||
if(cle && cle->IsLocalClient()) {
|
||||
const char *local_addr = zs->GetCLocalAddress();
|
||||
if(local_addr[0]) {
|
||||
zs_addr = local_addr;
|
||||
} else {
|
||||
struct in_addr in;
|
||||
in.s_addr = zs->GetIP();
|
||||
zs_addr=inet_ntoa(in);
|
||||
if (!strcmp(zs_addr,"127.0.0.1"))
|
||||
zs_addr=WorldConfig::get()->LocalAddress.c_str();
|
||||
zs_addr = inet_ntoa(in);
|
||||
}
|
||||
} else {
|
||||
const char *addr = zs->GetCAddress();
|
||||
if(addr[0]) {
|
||||
zs_addr = addr;
|
||||
} else {
|
||||
zs_addr=WorldConfig::get()->WorldAddress.c_str();
|
||||
struct in_addr in;
|
||||
in.s_addr = zs->GetIP();
|
||||
zs_addr = inet_ntoa(in);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(zsi->ip, zs_addr);
|
||||
zsi->port =zs->GetCPort();
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Sending client to zone %s (%d:%d) at %s:%d",zonename,zoneID,instanceID,zsi->ip,zsi->port);
|
||||
|
||||
@ -57,6 +57,7 @@ ZoneServer::ZoneServer(EmuTCPConnection* itcpc)
|
||||
instanceID = 0;
|
||||
|
||||
memset(clientaddress, 0, sizeof(clientaddress));
|
||||
memset(clientlocaladdress, 0, sizeof(clientlocaladdress));
|
||||
clientport = 0;
|
||||
BootingUp = false;
|
||||
authenticated = false;
|
||||
@ -581,7 +582,7 @@ bool ZoneServer::Process() {
|
||||
ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer;
|
||||
|
||||
if (!sci->port) {
|
||||
clientport=zoneserver_list.GetAvailableZonePort();
|
||||
clientport = zoneserver_list.GetAvailableZonePort();
|
||||
|
||||
ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
|
||||
memset(p.pBuffer,0,sizeof(ServerConnectInfo));
|
||||
@ -590,8 +591,18 @@ bool ZoneServer::Process() {
|
||||
SendPacket(&p);
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Auto zone port configuration. Telling zone to use port %d",clientport);
|
||||
} else {
|
||||
clientport=sci->port;
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Zone specified port %d, must be a previously allocated zone reconnecting.",clientport);
|
||||
clientport = sci->port;
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Zone specified port %d.",clientport);
|
||||
}
|
||||
|
||||
if(sci->address[0]) {
|
||||
strn0cpy(clientaddress, 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);
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Zone specified local address %s.", sci->address);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -56,6 +56,7 @@ public:
|
||||
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 clientaddress; }
|
||||
inline uint16 GetCPort() const { return clientport; }
|
||||
inline uint32 GetID() const { return ID; }
|
||||
inline bool IsBootingUp() const { return BootingUp; }
|
||||
@ -73,6 +74,7 @@ private:
|
||||
|
||||
uint32 ID;
|
||||
char clientaddress[250];
|
||||
char clientlocaladdress[250];
|
||||
uint16 clientport;
|
||||
bool BootingUp;
|
||||
bool staticzone;
|
||||
|
||||
@ -169,6 +169,7 @@ int command_init(void) {
|
||||
command_add("aggrozone", "[aggro] - Aggro every mob in the zone with X aggro. Default is 0. Not recommend if you're not invulnerable.", 100, command_aggrozone) ||
|
||||
command_add("ai", "[factionid/spellslist/con/guard/roambox/stop/start] - Modify AI on NPC target", 100, command_ai) ||
|
||||
command_add("appearance", "[type] [value] - Send an appearance packet for you or your target", 150, command_appearance) ||
|
||||
command_add("apply_shared_memory", "[shared_memory_name] - Tells every zone and world to apply a specific shared memory segment by name.", 250, command_apply_shared_memory) ||
|
||||
command_add("attack", "[targetname] - Make your NPC target attack targetname", 150, command_attack) ||
|
||||
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", 250, command_augmentitem) ||
|
||||
command_add("aug", nullptr, 250, command_augmentitem) ||
|
||||
@ -253,7 +254,7 @@ int command_init(void) {
|
||||
command_add("heromodel", "[hero model] [slot] - Full set of Hero's Forge Armor appearance. If slot is set, sends exact model just to slot.", 200, command_heromodel) ||
|
||||
command_add("hideme", "[on/off] - Hide yourself from spawn lists.", 80, command_hideme) ||
|
||||
command_add("hm", "[hero model] [slot] - Full set of Hero's Forge Armor appearance. If slot is set, sends exact model just to slot.)", 200, command_heromodel) ||
|
||||
command_add("hotfix", "[hotfix_name] - Reloads shared memory into a hotfix", 250, command_hotfix) ||
|
||||
command_add("hotfix", "[hotfix_name] - Reloads shared memory into a hotfix, equiv to load_shared_memory followed by apply_shared_memory", 250, command_hotfix) ||
|
||||
command_add("hp", "- Refresh your HP bar from the server.", 0, command_hp) ||
|
||||
command_add("incstat", "- Increases or Decreases a client's stats permanently.", 200, command_incstat) ||
|
||||
command_add("instance", "- Modify Instances", 200, command_instance) ||
|
||||
@ -271,6 +272,7 @@ int command_init(void) {
|
||||
command_add("level", "[level] - Set your or your target's level", 10, command_level) ||
|
||||
command_add("listnpcs", "[name/range] - Search NPCs", 20, command_listnpcs) ||
|
||||
command_add("listpetition", "- List petitions", 50, command_listpetition) ||
|
||||
command_add("load_shared_memory", "[shared_memory_name] - Reloads shared memory and uses the input as output", 250, command_load_shared_memory) ||
|
||||
command_add("loc", "- Print out your or your target's current location and heading", 0, command_loc) ||
|
||||
command_add("lock", "- Lock the worldserver", 150, command_lock) ||
|
||||
command_add("logs", "Manage anything to do with logs", 250, command_logs) ||
|
||||
@ -10634,10 +10636,7 @@ void command_hotfix(Client *c, const Seperator *sep) {
|
||||
hotfix_name = "hotfix_";
|
||||
}
|
||||
|
||||
|
||||
c->Message(0, "Creating and applying hotfix");
|
||||
//Not 100% certain on the thread safety of this.
|
||||
//I think it's okay however
|
||||
std::thread t1([c,hotfix_name]() {
|
||||
#ifdef WIN32
|
||||
if(hotfix_name.length() > 0) {
|
||||
@ -10666,3 +10665,52 @@ void command_hotfix(Client *c, const Seperator *sep) {
|
||||
|
||||
t1.detach();
|
||||
}
|
||||
|
||||
void command_load_shared_memory(Client *c, const Seperator *sep) {
|
||||
char hotfix[256] = { 0 };
|
||||
database.GetVariable("hotfix_name", hotfix, 256);
|
||||
std::string current_hotfix = hotfix;
|
||||
|
||||
std::string hotfix_name;
|
||||
if(strcasecmp(current_hotfix.c_str(), sep->arg[1]) == 0) {
|
||||
c->Message(0, "Cannot attempt to load this shared memory segment as it is already loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
hotfix_name = sep->arg[1];
|
||||
c->Message(0, "Loading shared memory segment %s", hotfix_name.c_str());
|
||||
std::thread t1([c,hotfix_name]() {
|
||||
#ifdef WIN32
|
||||
if(hotfix_name.length() > 0) {
|
||||
system(StringFormat("shared_memory -hotfix=%s", hotfix_name.c_str()).c_str());
|
||||
} else {
|
||||
system(StringFormat("shared_memory").c_str());
|
||||
}
|
||||
#else
|
||||
if(hotfix_name.length() > 0) {
|
||||
system(StringFormat("./shared_memory -hotfix=%s", hotfix_name.c_str()).c_str());
|
||||
}
|
||||
else {
|
||||
system(StringFormat("./shared_memory").c_str());
|
||||
}
|
||||
#endif
|
||||
c->Message(0, "Shared memory segment finished loading.");
|
||||
});
|
||||
|
||||
t1.detach();
|
||||
}
|
||||
|
||||
void command_apply_shared_memory(Client *c, const Seperator *sep) {
|
||||
char hotfix[256] = { 0 };
|
||||
database.GetVariable("hotfix_name", hotfix, 256);
|
||||
std::string hotfix_name = sep->arg[1];
|
||||
|
||||
c->Message(0, "Applying shared memory segment %s", hotfix_name.c_str());
|
||||
database.SetVariable("hotfix_name", hotfix_name.c_str());
|
||||
|
||||
ServerPacket pack(ServerOP_ChangeSharedMem, hotfix_name.length() + 1);
|
||||
if(hotfix_name.length() > 0) {
|
||||
strcpy((char*)pack.pBuffer, hotfix_name.c_str());
|
||||
}
|
||||
worldserver.SendPacket(&pack);
|
||||
}
|
||||
@ -326,6 +326,8 @@ void command_logs(Client *c, const Seperator *sep);
|
||||
void command_resetaa_timer(Client *c, const Seperator *sep);
|
||||
void command_reloadaa(Client *c, const Seperator *sep);
|
||||
void command_hotfix(Client *c, const Seperator *sep);
|
||||
void command_load_shared_memory(Client *c, const Seperator *sep);
|
||||
void command_apply_shared_memory(Client *c, const Seperator *sep);
|
||||
|
||||
#ifdef EQPROFILE
|
||||
void command_profiledump(Client *c, const Seperator *sep);
|
||||
|
||||
17
zone/net.cpp
17
zone/net.cpp
@ -575,16 +575,6 @@ uint32 NetConnection::GetIP(char* name)
|
||||
|
||||
}
|
||||
|
||||
void NetConnection::SaveInfo(char* address, uint32 port, char* waddress, char* filename) {
|
||||
|
||||
ZoneAddress = new char[strlen(address)+1];
|
||||
strcpy(ZoneAddress, address);
|
||||
ZonePort = port;
|
||||
WorldAddress = new char[strlen(waddress)+1];
|
||||
strcpy(WorldAddress, waddress);
|
||||
strn0cpy(ZoneFileName, filename, sizeof(ZoneFileName));
|
||||
}
|
||||
|
||||
NetConnection::NetConnection()
|
||||
:
|
||||
object_timer(5000),
|
||||
@ -594,9 +584,6 @@ NetConnection::NetConnection()
|
||||
raid_timer(1000),
|
||||
trap_timer(1000)
|
||||
{
|
||||
ZonePort = 0;
|
||||
ZoneAddress = 0;
|
||||
WorldAddress = 0;
|
||||
group_timer.Disable();
|
||||
raid_timer.Disable();
|
||||
corpse_timer.Disable();
|
||||
@ -606,10 +593,6 @@ NetConnection::NetConnection()
|
||||
}
|
||||
|
||||
NetConnection::~NetConnection() {
|
||||
if (ZoneAddress != 0)
|
||||
safe_delete_array(ZoneAddress);
|
||||
if (WorldAddress != 0)
|
||||
safe_delete_array(WorldAddress);
|
||||
}
|
||||
|
||||
/* Update Window Title with relevant information */
|
||||
|
||||
10
zone/net.h
10
zone/net.h
@ -39,20 +39,10 @@ public:
|
||||
|
||||
uint32 GetIP();
|
||||
uint32 GetIP(char* name);
|
||||
void SaveInfo(char* address, uint32 port, char* waddress,char* filename);
|
||||
char* GetWorldAddress() { return WorldAddress; }
|
||||
char* GetZoneAddress() { return ZoneAddress; }
|
||||
char* GetZoneFileName() { return ZoneFileName; }
|
||||
uint32 GetZonePort() { return ZonePort; }
|
||||
Timer object_timer;
|
||||
Timer door_timer;
|
||||
Timer corpse_timer;
|
||||
Timer group_timer;
|
||||
Timer raid_timer;
|
||||
Timer trap_timer;
|
||||
private:
|
||||
uint16 ZonePort;
|
||||
char* ZoneAddress;
|
||||
char* WorldAddress;
|
||||
char ZoneFileName[50];
|
||||
};
|
||||
|
||||
@ -112,7 +112,16 @@ void WorldServer::OnConnected() {
|
||||
|
||||
pack = new ServerPacket(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
|
||||
ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer;
|
||||
auto config = ZoneConfig::get();
|
||||
sci->port = ZoneConfig::get()->ZonePort;
|
||||
if(config->WorldAddress.length() > 0) {
|
||||
strn0cpy(sci->address, config->WorldAddress.c_str(), 250);
|
||||
}
|
||||
|
||||
if(config->LocalAddress.length() > 0) {
|
||||
strn0cpy(sci->address, config->LocalAddress.c_str(), 250);
|
||||
}
|
||||
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
@ -485,9 +494,7 @@ void WorldServer::Process() {
|
||||
if (zst->adminname[0] != 0)
|
||||
std::cout << "Zone bootup by " << zst->adminname << std::endl;
|
||||
|
||||
if (!(Zone::Bootup(zst->zoneid, zst->instanceid, zst->makestatic))) {
|
||||
SendChannelMessage(0, 0, 10, 0, 0, "%s:%i Zone::Bootup failed: %s", net.GetZoneAddress(), net.GetZonePort(), database.GetZoneName(zst->zoneid));
|
||||
}
|
||||
Zone::Bootup(zst->zoneid, zst->instanceid, zst->makestatic);
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZoneIncClient: {
|
||||
@ -508,8 +515,6 @@ void WorldServer::Process() {
|
||||
if ((Zone::Bootup(szic->zoneid, szic->instanceid))) {
|
||||
zone->AddAuth(szic);
|
||||
}
|
||||
else
|
||||
SendEmoteMessage(0, 0, 100, 0, "%s:%i Zone::Bootup failed: %s (%i)", net.GetZoneAddress(), net.GetZonePort(), database.GetZoneName(szic->zoneid, true), szic->zoneid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -715,30 +720,6 @@ void WorldServer::Process() {
|
||||
case ServerOP_ZoneReboot: {
|
||||
std::cout << "Got Server Requested Zone reboot" << std::endl;
|
||||
ServerZoneReboot_Struct* zb = (ServerZoneReboot_Struct*) pack->pBuffer;
|
||||
// printf("%i\n",zb->zoneid);
|
||||
struct in_addr in;
|
||||
in.s_addr = GetIP();
|
||||
#ifdef _WINDOWS
|
||||
char buffer[200];
|
||||
snprintf(buffer,200,". %s %i %s",zb->ip2, zb->port, inet_ntoa(in));
|
||||
if(zb->zoneid != 0) {
|
||||
snprintf(buffer,200,"%s %s %i %s",database.GetZoneName(zb->zoneid),zb->ip2, zb->port ,inet_ntoa(in));
|
||||
std::cout << "executing: " << buffer;
|
||||
ShellExecute(0,"Open",net.GetZoneFileName(), buffer, 0, SW_SHOWDEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "executing: " << net.GetZoneFileName() << " " << buffer;
|
||||
ShellExecute(0,"Open",net.GetZoneFileName(), buffer, 0, SW_SHOWDEFAULT);
|
||||
}
|
||||
#else
|
||||
char buffer[5];
|
||||
snprintf(buffer,5,"%i",zb->port); //just to be sure that it will work on linux
|
||||
if(zb->zoneid != 0)
|
||||
execl(net.GetZoneFileName(),net.GetZoneFileName(),database.GetZoneName(zb->zoneid),zb->ip2, buffer,inet_ntoa(in), nullptr);
|
||||
else
|
||||
execl(net.GetZoneFileName(),net.GetZoneFileName(),".",zb->ip2, buffer,inet_ntoa(in), nullptr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case ServerOP_SyncWorldTime: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user