Forum

Some update on old engine

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.

Moderator: InsideQC Admins

Some update on old engine

Postby revelator » Wed May 15, 2013 10:35 pm

Managed to squeeze in a few days Work on my tenebrae lite engine and i can report that i finally fixed the damn edo parser (newer worked for lights).

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


Engine now also sports GLSL Water shaders instead of the hardcoded crap that was used :)

Mirror code removed completely as well as the caustics (code was a mess and the mirror code newer worked correctly).

Image

Image

Future plans. Put caustics back in and fix more bugs.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2542
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Some update on old engine

Postby leileilol » Wed May 15, 2013 10:43 pm

How's that red light on the button being created? Does it switch to green?
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Some update on old engine

Postby revelator » Wed May 15, 2013 11:14 pm

It uses a cubemap as a halo object, does not change to green but is probably possible to get that effect it does pulsate though :).
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2542
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest