Merge branch 'master' into 303

Conflicts:
	src/game/ObjectMgr.cpp
This commit is contained in:
tomrus88 2008-11-22 17:23:44 +03:00
commit 6224f95fd5
15 changed files with 167 additions and 93 deletions

16
contrib/vmap_assembler/.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git-ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# MaNGOS generated files at Windows build
#
*.ncb
*.suo
Release
Debug

13
contrib/vmap_assembler/VC71/.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git-ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# MaNGOS generated files at Windows build
#
*.user

13
contrib/vmap_assembler/VC80/.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git-ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# MaNGOS generated files at Windows build
#
*.user

13
contrib/vmap_assembler/VC90/.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git-ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# MaNGOS generated files at Windows build
#
*.user

View file

@ -27,7 +27,7 @@ namespace MaNGOS
{
inline uint32 hk_honor_at_level(uint32 level, uint32 count=1)
{
return ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
}
}
namespace XP

View file

@ -64,8 +64,6 @@ void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data )
std::string ticketText;
recv_data >> ticketText;
CharacterDatabase.escape_string(ticketText);
if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
ticket->SetText(ticketText.c_str());
else
@ -103,8 +101,6 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2);
CharacterDatabase.escape_string(ticketText);
if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
{
WorldPacket data( SMSG_GMTICKET_CREATE, 4 );

View file

@ -50,7 +50,10 @@ class GMTicket
{
m_text = text ? text : "";
m_lastUpdate = time(NULL);
CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid);
std::string escapedString = m_text;
CharacterDatabase.escape_string(escapedString);
CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid);
}
void DeleteFromDB() const
@ -62,7 +65,11 @@ class GMTicket
{
CharacterDatabase.BeginTransaction();
DeleteFromDB();
CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText());
std::string escapedString = m_text;
CharacterDatabase.escape_string(escapedString);
CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, escapedString.c_str());
CharacterDatabase.CommitTransaction();
}
private:
@ -115,4 +122,4 @@ class GMTicketMgr
};
#define ticketmgr MaNGOS::Singleton<GMTicketMgr>::Instance()
#endif
#endif

View file

