• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Revision 803 error

Clary

New Member
Joined
Mar 7, 2008
Messages
1,007
Reaction score
1
while compiling Revision 803 pvp arena and pvp zones code i get this error
Code:
../player.cpp: In member function `virtual void Player::onKilledCreature(Creature*)':
../player.cpp:3258: error: expected `)' before "addUnjustifiedDead"
../player.cpp:3260: error: expected identifier before '!' token
../player.cpp:3260: error: expected `;' before '!' token

../player.cpp:3276: error: a function-definition is not allowed here before '{' token
../player.cpp:3298: error: a function-definition is not allowed here before '{' token
../player.cpp:3306: error: a function-definition is not allowed here before '{' token
../player.cpp:3314: error: a function-definition is not allowed here before '{' token
../player.cpp:3319: error: a function-definition is not allowed here before '{' token
../player.cpp:3325: error: a function-definition is not allowed here before '{' token
../player.cpp:3333: error: a function-definition is not allowed here before '{' token
../player.cpp:3342: error: a function-definition is not allowed here before '{' token

../player.cpp:3347: error: a function-definition is not allowed here before '{' token

../player.cpp:3352: error: a function-definition is not allowed here before '{' token
../player.cpp:3366: error: a function-definition is not allowed here before '{' token
../player.cpp:3394: error: a function-definition is not allowed here before '{' token
../player.cpp:3402: error: a function-definition is not allowed here before '{' token
../player.cpp:3410: error: a function-definition is not allowed here before '{' token
../player.cpp:3426: error: a function-definition is not allowed here before '{' token
../player.cpp:3434: error: a function-definition is not allowed here before '{' token
../player.cpp:3454: error: a function-definition is not allowed here before '{' token
../player.cpp:3465: error: a function-definition is not allowed here before '{' token
../player.cpp:3477: error: a function-definition is not allowed here before '{' token
../player.cpp:3482: error: a function-definition is not allowed here before '{' token

../player.cpp:3518: error: a function-definition is not allowed here before '{' token

../player.cpp:3530: error: a function-definition is not allowed here before '{' token
../player.cpp:3535: error: a function-definition is not allowed here before '{' token

../player.cpp:3541: error: a function-definition is not allowed here before '{' token

../player.cpp:3557: error: a function-definition is not allowed here before '{' token
../player.cpp:3563: error: a function-definition is not allowed here before '{' token
../player.cpp:3579: error: a function-definition is not allowed here before '{' token
../player.cpp:4066: error: a function-definition is not allowed here before '{' token
../player.cpp:4076: error: a function-definition is not allowed here before '{' token
../player.cpp:4086: error: a function-definition is not allowed here before '{' token
../player.cpp:4093: error: a function-definition is not allowed here before '{' token
../player.cpp:4099: error: a function-definition is not allowed here before '{' token
../player.cpp:4122: error: a function-definition is not allowed here before '{' token
../player.cpp:4130: error: a function-definition is not allowed here before '{' token
../player.cpp:4156: error: expected `}' at end of input[code]

