Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadWorld_Version1_Old_BeforeRelease88()

static int Terraria.IO.WorldFile.LoadWorld_Version1_Old_BeforeRelease88 ( BinaryReader fileIO)
inlinestaticprivate

Definition at line 3244 of file WorldFile.cs.

3245 {
3246 Main.WorldFileMetadata = FileMetadata.FromCurrentSettings(FileType.World);
3247 int versionNumber = _versionNumber;
3248 if (versionNumber > 279)
3249 {
3250 return 1;
3251 }
3252 Main.worldName = fileIO.ReadString();
3253 Main.worldID = fileIO.ReadInt32();
3254 Main.leftWorld = fileIO.ReadInt32();
3255 Main.rightWorld = fileIO.ReadInt32();
3256 Main.topWorld = fileIO.ReadInt32();
3257 Main.bottomWorld = fileIO.ReadInt32();
3258 Main.maxTilesY = fileIO.ReadInt32();
3259 Main.maxTilesX = fileIO.ReadInt32();
3260 if (versionNumber >= 112)
3261 {
3262 Main.GameMode = (fileIO.ReadBoolean() ? 1 : 0);
3263 }
3264 else
3265 {
3266 Main.GameMode = 0;
3267 }
3268 if (versionNumber >= 63)
3269 {
3270 Main.moonType = fileIO.ReadByte();
3271 }
3272 else
3273 {
3274 WorldGen.RandomizeMoonState(WorldGen.genRand);
3275 }
3276 WorldGen.clearWorld();
3277 if (versionNumber >= 44)
3278 {
3279 Main.treeX[0] = fileIO.ReadInt32();
3280 Main.treeX[1] = fileIO.ReadInt32();
3281 Main.treeX[2] = fileIO.ReadInt32();
3282 Main.treeStyle[0] = fileIO.ReadInt32();
3283 Main.treeStyle[1] = fileIO.ReadInt32();
3284 Main.treeStyle[2] = fileIO.ReadInt32();
3285 Main.treeStyle[3] = fileIO.ReadInt32();
3286 }
3287 if (versionNumber >= 60)
3288 {
3289 Main.caveBackX[0] = fileIO.ReadInt32();
3290 Main.caveBackX[1] = fileIO.ReadInt32();
3291 Main.caveBackX[2] = fileIO.ReadInt32();
3292 Main.caveBackStyle[0] = fileIO.ReadInt32();
3293 Main.caveBackStyle[1] = fileIO.ReadInt32();
3294 Main.caveBackStyle[2] = fileIO.ReadInt32();
3295 Main.caveBackStyle[3] = fileIO.ReadInt32();
3296 Main.iceBackStyle = fileIO.ReadInt32();
3297 if (versionNumber >= 61)
3298 {
3299 Main.jungleBackStyle = fileIO.ReadInt32();
3300 Main.hellBackStyle = fileIO.ReadInt32();
3301 }
3302 }
3303 else
3304 {
3305 WorldGen.RandomizeCaveBackgrounds();
3306 }
3307 Main.spawnTileX = fileIO.ReadInt32();
3308 Main.spawnTileY = fileIO.ReadInt32();
3309 Main.worldSurface = fileIO.ReadDouble();
3310 Main.rockLayer = fileIO.ReadDouble();
3311 _tempTime = fileIO.ReadDouble();
3312 _tempDayTime = fileIO.ReadBoolean();
3313 _tempMoonPhase = fileIO.ReadInt32();
3314 _tempBloodMoon = fileIO.ReadBoolean();
3315 if (versionNumber >= 70)
3316 {
3317 _tempEclipse = fileIO.ReadBoolean();
3318 Main.eclipse = _tempEclipse;
3319 }
3320 Main.dungeonX = fileIO.ReadInt32();
3321 Main.dungeonY = fileIO.ReadInt32();
3322 if (versionNumber >= 56)
3323 {
3324 WorldGen.crimson = fileIO.ReadBoolean();
3325 }
3326 else
3327 {
3328 WorldGen.crimson = false;
3329 }
3330 NPC.downedBoss1 = fileIO.ReadBoolean();
3331 NPC.downedBoss2 = fileIO.ReadBoolean();
3332 NPC.downedBoss3 = fileIO.ReadBoolean();
3333 if (versionNumber >= 66)
3334 {
3335 NPC.downedQueenBee = fileIO.ReadBoolean();
3336 }
3337 if (versionNumber >= 44)
3338 {
3339 NPC.downedMechBoss1 = fileIO.ReadBoolean();
3340 NPC.downedMechBoss2 = fileIO.ReadBoolean();
3341 NPC.downedMechBoss3 = fileIO.ReadBoolean();
3342 NPC.downedMechBossAny = fileIO.ReadBoolean();
3343 }
3344 if (versionNumber >= 64)
3345 {
3346 NPC.downedPlantBoss = fileIO.ReadBoolean();
3347 NPC.downedGolemBoss = fileIO.ReadBoolean();
3348 }
3349 if (versionNumber >= 29)
3350 {
3351 NPC.savedGoblin = fileIO.ReadBoolean();
3352 NPC.savedWizard = fileIO.ReadBoolean();
3353 if (versionNumber >= 34)
3354 {
3355 NPC.savedMech = fileIO.ReadBoolean();
3356 if (versionNumber >= 80)
3357 {
3358 NPC.savedStylist = fileIO.ReadBoolean();
3359 }
3360 }
3361 if (versionNumber >= 129)
3362 {
3363 NPC.savedTaxCollector = fileIO.ReadBoolean();
3364 }
3365 if (versionNumber >= 201)
3366 {
3367 NPC.savedGolfer = fileIO.ReadBoolean();
3368 }
3369 NPC.downedGoblins = fileIO.ReadBoolean();
3370 }
3371 if (versionNumber >= 32)
3372 {
3373 NPC.downedClown = fileIO.ReadBoolean();
3374 }
3375 if (versionNumber >= 37)
3376 {
3377 NPC.downedFrost = fileIO.ReadBoolean();
3378 }
3379 if (versionNumber >= 56)
3380 {
3381 NPC.downedPirates = fileIO.ReadBoolean();
3382 }
3383 WorldGen.shadowOrbSmashed = fileIO.ReadBoolean();
3384 WorldGen.spawnMeteor = fileIO.ReadBoolean();
3385 WorldGen.shadowOrbCount = fileIO.ReadByte();
3386 if (versionNumber >= 23)
3387 {
3388 WorldGen.altarCount = fileIO.ReadInt32();
3389 Main.hardMode = fileIO.ReadBoolean();
3390 }
3391 Main.invasionDelay = fileIO.ReadInt32();
3392 Main.invasionSize = fileIO.ReadInt32();
3393 Main.invasionType = fileIO.ReadInt32();
3394 Main.invasionX = fileIO.ReadDouble();
3395 if (versionNumber >= 113)
3396 {
3397 Main.sundialCooldown = fileIO.ReadByte();
3398 }
3399 if (versionNumber >= 53)
3400 {
3401 _tempRaining = fileIO.ReadBoolean();
3402 _tempRainTime = fileIO.ReadInt32();
3403 _tempMaxRain = fileIO.ReadSingle();
3404 }
3405 if (versionNumber >= 54)
3406 {
3407 WorldGen.SavedOreTiers.Cobalt = fileIO.ReadInt32();
3408 WorldGen.SavedOreTiers.Mythril = fileIO.ReadInt32();
3409 WorldGen.SavedOreTiers.Adamantite = fileIO.ReadInt32();
3410 }
3411 else if (versionNumber >= 23 && WorldGen.altarCount == 0)
3412 {
3413 WorldGen.SavedOreTiers.Cobalt = -1;
3414 WorldGen.SavedOreTiers.Mythril = -1;
3415 WorldGen.SavedOreTiers.Adamantite = -1;
3416 }
3417 else
3418 {
3419 WorldGen.SavedOreTiers.Cobalt = 107;
3420 WorldGen.SavedOreTiers.Mythril = 108;
3421 WorldGen.SavedOreTiers.Adamantite = 111;
3422 }
3423 int style = 0;
3424 int style2 = 0;
3425 int style3 = 0;
3426 int style4 = 0;
3427 int style5 = 0;
3428 int style6 = 0;
3429 int style7 = 0;
3430 int style8 = 0;
3431 int style9 = 0;
3432 int style10 = 0;
3433 if (versionNumber >= 55)
3434 {
3435 style = fileIO.ReadByte();
3436 style2 = fileIO.ReadByte();
3437 style3 = fileIO.ReadByte();
3438 }
3439 if (versionNumber >= 60)
3440 {
3441 style4 = fileIO.ReadByte();
3442 style5 = fileIO.ReadByte();
3443 style6 = fileIO.ReadByte();
3444 style7 = fileIO.ReadByte();
3445 style8 = fileIO.ReadByte();
3446 }
3447 WorldGen.setBG(0, style);
3448 WorldGen.setBG(1, style2);
3449 WorldGen.setBG(2, style3);
3450 WorldGen.setBG(3, style4);
3451 WorldGen.setBG(4, style5);
3452 WorldGen.setBG(5, style6);
3453 WorldGen.setBG(6, style7);
3454 WorldGen.setBG(7, style8);
3455 WorldGen.setBG(8, style9);
3456 WorldGen.setBG(9, style10);
3457 WorldGen.setBG(10, style);
3458 WorldGen.setBG(11, style);
3459 WorldGen.setBG(12, style);
3460 if (versionNumber >= 60)
3461 {
3462 Main.cloudBGActive = fileIO.ReadInt32();
3463 if (Main.cloudBGActive >= 1f)
3464 {
3465 Main.cloudBGAlpha = 1f;
3466 }
3467 else
3468 {
3469 Main.cloudBGAlpha = 0f;
3470 }
3471 }
3472 else
3473 {
3474 Main.cloudBGActive = -WorldGen.genRand.Next(8640, 86400);
3475 }
3476 if (versionNumber >= 62)
3477 {
3478 Main.numClouds = fileIO.ReadInt16();
3479 Main.windSpeedTarget = fileIO.ReadSingle();
3480 Main.windSpeedCurrent = Main.windSpeedTarget;
3481 }
3482 else
3483 {
3484 WorldGen.RandomizeWeather();
3485 }
3486 for (int i = 0; i < Main.maxTilesX; i++)
3487 {
3488 float num = (float)i / (float)Main.maxTilesX;
3489 Main.statusText = Lang.gen[51].Value + " " + (int)(num * 100f + 1f) + "%";
3490 for (int j = 0; j < Main.maxTilesY; j++)
3491 {
3492 Tile tile = Main.tile[i, j];
3493 int num2 = -1;
3494 tile.active(fileIO.ReadBoolean());
3495 if (tile.active())
3496 {
3497 num2 = ((versionNumber <= 77) ? fileIO.ReadByte() : fileIO.ReadUInt16());
3498 tile.type = (ushort)num2;
3499 if (tile.type == 127 || tile.type == 504)
3500 {
3501 tile.active(active: false);
3502 }
3503 if (versionNumber < 72 && (tile.type == 35 || tile.type == 36 || tile.type == 170 || tile.type == 171 || tile.type == 172))
3504 {
3505 tile.frameX = fileIO.ReadInt16();
3506 tile.frameY = fileIO.ReadInt16();
3507 }
3508 else if (Main.tileFrameImportant[num2])
3509 {
3510 if (versionNumber < 28 && num2 == 4)
3511 {
3512 tile.frameX = 0;
3513 tile.frameY = 0;
3514 }
3515 else if (versionNumber < 40 && tile.type == 19)
3516 {
3517 tile.frameX = 0;
3518 tile.frameY = 0;
3519 }
3520 else if (versionNumber < 195 && tile.type == 49)
3521 {
3522 tile.frameX = 0;
3523 tile.frameY = 0;
3524 }
3525 else
3526 {
3527 tile.frameX = fileIO.ReadInt16();
3528 tile.frameY = fileIO.ReadInt16();
3529 if (tile.type == 144)
3530 {
3531 tile.frameY = 0;
3532 }
3533 }
3534 }
3535 else
3536 {
3537 tile.frameX = -1;
3538 tile.frameY = -1;
3539 }
3540 if (versionNumber >= 48 && fileIO.ReadBoolean())
3541 {
3542 tile.color(fileIO.ReadByte());
3543 }
3544 }
3545 if (versionNumber <= 25)
3546 {
3547 fileIO.ReadBoolean();
3548 }
3549 if (fileIO.ReadBoolean())
3550 {
3551 tile.wall = fileIO.ReadByte();
3552 if (tile.wall >= WallID.Count)
3553 {
3554 tile.wall = 0;
3555 }
3556 if (versionNumber >= 48 && fileIO.ReadBoolean())
3557 {
3558 tile.wallColor(fileIO.ReadByte());
3559 }
3560 }
3561 if (fileIO.ReadBoolean())
3562 {
3563 tile.liquid = fileIO.ReadByte();
3564 tile.lava(fileIO.ReadBoolean());
3565 if (versionNumber >= 51)
3566 {
3567 tile.honey(fileIO.ReadBoolean());
3568 }
3569 }
3570 if (versionNumber >= 33)
3571 {
3572 tile.wire(fileIO.ReadBoolean());
3573 }
3574 if (versionNumber >= 43)
3575 {
3576 tile.wire2(fileIO.ReadBoolean());
3577 tile.wire3(fileIO.ReadBoolean());
3578 }
3579 if (versionNumber >= 41)
3580 {
3581 tile.halfBrick(fileIO.ReadBoolean());
3582 if (!Main.tileSolid[tile.type] && !TileID.Sets.NonSolidSaveSlopes[tile.type])
3583 {
3584 tile.halfBrick(halfBrick: false);
3585 }
3586 if (versionNumber >= 49)
3587 {
3588 tile.slope(fileIO.ReadByte());
3589 if (!Main.tileSolid[tile.type] && !TileID.Sets.NonSolidSaveSlopes[tile.type])
3590 {
3591 tile.slope(0);
3592 }
3593 }
3594 }
3595 if (versionNumber >= 42)
3596 {
3597 tile.actuator(fileIO.ReadBoolean());
3598 tile.inActive(fileIO.ReadBoolean());
3599 }
3600 int num3 = 0;
3601 if (versionNumber >= 25)
3602 {
3603 num3 = fileIO.ReadInt16();
3604 }
3605 if (num2 != -1)
3606 {
3607 if ((double)j <= Main.worldSurface)
3608 {
3609 if ((double)(j + num3) <= Main.worldSurface)
3610 {
3611 WorldGen.tileCounts[num2] += (num3 + 1) * 5;
3612 }
3613 else
3614 {
3615 int num4 = (int)(Main.worldSurface - (double)j + 1.0);
3616 int num5 = num3 + 1 - num4;
3617 WorldGen.tileCounts[num2] += num4 * 5 + num5;
3618 }
3619 }
3620 else
3621 {
3622 WorldGen.tileCounts[num2] += num3 + 1;
3623 }
3624 }
3625 if (num3 > 0)
3626 {
3627 for (int k = j + 1; k < j + num3 + 1; k++)
3628 {
3629 Main.tile[i, k].CopyFrom(Main.tile[i, j]);
3630 }
3631 j += num3;
3632 }
3633 }
3634 }
3635 WorldGen.AddUpAlignmentCounts(clearCounts: true);
3636 if (versionNumber < 67)
3637 {
3638 WorldGen.FixSunflowers();
3639 }
3640 if (versionNumber < 72)
3641 {
3642 WorldGen.FixChands();
3643 }
3644 int num6 = 40;
3645 if (versionNumber < 58)
3646 {
3647 num6 = 20;
3648 }
3649 int num7 = 1000;
3650 for (int l = 0; l < num7; l++)
3651 {
3652 if (!fileIO.ReadBoolean())
3653 {
3654 continue;
3655 }
3656 Main.chest[l] = new Chest();
3657 Main.chest[l].x = fileIO.ReadInt32();
3658 Main.chest[l].y = fileIO.ReadInt32();
3659 if (versionNumber >= 85)
3660 {
3661 string text = fileIO.ReadString();
3662 if (text.Length > 20)
3663 {
3664 text = text.Substring(0, 20);
3665 }
3666 Main.chest[l].name = text;
3667 }
3668 for (int m = 0; m < 40; m++)
3669 {
3670 Main.chest[l].item[m] = new Item();
3671 if (m >= num6)
3672 {
3673 continue;
3674 }
3675 int num8 = 0;
3676 num8 = ((versionNumber < 59) ? fileIO.ReadByte() : fileIO.ReadInt16());
3677 if (num8 > 0)
3678 {
3679 if (versionNumber >= 38)
3680 {
3681 Main.chest[l].item[m].netDefaults(fileIO.ReadInt32());
3682 }
3683 else
3684 {
3685 short defaults = ItemID.FromLegacyName(fileIO.ReadString(), versionNumber);
3686 Main.chest[l].item[m].SetDefaults(defaults);
3687 }
3688 Main.chest[l].item[m].stack = num8;
3689 if (versionNumber >= 36)
3690 {
3691 Main.chest[l].item[m].Prefix(fileIO.ReadByte());
3692 }
3693 }
3694 }
3695 }
3696 for (int n = 0; n < 1000; n++)
3697 {
3698 if (fileIO.ReadBoolean())
3699 {
3700 string text2 = fileIO.ReadString();
3701 int num9 = fileIO.ReadInt32();
3702 int num10 = fileIO.ReadInt32();
3703 if (Main.tile[num9, num10].active() && (Main.tile[num9, num10].type == 55 || Main.tile[num9, num10].type == 85))
3704 {
3705 Main.sign[n] = new Sign();
3706 Main.sign[n].x = num9;
3707 Main.sign[n].y = num10;
3708 Main.sign[n].text = text2;
3709 }
3710 }
3711 }
3712 bool flag = fileIO.ReadBoolean();
3713 int num11 = 0;
3714 while (flag)
3715 {
3716 if (versionNumber >= 190)
3717 {
3718 Main.npc[num11].SetDefaults(fileIO.ReadInt32());
3719 }
3720 else
3721 {
3722 Main.npc[num11].SetDefaults(NPCID.FromLegacyName(fileIO.ReadString()));
3723 }
3724 if (versionNumber >= 83)
3725 {
3726 Main.npc[num11].GivenName = fileIO.ReadString();
3727 }
3728 Main.npc[num11].position.X = fileIO.ReadSingle();
3729 Main.npc[num11].position.Y = fileIO.ReadSingle();
3730 Main.npc[num11].homeless = fileIO.ReadBoolean();
3731 Main.npc[num11].homeTileX = fileIO.ReadInt32();
3732 Main.npc[num11].homeTileY = fileIO.ReadInt32();
3733 flag = fileIO.ReadBoolean();
3734 num11++;
3735 }
3736 if (versionNumber >= 31 && versionNumber <= 83)
3737 {
3738 NPC.setNPCName(fileIO.ReadString(), 17, resetExtras: true);
3739 NPC.setNPCName(fileIO.ReadString(), 18, resetExtras: true);
3740 NPC.setNPCName(fileIO.ReadString(), 19, resetExtras: true);
3741 NPC.setNPCName(fileIO.ReadString(), 20, resetExtras: true);
3742 NPC.setNPCName(fileIO.ReadString(), 22, resetExtras: true);
3743 NPC.setNPCName(fileIO.ReadString(), 54, resetExtras: true);
3744 NPC.setNPCName(fileIO.ReadString(), 38, resetExtras: true);
3745 NPC.setNPCName(fileIO.ReadString(), 107, resetExtras: true);
3746 NPC.setNPCName(fileIO.ReadString(), 108, resetExtras: true);
3747 if (versionNumber >= 35)
3748 {
3749 NPC.setNPCName(fileIO.ReadString(), 124, resetExtras: true);
3750 if (versionNumber >= 65)
3751 {
3752 NPC.setNPCName(fileIO.ReadString(), 160, resetExtras: true);
3753 NPC.setNPCName(fileIO.ReadString(), 178, resetExtras: true);
3754 NPC.setNPCName(fileIO.ReadString(), 207, resetExtras: true);
3755 NPC.setNPCName(fileIO.ReadString(), 208, resetExtras: true);
3756 NPC.setNPCName(fileIO.ReadString(), 209, resetExtras: true);
3757 NPC.setNPCName(fileIO.ReadString(), 227, resetExtras: true);
3758 NPC.setNPCName(fileIO.ReadString(), 228, resetExtras: true);
3759 NPC.setNPCName(fileIO.ReadString(), 229, resetExtras: true);
3760 if (versionNumber >= 79)
3761 {
3762 NPC.setNPCName(fileIO.ReadString(), 353, resetExtras: true);
3763 }
3764 }
3765 }
3766 }
3767 if (Main.invasionType > 0 && Main.invasionSize > 0)
3768 {
3769 Main.FakeLoadInvasionStart();
3770 }
3771 if (versionNumber >= 7)
3772 {
3773 bool num12 = fileIO.ReadBoolean();
3774 string text3 = fileIO.ReadString();
3775 int num13 = fileIO.ReadInt32();
3776 if (num12 && (text3 == Main.worldName || num13 == Main.worldID))
3777 {
3778 return 0;
3779 }
3780 return 2;
3781 }
3782 return 0;
3783 }
static short FromLegacyName(string name, int release)
Definition ItemID.cs:12856
static int FromLegacyName(string name)
Definition NPCID.cs:11748
static bool[] NonSolidSaveSlopes
Definition TileID.cs:109
static readonly ushort Count
Definition WallID.cs:753
static bool _tempRaining
Definition WorldFile.cs:101
static bool _tempDayTime
Definition WorldFile.cs:107
static int _tempRainTime
Definition WorldFile.cs:105
static float _tempMaxRain
Definition WorldFile.cs:103
static bool _tempBloodMoon
Definition WorldFile.cs:109
static int _versionNumber
Definition WorldFile.cs:117
static bool _tempEclipse
Definition WorldFile.cs:111
static int _tempMoonPhase
Definition WorldFile.cs:113
static double _tempTime
Definition WorldFile.cs:99

