MessageStream.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. // FILE: MessageStream.h //////////////////////////////////////////////////////
  24. // The message stream propagates all messages thru a series of "translators"
  25. // Author: Michael S. Booth, February 2001
  26. #pragma once
  27. #ifndef _MESSAGE_STREAM_H_
  28. #define _MESSAGE_STREAM_H_
  29. #include "Common/GameCommon.h" // ensure we get DUMP_PERF_STATS, or not
  30. #include "Common/SubsystemInterface.h"
  31. #include "Lib/BaseType.h"
  32. #include "Common/GameMemory.h"
  33. enum { TRANSLATOR_ID_INVALID = -1 };
  34. // how far the the cursor moves before a click becomes a drag
  35. typedef UnsignedInt TranslatorID; ///< Unique identifiers for message stream translators
  36. class Drawable;
  37. class GameMessageList;
  38. enum ObjectID;
  39. enum DrawableID;
  40. union GameMessageArgumentType ///< Union of possible data for given message type
  41. {
  42. Int integer;
  43. Real real;
  44. Bool boolean;
  45. ObjectID objectID;
  46. DrawableID drawableID;
  47. UnsignedInt teamID;
  48. UnsignedInt squadID;
  49. Coord3D location;
  50. ICoord2D pixel;
  51. IRegion2D pixelRegion;
  52. UnsignedInt timestamp;
  53. WideChar wChar;
  54. };
  55. enum GameMessageArgumentDataType
  56. {
  57. ARGUMENTDATATYPE_INTEGER,
  58. ARGUMENTDATATYPE_REAL,
  59. ARGUMENTDATATYPE_BOOLEAN,
  60. ARGUMENTDATATYPE_OBJECTID,
  61. ARGUMENTDATATYPE_DRAWABLEID,
  62. ARGUMENTDATATYPE_TEAMID,
  63. ARGUMENTDATATYPE_LOCATION,
  64. ARGUMENTDATATYPE_PIXEL,
  65. ARGUMENTDATATYPE_PIXELREGION,
  66. ARGUMENTDATATYPE_TIMESTAMP,
  67. ARGUMENTDATATYPE_WIDECHAR,
  68. ARGUMENTDATATYPE_UNKNOWN
  69. };
  70. class GameMessageArgument : public MemoryPoolObject
  71. {
  72. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameMessageArgument, "GameMessageArgument")
  73. public:
  74. GameMessageArgument* m_next; ///< The next argument
  75. GameMessageArgumentType m_data; ///< The data storage of an argument
  76. GameMessageArgumentDataType m_type; ///< The type of the argument.
  77. };
  78. EMPTY_DTOR(GameMessageArgument)
  79. /**
  80. * A game message that either lives on TheMessageStream or TheCommandList.
  81. * Messages consist of a type, defining what the message is, and zero or more arguments
  82. * of various data types. The user of a message must know how many and what type of
  83. * arguments are valid for a given message type.
  84. */
  85. class GameMessage : public MemoryPoolObject
  86. {
  87. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameMessage, "GameMessage")
  88. public:
  89. /// The various messages which can be sent in a MessageStream
  90. /// @todo Replace this hardcoded enum with a generalized system that can be easily changed and updated
  91. /** @todo Because the Client will run faster than Logic, we'll need "superceding" messages for events
  92. such as mouse movements so we only send the latest one over the net */
  93. /** @todo Create two classes of message: raw input messages, and command messages. Raw input messages
  94. will be destroyed when they reach the end of the stream, whereas command messages will be
  95. transferred to TheCommandList */
  96. enum Type
  97. {
  98. MSG_INVALID, ///< (none) this msg should never actually occur
  99. MSG_FRAME_TICK, ///< (timestamp) once each frame this message is sent thru the stream
  100. // Client to Server messages
  101. // Note: Please keep MSG_RAW_MOUSE between MSG_RAW_MOUSE_BEGIN and MSG_RAW_MOUSE_END
  102. MSG_RAW_MOUSE_BEGIN,
  103. MSG_RAW_MOUSE_POSITION, ///< (pixel) the cursor's position
  104. MSG_RAW_MOUSE_LEFT_BUTTON_DOWN, ///< (pixel, modifiers, time)
  105. MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK, ///< (pixel, modifiers, time)
  106. MSG_RAW_MOUSE_LEFT_BUTTON_UP, ///< (pixel, modifiers, time)
  107. MSG_RAW_MOUSE_LEFT_CLICK, ///< (pixel, modifiers, time)
  108. MSG_RAW_MOUSE_LEFT_DRAG, ///< drag of the mouse with a button held down
  109. MSG_RAW_MOUSE_MIDDLE_BUTTON_DOWN, ///< (pixel, modifiers, time)
  110. MSG_RAW_MOUSE_MIDDLE_DOUBLE_CLICK, ///< (pixel, modifiers, time)
  111. MSG_RAW_MOUSE_MIDDLE_BUTTON_UP, ///< (pixel, modifiers, time)
  112. MSG_RAW_MOUSE_MIDDLE_DRAG, ///< drag of the mouse with a button held down
  113. MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, ///< (pixel, modifiers, time)
  114. MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK, ///< (pixel, modifiers, time)
  115. MSG_RAW_MOUSE_RIGHT_BUTTON_UP, ///< (pixel, modifiers, time)
  116. MSG_RAW_MOUSE_RIGHT_DRAG, ///< drag of the mouse with a button held down
  117. MSG_RAW_MOUSE_WHEEL, ///< (Int spin, + is away, - is toward user)
  118. MSG_RAW_MOUSE_END,
  119. MSG_RAW_KEY_DOWN, ///< (KeyDefType) the given key was pressed (uses Microsoft VK_ codes)
  120. MSG_RAW_KEY_UP, ///< (KeyDefType) the given key was released
  121. // Refined Mouse messages
  122. // NOTE: All processing should attempt to use these refined mouse messages, rather than the
  123. // RAW_* variants. (Please.) :-) jkmcd
  124. MSG_MOUSE_LEFT_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  125. MSG_MOUSE_LEFT_DOUBLE_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  126. MSG_MOUSE_MIDDLE_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  127. MSG_MOUSE_MIDDLE_DOUBLE_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  128. MSG_MOUSE_RIGHT_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  129. MSG_MOUSE_RIGHT_DOUBLE_CLICK, ///< (pixelRegion, 0 sized means its a point), (Int, modifier keys)
  130. // End Refined Mouse Messages
  131. MSG_CLEAR_GAME_DATA, ///< Clear all game data in memory
  132. MSG_NEW_GAME, ///< Start a new game
  133. // "meta" messages should be thought of as "virtual keystrokes" -- they exist
  134. // solely to provide an abstraction layer useful for keyboard/mouse remapping.
  135. // they should NEVER be sent over the network.
  136. MSG_BEGIN_META_MESSAGES, ///< Marker to delineate "meta" messages
  137. MSG_META_SAVE_VIEW1, ///< save current view as the given user-defined view
  138. MSG_META_SAVE_VIEW2, ///< save current view as the given user-defined view
  139. MSG_META_SAVE_VIEW3, ///< save current view as the given user-defined view
  140. MSG_META_SAVE_VIEW4, ///< save current view as the given user-defined view
  141. MSG_META_SAVE_VIEW5, ///< save current view as the given user-defined view
  142. MSG_META_SAVE_VIEW6, ///< save current view as the given user-defined view
  143. MSG_META_SAVE_VIEW7, ///< save current view as the given user-defined view
  144. MSG_META_SAVE_VIEW8, ///< save current view as the given user-defined view
  145. MSG_META_VIEW_VIEW1, ///< center view on the given user-defined view
  146. MSG_META_VIEW_VIEW2, ///< center view on the given user-defined view
  147. MSG_META_VIEW_VIEW3, ///< center view on the given user-defined view
  148. MSG_META_VIEW_VIEW4, ///< center view on the given user-defined view
  149. MSG_META_VIEW_VIEW5, ///< center view on the given user-defined view
  150. MSG_META_VIEW_VIEW6, ///< center view on the given user-defined view
  151. MSG_META_VIEW_VIEW7, ///< center view on the given user-defined view
  152. MSG_META_VIEW_VIEW8, ///< center view on the given user-defined view
  153. MSG_META_CREATE_TEAM0, ///< create user-defined team from the selected objects
  154. MSG_META_CREATE_TEAM1, ///< create user-defined team from the selected objects
  155. MSG_META_CREATE_TEAM2, ///< create user-defined team from the selected objects
  156. MSG_META_CREATE_TEAM3, ///< create user-defined team from the selected objects
  157. MSG_META_CREATE_TEAM4, ///< create user-defined team from the selected objects
  158. MSG_META_CREATE_TEAM5, ///< create user-defined team from the selected objects
  159. MSG_META_CREATE_TEAM6, ///< create user-defined team from the selected objects
  160. MSG_META_CREATE_TEAM7, ///< create user-defined team from the selected objects
  161. MSG_META_CREATE_TEAM8, ///< create user-defined team from the selected objects
  162. MSG_META_CREATE_TEAM9, ///< create user-defined team from the selected objects
  163. MSG_META_SELECT_TEAM0, ///< deselect all, then select all units in the given user-defined team
  164. MSG_META_SELECT_TEAM1, ///< deselect all, then select all units in the given user-defined team
  165. MSG_META_SELECT_TEAM2, ///< deselect all, then select all units in the given user-defined team
  166. MSG_META_SELECT_TEAM3, ///< deselect all, then select all units in the given user-defined team
  167. MSG_META_SELECT_TEAM4, ///< deselect all, then select all units in the given user-defined team
  168. MSG_META_SELECT_TEAM5, ///< deselect all, then select all units in the given user-defined team
  169. MSG_META_SELECT_TEAM6, ///< deselect all, then select all units in the given user-defined team
  170. MSG_META_SELECT_TEAM7, ///< deselect all, then select all units in the given user-defined team
  171. MSG_META_SELECT_TEAM8, ///< deselect all, then select all units in the given user-defined team
  172. MSG_META_SELECT_TEAM9, ///< deselect all, then select all units in the given user-defined team
  173. MSG_META_ADD_TEAM0, ///< add the user-defined team to the current selection
  174. MSG_META_ADD_TEAM1, ///< add the user-defined team to the current selection
  175. MSG_META_ADD_TEAM2, ///< add the user-defined team to the current selection
  176. MSG_META_ADD_TEAM3, ///< add the user-defined team to the current selection
  177. MSG_META_ADD_TEAM4, ///< add the user-defined team to the current selection
  178. MSG_META_ADD_TEAM5, ///< add the user-defined team to the current selection
  179. MSG_META_ADD_TEAM6, ///< add the user-defined team to the current selection
  180. MSG_META_ADD_TEAM7, ///< add the user-defined team to the current selection
  181. MSG_META_ADD_TEAM8, ///< add the user-defined team to the current selection
  182. MSG_META_ADD_TEAM9, ///< add the user-defined team to the current selection
  183. MSG_META_VIEW_TEAM0, ///< center view on given user-defined team (but do not affect selection)
  184. MSG_META_VIEW_TEAM1, ///< center view on given user-defined team (but do not affect selection)
  185. MSG_META_VIEW_TEAM2, ///< center view on given user-defined team (but do not affect selection)
  186. MSG_META_VIEW_TEAM3, ///< center view on given user-defined team (but do not affect selection)
  187. MSG_META_VIEW_TEAM4, ///< center view on given user-defined team (but do not affect selection)
  188. MSG_META_VIEW_TEAM5, ///< center view on given user-defined team (but do not affect selection)
  189. MSG_META_VIEW_TEAM6, ///< center view on given user-defined team (but do not affect selection)
  190. MSG_META_VIEW_TEAM7, ///< center view on given user-defined team (but do not affect selection)
  191. MSG_META_VIEW_TEAM8, ///< center view on given user-defined team (but do not affect selection)
  192. MSG_META_VIEW_TEAM9, ///< center view on given user-defined team (but do not affect selection)
  193. MSG_META_SELECT_MATCHING_UNITS, ///< selects mathcing units, used for both on screen and across map
  194. MSG_META_SELECT_NEXT_UNIT, ///< select 'next' unit
  195. MSG_META_SELECT_PREV_UNIT, ///< select 'prev' unit
  196. MSG_META_SELECT_NEXT_WORKER, ///< select 'next' worker
  197. MSG_META_SELECT_PREV_WORKER, ///< select 'prev' worker
  198. MSG_META_VIEW_COMMAND_CENTER, ///< center view on command center
  199. MSG_META_VIEW_LAST_RADAR_EVENT, ///< center view on last radar event
  200. MSG_META_SELECT_HERO, ///< selects player's hero character, if exists...
  201. MSG_META_SELECT_ALL, ///< selects all units across screen
  202. MSG_META_SCATTER, ///< selected units scatter
  203. MSG_META_STOP, ///< selected units stop
  204. MSG_META_DEPLOY, ///< selected units 'deploy'
  205. MSG_META_CREATE_FORMATION, ///< selected units become a formation
  206. MSG_META_FOLLOW, ///< selected units 'follow'
  207. MSG_META_CHAT_PLAYERS, ///< send chat msg to all players
  208. MSG_META_CHAT_ALLIES, ///< send chat msg to allied players
  209. MSG_META_CHAT_EVERYONE, ///< send chat msg to everyone (incl. observers)
  210. MSG_META_DIPLOMACY, ///< bring up diplomacy screen
  211. MSG_META_OPTIONS, ///< bring up options screen
  212. #if defined(_DEBUG) || defined(_INTERNAL)
  213. MSG_META_HELP, ///< bring up help screen
  214. #endif
  215. MSG_META_TOGGLE_LOWER_DETAILS, ///< toggles graphics options to crappy mode instantly
  216. MSG_META_TOGGLE_CONTROL_BAR, ///< show/hide controlbar
  217. MSG_META_BEGIN_PATH_BUILD, ///< enter path-building mode
  218. MSG_META_END_PATH_BUILD, ///< exit path-building mode
  219. MSG_META_BEGIN_FORCEATTACK, ///< enter force-attack mode
  220. MSG_META_END_FORCEATTACK, ///< exit force-attack mode
  221. MSG_META_BEGIN_FORCEMOVE, ///< enter force-move mode
  222. MSG_META_END_FORCEMOVE, ///< exit force-move mode
  223. MSG_META_BEGIN_WAYPOINTS, ///< enter waypoint mode
  224. MSG_META_END_WAYPOINTS, ///< exit waypoint mode
  225. MSG_META_BEGIN_PREFER_SELECTION, ///< The Shift key has been depressed alone
  226. MSG_META_END_PREFER_SELECTION, ///< The Shift key has been released.
  227. MSG_META_TAKE_SCREENSHOT, ///< take screenshot
  228. MSG_META_ALL_CHEER, ///< Yay! :)
  229. MSG_META_TOGGLE_ATTACKMOVE, ///< enter attack-move mode
  230. MSG_META_BEGIN_CAMERA_ROTATE_LEFT,
  231. MSG_META_END_CAMERA_ROTATE_LEFT,
  232. MSG_META_BEGIN_CAMERA_ROTATE_RIGHT,
  233. MSG_META_END_CAMERA_ROTATE_RIGHT,
  234. MSG_META_BEGIN_CAMERA_ZOOM_IN,
  235. MSG_META_END_CAMERA_ZOOM_IN,
  236. MSG_META_BEGIN_CAMERA_ZOOM_OUT,
  237. MSG_META_END_CAMERA_ZOOM_OUT,
  238. MSG_META_CAMERA_RESET,
  239. // META items that are really for debug/demo/development use only...
  240. // They do not get built into RELEASE builds.
  241. #if defined(_DEBUG) || defined(_INTERNAL)
  242. MSG_META_DEMO_TOGGLE_BEHIND_BUILDINGS, ///< Toggles showing units behind buildings or not
  243. MSG_META_DEMO_TOGGLE_LETTERBOX, ///< enable/disable letterbox mode
  244. MSG_META_DEMO_TOGGLE_MESSAGE_TEXT, ///< toggle the text from the UI messages
  245. MSG_META_DEMO_LOD_DECREASE, ///< decrease LOD by 1
  246. MSG_META_DEMO_LOD_INCREASE, ///< increase LOD by 1
  247. MSG_META_DEMO_TOGGLE_ZOOM_LOCK, ///< Toggle the camera zoom lock on/off
  248. MSG_META_DEMO_PLAY_CAMEO_MOVIE, ///< Play a movie in the cameo spot
  249. MSG_META_DEMO_INSTANT_QUIT, ///< bail out of game immediately
  250. MSG_META_DEMO_TOGGLE_SPECIAL_POWER_DELAYS, ///< Toggle special power delays on/off
  251. MSG_META_DEMO_BATTLE_CRY, ///< battle cry
  252. MSG_META_DEMO_SWITCH_TEAMS, ///< switch local control to another team
  253. MSG_META_DEMO_SWITCH_TEAMS_BETWEEN_CHINA_USA, ///< switch the local player between china and usa
  254. MSG_META_DEMO_TOGGLE_PARTICLEDEBUG, ///< show/hide the particle system debug info
  255. MSG_META_DEMO_TOGGLE_SHADOW_VOLUMES, ///< show/hide shadow volumes
  256. MSG_META_DEMO_TOGGLE_FOGOFWAR,
  257. MSG_META_DEMO_KILL_ALL_ENEMIES, ///< kill ALL ENEMIES! (yeah!)
  258. MSG_META_DEMO_KILL_SELECTION, ///< kill the selected units (yeah!)
  259. MSG_META_DEMO_TOGGLE_HURT_ME_MODE, ///< do 10% damage to the selected units (yeah!)
  260. MSG_META_DEMO_TOGGLE_HAND_OF_GOD_MODE, ///< do 100% damage to the selected units (w00t!)
  261. MSG_META_DEMO_DEBUG_SELECTION, ///< select a given unit for state-machine debugging
  262. MSG_META_DEMO_LOCK_CAMERA_TO_SELECTION, ///< lock the view camera to the selected object
  263. MSG_META_DEMO_TOGGLE_SOUND, ///< toggle sound/video on/off
  264. MSG_META_DEMO_TOGGLE_TRACKMARKS, ///< toggle tank tread marks on/off
  265. MSG_META_DEMO_TOGGLE_WATERPLANE, ///< toggle waterplane on/off
  266. MSG_META_DEMO_TIME_OF_DAY, ///< change time-of-day lighting
  267. MSG_META_DEMO_TOGGLE_MUSIC, ///< turn background music on/off
  268. MSG_META_DEMO_MUSIC_NEXT_TRACK, ///< play next track
  269. MSG_META_DEMO_MUSIC_PREV_TRACK, ///< play prev track
  270. MSG_META_DEMO_NEXT_OBJECTIVE_MOVIE, ///< play next "Objective" movie
  271. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE1, ///< play specific "Objective" movie
  272. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE2, ///< play specific "Objective" movie
  273. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE3, ///< play specific "Objective" movie
  274. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE4, ///< play specific "Objective" movie
  275. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE5, ///< play specific "Objective" movie
  276. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE6, ///< play specific "Objective" movie
  277. MSG_META_DEMO_BEGIN_ADJUST_PITCH, ///< enter adjust-pitch mode
  278. MSG_META_DEMO_END_ADJUST_PITCH, ///< exit adjust-pitch mode
  279. MSG_META_DEMO_BEGIN_ADJUST_FOV, ///< enter adjust-FOV mode
  280. MSG_META_DEMO_END_ADJUST_FOV, ///< exit adjust-FOV mode
  281. MSG_META_DEMO_LOCK_CAMERA_TO_PLANES, ///< lock camera to airborne thingies
  282. MSG_META_DEMO_REMOVE_PREREQ, ///< Turn of Prerequisite checks in building legality
  283. MSG_META_DEMO_INSTANT_BUILD, ///< All building is with a timer of 1
  284. MSG_META_DEMO_FREE_BUILD, ///< All building is for 0 money
  285. MSG_META_DEMO_RUNSCRIPT1, ///< run script named "KEY_F1"
  286. MSG_META_DEMO_RUNSCRIPT2, ///< run script named "KEY_F2"
  287. MSG_META_DEMO_RUNSCRIPT3, ///< run script named "KEY_F3"
  288. MSG_META_DEMO_RUNSCRIPT4, ///< run script named "KEY_F4"
  289. MSG_META_DEMO_RUNSCRIPT5, ///< run script named "KEY_F5"
  290. MSG_META_DEMO_RUNSCRIPT6, ///< run script named "KEY_F6"
  291. MSG_META_DEMO_RUNSCRIPT7, ///< run script named "KEY_F7"
  292. MSG_META_DEMO_RUNSCRIPT8, ///< run script named "KEY_F8"
  293. MSG_META_DEMO_RUNSCRIPT9, ///< run script named "KEY_F9"
  294. MSG_META_DEMO_ENSHROUD, ///< re-shroud the world for the local player
  295. MSG_META_DEMO_DESHROUD, ///< de-shroud the world for the local player
  296. MSG_META_DEBUG_SHOW_EXTENTS, ///< show object extents
  297. MSG_META_DEBUG_SHOW_HEALTH, ///< show object health
  298. MSG_META_DEBUG_GIVE_VETERANCY, ///< give a veterancy level to selected objects
  299. MSG_META_DEBUG_TAKE_VETERANCY, ///< take a veterancy level from selected objects
  300. MSG_META_DEMO_TOGGLE_AI_DEBUG, ///< show/hide the ai debug stats
  301. MSG_META_DEMO_TOGGLE_CAMERA_DEBUG, ///< show/hide the camera debug stats
  302. MSG_META_DEMO_TOGGLE_AVI, ///< start capturing video
  303. MSG_META_DEMO_TOGGLE_BW_VIEW, ///< enable/disable black & white camera mode
  304. MSG_META_DEMO_TOGGLE_RED_VIEW, ///< enable/disable red tinted view
  305. MSG_META_DEMO_TOGGLE_GREEN_VIEW, ///< enable/disable green view
  306. MSG_META_DEMO_TOGGLE_MOTION_BLUR_ZOOM, ///< enable/disable green view
  307. MSG_META_DEMO_TOGGLE_MILITARY_SUBTITLES, ///< enable/disable military subtitles
  308. MSG_META_DEMO_ADD_CASH, ///< adds 10000 cash to the player
  309. #ifdef ALLOW_SURRENDER
  310. MSG_META_DEMO_TEST_SURRENDER, ///< Test key to show surrender animation in game.
  311. #endif
  312. MSG_META_DEMO_TOGGLE_RENDER, ///< toggle rendering on/off
  313. MSG_META_DEMO_KILL_AREA_SELECTION, ///< (teamID, objectID1, objectID2, ... objectIDN)
  314. MSG_META_DEMO_CYCLE_LOD_LEVEL, ///< cycles through dynamic game detail levels.
  315. MSG_META_DEBUG_INCR_ANIM_SKATE_SPEED, ///< for debugging anim skate speeds
  316. MSG_META_DEBUG_DECR_ANIM_SKATE_SPEED, ///< for debugging anim skate speeds
  317. MSG_META_DEBUG_CYCLE_EXTENT_TYPE, ///< change extent
  318. MSG_META_DEBUG_INCREASE_EXTENT_MAJOR, ///< change extent
  319. MSG_META_DEBUG_INCREASE_EXTENT_MAJOR_BIG, ///< change extent
  320. MSG_META_DEBUG_DECREASE_EXTENT_MAJOR, ///< change extent
  321. MSG_META_DEBUG_DECREASE_EXTENT_MAJOR_BIG, ///< change extent
  322. MSG_META_DEBUG_INCREASE_EXTENT_MINOR, ///< change extent
  323. MSG_META_DEBUG_INCREASE_EXTENT_MINOR_BIG, ///< change extent
  324. MSG_META_DEBUG_DECREASE_EXTENT_MINOR, ///< change extent
  325. MSG_META_DEBUG_DECREASE_EXTENT_MINOR_BIG, ///< change extent
  326. MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT, ///< change extent
  327. MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT_BIG, ///< change extent
  328. MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT, ///< change extent
  329. MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT_BIG, ///< change extent
  330. MSG_META_DEBUG_VTUNE_ON, ///< turn on/off Vtune
  331. MSG_META_DEBUG_VTUNE_OFF, ///< turn on/off Vtune
  332. MSG_META_DEBUG_TOGGLE_FEATHER_WATER, ///< toggle lorenzen's feather water
  333. MSG_META_DEBUG_DUMP_ASSETS, ///< dumps currently used map assets to a file.
  334. MSG_NO_DRAW, ///< show/hide all objects to test Drawing code
  335. MSG_META_DEMO_TOGGLE_METRICS, ///< Toggle the metrics on/off
  336. MSG_META_DEMO_TOGGLE_PROJECTILEDEBUG, ///< Toggles bezier curves on projectiles on/off
  337. MSG_META_DEMO_TOGGLE_VISIONDEBUG, ///< Toggles vision debug circles on/off
  338. MSG_META_DEMO_TOGGLE_THREATDEBUG, ///< Toggle the threat debugger on/off
  339. MSG_META_DEMO_TOGGLE_CASHMAPDEBUG, ///< Toggle the cash map debugger on/off
  340. MSG_META_DEMO_TOGGLE_GRAPHICALFRAMERATEBAR, ///< Toggle the graphical framerate bar on/off
  341. MSG_META_DEMO_GIVE_ALL_SCIENCES, ///< grant all grantable sciences
  342. MSG_META_DEMO_GIVE_RANKLEVEL, ///< up one RankLevel
  343. MSG_META_DEMO_TAKE_RANKLEVEL, ///< up one RankLevel
  344. MSG_META_DEMO_GIVE_SCIENCEPURCHASEPOINTS, ///< give yourself an SPP (but no rank change)
  345. MSG_META_DEBUG_TOGGLE_NETWORK, ///< toggle between having and not having network traffic.
  346. MSG_META_DEBUG_DUMP_PLAYER_OBJECTS, ///< Dump numbers of objects owned by each player to the script debug window
  347. MSG_META_DEBUG_DUMP_ALL_PLAYER_OBJECTS, ///< Dump numbers of objects owned by each player to the script debug window, and additional object info
  348. MSG_META_DEBUG_WIN, ///< Instant Win
  349. MSG_META_DEMO_TOGGLE_DEBUG_STATS, ///< show/hide the debug stats
  350. /// @todo END section to REMOVE (not disable) for release
  351. #endif // defined(_DEBUG) || defined(_INTERNAL)
  352. #if defined(_INTERNAL) || defined(_DEBUG) || defined(_PLAYTEST)
  353. MSG_META_DEMO_TOGGLE_AUDIODEBUG, ///< show/hide the audio debug info
  354. #endif//defined(_INTERNAL) || defined(_DEBUG) || defined(_PLAYTEST)
  355. #ifdef DUMP_PERF_STATS
  356. MSG_META_DEMO_PERFORM_STATISTICAL_DUMP, ///< dump performance stats for this frame to StatisticsDump.txt
  357. #endif//DUMP_PERF_STATS
  358. MSG_META_PLACE_BEACON,
  359. MSG_META_REMOVE_BEACON,
  360. MSG_END_META_MESSAGES, ///< Marker to delineate "meta" messages
  361. MSG_MOUSEOVER_DRAWABLE_HINT, ///< (drawableid) the given drawable is under the mouse, regardless of button states
  362. MSG_MOUSEOVER_LOCATION_HINT, ///< (location) The cursor is not over a drawable, but is here.
  363. MSG_VALID_GUICOMMAND_HINT, ///< posted when the gui command is valid if the user clicked to execute it.
  364. MSG_INVALID_GUICOMMAND_HINT, ///< posted when the gui command is not valid if the user were to click to attempt to execute it.
  365. MSG_AREA_SELECTION_HINT, ///< (pixelRegion) rectangular selection area under construction, not confirmed
  366. //Command hints
  367. MSG_DO_ATTACK_OBJECT_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  368. MSG_IMPOSSIBLE_ATTACK_HINT, ///< we can't do anything, and target is out of range.
  369. MSG_DO_FORCE_ATTACK_OBJECT_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  370. MSG_DO_FORCE_ATTACK_GROUND_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  371. MSG_GET_REPAIRED_HINT, ///< If clicked, selected unit will go get repaired at clicked object
  372. MSG_GET_HEALED_HINT, ///< If clicked, selected unit will go get healed at clicked object
  373. MSG_DO_REPAIR_HINT, ///< if clicked, dozer will go repair the clicked target
  374. MSG_RESUME_CONSTRUCTION_HINT, ///< if clicked, dozer will go construct a partially constructed building
  375. MSG_ENTER_HINT, ///< if clicked, selected unit(s) will attempt to enter clicked object
  376. MSG_DOCK_HINT, ///< If clicked, selected unit(s) will dock
  377. MSG_DO_MOVETO_HINT, ///< (location) If clicked, a move would be ordered, "Current Selection" is assumed
  378. MSG_DO_ATTACKMOVETO_HINT, ///< (location) If clicked, a move would be ordered, "Current Selection" is assumed
  379. MSG_ADD_WAYPOINT_HINT, ///< (location) If clicked, a waypoint will be added for currently selected units.
  380. //Context command hints
  381. MSG_HIJACK_HINT, ///< if clicked, selected unit(s) will attempt to take over vehicle.
  382. MSG_FIREBOMB_HINT, ///< throw a molotov cocktail
  383. MSG_CONVERT_TO_CARBOMB_HINT, ///< if clicked, selected unit(s) will attempt to convert clicked object into a carbomb.
  384. MSG_CAPTUREBUILDING_HINT,
  385. #ifdef ALLOW_SURRENDER
  386. MSG_PICK_UP_PRISONER_HINT,
  387. #endif
  388. MSG_SNIPE_VEHICLE_HINT,
  389. MSG_DEFECTOR_HINT,
  390. MSG_SET_RALLY_POINT_HINT, ///< (location) if clicked, we will place a rally point here.
  391. MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION_HINT,
  392. MSG_DO_SALVAGE_HINT,
  393. MSG_DO_INVALID_HINT, ///< Display invalid cursor because no real command can be done in this context.
  394. MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT,
  395. MSG_HACK_HINT,
  396. //*********************************************************************************************************
  397. //*********************************************************************************************************
  398. /*
  399. Note that we start this at a fixed value, so that (regardless of ifdefs upstream from us) we have the same
  400. numeric values for all enums that are saved in replay files. This helps improve compatibility between
  401. replay files created in internal vs. release builds (though they will still generate sync errors in
  402. some situations due to other reasons, e.g., DEBUG_LOG using the FPU and thus changing its state).
  403. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  404. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  405. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  406. */
  407. MSG_BEGIN_NETWORK_MESSAGES = 1000, ///< MARKER TO DELINEATE MESSAGES THAT GO OVER THE NETWORK
  408. //*********************************************************************************************************
  409. MSG_CREATE_SELECTED_GROUP, /**< (Bool createNewGroup, objectID1, objectID2, ... objectIDN)
  410. * The selected team is created/augmented with the given team members
  411. */
  412. MSG_CREATE_SELECTED_GROUP_NO_SOUND, /**< (Bool createNewGroup, objectID1, objectID2, ... objectIDN)
  413. * The selected team is created/augmented with the given team members.
  414. * Do not play their selection sounds.
  415. */
  416. MSG_DESTROY_SELECTED_GROUP, ///< (teamID) the given team is no longer valid
  417. MSG_REMOVE_FROM_SELECTED_GROUP, /**< (objectID1, objectID2, ... objectIDN)
  418. * Remove these units from the selected group. (N should almost always be 1)
  419. */
  420. MSG_SELECTED_GROUP_COMMAND, ///< (teamID) the NEXT COMMAND acts upon all members of this team
  421. MSG_CREATE_TEAM0, ///< Creates a hotkey squad from the currently selected units.
  422. MSG_CREATE_TEAM1,
  423. MSG_CREATE_TEAM2,
  424. MSG_CREATE_TEAM3,
  425. MSG_CREATE_TEAM4,
  426. MSG_CREATE_TEAM5,
  427. MSG_CREATE_TEAM6,
  428. MSG_CREATE_TEAM7,
  429. MSG_CREATE_TEAM8,
  430. MSG_CREATE_TEAM9,
  431. MSG_SELECT_TEAM0, ///< Set a hotkey squad to be the currently selected units.
  432. MSG_SELECT_TEAM1, ///< Set a hotkey squad to be the currently selected units.
  433. MSG_SELECT_TEAM2, ///< Set a hotkey squad to be the currently selected units.
  434. MSG_SELECT_TEAM3, ///< Set a hotkey squad to be the currently selected units.
  435. MSG_SELECT_TEAM4, ///< Set a hotkey squad to be the currently selected units.
  436. MSG_SELECT_TEAM5, ///< Set a hotkey squad to be the currently selected units.
  437. MSG_SELECT_TEAM6, ///< Set a hotkey squad to be the currently selected units.
  438. MSG_SELECT_TEAM7, ///< Set a hotkey squad to be the currently selected units.
  439. MSG_SELECT_TEAM8, ///< Set a hotkey squad to be the currently selected units.
  440. MSG_SELECT_TEAM9, ///< Set a hotkey squad to be the currently selected units.
  441. MSG_ADD_TEAM0, ///< Add hotkey squad to the currently selected units.
  442. MSG_ADD_TEAM1, ///< Add hotkey squad to the currently selected units.
  443. MSG_ADD_TEAM2, ///< Add hotkey squad to the currently selected units.
  444. MSG_ADD_TEAM3, ///< Add hotkey squad to the currently selected units.
  445. MSG_ADD_TEAM4, ///< Add hotkey squad to the currently selected units.
  446. MSG_ADD_TEAM5, ///< Add hotkey squad to the currently selected units.
  447. MSG_ADD_TEAM6, ///< Add hotkey squad to the currently selected units.
  448. MSG_ADD_TEAM7, ///< Add hotkey squad to the currently selected units.
  449. MSG_ADD_TEAM8, ///< Add hotkey squad to the currently selected units.
  450. MSG_ADD_TEAM9, ///< Add hotkey squad to the currently selected units.
  451. MSG_DO_ATTACKSQUAD, ///< (numObjects) (numObjects * objectID)
  452. MSG_DO_WEAPON, ///< fire specific weapon
  453. MSG_DO_WEAPON_AT_LOCATION, ///< fire a specific weapon at location
  454. MSG_DO_WEAPON_AT_OBJECT, ///< fire a specific weapon at a target object
  455. MSG_DO_SPECIAL_POWER, ///< do special
  456. MSG_DO_SPECIAL_POWER_AT_LOCATION, ///< do special with target location
  457. MSG_DO_SPECIAL_POWER_AT_OBJECT, ///< do special at with target object
  458. MSG_SET_RALLY_POINT, ///< (objectID, location)
  459. MSG_PURCHASE_SCIENCE, ///< purchase a science
  460. MSG_QUEUE_UPGRADE, ///< queue the "research" of an upgrade
  461. MSG_CANCEL_UPGRADE, ///< cancel the "research" of an upgrade
  462. MSG_QUEUE_UNIT_CREATE, ///< clicked on a button to queue the production of a unit
  463. MSG_CANCEL_UNIT_CREATE, ///< clicked on UI button to cancel production of a unit
  464. MSG_DOZER_CONSTRUCT, /**< building things requires clicking on a dozer
  465. selecting what to build, selecting where to
  466. build it ... this construct message will
  467. start the actual build process */
  468. MSG_DOZER_CONSTRUCT_LINE, ///< Like MSG_CONSTRUCT, but for build procesess that occur in a line (like walls)
  469. MSG_DOZER_CANCEL_CONSTRUCT, ///< cancel construction of a building
  470. MSG_SELL, ///< sell a structure
  471. MSG_EXIT, ///< WE want to exit from whatever WE are inside of
  472. MSG_EVACUATE, ///< Dump out all of OUR contained objects
  473. MSG_EXECUTE_RAILED_TRANSPORT, ///< Execute railed transport sequence
  474. MSG_COMBATDROP_AT_LOCATION, ///< dump out all rappellers
  475. MSG_COMBATDROP_AT_OBJECT, ///< dump out all rappellers
  476. MSG_AREA_SELECTION, ///< (pixelRegion) rectangular selection area
  477. MSG_DO_ATTACK_OBJECT, ///< (objectID, victim objectID)
  478. MSG_DO_FORCE_ATTACK_OBJECT, ///< force attack the given object if picked
  479. MSG_DO_FORCE_ATTACK_GROUND, ///< (locationID) bombard the given location if picked
  480. MSG_GET_REPAIRED, ///< selected unit will go get repaired at clicked object
  481. MSG_GET_HEALED, ///< selected unit will go get healed at clicked object
  482. MSG_DO_REPAIR, ///< dozer will go repair the clicked target
  483. MSG_RESUME_CONSTRUCTION, ///< resume construction on a structure
  484. MSG_ENTER, ///< Enter object
  485. MSG_DOCK, ///< Dock with this object
  486. MSG_DO_MOVETO, ///< location
  487. MSG_DO_ATTACKMOVETO, ///< location
  488. MSG_DO_FORCEMOVETO, ///< location
  489. MSG_ADD_WAYPOINT, ///< location
  490. MSG_DO_GUARD_POSITION, ///< Guard with the currently selected group
  491. MSG_DO_GUARD_OBJECT, ///< Guard with the currently selected group
  492. MSG_DO_STOP, ///< Stop with the currently selected group
  493. MSG_DO_SCATTER, ///< Scatter the currently selected group
  494. MSG_INTERNET_HACK, ///< Begin a persistent internet hack (free slow income)
  495. MSG_DO_CHEER, ///< Orders selected units to play cheer animation (if possible)
  496. MSG_TOGGLE_OVERCHARGE, ///< Toggle overcharge status of a power plant
  497. MSG_SWITCH_WEAPONS, ///< Switches which weapon slot to use for an object
  498. MSG_CONVERT_TO_CARBOMB,
  499. MSG_CAPTUREBUILDING,
  500. MSG_DISABLEVEHICLE_HACK,
  501. MSG_STEALCASH_HACK,
  502. MSG_DISABLEBUILDING_HACK,
  503. MSG_SNIPE_VEHICLE,
  504. MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION,
  505. MSG_DO_SALVAGE,
  506. MSG_CLEAR_INGAME_POPUP_MESSAGE, ///< If we want a replay to work with the popup messages then we need it to be passed
  507. MSG_PLACE_BEACON,
  508. MSG_REMOVE_BEACON,
  509. MSG_SET_BEACON_TEXT,
  510. MSG_SET_REPLAY_CAMERA, ///< Track camera pos for replays
  511. MSG_SELF_DESTRUCT, ///< Destroys a player's units (for copy protection or to quit to observer)
  512. MSG_CREATE_FORMATION, ///< Creates a formation.
  513. MSG_LOGIC_CRC, ///< CRC from the logic passed around in a network game :)
  514. MSG_SET_MINE_CLEARING_DETAIL, ///< CRC from the logic passed around in a network game :)
  515. MSG_BEGIN_DEBUG_NETWORK_MESSAGES = 1900, ///< network messages that exist only in debug/internal builds. all grouped separately.
  516. #if defined(_DEBUG) || defined(_INTERNAL)
  517. // all debug/internal-only messages must go here.
  518. MSG_DEBUG_KILL_SELECTION,
  519. MSG_DEBUG_HURT_OBJECT,
  520. MSG_DEBUG_KILL_OBJECT,
  521. #endif
  522. //*********************************************************************************************************
  523. MSG_END_NETWORK_MESSAGES = 1999, ///< MARKER TO DELINEATE MESSAGES THAT GO OVER THE NETWORK
  524. //*********************************************************************************************************
  525. //*********************************************************************************************************
  526. // Server to Client messages
  527. MSG_TIMESTAMP, ///< The current frame number
  528. MSG_OBJECT_CREATED, ///< (objectID, Int type) Cause a drawable to be created and bound to this ID
  529. MSG_OBJECT_DESTROYED, ///< (objectID) Free bound drawable
  530. MSG_OBJECT_POSITION, ///< (objectID, location) New position of object
  531. MSG_OBJECT_ORIENTATION, ///< (objectID, angle) New orientation of object
  532. MSG_OBJECT_JOINED_TEAM, ///< (objectID) New team affiliation of object
  533. MSG_COUNT
  534. };
  535. GameMessage( Type type );
  536. GameMessage *next( void ) { return m_next; } ///< Return next message in the stream
  537. GameMessage *prev( void ) { return m_prev; } ///< Return prev message in the stream
  538. Type getType( void ) const { return m_type; } ///< Return the message type
  539. UnsignedByte getArgumentCount( void ) const { return m_argCount; } ///< Return the number of arguments for this msg
  540. AsciiString getCommandAsAsciiString( void ); ///< returns a string representation of the command type.
  541. static AsciiString getCommandTypeAsAsciiString(GameMessage::Type t);
  542. Int getPlayerIndex( void ) const { return m_playerIndex; } ///< Return the originating player
  543. // access methods for GameMessageArgumentType enum
  544. void appendIntegerArgument( Int arg );
  545. void appendRealArgument( Real arg );
  546. void appendBooleanArgument( Bool arg );
  547. void appendDrawableIDArgument( DrawableID arg );
  548. void appendObjectIDArgument( ObjectID arg );
  549. void appendTeamIDArgument( UnsignedInt arg );
  550. void appendLocationArgument( const Coord3D& arg );
  551. void appendPixelArgument( const ICoord2D& arg );
  552. void appendPixelRegionArgument( const IRegion2D& arg );
  553. void appendWideCharArgument( const WideChar& arg );
  554. void appendTimestampArgument( UnsignedInt arg );
  555. /**
  556. * Return the given argument union.
  557. * @todo This should be a more list-like interface. Very inefficient.
  558. */
  559. const GameMessageArgumentType *getArgument( Int argIndex ) const;
  560. GameMessageArgumentDataType getArgumentDataType( Int argIndex );
  561. void friend_setNext(GameMessage* m) { m_next = m; }
  562. void friend_setPrev(GameMessage* m) { m_prev = m; }
  563. void friend_setList(GameMessageList* m) { m_list = m; }
  564. void friend_setPlayerIndex(Int i) { m_playerIndex = i; }
  565. private:
  566. // friend classes are bad. don't use them. no, really.
  567. // if for no other reason than the fact that they subvert MemoryPoolObject. (srj)
  568. GameMessage *m_next, *m_prev; ///< List links for message list
  569. GameMessageList *m_list; ///< The list this message is on
  570. Type m_type; ///< The type of this message
  571. Int m_playerIndex; ///< The Player who issued the command
  572. /// @todo If a GameMessage needs more than 255 arguments, it needs to be split up into multiple GameMessage's.
  573. UnsignedByte m_argCount; ///< The number of arguments of this message
  574. GameMessageArgument *m_argList, *m_argTail; ///< This message's arguments
  575. /// allocate a new argument, add it to list, return pointer to its data
  576. GameMessageArgument *allocArg( void );
  577. };
  578. /**
  579. * The GameMessageList class encapsulates the manipulation of lists of GameMessages.
  580. * Both MessageStream and CommandList derive from this class.
  581. */
  582. class GameMessageList : public SubsystemInterface
  583. {
  584. public:
  585. GameMessageList( void );
  586. virtual ~GameMessageList();
  587. virtual void init( void ) { }; ///< Initialize system
  588. virtual void reset( void ) { }; ///< Reset system
  589. virtual void update( void ) { }; ///< Update system
  590. GameMessage *getFirstMessage( void ) { return m_firstMessage; } ///< Return the first message
  591. virtual void appendMessage( GameMessage *msg ); ///< Add message to end of the list
  592. virtual void insertMessage( GameMessage *msg, GameMessage *messageToInsertAfter ); // Insert message after messageToInsertAfter.
  593. virtual void removeMessage( GameMessage *msg ); ///< Remove message from the list
  594. virtual Bool containsMessageOfType( GameMessage::Type type ); ///< Return true if a message of type is in the message stream
  595. protected:
  596. GameMessage *m_firstMessage; ///< The first message on the list
  597. GameMessage *m_lastMessage; ///< The last message on the list
  598. };
  599. /**
  600. What to do with a GameMessage after a translator has handled it.
  601. Use a custom enum (rather than a Bool) to make the code more obvious.
  602. */
  603. enum GameMessageDisposition
  604. {
  605. KEEP_MESSAGE, ///< continue processing this message thru other translators
  606. DESTROY_MESSAGE ///< destroy this message immediately and don't hand it to any other translators
  607. };
  608. class GameMessageTranslator
  609. {
  610. public:
  611. virtual GameMessageDisposition translateGameMessage(const GameMessage *msg) = 0;
  612. virtual ~GameMessageTranslator() { }
  613. };
  614. /**
  615. * A MessageStream contains an ordered list of messages which can have one or more
  616. * prioritized message handler functions ("translators") attached to it.
  617. */
  618. class MessageStream : public GameMessageList
  619. {
  620. public:
  621. MessageStream( void );
  622. virtual ~MessageStream();
  623. // Inherited Methods ----------------------------------------------------------------------------
  624. virtual void init( void );
  625. virtual void reset( void );
  626. virtual void update( void );
  627. virtual GameMessage *appendMessage( GameMessage::Type type ); ///< Append a message to the end of the stream
  628. virtual GameMessage *insertMessage( GameMessage::Type type, GameMessage *messageToInsertAfter ); // Insert message after messageToInsertAfter.
  629. // Methods NOT Inherited ------------------------------------------------------------------------
  630. void propagateMessages( void ); ///< Propagate messages through attached translators
  631. /**
  632. Attach a translator function to the stream at a priority value. Lower priorities are executed first.
  633. Note that MessageStream assumes ownership of the translator, and is responsible for freeing it!
  634. */
  635. TranslatorID attachTranslator( GameMessageTranslator *translator, UnsignedInt priority);
  636. GameMessageTranslator* findTranslator( TranslatorID id );
  637. void removeTranslator( TranslatorID ); ///< Remove a previously attached translator
  638. protected:
  639. struct TranslatorData
  640. {
  641. TranslatorData *m_next, *m_prev; ///< List links for list of translators
  642. TranslatorID m_id; ///< The unique ID of this translator
  643. GameMessageTranslator *m_translator; ///< The translor's interface function
  644. UnsignedInt m_priority; ///< The priority level of this translator
  645. TranslatorData() : m_next(0), m_prev(0), m_id(0), m_translator(0), m_priority(0)
  646. {
  647. }
  648. ~TranslatorData()
  649. {
  650. delete m_translator;
  651. }
  652. };
  653. TranslatorData *m_firstTranslator; ///< List of registered translators, in order of priority
  654. TranslatorData *m_lastTranslator;
  655. TranslatorID m_nextTranslatorID; ///< For issuing unique translator ID's
  656. };
  657. /**
  658. * The CommandList is the final set of messages that have made their way through
  659. * all of the Translators of the MessageStream, and reached the end.
  660. * This set of commands will be executed by the GameLogic on its next iteration.
  661. */
  662. class CommandList : public GameMessageList
  663. {
  664. public:
  665. CommandList( void );
  666. virtual ~CommandList();
  667. virtual void init( void ); ///< Init command list
  668. virtual void reset( void ); ///< Destroy all messages and reset list to empty
  669. virtual void update( void ); ///< Update hook
  670. void appendMessageList( GameMessage *list ); ///< Adds messages to the end of the command list
  671. protected:
  672. void destroyAllMessages( void ); ///< The meat of a reset and a shutdown
  673. };
  674. //
  675. // The message stream that filters client input into game commands
  676. //
  677. extern MessageStream *TheMessageStream;
  678. //
  679. // The list of commands awaiting execution by the GameLogic
  680. //
  681. extern CommandList *TheCommandList;
  682. //-----------------------------------------------------------------------------
  683. //-----------------------------------------------------------------------------
  684. //-----------------------------------------------------------------------------
  685. // Functions used in multiple translators should go here.
  686. //
  687. /**
  688. * Given an "anchor" point and the current mouse position (dest),
  689. * construct a valid 2D bounding region.
  690. */
  691. extern void buildRegion( const ICoord2D *anchor, const ICoord2D *dest, IRegion2D *region );
  692. #endif // _MESSAGE_STREAM_H_