Skip to content

Commit

Permalink
Merge SPP
Browse files Browse the repository at this point in the history
  • Loading branch information
ConanHUN committed Oct 15, 2013
2 parents c280548 + 6e2794d commit 9a0410d
Show file tree
Hide file tree
Showing 48 changed files with 700 additions and 384 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ add_subdirectory(dep) # TODO: add vmap extractor build support

# Add definitions for all build types
# Don't place this above 'dep' subdirectory! Because of defines build will crash.
set(DEFINITIONS
DO_MYSQL
SYSCONFDIR="config/"
)
if (UNIX)
set(DEFINITIONS DO_MYSQL SYSCONFDIR="${CONF_DIR}/")
else()
set(DEFINITIONS DO_MYSQL SYSCONFDIR="config/")
endif()

set(DEFINITIONS_RELEASE NDEBUG)
set(DEFINITIONS_DEBUG _DEBUG MANGOS_DEBUG)
if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion Tools/update_new.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.6;108;http://www.ac-web.org/forums/showthread.php?179419-Single-Player-Project-Real-v2-(3-3-5a)&p=1951174&viewfull=1#post1951174
1.1.8;108;http://www.ac-web.org/forums/showthread.php?179419-Single-Player-Project-Real-v2-(3-3-5a)&p=1951174&viewfull=1#post1951174
1 change: 1 addition & 0 deletions src/game/AccountMgr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* Copyright (C) 2011-2013 MangosR2 <http://github.com/MangosR2>
*
* 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
Expand Down
13 changes: 11 additions & 2 deletions src/game/AccountMgr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005-2012 MaNGOS <http://getmangos.com/>
* Copyright (C) 2011-2013 MangosR2 <http://github.com/MangosR2>
*
* 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
Expand Down Expand Up @@ -47,9 +48,17 @@ struct PlayerDataCache

#define MAX_ACCOUNT_STR 16

typedef std::map<ObjectGuid, PlayerDataCache> PlayerDataCacheMap;
typedef UNORDERED_MAP<ObjectGuid, PlayerDataCache> PlayerDataCacheMap;
typedef std::vector<uint32> RafLinkedList;
typedef std::map<std::pair<uint32, bool>, RafLinkedList > RafLinkedMap;
typedef std::pair<uint32, bool> RafLinkedPair;
typedef UNORDERED_MAP<RafLinkedPair, RafLinkedList > RafLinkedMap;

HASH_NAMESPACE_START
template<> class hash <RafLinkedPair>
{
public: size_t operator()(const RafLinkedPair& __x) const { return (size_t)(uint32(__x.second) << 31) | (__x.first); }
};
HASH_NAMESPACE_END

