diff --git a/sql/characters.sql b/sql/characters.sql index 470f77545..bfa6ec967 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_7324_02_characters_character_aura` bit(1) default NULL + `required_7546_01_characters_uptime` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- diff --git a/sql/mangos.sql b/sql/mangos.sql index 574570af3..3c1e671eb 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -22,7 +22,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `version` varchar(120) default NULL, - `required_7536_01_mangos_spell_chain` bit(1) default NULL + `required_7544_01_mangos_uptime` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -17851,28 +17851,6 @@ LOCK TABLES `transports` WRITE; /*!40000 ALTER TABLE `transports` DISABLE KEYS */; /*!40000 ALTER TABLE `transports` ENABLE KEYS */; UNLOCK TABLES; - --- --- Table structure for table `uptime` --- - -DROP TABLE IF EXISTS `uptime`; -CREATE TABLE `uptime` ( - `starttime` bigint(20) unsigned NOT NULL default '0', - `startstring` varchar(64) NOT NULL default '', - `uptime` bigint(20) unsigned NOT NULL default '0', - `maxplayers` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`starttime`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; - --- --- Dumping data for table `uptime` --- - -LOCK TABLES `uptime` WRITE; -/*!40000 ALTER TABLE `uptime` DISABLE KEYS */; -/*!40000 ALTER TABLE `uptime` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/sql/realmd.sql b/sql/realmd.sql index 4d08c776a..ee8e023f1 100644 --- a/sql/realmd.sql +++ b/sql/realmd.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `realmd_db_version`; CREATE TABLE `realmd_db_version` ( - `required_6976_01_realmd_realmd_db_version` bit(1) default NULL + `required_7546_02_realmd_uptime` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -174,6 +174,29 @@ INSERT INTO `realmlist` VALUES (1,'MaNGOS','127.0.0.1',8085,1,0,1,0,0); /*!40000 ALTER TABLE `realmlist` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Table structure for table `uptime` +-- + +DROP TABLE IF EXISTS `uptime`; +CREATE TABLE `uptime` ( + `realmid` int(11) unsigned NOT NULL, + `starttime` bigint(20) unsigned NOT NULL default '0', + `startstring` varchar(64) NOT NULL default '', + `uptime` bigint(20) unsigned NOT NULL default '0', + `maxplayers` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`realmid`,`starttime`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; + +-- +-- Dumping data for table `uptime` +-- + +LOCK TABLES `uptime` WRITE; +/*!40000 ALTER TABLE `uptime` DISABLE KEYS */; +/*!40000 ALTER TABLE `uptime` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/sql/updates/7544_01_mangos_uptime.sql b/sql/updates/7544_01_mangos_uptime.sql new file mode 100644 index 000000000..223f3f630 --- /dev/null +++ b/sql/updates/7544_01_mangos_uptime.sql @@ -0,0 +1,3 @@ +ALTER TABLE db_version CHANGE COLUMN required_7536_01_mangos_spell_chain required_7544_01_mangos_uptime bit; + +DROP TABLE IF EXISTS `uptime`; \ No newline at end of file diff --git a/sql/updates/7544_02_characters_uptime.sql b/sql/updates/7544_02_characters_uptime.sql new file mode 100644 index 000000000..5251056a7 --- /dev/null +++ b/sql/updates/7544_02_characters_uptime.sql @@ -0,0 +1,14 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_7324_02_characters_character_aura required_7544_02_characters_uptime bit; + +-- +-- Table structure for table `uptime` +-- + +DROP TABLE IF EXISTS `uptime`; +CREATE TABLE `uptime` ( + `starttime` bigint(20) unsigned NOT NULL default '0', + `startstring` varchar(64) NOT NULL default '', + `uptime` bigint(20) unsigned NOT NULL default '0', + `maxplayers` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`starttime`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; diff --git a/sql/updates/7546_01_characters_uptime.sql b/sql/updates/7546_01_characters_uptime.sql new file mode 100644 index 000000000..51d7c4ccf --- /dev/null +++ b/sql/updates/7546_01_characters_uptime.sql @@ -0,0 +1,3 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_7544_02_characters_uptime required_7546_01_characters_uptime bit; + +DROP TABLE IF EXISTS `uptime`; \ No newline at end of file diff --git a/sql/updates/7546_02_realmd_uptime.sql b/sql/updates/7546_02_realmd_uptime.sql new file mode 100644 index 000000000..a53b0f95f --- /dev/null +++ b/sql/updates/7546_02_realmd_uptime.sql @@ -0,0 +1,16 @@ +ALTER TABLE realmd_db_version CHANGE COLUMN required_6976_01_realmd_realmd_db_version required_7546_02_realmd_uptime bit; + + +-- +-- Table structure for table `uptime` +-- + +DROP TABLE IF EXISTS `uptime`; +CREATE TABLE `uptime` ( + `realmid` int(11) unsigned NOT NULL, + `starttime` bigint(20) unsigned NOT NULL default '0', + `startstring` varchar(64) NOT NULL default '', + `uptime` bigint(20) unsigned NOT NULL default '0', + `maxplayers` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`realmid`,`starttime`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index c770d6133..af1ec8f82 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -202,6 +202,10 @@ pkgdata_DATA = \ 7495_01_mangos_mangos_string.sql \ 7503_01_mangos_command.sql \ 7536_01_mangos_spell_chain.sql \ + 7544_01_mangos_uptime.sql \ + 7544_02_characters_uptime.sql \ + 7546_01_characters_uptime.sql \ + 7546_02_realmd_uptime.sql \ README ## Additional files to include when running 'make dist' @@ -384,4 +388,8 @@ EXTRA_DIST = \ 7495_01_mangos_mangos_string.sql \ 7503_01_mangos_command.sql \ 7536_01_mangos_spell_chain.sql \ + 7544_01_mangos_uptime.sql \ + 7544_02_characters_uptime.sql \ + 7546_01_characters_uptime.sql \ + 7546_02_realmd_uptime.sql \ README diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index edc8a708c..4efed7c97 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -20,7 +20,7 @@ #include "Common.h" #include "Player.h" #include "WorldPacket.h" -#include "Database/DBCEnums.h" +#include "DBCEnums.h" #include "GameEventMgr.h" #include "ObjectMgr.h" #include "Guild.h" @@ -725,14 +725,24 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(!worldOverlayEntry) break; - int32 exploreFlag = GetAreaFlagByAreaID(worldOverlayEntry->areatableID); - if(exploreFlag < 0) - break; + bool matchFound = false; + for (int i = 0; i < 3; ++i) + { + int32 exploreFlag = GetAreaFlagByAreaID(worldOverlayEntry->areatableID[i]); + if(exploreFlag < 0) + break; - uint32 playerIndexOffset = uint32(exploreFlag) / 32; - uint32 mask = 1<< (uint32(exploreFlag) % 32); + uint32 playerIndexOffset = uint32(exploreFlag) / 32; + uint32 mask = 1<< (uint32(exploreFlag) % 32); - if(GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask) + if(GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask) + { + matchFound = true; + break; + } + } + + if(matchFound) SetCriteriaProgress(achievementCriteria, 1); break; } @@ -752,18 +762,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION: { - // skip faction check only at loading - if (miscvalue1 && GetPlayer()->GetReputationRank(miscvalue1) < REP_EXALTED) - continue; - - uint32 counter = 0; - FactionStateList const& factionStateList = GetPlayer()->GetReputationMgr().GetStateList(); - for (FactionStateList::const_iterator iter = factionStateList.begin(); iter!= factionStateList.end(); ++iter) - if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(iter->second.ID)) - if(ReputationMgr::ReputationToRank(iter->second.Standing + GetPlayer()->GetReputationMgr().GetBaseReputation(factionEntry)) >= REP_EXALTED) - ++counter; - - SetCriteriaProgress(achievementCriteria, counter); + SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetExaltedFactionCount()); break; } case ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP: @@ -856,6 +855,15 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui SetCriteriaProgress(achievementCriteria, spellCount); break; } + case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION: + SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetReveredFactionCount()); + break; + case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION: + SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetHonoredFactionCount()); + break; + case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS: + SetCriteriaProgress(achievementCriteria, GetPlayer()->GetReputationMgr().GetVisibleFactionCount()); + break; case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: { if (!miscvalue1 || miscvalue1 != achievementCriteria->cast_spell.spellID) @@ -920,9 +928,6 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION: case ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED: - case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION: - case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION: - case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS: case ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM: case ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM: case ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED: @@ -1057,6 +1062,9 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: + case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION: + case ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION: + case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALTH: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_SPELLPOWER: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_ARMOR: diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index af637bcc2..d355023d6 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -20,9 +20,9 @@ #include "Common.h" #include "Policies/Singleton.h" -#include "Database/DBCEnums.h" -#include "Database/DBCStores.h" #include "Database/DatabaseEnv.h" +#include "DBCEnums.h" +#include "DBCStores.h" #include #include diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 84457c570..8a2f838ba 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -18,8 +18,8 @@ #include "Common.h" #include "Database/DatabaseEnv.h" -#include "Database/DBCStores.h" #include "Database/SQLStorage.h" +#include "DBCStores.h" #include "ProgressBar.h" #include "AccountMgr.h" diff --git a/src/shared/Database/DBCEnums.h b/src/game/DBCEnums.h similarity index 100% rename from src/shared/Database/DBCEnums.h rename to src/game/DBCEnums.h diff --git a/src/shared/Database/DBCStores.cpp b/src/game/DBCStores.cpp similarity index 99% rename from src/shared/Database/DBCStores.cpp rename to src/game/DBCStores.cpp index 4b8b1d69f..816712c5b 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -17,12 +17,11 @@ */ #include "DBCStores.h" -//#include "DataStore.h" #include "Policies/SingletonImp.h" #include "Log.h" #include "ProgressBar.h" -#include "DBCfmt.cpp" +#include "DBCfmt.h" #include @@ -157,7 +156,7 @@ template inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, const std::string& dbc_path, const std::string& filename) { // compatibility format and C++ structure sizes - assert(DBCFile::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFile::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); + assert(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); std::string dbc_filename = dbc_path + filename; if(storage.Load(dbc_filename.c_str())) diff --git a/src/shared/Database/DBCStores.h b/src/game/DBCStores.h similarity index 79% rename from src/shared/Database/DBCStores.h rename to src/game/DBCStores.h index a87d21d23..519c97733 100644 --- a/src/shared/Database/DBCStores.h +++ b/src/game/DBCStores.h @@ -16,12 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCSTORES_H -#define DBCSTORES_H +#ifndef MANGOS_DBCSTORES_H +#define MANGOS_DBCSTORES_H #include "Common.h" -//#include "DataStore.h" -#include "dbcfile.h" +#include "Database/DBCStore.h" #include "DBCStructure.h" #include @@ -57,77 +56,6 @@ void Map2ZoneCoordinates(float& x,float& y,uint32 zone); uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls); -template -class DBCStorage -{ - typedef std::list StringPoolList; - public: - explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { } - ~DBCStorage() { Clear(); } - - T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; } - uint32 GetNumRows() const { return nCount; } - char const* GetFormat() const { return fmt; } - uint32 GetFieldCount() const { return fieldCount; } - - bool Load(char const* fn) - { - DBCFile dbc; - // Check if load was sucessful, only then continue - if(!dbc.Load(fn, fmt)) - return false; - - fieldCount = dbc.GetCols(); - m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable); - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); - - // error in dbc file at loading if NULL - return indexTable!=NULL; - } - - bool LoadStringsFrom(char const* fn) - { - // DBC must be already loaded using Load - if(!indexTable) - return false; - - DBCFile dbc; - // Check if load was successful, only then continue - if(!dbc.Load(fn, fmt)) - return false; - - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); - - return true; - } - - void Clear() - { - if (!indexTable) - return; - - delete[] ((char*)indexTable); - indexTable = NULL; - delete[] ((char*)m_dataTable); - m_dataTable = NULL; - - while(!m_stringPoolList.empty()) - { - delete[] m_stringPoolList.front(); - m_stringPoolList.pop_front(); - } - nCount = 0; - } - - private: - uint32 nCount; - uint32 fieldCount; - char const* fmt; - T** indexTable; - T* m_dataTable; - StringPoolList m_stringPoolList; -}; - extern DBCStorage sAchievementStore; extern DBCStorage sAchievementCriteriaStore; extern DBCStorage sAreaStore;// recommend access using functions diff --git a/src/shared/Database/DBCStructure.h b/src/game/DBCStructure.h similarity index 99% rename from src/shared/Database/DBCStructure.h rename to src/game/DBCStructure.h index fb0e01faf..beb0b2070 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCSTRUCTURE_H -#define DBCSTRUCTURE_H +#ifndef MANGOS_DBCSTRUCTURE_H +#define MANGOS_DBCSTRUCTURE_H #include "DBCEnums.h" #include "Platform/Define.h" @@ -1618,7 +1618,7 @@ struct WorldSafeLocsEntry struct WorldMapOverlayEntry { uint32 ID; // 0 - uint32 areatableID; // 2 + uint32 areatableID[4]; // 2-5 }; // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform diff --git a/src/shared/Database/DBCfmt.cpp b/src/game/DBCfmt.h similarity index 98% rename from src/shared/Database/DBCfmt.cpp rename to src/game/DBCfmt.h index 55a47d2f3..748c59f2c 100644 --- a/src/shared/Database/DBCfmt.cpp +++ b/src/game/DBCfmt.h @@ -16,6 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef MANGOS_DBCSFRM_H +#define MANGOS_DBCSFRM_H + const char Achievementfmt[]="niixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxxi"; const char AchievementCriteriafmt[]="niiiiiiiixxxxxxxxxxxxxxxxxiixix"; const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx"; @@ -96,4 +99,6 @@ const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx"; const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx"; const char WorldMapAreaEntryfmt[]="xinxffffix"; const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx"; -const char WorldMapOverlayEntryfmt[]="nxixxxxxxxxxxxxxx"; +const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx"; + +#endif \ No newline at end of file diff --git a/src/game/HostilRefManager.cpp b/src/game/HostilRefManager.cpp index 149f91494..5b1f83787 100644 --- a/src/game/HostilRefManager.cpp +++ b/src/game/HostilRefManager.cpp @@ -19,7 +19,7 @@ #include "HostilRefManager.h" #include "ThreatManager.h" #include "Unit.h" -#include "Database/DBCStructure.h" +#include "DBCStructure.h" #include "SpellMgr.h" HostilRefManager::~HostilRefManager() diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 67e13ba9a..a249c66a2 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -2066,7 +2066,7 @@ bool ChatHandler::HandleModifyMorphCommand(const char* args) //kick player bool ChatHandler::HandleKickPlayerCommand(const char *args) { - if (!args) + if (!*args) { Player* player = getSelectedPlayer(); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index df24f4eec..b8395c3be 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3556,7 +3556,7 @@ bool ChatHandler::HandleNpcAllowMovementCommand(const char* /*args*/) bool ChatHandler::HandleNpcChangeEntryCommand(const char *args) { - if(!args) + if (!*args) return false; uint32 newEntryNum = atoi(args); @@ -5047,7 +5047,7 @@ bool ChatHandler::HandleBanIPCommand(const char* args) bool ChatHandler::HandleBanHelper(BanMode mode, const char* args) { - if(!args) + if (!*args) return false; char* cnameOrIP = strtok ((char*)args, " "); @@ -5135,7 +5135,7 @@ bool ChatHandler::HandleUnBanIPCommand(const char* args) bool ChatHandler::HandleUnBanHelper(BanMode mode, const char* args) { - if(!args) + if (!*args) return false; char* cnameOrIP = strtok ((char*)args, " "); @@ -5178,7 +5178,7 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, const char* args) bool ChatHandler::HandleBanInfoAccountCommand(const char* args) { - if(!args) + if (!*args) return false; char* cname = strtok((char*)args, ""); @@ -5205,7 +5205,7 @@ bool ChatHandler::HandleBanInfoAccountCommand(const char* args) bool ChatHandler::HandleBanInfoCharacterCommand(const char* args) { - if(!args) + if (!*args) return false; std::string name = extractPlayerNameFromLink((char*)args); @@ -5264,7 +5264,7 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) bool ChatHandler::HandleBanInfoIPCommand(const char* args) { - if(!args) + if (!*args) return false; char* cIP = strtok ((char*)args, ""); @@ -5533,7 +5533,7 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/) bool ChatHandler::HandleGMFlyModeCommand(const char* args) { - if(!args) + if (!*args) return false; Player *target = getSelectedPlayer(); @@ -5559,7 +5559,7 @@ bool ChatHandler::HandleGMFlyModeCommand(const char* args) bool ChatHandler::HandlePDumpLoadCommand(const char *args) { - if(!args) + if (!*args) return false; char * file = strtok((char*)args, " "); @@ -5670,7 +5670,7 @@ bool ChatHandler::HandlePDumpLoadCommand(const char *args) bool ChatHandler::HandlePDumpWriteCommand(const char *args) { - if(!args) + if (!*args) return false; char* file = strtok((char*)args, " "); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 912ead72c..78043d900 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -27,7 +27,7 @@ #include "UpdateMask.h" #include "Unit.h" #include "Language.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" void MailItem::deleteItem( bool inDB ) { diff --git a/src/game/Makefile.am b/src/game/Makefile.am index 5ad352163..ca21eab63 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -97,6 +97,11 @@ libmangosgame_a_SOURCES = \ CreatureAISelector.h \ Creature.cpp \ Creature.h \ + DBCEnums.h \ + DBCfmt.h \ + DBCStores.cpp \ + DBCStores.h \ + DBCStructure.h \ debugcmds.cpp \ DestinationHolder.cpp \ DestinationHolder.h \ diff --git a/src/game/Map.h b/src/game/Map.h index ca027b8ec..e0739c423 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -24,7 +24,7 @@ #include "zthread/Lockable.h" #include "zthread/Mutex.h" #include "zthread/FairReadWriteLock.h" -#include "Database/DBCStructure.h" +#include "DBCStructure.h" #include "GridDefines.h" #include "Cell.h" #include "Object.h" diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 424af420e..4d2734c5a 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -20,7 +20,7 @@ #include "Errors.h" #include "Pet.h" #include "Player.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "Spell.h" #include "ObjectAccessor.h" #include "SpellMgr.h" diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 351ed3c99..3b09f1cf6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -343,8 +343,6 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa m_DailyQuestChanged = false; m_lastDailyQuestTime = 0; - m_regenTimer = 0; - m_weaponChangeTimer = 0; for (int i=0; im_Last_tick) UpdateItemDuration(uint32(now- m_Last_tick)); @@ -17454,13 +17450,14 @@ void Player::LeaveBattleground(bool teleportToEntryPoint) { if(BattleGround *bg = GetBattleGround()) { - bool need_debuf = bg->isBattleGround() && (bg->GetStatus() == STATUS_IN_PROGRESS) && sWorld.getConfig(CONFIG_BATTLEGROUND_CAST_DESERTER); - bg->RemovePlayerAtLeave(GetGUID(), teleportToEntryPoint, true); // call after remove to be sure that player resurrected for correct cast - if(need_debuf) - CastSpell(this, 26013, true); // Deserter + if( bg->isBattleGround() && sWorld.getConfig(CONFIG_BATTLEGROUND_CAST_DESERTER) ) + { + if( bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN ) + CastSpell(this, 26013, true); // Deserter + } } } diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp index 872bc06f2..15854fef9 100644 --- a/src/game/ReputationMgr.cpp +++ b/src/game/ReputationMgr.cpp @@ -17,7 +17,7 @@ */ #include "ReputationMgr.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "Player.h" #include "WorldPacket.h" @@ -198,6 +198,10 @@ void ReputationMgr::SendVisible(FactionState const* faction) const void ReputationMgr::Initilize() { m_factions.clear(); + m_visibleFactionCount = 0; + m_honoredFactionCount = 0; + m_reveredFactionCount = 0; + m_exaltedFactionCount = 0; for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++) { @@ -212,12 +216,17 @@ void ReputationMgr::Initilize() newFaction.Flags = GetDefaultStateFlags(factionEntry); newFaction.Changed = true; + if( newFaction.Flags & FACTION_FLAG_VISIBLE ) + ++m_visibleFactionCount; + + UpdateRankCounters(REP_HOSTILE,GetBaseRank(factionEntry)); + m_factions[newFaction.ReputationListID] = newFaction; } } } -bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing) +bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) { SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); if (flist) @@ -227,89 +236,50 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi { FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); if(factionEntryCalc) - res = SetOneFactionReputation(factionEntryCalc, standing); + res = SetOneFactionReputation(factionEntryCalc, standing, incremental); } return res; } else - return SetOneFactionReputation(factionEntry, standing); + return SetOneFactionReputation(factionEntry, standing, incremental); } -bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing) +bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental) { FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); if (itr != m_factions.end()) { + int32 BaseRep = GetBaseReputation(factionEntry); + + if(incremental) + standing += itr->second.Standing + BaseRep; + if (standing > Reputation_Cap) standing = Reputation_Cap; - else - if (standing < Reputation_Bottom) - standing = Reputation_Bottom; + else if (standing < Reputation_Bottom) + standing = Reputation_Bottom; + + ReputationRank old_rank = ReputationToRank(itr->second.Standing + BaseRep); + ReputationRank new_rank = ReputationToRank(standing); - int32 BaseRep = GetBaseReputation(factionEntry); itr->second.Standing = standing - BaseRep; itr->second.Changed = true; SetVisible(&itr->second); - if(ReputationToRank(standing) <= REP_HOSTILE) + if(new_rank <= REP_HOSTILE) SetAtWar(&itr->second,true); SendState(&itr->second); - m_player->ReputationChanged(factionEntry); - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID); - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID); - return true; - } - return false; -} - -bool ReputationMgr::ModifyReputation(FactionEntry const* factionEntry, int32 standing) -{ - SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); - if (flist) - { - bool res = false; - for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr) - { - FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); - if(factionEntryCalc) - res = ModifyOneFactionReputation(factionEntryCalc, standing); - } - return res; - } - else - return ModifyOneFactionReputation(factionEntry, standing); -} - -bool ReputationMgr::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing) -{ - FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr != m_factions.end()) - { - int32 BaseRep = GetBaseReputation(factionEntry); - int32 new_rep = BaseRep + itr->second.Standing + standing; - - if (new_rep > Reputation_Cap) - new_rep = Reputation_Cap; - else - if (new_rep < Reputation_Bottom) - new_rep = Reputation_Bottom; - - if(ReputationToRank(new_rep) <= REP_HOSTILE) - SetAtWar(&itr->second,true); - - itr->second.Standing = new_rep - BaseRep; - itr->second.Changed = true; - - SetVisible(&itr->second); - SendState(&itr->second); + UpdateRankCounters(old_rank, new_rank); m_player->ReputationChanged(factionEntry); - - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID); m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION,factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION,factionEntry->ID); return true; } @@ -350,6 +320,8 @@ void ReputationMgr::SetVisible(FactionState* faction) faction->Flags |= FACTION_FLAG_VISIBLE; faction->Changed = true; + ++m_visibleFactionCount; + SendVisible(faction); } @@ -432,6 +404,12 @@ void ReputationMgr::LoadFromDB(QueryResult *result) // update standing to current faction->Standing = int32(fields[1].GetUInt32()); + // update counters + int32 BaseRep = GetBaseReputation(factionEntry); + ReputationRank old_rank = ReputationToRank(BaseRep); + ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing); + UpdateRankCounters(old_rank,new_rank); + uint32 dbFactionFlags = fields[2].GetUInt32(); if( dbFactionFlags & FACTION_FLAG_VISIBLE ) @@ -478,3 +456,20 @@ void ReputationMgr::SaveToDB() } CharacterDatabase.CommitTransaction(); } + +void ReputationMgr::UpdateRankCounters( ReputationRank old_rank, ReputationRank new_rank ) +{ + if(old_rank >= REP_EXALTED) + --m_exaltedFactionCount; + if(old_rank >= REP_REVERED) + --m_reveredFactionCount; + if(old_rank >= REP_HONORED) + --m_honoredFactionCount; + + if(new_rank >= REP_EXALTED) + ++m_exaltedFactionCount; + if(new_rank >= REP_REVERED) + ++m_reveredFactionCount; + if(new_rank >= REP_HONORED) + ++m_honoredFactionCount; +} \ No newline at end of file diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h index edc60edfd..b81634119 100644 --- a/src/game/ReputationMgr.h +++ b/src/game/ReputationMgr.h @@ -21,7 +21,7 @@ #include "Common.h" #include "SharedDefines.h" -#include "Database/DBCStructure.h" +#include "DBCStructure.h" #include enum FactionFlags @@ -56,7 +56,8 @@ class QueryResult; class ReputationMgr { public: // constructors and global modifiers - explicit ReputationMgr(Player* owner) : m_player(owner) {} + explicit ReputationMgr(Player* owner) : m_player(owner), + m_visibleFactionCount(0), m_honoredFactionCount(0), m_reveredFactionCount(0), m_exaltedFactionCount(0) {} ~ReputationMgr() {} void SaveToDB(); @@ -68,6 +69,11 @@ class ReputationMgr static ReputationRank ReputationToRank(int32 standing); public: // accessors + uint8 GetVisibleFactionCount() const { return m_visibleFactionCount; } + uint8 GetHonoredFactionCount() const { return m_honoredFactionCount; } + uint8 GetReveredFactionCount() const { return m_reveredFactionCount; } + uint8 GetExaltedFactionCount() const { return m_exaltedFactionCount; } + FactionStateList const& GetStateList() const { return m_factions; } FactionState const* GetState(FactionEntry const* factionEntry) const @@ -95,8 +101,14 @@ class ReputationMgr } public: // modifiers - bool SetReputation(FactionEntry const* factionEntry, int32 standing); - bool ModifyReputation(FactionEntry const* factionEntry, int32 standing); + bool SetReputation(FactionEntry const* factionEntry, int32 standing) + { + return SetReputation(factionEntry, standing, false); + } + bool ModifyReputation(FactionEntry const* factionEntry, int32 standing) + { + return SetReputation(factionEntry, standing, true); + } void SetVisible(FactionTemplateEntry const* factionTemplateEntry); void SetVisible(FactionEntry const* factionEntry); @@ -114,16 +126,21 @@ class ReputationMgr private: // internal helper functions void Initilize(); uint32 GetDefaultStateFlags(const FactionEntry *factionEntry) const; - bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing); - bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing); + bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); + bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); void SetVisible(FactionState* faction); void SetAtWar(FactionState* faction, bool atWar); void SetInactive(FactionState* faction, bool inactive); void SendVisible(FactionState const* faction) const; + void UpdateRankCounters( ReputationRank old_rank, ReputationRank new_rank ); private: Player* m_player; FactionStateList m_factions; ForcedReactions m_forcedReactions; + uint8 m_visibleFactionCount :8; + uint8 m_honoredFactionCount :8; + uint8 m_reveredFactionCount :8; + uint8 m_exaltedFactionCount :8; }; #endif diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 46b861b69..19b7d2b99 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -17,7 +17,7 @@ */ #include "Common.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "WorldPacket.h" #include "WorldSession.h" #include "ObjectMgr.h" diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 875459fc0..7ef35a593 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -20,7 +20,7 @@ #include "ObjectMgr.h" #include "SpellAuraDefines.h" #include "ProgressBar.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "World.h" #include "Chat.h" #include "Spell.h" diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 5e068887e..d026ccb36 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -23,7 +23,7 @@ // For more high level function for sSpellStore data #include "SharedDefines.h" -#include "Database/DBCStructure.h" +#include "DBCStructure.h" #include "Database/SQLStorage.h" #include "Utilities/UnorderedMap.h" diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index b91020a23..f10d75039 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -19,7 +19,7 @@ #include "TotemAI.h" #include "Totem.h" #include "Creature.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "ObjectAccessor.h" #include "SpellMgr.h" diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 190467688..97bb68ae3 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -24,7 +24,7 @@ #include "Path.h" #include "WorldPacket.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "ProgressBar.h" void MapManager::LoadTransports() diff --git a/src/game/Unit.h b/src/game/Unit.h index 3b6013701..0c618a4d9 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -31,7 +31,7 @@ #include "FollowerRefManager.h" #include "Utilities/EventProcessor.h" #include "MotionMaster.h" -#include "Database/DBCStructure.h" +#include "DBCStructure.h" #include enum SpellInterruptFlags diff --git a/src/game/World.cpp b/src/game/World.cpp index 364147e4e..0adec7ac1 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -40,7 +40,7 @@ #include "ObjectMgr.h" #include "SpellMgr.h" #include "Chat.h" -#include "Database/DBCStores.h" +#include "DBCStores.h" #include "LootMgr.h" #include "ItemEnchantmentMgr.h" #include "MapManager.h" @@ -1367,8 +1367,8 @@ void World::SetInitialWorldSettings() sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); - WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', " I64FMTD ", 0)", - isoDate, uint64(m_startTime)); + loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " I64FMTD ", '%s', 0)", + realmID, uint64(m_startTime), isoDate); m_timers[WUPDATE_OBJECTS].SetInterval(0); m_timers[WUPDATE_SESSIONS].SetInterval(0); @@ -1534,10 +1534,10 @@ void World::Update(uint32 diff) if (m_timers[WUPDATE_UPTIME].Passed()) { uint32 tmpDiff = (m_gameTime - m_startTime); - uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); + uint32 maxClientsNum = GetMaxActiveSessionCount(); m_timers[WUPDATE_UPTIME].Reset(); - WorldDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d WHERE starttime = " I64FMTD, tmpDiff, maxClientsNum, uint64(m_startTime)); + loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " I64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime)); } ///
  • Handle all other objects diff --git a/src/shared/Database/dbcfile.cpp b/src/shared/Database/DBCFileLoader.cpp similarity index 93% rename from src/shared/Database/dbcfile.cpp rename to src/shared/Database/DBCFileLoader.cpp index 519e77de7..719138aff 100644 --- a/src/shared/Database/dbcfile.cpp +++ b/src/shared/Database/DBCFileLoader.cpp @@ -20,15 +20,15 @@ #include #include -#include "dbcfile.h" +#include "DBCFileLoader.h" -DBCFile::DBCFile() +DBCFileLoader::DBCFileLoader() { data = NULL; fieldsOffset = NULL; } -bool DBCFile::Load(const char *filename, const char *fmt) +bool DBCFileLoader::Load(const char *filename, const char *fmt) { uint32 header; @@ -89,7 +89,7 @@ bool DBCFile::Load(const char *filename, const char *fmt) return true; } -DBCFile::~DBCFile() +DBCFileLoader::~DBCFileLoader() { if(data) delete [] data; @@ -97,13 +97,13 @@ DBCFile::~DBCFile() delete [] fieldsOffset; } -DBCFile::Record DBCFile::getRecord(size_t id) +DBCFileLoader::Record DBCFileLoader::getRecord(size_t id) { assert(data); return Record(*this, data + id*recordSize); } -uint32 DBCFile::GetFormatRecordSize(const char * format,int32* index_pos) +uint32 DBCFileLoader::GetFormatRecordSize(const char * format,int32* index_pos) { uint32 recordsize = 0; int32 i = -1; @@ -135,7 +135,7 @@ uint32 DBCFile::GetFormatRecordSize(const char * format,int32* index_pos) return recordsize; } -char* DBCFile::AutoProduceData(const char* format, uint32& records, char**& indexTable) +char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**& indexTable) { /* format STRING, NA, FLOAT,NA,INT <=> @@ -218,7 +218,7 @@ char* DBCFile::AutoProduceData(const char* format, uint32& records, char**& inde return dataTable; } -char* DBCFile::AutoProduceStrings(const char* format, char* dataTable) +char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable) { if(strlen(format)!=fieldCount) return NULL; diff --git a/src/shared/Database/dbcfile.h b/src/shared/Database/DBCFileLoader.h similarity index 92% rename from src/shared/Database/dbcfile.h rename to src/shared/Database/DBCFileLoader.h index 74e6b6f3f..13562148d 100644 --- a/src/shared/Database/dbcfile.h +++ b/src/shared/Database/DBCFileLoader.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DBCFILE_H -#define DBCFILE_H +#ifndef DBC_FILE_LOADER_H +#define DBC_FILE_LOADER_H #include "Platform/Define.h" #include "Utilities/ByteConverter.h" #include @@ -35,11 +35,11 @@ enum FT_LOGIC='l' //Logical (boolean) }; -class DBCFile +class DBCFileLoader { public: - DBCFile(); - ~DBCFile(); + DBCFileLoader(); + ~DBCFileLoader(); bool Load(const char *filename, const char *fmt); @@ -75,11 +75,11 @@ class DBCFile } private: - Record(DBCFile &file_, unsigned char *offset_): offset(offset_), file(file_) {} + Record(DBCFileLoader &file_, unsigned char *offset_): offset(offset_), file(file_) {} unsigned char *offset; - DBCFile &file; + DBCFileLoader &file; - friend class DBCFile; + friend class DBCFileLoader; }; diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h new file mode 100644 index 000000000..523d5c5a0 --- /dev/null +++ b/src/shared/Database/DBCStore.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef DBCSTORE_H +#define DBCSTORE_H + +#include "DBCFileLoader.h" + +template +class DBCStorage +{ + typedef std::list StringPoolList; + public: + explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { } + ~DBCStorage() { Clear(); } + + T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; } + uint32 GetNumRows() const { return nCount; } + char const* GetFormat() const { return fmt; } + uint32 GetFieldCount() const { return fieldCount; } + + bool Load(char const* fn) + { + DBCFileLoader dbc; + // Check if load was sucessful, only then continue + if(!dbc.Load(fn, fmt)) + return false; + + fieldCount = dbc.GetCols(); + m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable); + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + + // error in dbc file at loading if NULL + return indexTable!=NULL; + } + + bool LoadStringsFrom(char const* fn) + { + // DBC must be already loaded using Load + if(!indexTable) + return false; + + DBCFileLoader dbc; + // Check if load was successful, only then continue + if(!dbc.Load(fn, fmt)) + return false; + + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + + return true; + } + + void Clear() + { + if (!indexTable) + return; + + delete[] ((char*)indexTable); + indexTable = NULL; + delete[] ((char*)m_dataTable); + m_dataTable = NULL; + + while(!m_stringPoolList.empty()) + { + delete[] m_stringPoolList.front(); + m_stringPoolList.pop_front(); + } + nCount = 0; + } + + private: + uint32 nCount; + uint32 fieldCount; + char const* fmt; + T** indexTable; + T* m_dataTable; + StringPoolList m_stringPoolList; +}; +#endif diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h index a446aee41..e2b6fdc0f 100644 --- a/src/shared/Database/DatabaseEnv.h +++ b/src/shared/Database/DatabaseEnv.h @@ -23,7 +23,6 @@ #include "Log.h" #include "Errors.h" -#include "Database/DBCStores.h" #include "Database/Field.h" #include "Database/QueryResult.h" diff --git a/src/shared/Database/Makefile.am b/src/shared/Database/Makefile.am index f9de9576f..40ee034ce 100644 --- a/src/shared/Database/Makefile.am +++ b/src/shared/Database/Makefile.am @@ -27,10 +27,9 @@ AM_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(sr noinst_LIBRARIES = libmangosdatabase.a libmangosdatabase_a_SOURCES = \ - DBCStores.cpp \ - DBCStores.h \ - DBCStructure.h \ - DBCfmt.cpp \ + DBCFileLoader.cpp \ + DBCFileLoader.h \ + DBCStore.h \ Database.cpp \ Database.h \ DatabaseEnv.h \ @@ -59,6 +58,4 @@ libmangosdatabase_a_SOURCES = \ SqlDelayThread.cpp \ SqlDelayThread.h \ SqlOperations.cpp \ - SqlOperations.h \ - dbcfile.cpp \ - dbcfile.h + SqlOperations.h diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h index c65f9a9e2..bfc8c2c21 100644 --- a/src/shared/Database/SQLStorageImpl.h +++ b/src/shared/Database/SQLStorageImpl.h @@ -18,7 +18,7 @@ #include "ProgressBar.h" #include "Log.h" -#include "dbcfile.h" +#include "DBCFileLoader.h" template template diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 46cde255f..6b2099499 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7542" + #define REVISION_NR "7552" #endif // __REVISION_NR_H__ diff --git a/win/VC71/game.vcproj b/win/VC71/game.vcproj index c9ade4015..d24fd6aa5 100644 --- a/win/VC71/game.vcproj +++ b/win/VC71/game.vcproj @@ -798,6 +798,21 @@ + + + + + + + + + + diff --git a/win/VC71/shared.vcproj b/win/VC71/shared.vcproj index ca5d535b8..b642f2aa3 100644 --- a/win/VC71/shared.vcproj +++ b/win/VC71/shared.vcproj @@ -198,37 +198,13 @@ + RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp"> + RelativePath="..\..\src\shared\Database\DBCFileLoader.h"> - - - - - - - - - - - - - - + RelativePath="..\..\src\shared\Database\DBCStore.h"> diff --git a/win/VC80/game.vcproj b/win/VC80/game.vcproj index f0721a841..0c754fde8 100644 --- a/win/VC80/game.vcproj +++ b/win/VC80/game.vcproj @@ -1238,6 +1238,26 @@ + + + + + + + + + + diff --git a/win/VC80/shared.vcproj b/win/VC80/shared.vcproj index c81f23a60..6a0e9fdf8 100644 --- a/win/VC80/shared.vcproj +++ b/win/VC80/shared.vcproj @@ -440,63 +440,15 @@ Name="DataStores" > - - - - - - - - - - - - - - - - - - - - diff --git a/win/VC90/game.vcproj b/win/VC90/game.vcproj index 2ba06dc11..a3879fbdb 100644 --- a/win/VC90/game.vcproj +++ b/win/VC90/game.vcproj @@ -1240,6 +1240,26 @@ + + + + + + + + + + diff --git a/win/VC90/shared.vcproj b/win/VC90/shared.vcproj index 29e6d8bf1..51cc4375f 100644 --- a/win/VC90/shared.vcproj +++ b/win/VC90/shared.vcproj @@ -444,63 +444,15 @@ Name="DataStores" > - - - - - - - - - - - - - - - - - - - -