References Terraria.IO.WorldFile._tempBloodMoon, Terraria.IO.WorldFile._tempDayTime, Terraria.IO.WorldFile._tempEclipse, Terraria.IO.WorldFile._tempMaxRain, Terraria.IO.WorldFile._tempMoonPhase, Terraria.IO.WorldFile._tempRaining, Terraria.IO.WorldFile._tempRainTime, Terraria.IO.WorldFile._tempTime, Terraria.IO.WorldFile._versionNumber, Terraria.Tile.active(), Terraria.Tile.actuator(), Terraria.WorldGen.AddUpAlignmentCounts(), Terraria.WorldGen.altarCount, Terraria.Main.caveBackStyle, Terraria.Main.caveBackX, Terraria.Main.chest, Terraria.WorldGen.clearWorld(), Terraria.Main.cloudBGActive, Terraria.Tile.color(), Terraria.ID.WallID.Count, Terraria.Main.FakeLoadInvasionStart(), Terraria.WorldGen.FixChands(), Terraria.WorldGen.FixSunflowers(), Terraria.IO.FileMetadata.FromCurrentSettings(), Terraria.ID.NPCID.FromLegacyName(), Terraria.ID.ItemID.FromLegacyName(), Terraria.Lang.gen, Terraria.WorldGen.genRand, Terraria.Tile.halfBrick(), Terraria.Tile.honey(), Terraria.Tile.inActive(), Terraria.Main.invasionSize, Terraria.Main.invasionType, Terraria.Tile.lava(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.ID.TileID.Sets.NonSolidSaveSlopes, Terraria.Main.npc, Terraria.WorldGen.RandomizeCaveBackgrounds(), Terraria.WorldGen.RandomizeMoonState(), Terraria.WorldGen.RandomizeWeather(), Terraria.WorldGen.setBG(), Terraria.NPC.setNPCName(), Terraria.Main.sign, Terraria.Tile.slope(), System.text, Terraria.Main.tile, Terraria.WorldGen.tileCounts, Terraria.Main.tileFrameImportant, Terraria.Main.tileSolid, Terraria.Main.treeStyle, Terraria.Main.treeX, Terraria.Tile.type, Terraria.Tile.wall, Terraria.Tile.wallColor(), Terraria.Main.windSpeedTarget, Terraria.Tile.wire(), Terraria.Tile.wire2(), Terraria.Tile.wire3(), Terraria.Main.worldID, Terraria.Main.worldName, and Terraria.Main.worldSurface.

Referenced by Terraria.IO.WorldFile.LoadWorld().