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

◆ LoadChests()

static void Terraria.IO.WorldFile.LoadChests ( BinaryReader reader)
inlinestatic

Definition at line 2572 of file WorldFile.cs.

2573 {
2574 int num = reader.ReadInt16();
2575 int num2 = reader.ReadInt16();
2576 int num3;
2577 int num4;
2578 if (num2 < 40)
2579 {
2580 num3 = num2;
2581 num4 = 0;
2582 }
2583 else
2584 {
2585 num3 = 40;
2586 num4 = num2 - 40;
2587 }
2588 int i;
2589 for (i = 0; i < num; i++)
2590 {
2591 Chest chest = new Chest();
2592 chest.x = reader.ReadInt32();
2593 chest.y = reader.ReadInt32();
2594 chest.name = reader.ReadString();
2595 for (int j = 0; j < num3; j++)
2596 {
2597 short num5 = reader.ReadInt16();
2598 Item item = new Item();
2599 if (num5 > 0)
2600 {
2601 item.netDefaults(reader.ReadInt32());
2602 item.stack = num5;
2603 item.Prefix(reader.ReadByte());
2604 }
2605 else if (num5 < 0)
2606 {
2607 item.netDefaults(reader.ReadInt32());
2608 item.Prefix(reader.ReadByte());
2609 item.stack = 1;
2610 }
2611 chest.item[j] = item;
2612 }
2613 for (int k = 0; k < num4; k++)
2614 {
2615 short num5 = reader.ReadInt16();
2616 if (num5 > 0)
2617 {
2618 reader.ReadInt32();
2619 reader.ReadByte();
2620 }
2621 }
2622 Main.chest[i] = chest;
2623 }
2625 for (int l = 0; l < i; l++)
2626 {
2627 if (Main.chest[l] != null)
2628 {
2629 Point16 item2 = new Point16(Main.chest[l].x, Main.chest[l].y);
2630 if (list.Contains(item2))
2631 {
2632 Main.chest[l] = null;
2633 }
2634 else
2635 {
2636 list.Add(item2);
2637 }
2638 }
2639 }
2640 for (; i < 8000; i++)
2641 {
2642 Main.chest[i] = null;
2643 }
2644 if (_versionNumber < 115)
2645 {
2647 }
2648 }
virtual byte ReadByte()
virtual string ReadString()
virtual int ReadInt32()
virtual short ReadInt16()
static void FixDresserChests()
static int _versionNumber
Definition WorldFile.cs:117

References Terraria.IO.WorldFile._versionNumber, Terraria.Main.chest, Terraria.IO.WorldFile.FixDresserChests(), System.item, Terraria.Chest.item, System.list, System.IO.BinaryReader.ReadByte(), System.IO.BinaryReader.ReadInt16(), System.IO.BinaryReader.ReadInt32(), and System.IO.BinaryReader.ReadString().

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