OREBEL.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 : OREBEL.H
  21. //Description : class Rebel
  22. #ifndef __OREBEL_H
  23. #define __OREBEL_H
  24. #ifndef __ODYNARRB_H
  25. #include <ODYNARRB.h>
  26. #endif
  27. //------- action mode definitions --------//
  28. enum { REBEL_IDLE=1,
  29. REBEL_ATTACK_TOWN, // Attack town without capturing
  30. REBEL_ATTACK_FIRM, // Attack firm without capturing
  31. REBEL_SETTLE_NEW, // Settle to a new town
  32. REBEL_SETTLE_TO, // Settle to an existing town
  33. };
  34. //---------- Define class Rebel ---------//
  35. #pragma pack(1)
  36. class Rebel
  37. {
  38. public:
  39. short rebel_recno; // recno of this rebel in rebel_array
  40. short leader_unit_recno;
  41. char action_mode;
  42. short action_para;
  43. short action_para2;
  44. short mobile_rebel_count; // no. of units in this rebel group
  45. short town_recno; // the town controlled by the rebel, one rebel can only control one town
  46. char hostile_nation_bits;
  47. public:
  48. Rebel();
  49. ~Rebel();
  50. void next_day();
  51. void join(int unitRecno);
  52. void set_action(int actionMode, int actionPara=0, int actionPara2=0)
  53. { action_mode = actionMode, action_para = actionPara; action_para2 = actionPara2; }
  54. void town_being_attacked(int attackerUnitRecno);
  55. void set_hostile_nation(short nationRecno);
  56. void reset_hostile_nation(short nationRecno);
  57. int is_hostile_nation(short nationRecno);
  58. public:
  59. void think_new_action();
  60. void think_cur_action();
  61. void think_town_action();
  62. int think_settle_new();
  63. int think_settle_to();
  64. int think_capture_attack_town();
  65. int think_attack_firm();
  66. void execute_new_action();
  67. void stop_all_rebel_unit();
  68. void turn_indepedent();
  69. int select_new_leader();
  70. void process_leader_quit();
  71. // #### patch begin Gilbert 20/1 ######//
  72. UCHAR crc8();
  73. void clear_ptr();
  74. // #### patch end Gilbert 20/1 ######//
  75. };
  76. #pragma pack()
  77. //-------- Define class RebelArray -------//
  78. class RebelArray : public DynArrayB
  79. {
  80. public:
  81. short rebel_count;
  82. public:
  83. RebelArray();
  84. ~RebelArray();
  85. void init();
  86. void deinit();
  87. int create_rebel(int unitRecno, int hostileNationRecno, int actionMode=REBEL_IDLE, int actionPara=0);
  88. void del_rebel(int rebelRecno);
  89. void drop_rebel_identity(int unitRecno);
  90. void settle_town(int unitRecno, int townRecno);
  91. void next_day();
  92. void stop_attack_town(short townRecno);
  93. void stop_attack_firm(short firmRecno);
  94. void stop_attack_nation(short nationRecno);
  95. //--------- file functions -----------//
  96. int write_file(File* filePtr);
  97. int read_file(File* filePtr);
  98. //--------------------------------------//
  99. #ifdef DEBUG
  100. Rebel* operator[](int recNo);
  101. #else
  102. Rebel* operator[](int recNo) { return (Rebel*) get_ptr(recNo); }
  103. #endif
  104. int is_deleted(int recNo) { return get_ptr(recNo) == NULL; }
  105. };
  106. extern RebelArray rebel_array;
  107. //----------------------------------------//
  108. #endif