my player.cpp :
[code]
void Player::onCombatRemoveCondition(const Creature* attacker, Condition* condition)
{
	//Creature::onCombatRemoveCondition(attacker, condition);
	bool remove = true;

	if(condition->getId() != 0)
	{
		remove = false;

		//Means the condition is from an item, id == slot
		if(g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		{
			Item* item = getInventoryItem((slots_t)condition->getId());
			if(item)
			{
				//25% chance to destroy the item
				if(25 >= random_range(0, 100))
					g_game.internalRemoveItem(item);
			}
		}
	}

	if(remove)
		removeCondition(condition);
}

void Player::onAttackedCreature(Creature* target)
{
	Creature::onAttackedCreature(target);

	if(!hasFlag(PlayerFlag_NotGainInFight))
	{
		if(target != this)
		{
			if(Player* targetPlayer = target->getPlayer())
			{
				pzLocked = true;
				if(!isPartner(targetPlayer) && !Combat::isInPvpZone(this, targetPlayer) && !targetPlayer->hasAttacked(this))
				{
					addAttacked(targetPlayer);
					if(targetPlayer->getSkull() == SKULL_NONE && getSkull() == SKULL_NONE)
					{
						setSkull(SKULL_WHITE);
						g_game.updateCreatureSkull(this);
					}

					if(getSkull() == SKULL_NONE)
						targetPlayer->sendCreatureSkull(this);
				}
			}
		}
		addInFightTicks();
	}
}

void Player::onAttacked()
{
	Creature::onAttacked();

	if(!hasFlag(PlayerFlag_NotGainInFight))
		addInFightTicks();
}

void Player::onPlacedCreature()
{
	//scripting event - onLogin
	if(!g_creatureEvents->playerLogin(this))
		kickPlayer(true);
}

void Player::onRemovedCreature()
{
	//
}

void Player::onAttackedCreatureDrainHealth(Creature* target, int32_t points)
{
	Creature::onAttackedCreatureDrainHealth(target, points);
}

void Player::onKilledCreature(Creature* target)
{
	if(hasFlag(PlayerFlag_NotGenerateLoot))
		target->setDropLoot(false);

	Creature::onKilledCreature(target);

	if(Player* targetPlayer = target->getPlayer())
	{
		if(targetPlayer && targetPlayer->getZone() == ZONE_PVP)
		{
			targetPlayer->setDropLoot(false);
			targetPlayer->setLossSkill(false);
		}
		else if(!hasFlag(PlayerFlag_NotGainInFight))
		{
			if(!Combat::isInPvpZone(this, targetPlayer) &&
				!targetPlayer->hasAttacked(this) &&
				targetPlayer->getSkull() == SKULL_NONE
				[B]addUnjustifiedDead(targetPlayer);[/B]
				#ifdef __PVP_ARENA__
				&& !getTile()->hasFlag(TILESTATE_NOSKULLS)
				#endif //__PVP_ARENA__
				)
			{

			if(!Combat::isInPvpZone(this, targetPlayer) && hasCondition(CONDITION_INFIGHT))
			{
				pzLocked = true;
				Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, g_config.getNumber(ConfigManager::WHITE_SKULL_TIME), 0);
				addCondition(condition);
			}
		}
	}
}

void Player::onGainExperience(uint64_t gainExperience)
{
	if(hasFlag(PlayerFlag_NotGainExperience)){
		gainExperience = 0;
	}

	Creature::onGainExperience(gainExperience);

	if(gainExperience > 0)
	{
		//soul regeneration
		if(gainExperience >= getLevel())
		{
			Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_SOUL, 4 * 60 * 1000, 0);
			condition->setParam(CONDITIONPARAM_SOULGAIN, 1);
			condition->setParam(CONDITIONPARAM_SOULTICKS, vocation->getSoulGainTicks() * 1000);
			addCondition(condition);
		}
		addExperience(gainExperience);
	}
}

bool Player::isImmune(CombatType_t type) const
{
	if(hasFlag(PlayerFlag_CannotBeAttacked))
		return true;

	return Creature::isImmune(type);
}

bool Player::isImmune(ConditionType_t type) const
{
	if(hasFlag(PlayerFlag_CannotBeAttacked))
		return true;

	return Creature::isImmune(type);
}

bool Player::isAttackable() const
{
	return !hasFlag(PlayerFlag_CannotBeAttacked);
}

void Player::changeHealth(int32_t healthChange)
{
	Creature::changeHealth(healthChange);
	sendStats();
}

void Player::changeMana(int32_t manaChange)
{
	if(!hasFlag(PlayerFlag_HasInfiniteMana))
		Creature::changeMana(manaChange);

	sendStats();
}

void Player::changeSoul(int32_t soulChange)
{
	if(soulChange > 0)
		soul += std::min(soulChange, soulMax - soul);
	else
		soul = std::max((int32_t)0, soul + soulChange);
	sendStats();
}

const OutfitListType& Player::getPlayerOutfits()
{
	return m_playerOutfits.getOutfits();
}

bool Player::canWear(uint32_t _looktype, uint32_t _addons)
{
	return m_playerOutfits.isInList(_looktype, _addons, isPremium(), getSex());
}

bool Player::canLogout()
{
	if(isConnecting)
		return false;

	if(hasCondition(CONDITION_INFIGHT))
		return false;

	if(getTile()->hasFlag(TILESTATE_NOLOGOUT))
		return false;

	return true;
}

