]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
prvm_edict: Implement __fullspawndata. Testing only; don't use in production yet
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Jul 2020 02:44:19 +0000 (02:44 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Jul 2020 02:44:19 +0000 (02:44 +0000)
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

dpdefs/dpextensions.qc
prvm_edict.c

index 9cdeb695744219f529aed58e1636d992980b6c8f..05812846742975bf25bdcc7c6d22e15c8e9fc109 100644 (file)
@@ -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
index 9a14bef9a208795c3646cc396a44c72e5cee76d8..720bd6d17e3e986e98e33212444e3ce8bd593dd7 100644 (file)
@@ -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));