1 #include "Directories.h" 2 #include "WorldDat.h" 3 #include "WorldDef.h" 4 #include "TileDef.h" 5 #include "Sys_Globals.h" 6 #include "Tile_Surface.h" 7 #include "FileMan.h" 8 9 #include "ContentManager.h" 10 #include "GameInstance.h" 11 12 #include <string_theory/format> 13 14 15 // THIS FILE CONTAINS DEFINITIONS FOR TILESET FILES 16 17 UINT8 gubNumTilesets; 18 TILESET gTilesets[MAX_NUM_TILESETS]; 19 20 21 static void SetTilesetFourTerrainValues(void); 22 static void SetTilesetThreeTerrainValues(void); 23 static void SetTilesetTwoTerrainValues(void); 24 25 InitEngineTilesets(void)26void InitEngineTilesets(void) 27 try 28 { 29 AutoSGPFile f(GCM->openGameResForReading(GCM->getTilesetDBResName())); 30 31 // READ # TILESETS and compare 32 FileRead(f, &gubNumTilesets, sizeof(gubNumTilesets)); 33 switch (gubNumTilesets) 34 { 35 case VANILLA_NUM_TILESETS: 36 SLOGD("Loading vanilla tilesets"); 37 break; 38 case JA25_NUM_TILESETS: 39 SLOGI("Loading tilesets for Unfinished Business"); 40 break; 41 default: 42 SET_ERROR("Number of tilesets in code does not match data file"); 43 return; 44 } 45 46 // READ #files 47 UINT32 uiNumFiles; 48 FileRead(f, &uiNumFiles, sizeof(uiNumFiles)); 49 if (uiNumFiles != NUMBEROFTILETYPES) 50 { 51 SET_ERROR("Number of tilesets slots in code does not match data file"); 52 return; 53 } 54 55 // Loop through each tileset, load name then files 56 for (UINT8 i = 0; i < gubNumTilesets; i++) 57 { 58 TILESET& ts = gTilesets[i]; 59 //Read name 60 ts.zName = FileReadString(f, TILESET_NAME_LENGTH); 61 62 // Read ambience value 63 FileRead(f, &(ts.ubAmbientID), sizeof(UINT8)); 64 65 // Loop for files 66 for (UINT32 cnt2 = 0; cnt2 < uiNumFiles; ++cnt2) 67 { 68 // Read file name 69 ts.zTileSurfaceFilenames[cnt2] = FileReadString(f, TILE_SURFACE_FILENAME_LENGTH); 70 } 71 } 72 73 // Set callbacks 74 gTilesets[CAVES_1 ].MovementCostFnc = SetTilesetTwoTerrainValues; 75 gTilesets[AIRSTRIP ].MovementCostFnc = SetTilesetThreeTerrainValues; 76 gTilesets[DEAD_AIRSTRIP].MovementCostFnc = SetTilesetThreeTerrainValues; 77 gTilesets[TEMP_14 ].MovementCostFnc = SetTilesetThreeTerrainValues; 78 gTilesets[TEMP_18 ].MovementCostFnc = SetTilesetThreeTerrainValues; 79 gTilesets[TEMP_19 ].MovementCostFnc = SetTilesetThreeTerrainValues; 80 gTilesets[TEMP_26 ].MovementCostFnc = SetTilesetThreeTerrainValues; 81 gTilesets[TEMP_27 ].MovementCostFnc = SetTilesetThreeTerrainValues; 82 gTilesets[TEMP_28 ].MovementCostFnc = SetTilesetThreeTerrainValues; 83 gTilesets[TEMP_29 ].MovementCostFnc = SetTilesetThreeTerrainValues; 84 gTilesets[TROPICAL_1 ].MovementCostFnc = SetTilesetFourTerrainValues; 85 gTilesets[TEMP_20 ].MovementCostFnc = SetTilesetFourTerrainValues; 86 } 87 catch (...) 88 { 89 SET_ERROR("Failed to load tileset data file"); 90 } 91 92 SetTilesetOneTerrainValues()93void SetTilesetOneTerrainValues( ) 94 { 95 // FIRST TEXUTRES 96 gTileSurfaceArray[ FIRSTTEXTURE ]->ubTerrainID = FLAT_GROUND; 97 gTileSurfaceArray[ SECONDTEXTURE ]->ubTerrainID = FLAT_GROUND; 98 gTileSurfaceArray[ THIRDTEXTURE ]->ubTerrainID = FLAT_GROUND; 99 gTileSurfaceArray[ FOURTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 100 gTileSurfaceArray[ FIFTHTEXTURE ]->ubTerrainID = LOW_GRASS; 101 gTileSurfaceArray[ SIXTHTEXTURE ]->ubTerrainID = LOW_GRASS; 102 gTileSurfaceArray[ SEVENTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 103 gTileSurfaceArray[ REGWATERTEXTURE ]->ubTerrainID = LOW_WATER; 104 gTileSurfaceArray[ DEEPWATERTEXTURE ]->ubTerrainID = DEEP_WATER; 105 106 // NOW ROADS 107 gTileSurfaceArray[ FIRSTROAD ]->ubTerrainID = DIRT_ROAD; 108 gTileSurfaceArray[ ROADPIECES ]->ubTerrainID = DIRT_ROAD; 109 110 // NOW FLOORS 111 gTileSurfaceArray[ FIRSTFLOOR ]->ubTerrainID = FLAT_FLOOR; 112 gTileSurfaceArray[ SECONDFLOOR ]->ubTerrainID = FLAT_FLOOR; 113 gTileSurfaceArray[ THIRDFLOOR ]->ubTerrainID = FLAT_FLOOR; 114 gTileSurfaceArray[ FOURTHFLOOR ]->ubTerrainID = FLAT_FLOOR; 115 116 // NOW ANY TERRAIN MODIFYING DEBRIS 117 118 } 119 120 SetTilesetTwoTerrainValues(void)121static void SetTilesetTwoTerrainValues(void) 122 { 123 // FIRST TEXUTRES 124 gTileSurfaceArray[ FIRSTTEXTURE ]->ubTerrainID = FLAT_GROUND; 125 gTileSurfaceArray[ SECONDTEXTURE ]->ubTerrainID = FLAT_GROUND; 126 gTileSurfaceArray[ THIRDTEXTURE ]->ubTerrainID = FLAT_GROUND; 127 gTileSurfaceArray[ FOURTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 128 gTileSurfaceArray[ FIFTHTEXTURE ]->ubTerrainID = LOW_GRASS; 129 gTileSurfaceArray[ SIXTHTEXTURE ]->ubTerrainID = LOW_GRASS; 130 gTileSurfaceArray[ SEVENTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 131 gTileSurfaceArray[ REGWATERTEXTURE ]->ubTerrainID = LOW_WATER; 132 gTileSurfaceArray[ DEEPWATERTEXTURE ]->ubTerrainID = DEEP_WATER; 133 134 // NOW ROADS 135 gTileSurfaceArray[ FIRSTROAD ]->ubTerrainID = DIRT_ROAD; 136 gTileSurfaceArray[ ROADPIECES ]->ubTerrainID = DIRT_ROAD; 137 138 139 // NOW FLOORS 140 gTileSurfaceArray[ FIRSTFLOOR ]->ubTerrainID = FLAT_GROUND; 141 gTileSurfaceArray[ SECONDFLOOR ]->ubTerrainID = FLAT_GROUND; 142 gTileSurfaceArray[ THIRDFLOOR ]->ubTerrainID = FLAT_GROUND; 143 gTileSurfaceArray[ FOURTHFLOOR ]->ubTerrainID = FLAT_GROUND; 144 145 } 146 147 SetTilesetThreeTerrainValues(void)148static void SetTilesetThreeTerrainValues(void) 149 { 150 // DIFFERENCE FROM #1 IS THAT ROADS ARE PAVED 151 152 // FIRST TEXUTRES 153 gTileSurfaceArray[ FIRSTTEXTURE ]->ubTerrainID = FLAT_GROUND; 154 gTileSurfaceArray[ SECONDTEXTURE ]->ubTerrainID = FLAT_GROUND; 155 gTileSurfaceArray[ THIRDTEXTURE ]->ubTerrainID = FLAT_GROUND; 156 gTileSurfaceArray[ FOURTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 157 gTileSurfaceArray[ FIFTHTEXTURE ]->ubTerrainID = LOW_GRASS; 158 gTileSurfaceArray[ SIXTHTEXTURE ]->ubTerrainID = LOW_GRASS; 159 gTileSurfaceArray[ SEVENTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 160 gTileSurfaceArray[ REGWATERTEXTURE ]->ubTerrainID = LOW_WATER; 161 gTileSurfaceArray[ DEEPWATERTEXTURE ]->ubTerrainID = DEEP_WATER; 162 163 // NOW ROADS 164 gTileSurfaceArray[ FIRSTROAD ]->ubTerrainID = PAVED_ROAD; 165 gTileSurfaceArray[ ROADPIECES ]->ubTerrainID = PAVED_ROAD; 166 167 168 // NOW FLOORS 169 gTileSurfaceArray[ FIRSTFLOOR ]->ubTerrainID = FLAT_FLOOR; 170 gTileSurfaceArray[ SECONDFLOOR ]->ubTerrainID = FLAT_FLOOR; 171 gTileSurfaceArray[ THIRDFLOOR ]->ubTerrainID = FLAT_FLOOR; 172 gTileSurfaceArray[ FOURTHFLOOR ]->ubTerrainID = FLAT_FLOOR; 173 174 // NOW ANY TERRAIN MODIFYING DEBRIS 175 176 } 177 178 SetTilesetFourTerrainValues(void)179static void SetTilesetFourTerrainValues(void) 180 { 181 // DIFFERENCE FROM #1 IS THAT FLOOR2 IS NOT FLAT_FLOOR BUT FLAT_GROUND 182 183 // FIRST TEXUTRES 184 gTileSurfaceArray[ FIRSTTEXTURE ]->ubTerrainID = FLAT_GROUND; 185 gTileSurfaceArray[ SECONDTEXTURE ]->ubTerrainID = FLAT_GROUND; 186 gTileSurfaceArray[ THIRDTEXTURE ]->ubTerrainID = FLAT_GROUND; 187 gTileSurfaceArray[ FOURTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 188 gTileSurfaceArray[ FIFTHTEXTURE ]->ubTerrainID = LOW_GRASS; 189 gTileSurfaceArray[ SIXTHTEXTURE ]->ubTerrainID = LOW_GRASS; 190 gTileSurfaceArray[ SEVENTHTEXTURE ]->ubTerrainID = FLAT_GROUND; 191 gTileSurfaceArray[ REGWATERTEXTURE ]->ubTerrainID = LOW_WATER; 192 gTileSurfaceArray[ DEEPWATERTEXTURE ]->ubTerrainID = DEEP_WATER; 193 194 // NOW ROADS 195 gTileSurfaceArray[ FIRSTROAD ]->ubTerrainID = DIRT_ROAD; 196 gTileSurfaceArray[ ROADPIECES ]->ubTerrainID = DIRT_ROAD; 197 198 199 // NOW FLOORS 200 gTileSurfaceArray[ FIRSTFLOOR ]->ubTerrainID = FLAT_FLOOR; 201 gTileSurfaceArray[ SECONDFLOOR ]->ubTerrainID = FLAT_GROUND; 202 gTileSurfaceArray[ THIRDFLOOR ]->ubTerrainID = FLAT_FLOOR; 203 gTileSurfaceArray[ FOURTHFLOOR ]->ubTerrainID = FLAT_FLOOR; 204 205 // NOW ANY TERRAIN MODIFYING DEBRIS 206 207 } 208