diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c index 2807c9e36b3..da2a3e59c93 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 a2d0616ab73..7eb98646cbe 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);