HandleEnterWorldPacket refactor

This commit is contained in:
Arthur Ice
2013-03-10 16:15:23 -07:00
parent 29262d966e
commit d5da4aa90b
2 changed files with 231 additions and 223 deletions
+91 -84
View File
@@ -687,78 +687,25 @@ bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app)
return true;
}
bool Client::HandlePacket(const EQApplicationPacket *app) {
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app)
{
const WorldConfig *Config=WorldConfig::get();
EmuOpcode opcode = app->GetOpcode();
clog(WORLD__CLIENT_TRACE,"Recevied EQApplicationPacket");
_pkt(WORLD__CLIENT_TRACE,app);
bool ret = true;
if (!eqs->CheckState(ESTABLISHED)) {
clog(WORLD__CLIENT,"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())) {
clog(WORLD__CLIENT,"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
clog(WORLD__CLIENT_ERR,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
return false;
}
else if (opcode == OP_AckPacket) {
return true;
}
switch(opcode)
{
case OP_CrashDump:
break;
case OP_SendLoginInfo:
{
return HandleLoginInfoPacket(app);
}
case OP_ApproveName: //Name approval
{
return HandleApproveNamePacket(app);
}
case OP_RandomNameGenerator:
{
return HandleRandomNameGeneratorPacket(app);
}
case OP_CharacterCreateRequest:
{
return HandleCharacterCreateRequestPacket(app);
}
case OP_CharacterCreate: //Char create
{
return HandleCharacterCreatePacket(app);
}
case OP_EnterWorld: // Enter world
{
if (GetAccountID() == 0) {
clog(WORLD__CLIENT_ERR,"Enter world with no logged in account");
eqs->Close();
break;
return false;
}
if(GetAdmin() < 0)
{
clog(WORLD__CLIENT,"Account banned or suspended.");
eqs->Close();
break;
return false;
}
if (RuleI(World, MaxClientsPerIP) >= 0) {
client_list.GetCLEIP(this->GetIP()); //Check current CLE Entry IPs against incoming connection
//Check current CLE Entry IPs against incoming connection
client_list.GetCLEIP(this->GetIP());
}
EnterWorld_Struct *ew=(EnterWorld_Struct *)app->pBuffer;
@@ -767,17 +714,18 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
EQApplicationPacket *outapp;
uint32 tmpaccid = 0;
charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID, &instanceID);
if (charid == 0 || tmpaccid != GetAccountID()) {
clog(WORLD__CLIENT_ERR,"Could not get CharInfo for '%s'",char_name);
eqs->Close();
break;
return false;
}
// Make sure this account owns this character
if (tmpaccid != GetAccountID()) {
clog(WORLD__CLIENT_ERR,"This account does not own the character named '%s'",char_name);
eqs->Close();
break;
return false;
}
if(!pZoning && ew->return_home)
@@ -809,7 +757,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
clog(WORLD__CLIENT_ERR,"'%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();
break;
return false;
}
}
@@ -842,7 +790,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
clog(WORLD__CLIENT_ERR,"'%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();
break;
return false;
}
}
@@ -897,8 +845,8 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
outapp->pBuffer = new uchar[outapp->size];
memset(outapp->pBuffer,0,outapp->size);
strcpy((char*)outapp->pBuffer, tmp);
} else {
}
else {
// Null Message of the Day. :)
outapp->size = 1;
outapp->pBuffer = new uchar[outapp->size];
@@ -922,12 +870,14 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
EQApplicationPacket *outapp2 = new EQApplicationPacket(OP_SetChatServer);
char buffer[112];
sprintf(buffer,"%s,%i,%s.%s,%c%08X",
sprintf(buffer,
"%s,%i,%s.%s,%c%08X",
Config->ChatHost.c_str(),
Config->ChatPort,
Config->ShortName.c_str(),
this->GetCharName(), ConnectionType, MailKey
);
this->GetCharName(),
ConnectionType,
MailKey);
outapp2->size=strlen(buffer)+1;
outapp2->pBuffer = new uchar[outapp2->size];
memcpy(outapp2->pBuffer,buffer,outapp2->size);
@@ -943,8 +893,10 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
Config->MailHost.c_str(),
Config->MailPort,
Config->ShortName.c_str(),
this->GetCharName(), ConnectionType, MailKey
);
this->GetCharName(),
ConnectionType,
MailKey);
outapp2->size=strlen(buffer)+1;
outapp2->pBuffer = new uchar[outapp2->size];
memcpy(outapp2->pBuffer,buffer,outapp2->size);
@@ -952,10 +904,68 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
safe_delete(outapp2);
EnterWorld();
return true;
}
bool Client::HandlePacket(const EQApplicationPacket *app) {
const WorldConfig *Config=WorldConfig::get();
EmuOpcode opcode = app->GetOpcode();
clog(WORLD__CLIENT_TRACE,"Recevied EQApplicationPacket");
_pkt(WORLD__CLIENT_TRACE,app);
if (!eqs->CheckState(ESTABLISHED)) {
clog(WORLD__CLIENT,"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())) {
clog(WORLD__CLIENT,"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
clog(WORLD__CLIENT_ERR,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]);
return false;
}
else if (opcode == OP_AckPacket) {
return true;
}
switch(opcode)
{
case OP_CrashDump:
break;
case OP_SendLoginInfo:
{
return HandleLoginInfoPacket(app);
}
case OP_ApproveName: //Name approval
{
return HandleApproveNamePacket(app);
}
case OP_RandomNameGenerator:
{
return HandleRandomNameGeneratorPacket(app);
}
case OP_CharacterCreateRequest:
{
return HandleCharacterCreateRequestPacket(app);
}
case OP_CharacterCreate: //Char create
{
return HandleCharacterCreatePacket(app);
}
case OP_EnterWorld: // Enter world
{
return HandleEnterWorldPacket(app);
}
case OP_LoginComplete:{
break;
return true;
}
case OP_DeleteCharacter: {
uint32 char_acct_id = database.GetAccountIDByChar((char*)app->pBuffer);
@@ -965,14 +975,14 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
database.DeleteCharacter((char *)app->pBuffer);
SendCharInfo();
}
break;
return true;
}
case OP_ApproveWorld:
{
break;
return true;
}
case OP_WorldClientReady:{
break;
return true;
}
case OP_World_Client_CRC1:
case OP_World_Client_CRC2: {
@@ -981,18 +991,18 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
// before OP_World_Client_CRC1. Therefore, if we receive OP_World_Client_CRC1 before OP_EnterWorld,
// then 'Start Tutorial' was not chosen.
StartInTutorial = false;
break;
return true;
}
case OP_WearChange: { // User has selected a different character
break;
return true;
}
case OP_WorldComplete: {
eqs->Close();
break;
return true;
}
case OP_LoginUnknown1:
case OP_LoginUnknown2:
break;
return true;
case OP_ZoneChange:
// HoT sends this to world while zoning and wants it echoed back.
@@ -1000,16 +1010,13 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
{
QueuePacket(app);
}
break;
return true;
default: {
clog(WORLD__CLIENT_ERR,"Received unknown EQApplicationPacket");
_pkt(WORLD__CLIENT_ERR,app);
break;
return true;
}
}
return ret;
}
bool Client::Process() {
+1
View File
@@ -96,6 +96,7 @@ private:
bool HandleRandomNameGeneratorPacket(const EQApplicationPacket *app);
bool HandleCharacterCreateRequestPacket(const EQApplicationPacket *app);
bool HandleCharacterCreatePacket(const EQApplicationPacket *app);
bool HandleEnterWorldPacket(const EQApplicationPacket *app);
ClientListEntry* cle;
Timer CLE_keepalive_timer;