@ -42,6 +42,7 @@
#include "InstanceSaveMgr.h"
#include "SpellAuras.h"
#include "Util.h"
#include "WaypointManager.h"
INSTANTIATE_SINGLETON_1(ObjectMgr);
@ -116,8 +117,12 @@ ObjectMgr::ObjectMgr()
m_hiGoGuid = 1;
m_hiDoGuid = 1;
m_hiCorpseGuid = 1;
m_hiPetNumber = 1;
m_ItemTextId = 1;
m_mailid = 1;
m_auctionid = 1;
m_guildId = 1;
m_arenaTeamId = 1;
mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS);
mGuildBankTabPrice[0] = 100;
@ -5132,7 +5137,6 @@ void ObjectMgr::SetHighestGuids()
if( result )
{
m_hiCharGuid = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5140,7 +5144,6 @@ void ObjectMgr::SetHighestGuids()
if( result )
{
m_hiCreatureGuid = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5153,7 +5156,6 @@ void ObjectMgr::SetHighestGuids()
if( result )
{
m_hiItemGuid = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5167,7 +5169,6 @@ void ObjectMgr::SetHighestGuids()
if( result )
{
m_hiGoGuid = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5175,39 +5176,27 @@ void ObjectMgr::SetHighestGuids()
if( result )
{
m_auctionid = (*result)[0].GetUInt32()+1;
delete result;
}
else
{
m_auctionid = 0;
}
result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" );
if( result )
{
m_mailid = (*result)[0].GetUInt32()+1;
delete result;
}
else
{
m_mailid = 0;
}
result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" );
if( result )
{
m_ItemTextId = (*result)[0].GetUInt32();
m_ItemTextId = (*result)[0].GetUInt32()+1;
delete result;
}
else
m_ItemTextId = 0;
result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" );
if( result )
{
m_hiCorpseGuid = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5215,7 +5204,6 @@ void ObjectMgr::SetHighestGuids()
if (result)
{
m_arenaTeamId = (*result)[0].GetUInt32()+1;
delete result;
}
@ -5223,64 +5211,58 @@ void ObjectMgr::SetHighestGuids()
if (result)
{
m_guildId = (*result)[0].GetUInt32()+1;
delete result;
}
}
uint32 ObjectMgr::GenerateArenaTeamId()
{
++m_arenaTeamId;
if(m_arenaTeamId>=0xFFFFFFFF)
if(m_arenaTeamId>=0xFFFFFFFE)
{
sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_arenaTeamId;
return m_arenaTeamId++;
}
uint32 ObjectMgr::GenerateGuildId()
{
++m_guildId;
if(m_guildId>=0xFFFFFFFF)
if(m_guildId>=0xFFFFFFFE)
{
sLog.outError("Guild ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_guildId;
return m_guildId++;
}
uint32 ObjectMgr::GenerateAuctionID()
{
++m_auctionid;
if(m_auctionid>=0xFFFFFFFF)
if(m_auctionid>=0xFFFFFFFE)
{
sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_auctionid;
return m_auctionid++;
}
uint32 ObjectMgr::GenerateMailID()
{
++m_mailid;
if(m_mailid>=0xFFFFFFFF)
if(m_mailid>=0xFFFFFFFE)
{
sLog.outError("Mail ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_mailid;
return m_mailid++;
}
uint32 ObjectMgr::GenerateItemTextID()
{
++m_ItemTextId;
if(m_ItemTextId>=0xFFFFFFFF)
if(m_ItemTextId>=0xFFFFFFFE)
{
sLog.outError("Item text ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_ItemTextId;
return m_ItemTextId++;
}
uint32 ObjectMgr::CreateItemText(std::string text)
@ -5302,29 +5284,26 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
switch(guidhigh)
{
case HIGHGUID_ITEM:
++m_hiItemGuid;
if(m_hiItemGuid>=0xFFFFFFFF)
if(m_hiItemGuid>=0xFFFFFFFE)
{
sLog.outError("Item guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiItemGuid;
return m_hiItemGuid++;
case HIGHGUID_UNIT:
++m_hiCreatureGuid;
if(m_hiCreatureGuid>=0x00FFFFFF)
if(m_hiCreatureGuid>=0x00FFFFFE)
{
sLog.outError("Creature guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiCreatureGuid;
return m_hiCreatureGuid++;
case HIGHGUID_PET:
++m_hiPetGuid;
if(m_hiPetGuid>=0x00FFFFFF)
if(m_hiPetGuid>=0x00FFFFFE)
{
sLog.outError("Pet guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiPetGuid;
return m_hiPetGuid++;
case HIGHGUID_VEHICLE:
++m_hiVehicleGuid;
if(m_hiVehicleGuid>=0x00FFFFFF)
@ -5332,39 +5311,35 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
sLog.outError("Vehicle guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiVehicleGuid;
return m_hiVehicleGuid++;
case HIGHGUID_PLAYER:
++m_hiCharGuid;
if(m_hiCharGuid>=0xFFFFFFFF)
if(m_hiCharGuid>=0xFFFFFFFE)
{
sLog.outError("Players guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiCharGuid;
return m_hiCharGuid++;
case HIGHGUID_GAMEOBJECT:
++m_hiGoGuid;
if(m_hiGoGuid>=0x00FFFFFF)
if(m_hiGoGuid>=0x00FFFFFE)
{
sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiGoGuid;
return m_hiGoGuid++;
case HIGHGUID_CORPSE:
++m_hiCorpseGuid;
if(m_hiCorpseGuid>=0xFFFFFFFF)
if(m_hiCorpseGuid>=0xFFFFFFFE)
{
sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiCorpseGuid;
return m_hiCorpseGuid++;
case HIGHGUID_DYNAMICOBJECT:
++m_hiDoGuid;
if(m_hiDoGuid>=0xFFFFFFFF)
if(m_hiDoGuid>=0xFFFFFFFE)
{
sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiDoGuid;
return m_hiDoGuid++;
default:
ASSERT(0);
}
@ -7387,6 +7362,8 @@ void ObjectMgr::LoadDbScriptStrings()
CheckScripts(sGameObjectScripts,ids);
CheckScripts(sEventScripts,ids);
WaypointMgr.CheckTextsExistance(ids);
for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr);
}

View file

@ -778,12 +778,16 @@ class ObjectMgr
const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
uint32 GetScriptId(const char *name);
protected:
// first free id for selected id type
uint32 m_auctionid;
uint32 m_mailid;
uint32 m_ItemTextId;
uint32 m_arenaTeamId;
uint32 m_guildId;
uint32 m_hiPetNumber;
// first free low guid for seelcted guid type
uint32 m_hiCharGuid;
uint32 m_hiCreatureGuid;
uint32 m_hiPetGuid;
@ -793,8 +797,6 @@ class ObjectMgr
uint32 m_hiDoGuid;
uint32 m_hiCorpseGuid;
uint32 m_hiPetNumber;
QuestMap mQuestTemplates;
typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;

View file

@ -5194,6 +5194,10 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
x = GetPositionX();
y = GetPositionY();
z = GetPositionZ();
// group update
if(GetGroup() && (old_x != x || old_y != y))
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
}
// code block for underwater state update
@ -5201,10 +5205,6 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
CheckExploreSystem();
// group update
if(GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
return true;
}

View file

@ -389,7 +389,8 @@ DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::str
}
else incHighest = false;
}
else guid = objmgr.m_hiCharGuid;
else
guid = objmgr.m_hiCharGuid;
// normalize the name if specified and check if it exists
if(!normalizePlayerName(name))

View file

@ -9719,6 +9719,9 @@ void Unit::SetMaxHealth(uint32 val)
void Unit::SetPower(Powers power, uint32 val)
{
if(GetPower(power) == val)
return;
uint32 maxPower = GetMaxPower(power);
if(maxPower < val)
val = maxPower;

View file

@ -122,32 +122,18 @@ void WaypointManager::Load()
be.emote = fields[7].GetUInt32();
be.spell = fields[8].GetUInt32();
// load and store without holes in array
int j = 0;
for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
{
be.textid[j] = fields[9+i].GetUInt32();
if(be.textid[j])
be.textid[i] = fields[9+i].GetUInt32();
if(be.textid[i])
{
if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID)
if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID)
{
sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]);
sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[i]);
continue;
}
if (!objmgr.GetMangosStringLocale (be.textid[j]))
{
sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.",
id, point, be.textid[j], i+1);
continue;
}
++j; // to next internal field
}
}
// fill array tail
for(; j < MAX_WAYPOINT_TEXT; ++j)
be.textid[j] = 0;
// save memory by not storing empty behaviors
if(!be.isEmpty())
@ -306,3 +292,49 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel
if(field == "model2") node.behavior->model2 = text ? atoi(text) : 0;
}
}
void WaypointManager::CheckTextsExistance(std::set<int32>& ids)
{
WaypointPathMap::iterator pmItr = m_pathMap.begin();
for ( ; pmItr != m_pathMap.end(); ++pmItr)
{
for (int i = 0; i < pmItr->second.size(); ++i)
{
if (!pmItr->second[i].behavior)
continue;
// Now we check text existence and put all zero texts ids to the end of array
// Counting leading zeros for futher textid shift
int zeroCount = 0;
for (int j = 0; j < MAX_WAYPOINT_TEXT; ++j)
{
if (!pmItr->second[i].behavior->textid[j])
{
++zeroCount;
continue;
}
else
{
if (!objmgr.GetMangosStringLocale(pmItr->second[i].behavior->textid[j]))
{
sLog.outErrorDb("ERROR: Some waypoint has textid%u with not existing %u text.", j, pmItr->second[i].behavior->textid[j]);
pmItr->second[i].behavior->textid[j] = 0;
++zeroCount;
continue;
}
else
ids.erase(pmItr->second[i].behavior->textid[j]);
// Shifting check
if (zeroCount)
{
// Correct textid but some zeros leading, so move it forward.
pmItr->second[i].behavior->textid[j-zeroCount] = pmItr->second[i].behavior->textid[j];
pmItr->second[i].behavior->textid[j] = 0;
}
}
}
}
}
}

View file

@ -76,6 +76,7 @@ class WaypointManager
void DeletePath(uint32 id);
void SetNodePosition(uint32 id, uint32 point, float x, float y, float z);
void SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text);
void CheckTextsExistance(std::set<int32>& ids);
private:
void _addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6838"
#define REVISION_NR "6841"
#endif // __REVISION_NR_H__