diff options
Diffstat (limited to 'src/game/Level3.cpp')
-rw-r--r-- | src/game/Level3.cpp | 371 |
1 files changed, 190 insertions, 181 deletions
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 7e7228f5885..88be4f6f2d5 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -427,17 +427,8 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args) } //reload commands -bool ChatHandler::HandleReloadCommand(const char* arg) -{ - // this is error catcher for wrong table name in .reload commands - PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg); - SetSentErrorMessage(true); - return false; -} - bool ChatHandler::HandleReloadAllCommand(const char*) { - HandleReloadAreaTriggerTeleportCommand(""); HandleReloadSkillFishingBaseLevelCommand(""); HandleReloadAllAreaCommand(""); @@ -522,6 +513,7 @@ bool ChatHandler::HandleReloadAllSpellCommand(const char*) HandleReloadSpellElixirCommand("a"); HandleReloadSpellLearnSpellCommand("a"); HandleReloadSpellProcEventCommand("a"); + HandleReloadSpellBonusesCommand("a"); HandleReloadSpellScriptTargetCommand("a"); HandleReloadSpellTargetPositionCommand("a"); HandleReloadSpellThreatsCommand("a"); @@ -672,6 +664,15 @@ bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) return true; } +bool ChatHandler::HandleReloadLootTemplatesMillingCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`milling_loot_template`)" ); + LoadLootTemplates_Milling(); + LootTemplates_Milling.CheckLootRefs(); + SendGlobalSysMessage("DB table `milling_loot_template` reloaded."); + return true; +} + bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) { sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); @@ -716,6 +717,15 @@ bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) return true; } +bool ChatHandler::HandleReloadLootTemplatesSpellCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`spell_loot_template`)" ); + LoadLootTemplates_Spell(); + LootTemplates_Spell.CheckLootRefs(); + SendGlobalSysMessage("DB table `spell_loot_template` reloaded."); + return true; +} + bool ChatHandler::HandleReloadTrinityStringCommand(const char*) { sLog.outString( "Re-Loading trinity_string Table!" ); @@ -828,6 +838,14 @@ bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) return true; } +bool ChatHandler::HandleReloadSpellBonusesCommand(const char*) +{ + sLog.outString( "Re-Loading Spell Bonus Data..." ); + spellmgr.LoadSpellBonusess(); + SendGlobalSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); + return true; +} + bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*) { sLog.outString( "Re-Loading SpellsScriptTarget..." ); @@ -1213,19 +1231,10 @@ bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) return false; } - uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); - - /// m_session==NULL only for console - uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; - /// can set password only for target with less security /// This is also reject self apply in fact - if (targetSecurity >= plSecurity) - { - SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage (true); + if(HasLowerSecurityAccount (NULL,targetAccountId,true)) return false; - } if (strcmp(szPassword1,szPassword2)) { @@ -1303,7 +1312,6 @@ bool ChatHandler::HandleSetSkillCommand(const char* args) char *max_p = strtok (NULL, " "); int32 skill = atoi(skill_p); - if (skill <= 0) { PSendSysMessage(LANG_INVALID_SKILL_ID, skill); @@ -1353,27 +1361,12 @@ bool ChatHandler::HandleUnLearnCommand(const char* args) return false; // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - uint32 min_id = extractSpellIdFromLink((char*)args); - if(!min_id) + uint32 spell_id = extractSpellIdFromLink((char*)args); + if(!spell_id) return false; - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - char* tail = strtok(NULL,""); - - uint32 max_id = extractSpellIdFromLink(tail); - - if (!max_id) - { - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - max_id = min_id+1; - } - else - { - if (max_id < min_id) - std::swap(min_id,max_id); - - max_id=max_id+1; - } + char const* allStr = strtok(NULL," "); + bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; Player* target = getSelectedPlayer(); if(!target) @@ -1383,13 +1376,13 @@ bool ChatHandler::HandleUnLearnCommand(const char* args) return false; } - for(uint32 spell=min_id;spell<max_id;spell++) - { - if (target->HasSpell(spell)) - target->removeSpell(spell); - else - SendSysMessage(LANG_FORGET_SPELL); - } + if(allRanks) + spell_id = spellmgr.GetFirstSpellInChain (spell_id); + + if (target->HasSpell(spell_id)) + target->removeSpell(spell_id,false,!allRanks); + else + SendSysMessage(LANG_FORGET_SPELL); return true; } @@ -2054,7 +2047,7 @@ bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) continue; } - m_session->GetPlayer()->learnSpell(spell); + m_session->GetPlayer()->learnSpell(spell,false); } SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); @@ -2094,7 +2087,7 @@ bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) continue; } - m_session->GetPlayer()->learnSpell(spell); + m_session->GetPlayer()->learnSpell(spell,false); } SendSysMessage(LANG_LEARNING_GM_SKILLS); @@ -2121,6 +2114,10 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) if(!spellInfo) continue; + // skip server-side/triggered spells + if(spellInfo->spellLevel==0) + continue; + // skip wrong class/race skills if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) continue; @@ -2129,8 +2126,6 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) if( spellInfo->SpellFamilyName != family) continue; - //TODO: skip triggered spells - // skip spells with first rank learned as talent (and all talents then also) uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id); if(GetTalentSpellCost(first_rank) > 0 ) @@ -2140,27 +2135,13 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; - m_session->GetPlayer()->learnSpell(i); + m_session->GetPlayer()->learnSpell(i,false); } SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); return true; } -static void learnAllHighRanks(Player* player, uint32 spellid) -{ - SpellChainNode const* node; - do - { - node = spellmgr.GetSpellChainNode(spellid); - player->learnSpell(spellid); - if (!node) - break; - spellid=node->next; - } - while (node->next); -} - bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) { Player* player = m_session->GetPlayer(); @@ -2198,11 +2179,8 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) continue; - // learn highest rank of talent - player->learnSpell(spellid); - - // and learn all non-talent spell ranks (recursive by tree) - learnAllHighRanks(player,spellid); + // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) + player->learnSpellHighRank(spellid); } SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); @@ -2213,7 +2191,7 @@ bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) { // skipping UNIVERSAL language (0) for(int i = 1; i < LANGUAGES_COUNT; ++i) - m_session->GetPlayer()->learnSpell(lang_description[i].spell_id); + m_session->GetPlayer()->learnSpell(lang_description[i].spell_id,false); SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); return true; @@ -2269,25 +2247,31 @@ bool ChatHandler::HandleLearnCommand(const char* args) if(!spell || !sSpellStore.LookupEntry(spell)) return false; - if (targetPlayer->HasSpell(spell)) + char const* allStr = strtok(NULL," "); + bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) { - if(targetPlayer == m_session->GetPlayer()) - SendSysMessage(LANG_YOU_KNOWN_SPELL); - else - PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); SetSentErrorMessage(true); return false; } - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!allRanks && targetPlayer->HasSpell(spell)) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + if(targetPlayer == m_session->GetPlayer()) + SendSysMessage(LANG_YOU_KNOWN_SPELL); + else + PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); SetSentErrorMessage(true); return false; } - targetPlayer->learnSpell(spell); + if(allRanks) + targetPlayer->learnSpellHighRank(spell); + else + targetPlayer->learnSpell(spell,false); return true; } @@ -3097,15 +3081,25 @@ bool ChatHandler::HandleLookupSkillCommand(const char* args) if(loc < MAX_LOCALE) { + char valStr[50] = ""; char const* knownStr = ""; if(target && target->HasSkill(id)) + { knownStr = GetTrinityString(LANG_KNOWN); + uint32 curValue = target->GetPureSkillValue(id); + uint32 maxValue = target->GetPureMaxSkillValue(id); + uint32 permValue = target->GetSkillPermBonusValue(id); + uint32 tempValue = target->GetSkillTempBonusValue(id); + + char const* valFormat = GetTrinityString(LANG_SKILL_VALUES); + snprintf(valStr,50,valFormat,curValue,maxValue,permValue,tempValue); + } // send skill in "id - [namedlink locale]" format if (m_session) - PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr); + PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr,valStr); else - PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr); + PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr,valStr); ++counter; } @@ -3172,7 +3166,7 @@ bool ChatHandler::HandleLookupSpellCommand(const char* args) bool talent = (talentCost > 0); bool passive = IsPassiveSpell(id); - bool active = target && (target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2)); + bool active = target && target->HasAura(id); // unit32 used to prevent interpreting uint8 as char at output // find rank of learned spell for learning spell, or talent rank @@ -3889,10 +3883,6 @@ bool ChatHandler::HandleReviveCommand(const char* args) bool ChatHandler::HandleAuraCommand(const char* args) { - char* px = strtok((char*)args, " "); - if (!px) - return false; - Unit *target = getSelectedUnit(); if(!target) { @@ -3901,7 +3891,9 @@ bool ChatHandler::HandleAuraCommand(const char* args) return false; } - uint32 spellID = (uint32)atoi(px); + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellID = extractSpellIdFromLink((char*)args); + SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); if(spellInfo) { @@ -3925,10 +3917,6 @@ bool ChatHandler::HandleAuraCommand(const char* args) bool ChatHandler::HandleUnAuraCommand(const char* args) { - char* px = strtok((char*)args, " "); - if (!px) - return false; - Unit *target = getSelectedUnit(); if(!target) { @@ -3944,7 +3932,11 @@ bool ChatHandler::HandleUnAuraCommand(const char* args) return true; } - uint32 spellID = (uint32)atoi(px); + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellID = extractSpellIdFromLink((char*)args); + if(!spellID) + return false; + target->RemoveAurasDueToSpell(spellID); return true; @@ -4193,36 +4185,6 @@ bool ChatHandler::HandleHoverCommand(const char* args) return true; } -bool ChatHandler::HandleWaterwalkCommand(const char* args) -{ - if(!args) - return false; - - Player *player = getSelectedPlayer(); - if(!player) - { - PSendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if (strncmp(args, "on", 3) == 0) - player->SetMovement(MOVE_WATER_WALK); // ON - else if (strncmp(args, "off", 4) == 0) - player->SetMovement(MOVE_LAND_WALK); // OFF - else - { - SendSysMessage(LANG_USE_BOL); - return false; - } - - PSendSysMessage(LANG_YOU_SET_WATERWALK, args, player->GetName()); - if(needReportToTarget(player)) - ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetName()); - return true; - -} - bool ChatHandler::HandleLevelUpCommand(const char* args) { char* px = strtok((char*)args, " "); @@ -4332,8 +4294,6 @@ bool ChatHandler::HandleShowAreaCommand(const char* args) if (!*args) return false; - int area = atoi((char*)args); - Player *chr = getSelectedPlayer(); if (chr == NULL) { @@ -4342,10 +4302,11 @@ bool ChatHandler::HandleShowAreaCommand(const char* args) return false; } + int area = GetAreaFlagByAreaID(atoi((char*)args)); int offset = area / 32; uint32 val = (uint32)(1 << (area % 32)); - if(offset >= 128) + if(area<0 || offset >= 128) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -4364,8 +4325,6 @@ bool ChatHandler::HandleHideAreaCommand(const char* args) if (!*args) return false; - int area = atoi((char*)args); - Player *chr = getSelectedPlayer(); if (chr == NULL) { @@ -4374,10 +4333,11 @@ bool ChatHandler::HandleHideAreaCommand(const char* args) return false; } + int area = GetAreaFlagByAreaID(atoi((char*)args)); int offset = area / 32; uint32 val = (uint32)(1 << (area % 32)); - if(offset >= 128) + if(area<0 || offset >= 128) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -4723,11 +4683,28 @@ bool ChatHandler::HandleListAurasCommand (const char * /*args*/) for (Unit::AuraMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr) { bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; - PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), - itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), - itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()], - (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); + + char const* name = itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()]; + + if (m_session) + { + std::ostringstream ss_name; + ss_name << "|cffffffff|Hspell:" << itr->second->GetId() << "|h[" << name << "]|h|r"; + + PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), + itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), + ss_name.str().c_str(), + (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); + } + else + { + PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), + itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), + name, + (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); + } } for (int i = 0; i < TOTAL_AURAS; i++) { @@ -4737,9 +4714,24 @@ bool ChatHandler::HandleListAurasCommand (const char * /*args*/) for (Unit::AuraList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr) { bool talent = GetTalentSpellCost((*itr)->GetId()) > 0; - PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()],((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); + + char const* name = (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()]; + + if (m_session) + { + std::ostringstream ss_name; + ss_name << "|cffffffff|Hspell:" << (*itr)->GetId() << "|h[" << name << "]|h|r"; + + PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), + ss_name.str().c_str(),((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); + } + else + { + PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), + name,((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); + } } } return true; @@ -4794,19 +4786,6 @@ static bool HandleResetStatsOrLevelHelper(Player* player) uint8 powertype = cEntry->powerType; - uint32 unitfield; - if(powertype == POWER_RAGE) - unitfield = 0x1100EE00; - else if(powertype == POWER_ENERGY) - unitfield = 0x00000000; - else if(powertype == POWER_MANA) - unitfield = 0x0000EE00; - else - { - sLog.outError("Invalid default powertype %u for player (class %u)",powertype,player->getClass()); - return false; - } - // reset m_form if no aura if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) player->m_form = FORM_NONE; @@ -4836,9 +4815,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player) } } - // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value - player->SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); - player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY | UNIT_BYTE2_FLAG_UNK5 ); + player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP ); player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); @@ -4880,17 +4857,26 @@ bool ChatHandler::HandleResetLevelCommand(const char * args) if(!HandleResetStatsOrLevelHelper(player)) return false; - player->SetLevel(1); + // set starting level + uint32 start_level = player->getClass() != CLASS_DEATH_KNIGHT + ? sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) + : sWorld.getConfig(CONFIG_START_HEROIC_PLAYER_LEVEL); + + player->SetLevel(start_level); + player->InitRunes(); player->InitStatsForLevel(true); player->InitTaxiNodesForLevel(); + player->InitGlyphsForLevel(); player->InitTalentForLevel(); player->SetUInt32Value(PLAYER_XP,0); // reset level to summoned pet Pet* pet = player->GetPet(); if(pet && pet->getPetType()==SUMMON_PET) + { pet->InitStatsForLevel(1); - + pet->InitTalentForLevel(); + } return true; } @@ -4924,8 +4910,10 @@ bool ChatHandler::HandleResetStatsCommand(const char * args) if(!HandleResetStatsOrLevelHelper(player)) return false; + player->InitRunes(); player->InitStatsForLevel(true); player->InitTaxiNodesForLevel(); + player->InitGlyphsForLevel(); player->InitTalentForLevel(); return true; @@ -5001,13 +4989,6 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args) else player = getSelectedPlayer(); - if(!player && !playerGUID) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - if(player) { player->resetTalents(true); @@ -5016,14 +4997,33 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args) if(m_session->GetPlayer()!=player) PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); + return true; } - else + else if (playerGUID) { CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) ); PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName); + return true; + } + // Try reset talenents as Hunter Pet + Creature* creature = getSelectedCreature(); + if (creature && creature->isPet() && ((Pet *)creature)->getPetType() == HUNTER_PET) + { + ((Pet *)creature)->resetTalents(true); + Unit *owner = creature->GetOwner(); + if (owner && owner->GetTypeId() == TYPEID_PLAYER) + { + player = (Player *)owner; + ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS); + if(m_session->GetPlayer()!=player) + PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); + } + return true; } - return true; + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; } bool ChatHandler::HandleResetAllCommand(const char * args) @@ -6682,8 +6682,15 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args) SetSentErrorMessage(true); return false; } + } + // Let set addon state only for lesser (strong) security level + // or to self account + if (m_session && m_session->GetAccountId () != account_id && + HasLowerSecurityAccount (NULL,account_id,true)) + return false; + int lev=atoi(szExp); //get int anyway (0 if error) if(lev < 0) return false; @@ -6778,17 +6785,17 @@ bool ChatHandler::HandleSendItemsCommand(const char* args) } uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1; - if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount) + if(item_count < 1 || item_proto->MaxCount > 0 && item_count > uint32(item_proto->MaxCount)) { PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id); SetSentErrorMessage(true); return false; } - while(item_count > item_proto->Stackable) + while(item_count > item_proto->GetMaxStackSize()) { - items.push_back(ItemPair(item_id,item_proto->Stackable)); - item_count -= item_proto->Stackable; + items.push_back(ItemPair(item_id,item_proto->GetMaxStackSize())); + item_count -= item_proto->GetMaxStackSize(); } items.push_back(ItemPair(item_id,item_count)); @@ -6994,30 +7001,27 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args) return false; } + PlayerInfo const* info = objmgr.GetPlayerInfo(player->getRace(), player->getClass()); + if(!info) + return false; + char const* gender_str = (char*)args; int gender_len = strlen(gender_str); - uint32 displayId = player->GetNativeDisplayId(); - char const* gender_full = NULL; - uint32 new_displayId = displayId; Gender gender; - if(!strncmp(gender_str,"male",gender_len)) // MALE + if(!strncmp(gender_str, "male", gender_len)) // MALE { if(player->getGender() == GENDER_MALE) return true; - gender_full = "male"; - new_displayId = player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1; gender = GENDER_MALE; } - else if (!strncmp(gender_str,"female",gender_len)) // FEMALE + else if (!strncmp(gender_str, "female", gender_len)) // FEMALE { if(player->getGender() == GENDER_FEMALE) return true; - gender_full = "female"; - new_displayId = player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1; gender = GENDER_FEMALE; } else @@ -7029,14 +7033,19 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args) // Set gender player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); + player->SetByteValue(PLAYER_BYTES_3, 0, gender); // Change display ID - player->SetDisplayId(new_displayId); - player->SetNativeDisplayId(new_displayId); + player->SetDisplayId(gender ? info->displayId_f : info->displayId_m); + player->SetNativeDisplayId(gender ? info->displayId_f : info->displayId_m); + + char const* gender_full = gender ? "female" : "male"; + + PSendSysMessage(LANG_YOU_CHANGE_GENDER, player->GetName(), gender_full); - PSendSysMessage(LANG_YOU_CHANGE_GENDER, player->GetName(),gender_full); if (needReportToTarget(player)) - ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full,GetName()); + ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetName()); + return true; } |