Permalink
Browse files

Assert on collision of hashes of resource types or filenames.

This should be a minor improvement over silently retreiving the wrong resource on filename hash collisions.
  • Loading branch information...
1 parent 398f77e commit 74c153cf7bcc823ce1ace112cb9ce96d527c9f97 @Cyp Cyp committed Aug 2, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/framework/frameresource.cpp
@@ -419,6 +419,7 @@ bool resLoadFile(const char *pType, const char *pFile)
{
if (psT->HashedType == HashedType)
{
+ ASSERT(strcmp(psT->aType, pType) == 0, "Hash collision \"%s\" vs \"%s\"", psT->aType, pType);
break;
}
}
@@ -435,7 +436,8 @@ bool resLoadFile(const char *pType, const char *pFile)
{
if(psRes->HashedID == HashedName)
{
- debug(LOG_WZ, "resLoadFile: Duplicate file name: %s (hash %x) for type %s",
+ ASSERT(strcasecmp(psRes->aID, pFile) == 0, "Hash collision \"%s\" vs \"%s\"", psRes->aID, pFile);
+ debug(LOG_WZ, "Duplicate file name: %s (hash %x) for type %s",
pFile, HashedName, psT->aType);
// assume that they are actually both the same and silently fail
// lovely little hack to allow some files to be loaded from disk (believe it or not!).

0 comments on commit 74c153c

Please sign in to comment.