]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move GetField_fullspawndata from miscfunctions.qc to main.qc
authorbones_was_here <bones_was_here@xa.org.au>
Fri, 25 Sep 2020 11:37:10 +0000 (21:37 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Fri, 25 Sep 2020 11:37:10 +0000 (21:37 +1000)
qcsrc/server/main.qc
qcsrc/server/miscfunctions.qc

index 3859ffa6f7e0b750452b5098db1fcf1232fa4bc2..8eb4c5c5ae5ce44a0ac7a6c8c4bbac131f977533 100644 (file)
@@ -368,6 +368,62 @@ void SV_OnEntityPreSpawnFunction(entity this)
        }
 }
 
+string GetField_fullspawndata(entity e, string f, ...)
+/* Retrieves the value of a map entity field from fullspawndata
+ * This bypasses field value changes made by the engine,
+ * eg string-to-float and escape sequence substitution.
+ *
+ * Avoids the need to declare fields just to read them once :)
+ *
+ * Returns the last instance of the field to match DarkPlaces behaviour.
+ * Path support: converts \ to / and tests the file if a third (bool, true) arg is passed.
+ * Returns string_null if the entity does not have the field, or the file is not in the VFS.
+ *
+ * FIXME: entities with //comments are not supported.
+ */
+{
+       string v = string_null;
+
+       if (!e.fullspawndata)
+       {
+               LOG_WARNF("^1EDICT %s (classname %s) has no fullspawndata, engine lacks support?", ftos(num_for_edict(e)), e.classname);
+               return v;
+       }
+
+       if (strstrofs(e.fullspawndata, "//", 0) >= 0)
+       {
+               // tokenize and tokenize_console return early if "//" is reached,
+               // which can leave an odd number of tokens and break key:value pairing.
+               LOG_WARNF("^1EDICT %s fullspawndata contains unsupported //comment^7%s", ftos(num_for_edict(e)), e.fullspawndata);
+               return v;
+       }
+
+       //print(sprintf("%s(EDICT %s, FIELD %s)\n", __FUNC__, ftos(num_for_edict(e)), f));
+       //print(strcat("FULLSPAWNDATA:", e.fullspawndata, "\n"));
+
+       // tokenize treats \ as an escape, but tokenize_console returns the required literal
+       for (int t = tokenize_console(e.fullspawndata) - 3; t > 0; t -= 2)
+       {
+               //print(sprintf("\tTOKEN %s:%s\t%s:%s\n", ftos(t), ftos(t + 1), argv(t), argv(t + 1)));
+               if (argv(t) == f)
+               {
+                       v = argv(t + 1);
+                       break;
+               }
+       }
+
+       //print(strcat("RESULT: ", v, "\n\n"));
+
+       if (v && ...(0, bool) == true)
+       {
+               v = strreplace("\\", "/", v);
+               if (whichpack(v) == "")
+                       return string_null;
+       }
+
+       return v;
+}
+
 void WarpZone_PostInitialize_Callback()
 {
        // create waypoint links for warpzones
index f910b9f912a90cce221387ba4dfbff60c18b604e..d45131837bb8a8e600e0a67c39dd2682c6093f64 100644 (file)
@@ -317,59 +317,3 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f
 {
        return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance);
 }
-
-string GetField_fullspawndata(entity e, string f, ...)
-/* Retrieves the value of a map entity field from fullspawndata
- * This bypasses field value changes made by the engine,
- * eg string-to-float and escape sequence substitution.
- *
- * Avoids the need to declare fields just to read them once :)
- *
- * Returns the last instance of the field to match DarkPlaces behaviour.
- * Path support: converts \ to / and tests the file if a third (bool, true) arg is passed.
- * Returns string_null if the entity does not have the field, or the file is not in the VFS.
- *
- * FIXME: entities with //comments are not supported.
- */
-{
-       string v = string_null;
-
-       if (!e.fullspawndata)
-       {
-               LOG_WARNF("^1EDICT %s (classname %s) has no fullspawndata, engine lacks support?", ftos(num_for_edict(e)), e.classname);
-               return v;
-       }
-
-       if (strstrofs(e.fullspawndata, "//", 0) >= 0)
-       {
-               // tokenize and tokenize_console return early if "//" is reached,
-               // which can leave an odd number of tokens and break key:value pairing.
-               LOG_WARNF("^1EDICT %s fullspawndata contains unsupported //comment^7%s", ftos(num_for_edict(e)), e.fullspawndata);
-               return v;
-       }
-
-       //print(sprintf("%s(EDICT %s, FIELD %s)\n", __FUNC__, ftos(num_for_edict(e)), f));
-       //print(strcat("FULLSPAWNDATA:", e.fullspawndata, "\n"));
-
-       // tokenize treats \ as an escape, but tokenize_console returns the required literal
-       for (int t = tokenize_console(e.fullspawndata) - 3; t > 0; t -= 2)
-       {
-               //print(sprintf("\tTOKEN %s:%s\t%s:%s\n", ftos(t), ftos(t + 1), argv(t), argv(t + 1)));
-               if (argv(t) == f)
-               {
-                       v = argv(t + 1);
-                       break;
-               }
-       }
-
-       //print(strcat("RESULT: ", v, "\n\n"));
-
-       if (v && ...(0, bool) == true)
-       {
-               v = strreplace("\\", "/", v);
-               if (whichpack(v) == "")
-                       return string_null;
-       }
-
-       return v;
-}