class AccountMgr : public MaNGOS::Singleton<AccountMgr, MaNGOS::ClassLevelLockable<AccountMgr, ACE_Thread_Mutex> >
{
Expand Down
10 changes: 5 additions & 5 deletions src/game/AchievementMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct AchievementCriteriaEntry;
typedef std::list<AchievementCriteriaEntry const*> AchievementCriteriaEntryList;
typedef std::list<AchievementEntry const*> AchievementEntryList;

typedef std::map<uint32, AchievementCriteriaEntryList> AchievementCriteriaListByAchievement;
typedef std::map<uint32, AchievementEntryList> AchievementListByReferencedId;
typedef std::map<uint32, time_t> AchievementCriteriaFailTimeMap;
typedef UNORDERED_MAP<uint32, AchievementCriteriaEntryList> AchievementCriteriaListByAchievement;
typedef UNORDERED_MAP<uint32, AchievementEntryList> AchievementListByReferencedId;
typedef UNORDERED_MAP<uint32, time_t> AchievementCriteriaFailTimeMap;

struct CriteriaProgress
{
Expand Down Expand Up @@ -215,7 +215,7 @@ struct AchievementCriteriaRequirementSet
Storage storage;
};

typedef std::map<uint32, AchievementCriteriaRequirementSet> AchievementCriteriaRequirementMap;
typedef UNORDERED_MAP<uint32, AchievementCriteriaRequirementSet> AchievementCriteriaRequirementMap;

struct AchievementReward
{
Expand Down Expand Up @@ -336,7 +336,7 @@ class AchievementGlobalMgr
// store achievements by referenced achievement id to speed up lookup
AchievementListByReferencedId m_AchievementListByReferencedId;

typedef std::map<uint32, time_t> AllCompletedAchievements;
typedef UNORDERED_MAP<uint32, time_t> AllCompletedAchievements;
AllCompletedAchievements m_allCompletedAchievements;

AchievementRewardsMap m_achievementRewards;
Expand Down
2 changes: 1 addition & 1 deletion src/game/AuctionHouseMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void AuctionHouseMgr::LoadAuctions()

BarGoLink bar(AuctionCount);

typedef std::map<uint32, std::wstring> PlayerNames;
typedef UNORDERED_MAP<uint32, std::wstring> PlayerNames;
PlayerNames playerNames; // caching for load time

do
Expand Down
11 changes: 6 additions & 5 deletions src/game/BattleGround/BattleGroundIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void BattleGroundIC::Update(uint32 diff)

// gunship starting
if (node == BG_IC_NODE_HANGAR)
(teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->BuildStartMovePacket(GetBgMap());
(teamIndex == TEAM_INDEX_ALLIANCE ? gunshipAlliance : gunshipHorde)->Start();
}
}
}
Expand Down Expand Up @@ -593,7 +593,7 @@ void BattleGroundIC::EventPlayerClickedOnFlag(Player *source, GameObject* target
sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_IC_SOUND_NODE_ASSAULTED_ALLIANCE : BG_IC_SOUND_NODE_ASSAULTED_HORDE;

if (node == BG_IC_NODE_HANGAR)
(teamIndex == TEAM_INDEX_ALLIANCE ? gunshipHorde : gunshipAlliance)->BuildStopMovePacket(GetBgMap());
(teamIndex == TEAM_INDEX_ALLIANCE ? gunshipHorde : gunshipAlliance)->Stop();
}
PlaySoundToAll(sound);
}
Expand Down Expand Up @@ -784,7 +784,8 @@ WorldSafeLocsEntry const* BattleGroundIC::GetClosestGraveYard(Player* player)

Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period)
{
Transport* t = new Transport;
// FIXME - remove this method always...
MOTransport* t = new MOTransport;

const GameObjectInfo* goinfo = sObjectMgr.GetGameObjectInfo(goEntry);

Expand All @@ -796,7 +797,7 @@ Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period)
}

std::set<uint32> mapsUsed;
t->m_period = period;
t->SetDBPeriod(period);

if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
// skip transports with empty waypoints list
Expand All @@ -806,7 +807,7 @@ Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period)
return NULL;
}

WorldLocation const& loc = t->m_WayPoints[0].loc;
WorldLocation const& loc = t->GetWayPoint(0).loc;

// creates the Gameobject
if (!t->Create(goEntry, loc.GetMapId(), loc.x, loc.y, loc.z, loc.o, GO_ANIMPROGRESS_DEFAULT, 0))
Expand Down
4 changes: 2 additions & 2 deletions src/game/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct CreatureSpellEntry
#define MAX_CREATURE_SPELL_LISTS 8

typedef std::map<uint8 /* index */, CreatureSpellEntry> CreatureSpellsList;
typedef std::map<uint32 /*creature_id*/,CreatureSpellsList> CreatureSpellStorage;
typedef UNORDERED_MAP<uint32 /*creature_id*/,CreatureSpellsList> CreatureSpellStorage;

// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ )
Expand Down Expand Up @@ -502,7 +502,7 @@ class MANGOS_DLL_SPEC Creature : public Unit

char const* GetSubName() const { return m_creatureInfo->SubName; }

void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update
virtual void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update

virtual void RegenerateAll(uint32 update_diff);

Expand Down
94 changes: 80 additions & 14 deletions src/game/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,39 @@

#include <map>

typedef std::map<uint16, uint32> AreaFlagByAreaID;
typedef std::map<uint32, uint32> AreaFlagByMapID;
typedef UNORDERED_MAP<uint16, uint32> AreaFlagByAreaID;
typedef UNORDERED_MAP<uint32, uint32> AreaFlagByMapID;

