[svn] * Minor code fixes

* Move account related functions from ObjectMgr to AccountMgr and drop duplicate functions - source mangos
* recognize the dummy spells 38637, 38638 and 38639 as negative - source mangos
* added new command ".reload all_locales". Now all locales_* tables can be reloaded - source mangos

--HG--
branch : trunk
This commit is contained in:
KingPin
2008-10-20 12:59:45 -05:00
parent 35f378aef9
commit cdb7fd43ee
13 changed files with 141 additions and 59 deletions

3
sql/updates/84_world.sql Normal file
View File

@@ -0,0 +1,3 @@
DELETE FROM command WHERE name = 'reload all_locales';
INSERT INTO `command` VALUES
('reload all_locales',3,'Syntax: .reload all_locales\r\n\r\nReload all `locales_*` tables with reload support added and that can be _safe_ reloaded.');

View File

@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "AccountMgr.h"
#include "AccountAccessor.h"
#include "Database/DatabaseEnv.h"
#include "ObjectMgr.h"
#include "Player.h"
@@ -81,7 +81,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
uint64 guid = MAKE_NEW_GUID(guidlo, 0, HIGHGUID_PLAYER);
// kick if player currently
if(Player* p = objmgr.GetPlayer(guid))
if(Player* p = ObjectAccessor::FindPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
@@ -168,6 +168,32 @@ uint32 AccountMgr::GetId(std::string username)
}
}
uint32 AccountMgr::GetSecurity(uint32 acc_id)
{
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
if(result)
{
uint32 sec = (*result)[0].GetUInt32();
delete result;
return sec;
}
return 0;
}
bool AccountMgr::GetName(uint32 acc_id, std::string &name)
{
QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
if(result)
{
name = (*result)[0].GetCppString();
delete result;
return true;
}
return false;
}
bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
{
normilizeString(passwd);

View File

@@ -50,6 +50,9 @@ class AccountMgr
bool CheckPassword(uint32 accid, std::string passwd);
uint32 GetId(std::string username);
uint32 GetIdByGUID(const uint64 &guid) const;
uint32 GetSecurity(uint32 acc_id);
bool GetName(uint32 acc_id, std::string &name);
static bool normilizeString(std::string& utf8str);
};

View File

@@ -148,6 +148,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "all_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllScriptsCommand, "", NULL },
{ "all_spell", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllSpellCommand, "", NULL },
{ "all_item", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllItemCommand, "", NULL },
{ "all_locales", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllLocalesCommand, "", NULL },
{ "config", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadConfigCommand, "", NULL },
@@ -196,6 +197,12 @@ ChatCommand * ChatHandler::getCommandTable()
{ "spell_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptsCommand, "", NULL },
{ "spell_target_position", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTargetPositionCommand, "", NULL },
{ "spell_threats", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellThreatsCommand, "", NULL },
{ "locales_creature", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesCreatureCommand, "", NULL },
{ "locales_gameobject", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesGameobjectCommand, "", NULL },
{ "locales_item", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesItemCommand, "", NULL },
{ "locales_npc_text", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesNpcTextCommand, "", NULL },
{ "locales_page_text", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL },
{ "locales_quest", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL },
{ "", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommand, "", NULL },
{ NULL, 0, NULL, "", NULL }
};
@@ -715,6 +722,7 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, ch
continue;
if( !hasStringAbbr(table[i].Name, subcmd) )
continue;
(list += "\n ") += table[i].Name;
}

View File

@@ -146,6 +146,7 @@ class ChatHandler
bool HandleReloadAllQuestCommand(const char* args);
bool HandleReloadAllScriptsCommand(const char* args);
bool HandleReloadAllSpellCommand(const char* args);
bool HandleReloadAllLocalesCommand(const char* args);
bool HandleReloadConfigCommand(const char* args);
@@ -194,6 +195,12 @@ class ChatHandler
bool HandleReloadSpellPetAurasCommand(const char* args);
bool HandleReloadPageTextsCommand(const char* args);
bool HandleReloadItemEnchantementsCommand(const char* args);
bool HandleReloadLocalesCreatureCommand(const char* args);
bool HandleReloadLocalesGameobjectCommand(const char* args);
bool HandleReloadLocalesItemCommand(const char* args);
bool HandleReloadLocalesNpcTextCommand(const char* args);
bool HandleReloadLocalesPageTextCommand(const char* args);
bool HandleReloadLocalesQuestCommand(const char* args);
bool HandleInstanceListBindsCommand(const char* args);
bool HandleInstanceUnbindCommand(const char* args);

View File

