[dev thread] .trk format
3 posters
Page 1 of 1
[dev thread] .trk format
While mhenr18's lrtools does a good job at loading the .trk format, I feel that I should document changes, especially new things saved in the feature string here.
mhenr's source: https://github.com/mhenr18/lrtools/blob/master/LRTools/trk/trk_source.cpp
here's some pseudocode:
mhenr's source: https://github.com/mhenr18/lrtools/blob/master/LRTools/trk/trk_source.cpp
here's some pseudocode:
- Code:
little endian
strings are prefixed with an int16 denoting length, ASCII
vlength-string strings are length encoded 7 bits at a time, this is because of an oopsie i made in the song info encoding.
point64 is shorthand for two doubles, x and y.
enum LineType
{
Scenery=0,
Blue=1,
Red = 2,
}
CURRENT FEATURE STRINGS:REDMULTIPLIER;SCENERYWIDTH;6.1;SONGINFO;IGNORABLE_TRIGGER;
MAGIC = TRK\xF2, as a hex int: 0xF24B5254
[int32:MAGIC]
[byte:version] // 1
[string:features]//caps, seperated by semicolons. "REDMULTIPLIER;SONGINFO;SCENERYWIDTH" just for example. Always check every feature is supported before continuing to load. provided for future and backwards compatibility.
if (feature_songinfo)
{
[vlength-string:song_info]//split by \r\n, should only be two strings as a result. one is the name, one is a float32 denoting start offset. data will be something like example.mp3\r\n10.5
}
[point64:start point]
if (feature_6.1)
{
//set physics to 6.1 here
}
[int32: line count]
{
[int8:typeflags]=
linetype = (typeflags & 0x1F),
line_inv = (typeflags >> 7) != 0,//only matters if not scenery
line_limit = (typeflags >> 5) & 0x3;//only matters if not scenery
if (linetype == red)
{
if (feature_redmultiplier)
{
[int8:multiplier]
}
}
if (linetype == blue || linetype == red)
{
if (feature_ignorabletrigger)
{
if ([bool:haszoomtrigger])
{
[float32:zoomtarget]
[int16:zoomframes]
}
}
[int32:line ID]
if (lim != 0)
{
[int32:prev line ID]//if no prev line, -1
[int32:next line ID]//if no next line, -1
}
}
else if (linetype == scenery)
{
if (feature_scenerywidth)
{
[int8:(width*10)]// divide by 10 to get linewidth. didn't want to store a whole float
}
}
[point64:line point 1]
[point64:line point 2]
}
[EOF]
Last edited by JealousCloud on Sat Feb 27, 2016 6:12 pm; edited 1 time in total
JealousCloud- Member
- see you, space cowboy...
Re: [dev thread] .trk format
I'll get around to supporting some of the newer features, even if that means just ignoring them (i.e music syncing) or throwing errors if you try and convert them to versions that don't support them.
Thanks for posting this up though, beats having to figure things out the hard way.
Thanks for posting this up though, beats having to figure things out the hard way.
Re: [dev thread] .trk format
No changes, so yes.Conundrumer wrote:is this up to date?
JealousCloud- Member
- see you, space cowboy...
Re: [dev thread] .trk format
two errors:
- songinfo comes before startposition
- songinfo string length is int8, not int16
Conundrumer- Line Rider Legend
- actually working on OII
Re: [dev thread] .trk format
shit, thanks.Conundrumer wrote:two errors:
- songinfo comes before startposition
- songinfo string length is int8, not int16
Though actually songinfo string length is variable cause I used BinaryWriter.WriteString in just that case which happens to write string length 7 bits at a time :|
JealousCloud- Member
- see you, space cowboy...
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Mar 18, 2024 11:03 am by alpha leonis
» bubblegum - Pure5152
Thu Nov 23, 2023 4:36 am by Rafael
» Started in 2020 - thoughts?
Mon Jul 24, 2023 1:21 pm by cvang
» Hypersonic Motion - Preview and explanation
Mon Jul 24, 2023 12:15 pm by alpha leonis
» Track question
Mon Jul 24, 2023 12:14 pm by alpha leonis
» Line Rider Pointy Wobbly Italian Rat ~ Leonis
Mon Jul 24, 2023 12:12 pm by alpha leonis
» Line Rider Prism ~ Leonis
Mon Jul 24, 2023 12:11 pm by alpha leonis
» Playtime - pure5152
Tue May 16, 2023 4:05 pm by Sheldon
» I coded today!
Mon Mar 20, 2023 6:53 am by jimmysanders