Mercurial > mm7
comparison TileTable.cpp @ 1588:e6ac4919b22c
Слияние
author | Ritor1 |
---|---|
date | Mon, 09 Sep 2013 09:13:40 +0600 |
parents | c4ab816fcc5e |
children | 75fafd8ced59 |
comparison
equal
deleted
inserted
replaced
1587:b42e6f35e03d | 1588:e6ac4919b22c |
---|---|
1 #ifdef _MSC_VER | 1 #ifdef _MSC_VER |
2 #define _CRT_SECURE_NO_WARNINGS | 2 #define _CRT_SECURE_NO_WARNINGS |
3 #endif | 3 #endif |
4 | 4 |
5 #include <assert.h> | |
6 #include <stdio.h> | 5 #include <stdio.h> |
7 #include <stdlib.h> | 6 #include <stdlib.h> |
8 #include <string.h> | 7 #include <string.h> |
9 | 8 |
10 #include "TileFrameTable.h" | 9 #include "TileFrameTable.h" |
28 } | 27 } |
29 | 28 |
30 //----- (00487E3B) -------------------------------------------------------- | 29 //----- (00487E3B) -------------------------------------------------------- |
31 TileDesc *TileTable::GetTileById(unsigned int uTileID) | 30 TileDesc *TileTable::GetTileById(unsigned int uTileID) |
32 { | 31 { |
33 /*TileDesc *result; // eax@3 | 32 Assert(uTileID < sNumTiles); |
34 | |
35 if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) ) | |
36 result = this->pTiles; | |
37 else | |
38 result = &this->pTiles[uTileID]; | |
39 return result;*/ | |
40 | |
41 assert(uTileID < sNumTiles); | |
42 return &pTiles[uTileID]; | 33 return &pTiles[uTileID]; |
43 } | 34 } |
44 | 35 |
45 //----- (00487E58) -------------------------------------------------------- | 36 //----- (00487E58) -------------------------------------------------------- |
46 void TileTable::InitializeTileset(Tileset tileset) | 37 void TileTable::InitializeTileset(Tileset tileset) |
110 | 101 |
111 v1 = Str; | 102 v1 = Str; |
112 v2 = fopen("data\\dtile.bin", "wb"); | 103 v2 = fopen("data\\dtile.bin", "wb"); |
113 v3 = v2; | 104 v3 = v2; |
114 if ( !v2 ) | 105 if ( !v2 ) |
115 Abortf("Unable to save dtile.bin!"); | 106 Error("Unable to save dtile.bin!"); |
116 fwrite(v1, 4u, 1u, v2); | 107 fwrite(v1, 4u, 1u, v2); |
117 fwrite(v1->pTiles, 0x1Au, v1->sNumTiles, v3); | 108 fwrite(v1->pTiles, 0x1Au, v1->sNumTiles, v3); |
118 fclose(v3); | 109 fclose(v3); |
119 } | 110 } |
120 | 111 |
123 { | 114 { |
124 uint num_mm6_tiles = data_mm6 ? *(int *)data_mm6 : 0, | 115 uint num_mm6_tiles = data_mm6 ? *(int *)data_mm6 : 0, |
125 num_mm7_tiles = data_mm7 ? *(int *)data_mm7 : 0, | 116 num_mm7_tiles = data_mm7 ? *(int *)data_mm7 : 0, |
126 num_mm8_tiles = data_mm8 ? *(int *)data_mm8 : 0; | 117 num_mm8_tiles = data_mm8 ? *(int *)data_mm8 : 0; |
127 sNumTiles = num_mm6_tiles + num_mm7_tiles + num_mm8_tiles; | 118 sNumTiles = num_mm6_tiles + num_mm7_tiles + num_mm8_tiles; |
128 assert(sNumTiles); | 119 Assert(sNumTiles); |
129 assert(!num_mm8_tiles); | 120 Assert(!num_mm8_tiles); |
130 | 121 |
131 pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, sNumTiles * sizeof(TileDesc), "Tile Descrip"); | 122 pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, sNumTiles * sizeof(TileDesc), "Tile Descrip"); |
132 memcpy(pTiles, (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc)); | 123 memcpy(pTiles, (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc)); |
133 memcpy(pTiles + num_mm7_tiles, (char *)data_mm6 + 4, num_mm6_tiles * sizeof(TileDesc)); | 124 memcpy(pTiles + num_mm7_tiles, (char *)data_mm6 + 4, num_mm6_tiles * sizeof(TileDesc)); |
134 memcpy(pTiles + num_mm6_tiles + num_mm7_tiles, (char *)data_mm8 + 4, num_mm8_tiles * sizeof(TileDesc)); | 125 memcpy(pTiles + num_mm6_tiles + num_mm7_tiles, (char *)data_mm8 + 4, num_mm8_tiles * sizeof(TileDesc)); |
224 | 215 |
225 v2 = this; | 216 v2 = this; |
226 v3 = fopen(pFilename, "r"); | 217 v3 = fopen(pFilename, "r"); |
227 File = v3; | 218 File = v3; |
228 if ( !v3 ) | 219 if ( !v3 ) |
229 Abortf("TileTable::load - Unable to open file: %s."); | 220 Error("TileTable::load - Unable to open file: %s."); |
230 v4 = 0; | 221 v4 = 0; |
231 for ( i = v3; fgets(&Buf, 490, i); i = File ) | 222 for ( i = v3; fgets(&Buf, 490, i); i = File ) |
232 { | 223 { |
233 *strchr(&Buf, 10) = 0; | 224 *strchr(&Buf, 10) = 0; |
234 memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); | 225 memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); |
237 } | 228 } |
238 v2->sNumTiles = v4; | 229 v2->sNumTiles = v4; |
239 v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip"); | 230 v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip"); |
240 v2->pTiles = (TileDesc *)v5; | 231 v2->pTiles = (TileDesc *)v5; |
241 if ( !v5 ) | 232 if ( !v5 ) |
242 Abortf("TileTable::Load - Out of Memory!"); | 233 Error("TileTable::Load - Out of Memory!"); |
243 memset(v5, 0, 26 * v2->sNumTiles); | 234 memset(v5, 0, 26 * v2->sNumTiles); |
244 v2->sNumTiles = 0; | 235 v2->sNumTiles = 0; |
245 fseek(File, 0, 0); | 236 fseek(File, 0, 0); |
246 if ( fgets(&Buf, 490, File) ) | 237 if ( fgets(&Buf, 490, File) ) |
247 { | 238 { |