Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Galera preciso de ajuda de um programer c++ Urgente PF alguem me ajuda?me ot ta dando um bug os cara pega ml 1000++++++ eu ja fiz de tudo e nao da nada pf alguem me ajuda?

O mattziin Falou que o erro e na sources do sv alguem poderia me ajuda PF PF GALERA.

Link para o post
Compartilhar em outros sites

Como assim poste aqui entre [spoilers]

"Arquivo"

[ /spoiler]

(sem o espaço)

Editado por sear10 (veja o histórico de edições)

 

6cb96129-c6fb-49ca-8267-4cbf4f41578c.gif

Link para o post
Compartilhar em outros sites

Toma uma parte do player.cpp

////////////////////////////////////////////////////////////////////////

// OpenTibia - an opensource roleplaying game

////////////////////////////////////////////////////////////////////////

// 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, either version 3 of the License, or

// (at your option) any later version.

//

// This program is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; 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, see <http://www.gnu.org/licenses/>.

////////////////////////////////////////////////////////////////////////

#include "otpch.h"

#include <iostream>

#include "player.h"

#include "iologindata.h"

#include "ioban.h"

#include "town.h"

#include "house.h"

#include "beds.h"

#include "combat.h"

#if defined(WINDOWS) && !defined(__CONSOLE__)

#include "gui.h"

#endif

#include "movement.h"

#include "weapons.h"

#include "creatureevent.h"

#include "configmanager.h"

#include "game.h"

#include "chat.h"

extern ConfigManager g_config;

extern Game g_game;

extern Chat g_chat;

extern MoveEvents* g_moveEvents;

extern Weapons* g_weapons;

extern CreatureEvents* g_creatureEvents;

AutoList<Player> Player::autoList;

#ifdef __ENABLE_SERVER_DIAGNOSTIC__

uint32_t Player::playerCount = 0;

#endif

MuteCountMap Player::muteCountMap;

Player::Player(const std::string& _name, ProtocolGame* p):

Creature(), transferContainer(ITEM_LOCKER), name(_name), nameDescription(_name), client(p)

{

if(client)

client->setPlayer(this);

pzLocked = isConnecting = addAttackSkillPoint = requestedOutfit = false;

saving = true;

lastAttackBlockType = BLOCK_NONE;

chaseMode = CHASEMODE_STANDSTILL;

fightMode = FIGHTMODE_ATTACK;

tradeState = TRADE_NONE;

accountManager = MANAGER_NONE;

guildLevel = GUILDLEVEL_NONE;

promotionLevel = walkTaskEvent = actionTaskEvent = nextStepEvent = bloodHitCount = shieldBlockCount = 0;

lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = 0;

soul = guildId = levelPercent = magLevelPercent = magLevel = experience = damageImmunities = 0;

conditionImmunities = conditionSuppressions = groupId = vocation_id = managerNumber2 = town = skullEnd = 0;

lastLogin = lastLogout = lastIP = messageTicks = messageBuffer = nextAction = 0;

editListId = maxWriteLen = windowTextId = rankId = 0;

purchaseCallback = saleCallback = -1;

level = shootRange = 1;

rates[sKILL__MAGLEVEL] = rates[sKILL__LEVEL] = 1.0f;

soulMax = 100;

capacity = 400.00;

stamina = STAMINA_MAX;

lastLoad = lastPing = lastPong = OTSYS_TIME();

writeItem = NULL;

group = NULL;

editHouse = NULL;

shopOwner = NULL;

tradeItem = NULL;

tradePartner = NULL;

walkTask = NULL;

setVocation(0);

setParty(NULL);

transferContainer.setParent(NULL);

for(int32_t i = 0; i < 11; i++)

{

inventory = NULL;

inventoryAbilities = false;

}

for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)

{

skills[sKILL_LEVEL] = 10;

skills[sKILL_TRIES] = skills[sKILL_PERCENT] = 0;

rates = 1.0f;

}

for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)

varSkills = 0;

for(int32_t i = STAT_FIRST; i <= STAT_LAST; ++i)

varStats = 0;

for(int32_t i = LOSS_FIRST; i <= LOSS_LAST; ++i)

lossPercent = 100;

for(int8_t i = 0; i <= 13; i++)

