DMUSIC: more Unreal2 dmloader fixes

Raphaël Junqueira fenix at club-internet.fr
Tue Oct 28 02:33:03 CST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

Now Unreal2 seems to crash on dmscript use.

Rok, have you an idea how to load a IDirectMusicContainer ?

Changelog:
 - better traces
 - some IPersistStream::GetClassID impl (it's the correct way ?)
 - add the "search by name" support for IDirectMusicLoader8::GetObject (and an 
hack for understanding containers use)

Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/ninDp7NA3AmQTU4RAoucAJ9+4THEnoNK9mk36KKpXH2NpgtdegCfXBY2
QBbrvvcx/Y+FFMtM2PIN/vA=
=LrXJ
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: dmloader/dmloader_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/dmloader_private.h,v
retrieving revision 1.4
diff -u -r1.4 dmloader_private.h
--- dmloader/dmloader_private.h	22 Sep 2003 19:37:33 -0000	1.4
+++ dmloader/dmloader_private.h	28 Oct 2003 08:26:03 -0000
@@ -43,6 +43,7 @@
 	struct list entry; /* for listing elements */
 	GUID guidObject;
 	WCHAR wzFileName[MAX_PATH];
+        WCHAR wzName[256];
     IDirectMusicObject* pObject;
 } DMUS_PRIVATE_CACHE_ENTRY, *LPDMUS_PRIVATE_CACHE_ENTRY;
 
Index: dmloader/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loader.c,v
retrieving revision 1.7
diff -u -r1.7 loader.c
--- dmloader/loader.c	28 Oct 2003 00:10:38 -0000	1.7
+++ dmloader/loader.c	28 Oct 2003 08:26:04 -0000
@@ -78,7 +78,7 @@
 	DMUS_PRIVATE_CACHE_ENTRY *cacheEntry;
 	LPDMUS_PRIVATE_CACHE_ENTRY newEntry;
 
-	TRACE("(%p, %p, %s, %p)\n", This, pDesc, debugstr_guid(riid), ppv);
+	TRACE("(%p, %p(dwValidData:0x%08lx), %s, %p)\n", This, pDesc, pDesc->dwValidData, debugstr_guid(riid), ppv);
 
 	TRACE("looking up cache...\n");
 
@@ -90,53 +90,94 @@
 				if (IsEqualGUID (&cacheEntry->guidObject, &pDesc->guidObject)) {
 					TRACE(": found it by GUID\n");
 					if (cacheEntry->pObject)
-						return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT)cacheEntry->pObject, riid, ppv);
+						return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
 				}
 			}
 			if (pDesc->dwValidData & DMUS_OBJ_FILENAME) {
 				if (cacheEntry->wzFileName && !strncmpW (pDesc->wszFileName, cacheEntry->wzFileName, MAX_PATH)) {
 					TRACE(": found it by FileName\n");
 					if (cacheEntry->pObject)
-						return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT)cacheEntry->pObject, riid, ppv);
+						return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
 				}
 			}
+		} else if (pDesc->dwValidData & DMUS_OBJ_NAME) {
+		  /**
+		   * Usually search by name (for example main procedure name for scripts) after containers loading
+		   * TODO: container loading code
+		   */
+		  TRACE(" comparing \"%s\" with cached \"%s\"(file:%s)\n", debugstr_w (pDesc->wszName), debugstr_w (cacheEntry->wzName)debugstr_w, (cacheEntry->wzFileName));
+		  if (cacheEntry->wzName && !strncmpW (pDesc->wszName, cacheEntry->wzName, 256)) {
+		    TRACE(": found it by Name\n");
+		    if (NULL != cacheEntry->pObject)
+		      return IDirectMusicObject_QueryInterface ((LPDIRECTMUSICOBJECT) cacheEntry->pObject, riid, ppv);
+		  }
 		}
 	}
 	
 	/* object doesn't exist in cache... guess we'll have to load it */
 	TRACE(": object does not exist in cache\n");
