Pluciński Mariusz : gameux: Add implementation of IGameStatistics::GetStatistic.

Alexandre Julliard julliard at winehq.org
Fri Nov 5 13:47:16 CDT 2010


Module: wine
Branch: master
Commit: 6b35b5dd37873e42484127336ed0b9707dc67179
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6b35b5dd37873e42484127336ed0b9707dc67179

Author: Pluciński Mariusz <vshader at gmail.com>
Date:   Thu Nov  4 16:37:04 2010 +0100

gameux: Add implementation of IGameStatistics::GetStatistic.

---

 dlls/gameux/gamestatistics.c       |   45 ++++++++++++++++++++++++++++++++++-
 dlls/gameux/tests/gamestatistics.c |   36 ++++++++++++++--------------
 2 files changed, 61 insertions(+), 20 deletions(-)

diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c
index 2807c9e..da2a3e5 100644
--- a/dlls/gameux/gamestatistics.c
+++ b/dlls/gameux/gamestatistics.c
@@ -839,8 +839,49 @@ static HRESULT WINAPI GameStatisticsImpl_GetStatistic(
     LPWSTR *pName,
     LPWSTR *pValue)
 {
-    FIXME("stub\n");
-    return E_NOTIMPL;
+    HRESULT hr = S_OK;
+    LONG nLength;
+    GameStatisticsImpl *This = impl_from_IGameStatistics(iface);
+
+    TRACE("%p, %d,%d, %p, %p\n", This, categoryIndex, statIndex, pName, pValue);
+
+    if(!pName || !pValue)
+        return E_INVALIDARG;
+
+    *pName = NULL;
+    *pValue = NULL;
+
+    if(categoryIndex >= MAX_CATEGORIES || statIndex >= MAX_STATS_PER_CATEGORY)
+        hr = E_INVALIDARG;
+
+    if(SUCCEEDED(hr))
+    {
+        nLength = lstrlenW(This->stats.categories[categoryIndex].stats[statIndex].sName);
+        if(nLength != 0)
+        {
+            *pName = CoTaskMemAlloc(sizeof(WCHAR)*(nLength+1));
+            if(!(*pName))
+                hr = E_OUTOFMEMORY;
+            else
+                lstrcpyW(*pName, This->stats.categories[categoryIndex].stats[statIndex].sName);
+        }
+    }
+
+    if(SUCCEEDED(hr))
+    {
+        nLength = lstrlenW(This->stats.categories[categoryIndex].stats[statIndex].sValue);
+        if(nLength != 0)
+        {
+            *pValue = CoTaskMemAlloc(sizeof(WCHAR)*(nLength+1));
+            if(!(*pValue))
+                hr = E_OUTOFMEMORY;
+            else
+                lstrcpyW(*pValue, This->stats.categories[categoryIndex].stats[statIndex].sValue);
+        }
+    }
+
+    TRACE("returning pair; %s => %s\n", debugstr_w(*pName), debugstr_w(*pValue));
+    return hr;
 }
 
 static HRESULT WINAPI GameStatisticsImpl_SetStatistic(
diff --git a/dlls/gameux/tests/gamestatistics.c b/dlls/gameux/tests/gamestatistics.c
index a2d0616..7eb9864 100644
--- a/dlls/gameux/tests/gamestatistics.c
+++ b/dlls/gameux/tests/gamestatistics.c
@@ -367,44 +367,44 @@ static void test_gamestatisticsmgr( void )
         CoTaskMemFree(lpName);
 
         hr = IGameStatistics_GetStatistic(gs, 0, 0, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic00)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue00)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic00)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue00)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 
         hr = IGameStatistics_GetStatistic(gs, 0, 1, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic01)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue01)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic01)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue01)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 
         hr = IGameStatistics_GetStatistic(gs, 1, 0, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic10)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue10)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic10)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue10)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 
         hr = IGameStatistics_GetStatistic(gs, 1, 1, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic11)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue11)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic11)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue11)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 
         hr = IGameStatistics_GetStatistic(gs, 2, 0, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic20)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue20)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic20)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue20)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 
         hr = IGameStatistics_GetStatistic(gs, 2, 1, &lpName, &lpValue);
-        todo_wine ok(hr == S_OK, "getting statistic failed\n");
-        todo_wine ok(lstrcmpW(lpName, sStatistic21)==0, "getting statistic returned invalid name\n");
-        todo_wine ok(lstrcmpW(lpValue, sValue21)==0, "getting statistic returned invalid value\n");
+        ok(hr == S_OK, "getting statistic failed\n");
+        ok(lstrcmpW(lpName, sStatistic21)==0, "getting statistic returned invalid name\n");
+        ok(lstrcmpW(lpValue, sValue21)==0, "getting statistic returned invalid value\n");
         CoTaskMemFree(lpName);
         CoTaskMemFree(lpValue);
 




More information about the wine-cvs mailing list