talkState = false;

#ifdef __ENABLE_SERVER_DIAGNOSTIC__

playerCount++;

#endif

}

Player::~Player()

{

#ifdef __ENABLE_SERVER_DIAGNOSTIC__

playerCount--;

#endif

setWriteItem(NULL);

for(int32_t i = 0; i < 11; i++)

{

if(inventory)

{

inventory->setParent(NULL);

inventory->unRef();

inventory = NULL;

inventoryAbilities = false;

}

}

setNextWalkActionTask(NULL);

transferContainer.setParent(NULL);

for(DepotMap::iterator it = depots.begin(); it != depots.end(); it++)

it->second.first->unRef();

}

void Player::setVocation(uint32_t vocId)

{

vocation_id = vocId;

vocation = Vocations::getInstance()->getVocation(vocId);

soulMax = vocation->getGain(GAIN_SOUL);

if(Condition* condition = getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT))

{

condition->setParam(CONDITIONPARAM_HEALTHGAIN, vocation->getGainAmount(GAIN_HEALTH));

condition->setParam(CONDITIONPARAM_HEALTHTICKS, (vocation->getGainTicks(GAIN_HEALTH) * 1000));

condition->setParam(CONDITIONPARAM_MANAGAIN, vocation->getGainAmount(GAIN_MANA));

condition->setParam(CONDITIONPARAM_MANATICKS, (vocation->getGainTicks(GAIN_MANA) * 1000));

}

}

bool Player::isPushable() const

{

return accountManager == MANAGER_NONE && !hasFlag(PlayerFlag_CannotBePushed) && Creature::isPushable();

}

std::string Player::getDescription(int32_t lookDistance) const

{

std::stringstream s;

if(lookDistance == -1)

{

s << "yourself.";

if(hasFlag(PlayerFlag_ShowGroupNameInsteadOfVocation))

s << " You are " << group->getName();

else if(vocation_id != 0)

s << " You are " << vocation->getDescription();

else

s << " You have no vocation";

}

else

{

s << nameDescription;

if(!hasCustomFlag(PlayerCustomFlag_HideLevel))

s << " (Level " << level << ")";

s << ". " << (sex % 2 ? "He" : "She");

if(hasFlag(PlayerFlag_ShowGroupNameInsteadOfVocation))

s << " is " << group->getName();

else if(vocation_id != 0)

s << " is " << vocation->getDescription();

else

s << " has no vocation";

s << getSpecialDescription();

}

std::string tmp;

if(marriage && IOLoginData::getInstance()->getNameByGuid(marriage, tmp))

{

s << ", ";

if(vocation_id == 0)

{

if(lookDistance == -1)

s << "and you are";

else

s << "and is";

s << " ";

}

s << (sex % 2 ? "husband" : "wife") << " of " << tmp;

}

s << ".";

if(guildId)

{

if(lookDistance == -1)

s << " You are ";

else

s << " " << (sex % 2 ? "He" : "She") << " is ";

s << (rankName.empty() ? "a member" : rankName)<< " of the " << guildName;

if(!guildNick.empty())

s << " (" << guildNick << ")";

s << ".";

}

return s.str();

}

Item* Player::getInventoryItem(slots_t slot) const

{

if(slot > SLOT_PRE_FIRST && slot < SLOT_LAST)

return inventory[slot];

if(slot == SLOT_HAND)

return inventory[sLOT_LEFT] ? inventory[sLOT_LEFT] : inventory[sLOT_RIGHT];

return NULL;

}

Item* Player::getEquippedItem(slots_t slot) const

{

Item* item = getInventoryItem(slot);

if(!item)

return NULL;

switch(slot)

{

case SLOT_LEFT:

case SLOT_RIGHT:

return item->getWieldPosition() == SLOT_HAND ? item : NULL;

default:

break;

}

return item->getWieldPosition() == slot ? item : NULL;

}

void Player::setConditionSuppressions(uint32_t conditions, bool remove)

{

if(!remove)

conditionSuppressions |= conditions;

else

conditionSuppressions &= ~conditions;

}

Item* Player::getWeapon(bool ignoreAmmo /*= false*/)

