The problem was mostly that the parser exited early because of worldspawn but i needed the data for "classname" "light" etc. for it to Work, so i rolled my own parser and also fixed the fubared fog when comming out of Water.
heres the beast.
Code: Select all
/*
==================
CL_ParseEntityLump
Parse entity data
==================
*/
void CL_ParseEntityLump(void)
{
int i;
char *data;
char key[128], value[4096];
entity_t *ent;
// load skies early
R_LoadSkys();
// copy of the static entities parser
i = cl.num_statics;
if (i >= MAX_STATIC_ENTITIES)
{
Host_Error ("Too many static entities");
}
ent = &cl_static_entities[i];
cl.num_statics++;
// get data
data = cl.worldmodel->entities;
// parse
if (!data)
{
return;
}
data = COM_Parse(data);
if (!data)
{
return; // valid exit
}
if (com_token[0] != '{')
{
Con_Printf("CL_ParseEntityLump: Failed Parsing opening brace\n");
return; // error
}
while (1)
{
data = COM_Parse(data);
if (!data)
{
return; // error
}
// FIXME: change light to _light to get rid of this hack
if (!strcmp(com_token, "light"))
{
strcpy (com_token, "light_lev"); // hack for single light def
}
strcpy(key, com_token);
while (key[strlen(key)-1] == ' ') // remove trailing spaces
{
key[strlen(key)-1] = 0;
}
data = COM_Parse(data);
if (!data)
{
return; // error
}
// moved here because we need to parse classname beyond worldspawn
if (com_token[0] == '}')
{
return; // error
}
strcpy(value, com_token);
// argh quake uses "light" as a token for both ("classname" "light") and ("light").
if (!strcmp(key, "_noautolight"))
{
Con_Printf("Autolight: Disabled\n");
break;
}
if (!strcmp(key, "_lightmapbright"))
{
lightmap_brightness = atof(value);
}
else if (!strcmp(key, "light_lev"))
{
ent->light_lev = atoi(value);
}
else if (!strcmp(key, "model"))
{
ent->model = Mod_ForName(value, true);
}
else if (!strcmp(key, "skin"))
{
ent->skinnum = atoi(value);
}
else if (!strcmp(key, "style"))
{
ent->style = atoi(value);
}
else if (!strcmp(key, "origin"))
{
COM_ParseVector(value, ent->origin);
}
else if (!strcmp(key, "angles"))
{
COM_ParseVector(value, ent->angles);
}
else if (!strcmp(key, "color"))
{
COM_ParseVector(value, ent->color);
}
else if (!strcmp(key, "_skybox"))
{
strcpy(skybox_name, value);
}
else if (!strcmp(key, "_cloudspeed"))
{
skybox_cloudspeed = atof(value);
}
else if (!strcmp(key, "_fog_color"))
{
vec3_t fogcolor;
COM_ParseVector(value, fogcolor);
Cvar_SetValue("fog_r", fogcolor[0]);
Cvar_SetValue("fog_g", fogcolor[1]);
Cvar_SetValue("fog_b", fogcolor[2]);
}
else if (!strcmp(key, "_fog_start"))
{
Cvar_Set("fog_start", value);
if (!fog_start.value)
{
Cvar_SetValue ("fog_enabled", 0.0f);
}
}
else if (!strcmp(key, "_fog_end"))
{
Cvar_Set("fog_end", value);
if (!fog_end.value)
{
Cvar_SetValue ("fog_enabled", 0.0f);
}
}
/* reckless aupport more light types */
if (!strcmp(key, "classname"))
{
if (!strcmp(value, "light") ||
!strcmp(value, "light_fluoro") ||
!strcmp(value, "light_fluorospark") ||
!strcmp(value, "light_torch_small_walltorch") ||
!strcmp(value, "light_flame_large_yellow") ||
!strcmp(value, "light_flame_small_yellow") ||
!strcmp(value, "light_flame_small_white"))
{
Con_Printf("Autolight: Enabled\n");
R_CalcSvBsp(ent);
break;
}
}
}
}
Mirror code removed completely as well as the caustics (code was a mess and the mirror code newer worked correctly).
Future plans. Put caustics back in and fix more bugs.