Misc fixes for ticket:2435 (cleanup, cosmetic) to reduce diffcount
parent
b4c9ca5f10
commit
9e9fc1ba5b
|
@ -316,7 +316,7 @@ void frameShutDown(void)
|
|||
PHYSFS_file* openLoadFile(const char* fileName, bool hard_fail)
|
||||
{
|
||||
PHYSFS_file* fileHandle = PHYSFS_openRead(fileName);
|
||||
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
|
||||
debug(LOG_NEVER, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
|
||||
if (!fileHandle)
|
||||
{
|
||||
if (hard_fail)
|
||||
|
|
|
@ -88,6 +88,12 @@ void resShutDown(void)
|
|||
}
|
||||
}
|
||||
|
||||
// force set the base resource directory
|
||||
void resForceBaseDir(const char* pResDir)
|
||||
{
|
||||
sstrcpy(aResDir, pResDir);
|
||||
sstrcpy(aCurrResDir, pResDir);
|
||||
}
|
||||
|
||||
// set the base resource directory
|
||||
void resSetBaseDir(const char* pResDir)
|
||||
|
@ -465,7 +471,7 @@ bool resLoadFile(const char *pType, const char *pFile)
|
|||
// Now process the buffer data
|
||||
if (!psT->buffLoad(Resource->pBuffer, Resource->size, &pData))
|
||||
{
|
||||
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
ASSERT(false, "The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
FreeResourceFile(Resource);
|
||||
if (psT->release != NULL)
|
||||
{
|
||||
|
@ -481,7 +487,7 @@ bool resLoadFile(const char *pType, const char *pFile)
|
|||
// Process data directly from file
|
||||
if (!psT->fileLoad(aFileName, &pData))
|
||||
{
|
||||
debug(LOG_ERROR, "resLoadFile: The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
ASSERT(false, "The load function for resource type \"%s\" failed for file \"%s\"", pType, pFile);
|
||||
if (psT->release != NULL)
|
||||
{
|
||||
psT->release(pData);
|
||||
|
@ -491,7 +497,7 @@ bool resLoadFile(const char *pType, const char *pFile)
|
|||
}
|
||||
else
|
||||
{
|
||||
debug(LOG_ERROR, "resLoadFile: No load functions for this type (%s)", pType);
|
||||
ASSERT(false, "No load functions for this type (%s)", pType);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -778,10 +784,6 @@ void resReleaseBlockData(SDWORD blockID)
|
|||
{
|
||||
psT->release( psRes->pData );
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT( false,"resReleaseAllData: NULL release function" );
|
||||
}
|
||||
|
||||
psNRes = psRes->psNext;
|
||||
free(psRes);
|
||||
|
|
|
@ -88,6 +88,7 @@ extern void resShutDown(void);
|
|||
|
||||
/** Set the base resource directory. */
|
||||
extern void resSetBaseDir(const char* pResDir);
|
||||
extern void resForceBaseDir(const char* pResDir);
|
||||
|
||||
/** Parse the res file. */
|
||||
bool resLoad(const char *pResFile, SDWORD blockID);
|
||||
|
@ -112,9 +113,6 @@ extern bool resAddFileLoad(const char *pType, RES_FILELOAD fileLoad,
|
|||
/** Call the load function for a file. */
|
||||
extern bool resLoadFile(const char *pType, const char *pFile);
|
||||
|
||||
/** Add data to the resource system. */
|
||||
extern bool resAddData(char *pType, char *pID, void *pData);
|
||||
|
||||
/** Return the resource for a type and ID */
|
||||
extern void *resGetDataFromHash(const char *pType, UDWORD HashedID);
|
||||
extern void *resGetData(const char *pType, const char *pID);
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "eventsave.h"
|
||||
|
||||
|
||||
|
||||
// the event save file header
|
||||
typedef struct _event_save_header
|
||||
{
|
||||
|
@ -52,11 +51,9 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
INTERP_VAL *psVal;
|
||||
SCR_VAL_SAVE saveFunc;
|
||||
char *pPos;
|
||||
//not hashed char *pScriptID;
|
||||
UDWORD hashedName;
|
||||
UWORD *pValSize = NULL;
|
||||
|
||||
|
||||
size = 0;
|
||||
numContext = 0;
|
||||
pPos = pBuffer;
|
||||
|
@ -74,7 +71,6 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
numContext += 1;
|
||||
|
||||
// save the context info
|
||||
//nothashed if (!resGetIDfromData("SCRIPT", psCCont->psCode, &hashedName))
|
||||
if (!resGetHashfromData("SCRIPT", psCCont->psCode, &hashedName))
|
||||
{
|
||||
debug( LOG_FATAL, "eventSaveContext: couldn't find script resource id" );
|
||||
|
@ -85,8 +81,6 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
|
||||
if (pBuffer != NULL)
|
||||
{
|
||||
//not hashed strcpy(pPos, pScriptID);
|
||||
//not hashed pPos += strlen(pScriptID) + 1;
|
||||
*((UDWORD*)pPos) = (UDWORD)hashedName;
|
||||
endian_udword((UDWORD*)pPos);
|
||||
pPos += sizeof(UDWORD);
|
||||
|
@ -99,7 +93,6 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
pPos += sizeof(UBYTE);
|
||||
}
|
||||
|
||||
//not hashed size += strlen(pScriptID) + 1 + sizeof(SWORD) + sizeof(UBYTE);
|
||||
size += sizeof(UDWORD) + sizeof(SWORD) + sizeof(UBYTE);
|
||||
|
||||
// save the context variables
|
||||
|
@ -220,7 +213,7 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize)
|
|||
}
|
||||
|
||||
// load the context information for the script system
|
||||
static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize, BOOL bHashed)
|
||||
static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize)
|
||||
{
|
||||
UDWORD size, valSize,stringLen;
|
||||
SDWORD numVars, i, numContext, context;
|
||||
|
@ -228,7 +221,6 @@ static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize,
|
|||
INTERP_TYPE type;
|
||||
SCR_VAL_LOAD loadFunc;
|
||||
char *pPos;
|
||||
char *pScriptID = NULL;
|
||||
UDWORD hashedName;
|
||||
SCRIPT_CODE *psCode;
|
||||
CONTEXT_RELEASE release;
|
||||
|
@ -246,17 +238,11 @@ static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize,
|
|||
// go through the contexts
|
||||
for(context=0; context < numContext; context += 1)
|
||||
{
|
||||
if(bHashed) {
|
||||
endian_udword((UDWORD*)pPos);
|
||||
hashedName = *((UDWORD*)pPos);
|
||||
psCode = (SCRIPT_CODE*)resGetDataFromHash("SCRIPT", hashedName);
|
||||
pPos += sizeof(UDWORD);
|
||||
} else {
|
||||
// get the script code
|
||||
pScriptID = (char *)pPos;
|
||||
psCode = (SCRIPT_CODE*)resGetData("SCRIPT", pScriptID);
|
||||
pPos += strlen(pScriptID) + 1;
|
||||
}
|
||||
|
||||
// check the number of variables
|
||||
endian_sword((SWORD*)pPos);
|
||||
numVars = psCode->numGlobals + psCode->arraySize;
|
||||
|
@ -281,11 +267,7 @@ static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize,
|
|||
// bit of a hack this - note the id of the context to link it to the triggers
|
||||
psContList->id = (SWORD)context;
|
||||
|
||||
if(bHashed) {
|
||||
size += sizeof(UDWORD) + sizeof(SWORD) + sizeof(UBYTE);
|
||||
} else {
|
||||
size += strlen(pScriptID) + 1 + sizeof(SWORD) + sizeof(UBYTE);
|
||||
}
|
||||
|
||||
// set the context variables
|
||||
for(i=0; i < numVars; i+= 1)
|
||||
|
@ -601,8 +583,6 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize)
|
|||
}
|
||||
totalSize += size;
|
||||
|
||||
|
||||
|
||||
// Allocate the buffer to save to
|
||||
pBuffer = (char*)malloc(totalSize);
|
||||
if (pBuffer == NULL)
|
||||
|
@ -613,7 +593,6 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize)
|
|||
}
|
||||
pPos = pBuffer;
|
||||
|
||||
|
||||
// set the header
|
||||
psHdr = (EVENT_SAVE_HDR *)pPos;
|
||||
psHdr->aFileType[0] = 'e';
|
||||
|
@ -625,7 +604,6 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize)
|
|||
|
||||
pPos += sizeof(EVENT_SAVE_HDR);
|
||||
|
||||
|
||||
// save the contexts
|
||||
if (!eventSaveContext(pPos, &size))
|
||||
{
|
||||
|
@ -655,38 +633,25 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize)
|
|||
|
||||
|
||||
// Load the state of the event system
|
||||
BOOL eventLoadState(char *pBuffer, UDWORD fileSize, BOOL bHashed)
|
||||
BOOL eventLoadState(char *pBuffer, UDWORD fileSize)
|
||||
{
|
||||
UDWORD size, totalSize, version;
|
||||
char *pPos;
|
||||
EVENT_SAVE_HDR *psHdr;
|
||||
|
||||
|
||||
pPos = pBuffer;
|
||||
totalSize = 0;
|
||||
|
||||
// Get the header
|
||||
psHdr = (EVENT_SAVE_HDR *)pPos;
|
||||
endian_udword(&psHdr->version);
|
||||
if (strncmp(psHdr->aFileType, "evnt", 4) != 0)
|
||||
{
|
||||
debug( LOG_FATAL, "eventLoadState: invalid file header" );
|
||||
abort();
|
||||
return false;
|
||||
}
|
||||
/* if ((psHdr->version != 1) &&
|
||||
(psHdr->version != 2))
|
||||
{
|
||||
DBERROR(("eventLoadState: invalid file version"));
|
||||
return false;
|
||||
}*/
|
||||
ASSERT_OR_RETURN(false, strncmp(psHdr->aFileType, "evnt", 4) == 0, "Invalid file header");
|
||||
version = psHdr->version;
|
||||
pPos += sizeof(EVENT_SAVE_HDR);
|
||||
totalSize += sizeof(EVENT_SAVE_HDR);
|
||||
|
||||
|
||||
// load the event contexts
|
||||
if (!eventLoadContext(version, pPos, &size, bHashed))
|
||||
if (!eventLoadContext(version, pPos, &size))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,6 @@
|
|||
extern BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize);
|
||||
|
||||
// Load the state of the event system
|
||||
extern BOOL eventLoadState(char *pBuffer, UDWORD fileSize, BOOL bHashed);
|
||||
extern BOOL eventLoadState(char *pBuffer, UDWORD fileSize);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11347,7 +11347,6 @@ BOOL loadScriptState(char *pFileName)
|
|||
{
|
||||
char *pFileData;
|
||||
UDWORD fileSize;
|
||||
BOOL bHashed = false;
|
||||
|
||||
// change the file extension
|
||||
pFileName[strlen(pFileName)-4] = (char)0;
|
||||
|
@ -11361,12 +11360,7 @@ BOOL loadScriptState(char *pFileName)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (saveGameVersion > VERSION_12)
|
||||
{
|
||||
bHashed = true;
|
||||
}
|
||||
|
||||
if (!eventLoadState(pFileData, fileSize, bHashed))
|
||||
if (!eventLoadState(pFileData, fileSize))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,6 @@ BOOL scrGenExternSet(UDWORD index)
|
|||
{
|
||||
// Since tutorial is skirmish
|
||||
NetPlay.players[0].allocated = true;
|
||||
debug(LOG_ERROR, "tutorial turned %s", val ? "on" : "off");
|
||||
}
|
||||
break;
|
||||
case EXTID_EXTRAVICTORYFLAG:
|
||||
|
|
|
@ -1677,9 +1677,6 @@ VAR_SYMBOL asObjTable[] =
|
|||
*/
|
||||
CONST_SYMBOL asConstantTable[] =
|
||||
{
|
||||
/* { "TEST_BOOL_CONST", VAL_BOOL, true, 0, 0 },
|
||||
{ "TEST_INT_CONST", VAL_INT, 0, 10, 0 },*/
|
||||
|
||||
//reticule button IDs - for scrFlashOn & Off
|
||||
// original annette styley
|
||||
{ "OPTIONS", VAL_INT, false, IDRET_OPTIONS, NULL, NULL, 0.0f },
|
||||
|
@ -1691,7 +1688,6 @@ CONST_SYMBOL asConstantTable[] =
|
|||
{ "DESIGN", VAL_INT, false, IDRET_DESIGN, NULL, NULL, 0.0f },
|
||||
{ "COMMAND", VAL_INT, false, IDRET_COMMAND, NULL, NULL, 0.0f },
|
||||
|
||||
|
||||
// new styley that supports many other buttons
|
||||
{ "IDRET_OPTIONS", VAL_INT, false, IDRET_OPTIONS, NULL, NULL, 0.0f },
|
||||
{ "IDRET_CANCEL", VAL_INT, false, IDRET_CANCEL, NULL, NULL, 0.0f },
|
||||
|
@ -1719,13 +1715,11 @@ CONST_SYMBOL asConstantTable[] =
|
|||
// the first (top-left) button on the list window (up from the reticule)
|
||||
{ "IDSTAT_START", VAL_INT, false, IDSTAT_START, NULL, NULL, 0.0f },
|
||||
|
||||
|
||||
//message Types
|
||||
{ "RES_MSG", VAL_INT, false, MSG_RESEARCH, NULL, NULL, 0.0f },
|
||||
{ "CAMP_MSG", VAL_INT, false, MSG_CAMPAIGN, NULL, NULL, 0.0f },
|
||||
{ "MISS_MSG", VAL_INT, false, MSG_MISSION, NULL, NULL, 0.0f },
|
||||
{ "PROX_MSG", VAL_INT, false, MSG_PROXIMITY, NULL, NULL, 0.0f },
|
||||
//{ "TUT_MSG", VAL_INT, false, MSG_TUTORIAL, NULL, NULL, 0.0f }, NOT NEEDED
|
||||
|
||||
//used for null pointers
|
||||
{ "NULLTEMPLATE", (INTERP_TYPE)ST_POINTER_T, false, 0, NULL, NULL, 0.0f },
|
||||
|
@ -1941,7 +1935,6 @@ CONST_SYMBOL asConstantTable[] =
|
|||
{ "STATUS_BattleMapViewEnabled",VAL_INT, false, STATUS_BattleMapViewEnabled, NULL, NULL, 0.0f }, // Are we currently in the battlemap view (tactical display) true=yes
|
||||
{ "STATUS_DeliveryReposInProgress",VAL_INT,false, STATUS_DeliveryReposInProgress, NULL, NULL, 0.0f }, // Are we currently in the delivery repos mode
|
||||
|
||||
|
||||
//possible values for externed targetedObjectType
|
||||
{ "MT_TERRAIN", VAL_INT, false, MT_TERRAIN, NULL, NULL, 0.0f },
|
||||
{ "MT_RESOURCE", VAL_INT, false, MT_RESOURCE, NULL, NULL, 0.0f },
|
||||
|
@ -2291,16 +2284,12 @@ BOOL scrTabInitialise(void)
|
|||
// Set the object variable table
|
||||
scriptSetObjectTab(asObjTable);
|
||||
|
||||
|
||||
|
||||
|
||||
// Set the callback table
|
||||
scriptSetCallbackTab(asCallbackTable);
|
||||
|
||||
// Set the type equivalence table
|
||||
scriptSetTypeEquiv(asEquivTable);
|
||||
|
||||
|
||||
// Set the create and release functions
|
||||
if (!eventAddValueCreate((INTERP_TYPE)ST_BASEOBJECT, scrvAddBasePointer))
|
||||
{
|
||||
|
@ -2362,14 +2351,9 @@ BOOL scrTabInitialise(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Shut down the script system
|
||||
void scrShutDown(void)
|
||||
{
|
||||
scrvShutDown();
|
||||
scriptShutDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue