I am trying to save player's objects but my loaded result is corrupt and placed in weird shapes like 3D arrows. Weirdly enough when terrain is saved, the terrain is fine but objects added later cause the problem. I am using OpenTK for OpenGL.
The file seems to contain some repeated parts? Here is a part of the (large) file I end up with:
(0; 0; 0),(0; 0; 0),(0; 0; 1),(0; 1; 0),(1; 0; 0),(0; 0; 2),(0; 2; 0),(2; 0; 0),(0; 0; 0)
Here is my loading code:
void MapLoad(string filelocation)
{
string[] map_;
string line = File.ReadAllText(filelocation);//
map_ = line.Split(new char[] { ',', ';', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
for (int xj = 0; xj < line.Split(',').Length; xj += 3)
{
// Here xj is an index of a X coordinate, xj + 1 is an index of a Y coordinate, xj + 2 is an index of a Z coordinate
//copied pasted for suring answer will work
block_file.Add(new Vector3(Int32.Parse(map_[xj]), Int32.Parse(map_[xj + 1]), Int32.Parse(map_[xj + 2])));
}
}
The Vector3 is from OpenTK.
Here is my writing code:
if(key.KeyCode == Keys.F7)
{
File.WriteAllText("usermap.txt", String.Join(",",block_file));//new char[] { ',', ';', '(', ')'
}

