diff options
author | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-03-27 13:19:56 +0100 |
---|---|---|
committer | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-03-27 13:19:56 +0100 |
commit | 1b8d917ea9ba4cb7190a8da94d9128cb9bd561a4 (patch) | |
tree | 9479c21968ddf6b267cdc51b8586deb6986dd73d /src | |
parent | c97c381ea0b63963b3756f531b8c64636cb5d66b (diff) | |
parent | b78885622078bcf56b21694b39964c25ae4794f6 (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Diffstat (limited to 'src')
-rw-r--r-- | src/server/collision/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Grids/GridStates.cpp | 45 | ||||
-rw-r--r-- | src/server/game/Grids/GridStates.h | 27 | ||||
-rw-r--r-- | src/server/game/Maps/MapManager.h | 9 | ||||
-rw-r--r-- | src/server/shared/Debugging/Errors.cpp | 25 | ||||
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.cpp | 19 | ||||
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 6 |
8 files changed, 97 insertions, 50 deletions
diff --git a/src/server/collision/CMakeLists.txt b/src/server/collision/CMakeLists.txt index b4012b63812..f254ffda94c 100644 --- a/src/server/collision/CMakeLists.txt +++ b/src/server/collision/CMakeLists.txt @@ -83,6 +83,10 @@ add_library(collision STATIC ${collision_STAT_PCH_SRC} ) +target_link_libraries(collision + shared +) + # Generate precompiled header if (USE_COREPCH) add_cxx_pch(collision ${collision_STAT_PCH_HDR} ${collision_STAT_PCH_SRC}) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 9c476ea55fc..f5a75de73f8 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1023,8 +1023,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!IsSmart()) break; - CAST_AI(SmartAI, me->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1);//next tick - CAST_AI(SmartAI, me->AI())->StartDespawn(); + // The AI is only updated if the creature is alive + if (me->isAlive()) + { + CAST_AI(SmartAI, me->AI())->SetDespawnTime(e.action.forceDespawn.delay + 1); // Next tick + CAST_AI(SmartAI, me->AI())->StartDespawn(); + } + // Otherwise we call the despawn directly + else + me->DespawnOrUnsummon(e.action.forceDespawn.delay); + break; } case SMART_ACTION_SET_INGAME_PHASE_MASK: diff --git a/src/server/game/Grids/GridStates.cpp b/src/server/game/Grids/GridStates.cpp index e4f995cd8d2..c4db919c51b 100644 --- a/src/server/game/Grids/GridStates.cpp +++ b/src/server/game/Grids/GridStates.cpp @@ -18,53 +18,58 @@ #include "GridStates.h" #include "GridNotifiers.h" -#include "Grid.h" #include "Log.h" -void InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32) const +#ifdef TRINITY_DEBUG +bool GridState::checkMagic() { + if (i_Magic != MAGIC_TESTVAL) + { + sLog->outError(LOG_FILTER_GENERAL, "!!! GridState: Magic value gone !!!"); + return false; + } + return true; } +#endif + +void InvalidState::Update(Map&, NGridType&, GridInfo&, uint32) const +{ } -void ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 t_diff) const +void ActiveState::Update(Map& map, NGridType& grid, GridInfo& info, uint32 diff) const { // Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle - info.UpdateTimeTracker(t_diff); + info.UpdateTimeTracker(diff); if (info.getTimeTracker().Passed()) { - if (!grid.GetWorldObjectCountInNGrid<Player>() && !m.ActiveObjectsNearGrid(grid)) + if (!grid.GetWorldObjectCountInNGrid<Player>() && !map.ActiveObjectsNearGrid(grid)) { ObjectGridStoper worker; TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker); grid.VisitAllGrids(visitor); grid.SetGridState(GRID_STATE_IDLE); - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", grid.getX(), grid.getY(), m.GetId()); + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to IDLE state", grid.getX(), grid.getY(), map.GetId()); } else - { - m.ResetGridExpiry(grid, 0.1f); - } + map.ResetGridExpiry(grid, 0.1f); } } -void IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32) const +void IdleState::Update(Map& map, NGridType& grid, GridInfo&, uint32) const { - m.ResetGridExpiry(grid); + map.ResetGridExpiry(grid); grid.SetGridState(GRID_STATE_REMOVAL); - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), m.GetId()); + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), map.GetId()); } -void RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 t_diff) const +void RemovalState::Update(Map& map, NGridType& grid, GridInfo& info, uint32 diff) const { if (!info.getUnloadLock()) { - info.UpdateTimeTracker(t_diff); - if (info.getTimeTracker().Passed()) + info.UpdateTimeTracker(diff); + if (info.getTimeTracker().Passed() && !map.UnloadGrid(grid, false)) { - if (!m.UnloadGrid(grid, false)) - { - sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), m.GetId()); - m.ResetGridExpiry(grid); - } + sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), map.GetId()); + map.ResetGridExpiry(grid); } } } diff --git a/src/server/game/Grids/GridStates.h b/src/server/game/Grids/GridStates.h index 54fe0d62378..09682c716a9 100644 --- a/src/server/game/Grids/GridStates.h +++ b/src/server/game/Grids/GridStates.h @@ -19,8 +19,10 @@ #ifndef TRINITY_GRIDSTATES_H #define TRINITY_GRIDSTATES_H -#include "Map.h" -#include "Object.h" +#include "GridDefines.h" +#include "NGrid.h" + +class Map; class GridState { @@ -28,44 +30,35 @@ class GridState #ifdef TRINITY_DEBUG #define MAGIC_TESTVAL 0xFBE823BA GridState() { i_Magic = MAGIC_TESTVAL; } - bool checkMagic() - { - if (i_Magic != MAGIC_TESTVAL) - { - sLog->outError(LOG_FILTER_GENERAL, "!!! GridState: Magic value gone !!!"); - return false; - } - return true; - } + bool checkMagic(); void setMagic() { i_Magic = MAGIC_TESTVAL; } unsigned int i_Magic; #endif virtual ~GridState() {}; - virtual void Update(Map &, NGridType&, GridInfo &, const uint32 t_diff) const = 0; + virtual void Update(Map &, NGridType&, GridInfo &, uint32 t_diff) const = 0; }; class InvalidState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; }; class ActiveState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; }; class IdleState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; }; class RemovalState : public GridState { public: - void Update(Map &, NGridType &, GridInfo &, const uint32 t_diff) const; + void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const; }; #endif - diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index 09e09a80148..8af609c61e2 100644 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -19,14 +19,15 @@ #ifndef TRINITY_MAPMANAGER_H #define TRINITY_MAPMANAGER_H -#include "Define.h" -#include <ace/Singleton.h> -#include <ace/Thread_Mutex.h> -#include "Common.h" +#include "Object.h" #include "Map.h" #include "GridStates.h" #include "MapUpdater.h" +#include <ace/Singleton.h> +#include <ace/Thread_Mutex.h> + + class Transport; struct TransportCreatureProto; diff --git a/src/server/shared/Debugging/Errors.cpp b/src/server/shared/Debugging/Errors.cpp index bd299906de0..10ede3ae402 100644 --- a/src/server/shared/Debugging/Errors.cpp +++ b/src/server/shared/Debugging/Errors.cpp @@ -1,5 +1,22 @@ +/* + * Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> + * + * 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, see <http://www.gnu.org/licenses/>. + */ + #include "Errors.h" -#include "Log.h" #include <ace/Stack_Trace.h> #include <ace/OS_NS_unistd.h> @@ -16,7 +33,7 @@ void Assert(char const *file, int line, char const *function, char const *messag void Fatal(char const *file, int line, char const *function, char const *message) { - sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n", + fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n %s\n", file, line, function, message); ACE_OS::sleep(10); *((volatile int*)NULL) = 0; @@ -24,14 +41,14 @@ void Fatal(char const *file, int line, char const *function, char const *message void Error(char const *file, int line, char const *function, char const *message) { - sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s ERROR:\n %s\n", + fprintf(stderr, "\n%s:%i in %s ERROR:\n %s\n", file, line, function, message); *((volatile int*)NULL) = 0; } void Warning(char const *file, int line, char const *function, char const *message) { - sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n", + fprintf(stderr, "\n%s:%i in %s WARNING:\n %s\n", file, line, function, message); } diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index a14cf3477af..3b4be003858 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -1,4 +1,23 @@ +/* + * Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> + * + * 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, see <http://www.gnu.org/licenses/>. + */ + #include "ByteBuffer.h" +#include "Common.h" #include "Log.h" #include <ace/Stack_Trace.h> diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 0f4221b53ff..0bbaff38be1 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -20,16 +20,16 @@ #define _BYTEBUFFER_H #include "Define.h" -#include "Debugging/Errors.h" -#include "Utilities/ByteConverter.h" +#include "Errors.h" +#include "ByteConverter.h" #include <exception> #include <list> #include <map> #include <string> #include <vector> - #include <cstring> +#include <time.h> // Root of ByteBuffer exception hierarchy class ByteBufferException : public std::exception |