winblows.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #define WIN32_LEAN_AND_MEAN
  19. #include <windows.h>
  20. #include <windowsx.h>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <stdarg.h>
  24. #include "winblows.h"
  25. HINSTANCE Global_instance;
  26. LPSTR Global_commandline;
  27. int Global_commandshow;
  28. /*
  29. * WinMain - initialization, message loop
  30. */
  31. int PASCAL WinMain( HINSTANCE instance, HINSTANCE, char *command_line, int command_show)
  32. {
  33. //////MSG msg;
  34. Global_instance = instance;
  35. Global_commandline = command_line;
  36. Global_commandshow = command_show;
  37. int argc;
  38. char *argv[64];
  39. char path_to_exe[512];
  40. GetModuleFileName(instance,(char *)&path_to_exe,512);
  41. argc=1;
  42. argv[0]=path_to_exe;
  43. int command_scan=0;
  44. char command_char;
  45. do
  46. {
  47. /*
  48. ** Scan for non-space character on command line
  49. */
  50. do
  51. {
  52. command_char = *( command_line+command_scan++ );
  53. } while ( command_char==' ' );
  54. if ( command_char!=0 && command_char != 13 )
  55. {
  56. argv[argc++]=command_line+command_scan-1;
  57. /*
  58. ** Scan for space character on command line
  59. */
  60. do
  61. {
  62. command_char = *( command_line+command_scan++ );
  63. } while ( command_char!=' ' && command_char != 0 && command_char!=13);
  64. *( command_line+command_scan-1 ) = 0;
  65. }
  66. } while ( command_char != 0 && command_char != 13 && argc<20 );
  67. #ifdef MULTIPLAYERDEMO
  68. /*
  69. ** Force some command line arguments for console mode demo server.
  70. */
  71. /*
  72. ** If the user didn't specify a server.ini then add the default to the command line.
  73. */
  74. char temp[256];
  75. bool found = false;
  76. for (int i=1 ; i<argc ; i++) {
  77. strcpy(temp, argv[i]);
  78. strupr(temp);
  79. if (strstr(temp, "GAMESPYSERVER=")) {
  80. found = true;
  81. break;
  82. }
  83. }
  84. if (!found) {
  85. argv[argc++] = "GAMESPYSERVER=server.ini";
  86. }
  87. /*
  88. ** Add the 'NODX' flag. If it's already there, well, it's there twice now.
  89. */
  90. argv[argc++] = "/NODX";
  91. #endif //MULTIPLAYERDEMO
  92. return(main(argc,argv));
  93. } /* WinMain */
  94. int Print_WM(UINT message,char *out)
  95. {
  96. switch(message)
  97. {
  98. case WM_NULL:
  99. sprintf(out,"WM_NULL");
  100. break;
  101. case WM_CREATE:
  102. sprintf(out,"WM_CREATE");
  103. break;
  104. case WM_DESTROY:
  105. sprintf(out,"WM_DESTROY");
  106. break;
  107. case WM_CANCELMODE:
  108. sprintf(out,"WM_CANCELMODE");
  109. break;
  110. case WM_ERASEBKGND:
  111. sprintf(out,"WM_ERASEBKGND");
  112. break;
  113. case WM_GETTEXT:
  114. sprintf(out,"WM_GETTEXT");
  115. break;
  116. case WM_QUERYOPEN:
  117. sprintf(out,"WM_QUERYOPEN");
  118. break;
  119. case WM_MOVE:
  120. sprintf(out,"WM_MOVE");
  121. break;
  122. case WM_SIZE:
  123. sprintf(out,"WM_SIZE");
  124. break;
  125. case WM_ACTIVATE:
  126. sprintf(out,"WM_ACTIVATE");
  127. break;
  128. case WM_SETFOCUS:
  129. sprintf(out,"WM_SETFOCUS");
  130. break;
  131. case WM_KILLFOCUS:
  132. sprintf(out,"WM_KILLFOCUS");
  133. break;
  134. case WM_ENABLE:
  135. sprintf(out,"WM_ENABLE");
  136. break;
  137. case WM_SETREDRAW:
  138. sprintf(out,"WM_REDRAW");
  139. break;
  140. case WM_PAINT:
  141. sprintf(out,"WM_PAINT");
  142. break;
  143. case WM_CLOSE:
  144. sprintf(out,"WM_CLOSE");
  145. break;
  146. case WM_QUIT:
  147. sprintf(out,"WM_QUIT");
  148. break;
  149. case WM_ACTIVATEAPP:
  150. sprintf(out,"WM_ACTIVATEAPP");
  151. break;
  152. case WM_SETCURSOR:
  153. sprintf(out,"WM_SETCURSOR");
  154. break;
  155. case WM_KEYDOWN:
  156. sprintf(out,"WM_KEYDOWN");
  157. break;
  158. case WM_MOUSEMOVE:
  159. sprintf(out,"WM_MOUSEMOVE");
  160. break;
  161. case WM_WINDOWPOSCHANGING:
  162. sprintf(out,"WM_WINDOWPOSCHANGING");
  163. break;
  164. case WM_WINDOWPOSCHANGED:
  165. sprintf(out,"WM_WINDOWPOSCHANGED");
  166. break;
  167. case WM_DISPLAYCHANGE:
  168. sprintf(out,"WM_DISPLAYCHANGE");
  169. break;
  170. case WM_NCPAINT:
  171. sprintf(out,"WM_NCPAINT");
  172. break;
  173. case WM_PALETTEISCHANGING:
  174. sprintf(out,"WM_PALETTEISCHANGING");
  175. break;
  176. case WM_PALETTECHANGED:
  177. sprintf(out,"WM_PALETTECHANGED");
  178. break;
  179. case WM_NCACTIVATE:
  180. sprintf(out,"WM_NCACTIVATE");
  181. break;
  182. case WM_NCCALCSIZE:
  183. sprintf(out,"WM_NCCALCSIZE");
  184. break;
  185. case WM_SYSCOMMAND:
  186. sprintf(out,"WM_SYSCOMMAND");
  187. break;
  188. default:
  189. sprintf(out,"? UNKNOWN ?");
  190. return(-1);
  191. }
  192. return(0);
  193. }