-	result = CoCreateInstance (&pDesc->guidClass, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (LPVOID*)&pObject);
+	if (pDesc->dwValidData & DMUS_OBJ_LOADED) {
+	  ERR("Wanted a on-memory (cached) entry, but not found. Active Hack (waiting for Load code)\n");
+	  /* ugly hack waiting for Load impl */
+	  result = CoCreateInstance (&pDesc->guidClass, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (LPVOID*) &pObject);
+	  if (SUCCEEDED(result)) {
+	    /* add object to cache */
+	    result = IDirectMusicObject_QueryInterface (pObject, riid, ppv);
+	    if (SUCCEEDED(result)) {
+	      newEntry = (LPDMUS_PRIVATE_CACHE_ENTRY) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_CACHE_ENTRY));
+	      if (pDesc->dwValidData & DMUS_OBJ_NAME)
+		strncpyW (newEntry->wzName, pDesc->wszName, 256);
+	      newEntry->pObject = pObject;
+	      list_add_tail (&This->CacheList, &newEntry->entry);
+	      TRACE(": filled in cache entry\n");
+	    } else {
+	      IDirectMusicObject_Release(pObject);
+	    }
+	  }
+	  return result;
+	  /*
+	   * Normal code
+	  *ppv = NULL;
+	  return E_FAIL;
+	  */
+	}
+	if (!(pDesc->dwValidData & DMUS_OBJ_CLASS)) {
+	  WARN("guidClass not valid but needed. What they want to do ?\n");
+	  *ppv = NULL;
+	  return DMUS_E_LOADER_NOCLASSID;
+	}
+	result = CoCreateInstance (&pDesc->guidClass, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (LPVOID*) &pObject);
 	if (FAILED(result)) return result;
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME) {
 		/* load object from file */
 		WCHAR wzFileName[MAX_PATH];
 		ILoaderStream* pStream;
-                IPersistStream *pPersistStream = NULL;
+                IPersistStream* pPersistStream = NULL;
 		/* if it's full path, don't add search directory path, otherwise do */
 		if (pDesc->dwValidData & DMUS_OBJ_FULLPATH) {
-			lstrcpyW( wzFileName, pDesc->wszFileName );
+			lstrcpyW(wzFileName, pDesc->wszFileName);
 		} else {
 			WCHAR *p;
-			lstrcpyW( wzFileName, This->wzSearchPath );
+			lstrcpyW(wzFileName, This->wzSearchPath);
 			p = wzFileName + lstrlenW(wzFileName);
 			if (p > wzFileName && p[-1] != '\\') *p++ = '\\';
-			strcpyW( p, pDesc->wszFileName );
+			strcpyW(p, pDesc->wszFileName);
 		}
 		TRACE(": loading from file (%s)\n", debugstr_w(wzFileName));
          
-		result = DMUSIC_CreateLoaderStream ((LPSTREAM*)&pStream);
+		result = DMUSIC_CreateLoaderStream ((LPSTREAM*) &pStream);
 		if (FAILED(result)) return result;
 		
-		result = ILoaderStream_Attach (pStream, wzFileName, (LPDIRECTMUSICLOADER)iface);
+		result = ILoaderStream_Attach (pStream, wzFileName, (LPDIRECTMUSICLOADER) iface);
 		if (FAILED(result)) return result;
 			
-		result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*)&pPersistStream);
+		result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*) &pPersistStream);
                 if (FAILED(result)) return result;
 			
-		result = IPersistStream_Load (pPersistStream, (LPSTREAM)pStream);
+		result = IPersistStream_Load (pPersistStream, (LPSTREAM) pStream);
                 if (FAILED(result)) return result;
 			
-                ILoaderStream_IStream_Release ((LPSTREAM)pStream);
+                ILoaderStream_IStream_Release ((LPSTREAM) pStream);
                 IPersistStream_Release (pPersistStream);
 	} else if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
 		/* load object from stream */
@@ -144,7 +185,7 @@
 		IPersistStream* pPersistStream = NULL;
 
 		TRACE(": loading from stream\n");
