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

◆ ValidateWorld()

static bool Terraria.IO.WorldFile.ValidateWorld ( BinaryReader fileIO)
inlinestatic

Definition at line 2846 of file WorldFile.cs.

2847 {
2848 new Stopwatch().Start();
2849 try
2850 {
2851 Stream baseStream = fileIO.BaseStream;
2852 int num = fileIO.ReadInt32();
2853 if (num == 0 || num > 279)
2854 {
2855 return false;
2856 }
2857 baseStream.Position = 0L;
2859 {
2860 return false;
2861 }
2862 string text = fileIO.ReadString();
2863 if (num >= 179)
2864 {
2865 if (num == 179)
2866 {
2867 fileIO.ReadInt32();
2868 }
2869 else
2870 {
2871 fileIO.ReadString();
2872 }
2873 fileIO.ReadUInt64();
2874 }
2875 if (num >= 181)
2876 {
2877 fileIO.ReadBytes(16);
2878 }
2879 int num2 = fileIO.ReadInt32();
2880 fileIO.ReadInt32();
2881 fileIO.ReadInt32();
2882 fileIO.ReadInt32();
2883 fileIO.ReadInt32();
2884 int num3 = fileIO.ReadInt32();
2885 int num4 = fileIO.ReadInt32();
2886 baseStream.Position = positions[1];
2887 for (int i = 0; i < num4; i++)
2888 {
2889 float num5 = (float)i / (float)Main.maxTilesX;
2890 Main.statusText = Lang.gen[73].Value + " " + (int)(num5 * 100f + 1f) + "%";
2891 int num6;
2892 for (num6 = 0; num6 < num3; num6++)
2893 {
2894 byte b;
2895 byte b2 = (b = 0);
2896 byte b3 = fileIO.ReadByte();
2897 bool flag = false;
2898 if ((b3 & 1) == 1)
2899 {
2900 flag = true;
2901 b2 = fileIO.ReadByte();
2902 }
2903 bool flag2 = false;
2904 if (flag && (b2 & 1) == 1)
2905 {
2906 flag2 = true;
2907 b = fileIO.ReadByte();
2908 }
2909 if (flag2 && (b & 1) == 1)
2910 {
2911 fileIO.ReadByte();
2912 }
2913 if ((b3 & 2) == 2)
2914 {
2915 int num7;
2916 if ((b3 & 0x20) == 32)
2917 {
2918 byte b4 = fileIO.ReadByte();
2919 num7 = fileIO.ReadByte();
2920 num7 = (num7 << 8) | b4;
2921 }
2922 else
2923 {
2924 num7 = fileIO.ReadByte();
2925 }
2926 if (importance[num7])
2927 {
2928 fileIO.ReadInt16();
2929 fileIO.ReadInt16();
2930 }
2931 if ((b & 8) == 8)
2932 {
2933 fileIO.ReadByte();
2934 }
2935 }
2936 if ((b3 & 4) == 4)
2937 {
2938 fileIO.ReadByte();
2939 if ((b & 0x10) == 16)
2940 {
2941 fileIO.ReadByte();
2942 }
2943 }
2944 if ((b3 & 0x18) >> 3 != 0)
2945 {
2946 fileIO.ReadByte();
2947 }
2948 if ((b & 0x40) == 64)
2949 {
2950 fileIO.ReadByte();
2951 }
2952 num6 += (byte)((b3 & 0xC0) >> 6) switch
2953 {
2954 0 => 0,
2955 1 => fileIO.ReadByte(),
2956 _ => fileIO.ReadInt16(),
2957 };
2958 }
2959 }
2960 if (baseStream.Position != positions[2])
2961 {
2962 return false;
2963 }
2964 int num8 = fileIO.ReadInt16();
2965 int num9 = fileIO.ReadInt16();
2966 for (int j = 0; j < num8; j++)
2967 {
2968 fileIO.ReadInt32();
2969 fileIO.ReadInt32();
2970 fileIO.ReadString();
2971 for (int k = 0; k < num9; k++)
2972 {
2973 if (fileIO.ReadInt16() > 0)
2974 {
2975 fileIO.ReadInt32();
2976 fileIO.ReadByte();
2977 }
2978 }
2979 }
2980 if (baseStream.Position != positions[3])
2981 {
2982 return false;
2983 }
2984 int num10 = fileIO.ReadInt16();
2985 for (int l = 0; l < num10; l++)
2986 {
2987 fileIO.ReadString();
2988 fileIO.ReadInt32();
2989 fileIO.ReadInt32();
2990 }
2991 if (baseStream.Position != positions[4])
2992 {
2993 return false;
2994 }
2996 if (baseStream.Position != positions[5])
2997 {
2998 return false;
2999 }
3000 if (_versionNumber >= 116 && _versionNumber <= 121)
3001 {
3002 int num11 = fileIO.ReadInt32();
3003 for (int m = 0; m < num11; m++)
3004 {
3005 fileIO.ReadInt16();
3006 fileIO.ReadInt16();
3007 }
3008 if (baseStream.Position != positions[6])
3009 {
3010 return false;
3011 }
3012 }
3013 if (_versionNumber >= 122)
3014 {
3015 int num12 = fileIO.ReadInt32();
3016 for (int n = 0; n < num12; n++)
3017 {
3019 }
3020 }
3021 if (_versionNumber >= 170)
3022 {
3023 int num13 = fileIO.ReadInt32();
3024 for (int num14 = 0; num14 < num13; num14++)
3025 {
3026 fileIO.ReadInt64();
3027 }
3028 }
3029 if (_versionNumber >= 189)
3030 {
3031 int num15 = fileIO.ReadInt32();
3032 fileIO.ReadBytes(12 * num15);
3033 }
3034 if (_versionNumber >= 210)
3035 {
3036 Main.BestiaryTracker.ValidateWorld(fileIO, _versionNumber);
3037 }
3038 if (_versionNumber >= 220)
3039 {
3041 }
3042 bool num16 = fileIO.ReadBoolean();
3043 string text2 = fileIO.ReadString();
3044 int num17 = fileIO.ReadInt32();
3045 bool result = false;
3046 if (num16 && (text2 == text || num17 == num2))
3047 {
3048 result = true;
3049 }
3050 return result;
3051 }
3052 catch (Exception value)
3053 {
3054 using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", append: true))
3055 {
3056 streamWriter.WriteLine(DateTime.Now);
3057 streamWriter.WriteLine(value);
3058 streamWriter.WriteLine("");
3059 }
3060 return false;
3061 }
3062 }
static TileEntity Read(BinaryReader reader, bool networkSend=false)
Definition TileEntity.cs:86
static bool LoadFileFormatHeader(BinaryReader reader, out bool[] importance, out int[] positions)
static void ValidateLoadNPCs(BinaryReader fileIO)
static int _versionNumber
Definition WorldFile.cs:117
static DateTime Now
Definition DateTime.cs:103

References Terraria.IO.WorldFile._versionNumber, Terraria.Main.BestiaryTracker, Terraria.Lang.gen, Terraria.GameContent.Creative.CreativePowerManager.Instance, System.L, Terraria.IO.WorldFile.LoadFileFormatHeader(), Terraria.Main.maxTilesX, System.DateTime.Now, Terraria.DataStructures.TileEntity.Read(), System.Diagnostics.Stopwatch.Start(), System.text, Terraria.IO.WorldFile.ValidateLoadNPCs(), and System.value.

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