Zylann / voxelgame

Voxel world prototype made with Godot Engine
Other
513 stars 84 forks source link

How to save and load multiplayer guide. #100

Closed WithinAmnesia closed 4 months ago

WithinAmnesia commented 4 months ago

Blockygame is saving to disc. How do we get working saving and loading of this in multiplayer? https://github.com/Zylann/voxelgame/blob/2147d8152ac860c616b764786f736e0cd7a4d844/project/blocky_game/blocky_game.tscn#L28

Is there a branch or way to do this to load up previous worlds instead of a fresh reset to each seed every time? How do we get persistent dynamic worlds properly loading and saving in multiplayer? How do we get the game menus to do this or is there guide on how to do the minecraft style of like main esc key game menu with options like save (in single player) and or exit (save before exit / server saves automatics periodically / with change checks like minecraft multiplayer servers) and working load and join world menus options etc? It looks like there is save chunk data how do we load this in multiplayer to get a present world like minecraft multiplayer server dynamic open-worlds?

What is needed to get multiplayer save and load game data working? As from: https://github.com/Zylann/voxelgame/issues/85#issuecomment-1955145256 Is there a guide for this or demonstration or does one need to be made for this essential functionality? It feel like its so close but I am not sure what to properly do? What should be done? What are your thoughts and suggestions on how to get multiplayer save and load data to work? All feedback is welcome.

Zylann commented 4 months ago

Blockygame is saving to disc. How do we get working saving and loading of this in multiplayer?

The server saves to disk where the directory is specified. If the server is closed and restarted it will load the map from there. Clients just connect, the server sends them voxel chunks based on player positions, so clients can see the same map as a result. That's how this demo works.

Is there a branch or way to do this to load up previous worlds instead of a fresh reset to each seed every time?

It's not resetting everytime to my knowledge, or maybe it's a bug that I'm unaware of.

How do we get the game menus to do this or is there guide on how to do the minecraft style of like main esc key game menu with options like save (in single player) and or exit (save before exit / server saves automatics periodically / with change checks like minecraft multiplayer servers) and working load and join world menus options etc?

Man that's a huge sentence but it's already working like that, sort of. When you move around in the game, chunks that get unloaded get saved if they were modified. Exit through the menu also saves modified chunks https://github.com/Zylann/voxelgame/blob/2147d8152ac860c616b764786f736e0cd7a4d844/project/blocky_game/blocky_game.gd#L179

how do we load this in multiplayer rot get a present world like minecraft multiplayer server dynamic open-worlds?

Same question

What is needed to get multiplayer save and load game data working?

Same question again

Is there a guide for this or demonstration or does one need to be made for this essential functionality?

The demo is based on these notes I already linked in another of your issues: https://voxel-tools.readthedocs.io/en/latest/multiplayer/

t feel like its so close but I am not sure what to properly do? What should be done?

I don't know, the demo should just be saving automatically already. Same question, if it somehow doesn't load the same world after server restart or when re-joining as a client then it might be a bug.

What are your thoughts and suggestions on how to get multiplayer save and load data to work?

Same question again

WithinAmnesia commented 4 months ago

"The server saves to disk where the directory is specified." Where is this? How can this be found and what is the default?

"If the server is closed and restarted it will load the map from there." Is a force stop not working as intended? How should this be done to properly work closing and restarting the server?

"Clients just connect, the server sends them voxel chunks based on player positions, so clients can see the same map as a result. That's how this demo works." Where are the voxel chunk data stored usually? What does the data storage look like typically? I heard things about people saying binary serializer but I'm not sure how all this works 100% right now for I am just learning the core of this right now.

