1 /**
2  * !!!WARNING!!!
3  *  This file cannot be included in other .h files TODO why?
4  *  These macros cannot be used at inline methods declared in .h files TODO why?
5  *  If you do this, it may SEGFAULT only when being run.
6  *   Compiler and linker will warn nothing about the problem!
7  *  On linux this check can be added prior to compile: `egrep "dbgmsgproj.h" * -rnI --include "*.h"`
8  */
9 
10 #ifndef INCLUDE_DBGMSGPROJ_H_
11 
12   #define INCLUDE_DBGMSGPROJ_H_
13 
14   #ifdef DBGMSG
15 
16     #ifdef ECLIPSE_IDE
17       #define __V2_H__
18       #define __BITMAP_H__
19       #define __GRAPHICS_H__
20       #define __CHAR_H__
21       #define __ITEM_H__
22       #define __ERROR_H__
23       #define DBGMSG_STRETCHREGION
24     #endif
25 
26     #include "dbgmsg.h"
27 
28     /************************************************************
29      * CUSTOM / PROJECT SPECIFIC, modify at will
30      ************************************************************/
31     #ifndef DBGMSG_OBJ //do NOT define DBGMSG_OBJ this in your project cpp files!
32 
33       class dbgmsgproj { public:
34         #if defined(__V2_H__) && !defined(DBGAV2)
dbgV2(v2 v2Val,const char * c)35           static std::stringstream dbgV2(v2 v2Val,const char* c){
36             std::stringstream ss;
37             ss<<c<<"/";
38             ss<<"X,Y="<<((int)v2Val.X)<<","<<((int)v2Val.Y)<<"/";
39             return ss;
40           }
41           #define DBGAV2(v2)  dbgmsgproj::dbgV2(v2,DBGTOSTR(v2)).str()
42           #define DBGSV2(v2)  DBGSS(DBGAV2(v2))
43         #endif
44 
45         #if defined(__BITMAP_H__) && !defined(DBGBLD)
46           #include <sstream>
dbgBLD(const blitdata & rB,const char * strInfo)47           static std::stringstream dbgBLD(const blitdata& rB,const char* strInfo){
48             std::stringstream ss;
49             ss<<strInfo<<"/";
50             ss<<"Src="<<rB.Src.X<<","<<rB.Src.Y<<"/";
51             ss<<"Dest="<<rB.Dest.X<<","<<rB.Dest.Y<<"/";
52             ss<<"Border="<<rB.Border.X<<","<<rB.Border.Y<<"/";
53             ss<<"Stretch="<<rB.Stretch<<"/";
54             //        DBG2("rB.Bitmap",rB.Bitmap); // some(random)times this causes SEGFAULT: rB.Bitmap->GetSize()
55             if(rB.Bitmap!=NULL)ss<<"BitmapSize="<<rB.Bitmap->GetSize().X<<","<<rB.Bitmap->GetSize().Y<<"/";
56             return ss;
57           }
58           #define DBGBLD(rb) DBGSS(dbgmsgproj::dbgBLD(rb,DBGTOSTR(rb)).str())
59         #endif
60 
61         #if defined(__GRAPHICS_H__) && defined(DBGMSG_STRETCHREGION) && !defined(DBGSRI) //TODO if stretchRegion moves to graphics.h, DBGMSG_STRETCHREGION can be removed everywhere
dbgSRI(stretchRegion & SR,const char * strInfo)62           static std::stringstream dbgSRI(stretchRegion& SR,const char* strInfo){
63             blitdata& rB=SR.B;
64             std::stringstream ss;
65             ss<<strInfo
66               <<"["<<SR.iIndex<<"]SR@"
67               <<"bEnabled="<<SR.bEnabled<<"/"
68               <<"bForceXBRZ="<<SR.bUseXBRZ<<"/"
69               <<"id="<<SR.strId<<"/"
70               <<dbgmsgproj::dbgBLD(rB,"").str()
71             ;
72             return ss;
73           }
74           #define DBGSRI(info)  DBG1( dbgmsgproj::dbgSRI(rSR,info).str())
75           #define DBGSR         DBGSRI("")
76         #endif
77       };
78 
79       #if defined(__CHAR_H__) && !defined(DBGCHAR)
80         #define DBGCHAR(ch,info) DBG8(info, ch->CHAR_NAME(DEFINITE), ch->GetAssignedName().CStr(), ch, ch->GetID(), ch->IsPlayer(), ch->GetStack()->GetItems(), ch->GetEquipments() ) //, std::bitset<16>(ch->GetFlags()) )
81       #endif
82 
83       #if defined(__ITEM_H__) && !defined(DBGITEM)
84         #define DBGITEM(it,info) DBG4(info,it,it->GetName(UNARTICLED).CStr(),(it==NULL?0:it->GetID()))
85       #endif
86 
87       #if defined(__ERROR_H__) && !defined(DBGABORT)
88         #define DBGABORT(x...) ABORT(x) //will only abort in development mode
89       #endif
90 
91     #endif //DBGMSG_OBJ
92 
93   #else
94     //dbgmsg macro erasers
95     #define DBGOE(s)
96     #define DBGSS(s)
97     #define DBG1(a)
98     #define DBG2(a,b)
99     #define DBG3(a,b,c)
100     #define DBG4(a,b,c,d)
101     #define DBG5(a,b,c,d,e)
102     #define DBG6(a,b,c,d,e,f)
103     #define DBG7(a,b,c,d,e,f,g)
104     #define DBG8(a,b,c,d,e,f,g,h)
105     #define DBG9(a,b,c,d,e,f,g,h,i)
106     #define DBGLN
107     #define DBGSTK
108     #define DBGBREAKPOINT
109     #define DBGTOSTR_(str)
110     #define DBGTOSTR(str)
111     #define DBGB(B)
112     #define DBGSB(B)
113     #define DBGI(I)
114     #define DBGSI(I)
115     #define DBGF(F)
116     #define DBGSF(F)
117     #define DBGC(C)
118     #define DBGSC(C)
119     #define DBGS(SS)
120     #define DBGEXEC(cmds)
121     #define DBGSETV(id,val)
122     #define DBGGETV(id,defval)
123     #define DBGGETVD(id,defval)
124 
125     // proj specifics
126     #define DBGAV2(v2)
127     #define DBGSV2(v2)
128 
129     #define DBGBLD(rb)
130     #define DBGSRI(info)
131 
132     #define DBGSR
133 
134     #define DBGCHAR(ch,info)
135     #define DBGITEM(it,info)
136     #define DBGABORT(x,...)
137 
138   #endif //DBGMSG
139 
140 #endif //INCLUDE_DBGMSGPROJ_H_
141