aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h17
-rw-r--r--src/framework/Platform/Define.h3
-rw-r--r--src/game/CMakeLists.txt2
-rw-r--r--src/game/Group.cpp7
-rw-r--r--src/game/Level1.cpp12
-rw-r--r--src/game/MapManager.cpp41
-rw-r--r--src/game/Spell.cpp5
-rw-r--r--src/game/SpellEffects.cpp5
-rw-r--r--src/game/World.cpp3
-rw-r--r--src/game/World.h1
-rw-r--r--src/shared/CMakeLists.txt2
-rw-r--r--src/shared/Util.cpp56
-rw-r--r--src/trinitycore/CMakeLists.txt2
-rw-r--r--src/trinitycore/trinitycore.conf.dist5
-rw-r--r--src/trinityrealm/CMakeLists.txt1
15 files changed, 141 insertions, 21 deletions
diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h
index 52677a6da37..b845c66823f 100644
--- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h
+++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/def_blood_furnace.h
@@ -1,18 +1,6 @@
/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- * 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
- */
+ * This program is free software licensed under GPL version 2
+ * Please see the included DOCS/LICENSE.TXT for more information */
#ifndef DEF_BLOOD_FURNACE_H
#define DEF_BLOOD_FURNACE_H
@@ -39,4 +27,3 @@
#define DATA_PRISON_CELL8 20
#endif
-
diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h
index 57c5b1b59cd..8f10fc20020 100644
--- a/src/framework/Platform/Define.h
+++ b/src/framework/Platform/Define.h
@@ -137,7 +137,10 @@ typedef uint32 DWORD;
typedef uint64 OBJECT_HANDLE;
+//#define MULTI_THREAD_MAP
+#ifdef MULTI_THREAD_MAP
#define MAP_BASED_RAND_GEN
+#endif
#define MaNGOS Trinity
#define MANGOS_DLL_DECL TRINITY_DLL_DECL
diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
index 339594bc4f9..bb05b4d6076 100644
--- a/src/game/CMakeLists.txt
+++ b/src/game/CMakeLists.txt
@@ -294,6 +294,6 @@ SET(game_STAT_SRCS
Wintergrasp.cpp
ZoneScript.h
)
-
+add_definitions(-fopenmp)
add_library(game STATIC ${game_STAT_SRCS})
ADD_DEPENDENCIES(game revision.h)
diff --git a/src/game/Group.cpp b/src/game/Group.cpp
index 24e5601abe8..c08d1236c32 100644
--- a/src/game/Group.cpp
+++ b/src/game/Group.cpp
@@ -1511,7 +1511,12 @@ void Group::ResetInstances(uint8 method, Player* SendMsgTo)
// if the map is loaded, reset it
Map *map = MapManager::Instance().FindMap(p->GetMapId(), p->GetInstanceId());
if(map && map->IsDungeon())
- isEmpty = ((InstanceMap*)map)->Reset(method);
+ {
+ if(p->CanReset())
+ isEmpty = ((InstanceMap*)map)->Reset(method);
+ else
+ isEmpty = !map->HavePlayers();
+ }
if(SendMsgTo)
{
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 43e7fb74660..51e94452399 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -55,6 +55,15 @@ bool ChatHandler::HandleNpcSayCommand(const char* args)
pCreature->MonsterSay(args, LANG_UNIVERSAL, 0);
+ // make some emotes
+ char lastchar = args[strlen(args) - 1];
+ switch(lastchar)
+ {
+ case '?': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
+ case '!': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
+ default: pCreature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
+ }
+
return true;
}
@@ -73,6 +82,9 @@ bool ChatHandler::HandleNpcYellCommand(const char* args)
pCreature->MonsterYell(args, LANG_UNIVERSAL, 0);
+ // make an emote
+ pCreature->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT);
+
return true;
}
diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp
index ece2876cab4..0da0d003144 100644
--- a/src/game/MapManager.cpp
+++ b/src/game/MapManager.cpp
@@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifdef MULTI_THREAD_MAP
+#include <omp.h>
+#endif
#include "MapManager.h"
#include "InstanceSaveMgr.h"
#include "Policies/SingletonImp.h"
@@ -251,12 +254,33 @@ MapManager::Update(uint32 diff)
if( !i_timer.Passed() )
return;
- for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
+#ifdef MULTI_THREAD_MAP
+ uint32 i=0;
+ MapMapType::iterator iter;
+ std::vector<Map*> update_queue(i_maps.size());
+ omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
+ for(iter = i_maps.begin(), i=0;iter != i_maps.end(); ++iter, i++)
+ update_queue[i]=iter->second;
+/*
+ gomp in gcc <4.4 version cannot parallelise loops using random access iterators
+ so until gcc 4.4 isnt standard, we need the update_queue workaround
+*/
+#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
+ for(int32 i = 0; i < i_maps.size(); ++i)
{
checkAndCorrectGridStatesArray(); // debugging code, should be deleted some day
+ update_queue[i]->Update(i_timer.GetCurrent());
+ sWorld.RecordTimeDiff("UpdateMap %u", update_queue[i]->GetId());
+ // sLog.outError("This is thread %d out of %d threads,updating map %u",omp_get_thread_num(),omp_get_num_threads(),iter->second->GetId());
+
+ }
+#else
+ for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
+ {
iter->second->Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateMap %u", iter->second->GetId());
}
+#endif
ObjectAccessor::Instance().Update(i_timer.GetCurrent());
sWorld.RecordTimeDiff("UpdateObjectAccessor");
@@ -269,8 +293,19 @@ MapManager::Update(uint32 diff)
void MapManager::DoDelayedMovesAndRemoves()
{
- for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
- iter->second->RelocationNotify();
+ /*
+ int i =0;
+ std::vector<Map*> update_queue(i_maps.size());
+ MapMapType::iterator iter;
+ for(iter = i_maps.begin();iter != i_maps.end(); ++iter, i++)
+ update_queue[i] = iter->second;
+
+ omp_set_num_threads(sWorld.getConfig(CONFIG_NUMTHREADS));
+
+#pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
+ for(i=0;i<i_maps.size();i++)
+ update_queue[i]->DoDelayedMovesAndRemoves();
+ */
}
bool MapManager::ExistMapAndVMap(uint32 mapid, float x,float y)
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 89eb18f2486..ed818d95570 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -3251,6 +3251,11 @@ void Spell::SendSpellGo()
//sLog.outDebug("Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id);
uint32 castFlags = CAST_FLAG_UNKNOWN3;
+
+ // triggered spells with spell visual != 0
+ if(m_IsTriggeredSpell || m_triggeredByAuraSpell)
+ castFlags |= CAST_FLAG_UNKNOWN0;
+
if(m_spellInfo->Attributes & SPELL_ATTR_REQ_AMMO)
castFlags |= CAST_FLAG_AMMO; // arrows/bullets visual
if ((m_caster->GetTypeId() == TYPEID_PLAYER ||
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 2aa9413ede9..01e7ec07c05 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -4157,6 +4157,11 @@ void Spell::EffectTaunt(uint32 /*i*/)
unitTarget->getThreatManager().addThreat(m_caster, itsThreat - myThreat);
}
+ //Set aggro victim to caster
+ if( !unitTarget->getThreatManager().getOnlineContainer().empty() )
+ if(HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster))
+ unitTarget->getThreatManager().setCurrentVictim(forcedVictim);
+
if(((Creature*)unitTarget)->IsAIEnabled && !((Creature*)unitTarget)->HasReactState(REACT_PASSIVE))
((Creature*)unitTarget)->AI()->AttackStart(m_caster);
}
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 150b2285191..3b72d0d2d02 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -1088,6 +1088,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000);
m_configs[CONFIG_MIN_LOG_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeDiff", 10);
m_configs[CONFIG_CHECK_DB] = sConfig.GetBoolDefault("CheckDB", true);
+ m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads",1);
std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", "");
char * forbiddenMaps = new char[forbiddenmaps.length() + 1];
@@ -1784,9 +1785,11 @@ void World::Update(uint32 diff)
sBattleGroundMgr.Update(diff);
RecordTimeDiff("UpdateBattleGroundMgr");
+
sOutdoorPvPMgr.Update(diff);
RecordTimeDiff("UpdateOutdoorPvPMgr");
+
// execute callbacks from sql queries that were queued recently
UpdateResultQueue();
RecordTimeDiff("UpdateResultQueue");
diff --git a/src/game/World.h b/src/game/World.h
index c91ee2e70ec..d8bb7477568 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -235,6 +235,7 @@ enum WorldConfigs
CONFIG_CHECK_DB,
CONFIG_ENABLE_SINFO_LOGIN,
CONFIG_PET_LOS,
+ CONFIG_NUMTHREADS,
CONFIG_OFFHAND_CHECK_AT_TALENTS_RESET,
CONFIG_CHATLOG_CHANNEL,
CONFIG_CHATLOG_WHISPER,
diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt
index b271e2b9545..de73967546b 100644
--- a/src/shared/CMakeLists.txt
+++ b/src/shared/CMakeLists.txt
@@ -21,7 +21,7 @@ SET(shared_STAT_SRCS
WorldPacket.h
SystemConfig.h
)
-
+add_definitions(-fopenmp)
add_library(shared STATIC ${shared_STAT_SRCS})
target_link_libraries(
shared
diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp
index ac57fc3c9e9..354568c778f 100644
--- a/src/shared/Util.cpp
+++ b/src/shared/Util.cpp
@@ -28,6 +28,60 @@
typedef ACE_TSS<MTRand> MTRandTSS;
static MTRandTSS mtRand;
+#ifdef MULTI_THREAD_MAP
+
+int32 irand (int32 min, int32 max)
+{
+ int32 result;
+#pragma omp critical (mtrand)
+{
+ result = int32 (mtRand->randInt (max - min)) + min;
+}
+ return result;
+}
+
+uint32 urand (uint32 min, uint32 max)
+{
+ uint32 result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randInt (max - min) + min;
+}
+ return result;
+}
+
+int32 rand32 ()
+{
+ int32 result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randInt ();
+}
+ return result;
+}
+
+double rand_norm(void)
+{
+ double result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randExc ();
+}
+ return result;
+}
+
+double rand_chance (void)
+{
+ double result;
+#pragma omp critical (mtrand)
+{
+ result = mtRand->randExc (100.0);
+}
+ return result;
+}
+
+#else
+
int32 irand (int32 min, int32 max)
{
return int32 (mtRand->randInt (max - min)) + min;
@@ -53,6 +107,8 @@ double rand_chance (void)
return mtRand->randExc (100.0);
}
+#endif
+
Tokens StrSplit(const std::string &src, const std::string &sep)
{
Tokens r;
diff --git a/src/trinitycore/CMakeLists.txt b/src/trinitycore/CMakeLists.txt
index f6b2b3a75b0..81dfb849ce7 100644
--- a/src/trinitycore/CMakeLists.txt
+++ b/src/trinitycore/CMakeLists.txt
@@ -43,8 +43,10 @@ trinityauth
trinityconfig
vmaps
ZThread
+termcap
g3dlite
readline
+gomp
${SCRIPT_LIB}
${MYSQL_LIBRARIES}
${POSTGRE_LIBS}
diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist
index bc6d907fbe0..4cb5ec233c1 100644
--- a/src/trinitycore/trinitycore.conf.dist
+++ b/src/trinitycore/trinitycore.conf.dist
@@ -188,6 +188,10 @@ EAIErrorLevel = 2
# Default: 1 (permit addon channel)
# 0 (do not permit addon channel)
#
+# MapUpdate.Threads
+# Number of threads to update maps.
+# Default: 1
+#
###################################################################################################################
UseProcessors = 0
@@ -214,6 +218,7 @@ LogDB.Opt.ClearInterval = 10
LogDB.Opt.ClearTime = 1209600
MaxCoreStuckTime = 0
AddonChannel = 1
+MapUpdate.Threads = 1
###################################################################################################################
# SERVER LOGGING
diff --git a/src/trinityrealm/CMakeLists.txt b/src/trinityrealm/CMakeLists.txt
index a8f5a646924..62f943a1c96 100644
--- a/src/trinityrealm/CMakeLists.txt
+++ b/src/trinityrealm/CMakeLists.txt
@@ -38,6 +38,7 @@ trinityauth
trinityconfig
ZThread
zlib
+gomp
${SSLLIB}
${MYSQL_LIBRARIES}
${OSX_LIBS}