OTECHRES.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 : OTECHRES.H
  21. //Description : class Tech
  22. #ifndef __OTECHRES_H
  23. #define __OTECHRES_H
  24. #ifndef __ORESX_H
  25. #include <ORESX.h>
  26. #endif
  27. //--------- Define constant -----------//
  28. enum { TECH_SMALL_ICON_WIDTH=24,
  29. TECH_SMALL_ICON_HEIGHT=20,
  30. TECH_LARGE_ICON_WIDTH=46,
  31. TECH_LARGE_ICON_HEIGHT=38
  32. };
  33. //------ define tech classes ----------//
  34. enum { TECH_CLASS_COUNT=2 };
  35. enum { TECH_WEAPON=1,
  36. TECH_SHIP,
  37. };
  38. //------ define struct TechClassRec ---------//
  39. struct TechClassRec
  40. {
  41. enum { CODE_LEN=8, ICON_NAME_LEN=8 };
  42. char class_code[CODE_LEN];
  43. char icon_name[ICON_NAME_LEN];
  44. };
  45. //------ define struct TechRec ---------//
  46. struct TechRec
  47. {
  48. enum { CODE_LEN=8, MAX_TECH_LEVEL_LEN=3, COMPLEX_LEVEL_LEN=3, ID_LEN=3, ICON_NAME_LEN=8 };
  49. char class_code[CODE_LEN];
  50. char max_tech_level[MAX_TECH_LEVEL_LEN];
  51. char complex_level[COMPLEX_LEVEL_LEN];
  52. char unit_code[CODE_LEN];
  53. char firm_code[CODE_LEN];
  54. char parent_unit_code[CODE_LEN];
  55. char parent_firm_code[CODE_LEN];
  56. char parent_level;
  57. char icon_name[ICON_NAME_LEN];
  58. char class_id[ID_LEN];
  59. char unit_id[ID_LEN];
  60. char firm_id[ID_LEN];
  61. char parent_unit_id[ID_LEN];
  62. char parent_firm_id[ID_LEN];
  63. };
  64. //-------- define struct TechClass ----------//
  65. #pragma pack(1)
  66. class TechClass
  67. {
  68. public:
  69. short class_id;
  70. short first_tech_id;
  71. short tech_count;
  72. short icon_index;
  73. char* tech_icon();
  74. //-------- dynamic game vars --------//
  75. short nation_research_firm_recno_array[MAX_NATION]; // the recno of each nation's research firm currently researching this technology
  76. public:
  77. void set_nation_research_firm_recno(int nationRecno, int firmRecno) { nation_research_firm_recno_array[nationRecno-1] = firmRecno; }
  78. int get_nation_research_firm_recno(int nationRecno) { return nation_research_firm_recno_array[nationRecno-1]; }
  79. int is_nation_researching(int nationRecno) { return nation_research_firm_recno_array[nationRecno-1]; }
  80. };
  81. #pragma pack()
  82. //-------- define struct TechInfo ----------//
  83. #pragma pack(1)
  84. class TechInfo
  85. {
  86. public:
  87. short tech_id;
  88. short class_id;
  89. short max_tech_level; // maximum level for this technology
  90. short complex_level;
  91. short unit_id;
  92. short firm_id;
  93. short parent_unit_id;
  94. short parent_firm_id;
  95. char parent_level;
  96. short icon_index;
  97. char* tech_large_icon();
  98. char* tech_small_icon();
  99. char* tech_des(); // description of the technology
  100. //-------- dynamic game vars --------//
  101. char nation_tech_level_array[MAX_NATION]; // each nation's the technology level of this unit,
  102. char nation_is_researching_array[MAX_NATION]; // whether the nation is researching this technology, it stores the number of firms of each nation researching on this technology.
  103. float nation_research_progress_array[MAX_NATION]; // the progresses of each nation researching this technology, when it reaches complex_level, the research is done.
  104. public:
  105. void set_nation_tech_level(int nationRecno, int techLevel);
  106. int get_nation_tech_level(int nationRecno) { return nation_tech_level_array[nationRecno-1]; }
  107. void inc_nation_is_researching(int nationRecno);
  108. void dec_nation_is_researching(int nationRecno);
  109. int is_nation_researching(int nationRecno) { return nation_is_researching_array[nationRecno-1]; }
  110. int is_parent_tech_invented(int nationRecno);
  111. int can_research(int nationRecno);
  112. int progress(int nationRecno, float progressPoint);
  113. float get_progress(int nationRecno);
  114. };
  115. #pragma pack()
  116. //------ define class TechRes ----------//
  117. class TechRes
  118. {
  119. public:
  120. char init_flag;
  121. short tech_class_count;
  122. short tech_count;
  123. short total_tech_level; // the sum of research levels of all technology
  124. TechClass* tech_class_array;
  125. TechInfo* tech_info_array;
  126. ResourceIdx res_bitmap;
  127. public:
  128. TechRes();
  129. void init();
  130. void deinit();
  131. void init_nation_tech(int nationRecno);
  132. void inc_all_tech_level(int nationRecno);
  133. int write_file(File*);
  134. int read_file(File*);
  135. #ifdef DEBUG
  136. TechInfo* operator[](int techId); // pass techId as recno
  137. TechClass* tech_class(int techClassId);
  138. #else
  139. TechInfo* operator[](int techId) { return tech_info_array+techId-1; }
  140. TechClass* tech_class(int techClassId) { return tech_class_array+techClassId-1; }
  141. #endif
  142. private:
  143. void load_tech_class();
  144. void load_tech_info();
  145. };
  146. extern TechRes tech_res;
  147. //------------------------------------//
  148. #endif