I've found an issue where sometimes a world will fail to load chests (maybe signs too) because there are too many on the map.
The strange thing is that the map will load in tshock and save and load again fine, however I've come across this issue with loading the world in Tedit and saving it again.
The world file will load in vanilla Terraria Server fine.
After some investigation I've narrowed the issue down to the loadWorld() function in WorldFile.cs where it gets to num = (num1 > 87 ? WorldFile.LoadWorld_Version2(binaryReader) : WorldFile.LoadWorld_Version1(binaryReader));
Within the LoadWorld_Version2() function, we find the LoadChests(); function which is where the crash occurs.
Through my investigation, I've found that a map with over 1000 chests seems to trigger the trash.
Like I said, strange thing is it saves and loads fine in TSAPI, but after being opened and saved again in TEdit it breaks. Might be somethign to do with the way the chests are resaved.
Inside the LoadChests() function there is a loop where it creates the chests and sets it's items and it will crash when it gets to chest 1001
On this line:
for (i = 0; i < num3; i++)
num3 (really descriptive) is the number of chests in the world that it tries to laod, but as soon as i > 1000 it crashes.
I dont have a lot of exp, but changing num3 to 1000 doesn't workd around this as the stream position becomes out of place because it skips a number of reads.
What I did find however, is that if I opened the world in Tedit again and delete however many chests I am over the 1000 chest limit, the world will load fine again.
This issue may be present with Signs as well, but I dont think ive ever had over 1000 signs in a world.