From 4c2b37c34da33566bc2f6b34d9ef0bfd16604cba Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Fri, 22 Oct 2021 21:20:22 +0200 Subject: [PATCH] NSEntity: Save/Restore behaviour for some more fields. --- src/gs-entbase/shared/NSEntity.qc | 21 ++++++++++++++++++++ src/server/entry.qc | 33 ++++++++++++++++++------------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/gs-entbase/shared/NSEntity.qc b/src/gs-entbase/shared/NSEntity.qc index 6d5947c6..95e8819b 100644 --- a/src/gs-entbase/shared/NSEntity.qc +++ b/src/gs-entbase/shared/NSEntity.qc @@ -352,8 +352,14 @@ void NSEntity::Save(float handle) { SaveVector(handle, "origin", origin); + SaveVector(handle, "absmin", absmin); + SaveVector(handle, "absmax", absmax); + SaveVector(handle, "mins", mins); + SaveVector(handle, "maxs", mins); SaveString(handle, "model", model); SaveVector(handle, "angles", angles); + SaveFloat(handle, "solid", solid); + SaveFloat(handle, "movetype", movetype); SaveString(handle, "targetname", targetname); SaveString(handle, "target", target); SaveFloat(handle, "health", health); @@ -368,6 +374,18 @@ NSEntity::Restore(string strKey, string strValue) case "origin": origin = stov(strValue); break; + case "absmin": + absmin = stov(strValue); + break; + case "absmax": + absmax = stov(strValue); + break; + case "mins": + mins = stov(strValue); + break; + case "maxs": + maxs = stov(strValue); + break; case "model": model = strValue; break; @@ -377,6 +395,9 @@ NSEntity::Restore(string strKey, string strValue) case "solid": solid = stof(strValue); break; + case "movetype": + movetype = stof(strValue); + break; case "targetname": targetname = strValue; break; diff --git a/src/server/entry.qc b/src/server/entry.qc index e8ec6e8a..14add4e1 100644 --- a/src/server/entry.qc +++ b/src/server/entry.qc @@ -653,6 +653,7 @@ SV_ShouldPause(float newstatus) return newstatus; } +//#define REEDICT 0 void SV_PerformLoad(float fh) { @@ -660,40 +661,42 @@ SV_PerformLoad(float fh) entity eold; string l; float n; - e = world; + NSEntity loadent; int braced; - NSEntity loadent; -/* +#ifdef REEDICT while ((e=nextent(e))) { if (edict_num(1) != e) remove(e); } -*/ +#else + entity e = world; +#endif -#if 1 /* read line per line of our file handle */ while ((l=fgets(fh))) { - float args = tokenize(l); + float args = tokenize_console(l); if (!args) break; if (argv(0) == "ENTITY") { string cname; +#ifndef REEDICT n = stof(argv(1)); - cname = argv(2); e = edict_num(n); +#else + entity e = spawn(); +#endif + cname = argv(2); loadent = __NULL__; __fullspawndata = fgets(fh); - print(sprintf("Try spawning %s\n", cname)); /* call the constructor if one is present, init the default fields */ if (isfunction(strcat("spawnfunc_", cname))) { e.classname = cname; - print(sprintf("I'm actually spawning %s\n", cname)); eold = self; self = e; @@ -707,19 +710,21 @@ SV_PerformLoad(float fh) continue; } } else if (argv(0) == "{") { - braced++; } else if (argv(0) == "}") { - braced--; - } else if (braced == 1) { + if (loadent) { + loadent.Respawn(); + loadent = __NULL__; + } + } else { if (loadent) { int c = tokenize(l); - if (c == 2) + if (c == 2) { loadent.Restore(argv(0), argv(1)); + } } } } -#endif } void