void Player::genReservedStorageRange()
{
	uint32_t base_key;
	//generate outfits range
	base_key = PSTRG_OUTFITS_RANGE_START + 1;

	const OutfitList& global_outfits = Outfits::getInstance()->getOutfitList(sex);

	const OutfitListType& outfits = m_playerOutfits.getOutfits();
	OutfitListType::const_iterator it;
	for(it = outfits.begin(); it != outfits.end(); ++it)
	{
		uint32_t looktype = (*it)->looktype;
		uint32_t addons = (*it)->addons;
		if(!global_outfits.isInList(looktype, addons, isPremium(), getSex()))
		{
			long value = (looktype << 16) | (addons & 0xFF);
			storageMap[base_key] = value;
			base_key++;
			if(base_key > PSTRG_OUTFITS_RANGE_START + PSTRG_OUTFITS_RANGE_SIZE)
			{
				std::cout << "Warning: [Player::genReservedStorageRange()] Player " << getName() << " with more than 500 outfits!." << std::endl;
				break;
			}
		}
	}
}

void Player::addOutfit(uint32_t _looktype, uint32_t _addons)
{
	Outfit outfit;
	outfit.looktype = _looktype;
	outfit.addons = _addons;
	m_playerOutfits.addOutfit(outfit);
}

bool Player::remOutfit(uint32_t _looktype, uint32_t _addons)
{
	Outfit outfit;
	outfit.looktype = _looktype;
	outfit.addons = _addons;
	return m_playerOutfits.remOutfit(outfit);
}

void Player::setSex(PlayerSex_t newSex)
{
	sex = newSex;
	Outfits* outfits = Outfits::getInstance();
	const OutfitListType& global_outfits = outfits->getOutfits(sex);
	OutfitListType::const_iterator it;
	Outfit outfit;
	for(it = global_outfits.begin(); it != global_outfits.end(); ++it)
	{
		outfit.looktype = (*it)->looktype;
		outfit.addons = (*it)->addons;
		outfit.premium = (*it)->premium;
		m_playerOutfits.addOutfit(outfit);
	}
}

Skulls_t Player::getSkull() const
{
	if(hasFlag(PlayerFlag_NotGainInFight))
		return SKULL_NONE;

	return skull;
}

Skulls_t Player::getSkullClient(const Player* player) const
{
	if(!player || g_game.getWorldType() != WORLD_TYPE_PVP)
		return SKULL_NONE;

	if(getSkull() != SKULL_NONE)
	{
		if(player->hasAttacked(this))
			return SKULL_YELLOW;
	}

	if(player->getSkull() == SKULL_NONE)
	{
		if(isPartner(player))
			return SKULL_GREEN;
	}

	return player->getSkull();
}

bool Player::hasAttacked(const Player* attacked) const
{
	if(hasFlag(PlayerFlag_NotGainInFight) || !attacked)
		return false;

	AttackedSet::const_iterator it;
	uint32_t attackedId = attacked->getID();
	it = attackedSet.find(attackedId);
	return it != attackedSet.end();
}

void Player::addAttacked(const Player* attacked)
{
	if(hasFlag(PlayerFlag_NotGainInFight) || !attacked || attacked == this)
		return;

	AttackedSet::iterator it;
	uint32_t attackedId = attacked->getID();
	it = attackedSet.find(attackedId);
	if(it == attackedSet.end())
		attackedSet.insert(attackedId);
}

void Player::clearAttacked()
{
	attackedSet.clear();
}

