Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Vapourware Codexian Game Development Thread

Nathaniel3W

Rockwell Studios
Patron
Developer
Joined
Feb 5, 2015
Messages
1,305
Location
Washington, DC
Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming!
Still holding to your assertion that you're not trying to be a dick?

No wonder games are so huge now-days.

In my day we used bits inside of bytes (or words, or double words or bigger) to depict thing in memory.

JSON must be some dumb neckbeard shit, never heard of it...I take a wild guess and say the J is for java?

You dun fucked up son.

Zep--

Again...JAVA...

You dun fucked up, son.

Zep--

What?

You need HELP saving savegame data? Maybe programming is not for you...just sayin'.

Zep--

Arrays. (of gosh...BYTES)

Zep--

I don't think he knows how to use arrays or multidimensional arrays.

Zep--

Typical self-learned 'JAVA' programmer.

Zep--

You: My savegame "Solution" I copped off the internet is crashing my viewer which I also copped off the internet since I'm too lazy and/or dense/inexperienced to write my own.
Me: LOL JAVA. gg nub.

Is more like it.

Zep--

And by the way, my savegame solution is working fine now. I don't know why anyone would go back and remake a perfectly functional system from scratch when there are still issues in the backlog.
 

Zep Zepo

Titties and Beer
Dumbfuck Repressed Homosexual
Joined
Mar 23, 2013
Messages
5,233
That's "Tough Love" which you keep mistakenly take as "being a dick"

Zep--
 

zwanzig_zwoelf

Graverobber Foundation
Developer
Joined
Nov 21, 2015
Messages
3,178
Location
デゼニランド
Writing a savegame system on your own may appear daunting/scary at first, but once you've figured out what you really need to save and load, you can offload a lot of things onto the game itself. Besides, it's usually a few hours of work with all these fancy tools we've got today and you can always figure out a way or two to improve it.
 

Severian Silk

Guest
And maybe there is a better way to save the game than using JSON. I haven't ruled that out. But I can say that there is no other way to save the game that is already working so any other option already has that count against it.
You could go back in time a decade and use XML instead.
 

vdweller

Arcane
Developer
Joined
Feb 5, 2016
Messages
625
My games' saves are plain ol' text files. You know, write a number or a string, change line, write something else... I just recently started adding some data structure-to-string ancoding that Game Maker: Studio has, but then again I had to do some minimal string compression because the resulting strings had a fuckton of zeroes.

My save files usually are in the range of 1-100Kb so I never actually bothered with another format... :M
 

baturinsky

Arcane
Joined
Apr 21, 2013
Messages
5,623
Location
Russia
Text is way easier to debug and save-edit. Binary is better in pretty much everything else.

I use Protobuf-based saving in my current Unity project.

Also, you may want to zip your save files to reduce their size a lot, especially if you save as XML or you can do compression in separate thread.
 

vdweller

Arcane
Developer
Joined
Feb 5, 2016
Messages
625
To all thread readers/developers:

What is the craziest code hack/workaround you have ever done to get something running or running more efficiently?
 

Zep Zepo

Titties and Beer
Dumbfuck Repressed Homosexual
Joined
Mar 23, 2013
Messages
5,233
To all thread readers/developers:

What is the craziest code hack/workaround you have ever done to get something running or running more efficiently?

Self-modifying code due to the memory limitation on a Vic-20. (In ASM/Machine Language, of course)

Zep--
 

baturinsky

Arcane
Joined
Apr 21, 2013
Messages
5,623
Location
Russia
About saving (and a bit about what) and a bit about what vdveller said.

I have two parts in save data: a header that has object's ids and instantiation data (such as prefab name, etc), and a body that is more or less "usually" structured.

When I load, I read header and create all the objects with the right types, from the right prototypes, sometimes find pre-existing permanent objects instead of creating them. And I make a dictionary id->object.

Then I read the save's body, loading data into those objects. And if there is some reference form inside one object to another (serialised as Id, of cause), I have a dictionary to resolve it immediately.

Hacky part is that I use simply object's order to find which header matches wchich body. I.e. I just give the next "blank" object in queue when Protobuf hook requests next object.

static public Hull fabricate()
{
return Persistence.getNextInstance() as Hull;
}

[ProtoBuf.ProtoBeforeSerialization]
public void saveHeader()
{
Persistence.addHeader(guid, "Equipment/Hulls/" + name);
}

It works as long as "ProtoBeforeSerialization" is called exactly in same order and same times as SetFactory-set factory (i.e. "fabricate"). It causes some problems, for example if fabricate is not called because object in question was already created as part of parent object's constructon. But nothing unresolvable so far.
 

The Avatar

Pseudodragon Studios
Developer
Joined
Jan 15, 2016
Messages
336
Location
The United States of America
I use ScriptableObjects to JSON in my Unity game to save. All of my data for NPCs, global flags, game state, etc goes in ScriptableObjects. This has the advantage of being able to use (custom) inspectors in Unity to author them at design time, and it's dead simple to serialize them to JSON. Fully supports polymorphic types and references to assets on the file system(like portrait textures for NPCs). Asset references are otherwise difficult to do because of the way Unity handles asset management. You can't just have a path unless you put everything in Resources.
 

