OSERES.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 : OSERES.H
  21. // Description : Header file of sound resource
  22. // Onwer : Gilbert
  23. #ifndef __OSERES_H
  24. #define __OSERES_H
  25. // ------------- Define struct SERec -------------//
  26. struct SERec
  27. {
  28. enum { RECNO_LEN=3, CODE_LEN=12, VERB_LEN=4, OUT_FRAME_LEN=3, FILE_NAME_LEN=8};
  29. char subject_type;
  30. char subject_code[CODE_LEN];
  31. char subject_id[RECNO_LEN];
  32. char action[VERB_LEN];
  33. char object_type;
  34. char object_id[RECNO_LEN];
  35. char out_frame[OUT_FRAME_LEN];
  36. char file_name[FILE_NAME_LEN];
  37. };
  38. // ------------- Define struct SEInfo -------------//
  39. struct SEInfo
  40. {
  41. enum { VERB_LEN=4, FILE_NAME_LEN=8 };
  42. char subject_type; // S=sprite, U=unit, R=race, F=firm, T=town
  43. short subject_id;
  44. char action[VERB_LEN+1]; // '\0' padding
  45. char object_type;
  46. short object_id;
  47. short out_frame;
  48. char file_name[FILE_NAME_LEN+1];
  49. short effect_id; // id returned from se_ctrl.scan
  50. int match(char, short, char *, char, short);
  51. };
  52. // ---------- Define struct SEInfoIndex -------//
  53. struct SEInfoIndex
  54. {
  55. char subject_type;
  56. char dummy;
  57. short subject_id;
  58. int start_rec;
  59. int end_rec;
  60. };
  61. // ---------- Define struct SETypeIndex -------//
  62. struct SETypeIndex
  63. {
  64. char subject_type;
  65. char dummy;
  66. int start_rec;
  67. int end_rec;
  68. };
  69. // ------------- Define class SERes -------------//
  70. class SECtrl;
  71. class SERes
  72. {
  73. public:
  74. int init_flag;
  75. SECtrl* se_output;
  76. int se_array_count;
  77. SEInfo* se_array;
  78. int se_index_count;
  79. SEInfoIndex *se_index_array;
  80. int type_index_count;
  81. SETypeIndex *type_index_array;
  82. static unsigned long last_select_time;
  83. static unsigned long last_command_time;
  84. static unsigned long select_sound_length;
  85. unsigned seed;
  86. public:
  87. SERes();
  88. ~SERes();
  89. void init1(); // init before se_ctrl.init
  90. void init2(SECtrl*); // init after se_ctrl.init
  91. void deinit();
  92. SEInfo* scan(char,short, char *, char,short, int findFirst=0);
  93. short scan_id(char,short, char *, char,short, int findFirst=0);
  94. SEInfo* operator[] (int);
  95. void sound(short xLoc, short yLoc, short frame, char,short, char *, char=0,short=0);
  96. void far_sound(short xLoc, short yLoc, short frame, char,short, char *, char=0,short=0);
  97. static int mark_select_object_time(); // return false if this sound should be skipped due to too frequent
  98. static int mark_command_time(); // return false if this sound should be skipped due to too frequent
  99. private:
  100. void load_info();
  101. void sort_info();
  102. void build_index();
  103. unsigned random(unsigned);
  104. };
  105. extern SERes se_res;
  106. #endif