"It's not resetting everytime to my knowledge, or maybe it's a bug that I'm unaware of." I have only experience reset worlds every time in single player and multiplayer. I have no clue how the menu works when playing in the game or what buttons to press. WASD for move E for inventory scroll wheel to select the block hotbars right and left click place and destroy blocks / shoot the gun and Esc = a weird camera feature and I just force close the instances and or press the client editor stop. I am not sure how the keybinds work I am just guessing I wish I knew what the keybinds were and how to properly operate the menu but its is a blind stumbling around lost kind of experience with always reset worlds. What should one know to do this properly?

"Man that's a huge sentence but it's already working like that, sort of. When you move around in the game, chunks that get unloaded get saved if they were modified. Exit through the menu also saves modified chunks." I am stuck and I am sorry for my repeating thoughts that what it feels like in my mind trying to find these puzzles solutions.

"Exit through the menu also saves modified chunks." How does one do this? How can world be selected or is it just 1 world? Every time it resets is my experience. It has felt just like the 20 other lesser minecraft-like github godot projects that cannot save and I am wondering over and over how to save the worlds in multiplayer its really important lol. How do we save the worlds with the in game menus?

"The demo is based on these notes I already linked in another of your issues: https://voxel-tools.readthedocs.io/en/latest/multiplayer/" This is a general overview I am stuck with the save and load features for I am blind and stumbling around a bit lost. I am not sure what steps to take to save and load the game worlds. My experience has been always reset game world in multiplayer and single player. I am not aware of bugs for this is all new to myself.

"I don't know, the demo should just be saving automatically already. Same question, if it somehow doesn't load the same world after server restart or when re-joining as a client then it might be a bug." How does the server work? I just start 4 instances in the Godot 4.2.1(2).NET Voxel module editor and click multiplayer instance 1 and then on instance 1 clicks host server, then spawns into the game world and falls to the game world. Instance 2,3,4 are subsequently the same chain of actions of connect to server and spawn in and fall to the world and they can all see each other and interact with the world and the server can handle multiplayer clients / instances / players and that works.

It is just I cannot figure out how to use the menus. So I just close with windows key press use my desktop mouse to go to the stop running project button click is and that closes all 4 instances at once and I then restart all for instances again and it is always reset. Maybe it is due to not knowing how to access the in game menu and not saving from menu? Are force project stops bad? Why can't the server start again and be the same after this? What is causing the resets / lack of saving of its is supposed to be saving? I am new to all of this so I do not know what should be happening.

What should be done? How do the menus work? All feedback is welcome.

Zylann commented 4 months ago

"The server saves to disk where the directory is specified." Where is this? How can this be found and what is the default?

You found already in game.tscn where it is specified. Looking around, you might see it's a property of a resource. If you open the editor, open the scene and select the terrain node, it has a stream property (in this engine streams are how saving and loading is configured) which has a resource assigned, and that resource has the directory property.

Is a force stop not working as intended?

Force stop (as in the Stop button of the editor or Ending Task from your task manager) will kill the game, and therefore will have no chance to save anything. Worse, if saving was already underway, it could abruptly stop and leave the save in a corrupted state.

Where are the voxel chunk data stored usually?

The server loads chunks from files and keeps them in memory around player areas.

What does the data storage look like typically?

If I remember correctly the demo uses VoxelStreamRegionFiles, which is a directory under which there are multiple files organized in regions similarly to how Minecraft does it. Voxel data is saved into them, as a compressed binary format documented here.

I have only experience reset worlds every time in single player and multiplayer.

If you have only closed the game using the Stop button of the Godot Editor, it's likely nothing was saved due to the game getting killed as I described earlier. But if you close the game normally using the game's menu (if present) or the window's exit button, it should save. If it still doesnt save when exiting normally, that might be a problem. Check console for eventual errors. Try in singleplayer first because it is simpler to test saving.

I have no clue how the menu works when playing in the game or what buttons to press.

There is no save button because it is supposed to do this automatically when you move around or quit normally.

I am not sure how the keybinds work

There is no keybind in this demo as far as I remember.

"Exit through the menu also saves modified chunks." How does one do this?

I might be misremembering because I havent launched that demo in a while but if there is no exit button in the menu, closing the window should work too.

