Hello!
For context, I am working on a building game that allows players to build as massive or as detailed as they like (without breaking ToS, lagging the server, etc.). and I am working on the saving system currently for said game.
I have developed a really nice string compression format to store in the datastores, but I would like feedback on how I can improve the format (both from an efficiency perspective when translating to actual objects/into the format and also how to further save space).
I think the best way to show the format is to give an example and walk through the translation process:
Pu*7*1255255255200+0.75+4+4+4+0110*6*2*5*|
Now, obviously, this is unreadable, so I am going to break it down further.
The format works primarily on positions. The translator expects certain values to be at certain positions with certain lengths. If, for whatever reason, a value is nil, a preset default value, or doesn’t use the full allotted character length, it will append a “+” character to that field. I call this the termination character. It essentially lets the translator know when to move on to another value if the field ends earlier than expected.
To further save space, if more than 3 consecutive termination characters are found (like “+++”), the translator will count them up and replace them with *[count of term symbols]* (like *5*) and upon getting past 9 termination symbols, it will loop into alphabetical characters (i.e. *B* indicates 10 termination symbols).
To indicate the end of an object in this format, I use the “|” character.
Now, to roughly show the expected fields:
[Object Type],[Object Subtype],[Position Relative to Plot],[Orientation],[CastShadow],[Color],[Material Number],[Reflectance],[Transparency],[Size],[CanCollide],[CanQuery],[CanTouch],[CollisionGroupId],[CustomPhysicalProperties],[Shape],[Ore Attributes ID],[PartCount],[Unique Data].
Now, I can use the example from earlier to describe what the above means:
Pu*7*1255255255200+0.75+4+4+4+0110*6*2*5*|
P = Object Type of "Pinkprint"
u = Object subtype of "unfinished"
Skip 7 fields...
CastShadow = true (1)
Color = RGB(255,255,255)
Material = "SmoothPlastic" (material #20)
Reflectance = 0
Transparency = 0.75
Size = {4,4,4}
CanCollide = false (0)
CanQuery = true (1)
CanTouch = true (1)
CollisionGroupId = 0
Skip 6 fields...
Shape = "Box" (Shape # 2)
Skip 5 fields...
End of object |
I hope that is easy to digest. But yes, most of these fields will never realistically be used, HOWEVER, I want to allow the most creative individuals to be able to utilize these in wacky ways I would have never thought of.
Now, to reiterate my two questions:
1.) How can I compress the string format even further to decrease space?
2.) How can I speed up the translation process between converting from say, an Instance to the string and vice versa.
Bonus Question
Realistically, say I have 10 players in a server, what would be the uppermost part count I can allocate to each player to build with, WITHOUT causing excessive lag? I was thinking 10k per player (100k total player-built parts if 10 people all have massive builds), but I am unsure if that will be far too laggy.
Realistically, I understand most players will never, ever, ever reach anywhere near 10k parts in their builds, but I really want to cater to those builders who go above and beyond.
Thanks in advance!