<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<span>Hi Micheal,<br>
</span>
<div><br>
</div>
<div>Game LegoLand.<br>
</div>
<div><br>
</div>
<div>This game loads about 40 objects (sgt,sty) into the cache, and when it's looping<br>
</div>
<div>over the cache it's selecting the wrong object.<br>
</div>
<div><br>
</div>
<div>Simple example, of 3 objects.<br>
</div>
<div><br>
</div>
<div>1. GUID XX, Name "Trans" category "chord"   (filename trans.sgt)<br>
</div>
<div>2. GUID YY, Name "Other" category "tempo"<br>
</div>
<div>3. GUID ZZ, Name "Trans" category "chord"   (filename trans.sty)<br>
</div>
<div><br>
</div>
<div>Using IDirectMusicLoader8_GetObject<br>
</div>
<div><br>
</div>
<div>Processing element 3, searching for an object with GUID = XX, Name = "Trans" and category = "chord".<br>
</div>
<div>We find the object 1 (correct)<br>
</div>
<div>We continue searching and find object 3 (wrong that's ourself). <br>
</div>
<div>Then we attempt to resolve object 3 by calling _GetObject again, causing a stack overflow.<br>
</div>
<div><br>
</div>
<div>Snippet of the log.<br>
</div>
<div>0030:trace:dmloader:dump_DMUS_OBJECTDESC  - wszFileName = L"WLtran2.sty"<br>
</div>
<div>0030:trace:dmloader:IDirectMusicLoaderImpl_GetObject : looking if we have object in the cache or if it can be found via alias<br>
</div>
<div>0030:trace:dmloader:IDirectMusicLoaderImpl_GetObject : found it by object GUID<br>
</div>
<div>0030:trace:dmloader:IDirectMusicLoaderImpl_GetObject : not loaded yet<br>
</div>
<div>0030:trace:dmloader:IDirectMusicLoaderImpl_GetObject : found it by name and category<br>
</div>
<div>0030:trace:dmloader:IDirectMusicLoaderImpl_GetObject : not loaded yet<br>
</div>
<div><br>
</div>
<div>The unique identifiers in this structure are GUID, filename.<br>
</div>
<div><br>
</div>
<div>Also the loop has bad logic. <br>
</div>
<div><br>
</div>
<div>These are the same, so the second if will never be hit.<br>
</div>
<div>else if ((pDesc->dwValidData & (DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH)) &&<br>
</div>
<div>...<br>
</div>
<div>else if ((pDesc->dwValidData & DMUS_OBJ_FILENAME) &&<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>If we want to keep all conditions, then we could do something beflow, so <br>
</div>
<div>weight is given each flag. (simplify logic).<br>
</div>
<div>if (pDesc->dwValidData & DMUS_OBJ_OBJECT) <br>
</div>
<div>{<br>
</div>
<div>    if(IsEqualGUID (&pDesc->guidObject, &pExistingEntry->Desc.guidObject))<br>
</div>
<div>        pObjectEntry = pExistingEntry;<br>
</div>
<div>    break;<br>
</div>
<div>}<br>
</div>
<div><br>
</div>
<div>Regards<br>
</div>
<span>Alistair.</span><br>
</body>
</html>