@@ -96,7 +96,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
else
{
account_id = objmgr.GetPlayerAccountIdByGUID(guid);
security = objmgr.GetSecurityByAccount(account_id);
security = accmgr.GetSecurity(account_id);
}
if(security >= m_session->GetSecurity())
@@ -162,7 +162,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
else
{
account_id = objmgr.GetPlayerAccountIdByGUID(guid);
security = objmgr.GetSecurityByAccount(account_id);
security = accmgr.GetSecurity(account_id);
}
if(security >= m_session->GetSecurity())
@@ -1449,7 +1449,7 @@ bool ChatHandler::HandleSetMoveTypeCommand(const char* args)
{
type_str = guid_str;
pCreature = getSelectedCreature();
if(!pCreature)
if(!pCreature || pCreature->isPet())
return false;
lowguid = pCreature->GetDBTableGUIDLow();
}
@@ -1595,7 +1595,7 @@ bool ChatHandler::HandleSetModelCommand(const char* args)
Creature *pCreature = getSelectedCreature();
if(!pCreature)
if(!pCreature || pCreature->isPet())
{
SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true);
@@ -2212,7 +2212,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
// No GUID provided
// -> Player must have selected a creature
if(!target)
if(!target || target->isPet())
{
SendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true);
@@ -2296,7 +2296,7 @@ bool ChatHandler::HandleWpAddCommand(const char* args)
}
target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT));
if(!target)
if(!target || target->isPet())
{
PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid);
SetSentErrorMessage(true);

View File

