OGFILE.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 : OGFILE.H
  21. //Description : Oject Game file, save and restore game
  22. #ifndef __OGFILE_H
  23. #define __OGFILE_H
  24. #ifndef __OFILE_H
  25. #include <OFILE.h>
  26. #endif
  27. #ifndef __ODYNARR_H
  28. #include <ODYNARR.h>
  29. #endif
  30. #ifndef __ONATION_Hd
  31. #include <ONATION.h>
  32. #endif
  33. #ifdef AMPLUS
  34. //------------ Define constant for game version == 1xx -----------------//
  35. #define VERSION_1_MAX_RACE 7
  36. #define VERSION_1_MAX_UNIT_TYPE 37
  37. #define VERSION_1_RACERES_NAME_COUNT 1582
  38. #define VERSION_1_UNITRES_UNIT_INFO_COUNT 37
  39. #define VERSION_1_TOWNRES_TOWN_NAME_COUNT 367
  40. #define VERSION_1_GODRES_GOD_COUNT 7
  41. #define VERSION_1_TECH_COUNT 7
  42. #endif
  43. //-------- Define struct HallFame ----------//
  44. enum { HALL_FAME_NUM = 6 }; // No. of Hall of Fame entries
  45. #pragma pack(1)
  46. struct HallFame // Hall of Fame
  47. {
  48. char player_name[NationArray::HUMAN_NAME_LEN+1];
  49. char race_id;
  50. short start_year;
  51. short end_year;
  52. int score;
  53. int population;
  54. short difficulty_rating;
  55. public:
  56. void disp_info(int,int,int);
  57. void record_data(int);
  58. };
  59. #pragma pack()
  60. //-------- Define class GameFile -----------//
  61. #pragma pack(1)
  62. class GameFile
  63. {
  64. public:
  65. size_t class_size; // for version compare
  66. char file_name[MAX_PATH+1];
  67. char player_name[NationArray::HUMAN_NAME_LEN+1];
  68. char race_id;
  69. char nation_color;
  70. int game_date; // the game date of the saved game
  71. FILETIME file_date; // saving game date
  72. short terrain_set;
  73. static File* file_ptr;
  74. static char last_read_success_flag;
  75. public:
  76. int save_game(char* =NULL);
  77. int load_game(char* =NULL);
  78. void set_file_name();
  79. void disp_info(int x, int y);
  80. int validate_header();
  81. private:
  82. void save_process();
  83. void load_process();
  84. int write_game_header(File* filePtr);
  85. int write_file(File*);
  86. int write_file_1(File*);
  87. int write_file_2(File*);
  88. int write_file_3(File*);
  89. int read_file(File*);
  90. int read_file_1(File*);
  91. int read_file_2(File*);
  92. int read_file_3(File*);
  93. void write_book_mark(short bookMark);
  94. int read_book_mark(short bookMark);
  95. };
  96. #pragma pack()
  97. //------- Define class GameFileArray --------//
  98. class GameFileArray : public DynArray
  99. {
  100. public:
  101. char demo_format; // whether write the game in shareware format or not (only selectable in design mode)
  102. char has_read_hall_of_fame;
  103. char last_file_name[MAX_PATH+1];
  104. //### begin alex 5/3 ###//
  105. #ifdef AMPLUS
  106. short load_file_game_version; // game version of load file
  107. char same_version; // true if major version of the load game is same as that of the program
  108. #endif
  109. //#### end alex 5/3 ####//
  110. HallFame hall_fame_array[HALL_FAME_NUM];
  111. public:
  112. GameFileArray();
  113. void init(char *extStr);
  114. void deinit();
  115. int menu(int, int *recno=NULL);
  116. int save_game() { return menu(1); }
  117. int load_game() { return menu(2); }
  118. void save_new_game(char* =NULL); // save a new game immediately without prompting menu
  119. int read_hall_of_fame();
  120. int write_hall_of_fame(); // it may be called by group_res.gen_group() in writting default name
  121. void disp_hall_of_fame();
  122. int add_hall_of_fame(int);
  123. GameFile* operator[](int recNo);
  124. private:
  125. void disp_browse();
  126. void load_all_game_header(char *extStr);
  127. int process_action(int=0);
  128. void del_game();
  129. };
  130. extern GameFileArray game_file_array;
  131. extern GameFile game_file; //**BUGHERE
  132. //-----------------------------------------
  133. #endif