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(); objListIntegCheck();
#endif #endif
// tell the script system about any destroyed objects
if (psDestroyedObj != NULL)
{
scrvUpdateBasePointers();
}
/* Go through the destroyed objects list looking for objects that /* Go through the destroyed objects list looking for objects that
were destroyed before this turn */ were destroyed before this turn */

View File

@ -2297,42 +2297,6 @@ BOOL scrTabInitialise(void)
scriptSetTypeEquiv(asEquivTable); scriptSetTypeEquiv(asEquivTable);
// Set the create and release functions // 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)) if (!eventAddValueCreate((INTERP_TYPE)ST_GROUP, scrvNewGroup))
{ {
return false; return false;

View File

@ -48,16 +48,10 @@ typedef struct _scrv_store
// The list of script contexts // The list of script contexts
static SCRV_STORE *psContextStore=NULL; 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 // Initialise the script value module
BOOL scrvInitialise(void) BOOL scrvInitialise(void)
{ {
psContextStore = NULL; psContextStore = NULL;
memset(asBasePointers, 0, sizeof(asBasePointers));
return true; return true;
} }
@ -75,7 +69,6 @@ void scrvShutDown(void)
} }
} }
// reset the script value module // reset the script value module
void scrvReset(void) void scrvReset(void)
{ {
@ -88,31 +81,18 @@ void scrvReset(void)
free(psCurr->pIDString); free(psCurr->pIDString);
free(psCurr); free(psCurr);
} }
psContextStore = NULL; psContextStore = NULL;
memset(asBasePointers, 0, sizeof(asBasePointers));
} }
// Add a new context to the list // Add a new context to the list
BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type) BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
{ {
SCRV_STORE *psNew; SCRV_STORE *psNew;
psNew = (SCRV_STORE*)malloc(sizeof(SCRV_STORE)); psNew = (SCRV_STORE*)malloc(sizeof(SCRV_STORE));
if (!psNew) ASSERT_OR_RETURN(false, psNew, "Out of memory");
{
debug( LOG_FATAL, "scrvAddContext: Out of memory" );
abort();
return false;
}
psNew->pIDString = (char*)malloc(strlen(pID) + 1); psNew->pIDString = (char*)malloc(strlen(pID) + 1);
if (!psNew->pIDString) ASSERT_OR_RETURN(false, psNew->pIDString, "Out of memory");
{
debug( LOG_FATAL, "scrvAddContext: Out of memory" );
abort();
return false;
}
strcpy(psNew->pIDString, pID); strcpy(psNew->pIDString, pID);
psNew->type = type; psNew->type = type;
psNew->psContext = psContext; psNew->psContext = psContext;
@ -123,63 +103,6 @@ BOOL scrvAddContext(char *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type)
return true; 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 // create a group structure for a ST_GROUP variable
BOOL scrvNewGroup(INTERP_VAL *psVal) BOOL scrvNewGroup(INTERP_VAL *psVal)
{ {
@ -198,7 +121,6 @@ BOOL scrvNewGroup(INTERP_VAL *psVal)
return true; return true;
} }
// release a ST_GROUP variable // release a ST_GROUP variable
void scrvReleaseGroup(INTERP_VAL *psVal) void scrvReleaseGroup(INTERP_VAL *psVal)
{ {
@ -207,8 +129,7 @@ void scrvReleaseGroup(INTERP_VAL *psVal)
psGroup = (DROID_GROUP*)psVal->v.oval; psGroup = (DROID_GROUP*)psVal->v.oval;
grpReset(psGroup); grpReset(psGroup);
ASSERT( psGroup->refCount == 1, ASSERT(psGroup->refCount == 1, "Reference count is wrong");
"scrvReleaseGroup: ref count is wrong" );
// do a final grpLeave to free the group // do a final grpLeave to free the group
grpLeave(psGroup, NULL); 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 ); ASSERT(false, "Could not find context for id: %s", pID);
abort();
return false; 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 // Get a context from the list
extern BOOL scrvGetContext(char *pID, SCRIPT_CONTEXT **ppsContext); 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 // create a group structure for a ST_GROUP variable
extern BOOL scrvNewGroup(INTERP_VAL *psVal); extern BOOL scrvNewGroup(INTERP_VAL *psVal);
@ -107,7 +98,4 @@ extern void scrvReset(void);
// Load a script value file // Load a script value file
extern BOOL scrvLoad(PHYSFS_file* fileHandle); extern BOOL scrvLoad(PHYSFS_file* fileHandle);
// Link any object types to the actual pointer values
//extern BOOL scrvLinkValues(void);
#endif // __INCLUDED_SRC_SCRIPTVALS_H__ #endif // __INCLUDED_SRC_SCRIPTVALS_H__