void Character::Logout()
{
if (!this->online)
{
if (this->guild)
{
this->guild->Release();
this->guild = 0;
}
return;
}
if (this->trading)
{
PacketBuilder builder(PACKET_TRADE, PACKET_CLOSE);
builder.AddShort(this->id);
this->trade_partner->player->client->SendBuilder(builder);
this->player->client->state = EOClient::Playing;
this->trading = false;
this->trade_inventory.clear();
this->trade_agree = false;
this->trade_partner->player->client->state = EOClient::Playing;
this->trade_partner->trading = false;
this->trade_partner->trade_inventory.clear();
this->trade_agree = false;
this->trade_partner->trade_partner = 0;
this->trade_partner = 0;
}
if (this->party)
{
this->party->Leave(this);
}
if (this->arena)
{
--this->arena->occupants;
}
UTIL_PTR_LIST_FOREACH(this->unregister_npc, NPC, npc)
{
UTIL_PTR_LIST_FOREACH(npc->damagelist, NPC_Opponent, checkopp)
{
if (checkopp->attacker == this)
{
npc->totaldamage -= checkopp->damage;
npc->damagelist.erase(checkopp);
break;
}
}
}
if(this->has_pet)
{
erase_first(this->map->npcs, this->pet);
this->pet->Release();
this->has_pet = false;
}
this->online = false;
this->Save();
this->world->Logout(this);
}