void Player::addUnjustifiedDead(const Player* attacked)
{
	if(hasFlag(PlayerFlag_NotGainInFight) || attacked == this || party && party == attacked->party
		|| g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED)
		return;

	if(client)
	{
		char buffer[70];
		sprintf(buffer, "Warning! The murder of %s was not justified.", attacked->getName().c_str());
		client->sendTextMessage(MSG_STATUS_WARNING, buffer);
	}

	redSkullTicks += g_config.getNumber(ConfigManager::FRAG_TIME);
	if(g_config.getNumber(ConfigManager::KILLS_TO_RED) != 0 && redSkullTicks >= (g_config.getNumber(ConfigManager::KILLS_TO_RED) - 1) * g_config.getNumber(ConfigManager::FRAG_TIME) && getSkull() != SKULL_RED)
	{
		setSkull(SKULL_RED);
		g_game.updateCreatureSkull(this);
	}
	else if(g_config.getNumber(ConfigManager::KILLS_TO_BAN) != 0 && redSkullTicks >= (g_config.getNumber(ConfigManager::KILLS_TO_BAN) - 1) * g_config.getNumber(ConfigManager::FRAG_TIME))
	{
		Account account = IOLoginData::getInstance()->loadAccount(accountNumber);
		if(account.warnings > 3)
			g_bans.addAccountDeletion(accountNumber, time(NULL), 28, 7, "No comment.", 0);
		else if(account.warnings == 3)
			g_bans.addAccountBan(accountNumber, time(NULL) + (30 * 86400), 28, 4, "No comment.", 0);
		else
			g_bans.addAccountBan(accountNumber, time(NULL) + (7 * 86400), 28, 2, "No comment.", 0);

		uint32_t playerId = getID();
		g_game.addMagicEffect(getPosition(), NM_ME_MAGIC_POISON);
		Scheduler::getScheduler().addEvent(createSchedulerTask(500,
			boost::bind(&Game::kickPlayer, &g_game, playerId, false)));
	}
}

void Player::checkRedSkullTicks(int32_t ticks)
{
	if(redSkullTicks - ticks > 0)
		redSkullTicks = redSkullTicks - ticks;

	if(redSkullTicks < 1000 && !hasCondition(CONDITION_INFIGHT) && skull != SKULL_NONE)
	{
		setSkull(SKULL_NONE);
		g_game.updateCreatureSkull(this);
	}
}

uint64_t Player::getLostExperience()
{
	return (skillLoss ? (uint64_t)std::floor(experience * getLostPercent()) : 0);
}

bool Player::isPromoted()
{
	int32_t promotedVocation = g_vocations.getPromotedVocation(vocation_id);
	return promotedVocation == 0 && vocation_id != promotedVocation;
}

double Player::getLostPercent()
{
	uint16_t lostPercent = g_config.getNumber(ConfigManager::DEATH_LOSE_PERCENT);
	for(int16_t i = 0; i < 5; i++)
	{
		if(lostPercent == 0) break;
		if(hasBlessing(i))
			lostPercent--;
	}

	if(isPromoted() && lostPercent >= 3)
		lostPercent -= 3;

	return lostPercent / (double)100;
}

void Player::learnInstantSpell(const std::string& name)
{
	if(!hasLearnedInstantSpell(name))
		learnedInstantSpellList.push_back(name);
}

bool Player::hasLearnedInstantSpell(const std::string& name) const
{
	if(hasFlag(PlayerFlag_CannotUseSpells))
		return false;

	if(hasFlag(PlayerFlag_IgnoreSpellCheck))
		return true;

	for(LearnedInstantSpellList::const_iterator it = learnedInstantSpellList.begin(); it != learnedInstantSpellList.end(); ++it)
	{
		if(strcasecmp((*it).c_str(), name.c_str()) == 0)
			return true;
	}
	return false;
}