{

Item* item;

for(uint32_t slot = SLOT_RIGHT; slot <= SLOT_LEFT; slot++)

{

item = getEquippedItem((slots_t)slot);

if(!item)

continue;

switch(item->getWeaponType())

{

case WEAPON_SWORD:

case WEAPON_AXE:

case WEAPON_CLUB:

case WEAPON_WAND:

case WEAPON_FIST:

{

const Weapon* weapon = g_weapons->getWeapon(item);

if(weapon)

return item;

break;

}

case WEAPON_DIST:

{

if(!ignoreAmmo && item->getAmmoType() != AMMO_NONE)

{

Item* ammoItem = getInventoryItem(SLOT_AMMO);

if(ammoItem && ammoItem->getAmmoType() == item->getAmmoType())

{

const Weapon* weapon = g_weapons->getWeapon(ammoItem);

if(weapon)

{

shootRange = item->getShootRange();

return ammoItem;

}

}

}

else

{

const Weapon* weapon = g_weapons->getWeapon(item);

if(weapon)

{

shootRange = item->getShootRange();

return item;

}

}

break;

}

default:

break;

}

}

return NULL;

}

WeaponType_t Player::getWeaponType()

{

if(Item* item = getWeapon())

return item->getWeaponType();

return WEAPON_NONE;

}

int32_t Player::getWeaponSkill(const Item* item) const

{

if(!item)

return getSkill(SKILL_FIST, SKILL_LEVEL);

switch(item->getWeaponType())

{

case WEAPON_SWORD:

return getSkill(SKILL_SWORD, SKILL_LEVEL);

case WEAPON_CLUB:

return getSkill(SKILL_CLUB, SKILL_LEVEL);

case WEAPON_AXE:

return getSkill(SKILL_AXE, SKILL_LEVEL);

case WEAPON_FIST:

return getSkill(SKILL_FIST, SKILL_LEVEL);

case WEAPON_DIST:

return getSkill(SKILL_DIST, SKILL_LEVEL);

default:

break;

}

return 0;

}

int32_t Player::getArmor() const

{

int32_t armor = 0;

for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)

{

if(Item* item = getInventoryItem((slots_t)i))

armor += item->getArmor();

}

if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0)

return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR));

return armor;

}

void Player::getShieldAndWeapon(const Item* &shield, const Item* &weapon) const

{

shield = weapon = NULL;

Item* item = NULL;

for(uint32_t slot = SLOT_RIGHT; slot <= SLOT_LEFT; slot++)

{

item = getInventoryItem((slots_t)slot);

if(!item)

continue;

switch(item->getWeaponType())

{

case WEAPON_NONE:

break;

case WEAPON_SHIELD:

{

if(!shield || (shield && item->getDefense() > shield->getDefense()))

shield = item;

break;

}

default: //weapons that are not shields

{

weapon = item;

break;

}

}

}

}

int32_t Player::getDefense() const

{

int32_t baseDefense = 5, defenseValue = 0, defenseSkill = 0, extraDefense = 0;

float defenseFactor = getDefenseFactor();

const Item* weapon = NULL;

const Item* shield = NULL;

getShieldAndWeapon(shield, weapon);

if(weapon)

{

extraDefense = weapon->getExtraDefense();

defenseValue = baseDefense + weapon->getDefense();

defenseSkill = getWeaponSkill(weapon);

}

if(shield && shield->getDefense() > defenseValue)

{

if(shield->getExtraDefense() > extraDefense)

extraDefense = shield->getExtraDefense();

defenseValue = baseDefense + shield->getDefense();

defenseSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);

}

if(!defenseSkill)

return 0;

defenseValue += extraDefense;

if(vocation->getMultiplier(MULTIPLIER_DEFENSE) != 1.0)

defenseValue = int32_t(defenseValue * vocation->getMultiplier(MULTIPLIER_DEFENSE));

return ((int32_t)std::ceil(((float)(defenseSkill * (defenseValue * 0.015)) + (defenseValue * 0.1)) * defenseFactor));

}

float Player::getAttackFactor() const

{

switch(fightMode)

{

case FIGHTMODE_BALANCED:

return 1.2f;

case FIGHTMODE_DEFENSE:

return 2.0f;

case FIGHTMODE_ATTACK:

default:

break;

}

return 1.0f;

}

