From: black Date: Wed, 25 May 2005 09:07:38 +0000 (+0000) Subject: -LoadProgs now expects to be called after InitProg, so it wont do any X-Git-Tag: xonotic-v0.1.0preview~4841 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7346f55327816ed5eeef2756c426c0ecc2c06cb6;p=xonotic%2Fdarkplaces.git -LoadProgs now expects to be called after InitProg, so it wont do any unnecessary clean-ups. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5340 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/progsvm.h b/progsvm.h index 4f51861b..d702a7dc 100644 --- a/progsvm.h +++ b/progsvm.h @@ -241,7 +241,7 @@ typedef void (*prvm_builtin_t) (void); // [INIT] variables flagged with this token can be initialized by 'you' // NOTE: external code has to create and free the mempools but everything else is done by prvm ! -typedef struct vm_prog_s +typedef struct prvm_prog_s { dprograms_t *progs; mfunction_t *functions; @@ -386,7 +386,6 @@ void VM_Cmd_Reset(void); void PRVM_Init (void); void PRVM_ExecuteProgram (func_t fnum, const char *errormessage); -void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_func); #define PRVM_Alloc(buffersize) _PRVM_Alloc(buffersize, __FILE__, __LINE__) #define PRVM_Free(buffer) _PRVM_Free(buffer, __FILE__, __LINE__) @@ -486,14 +485,22 @@ void PRVM_FreeString(char *s); // other prog handling functions qboolean PRVM_SetProgFromString(const char *str); -void PRVM_SetProg(int prognr); +void PRVM_SetProg(int prognr); -void PRVM_InitProg(int prognr); -void PRVM_ResetProg(void); +/* +Initializing a vm: +Call InitProg with the num +Set up the fields marked with [INIT] in the prog struct +Load a program with LoadProgs +*/ +void PRVM_InitProg(int prognr); +// LoadProgs expects to be called right after InitProg +void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_func); +void PRVM_ResetProg(void); qboolean PRVM_ProgLoaded(int prognr); -int PRVM_GetProgNr(void); +int PRVM_GetProgNr(void); // TODO: fill in the params diff --git a/prvm_edict.c b/prvm_edict.c index e38e0782..53f7e5d2 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1220,9 +1220,9 @@ PRVM_ResetProg void PRVM_ResetProg() { + PRVM_GCALL(reset_cmd)(); Mem_FreePool(&prog->progs_mempool); memset(prog,0,sizeof(prvm_prog_t)); - PRVM_GCALL(reset_cmd)(); } /* @@ -1237,8 +1237,6 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required ddef_t *infielddefs; dfunction_t *dfunctions; - Mem_EmptyPool(prog->progs_mempool); - prog->progs = (dprograms_t *)FS_LoadFile (filename, prog->progs_mempool, false); if (prog->progs == NULL) PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME); @@ -1472,10 +1470,6 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required && prog->flag && prog->self) prog->flag |= PRVM_OP_STATE; - if( prog->loaded ) { - PRVM_GCALL(reset_cmd)(); - } - prog->loaded = TRUE; PRVM_GCALL(init_cmd)(); // init mempools