OGF_V1.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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 : OGF_V1.CPP
  21. // Description : Old Class structures for save game conversion
  22. #ifdef AMPLUS
  23. #include <OGF_V1.h>
  24. #include <OTOWN.h>
  25. #include <ONATIONA.h>
  26. #include <ONATION.h>
  27. //---------------- begin of function Version_1_Town::convert_to_version_2() -----------------//
  28. void Version_1_Town::convert_to_version_2(Town *townPtr)
  29. {
  30. townPtr->town_recno = town_recno;
  31. townPtr->town_name_id = town_name_id;
  32. townPtr->nation_recno = nation_recno;
  33. townPtr->rebel_recno = rebel_recno;
  34. townPtr->race_id = race_id;
  35. townPtr->setup_date = setup_date;
  36. townPtr->ai_town = ai_town;
  37. townPtr->ai_link_checked = ai_link_checked;
  38. townPtr->independ_town_nation_relation = independ_town_nation_relation;
  39. townPtr->has_linked_own_camp = has_linked_own_camp;
  40. townPtr->has_linked_enemy_camp = has_linked_enemy_camp;
  41. townPtr->is_base_town = is_base_town;
  42. townPtr->loc_x1 = loc_x1;
  43. townPtr->loc_y1 = loc_y1;
  44. townPtr->loc_x2 = loc_x2;
  45. townPtr->loc_y2 = loc_y2;
  46. townPtr->abs_x1 = abs_x1;
  47. townPtr->abs_y1 = abs_y1;
  48. townPtr->abs_x2 = abs_x2;
  49. townPtr->abs_y2 = abs_y2;
  50. townPtr->center_x = center_x;
  51. townPtr->center_y = center_y;
  52. townPtr->region_id = region_id;
  53. townPtr->layout_id = layout_id;
  54. townPtr->first_slot_id = first_slot_id;
  55. memcpy(townPtr->slot_object_id_array, slot_object_id_array, sizeof(slot_object_id_array));
  56. townPtr->population = population;
  57. townPtr->jobless_population = jobless_population;
  58. memset(townPtr->max_race_pop_array, 0, sizeof(townPtr->max_race_pop_array));
  59. memcpy(townPtr->max_race_pop_array, max_race_pop_array, sizeof(max_race_pop_array[0])*VERSION_1_MAX_RACE);
  60. memset(townPtr->race_pop_array, 0, sizeof(townPtr->race_pop_array));
  61. memcpy(townPtr->race_pop_array, race_pop_array, sizeof(race_pop_array[0])*VERSION_1_MAX_RACE);
  62. memset(townPtr->race_pop_growth_array, 0, sizeof(townPtr->race_pop_growth_array));
  63. memcpy(townPtr->race_pop_growth_array, race_pop_growth_array, sizeof(race_pop_growth_array[0])*VERSION_1_MAX_RACE);
  64. memset(townPtr->jobless_race_pop_array, 0, sizeof(townPtr->jobless_race_pop_array));
  65. memcpy(townPtr->jobless_race_pop_array, jobless_race_pop_array, sizeof(jobless_race_pop_array[0])*VERSION_1_MAX_RACE);
  66. memset(townPtr->race_loyalty_array, 0, sizeof(townPtr->race_loyalty_array));
  67. memcpy(townPtr->race_loyalty_array, race_loyalty_array, sizeof(race_loyalty_array[0])*VERSION_1_MAX_RACE);
  68. memset(townPtr->race_target_loyalty_array, 0, sizeof(townPtr->race_target_loyalty_array));
  69. memcpy(townPtr->race_target_loyalty_array, race_target_loyalty_array, sizeof(race_target_loyalty_array[0])*VERSION_1_MAX_RACE);
  70. memset(townPtr->race_spy_count_array, 0, sizeof(townPtr->race_spy_count_array));
  71. memcpy(townPtr->race_spy_count_array, race_spy_count_array, sizeof(race_spy_count_array[0])*VERSION_1_MAX_RACE);
  72. memset(townPtr->race_resistance_array, 0, sizeof(townPtr->race_resistance_array));
  73. memcpy(townPtr->race_resistance_array, race_resistance_array, sizeof(race_resistance_array[0][0])*VERSION_1_MAX_RACE*MAX_NATION);
  74. memset(townPtr->race_target_resistance_array, 0, sizeof(townPtr->race_target_resistance_array));
  75. memcpy(townPtr->race_target_resistance_array, race_target_resistance_array, sizeof(race_target_resistance_array[0][0])*VERSION_1_MAX_RACE*MAX_NATION);
  76. townPtr->town_defender_count = town_defender_count;
  77. townPtr->last_being_attacked_date = last_being_attacked_date;
  78. townPtr->received_hit_count = received_hit_count;
  79. memcpy(townPtr->train_queue_skill_array, train_queue_skill_array, sizeof(train_queue_skill_array));
  80. memcpy(townPtr->train_queue_race_array, train_queue_race_array, sizeof(train_queue_race_array));
  81. townPtr->train_queue_count = train_queue_count;
  82. townPtr->train_unit_recno = train_unit_recno;
  83. townPtr->train_unit_action_id = train_unit_action_id;
  84. townPtr->start_train_frame_no = start_train_frame_no;
  85. townPtr->defend_target_recno = defend_target_recno;
  86. townPtr->accumulated_collect_tax_penalty = accumulated_collect_tax_penalty;
  87. townPtr->accumulated_reward_penalty = accumulated_reward_penalty;
  88. townPtr->accumulated_recruit_penalty = accumulated_recruit_penalty;
  89. townPtr->accumulated_enemy_grant_penalty = accumulated_enemy_grant_penalty;
  90. townPtr->last_rebel_date = last_rebel_date;
  91. townPtr->independent_unit_join_nation_min_rating = independent_unit_join_nation_min_rating;
  92. townPtr->quality_of_life = quality_of_life;
  93. townPtr->auto_collect_tax_loyalty = auto_collect_tax_loyalty;
  94. townPtr->auto_grant_loyalty = auto_grant_loyalty;
  95. townPtr->town_combat_level = town_combat_level;
  96. memcpy(townPtr->has_product_supply, has_product_supply, sizeof(has_product_supply));
  97. townPtr->no_neighbor_space = no_neighbor_space;
  98. townPtr->linked_firm_count = linked_firm_count;
  99. townPtr->linked_town_count = linked_town_count;
  100. memcpy(townPtr->linked_firm_array, linked_firm_array, sizeof(linked_firm_array));
  101. memcpy(townPtr->linked_town_array, linked_town_array, sizeof(linked_town_array));
  102. memcpy(townPtr->linked_firm_enable_array, linked_firm_enable_array, sizeof(linked_firm_enable_array));
  103. memcpy(townPtr->linked_town_enable_array, linked_town_enable_array, sizeof(linked_town_enable_array));
  104. }
  105. //---------------- end of function Version_1_Town::convert_to_version_2() -----------------//
  106. //---------------- begin of function Version_1_NationArray::convert_to_version_2() -----------------//
  107. void Version_1_NationArray::convert_to_version_2(NationArray *nationArrayPtr)
  108. {
  109. nationArrayPtr->nation_count = nation_count;
  110. nationArrayPtr->ai_nation_count = ai_nation_count;
  111. nationArrayPtr->last_del_nation_date = last_del_nation_date;
  112. nationArrayPtr->last_new_nation_date = last_new_nation_date;
  113. nationArrayPtr->max_nation_population = max_nation_population;
  114. nationArrayPtr->all_nation_population = all_nation_population;
  115. nationArrayPtr->independent_town_count = independent_town_count;
  116. memset(nationArrayPtr->independent_town_count_race_array, 0, sizeof(nationArrayPtr->independent_town_count_race_array));
  117. memcpy(nationArrayPtr->independent_town_count_race_array, independent_town_count_race_array, sizeof(independent_town_count_race_array));
  118. nationArrayPtr->max_nation_units = max_nation_units;
  119. nationArrayPtr->max_nation_humans = max_nation_humans;
  120. nationArrayPtr->max_nation_generals = max_nation_generals;
  121. nationArrayPtr->max_nation_weapons = max_nation_weapons;
  122. nationArrayPtr->max_nation_ships = max_nation_ships;
  123. nationArrayPtr->max_nation_spies = max_nation_spies;
  124. nationArrayPtr->max_nation_firms = max_nation_firms;
  125. nationArrayPtr->max_nation_tech_level = max_nation_tech_level;
  126. nationArrayPtr->max_population_rating = max_population_rating;
  127. nationArrayPtr->max_military_rating = max_military_rating;
  128. nationArrayPtr->max_economic_rating = max_economic_rating;
  129. nationArrayPtr->max_reputation = max_reputation;
  130. nationArrayPtr->max_kill_monster_score = max_kill_monster_score;
  131. nationArrayPtr->max_overall_rating = max_overall_rating;
  132. nationArrayPtr->max_population_nation_recno = max_population_nation_recno;
  133. nationArrayPtr->max_military_nation_recno = max_military_nation_recno;
  134. nationArrayPtr->max_economic_nation_recno = max_economic_nation_recno;
  135. nationArrayPtr->max_reputation_nation_recno = max_reputation_nation_recno;
  136. nationArrayPtr->max_kill_monster_nation_recno = max_kill_monster_nation_recno;
  137. nationArrayPtr->max_overall_nation_recno = max_overall_nation_recno;
  138. nationArrayPtr->last_alliance_id = last_alliance_id;
  139. nationArrayPtr->nation_peace_days = nation_peace_days;
  140. nationArrayPtr->player_recno = player_recno;
  141. nationArrayPtr->player_ptr = player_ptr;
  142. memcpy(nationArrayPtr->nation_color_array, nation_color_array, sizeof(nation_color_array[0])*(MAX_NATION+1));
  143. memcpy(nationArrayPtr->nation_power_color_array, nation_power_color_array, sizeof(nation_power_color_array[0])*(MAX_NATION+2));
  144. memcpy(nationArrayPtr->human_name_array, human_name_array, sizeof(human_name_array[0])*(MAX_NATION));
  145. }
  146. //---------------- end of function Version_1_NationArray::convert_to_version_2() -----------------//
  147. //---------------- begin of function Version_1_NationBase::convert_to_version_2() -----------------//
  148. void Version_1_NationBase::convert_to_version_2(Nation *nationPtr)
  149. {
  150. nationPtr->nation_recno = nation_recno;
  151. nationPtr->nation_type = nation_type;
  152. nationPtr->race_id = race_id;
  153. nationPtr->color_scheme_id = color_scheme_id;
  154. nationPtr->nation_color = nation_color;
  155. nationPtr->king_unit_recno = king_unit_recno;
  156. nationPtr->king_leadership = king_leadership;
  157. nationPtr->nation_name_id = nation_name_id;
  158. memcpy(nationPtr->nation_name_str, nation_name_str, sizeof(nation_name_str));
  159. nationPtr->player_id = player_id;
  160. nationPtr->next_frame_ready = next_frame_ready;
  161. nationPtr->last_caravan_id = last_caravan_id;
  162. nationPtr->nation_firm_count = nation_firm_count;
  163. nationPtr->last_build_firm_date = last_build_firm_date;
  164. memset(nationPtr->know_base_array, 0, sizeof(nationPtr->know_base_array));
  165. memcpy(nationPtr->know_base_array, know_base_array, sizeof(know_base_array));
  166. memset(nationPtr->base_count_array, 0, sizeof(nationPtr->base_count_array));
  167. memcpy(nationPtr->base_count_array, base_count_array, sizeof(base_count_array));
  168. nationPtr->is_at_war_today = is_at_war_today;
  169. nationPtr->is_at_war_yesterday = is_at_war_yesterday;
  170. nationPtr->last_war_date = last_war_date;
  171. nationPtr->last_attacker_unit_recno = last_attacker_unit_recno;
  172. nationPtr->last_independent_unit_join_date = last_independent_unit_join_date;
  173. nationPtr->cheat_enabled_flag = cheat_enabled_flag;
  174. //----------------------------------//
  175. nationPtr->cash = cash;
  176. nationPtr->food = food;
  177. nationPtr->reputation = reputation;
  178. nationPtr->kill_monster_score = kill_monster_score;
  179. //------- town auto policy -------------//
  180. nationPtr->auto_collect_tax_loyalty = auto_collect_tax_loyalty;
  181. nationPtr->auto_grant_loyalty = auto_grant_loyalty;
  182. //----- yearly income, expense and profit ------//
  183. nationPtr->cur_year_profit = cur_year_profit;
  184. nationPtr->last_year_profit = last_year_profit;
  185. nationPtr->cur_year_fixed_income = cur_year_fixed_income;
  186. nationPtr->last_year_fixed_income = last_year_fixed_income;
  187. nationPtr->cur_year_fixed_expense = cur_year_fixed_expense;
  188. nationPtr->last_year_fixed_expense = last_year_fixed_expense;
  189. //------- yearly income ------//
  190. memcpy(nationPtr->cur_year_income_array, cur_year_income_array, sizeof(cur_year_income_array));
  191. memcpy(nationPtr->last_year_income_array, last_year_income_array, sizeof(last_year_income_array));
  192. nationPtr->cur_year_income = cur_year_income;
  193. nationPtr->last_year_income = last_year_income;
  194. //------- yearly expense ------//
  195. memcpy(nationPtr->cur_year_expense_array, cur_year_expense_array, sizeof(cur_year_expense_array));
  196. memcpy(nationPtr->last_year_expense_array, last_year_expense_array, sizeof(last_year_expense_array));
  197. nationPtr->cur_year_expense = cur_year_expense;
  198. nationPtr->last_year_expense = last_year_expense;
  199. //------- yearly expense ------//
  200. nationPtr->cur_year_cheat = cur_year_cheat;
  201. nationPtr->last_year_cheat = last_year_cheat;
  202. //----- yearly food in, out and change ------//
  203. nationPtr->cur_year_food_in = cur_year_food_in;
  204. nationPtr->last_year_food_in = last_year_food_in;
  205. nationPtr->cur_year_food_out = cur_year_food_out;
  206. nationPtr->last_year_food_out = last_year_food_out;
  207. nationPtr->cur_year_food_change = cur_year_food_change;
  208. nationPtr->last_year_food_change = last_year_food_change;
  209. //----- yearly reputatino change ------//
  210. nationPtr->cur_year_reputation_change = cur_year_reputation_change;
  211. nationPtr->last_year_reputation_change = last_year_reputation_change;
  212. //--------- er-nation relationship -----------//
  213. memcpy(nationPtr->relation_array, relation_array, sizeof(relation_array));
  214. memcpy(nationPtr->relation_status_array, relation_status_array, sizeof(relation_status_array));
  215. memcpy(nationPtr->relation_passable_array, relation_passable_array, sizeof(relation_passable_array));
  216. memcpy(nationPtr->relation_should_attack_array, relation_should_attack_array, sizeof(relation_should_attack_array));
  217. nationPtr->is_allied_with_player = is_allied_with_player;
  218. //---------- statistic ------------//
  219. nationPtr->total_population = total_population;
  220. nationPtr->total_jobless_population = total_jobless_population;
  221. nationPtr->total_unit_count = total_unit_count;
  222. nationPtr->total_human_count = total_human_count;
  223. nationPtr->total_general_count = total_general_count;
  224. nationPtr->total_weapon_count = total_weapon_count;
  225. nationPtr->total_ship_count = total_ship_count;
  226. nationPtr->total_firm_count = total_firm_count;
  227. nationPtr->total_spy_count = total_spy_count;
  228. nationPtr->total_ship_combat_level = total_ship_combat_level;
  229. nationPtr->largest_town_recno = largest_town_recno;
  230. nationPtr->largest_town_pop = largest_town_pop;
  231. memcpy(nationPtr->raw_count_array, raw_count_array, sizeof(raw_count_array));
  232. memset(nationPtr->last_unit_name_id_array, 0, sizeof(nationPtr->last_unit_name_id_array));
  233. memcpy(nationPtr->last_unit_name_id_array, last_unit_name_id_array, sizeof(last_unit_name_id_array));
  234. //--------- rank ratings ---------//
  235. nationPtr->population_rating = population_rating;
  236. nationPtr->military_rating = military_rating;
  237. nationPtr->economic_rating = economic_rating;
  238. nationPtr->overall_rating = overall_rating;
  239. //------ additional statistic ------//
  240. nationPtr->enemy_soldier_killed = enemy_soldier_killed;
  241. nationPtr->own_soldier_killed = own_soldier_killed;
  242. nationPtr->enemy_civilian_killed = enemy_civilian_killed;
  243. nationPtr->own_civilian_killed = own_civilian_killed;
  244. nationPtr->enemy_weapon_destroyed = enemy_weapon_destroyed;
  245. nationPtr->own_weapon_destroyed = own_weapon_destroyed;
  246. nationPtr->enemy_ship_destroyed = enemy_ship_destroyed;
  247. nationPtr->own_ship_destroyed = own_ship_destroyed;
  248. nationPtr->enemy_firm_destroyed = enemy_firm_destroyed;
  249. nationPtr->own_firm_destroyed = own_firm_destroyed;
  250. }
  251. //---------------- end of function Version_1_NationBase::convert_to_version_2() -----------------//
  252. //---------------- begin of function Version_1_Nation::convert_to_version_2() -----------------//
  253. void Version_1_Nation::convert_to_version_2(Nation *nationPtr)
  254. {
  255. Version_1_NationBase::convert_to_version_2(nationPtr);
  256. nationPtr->action_array = action_array;
  257. nationPtr->last_action_id = last_action_id;
  258. nationPtr->ai_town_size = ai_town_size;
  259. nationPtr->ai_base_size = ai_base_size;
  260. nationPtr->ai_mine_size = ai_mine_size;
  261. nationPtr->ai_factory_size = ai_factory_size;
  262. nationPtr->ai_camp_size = ai_camp_size;
  263. nationPtr->ai_research_size = ai_research_size;
  264. nationPtr->ai_war_size = ai_war_size;
  265. nationPtr->ai_harbor_size = ai_harbor_size;
  266. nationPtr->ai_market_size = ai_market_size;
  267. nationPtr->ai_inn_size = ai_inn_size;
  268. nationPtr->ai_general_size = ai_general_size;
  269. nationPtr->ai_caravan_size = ai_caravan_size;
  270. nationPtr->ai_ship_size = ai_ship_size;
  271. nationPtr->ai_town_count = ai_town_count;
  272. nationPtr->ai_base_count = ai_base_count;
  273. nationPtr->ai_mine_count = ai_mine_count;
  274. nationPtr->ai_factory_count = ai_factory_count;
  275. nationPtr->ai_camp_count = ai_camp_count;
  276. nationPtr->ai_research_count = ai_research_count;
  277. nationPtr->ai_war_count = ai_war_count;
  278. nationPtr->ai_harbor_count = ai_harbor_count;
  279. nationPtr->ai_market_count = ai_market_count;
  280. nationPtr->ai_inn_count = ai_inn_count;
  281. nationPtr->ai_general_count = ai_general_count;
  282. nationPtr->ai_caravan_count = ai_caravan_count;
  283. nationPtr->ai_ship_count = ai_ship_count;
  284. nationPtr->ai_base_town_count = ai_base_town_count;
  285. memcpy(nationPtr->firm_should_close_array, firm_should_close_array, sizeof(firm_should_close_array));
  286. //------------------------------------------------------//
  287. // parameters about the nation itself
  288. //------------------------------------------------------//
  289. memcpy(nationPtr->ai_region_array, ai_region_array, sizeof(ai_region_array));
  290. nationPtr->ai_region_count = ai_region_count;
  291. //------------------------------------------------------//
  292. // AI personalties
  293. //------------------------------------------------------//
  294. nationPtr->pref_force_projection = pref_force_projection;
  295. nationPtr->pref_military_development = pref_military_development;
  296. nationPtr->pref_economic_development = pref_economic_development;
  297. nationPtr->pref_inc_pop_by_capture = pref_inc_pop_by_capture;
  298. nationPtr->pref_inc_pop_by_growth = pref_inc_pop_by_growth;
  299. nationPtr->pref_peacefulness = pref_peacefulness;
  300. nationPtr->pref_military_courage = pref_military_courage;
  301. nationPtr->pref_territorial_cohesiveness = pref_territorial_cohesiveness;
  302. nationPtr->pref_trading_tendency = pref_trading_tendency;
  303. nationPtr->pref_allying_tendency = pref_allying_tendency;
  304. nationPtr->pref_honesty = pref_honesty;
  305. nationPtr->pref_town_harmony = pref_town_harmony;
  306. nationPtr->pref_loyalty_concern = pref_loyalty_concern;
  307. nationPtr->pref_forgiveness = pref_forgiveness;
  308. nationPtr->pref_collect_tax = pref_collect_tax;
  309. nationPtr->pref_hire_unit = pref_hire_unit;
  310. nationPtr->pref_use_weapon = pref_use_weapon;
  311. nationPtr->pref_keep_general = pref_keep_general;
  312. nationPtr->pref_keep_skilled_unit = pref_keep_skilled_unit;
  313. nationPtr->pref_diplomacy_retry = pref_diplomacy_retry;
  314. nationPtr->pref_attack_monster = pref_attack_monster;
  315. nationPtr->pref_spy = pref_spy;
  316. nationPtr->pref_counter_spy = pref_counter_spy;
  317. nationPtr->pref_food_reserve = pref_food_reserve;
  318. nationPtr->pref_cash_reserve = pref_cash_reserve;
  319. nationPtr->pref_use_marine = pref_use_marine;
  320. nationPtr->pref_unit_chase_distance = pref_unit_chase_distance;
  321. nationPtr->pref_repair_concern = pref_repair_concern;
  322. nationPtr->pref_scout = pref_scout;
  323. //------- AI action vars --------//
  324. nationPtr->ai_capture_enemy_town_recno = ai_capture_enemy_town_recno;
  325. nationPtr->ai_capture_enemy_town_plan_date = ai_capture_enemy_town_plan_date;
  326. nationPtr->ai_capture_enemy_town_start_attack_date = ai_capture_enemy_town_start_attack_date;
  327. nationPtr->ai_capture_enemy_town_use_all_camp = ai_capture_enemy_town_use_all_camp;
  328. nationPtr->ai_last_defend_action_date = ai_last_defend_action_date;
  329. nationPtr->ai_attack_target_x_loc = ai_attack_target_x_loc;
  330. nationPtr->ai_attack_target_y_loc = ai_attack_target_y_loc;
  331. nationPtr->ai_attack_target_nation_recno = ai_attack_target_nation_recno;
  332. memcpy(nationPtr->attack_camp_array, attack_camp_array, sizeof(attack_camp_array));
  333. nationPtr->attack_camp_count = attack_camp_count;
  334. nationPtr->lead_attack_camp_recno = lead_attack_camp_recno;
  335. }
  336. //---------------- end of function Version_1_Nation::convert_to_version_2() -----------------//
  337. #endif