struct WMOAreaTableTripple
{
WMOAreaTableTripple(int32 r, int32 a, int32 g) : groupId(g), rootId(r), adtId(a)
{
}

bool operator <(const WMOAreaTableTripple& b) const
bool operator <(WMOAreaTableTripple const& b) const
{
return memcmp(this, &b, sizeof(WMOAreaTableTripple)) < 0;
}

bool operator == (WMOAreaTableTripple const& b) const
{
return (groupId == b.groupId && rootId == b.rootId && adtId == b.adtId);
}

// ordered by entropy; that way memcmp will have a minimal medium runtime
int32 groupId;
int32 rootId;
int32 adtId;
};

typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const*> WMOAreaInfoByTripple;
HASH_NAMESPACE_START
template<> class hash <WMOAreaTableTripple>
{
public: size_t operator()(const WMOAreaTableTripple& __x) const { return (size_t)((__x.groupId << 24) | (__x.rootId << 16) | __x.adtId); }
};
HASH_NAMESPACE_END

typedef UNORDERED_MAP<WMOAreaTableTripple, WMOAreaTableEntry const*> WMOAreaInfoByTripple;

DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt);
DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt);
Expand Down Expand Up @@ -197,6 +209,7 @@ DBCStorage <VehicleEntry> sVehicleStore(VehicleEntryfmt);
DBCStorage <VehicleSeatEntry> sVehicleSeatStore(VehicleSeatEntryfmt);
DBCStorage <WMOAreaTableEntry> sWMOAreaTableStore(WMOAreaTableEntryfmt);
DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt);
WorldMapAreaMap sWorldMapAreaMap;
DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt);
DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
DBCStorage <WorldStateEntry> sWorldStateStore(WorldStateEntryfmt);
Expand Down Expand Up @@ -697,6 +710,14 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sVehicleStore, dbcPath, "Vehicle.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sVehicleSeatStore, dbcPath, "VehicleSeat.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWorldMapAreaStore, dbcPath, "WorldMapArea.dbc");
for (uint32 i = 0; i < sWorldMapAreaStore.GetNumRows(); ++i)
{
if (WorldMapAreaEntry const* entry = sWorldMapAreaStore.LookupEntry(i))
{
if (entry->zone_id != 0) // Strip overall continent definition
sWorldMapAreaMap.insert(WorldMapAreaMap::value_type(entry->zone_id, entry));
}
}
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWMOAreaTableStore, dbcPath, "WMOAreaTable.dbc");
for (uint32 i = 0; i < sWMOAreaTableStore.GetNumRows(); ++i)
{
Expand Down Expand Up @@ -806,11 +827,8 @@ int32 GetAreaFlagByAreaID(uint32 area_id)

WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
{
WMOAreaInfoByTripple::iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid));
if(i == sWMOAreaInfoByTripple.end())
return NULL;
return i->second;

WMOAreaInfoByTripple::const_iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid));
return (i == sWMOAreaInfoByTripple.end()) ? NULL : i->second;
}

AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id)
Expand Down Expand Up @@ -844,11 +862,9 @@ uint32 GetAreaFlagByMapId(uint32 mapid)

uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
{
if (mapid != 530 && mapid != 571) // speed for most cases
return mapid;

if (WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId))
return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id;
WorldMapAreaMap::const_iterator itr = sWorldMapAreaMap.find(zoneId);
if (itr != sWorldMapAreaMap.end())
return itr->second->virtual_map_id >= 0 ? itr->second->virtual_map_id : itr->second->map_id;

return mapid;
}
Expand All @@ -871,6 +887,56 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
}
}

WorldMapAreaEntry const* GetWorldMapAreaByAreaID(uint32 area_id)
{
int32 areaflag = GetAreaFlagByAreaID(area_id);

if (areaflag < 0)
return NULL;

AreaTableEntry const* entry = sAreaStore.LookupEntry(areaflag);

if (!entry)
return NULL;

WorldMapAreaMap::const_iterator itr = sWorldMapAreaMap.find((entry->zone == 0) ? entry->ID : entry->zone);
if (itr != sWorldMapAreaMap.end())
return itr->second;

return NULL;
}

WorldMapAreaEntry const* GetWorldMapAreaByMapID(uint32 map_id)
{
MapEntry const* targetMapEntry = sMapStore.LookupEntry(map_id);
if (!targetMapEntry)
return NULL;

for (uint32 i = 0; i < sWorldMapAreaStore.GetNumRows(); ++i)
{
if (WorldMapAreaEntry const* entry = sWorldMapAreaStore.LookupEntry(i))
{
if (entry->map_id == map_id && (!targetMapEntry->IsContinent() || (entry->zone_id == 0)))
return entry;
}
}
return NULL;
}

