Ticket #8911: cruise_v2.patch
File cruise_v2.patch, 21.6 KB (added by , 16 years ago) |
---|
-
engines/cruise/cruise_main.cpp
243 239 return NULL; 244 240 } 245 241 246 return ((ovlData3Struct *) (ovlData->ptr1 + param * 0x1C));242 return &ovlData->ptr1[param]; 247 243 } 248 244 249 245 void scriptFunc2(int scriptNumber, scriptInstanceStruct * scriptHandle, -
engines/cruise/saveload.cpp
465 465 void loadSavegameDataSub6(Common::InSaveFile& currentSaveFile) { 466 466 int32 var; 467 467 468 var = currentSaveFile.readUint32LE(); 469 flipLong(&var); 468 var = currentSaveFile.readUint32BE(); 470 469 471 470 if (var) { 472 471 int i; -
engines/cruise/vars.h
91 91 }; 92 92 93 93 struct setHeaderEntry { 94 int16 field_0; // offset ptr part 1 95 int16 field_2; // offset ptr part 2 94 int32 field_0; // offset ptr 96 95 int16 width; 97 96 int16 height; 98 97 int16 type; // resource type, ie. sprites 0,1,4,5 and 8 -
engines/cruise/overlay.cpp
23 23 * 24 24 */ 25 25 26 #include "common/stream.h" 27 26 28 #include "cruise/cruise_main.h" 27 29 28 30 namespace Cruise { … … 50 52 char fileName[50]; 51 53 int fileIdx; 52 54 int unpackedSize; 53 char *unpackedBuffer; 54 char *scriptPtr; 55 byte *unpackedBuffer; 55 56 ovlDataStruct *ovlData; 56 57 57 58 printf("Load overlay: %s\n", scriptName); … … 105 106 unpackedSize = volumePtrToFileDescriptor[fileIdx].extSize + 2; 106 107 107 108 // TODO: here, can unpack in gfx module buffer 108 unpackedBuffer = ( char*)mallocAndZero(unpackedSize);109 unpackedBuffer = (byte *)mallocAndZero(unpackedSize); 109 110 110 111 if (!unpackedBuffer) { 111 112 return (-2); … … 127 128 128 129 printf("OVL loading done...\n"); 129 130 130 scriptPtr = unpackedBuffer;131 Common::MemoryReadStream s(unpackedBuffer, unpackedSize); 131 132 132 133 ovlData = overlayTable[scriptIdx].ovlData; 133 134 134 memcpy(ovlData, scriptPtr, sizeof(ovlDataStruct)); 135 135 // Skip pointers 136 s.skip(60); 137 136 138 ovlData->arrayProc = NULL; 137 139 ovlData->ptr1 = NULL; 138 140 ovlData->arrayObject = NULL; … … 148 150 ovlData->arrayNameSymbGlob = NULL; 149 151 ovlData->data4Ptr = NULL; 150 152 ovlData->ptr8 = NULL; 151 ovlData->numProc = readB16(scriptPtr + 60);152 ovlData->numRel = readB16(scriptPtr + 62);153 ovlData->numSymbGlob = readB16(scriptPtr + 64);154 ovlData->numRelocGlob = readB16(scriptPtr + 66);155 ovlData->numMsgRelHeader = readB16(scriptPtr + 68);156 ovlData->numObj = readB16(scriptPtr + 70);157 ovlData->numStrings = readB16(scriptPtr + 72);158 ovlData->size8 = readB16(scriptPtr + 74);159 ovlData->size9 = readB16(scriptPtr + 76);160 ovlData->nameExportSize = readB16(scriptPtr + 78);161 ovlData->exportNamesSize = readB16(scriptPtr + 80);162 ovlData->specialString2Length = readB16(scriptPtr + 82);163 ovlData->sizeOfData4 = readB16(scriptPtr + 84);164 ovlData->size12 = readB16(scriptPtr + 86);165 ovlData->specialString1Length = readB16(scriptPtr + 88);166 ovlData->scriptNumber = readB16(scriptPtr + 90);153 ovlData->numProc = s.readUint16BE(); 154 ovlData->numRel = s.readUint16BE(); 155 ovlData->numSymbGlob = s.readUint16BE(); 156 ovlData->numRelocGlob = s.readUint16BE(); 157 ovlData->numMsgRelHeader = s.readUint16BE(); 158 ovlData->numObj = s.readUint16BE(); 159 ovlData->numStrings = s.readUint16BE(); 160 ovlData->size8 = s.readUint16BE(); 161 ovlData->size9 = s.readUint16BE(); 162 ovlData->nameExportSize = s.readUint16BE(); 163 ovlData->exportNamesSize = s.readUint16BE(); 164 ovlData->specialString2Length = s.readUint16BE(); 165 ovlData->sizeOfData4 = s.readUint16BE(); 166 ovlData->size12 = s.readUint16BE(); 167 ovlData->specialString1Length = s.readUint16BE(); 168 ovlData->scriptNumber = s.readUint16BE(); 167 169 168 scriptPtr += 92;169 170 170 if (ovlData->numSymbGlob) { // export data 171 171 int i; 172 172 ovlData->arraySymbGlob = … … 177 177 } 178 178 179 179 for (i = 0; i < ovlData->numSymbGlob; i++) { 180 ovlData->arraySymbGlob[i].var0 = readB16(scriptPtr); 181 ovlData->arraySymbGlob[i].var2 = readB16(scriptPtr + 2); 182 ovlData->arraySymbGlob[i].var4 = readB16(scriptPtr + 4); 183 ovlData->arraySymbGlob[i].idx = readB16(scriptPtr + 6); 184 ovlData->arraySymbGlob[i].offsetToName = readB16(scriptPtr + 8); 185 186 scriptPtr += 10; 180 ovlData->arraySymbGlob[i].var0 = s.readUint16BE(); 181 ovlData->arraySymbGlob[i].var2 = s.readUint16BE(); 182 ovlData->arraySymbGlob[i].var4 = s.readUint16BE(); 183 ovlData->arraySymbGlob[i].idx = s.readUint16BE(); 184 ovlData->arraySymbGlob[i].offsetToName = s.readUint16BE(); 187 185 } 188 186 } 189 187 … … 194 192 return (-2); 195 193 } 196 194 197 memcpy(ovlData->arrayNameSymbGlob, scriptPtr, ovlData->exportNamesSize); 198 scriptPtr += ovlData->exportNamesSize; 195 s.read(ovlData->arrayNameSymbGlob, ovlData->exportNamesSize); 199 196 } 200 197 201 198 if (ovlData->numRelocGlob) { // import data … … 210 207 } 211 208 212 209 for (i = 0; i < ovlData->numRelocGlob; i++) { 213 ovlData->arrayRelocGlob[i].var0 = readB16(scriptPtr); 214 ovlData->arrayRelocGlob[i].var1 = readB16(scriptPtr + 2); 215 ovlData->arrayRelocGlob[i].linkType = readB16(scriptPtr + 4); 216 ovlData->arrayRelocGlob[i].linkIdx = readB16(scriptPtr + 6); 217 ovlData->arrayRelocGlob[i].nameOffset = readB16(scriptPtr + 8); 218 219 scriptPtr += 10; 210 ovlData->arrayRelocGlob[i].var0 = s.readUint16BE(); 211 ovlData->arrayRelocGlob[i].var1 = s.readUint16BE(); 212 ovlData->arrayRelocGlob[i].linkType = s.readUint16BE(); 213 ovlData->arrayRelocGlob[i].linkIdx = s.readUint16BE(); 214 ovlData->arrayRelocGlob[i].nameOffset = s.readUint16BE(); 220 215 } 221 216 } 222 217 … … 226 221 if (!ovlData->arrayNameRelocGlob) { 227 222 return (-2); 228 223 } 229 230 memcpy(ovlData->arrayNameRelocGlob, scriptPtr, 231 ovlData->nameExportSize); 232 scriptPtr += ovlData->nameExportSize; 224 225 s.read(ovlData->arrayNameRelocGlob, ovlData->nameExportSize); 233 226 } 234 227 235 228 if (ovlData->numMsgRelHeader) { // link data 229 int i; 236 230 ASSERT(sizeof(linkDataStruct) == 0x22); 237 231 238 232 ovlData->arrayMsgRelHeader = (linkDataStruct *) mallocAndZero(ovlData->numMsgRelHeader * sizeof(linkDataStruct)); … … 241 235 return (-2); 242 236 } 243 237 244 memcpy(ovlData->arrayMsgRelHeader, scriptPtr, ovlData->numMsgRelHeader * sizeof(linkDataStruct)); 245 scriptPtr += ovlData->numMsgRelHeader * sizeof(linkDataStruct); 246 flipGen(ovlData->arrayMsgRelHeader, ovlData->numMsgRelHeader * sizeof(linkDataStruct)); 238 for (i = 0; i < ovlData->numMsgRelHeader; i++) { 239 ovlData->arrayMsgRelHeader[i].type = s.readUint16BE(); 240 ovlData->arrayMsgRelHeader[i].id = s.readUint16BE(); 241 ovlData->arrayMsgRelHeader[i].offsetVerbeName = s.readUint16BE(); 242 ovlData->arrayMsgRelHeader[i].verbOverlay = s.readUint16BE(); 243 ovlData->arrayMsgRelHeader[i].verbNumber = s.readUint16BE(); 244 245 ovlData->arrayMsgRelHeader[i].obj1Overlay = s.readUint16BE(); 246 ovlData->arrayMsgRelHeader[i].obj1Number = s.readUint16BE(); 247 ovlData->arrayMsgRelHeader[i].obj2Overlay = s.readUint16BE(); 248 ovlData->arrayMsgRelHeader[i].obj2Number = s.readUint16BE(); 249 250 ovlData->arrayMsgRelHeader[i].trackX = s.readUint16BE(); 251 ovlData->arrayMsgRelHeader[i].trackY = s.readUint16BE(); 252 253 ovlData->arrayMsgRelHeader[i].obj1NewState = s.readUint16BE(); 254 ovlData->arrayMsgRelHeader[i].obj2NewState = s.readUint16BE(); 255 256 ovlData->arrayMsgRelHeader[i].obj1OldState = s.readUint16BE(); 257 ovlData->arrayMsgRelHeader[i].obj2OldState = s.readUint16BE(); 258 259 ovlData->arrayMsgRelHeader[i].trackDirection = s.readUint16BE(); 260 ovlData->arrayMsgRelHeader[i].dialog = s.readUint16BE(); 261 } 247 262 } 248 263 249 264 if (ovlData->numProc) { // script … … 251 266 int i; 252 267 253 268 ovlData->arrayProc = 254 (ovlData3Struct *) mallocAndZero(ovlData->numProc * 255 sizeof(ovlData3Struct)); 269 (ovlData3Struct *) mallocAndZero(ovlData->numProc * sizeof(ovlData3Struct)); 256 270 257 271 if (!ovlData->arrayProc) { 258 /* releaseScript(scriptIdx,scriptName);259 260 if (freeIsNeeded) {261 freePtr(unpackedBuffer);262 } */263 264 272 return (-2); 265 273 } 266 274 267 memcpy(ovlData->arrayProc, scriptPtr, 268 ovlData->numProc * sizeof(ovlData3Struct)); 269 scriptPtr += ovlData->numProc * 0x1C; 275 for (i = 0; i < ovlData->numProc; i++) { 276 s.skip(4); 277 ovlData->arrayProc[i].dataPtr = NULL; 278 ovlData->arrayProc[i].sizeOfData = s.readUint16BE(); 279 ovlData->arrayProc[i].offsetToSubData3 = s.readUint16BE(); 280 ovlData->arrayProc[i].offsetToImportData = s.readUint16BE(); 281 ovlData->arrayProc[i].offsetToSubData2 = s.readUint16BE(); 282 ovlData->arrayProc[i].offsetToImportName = s.readUint16BE(); 283 ovlData->arrayProc[i].offsetToSubData5 = s.readUint16BE(); 284 ovlData->arrayProc[i].sysKey = s.readUint16BE(); 285 ovlData->arrayProc[i].var12 = s.readUint16BE(); 286 ovlData->arrayProc[i].numRelocGlob = s.readUint16BE(); 287 ovlData->arrayProc[i].subData2Size = s.readUint16BE(); 288 ovlData->arrayProc[i].var18 = s.readUint16BE(); 289 ovlData->arrayProc[i].var1A = s.readUint16BE(); 290 } 270 291 271 flipGen(ovlData->arrayProc,272 ovlData->numProc * sizeof(ovlData3Struct));273 274 292 tempPtr = ovlData->arrayProc; 275 293 276 294 for (i = 0; i < ovlData->numProc; i++) { 277 uint8 *ptr = tempPtr->dataPtr = 278 (uint8 *) mallocAndZero(tempPtr->sizeOfData); 295 tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData); 279 296 280 if (!ptr) { 281 /* releaseScript(scriptIdx,scriptName); 282 * 283 * if (freeIsNeeded) 284 * { 285 * freePtr(unpackedBuffer); 286 * } */ 287 297 if (!tempPtr->dataPtr) { 288 298 return (-2); 289 299 } 290 300 291 memcpy(ptr, scriptPtr, tempPtr->sizeOfData); 292 scriptPtr += tempPtr->sizeOfData; 301 s.read(tempPtr->dataPtr, tempPtr->sizeOfData); 293 302 294 303 if (tempPtr->offsetToImportData) { 295 flipGen( ptr + tempPtr->offsetToImportData,304 flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData, 296 305 tempPtr->numRelocGlob * 10); 297 306 } 298 307 299 308 if (tempPtr->offsetToSubData2) { 300 flipGen( ptr + tempPtr->offsetToImportData,309 flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2, 301 310 tempPtr->subData2Size * 10); 302 311 } 303 312 … … 310 319 int i; 311 320 312 321 ovlData->ptr1 = 313 ( uint8 *) mallocAndZero(ovlData->numRel * 0x1C);322 (ovlData3Struct *) mallocAndZero(ovlData->numRel * sizeof(ovlData3Struct)); 314 323 315 324 if (!ovlData->ptr1) { 316 325 return (-2); 317 326 } 318 327 319 memcpy(ovlData->ptr1, scriptPtr, ovlData->numRel * 0x1C); 320 scriptPtr += ovlData->numRel * 0x1C; 321 flipGen(ovlData->ptr1, ovlData->numRel * 0x1C); 322 328 for (i = 0; i < ovlData->numRel; i++) { 329 s.skip(4); 330 ovlData->ptr1[i].dataPtr = NULL; 331 ovlData->ptr1[i].sizeOfData = s.readUint16BE(); 332 ovlData->ptr1[i].offsetToSubData3 = s.readUint16BE(); 333 ovlData->ptr1[i].offsetToImportData = s.readUint16BE(); 334 ovlData->ptr1[i].offsetToSubData2 = s.readUint16BE(); 335 ovlData->ptr1[i].offsetToImportName = s.readUint16BE(); 336 ovlData->ptr1[i].offsetToSubData5 = s.readUint16BE(); 337 ovlData->ptr1[i].sysKey = s.readUint16BE(); 338 ovlData->ptr1[i].var12 = s.readUint16BE(); 339 ovlData->ptr1[i].numRelocGlob = s.readUint16BE(); 340 ovlData->ptr1[i].subData2Size = s.readUint16BE(); 341 ovlData->ptr1[i].var18 = s.readUint16BE(); 342 ovlData->ptr1[i].var1A = s.readUint16BE(); 343 } 344 323 345 tempPtr = (ovlData3Struct *) ovlData->ptr1; 324 346 325 347 for (i = 0; i < ovlData->numRel; i++) { 326 uint8 *ptr = tempPtr->dataPtr = 327 (uint8 *) mallocAndZero(tempPtr->sizeOfData); 348 tempPtr->dataPtr = (uint8 *) mallocAndZero(tempPtr->sizeOfData); 328 349 329 if (!ptr) { 330 /* releaseScript(scriptIdx,scriptName); 331 * 332 * if (freeIsNeeded) 333 * { 334 * freePtr(unpackedBuffer); 335 * } */ 336 350 if (!tempPtr->dataPtr) { 337 351 return (-2); 338 352 } 339 353 340 memcpy(ptr, scriptPtr, tempPtr->sizeOfData); 341 scriptPtr += tempPtr->sizeOfData; 354 s.read(tempPtr->dataPtr, tempPtr->sizeOfData); 342 355 343 356 if (tempPtr->offsetToImportData) { 344 flipGen( ptr + tempPtr->offsetToImportData,357 flipGen(tempPtr->dataPtr + tempPtr->offsetToImportData, 345 358 tempPtr->numRelocGlob * 10); 346 359 } 347 360 348 361 if (tempPtr->offsetToSubData2) { 349 flipGen( ptr + tempPtr->offsetToImportData,362 flipGen(tempPtr->dataPtr + tempPtr->offsetToSubData2, 350 363 tempPtr->subData2Size * 10); 351 364 } 352 365 … … 367 380 return (-2); 368 381 } 369 382 370 memcpy(ovlData->ptr8, scriptPtr, ovlData->size12); 371 scriptPtr += ovlData->size12; 383 s.read(ovlData->ptr8, ovlData->size12); 372 384 } 373 385 374 386 if (ovlData->numObj) { … … 378 390 sizeof(objDataStruct)); 379 391 380 392 if (!ovlData->arrayObject) { 381 /* releaseScript(scriptIdx,scriptName);382 383 if (freeIsNeeded) {384 freePtr(unpackedBuffer);385 } */386 387 393 return (-2); 388 394 } 389 395 390 396 for (i = 0; i < ovlData->numObj; i++) { 391 ovlData->arrayObject[i]._type = *(int16 *) scriptPtr; 392 scriptPtr += 2; 393 flipShort(&ovlData->arrayObject[i]._type); 394 395 int16 tempClass = *(int16 *) scriptPtr; 396 flipShort(&tempClass); 397 ovlData->arrayObject[i]._class = (eClass)tempClass; 398 scriptPtr += 2; 399 400 ovlData->arrayObject[i]._nameOffset = *(int16 *) scriptPtr; 401 scriptPtr += 2; 402 flipShort(&ovlData->arrayObject[i]._nameOffset); 403 404 ovlData->arrayObject[i]._numStates = *(int16 *) scriptPtr; 405 scriptPtr += 2; 406 flipShort(&ovlData->arrayObject[i]._numStates); 407 408 ovlData->arrayObject[i]._varTableIdx = *(int16 *) scriptPtr; 409 scriptPtr += 2; 410 flipShort(&ovlData->arrayObject[i]._varTableIdx); 411 412 ovlData->arrayObject[i]._firstStateIdx = *(int16 *) scriptPtr; 413 scriptPtr += 2; 414 flipShort(&ovlData->arrayObject[i]._firstStateIdx); 415 416 ovlData->arrayObject[i]._stateTableIdx = *(int16 *) scriptPtr; 417 scriptPtr += 2; 418 flipShort(&ovlData->arrayObject[i]._stateTableIdx); 397 ovlData->arrayObject[i]._type = s.readUint16BE(); 398 ovlData->arrayObject[i]._class = (eClass) s.readUint16BE(); 399 ovlData->arrayObject[i]._nameOffset = s.readUint16BE(); 400 ovlData->arrayObject[i]._numStates = s.readUint16BE(); 401 ovlData->arrayObject[i]._varTableIdx = s.readUint16BE(); 402 ovlData->arrayObject[i]._firstStateIdx = s.readUint16BE(); 403 ovlData->arrayObject[i]._stateTableIdx = s.readUint16BE(); 419 404 } 420 405 421 // alloc te states for object with multiple states406 // allocate states for object with multiple states 422 407 423 408 if (scriptNotLoadedBefore) { 424 409 overlayTable[scriptIdx].state = stateID; … … 430 415 ovlData->arrayObjVar = 431 416 (objectParams *) mallocAndZero(ovlData->size9 * 432 417 sizeof(objectParams)); 433 memset(ovlData->arrayObjVar, 0,434 ovlData->size9 * sizeof(objectParams));435 418 436 419 if (!ovlData->arrayObjVar) { 437 /* releaseScript(scriptIdx,scriptName);438 439 if (freeIsNeeded) {440 freePtr(unpackedBuffer);441 } */442 443 420 return (-2); 444 421 } 445 422 } 446 423 447 424 if (ovlData->size8) { 425 int i; 448 426 ovlData->arrayStates = 449 427 (objectParams *) mallocAndZero(ovlData->size8 * 450 428 sizeof(objectParams)); 451 429 452 430 if (!ovlData->arrayStates) { 453 /* releaseScript(scriptIdx,scriptName);454 455 if (freeIsNeeded) {456 freePtr(unpackedBuffer);457 } */458 459 431 return (-2); 460 432 } 461 433 462 memcpy(ovlData->arrayStates, scriptPtr, ovlData->size8 * 12); // TODO: made read item by item 463 scriptPtr += ovlData->size8 * 12; 464 flipGen(ovlData->arrayStates, ovlData->size8 * 12); 434 for (i = 0; i < ovlData->size8; i++) { 435 ovlData->arrayStates[i].X = s.readUint16BE(); 436 ovlData->arrayStates[i].Y = s.readUint16BE(); 437 ovlData->arrayStates[i].Z = s.readUint16BE(); 438 ovlData->arrayStates[i].frame = s.readUint16BE(); 439 ovlData->arrayStates[i].scale = s.readUint16BE(); 440 ovlData->arrayStates[i].state = s.readUint16BE(); 441 } 465 442 } 466 443 467 444 if (ovlData->numStrings) { … … 472 449 sizeof(stringEntryStruct)); 473 450 474 451 for (i = 0; i < ovlData->numStrings; i++) { 475 ovlData->stringTable[i].idx = *(int16 *) scriptPtr; 476 flipShort(&ovlData->stringTable[i].idx); 477 scriptPtr += 2; 452 ovlData->stringTable[i].idx = s.readUint16BE(); 478 453 } 479 454 } 480 455 481 /* if (freeIsNeeded) {482 freePtr(unpackedBuffer);483 } */484 485 456 if (ovlData->sizeOfData4) { 486 457 ovlData->data4Ptr = 487 458 (uint8 *) mallocAndZero(ovlData->sizeOfData4); 488 memset(ovlData->data4Ptr, 0, ovlData->sizeOfData4);489 459 490 460 if (!ovlData->data4Ptr) { 491 //releaseScript(scriptIdx,scriptName);492 461 return (-2); 493 462 } 494 463 } … … 516 485 unpackedSize = volumePtrToFileDescriptor[fileIdx].extSize + 2; 517 486 518 487 // TODO: here, can unpack in gfx module buffer 519 unpackedBuffer = ( char*)mallocAndZero(unpackedSize);488 unpackedBuffer = (byte *)mallocAndZero(unpackedSize); 520 489 521 490 if (!unpackedBuffer) { 522 491 return (-2); … … 538 507 loadPakedFileToMem(fileIdx, (uint8 *) unpackedBuffer); 539 508 } 540 509 541 scriptPtr = unpackedBuffer;510 Common::MemoryReadStream s2(unpackedBuffer, unpackedSize); 542 511 543 memcpy(&ovlData->specialString1Length, scriptPtr, 2); 544 scriptPtr += 2; 545 flipShort(&ovlData->specialString1Length); // recheck if needed 546 512 ovlData->specialString1Length = s2.readUint16BE(); 547 513 if (ovlData->specialString1Length) { 548 514 ovlData->nameVerbGlob = (char *) mallocAndZero(ovlData->specialString1Length); 549 515 … … 558 524 return (-2); 559 525 } 560 526 561 memcpy(ovlData->nameVerbGlob, scriptPtr, 562 ovlData->specialString1Length); 563 scriptPtr += ovlData->specialString1Length; 527 s2.read(ovlData->nameVerbGlob, ovlData->specialString1Length); 564 528 } 565 529 566 memcpy(&ovlData->specialString2Length, scriptPtr, 2); 567 scriptPtr += 2; 568 flipShort(&ovlData->specialString2Length); // recheck if needed 569 530 ovlData->specialString2Length = s2.readUint16BE(); 570 531 if (ovlData->specialString2Length) { 571 532 ovlData->arrayNameObj = (char *) mallocAndZero(ovlData->specialString2Length); 572 533 … … 581 542 return (-2); 582 543 } 583 544 584 memcpy(ovlData->arrayNameObj, scriptPtr, 585 ovlData->specialString2Length); 586 scriptPtr += ovlData->specialString2Length; 545 s2.read(ovlData->arrayNameObj, ovlData->specialString2Length); 587 546 } 588 547 589 548 for (i = 0; i < ovlData->numStrings; i++) { 590 ovlData->stringTable[i].length = *(int16 *) scriptPtr; 591 scriptPtr += 2; 592 flipShort(&ovlData->stringTable[i].length); 549 ovlData->stringTable[i].length = s2.readUint16BE(); 593 550 594 551 if (ovlData->stringTable[i].length) { 595 552 ovlData->stringTable[i].string = … … 607 564 return (-2); 608 565 } 609 566 610 memcpy(ovlData->stringTable[i].string, scriptPtr, ovlData->stringTable[i].length); 611 scriptPtr += ovlData->stringTable[i].length; 567 s2.read(ovlData->stringTable[i].string, ovlData->stringTable[i].length); 612 568 } 613 569 } 614 570 } -
engines/cruise/dataLoader.cpp
24 24 */ 25 25 26 26 #include "cruise/cruise_main.h" 27 #include "common/endian.h" 27 28 28 29 namespace Cruise { 29 30 … … 412 405 } 413 406 414 407 int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentDestEntry) { 415 uint8 *ptr2;416 408 uint8 *ptr3; 417 409 int offset; 418 410 int sec = 0; … … 422 414 sec = 1; 423 415 } 424 416 425 ptr2 = ptr + 4;417 numIdx = READ_BE_UINT16(ptr + 4); 426 418 427 memcpy(&numIdx, ptr2, 2);428 flipShort(&numIdx);429 430 419 ptr3 = ptr + 6; 431 420 432 421 offset = currentEntryIdx * 16; 433 422 434 423 { 435 uint8 *ptr4;436 424 int resourceSize; 437 425 int fileIndex; 438 426 setHeaderEntry localBuffer; 439 427 uint8 *ptr5; 440 428 441 ptr4 = ptr + offset + 6;429 Common::MemoryReadStream s4(ptr + offset + 6, 16); 442 430 443 memcpy(&localBuffer, ptr4, sizeof(setHeaderEntry)); 431 localBuffer.field_0 = s4.readUint32BE(); 432 localBuffer.width = s4.readUint16BE(); 433 localBuffer.height = s4.readUint16BE(); 434 localBuffer.type = s4.readUint16BE(); 435 localBuffer.transparency = s4.readUint16BE(); 436 localBuffer.field_C = s4.readUint16BE(); 437 localBuffer.field_E = s4.readUint16BE(); 444 438 445 flipLong((int32 *) & localBuffer.field_0);446 flipGen(&localBuffer.width, 12);447 448 439 if (sec == 1) { 449 440 localBuffer.width = localBuffer.width - (localBuffer.type * 2); // Type 1: Width - (1*2) , Type 5: Width - (5*2) 450 441 } -
engines/cruise/ctp.cpp
153 153 int16* a2; 154 154 155 155 a1 = a2 = (int16*)str; 156 a2 += 4+sizeof(int16*); // skip header157 156 a2 += sizeof(int16*) / sizeof(int16) + 6; // skip header 157 158 158 int16* XArray = XMIN_XMAX; 159 159 int minY = *XArray++; 160 160 … … 178 178 179 179 adrStructPoly = (uint8*)a2; 180 180 181 *(uint16**)a2 = (uint16*)-1; 182 181 *(uint16**)a2 = (uint16*)-1; //chained list terminator 182 183 183 a1+=sizeof(int16*); 184 184 *a1++=num; 185 185 *a1++=walkboxColor[num]; … … 339 328 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0 ); 340 329 } 341 330 342 polyStructExp = adrStructPoly += 4;331 polyStructExp = adrStructPoly += sizeof(int16 *); 343 332 344 333 for(int i= numberOfWalkboxes-1; i >=0; i--) { 345 334 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20 ); 346 335 } 347 336 348 int ctSize = (adrStructPoly - ptr) + 4; // for now, the +4is a safe zone337 int ctSize = (adrStructPoly - ptr) + sizeof(int16 *); // for now, the +sizeof(int16 *) is a safe zone 349 338 adrStructPoly = polyStructNorm = polyStruct = (uint8 *) malloc(ctSize); 350 339 351 340 for(int i= numberOfWalkboxes-1; i >=0; i--) { 352 341 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0); 353 342 } 354 343 355 polyStructExp = adrStructPoly += 4;344 polyStructExp = adrStructPoly += sizeof(int16 *); 356 345 357 346 for(int i= numberOfWalkboxes-1; i >=0; i--) { 358 347 makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20); -
engines/cruise/overlay.h
129 129 struct ovlDataStruct { 130 130 131 131 ovlData3Struct *arrayProc; 132 uint8*ptr1;132 ovlData3Struct *ptr1; 133 133 objDataStruct *arrayObject; 134 134 objectParams *arrayStates; 135 135 objectParams *arrayObjVar;