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

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

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19#ifndef _DEBUGCMDLOGGER_H
20#define _DEBUGCMDLOGGER_H
21
22#include <G3D/Vector3.h>
23#include <G3D/Array.h>
24
25/**
26Class is used for debugging. We log activities into a file.
27With an external Class we read that log and display the activity in a graphical view.
28*/
29
30namespace VMAP
31{
32
33    //==========================================
34    enum C_TYPES
35    {
36        STOP,
37        START,
38        LOAD_TILE,
39        UNLOAD_TILE,
40        SET_POS,
41        TEST_VIS,
42        LOAD_INSTANCE,
43        UNLOAD_INSTANCE,
44        TEST_HEIGHT,
45        TEST_OBJECT_HIT,
46    };
47
48    class Command
49    {
50        int iType;
51        float floats[9];
52        int ints[4];
53        char buffer[100];
54        public:
55
56            Command() { iType = STOP; }
57
58            inline int getType() { return iType; }
59            inline G3D::Vector3 getVector(int pos) { return(G3D::Vector3(floats[pos*3+0], floats[pos*3+1], floats[pos*3+2])); }
60            inline int getInt(int pos) { return(ints[pos]); }
61            inline char* getBuffer() { return(buffer); }
62
63            void fillStopCmd() { iType = STOP; }
64            void fillStartCmd() { iType = START; }
65            void fillLoadTileCmd(int x, int y, G3D::uint32 pMapId) { iType = LOAD_TILE; ints[0] = x; ints[1] = y; ints[2] = pMapId; }
66            //void fillLoadTileCmd(int x,int y) { iType = LOAD_TILE; ints[0] = x; ints[1] = y; }
67            void fillUnloadTileCmd(G3D::uint32 pMapId) { iType = UNLOAD_INSTANCE; ints[0] = pMapId; }
68            void fillUnloadTileCmd(unsigned int pMapId, int x,int y) { iType = UNLOAD_TILE; ints[0] = x; ints[1] = y; ints[0]=pMapId; }
69            void fillSetPosCmd(G3D::Vector3 pPos) { iType = SET_POS; floats[0] = pPos.x; floats[1]=pPos.y; floats[2]=pPos.z; }
70            void fillTestVisCmd(int pMapId, G3D::Vector3 pPos1, G3D::Vector3 pPos2, bool result)
71            {
72                iType = TEST_VIS; floats[0] = pPos1.x; floats[1]=pPos1.y; floats[2]=pPos1.z;
73                floats[3] = pPos2.x; floats[4]=pPos2.y; floats[5]=pPos2.z;
74                ints[0] = result; ints[1] = pMapId;
75            }
76            void fillTestHeightCmd(int pMapId, G3D::Vector3 pPos, float result)
77            {
78                iType = TEST_HEIGHT; floats[0] = pPos.x; floats[1]=pPos.y; floats[2]=pPos.z;
79                floats[3] = result; ints[0] = pMapId;
80            }
81            void fillTestObjectHitCmd(int pMapId, G3D::Vector3 pPos1, G3D::Vector3 pPos2, G3D::Vector3 pResultPos, bool result)
82            {
83                iType = TEST_OBJECT_HIT; floats[0] = pPos1.x; floats[1]=pPos1.y; floats[2]=pPos1.z;
84                floats[3] = pPos2.x; floats[4]=pPos2.y; floats[5]=pPos2.z;
85                floats[6] = pResultPos.x; floats[7]=pResultPos.y; floats[8]=pResultPos.z;
86                ints[0] = result; ints[1] = pMapId;
87            }
88
89            bool isCoreCmd() const { return(iType != TEST_VIS); }
90    };
91
92    //==========================================
93
94    class CommandFileRW
95    {
96        private:
97            std::string iFileName;
98            long iLastPos;
99            G3D::Array<G3D::Array<Command> > iCommandArray;
100            bool resetfile;
101            bool iWritingEnabled;
102        public:
103            CommandFileRW() { iLastPos=0; iWritingEnabled = true; resetfile = true;}
104            CommandFileRW(const std::string& pFileName) { iLastPos = 0; iFileName = pFileName; iWritingEnabled = true; resetfile = true; }
105            void setResetFile() { resetfile = true; }
106            void enableWriting(bool pValue) { iWritingEnabled = pValue; }
107            void setFileName(const std::string& pName) { iFileName = pName; }
108            bool getNewCommands(G3D::Array<Command>& commandArray);
109            const G3D::Array<G3D::Array<Command> >& getFullCommandArray() { return iCommandArray; }
110
111            bool appendCmd(const Command& pCommand);
112            bool appendCmds(const G3D::Array<Command>& pCmdArray);
113    };
114
115}
116#endif
Note: See TracBrowser for help on using the browser.