Backport r2265,2266,2268 from branches/2.0

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2269 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-07-29 16:58:16 +00:00
parent 0931065023
commit f612678624
1 changed files with 12 additions and 50 deletions

View File

@ -570,68 +570,23 @@ BOOL resLoadFile(const char *pType, const char *pFile)
/* Return the resource for a type and hashedname */
void *resGetDataFromHash(const char *pType, UDWORD HashedID)
{
RES_TYPE *psT;
RES_DATA *psRes;
UDWORD HashedType;
RES_TYPE *psT = NULL;
RES_DATA *psRes = NULL;
// Find the correct type
HashedType=HashString(pType); // la da la
UDWORD HashedType = HashString(pType);
for(psT = psResTypes; psT != NULL; psT = psT->psNext )
{
if (psT->HashedType==HashedType)
{
break;
}
}
if (psT == NULL)
{
ASSERT( FALSE, "resGetData: Unknown type: %s", pType );
return NULL;
}
for(psRes = psT->psRes; psRes; psRes = psRes->psNext)
{
if (psRes->HashedID == HashedID)
{
/* We found it */
break;
}
}
if (psRes == NULL)
{
ASSERT( psRes != NULL, "resGetDataFromHash: Unknown ID:" );
return NULL;
}
psRes->usage += 1;
return psRes->pData;
}
/* Return the resource for a type and ID */
void *resGetData(const char *pType, const char *pID)
{
RES_TYPE *psT;
RES_DATA *psRes;
// Find the correct type
UDWORD HashedType = HashString(pType);
UDWORD HashedID = HashStringIgnoreCase(pID);
for(psT = psResTypes; psT != NULL; psT = psT->psNext )
{
if (psT->HashedType == HashedType)
{
break;
}
}
ASSERT( psT != NULL, "resGetDataFromHash: Unknown type: %s", pType );
if (psT == NULL)
{
ASSERT( FALSE, "resGetData: Unknown type: %s", pType );
return NULL;
}
@ -644,9 +599,9 @@ void *resGetData(const char *pType, const char *pID)
}
}
ASSERT( psRes != NULL, "resGetDataFromHash: Unknown ID: %0x Type: %s", HashedID, pType );
if (psRes == NULL)
{
ASSERT( psRes != NULL, "resGetData: Unknown ID: %s of type %s", pID, pType );
return NULL;
}
@ -656,6 +611,13 @@ void *resGetData(const char *pType, const char *pID)
}
/* Return the resource for a type and ID */
void *resGetData(const char *pType, const char *pID)
{
return resGetDataFromHash(pType, HashStringIgnoreCase(pID));
}
BOOL resGetHashfromData(const char *pType, const void *pData, UDWORD *pHash)
{
RES_TYPE *psT;