@@ -24,6 +24,7 @@
#include "WorldSession.h"
#include "World.h"
#include "ObjectMgr.h"
#include "AccountMgr.h"
#include "PlayerDump.h"
#include "SpellMgr.h"
#include "Player.h"
@@ -72,6 +73,7 @@ bool ChatHandler::HandleReloadAllCommand(const char*)
HandleReloadAllQuestCommand("");
HandleReloadAllSpellCommand("");
HandleReloadAllItemCommand("");
HandleReloadAllLocalesCommand("");
HandleReloadCommandCommand("");
HandleReloadReservedNameCommand("");
@@ -158,6 +160,17 @@ bool ChatHandler::HandleReloadAllItemCommand(const char*)
return true;
}
bool ChatHandler::HandleReloadAllLocalesCommand(const char* args)
{
HandleReloadLocalesCreatureCommand("a");
HandleReloadLocalesGameobjectCommand("a");
HandleReloadLocalesItemCommand("a");
HandleReloadLocalesNpcTextCommand("a");
HandleReloadLocalesPageTextCommand("a");
HandleReloadLocalesQuestCommand("a");
return true;
}
bool ChatHandler::HandleReloadConfigCommand(const char* arg)
{
sLog.outString( "Re-Loading config settings..." );
@@ -600,6 +613,54 @@ bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/)
return true;
}
bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales Creature ...");
objmgr.LoadCreatureLocales();
SendGlobalSysMessage("DB table `locales_creature` reloaded.");
return true;
}
bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales Gameobject ... ");
objmgr.LoadGameObjectLocales();
SendGlobalSysMessage("DB table `locales_gameobject` reloaded.");
return true;
}
bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales Item ... ");
objmgr.LoadItemLocales();
SendGlobalSysMessage("DB table `locales_item` reloaded.");
return true;
}
bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales NPC Text ... ");
objmgr.LoadNpcTextLocales();
SendGlobalSysMessage("DB table `locales_npc_text` reloaded.");
return true;
}
bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales Page Text ... ");
objmgr.LoadPageTextLocales();
SendGlobalSysMessage("DB table `locales_page_text` reloaded.");
return true;
}
bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
{
sLog.outString( "Re-Loading Locales Quest ... ");
objmgr.LoadQuestLocales();
SendGlobalSysMessage("DB table `locales_quest` reloaded.");
return true;
}
bool ChatHandler::HandleLoadScriptsCommand(const char* args)
{
if(!LoadScriptingModule(args)) return true;
@@ -654,7 +715,7 @@ bool ChatHandler::HandleSecurityCommand(const char* args)
return false;
}
targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
targetSecurity = objmgr.GetSecurityByAccount(targetAccountId);
targetSecurity = accmgr.GetSecurity(targetAccountId);
}
arg2 = strtok(NULL, " ");
@@ -4954,14 +5015,14 @@ bool ChatHandler::HandleLoadPDumpCommand(const char *args)
if(!file || !acc)
return false;
uint32 account_id = objmgr.GetAccountByAccountName(acc);
uint32 account_id = accmgr.GetId(acc);
if(!account_id)
{
account_id = atoi(acc);
if(account_id)
{
std::string acc_name;
if(!objmgr.GetAccountNameByAccount(account_id,acc_name))
if(!accmgr.GetName(account_id,acc_name))
return false;
}
else

View File

@@ -39,6 +39,7 @@
#include "GameEvent.h"
#include "Spell.h"
#include "Chat.h"
#include "AccountMgr.h"
#include "InstanceSaveMgr.h"
#include "SpellAuras.h"
#include "Util.h"
@@ -320,6 +321,7 @@ void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction )
{
bidder_accId = GetPlayerAccountIdByGUID(bidder_guid);
bidder_security = GetSecurityByAccount(bidder_accId);
bidder_security = accmgr.GetSecurity(bidder_accId);
if(bidder_security > SEC_PLAYER ) // not do redundant DB requests
{
@@ -504,6 +506,8 @@ CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id)
void ObjectMgr::LoadCreatureLocales()
{
mCreatureLocaleMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature");
if(!result)
@@ -1297,46 +1301,6 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
return 0;
}
uint32 ObjectMgr::GetSecurityByAccount(uint32 acc_id) const
{
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
if(result)
{
uint32 sec = (*result)[0].GetUInt32();
delete result;
return sec;
}
return 0;
}
bool ObjectMgr::GetAccountNameByAccount(uint32 acc_id, std::string &name) const
{
QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
if(result)
{
name = (*result)[0].GetCppString();
delete result;
return true;
}
return false;
}
uint32 ObjectMgr::GetAccountByAccountName(std::string name) const
{
loginDatabase.escape_string(name);
QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", name.c_str());
if(result)
{
uint32 id = (*result)[0].GetUInt32();
delete result;
return id;
}
return 0;
}
void ObjectMgr::LoadAuctions()
{
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
@@ -1398,6 +1362,8 @@ void ObjectMgr::LoadAuctions()
void ObjectMgr::LoadItemLocales()
{
mItemLocaleMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item");
if(!result)
@@ -3419,6 +3385,8 @@ void ObjectMgr::LoadQuests()
void ObjectMgr::LoadQuestLocales()
{
mQuestLocaleMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1,"
"Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2,"
@@ -4014,6 +3982,8 @@ void ObjectMgr::LoadPageTexts()
void ObjectMgr::LoadPageTextLocales()
{
mPageTextLocaleMap.clear();
QueryResult *result = WorldDatabase.PQuery("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text");
if(!result)
@@ -4180,6 +4150,8 @@ void ObjectMgr::LoadGossipText()
void ObjectMgr::LoadNpcTextLocales()
{
mNpcTextLocaleMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1,"
"Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2,"
@@ -5203,6 +5175,8 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
void ObjectMgr::LoadGameObjectLocales()
{
mGameObjectLocaleMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8,"
"castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4,"

View File

@@ -396,9 +396,6 @@ class ObjectMgr
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
uint32 GetPlayerTeamByGUID(const uint64 &guid) const;
uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const;
uint32 GetSecurityByAccount(uint32 acc_id) const;
bool GetAccountNameByAccount(uint32 acc_id, std::string &name) const;
uint32 GetAccountByAccountName(std::string name) const;
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid );
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost);

View File

@@ -2057,9 +2057,9 @@ enum SummonType
SUMMON_TYPE_UNKNOWN3 = 181,
SUMMON_TYPE_UNKNOWN4 = 187,
SUMMON_TYPE_UNKNOWN1 = 247,
SUMMON_TYPE_UNKNOWN5 = 307,
SUMMON_TYPE_CRITTER2 = 407,
SUMMON_TYPE_UNKNOWN6 = 409,
SUMMON_TYPE_CRITTER3 = 307,
SUMMON_TYPE_UNKNOWN5 = 409,
SUMMON_TYPE_UNKNOWN2 = 427,
SUMMON_TYPE_POSESSED2 = 428
};

View File

@@ -3083,6 +3083,7 @@ void Spell::EffectSummonType(uint32 i)
break;
case SUMMON_TYPE_CRITTER:
case SUMMON_TYPE_CRITTER2:
case SUMMON_TYPE_CRITTER3:
EffectSummonCritter(i);
break;
case SUMMON_TYPE_TOTEM_SLOT1:
@@ -3097,7 +3098,6 @@ void Spell::EffectSummonType(uint32 i)
case SUMMON_TYPE_UNKNOWN3:
case SUMMON_TYPE_UNKNOWN4:
case SUMMON_TYPE_UNKNOWN5:
case SUMMON_TYPE_UNKNOWN6:
break;
default:
sLog.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[i]);

View File

@@ -325,6 +325,9 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex)
{
case 13139: // net-o-matic special effect
case 23445: // evil twin
case 38637: // Nether Exhaustion (red)
case 38638: // Nether Exhaustion (green)
case 38639: // Nether Exhaustion (blue)
return false;
default:
break;

View File

@@ -168,14 +168,14 @@ void CliLoadPlayerDump(char*command,pPrintf zprintf)
return;
}
uint32 account_id = objmgr.GetAccountByAccountName(acc);
uint32 account_id = accmgr.GetId(acc);
if(!account_id)
{
account_id = atoi(acc);
if(account_id)
{
std::string acc_name;
if(!objmgr.GetAccountNameByAccount(account_id,acc_name))
if(!accmgr.GetName(account_id,acc_name))
{
zprintf("Failed to load the character! Account not exist.\r\n");
return;