ts2 / ts2-data

Experimental repos for sharing json data files of ts2 sims
https://ts2.github.io/
GNU General Public License v2.0
6 stars 2 forks source link

mishmash in the json data #5

Open mdziczkowski opened 9 years ago

mdziczkowski commented 9 years ago

I would suggest to clean-up the json because the "track items" are mixed up too much and it makes unable to create propper structures for it

pedromorgan commented 9 years ago

@mcgiwer Can u explain what the mish mash is ?

npiganeau commented 9 years ago

@mcgiwer Can you give examples? The files are read all right by the ts2 software, so I don't really understand what you mean either.

pedromorgan commented 9 years ago

To update @npiganeau , @mcgiwer is making some of the data structures in go, and the serialise technique from to_json() is py is not really readable in some cases in golang...

pedromorgan commented 9 years ago

eg tuples and arrays in "pure json" would be structures, instead of baing "embedded together" in a single string etc

npiganeau commented 9 years ago

You mean for routesSetParams for example ?

Well that's for historical reasons, they were treated as strings because they were stored in one column of the sqlite database. I'll see what I can do to make them pure json, should not be too complicated.

pedromorgan commented 9 years ago

its probably in the to_json() function,, should be called get_data() or something like that

Please NOTE that I am in favour of mixedNaming,

npiganeau commented 9 years ago

I've made the modification + updated ts2-data. It was just that I called the Str property instead of the property itself in for_json()

pedromorgan commented 9 years ago

Re ts2-data..

Can we make the countires small case eg uk instead of Uk, germany ??

npiganeau commented 9 years ago

Folder names are read 'as is' inside the "open" dialog of ts2, so having them lower case would not be very pretty, unless you find a way to show another name inside the software such as a __folder__ file with the full pretty name of the country (maybe with different translations defined inside the file could be cool too)

mdziczkowski commented 9 years ago

example:

many "types" are mixed with each other in the TrackItems. Even if they have seperate ID's it isn't sorted and grouped by the item type

npiganeau commented 9 years ago

That's because they are all of the same type of objects, that's why they have a unique ID. They have many interaction as being "trackItems" in the code (independently of their precise type), so you just can't separate them as if they were completely different.

You must think of the different trackItems types as being different set of properties of the same type.

In the python implementation, this is done by having a base class "TrackItem" and inherited classes for each, but that's an implementation dependant choice. If I had to do it in golang, I would probably have a common struct for all of them, a common "TrackItem" interface and a specific interface derived from "TrackItem" for each trackItem type.

mdziczkowski commented 9 years ago

@npiganeau they aren't exactly the same type. Coresponding from the __type__, there are differences in other fields and then from definied variables

npiganeau commented 9 years ago

@mcgiwer don't take it the wrong way round:

These json files are the dump of the theoretical "ts2 data model" that I have invented for ts2. This model is optimised for running the game, not for loading or saving the file : the goal is to have optimised game running, not to have an easy file loading. This model is implementation independent.

As I said, it has been implemented in python as inherited classes, but you should implement it as a single large struct on languages that do not support inheritance to be able to code items interactions (pointers between items for instance: nextItem and previousItem). All variables will not be used by all instances, but that's not an issue, is it?

npiganeau commented 9 years ago

BTW, when the files were saved to sqlite, all track items were stored in the same table.

mdziczkowski commented 9 years ago

@npiganeau what do you think about to split the ts2-data files into half? the SQLite ones would be for Python version and JSON would be for GO? this way it won't be coliding in case of need changing the file structure in ts2-python

npiganeau commented 9 years ago

TS2 file format is JSON.

If you want to make a new implementation of ts2 in go, then

mdziczkowski commented 9 years ago

@npiganeau it will be compatible with it, but the order of the entries in TrainItems will be changed to make it more sorted and grouped by __type__

And second thing... I would propose you to make it modular to make the future development easier. I am participating in many train related projects and one of it (written in Deplhi and currently beeing converted to other language) has become so large (over 250,000 lines of code) that it was very difficult to progress with the works. That why the developers have listened to my advise and splited it into blocks (modules) and it helped much

npiganeau commented 9 years ago

I would propose you to make it modular to make the future development easier.

That's what's planned for v0.7. See wiki link in previous post.

mdziczkowski commented 9 years ago

@npiganeau in wiki is about 0.6 and not 0.7

what have you used to do the graph? and the editor should be pinned to launcher and not server (server should be a second plan element to with users shouldn't have direct access

npiganeau commented 9 years ago

@mcgiwer Since I wrote the wiki, and I also coded the software, I do hope that I know what I am talking about :-)

Next arch is what is planned starting from v0.7 to make ts2 modular.

v0.6 is a monolithic software of over 20,000 lines of code

mdziczkowski commented 9 years ago

I edited my earlier post and fixed the amount of zero's (it seem I have small keyboard issues and not always all chars pop in)