ORAWRES.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 : ORAWRES.H
  21. //Description : Header file of object RawRes
  22. #ifndef __ORAWRES_H
  23. #define __ORAWRES_H
  24. #ifndef __ORES_H
  25. #include <ORES.h>
  26. #endif
  27. #ifndef __ODYNARR_H
  28. #include <ODYNARR.h>
  29. #endif
  30. //------------- define constant --------------//
  31. #define MAX_RAW 3
  32. #define MAX_PRODUCT 3
  33. #define MAX_RAW_RESERVE_QTY 20000
  34. //------------ define icon size -------------//
  35. enum { RAW_SMALL_ICON_WIDTH=10,
  36. RAW_SMALL_ICON_HEIGHT=10,
  37. RAW_LARGE_ICON_WIDTH=32,
  38. RAW_LARGE_ICON_HEIGHT=32
  39. };
  40. //----------- Define raw material types ---------//
  41. enum { RAW_CLAY=1,
  42. RAW_COPPER,
  43. RAW_IRON, };
  44. //------------ Define struct RawRec ---------------//
  45. struct RawRec
  46. {
  47. enum { NAME_LEN=12, TERA_TYPE_LEN=1 };
  48. char name[NAME_LEN];
  49. char tera_type[TERA_TYPE_LEN];
  50. };
  51. //------------- Define struct RawInfo --------------//
  52. struct RawInfo
  53. {
  54. public:
  55. enum { NAME_LEN=20 };
  56. char raw_id;
  57. char name[NAME_LEN+1];
  58. char tera_type;
  59. DynArray raw_supply_firm_array;
  60. DynArray product_supply_firm_array;
  61. public:
  62. RawInfo();
  63. void add_raw_supply_firm(short firmRecno);
  64. void add_product_supply_firm(short firmRecno);
  65. short get_raw_supply_firm(short recNo) { return *( (short*) raw_supply_firm_array.get(recNo) ); }
  66. short get_product_supply_firm(short recNo) { return *( (short*) product_supply_firm_array.get(recNo) ); }
  67. };
  68. //----------- Define class RawRes ---------------//
  69. class RawRes
  70. {
  71. public:
  72. short raw_count;
  73. RawInfo* raw_info_array;
  74. char init_flag;
  75. Resource res_icon;
  76. public:
  77. RawRes();
  78. void init();
  79. void deinit();
  80. void next_day();
  81. void update_supply_firm();
  82. void put_small_product_icon(int x, int y, int rawId);
  83. void put_small_raw_icon(int x, int y, int rawId);
  84. char* large_product_icon(int rawId) { return res_icon.read(rawId); }
  85. char* small_product_icon(int rawId) { return res_icon.read(MAX_RAW+rawId); }
  86. char* large_raw_icon(int rawId) { return res_icon.read(MAX_RAW*2+rawId); }
  87. char* small_raw_icon(int rawId) { return res_icon.read(MAX_RAW*3+rawId); }
  88. int write_file(File*);
  89. int read_file(File*);
  90. RawInfo* operator[](int rawId); // pass rawId as recno
  91. private:
  92. void load_all_info();
  93. };
  94. extern RawRes raw_res;
  95. //----------------------------------------------------//
  96. #endif