Merge of a monster

This commit is contained in:
KimLS
2017-04-02 20:03:51 -07:00
146 changed files with 10532 additions and 7432 deletions
+88 -86
View File
@@ -157,7 +157,7 @@ void Client::SendEnterWorld(std::string name)
eqs->Close();
return;
} else {
Log.Out(Logs::Detail, Logs::World_Server,"Telling client to continue session.");
Log(Logs::Detail, Logs::World_Server,"Telling client to continue session.");
}
}
@@ -201,7 +201,7 @@ void Client::SendCharInfo() {
QueuePacket(outapp);
}
else {
Log.Out(Logs::General, Logs::World_Server, "[Error] Database did not return an OP_SendCharInfo packet for account %u", GetAccountID());
Log(Logs::General, Logs::World_Server, "[Error] Database did not return an OP_SendCharInfo packet for account %u", GetAccountID());
}
safe_delete(outapp);
}
@@ -406,7 +406,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
if (strlen(password) <= 1) {
// TODO: Find out how to tell the client wrong username/password
Log.Out(Logs::Detail, Logs::World_Server,"Login without a password");
Log(Logs::Detail, Logs::World_Server,"Login without a password");
return false;
}
@@ -433,17 +433,19 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
else
id=atoi(name);
if (loginserverlist.Connected() == false && !is_player_zoning) {
Log.Out(Logs::General, Logs::World_Server,"Error: Login server login while not connected to login server.");
Log(Logs::General, Logs::World_Server,"Error: Login server login while not connected to login server.");
return false;
}
if (((cle = client_list.CheckAuth(name, password)) || (cle = client_list.CheckAuth(id, password))))
{
if (cle->AccountID() == 0 || (!minilogin && cle->LSID()==0)) {
Log.Out(Logs::General, Logs::World_Server,"ID is 0. Is this server connected to minilogin?");
if(!minilogin)
Log.Out(Logs::General, Logs::World_Server,"If so you forget the minilogin variable...");
else
Log.Out(Logs::General, Logs::World_Server,"Could not find a minilogin account, verify ip address logging into minilogin is the same that is in your account table.");
Log(Logs::General, Logs::World_Server,"ID is 0. Is this server connected to minilogin?");
if (!minilogin) {
Log(Logs::General, Logs::World_Server, "If so you forget the minilogin variable...");
}
else {
Log(Logs::General, Logs::World_Server, "Could not find a minilogin account, verify ip address logging into minilogin is the same that is in your account table.");
}
return false;
}
@@ -451,11 +453,11 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
if(minilogin){
WorldConfig::DisableStats();
Log.Out(Logs::General, Logs::World_Server, "MiniLogin Account #%d",cle->AccountID());
Log(Logs::General, Logs::World_Server, "MiniLogin Account #%d",cle->AccountID());
}
else {
if (!is_player_zoning) {
Log.Out(Logs::General, Logs::World_Server,
Log(Logs::General, Logs::World_Server,
"Account (%s) Logging in :: LSID: %d ", cle->AccountName(), cle->LSID());
}
}
@@ -491,7 +493,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
}
else {
// TODO: Find out how to tell the client wrong username/password
Log.Out(Logs::Detail, Logs::World_Server,"Bad/Expired session key '%s'",name);
Log(Logs::Detail, Logs::World_Server,"Bad/Expired session key '%s'",name);
return false;
}
@@ -505,7 +507,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app)
{
if (GetAccountID() == 0) {
Log.Out(Logs::Detail, Logs::World_Server,"Name approval request with no logged in account");
Log(Logs::Detail, Logs::World_Server,"Name approval request with no logged in account");
return false;
}
@@ -513,7 +515,7 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app)
uchar race = app->pBuffer[64];
uchar clas = app->pBuffer[68];
Log.Out(Logs::Detail, Logs::World_Server, "Name approval request. Name=%s, race=%s, class=%s", char_name, GetRaceIDName(race), GetClassIDName(clas));
Log(Logs::Detail, Logs::World_Server, "Name approval request. Name=%s, race=%s, class=%s", char_name, GetRaceIDName(race), GetClassIDName(clas));
EQApplicationPacket *outapp;
outapp = new EQApplicationPacket;
@@ -674,11 +676,11 @@ bool Client::HandleCharacterCreateRequestPacket(const EQApplicationPacket *app)
bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) {
if (GetAccountID() == 0) {
Log.Out(Logs::Detail, Logs::World_Server,"Account ID not set; unable to create character.");
Log(Logs::Detail, Logs::World_Server,"Account ID not set; unable to create character.");
return false;
}
else if (app->size != sizeof(CharCreate_Struct)) {
Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct));
Log(Logs::Detail, Logs::World_Server,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct));
DumpPacket(app);
// the previous behavior was essentially returning true here
// but that seems a bit odd to me.
@@ -705,14 +707,14 @@ bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) {
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
if (GetAccountID() == 0) {
Log.Out(Logs::Detail, Logs::World_Server,"Enter world with no logged in account");
Log(Logs::Detail, Logs::World_Server,"Enter world with no logged in account");
eqs->Close();
return true;
}
if(GetAdmin() < 0)
{
Log.Out(Logs::Detail, Logs::World_Server,"Account banned or suspended.");
Log(Logs::Detail, Logs::World_Server,"Account banned or suspended.");
eqs->Close();
return true;
}
@@ -728,14 +730,14 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
uint32 tmpaccid = 0;
charid = database.GetCharacterInfo(char_name, &tmpaccid, &zone_id, &instance_id);
if (charid == 0 || tmpaccid != GetAccountID()) {
Log.Out(Logs::Detail, Logs::World_Server,"Could not get CharInfo for '%s'",char_name);
Log(Logs::Detail, Logs::World_Server,"Could not get CharInfo for '%s'",char_name);
eqs->Close();
return true;
}
// Make sure this account owns this character
if (tmpaccid != GetAccountID()) {
Log.Out(Logs::Detail, Logs::World_Server,"This account does not own the character named '%s'",char_name);
Log(Logs::Detail, Logs::World_Server,"This account does not own the character named '%s'",char_name);
eqs->Close();
return true;
}
@@ -777,7 +779,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
zone_id = database.MoveCharacterToBind(charid, 4);
}
else {
Log.Out(Logs::Detail, Logs::World_Server, "'%s' is trying to go home before they're able...", char_name);
Log(Logs::Detail, Logs::World_Server, "'%s' is trying to go home before they're able...", char_name);
database.SetHackerFlag(GetAccountName(), char_name, "MQGoHome: player tried to go home before they were able.");
eqs->Close();
return true;
@@ -801,7 +803,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
database.MoveCharacterToZone(charid, database.GetZoneName(zone_id));
}
else {
Log.Out(Logs::Detail, Logs::World_Server, "'%s' is trying to go to tutorial but are not allowed...", char_name);
Log(Logs::Detail, Logs::World_Server, "'%s' is trying to go to tutorial but are not allowed...", char_name);
database.SetHackerFlag(GetAccountName(), char_name, "MQTutorial: player tried to enter the tutorial without having tutorial enabled for this character.");
eqs->Close();
return true;
@@ -812,7 +814,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
if (zone_id == 0 || !database.GetZoneName(zone_id)) {
// This is to save people in an invalid zone, once it's removed from the DB
database.MoveCharacterToZone(charid, "arena");
Log.Out(Logs::Detail, Logs::World_Server, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zone_id, char_name);
Log(Logs::Detail, Logs::World_Server, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zone_id, char_name);
}
if(instance_id > 0)
@@ -926,7 +928,7 @@ bool Client::HandleDeleteCharacterPacket(const EQApplicationPacket *app) {
uint32 char_acct_id = database.GetAccountIDByChar((char*)app->pBuffer);
if(char_acct_id == GetAccountID()) {
Log.Out(Logs::Detail, Logs::World_Server,"Delete character: %s",app->pBuffer);
Log(Logs::Detail, Logs::World_Server,"Delete character: %s",app->pBuffer);
database.DeleteCharacter((char *)app->pBuffer);
SendCharInfo();
}
@@ -947,24 +949,24 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
EmuOpcode opcode = app->GetOpcode();
Log.Out(Logs::Detail, Logs::World_Server,"Recevied EQApplicationPacket");
Log(Logs::Detail, Logs::World_Server,"Recevied EQApplicationPacket");
if (!eqs->CheckState(ESTABLISHED)) {
Log.Out(Logs::Detail, Logs::World_Server,"Client disconnected (net inactive on send)");
Log(Logs::Detail, Logs::World_Server,"Client disconnected (net inactive on send)");
return false;
}
// Voidd: Anti-GM Account hack, Checks source ip against valid GM Account IP Addresses
if (RuleB(World, GMAccountIPList) && this->GetAdmin() >= (RuleI(World, MinGMAntiHackStatus))) {
if(!database.CheckGMIPs(long2ip(this->GetIP()).c_str(), this->GetAccountID())) {
Log.Out(Logs::Detail, Logs::World_Server,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID());
Log(Logs::Detail, Logs::World_Server,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID());
eqs->Close();
}
}
if (GetAccountID() == 0 && opcode != OP_SendLoginInfo) {
// Got a packet other than OP_SendLoginInfo when not logged in
Log.Out(Logs::Detail, Logs::World_Server,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
Log(Logs::Detail, Logs::World_Server,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
return false;
}
else if (opcode == OP_AckPacket) {
@@ -1042,7 +1044,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
}
default:
{
Log.Out(Logs::Detail, Logs::World_Server,"Received unknown EQApplicationPacket");
Log(Logs::Detail, Logs::World_Server,"Received unknown EQApplicationPacket");
return true;
}
}
@@ -1060,7 +1062,7 @@ bool Client::Process() {
to.sin_addr.s_addr = ip;
if (autobootup_timeout.Check()) {
Log.Out(Logs::General, Logs::World_Server, "Zone bootup timer expired, bootup failed or too slow.");
Log(Logs::General, Logs::World_Server, "Zone bootup timer expired, bootup failed or too slow.");
TellClientZoneUnavailable();
}
if(connect.Check()){
@@ -1094,7 +1096,7 @@ bool Client::Process() {
loginserverlist.SendPacket(pack);
safe_delete(pack);
}
Log.Out(Logs::Detail, Logs::World_Server,"Client disconnected (not active in process)");
Log(Logs::Detail, Logs::World_Server,"Client disconnected (not active in process)");
return false;
}
@@ -1143,17 +1145,17 @@ void Client::EnterWorld(bool TryBootup) {
}
else {
if (TryBootup) {
Log.Out(Logs::General, Logs::World_Server, "Attempting autobootup of %s (%d:%d)", zone_name, zone_id, instance_id);
Log(Logs::General, Logs::World_Server, "Attempting autobootup of %s (%d:%d)", zone_name, zone_id, instance_id);
autobootup_timeout.Start();
zone_waiting_for_bootup = zoneserver_list.TriggerBootup(zone_id, instance_id);
if (zone_waiting_for_bootup == 0) {
Log.Out(Logs::General, Logs::World_Server, "No zoneserver available to boot up.");
Log(Logs::General, Logs::World_Server, "No zoneserver available to boot up.");
TellClientZoneUnavailable();
}
return;
}
else {
Log.Out(Logs::General, Logs::World_Server, "Requested zone %s is not running.", zone_name);
Log(Logs::General, Logs::World_Server, "Requested zone %s is not running.", zone_name);
TellClientZoneUnavailable();
return;
}
@@ -1167,7 +1169,7 @@ void Client::EnterWorld(bool TryBootup) {
cle->SetChar(charid, char_name);
database.UpdateLiveChar(char_name, GetAccountID());
Log.Out(Logs::General, Logs::World_Server,
Log(Logs::General, Logs::World_Server,
"(%s) %s %s (Zone ID %d: Instance ID: %d) ",
char_name,
(seen_character_select ? "Zoning from character select" : "Zoning to"),
@@ -1178,7 +1180,7 @@ void Client::EnterWorld(bool TryBootup) {
if (seen_character_select) {
if (GetAdmin() < 80 && zoneserver_list.IsZoneLocked(zone_id)) {
Log.Out(Logs::General, Logs::World_Server, "Enter world failed. Zone is locked.");
Log(Logs::General, Logs::World_Server, "Enter world failed. Zone is locked.");
TellClientZoneUnavailable();
return;
}
@@ -1216,9 +1218,9 @@ void Client::Clearance(int8 response)
{
if (zs == 0)
{
Log.Out(Logs::Detail, Logs::World_Server,"Unable to find zoneserver in Client::Clearance!!");
Log(Logs::Detail, Logs::World_Server,"Unable to find zoneserver in Client::Clearance!!");
} else {
Log.Out(Logs::Detail, Logs::World_Server, "Invalid response %d in Client::Clearance", response);
Log(Logs::Detail, Logs::World_Server, "Invalid response %d in Client::Clearance", response);
}
TellClientZoneUnavailable();
@@ -1228,20 +1230,20 @@ void Client::Clearance(int8 response)
EQApplicationPacket* outapp;
if (zs->GetCAddress() == nullptr) {
Log.Out(Logs::Detail, Logs::World_Server, "Unable to do zs->GetCAddress() in Client::Clearance!!");
Log(Logs::Detail, Logs::World_Server, "Unable to do zs->GetCAddress() in Client::Clearance!!");
TellClientZoneUnavailable();
return;
}
if (zone_id == 0) {
Log.Out(Logs::Detail, Logs::World_Server, "zoneID is nullptr in Client::Clearance!!");
Log(Logs::Detail, Logs::World_Server, "zoneID is nullptr in Client::Clearance!!");
TellClientZoneUnavailable();
return;
}
const char* zonename = database.GetZoneName(zone_id);
if (zonename == 0) {
Log.Out(Logs::Detail, Logs::World_Server, "zonename is nullptr in Client::Clearance!!");
Log(Logs::Detail, Logs::World_Server, "zonename is nullptr in Client::Clearance!!");
TellClientZoneUnavailable();
return;
}
@@ -1259,10 +1261,10 @@ void Client::Clearance(int8 response)
} else {
if(strcmp(zs->GetIP().c_str(), "127.0.0.1") == 0)
{
Log.Out(Logs::Detail, Logs::World_Server, "Local zone address was %s, setting local address to: %s", zs_addr, WorldConfig::get()->LocalAddress.c_str());
Log(Logs::Detail, Logs::World_Server, "Local zone address was %s, setting local address to: %s", zs_addr, WorldConfig::get()->LocalAddress.c_str());
zs_addr = WorldConfig::get()->LocalAddress.c_str();
} else {
Log.Out(Logs::Detail, Logs::World_Server, "Local zone address %s", zs_addr);
Log(Logs::Detail, Logs::World_Server, "Local zone address %s", zs_addr);
}
}
@@ -1277,7 +1279,7 @@ void Client::Clearance(int8 response)
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,zone_id,instance_id,zsi->ip,zsi->port);
Log(Logs::Detail, Logs::World_Server,"Sending client to zone %s (%d:%d) at %s:%d",zonename,zone_id,instance_id,zsi->ip,zsi->port);
QueuePacket(outapp);
safe_delete(outapp);
@@ -1308,7 +1310,7 @@ bool Client::GenPassKey(char* key) {
}
void Client::QueuePacket(const EQApplicationPacket* app, bool ack_req) {
Log.Out(Logs::Detail, Logs::World_Server, "Sending EQApplicationPacket OpCode 0x%04x",app->GetOpcode());
Log(Logs::Detail, Logs::World_Server, "Sending EQApplicationPacket OpCode 0x%04x",app->GetOpcode());
ack_req = true; // It's broke right now, dont delete this line till fix it. =P
eqs->QueuePacket(app, ack_req);
@@ -1391,27 +1393,27 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
in.s_addr = GetIP();
Log.Out(Logs::Detail, Logs::World_Server, "Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort());
Log.Out(Logs::Detail, Logs::World_Server, "Name: %s", name);
Log.Out(Logs::Detail, Logs::World_Server, "Race: %d Class: %d Gender: %d Deity: %d Start zone: %d Tutorial: %s",
Log(Logs::Detail, Logs::World_Server, "Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort());
Log(Logs::Detail, Logs::World_Server, "Name: %s", name);
Log(Logs::Detail, Logs::World_Server, "Race: %d Class: %d Gender: %d Deity: %d Start zone: %d Tutorial: %s",
cc->race, cc->class_, cc->gender, cc->deity, cc->start_zone, cc->tutorial ? "true" : "false");
Log.Out(Logs::Detail, Logs::World_Server, "STR STA AGI DEX WIS INT CHA Total");
Log.Out(Logs::Detail, Logs::World_Server, "%3d %3d %3d %3d %3d %3d %3d %3d",
Log(Logs::Detail, Logs::World_Server, "STR STA AGI DEX WIS INT CHA Total");
Log(Logs::Detail, Logs::World_Server, "%3d %3d %3d %3d %3d %3d %3d %3d",
cc->STR, cc->STA, cc->AGI, cc->DEX, cc->WIS, cc->INT, cc->CHA,
stats_sum);
Log.Out(Logs::Detail, Logs::World_Server, "Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2);
Log.Out(Logs::Detail, Logs::World_Server, "Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor);
Log.Out(Logs::Detail, Logs::World_Server, "Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor);
Log(Logs::Detail, Logs::World_Server, "Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2);
Log(Logs::Detail, Logs::World_Server, "Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor);
Log(Logs::Detail, Logs::World_Server, "Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor);
/* Validate the char creation struct */
if (m_ClientVersionBit & EQEmu::versions::bit_SoFAndLater) {
if (!CheckCharCreateInfoSoF(cc)) {
Log.Out(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)");
Log(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)");
return false;
}
} else {
if (!CheckCharCreateInfoTitanium(cc)) {
Log.Out(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)");
Log(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)");
return false;
}
}
@@ -1476,14 +1478,14 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
/* If it is an SoF Client and the SoF Start Zone rule is set, send new chars there */
if (m_ClientVersionBit & EQEmu::versions::bit_SoFAndLater) {
Log.Out(Logs::Detail, Logs::World_Server,"Found 'SoFStartZoneID' rule setting: %i", RuleI(World, SoFStartZoneID));
Log(Logs::Detail, Logs::World_Server,"Found 'SoFStartZoneID' rule setting: %i", RuleI(World, SoFStartZoneID));
if (RuleI(World, SoFStartZoneID) > 0) {
pp.zone_id = RuleI(World, SoFStartZoneID);
cc->start_zone = pp.zone_id;
}
}
else {
Log.Out(Logs::General, Logs::World_Server, "Found 'TitaniumStartZoneID' rule setting: %i", RuleI(World, TitaniumStartZoneID));
Log(Logs::General, Logs::World_Server, "Found 'TitaniumStartZoneID' rule setting: %i", RuleI(World, TitaniumStartZoneID));
if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */
pp.zone_id = RuleI(World, TitaniumStartZoneID);
@@ -1543,11 +1545,11 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
pp.binds[0].heading = pp.heading;
}
Log.Out(Logs::Detail, Logs::World_Server,"Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f",
Log(Logs::Detail, Logs::World_Server,"Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f",
database.GetZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading);
Log.Out(Logs::Detail, Logs::World_Server,"Bind location: %s (%d) %0.2f, %0.2f, %0.2f",
Log(Logs::Detail, Logs::World_Server,"Bind location: %s (%d) %0.2f, %0.2f, %0.2f",
database.GetZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z);
Log.Out(Logs::Detail, Logs::World_Server,"Home location: %s (%d) %0.2f, %0.2f, %0.2f",
Log(Logs::Detail, Logs::World_Server,"Home location: %s (%d) %0.2f, %0.2f, %0.2f",
database.GetZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z);
/* Starting Items inventory */
@@ -1556,10 +1558,10 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc)
// now we give the pp and the inv we made to StoreCharacter
// to see if we can store it
if (!database.StoreCharacter(GetAccountID(), &pp, &inv)) {
Log.Out(Logs::Detail, Logs::World_Server,"Character creation failed: %s", pp.name);
Log(Logs::Detail, Logs::World_Server,"Character creation failed: %s", pp.name);
return false;
}
Log.Out(Logs::Detail, Logs::World_Server,"Character creation successful: %s", pp.name);
Log(Logs::Detail, Logs::World_Server,"Character creation successful: %s", pp.name);
return true;
}
@@ -1569,7 +1571,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
if (!cc)
return false;
Log.Out(Logs::Detail, Logs::World_Server, "Validating char creation info...");
Log(Logs::Detail, Logs::World_Server, "Validating char creation info...");
RaceClassCombos class_combo;
bool found = false;
@@ -1586,7 +1588,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
}
if (!found) {
Log.Out(Logs::Detail, Logs::World_Server, "Could not find class/race/deity/start_zone combination");
Log(Logs::Detail, Logs::World_Server, "Could not find class/race/deity/start_zone combination");
return false;
}
@@ -1603,7 +1605,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
}
if (!found) {
Log.Out(Logs::Detail, Logs::World_Server, "Could not find starting stats for selected character combo, cannot verify stats");
Log(Logs::Detail, Logs::World_Server, "Could not find starting stats for selected character combo, cannot verify stats");
return false;
}
@@ -1616,37 +1618,37 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
allocation.DefaultPointAllocation[6];
if (cc->STR > allocation.BaseStats[0] + max_stats || cc->STR < allocation.BaseStats[0]) {
Log.Out(Logs::Detail, Logs::World_Server, "Strength out of range");
Log(Logs::Detail, Logs::World_Server, "Strength out of range");
return false;
}
if (cc->DEX > allocation.BaseStats[1] + max_stats || cc->DEX < allocation.BaseStats[1]) {
Log.Out(Logs::Detail, Logs::World_Server, "Dexterity out of range");
Log(Logs::Detail, Logs::World_Server, "Dexterity out of range");
return false;
}
if (cc->AGI > allocation.BaseStats[2] + max_stats || cc->AGI < allocation.BaseStats[2]) {
Log.Out(Logs::Detail, Logs::World_Server, "Agility out of range");
Log(Logs::Detail, Logs::World_Server, "Agility out of range");
return false;
}
if (cc->STA > allocation.BaseStats[3] + max_stats || cc->STA < allocation.BaseStats[3]) {
Log.Out(Logs::Detail, Logs::World_Server, "Stamina out of range");
Log(Logs::Detail, Logs::World_Server, "Stamina out of range");
return false;
}
if (cc->INT > allocation.BaseStats[4] + max_stats || cc->INT < allocation.BaseStats[4]) {
Log.Out(Logs::Detail, Logs::World_Server, "Intelligence out of range");
Log(Logs::Detail, Logs::World_Server, "Intelligence out of range");
return false;
}
if (cc->WIS > allocation.BaseStats[5] + max_stats || cc->WIS < allocation.BaseStats[5]) {
Log.Out(Logs::Detail, Logs::World_Server, "Wisdom out of range");
Log(Logs::Detail, Logs::World_Server, "Wisdom out of range");
return false;
}
if (cc->CHA > allocation.BaseStats[6] + max_stats || cc->CHA < allocation.BaseStats[6]) {
Log.Out(Logs::Detail, Logs::World_Server, "Charisma out of range");
Log(Logs::Detail, Logs::World_Server, "Charisma out of range");
return false;
}
@@ -1659,7 +1661,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc)
current_stats += cc->WIS - allocation.BaseStats[5];
current_stats += cc->CHA - allocation.BaseStats[6];
if (current_stats > max_stats) {
Log.Out(Logs::Detail, Logs::World_Server, "Current Stats > Maximum Stats");
Log(Logs::Detail, Logs::World_Server, "Current Stats > Maximum Stats");
return false;
}
@@ -1740,7 +1742,7 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc)
if (!cc)
return false;
Log.Out(Logs::Detail, Logs::World_Server,"Validating char creation info...");
Log(Logs::Detail, Logs::World_Server,"Validating char creation info...");
classtemp = cc->class_ - 1;
racetemp = cc->race - 1;
@@ -1753,16 +1755,16 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc)
// if out of range looking it up in the table would crash stuff
// so we return from these
if (classtemp >= PLAYER_CLASS_COUNT) {
Log.Out(Logs::Detail, Logs::World_Server," class is out of range");
Log(Logs::Detail, Logs::World_Server," class is out of range");
return false;
}
if (racetemp >= _TABLE_RACES) {
Log.Out(Logs::Detail, Logs::World_Server," race is out of range");
Log(Logs::Detail, Logs::World_Server," race is out of range");
return false;
}
if (!ClassRaceLookupTable[classtemp][racetemp]) { //Lookup table better than a bunch of ifs?
Log.Out(Logs::Detail, Logs::World_Server," invalid race/class combination");
Log(Logs::Detail, Logs::World_Server," invalid race/class combination");
// we return from this one, since if it's an invalid combination our table
// doesn't have meaningful values for the stats
return false;
@@ -1790,43 +1792,43 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc)
// that are messed up not just the first hit
if (bTOTAL + stat_points != cTOTAL) {
Log.Out(Logs::Detail, Logs::World_Server," stat points total doesn't match expected value: expecting %d got %d", bTOTAL + stat_points, cTOTAL);
Log(Logs::Detail, Logs::World_Server," stat points total doesn't match expected value: expecting %d got %d", bTOTAL + stat_points, cTOTAL);
Charerrors++;
}
if (cc->STR > bSTR + stat_points || cc->STR < bSTR) {
Log.Out(Logs::Detail, Logs::World_Server," stat STR is out of range");
Log(Logs::Detail, Logs::World_Server," stat STR is out of range");
Charerrors++;
}
if (cc->STA > bSTA + stat_points || cc->STA < bSTA) {
Log.Out(Logs::Detail, Logs::World_Server," stat STA is out of range");
Log(Logs::Detail, Logs::World_Server," stat STA is out of range");
Charerrors++;
}
if (cc->AGI > bAGI + stat_points || cc->AGI < bAGI) {
Log.Out(Logs::Detail, Logs::World_Server," stat AGI is out of range");
Log(Logs::Detail, Logs::World_Server," stat AGI is out of range");
Charerrors++;
}
if (cc->DEX > bDEX + stat_points || cc->DEX < bDEX) {
Log.Out(Logs::Detail, Logs::World_Server," stat DEX is out of range");
Log(Logs::Detail, Logs::World_Server," stat DEX is out of range");
Charerrors++;
}
if (cc->WIS > bWIS + stat_points || cc->WIS < bWIS) {
Log.Out(Logs::Detail, Logs::World_Server," stat WIS is out of range");
Log(Logs::Detail, Logs::World_Server," stat WIS is out of range");
Charerrors++;
}
if (cc->INT > bINT + stat_points || cc->INT < bINT) {
Log.Out(Logs::Detail, Logs::World_Server," stat INT is out of range");
Log(Logs::Detail, Logs::World_Server," stat INT is out of range");
Charerrors++;
}
if (cc->CHA > bCHA + stat_points || cc->CHA < bCHA) {
Log.Out(Logs::Detail, Logs::World_Server," stat CHA is out of range");
Log(Logs::Detail, Logs::World_Server," stat CHA is out of range");
Charerrors++;
}
/*TODO: Check for deity/class/race.. it'd be nice, but probably of any real use to hack(faction, deity based items are all I can think of)
I am NOT writing those tables - kathgar*/
Log.Out(Logs::Detail, Logs::World_Server,"Found %d errors in character creation request", Charerrors);
Log(Logs::Detail, Logs::World_Server,"Found %d errors in character creation request", Charerrors);
return Charerrors == 0;
}
+1 -1
View File
@@ -283,7 +283,7 @@ bool ClientListEntry::CheckAuth(uint32 iLSID, const char* iKey) {
int16 tmpStatus = WorldConfig::get()->DefaultStatus;
paccountid = database.CreateAccount(plsname, 0, tmpStatus, LSID());
if (!paccountid) {
Log.Out(Logs::Detail, Logs::World_Server,"Error adding local account for LS login: '%s', duplicate name?" ,plsname);
Log(Logs::Detail, Logs::World_Server,"Error adding local account for LS login: '%s', duplicate name?" ,plsname);
return false;
}
strn0cpy(paccountname, plsname, sizeof(paccountname));
+17 -17
View File
@@ -63,7 +63,7 @@ void ClientList::Process() {
if (!iterator.GetData()->Process()) {
struct in_addr in;
in.s_addr = iterator.GetData()->GetIP();
Log.Out(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort());
Log(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort());
//the client destructor should take care of this.
// iterator.GetData()->Free();
iterator.RemoveCurrent();
@@ -158,16 +158,16 @@ void ClientList::GetCLEIP(uint32 iIP) {
countCLEIPs = iterator.GetData();
if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // If the IP matches, and the connection admin status is below the exempt status, or exempt status is less than 0 (no-one is exempt)
IPInstances++; // Increment the occurences of this IP address
Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
if (RuleB(World, EnableIPExemptions)) {
Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str()));
Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str()));
if (IPInstances > database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())) {
if(RuleB(World, IPLimitDisconnectAll)) {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
return;
} else {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
countCLEIPs->SetOnline(CLE_Status_Offline);
iterator.RemoveCurrent();
continue;
@@ -176,14 +176,14 @@ void ClientList::GetCLEIP(uint32 iIP) {
} else {
if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If the number of connections exceeds the lower limit
if (RuleB(World, MaxClientsSetByStatus)) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules
Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin());
Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin());
if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP
if(RuleB(World, IPLimitDisconnectAll)) {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
return;
} else {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
iterator.RemoveCurrent();
continue;
@@ -191,22 +191,22 @@ void ClientList::GetCLEIP(uint32 iIP) {
}
} else if ((countCLEIPs->Admin() < RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0)) { // Else if the Admin status of the connection is not eligible for the higher limit, or there is no higher limit (AddMaxClientStatus < 0)
if(RuleB(World, IPLimitDisconnectAll)) {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
return;
} else {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
iterator.RemoveCurrent();
continue;
}
} else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that
if(RuleB(World, IPLimitDisconnectAll)) {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
DisconnectByIP(iIP);
return;
} else {
Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
iterator.RemoveCurrent();
continue;
@@ -468,7 +468,7 @@ void ClientList::SendOnlineGuildMembers(uint32 FromID, uint32 GuildID)
if(!from)
{
Log.Out(Logs::Detail, Logs::World_Server,"Invalid client. FromID=%i GuildID=%i", FromID, GuildID);
Log(Logs::Detail, Logs::World_Server,"Invalid client. FromID=%i GuildID=%i", FromID, GuildID);
return;
}
@@ -771,7 +771,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
safe_delete_array(output);
}
catch(...){
Log.Out(Logs::Detail, Logs::World_Server,"Unknown error in world's SendWhoAll (probably mem error), ignoring...");
Log(Logs::Detail, Logs::World_Server,"Unknown error in world's SendWhoAll (probably mem error), ignoring...");
return;
}
}
@@ -914,7 +914,7 @@ void ClientList::SendFriendsWho(ServerFriendsWho_Struct *FriendsWho, WorldTCPCon
safe_delete(pack2);
}
catch(...){
Log.Out(Logs::Detail, Logs::World_Server,"Unknown error in world's SendFriendsWho (probably mem error), ignoring...");
Log(Logs::Detail, Logs::World_Server,"Unknown error in world's SendFriendsWho (probably mem error), ignoring...");
return;
}
}
@@ -1147,7 +1147,7 @@ Client* ClientList::FindByAccountID(uint32 account_id) {
iterator.Reset();
while(iterator.MoreElements()) {
Log.Out(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByAccountID(%p) iterator.GetData()[%p]", this, account_id, iterator.GetData());
Log(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByAccountID(%p) iterator.GetData()[%p]", this, account_id, iterator.GetData());
if (iterator.GetData()->GetAccountID() == account_id) {
Client* tmp = iterator.GetData();
return tmp;
@@ -1162,7 +1162,7 @@ Client* ClientList::FindByName(char* charname) {
iterator.Reset();
while(iterator.MoreElements()) {
Log.Out(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByName(\"%s\") iterator.GetData()[%p]", this, charname, iterator.GetData());
Log(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByName(\"%s\") iterator.GetData()[%p]", this, charname, iterator.GetData());
if (iterator.GetData()->GetCharName() == charname) {
Client* tmp = iterator.GetData();
return tmp;
+890
View File
@@ -0,0 +1,890 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
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 "../common/global_define.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include "../common/version.h"
#include "console.h"
#include "zoneserver.h"
#include "worlddb.h"
#include "../common/packet_dump.h"
#include "../common/seperator.h"
#include "../common/eq_packet_structs.h"
#include "../common/eq_packet.h"
#include "login_server.h"
#include "login_server_list.h"
#include "../common/serverinfo.h"
#include "../common/md5.h"
#include "../common/opcodemgr.h"
#include "../common/rulesys.h"
#include "../common/ruletypes.h"
#include "../common/string_util.h"
#include "world_config.h"
#include "zoneserver.h"
#include "zonelist.h"
#include "clientlist.h"
#include "launcher_list.h"
#include "ucs.h"
#include "queryserv.h"
#ifdef _WINDOWS
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
extern ZSList zoneserver_list;
extern uint32 numzones;
extern LoginServerList loginserverlist;
extern ClientList client_list;
extern LauncherList launcher_list;
extern UCSConnection UCSLink;
extern QueryServConnection QSLink;
extern volatile bool RunLoops;
ConsoleList console_list;
void CatchSignal(int sig_num);
Console::Console(EmuTCPConnection* itcpc)
: WorldTCPConnection(),
timeout_timer(RuleI(Console, SessionTimeOut)),
prompt_timer(1)
{
tcpc = itcpc;
tcpc->SetEcho(true);
state = 0;
paccountid = 0;
memset(paccountname, 0, sizeof(paccountname));
admin = 0;
pAcceptMessages = false;
}
Console::~Console() {
if (tcpc)
tcpc->Free();
}
void Console::Die() {
state = CONSOLE_STATE_CLOSED;
struct in_addr in;
in.s_addr = GetIP();
Log(Logs::Detail, Logs::World_Server,"Removing console from %s:%d",inet_ntoa(in),GetPort());
tcpc->Disconnect();
}
bool Console::SendChannelMessage(const ServerChannelMessage_Struct* scm) {
if (!pAcceptMessages)
return false;
switch (scm->chan_num) {
if(RuleB(Chat, ServerWideAuction)){
case 4: {
SendMessage(1, "%s auctions, '%s'", scm->from, scm->message);
break;
}
}
if(RuleB(Chat, ServerWideOOC)){
case 5: {
SendMessage(1, "%s says ooc, '%s'", scm->from, scm->message);
break;
}
}
case 6: {
SendMessage(1, "%s BROADCASTS, '%s'", scm->from, scm->message);
break;
}
case 7: {
SendMessage(1, "[%s] tells you, '%s'", scm->from, scm->message);
auto pack = new ServerPacket(ServerOP_ChannelMessage,
sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1);
memcpy(pack->pBuffer, scm, pack->size);
ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*) pack->pBuffer;
strcpy(scm2->deliverto, scm2->from);
scm2->noreply = true;
client_list.SendPacket(scm->from, pack);
safe_delete(pack);
break;
}
case 11: {
SendMessage(1, "%s GMSAYS, '%s'", scm->from, scm->message);
break;
}
default: {
return false;
}
}
return true;
}
bool Console::SendEmoteMessage(uint32 type, const char* message, ...) {
if (!message)
return false;
if (!pAcceptMessages)
return false;
va_list argptr;
char buffer[1024];
va_start(argptr, message);
vsnprintf(buffer, sizeof(buffer), message, argptr);
va_end(argptr);
SendMessage(1, message);
return true;
}
bool Console::SendEmoteMessageRaw(uint32 type, const char* message) {
if (!message)
return false;
if (!pAcceptMessages)
return false;
SendMessage(1, message);
return true;
}
void Console::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...) {
if (!message)
return;
if (to_guilddbid != 0 || to_minstatus > Admin())
return;
va_list argptr;
char buffer[1024];
va_start(argptr, message);
vsnprintf(buffer, sizeof(buffer), message, argptr);
va_end(argptr);
SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, buffer);
}
void Console::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) {
if (!message)
return;
if (to_guilddbid != 0 || to_minstatus > Admin())
return;
SendMessage(1, message);
}
void Console::SendMessage(uint8 newline, const char* message, ...) {
if (!message)
return;
char* buffer = 0;
uint32 bufsize = 1500;
if (message)
bufsize += strlen(message);
buffer = new char[bufsize];
memset(buffer, 0, bufsize);
if (message != 0) {
va_list argptr;
va_start(argptr, message);
vsnprintf(buffer, bufsize - 512, message, argptr);
va_end(argptr);
}
if (newline) {
char outbuf[3];
outbuf[0] = 13;
outbuf[1] = 10;
outbuf[2] = 0;
for (int i=0; i < newline; i++)
strcat(buffer, outbuf);
}
tcpc->Send((uchar*) buffer, strlen(buffer));
safe_delete_array(buffer);
}
bool Console::Process() {
if (state == CONSOLE_STATE_CLOSED)
return false;
if (!tcpc->Connected()) {
struct in_addr in;
in.s_addr = GetIP();
Log(Logs::Detail, Logs::World_Server,"Removing console (!tcpc->Connected) from %s:%d",inet_ntoa(in),GetPort());
return false;
}
//if we have not gotten the special markers after this timer, send login prompt
if(prompt_timer.Check()) {
struct in_addr in;
in.s_addr = GetIP();
std::string connecting_ip = inet_ntoa(in);
SendMessage(2, StringFormat("Establishing connection from IP: %s Port: %d", inet_ntoa(in), GetPort()).c_str());
if (connecting_ip.find("127.0.0.1") != std::string::npos) {
SendMessage(2, StringFormat("Connecting established from local host, auto assuming admin").c_str());
state = CONSOLE_STATE_CONNECTED;
tcpc->SetEcho(false);
admin = 255;
SendPrompt();
}
else {
if (tcpc->GetMode() == EmuTCPConnection::modeConsole)
tcpc->Send((const uchar*) "Username: ", strlen("Username: "));
}
prompt_timer.Disable();
}
if (timeout_timer.Check()) {
SendMessage(1, 0);
SendMessage(1, "Timeout, disconnecting...");
struct in_addr in;
in.s_addr = GetIP();
Log(Logs::Detail, Logs::World_Server,"TCP connection timeout from %s:%d",inet_ntoa(in),GetPort());
return false;
}
if (tcpc->GetMode() == EmuTCPConnection::modePacket) {
struct in_addr in;
in.s_addr = GetIP();
if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
auto zs = new ZoneServer(tcpc);
Log(Logs::Detail, Logs::World_Server,"New zoneserver #%d from %s:%d", zs->GetID(), inet_ntoa(in), GetPort());
zoneserver_list.Add(zs);
numzones++;
tcpc = 0;
} else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
Log(Logs::Detail, Logs::World_Server,"New launcher from %s:%d", inet_ntoa(in), GetPort());
launcher_list.Add(tcpc);
tcpc = 0;
}
else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS)
{
Log(Logs::Detail, Logs::World_Server,"New UCS Connection from %s:%d", inet_ntoa(in), GetPort());
UCSLink.SetConnection(tcpc);
tcpc = 0;
}
else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ)
{
Log(Logs::Detail, Logs::World_Server,"New QS Connection from %s:%d", inet_ntoa(in), GetPort());
QSLink.SetConnection(tcpc);
tcpc = 0;
}
else {
Log(Logs::Detail, Logs::World_Server,"Unsupported packet mode from %s:%d", inet_ntoa(in), GetPort());
}
return false;
}
char* command = 0;
while ((command = tcpc->PopLine())) {
timeout_timer.Start();
ProcessCommand(command);
delete command;
}
return true;
}
void ConsoleList::Add(Console* con) {
list.Insert(con);
}
void ConsoleList::Process() {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
while(iterator.MoreElements()) {
if (!iterator.GetData()->Process())
iterator.RemoveCurrent();
else
iterator.Advance();
}
}
void ConsoleList::KillAll() {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
while(iterator.MoreElements()) {
iterator.GetData()->Die();
iterator.RemoveCurrent();
}
}
void ConsoleList::SendConsoleWho(WorldTCPConnection* connection, const char* to, int16 admin, char** output, uint32* outsize, uint32* outlen) {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
struct in_addr in;
int x = 0;
while(iterator.MoreElements()) {
in.s_addr = iterator.GetData()->GetIP();
if (admin >= iterator.GetData()->Admin())
AppendAnyLenString(output, outsize, outlen, " Console: %s:%i AccID: %i AccName: %s", inet_ntoa(in), iterator.GetData()->GetPort(), iterator.GetData()->AccountID(), iterator.GetData()->AccountName());
else
AppendAnyLenString(output, outsize, outlen, " Console: AccID: %i AccName: %s", iterator.GetData()->AccountID(), iterator.GetData()->AccountName());
if (*outlen >= 3584) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, *output);
safe_delete(*output);
*outsize = 0;
*outlen = 0;
}
else {
if (connection->IsConsole())
AppendAnyLenString(output, outsize, outlen, "\r\n");
else
AppendAnyLenString(output, outsize, outlen, "\n");
}
x++;
iterator.Advance();
}
AppendAnyLenString(output, outsize, outlen, "%i consoles connected", x);
}
void ConsoleList::SendChannelMessage(const ServerChannelMessage_Struct* scm) {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
while(iterator.MoreElements()) {
iterator.GetData()->SendChannelMessage(scm);
iterator.Advance();
}
}
void ConsoleList::SendEmoteMessage(uint32 type, const char* message, ...) {
va_list argptr;
char buffer[1024];
va_start(argptr, message);
vsnprintf(buffer, sizeof(buffer), message, argptr);
va_end(argptr);
SendEmoteMessageRaw(type, buffer);
}
void ConsoleList::SendEmoteMessageRaw(uint32 type, const char* message) {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
while(iterator.MoreElements()) {
iterator.GetData()->SendEmoteMessageRaw(type, message);
iterator.Advance();
}
}
Console* ConsoleList::FindByAccountName(const char* accname) {
LinkedListIterator<Console*> iterator(list);
iterator.Reset();
while(iterator.MoreElements()) {
if (strcasecmp(iterator.GetData()->AccountName(), accname) == 0)
return iterator.GetData();
iterator.Advance();
}
return 0;
}
void Console::ProcessCommand(const char* command) {
switch(state)
{
case CONSOLE_STATE_USERNAME:
{
if (strlen(command) >= 16) {
SendMessage(1, 0);
SendMessage(2, "Username buffer overflow.");
SendMessage(1, "Bye Bye.");
state = CONSOLE_STATE_CLOSED;
return;
}
strcpy(paccountname, command);
state = CONSOLE_STATE_PASSWORD;
SendMessage(0, "Password: ");
tcpc->SetEcho(false);
break;
}
case CONSOLE_STATE_PASSWORD:
{
if (strlen(command) >= 16) {
SendMessage(1, 0);
SendMessage(2, "Password buffer overflow.");
SendMessage(1, "Bye Bye.");
state = CONSOLE_STATE_CLOSED;
return;
}
paccountid = database.CheckLogin(paccountname ,command);
if (paccountid == 0) {
SendMessage(1, 0);
SendMessage(2, "Login failed.");
SendMessage(1, "Bye Bye.");
state = CONSOLE_STATE_CLOSED;
return;
}
database.GetAccountName(paccountid, paccountname); // fixes case and stuff
admin = database.CheckStatus(paccountid);
if (!(admin >= consoleLoginStatus)) {
SendMessage(1, 0);
SendMessage(2, "Access denied.");
SendMessage(1, "Bye Bye.");
state = CONSOLE_STATE_CLOSED;
return;
}
Log(Logs::Detail, Logs::World_Server,"TCP console authenticated: Username=%s, Admin=%d",paccountname,admin);
SendMessage(1, 0);
SendMessage(2, "Login accepted.");
state = CONSOLE_STATE_CONNECTED;
tcpc->SetEcho(true);
SendPrompt();
break;
}
case CONSOLE_STATE_CONNECTED: {
Log(Logs::Detail, Logs::World_Server,"TCP command: %s: \"%s\"",paccountname ,command);
Seperator sep(command);
if (strcasecmp(sep.arg[0], "help") == 0 || strcmp(sep.arg[0], "?") == 0) {
SendMessage(1, " whoami");
SendMessage(1, " who");
SendMessage(1, " zonestatus");
SendMessage(1, " uptime [zoneID#]");
SendMessage(1, " emote [zonename or charname or world] [type] [message]");
SendMessage(1, " echo [on/off]");
SendMessage(1, " acceptmessages [on/off]");
SendMessage(1, " tell [name] [message]");
SendMessage(1, " broadcast [message]");
SendMessage(1, " gmsay [message]");
SendMessage(1, " ooc [message]");
SendMessage(1, " auction [message]");
if (admin >= consoleKickStatus)
SendMessage(1, " kick [charname]");
if (admin >= consoleLockStatus)
SendMessage(1, " lock/unlock");
if (admin >= consoleZoneStatus) {
SendMessage(1, " zoneshutdown [zonename or ZoneServerID]");
SendMessage(1, " zonebootup [ZoneServerID] [zonename]");
SendMessage(1, " zonelock [list|lock|unlock] [zonename]");
}
if (admin >= consoleFlagStatus)
SendMessage(1, " flag [status] [accountname]");
if (admin >= consolePassStatus)
SendMessage(1, " setpass [accountname] [newpass]");
if (admin >= consoleWorldStatus) {
SendMessage(1, " version");
SendMessage(1, " worldshutdown");
}
if (admin >= 201) {
SendMessage(1, " IPLookup [name]");
}
if (admin >= 100) {
SendMessage(1, " LSReconnect");
SendMessage(1, " signalcharbyname charname ID");
SendMessage(1, " reloadworld");
}
}
else if (strcasecmp(sep.arg[0], "ping") == 0) {
// do nothing
}
else if (strcasecmp(sep.arg[0], "signalcharbyname") == 0) {
SendMessage(1, "Signal Sent to %s with ID %i", (char*) sep.arg[1], atoi(sep.arg[2]));
uint32 message_len = strlen((char*) sep.arg[1]) + 1;
auto pack = new ServerPacket(ServerOP_CZSignalClientByName,
sizeof(CZClientSignalByName_Struct) + message_len);
CZClientSignalByName_Struct* CZSC = (CZClientSignalByName_Struct*) pack->pBuffer;
strn0cpy(CZSC->Name, (char*) sep.arg[1], 64);
CZSC->data = atoi(sep.arg[2]);
zoneserver_list.SendPacket(pack);
safe_delete(pack);
}
else if (strcasecmp(sep.arg[0], "setpass") == 0 && admin >= consolePassStatus) {
if (sep.argnum != 2)
SendMessage(1, "Format: setpass accountname password");
else {
int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(sep.arg[1], &tmpstatus);
if (!tmpid)
SendMessage(1, "Error: Account not found");
else if (tmpstatus > admin)
SendMessage(1, "Cannot change password: Account's status is higher than yours");
else if (database.SetLocalPassword(tmpid, sep.arg[2]))
SendMessage(1, "Password changed.");
else
SendMessage(1, "Error changing password.");
}
}
else if (strcasecmp(sep.arg[0], "uptime") == 0) {
if (sep.IsNumber(1) && atoi(sep.arg[1]) > 0) {
auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct));
ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer;
snprintf(sus->adminname, sizeof(sus->adminname), "*%s", this->GetName());
sus->zoneserverid = atoi(sep.arg[1]);
ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
if (zs)
zs->SendPacket(pack);
else
SendMessage(1, "Zoneserver not found.");
delete pack;
}
else {
ZSList::ShowUpTime(this);
}
}
else if (strcasecmp(sep.arg[0], "md5") == 0) {
uint8 md5[16];
MD5::Generate((const uchar*) sep.argplus[1], strlen(sep.argplus[1]), md5);
SendMessage(1, "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]);
}
else if (strcasecmp(sep.arg[0], "whoami") == 0) {
SendMessage(1, "You are logged in as '%s'", this->AccountName());
SendMessage(1, "You are known as '*%s'", this->AccountName());
SendMessage(1, "AccessLevel: %d", this->Admin());
}
else if (strcasecmp(sep.arg[0], "echo") == 0) {
if (strcasecmp(sep.arg[1], "on") == 0)
tcpc->SetEcho(true);
else if (strcasecmp(sep.arg[1], "off") == 0) {
if (pAcceptMessages)
SendMessage(1, "Echo can not be turned off while acceptmessages is on");
else
tcpc->SetEcho(false);
}
else
SendMessage(1, "Usage: echo [on/off]");
}
else if (strcasecmp(sep.arg[0], "acceptmessages") == 0) {
if (strcasecmp(sep.arg[1], "on") == 0)
if (tcpc->GetEcho())
SendMessage(1, "AcceptMessages can not be turned on while echo is on");
else
pAcceptMessages = true;
else if (strcasecmp(sep.arg[1], "off") == 0)
pAcceptMessages = false;
else
SendMessage(1, "Usage: acceptmessages [on/off]");
}
else if (strcasecmp(sep.arg[0], "tell") == 0) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
zoneserver_list.SendChannelMessage(tmpname, sep.arg[1], 7, 0, sep.argplus[2]);
}
else if (strcasecmp(sep.arg[0], "broadcast") == 0) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, sep.argplus[1]);
}
else if (strcasecmp(sep.arg[0], "ooc") == 0) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, sep.argplus[1]);
}
else if (strcasecmp(sep.arg[0], "auction") == 0) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, sep.argplus[1]);
}
else if (strcasecmp(sep.arg[0], "gmsay") == 0 || strcasecmp(sep.arg[0], "pr") == 0) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, sep.argplus[1]);
}
else if (strcasecmp(sep.arg[0], "emote") == 0) {
if (strcasecmp(sep.arg[1], "world") == 0)
zoneserver_list.SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]);
else {
ZoneServer* zs = zoneserver_list.FindByName(sep.arg[1]);
if (zs != 0)
zs->SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]);
else
zoneserver_list.SendEmoteMessageRaw(sep.arg[1], 0, 0, atoi(sep.arg[2]), sep.argplus[3]);
}
}
else if (strcasecmp(sep.arg[0], "movechar") == 0) {
if(sep.arg[1][0]==0 || sep.arg[2][0] == 0)
SendMessage(1, "Usage: movechar [charactername] [zonename]");
else {
if (!database.GetZoneID(sep.arg[2]))
SendMessage(1, "Error: Zone '%s' not found", sep.arg[2]);
else if (!database.CheckUsedName((char*) sep.arg[1])) {
if (!database.MoveCharacterToZone((char*) sep.arg[1], (char*) sep.arg[2]))
SendMessage(1, "Character Move Failed!");
else
SendMessage(1, "Character has been moved.");
}
else
SendMessage(1, "Character Does Not Exist");
}
}
else if (strcasecmp(sep.arg[0], "flag") == 0 && this->Admin() >= consoleFlagStatus) {
// SCORPIOUS2K - reversed parameter order for flag
if(sep.arg[2][0]==0 || !sep.IsNumber(1))
SendMessage(1, "Usage: flag [status] [accountname]");
else
{
if (atoi(sep.arg[1]) > this->Admin())
SendMessage(1, "You cannot set people's status to higher than your own");
else if (atoi(sep.arg[1]) < 0 && this->Admin() < consoleFlagStatus)
SendMessage(1, "You have too low of status to change flags");
else if (!database.SetAccountStatus(sep.arg[2], atoi(sep.arg[1])))
SendMessage(1, "Unable to flag account!");
else
SendMessage(1, "Account Flaged");
}
}
else if (strcasecmp(sep.arg[0], "kick") == 0 && admin >= consoleKickStatus) {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
auto pack = new ServerPacket;
pack->opcode = ServerOP_KickPlayer;
pack->size = sizeof(ServerKickPlayer_Struct);
pack->pBuffer = new uchar[pack->size];
ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
strcpy(skp->adminname, tmpname);
strcpy(skp->name, sep.arg[1]);
skp->adminrank = this->Admin();
zoneserver_list.SendPacket(pack);
delete pack;
}
else if (strcasecmp(sep.arg[0], "who") == 0) {
auto whom = new Who_All_Struct;
memset(whom, 0, sizeof(Who_All_Struct));
whom->lvllow = 0xFFFF;
whom->lvlhigh = 0xFFFF;
whom->wclass = 0xFFFF;
whom->wrace = 0xFFFF;
whom->gmlookup = 0xFFFF;
for (int i=1; i<=sep.argnum; i++) {
if (strcasecmp(sep.arg[i], "gm") == 0)
whom->gmlookup = 1;
else if (sep.IsNumber(i)) {
if (whom->lvllow == 0xFFFF) {
whom->lvllow = atoi(sep.arg[i]);
whom->lvlhigh = whom->lvllow;
}
else if (atoi(sep.arg[i]) > int(whom->lvllow))
whom->lvlhigh = atoi(sep.arg[i]);
else
whom->lvllow = atoi(sep.arg[i]);
}
else
strn0cpy(whom->whom, sep.arg[i], sizeof(whom->whom));
}
client_list.ConsoleSendWhoAll(0, admin, whom, this);
delete whom;
}
else if (strcasecmp(sep.arg[0], "zonestatus") == 0) {
zoneserver_list.SendZoneStatus(0, admin, this);
}
else if (strcasecmp(sep.arg[0], "exit") == 0 || strcasecmp(sep.arg[0], "quit") == 0) {
SendMessage(1, "Bye Bye.");
state = CONSOLE_STATE_CLOSED;
}
else if (strcasecmp(sep.arg[0], "zoneshutdown") == 0 && admin >= consoleZoneStatus) {
if (sep.arg[1][0] == 0) {
SendMessage(1, "Usage: zoneshutdown zoneshortname");
} else {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
auto pack = new ServerPacket;
pack->size = sizeof(ServerZoneStateChange_struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, sizeof(ServerZoneStateChange_struct));
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
pack->opcode = ServerOP_ZoneShutdown;
strcpy(s->adminname, tmpname);
if (sep.arg[1][0] >= '0' && sep.arg[1][0] <= '9')
s->ZoneServerID = atoi(sep.arg[1]);
else
s->zoneid = database.GetZoneID(sep.arg[1]);
ZoneServer* zs = 0;
if (s->ZoneServerID != 0)
zs = zoneserver_list.FindByID(s->ZoneServerID);
else if (s->zoneid != 0)
zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid));
else
SendMessage(1, "Error: ZoneShutdown: neither ID nor name specified");
if (zs == 0)
SendMessage(1, "Error: ZoneShutdown: zoneserver not found");
else
zs->SendPacket(pack);
delete pack;
}
}
else if (strcasecmp(sep.arg[0], "zonebootup") == 0 && admin >= consoleZoneStatus) {
if (sep.arg[2][0] == 0 || !sep.IsNumber(1)) {
SendMessage(1, "Usage: zonebootup ZoneServerID# zoneshortname");
} else {
char tmpname[64];
tmpname[0] = '*';
strcpy(&tmpname[1], paccountname);
Log(Logs::Detail, Logs::World_Server,"Console ZoneBootup: %s, %s, %s",tmpname,sep.arg[2],sep.arg[1]);
zoneserver_list.SOPZoneBootup(tmpname, atoi(sep.arg[1]), sep.arg[2], (bool) (strcasecmp(sep.arg[3], "static") == 0));
}
}
else if (strcasecmp(sep.arg[0], "worldshutdown") == 0 && admin >= consoleWorldStatus) {
int32 time, interval;
if(sep.IsNumber(1) && sep.IsNumber(2) && ((time=atoi(sep.arg[1]))>0) && ((interval=atoi(sep.arg[2]))>0)) {
zoneserver_list.WorldShutDown(time, interval);
}
else if(strcasecmp(sep.arg[1], "now") == 0) {
zoneserver_list.WorldShutDown(0, 0);
}
else if(strcasecmp(sep.arg[1], "disable") == 0) {
SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World shutdown aborted.");
zoneserver_list.SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World shutdown aborted.");
zoneserver_list.shutdowntimer->Disable();
zoneserver_list.reminder->Disable();
}
else {
SendMessage(1, "Usage: worldshutdown [now] [disable] ([time] [interval])");
//Go ahead and shut down since that's what this used to do when invoked this way.
zoneserver_list.WorldShutDown(0, 0);
}
}
else if (strcasecmp(sep.arg[0], "lock") == 0 && admin >= consoleLockStatus) {
WorldConfig::LockWorld();
if (loginserverlist.Connected()) {
loginserverlist.SendStatus();
SendMessage(1, "World locked.");
}
else {
SendMessage(1, "World locked, but login server not connected.");
}
}
else if (strcasecmp(sep.arg[0], "unlock") == 0 && admin >= consoleLockStatus) {
WorldConfig::UnlockWorld();
if (loginserverlist.Connected()) {
loginserverlist.SendStatus();
SendMessage(1, "World unlocked.");
}
else {
SendMessage(1, "World unlocked, but login server not connected.");
}
}
else if (strcasecmp(sep.arg[0], "version") == 0 && admin >= consoleWorldStatus) {
SendMessage(1, "Current version information.");
SendMessage(1, " %s", CURRENT_VERSION);
SendMessage(1, " Compiled on: %s at %s", COMPILE_DATE, COMPILE_TIME);
SendMessage(1, " Last modified on: %s", LAST_MODIFIED);
}
else if (strcasecmp(sep.arg[0], "serverinfo") == 0 && admin >= 200) {
if (strcasecmp(sep.arg[1], "os") == 0) {
#ifdef _WINDOWS
GetOS();
char intbuffer [sizeof(unsigned long)];
SendMessage(1, "Operating system information.");
SendMessage(1, " %s", Ver_name);
SendMessage(1, " Build number: %s", ultoa(Ver_build, intbuffer, 10));
SendMessage(1, " Minor version: %s", ultoa(Ver_min, intbuffer, 10));
SendMessage(1, " Major version: %s", ultoa(Ver_maj, intbuffer, 10));
SendMessage(1, " Platform Id: %s", ultoa(Ver_pid, intbuffer, 10));
#else
char os_string[100];
SendMessage(1, "Operating system information.");
SendMessage(1, " %s", GetOS(os_string));
#endif
}
else {
SendMessage(1, "Usage: Serverinfo [type]");
SendMessage(1, " OS - Operating system version information.");
}
}
else if (strcasecmp(sep.arg[0], "IPLookup") == 0 && admin >= 201) {
client_list.SendCLEList(admin, 0, this, sep.argplus[1]);
}
else if (strcasecmp(sep.arg[0], "LSReconnect") == 0 && admin >= 100) {
#ifdef _WINDOWS
_beginthread(AutoInitLoginServer, 0, nullptr);
#else
pthread_t thread;
pthread_create(&thread, nullptr, &AutoInitLoginServer, nullptr);
#endif
RunLoops = true;
SendMessage(1, " Login Server Reconnect manually restarted by Console");
Log(Logs::Detail, Logs::World_Server,"Login Server Reconnect manually restarted by Console");
}
else if (strcasecmp(sep.arg[0], "zonelock") == 0 && admin >= consoleZoneStatus) {
if (strcasecmp(sep.arg[1], "list") == 0) {
zoneserver_list.ListLockedZones(0, this);
}
else if (strcasecmp(sep.arg[1], "lock") == 0 && admin >= 101) {
uint16 tmp = database.GetZoneID(sep.arg[2]);
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, true))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(tmp));
else
SendMessage(1, "Failed to change lock");
}
else
SendMessage(1, "Usage: #zonelock lock [zonename]");
}
else if (strcasecmp(sep.arg[1], "unlock") == 0 && admin >= 101) {
uint16 tmp = database.GetZoneID(sep.arg[2]);
if (tmp) {
if (zoneserver_list.SetLockedZone(tmp, false))
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(tmp));
else
SendMessage(1, "Failed to change lock");
}
else
SendMessage(1, "Usage: #zonelock unlock [zonename]");
}
else {
SendMessage(1, "#zonelock sub-commands");
SendMessage(1, " list");
if (admin >= 101) {
SendMessage(1, " lock [zonename]");
SendMessage(1, " unlock [zonename]");
}
}
}
else if (strcasecmp(sep.arg[0], "reloadworld") == 0 && admin > 101)
{
SendEmoteMessage(0,0,0,15,"Reloading World...");
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
ReloadWorld_Struct* RW = (ReloadWorld_Struct*) pack->pBuffer;
RW->Option = 1;
zoneserver_list.SendPacket(pack);
safe_delete(pack);
}
else if (strcasecmp(sep.arg[0], "") == 0){
/* Hit Enter with no command */
}
else {
SendMessage(1, "Command unknown.");
}
if (state == CONSOLE_STATE_CONNECTED)
SendPrompt();
break;
}
default: {
break;
}
}
}
void Console::SendPrompt() {
if (tcpc->GetEcho())
SendMessage(0, "%s> ", paccountname);
}
+6 -5
View File
@@ -41,8 +41,9 @@ void EQLConfig::LoadSettings() {
std::string query = StringFormat("SELECT dynamics FROM launcher WHERE name = '%s'", namebuf);
auto results = database.QueryDatabase(query);
if (!results.Success())
Log.Out(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str());
if (!results.Success()) {
Log(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str());
}
else {
auto row = results.begin();
m_dynamics = atoi(row[0]);
@@ -51,7 +52,7 @@ void EQLConfig::LoadSettings() {
query = StringFormat("SELECT zone, port FROM launcher_zones WHERE launcher = '%s'", namebuf);
results = database.QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str());
Log(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str());
return;
}
@@ -198,7 +199,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
Log(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
return false;
}
@@ -234,7 +235,7 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
Log(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
return false;
}
+335
View File
@@ -0,0 +1,335 @@
/* EQEMu: Everquest Server Emulator
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 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 "../common/global_define.h"
#include "eqw_http_handler.h"
#include "../common/SocketLib/Base64.h"
#include "eqw_parser.h"
#include "eqw.h"
#include "http_request.h"
#include "worlddb.h"
#include "console.h"
Mime EQWHTTPHandler::s_mime;
#ifdef EMBPERL
EQWParser *EQWHTTPHandler::s_parser = nullptr;
#endif
const int EQWHTTPHandler::READ_BUFFER_LEN = 1024; //for page IO, was a static const member, but VC6 got mad.
EQWHTTPHandler::EQWHTTPHandler(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
: HttpdSocket(ID,in_socket,irIP,irPort),
m_closeOnFinish(false)
{
}
EQWHTTPHandler::~EQWHTTPHandler() {
}
#ifdef EMBPERL
EQWParser *EQWHTTPHandler::GetParser() {
if(s_parser == nullptr) {
EQW::Singleton()->ClearOutput();
s_parser = new EQWParser();
const std::string &res = EQW::Singleton()->GetOutput();
if(!res.empty()) {
printf("EQWParser Init output:\n%s\n\n", res.c_str());
EQW::Singleton()->ClearOutput();
}
}
return(s_parser);
}
#endif
/*void EQWHTTPHandler::OnWrite() {
HttpdSocket::OnWrite();
if(m_closeOnFinish && GetOutputLength() == 0) {
// printf("CLOSING\n");
Close();
}
}*/
void EQWHTTPHandler::Exec() {
m_sentHeaders = false;
m_responseCode = "200";
// printf("Request: %s, %s, %s, %s.\n", GetMethod().c_str(), GetUrl().c_str(), GetUri().c_str(), GetQueryString().c_str());
SetHttpVersion("HTTP/1.0");
AddResponseHeader("Connection", "close");
if(GetUri().find("..") != std::string::npos) {
SendResponse("403", "Forbidden");
printf("%s is forbidden.\n", GetUri().c_str());
return;
}
if(!CheckAuth()) {
AddResponseHeader("Content-type", "text/plain");
AddResponseHeader("WWW-Authenticate", "Basic realm=\"EQEmulator\"");
SendResponse("401", "Authorization Required");
SendString("Gotta Authenticate.");
} else {
std::string::size_type start = GetUri().find_first_not_of('/');
std::string page;
if(start != std::string::npos)
page = GetUri().substr(start);
else
page = "index.html";
SendPage(page);
}
/* if (!Detach()) {
printf("Unable to detach...\n");
}
if(GetOutputLength() > 0) {
//we cannot close yet
m_closeOnFinish = true;
} else {
Close();
}*/
Free(); //the "app" side (us) is done with this connection too...
Disconnect();
}
void EQWHTTPHandler::OnHeader(const std::string& key,const std::string& value) {
HttpdSocket::OnHeader(key, value);
if (!strcasecmp(key.c_str(),"Authorization")) {
if(strncasecmp(value.c_str(), "Basic ", 6)) {
printf("Invalid auth type. Expected Basic: %s\n", value.c_str());
return;
}
std::string dec;
Base64::decode(value.c_str() + 6, dec);
std::string::size_type cpos;
cpos = dec.find_first_of(':');
if(cpos == std::string::npos) {
printf("Invalid auth string: %s\n", dec.c_str());
return;
}
m_username = dec.substr(0, cpos);
m_password = dec.substr(cpos+1);
}
}
//we should prolly cache login info here... if we load a fresh page, we could be checking
//their auth dozens of times rather quickly...
bool EQWHTTPHandler::CheckAuth() const {
if(m_username.length() < 1)
return(false);
int16 status = 0;
uint32 acctid = database.CheckLogin(m_username.c_str(), m_password.c_str(), &status);
if(acctid == 0) {
Log(Logs::Detail, Logs::World_Server, "Login autentication failed for %s with '%s'", m_username.c_str(), m_password.c_str());
return(false);
}
if(status < httpLoginStatus) {
Log(Logs::Detail, Logs::World_Server, "Login of %s failed: status too low.", m_username.c_str());
return(false);
}
return(true);
}
void EQWHTTPHandler::SendPage(const std::string &file) {
std::string path = "templates/";
path += file;
FILE *f = fopen(path.c_str(), "rb");
if(f == nullptr) {
SendResponse("404", "Not Found");
SendString("Not found.");
printf("%s not found.\n", file.c_str());
return;
}
std::string type = s_mime.GetMimeFromFilename(file);
AddResponseHeader("Content-type", type);
bool process = false;
#ifdef EMBPERL
if(type == "text/html")
process = true;
else {
//not processing, send headers right away
#endif
SendResponse("200", "OK");
#ifdef EMBPERL
}
#endif
auto buffer = new char[READ_BUFFER_LEN + 1];
size_t len;
std::string to_process;
while((len = fread(buffer, 1, READ_BUFFER_LEN, f)) > 0) {
buffer[len] = '\0';
if(process)
to_process += buffer;
else
SendBuf(buffer, len);
}
delete[] buffer;
fclose(f);
#ifdef EMBPERL
if(process) {
//convert the base form into a useful perl exportable form
HTTPRequest req(this, GetHttpForm());
GetParser()->SetHTTPRequest("testing", &req);
//parse out the page and potentially pass some stuff on to perl.
ProcessAndSend(to_process);
//clear out the form, just in case (since it gets destroyed next)
GetParser()->SetHTTPRequest("testing", nullptr);
}
#endif
}
bool EQWHTTPHandler::LoadMimeTypes(const char *filename) {
return(s_mime.LoadMimeFile(filename));
}
#ifdef EMBPERL
void EQWHTTPHandler::ProcessAndSend(const std::string &str) {
std::string::size_type len = str.length();
std::string::size_type start = 0;
std::string::size_type pos, end;
while((pos = str.find("<?", start)) != std::string::npos) {
//send all the crap leading up to the script block
if(pos != start) {
ProcessText(str.c_str() + start, pos-start);
}
//look for the end of this script block...
end = str.find("?>", pos+2);
if(end == std::string::npos) {
//terminal ?> not found... should issue a warning or something...
std::string scriptBody = str.substr(pos+2);
ProcessScript(scriptBody);
start = len;
break;
} else {
//script only consumes some of this buffer...
std::string scriptBody = str.substr(pos+2, end-pos-2);
ProcessScript(scriptBody);
start = end + 2;
}
}
//send whatever is left over
if(start != len)
ProcessText(str.c_str() + start, len-start);
}
void EQWHTTPHandler::ProcessScript(const std::string &script_body) {
const char *script = script_body.c_str();
if(strcmp("perl", script) == 0)
script += 4; //allow <?perl
// printf("Script: ''''%s''''\n\n", script_body.c_str());
GetParser()->EQW_eval("testing", script_body.c_str());
const std::string &res = EQW::Singleton()->GetOutput();
if(!res.empty()) {
ProcessText(res.c_str(), res.length());
EQW::Singleton()->ClearOutput();
}
}
void EQWHTTPHandler::ProcessText(const char *txt, int len) {
if(!m_sentHeaders) {
SendResponse(m_responseCode, "OK");
m_sentHeaders = true;
}
SendBuf(txt, len);
}
#endif
EQWHTTPServer::EQWHTTPServer()
: m_port(0)
{
}
void EQWHTTPServer::CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) {
auto conn = new EQWHTTPHandler(ID, in_socket, irIP, irPort);
AddConnection(conn);
}
void EQWHTTPServer::Stop() {
Log(Logs::Detail, Logs::World_Server, "Requesting that HTTP Service stop.");
m_running = false;
Close();
}
bool EQWHTTPServer::Start(uint16 port, const char *mime_file) {
if(m_running) {
Log(Logs::Detail, Logs::World_Server, "HTTP Service is already running on port %d", m_port);
return(false);
}
//load up our nice mime types
if(!EQWHTTPHandler::LoadMimeTypes(mime_file)) {
Log(Logs::Detail, Logs::World_Server, "Failed to load mime types from '%s'", mime_file);
return(false);
} else {
Log(Logs::Detail, Logs::World_Server, "Loaded mime types from %s", mime_file);
}
//fire up the server thread
char errbuf[TCPServer_ErrorBufferSize];
if(!Open(port, errbuf)) {
Log(Logs::Detail, Logs::World_Server, "Unable to bind to port %d for HTTP service: %s", port, errbuf);
return(false);
}
m_running = true;
m_port = port;
/*
#ifdef _WINDOWS
_beginthread(ThreadProc, 0, this);
#else
pthread_create(&m_thread, nullptr, ThreadProc, this);
#endif*/
return(true);
}
/*
void EQWHTTPServer::Run() {
Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread started on port %d", m_port);
do {
#warning DELETE THIS IF YOU DONT USE IT
Sleep(10);
} while(m_running);
Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread terminating on port %d", m_port);
}
ThreadReturnType EQWHTTPServer::ThreadProc(void *data) {
((EQWHTTPServer *) data)->Run();
THREAD_RETURN(nullptr);
}*/
+348
View File
@@ -0,0 +1,348 @@
/* EQEMu: Everquest Server Emulator
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 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
*/
//a lot of this is copied from embperl.cpp, but I didnt feel like factoring the common stuff out
#ifdef EMBPERL
#include "../common/global_define.h"
#include "eqw_parser.h"
#include "eqw.h"
#include "../common/eqdb.h"
#include "worlddb.h"
#ifndef GvCV_set
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
#endif
XS(XS_EQWIO_PRINT);
//so embedded scripts can use xs extensions (ala 'use socket;')
EXTERN_C void boot_DynaLoader(pTHX_ CV* cv);
EXTERN_C XS(boot_EQW);
EXTERN_C XS(boot_EQDB);
EXTERN_C XS(boot_EQDBRes);
EXTERN_C XS(boot_HTTPRequest);
EXTERN_C XS(boot_EQLConfig);
EXTERN_C void xs_init(pTHX)
{
char file[256];
strncpy(file, __FILE__, 256);
file[255] = '\0';
char buf[128]; //shouldent have any function names longer than this.
//add the strcpy stuff to get rid of const warnings....
newXS(strcpy(buf, "DynaLoader::boot_DynaLoader"), boot_DynaLoader, file);
newXS(strcpy(buf, "EQW::boot_EQW"), boot_EQW, file);
newXS(strcpy(buf, "EQDB::boot_EQDB"), boot_EQDB, file);
newXS(strcpy(buf, "EQDBRes::boot_EQDBRes"), boot_EQDBRes, file);
newXS(strcpy(buf, "HTTPRequest::boot_HTTPRequest"), boot_HTTPRequest, file);
newXS(strcpy(buf, "EQLConfig::boot_EQLConfig"), boot_EQLConfig, file);
newXS(strcpy(buf, "EQWIO::PRINT"), XS_EQWIO_PRINT, file);
}
EQWParser::EQWParser() {
//setup perl...
my_perl = perl_alloc();
_empty_sv = newSV(0);
if (!my_perl) {
Log(Logs::Detail, Logs::World_Server, "Error: perl_alloc failed!");
}
else {
DoInit();
}
}
void EQWParser::DoInit() {
const char *argv_eqemu[] = { "",
"-w", "-W",
"-e", "0;", nullptr };
int argc = 5;
char **argv = (char **)argv_eqemu;
char **env = { nullptr };
PL_perl_destruct_level = 1;
perl_construct(my_perl);
PERL_SYS_INIT3(&argc, &argv, &env);
perl_parse(my_perl, xs_init, argc, argv, env);
perl_run(my_perl);
//a little routine we use a lot.
eval_pv("sub my_eval {eval $_[0];}", TRUE); //dies on error
//ruin the perl exit and command:
eval_pv("sub my_exit {}",TRUE);
eval_pv("sub my_sleep {}",TRUE);
if(gv_stashpv("CORE::GLOBAL", FALSE)) {
GV *exitgp = gv_fetchpv("CORE::GLOBAL::exit", TRUE, SVt_PVCV);
GvCV_set(exitgp, perl_get_cv("my_exit", TRUE)); //dies on error
GvIMPORTED_CV_on(exitgp);
GV *sleepgp = gv_fetchpv("CORE::GLOBAL::sleep", TRUE, SVt_PVCV);
GvCV_set(sleepgp, perl_get_cv("my_sleep", TRUE)); //dies on error
GvIMPORTED_CV_on(sleepgp);
}
//setup eval_file
eval_pv(
"our %Cache;"
"use Symbol qw(delete_package);"
"sub eval_file {"
"my($package, $filename) = @_;"
"$filename=~s/\'//g;"
"if(! -r $filename) { print \"Unable to read perl file '$filename'\\n\"; return; }"
"my $mtime = -M $filename;"
"if(defined $Cache{$package}{mtime}&&$Cache{$package}{mtime} <= $mtime && !($package eq 'plugin')){"
" return;"
"} else {"
//we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require '$filename'; \");"
"}"
"}"
,FALSE);
//make a tie-able class to capture IO and get it where it needs to go
eval_pv(
"package EQWIO; "
// "&boot_EQEmuIO;"
"sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '.$me); return($me); } "
"sub WRITE { } "
"sub PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } "
"sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } "
"sub DESTROY { my $me = shift; $me->PRINT('Destroying '.$me); } "
//this ties us for all packages
"package MAIN;"
" if(tied *STDOUT) { untie(*STDOUT); }"
" if(tied *STDERR) { untie(*STDERR); }"
" tie *STDOUT, 'EQWIO';"
" tie *STDERR, 'EQWIO';"
,FALSE);
eval_pv(
"package world; "
,FALSE
);
//make sure the EQW pointer is set up in this package
EQW *curc = EQW::Singleton();
SV *l = get_sv("world::EQW", true);
if(curc != nullptr) {
sv_setref_pv(l, "EQW", curc);
} else {
//clear out the value, mainly to get rid of blessedness
sv_setsv(l, _empty_sv);
}
//make sure the EQDB pointer is set up in this package
EQDB::SetMySQL(database.getMySQL());
EQDB *curc_db = EQDB::Singleton();
SV *l_db = get_sv("world::EQDB", true);
if(curc_db != nullptr) {
sv_setref_pv(l_db, "EQDB", curc_db);
} else {
//clear out the value, mainly to get rid of blessedness
sv_setsv(l_db, _empty_sv);
}
//load up EQW
eval_pv(
"package EQW;"
"&boot_EQW;" //load our EQW XS
"package EQDB;"
"&boot_EQDB;" //load our EQW XS
"package EQDBRes;"
"&boot_EQDBRes;" //load our EQW XS
"package HTTPRequest;"
"&boot_HTTPRequest;" //load our HTTPRequest XS
"package EQLConfig;"
"&boot_EQLConfig;" //load our EQLConfig XS
, FALSE );
#ifdef EMBPERL_PLUGIN
Log(Logs::Detail, Logs::World_Server, "Loading worldui perl plugins.");
std::string err;
if(!eval_file("world", "worldui.pl", err)) {
Log(Logs::Detail, Logs::World_Server, "Warning - world.pl: %s", err.c_str());
}
eval_pv(
"package world; "
"if(opendir(D,'worldui')) { "
" my @d = readdir(D);"
" closedir(D);"
" foreach(@d){ "
" next unless(/\\.pl$); "
" require 'templates/'.$_;"
" }"
"}"
,FALSE);
#endif //EMBPERL_PLUGIN
}
EQWParser::~EQWParser() {
//removed to try to stop perl from exploding on reload, we'll see
/* eval_pv(
"package quest;"
" untie *STDOUT;"
" untie *STDERR;"
,FALSE);
*/
perl_free(my_perl);
}
bool EQWParser::eval_file(const char * packagename, const char * filename, std::string &error)
{
std::vector<std::string> args;
args.push_back(packagename);
args.push_back(filename);
return(dosub("eval_file", args, error));
}
bool EQWParser::dosub(const char * subname, const std::vector<std::string> &args, std::string &error, int mode) {
bool err = false;
dSP; // initialize stack pointer
ENTER; // everything created after here
SAVETMPS; // ...is a temporary variable
PUSHMARK(SP); // remember the stack pointer
if(!args.empty())
{
for (auto i = args.begin(); i != args.end(); ++i) { /* push the arguments onto the perl stack */
XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
}
}
PUTBACK; // make local stack pointer global
call_pv(subname, mode); /*eval our code*/
SPAGAIN; // refresh stack pointer
if(SvTRUE(ERRSV)) {
err = true;
}
FREETMPS; // free temp values
LEAVE; // ...and the XPUSHed "mortal" args.
if(err) {
error = "Perl runtime error: ";
error += SvPVX(ERRSV);
return(false);
}
return(true);
}
bool EQWParser::eval(const char * code, std::string &error) {
std::vector<std::string> arg;
arg.push_back(code);
return(dosub("my_eval", arg, error, G_SCALAR|G_DISCARD|G_EVAL|G_KEEPERR));
}
void EQWParser::EQW_eval(const char *pkg, const char *code) {
char namebuf[64];
snprintf(namebuf, 64, "package %s;", pkg);
eval_pv(namebuf, FALSE);
//make sure the EQW pointer is set up
EQW *curc = EQW::Singleton();
snprintf(namebuf, 64, "EQW");
// snprintf(namebuf, 64, "%s::EQW", pkg);
SV *l = get_sv(namebuf, true);
if(curc != nullptr) {
sv_setref_pv(l, "EQW", curc);
} else {
//clear out the value, mainly to get rid of blessedness
sv_setsv(l, _empty_sv);
}
//make sure the EQDB pointer is set up
EQDB *curc_db = EQDB::Singleton();
snprintf(namebuf, 64, "EQDB");
// snprintf(namebuf, 64, "%s::EQW", pkg);
SV *l_db = get_sv(namebuf, true);
if(curc_db != nullptr) {
sv_setref_pv(l_db, "EQDB", curc_db);
} else {
//clear out the value, mainly to get rid of blessedness
sv_setsv(l_db, _empty_sv);
}
std::string err;
if(!eval(code, err)) {
EQW::Singleton()->AppendOutput(err.c_str());
}
}
void EQWParser::SetHTTPRequest(const char *pkg, HTTPRequest *it) {
char namebuf[64];
snprintf(namebuf, 64, "package %s;", pkg);
eval_pv(namebuf, FALSE);
snprintf(namebuf, 64, "request");
// snprintf(namebuf, 64, "%s::EQW", pkg);
SV *l = get_sv(namebuf, true);
if(it != nullptr) {
sv_setref_pv(l, "HTTPRequest", it);
} else {
//clear out the value, mainly to get rid of blessedness
sv_setsv(l, _empty_sv);
}
}
/*
$editors = array();
$editors["merchant"] = new MerchantEditor();
#... for other editors
if(defined($editors[$editor])) {
$edit = $editors[$editor];
$edit->dispatch($action);
}
class MerchantEditor extends BaseEditor {
MerchantEditor() {
$this->RegisterAction(0, "get_merchantlist", "merchant/merchant.tmpl.php", "no");
$this->RegisterAction(1, "get_merchantlist", "merchant/merchant.edit.tmpl.php", "no");
}
}
function dispatch() {
my $dispatcher = $this->_dispatchers[$action];
$body = new Template($dispatcher["template"]);
my $proc = $dispatcher["proc"];
$vars = $this->$proc();
if($dispatcher["guestmode"] == "no") {
check_authorization();
}
if ($vars) {
foreach ($vars as $key=>$value) {
$body->set($key, $value);
}
}
}
*/
#endif //EMBPERL
+61 -57
View File
@@ -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;
}
}
+32 -32
View File
@@ -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
*/
@@ -24,7 +24,7 @@
#include "eql_config.h"
LauncherList::LauncherList()
: nextID(1)
: nextID(1)
{
}
@@ -32,21 +32,21 @@ LauncherList::~LauncherList() {
std::vector<LauncherLink *>::iterator cur, end;
cur = m_pendingLaunchers.begin();
end = m_pendingLaunchers.end();
for(; cur != end; ++cur) {
for (; cur != end; ++cur) {
delete *cur;
}
std::map<std::string, EQLConfig *>::iterator curc, endc;
curc = m_configs.begin();
endc = m_configs.end();
for(; curc != endc; ++curc) {
for (; curc != endc; ++curc) {
delete curc->second;
}
std::map<std::string, LauncherLink *>::iterator curl, endl;
curl = m_launchers.begin();
endl = m_launchers.end();
for(; curl != endl; ++curl) {
for (; curl != endl; ++curl) {
delete curl->second;
}
}
@@ -54,9 +54,9 @@ LauncherList::~LauncherList() {
void LauncherList::Process() {
std::vector<LauncherLink *>::iterator cur;
cur = m_pendingLaunchers.begin();
while(cur != m_pendingLaunchers.end()) {
while (cur != m_pendingLaunchers.end()) {
LauncherLink *l = *cur;
if(l->HasName()) {
if (l->HasName()) {
//launcher has identified itself now.
//remove ourself from the pending list
cur = m_pendingLaunchers.erase(cur);
@@ -64,14 +64,15 @@ void LauncherList::Process() {
//kill off anybody else using our name.
std::map<std::string, LauncherLink *>::iterator res;
res = m_launchers.find(name);
if(res != m_launchers.end()) {
Log.Out(Logs::Detail, Logs::World_Server, "Ghosting launcher %s", name.c_str());
if (res != m_launchers.end()) {
Log(Logs::Detail, Logs::World_Server, "Ghosting launcher %s", name.c_str());
delete res->second;
}
Log.Out(Logs::Detail, Logs::World_Server, "Removing pending launcher %d. Adding %s to active list.", l->GetID(), name.c_str());
Log(Logs::Detail, Logs::World_Server, "Removing pending launcher %d. Adding %s to active list.", l->GetID(), name.c_str());
//put the launcher in the list.
m_launchers[name] = l;
} else {
}
else {
++cur;
}
}
@@ -80,7 +81,7 @@ void LauncherList::Process() {
LauncherLink *LauncherList::Get(const char *name) {
std::map<std::string, LauncherLink *>::iterator res;
res = m_launchers.find(name);
if(res == m_launchers.end())
if (res == m_launchers.end())
return(nullptr);
return(res->second);
}
@@ -89,8 +90,8 @@ LauncherLink *LauncherList::FindByZone(const char *short_name) {
std::map<std::string, LauncherLink *>::iterator cur, end;
cur = m_launchers.begin();
end = m_launchers.end();
for(; cur != end; ++cur) {
if(cur->second->ContainsZone(short_name))
for (; cur != end; ++cur) {
if (cur->second->ContainsZone(short_name))
return(cur->second);
}
return(nullptr);
@@ -98,7 +99,7 @@ LauncherLink *LauncherList::FindByZone(const char *short_name) {
void LauncherList::Add(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn) {
auto it = new LauncherLink(nextID++, conn);
Log.Out(Logs::Detail, Logs::World_Server, "Adding pending launcher %d", it->GetID());
Log(Logs::Detail, Logs::World_Server, "Adding pending launcher %d", it->GetID());
m_pendingLaunchers.push_back(it);
}
@@ -132,7 +133,7 @@ void LauncherList::GetLauncherNameList(std::vector<std::string> &res) {
std::map<std::string, EQLConfig *>::iterator cur, end;
cur = m_configs.begin();
end = m_configs.end();
for(; cur != end; ++cur) {
for (; cur != end; ++cur) {
res.push_back(cur->first);
}
}
@@ -145,7 +146,7 @@ void LauncherList::LoadList() {
std::vector<std::string>::iterator cur, end;
cur = launchers.begin();
end = launchers.end();
for(; cur != end; ++cur) {
for (; cur != end; ++cur) {
m_configs[*cur] = new EQLConfig(cur->c_str());
}
}
@@ -153,7 +154,7 @@ void LauncherList::LoadList() {
EQLConfig *LauncherList::GetConfig(const char *name) {
std::map<std::string, EQLConfig *>::iterator res;
res = m_configs.find(name);
if(res == m_configs.end()) {
if (res == m_configs.end()) {
return(nullptr);
}
return(res->second);
@@ -166,15 +167,14 @@ void LauncherList::CreateLauncher(const char *name, uint8 dynamic_count) {
void LauncherList::Remove(const char *name) {
std::map<std::string, EQLConfig *>::iterator resc;
resc = m_configs.find(name);
if(resc != m_configs.end()) {
if (resc != m_configs.end()) {
delete resc->second;
m_configs.erase(resc);
}
std::map<std::string, LauncherLink *>::iterator resl;
resl = m_launchers.find(name);
if(resl != m_launchers.end()) {
if (resl != m_launchers.end()) {
resl->second->Disconnect();
}
}
+46 -47
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
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"
#include <iostream>
@@ -43,10 +43,10 @@ extern volatile bool RunLoops;
LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool legacy)
{
strn0cpy(LoginServerAddress,iAddress,256);
strn0cpy(LoginServerAddress, iAddress, 256);
LoginServerPort = iPort;
strn0cpy(LoginAccount,Account,31);
strn0cpy(LoginPassword,Password,31);
strn0cpy(LoginAccount, Account, 31);
strn0cpy(LoginPassword, Password, 31);
CanAccountUpdate = false;
IsLegacy = legacy;
Connect();
@@ -57,7 +57,7 @@ LoginServer::~LoginServer() {
void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
UsertoWorldRequest_Struct* utwr = (UsertoWorldRequest_Struct*)p.Data();
uint32 id = database.GetAccountIDFromLSID(utwr->lsaccountid);
@@ -99,8 +99,8 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
try {
auto slsca = p.GetSerialize<ClientAuth_Struct>(0);
@@ -109,27 +109,27 @@ void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) {
// online at the same time.
client_list.EnforceSessionLimit(slsca.lsaccount_id);
}
client_list.CLEAdd(slsca.lsaccount_id, slsca.name, slsca.key, slsca.worldadmin, slsca.ip, slsca.local);
}
catch (std::exception &ex) {
Log.OutF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
LogF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
}
}
void LoginServer::ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log.Out(Logs::Detail, Logs::World_Server, "Login server responded with FatalError.");
Log(Logs::Detail, Logs::World_Server, "Login server responded with FatalError.");
if (p.Length() > 1) {
Log.Out(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data());
Log(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data());
}
}
void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
ServerSystemwideMessage* swm = (ServerSystemwideMessage*)p.Data();
zoneserver_list.SendEmoteMessageRaw(0, 0, 0, swm->type, swm->message);
@@ -137,44 +137,44 @@ void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p)
void LoginServer::ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
if (!Config->WorldAddress.length()) {
WorldConfig::SetWorldAddress((char *)p.Data());
Log.Out(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data());
Log(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data());
}
}
void LoginServer::ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p) {
const WorldConfig *Config = WorldConfig::get();
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
Log.Out(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver");
Log(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver");
CanAccountUpdate = true;
}
bool LoginServer::Connect() {
std::string tmp;
if(database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) {
if (database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) {
minilogin = true;
Log.Out(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type");
Log(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type");
}
else
minilogin = false;
if (minilogin && WorldConfig::get()->WorldAddress.length()==0) {
Log.Out(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the <address> element in the <world> section.");
if (minilogin && WorldConfig::get()->WorldAddress.length() == 0) {
Log(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the <address> element in the <world> section.");
return false;
}
char errbuf[1024];
if ((LoginServerIP = ResolveIP(LoginServerAddress, errbuf)) == 0) {
Log.Out(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.",LoginServerAddress);
Log(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.", LoginServerAddress);
return false;
}
if (LoginServerIP == 0 || LoginServerPort == 0) {
Log.Out(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d",LoginServerAddress,LoginServerPort);
Log(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d", LoginServerAddress, LoginServerPort);
return false;
}
@@ -182,7 +182,7 @@ bool LoginServer::Connect() {
legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false));
legacy_client->OnConnect([this](EQ::Net::ServertalkLegacyClient *client) {
if (client) {
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
Log(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
if (minilogin)
SendInfo();
else
@@ -195,7 +195,7 @@ bool LoginServer::Connect() {
}));
}
else {
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
Log(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
}
});
@@ -211,7 +211,7 @@ bool LoginServer::Connect() {
client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", ""));
client->OnConnect([this](EQ::Net::ServertalkClient *client) {
if (client) {
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
Log(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
if (minilogin)
SendInfo();
else
@@ -224,7 +224,7 @@ bool LoginServer::Connect() {
}));
}
else {
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
Log(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
}
});
@@ -239,14 +239,14 @@ bool LoginServer::Connect() {
return true;
}
void LoginServer::SendInfo() {
const WorldConfig *Config=WorldConfig::get();
const WorldConfig *Config = WorldConfig::get();
auto pack = new ServerPacket;
pack->opcode = ServerOP_LSInfo;
pack->size = sizeof(ServerLSInfo_Struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*) pack->pBuffer;
ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*)pack->pBuffer;
strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION);
strcpy(lsi->serverversion, LOGIN_VERSION);
strcpy(lsi->name, Config->LongName.c_str());
@@ -258,14 +258,14 @@ void LoginServer::SendInfo() {
}
void LoginServer::SendNewInfo() {
const WorldConfig *Config=WorldConfig::get();
const WorldConfig *Config = WorldConfig::get();
auto pack = new ServerPacket;
pack->opcode = ServerOP_NewLSInfo;
pack->size = sizeof(ServerNewLSInfo_Struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*) pack->pBuffer;
ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*)pack->pBuffer;
strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION);
strcpy(lsi->serverversion, LOGIN_VERSION);
strcpy(lsi->name, Config->LongName.c_str());
@@ -291,7 +291,7 @@ void LoginServer::SendStatus() {
pack->size = sizeof(ServerLSStatus_Struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*) pack->pBuffer;
ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*)pack->pBuffer;
if (WorldConfig::get()->Locked)
lss->status = -2;
@@ -307,12 +307,11 @@ void LoginServer::SendStatus() {
}
void LoginServer::SendAccountUpdate(ServerPacket* pack) {
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
if(CanUpdate()) {
Log.Out(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d",LoginServerAddress,LoginServerPort);
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *)pack->pBuffer;
if (CanUpdate()) {
Log(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d", LoginServerAddress, LoginServerPort);
strn0cpy(s->worldaccount, LoginAccount, 30);
strn0cpy(s->worldpassword, LoginPassword, 30);
SendPacket(pack);
}
}
+13 -14
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
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"
#include <iostream>
@@ -88,7 +88,7 @@ bool LoginServerList::SendPacket(ServerPacket* pack) {
}
bool LoginServerList::SendAccountUpdate(ServerPacket* pack) {
Log.Out(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers");
Log(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers");
for (auto &iter : m_list) {
if ((*iter).CanUpdate()) {
(*iter).SendAccountUpdate(pack);
@@ -137,4 +137,3 @@ bool LoginServerList::CanUpdate() {
return false;
}
+139 -136
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
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"
@@ -41,27 +41,27 @@
#include "client.h"
#include "worlddb.h"
#ifdef _WINDOWS
#include <process.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#include <conio.h>
#include <process.h>
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#include <conio.h>
#else
#include <pthread.h>
#include "../common/unix.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#if not defined (FREEBSD) && not defined (DARWIN)
union semun {
int val;
struct semid_ds *buf;
ushort *array;
struct seminfo *__buf;
void *__pad;
};
#endif
#include <pthread.h>
#include "../common/unix.h"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/shm.h>
#if not defined (FREEBSD) && not defined (DARWIN)
union semun {
int val;
struct semid_ds *buf;
ushort *array;
struct seminfo *__buf;
void *__pad;
};
#endif
#endif
@@ -91,7 +91,7 @@ ZSList zoneserver_list;
LoginServerList loginserverlist;
UCSConnection UCSLink;
QueryServConnection QSLink;
LauncherList launcher_list;
LauncherList launcher_list;
AdventureManager adventure_manager;
EQEmu::Random emu_random;
volatile bool RunLoops = true;
@@ -99,20 +99,20 @@ uint32 numclients = 0;
uint32 numzones = 0;
bool holdzones = false;
const WorldConfig *Config;
EQEmuLogSys Log;
EQEmuLogSys LogSys;
WebInterfaceList web_interface;
void CatchSignal(int sig_num);
int main(int argc, char** argv) {
RegisterExecutablePlatform(ExePlatformWorld);
Log.LoadLogSettingsDefaults();
LogSys.LoadLogSettingsDefaults();
set_exception_handler();
/* Database Version Check */
uint32 Database_Version = CURRENT_BINARY_DATABASE_VERSION;
uint32 Bots_Database_Version = CURRENT_BINARY_BOTS_DATABASE_VERSION;
if (argc >= 2) {
if (argc >= 2) {
if (strcasecmp(argv[1], "db_version") == 0) {
std::cout << "Binary Database Version: " << Database_Version << " : " << Bots_Database_Version << std::endl;
return 0;
@@ -120,66 +120,67 @@ int main(int argc, char** argv) {
}
// Load server configuration
Log.Out(Logs::General, Logs::World_Server, "Loading server configuration..");
Log(Logs::General, Logs::World_Server, "Loading server configuration..");
if (!WorldConfig::LoadConfig()) {
Log.Out(Logs::General, Logs::World_Server, "Loading server configuration failed.");
Log(Logs::General, Logs::World_Server, "Loading server configuration failed.");
return 1;
}
Config = WorldConfig::get();
Log.Out(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
Log(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
return 1;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
return 1;
}
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
return 1;
}
#endif
#endif
// add login server config to list
if (Config->LoginCount == 0) {
if (Config->LoginHost.length()) {
loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str(), Config->LoginLegacy);
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
}
} else {
LinkedList<LoginConfig*> loginlist=Config->loginlist;
}
else {
LinkedList<LoginConfig*> loginlist = Config->loginlist;
LinkedListIterator<LoginConfig*> iterator(loginlist);
iterator.Reset();
while(iterator.MoreElements()) {
while (iterator.MoreElements()) {
loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str(),
iterator.GetData()->LoginLegacy);
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
iterator.Advance();
}
}
Log.Out(Logs::General, Logs::World_Server, "Connecting to MySQL...");
Log(Logs::General, Logs::World_Server, "Connecting to MySQL...");
if (!database.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort)) {
Log.Out(Logs::General, Logs::World_Server, "Cannot continue without a database connection.");
Log(Logs::General, Logs::World_Server, "Cannot continue without a database connection.");
return 1;
}
guild_mgr.SetDatabase(&database);
/* Register Log System and Settings */
database.LoadLogSettings(Log.log_settings);
Log.StartFileLogs();
database.LoadLogSettings(LogSys.log_settings);
LogSys.StartFileLogs();
bool ignore_db = false;
if (argc >= 2) {
@@ -227,7 +228,7 @@ int main(int argc, char** argv) {
if (argc == 4) {
if (Seperator::IsNumber(argv[3])) {
if (atoi(argv[3]) >= 0 && atoi(argv[3]) <= 255) {
if (database.SetAccountStatus(argv[2], atoi(argv[3]))){
if (database.SetAccountStatus(argv[2], atoi(argv[3]))) {
std::cout << "Account flagged: Username='" << argv[2] << "', status=" << argv[3] << std::endl;
return 0;
}
@@ -266,7 +267,7 @@ int main(int argc, char** argv) {
std::cout << "Usage: world startzone zoneshortname" << std::endl;
return 0;
}
else if(strcasecmp(argv[1], "ignore_db") == 0) {
else if (strcasecmp(argv[1], "ignore_db") == 0) {
ignore_db = true;
}
else {
@@ -275,100 +276,102 @@ int main(int argc, char** argv) {
}
}
if(!ignore_db) {
Log.Out(Logs::General, Logs::World_Server, "Checking Database Conversions..");
if (!ignore_db) {
Log(Logs::General, Logs::World_Server, "Checking Database Conversions..");
database.CheckDatabaseConversions();
}
Log.Out(Logs::General, Logs::World_Server, "Loading variables..");
Log(Logs::General, Logs::World_Server, "Loading variables..");
database.LoadVariables();
std::string hotfix_name;
if(database.GetVariable("hotfix_name", hotfix_name)) {
if (database.GetVariable("hotfix_name", hotfix_name)) {
if (!hotfix_name.empty()) {
Log.Out(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str());
Log(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str());
}
}
Log.Out(Logs::General, Logs::World_Server, "Loading zones..");
Log(Logs::General, Logs::World_Server, "Loading zones..");
database.LoadZoneNames();
Log.Out(Logs::General, Logs::World_Server, "Clearing groups..");
Log(Logs::General, Logs::World_Server, "Clearing groups..");
database.ClearGroup();
Log.Out(Logs::General, Logs::World_Server, "Clearing raids..");
Log(Logs::General, Logs::World_Server, "Clearing raids..");
database.ClearRaid();
database.ClearRaidDetails();
database.ClearRaidLeader();
Log.Out(Logs::General, Logs::World_Server, "Clearing inventory snapshots..");
Log(Logs::General, Logs::World_Server, "Clearing inventory snapshots..");
database.ClearInvSnapshots();
Log.Out(Logs::General, Logs::World_Server, "Loading items..");
if(!database.LoadItems(hotfix_name))
Log.Out(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring");
Log.Out(Logs::General, Logs::World_Server, "Loading skill caps..");
if(!database.LoadSkillCaps(std::string(hotfix_name)))
Log.Out(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring");
Log.Out(Logs::General, Logs::World_Server, "Loading guilds..");
Log(Logs::General, Logs::World_Server, "Loading items..");
if (!database.LoadItems(hotfix_name))
Log(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring");
Log(Logs::General, Logs::World_Server, "Loading skill caps..");
if (!database.LoadSkillCaps(std::string(hotfix_name)))
Log(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring");
Log(Logs::General, Logs::World_Server, "Loading guilds..");
guild_mgr.LoadGuilds();
//rules:
{
std::string tmp;
if (database.GetVariable("RuleSet", tmp)) {
Log.Out(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str());
if(!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
Log.Out(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
Log(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str());
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
Log(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
}
} else {
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
Log.Out(Logs::General, Logs::World_Server, "No rule set configured, using default rules");
} else {
Log.Out(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str());
}
else {
if (!RuleManager::Instance()->LoadRules(&database, "default")) {
Log(Logs::General, Logs::World_Server, "No rule set configured, using default rules");
}
else {
Log(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str());
}
}
}
if(RuleB(World, ClearTempMerchantlist)){
Log.Out(Logs::General, Logs::World_Server, "Clearing temporary merchant lists..");
if (RuleB(World, ClearTempMerchantlist)) {
Log(Logs::General, Logs::World_Server, "Clearing temporary merchant lists..");
database.ClearMerchantTemp();
}
Log.Out(Logs::General, Logs::World_Server, "Loading EQ time of day..");
Log(Logs::General, Logs::World_Server, "Loading EQ time of day..");
TimeOfDay_Struct eqTime;
time_t realtime;
eqTime = database.LoadTime(realtime);
zoneserver_list.worldclock.SetCurrentEQTimeOfDay(eqTime, realtime);
Timer EQTimeTimer(600000);
EQTimeTimer.Start(600000);
Log.Out(Logs::General, Logs::World_Server, "Loading launcher list..");
Log(Logs::General, Logs::World_Server, "Loading launcher list..");
launcher_list.LoadList();
std::string tmp;
database.GetVariable("holdzones",tmp);
database.GetVariable("holdzones", tmp);
if (tmp.length() == 1 && tmp[0] == '1') {
holdzones = true;
}
Log.Out(Logs::General, Logs::World_Server, "Reboot zone modes %s",holdzones ? "ON" : "OFF");
Log(Logs::General, Logs::World_Server, "Reboot zone modes %s", holdzones ? "ON" : "OFF");
Log.Out(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses());
Log(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses());
Log.Out(Logs::General, Logs::World_Server, "Loading adventures...");
if(!adventure_manager.LoadAdventureTemplates())
Log(Logs::General, Logs::World_Server, "Loading adventures...");
if (!adventure_manager.LoadAdventureTemplates())
{
Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
Log(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
}
if(!adventure_manager.LoadAdventureEntries())
if (!adventure_manager.LoadAdventureEntries())
{
Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
Log(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
}
adventure_manager.Load();
adventure_manager.LoadLeaderboardInfo();
Log.Out(Logs::General, Logs::World_Server, "Purging expired instances");
Log(Logs::General, Logs::World_Server, "Purging expired instances");
database.PurgeExpiredInstances();
Timer PurgeInstanceTimer(450000);
PurgeInstanceTimer.Start(450000);
Log.Out(Logs::General, Logs::World_Server, "Loading char create info...");
Log(Logs::General, Logs::World_Server, "Loading char create info...");
database.LoadCharacterCreateAllocations();
database.LoadCharacterCreateCombos();
@@ -380,10 +383,10 @@ int main(int argc, char** argv) {
server_opts.ipv6 = false;
server_opts.credentials = Config->SharedKey;
server_connection->Listen(server_opts);
Log.Out(Logs::General, Logs::World_Server, "Server (TCP) listener started.");
Log(Logs::General, Logs::World_Server, "Server (TCP) listener started.");
server_connection->OnConnectionIdentified("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}",
LogF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}",
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
numzones++;
@@ -391,7 +394,7 @@ int main(int argc, char** argv) {
});
server_connection->OnConnectionRemoved("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}",
LogF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}",
connection->GetUUID());
numzones--;
@@ -399,56 +402,56 @@ int main(int argc, char** argv) {
});
server_connection->OnConnectionIdentified("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}",
LogF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}",
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
launcher_list.Add(connection);
});
server_connection->OnConnectionRemoved("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}",
LogF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}",
connection->GetUUID());
launcher_list.Remove(connection);
});
server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
LogF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
QSLink.AddConnection(connection);
});
server_connection->OnConnectionRemoved("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
connection->GetUUID());
QSLink.RemoveConnection(connection);
});
server_connection->OnConnectionIdentified("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}",
LogF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}",
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
UCSLink.SetConnection(connection);
});
server_connection->OnConnectionRemoved("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
connection->GetUUID());
UCSLink.SetConnection(nullptr);
});
server_connection->OnConnectionIdentified("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}",
LogF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}",
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
web_interface.AddConnection(connection);
});
server_connection->OnConnectionRemoved("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
Log.OutF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}",
LogF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}",
connection->GetUUID());
web_interface.RemoveConnection(connection);
@@ -472,10 +475,10 @@ int main(int argc, char** argv) {
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
stream_identifier.AddStream(stream);
Log.OutF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
});
while(RunLoops) {
while (RunLoops) {
Timer::SetCurrentTime();
eqs = nullptr;
@@ -483,33 +486,34 @@ int main(int argc, char** argv) {
stream_identifier.Process();
//check the stream identifier for any now-identified streams
while((eqsi = stream_identifier.PopIdentified())) {
while ((eqsi = stream_identifier.PopIdentified())) {
//now that we know what patch they are running, start up their client object
struct in_addr in;
in.s_addr = eqsi->GetRemoteIP();
if (RuleB(World, UseBannedIPsTable)){ //Lieka: Check to see if we have the responsibility for blocking IPs.
Log.Out(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in));
if (!database.CheckBannedIPs(inet_ntoa(in))){ //Lieka: Check inbound IP against banned IP table.
Log.Out(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in));
if (RuleB(World, UseBannedIPsTable)) { //Lieka: Check to see if we have the responsibility for blocking IPs.
Log(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in));
if (!database.CheckBannedIPs(inet_ntoa(in))) { //Lieka: Check inbound IP against banned IP table.
Log(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in));
auto client = new Client(eqsi);
// @merth: client->zoneattempt=0;
client_list.Add(client);
} else {
Log.Out(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in));
}
else {
Log(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in));
eqsi->Close(); //Lieka: If the inbound IP is on the banned table, close the EQStream.
}
}
if (!RuleB(World, UseBannedIPsTable)){
Log.Out(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
auto client = new Client(eqsi);
// @merth: client->zoneattempt=0;
client_list.Add(client);
if (!RuleB(World, UseBannedIPsTable)) {
Log(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
auto client = new Client(eqsi);
// @merth: client->zoneattempt=0;
client_list.Add(client);
}
}
client_list.Process();
if(PurgeInstanceTimer.Check())
if (PurgeInstanceTimer.Check())
{
database.PurgeExpiredInstances();
}
@@ -519,36 +523,36 @@ int main(int argc, char** argv) {
TimeOfDay_Struct tod;
zoneserver_list.worldclock.GetCurrentEQTimeOfDay(time(0), &tod);
if (!database.SaveTime(tod.minute, tod.hour, tod.day, tod.month, tod.year))
Log.Out(Logs::General, Logs::World_Server, "Failed to save eqtime.");
Log(Logs::General, Logs::World_Server, "Failed to save eqtime.");
else
Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
Log(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
}
zoneserver_list.Process();
launcher_list.Process();
LFPGroupList.Process();
LFPGroupList.Process();
adventure_manager.Process();
if (InterserverTimer.Check()) {
InterserverTimer.Start();
database.ping();
database.ping();
}
EQ::EventLoop::Get().Process();
Sleep(5);
}
Log.Out(Logs::General, Logs::World_Server, "World main loop completed.");
Log.Out(Logs::General, Logs::World_Server, "Shutting down zone connections (if any).");
Log(Logs::General, Logs::World_Server, "World main loop completed.");
Log(Logs::General, Logs::World_Server, "Shutting down zone connections (if any).");
zoneserver_list.KillAll();
Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
Log.CloseFileLogs();
Log(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
Log(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
LogSys.CloseFileLogs();
return 0;
}
void CatchSignal(int sig_num) {
Log.Out(Logs::General, Logs::World_Server,"Caught signal %d",sig_num);
Log(Logs::General, Logs::World_Server, "Caught signal %d", sig_num);
RunLoops = false;
}
@@ -564,4 +568,3 @@ void UpdateWindowTitle(char* iNewTitle) {
SetConsoleTitle(tmp);
#endif
}
+1 -1
View File
@@ -51,4 +51,4 @@ bool QueryServConnection::SendPacket(ServerPacket* pack)
}
return true;
}
}
+22 -23
View File
@@ -14,9 +14,9 @@ UCSConnection::UCSConnection()
void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> inStream)
{
if(Stream && Stream->Handle())
if (Stream && Stream->Handle())
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS.");
Log(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS.");
Stream->Handle()->Disconnect();
}
@@ -34,33 +34,33 @@ void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
ServerPacket tpack(opcode, p);
ServerPacket *pack = &tpack;
switch(opcode)
switch (opcode)
{
case 0:
break;
case 0:
break;
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ZAAuth:
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated.");
break;
}
default:
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", opcode, pack->size);
DumpPacket(pack->pBuffer, pack->size);
break;
}
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ZAAuth:
{
Log(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated.");
break;
}
default:
{
Log(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", opcode, pack->size);
DumpPacket(pack->pBuffer, pack->size);
break;
}
}
}
void UCSConnection::SendPacket(ServerPacket* pack)
{
if(!Stream)
if (!Stream)
return;
Stream->SendPacket(pack);
@@ -78,4 +78,3 @@ void UCSConnection::SendMessage(const char *From, const char *Message)
SendPacket(pack);
safe_delete(pack);
}
+13 -13
View File
@@ -34,7 +34,7 @@ WorldGuildManager guild_mgr;
void WorldGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd, bool rank, bool relation) {
Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation);
Log(Logs::Detail, Logs::Guilds, "Broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation);
auto pack = new ServerPacket(ServerOP_RefreshGuild, sizeof(ServerGuildRefresh_Struct));
ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer;
s->guild_id = guild_id;
@@ -47,7 +47,7 @@ void WorldGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd,
}
void WorldGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) {
Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting char refresh for %d from guild %d to world", charid, guild_id);
Log(Logs::Detail, Logs::Guilds, "Broadcasting char refresh for %d from guild %d to world", charid, guild_id);
auto pack = new ServerPacket(ServerOP_GuildCharRefresh, sizeof(ServerGuildCharRefresh_Struct));
ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer;
s->guild_id = guild_id;
@@ -58,7 +58,7 @@ void WorldGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, ui
}
void WorldGuildManager::SendGuildDelete(uint32 guild_id) {
Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting guild delete for guild %d to world", guild_id);
Log(Logs::Detail, Logs::Guilds, "Broadcasting guild delete for guild %d to world", guild_id);
auto pack = new ServerPacket(ServerOP_DeleteGuild, sizeof(ServerGuildID_Struct));
ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer;
s->guild_id = guild_id;
@@ -71,18 +71,18 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) {
case ServerOP_RefreshGuild: {
if(pack->size != sizeof(ServerGuildRefresh_Struct)) {
Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct));
Log(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct));
return;
}
ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer;
Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change);
Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change);
//broadcast this packet to all zones.
zoneserver_list.SendPacket(pack);
//preform a local refresh.
if(!RefreshGuild(s->guild_id)) {
Log.Out(Logs::Detail, Logs::Guilds, "Unable to preform local refresh on guild %d", s->guild_id);
Log(Logs::Detail, Logs::Guilds, "Unable to preform local refresh on guild %d", s->guild_id);
//can we do anything?
}
@@ -91,11 +91,11 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) {
case ServerOP_GuildCharRefresh: {
if(pack->size != sizeof(ServerGuildCharRefresh_Struct)) {
Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct));
Log(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct));
return;
}
ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer;
Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild member refresh for char %d to all zones with members of guild %d", s->char_id, s->guild_id);
Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild member refresh for char %d to all zones with members of guild %d", s->char_id, s->guild_id);
//preform the local update
client_list.UpdateClientGuild(s->char_id, s->guild_id);
@@ -110,18 +110,18 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) {
case ServerOP_DeleteGuild: {
if(pack->size != sizeof(ServerGuildID_Struct)) {
Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct));
Log(Logs::Detail, Logs::Guilds, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct));
return;
}
ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer;
Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild delete for guild %d", s->guild_id);
Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild delete for guild %d", s->guild_id);
//broadcast this packet to all zones.
zoneserver_list.SendPacket(pack);
//preform a local refresh.
if(!LocalDeleteGuild(s->guild_id)) {
Log.Out(Logs::Detail, Logs::Guilds, "Unable to preform local delete on guild %d", s->guild_id);
Log(Logs::Detail, Logs::Guilds, "Unable to preform local delete on guild %d", s->guild_id);
//can we do anything?
}
@@ -131,7 +131,7 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) {
case ServerOP_GuildMemberUpdate: {
if(pack->size != sizeof(ServerGuildMemberUpdate_Struct))
{
Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_GuildMemberUpdate of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildMemberUpdate_Struct));
Log(Logs::Detail, Logs::Guilds, "Received ServerOP_GuildMemberUpdate of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildMemberUpdate_Struct));
return;
}
@@ -141,7 +141,7 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) {
}
default:
Log.Out(Logs::Detail, Logs::Guilds, "Unknown packet 0x%x received from zone??", pack->opcode);
Log(Logs::Detail, Logs::Guilds, "Unknown packet 0x%x received from zone??", pack->opcode);
break;
}
}
+5 -5
View File
@@ -361,14 +361,14 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct*
return false;
}
Log.Out(Logs::General, Logs::Status, "SoF Start zone query: %s\n", query.c_str());
Log(Logs::General, Logs::Status, "SoF Start zone query: %s\n", query.c_str());
if (results.RowCount() == 0) {
printf("No start_zones entry in database, using defaults\n");
isTitanium ? SetTitaniumDefaultStartZone(in_pp, in_cc) : SetSoFDefaultStartZone(in_pp, in_cc);
}
else {
Log.Out(Logs::General, Logs::Status, "Found starting location in start_zones");
Log(Logs::General, Logs::Status, "Found starting location in start_zones");
auto row = results.begin();
in_pp->x = atof(row[0]);
in_pp->y = atof(row[1]);
@@ -507,7 +507,7 @@ void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
const std::string query = "SELECT name FROM launcher";
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::General, Logs::Error, "WorldDatabase::GetLauncherList: %s", results.ErrorMessage().c_str());
Log(Logs::General, Logs::Error, "WorldDatabase::GetLauncherList: %s", results.ErrorMessage().c_str());
return;
}
@@ -529,7 +529,7 @@ void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey)
MailKeyString, CharID);
auto results = QueryDatabase(query);
if (!results.Success())
Log.Out(Logs::General, Logs::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, results.ErrorMessage().c_str());
Log(Logs::General, Logs::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, results.ErrorMessage().c_str());
}
@@ -538,7 +538,7 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
std::string query = StringFormat("SELECT level FROM character_data WHERE name = '%s'", name);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::General, Logs::Error, "WorldDatabase::GetCharacterLevel: %s", results.ErrorMessage().c_str());
Log(Logs::General, Logs::Error, "WorldDatabase::GetCharacterLevel: %s", results.ErrorMessage().c_str());
return false;
}
+93 -93
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
Copyright (C) 2001-2005 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"
#include "zonelist.h"
@@ -38,7 +38,7 @@ ZSList::ZSList()
{
NextID = 1;
CurGroupID = 1;
LastAllocatedPort=0;
LastAllocatedPort = 0;
memset(pLockedZones, 0, sizeof(pLockedZones));
m_tick.reset(new EQ::Timer(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1)));
@@ -83,7 +83,7 @@ void ZSList::Remove(const std::string &uuid)
void ZSList::KillAll() {
auto iterator = list.begin();
while(iterator != list.end()) {
while (iterator != list.end()) {
(*iterator)->Disconnect();
iterator = list.erase(iterator);
}
@@ -91,19 +91,19 @@ void ZSList::KillAll() {
void ZSList::Process() {
if(shutdowntimer && shutdowntimer->Check()){
Log.Out(Logs::Detail, Logs::World_Server, "Shutdown timer has expired. Telling all zones to shut down and exiting. (fake sigint)");
if (shutdowntimer && shutdowntimer->Check()) {
Log(Logs::Detail, Logs::World_Server, "Shutdown timer has expired. Telling all zones to shut down and exiting. (fake sigint)");
auto pack2 = new ServerPacket;
pack2->opcode = ServerOP_ShutdownAll;
pack2->size=0;
pack2->size = 0;
SendPacket(pack2);
safe_delete(pack2);
Process();
CatchSignal(2);
}
if(reminder && reminder->Check() && shutdowntimer){
SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now. World will shut down in %i minutes...", ((shutdowntimer->GetRemainingTime()/1000) / 60));
if (reminder && reminder->Check() && shutdowntimer) {
SendEmoteMessage(0, 0, 0, 15, "<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now. World will shut down in %i minutes...", ((shutdowntimer->GetRemainingTime() / 1000) / 60));
}
}
@@ -130,11 +130,11 @@ bool ZSList::SendPacket(uint32 ZoneID, ServerPacket* pack) {
}
bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
if(instanceID != 0)
if (instanceID != 0)
{
auto iterator = list.begin();
while (iterator != list.end()) {
if((*iterator)->GetInstanceID() == instanceID) {
if ((*iterator)->GetInstanceID() == instanceID) {
ZoneServer* tmp = (*iterator).get();
tmp->SendPacket(pack);
return true;
@@ -258,7 +258,7 @@ void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) {
char locked[4];
if (WorldConfig::get()->Locked == true){
if (WorldConfig::get()->Locked == true) {
strcpy(locked, "Yes");
}
else {
@@ -268,16 +268,16 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
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:^");
}
@@ -292,13 +292,13 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
zone_server_data = (*iterator).get();
auto addr = zone_server_data->GetIP();
if (zone_server_data->IsStaticZone()){
if (zone_server_data->IsStaticZone()) {
z++;
}
else if (zone_server_data->GetZoneID() != 0){
else if (zone_server_data->GetZoneID() != 0) {
w++;
}
else if (zone_server_data->GetZoneID() == 0 && !zone_server_data->IsBootingUp()){
else if (zone_server_data->GetZoneID() == 0 && !zone_server_data->IsBootingUp()) {
v++;
}
@@ -308,29 +308,29 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
is_static_string[0] = 'D';
if (admin >= 150) {
if (zone_server_data->GetZoneID()){
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()){
else if (zone_server_data->IsBootingUp()) {
strcpy(zone_data_string, "...");
}
else{
else {
zone_data_string[0] = 0;
}
AppendAnyLenString(&output, &outsize, &outlen,
"#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)",
zone_server_data->GetID(),
is_static_string,
AppendAnyLenString(&output, &outsize, &outlen,
"#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)",
zone_server_data->GetID(),
is_static_string,
addr.c_str(),
zone_server_data->GetPort(),
zone_server_data->NumPlayers(),
zone_server_data->GetCAddress(),
zone_server_data->GetCPort(),
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);
@@ -358,10 +358,10 @@ 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, "^");
}
}
@@ -371,7 +371,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
iterator++;
}
if (connection->IsConsole()){
if (connection->IsConsole()) {
AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.\r\n", x, y);
}
else {
@@ -380,7 +380,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.", z, w, v);
if (output){
if (output) {
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
}
@@ -406,10 +406,10 @@ void ZSList::SendChannelMessageRaw(const char* from, const char* to, uint8 chan_
auto pack = new ServerPacket;
pack->opcode = ServerOP_ChannelMessage;
pack->size = sizeof(ServerChannelMessage_Struct)+strlen(message)+1;
pack->size = sizeof(ServerChannelMessage_Struct) + strlen(message) + 1;
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer;
if (from == 0) {
strcpy(scm->from, "WServer");
scm->noreply = true;
@@ -421,8 +421,8 @@ void ZSList::SendChannelMessageRaw(const char* from, const char* to, uint8 chan_
else
strcpy(scm->from, from);
if (to != 0) {
strcpy((char *) scm->to, to);
strcpy((char *) scm->deliverto, to);
strcpy((char *)scm->to, to);
strcpy((char *)scm->deliverto, to);
}
else {
scm->to[0] = 0;
@@ -457,13 +457,13 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
auto pack = new ServerPacket;
pack->opcode = ServerOP_EmoteMessage;
pack->size = sizeof(ServerEmoteMessage_Struct)+strlen(message)+1;
pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1;
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
if (to) {
strcpy((char *) sem->to, to);
strcpy((char *)sem->to, to);
}
else {
sem->to[0] = 0;
@@ -473,9 +473,9 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
sem->minstatus = to_minstatus;
sem->type = type;
strcpy(&sem->message[0], message);
char tempto[64]={0};
if(to)
strn0cpy(tempto,to,64);
char tempto[64] = { 0 };
if (to)
strn0cpy(tempto, to, 64);
if (tempto[0] == 0) {
SendPacket(pack);
@@ -493,9 +493,9 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
void ZSList::SendTimeSync() {
auto pack = new ServerPacket(ServerOP_SyncWorldTime, sizeof(eqTimeOfDay));
eqTimeOfDay* tod = (eqTimeOfDay*) pack->pBuffer;
tod->start_eqtime=worldclock.getStartEQTime();
tod->start_realtime=worldclock.getStartRealTime();
eqTimeOfDay* tod = (eqTimeOfDay*)pack->pBuffer;
tod->start_eqtime = worldclock.getStartEQTime();
tod->start_realtime = worldclock.getStartRealTime();
SendPacket(pack);
delete pack;
}
@@ -503,7 +503,7 @@ void ZSList::SendTimeSync() {
void ZSList::NextGroupIDs(uint32 &start, uint32 &end) {
start = CurGroupID;
CurGroupID += 1000; //hand them out 1000 at a time...
if(CurGroupID < start) { //handle overflow
if (CurGroupID < start) { //handle overflow
start = 1;
CurGroupID = 1001;
}
@@ -535,7 +535,7 @@ void ZSList::SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const cha
}
}
void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skipid, uint32 zoneid){
void ZSList::RebootZone(const char* ip1, uint16 port, const char* ip2, uint32 skipid, uint32 zoneid) {
// get random zone
uint32 x = 0;
auto iterator = list.begin();
@@ -547,10 +547,10 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip
return;
auto tmp = new ZoneServer *[x];
uint32 y = 0;
iterator = list.begin();
while (iterator != list.end()) {
if (!strcmp((*iterator)->GetCAddress(),ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) {
if (!strcmp((*iterator)->GetCAddress(), ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) {
tmp[y++] = (*iterator).get();
}
iterator++;
@@ -559,16 +559,16 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip
safe_delete_array(tmp);
return;
}
uint32 z = emu_random.Int(0, y-1);
uint32 z = emu_random.Int(0, y - 1);
auto pack = new ServerPacket(ServerOP_ZoneReboot, sizeof(ServerZoneReboot_Struct));
ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*) pack->pBuffer;
// strcpy(s->ip1,ip1);
strcpy(s->ip2,ip2);
ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*)pack->pBuffer;
// strcpy(s->ip1,ip1);
strcpy(s->ip2, ip2);
s->port = port;
s->zoneid = zoneid;
if(zoneid != 0)
Log.Out(Logs::Detail, Logs::World_Server,"Rebooting static zone with the ID of: %i",zoneid);
if (zoneid != 0)
Log(Logs::Detail, Logs::World_Server, "Rebooting static zone with the ID of: %i", zoneid);
tmp[z]->SendPacket(pack);
delete pack;
safe_delete_array(tmp);
@@ -576,36 +576,36 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip
uint16 ZSList::GetAvailableZonePort()
{
const WorldConfig *Config=WorldConfig::get();
const WorldConfig *Config = WorldConfig::get();
int i;
uint16 port=0;
uint16 port = 0;
if (LastAllocatedPort==0)
i=Config->ZonePortLow;
if (LastAllocatedPort == 0)
i = Config->ZonePortLow;
else
i=LastAllocatedPort+1;
i = LastAllocatedPort + 1;
while(i!=LastAllocatedPort && port==0) {
while (i != LastAllocatedPort && port == 0) {
if (i>Config->ZonePortHigh)
i=Config->ZonePortLow;
i = Config->ZonePortLow;
if (!FindByPort(i)) {
port=i;
port = i;
break;
}
i++;
}
LastAllocatedPort=port;
LastAllocatedPort = port;
return port;
}
uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
if(iInstanceID > 0)
if (iInstanceID > 0)
{
auto iterator = list.begin();
while (iterator != list.end()) {
if((*iterator)->GetInstanceID() == iInstanceID)
if ((*iterator)->GetInstanceID() == iInstanceID)
{
return (*iterator)->GetID();
}
@@ -615,7 +615,7 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
iterator = list.begin();
while (iterator != list.end()) {
if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) {
ZoneServer* zone=(*iterator).get();
ZoneServer* zone = (*iterator).get();
zone->TriggerBootup(iZoneID, iInstanceID);
return zone->GetID();
}
@@ -627,7 +627,7 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
{
auto iterator = list.begin();
while (iterator != list.end()) {
if((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0)
if ((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0)
{
return (*iterator)->GetID();
}
@@ -647,11 +647,11 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
}
}
void ZSList::SendLSZones(){
void ZSList::SendLSZones() {
auto iterator = list.begin();
while(iterator != list.end()) {
while (iterator != list.end()) {
ZoneServer* zs = (*iterator).get();
zs->LSBootUpdate(zs->GetZoneID(),true);
zs->LSBootUpdate(zs->GetZoneID(), true);
iterator++;
}
}
@@ -671,24 +671,24 @@ void ZSList::GetZoneIDList(std::vector<uint32> &zones) {
void ZSList::WorldShutDown(uint32 time, uint32 interval)
{
if( time > 0 ) {
SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down in %i minutes, everyone log out before this time.", (time / 60));
if (time > 0) {
SendEmoteMessage(0, 0, 0, 15, "<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down in %i minutes, everyone log out before this time.", (time / 60));
time *= 1000;
interval *= 1000;
if(interval < 5000) { interval = 5000; }
if (interval < 5000) { interval = 5000; }
shutdowntimer->SetTimer(time);
reminder->SetTimer(interval-1000);
reminder->SetTimer(interval - 1000);
reminder->SetAtTrigger(interval);
shutdowntimer->Start();
reminder->Start();
}
else {
SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now.");
SendEmoteMessage(0, 0, 0, 15, "<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now.");
auto pack = new ServerPacket;
pack->opcode = ServerOP_ShutdownAll;
pack->size=0;
pack->size = 0;
SendPacket(pack);
safe_delete(pack);
Process();
@@ -709,7 +709,7 @@ void ZSList::OnTick(EQ::Timer *t)
for (auto &zone : list)
{
Json::Value outzone;
outzone["CAddress"] = zone->GetCAddress();
outzone["CLocalAddress"] = zone->GetCLocalAddress();
outzone["CompileTime"] = zone->GetCompileTime();
@@ -734,4 +734,4 @@ void ZSList::OnTick(EQ::Timer *t)
}
web_interface.SendEvent(out);
}
}
+1075 -1073
View File
File diff suppressed because it is too large Load Diff