root/trunk/src/shared/vmap/DebugCmdLogger.h @ 102

Revision 102, 4.6 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05: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 _DEBUGCMDLOGGER_H
22#define _DEBUGCMDLOGGER_H
23
24#include <G3D/Vector3.h>
25#include <G3D/Array.h>
26
27/**
28Class is used for debugging. We log activities into a file.
29With an external Class we read that log and display the activity in a graphical view.
30*/
31
32namespace VMAP
33{
34
35    //==========================================
36    enum C_TYPES
37    {
38        STOP,
39        START,
40        LOAD_TILE,
41        UNLOAD_TILE,
42        SET_POS,
43        TEST_VIS,
44        LOAD_INSTANCE,
45        UNLOAD_INSTANCE,
46        TEST_HEIGHT,
47        TEST_OBJECT_HIT,
48    };
49
50    class Command
51    {
52        int iType;
53        float floats[9];
54        int ints[4];
55        char buffer[100];
56        public:
57
58            Command() { iType = STOP; }
59
60            inline int getType() { return iType; }
61            inline G3D::Vector3 getVector(int pos) { return(G3D::Vector3(floats[pos*3+0], floats[pos*3+1], floats[pos*3+2])); }
62            inline int getInt(int pos) { return(ints[pos]); }
63            inline char* getBuffer() { return(buffer); }
64
65            void fillStopCmd() { iType = STOP; }
66            void fillStartCmd() { iType = START; }
67            void fillLoadTileCmd(int x, int y, G3D::uint32 pMapId) { iType = LOAD_TILE; ints[0] = x; ints[1] = y; ints[2] = pMapId; }
68            //void fillLoadTileCmd(int x,int y) { iType = LOAD_TILE; ints[0] = x; ints[1] = y; }
69            void fillUnloadTileCmd(G3D::uint32 pMapId) { iType = UNLOAD_INSTANCE; ints[0] = pMapId; }
70            void fillUnloadTileCmd(unsigned int pMapId, int x,int y) { iType = UNLOAD_TILE; ints[0] = x; ints[1] = y; ints[0]=pMapId; }
71            void fillSetPosCmd(G3D::Vector3 pPos) { iType = SET_POS; floats[0] = pPos.x; floats[1]=pPos.y; floats[2]=pPos.z; }
72            void fillTestVisCmd(int pMapId, G3D::Vector3 pPos1, G3D::Vector3 pPos2, bool result)
73            {
74                iType = TEST_VIS; floats[0] = pPos1.x; floats[1]=pPos1.y; floats[2]=pPos1.z;
75                floats[3] = pPos2.x; floats[4]=pPos2.y; floats[5]=pPos2.z;
76                ints[0] = result; ints[1] = pMapId;
77            }
78            void fillTestHeightCmd(int pMapId, G3D::Vector3 pPos, float result)
79            {
80                iType = TEST_HEIGHT; floats[0] = pPos.x; floats[1]=pPos.y; floats[2]=pPos.z;
81                floats[3] = result; ints[0] = pMapId;
82            }
83            void fillTestObjectHitCmd(int pMapId, G3D::Vector3 pPos1, G3D::Vector3 pPos2, G3D::Vector3 pResultPos, bool result)
84            {
85                iType = TEST_OBJECT_HIT; floats[0] = pPos1.x; floats[1]=pPos1.y; floats[2]=pPos1.z;
86                floats[3] = pPos2.x; floats[4]=pPos2.y; floats[5]=pPos2.z;
87                floats[6] = pResultPos.x; floats[7]=pResultPos.y; floats[8]=pResultPos.z;
88                ints[0] = result; ints[1] = pMapId;
89            }
90
91            bool isCoreCmd() const { return(iType != TEST_VIS); }
92    };
93
94    //==========================================
95
96    class CommandFileRW
97    {
98        private:
99            std::string iFileName;
100            long iLastPos;
101            G3D::Array<G3D::Array<Command> > iCommandArray;
102            bool resetfile;
103            bool iWritingEnabled;
104        public:
105            CommandFileRW() { iLastPos=0; iWritingEnabled = true; resetfile = true;}
106            CommandFileRW(const std::string& pFileName) { iLastPos = 0; iFileName = pFileName; iWritingEnabled = true; resetfile = true; }
107            void setResetFile() { resetfile = true; }
108            void enableWriting(bool pValue) { iWritingEnabled = pValue; }
109            void setFileName(const std::string& pName) { iFileName = pName; }
110            bool getNewCommands(G3D::Array<Command>& commandArray);
111            const G3D::Array<G3D::Array<Command> >& getFullCommandArray() { return iCommandArray; }
112
113            bool appendCmd(const Command& pCommand);
114            bool appendCmds(const G3D::Array<Command>& pCmdArray);
115    };
116
117}
118#endif
Note: See TracBrowser for help on using the browser.