void Player::manageAccount(const std::string &text)
{
	std::stringstream msg;
	msg << "Account Manager: ";
	if(namelockedPlayer != "")
	{
		if(!talkState[1])
		{
			newCharacterName = text;
			trimString(newCharacterName);
			if(!isValidName(newCharacterName))
				msg << "That name seems to contain invalid symbols tell me another name.";
			else if(islower(newCharacterName[0]))
				msg << "Names dont start with lowercase tell me another name starting with uppercase!";
			else if(newCharacterName.length() > 20)
				msg << "The name you want is too long, please select a shorter name.";
			else if(upchar(newCharacterName[0]) == 'G' && upchar(newCharacterName[1]) == 'M')
				msg << "Your character is not a gamemaster please tell me another name!";
			else if(IOLoginData::getInstance()->playerExists(newCharacterName))
				msg << "A player with this name currently exists, please choose another name.";
			else if(newCharacterName.length() < 4)
				msg << "Your name you want is too short, please select a longer name.";
			else
			{
				talkState[1] = true;
				talkState[2] = true;
				msg << newCharacterName << ", are you sure?";
			}
		}
		else if(checkText(text, "no") && talkState[2])
		{
			talkState[1] = false;
			talkState[2] = true;
			msg << "What else would you like to name your character?";
		}
		else if(checkText(text, "yes") && talkState[2])
		{
			if(!IOLoginData::getInstance()->playerExists(newCharacterName))
			{
				uint32_t _guid;
				IOLoginData::getInstance()->getGuidByName(_guid, namelockedPlayer);
				if(IOLoginData::getInstance()->changeName(_guid, newCharacterName))
				{
					g_bans.removePlayerNamelock(_guid);

					talkState[1] = true;
					talkState[2] = false;
					msg << "Your character has successfully been renamed, you should now be able to login at it without any problems.";
				}
				else
				{
					talkState[1] = false;
					talkState[2] = true;
					msg << "Failed to change your name, please try another name.";
				}
			}
			else
			{
				talkState[1] = false;
				talkState[2] = true;
				msg << "A player with that name already exists, please pick another name.";
			}
		}
		else
			msg << "Sorry, but I can't understand you, please try to repeat that!";
	}
	else if(accountManager)
	{
		Account account = IOLoginData::getInstance()->loadAccount(realAccount);
		if(checkText(text, "cancel") || checkText(text, "account") && !talkState[1])
		{
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;
			msg << "Do you want to change your 'password', request a 'recovery key', add a 'character', or 'delete' a character?";
		}
		else if(checkText(text, "delete") && talkState[1])
		{
			talkState[1] = false;
			talkState[2] = true;
			msg << "Which character would you like to delete?";
		}
		else if(talkState[2])
		{
			if(!isValidName(text))
				msg << "That name contains invalid characters, try to say your name again, you might have typed it wrong.";
			else
			{
				talkState[2] = false;
				talkState[3] = true;
				removeChar = text;
				msg << "Do you really want to delete the character named " << removeChar << "?";
			}
		}
		else if(checkText(text, "yes") && talkState[3])
		{
			int32_t result = IOLoginData::getInstance()->deleteCharacter(realAccount, removeChar);
			switch(result)
			{
				case 0:
					msg << "Either the character does not belong to you or it doesn't exist.";
					break;

				case 1:
					msg << "Your character has been deleted.";
					break;

				case 2:
					msg << "Your character is a houseowner, to make sure you really want to lose your house deleting your character you have to login and leave the house or pass it to someone else.";
					break;

				case 3:
					msg << "Your character is the leader of a guild, you need to disband or pass the leadership to delete your character.";
					break;

				case 4:
					msg << "A character with that name is currently online, to delete a character it has to be offline.";
					break;
			}
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;
		}
		else if(checkText(text, "no") && talkState[3])
		{
			talkState[1] = true;
			talkState[3] = false;
			msg << "Tell me what character you want to delete.";
		}
		else if(checkText(text, "password") && talkState[1])
		{
			talkState[1] = false;
			talkState[4] = true;
			msg << "Tell me your new password please.";
		}
		else if(talkState[4])
		{
			if(isValidPassword(text))
			{
				if(text.length() > 5)
				{
					talkState[4] = false;
					talkState[5] = true;
					newPassword = text;
					msg << "Should '" << newPassword << "' be your new password?";
				}
				else
					msg << "That password is too short, please select a longer password.";
			}
			else
				msg << "That password contains invalid characters... tell me another one.";
		}
		else if(checkText(text, "yes") && talkState[5])
		{
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;

			IOLoginData::getInstance()->setNewPassword(realAccount, newPassword);
			msg << "Your password has been changed.";
		}
		else if(checkText(text, "no") && talkState[5])
		{
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;
			msg << "Then not.";
		}
		else if(checkText(text, "character") && talkState[1])
		{
			if(account.charList.size() <= 15)
			{
				talkState[1] = false;
				talkState[6] = true;
				msg << "What would you like as your character name?";
			}
			else
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; i++)
					talkState[i] = false;
				msg << "Your account reach the limit of 15 players, you can 'delete' a character if you want to create a new one.";
			}
		}
		else if(talkState[6])
		{
			newCharacterName = text;
			trimString(newCharacterName);
			if(!isValidName(newCharacterName))
				msg << "That name seems to contain invalid symbols tell me another name.";
			else if(islower(newCharacterName[0]))
				msg << "Names dont start with lowercase tell me another name starting with uppercase!";
			else if(newCharacterName.length() > 20)
				msg << "The name you want is too long, please select a shorter name.";
			else if(upchar(newCharacterName[0]) == 'G' && (upchar(newCharacterName[1]) == 'M' || upchar(newCharacterName[1]) == 'O' && upchar(newCharacterName[2]) == 'D'))
				msg << "Your character is not a gamemaster please tell me a another name!";
			else if(IOLoginData::getInstance()->playerExists(newCharacterName))
				msg << "A player with this name currently exists, please choose another name.";
			else if(newCharacterName.length() < 4)
				msg << "Your name you want is too short, please select a longer name.";
			else
			{
				talkState[6] = false;
				talkState[7] = true;
				msg << newCharacterName << ", are you sure?";
			}
		}
		else if(checkText(text, "no") && talkState[7])
		{
			talkState[6] = true;
			talkState[7] = false;
			msg << "What else would you like to name your character?";
		}
		else if(checkText(text, "yes") && talkState[7])
		{
			talkState[7] = false;
			talkState[8] = true;
			msg << "Should your character be a 'male' or a 'female'.";
		}
		else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
		{
			talkState[8] = false;
			talkState[9] = true;
			if(checkText(text, "female"))
			{
				msg << "A female, are you sure?";
				_newSex = PLAYERSEX_FEMALE;
			}
			else
			{
				msg << "A male, are you sure?";
				_newSex = PLAYERSEX_MALE;
			}
		}
		else if(checkText(text, "no") && talkState[9])
		{
			talkState[8] = true;
			talkState[9] = false;
			msg << "Tell me.. would you like to be a 'male' or a 'female'?";
		}
		else if(checkText(text, "yes") && talkState[9])
		{
			if(g_config.getString(ConfigManager::START_CHOOSEVOC) == "yes")
			{
				talkState[9] = false;
				talkState[11] = true;
				bool firstPart = true;
				for(VocationsMap::iterator it = g_vocations.getFirstVocation(); it != g_vocations.getLastVocation(); ++it)
				{
					if(it->first == (it->second)->getFromVocation() && it->first != 0)
					{
						if(firstPart)
						{
							msg << "What do you want to be... " << (it->second)->getVocDescription();
							firstPart = false;
						}
						else if(it->first - 1 != 0)
							msg << ", " << (it->second)->getVocDescription();
						else
							msg << " or " << (it->second)->getVocDescription() << ".";
					}
				}
			}
			else
			{
				if(!IOLoginData::getInstance()->playerExists(newCharacterName))
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; i++)
						talkState[i] = false;
					if(IOLoginData::getInstance()->createCharacter(realAccount, newCharacterName, newVocation, _newSex))
						msg << "Your character has been made.";
					else
						msg << "Your character has NOT been made, please try again.";
				}
				else
				{
					talkState[6] = true;
					talkState[9] = false;
					msg << "A player with this name currently exists, please choose another name.";
				}
			}
		}
		else if(talkState[11])
		{
			for(VocationsMap::iterator it = g_vocations.getFirstVocation(); it != g_vocations.getLastVocation(); ++it)
			{
				std::string vocationName = (it->second)->getVocName();
				std::transform(vocationName.begin(), vocationName.end(), vocationName.begin(), tolower);
				if(checkText(text, vocationName) && it != g_vocations.getLastVocation() && it->first == (it->second)->getFromVocation() && it->first != 0)
				{
					msg << "So you would like to be " << (it->second)->getVocDescription() << "... are you sure?";
					newVocation = it->first;
					talkState[11] = false;
					talkState[12] = true;
				}
			}
			if(msg.str().length() == 17)
				msg << "I don't understand what vocation you would like to be... could you please repeat it?";
		}
		else if(checkText(text, "yes") && talkState[12])
		{
			if(!IOLoginData::getInstance()->playerExists(newCharacterName))
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; i++)
					talkState[i] = false;
				if(IOLoginData::getInstance()->createCharacter(realAccount, newCharacterName, newVocation, _newSex))
					msg << "Your character has been made.";
				else
					msg << "Your character has NOT been made, please try again.";
			}
			else
			{
				talkState[6] = true;
				talkState[9] = false;
				msg << "A player with this name currently exists, please choose another name.";
			}
		}
		else if(checkText(text, "no") && talkState[12])
		{
			talkState[11] = true;
			talkState[12] = false;
			msg << "No? Then what would you like to be?";
		}
		else if(checkText(text, "recovery key") && talkState[1])
		{
			talkState[1] = false;
			talkState[10] = true;
			msg << "Would you like a recovery key?";
		}
		else if(checkText(text, "yes") && talkState[10])
		{
			if(account.recoveryKey != "0")
				msg << "Sorry, you already have a recovery key, for security reasons I may not give you a new one.";
			else
			{
				recoveryKey = generateRecoveryKey(4, 4);
				IOLoginData::getInstance()->setRecoveryKey(realAccount, recoveryKey);
				msg << "Your recovery key is: " << recoveryKey << ".";
			}
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;
		}
		else if(checkText(text, "no") && talkState[10])
		{
			msg << "Then not.";
			talkState[1] = true;
			for(int8_t i = 2; i <= 12; i++)
				talkState[i] = false;
		}
		else
			msg << "Please read the latest message that I have specified, I dont understand the current requested action.";
	}
	else
	{
		if(checkText(text, "account") && !talkState[1])
		{
			msg << "What would you like your password to be?";
			talkState[1] = true;
			talkState[2] = true;
		}
		else if(talkState[2])
		{
			if(isValidPassword(text))
			{
				if(text.length() > 5)
				{
					msg << text << " is it? 'yes' or 'no'?";
					newPassword = text;
					talkState[3] = true;
					talkState[2] = false;
				}
				else
					msg << "That password is too short, please select a longer password.";
			}
			else
				msg << "That password contains invalid characters... tell me another one.";
		}
		else if(checkText(text, "yes") && talkState[3])
		{
			if(g_config.getString(ConfigManager::GENERATE_ACCOUNT_NUMBER) == "yes")
			{
				do
				{
					sprintf(newAccountNumber, "%d%d%d%d%d%d%d", random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9));
					newAccount = atoi(newAccountNumber);
				}
				while(IOLoginData::getInstance()->accountExists(newAccount));
				msg << "Your account has been created, you login with account number '" << newAccount << "' and password '" << newPassword << "', if the account number is hard to remember please write it down!";

				IOLoginData::getInstance()->createAccount(newAccount, newPassword);
				for(int8_t i = 2; i <= 8; i++)
					talkState[i] = false;
			}
			else
			{
				msg << "What would you like your account number to be?";
				talkState[3] = false;
				talkState[4] = true;
			}
		}
		else if(checkText(text, "no") && talkState[3])
		{
			talkState[2] = true;
			talkState[3] = false;
			msg << "What would you like your password to be then?";
		}
		else if(talkState[4])
		{
			if(isNumbers(text))
			{
				if(text.length() >= 6)
				{
					if(text.length() <= 8)
					{
						newAccount = atoi(text.c_str());
						msg << newAccount << ", are you sure?";
						talkState[4] = false;
						talkState[5] = true;
					}
					else
						msg << "That account number is too long.. an account number has to be atleast 6 numbers and not more than 8 numbers, please pick another account number.";
				}
				else
					msg << "That account number is too short.. an account number has to be atleast 6 numbers and not more than 8 numbers, please pick another account number.";
			}
			else
				msg << "Your account number may only contain numbers, please pick another account number.";
		}
		else if(checkText(text, "yes") && talkState[5])
		{
			if(!IOLoginData::getInstance()->accountExists(newAccount))
			{
				IOLoginData::getInstance()->createAccount(newAccount, newPassword);
				msg << "Your account has been created, you can login with account number: '" << newAccount << "' and password: '" << newPassword << "'!";
			}
			else
			{
				msg << "An account with that number combination already exists, please try another account number.";
				talkState[4] = true;
				talkState[5] = false;
			}
		}
		else if(checkText(text, "no") && talkState[5])
		{
			talkState[5] = false;
			talkState[4] = true;
			msg << "What else would you like as your account number?";
		}
		else if(checkText(text, "recover") && !talkState[6])
		{
			talkState[6] = true;
			talkState[7] = true;
			msg << "What was your account number?";
		}
		else if(talkState[7])
		{
			accountNumberAttempt = text;
			talkState[7] = false;
			talkState[8] = true;
			msg << "What was your recovery key?";
		}
		else if(talkState[8])
		{
			recoveryKeyAttempt = text;
			uint32_t accountId = atoi(accountNumberAttempt.c_str());
			if(IOLoginData::getInstance()->validRecoveryKey(accountId, recoveryKeyAttempt) && recoveryKeyAttempt != "0")
			{
				char buffer[50];
				sprintf(buffer, "%s%d", g_config.getString(ConfigManager::SERVER_NAME).c_str(), random_range(100, 999));
				IOLoginData::getInstance()->setNewPassword(accountId, buffer);
				msg << "Correct! Your new password is: " << buffer << ".";
			}
			else
				msg << "Sorry, but that information you gave me did not match to any account :(.";

			for(int8_t i = 2; i <= 8; i++)
				talkState[i] = false;
		}
		else
			msg << "Sorry, but I can't understand you, please try to repeat that.";
	}
	sendTextMessage(MSG_STATUS_CONSOLE_BLUE, msg.str().c_str());
}