-		result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*)&pPersistStream);
+		result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*) &pPersistStream);
                 if (FAILED(result)) return result;
 			
                 result = IStream_Clone (pDesc->pStream, &pClonedStream);
@@ -165,19 +206,19 @@
 			if (FAILED(DMUSIC_GetDefaultGMPath (wzFileName)))
 				return E_FAIL;
 			/* load object from file */
-			result = DMUSIC_CreateLoaderStream ((LPSTREAM*)&pStream);
+			result = DMUSIC_CreateLoaderStream ((LPSTREAM*) &pStream);
 			if (FAILED(result)) return result;
 
-			result = ILoaderStream_Attach (pStream, wzFileName, (LPDIRECTMUSICLOADER)iface);
+			result = ILoaderStream_Attach (pStream, wzFileName, (LPDIRECTMUSICLOADER) iface);
 			if (FAILED(result)) return result;
 
-			result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*)&pPersistStream);
+			result = IDirectMusicObject_QueryInterface (pObject, &IID_IPersistStream, (LPVOID*) &pPersistStream);
                         if (FAILED(result)) return result;
 
-			result = IPersistStream_Load (pPersistStream, (LPSTREAM)pStream);
+			result = IPersistStream_Load (pPersistStream, (LPSTREAM) pStream);
                         if (FAILED(result)) return result;
 
-                        ILoaderStream_IStream_Release ((LPSTREAM)pStream);
+                        ILoaderStream_IStream_Release ((LPSTREAM) pStream);
 			IPersistStream_Release (pPersistStream);
 		} else {
 			return E_FAIL;
Index: dmscript/script.c
===================================================================
RCS file: /home/wine/wine/dlls/dmscript/script.c,v
retrieving revision 1.3
diff -u -r1.3 script.c
--- dmscript/script.c	5 Sep 2003 23:08:39 -0000	1.3
+++ dmscript/script.c	28 Oct 2003 08:26:05 -0000
@@ -177,6 +177,7 @@
 {
 	IDirectMusicScriptImpl* dmscript;
 	
+	TRACE("(%p,%p,%p)\n",lpcGUID, ppDMScript, pUnkOuter);
 	if (IsEqualIID (lpcGUID, &IID_IDirectMusicScript)) {
 		dmscript = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl));
 		if (NULL == dmscript) {
@@ -349,7 +350,8 @@
 /* IDirectMusicScriptObjectStream IPersist part: */
 HRESULT WINAPI IDirectMusicScriptObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
 {
-	return E_NOTIMPL;
+        *pClassID = CLSID_DirectMusicScript;
+	return S_OK;
 }
 
 /* IDirectMusicScriptObjectStream IPersistStream part: */
Index: dmscript/scripttrack.c
===================================================================
RCS file: /home/wine/wine/dlls/dmscript/scripttrack.c,v
retrieving revision 1.2
diff -u -r1.2 scripttrack.c
--- dmscript/scripttrack.c	5 Sep 2003 23:08:39 -0000	1.2
+++ dmscript/scripttrack.c	28 Oct 2003 08:26:06 -0000
@@ -301,7 +301,8 @@
 /* IDirectMusicScriptTrackStream IPersist part: */
 HRESULT WINAPI IDirectMusicScriptTrackStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
 {
-	return E_NOTIMPL;
+        *pClassID = CLSID_DirectMusicScriptTrack;
+	return S_OK;
 }
 
 /* IDirectMusicScriptTrackStream IPersistStream part: */
Index: ntdll/path.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/path.c,v
retrieving revision 1.11
diff -u -r1.11 path.c
--- ntdll/path.c	28 Oct 2003 00:07:56 -0000	1.11
+++ ntdll/path.c	28 Oct 2003 08:26:09 -0000
@@ -321,6 +321,7 @@
     LPWSTR              ptr;
     UNICODE_STRING*     cd;
 
+    TRACE("name %s size %lu\n",debugstr_w(name),size);
     reqsize = sizeof(WCHAR); /* '\0' at the end */
 
     RtlAcquirePebLock();


More information about the wine-patches mailing list