float Player::getDefenseFactor() const

{

switch(fightMode)

{

case FIGHTMODE_BALANCED:

return 1.2f;

case FIGHTMODE_DEFENSE:

{

if((OTSYS_TIME() - lastAttack) < const_cast<Player*>(this)->getAttackSpeed()) //attacking will cause us to get into normal defense

return 1.0f;

return 2.0f;

}

case FIGHTMODE_ATTACK:

default:

break;

}

return 1.0f;

}

void Player::sendIcons() const

{

if(!client)

return;

uint32_t icons = 0;

for(ConditionList::const_iterator it = conditions.begin(); it != conditions.end(); ++it)

{

if(!isSuppress((*it)->getType()))

icons |= (*it)->getIcons();

}

if(getZone() == ZONE_PROTECTION)

icons |= ICON_PROTECTIONZONE;

if(pzLocked)

icons |= ICON_PZ;

client->sendIcons(icons);

}

void Player::updateInventoryWeight()

{

inventoryWeight = 0.00;

if(hasFlag(PlayerFlag_HasInfiniteCapacity))

return;

for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)

{

if(Item* item = getInventoryItem((slots_t)i))

inventoryWeight += item->getWeight();

}

}

void Player::updateInventoryGoods(uint32_t itemId)

{

if(Item::items[itemId].worth)

{

sendGoods();

return;

}

for(ShopInfoList::iterator it = shopOffer.begin(); it != shopOffer.end(); ++it)

{

if(it->itemId != itemId)

continue;

sendGoods();

break;

}

}

int32_t Player::getPlayerInfo(playerinfo_t playerinfo) const

{

switch(playerinfo)

{

case PLAYERINFO_LEVEL:

return level;

case PLAYERINFO_LEVELPERCENT:

return levelPercent;

case PLAYERINFO_MAGICLEVEL:

return std::max((int32_t)0, ((int32_t)magLevel + varStats[sTAT_MAGICLEVEL]));

case PLAYERINFO_MAGICLEVELPERCENT:

return magLevelPercent;

case PLAYERINFO_HEALTH:

return health;

case PLAYERINFO_MAXHEALTH:

return std::max((int32_t)1, ((int32_t)healthMax + varStats[sTAT_MAXHEALTH]));

case PLAYERINFO_MANA:

return mana;

case PLAYERINFO_MAXMANA:

return std::max((int32_t)0, ((int32_t)manaMax + varStats[sTAT_MAXMANA]));

case PLAYERINFO_SOUL:

return std::max((int32_t)0, ((int32_t)soul + varStats[sTAT_SOUL]));

default:

break;

}

return 0;

}

int32_t Player::getSkill(skills_t skilltype, skillsid_t skillinfo) const

{

int32_t ret = skills[skilltype][skillinfo];

if(skillinfo == SKILL_LEVEL)

ret += varSkills[skilltype];

return std::max((int32_t)0, ret);

}

void Player::addSkillAdvance(skills_t skill, uint32_t count, bool useMultiplier/* = true*/)

{

if(!count)

return;

//player has reached max skill

uint32_t currReqTries = vocation->getReqSkillTries(skill, skills[skill][sKILL_LEVEL]),

nextReqTries = vocation->getReqSkillTries(skill, skills[skill][sKILL_LEVEL] + 1);

if(currReqTries > nextReqTries)

return;

if(useMultiplier)

count = uint32_t((double)count * rates[skill] * g_config.getDouble(ConfigManager::RATE_SKILL));

std::stringstream s;

while(skills[skill][sKILL_TRIES] + count >= nextReqTries)

{

count -= nextReqTries - skills[skill][sKILL_TRIES];

skills[skill][sKILL_TRIES] = skills[skill][sKILL_PERCENT] = 0;

skills[skill][sKILL_LEVEL]++;

s.str("");

s << "You advanced in " << getSkillName(skill);

if(g_config.getBool(ConfigManager::ADVANCING_SKILL_LEVEL))

s << " [" << skills[skill][sKILL_LEVEL] << "]";

s << ".";

sendTextMessage(MSG_EVENT_ADVANCE, s.str().c_str());

CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE);

for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it)

