Hello,
normally I searching on Google before asking question somewhere, hovever in this case I haven't any idea what to do or search. My problem is following:
I am developing minecraft for the blinds as I noticed few times before. For begin, I selected surface of size 200*200*200 blocks, what gives 8000000 blocks. That is okay, game is relative fast, working without lags etc. Problem shows when loading map. for first versions of project, I choosed simple notation like this:
me.x;me.y;me.z;block.x;block.y;block.z;block.id;block.x;bnlock.y;block.z;block.id etc.
Yeah, it can be reduced by using for example ascii characters to reduce size, but that is not important now, problem is in time which program needs to load map.
For first, I choosed method of loading all blocks to the string, and split them with string_split. Hovever this wasn't so effective, result array has 8000000 instead of 16000000 places. I don't know why, but as I am thinking about it, is possible that there were some programming mistakes, but that isn't important, after it I choosed my own method to read string with map character by character, find separators and enter values to the three dimensional array, which is used as a main world matrix.
Code was simple, like read_until function from file object, there was one pointer and something like:
string string_read_until(string input, int pointer) {
string result="";
while (input[pointer]!=";") {
result+=input[pointer];
pointer++;
}
}
This is not of course original code, it has seeable out of bounds bug when implementing, but original has prevention, this is only example how code looks. It works, only small mistake was there. Loading duration was about 50 minutes, loading space 200*200*10.
I didn't know what to do. After some time, I got an idea. I overwrited my function with read_until from file object, and whole system remaked to read directly from file. I was really surprised when after this change map loaded in time about 10-20 seconds.
And that is what I don't understand, why reading from my ssd hardrive (not tested on hdd) is faster than reading from memori? Ram should to be faster if I know right, so why this is happening? I am asking also because now I am working on server, and clients take again about 50 minutes to load sended map, that's really long,I need to make it faster but don't know how to do it, only solution seems to save received map to the file and use standard loading method, but this is not explayning problem itself, also more disk usage is needed.
Thank you for help, I want to record small introduction for our Slovak and Czech blind community, so we need multiplayer mode as soon as possible.
Greetings
Rastislav