From: cloudwalk Date: Wed, 15 Jul 2020 02:44:19 +0000 (+0000) Subject: prvm_edict: Implement __fullspawndata. Testing only; don't use in production yet X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=68cf35fc5c0db38772f437f144f2f40d18c903d5;p=xonotic%2Fdarkplaces.git prvm_edict: Implement __fullspawndata. Testing only; don't use in production yet http://icculus.org/finger/marco?date=2019-01-25&time=05-38-02 The idea of exposing these key/value pairs to QC is great but perhaps a a better, cleaner method could be used down the road. But this has to be kept for FTE compatibility. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12813 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc index 9cdeb695..05812846 100644 --- a/dpdefs/dpextensions.qc +++ b/dpdefs/dpextensions.qc @@ -2616,3 +2616,10 @@ float MOVETYPE_USER_LAST = 191; .float clipgroup; //description: //If two entities have this field set to the same non-zero integer value, they won't collide with each other. + +//idea: eukara +//darkplaces implementation: Cloudwalk +// Do NOT use in production yet. +string __fullspawndata; +//description: +// http://icculus.org/finger/marco?date=2019-01-25&time=05-38-02 diff --git a/prvm_edict.c b/prvm_edict.c index 9a14bef9..720bd6d1 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1367,7 +1367,10 @@ to call PRVM_ED_CallSpawnFunctions () to let the objects initialize themselves. void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) { prvm_edict_t *ent; + const char *start; int parsed, inhibited, spawned, died; + ddef_t *fulldata_ddef = NULL; + prvm_eval_t *fulldata = NULL; const char *funcname; mfunction_t *func; char vabuf[1024]; @@ -1400,7 +1403,7 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) // clear it if (ent != prog->edicts) // hack memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t)); - + start = data; data = PRVM_ED_ParseEdict (prog, data, ent); parsed++; @@ -1438,6 +1441,32 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) PRVM_ED_Free (prog, ent); continue; } + /* + * This is required for FTE compatibility (FreeCS). + * It copies the key/value pairs themselves into a + * global for QC to parse on its own. + */ + else + { + fulldata_ddef = PRVM_ED_FindGlobal(prog, "__fullspawndata"); + if(fulldata_ddef) + fulldata = (prvm_eval_t *) &prog->globals.fp[fulldata_ddef->ofs]; + if(fulldata) + { + const char *in; + char *spawndata; + fulldata->string = PRVM_AllocString(prog, data - start + 1, &spawndata); + for(in = start; in < data; ) + { + char c = *in++; + if(c == '\n') + *spawndata++ = '\t'; + else + *spawndata++ = c; + } + *spawndata = 0; + } + } // look for the spawn function funcname = PRVM_GetString(prog, PRVM_alledictstring(ent, classname));