[7272] Trailing whitespace cleaning
[getmangos.git] / src / shared / vmap / DebugCmdLogger.h
blobb9cc05cec64340142e07b6307e0ebebb29bd002a
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #ifndef _DEBUGCMDLOGGER_H
20 #define _DEBUGCMDLOGGER_H
22 #include <G3D/Vector3.h>
23 #include <G3D/Array.h>
25 /**
26 Class is used for debugging. We log activities into a file.
27 With an external Class we read that log and display the activity in a graphical view.
30 namespace VMAP
33 //==========================================
34 enum C_TYPES
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,
48 class Command
50 int iType;
51 float floats[9];
52 int ints[4];
53 char buffer[100];
54 public:
56 Command() { iType = STOP; }
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); }
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)
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;
76 void fillTestHeightCmd(int pMapId, G3D::Vector3 pPos, float result)
78 iType = TEST_HEIGHT; floats[0] = pPos.x; floats[1]=pPos.y; floats[2]=pPos.z;
79 floats[3] = result; ints[0] = pMapId;
81 void fillTestObjectHitCmd(int pMapId, G3D::Vector3 pPos1, G3D::Vector3 pPos2, G3D::Vector3 pResultPos, bool result)
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;
89 bool isCoreCmd() const { return(iType != TEST_VIS); }
92 //==========================================
94 class CommandFileRW
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; }
111 bool appendCmd(const Command& pCommand);
112 bool appendCmds(const G3D::Array<Command>& pCmdArray);
116 #endif