Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Retired Duck
retired moderator
Original Poster
#1 Old 5th Oct 2009 at 1:08 PM
Default OBJD File format
Hi all,

I'm having trouble parsing a couple of TS3 objd resources. I tried loading the resource in s3pe, and it seems to be having similar difficulties.

I'm parsing from this spec:
http://www.simswiki.info/wiki.php?t...ms_3:0x319E4F1D
But the attached OBJD resource isn't parsing nicely. I've tracked my issue down to byte 0x6CD. It's inside the property list of a Material Block, so should be following the typecodes as listed here:
http://www.simswiki.info/wiki.php?t...e#Material_List

If I read the first typecode byte 0x01, it prompts me to read a string of 0x40 characters, which comes out as "AX:\InStore\Complates\Materials\Store001_Basics\tikiStripes01Lrg". Then it becomes a bit of a mess, causing buffer overruns and fun stuff like that.

However, if I read the first byte, 0x01, then read a second byte (0xC0), then read a third byte (0x41) and use that third byte for the length, I get the more sensible string "X:\InStore\Complates\Materials\Store001_Basics\tikiStripes01Lrg_4". It then falls back into sync with the next property (a single byte, then a typecode 5 with two floats both equal to 1.0).

I'm not sure what the rule is for this though. What is the extra byte doing there? Or have I just done something stupid a few hundred bytes earlier which is messing up my offset?
Attached files:
File Type: rar  S3_319E4F1D_01000000_00000000000F4297.rar (1.6 KB, 159 downloads) - View custom content
Advertisement
Retired Duck
retired moderator
Original Poster
#2 Old 6th Oct 2009 at 9:15 AM
Okay, answering my own question.

The definition of typecode 01:
BYTE 6 bit value
if & 0x40, value is following byte | 0x40
If first byte & 0x80, length of a following string
Otherwise value is index into string table

I was mistakenly thinking the first two "if" conditions were mutually exclusive. They're not. If the most significant bit is true, it is the length of the following string, except if it the second most significant bit is also true. In that case, the length is the value is following byte | 0x40. The spec is correct (if slightly cryptic), I just mis-read it. Mea culpa.
One horse disagreer of the Apocalypse
#3 Old 6th Oct 2009 at 3:52 PM
But S3PE is still broken when confronted with some OBJDs?

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Retired Duck
retired moderator
Original Poster
#4 Old 7th Oct 2009 at 9:54 AM
Hi Inge,

Yep, I just grabbed the latest s3pe, and it seems to be having the same issue that Postal had. Stack trace:

Code:
Error reading resource 319E4F1D:01000000:00000000000F4297
Exception has been thrown by the target of an invocation.
Unexpected subType read: 0xC0 at 0x000006CF
----
Stack trace:
   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at s3pi.WrapperDealer.WrapperDealer.WrapperForType(String type, Int32 APIversion, Stream s)
   at s3pi.WrapperDealer.WrapperDealer.GetResource(Int32 APIversion, IPackage pkg, IResourceIndexEntry rie, Boolean AlwaysDefault)
   at S3PIDemoFE.MainForm.browserWidget1_SelectedResourceChanged(Object sender, ResourceChangedEventArgs e)
----
Stack trace:
   at CatalogResource.CatalogResource.TypeCode01.Parse(Stream s)
   at CatalogResource.CatalogResource.TypeCode.CreateTypeCode(Int32 APIversion, EventHandler handler, Stream s, Byte[] prefix)
   at CatalogResource.CatalogResource.TypeCodeList.CreateElement(Stream s, Boolean& inc)
   at s3pi.Interfaces.AResource.DependentList`1.Parse(Stream s)
   at s3pi.Interfaces.AResource.DependentList`1..ctor(EventHandler handler, Stream s)
   at CatalogResource.CatalogResource.MaterialBlock.Parse(Stream s)
   at CatalogResource.CatalogResource.Material.Parse(Stream s)
   at CatalogResource.CatalogResource.MaterialList.CreateElement(Stream s)
   at s3pi.Interfaces.AResource.DependentList`1.CreateElement(Stream s, Boolean& inc)
   at s3pi.Interfaces.AResource.DependentList`1.Parse(Stream s)
   at s3pi.Interfaces.AResource.DependentList`1..ctor(EventHandler handler, Stream s)
   at CatalogResource.ObjectCatalogResource.Parse(Stream s)
   at CatalogResource.CatalogResource..ctor(Int32 APIversion, Stream s)
   at CatalogResource.ObjectCatalogResource..ctor(Int32 APIversion, Stream s)
One horse disagreer of the Apocalypse
#5 Old 7th Oct 2009 at 9:57 AM
Thanks, I'll send Peter a link to this thread.

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Don't ask me, I just code
#6 Old 7th Oct 2009 at 6:54 PM
I'd been aware that there was a potential issue if both bits were set but hadn't been able to find any examples. Thanks for doing that hard part, Echo!
Retired Duck
retired moderator
Original Poster
#7 Old 7th Oct 2009 at 11:47 PM
I'll be honest, JFade found it, not me. But you're welcome in any case!
Don't ask me, I just code
#8 Old 10th Oct 2009 at 9:56 AM
I've updated the WIKI page with what I think's been explained here.
One horse disagreer of the Apocalypse
#9 Old 1st Nov 2009 at 9:44 AM
This fix is having to be backed out, as it was either specced in the first place, or implemented incorrectly, and was causing the weird windows in another thread.

Please can all parties revisit this thread and the wiki changes that were made on the back of it, and see if there is anything wrong in the spec?

"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
Back to top