Merge branch 'master' into StringFormatting.

Cleaned up the problems. Tested on Linux. Still need to test on windows.

Conflicts:
	common/CMakeLists.txt
	common/MiscFunctions.cpp
	common/MiscFunctions.h
	common/debug.cpp
	world/Adventure.cpp
This commit is contained in:
Arthur Ice
2013-05-19 18:56:21 -07:00
618 changed files with 38225 additions and 38967 deletions
+90 -90
View File
@@ -1,19 +1,19 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
/* EQEMu: Everquest Server Emulator
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
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.
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/debug.h"
@@ -56,7 +56,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
if(zc->zoneID == 0) {
//client dosent know where they are going...
//try to figure it out for them.
switch(zone_mode) {
case EvacToSafeCoords:
case ZoneToSafeCoords:
@@ -73,10 +73,10 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
case ZoneToBindPoint:
target_zone_id = m_pp.binds[0].zoneId;
break;
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
target_zone_id = zonesummon_id;
break;
case ZoneUnsolicited: //client came up with this on its own.
case ZoneUnsolicited: //client came up with this on its own.
zone_point = zone->GetClosestZonePointWithoutZone(GetX(), GetY(), GetZ(), this, ZONEPOINT_NOZONE_RANGE);
if(zone_point) {
//we found a zone point, which is a reasonable distance away
@@ -86,7 +86,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
} else {
//unable to find a zone point... is there anything else
//that can be a valid un-zolicited zone request?
CheatDetected(MQZone, zc->x, zc->y, zc->z);
Message(13, "Invalid unsolicited zone request.");
LogFile->write(EQEMuLog::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id);
@@ -103,7 +103,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
target_zone_id = zonesummon_id;
else
target_zone_id = zc->zoneID;
//if we are zoning to a specific zone unsolicied,
//then until otherwise determined, they must be zoning
//on a zone line.
@@ -120,7 +120,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
//then we assume this is invalid.
if(!zone_point || zone_point->target_zone_id != target_zone_id) {
LogFile->write(EQEMuLog::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id);
CheatDetected(MQGate, zc->x, zc->y, zc->z);
CheatDetected(MQGate, zc->x, zc->y, zc->z);
SendZoneCancel(zc);
return;
}
@@ -171,7 +171,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
char buf[10];
snprintf(buf, 9, "%d", target_zone_id);
buf[9] = '\0';
parse->EventPlayer(EVENT_ZONE, this, buf, 0);
parse->EventPlayer(EVENT_ZONE, this, buf, 0);
//handle circumvention of zone restrictions
@@ -206,19 +206,19 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
dest_z = m_pp.binds[0].z;
ignorerestrictions = 1; //can always get to our bind point? seems exploitable
break;
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
case ZoneSolicited: //we told the client to zone somewhere, so we know where they are going.
//recycle zonesummon variables
dest_x = zonesummon_x;
dest_y = zonesummon_y;
dest_z = zonesummon_z;
break;
case ZoneUnsolicited: //client came up with this on its own.
case ZoneUnsolicited: //client came up with this on its own.
//client requested a zoning... what are the cases when this could happen?
//Handle zone point case:
if(zone_point != nullptr) {
//they are zoning using a valid zone point, figure out coords
//999999 is a placeholder for 'same as where they were from'
if(zone_point->target_x == 999999)
dest_x = GetX();
@@ -236,12 +236,12 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
dest_h = GetHeading();
else
dest_h = zone_point->target_heading;
break;
}
//for now, there are no other cases...
//could not find a valid reason for them to be zoning, stop it.
CheatDetected(MQZoneUnknownDest, 0.0, 0.0, 0.0);
LogFile->write(EQEMuLog::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%s'. Not near a zone point.", GetName(), target_zone_name);
@@ -257,20 +257,20 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
//not sure when we would use ZONE_ERROR_NOTREADY
//enforce min status and level
if (!ignorerestrictions && (Admin() < minstatus || GetLevel() < minlevel))
if (!ignorerestrictions && (Admin() < minstatus || GetLevel() < minlevel))
{
myerror = ZONE_ERROR_NOEXPERIENCE;
}
if(!ignorerestrictions && flag_needed[0] != '\0') {
//the flag needed string is not empty, meaning a flag is required.
if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(target_zone_id))
if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(target_zone_id))
{
Message(13, "You do not have the flag to enter %s.", target_zone_name);
myerror = ZONE_ERROR_NOEXPERIENCE;
}
}
//TODO: ADVENTURE ENTRANCE CHECK
if(myerror == 1) {
@@ -294,15 +294,15 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) {
zc2->success = 1;
outapp->priority = 6;
FastQueuePacket(&outapp);
//reset to unsolicited.
zone_mode = ZoneUnsolicited;
}
void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
{
LogFile->write(EQEMuLog::Error, "Zone %i is not available because target wasn't found or character insufficent level", zc->zoneID);
SetPortExemption(true);
EQApplicationPacket *outapp;
@@ -313,7 +313,7 @@ void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
zc2->success = err;
outapp->priority = 6;
FastQueuePacket(&outapp);
//reset to unsolicited.
zone_mode = ZoneUnsolicited;
}
@@ -321,15 +321,15 @@ void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instance_id, float dest_x, float dest_y, float dest_z, float dest_h, int8 ignore_r) {
//this is called once the client is fully allowed to zone here
//it takes care of all the activities which occur when a client zones out
SendLogoutPackets();
//dont clear aggro until the zone is successful
entity_list.RemoveFromHateLists(this);
if(this->GetPet())
entity_list.RemoveFromHateLists(this->GetPet());
LogFile->write(EQEMuLog::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f",
m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id,
dest_x, dest_y, dest_z);
@@ -343,10 +343,10 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
m_pp.heading = dest_h;
m_pp.zone_id = zone_id;
m_pp.zoneInstance = instance_id;
//Force a save so its waiting for them when they zone
Save(2);
if (zone_id == zone->GetZoneID() && instance_id == zone->GetInstanceID()) {
// No need to ask worldserver if we're zoning to ourselves (most
// likely to a bind point), also fixes a bug since the default response was failure
@@ -358,7 +358,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
zc2->success = 1;
outapp->priority = 6;
FastQueuePacket(&outapp);
zone->StartShutdownTimer(AUTHENTICATION_TIMEOUT * 1000);
} else {
// vesuvias - zoneing to another zone so we need to the let the world server
@@ -377,7 +377,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
worldserver.SendPacket(pack);
safe_delete(pack);
}
//reset to unsolicited.
zone_mode = ZoneUnsolicited;
zonesummon_x = 0;
@@ -479,7 +479,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
return;
}
iZoneNameLength = strlen(pZoneName);
switch(zm) {
case EvacToSafeCoords:
case ZoneToSafeCoords:
@@ -493,7 +493,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
zonesummon_y = y_pos = y;
zonesummon_z = z_pos = z;
SetHeading(heading);
zonesummon_id = zoneID;
zonesummon_ignorerestrictions = 1;
break;
@@ -502,7 +502,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
zonesummon_y = y;
zonesummon_z = z;
SetHeading(heading);
zonesummon_id = zoneID;
zonesummon_ignorerestrictions = ignorerestrictions;
break;
@@ -517,7 +517,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
y = y_pos = m_pp.binds[0].y;
z = z_pos = m_pp.binds[0].z;
heading = m_pp.binds[0].heading;
zonesummon_ignorerestrictions = 1;
LogFile->write(EQEMuLog::Debug, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading);
break;
@@ -604,7 +604,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
gmg->heading = heading;
gmg->instance_id = instance_id;
gmg->type = 0x01; // '0x01' was an observed value for the type field, not sure of meaning
// we hide the real zoneid we want to evac/succor to here
zonesummon_id = zoneID;
@@ -619,19 +619,19 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
proximity_x = x_pos;
proximity_y = y_pos;
proximity_z = z_pos;
//send out updates to people in zone.
SendPosition();
#ifdef PACKET_UPDATE_MANAGER
#ifdef PACKET_UPDATE_MANAGER
//flush our position queues because we dont know where we will end up
update_manager.FlushQueues();
#endif
}
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RequestClientZoneChange, sizeof(RequestClientZoneChange_Struct));
RequestClientZoneChange_Struct* gmg = (RequestClientZoneChange_Struct*) outapp->pBuffer;
gmg->zone_id = zoneID;
gmg->x = x;
gmg->y = y;
@@ -704,9 +704,9 @@ void Client::SetBindPoint(int to_zone, float new_x, float new_y, float new_z) {
void Client::GoToBind(uint8 bindnum) {
// if the bind number is invalid, use the primary bind
if(bindnum > 4)
if(bindnum > 4)
bindnum = 0;
// move the client, which will zone them if needed.
// ignore restrictions on the zone request..?
if(bindnum == 0)
@@ -722,17 +722,17 @@ void Client::GoToDeath() {
void Client::SetZoneFlag(uint32 zone_id) {
if(HasZoneFlag(zone_id))
return;
zone_flags.insert(zone_id);
//update the DB
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
// Retrieve all waypoints for this grid
if(!database.RunQuery(query,MakeAnyLenString(&query,
"INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)",
CharacterID(),zone_id),errbuf)) {
// Retrieve all waypoints for this grid
if(!database.RunQuery(query,MakeAnyLenString(&query,
"INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)",
CharacterID(),zone_id),errbuf)) {
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), errbuf);
}
}
@@ -740,17 +740,17 @@ void Client::SetZoneFlag(uint32 zone_id) {
void Client::ClearZoneFlag(uint32 zone_id) {
if(!HasZoneFlag(zone_id))
return;
zone_flags.erase(zone_id);
//update the DB
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
// Retrieve all waypoints for this grid
if(!database.RunQuery(query,MakeAnyLenString(&query,
"DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d",
CharacterID(),zone_id),errbuf)) {
// Retrieve all waypoints for this grid
if(!database.RunQuery(query,MakeAnyLenString(&query,
"DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d",
CharacterID(),zone_id),errbuf)) {
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), errbuf);
}
}
@@ -760,22 +760,22 @@ void Client::LoadZoneFlags() {
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
// Retrieve all waypoints for this grid
if(database.RunQuery(query,MakeAnyLenString(&query,
"SELECT zoneID from zone_flags WHERE charID=%d",
CharacterID()),errbuf,&result))
{
// Retrieve all waypoints for this grid
if(database.RunQuery(query,MakeAnyLenString(&query,
"SELECT zoneID from zone_flags WHERE charID=%d",
CharacterID()),errbuf,&result))
{
while((row = mysql_fetch_row(result))) {
zone_flags.insert(atoi(row[0]));
}
mysql_free_result(result);
}
else // DB query error!
{
}
else // DB query error!
{
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), errbuf);
}
safe_delete_array(query);
}
safe_delete_array(query);
}
bool Client::HasZoneFlag(uint32 zone_id) const {
@@ -787,24 +787,24 @@ void Client::SendZoneFlagInfo(Client *to) const {
to->Message(0, "%s has no zone flags.", GetName());
return;
}
set<uint32>::const_iterator cur, end;
cur = zone_flags.begin();
end = zone_flags.end();
char empty[1] = { '\0' };
to->Message(0, "Flags for %s:", GetName());
for(; cur != end; cur++) {
uint32 zoneid = *cur;
const char *short_name = database.GetZoneName(zoneid);
char *long_name = nullptr;
database.GetZoneLongName(short_name, &long_name);
if(long_name == nullptr)
long_name = empty;
float safe_x, safe_y, safe_z;
int16 minstatus = 0;
uint8 minlevel = 0;
@@ -812,7 +812,7 @@ void Client::SendZoneFlagInfo(Client *to) const {
if(!database.GetSafePoints(short_name, 0, &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_name)) {
strcpy(flag_name, "(ERROR GETTING NAME)");
}
to->Message(0, "Has Flag %s for zone %s (%d,%s)", flag_name, long_name, zoneid, short_name);
if(long_name != empty)
delete[] long_name;
@@ -821,12 +821,12 @@ void Client::SendZoneFlagInfo(Client *to) const {
bool Client::CanBeInZone() {
//check some critial rules to see if this char needs to be booted from the zone
//only enforce rules here which are serious enough to warrant being kicked from
//the zone
//only enforce rules here which are serious enough to warrant being kicked from
//the zone
if(Admin() >= RuleI(GM, MinStatusToZoneAnywhere))
return(true);
float safe_x, safe_y, safe_z;
int16 minstatus = 0;
uint8 minlevel = 0;
@@ -836,7 +836,7 @@ bool Client::CanBeInZone() {
_log(CLIENT__ERROR, "Unable to query zone info for ourself '%s'", zone->GetShortName());
return(false);
}
if(GetLevel() < minlevel) {
_log(CLIENT__ERROR, "Character does not meet min level requirement (%d < %d)!", GetLevel(), minlevel);
return(false);
@@ -845,7 +845,7 @@ bool Client::CanBeInZone() {
_log(CLIENT__ERROR, "Character does not meet min status requirement (%d < %d)!", Admin(), minstatus);
return(false);
}
if(flag_needed[0] != '\0') {
//the flag needed string is not empty, meaning a flag is required.
if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(zone->GetZoneID())) {