OSYS.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OSYS.H
  21. //Description : Header file for Game class
  22. #ifndef __OSYS_H
  23. #define __OSYS_H
  24. #ifndef __ALL_H
  25. #include <ALL.h>
  26. #endif
  27. #ifndef __WINDOWS_
  28. #include <windows.h>
  29. #endif
  30. //------ Define common data buffer size ------//
  31. enum { COMMON_DATA_BUF_SIZE = 64*1024 }; // keep a 64K common buffer for all temporary memory storage like reading files temporarily into memory
  32. //-------------- define constant ------------//
  33. #define FRAMES_PER_DAY 10 // no. of frames per day
  34. #ifdef AMPLUS
  35. #define MAX_SCENARIO_PATH 2
  36. #else
  37. #define MAX_SCENARIO_PATH 1
  38. #endif
  39. //------------ sys_flag --------------//
  40. enum { SYS_PREGAME=0, SYS_RUN };
  41. //--------- game version ---------//
  42. enum { VERSION_FULL,
  43. VERSION_DEMO,
  44. VERSION_MULTIPLAYER_ONLY };
  45. //--------- Define info modes --------//
  46. enum { VIEW_MODE_COUNT=10 };
  47. enum { MODE_NORMAL,
  48. MODE_NATION,
  49. MODE_TOWN,
  50. MODE_ECONOMY,
  51. MODE_TRADE,
  52. MODE_MILITARY,
  53. MODE_TECH,
  54. MODE_SPY,
  55. MODE_RANK,
  56. MODE_NEWS_LOG,
  57. MODE_AI_ACTION,
  58. };
  59. //### begin alex 11/8 ###//
  60. //------------------ define debug_seed_status_flag ----------------//
  61. enum { NO_DEBUG_SYN = 0,
  62. DEBUG_SYN_LOAD_AND_COMPARE_ONCE,
  63. DEBUG_SYN_AUTO_SAVE,
  64. DEBUG_SYN_AUTO_LOAD,
  65. };
  66. //#### end alex 11/8 ####//
  67. //-------- Define class Sys -----------//
  68. class Sys
  69. {
  70. public:
  71. HINSTANCE app_hinstance; // handle of the application running
  72. HWND main_hwnd;
  73. char game_version; // VERSION_???
  74. char active_flag; // we are the active app.
  75. char paused_flag; // whether the game is paused
  76. char sys_flag;
  77. char init_flag;
  78. char signal_exit_flag;
  79. char need_redraw_flag; // set to 1 if task switched back. After redraw, clear it
  80. char cheat_enabled_flag;
  81. char view_mode; // the view mode can be MODE_???
  82. char map_need_redraw;
  83. char zoom_need_redraw;
  84. //------ frame related vars -----//
  85. int day_frame_count;
  86. DWORD next_frame_time; // next frame's time for maintaining a specific game speed
  87. //----- multiplayer vars ----//
  88. DWORD frame_count; // frame count, for is_sync_frame only
  89. char is_sync_frame; // whether sync should take place at the current frame (for handling one sync per n frames)
  90. char mp_save_flag; // indicate a request to save game in multi-player game
  91. DWORD mp_save_frame; // save game in which frame
  92. //---- continous key string -----//
  93. enum { MAX_KEY_STR = 10 }; // Maximum 10 different key string
  94. int key_str_pos[MAX_KEY_STR]; // for detecting cheating codes
  95. //-------- statistic --------//
  96. DWORD last_second_time;
  97. int frames_in_this_second;
  98. int frames_per_second; // the actual frames per second
  99. //------- file paths -------//
  100. char cdrom_drive;
  101. char dir_image[MAX_PATH+1];
  102. char dir_encyc[MAX_PATH+1];
  103. #ifdef AMPLUS
  104. char dir_encyc2[MAX_PATH+1];
  105. #endif
  106. char dir_music[MAX_PATH+1];
  107. char dir_movie[MAX_PATH+1];
  108. char dir_tutorial[MAX_PATH+1];
  109. union
  110. {
  111. char dir_scenario[MAX_PATH+1];
  112. char dir_scenario_path[MAX_SCENARIO_PATH][MAX_PATH+1];
  113. };
  114. //------- other vars --------//
  115. char* common_data_buf;
  116. char debug_session;
  117. char testing_session;
  118. public:
  119. Sys();
  120. ~Sys();
  121. int init(HINSTANCE hInstance);
  122. void deinit();
  123. void deinit_directx();
  124. void deinit_objects();
  125. void run(int=0);
  126. void yield();
  127. void yield_wsock_msg();
  128. void set_speed(int frameSpeed, int remoteCall=0);
  129. void set_view_mode(int viewMode, int viewingNationRecno=0, int viewingSpyRecno=0);
  130. // ##### begin Gilbert 22/10 #######//
  131. void disp_view_mode(int observeMode=0);
  132. // ##### end Gilbert 22/10 #######//
  133. void capture_screen();
  134. void capture_minimap();
  135. void disp_frame();
  136. void blt_virtual_buf();
  137. long main_win_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  138. void handle_window_messages();
  139. void pause();
  140. void unpause();
  141. void mp_request_save(DWORD frame);
  142. void mp_clear_request_save();
  143. //-------------- single player syn. game testing functions --------------//
  144. void sp_open_seed_file(char *filename);
  145. void sp_create_seed_file(char *filename);
  146. void sp_close_seed_file();
  147. void sp_load_seed_file();
  148. void sp_record_match_seed();
  149. void sp_record_seed();
  150. void sp_write_seed();
  151. void sp_compare_seed();
  152. void sp_seed_pos_reset();
  153. void sp_seed_pos_set(int pos);
  154. //---- for setting game directories ----//
  155. void set_game_dir();
  156. int set_one_dir( char* checkFileName, char* defaultDir, char* trueDir );
  157. void get_cdrom_drive();
  158. //-------- for load/save games --------//
  159. int write_file(File* filePtr);
  160. int read_file(File* filePtr);
  161. void save_game();
  162. void load_game();
  163. private:
  164. int init_win();
  165. int init_directx();
  166. int init_objects();
  167. void main_loop(int);
  168. void detect();
  169. void process();
  170. void disp_button();
  171. void detect_button();
  172. void disp_view();
  173. void update_view();
  174. void detect_view();
  175. void disp_map();
  176. void disp_zoom();
  177. int should_next_frame();
  178. int is_mp_sync( int *unreadyPlayerFlag );
  179. void auto_save();
  180. void blt_next_frame();
  181. void disp_frames_per_second();
  182. BOOL restore();
  183. void process_key(unsigned scanCode, unsigned skeyState);
  184. void detect_letter_key(unsigned scanCode, unsigned skeyState);
  185. void detect_function_key(unsigned scanCode, unsigned skeyState);
  186. void detect_cheat_key(unsigned scanCode, unsigned skeyState);
  187. void detect_debug_cheat_key(unsigned scanCode, unsigned skeyState);
  188. int detect_set_speed(unsigned scanCode, unsigned skeyState);
  189. int detect_key_str(int keyStrId, char* keyStr);
  190. };
  191. extern Sys sys;
  192. #ifdef DEBUG
  193. extern char debug2_enable_flag;
  194. extern File seedCompareFile;
  195. //### begin alex 11/8 ###//
  196. extern char debug_seed_status_flag;
  197. //#### end alex 11/8 ####//
  198. extern int debug_sim_game_type;
  199. #endif
  200. //-------------------------------------//
  201. #endif