root/trunk/src/game/WaypointManager.h @ 268

Revision 263, 2.9 kB (checked in by yumileroy, 17 years ago)

Some missing changes. This should fix the bug that loading char causes crash.
Please do not commit to the other tip (I do not know how to delete it).

Original author: megamage
Date: 2008-11-20 17:40:13-06:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITY_WAYPOINTMANAGER_H
22#define TRINITY_WAYPOINTMANAGER_H
23
24#include <vector>
25#include <string>
26#include "Utilities/UnorderedMap.h"
27
28#define MAX_WAYPOINT_TEXT 5
29struct WaypointBehavior
30{
31    uint32 emote;
32    uint32 spell;
33    int32  textid[MAX_WAYPOINT_TEXT];
34    uint32 model1;
35    uint32 model2;
36
37    bool isEmpty();
38    WaypointBehavior() {}
39    WaypointBehavior(const WaypointBehavior &b);
40};
41
42struct WaypointNode
43{
44    float x;
45    float y;
46    float z;
47    float orientation;
48    uint32 delay;
49    WaypointBehavior * behavior;
50    WaypointNode() {}
51    WaypointNode(float _x, float _y, float _z, float _o, uint32 _delay, WaypointBehavior * _behavior)
52      : x(_x), y(_y), z(_z), orientation(_o), delay(_delay), behavior(_behavior) {}
53};
54
55typedef std::vector<WaypointNode> WaypointPath;
56
57class WaypointManager
58{
59    public:
60        WaypointManager() {}
61        ~WaypointManager() { Unload(); }
62
63        void Load();
64        void Unload();
65
66        void Cleanup();
67
68        WaypointPath *GetPath(uint32 id)
69        {
70            WaypointPathMap::iterator itr = m_pathMap.find(id);
71            return itr != m_pathMap.end() ? &itr->second : NULL;
72        }
73
74        void AddLastNode(uint32 id, float x, float y, float z, float o, uint32 delay, uint32 wpGuid);
75        void AddAfterNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid);
76        uint32 GetLastPoint(uint32 id, uint32 default_notfound);
77        void DeleteNode(uint32 id, uint32 point);
78        void DeletePath(uint32 id);
79        void SetNodePosition(uint32 id, uint32 point, float x, float y, float z);
80        void SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text);
81
82    private:
83        void _addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid);
84        void _clearPath(WaypointPath &path);
85
86        typedef UNORDERED_MAP<uint32, WaypointPath> WaypointPathMap;
87        WaypointPathMap m_pathMap;
88};
89
90#define WaypointMgr Trinity::Singleton<WaypointManager>::Instance()
91
92#endif
Note: See TracBrowser for help on using the browser.