bool Player::isInvitedToGuild(uint32_t guild_id) const
{
	for(InvitedToGuildsList::const_iterator it = invitedToGuildsList.begin(); it != invitedToGuildsList.end(); ++it)
	{
		if((*it) == guild_id)
			return true;
	}
	return false;
}

void Player::resetGuildInformation()
{
	sendClosePrivate(0x00);
	guildId = 0;
	guildName = "";
	guildRank = "";
	guildNick = "";
	guildLevel = 0;
}

bool Player::isPremium() const
{
	if(g_config.getString(ConfigManager::FREE_PREMIUM) == "yes" || hasFlag(PlayerFlag_IsAlwaysPremium))
		return true;
	return premiumDays;
}

void Player::setGuildLevel(GuildLevel_t newGuildLevel)
{
	guildLevel = newGuildLevel;
	setGuildRank(IOGuild::getInstance()->getRankName(guildLevel, guildId));
}

void Player::setGroupId(int32_t newId)
{
	const PlayerGroup* group = IOLoginData::getInstance()->getPlayerGroup(newId);
	if(group)
	{
		groupId = newId;
		groupName = group->m_name;
		toLowerCaseString(groupName);
		setFlags(group->m_flags);
		accessLevel = (group->m_access >= 1);

		if(group->m_maxdepotitems > 0)
			maxDepotLimit = group->m_maxdepotitems;
		else if(isPremium())
			maxDepotLimit = 2000;
		
		if(group->m_maxviplist > 0)
			maxVipLimit = group->m_maxviplist;
		else if(isPremium())
			maxVipLimit = 100;
	}
}

bool Player::isPartner(const Player* player) const
{
	if(!player || !party || !player->party)
		return false;

	return (party == player->party);
}

Shields_t Player::getShieldClient(Player* player)
{
	Shields_t shield = SHIELD_NONE;
	if(!player)
		return shield;
	
	if(party)
	{
		if(player->party)
		{
			if(party == player->party)
			{
				if(player == party->getLeader())
					shield = SHIELD_LEADER;
				else
					shield = SHIELD_MEMBER;
			}
		}
		else if(this == party->getLeader() && party->isInvited(player))
			shield = SHIELD_HALF;
	}
	else if(player->party)
	{
		if(player->party->getLeader() == player && player->party->isInvited(this))
			shield = SHIELD_INVITED;
	}
	return shield;
}

not full player.cpp but i am sure it would help u i made the area where errors start bold
 
Last edited:
coz it is cool and i want pvp arena?
 
seriously if u wont help saying this is outdated who would help..
and TFS doesn't have any special code.
 
Last edited:
yup u are right as well i think i managed to fix.
 
Back
Top