(*it)->executeAdvance(this, skill, (skills[skill][sKILL_LEVEL] - 1), skills[skill][sKILL_LEVEL]);

currReqTries = nextReqTries;

nextReqTries = vocation->getReqSkillTries(skill, skills[skill][sKILL_LEVEL] + 1);

if(currReqTries > nextReqTries)

{

count = 0;

break;

}

}

if(count)

skills[skill][sKILL_TRIES] += count;

//update percent

uint32_t newPercent = Player::getPercentLevel(skills[skill][sKILL_TRIES], nextReqTries);

if(skills[skill][sKILL_PERCENT] != newPercent)

{

skills[skill][sKILL_PERCENT] = newPercent;

sendSkills();

}

else if(!s.str().empty())

sendSkills();

}

void Player::setVarStats(stats_t stat, int32_t modifier)

{

varStats[stat] += modifier;

switch(stat)

{

case STAT_MAXHEALTH:

{

if(getHealth() > getMaxHealth())

Creature::changeHealth(getMaxHealth() - getHealth());

else

g_game.addCreatureHealth(this);

break;

}

case STAT_MAXMANA:

{

if(getMana() > getMaxMana())

Creature::changeMana(getMaxMana() - getMana());

break;

}

default:

break;

}

}

int32_t Player::getDefaultStats(stats_t stat)

{

switch(stat)

{

case STAT_MAGICLEVEL:

return getMagicLevel() - getVarStats(STAT_MAGICLEVEL);

case STAT_MAXHEALTH:

return getMaxHealth() - getVarStats(STAT_MAXHEALTH);

case STAT_MAXMANA:

return getMaxMana() - getVarStats(STAT_MAXMANA);

case STAT_SOUL:

return getSoul() - getVarStats(STAT_SOUL);

default:

break;

}

return 0;

}

Container* Player::getContainer(uint32_t cid)

{

for(ContainerVector::iterator it = containerVec.begin(); it != containerVec.end(); ++it)

{

if(it->first == cid)

return it->second;

}

return NULL;

}

int32_t Player::getContainerID(const Container* container) const

{

for(ContainerVector::const_iterator cl = containerVec.begin(); cl != containerVec.end(); ++cl)

{

if(cl->second == container)

return cl->first;

}

return -1;

}

void Player::addContainer(uint32_t cid, Container* container)

{

#ifdef __DEBUG__

std::cout << getName() << ", addContainer: " << (int32_t)cid << std::endl;

#endif

if(cid > 0xF)

return;

for(ContainerVector::iterator cl = containerVec.begin(); cl != containerVec.end(); ++cl)

{

if(cl->first == cid)

{

cl->second = container;

return;

}

}

containerVec.push_back(std::make_pair(cid, container));

}

void Player::closeContainer(uint32_t cid)

{

for(ContainerVector::iterator cl = containerVec.begin(); cl != containerVec.end(); ++cl)

{

if(cl->first == cid)

{

containerVec.erase(cl);

break;

}

}

#ifdef __DEBUG__

std::cout << getName() << ", closeContainer: " << (int32_t)cid << std::endl;

#endif

}

bool Player::canOpenCorpse(uint32_t ownerId)

{

return getID() == ownerId || (party && party->canOpenCorpse(ownerId)) || hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges);

}

uint16_t Player::getLookCorpse() const

{

uint16_t naruto, sasuke, lee, sakura, gaara, neji, kiba, shikamaru, hinata, tenten, itachi, bee, kakashi, kankuro, defaultt = 0;

/*Config */

naruto = 2930; // copse for naruto

sasuke = 2806; // copse for sasuke

lee = 2890; // copse for lee

sakura = 2917; // copse for sakura

gaara = 2882; // copse for gaara

neji = 2899; // copse for neji

kiba = 2891; // copse for kiba

shikamaru = 2895; // copse for shikamaru

hinata = 2816; // copse for hinata

tenten = 2925; // copse for tenten

itachi = 2898; // copse for itachi

bee = 2932; // copse for itachi

kakashi = 2852; // copse for kakashi

kankuro = 2815; // copse for kakashi

defaultt = 3354; // copse for vocations not mentioned up, like if he has no vocation

/*End */

if (getVocationId() == 1)

return naruto;

Editado por Dyn (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo