Remove a ton of unused, script-related code, and lift the needless limit on 2000 globals for all scripts combined.

master
Per Inge Mathisen 2011-01-10 18:39:44 +01:00
parent 87c358545d
commit 992844f3b5
4 changed files with 4 additions and 138 deletions

View File

@ -136,12 +136,6 @@ void objmemUpdate(void)
objListIntegCheck();
#endif
// tell the script system about any destroyed objects
if (psDestroyedObj != NULL)
{
scrvUpdateBasePointers();
}
/* Go through the destroyed objects list looking for objects that
were destroyed before this turn */

View File

@ -2297,42 +2297,6 @@ BOOL scrTabInitialise(void)
scriptSetTypeEquiv(asEquivTable);
// Set the create and release functions
if (!eventAddValueCreate((INTERP_TYPE)ST_BASEOBJECT, scrvAddBasePointer))
{
return false;
}
if (!eventAddValueRelease((INTERP_TYPE)ST_BASEOBJECT, scrvReleaseBasePointer))
{
return false;
}
if (!eventAddValueCreate((INTERP_TYPE)ST_DROID, scrvAddBasePointer))
{
return false;
}
if (!eventAddValueRelease((INTERP_TYPE)ST_DROID, scrvReleaseBasePointer))
{
return false;
}
if (!eventAddValueCreate((INTERP_TYPE)ST_STRUCTURE, scrvAddBasePointer))
{
return false;
}
if (!eventAddValueRelease((INTERP_TYPE)ST_STRUCTURE, scrvReleaseBasePointer))
{
return false;
}
if (!eventAddValueCreate((INTERP_TYPE)ST_FEATURE, scrvAddBasePointer))
{
return false;
}
if (!eventAddValueRelease((INTERP_TYPE)ST_FEATURE, scrvReleaseBasePointer))
{
return false;
}
if (!eventAddValueCreate((INTERP_TYPE)ST_GROUP, scrvNewGroup))
{
return false;

View File

@ -48,16 +48,10 @@ typedef struct _scrv_store
// The list of script contexts
static SCRV_STORE *psContextStore=NULL;
// keep a note of all base object pointers
#define MAX_BASEPOINTER 2000 //200 - local variables require more of these ("run" error)
static INTERP_VAL *asBasePointers[MAX_BASEPOINTER];
// Initialise the script value module
BOOL scrvInitialise(void)
{
psContextStore = NULL;
memset(asBasePointers, 0, sizeof(asBasePointers));
return true;
}
@ -75,7 +69,6 @@ void scrvShutDown(void)
}
}
// reset the script value module
void scrvReset(void)
{
@ -88,31 +81,18 @@ void scrvReset(void)
free(psCurr->pIDString);
free(psCurr);
}
psContextStore = NULL;
memset(asBasePointers, 0, sizeof(asBasePointers));
}
// Add a new context to the list
BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
{
SCRV_STORE *psNew;
psNew = (SCRV_STORE*)malloc(sizeof(SCRV_STORE));
if (!psNew)
{
debug( LOG_FATAL, "scrvAddContext: Out of memory" );
abort();
return false;
}
ASSERT_OR_RETURN(false, psNew, "Out of memory");
psNew->pIDString = (char*)malloc(strlen(pID) + 1);
if (!psNew->pIDString)
{
debug( LOG_FATAL, "scrvAddContext: Out of memory" );
abort();
return false;
}
ASSERT_OR_RETURN(false, psNew->pIDString, "Out of memory");
strcpy(psNew->pIDString, pID);
psNew->type = type;
psNew->psContext = psContext;
@ -123,63 +103,6 @@ BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
return true;
}
// Add a new base pointer variable
BOOL scrvAddBasePointer(INTERP_VAL *psVal)
{
SDWORD i;
for(i=0; i<MAX_BASEPOINTER; i++)
{
if (asBasePointers[i] == NULL)
{
asBasePointers[i] = psVal;
return true;
}
}
ASSERT(false, "scrvAddBasePointer: not enough base pointers left (total :%d)", MAX_BASEPOINTER);
return false;
}
// remove a base pointer from the list
void scrvReleaseBasePointer(INTERP_VAL *psVal)
{
SDWORD i;
for(i=0; i<MAX_BASEPOINTER; i++)
{
if (asBasePointers[i] == psVal)
{
asBasePointers[i] = NULL;
return;
}
}
}
// Check all the base pointers to see if they have died
void scrvUpdateBasePointers(void)
{
unsigned int i;
for(i = 0; i < MAX_BASEPOINTER; i++)
{
if (asBasePointers[i] != NULL)
{
INTERP_VAL *psVal = asBasePointers[i];
BASE_OBJECT *psObj = (BASE_OBJECT *)psVal->v.oval;
if (psObj && isDead(psObj))
{
psVal->v.oval = NULL;
}
}
}
}
// create a group structure for a ST_GROUP variable
BOOL scrvNewGroup(INTERP_VAL *psVal)
{
@ -198,7 +121,6 @@ BOOL scrvNewGroup(INTERP_VAL *psVal)
return true;
}
// release a ST_GROUP variable
void scrvReleaseGroup(INTERP_VAL *psVal)
{
@ -207,8 +129,7 @@ void scrvReleaseGroup(INTERP_VAL *psVal)
psGroup = (DROID_GROUP*)psVal->v.oval;
grpReset(psGroup);
ASSERT( psGroup->refCount == 1,
"scrvReleaseGroup: ref count is wrong" );
ASSERT(psGroup->refCount == 1, "Reference count is wrong");
// do a final grpLeave to free the group
grpLeave(psGroup, NULL);
@ -229,7 +150,6 @@ BOOL scrvGetContext(char *pID, SCRIPT_CONTEXT **ppsContext)
}
}
debug( LOG_FATAL, "scrvGetContext: couldn't find context for id: %s", pID );
abort();
ASSERT(false, "Could not find context for id: %s", pID);
return false;
}

View File

@ -80,15 +80,6 @@ extern BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
// Get a context from the list
extern BOOL scrvGetContext(char *pID, SCRIPT_CONTEXT **ppsContext);
// Add a new base pointer variable
extern BOOL scrvAddBasePointer(INTERP_VAL *psVal);
// Check all the base pointers to see if they have died
extern void scrvUpdateBasePointers(void);
// remove a base pointer from the list
extern void scrvReleaseBasePointer(INTERP_VAL *psVal);
// create a group structure for a ST_GROUP variable
extern BOOL scrvNewGroup(INTERP_VAL *psVal);
@ -107,7 +98,4 @@ extern void scrvReset(void);
// Load a script value file
extern BOOL scrvLoad(PHYSFS_file* fileHandle);
// Link any object types to the actual pointer values
//extern BOOL scrvLinkValues(void);
#endif // __INCLUDED_SRC_SCRIPTVALS_H__