How can world be selected or is it just 1 world?

It's only one world.

How does the server work?

Last time I tested I used a console to launch the scene twice. In the first instance I select "Host Server", in the second instance I select "Connect to server". I havent tested this with Godot's multi-instance debugging, but AFAIK it should work the same.

WithinAmnesia commented 4 months ago

Quick update: blockygame.gd ~line 167 " if event.keycode == KEY_M:

Force save

            _save_world()"

I looked at the code looking for keybinds and through to try M for map save and I did the same as before with 4 instance s hot a big hole in the mountain side with the rocket launcher gun and pressed M a bunch and windows force closed and the restarted 4 instances again and I got the save to world save to work :-D!

WithinAmnesia commented 4 months ago

"You found already in game.tscn where it is specified. Looking around, you might see it's a property of a resource. If you open the editor, open the scene and select the terrain node, it has a stream property (in this engine streams are how saving and loading is configured) which has a resource assigned, and that resource has the directory property."

Blocky_game.tscn -> VoxelTerrain -> VoxelStreamRegionFiles -> Directory res://blocky_game/save Yes?

"Force stop (as in the Stop button of the editor or Ending Task from your task manager) will kill the game, and therefore will have no chance to save anything. Worse, if saving was already underway, it could abruptly stop and leave the save in a corrupted state." Uh oh lol that sounds bad. We gotta figure out a better way then lol. Its a good thing I make lots of back ups and iterations hmmm lol.

"The server loads chunks from files and keeps them in memory around player areas." So maybe in this case with blockygame too it is kinda like "res://blocky_game/save" or is there more going on because I am really new to this so I'm trying to figure out how its all working together. Its not simple and very well put together for sure. There is a lot to learn.