std::set<uint32> GetWorldMapAreaSetByMapID(uint32 map_id)
{
std::set<uint32> maps;
for (uint32 i = 0; i < sWorldMapAreaStore.GetNumRows(); ++i)
{
if (WorldMapAreaEntry const* entry = sWorldMapAreaStore.LookupEntry(i))
{
if (entry->map_id == map_id && !(entry->zone_id == 0)) // scip continents main area
maps.insert(entry->zone_id);
}
}
return maps;
}

ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
{
// not sorted, numbering index from 0
Expand Down
13 changes: 11 additions & 2 deletions src/game/DBCStores.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,21 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT
bool Zone2MapCoordinates(float& x, float& y, uint32 zone);
bool Map2ZoneCoordinates(float& x, float& y, uint32 zone);

typedef std::map<uint32/* pair32(dungeonId,expansion) */,LFGDungeonExpansionEntry const*> LFGDungeonExpansionMap;
typedef UNORDERED_MAP<uint32/* pair32(dungeonId,expansion) */,LFGDungeonExpansionEntry const*> LFGDungeonExpansionMap;
LFGDungeonExpansionEntry const* GetLFGExpansionEntry(uint32 dungeonId, uint32 expansion);

typedef std::map<uint32/*pair32(map,diff)*/,MapDifficultyEntry const*> MapDifficultyMap;
typedef UNORDERED_MAP<uint32/*pair32(map,diff)*/,MapDifficultyEntry const*> MapDifficultyMap;
MapDifficultyEntry const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);

typedef UNORDERED_MAP<uint32 /*zone_id*/, WorldMapAreaEntry const*> WorldMapAreaMap;
WorldMapAreaEntry const* GetWorldMapAreaByAreaId(uint32 area_id);

// returns main WorldMapArea for all maps, overall WorldMapArea (zone_id = 0) for continents
WorldMapAreaEntry const* GetWorldMapAreaByMapID(uint32 map_id);

// returns set of all zones in given map (1 zone mostly)
std::set<uint32> GetWorldMapAreaSetByMapID(uint32 map_id);

// natural order for difficulties up-down iteration
// difficulties for dungeons/battleground ordered in normal way
// and if more high version not exist must be used lesser version
Expand Down
4 changes: 2 additions & 2 deletions src/game/DBCStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -2626,9 +2626,9 @@ struct WMOAreaTableEntry

struct WorldMapAreaEntry
{
//uint32 ID; // 0 m_ID
uint32 ID; // 0 m_ID
uint32 map_id; // 1 m_mapID
uint32 area_id; // 2 m_areaID index (continent 0 areas ignored)
uint32 zone_id; // 2 m_areaID index (0 areas contains oveall continent definition)
//char* internal_name // 3 m_areaName
float y1; // 4 m_locLeft
float y2; // 5 m_locRight
Expand Down
2 changes: 1 addition & 1 deletion src/game/DBCfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const char TotemCategoryEntryfmt[] = "nxxxxxxxxxxxxxxxxxii";
const char VehicleEntryfmt[] = "niffffiiiiiiiifffffffffffffffssssfifiixx";
const char VehicleSeatEntryfmt[] = "niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
const char WMOAreaTableEntryfmt[] = "niiixxxxxiixxxxxxxxxxxxxxxxx";
const char WorldMapAreaEntryfmt[] = "xinxffffixx";
const char WorldMapAreaEntryfmt[] = "niixffffixx";
const char WorldMapOverlayEntryfmt[] = "nxiiiixxxxxxxxxxx";
const char WorldSafeLocsEntryfmt[] = "nifffxxxxxxxxxxxxxxxxx";
const char WorldStateEntryfmt[]="niiixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxxxsiix";
Expand Down
2 changes: 1 addition & 1 deletion src/game/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang,
QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY);

void Update(uint32 update_diff, uint32 p_time) override;
virtual void Update(uint32 update_diff, uint32 p_time) override;
GameObjectInfo const* GetGOInfo() const;

virtual bool IsTransport() const override;
Expand Down
Loading

0 comments on commit 9a0410d

Please sign in to comment.