The Avatar

Pseudodragon Studios
Developer
Joined
Jan 15, 2016
Messages
336
Location
The United States of America
Technically, yes that would work for simple things- but for models and such you really want it to go through the import process so it can be converted to Unity's internal format and put in the asset database. I could be wrong, but I don't believe that stuff(importing fbx, etc) can be done at runtime without some external tools to do so.
 

zwanzig_zwoelf

Graverobber Foundation
Developer
Joined
Nov 21, 2015
Messages
3,178
Location
デゼニランド
That would be a pain in the ass indeed, but you can use asset bundles if you want to keep some data separately (and save some space using LZMA/LZ4 compression).
 

Zep Zepo

Titties and Beer
Dumbfuck Repressed Homosexual
Joined
Mar 23, 2013
Messages
5,233
The problem is this guy is using a save system he doesn't understand and tools that crash when he tries to view his saved shit.

God, don't even start recommending he has to learn how to compress things. Oi Vey!

Zep--
 

Nathaniel3W

Rockwell Studios
Patron
Developer
Joined
Feb 5, 2015
Messages
1,305
Location
Washington, DC
Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming!
Look man, I understand the system just fine. The problem with parsing the JSON was unrelated. When I say I didn't write the system, I mean I didn't code the file I/O. I control everything that goes into the file, down to the last character.
 

Zep Zepo

Titties and Beer
Dumbfuck Repressed Homosexual
Joined
Mar 23, 2013
Messages
5,233
I looked at your screenshot again. It's text, granted it's heavily formatted text, but in the end its text.

Text editors have been able to open large "text" files going on almost 20 years now.

There is nothing special about text.

Formatting it is another matter (so your tools can parse it).

Whatever that format is your using? (A neckbeard version of XML?). You'd be better off using XML then as it's been around a while.

So, what to do? Make a copy (ofc). Find that spot where your data crashes your tool, delete everything under that. Try to load again, still crashing? Delete another page. Rinse and repeat until the tool doesn't crash. Try to narrow down to the offending line(s).

I had to do something similar for a client not too long ago, the XML would parse, but the data was not coming in correctly. The XML was gigantic, probably 80MB or so. Turns out some shmo, who was doing some editing, used some UTF(something or other) characters not compatible with the application. Goofy characters...like a "U" with 2 dots over it and shit like that.

The most stupidest thing can cause the biggest headache...

Zep--
 

baturinsky

Arcane
Joined
Apr 21, 2013
Messages
5,623
Location
Russia
JSON by itself is not that bad, and has an advantage over binary format in it's human-accessibility.

Though, Unity's own JSON serialiser is shit, because it is dumb. Even browser's javascript allows way more configurability for json serialisation by hooks and such.
 

Nathaniel3W

Rockwell Studios
Patron
Developer
Joined
Feb 5, 2015
Messages
1,305
Location
Washington, DC
Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming!
He knows what JSON is. But any format invented after 1980 is just some new neckbeard thing.

Thanks for the advice Zep. I fixed the savegame weeks ago, and I ended up doing something similar. I wrote a regex that replaced anything that was an illegal character. I would feed the document into the JSON parser, it would fail and tell me which illegal character it came across, which I would add to the regex, and repeat. By the end I was able to read a perfectly legible and tab-indented JSON file and figure out where my stuff was getting saved and therefore what part of my code was saving something twice.

The issue with not being able to read the JSON was threefold: 1, Epic Games' savegame system doesn't write actual legal JSON, as evidenced by the illegal characters; 2, because I couldn't read the JSON on my own computer (because of the illegal characters) I found something online that didn't care whether the JSON was legal, but would just tab-indent everything anyway; and 3, I recently moved to Egypt where the internet sucks and when I started saving more data, inspecting 4 MB of text over the internet became cumbersome. Yes, this would have all been avoided if I had written the savegame system from scratch and therefore knew which certain illegal characters would violate JSON, and I would look out for that. It also would have been avoided if I had tried finding out why the JSON was illegal to begin with instead of using a crutch tab-indenter online, or had written my own.

Of course, lots of problems could be avoided if I just wrote my own game engine myself, and while I'm at it maybe I should write my own operating system myself, to run on the hardware I designed myself. But if I want to finish a game of this size (have you seen my game?) within my own lifetime, I'm going to have to rely a lot on code that other people wrote.
 

Zep Zepo

Titties and Beer
Dumbfuck Repressed Homosexual
Joined
Mar 23, 2013
Messages
5,233
I have no idea what JSON is. Never saw it, never used it. Only thing I learned in this thread is it's stand for Java Script something something.

And isn't all this neckbeard shit free? Why would you use something online instead of downloading something?

So tell us, how did your borrowed savegame system insert/change characters into your whatever that format is called you use? What exactly happened?

Zep--
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom