From 008d80df679dcc85f9f6057280906fba8509abe9 Mon Sep 17 00:00:00 2001 From: Bill Currie <bill@taniwha.org> Date: Wed, 5 Sep 2001 21:22:55 +0000 Subject: [PATCH] s/IMT_DEFAULT/IMT_0/g for the constant and move the name-enum entry for IMT_DEFAULT to the bottom of the list so that IMT_0 gets written as such rather than IMT_DEFAULT. Also, clean up nq's EF_* dlight creation a bit (haven't touched EF_MUZZLEFLASH: undecided on what to do). --- include/QF/keys.h | 2 +- libs/console/client.c | 2 +- libs/video/targets/keys.c | 13 ++++--- nq/source/cl_demo.c | 2 +- nq/source/cl_main.c | 80 +++++++++++++++++---------------------- nq/source/console.c | 2 +- qw/source/cl_main.c | 2 +- qw/source/console.c | 4 +- 8 files changed, 49 insertions(+), 58 deletions(-) diff --git a/include/QF/keys.h b/include/QF/keys.h index 94db5aae8..ebbff0d94 100644 --- a/include/QF/keys.h +++ b/include/QF/keys.h @@ -343,7 +343,7 @@ typedef struct typedef enum { IMT_CONSOLE, - IMT_DEFAULT, + IMT_0, IMT_1, IMT_2, IMT_3, diff --git a/libs/console/client.c b/libs/console/client.c index 591b023e6..28f60d367 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -109,7 +109,7 @@ Con_ToggleChat_f (void) if (cls.state == ca_active) */ key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; } else { key_dest = key_console; game_target = IMT_CONSOLE; diff --git a/libs/video/targets/keys.c b/libs/video/targets/keys.c index de33b9db6..31dcb673e 100644 --- a/libs/video/targets/keys.c +++ b/libs/video/targets/keys.c @@ -84,8 +84,7 @@ typedef struct { imtname_t imtnames[] = { {"IMT_CONSOLE", IMT_CONSOLE}, - {"IMT_DEFAULT", IMT_DEFAULT}, - {"IMT_0", IMT_DEFAULT}, + {"IMT_0", IMT_0}, {"IMT_1", IMT_1}, {"IMT_2", IMT_2}, {"IMT_3", IMT_3}, @@ -103,6 +102,8 @@ imtname_t imtnames[] = { {"IMT_15", IMT_15}, {"IMT_16", IMT_16}, + {"IMT_DEFAULT", IMT_0}, + {NULL, 0} }; @@ -427,8 +428,8 @@ Key_Game (knum_t key, short unicode) char cmd[1024]; kb = Key_GetBinding(game_target, key); - if (!kb && (game_target > IMT_DEFAULT)) - kb = Key_GetBinding(IMT_DEFAULT, key); + if (!kb && (game_target > IMT_0)) + kb = Key_GetBinding(IMT_0, key); /* Con_Printf("kb %p, game_target %d, key_dest %d, key %d\n", kb, @@ -606,7 +607,7 @@ Key_Message (knum_t key, short unicode) Cbuf_AddText ("\"\n"); key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; chat_bufferlen = 0; chat_buffer[0] = 0; return; @@ -614,7 +615,7 @@ Key_Message (knum_t key, short unicode) if (unicode == '\x1b' || key == K_ESCAPE) { key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; chat_bufferlen = 0; chat_buffer[0] = 0; return; diff --git a/nq/source/cl_demo.c b/nq/source/cl_demo.c index 9a2f1e04c..3ac6ea8c8 100644 --- a/nq/source/cl_demo.c +++ b/nq/source/cl_demo.c @@ -309,7 +309,7 @@ CL_PlayDemo_f (void) CL_SetState (ca_connected); cls.forcetrack = 0; key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; while ((c = Qgetc (cls.demofile)) != '\n') if (c == '-') diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 0c89a7c8e..3f9a87618 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -280,7 +280,7 @@ CL_EstablishConnection (const char *host) cls.signon = 0; // need all the signon messages // before playing key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; } /* @@ -409,40 +409,44 @@ SetPal (int i) } void -CL_NewDlight (int key, float x, float y, float z, float radius, float time, - int type) +CL_NewDlight (int key, vec3_t org, int effects) { + float radius; + float time = 0.1; dlight_t *dl; + static vec3_t normal = {0.4, 0.2, 0.05}; + static vec3_t red = {0.5, 0.05, 0.05}; + static vec3_t blue = {0.05, 0.05, 0.5}; + static vec3_t purple = {0.5, 0.05, 0.5}; + if (!(effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT))) + return; + + radius = 200 + (rand () & 31); dl = R_AllocDlight (key); - dl->origin[0] = x; - dl->origin[1] = y; - dl->origin[2] = z; + VectorCopy (org, dl->origin); + switch (effects & (EF_BLUE | EF_RED)) { + case EF_BLUE | EF_RED: + VectorCopy (purple, dl->color); + break; + case EF_BLUE: + VectorCopy (blue, dl->color); + break; + case EF_RED: + VectorCopy (red, dl->color); + break; + default: + VectorCopy (normal, dl->color); + break; + } + if (effects & EF_BRIGHTLIGHT) { + radius += 200; + dl->origin[2] += 16; + } else if (effects & EF_DIMLIGHT) { + time *= 0.001; + } dl->radius = radius; dl->die = cl.time + time; - switch (type) { - default: - case 0: - dl->color[0] = 0.4; - dl->color[1] = 0.2; - dl->color[2] = 0.05; - break; - case 1: // blue - dl->color[0] = 0.05; - dl->color[1] = 0.05; - dl->color[2] = 0.5; - break; - case 2: // red - dl->color[0] = 0.5; - dl->color[1] = 0.05; - dl->color[2] = 0.05; - break; - case 3: // purple - dl->color[0] = 0.5; - dl->color[1] = 0.05; - dl->color[2] = 0.5; - break; - } } /* @@ -593,21 +597,7 @@ CL_RelinkEntities (void) dl->color[1] = 0.1; dl->color[2] = 0.05; } - if ((ent->effects & (EF_BLUE | EF_RED)) == (EF_BLUE | EF_RED)) - CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2], - 200 + (rand () & 31), 0.1, 3); - if (ent->effects & EF_BLUE) - CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2], - 200 + (rand () & 31), 0.1, 1); - if (ent->effects & EF_RED) - CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2], - 200 + (rand () & 31), 0.1, 2); - if (ent->effects & EF_BRIGHTLIGHT) - CL_NewDlight (i, ent->origin[0], ent->origin[1], - ent->origin[2] + 16, 400 + (rand () & 31), 0.001, 0); - if (ent->effects & EF_DIMLIGHT) - CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2], - 200 + (rand () & 31), 0.001, 0); + CL_NewDlight (i, ent->origin, ent->effects); if (VectorDistance_fast(ent->msg_origins[1], ent->origin) > (256*256)) VectorCopy (ent ->origin, ent->msg_origins[1]); if (ent->model->flags & EF_ROCKET) { @@ -718,7 +708,7 @@ CL_SetState (cactive_t state) cls.state = state; if (cls.state == ca_active) { r_active = true; - game_target = IMT_DEFAULT; + game_target = IMT_0; key_dest = key_game; } else { r_active = false; diff --git a/nq/source/console.c b/nq/source/console.c index bdaf899f6..4670c176d 100644 --- a/nq/source/console.c +++ b/nq/source/console.c @@ -90,7 +90,7 @@ Con_ToggleConsole_f (void) if (key_dest == key_console) { if (cls.state == ca_active) { key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; } } else { key_dest = key_console; diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index f903d8f41..b0b89f074 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1074,7 +1074,7 @@ CL_SetState (cactive_t state) cls.state = state; if (cls.state == ca_active) { r_active = true; - game_target = IMT_DEFAULT; + game_target = IMT_0; key_dest = key_game; } else { r_active = false; diff --git a/qw/source/console.c b/qw/source/console.c index b04b593a4..06dfe6508 100644 --- a/qw/source/console.c +++ b/qw/source/console.c @@ -87,7 +87,7 @@ Con_ToggleConsole_f (void) if (key_dest == key_console) { if (cls.state == ca_active) { key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; } } else { key_dest = key_console; @@ -105,7 +105,7 @@ Con_ToggleChat_f (void) if (key_dest == key_console) { if (cls.state == ca_active) { key_dest = key_game; - game_target = IMT_DEFAULT; + game_target = IMT_0; } } else { key_dest = key_console;