Mercurial > mm7
comparison Overlays.cpp @ 1545:c4ab816fcc5e
assert, Abortf, AbortWithError -> Assert, Error
refactors here and there
author | Nomad |
---|---|
date | Sat, 07 Sep 2013 20:05:20 +0200 |
parents | 7ef4b64f6329 |
children | 75fafd8ced59 |
comparison
equal
deleted
inserted
replaced
1544:499761153844 | 1545:c4ab816fcc5e |
---|---|
174 | 174 |
175 v1 = this; | 175 v1 = this; |
176 v2 = fopen("data\\doverlay.bin", "wb"); | 176 v2 = fopen("data\\doverlay.bin", "wb"); |
177 v3 = v2; | 177 v3 = v2; |
178 if ( !v2 ) | 178 if ( !v2 ) |
179 Abortf("Unable to save doverlay.bin!"); | 179 Error("Unable to save doverlay.bin!"); |
180 fwrite(v1, 4u, 1u, v2); | 180 fwrite(v1, 4u, 1u, v2); |
181 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3); | 181 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3); |
182 fclose(v3); | 182 fclose(v3); |
183 } | 183 } |
184 | 184 |
188 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0, | 188 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0, |
189 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0, | 189 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0, |
190 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0; | 190 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0; |
191 | 191 |
192 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays; | 192 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays; |
193 assert(uNumOverlays); | 193 Assert(uNumOverlays); |
194 assert(!num_mm8_overlays); | 194 Assert(!num_mm8_overlays); |
195 | 195 |
196 pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, uNumOverlays * sizeof(OverlayDesc), "Ovl Des."); | 196 pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, uNumOverlays * sizeof(OverlayDesc), "Ovl Des."); |
197 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc)); | 197 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc)); |
198 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc)); | 198 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc)); |
199 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc)); | 199 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc)); |
228 v2->pOverlays = 0; | 228 v2->pOverlays = 0; |
229 v2->uNumOverlays = 0; | 229 v2->uNumOverlays = 0; |
230 v4 = fopen(Args, "r"); | 230 v4 = fopen(Args, "r"); |
231 File = v4; | 231 File = v4; |
232 if ( !v4 ) | 232 if ( !v4 ) |
233 Abortf("ObjectDescriptionList::load - Unable to open file: %s."); | 233 Error("ObjectDescriptionList::load - Unable to open file: %s."); |
234 | |
234 v5 = 0; | 235 v5 = 0; |
235 Argsa = 0; | 236 Argsa = 0; |
236 if ( fgets(&Buf, 490, v4) ) | 237 if ( fgets(&Buf, 490, v4) ) |
237 { | 238 { |
238 do | 239 do |
249 v6 = v2->pOverlays; | 250 v6 = v2->pOverlays; |
250 v2->uNumOverlays = v5; | 251 v2->uNumOverlays = v5; |
251 v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des."); | 252 v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des."); |
252 v2->pOverlays = (OverlayDesc *)v7; | 253 v2->pOverlays = (OverlayDesc *)v7; |
253 if ( v7 == (void *)v3 ) | 254 if ( v7 == (void *)v3 ) |
254 Abortf("OverlayDescriptionList::load - Out of Memory!"); | 255 Error("OverlayDescriptionList::load - Out of Memory!"); |
256 | |
255 memset(v7, v3, 8 * v2->uNumOverlays); | 257 memset(v7, v3, 8 * v2->uNumOverlays); |
256 v8 = File; | 258 v8 = File; |
257 v2->uNumOverlays = v3; | 259 v2->uNumOverlays = v3; |
258 fseek(v8, v3, v3); | 260 fseek(v8, v3, v3); |
259 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | 261 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) |