MessageStream.cpp 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. ** Command & Conquer Generals(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // MessageStream.cpp
  24. // Implementation of the message stream
  25. // Author: Michael S. Booth, February 2001
  26. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  27. #include "Common/MessageStream.h"
  28. #include "Common/Player.h"
  29. #include "Common/PlayerList.h"
  30. #include "Common/Recorder.h"
  31. #include "GameClient/InGameUI.h"
  32. #include "GameLogic/GameLogic.h"
  33. /// The singleton message stream for messages going to TheGameLogic
  34. MessageStream *TheMessageStream = NULL;
  35. CommandList *TheCommandList = NULL;
  36. //------------------------------------------------------------------------------------------------
  37. // GameMessage
  38. //
  39. /**
  40. * Constructor
  41. */
  42. GameMessage::GameMessage( GameMessage::Type type )
  43. {
  44. m_playerIndex = ThePlayerList->getLocalPlayer()->getPlayerIndex();
  45. m_type = type;
  46. m_argList = NULL;
  47. m_argTail = NULL;
  48. m_argCount = 0;
  49. m_list = 0;
  50. }
  51. /**
  52. * Destructor
  53. */
  54. GameMessage::~GameMessage( )
  55. {
  56. // free all arguments
  57. GameMessageArgument *arg, *nextArg;
  58. for( arg = m_argList; arg; arg=nextArg )
  59. {
  60. nextArg = arg->m_next;
  61. arg->deleteInstance();
  62. }
  63. // detach message from list
  64. if (m_list)
  65. m_list->removeMessage( this );
  66. }
  67. /**
  68. * Return the given argument union.
  69. * @todo This should be a more list-like interface. Very inefficient.
  70. */
  71. const GameMessageArgumentType *GameMessage::getArgument( Int argIndex ) const
  72. {
  73. static const GameMessageArgumentType junk = { 0 };
  74. int i=0;
  75. for( GameMessageArgument *a = m_argList; a; a=a->m_next, i++ )
  76. if (i == argIndex)
  77. return &a->m_data;
  78. DEBUG_CRASH(("argument not found"));
  79. return &junk;
  80. }
  81. /**
  82. * Return the given argument data type
  83. */
  84. GameMessageArgumentDataType GameMessage::getArgumentDataType( Int argIndex )
  85. {
  86. if (argIndex >= m_argCount) {
  87. return ARGUMENTDATATYPE_UNKNOWN;
  88. }
  89. int i=0;
  90. for (GameMessageArgument *a = m_argList; a && (i < argIndex); a=a->m_next, ++i );
  91. if (a != NULL)
  92. {
  93. return a->m_type;
  94. }
  95. return ARGUMENTDATATYPE_UNKNOWN;
  96. }
  97. /**
  98. * Allocate a new argument, add it to the argument list, and increment the total arg count
  99. */
  100. GameMessageArgument *GameMessage::allocArg( void )
  101. {
  102. // allocate a new argument
  103. GameMessageArgument *arg = newInstance(GameMessageArgument);
  104. // add to end of argument list
  105. if (m_argTail)
  106. m_argTail->m_next = arg;
  107. else
  108. {
  109. m_argList = arg;
  110. m_argTail = arg;
  111. }
  112. arg->m_next = NULL;
  113. m_argTail = arg;
  114. m_argCount++;
  115. return arg;
  116. }
  117. /**
  118. * Append an integer argument
  119. */
  120. void GameMessage::appendIntegerArgument( Int arg )
  121. {
  122. GameMessageArgument *a = allocArg();
  123. a->m_data.integer = arg;
  124. a->m_type = ARGUMENTDATATYPE_INTEGER;
  125. }
  126. void GameMessage::appendRealArgument( Real arg )
  127. {
  128. GameMessageArgument *a = allocArg();
  129. a->m_data.real = arg;
  130. a->m_type = ARGUMENTDATATYPE_REAL;
  131. }
  132. void GameMessage::appendBooleanArgument( Bool arg )
  133. {
  134. GameMessageArgument *a = allocArg();
  135. a->m_data.boolean = arg;
  136. a->m_type = ARGUMENTDATATYPE_BOOLEAN;
  137. }
  138. void GameMessage::appendObjectIDArgument( ObjectID arg )
  139. {
  140. GameMessageArgument *a = allocArg();
  141. a->m_data.objectID = arg;
  142. a->m_type = ARGUMENTDATATYPE_OBJECTID;
  143. }
  144. void GameMessage::appendDrawableIDArgument( DrawableID arg )
  145. {
  146. GameMessageArgument *a = allocArg();
  147. a->m_data.drawableID = arg;
  148. a->m_type = ARGUMENTDATATYPE_DRAWABLEID;
  149. }
  150. void GameMessage::appendTeamIDArgument( UnsignedInt arg )
  151. {
  152. GameMessageArgument *a = allocArg();
  153. a->m_data.teamID = arg;
  154. a->m_type = ARGUMENTDATATYPE_TEAMID;
  155. }
  156. void GameMessage::appendLocationArgument( const Coord3D& arg )
  157. {
  158. GameMessageArgument *a = allocArg();
  159. a->m_data.location = arg;
  160. a->m_type = ARGUMENTDATATYPE_LOCATION;
  161. }
  162. void GameMessage::appendPixelArgument( const ICoord2D& arg )
  163. {
  164. GameMessageArgument *a = allocArg();
  165. a->m_data.pixel = arg;
  166. a->m_type = ARGUMENTDATATYPE_PIXEL;
  167. }
  168. void GameMessage::appendPixelRegionArgument( const IRegion2D& arg )
  169. {
  170. GameMessageArgument *a = allocArg();
  171. a->m_data.pixelRegion = arg;
  172. a->m_type = ARGUMENTDATATYPE_PIXELREGION;
  173. }
  174. void GameMessage::appendTimestampArgument( UnsignedInt arg )
  175. {
  176. GameMessageArgument *a = allocArg();
  177. a->m_data.timestamp = arg;
  178. a->m_type = ARGUMENTDATATYPE_TIMESTAMP;
  179. }
  180. void GameMessage::appendWideCharArgument( const WideChar& arg )
  181. {
  182. GameMessageArgument *a = allocArg();
  183. a->m_data.wChar = arg;
  184. a->m_type = ARGUMENTDATATYPE_WIDECHAR;
  185. }
  186. AsciiString GameMessage::getCommandAsAsciiString( void )
  187. {
  188. return getCommandTypeAsAsciiString(m_type);
  189. }
  190. AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
  191. {
  192. #define CHECK_IF(x) if (t == x) { return #x; }
  193. AsciiString commandName = "UnknownMessage";
  194. if (t >= GameMessage::MSG_COUNT)
  195. {
  196. commandName = "Invalid command";
  197. }
  198. CHECK_IF(MSG_INVALID)
  199. CHECK_IF(MSG_FRAME_TICK)
  200. CHECK_IF(MSG_RAW_MOUSE_BEGIN)
  201. CHECK_IF(MSG_RAW_MOUSE_POSITION)
  202. CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_DOWN)
  203. CHECK_IF(MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK)
  204. CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_UP)
  205. CHECK_IF(MSG_RAW_MOUSE_LEFT_CLICK)
  206. CHECK_IF(MSG_RAW_MOUSE_LEFT_DRAG)
  207. CHECK_IF(MSG_RAW_MOUSE_MIDDLE_BUTTON_DOWN)
  208. CHECK_IF(MSG_RAW_MOUSE_MIDDLE_DOUBLE_CLICK)
  209. CHECK_IF(MSG_RAW_MOUSE_MIDDLE_BUTTON_UP)
  210. CHECK_IF(MSG_RAW_MOUSE_MIDDLE_DRAG)
  211. CHECK_IF(MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN)
  212. CHECK_IF(MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK)
  213. CHECK_IF(MSG_RAW_MOUSE_RIGHT_BUTTON_UP)
  214. CHECK_IF(MSG_RAW_MOUSE_RIGHT_DRAG)
  215. CHECK_IF(MSG_RAW_MOUSE_WHEEL)
  216. CHECK_IF(MSG_RAW_MOUSE_END)
  217. CHECK_IF(MSG_RAW_KEY_DOWN)
  218. CHECK_IF(MSG_RAW_KEY_UP)
  219. CHECK_IF(MSG_MOUSE_LEFT_CLICK)
  220. CHECK_IF(MSG_MOUSE_LEFT_DOUBLE_CLICK)
  221. CHECK_IF(MSG_MOUSE_MIDDLE_CLICK)
  222. CHECK_IF(MSG_MOUSE_MIDDLE_DOUBLE_CLICK)
  223. CHECK_IF(MSG_MOUSE_RIGHT_CLICK)
  224. CHECK_IF(MSG_MOUSE_RIGHT_DOUBLE_CLICK)
  225. CHECK_IF(MSG_CLEAR_GAME_DATA)
  226. CHECK_IF(MSG_NEW_GAME)
  227. CHECK_IF(MSG_BEGIN_META_MESSAGES)
  228. CHECK_IF(MSG_META_SAVE_VIEW1)
  229. CHECK_IF(MSG_META_SAVE_VIEW2)
  230. CHECK_IF(MSG_META_SAVE_VIEW3)
  231. CHECK_IF(MSG_META_SAVE_VIEW4)
  232. CHECK_IF(MSG_META_SAVE_VIEW5)
  233. CHECK_IF(MSG_META_SAVE_VIEW6)
  234. CHECK_IF(MSG_META_SAVE_VIEW7)
  235. CHECK_IF(MSG_META_SAVE_VIEW8)
  236. CHECK_IF(MSG_META_VIEW_VIEW1)
  237. CHECK_IF(MSG_META_VIEW_VIEW2)
  238. CHECK_IF(MSG_META_VIEW_VIEW3)
  239. CHECK_IF(MSG_META_VIEW_VIEW4)
  240. CHECK_IF(MSG_META_VIEW_VIEW5)
  241. CHECK_IF(MSG_META_VIEW_VIEW6)
  242. CHECK_IF(MSG_META_VIEW_VIEW7)
  243. CHECK_IF(MSG_META_VIEW_VIEW8)
  244. CHECK_IF(MSG_META_CREATE_TEAM0)
  245. CHECK_IF(MSG_META_CREATE_TEAM1)
  246. CHECK_IF(MSG_META_CREATE_TEAM2)
  247. CHECK_IF(MSG_META_CREATE_TEAM3)
  248. CHECK_IF(MSG_META_CREATE_TEAM4)
  249. CHECK_IF(MSG_META_CREATE_TEAM5)
  250. CHECK_IF(MSG_META_CREATE_TEAM6)
  251. CHECK_IF(MSG_META_CREATE_TEAM7)
  252. CHECK_IF(MSG_META_CREATE_TEAM8)
  253. CHECK_IF(MSG_META_CREATE_TEAM9)
  254. CHECK_IF(MSG_META_SELECT_TEAM0)
  255. CHECK_IF(MSG_META_SELECT_TEAM1)
  256. CHECK_IF(MSG_META_SELECT_TEAM2)
  257. CHECK_IF(MSG_META_SELECT_TEAM3)
  258. CHECK_IF(MSG_META_SELECT_TEAM4)
  259. CHECK_IF(MSG_META_SELECT_TEAM5)
  260. CHECK_IF(MSG_META_SELECT_TEAM6)
  261. CHECK_IF(MSG_META_SELECT_TEAM7)
  262. CHECK_IF(MSG_META_SELECT_TEAM8)
  263. CHECK_IF(MSG_META_SELECT_TEAM9)
  264. CHECK_IF(MSG_META_ADD_TEAM0)
  265. CHECK_IF(MSG_META_ADD_TEAM1)
  266. CHECK_IF(MSG_META_ADD_TEAM2)
  267. CHECK_IF(MSG_META_ADD_TEAM3)
  268. CHECK_IF(MSG_META_ADD_TEAM4)
  269. CHECK_IF(MSG_META_ADD_TEAM5)
  270. CHECK_IF(MSG_META_ADD_TEAM6)
  271. CHECK_IF(MSG_META_ADD_TEAM7)
  272. CHECK_IF(MSG_META_ADD_TEAM8)
  273. CHECK_IF(MSG_META_ADD_TEAM9)
  274. CHECK_IF(MSG_META_VIEW_TEAM0)
  275. CHECK_IF(MSG_META_VIEW_TEAM1)
  276. CHECK_IF(MSG_META_VIEW_TEAM2)
  277. CHECK_IF(MSG_META_VIEW_TEAM3)
  278. CHECK_IF(MSG_META_VIEW_TEAM4)
  279. CHECK_IF(MSG_META_VIEW_TEAM5)
  280. CHECK_IF(MSG_META_VIEW_TEAM6)
  281. CHECK_IF(MSG_META_VIEW_TEAM7)
  282. CHECK_IF(MSG_META_VIEW_TEAM8)
  283. CHECK_IF(MSG_META_VIEW_TEAM9)
  284. CHECK_IF(MSG_META_SELECT_MATCHING_UNITS)
  285. CHECK_IF(MSG_META_SELECT_NEXT_UNIT)
  286. CHECK_IF(MSG_META_SELECT_PREV_UNIT)
  287. CHECK_IF(MSG_META_SELECT_NEXT_WORKER)
  288. CHECK_IF(MSG_META_SELECT_PREV_WORKER)
  289. CHECK_IF(MSG_META_VIEW_COMMAND_CENTER)
  290. CHECK_IF(MSG_META_VIEW_LAST_RADAR_EVENT)
  291. CHECK_IF(MSG_META_SELECT_HERO)
  292. CHECK_IF(MSG_META_SELECT_ALL)
  293. CHECK_IF(MSG_META_SCATTER)
  294. CHECK_IF(MSG_META_STOP)
  295. CHECK_IF(MSG_META_DEPLOY)
  296. CHECK_IF(MSG_META_CREATE_FORMATION)
  297. CHECK_IF(MSG_META_FOLLOW)
  298. CHECK_IF(MSG_META_CHAT_PLAYERS)
  299. CHECK_IF(MSG_META_CHAT_ALLIES)
  300. CHECK_IF(MSG_META_CHAT_EVERYONE)
  301. CHECK_IF(MSG_META_DIPLOMACY)
  302. CHECK_IF(MSG_META_OPTIONS)
  303. #if defined(_DEBUG) || defined(_INTERNAL)
  304. CHECK_IF(MSG_META_HELP)
  305. #endif
  306. CHECK_IF(MSG_META_TOGGLE_LOWER_DETAILS)
  307. CHECK_IF(MSG_META_TOGGLE_CONTROL_BAR)
  308. CHECK_IF(MSG_META_BEGIN_PATH_BUILD)
  309. CHECK_IF(MSG_META_END_PATH_BUILD)
  310. CHECK_IF(MSG_META_BEGIN_FORCEATTACK)
  311. CHECK_IF(MSG_META_END_FORCEATTACK)
  312. CHECK_IF(MSG_META_BEGIN_FORCEMOVE)
  313. CHECK_IF(MSG_META_END_FORCEMOVE)
  314. CHECK_IF(MSG_META_BEGIN_WAYPOINTS)
  315. CHECK_IF(MSG_META_END_WAYPOINTS)
  316. CHECK_IF(MSG_META_BEGIN_PREFER_SELECTION)
  317. CHECK_IF(MSG_META_END_PREFER_SELECTION)
  318. CHECK_IF(MSG_META_TAKE_SCREENSHOT)
  319. CHECK_IF(MSG_META_ALL_CHEER)
  320. CHECK_IF(MSG_META_TOGGLE_ATTACKMOVE)
  321. CHECK_IF(MSG_META_BEGIN_CAMERA_ROTATE_LEFT)
  322. CHECK_IF(MSG_META_END_CAMERA_ROTATE_LEFT)
  323. CHECK_IF(MSG_META_BEGIN_CAMERA_ROTATE_RIGHT)
  324. CHECK_IF(MSG_META_END_CAMERA_ROTATE_RIGHT)
  325. CHECK_IF(MSG_META_BEGIN_CAMERA_ZOOM_IN)
  326. CHECK_IF(MSG_META_END_CAMERA_ZOOM_IN)
  327. CHECK_IF(MSG_META_BEGIN_CAMERA_ZOOM_OUT)
  328. CHECK_IF(MSG_META_END_CAMERA_ZOOM_OUT)
  329. CHECK_IF(MSG_META_CAMERA_RESET)
  330. #if defined(_DEBUG) || defined(_INTERNAL)
  331. CHECK_IF(MSG_META_DEMO_TOGGLE_BEHIND_BUILDINGS)
  332. CHECK_IF(MSG_META_DEMO_TOGGLE_LETTERBOX)
  333. CHECK_IF(MSG_META_DEMO_TOGGLE_MESSAGE_TEXT)
  334. CHECK_IF(MSG_META_DEMO_LOD_DECREASE)
  335. CHECK_IF(MSG_META_DEMO_LOD_INCREASE)
  336. CHECK_IF(MSG_META_DEMO_TOGGLE_ZOOM_LOCK)
  337. CHECK_IF(MSG_META_DEMO_PLAY_CAMEO_MOVIE)
  338. CHECK_IF(MSG_META_DEMO_INSTANT_QUIT)
  339. CHECK_IF(MSG_META_DEMO_TOGGLE_SPECIAL_POWER_DELAYS)
  340. CHECK_IF(MSG_META_DEMO_BATTLE_CRY)
  341. CHECK_IF(MSG_META_DEMO_SWITCH_TEAMS)
  342. CHECK_IF(MSG_META_DEMO_SWITCH_TEAMS_BETWEEN_CHINA_USA)
  343. CHECK_IF(MSG_META_DEMO_TOGGLE_PARTICLEDEBUG)
  344. CHECK_IF(MSG_META_DEMO_TOGGLE_SHADOW_VOLUMES)
  345. CHECK_IF(MSG_META_DEMO_TOGGLE_FOGOFWAR)
  346. CHECK_IF(MSG_META_DEMO_KILL_ALL_ENEMIES)
  347. CHECK_IF(MSG_META_DEMO_KILL_SELECTION)
  348. CHECK_IF(MSG_META_DEMO_TOGGLE_HURT_ME_MODE)
  349. CHECK_IF(MSG_META_DEMO_TOGGLE_HAND_OF_GOD_MODE)
  350. CHECK_IF(MSG_META_DEMO_DEBUG_SELECTION)
  351. CHECK_IF(MSG_META_DEMO_LOCK_CAMERA_TO_SELECTION)
  352. CHECK_IF(MSG_META_DEMO_TOGGLE_SOUND)
  353. CHECK_IF(MSG_META_DEMO_TOGGLE_TRACKMARKS)
  354. CHECK_IF(MSG_META_DEMO_TOGGLE_WATERPLANE)
  355. CHECK_IF(MSG_META_DEMO_TIME_OF_DAY)
  356. CHECK_IF(MSG_META_DEMO_TOGGLE_MUSIC)
  357. CHECK_IF(MSG_META_DEMO_MUSIC_NEXT_TRACK)
  358. CHECK_IF(MSG_META_DEMO_MUSIC_PREV_TRACK)
  359. CHECK_IF(MSG_META_DEMO_NEXT_OBJECTIVE_MOVIE)
  360. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE1)
  361. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE2)
  362. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE3)
  363. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE4)
  364. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE5)
  365. CHECK_IF(MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE6)
  366. CHECK_IF(MSG_META_DEMO_BEGIN_ADJUST_PITCH)
  367. CHECK_IF(MSG_META_DEMO_END_ADJUST_PITCH)
  368. CHECK_IF(MSG_META_DEMO_BEGIN_ADJUST_FOV)
  369. CHECK_IF(MSG_META_DEMO_END_ADJUST_FOV)
  370. CHECK_IF(MSG_META_DEMO_LOCK_CAMERA_TO_PLANES)
  371. CHECK_IF(MSG_META_DEMO_REMOVE_PREREQ)
  372. CHECK_IF(MSG_META_DEMO_INSTANT_BUILD)
  373. CHECK_IF(MSG_META_DEMO_FREE_BUILD)
  374. CHECK_IF(MSG_META_DEMO_RUNSCRIPT1)
  375. CHECK_IF(MSG_META_DEMO_RUNSCRIPT2)
  376. CHECK_IF(MSG_META_DEMO_RUNSCRIPT3)
  377. CHECK_IF(MSG_META_DEMO_RUNSCRIPT4)
  378. CHECK_IF(MSG_META_DEMO_RUNSCRIPT5)
  379. CHECK_IF(MSG_META_DEMO_RUNSCRIPT6)
  380. CHECK_IF(MSG_META_DEMO_RUNSCRIPT7)
  381. CHECK_IF(MSG_META_DEMO_RUNSCRIPT8)
  382. CHECK_IF(MSG_META_DEMO_RUNSCRIPT9)
  383. CHECK_IF(MSG_META_DEMO_ENSHROUD)
  384. CHECK_IF(MSG_META_DEMO_DESHROUD)
  385. CHECK_IF(MSG_META_DEBUG_SHOW_EXTENTS)
  386. CHECK_IF(MSG_META_DEBUG_SHOW_HEALTH)
  387. CHECK_IF(MSG_META_DEBUG_GIVE_VETERANCY)
  388. CHECK_IF(MSG_META_DEBUG_TAKE_VETERANCY)
  389. CHECK_IF(MSG_META_DEMO_TOGGLE_AI_DEBUG)
  390. CHECK_IF(MSG_META_DEMO_TOGGLE_CAMERA_DEBUG)
  391. CHECK_IF(MSG_META_DEMO_TOGGLE_AVI)
  392. CHECK_IF(MSG_META_DEMO_TOGGLE_BW_VIEW)
  393. CHECK_IF(MSG_META_DEMO_TOGGLE_RED_VIEW)
  394. CHECK_IF(MSG_META_DEMO_TOGGLE_GREEN_VIEW)
  395. CHECK_IF(MSG_META_DEMO_TOGGLE_MOTION_BLUR_ZOOM)
  396. CHECK_IF(MSG_META_DEMO_TOGGLE_MILITARY_SUBTITLES)
  397. CHECK_IF(MSG_META_DEMO_ADD_CASH)
  398. #ifdef ALLOW_SURRENDER
  399. CHECK_IF(MSG_META_DEMO_TEST_SURRENDER)
  400. #endif
  401. CHECK_IF(MSG_META_DEMO_TOGGLE_RENDER)
  402. CHECK_IF(MSG_META_DEMO_KILL_AREA_SELECTION)
  403. CHECK_IF(MSG_META_DEMO_CYCLE_LOD_LEVEL)
  404. CHECK_IF(MSG_META_DEBUG_INCR_ANIM_SKATE_SPEED)
  405. CHECK_IF(MSG_META_DEBUG_DECR_ANIM_SKATE_SPEED)
  406. CHECK_IF(MSG_META_DEBUG_CYCLE_EXTENT_TYPE)
  407. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_MAJOR)
  408. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_MAJOR_BIG)
  409. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_MAJOR)
  410. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_MAJOR_BIG)
  411. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_MINOR)
  412. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_MINOR_BIG)
  413. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_MINOR)
  414. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_MINOR_BIG)
  415. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT)
  416. CHECK_IF(MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT_BIG)
  417. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT)
  418. CHECK_IF(MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT_BIG)
  419. CHECK_IF(MSG_META_DEBUG_VTUNE_ON)
  420. CHECK_IF(MSG_META_DEBUG_VTUNE_OFF)
  421. CHECK_IF(MSG_META_DEBUG_TOGGLE_FEATHER_WATER)
  422. CHECK_IF(MSG_META_DEBUG_DUMP_ASSETS)
  423. CHECK_IF(MSG_NO_DRAW)
  424. CHECK_IF(MSG_META_DEMO_TOGGLE_METRICS)
  425. CHECK_IF(MSG_META_DEMO_TOGGLE_PROJECTILEDEBUG)
  426. CHECK_IF(MSG_META_DEMO_TOGGLE_VISIONDEBUG)
  427. CHECK_IF(MSG_META_DEMO_TOGGLE_THREATDEBUG)
  428. CHECK_IF(MSG_META_DEMO_TOGGLE_CASHMAPDEBUG)
  429. CHECK_IF(MSG_META_DEMO_TOGGLE_GRAPHICALFRAMERATEBAR)
  430. CHECK_IF(MSG_META_DEMO_GIVE_ALL_SCIENCES)
  431. CHECK_IF(MSG_META_DEMO_GIVE_RANKLEVEL)
  432. CHECK_IF(MSG_META_DEMO_TAKE_RANKLEVEL)
  433. CHECK_IF(MSG_META_DEMO_GIVE_SCIENCEPURCHASEPOINTS)
  434. CHECK_IF(MSG_META_DEBUG_TOGGLE_NETWORK)
  435. CHECK_IF(MSG_META_DEBUG_DUMP_PLAYER_OBJECTS)
  436. CHECK_IF(MSG_META_DEBUG_DUMP_ALL_PLAYER_OBJECTS)
  437. CHECK_IF(MSG_META_DEBUG_WIN)
  438. CHECK_IF(MSG_META_DEMO_TOGGLE_DEBUG_STATS)
  439. #endif // defined(_DEBUG) || defined(_INTERNAL)
  440. #if defined(_INTERNAL) || defined(_DEBUG) || defined(_PLAYTEST)
  441. CHECK_IF(MSG_META_DEMO_TOGGLE_AUDIODEBUG)
  442. #endif//defined(_INTERNAL) || defined(_DEBUG) || defined(_PLAYTEST)
  443. #ifdef DUMP_PERF_STATS
  444. CHECK_IF(MSG_META_DEMO_PERFORM_STATISTICAL_DUMP)
  445. #endif//DUMP_PERF_STATS
  446. CHECK_IF(MSG_META_PLACE_BEACON)
  447. CHECK_IF(MSG_META_REMOVE_BEACON)
  448. CHECK_IF(MSG_END_META_MESSAGES)
  449. CHECK_IF(MSG_MOUSEOVER_DRAWABLE_HINT)
  450. CHECK_IF(MSG_MOUSEOVER_LOCATION_HINT)
  451. CHECK_IF(MSG_VALID_GUICOMMAND_HINT)
  452. CHECK_IF(MSG_INVALID_GUICOMMAND_HINT)
  453. CHECK_IF(MSG_AREA_SELECTION_HINT)
  454. CHECK_IF(MSG_DO_ATTACK_OBJECT_HINT)
  455. CHECK_IF(MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT)
  456. CHECK_IF(MSG_DO_FORCE_ATTACK_OBJECT_HINT)
  457. CHECK_IF(MSG_DO_FORCE_ATTACK_GROUND_HINT)
  458. CHECK_IF(MSG_GET_REPAIRED_HINT)
  459. CHECK_IF(MSG_GET_HEALED_HINT)
  460. CHECK_IF(MSG_DO_REPAIR_HINT)
  461. CHECK_IF(MSG_RESUME_CONSTRUCTION_HINT)
  462. CHECK_IF(MSG_ENTER_HINT)
  463. CHECK_IF(MSG_DOCK_HINT)
  464. CHECK_IF(MSG_DO_MOVETO_HINT)
  465. CHECK_IF(MSG_DO_ATTACKMOVETO_HINT)
  466. CHECK_IF(MSG_ADD_WAYPOINT_HINT)
  467. CHECK_IF(MSG_HIJACK_HINT)
  468. CHECK_IF(MSG_FIREBOMB_HINT)
  469. CHECK_IF(MSG_CONVERT_TO_CARBOMB_HINT)
  470. CHECK_IF(MSG_CAPTUREBUILDING_HINT)
  471. CHECK_IF(MSG_HACK_HINT)
  472. #ifdef ALLOW_SURRENDER
  473. CHECK_IF(MSG_PICK_UP_PRISONER_HINT)
  474. #endif
  475. CHECK_IF(MSG_SNIPE_VEHICLE_HINT)
  476. CHECK_IF(MSG_DEFECTOR_HINT)
  477. CHECK_IF(MSG_SET_RALLY_POINT_HINT)
  478. CHECK_IF(MSG_DO_SALVAGE_HINT)
  479. CHECK_IF(MSG_DO_INVALID_HINT)
  480. CHECK_IF(MSG_BEGIN_NETWORK_MESSAGES)
  481. CHECK_IF(MSG_CREATE_SELECTED_GROUP)
  482. CHECK_IF(MSG_CREATE_SELECTED_GROUP_NO_SOUND)
  483. CHECK_IF(MSG_DESTROY_SELECTED_GROUP)
  484. CHECK_IF(MSG_REMOVE_FROM_SELECTED_GROUP)
  485. CHECK_IF(MSG_SELECTED_GROUP_COMMAND)
  486. CHECK_IF(MSG_CREATE_TEAM0)
  487. CHECK_IF(MSG_CREATE_TEAM1)
  488. CHECK_IF(MSG_CREATE_TEAM2)
  489. CHECK_IF(MSG_CREATE_TEAM3)
  490. CHECK_IF(MSG_CREATE_TEAM4)
  491. CHECK_IF(MSG_CREATE_TEAM5)
  492. CHECK_IF(MSG_CREATE_TEAM6)
  493. CHECK_IF(MSG_CREATE_TEAM7)
  494. CHECK_IF(MSG_CREATE_TEAM8)
  495. CHECK_IF(MSG_CREATE_TEAM9)
  496. CHECK_IF(MSG_SELECT_TEAM0)
  497. CHECK_IF(MSG_SELECT_TEAM1)
  498. CHECK_IF(MSG_SELECT_TEAM2)
  499. CHECK_IF(MSG_SELECT_TEAM3)
  500. CHECK_IF(MSG_SELECT_TEAM4)
  501. CHECK_IF(MSG_SELECT_TEAM5)
  502. CHECK_IF(MSG_SELECT_TEAM6)
  503. CHECK_IF(MSG_SELECT_TEAM7)
  504. CHECK_IF(MSG_SELECT_TEAM8)
  505. CHECK_IF(MSG_SELECT_TEAM9)
  506. CHECK_IF(MSG_ADD_TEAM0)
  507. CHECK_IF(MSG_ADD_TEAM1)
  508. CHECK_IF(MSG_ADD_TEAM2)
  509. CHECK_IF(MSG_ADD_TEAM3)
  510. CHECK_IF(MSG_ADD_TEAM4)
  511. CHECK_IF(MSG_ADD_TEAM5)
  512. CHECK_IF(MSG_ADD_TEAM6)
  513. CHECK_IF(MSG_ADD_TEAM7)
  514. CHECK_IF(MSG_ADD_TEAM8)
  515. CHECK_IF(MSG_ADD_TEAM9)
  516. CHECK_IF(MSG_DO_ATTACKSQUAD)
  517. CHECK_IF(MSG_DO_WEAPON)
  518. CHECK_IF(MSG_DO_WEAPON_AT_LOCATION)
  519. CHECK_IF(MSG_DO_WEAPON_AT_OBJECT)
  520. CHECK_IF(MSG_DO_SPECIAL_POWER)
  521. CHECK_IF(MSG_DO_SPECIAL_POWER_AT_LOCATION)
  522. CHECK_IF(MSG_DO_SPECIAL_POWER_AT_OBJECT)
  523. CHECK_IF(MSG_SET_RALLY_POINT)
  524. CHECK_IF(MSG_PURCHASE_SCIENCE)
  525. CHECK_IF(MSG_QUEUE_UPGRADE)
  526. CHECK_IF(MSG_CANCEL_UPGRADE)
  527. CHECK_IF(MSG_QUEUE_UNIT_CREATE)
  528. CHECK_IF(MSG_CANCEL_UNIT_CREATE)
  529. CHECK_IF(MSG_DOZER_CONSTRUCT)
  530. CHECK_IF(MSG_DOZER_CONSTRUCT_LINE)
  531. CHECK_IF(MSG_DOZER_CANCEL_CONSTRUCT)
  532. CHECK_IF(MSG_SELL)
  533. CHECK_IF(MSG_EXIT)
  534. CHECK_IF(MSG_EVACUATE)
  535. CHECK_IF(MSG_EXECUTE_RAILED_TRANSPORT)
  536. CHECK_IF(MSG_COMBATDROP_AT_LOCATION)
  537. CHECK_IF(MSG_COMBATDROP_AT_OBJECT)
  538. CHECK_IF(MSG_AREA_SELECTION)
  539. CHECK_IF(MSG_DO_ATTACK_OBJECT)
  540. CHECK_IF(MSG_DO_FORCE_ATTACK_OBJECT)
  541. CHECK_IF(MSG_DO_FORCE_ATTACK_GROUND)
  542. CHECK_IF(MSG_GET_REPAIRED)
  543. CHECK_IF(MSG_GET_HEALED)
  544. CHECK_IF(MSG_DO_REPAIR)
  545. CHECK_IF(MSG_RESUME_CONSTRUCTION)
  546. CHECK_IF(MSG_ENTER)
  547. CHECK_IF(MSG_DOCK)
  548. CHECK_IF(MSG_DO_MOVETO)
  549. CHECK_IF(MSG_DO_ATTACKMOVETO)
  550. CHECK_IF(MSG_DO_FORCEMOVETO)
  551. CHECK_IF(MSG_ADD_WAYPOINT)
  552. CHECK_IF(MSG_DO_GUARD_POSITION)
  553. CHECK_IF(MSG_DO_GUARD_OBJECT)
  554. CHECK_IF(MSG_DO_STOP)
  555. CHECK_IF(MSG_DO_SCATTER)
  556. CHECK_IF(MSG_INTERNET_HACK)
  557. CHECK_IF(MSG_DO_CHEER)
  558. #ifdef ALLOW_SURRENDER
  559. CHECK_IF(MSG_DO_SURRENDER)
  560. #endif
  561. CHECK_IF(MSG_TOGGLE_OVERCHARGE)
  562. #ifdef ALLOW_SURRENDER
  563. CHECK_IF(MSG_RETURN_TO_PRISON)
  564. #endif
  565. CHECK_IF(MSG_SWITCH_WEAPONS)
  566. CHECK_IF(MSG_CONVERT_TO_CARBOMB)
  567. CHECK_IF(MSG_CAPTUREBUILDING)
  568. CHECK_IF(MSG_DISABLEVEHICLE_HACK)
  569. CHECK_IF(MSG_STEALCASH_HACK)
  570. CHECK_IF(MSG_DISABLEBUILDING_HACK)
  571. CHECK_IF(MSG_SNIPE_VEHICLE)
  572. #ifdef ALLOW_SURRENDER
  573. CHECK_IF(MSG_PICK_UP_PRISONER)
  574. #endif
  575. CHECK_IF(MSG_DO_SALVAGE)
  576. CHECK_IF(MSG_CLEAR_INGAME_POPUP_MESSAGE)
  577. CHECK_IF(MSG_PLACE_BEACON)
  578. CHECK_IF(MSG_REMOVE_BEACON)
  579. CHECK_IF(MSG_SET_BEACON_TEXT)
  580. CHECK_IF(MSG_SET_REPLAY_CAMERA)
  581. CHECK_IF(MSG_SELF_DESTRUCT)
  582. CHECK_IF(MSG_CREATE_FORMATION)
  583. CHECK_IF(MSG_LOGIC_CRC)
  584. #if defined(_DEBUG) || defined(_INTERNAL)
  585. CHECK_IF(MSG_DEBUG_KILL_SELECTION)
  586. CHECK_IF(MSG_DEBUG_HURT_OBJECT)
  587. CHECK_IF(MSG_DEBUG_KILL_OBJECT)
  588. #endif
  589. CHECK_IF(MSG_END_NETWORK_MESSAGES)
  590. CHECK_IF(MSG_TIMESTAMP)
  591. CHECK_IF(MSG_OBJECT_CREATED)
  592. CHECK_IF(MSG_OBJECT_DESTROYED)
  593. CHECK_IF(MSG_OBJECT_POSITION)
  594. CHECK_IF(MSG_OBJECT_ORIENTATION)
  595. CHECK_IF(MSG_OBJECT_JOINED_TEAM)
  596. CHECK_IF(MSG_SET_MINE_CLEARING_DETAIL)
  597. return commandName;
  598. }
  599. //------------------------------------------------------------------------------------------------
  600. // GameMessageList
  601. //
  602. /**
  603. * Constructor
  604. */
  605. GameMessageList::GameMessageList( void )
  606. {
  607. m_firstMessage = 0;
  608. m_lastMessage = 0;
  609. }
  610. /**
  611. * Destructor
  612. */
  613. GameMessageList::~GameMessageList()
  614. {
  615. // destroy all messages currently on the list
  616. GameMessage *msg, *nextMsg;
  617. for( msg = m_firstMessage; msg; msg = nextMsg )
  618. {
  619. nextMsg = msg->next();
  620. // set list ptr to null to avoid it trying to remove itself from the list
  621. // that we are in the process of nuking...
  622. msg->friend_setList(NULL);
  623. msg->deleteInstance();
  624. }
  625. }
  626. /**
  627. * Append message to end of message list
  628. */
  629. void GameMessageList::appendMessage( GameMessage *msg )
  630. {
  631. msg->friend_setNext(NULL);
  632. if (m_lastMessage)
  633. {
  634. m_lastMessage->friend_setNext(msg);
  635. msg->friend_setPrev(m_lastMessage);
  636. m_lastMessage = msg;
  637. }
  638. else
  639. {
  640. // first message
  641. m_firstMessage = msg;
  642. m_lastMessage = msg;
  643. msg->friend_setPrev(NULL);
  644. }
  645. // note containment within message itself
  646. msg->friend_setList(this);
  647. }
  648. /**
  649. * Inserts the msg after messageToInsertAfter.
  650. */
  651. void GameMessageList::insertMessage( GameMessage *msg, GameMessage *messageToInsertAfter )
  652. {
  653. // First, set msg's next to be messageToInsertAfter's next.
  654. msg->friend_setNext(messageToInsertAfter->next());
  655. // Next, set msg's prev to be messageToInsertAfter
  656. msg->friend_setPrev(messageToInsertAfter);
  657. // Now update the next message's prev to be msg
  658. if (msg->next())
  659. msg->next()->friend_setPrev(msg);
  660. else // if the friend wasn't there, then messageToInsertAfter is the last message. Update it to be msg.
  661. m_lastMessage = msg;
  662. // Finally, update the messageToInsertAfter's next to be msg
  663. messageToInsertAfter->friend_setNext(msg);
  664. // note containment within the message itself
  665. msg->friend_setList(this);
  666. }
  667. /**
  668. * Remove given message from the list.
  669. */
  670. void GameMessageList::removeMessage( GameMessage *msg )
  671. {
  672. if (msg->next())
  673. msg->next()->friend_setPrev(msg->prev());
  674. else
  675. m_lastMessage = msg->prev();
  676. if (msg->prev())
  677. msg->prev()->friend_setNext(msg->next());
  678. else
  679. m_firstMessage = msg->next();
  680. msg->friend_setList(NULL);
  681. }
  682. /**
  683. * Return whether or not a message of the given type is in the message list
  684. */
  685. Bool GameMessageList::containsMessageOfType( GameMessage::Type type )
  686. {
  687. GameMessage *msg = getFirstMessage();
  688. while (msg) {
  689. if (msg->getType() == type) {
  690. return true;
  691. }
  692. msg = msg->next();
  693. }
  694. return false;
  695. }
  696. //------------------------------------------------------------------------------------------------
  697. // MessageStream
  698. //
  699. /**
  700. * Constructor
  701. */
  702. MessageStream::MessageStream( void )
  703. {
  704. m_firstTranslator = 0;
  705. m_nextTranslatorID = 1;
  706. }
  707. /**
  708. * Destructor
  709. */
  710. MessageStream::~MessageStream()
  711. {
  712. // destroy all translators
  713. TranslatorData *trans, *nextTrans;
  714. for( trans=m_firstTranslator; trans; trans=nextTrans )
  715. {
  716. nextTrans = trans->m_next;
  717. delete trans;
  718. }
  719. }
  720. /**
  721. * Init
  722. */
  723. void MessageStream::init( void )
  724. {
  725. // extend
  726. GameMessageList::init();
  727. }
  728. /**
  729. * Reset
  730. */
  731. void MessageStream::reset( void )
  732. {
  733. /// @todo Reset the MessageStream
  734. // extend
  735. GameMessageList::reset();
  736. }
  737. /**
  738. * Update
  739. */
  740. void MessageStream::update( void )
  741. {
  742. // extend
  743. GameMessageList::update();
  744. }
  745. /**
  746. * Create a new message of the given message type and append it
  747. * to this message stream. Return the message such that any data
  748. * associated with this message can be attached to it.
  749. */
  750. GameMessage *MessageStream::appendMessage( GameMessage::Type type )
  751. {
  752. GameMessage *msg = newInstance(GameMessage)( type );
  753. // add message to list
  754. GameMessageList::appendMessage( msg );
  755. return msg;
  756. }
  757. /**
  758. * Create a new message of the given message type and insert it
  759. * in the stream after messageToInsertAfter, which must not be NULL.
  760. */
  761. GameMessage *MessageStream::insertMessage( GameMessage::Type type, GameMessage *messageToInsertAfter )
  762. {
  763. GameMessage *msg = newInstance(GameMessage)(type);
  764. GameMessageList::insertMessage(msg, messageToInsertAfter);
  765. return msg;
  766. }
  767. /**
  768. * Attach the given Translator to the message stream, and return a
  769. * unique TranslatorID identifying it.
  770. * Translators are placed on a list, sorted by priority order. If two
  771. * Translators share a priority, they are kept in the same order they
  772. * were attached.
  773. */
  774. TranslatorID MessageStream::attachTranslator( GameMessageTranslator *translator,
  775. UnsignedInt priority)
  776. {
  777. MessageStream::TranslatorData *newSS = NEW MessageStream::TranslatorData;
  778. MessageStream::TranslatorData *ss;
  779. newSS->m_translator = translator;
  780. newSS->m_priority = priority;
  781. newSS->m_id = m_nextTranslatorID++;
  782. if (m_firstTranslator == NULL)
  783. {
  784. // first Translator to be attached
  785. newSS->m_prev = NULL;
  786. newSS->m_next = NULL;
  787. m_firstTranslator = newSS;
  788. m_lastTranslator = newSS;
  789. return newSS->m_id;
  790. }
  791. // seach the Translator list for our priority location
  792. for( ss=m_firstTranslator; ss; ss=ss->m_next )
  793. if (ss->m_priority > newSS->m_priority)
  794. break;
  795. if (ss)
  796. {
  797. // insert new Translator just BEFORE this one,
  798. // therefore, m_lastTranslator cannot be affected
  799. if (ss->m_prev)
  800. {
  801. ss->m_prev->m_next = newSS;
  802. newSS->m_prev = ss->m_prev;
  803. newSS->m_next = ss;
  804. ss->m_prev = newSS;
  805. }
  806. else
  807. {
  808. // insert at head of list
  809. newSS->m_prev = NULL;
  810. newSS->m_next = m_firstTranslator;
  811. m_firstTranslator->m_prev = newSS;
  812. m_firstTranslator = newSS;
  813. }
  814. }
  815. else
  816. {
  817. // append Translator to end of list
  818. m_lastTranslator->m_next = newSS;
  819. newSS->m_prev = m_lastTranslator;
  820. newSS->m_next = NULL;
  821. m_lastTranslator = newSS;
  822. }
  823. return newSS->m_id;
  824. }
  825. /**
  826. * Find a translator attached to this message stream given the ID
  827. */
  828. GameMessageTranslator* MessageStream::findTranslator( TranslatorID id )
  829. {
  830. MessageStream::TranslatorData *translatorData;
  831. for( translatorData = m_firstTranslator; translatorData; translatorData = translatorData->m_next )
  832. {
  833. if( translatorData->m_id == id )
  834. return translatorData->m_translator;
  835. }
  836. return NULL;
  837. }
  838. /**
  839. * Remove a previously attached translator.
  840. */
  841. void MessageStream::removeTranslator( TranslatorID id )
  842. {
  843. MessageStream::TranslatorData *ss;
  844. for( ss=m_firstTranslator; ss; ss=ss->m_next )
  845. if (ss->m_id == id)
  846. {
  847. // found the translator - remove it
  848. if (ss->m_prev)
  849. ss->m_prev->m_next = ss->m_next;
  850. else
  851. m_firstTranslator = ss->m_next;
  852. if (ss->m_next)
  853. ss->m_next->m_prev = ss->m_prev;
  854. else
  855. m_lastTranslator = ss->m_prev;
  856. // delete the translator data
  857. delete ss;
  858. break;
  859. }
  860. }
  861. // ------------------------------------------------------------------------------------------------
  862. // ------------------------------------------------------------------------------------------------
  863. #if defined(_DEBUG) || defined(_INTERNAL)
  864. Bool isInvalidDebugCommand( GameMessage::Type t )
  865. {
  866. // see if this is something that should be prevented in multiplayer games
  867. // Don't reject this stuff in skirmish games.
  868. if (TheGameLogic && !TheGameLogic->isInSkirmishGame() &&
  869. (TheRecorder && TheRecorder->isMultiplayer() && TheRecorder->getMode() == RECORDERMODETYPE_RECORD))
  870. {
  871. switch (t)
  872. {
  873. case GameMessage::MSG_META_DEMO_INSTANT_QUIT:
  874. case GameMessage::MSG_META_DEMO_SWITCH_TEAMS:
  875. case GameMessage::MSG_META_DEMO_SWITCH_TEAMS_BETWEEN_CHINA_USA:
  876. case GameMessage::MSG_META_DEMO_KILL_ALL_ENEMIES:
  877. case GameMessage::MSG_META_DEMO_KILL_SELECTION:
  878. case GameMessage::MSG_META_DEMO_TOGGLE_HURT_ME_MODE:
  879. case GameMessage::MSG_META_DEMO_TOGGLE_HAND_OF_GOD_MODE:
  880. case GameMessage::MSG_META_DEMO_TOGGLE_SPECIAL_POWER_DELAYS:
  881. case GameMessage::MSG_META_DEMO_TIME_OF_DAY:
  882. case GameMessage::MSG_META_DEMO_LOCK_CAMERA_TO_PLANES:
  883. case GameMessage::MSG_META_DEMO_REMOVE_PREREQ:
  884. case GameMessage::MSG_META_DEMO_INSTANT_BUILD:
  885. case GameMessage::MSG_META_DEMO_FREE_BUILD:
  886. case GameMessage::MSG_META_DEMO_RUNSCRIPT1:
  887. case GameMessage::MSG_META_DEMO_RUNSCRIPT2:
  888. case GameMessage::MSG_META_DEMO_RUNSCRIPT3:
  889. case GameMessage::MSG_META_DEMO_RUNSCRIPT4:
  890. case GameMessage::MSG_META_DEMO_RUNSCRIPT5:
  891. case GameMessage::MSG_META_DEMO_RUNSCRIPT6:
  892. case GameMessage::MSG_META_DEMO_RUNSCRIPT7:
  893. case GameMessage::MSG_META_DEMO_RUNSCRIPT8:
  894. case GameMessage::MSG_META_DEMO_RUNSCRIPT9:
  895. case GameMessage::MSG_META_DEMO_ENSHROUD:
  896. case GameMessage::MSG_META_DEMO_DESHROUD:
  897. case GameMessage::MSG_META_DEBUG_GIVE_VETERANCY:
  898. case GameMessage::MSG_META_DEBUG_TAKE_VETERANCY:
  899. //#pragma MESSAGE ("WARNING - DEBUG key in multiplayer!")
  900. case GameMessage::MSG_META_DEMO_ADD_CASH:
  901. case GameMessage::MSG_META_DEBUG_INCR_ANIM_SKATE_SPEED:
  902. case GameMessage::MSG_META_DEBUG_DECR_ANIM_SKATE_SPEED:
  903. case GameMessage::MSG_META_DEBUG_CYCLE_EXTENT_TYPE:
  904. case GameMessage::MSG_META_DEMO_TOGGLE_RENDER:
  905. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_MAJOR:
  906. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_MAJOR_BIG:
  907. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_MAJOR:
  908. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_MAJOR_BIG:
  909. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_MINOR:
  910. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_MINOR_BIG:
  911. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_MINOR:
  912. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_MINOR_BIG:
  913. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT:
  914. case GameMessage::MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT_BIG:
  915. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT:
  916. case GameMessage::MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT_BIG:
  917. case GameMessage::MSG_META_DEMO_KILL_AREA_SELECTION:
  918. case GameMessage::MSG_DEBUG_KILL_SELECTION:
  919. case GameMessage::MSG_DEBUG_HURT_OBJECT:
  920. case GameMessage::MSG_DEBUG_KILL_OBJECT:
  921. case GameMessage::MSG_META_DEMO_GIVE_SCIENCEPURCHASEPOINTS:
  922. case GameMessage::MSG_META_DEMO_GIVE_ALL_SCIENCES:
  923. case GameMessage::MSG_META_DEMO_GIVE_RANKLEVEL:
  924. case GameMessage::MSG_META_DEMO_TAKE_RANKLEVEL:
  925. case GameMessage::MSG_META_DEBUG_WIN:
  926. return true;
  927. }
  928. }
  929. return false;
  930. }
  931. #endif
  932. /**
  933. * Propagate messages thru attached Translators, invoking each Translator's
  934. * callback for each message in the stream.
  935. * Once all Translators have evaluated the message stream, all messages
  936. * in the stream are destroyed.
  937. */
  938. void MessageStream::propagateMessages( void )
  939. {
  940. MessageStream::TranslatorData *ss;
  941. GameMessage *msg, *next;
  942. // process each Translator
  943. for( ss=m_firstTranslator; ss; ss=ss->m_next )
  944. {
  945. for( msg=m_firstMessage; msg; msg=next )
  946. {
  947. if (ss->m_translator
  948. #if defined(_DEBUG) || defined(_INTERNAL)
  949. && !isInvalidDebugCommand(msg->getType())
  950. #endif
  951. )
  952. {
  953. GameMessageDisposition disp = ss->m_translator->translateGameMessage(msg);
  954. next = msg->next();
  955. if (disp == DESTROY_MESSAGE)
  956. {
  957. msg->deleteInstance();
  958. }
  959. }
  960. else
  961. {
  962. next = msg->next();
  963. }
  964. }
  965. }
  966. // transfer all messages that reached the end of the stream to TheCommandList
  967. TheCommandList->appendMessageList( m_firstMessage );
  968. // clear the stream
  969. m_firstMessage = NULL;
  970. m_lastMessage = NULL;
  971. }
  972. //------------------------------------------------------------------------------------------------
  973. // CommandList
  974. //
  975. /**
  976. * Constructor
  977. */
  978. CommandList::CommandList( void )
  979. {
  980. }
  981. /**
  982. * Destructor
  983. */
  984. CommandList::~CommandList()
  985. {
  986. destroyAllMessages();
  987. }
  988. /**
  989. * Init
  990. */
  991. void CommandList::init( void )
  992. {
  993. // extend
  994. GameMessageList::init();
  995. }
  996. /**
  997. * Destroy all messages on the list, and reset list to empty
  998. */
  999. void CommandList::reset( void )
  1000. {
  1001. // extend
  1002. GameMessageList::reset();
  1003. // destroy all messages
  1004. destroyAllMessages();
  1005. }
  1006. /**
  1007. * Update
  1008. */
  1009. void CommandList::update( void )
  1010. {
  1011. // extend
  1012. GameMessageList::update();
  1013. }
  1014. /**
  1015. * Destroy all messages on the command list, this will get called from the
  1016. * destructor and reset methods, DO NOT throw exceptions
  1017. */
  1018. void CommandList::destroyAllMessages( void )
  1019. {
  1020. GameMessage *msg, *next;
  1021. for( msg=m_firstMessage; msg; msg=next )
  1022. {
  1023. next = msg->next();
  1024. msg->deleteInstance();
  1025. }
  1026. m_firstMessage = NULL;
  1027. m_lastMessage = NULL;
  1028. }
  1029. /**
  1030. * Adds messages to the end of TheCommandList.
  1031. * Primarily used by TheMessageStream to put the final messages that reach the end of the
  1032. * stream on TheCommandList. Since TheGameClient will update faster than TheNetwork
  1033. * and TheGameLogic, messages will accumulate on this list.
  1034. */
  1035. void CommandList::appendMessageList( GameMessage *list )
  1036. {
  1037. GameMessage *msg, *next;
  1038. for( msg = list; msg; msg = next )
  1039. {
  1040. next = msg->next();
  1041. appendMessage( msg );
  1042. }
  1043. }
  1044. //-----------------------------------------------------------------------------
  1045. /**
  1046. * Given an "anchor" point and the current mouse position (dest),
  1047. * construct a valid 2D bounding region.
  1048. */
  1049. void buildRegion( const ICoord2D *anchor, const ICoord2D *dest, IRegion2D *region )
  1050. {
  1051. // build rectangular region defined by the drag selection
  1052. if (anchor->x < dest->x)
  1053. {
  1054. region->lo.x = anchor->x;
  1055. region->hi.x = dest->x;
  1056. }
  1057. else
  1058. {
  1059. region->lo.x = dest->x;
  1060. region->hi.x = anchor->x;
  1061. }
  1062. if (anchor->y < dest->y)
  1063. {
  1064. region->lo.y = anchor->y;
  1065. region->hi.y = dest->y;
  1066. }
  1067. else
  1068. {
  1069. region->lo.y = dest->y;
  1070. region->hi.y = anchor->y;
  1071. }
  1072. }