"If I remember correctly the demo uses VoxelStreamRegionFiles, which is a directory under which there are multiple files organized in regions similarly to how Minecraft does it. Voxel data is saved into them, as a compressed binary format documented here." Oh excellent! Right on this is really insightful. So there is a binary system ... ehhh ~binary serializer already at work??? I think right like data is sent back and from from client server with a binary serializer / compressor / decompressor thing to make the big data into small data to save on bandwidth / save performance / not clog up the server with multiplayer and the client sends big data into binary as small data 0s and 1s and the server gates the small data 'packets?' (I don't know the proper name?) and it uses the binary serializer / compressor / decompressor thing to like make the binary 0s and 1s into big data to process with the system systems and this goes back and forth like compressing a big piece of data into a small compressed data like packet / luggage bag / case and then sent through a small server / client communication bandwidth connection and the client gets the small compressed data packet / luggage case and unpacks it for the client to use and it goes in reverse to send data back and forth? I think that is what that mean / how it works? So we already have a binary serializer / compressor / decompressor server / client communication data packet system thing working already? I think? Is that right? Its already optimized or? I think so lol?

"If you have only closed the game using the Stop button of the Godot Editor, it's likely nothing was saved due to the game getting killed as I described earlier. But if you close the game normally using the game's menu (if present) or the window's exit button, it should save. If it still doesn't save when exiting normally, that might be a problem. Check console for eventual errors. Try in singleplayer first because it is simpler to test saving." Oh mate the exit button on the window refuses adamantly positively will not close the instance windows. I tried clicking as hard as I could lol. It cold closes with a big stop button in the editor and also task manger kill task or like close Godot editor entirely.

"Check console for eventual errors." I will do so more thoroughly too lol.

"Try in singleplayer first because it is simpler to test saving." The force save custom keybind to "M" in multiplayer with 4 instances / clients / players worked yaa. I'll try single player too but multiplayer mate it works yaa I am very happy with that lol.

"There is no save button because it is supposed to do this automatically when you move around or quit normally." Oh lol okay well I guess something happened lol. It doe snot save when moving around and I can't get the red X's to close in the window with the mouse I had to use drastic measures and the least drastic way was the Stop Running Project button in the editor that I know of that always ~'works' lol. What do we do here? That sounds really cool that it is supposed to save when moving and automatically and on close and I wish things work like that too for everyone.

"There is no keybind in this demo as far as I remember." Big sad face lol. I looked up like "key" in the github and found all the buttons and the force world save button option too and ya even like "menu" and "exit" and no like click buttons either lol. Big sad face for sure lol. Well its once little escape key menu away from like a big solution for the world save and load does work its just not with the game user interface is all. I played demos that had the menus but not the working feature and this is the opposite where it works but there is no menu for it lol. That's really good that it works mate good job too. This is the best voxel game on git hub for sure and i played or tried to play like all of them yaa lol.

mate I sooo happy the world saves in multiplayer you have no idea like how many things out there that just are full of big broken time mhmmmm. Over 500+ github godot project demos and like finally here is where everything works well. Its is like ethereal or a ephemeral or something where it materialize from thin air Excalibur from the lake or feeling to just have pulled sword in the stone lol. This me right now no joke mate: https://www.youtube.com/watch?v=4zIoElk3r2c + https://www.youtube.com/watch?v=K1MuvvS_xSw + https://www.youtube.com/watch?v=hyNu5i_6lKA but its probably more like https://www.youtube.com/watch?v=Yv4vPDqoOmQ but I maybe feel like that I look like https://www.youtube.com/watch?v=ZZ5LpwO-An4 or https://www.youtube.com/watch?v=ZTidn2dBYbY

Mate like thank you so much. I need a moment. Yesterday I was at this from 5 am to to 5 am today without hyperbole over a day working. I've been searching and searching like crazy for days on end and like finally something that works everywhere.

"I might be misremembering because I havent launched that demo in a while but if there is no exit button in the menu, closing the window should work too." Thats all good mate we got the world save button feature and it works the server can find a way to make it work for sure. I feel so relieved. I am make massive worlds.

"It's only one world." That's all I need. I got 1 big world to make by hand. 100 areas of 1,024 x 1,204 tiles with 16x16 pixel tiles in Godot 4.2.1.NET+.

"Last time I tested I used a console to launch the scene twice. In the first instance I select "Host Server", in the second instance I select "Connect to server". I havent tested this with Godot's multi-instance debugging, but AFAIK it should work the same." Mate it works reaaaaaaaaaaaalllly good. I've tried damn near a thousand github and more websites Godot 3 and Godot 4 project demos and projects and this is one is the chosen one mate like everything can be made now. I need to let this sink in.

I've been at this for 2 decade mate. RPGMaker 2003 to MV, Flare 480p made into 4K, Unity and Unreal metal humans Easy Survival RPG with 4K,8K,16K Metahumans with multiplayer.

https://www.youtube.com/watch?v=pJvduG0E628 and then https://www.youtube.com/watch?v=5L_fu-YUDU8 ad maybe some like: https://www.youtube.com/watch?v=_2ZcRGarC5U and https://www.youtube.com/watch?v=IS6n2Hx9Ykk

I have worked so long to get to where it is possible and reality to build big multiplayer games forever free. I am a very experienced RPG person. I have worked on retail World of Warcraft and and Baldur's Gate and I have other Blizzard games as art work and help and I worked on private servers for WoW and I am one of the most hardcore raiders in Vanilla World of Warcraft with Kronos. I've done everything in RPGs and I love Mount and Blade and Minecraft and every big RPG there is to be experience. Yet there is not much left for me to experience. I've beaten WoW I got best in slot with Naxxramas and there never been anything like that ever since. 40 person raiding the best of the best of the best in the world and setting records and being at very top top 5 even for the briefest of moments I was there and like its time to go even further beyond. Is in here is my soul: Who Will Rise To Make ~'Grand RPGs' Forever Free?: https://gist.github.com/WithinAmnesia/958d4c742d49331b5320abd11a3f7482