Connecting Tech Pros Worldwide Help | Site Map

Having trouble with this source code

Newbie
 
Join Date: Oct 2009
Posts: 3
#1: Oct 4 '09
OK this is the complete source code and when i compile it gets errors
i am stumped as to why. not sure if the headers are there or not
can some one please help me fix these errors please

Expand|Select|Wrap|Line Numbers
  1. #define charbody m==char Stridenum[44];
  2. unsigned int m_Stride;
  3. unsigned int NumVertices;
  4. unsigned int primCount;
  5. int Stridelogger = false;
  6. int stri = 0;
  7. int numvert = 0;
  8. int primcnt = 0;
  9. CD3DFont *pD3DFont;
  10. LPDIRECT3DTEXTURE9 texRed;
  11. LPDIRECT3DTEXTURE9 texBlue;
  12. LPDIRECT3DTEXTURE9 texYellow;
  13. LPDIRECT3DTEXTURE9 texGreen;
  14. LPDIRECT3DTEXTURE9 texWhite;
  15. LPDIRECT3DTEXTURE9 texAqua;
  16. //LPDIRECT3DTEXTURE9 texDarkBlue;
  17. //LPDIRECT3DTEXTURE9 texPink;
  18. //LPDIRECT3DTEXTURE9 texOrange;
  19. LPDIRECT3DTEXTURE9 texPurple;
  20. const BYTE bRed[60] =
  21. {
  22. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  23. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  24. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  25. 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  26. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  27. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  28. 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00
  29. };
  30. const BYTE bBlue[60] =
  31. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  32. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  33. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  34. 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  35. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  36. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  37. 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00
  38. };
  39.  
  40. const BYTE bGreen[60] =
  41. {
  42. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  44. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  45. 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
  46. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  47. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  48. 0x00, 0x9E, 0x00, 0x00, 0x00, 0x00
  49. };
  50. const BYTE bYellow[60] =
  51. {
  52. 0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  53. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  54. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  55. 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
  56. 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
  57. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  58. 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00
  59. }; 
  60. const BYTE bAqua[58] =
  61. {
  62. 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  63. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  64. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  65. 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
  66. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0xFF, 0xFF, 0x00, 0x00
  69. };
  70. const BYTE bPurple[58] =
  71. {
  72. 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  73. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  74. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  75. 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
  76. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  77. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  78. 0xFF, 0x00, 0xFF, 0x00
  79. };
  80. .r{}
  81. const BYTE bWhite[58] =
  82. {
  83. 0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  84. 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
  85. 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
  86. 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
  87. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  88. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0xFF, 0xFF, 0xFF, 0x00
  90. };
  91. #define D3DHOOK_TEXTURES
  92. HRESULT CD3DManager::Initialize()
  93. {
  94. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bRed, 60, &texRed);
  95. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bBlue, 60, &texBlue);
  96. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bGreen, 60, &texGreen);
  97. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bYellow, 60, &texYellow);
  98. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bWhite, 60, &texWhite);
  99. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bAqua, 60, &texAqua);
  100. D3DXCreateTextureFromFileInMemory(m_pD3Ddev, (LPCVOID)&bPurple, 60, &texPurple);
  101.  
  102. pD3DFont = new CD3DFont("Comic Sans MS", 12);
  103. pD3DFont->InitDeviceObjects(m_pD3Ddev);
  104. pD3DFont->RestoreDeviceObjects();
  105. return S_OK;
  106. }
  107. HRESULT CD3DManager::PreReset()
  108. {
  109. return S_OK;
  110. }
  111. HRESULT CD3DManager::PostReset()
  112. {
  113. return S_OK;
  114. }
  115. HRESULT CD3DManager::Release()
  116. {
  117. delete pD3DFont;
  118. texRed->Release();
  119. texBlue->Release();
  120. texGreen->Release();
  121. texWhite->Release();
  122. texAqua->Release();
  123. texYellow->Release();
  124. texPurple->Release();
  125. return S_OK;
  126. }
  127. in DIP
  128. -------
  129. if(GetAsyncKeyState(VK_F1)&1)
  130. {
  131. Stridelogger=!Stridelogger;
  132. }
  133. if(Stridelogger)
  134. {
  135. if(GetAsyncKeyState(VK_NUMPAD7)&1)stri ;
  136. if(GetAsyncKeyState(VK_NUMPAD1)&1)stri--;
  137. if(GetAsyncKeyState(VK_NUMPAD8)&1)numvert ;
  138. if(GetAsyncKeyState(VK_NUMPAD2)&1)numvert--;
  139. if(GetAsyncKeyState(VK_NUMPAD9)&1)primcnt ;
  140. if(GetAsyncKeyState(VK_NUMPAD3)&1)primcnt--;
  141. }
  142. if(m_Stride == stri)
  143. {
  144. m_pD3Ddev->SetTexture(0,texRed);
  145. return m_pD3Ddev->DrawIndexedPrimitive(Type,BaseVertexIndex,
  146. MinVertexIndex, NumVertices, startIndex, primCount);
  147. }
  148. if(NumVertices == numvert)
  149. {
  150. m_pD3Ddev->SetTexture(0,texBlue);
  151. return m_pD3Ddev->DrawIndexedPrimitive
  152. (Type,BaseVertexIndex,MinVertexIndex, NumVertices, startIndex, primCount);
  153. }
  154. if(primCount == primcnt)
  155. {
  156. m_pD3Ddev->SetTexture(0,texGreen);
  157. return m_pD3Ddev->DrawIndexedPrimitive (Type,BaseVertexIndex,MinVertexIndex, NumVertices, startIndex, primCount);
  158. }
  159. if(GetAsyncKeyState(VK_NUMPAD0)&1)
  160. {
  161. stri=0;
  162. numvert=0;
  163. primcnt=0;
  164. }
  165. if(GetAsyncKeyState(VK_NUMPAD4)&1)
  166. {
  167. add_log("Player Stride:%i",stri);
  168. }
  169. if(GetAsyncKeyState(VK_NUMPAD5)&1)
  170. {
  171. add_log("Stride:%i",stri);
  172. add_log("NumVertices:%i",numvert);
  173. add_log("primCount:%i",primcnt);
  174. }
  175.  
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,148
#2: Oct 4 '09

