1
0
Fork 0

Corrected LtgLoader._getDataSegment() impl. and offsets

- Unit testing would have caught this. It is terribly uncomfortable not unit testing.
master
Mike Gerwitz 2012-03-18 00:35:01 -04:00
parent 6654b19ecb
commit 822e1e6d05
1 changed files with 10 additions and 7 deletions

View File

@ -48,12 +48,12 @@
*/
ltjs.LtgLoader = Class( 'LtgLoader',
{
/** various data segment byte offsets and ranges **/
/** various data segment byte offsets and lengths **/
'private const _POS_NAME': [ 0, 40 ],
'private const _POS_AUTHOR': [ 40, 30 ],
'private const _POS_DESC': [ 70, 315 ],
'private const _POS_ID': [ 315, 320 ],
'private const _POS_MOFF': [ 320, 324 ],
'private const _POS_DESC': [ 70, 245 ],
'private const _POS_ID': [ 315, 5 ],
'private const _POS_MOFF': [ 320, 4 ],
/**
* Beginning of game bitmap (one byte past the header)
@ -103,15 +103,18 @@ ltjs.LtgLoader = Class( 'LtgLoader',
'private _getDataSegment': function( ltg_data, sgmt, stripnull )
{
// strip null bytes by default
stripnull = ( stripnull === undefined ) ? true : false;
stripnull = ( stripnull === undefined ) ? true : !!stripnull;
if ( typeof sgmt === 'string' )
{
sgmt = this.__self.$( sgmt );
}
return String.prototype.substr.apply( ltg_data, sgmt )
.split( '\x00' )[ 0 ];
var data = String.prototype.substr.apply( ltg_data, sgmt );
return ( stripnull )
? data.split( '\x00' )[ 0 ]
: data;
},