/ * SaveLevelData: Save current level to given file. */
| 525 | * SaveLevelData: Save current level to given file. |
| 526 | */ |
| 527 | void SaveLevelData (char *outfile) |
| 528 | { |
| 529 | FILE *file; |
| 530 | int i, width, height, true_minx, true_miny, true_maxx, true_maxy; |
| 531 | SHORT n; |
| 532 | BSPTree tree; |
| 533 | int temp; |
| 534 | long main_pos, server_pos, security_pos; |
| 535 | long node_pos, cwall_pos, rwall_pos, sector_pos, thing_pos, sidedef_pos; |
| 536 | WallDataList walls; |
| 537 | RECT room_subrect; |
| 538 | |
| 539 | // Backup existent file, if any |
| 540 | if (BackupFile(outfile) == False) |
| 541 | return; |
| 542 | |
| 543 | SELECT_WAIT_CURSOR(); |
| 544 | SAVE_WORK_MSG(); |
| 545 | |
| 546 | ClearLog(); |
| 547 | WorkMessage ("Saving data to \"%s\"...", outfile); |
| 548 | LogMessage ("Saving data to \"%s\"...\n", outfile); |
| 549 | |
| 550 | // Init. to NULL to destory it safely at the end of this function |
| 551 | pProgressDialog = NULL; |
| 552 | |
| 553 | // |
| 554 | // open the file |
| 555 | // |
| 556 | if ((file = fopen (outfile, "wb")) == NULL) |
| 557 | ProgError ("Unable to open file \"%s\"", outfile); |
| 558 | |
| 559 | security = 0; |
| 560 | |
| 561 | for (i=0; i < 4; i++) |
| 562 | WriteBytes(file, &room_magic[i], 1); |
| 563 | |
| 564 | temp = ROO_VERSION; |
| 565 | WriteBytes(file, &temp, 4); |
| 566 | security += ROO_VERSION; |
| 567 | |
| 568 | // Remember position in file for backpatching, and leave space in file |
| 569 | security_pos = FileCurPos(file); |
| 570 | WriteBytes(file, &temp, 4); |
| 571 | main_pos = FileCurPos(file); |
| 572 | WriteBytes(file, &temp, 4); |
| 573 | server_pos = FileCurPos(file); |
| 574 | WriteBytes(file, &temp, 4); |
| 575 | |
| 576 | // *** Save main section |
| 577 | |
| 578 | // Backpatch in position of client information |
| 579 | FileBackpatch(file, main_pos, FileCurPos(file)); |
| 580 | |
| 581 | // update MapMinX, MapMinY, MapMaxX, MapMaxY |
| 582 | FindRoomBoundary(); |
| 583 | |
| 584 | // See if we should set apparent room size smaller than actual room size |
no test coverage detected