ODYNARRB.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 :: ODYNARRB.H
  21. //Description :: Dynamic Array Object Version B
  22. #ifndef __ODYNARRB_H
  23. #define __ODYNARRB_H
  24. #ifndef __ODYNARR_H
  25. #include <ODYNARR.h>
  26. #endif
  27. //------------ Define Constant -------------//
  28. #define DEFAULT_REUSE_INTERVAL_DAYS 3
  29. //----------- Define variable type -----------//
  30. typedef char* (*CreateEleFP)();
  31. //--------- Define struct EmptyRoom -----------//
  32. #pragma pack(1)
  33. struct EmptyRoom
  34. {
  35. short recno;
  36. int deleted_game_date;
  37. };
  38. #pragma pack()
  39. //---------- Define class DynArrayB -----------//
  40. #pragma pack(1)
  41. class DynArrayB : public DynArray
  42. {
  43. public:
  44. EmptyRoom* empty_room_array;
  45. short empty_room_num; // rooms allocated
  46. short empty_room_count; // rooms used
  47. short reuse_interval_days;
  48. public:
  49. DynArrayB(int,int=DEF_DYNARRAY_BLOCK_SIZE,int reuseIntervalDays=0);
  50. ~DynArrayB();
  51. // packed_size() is the size when the array is packed (deleted record are actually removed)
  52. // packed_recno() is the recno when the array is packed
  53. int packed_size() { return size() - empty_room_count; }
  54. int packed_recno(int); // Given the recno unpacked, it returns the recno packed.
  55. void linkin(void*);
  56. void linkout(int= -1);
  57. void zap();
  58. int write_file(File*); // Write current dynamic array to file
  59. int read_file(File*); // Read dynamic array from file
  60. int write_empty_room(File*); // Write current dynamic array to file
  61. int read_empty_room(File*); // Read dynamic array from file
  62. int write_ptr_array(File*, int);
  63. int read_ptr_array(File*, int, CreateEleFP);
  64. };
  65. #pragma pack()
  66. //---------------------------------------------//
  67. #endif