re: Having trouble with this source code


There is little point saying that you have got compiler diagnostics (errors or warnings) and asking for help to fix them without actually posting those errors!
Newbie
 
Join Date: Oct 2009
Posts: 3
#3: Oct 4 '09

re: Having trouble with this source code


Hi i was going to do this but i dident know if it was needed or not. so i'll post it now.
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Documents and Settings\Ab\My Documents\Untitled1.cpp" -o "C:\Documents and Settings\Ab\My Documents\Untitled1.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:9: error: expected constructor, destructor, or type conversion before '*' token
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:9: error: expected `,' or `;' before '*' token

C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:10: error: expected unqualified-id before string constant
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:10: error: expected `)' before string constant
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:10: error: expected `,' or `;' before string constant
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:11: error: `LPDIRECT3DTEXTURE9' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:12: error: `LPDIRECT3DTEXTURE9' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:13: error: `LPDIRECT3DTEXTURE9' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:14: error: `LPDIRECT3DTEXTURE9' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:15: error: `LPDIRECT3DTEXTURE9' does not name a type

C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:19: error: `LPDIRECT3DTEXTURE9' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:20: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:30: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:41: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:51: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:61: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:71: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:81: error: expected unqualified-id before '.' token
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:81: error: expected `,' or `;' before '.' token
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:82: error: `BYTE' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:93: error: `HRESULT' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:108: error: `HRESULT' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:112: error: `HRESULT' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:116: error: `HRESULT' does not name a type
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:128: error: `in' does not name a type

C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:134: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:134: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:143: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:143: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:149: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:149: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:155: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:155: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:160: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:160: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:166: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:166: error: expected `,' or `;' before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:170: error: expected unqualified-id before "if"
C:\Documents and Settings\Ab\My Documents\Untitled1.cpp:170: error: expected `,' or `;' before "if"

Execution terminated

hope this help :)
Needs Regular Fix
 
Join Date: Jul 2008
Posts: 380
#4: Oct 4 '09

re: Having trouble with this source code


CD3DFont is never defined. It must be defined somewhere in the headers you had to include. Where did you get this code?
Newbie
 
Join Date: Oct 2009
Posts: 3
#5: Oct 4 '09

re: Having trouble with this source code


it's a code i had laying around from a website. i visit often, but as it is the headers are missing so i'll fix that and see how i get on
Reply