MessageStream.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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_SELECT_ALL_AIRCRAFT, ///< selects all air units just like select all
  203. MSG_META_SCATTER, ///< selected units scatter
  204. MSG_META_STOP, ///< selected units stop
  205. MSG_META_DEPLOY, ///< selected units 'deploy'
  206. MSG_META_CREATE_FORMATION, ///< selected units become a formation
  207. MSG_META_FOLLOW, ///< selected units 'follow'
  208. MSG_META_CHAT_PLAYERS, ///< send chat msg to all players
  209. MSG_META_CHAT_ALLIES, ///< send chat msg to allied players
  210. MSG_META_CHAT_EVERYONE, ///< send chat msg to everyone (incl. observers)
  211. MSG_META_DIPLOMACY, ///< bring up diplomacy screen
  212. MSG_META_OPTIONS, ///< bring up options screen
  213. #if defined(_DEBUG) || defined(_INTERNAL)
  214. MSG_META_HELP, ///< bring up help screen
  215. #endif
  216. MSG_META_TOGGLE_LOWER_DETAILS, ///< toggles graphics options to crappy mode instantly
  217. MSG_META_TOGGLE_CONTROL_BAR, ///< show/hide controlbar
  218. MSG_META_BEGIN_PATH_BUILD, ///< enter path-building mode
  219. MSG_META_END_PATH_BUILD, ///< exit path-building mode
  220. MSG_META_BEGIN_FORCEATTACK, ///< enter force-attack mode
  221. MSG_META_END_FORCEATTACK, ///< exit force-attack mode
  222. MSG_META_BEGIN_FORCEMOVE, ///< enter force-move mode
  223. MSG_META_END_FORCEMOVE, ///< exit force-move mode
  224. MSG_META_BEGIN_WAYPOINTS, ///< enter waypoint mode
  225. MSG_META_END_WAYPOINTS, ///< exit waypoint mode
  226. MSG_META_BEGIN_PREFER_SELECTION, ///< The Shift key has been depressed alone
  227. MSG_META_END_PREFER_SELECTION, ///< The Shift key has been released.
  228. MSG_META_TAKE_SCREENSHOT, ///< take screenshot
  229. MSG_META_ALL_CHEER, ///< Yay! :)
  230. MSG_META_TOGGLE_ATTACKMOVE, ///< enter attack-move mode
  231. MSG_META_BEGIN_CAMERA_ROTATE_LEFT,
  232. MSG_META_END_CAMERA_ROTATE_LEFT,
  233. MSG_META_BEGIN_CAMERA_ROTATE_RIGHT,
  234. MSG_META_END_CAMERA_ROTATE_RIGHT,
  235. MSG_META_BEGIN_CAMERA_ZOOM_IN,
  236. MSG_META_END_CAMERA_ZOOM_IN,
  237. MSG_META_BEGIN_CAMERA_ZOOM_OUT,
  238. MSG_META_END_CAMERA_ZOOM_OUT,
  239. MSG_META_CAMERA_RESET,
  240. MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE,
  241. MSG_META_TOGGLE_FAST_FORWARD_REPLAY, ///< Toggle the fast forward feature
  242. MSG_META_DEMO_INSTANT_QUIT, ///< bail out of game immediately
  243. #if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)//may be defined in GameCommon.h
  244. MSG_CHEAT_RUNSCRIPT1, ///< run script named "KEY_F1"
  245. MSG_CHEAT_RUNSCRIPT2, ///< run script named "KEY_F2"
  246. MSG_CHEAT_RUNSCRIPT3, ///< run script named "KEY_F3"
  247. MSG_CHEAT_RUNSCRIPT4, ///< run script named "KEY_F4"
  248. MSG_CHEAT_RUNSCRIPT5, ///< run script named "KEY_F5"
  249. MSG_CHEAT_RUNSCRIPT6, ///< run script named "KEY_F6"
  250. MSG_CHEAT_RUNSCRIPT7, ///< run script named "KEY_F7"
  251. MSG_CHEAT_RUNSCRIPT8, ///< run script named "KEY_F8"
  252. MSG_CHEAT_RUNSCRIPT9, ///< run script named "KEY_F9"
  253. MSG_CHEAT_TOGGLE_SPECIAL_POWER_DELAYS, ///< Toggle special power delays on/off
  254. MSG_CHEAT_SWITCH_TEAMS, ///< switch local control to another team
  255. MSG_CHEAT_KILL_SELECTION, ///< kill the selected units (yeah!)
  256. MSG_CHEAT_TOGGLE_HAND_OF_GOD_MODE, ///< do 100% damage to the selected units (w00t!)
  257. MSG_CHEAT_INSTANT_BUILD, ///< All building is with a timer of 1
  258. MSG_CHEAT_DESHROUD, ///< de-shroud the world for the local player
  259. MSG_CHEAT_ADD_CASH, ///< adds 10000 cash to the player
  260. MSG_CHEAT_GIVE_ALL_SCIENCES, ///< grant all grantable sciences
  261. MSG_CHEAT_GIVE_SCIENCEPURCHASEPOINTS, ///< give yourself an SPP (but no rank change)
  262. MSG_CHEAT_SHOW_HEALTH, ///< show object health
  263. MSG_CHEAT_TOGGLE_MESSAGE_TEXT, ///< hides/shows the onscreen messages
  264. #endif
  265. // META items that are really for debug/demo/development use only...
  266. // They do not get built into RELEASE builds.
  267. #if defined(_DEBUG) || defined(_INTERNAL)
  268. MSG_META_DEMO_TOGGLE_BEHIND_BUILDINGS, ///< Toggles showing units behind buildings or not
  269. MSG_META_DEMO_TOGGLE_LETTERBOX, ///< enable/disable letterbox mode
  270. MSG_META_DEMO_TOGGLE_MESSAGE_TEXT, ///< toggle the text from the UI messages
  271. MSG_META_DEMO_LOD_DECREASE, ///< decrease LOD by 1
  272. MSG_META_DEMO_LOD_INCREASE, ///< increase LOD by 1
  273. MSG_META_DEMO_TOGGLE_ZOOM_LOCK, ///< Toggle the camera zoom lock on/off
  274. MSG_META_DEMO_PLAY_CAMEO_MOVIE, ///< Play a movie in the cameo spot
  275. MSG_META_DEMO_TOGGLE_SPECIAL_POWER_DELAYS, ///< Toggle special power delays on/off
  276. MSG_META_DEMO_BATTLE_CRY, ///< battle cry
  277. MSG_META_DEMO_SWITCH_TEAMS, ///< switch local control to another team
  278. MSG_META_DEMO_SWITCH_TEAMS_BETWEEN_CHINA_USA, ///< switch the local player between china and usa
  279. MSG_META_DEMO_TOGGLE_PARTICLEDEBUG, ///< show/hide the particle system debug info
  280. MSG_META_DEMO_TOGGLE_SHADOW_VOLUMES, ///< show/hide shadow volumes
  281. MSG_META_DEMO_TOGGLE_FOGOFWAR,
  282. MSG_META_DEMO_KILL_ALL_ENEMIES, ///< kill ALL ENEMIES! (yeah!)
  283. MSG_META_DEMO_KILL_SELECTION, ///< kill the selected units (yeah!)
  284. MSG_META_DEMO_TOGGLE_HURT_ME_MODE, ///< do 10% damage to the selected units (yeah!)
  285. MSG_META_DEMO_TOGGLE_HAND_OF_GOD_MODE, ///< do 100% damage to the selected units (w00t!)
  286. MSG_META_DEMO_DEBUG_SELECTION, ///< select a given unit for state-machine debugging
  287. MSG_META_DEMO_LOCK_CAMERA_TO_SELECTION, ///< lock the view camera to the selected object
  288. MSG_META_DEMO_TOGGLE_SOUND, ///< toggle sound/video on/off
  289. MSG_META_DEMO_TOGGLE_TRACKMARKS, ///< toggle tank tread marks on/off
  290. MSG_META_DEMO_TOGGLE_WATERPLANE, ///< toggle waterplane on/off
  291. MSG_META_DEMO_TIME_OF_DAY, ///< change time-of-day lighting
  292. MSG_META_DEMO_TOGGLE_MUSIC, ///< turn background music on/off
  293. MSG_META_DEMO_MUSIC_NEXT_TRACK, ///< play next track
  294. MSG_META_DEMO_MUSIC_PREV_TRACK, ///< play prev track
  295. MSG_META_DEMO_NEXT_OBJECTIVE_MOVIE, ///< play next "Objective" movie
  296. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE1, ///< play specific "Objective" movie
  297. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE2, ///< play specific "Objective" movie
  298. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE3, ///< play specific "Objective" movie
  299. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE4, ///< play specific "Objective" movie
  300. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE5, ///< play specific "Objective" movie
  301. MSG_META_DEMO_PLAY_OBJECTIVE_MOVIE6, ///< play specific "Objective" movie
  302. MSG_META_DEMO_BEGIN_ADJUST_PITCH, ///< enter adjust-pitch mode
  303. MSG_META_DEMO_END_ADJUST_PITCH, ///< exit adjust-pitch mode
  304. MSG_META_DEMO_BEGIN_ADJUST_FOV, ///< enter adjust-FOV mode
  305. MSG_META_DEMO_END_ADJUST_FOV, ///< exit adjust-FOV mode
  306. MSG_META_DEMO_LOCK_CAMERA_TO_PLANES, ///< lock camera to airborne thingies
  307. MSG_META_DEMO_REMOVE_PREREQ, ///< Turn of Prerequisite checks in building legality
  308. MSG_META_DEMO_INSTANT_BUILD, ///< All building is with a timer of 1
  309. MSG_META_DEMO_FREE_BUILD, ///< All building is for 0 money
  310. MSG_META_DEMO_RUNSCRIPT1, ///< run script named "KEY_F1"
  311. MSG_META_DEMO_RUNSCRIPT2, ///< run script named "KEY_F2"
  312. MSG_META_DEMO_RUNSCRIPT3, ///< run script named "KEY_F3"
  313. MSG_META_DEMO_RUNSCRIPT4, ///< run script named "KEY_F4"
  314. MSG_META_DEMO_RUNSCRIPT5, ///< run script named "KEY_F5"
  315. MSG_META_DEMO_RUNSCRIPT6, ///< run script named "KEY_F6"
  316. MSG_META_DEMO_RUNSCRIPT7, ///< run script named "KEY_F7"
  317. MSG_META_DEMO_RUNSCRIPT8, ///< run script named "KEY_F8"
  318. MSG_META_DEMO_RUNSCRIPT9, ///< run script named "KEY_F9"
  319. MSG_META_DEMO_ENSHROUD, ///< re-shroud the world for the local player
  320. MSG_META_DEMO_DESHROUD, ///< de-shroud the world for the local player
  321. MSG_META_DEBUG_SHOW_EXTENTS, ///< show object extents
  322. MSG_META_DEBUG_SHOW_AUDIO_LOCATIONS, ///< show audio objects and radii
  323. MSG_META_DEBUG_SHOW_HEALTH, ///< show object health
  324. MSG_META_DEBUG_GIVE_VETERANCY, ///< give a veterancy level to selected objects
  325. MSG_META_DEBUG_TAKE_VETERANCY, ///< take a veterancy level from selected objects
  326. MSG_META_DEMO_TOGGLE_AI_DEBUG, ///< show/hide the ai debug stats
  327. MSG_META_DEMO_TOGGLE_SUPPLY_CENTER_PLACEMENT, ///<start/stop dumping to file all thoughts about placing SupplyCenters
  328. MSG_META_DEMO_TOGGLE_CAMERA_DEBUG, ///< show/hide the camera debug stats
  329. MSG_META_DEMO_TOGGLE_AVI, ///< start capturing video
  330. MSG_META_DEMO_TOGGLE_BW_VIEW, ///< enable/disable black & white camera mode
  331. MSG_META_DEMO_TOGGLE_RED_VIEW, ///< enable/disable red tinted view
  332. MSG_META_DEMO_TOGGLE_GREEN_VIEW, ///< enable/disable green view
  333. MSG_META_DEMO_TOGGLE_MOTION_BLUR_ZOOM, ///< enable/disable green view
  334. MSG_META_DEMO_TOGGLE_MILITARY_SUBTITLES, ///< enable/disable military subtitles
  335. MSG_META_DEMO_ADD_CASH, ///< adds 10000 cash to the player
  336. #ifdef ALLOW_SURRENDER
  337. MSG_META_DEMO_TEST_SURRENDER, ///< Test key to show surrender animation in game.
  338. #endif
  339. MSG_META_DEMO_TOGGLE_RENDER, ///< toggle rendering on/off
  340. MSG_META_DEMO_KILL_AREA_SELECTION, ///< (teamID, objectID1, objectID2, ... objectIDN)
  341. MSG_META_DEMO_CYCLE_LOD_LEVEL, ///< cycles through dynamic game detail levels.
  342. MSG_META_DEBUG_INCR_ANIM_SKATE_SPEED, ///< for debugging anim skate speeds
  343. MSG_META_DEBUG_DECR_ANIM_SKATE_SPEED, ///< for debugging anim skate speeds
  344. MSG_META_DEBUG_CYCLE_EXTENT_TYPE, ///< change extent
  345. MSG_META_DEBUG_INCREASE_EXTENT_MAJOR, ///< change extent
  346. MSG_META_DEBUG_INCREASE_EXTENT_MAJOR_BIG, ///< change extent
  347. MSG_META_DEBUG_DECREASE_EXTENT_MAJOR, ///< change extent
  348. MSG_META_DEBUG_DECREASE_EXTENT_MAJOR_BIG, ///< change extent
  349. MSG_META_DEBUG_INCREASE_EXTENT_MINOR, ///< change extent
  350. MSG_META_DEBUG_INCREASE_EXTENT_MINOR_BIG, ///< change extent
  351. MSG_META_DEBUG_DECREASE_EXTENT_MINOR, ///< change extent
  352. MSG_META_DEBUG_DECREASE_EXTENT_MINOR_BIG, ///< change extent
  353. MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT, ///< change extent
  354. MSG_META_DEBUG_INCREASE_EXTENT_HEIGHT_BIG, ///< change extent
  355. MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT, ///< change extent
  356. MSG_META_DEBUG_DECREASE_EXTENT_HEIGHT_BIG, ///< change extent
  357. MSG_META_DEBUG_VTUNE_ON, ///< turn on/off Vtune
  358. MSG_META_DEBUG_VTUNE_OFF, ///< turn on/off Vtune
  359. MSG_META_DEBUG_TOGGLE_FEATHER_WATER, ///< toggle lorenzen's feather water
  360. MSG_META_DEBUG_DUMP_ASSETS, ///< dumps currently used map assets to a file.
  361. MSG_NO_DRAW, ///< show/hide all objects to test Drawing code
  362. MSG_META_DEMO_TOGGLE_METRICS, ///< Toggle the metrics on/off
  363. MSG_META_DEMO_TOGGLE_PROJECTILEDEBUG, ///< Toggles bezier curves on projectiles on/off
  364. MSG_META_DEMO_TOGGLE_VISIONDEBUG, ///< Toggles vision debug circles on/off
  365. MSG_META_DEMO_TOGGLE_THREATDEBUG, ///< Toggle the threat debugger on/off
  366. MSG_META_DEMO_TOGGLE_CASHMAPDEBUG, ///< Toggle the cash map debugger on/off
  367. MSG_META_DEMO_TOGGLE_GRAPHICALFRAMERATEBAR, ///< Toggle the graphical framerate bar on/off
  368. MSG_META_DEMO_GIVE_ALL_SCIENCES, ///< grant all grantable sciences
  369. MSG_META_DEMO_GIVE_RANKLEVEL, ///< up one RankLevel
  370. MSG_META_DEMO_TAKE_RANKLEVEL, ///< up one RankLevel
  371. MSG_META_DEMO_GIVE_SCIENCEPURCHASEPOINTS, ///< give yourself an SPP (but no rank change)
  372. MSG_META_DEBUG_TOGGLE_NETWORK, ///< toggle between having and not having network traffic.
  373. MSG_META_DEBUG_DUMP_PLAYER_OBJECTS, ///< Dump numbers of objects owned by each player to the script debug window
  374. MSG_META_DEBUG_DUMP_ALL_PLAYER_OBJECTS, ///< Dump numbers of objects owned by each player to the script debug window, and additional object info
  375. MSG_META_DEBUG_OBJECT_ID_PERFORMANCE, ///< Run a mess of ObjectID lookups to see performance
  376. MSG_META_DEBUG_DRAWABLE_ID_PERFORMANCE, ///< Run a mess of DrawableID lookups to see performance
  377. MSG_META_DEBUG_SLEEPY_UPDATE_PERFORMANCE, ///< Peek at the size of the sleepy update vector
  378. MSG_META_DEBUG_WIN, ///< Instant Win
  379. MSG_META_DEMO_TOGGLE_DEBUG_STATS, ///< show/hide the debug stats
  380. /// @todo END section to REMOVE (not disable) for release
  381. #endif // defined(_DEBUG) || defined(_INTERNAL)
  382. #if defined(_INTERNAL) || defined(_DEBUG)
  383. MSG_META_DEMO_TOGGLE_AUDIODEBUG, ///< show/hide the audio debug info
  384. #endif//defined(_INTERNAL) || defined(_DEBUG)
  385. #ifdef DUMP_PERF_STATS
  386. MSG_META_DEMO_PERFORM_STATISTICAL_DUMP, ///< dump performance stats for this frame to StatisticsDump.txt
  387. #endif//DUMP_PERF_STATS
  388. MSG_META_PLACE_BEACON,
  389. MSG_META_REMOVE_BEACON,
  390. MSG_END_META_MESSAGES, ///< Marker to delineate "meta" messages
  391. MSG_MOUSEOVER_DRAWABLE_HINT, ///< (drawableid) the given drawable is under the mouse, regardless of button states
  392. MSG_MOUSEOVER_LOCATION_HINT, ///< (location) The cursor is not over a drawable, but is here.
  393. MSG_VALID_GUICOMMAND_HINT, ///< posted when the gui command is valid if the user clicked to execute it.
  394. MSG_INVALID_GUICOMMAND_HINT, ///< posted when the gui command is not valid if the user were to click to attempt to execute it.
  395. MSG_AREA_SELECTION_HINT, ///< (pixelRegion) rectangular selection area under construction, not confirmed
  396. //Command hints
  397. MSG_DO_ATTACK_OBJECT_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  398. MSG_IMPOSSIBLE_ATTACK_HINT, ///< we can't do anything, and target is out of range.
  399. MSG_DO_FORCE_ATTACK_OBJECT_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  400. MSG_DO_FORCE_ATTACK_GROUND_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
  401. MSG_GET_REPAIRED_HINT, ///< If clicked, selected unit will go get repaired at clicked object
  402. MSG_GET_HEALED_HINT, ///< If clicked, selected unit will go get healed at clicked object
  403. MSG_DO_REPAIR_HINT, ///< if clicked, dozer will go repair the clicked target
  404. MSG_RESUME_CONSTRUCTION_HINT, ///< if clicked, dozer will go construct a partially constructed building
  405. MSG_ENTER_HINT, ///< if clicked, selected unit(s) will attempt to enter clicked object
  406. MSG_DOCK_HINT, ///< If clicked, selected unit(s) will dock
  407. MSG_DO_MOVETO_HINT, ///< (location) If clicked, a move would be ordered, "Current Selection" is assumed
  408. MSG_DO_ATTACKMOVETO_HINT, ///< (location) If clicked, a move would be ordered, "Current Selection" is assumed
  409. MSG_ADD_WAYPOINT_HINT, ///< (location) If clicked, a waypoint will be added for currently selected units.
  410. //Context command hints
  411. MSG_HIJACK_HINT, ///< if clicked, selected unit(s) will attempt to take over vehicle.
  412. MSG_SABOTAGE_HINT,
  413. MSG_FIREBOMB_HINT, ///< throw a molotov cocktail
  414. MSG_CONVERT_TO_CARBOMB_HINT, ///< if clicked, selected unit(s) will attempt to convert clicked object into a carbomb.
  415. MSG_CAPTUREBUILDING_HINT,
  416. #ifdef ALLOW_SURRENDER
  417. MSG_PICK_UP_PRISONER_HINT,
  418. #endif
  419. MSG_SNIPE_VEHICLE_HINT,
  420. MSG_DEFECTOR_HINT,
  421. MSG_SET_RALLY_POINT_HINT, ///< (location) if clicked, we will place a rally point here.
  422. MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION_HINT,
  423. MSG_DO_SALVAGE_HINT,
  424. MSG_DO_INVALID_HINT, ///< Display invalid cursor because no real command can be done in this context.
  425. MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT,
  426. MSG_HACK_HINT,
  427. //*********************************************************************************************************
  428. //*********************************************************************************************************
  429. /*
  430. Note that we start this at a fixed value, so that (regardless of ifdefs upstream from us) we have the same
  431. numeric values for all enums that are saved in replay files. This helps improve compatibility between
  432. replay files created in internal vs. release builds (though they will still generate sync errors in
  433. some situations due to other reasons, e.g., DEBUG_LOG using the FPU and thus changing its state).
  434. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  435. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  436. there should be NO IFDEFS OF ANY KIND FROM HERE UNTIL MSG_END_NETWORK_MESSAGES.
  437. */
  438. MSG_BEGIN_NETWORK_MESSAGES = 1000, ///< MARKER TO DELINEATE MESSAGES THAT GO OVER THE NETWORK
  439. //*********************************************************************************************************
  440. MSG_CREATE_SELECTED_GROUP, /**< (Bool createNewGroup, objectID1, objectID2, ... objectIDN)
  441. * The selected team is created/augmented with the given team members
  442. */
  443. MSG_CREATE_SELECTED_GROUP_NO_SOUND, /**< (Bool createNewGroup, objectID1, objectID2, ... objectIDN)
  444. * The selected team is created/augmented with the given team members.
  445. * Do not play their selection sounds.
  446. */
  447. MSG_DESTROY_SELECTED_GROUP, ///< (teamID) the given team is no longer valid
  448. MSG_REMOVE_FROM_SELECTED_GROUP, /**< (objectID1, objectID2, ... objectIDN)
  449. * Remove these units from the selected group. (N should almost always be 1)
  450. */
  451. MSG_SELECTED_GROUP_COMMAND, ///< (teamID) the NEXT COMMAND acts upon all members of this team
  452. MSG_CREATE_TEAM0, ///< Creates a hotkey squad from the currently selected units.
  453. MSG_CREATE_TEAM1,
  454. MSG_CREATE_TEAM2,
  455. MSG_CREATE_TEAM3,
  456. MSG_CREATE_TEAM4,
  457. MSG_CREATE_TEAM5,
  458. MSG_CREATE_TEAM6,
  459. MSG_CREATE_TEAM7,
  460. MSG_CREATE_TEAM8,
  461. MSG_CREATE_TEAM9,
  462. MSG_SELECT_TEAM0, ///< Set a hotkey squad to be the currently selected units.
  463. MSG_SELECT_TEAM1, ///< Set a hotkey squad to be the currently selected units.
  464. MSG_SELECT_TEAM2, ///< Set a hotkey squad to be the currently selected units.
  465. MSG_SELECT_TEAM3, ///< Set a hotkey squad to be the currently selected units.
  466. MSG_SELECT_TEAM4, ///< Set a hotkey squad to be the currently selected units.
  467. MSG_SELECT_TEAM5, ///< Set a hotkey squad to be the currently selected units.
  468. MSG_SELECT_TEAM6, ///< Set a hotkey squad to be the currently selected units.
  469. MSG_SELECT_TEAM7, ///< Set a hotkey squad to be the currently selected units.
  470. MSG_SELECT_TEAM8, ///< Set a hotkey squad to be the currently selected units.
  471. MSG_SELECT_TEAM9, ///< Set a hotkey squad to be the currently selected units.
  472. MSG_ADD_TEAM0, ///< Add hotkey squad to the currently selected units.
  473. MSG_ADD_TEAM1, ///< Add hotkey squad to the currently selected units.
  474. MSG_ADD_TEAM2, ///< Add hotkey squad to the currently selected units.
  475. MSG_ADD_TEAM3, ///< Add hotkey squad to the currently selected units.
  476. MSG_ADD_TEAM4, ///< Add hotkey squad to the currently selected units.
  477. MSG_ADD_TEAM5, ///< Add hotkey squad to the currently selected units.
  478. MSG_ADD_TEAM6, ///< Add hotkey squad to the currently selected units.
  479. MSG_ADD_TEAM7, ///< Add hotkey squad to the currently selected units.
  480. MSG_ADD_TEAM8, ///< Add hotkey squad to the currently selected units.
  481. MSG_ADD_TEAM9, ///< Add hotkey squad to the currently selected units.
  482. MSG_DO_ATTACKSQUAD, ///< (numObjects) (numObjects * objectID)
  483. MSG_DO_WEAPON, ///< fire specific weapon
  484. MSG_DO_WEAPON_AT_LOCATION, ///< fire a specific weapon at location
  485. MSG_DO_WEAPON_AT_OBJECT, ///< fire a specific weapon at a target object
  486. MSG_DO_SPECIAL_POWER, ///< do special
  487. MSG_DO_SPECIAL_POWER_AT_LOCATION, ///< do special with target location
  488. MSG_DO_SPECIAL_POWER_AT_OBJECT, ///< do special at with target object
  489. MSG_SET_RALLY_POINT, ///< (objectID, location)
  490. MSG_PURCHASE_SCIENCE, ///< purchase a science
  491. MSG_QUEUE_UPGRADE, ///< queue the "research" of an upgrade
  492. MSG_CANCEL_UPGRADE, ///< cancel the "research" of an upgrade
  493. MSG_QUEUE_UNIT_CREATE, ///< clicked on a button to queue the production of a unit
  494. MSG_CANCEL_UNIT_CREATE, ///< clicked on UI button to cancel production of a unit
  495. MSG_DOZER_CONSTRUCT, /**< building things requires clicking on a dozer
  496. selecting what to build, selecting where to
  497. build it ... this construct message will
  498. start the actual build process */
  499. MSG_DOZER_CONSTRUCT_LINE, ///< Like MSG_CONSTRUCT, but for build procesess that occur in a line (like walls)
  500. MSG_DOZER_CANCEL_CONSTRUCT, ///< cancel construction of a building
  501. MSG_SELL, ///< sell a structure
  502. MSG_EXIT, ///< WE want to exit from whatever WE are inside of
  503. MSG_EVACUATE, ///< Dump out all of OUR contained objects
  504. MSG_EXECUTE_RAILED_TRANSPORT, ///< Execute railed transport sequence
  505. MSG_COMBATDROP_AT_LOCATION, ///< dump out all rappellers
  506. MSG_COMBATDROP_AT_OBJECT, ///< dump out all rappellers
  507. MSG_AREA_SELECTION, ///< (pixelRegion) rectangular selection area
  508. MSG_DO_ATTACK_OBJECT, ///< (objectID, victim objectID)
  509. MSG_DO_FORCE_ATTACK_OBJECT, ///< force attack the given object if picked
  510. MSG_DO_FORCE_ATTACK_GROUND, ///< (locationID) bombard the given location if picked
  511. MSG_GET_REPAIRED, ///< selected unit will go get repaired at clicked object
  512. MSG_GET_HEALED, ///< selected unit will go get healed at clicked object
  513. MSG_DO_REPAIR, ///< dozer will go repair the clicked target
  514. MSG_RESUME_CONSTRUCTION, ///< resume construction on a structure
  515. MSG_ENTER, ///< Enter object
  516. MSG_DOCK, ///< Dock with this object
  517. MSG_DO_MOVETO, ///< location
  518. MSG_DO_ATTACKMOVETO, ///< location
  519. MSG_DO_FORCEMOVETO, ///< location
  520. MSG_ADD_WAYPOINT, ///< location
  521. MSG_DO_GUARD_POSITION, ///< Guard with the currently selected group
  522. MSG_DO_GUARD_OBJECT, ///< Guard with the currently selected group
  523. MSG_DO_STOP, ///< Stop with the currently selected group
  524. MSG_DO_SCATTER, ///< Scatter the currently selected group
  525. MSG_INTERNET_HACK, ///< Begin a persistent internet hack (free slow income)
  526. MSG_DO_CHEER, ///< Orders selected units to play cheer animation (if possible)
  527. MSG_TOGGLE_OVERCHARGE, ///< Toggle overcharge status of a power plant
  528. MSG_SWITCH_WEAPONS, ///< Switches which weapon slot to use for an object
  529. MSG_CONVERT_TO_CARBOMB,
  530. MSG_CAPTUREBUILDING,
  531. MSG_DISABLEVEHICLE_HACK,
  532. MSG_STEALCASH_HACK,
  533. MSG_DISABLEBUILDING_HACK,
  534. MSG_SNIPE_VEHICLE,
  535. MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION,
  536. MSG_DO_SALVAGE,
  537. MSG_CLEAR_INGAME_POPUP_MESSAGE, ///< If we want a replay to work with the popup messages then we need it to be passed
  538. MSG_PLACE_BEACON,
  539. MSG_REMOVE_BEACON,
  540. MSG_SET_BEACON_TEXT,
  541. MSG_SET_REPLAY_CAMERA, ///< Track camera pos for replays
  542. MSG_SELF_DESTRUCT, ///< Destroys a player's units (for copy protection or to quit to observer)
  543. MSG_CREATE_FORMATION, ///< Creates a formation.
  544. MSG_LOGIC_CRC, ///< CRC from the logic passed around in a network game :)
  545. MSG_SET_MINE_CLEARING_DETAIL, ///< CRC from the logic passed around in a network game :)
  546. MSG_ENABLE_RETALIATION_MODE, ///< Turn retaliation mode on or off for the specified player.
  547. MSG_BEGIN_DEBUG_NETWORK_MESSAGES = 1900, ///< network messages that exist only in debug/internal builds. all grouped separately.
  548. #if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
  549. // all debug/internal-only messages must go here.
  550. MSG_DEBUG_KILL_SELECTION,
  551. MSG_DEBUG_HURT_OBJECT,
  552. MSG_DEBUG_KILL_OBJECT,
  553. #endif
  554. //*********************************************************************************************************
  555. MSG_END_NETWORK_MESSAGES = 1999, ///< MARKER TO DELINEATE MESSAGES THAT GO OVER THE NETWORK
  556. //*********************************************************************************************************
  557. //*********************************************************************************************************
  558. // Server to Client messages
  559. MSG_TIMESTAMP, ///< The current frame number
  560. MSG_OBJECT_CREATED, ///< (objectID, Int type) Cause a drawable to be created and bound to this ID
  561. MSG_OBJECT_DESTROYED, ///< (objectID) Free bound drawable
  562. MSG_OBJECT_POSITION, ///< (objectID, location) New position of object
  563. MSG_OBJECT_ORIENTATION, ///< (objectID, angle) New orientation of object
  564. MSG_OBJECT_JOINED_TEAM, ///< (objectID) New team affiliation of object
  565. MSG_COUNT
  566. };
  567. GameMessage( Type type );
  568. GameMessage *next( void ) { return m_next; } ///< Return next message in the stream
  569. GameMessage *prev( void ) { return m_prev; } ///< Return prev message in the stream
  570. Type getType( void ) const { return m_type; } ///< Return the message type
  571. UnsignedByte getArgumentCount( void ) const { return m_argCount; } ///< Return the number of arguments for this msg
  572. AsciiString getCommandAsAsciiString( void ); ///< returns a string representation of the command type.
  573. static AsciiString getCommandTypeAsAsciiString(GameMessage::Type t);
  574. Int getPlayerIndex( void ) const { return m_playerIndex; } ///< Return the originating player
  575. // access methods for GameMessageArgumentType enum
  576. void appendIntegerArgument( Int arg );
  577. void appendRealArgument( Real arg );
  578. void appendBooleanArgument( Bool arg );
  579. void appendDrawableIDArgument( DrawableID arg );
  580. void appendObjectIDArgument( ObjectID arg );
  581. void appendTeamIDArgument( UnsignedInt arg );
  582. void appendLocationArgument( const Coord3D& arg );
  583. void appendPixelArgument( const ICoord2D& arg );
  584. void appendPixelRegionArgument( const IRegion2D& arg );
  585. void appendWideCharArgument( const WideChar& arg );
  586. void appendTimestampArgument( UnsignedInt arg );
  587. /**
  588. * Return the given argument union.
  589. * @todo This should be a more list-like interface. Very inefficient.
  590. */
  591. const GameMessageArgumentType *getArgument( Int argIndex ) const;
  592. GameMessageArgumentDataType getArgumentDataType( Int argIndex );
  593. void friend_setNext(GameMessage* m) { m_next = m; }
  594. void friend_setPrev(GameMessage* m) { m_prev = m; }
  595. void friend_setList(GameMessageList* m) { m_list = m; }
  596. void friend_setPlayerIndex(Int i) { m_playerIndex = i; }
  597. private:
  598. // friend classes are bad. don't use them. no, really.
  599. // if for no other reason than the fact that they subvert MemoryPoolObject. (srj)
  600. GameMessage *m_next, *m_prev; ///< List links for message list
  601. GameMessageList *m_list; ///< The list this message is on
  602. Type m_type; ///< The type of this message
  603. Int m_playerIndex; ///< The Player who issued the command
  604. /// @todo If a GameMessage needs more than 255 arguments, it needs to be split up into multiple GameMessage's.
  605. UnsignedByte m_argCount; ///< The number of arguments of this message
  606. GameMessageArgument *m_argList, *m_argTail; ///< This message's arguments
  607. /// allocate a new argument, add it to list, return pointer to its data
  608. GameMessageArgument *allocArg( void );
  609. };
  610. /**
  611. * The GameMessageList class encapsulates the manipulation of lists of GameMessages.
  612. * Both MessageStream and CommandList derive from this class.
  613. */
  614. class GameMessageList : public SubsystemInterface
  615. {
  616. public:
  617. GameMessageList( void );
  618. virtual ~GameMessageList();
  619. virtual void init( void ) { }; ///< Initialize system
  620. virtual void reset( void ) { }; ///< Reset system
  621. virtual void update( void ) { }; ///< Update system
  622. GameMessage *getFirstMessage( void ) { return m_firstMessage; } ///< Return the first message
  623. virtual void appendMessage( GameMessage *msg ); ///< Add message to end of the list
  624. virtual void insertMessage( GameMessage *msg, GameMessage *messageToInsertAfter ); // Insert message after messageToInsertAfter.
  625. virtual void removeMessage( GameMessage *msg ); ///< Remove message from the list
  626. virtual Bool containsMessageOfType( GameMessage::Type type ); ///< Return true if a message of type is in the message stream
  627. protected:
  628. GameMessage *m_firstMessage; ///< The first message on the list
  629. GameMessage *m_lastMessage; ///< The last message on the list
  630. };
  631. /**
  632. What to do with a GameMessage after a translator has handled it.
  633. Use a custom enum (rather than a Bool) to make the code more obvious.
  634. */
  635. enum GameMessageDisposition
  636. {
  637. KEEP_MESSAGE, ///< continue processing this message thru other translators
  638. DESTROY_MESSAGE ///< destroy this message immediately and don't hand it to any other translators
  639. };
  640. class GameMessageTranslator
  641. {
  642. public:
  643. virtual GameMessageDisposition translateGameMessage(const GameMessage *msg) = 0;
  644. virtual ~GameMessageTranslator() { }
  645. };
  646. /**
  647. * A MessageStream contains an ordered list of messages which can have one or more
  648. * prioritized message handler functions ("translators") attached to it.
  649. */
  650. class MessageStream : public GameMessageList
  651. {
  652. public:
  653. MessageStream( void );
  654. virtual ~MessageStream();
  655. // Inherited Methods ----------------------------------------------------------------------------
  656. virtual void init( void );
  657. virtual void reset( void );
  658. virtual void update( void );
  659. virtual GameMessage *appendMessage( GameMessage::Type type ); ///< Append a message to the end of the stream
  660. virtual GameMessage *insertMessage( GameMessage::Type type, GameMessage *messageToInsertAfter ); // Insert message after messageToInsertAfter.
  661. // Methods NOT Inherited ------------------------------------------------------------------------
  662. void propagateMessages( void ); ///< Propagate messages through attached translators
  663. /**
  664. Attach a translator function to the stream at a priority value. Lower priorities are executed first.
  665. Note that MessageStream assumes ownership of the translator, and is responsible for freeing it!
  666. */
  667. TranslatorID attachTranslator( GameMessageTranslator *translator, UnsignedInt priority);
  668. GameMessageTranslator* findTranslator( TranslatorID id );
  669. void removeTranslator( TranslatorID ); ///< Remove a previously attached translator
  670. protected:
  671. struct TranslatorData
  672. {
  673. TranslatorData *m_next, *m_prev; ///< List links for list of translators
  674. TranslatorID m_id; ///< The unique ID of this translator
  675. GameMessageTranslator *m_translator; ///< The translor's interface function
  676. UnsignedInt m_priority; ///< The priority level of this translator
  677. TranslatorData() : m_next(0), m_prev(0), m_id(0), m_translator(0), m_priority(0)
  678. {
  679. }
  680. ~TranslatorData()
  681. {
  682. delete m_translator;
  683. }
  684. };
  685. TranslatorData *m_firstTranslator; ///< List of registered translators, in order of priority
  686. TranslatorData *m_lastTranslator;
  687. TranslatorID m_nextTranslatorID; ///< For issuing unique translator ID's
  688. };
  689. /**
  690. * The CommandList is the final set of messages that have made their way through
  691. * all of the Translators of the MessageStream, and reached the end.
  692. * This set of commands will be executed by the GameLogic on its next iteration.
  693. */
  694. class CommandList : public GameMessageList
  695. {
  696. public:
  697. CommandList( void );
  698. virtual ~CommandList();
  699. virtual void init( void ); ///< Init command list
  700. virtual void reset( void ); ///< Destroy all messages and reset list to empty
  701. virtual void update( void ); ///< Update hook
  702. void appendMessageList( GameMessage *list ); ///< Adds messages to the end of the command list
  703. protected:
  704. void destroyAllMessages( void ); ///< The meat of a reset and a shutdown
  705. };
  706. //
  707. // The message stream that filters client input into game commands
  708. //
  709. extern MessageStream *TheMessageStream;
  710. //
  711. // The list of commands awaiting execution by the GameLogic
  712. //
  713. extern CommandList *TheCommandList;
  714. //-----------------------------------------------------------------------------
  715. //-----------------------------------------------------------------------------
  716. //-----------------------------------------------------------------------------
  717. // Functions used in multiple translators should go here.
  718. //
  719. /**
  720. * Given an "anchor" point and the current mouse position (dest),
  721. * construct a valid 2D bounding region.
  722. */
  723. extern void buildRegion( const ICoord2D *anchor, const ICoord2D *dest, IRegion2D *region );
  724. #endif // _MESSAGE_STREAM_H_