NSEntity: Save/Restore behaviour for some more fields.

This commit is contained in:
Marco Cawthorne 2021-10-22 21:20:22 +02:00
parent fa5cdd5a80
commit 4c2b37c34d
Signed by: eukara
GPG key ID: C196CD8BA993248A
2 changed files with 40 additions and 14 deletions

View file

@ -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;

View file

@ -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