diff --git a/lib/script/evntsave.c b/lib/script/evntsave.c index 09523b0a4..7a2b7a9b2 100644 --- a/lib/script/evntsave.c +++ b/lib/script/evntsave.c @@ -217,7 +217,7 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize) } // load the context information for the script system -static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize, BOOL bHashed) +static BOOL eventLoadContext(const SDWORD version, char *pBuffer, UDWORD *pSize, BOOL bHashed) { UDWORD size, valSize,stringLen; SDWORD numVars, i, numContext, context; @@ -506,15 +506,13 @@ static BOOL eventSaveTriggerList(ACTIVE_TRIGGER *psList, char *pBuffer, UDWORD * // load a list of triggers -static BOOL eventLoadTriggerList(SDWORD version, char *pBuffer, UDWORD *pSize) +static BOOL eventLoadTriggerList(const SDWORD version, char *pBuffer, UDWORD *pSize) { UDWORD size, event, offset, time; char *pPos; SDWORD numTriggers, context, type, trigger, i; SCRIPT_CONTEXT *psContext; - version = version; - size = 0; pPos = pBuffer; diff --git a/src/scriptobj.c b/src/scriptobj.c index d639ea5af..9b97d5b55 100644 --- a/src/scriptobj.c +++ b/src/scriptobj.c @@ -1264,32 +1264,29 @@ BOOL scrValDefLoad(SDWORD version, INTERP_VAL *psVal, char *pBuffer, UDWORD size pPos = pBuffer; - switch (version) + if (version < 2) { - case 1: - members = size / sizeof(UDWORD); - break; - case 2: - members = (size - sizeof(SDWORD)*4) / sizeof(UDWORD); - break; - case 3: - members = (size - sizeof(SDWORD)*6) / sizeof(UDWORD); + members = size / sizeof(UDWORD); + } + else if (version < 3) + { + members = (size - sizeof(SDWORD)*4) / sizeof(UDWORD); + } + else + { + members = (size - sizeof(SDWORD)*6) / sizeof(UDWORD); - // get saved group member count/nullpointer flag - endian_sdword((SDWORD*)pPos); - bObjectDefined = ( *((SDWORD *)pPos) != UNALLOCATED_OBJECT ); + // get saved group member count/nullpointer flag + endian_sdword((SDWORD*)pPos); + bObjectDefined = ( *((SDWORD *)pPos) != UNALLOCATED_OBJECT ); - if(bObjectDefined) - { - savedMembers = *((SDWORD *)pPos); // get number of saved group members + if(bObjectDefined) + { + savedMembers = *((SDWORD *)pPos); // get number of saved group members - ASSERT(savedMembers == members, "scrValDefLoad: calculated and saved group member count did not match." ); - } - pPos += sizeof(SDWORD); - break; - default: - members = 0; - debug( LOG_ERROR, "scrValDefLoad: unsupported version %i", version); + ASSERT(savedMembers == members, "scrValDefLoad: calculated and saved group member count did not match." ); + } + pPos += sizeof(SDWORD); } // make sure group was allocated when it was saved (relevant starting from version 3)