[dev thread] .trk format

View previous topic View next topic Go down

[dev thread] .trk format

Post by JealousCloud on Sun Dec 20, 2015 9:37 pm

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:
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]
This currently includes 1.51 features but you get the idea.


Last edited by JealousCloud on Sat Feb 27, 2016 6:12 pm; edited 1 time in total

_________________
remember line rider advanced?
avatar
JealousCloud
Member

see you, space cowboy...


View user profile

Back to top Go down

Re: [dev thread] .trk format

Post by mhenr18 on Wed Dec 23, 2015 2:44 am

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.

mhenr18
Member


View user profile http://www.mhenr18.com

Back to top Go down

Re: [dev thread] .trk format

Post by Conundrumer on Sat Feb 20, 2016 5:27 pm

is this up to date?

_________________
Youtube
avatar
Conundrumer
Line Rider Legend

actually working on OII


View user profile

Back to top Go down

Re: [dev thread] .trk format

Post by JealousCloud on Sat Feb 20, 2016 7:17 pm

@Conundrumer wrote:is this up to date?
No changes, so yes.

_________________
remember line rider advanced?
avatar
JealousCloud
Member

see you, space cowboy...


View user profile

Back to top Go down

Re: [dev thread] .trk format

Post by Conundrumer on Sat Feb 27, 2016 6:04 pm

two errors:

  1. songinfo comes before startposition
  2. songinfo string length is int8, not int16

_________________
Youtube
avatar
Conundrumer
Line Rider Legend

actually working on OII


View user profile

Back to top Go down

Re: [dev thread] .trk format

Post by JealousCloud on Sat Feb 27, 2016 6:06 pm

@Conundrumer wrote:two errors:

  1. songinfo comes before startposition
  2. songinfo string length is int8, not int16

shit, thanks.

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 :|

_________________
remember line rider advanced?
avatar
JealousCloud
Member

see you, space cowboy...


View user profile

Back to top Go down

Re: [dev thread] .trk format

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum