mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
Merge commit 'origin/master' into 310
Conflicts: src/game/Player.cpp
This commit is contained in:
commit
6734694a90
47 changed files with 740 additions and 524 deletions
|
|
@ -3590,20 +3590,53 @@ void ObjectMgr::LoadPetCreateSpells()
|
|||
|
||||
uint32 creature_id = fields[0].GetUInt32();
|
||||
|
||||
if(!creature_id || !sCreatureStorage.LookupEntry<CreatureInfo>(creature_id))
|
||||
if(!creature_id)
|
||||
{
|
||||
sLog.outErrorDb("Creature id %u listed in `petcreateinfo_spell` not exist.",creature_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(creature_id);
|
||||
if(!cInfo)
|
||||
{
|
||||
sLog.outErrorDb("Creature id %u listed in `petcreateinfo_spell` not exist.",creature_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
PetCreateSpellEntry PetCreateSpell;
|
||||
|
||||
bool have_spell = false;
|
||||
bool have_spell_db = false;
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
PetCreateSpell.spellid[i] = fields[i + 1].GetUInt32();
|
||||
|
||||
if(PetCreateSpell.spellid[i] && !sSpellStore.LookupEntry(PetCreateSpell.spellid[i]))
|
||||
if(!PetCreateSpell.spellid[i])
|
||||
continue;
|
||||
|
||||
have_spell_db = true;
|
||||
|
||||
SpellEntry const* i_spell = sSpellStore.LookupEntry(PetCreateSpell.spellid[i]);
|
||||
if(!i_spell)
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `petcreateinfo_spell` does not exist",PetCreateSpell.spellid[i]);
|
||||
PetCreateSpell.spellid[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
have_spell = true;
|
||||
}
|
||||
|
||||
mPetCreateSpell[creature_id] = PetCreateSpell;
|
||||
if(!have_spell_db)
|
||||
{
|
||||
sLog.outErrorDb("Creature %u listed in `petcreateinfo_spell` have only 0 spell data, why it listed?",creature_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!have_spell)
|
||||
continue;
|
||||
|
||||
mPetCreateSpell[creature_id] = PetCreateSpell;
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
|
@ -6509,10 +6542,35 @@ void ObjectMgr::LoadGameObjectForQuests()
|
|||
|
||||
bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value)
|
||||
{
|
||||
int32 start_value = min_value;
|
||||
int32 end_value = max_value;
|
||||
// some string can have negative indexes range
|
||||
if (start_value < 0)
|
||||
{
|
||||
if (end_value >= start_value)
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.",table,min_value,max_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
// real range (max+1,min+1) exaple: (-10,-1000) -> -999...-10+1
|
||||
std::swap(start_value,end_value);
|
||||
++start_value;
|
||||
++end_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (start_value >= end_value)
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.",table,min_value,max_value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup affected map part for reloading case
|
||||
for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();)
|
||||
{
|
||||
if(itr->first >= min_value && itr->first <= max_value)
|
||||
if (itr->first >= start_value && itr->first < end_value)
|
||||
{
|
||||
MangosStringLocaleMap::iterator itr2 = itr;
|
||||
++itr;
|
||||
|
|
@ -6524,14 +6582,14 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min
|
|||
|
||||
QueryResult *result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table);
|
||||
|
||||
if(!result)
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
if(min_value == MIN_MANGOS_STRING_ID) // error only in case internal strings
|
||||
if (min_value == MIN_MANGOS_STRING_ID) // error only in case internal strings
|
||||
sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.",table);
|
||||
else
|
||||
sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table);
|
||||
|
|
@ -6549,22 +6607,20 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min
|
|||
|
||||
int32 entry = fields[0].GetInt32();
|
||||
|
||||
if(entry==0)
|
||||
if (entry==0)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` contain reserved entry 0, ignored.",table);
|
||||
continue;
|
||||
}
|
||||
else if(entry < min_value || entry > max_value)
|
||||
else if (entry < start_value || entry >= end_value)
|
||||
{
|
||||
int32 start = min_value > 0 ? min_value : max_value;
|
||||
int32 end = min_value > 0 ? max_value : min_value;
|
||||
sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,start,end);
|
||||
sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,min_value,max_value);
|
||||
continue;
|
||||
}
|
||||
|
||||
MangosStringLocale& data = mMangosStringLocaleMap[entry];
|
||||
|
||||
if(data.Content.size() > 0)
|
||||
if (data.Content.size() > 0)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry);
|
||||
continue;
|
||||
|
|
@ -6579,13 +6635,13 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min
|
|||
for(int i = 1; i < MAX_LOCALE; ++i)
|
||||
{
|
||||
std::string str = fields[i+1].GetCppString();
|
||||
if(!str.empty())
|
||||
if (!str.empty())
|
||||
{
|
||||
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
|
||||
if(idx >= 0)
|
||||
if (idx >= 0)
|
||||
{
|
||||
// 0 -> default, idx in to idx+1
|
||||
if(data.Content.size() <= idx+1)
|
||||
if (data.Content.size() <= idx+1)
|
||||
data.Content.resize(idx+2);
|
||||
|
||||
data.Content[idx+1] = str;
|
||||
|
|
@ -6597,7 +6653,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min
|
|||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
if(min_value == MIN_MANGOS_STRING_ID) // error only in case internal strings
|
||||
if (min_value == MIN_MANGOS_STRING_ID)
|
||||
sLog.outString( ">> Loaded %u MaNGOS strings from table %s", count,table);
|
||||
else
|
||||
sLog.outString( ">> Loaded %u string templates from %s", count,table);
|
||||
|
|
@ -7535,15 +7591,15 @@ uint32 GetAreaTriggerScriptId(uint32 trigger_id)
|
|||
|
||||
bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value)
|
||||
{
|
||||
if(start_value >= 0 || start_value <= end_value) // start/end reversed for negative values
|
||||
// MAX_DB_SCRIPT_STRING_ID is max allowed negative value for scripts (scrpts can use only more deep negative values
|
||||
// start/end reversed for negative values
|
||||
if (start_value > MAX_DB_SCRIPT_STRING_ID || end_value >= start_value)
|
||||
{
|
||||
sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), use (%d - %d) instead.",table,start_value,end_value,-1,std::numeric_limits<int32>::min());
|
||||
start_value = -1;
|
||||
end_value = std::numeric_limits<int32>::min();
|
||||
sLog.outErrorDb("Table '%s' attempt loaded with reserved by mangos range (%d - %d), strings not loaded.",table,start_value,end_value+1);
|
||||
return false;
|
||||
}
|
||||
|
||||
// for scripting localized strings allowed use _only_ negative entries
|
||||
return objmgr.LoadMangosStrings(db,table,end_value,start_value);
|
||||
return objmgr.LoadMangosStrings(db,table,start_value,end_value);
|
||||
}
|
||||
|
||||
uint32 MANGOS_DLL_SPEC GetScriptId(const char *name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue