Test fix for OOS message

This commit is contained in:
mathusummut
2018-09-28 00:10:04 +02:00
parent 8117d96c63
commit 8c8b827588
2 changed files with 11 additions and 12 deletions

View File

@@ -319,7 +319,7 @@ namespace Shared {
class ValueCheckerVault { class ValueCheckerVault {
protected: protected:
std::map<const void *, uint32> vaultList; std::map<const void *, int32> vaultList;
void addItemToVault(const void *ptr, int value); void addItemToVault(const void *ptr, int value);
void checkItemInVault(const void *ptr, int value) const; void checkItemInVault(const void *ptr, int value) const;

View File

@@ -2240,7 +2240,7 @@ namespace Shared {
return intToStr(width) + "x" + intToStr(height) + "-" + intToStr(depth); return intToStr(width) + "x" + intToStr(height) + "-" + intToStr(depth);
} }
void notifyValueChangedUnexpectedly() { void notifyValueChangedUnexpectedly(int expectedValue, int actualValue) {
//if(SystemFlags::VERBOSE_MODE_ENABLED) { //if(SystemFlags::VERBOSE_MODE_ENABLED) {
// printf("In [%s::%s Line: %d] check vault key [%p] value [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,value); // printf("In [%s::%s Line: %d] check vault key [%p] value [%d]\n",__FILE__,__FUNCTION__,__LINE__,ptr,value);
// for(map<const void *,string>::const_iterator iterFind = vaultList.begin(); // for(map<const void *,string>::const_iterator iterFind = vaultList.begin();
@@ -2248,8 +2248,9 @@ namespace Shared {
// printf("In [%s::%s Line: %d] LIST-- check vault key [%p] value [%s]\n",__FILE__,__FUNCTION__,__LINE__,iterFind->first,iterFind->second.c_str()); // printf("In [%s::%s Line: %d] LIST-- check vault key [%p] value [%s]\n",__FILE__,__FUNCTION__,__LINE__,iterFind->first,iterFind->second.c_str());
// } // }
//} //}
char szMsg[8096];
const char* szMsg = "A value in memory has changed unexpectedly. Game out of sync, try leaving and rejoining"; snprintf(szMsg, 8096, "A value in memory has changed unexpectedly (expected %d, found %d). Game out of sync, try leaving and rejoining",
expectedValue, actualValue);
printf("%s\n", szMsg); printf("%s\n", szMsg);
SystemFlags::OutputDebug(SystemFlags::debugSystem, "%s\n", szMsg); SystemFlags::OutputDebug(SystemFlags::debugSystem, "%s\n", szMsg);
SystemFlags::OutputDebug(SystemFlags::debugError, "%s\n", szMsg); SystemFlags::OutputDebug(SystemFlags::debugError, "%s\n", szMsg);
@@ -2260,19 +2261,17 @@ namespace Shared {
void ValueCheckerVault::addItemToVault(const void *ptr, int value) { void ValueCheckerVault::addItemToVault(const void *ptr, int value) {
#ifndef _DISABLE_MEMORY_VAULT_CHECKS #ifndef _DISABLE_MEMORY_VAULT_CHECKS
Checksum checksum; vaultList[ptr] = value;
vaultList[ptr] = checksum.addInt(value);
#endif #endif
} }
void ValueCheckerVault::checkItemInVault(const void *ptr, int value) const { void ValueCheckerVault::checkItemInVault(const void *ptr, int value) const {
#ifndef _DISABLE_MEMORY_VAULT_CHECKS #ifndef _DISABLE_MEMORY_VAULT_CHECKS
map<const void *, uint32>::const_iterator iterFind = vaultList.find(ptr); if (value == 0) //workaround
if (iterFind != vaultList.end()) { return;
Checksum checksum; map<const void *, int32>::const_iterator iterFind = vaultList.find(ptr);
if (iterFind->second != checksum.addInt(value)) if (iterFind != vaultList.end() && iterFind->second != value)
notifyValueChangedUnexpectedly(); notifyValueChangedUnexpectedly(value, iterFind->second);
}
#endif #endif
} }