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 21 // Filename : OSNOWRES.H 22 // Description : Header file of snow resource 23 // Owner : Gilbert 24 25 #ifndef __OSNOWRES_H 26 #define __OSNOWRES_H 27 28 #ifndef __ORESDB_H 29 #include <ORESDB.h> 30 #endif 31 32 // ----------- Define struct SnowRec --------- // 33 // 34 struct SnowRec 35 { 36 enum { FILE_NAME_LEN=8, OFFSET_LEN=3, BITMAP_PTR_LEN=4, RECNO_LEN=4 }; 37 char file_name[FILE_NAME_LEN]; 38 char offset_x[OFFSET_LEN]; 39 char offset_y[OFFSET_LEN]; 40 char next_file1[FILE_NAME_LEN]; 41 char next_file2[FILE_NAME_LEN]; 42 char next_file3[FILE_NAME_LEN]; 43 char next_file4[FILE_NAME_LEN]; 44 char prev_file1[FILE_NAME_LEN]; 45 char prev_file2[FILE_NAME_LEN]; 46 char bitmap_ptr[BITMAP_PTR_LEN]; 47 char next_ptr1[RECNO_LEN]; 48 char next_ptr2[RECNO_LEN]; 49 char next_ptr3[RECNO_LEN]; 50 char next_ptr4[RECNO_LEN]; 51 char prev_ptr1[RECNO_LEN]; 52 char prev_ptr2[RECNO_LEN]; 53 }; 54 55 // ---------- Define struct SnowInfo -------// 56 // 57 struct SnowInfo 58 { 59 enum { MAX_NEXT_PTR=4, MAX_PREV_PTR=2 }; 60 int snow_map_id; 61 char* bitmap_ptr; 62 SnowInfo* next_file[MAX_NEXT_PTR]; 63 SnowInfo* prev_file[MAX_PREV_PTR]; 64 short offset_x; 65 short offset_y; 66 unsigned short next_count; 67 unsigned short prev_count; 68 is_rootSnowInfo69 int is_root() { return prev_count == 0; } is_leafSnowInfo70 int is_leaf() { return next_count == 0; } rand_nextSnowInfo71 int rand_next(unsigned rand) { return is_leaf() ? snow_map_id : next_file[rand % next_count]->snow_map_id; } rand_prevSnowInfo72 int rand_prev(unsigned rand) { return is_root() ? snow_map_id : prev_file[rand % prev_count]->snow_map_id; } rand_next_ptrSnowInfo73 SnowInfo * rand_next_ptr(unsigned rand) { return is_leaf() ? this : next_file[rand % next_count]; } rand_prev_ptrSnowInfo74 SnowInfo * rand_prev_ptr(unsigned rand) { return is_root() ? NULL : prev_file[rand % prev_count]; } bitmap_widthSnowInfo75 short bitmap_width() { return *(short *)bitmap_ptr; } bitmap_heightSnowInfo76 short bitmap_height() { return *(((short *)bitmap_ptr)+1); } 77 void draw_at(short absX, short absY); 78 }; 79 80 81 // --------- Define class SnowRes -----// 82 // 83 class SnowRes 84 { 85 public: 86 SnowInfo* snow_info_array; 87 int snow_info_count; 88 SnowInfo** root_info_array; 89 unsigned root_count; 90 91 int init_flag; 92 ResourceDb res_bitmap; 93 94 public: 95 SnowRes(); 96 ~SnowRes(); 97 98 void init(); 99 void deinit(); 100 101 int rand_root(unsigned rand); 102 #ifdef DYNARRAY_DEBUG_ELEMENT_ACCESS 103 SnowInfo* operator[](int); 104 #else 105 SnowInfo* operator[](int snowMapId) { return snow_info_array+snowMapId-1; } 106 #endif 107 108 private: 109 void load_info(); 110 }; 111 112 extern SnowRes snow_res; 113 114 #endif