Wren testing

This commit is contained in:
iikorni
2026-09-03 22:18:23 -05:00
parent f1c99067d8
commit 1a0dad769c
49 changed files with 14712 additions and 72 deletions
+15 -3
View File
@@ -21,9 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// sv_edict.c -- entity dictionary
#include <fstream>
#include <sstream>
#include "pr_wren.hpp"
#include "quakedef.hpp"
#include "wren.hpp"
dprograms_t *progs;
dfunction_t *pr_functions;
@@ -1006,6 +1009,7 @@ void ED_LoadFromFile (const char *data)
pr_global_struct->time = sv.time;
std::istringstream ss{data};
sv.wentities = std::map<int, WrenHandle*>{};
// parse ents
@@ -1022,8 +1026,12 @@ void ED_LoadFromFile (const char *data)
ent = EDICT_NUM(0);
else
ent = ED_Alloc ();
std::istringstream copy{data};
copy.seekg(ss.tellg());
ED_ParseEdict (ss, ent);
auto vars = wren::parse_fields(copy);
// remove things from different skill levels or deathmatch
if (deathmatch.value)
{
@@ -1069,6 +1077,11 @@ void ED_LoadFromFile (const char *data)
pr_global_struct->self = EDICT_TO_PROG(ent);
PR_ExecuteProgram (func - pr_functions);
auto e = wren::create_entity(PR_GetString(ent->v.classname), vars);
if (e.has_value()) {
ent->wid = e->first;
sv.wentities[e->first] = e->second;
}
}
console::debug ("%i entities inhibited\n", inhibit);
@@ -1175,7 +1188,7 @@ void PR_LoadProgs (void)
for (i = 0; i < GEFV_CACHESIZE; i++)
gefvCache[i].field[0] = 0;
CRC_Init (&pr_crc);
crc::init (&pr_crc);
progs = (dprograms_t *)COM_LoadHunkFile ("progs.dat", NULL);
if (!progs)
@@ -1183,7 +1196,7 @@ void PR_LoadProgs (void)
console::debug ("Programs occupy %iK.\n", com_filesize/1024);
for (i = 0; i < com_filesize; i++)
CRC_ProcessByte (&pr_crc, ((byte *)progs)[i]);
crc::process_byte (&pr_crc, ((byte *)progs)[i]);
// byte swap the header
for (i = 0; i < (int) sizeof(*progs) / 4; i++)
@@ -1296,7 +1309,6 @@ void PR_Init (void)
saved4.inscribe();
}
edict_t *EDICT_NUM(int n)
{
if (n < 0 || n >= sv.max_edicts)