ONEWS.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 : ONEWS.H
  21. //Description : Object News
  22. #ifndef __ONEWS_H
  23. #define __ONEWS_H
  24. #ifndef __OBUTTON_H
  25. #include <OBUTTON.h>
  26. #endif
  27. #ifndef __OVBROWSE_H
  28. #include <OVBROWSE.h>
  29. #endif
  30. #ifndef __ODYNARRB_H
  31. #include <ODYNARRB.h>
  32. #endif
  33. //----- Maximum no. of news ---------//
  34. enum { MAX_NEWS=2000 };
  35. //--------- Define constant --------------//
  36. #define DISP_NEWS_DAYS 60 // how long a news should stay on the screen before it disappears
  37. #define DISP_NEWS_COUNT 5 // maximum no. of news message displayed on the screen at a time
  38. //-------- Define news type ---------//
  39. enum { NEWS_TYPE_NUM=1 };
  40. enum { NEWS_NORMAL=0 };
  41. enum { NEWS_WHO_NUM=4 };
  42. enum { NEWS_DISP_ALL=0, NEWS_DISP_FRIENDLY, NEWS_DISP_PLAYER, NEWS_DISP_NONE };
  43. //------- Define other constant -------//
  44. enum { DESTROYER_NATION=1, DESTROYER_REBEL, DESTROYER_MONSTER, DESTROYER_UNKNOWN };
  45. enum { NEWS_LOC_TOWN=1, NEWS_LOC_FIRM, NEWS_LOC_UNIT, NEWS_LOC_ANY }; // for News::loc_type
  46. //--------- Define news id. ----------//
  47. enum { NEWS_DIPLOMACY=1,
  48. NEWS_TOWN_REBEL,
  49. NEWS_MIGRATE,
  50. NEWS_NEW_NATION,
  51. NEWS_NATION_DESTROYED,
  52. NEWS_NATION_SURRENDER,
  53. NEWS_KING_DIE,
  54. NEWS_NEW_KING,
  55. NEWS_FIRM_DESTROYED, // when your firm is destroyed
  56. NEWS_FIRM_CAPTURED, // when your firm is taken over by another nation or you take over the firm of another nation
  57. NEWS_TOWN_DESTROYED, // when the last unit in the town is killed by an enemy
  58. NEWS_TOWN_ABANDONED, // when all villagers have left the village
  59. NEWS_TOWN_SURRENDERED, // A town surrenders to another natino
  60. NEWS_MONSTER_KING_KILLED,
  61. NEWS_MONSTER_FIRM_DESTROYED,
  62. NEWS_SCROLL_ACQUIRED,
  63. NEWS_MONSTER_GOLD_ACQUIRED,
  64. NEWS_YOUR_SPY_KILLED,
  65. NEWS_ENEMY_SPY_KILLED,
  66. NEWS_UNIT_BETRAY, // your unit betray or other nation's betray and turn towards you
  67. NEWS_UNIT_ASSASSINATED,
  68. NEWS_ASSASSINATOR_CAUGHT,
  69. NEWS_GENERAL_DIE,
  70. NEWS_RAW_EXHAUST,
  71. NEWS_TECH_RESEARCHED,
  72. NEWS_LIGHTNING_DAMAGE,
  73. NEWS_EARTHQUAKE_DAMAGE,
  74. NEWS_GOAL_DEADLINE,
  75. NEWS_WEAPON_SHIP_WORN_OUT,
  76. NEWS_FIRM_WORN_OUT,
  77. NEWS_CHAT_MSG,
  78. NEWS_MULTI_RETIRE,
  79. NEWS_MULTI_QUIT_GAME,
  80. NEWS_MULTI_SAVE_GAME,
  81. NEWS_MULTI_CONNECTION_LOST,
  82. };
  83. //------- Define struct News ---------//
  84. #pragma pack(1)
  85. struct News
  86. {
  87. public:
  88. char id; // id. of the news, NEWS_???
  89. char type; // news type // type may be > NEWS_TYPE_NUM, for indicating that the news has been displayed in the stock window, do display it on the newspaper again
  90. char news_type() { return type%NEWS_TYPE_NUM; }
  91. long news_date; // date of the news
  92. char nation_color1; // nation color, can't use nation_recno directly, because it may bankrupt one day
  93. char nation_color2;
  94. char nation_race_id1;
  95. char nation_race_id2;
  96. int nation_name_id1; // nation res. id of the nation that generate the news
  97. int nation_name_id2; // if the news is related to two nations (e.g. one nation buys the stock of another nation)
  98. char* nation_name1();
  99. char* nation_name2();
  100. char* king_name1(int addColor=0);
  101. char* king_name2(int addColor=0);
  102. short short_para1;
  103. short short_para2;
  104. short short_para3;
  105. short short_para4;
  106. short short_para5;
  107. char loc_type;
  108. short loc_type_para;
  109. WORD loc_type_para2; // must use WORD as it will be used to store unit name id.
  110. short loc_x, loc_y; // location where the news happens
  111. public:
  112. int put(int y, int detectAction, int& newsHeight);
  113. char* msg(); // return the news msg
  114. int is_major();
  115. void set_loc(int xLoc, int yLoc, int locType, int locTypePara=0, int locTypePara2=0);
  116. int is_loc_valid();
  117. //---- functions for return news string ----//
  118. void diplomacy();
  119. void town_rebel();
  120. void migrate();
  121. void new_nation();
  122. void nation_destroyed();
  123. void nation_surrender();
  124. void king_die();
  125. void new_king();
  126. void firm_destroyed();
  127. void firm_captured();
  128. void town_destroyed();
  129. void town_abandoned();
  130. void town_surrendered();
  131. void monster_king_killed();
  132. void monster_firm_destroyed();
  133. void scroll_acquired();
  134. void monster_gold_acquired();
  135. void your_spy_killed();
  136. void enemy_spy_killed();
  137. void unit_betray();
  138. void unit_assassinated();
  139. void assassinator_caught();
  140. void general_die();
  141. void raw_exhaust();
  142. void tech_researched();
  143. void lightning_damage();
  144. void earthquake_damage();
  145. void goal_deadline();
  146. void weapon_ship_worn_out();
  147. void firm_worn_out();
  148. void chat_msg();
  149. void multi_retire();
  150. void multi_quit_game();
  151. void multi_save_game();
  152. void multi_connection_lost();
  153. };
  154. #pragma pack()
  155. //-------- Define class NewsArray ----------//
  156. class Unit;
  157. class Font;
  158. class NewsArray : public DynArray
  159. {
  160. public:
  161. //------ display options ------//
  162. char news_type_option[NEWS_TYPE_NUM];
  163. char news_who_option;
  164. char news_add_flag;
  165. int last_clear_recno;
  166. public:
  167. NewsArray();
  168. void init();
  169. void deinit();
  170. void enable() { news_add_flag = 1; }
  171. void disable() { news_add_flag = 0; }
  172. void reset();
  173. void default_setting();
  174. void set_font(Font*);
  175. int detect();
  176. void disp();
  177. int put(int detectAction);
  178. void clear_news_disp();
  179. News* add_news(int newsId, int newsType, int nationRecno=0, int nationRecno2=0, int forceAdd=0);
  180. void remove(int newsId, int shortPara1);
  181. //------ functions for adding news -------//
  182. void diplomacy(int talkMsgRecno);
  183. void town_rebel(int townRecno, int rebelCount);
  184. void migrate(int srcTownRecno, int desTownRecno, int raceId, int migratedCount, int firmRecno=0);
  185. void new_nation(int kingUnitRecno);
  186. void nation_destroyed(int nationRecno);
  187. void nation_surrender(int nationRecno, int toNationRecno);
  188. void king_die(int nationRecno);
  189. void new_king(int nationRecno, int kingUnitRecno);
  190. void firm_destroyed(int firmRecno, Unit* attackUnit);
  191. void firm_captured(int firmRecno, int takeoverNationRecno, int spyTakeover);
  192. void town_destroyed(int townNameId, int xLoc, int yLoc, Unit* attackUnit);
  193. void town_abandoned(int townRecno);
  194. void town_surrendered(int townRecno, int toNationRecno);
  195. void monster_king_killed(int monsterId, int xLoc, int yLoc);
  196. void monster_firm_destroyed(int monsterId, int xLoc, int yLoc);
  197. void scroll_acquired(int acquireNationRecno, int scrollRaceId);
  198. void monster_gold_acquired(int goldAmt);
  199. void spy_killed(int spyRecno);
  200. void unit_betray(int unitRecno, int betrayToNationRecno);
  201. void unit_assassinated(int unitRecno, int spyKilled);
  202. void assassinator_caught(int spyRecno, int targetRankId);
  203. void general_die(int unitRecno);
  204. void raw_exhaust(int rawId, int xLoc, int yLoc);
  205. void tech_researched(int techId, int techVersion);
  206. void lightning_damage(int xLoc, int yLoc, int objectId, int recno, int objectDie);
  207. void earthquake_damage(int unitDamage, int unitDie, int townDamage, int firmDamage, int firmDie);
  208. void goal_deadline(int yearLeft, int monthLeft);
  209. void weapon_ship_worn_out(int unitId, int weaponLevel);
  210. void firm_worn_out(int firmRecno);
  211. void chat_msg(int nationRecno, char* chatStr);
  212. void multi_retire(int nationRecno);
  213. void multi_quit_game(int nationRecno);
  214. void multi_save_game();
  215. void multi_connection_lost(int nationRecno);
  216. //--------------------------------------------//
  217. int write_file(File*);
  218. int read_file(File*);
  219. News* operator[](int recNo);
  220. };
  221. extern NewsArray news_array;
  222. //-------------------------------------------//
  223. #endif