Skip to content

Commit

Permalink
POWERUP CAMERAS: basics working again
Browse files Browse the repository at this point in the history
Seems to have been enabled for 5 days in November 2005
  (QW-Group@b2d02eb#diff-b5d423e622646bcc125a3aa9008f2b591c0cf2c7cc67f5fa11506a93b26da439)
Can't find any other documentation or examples of
  it working

quad_time & pent_time were only set when on first spawn
  of first playthrough of demo
Will tie-in with QW-Group#126 & also
  https://www.quakeworld.nu/forum/topic/6562/108940

Not sure what the benefit of multiple cameras per powerup
  is (unless 4x multiview and showing different angles?)
  as quad & pent were tracked by stat, not by entity
  baseline etc
  • Loading branch information
meag committed Nov 2, 2020
1 parent 72f869c commit 198ea7a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 43 deletions.
1 change: 1 addition & 0 deletions cl_multiview.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// meag: for switching back to 3d resolution to draw the multiview outlines
#include "gl_model.h"
#include "gl_local.h"
#include "mvd_utils.h"

extern int glx, gly, glwidth, glheight;

Expand Down
11 changes: 8 additions & 3 deletions cl_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "utils.h"
#include "hud.h"
#include "hud_common.h"
#include "mvd_utils.h"

#ifdef X11_GAMMA_WORKAROUND
#include "tr_types.h"
Expand Down Expand Up @@ -889,7 +890,8 @@ static void V_AddViewWeapon(float bob)
cent->current.frame = view_message.weaponframe;
}

void V_CalcIntermissionRefdef (void) {
static void V_CalcIntermissionRefdef(void)
{
float old;

VectorCopy (cl.simorg, r_refdef.vieworg);
Expand All @@ -905,7 +907,7 @@ void V_CalcIntermissionRefdef (void) {
v_idlescale.value = old;
}

void V_CalcRefdef(void)
static void V_CalcRefdef(void)
{
vec3_t forward;
float bob;
Expand Down Expand Up @@ -963,8 +965,9 @@ void V_CalcRefdef(void)
r_refdef.viewangles[PITCH] += cl.punchangle * 0.5;
}

if (view_message.flags & PF_DEAD && (cl.stats[STAT_HEALTH] <= 0))
if (view_message.flags & PF_DEAD && (cl.stats[STAT_HEALTH] <= 0)) {
r_refdef.viewangles[ROLL] = 80; // dead view angle
}

//VULT CAMERAS
CameraUpdate(view_message.flags & PF_DEAD);
Expand Down Expand Up @@ -1020,6 +1023,8 @@ qbool V_PreRenderView(void)
V_CalcRefdef();
}

MVD_PowerupCam_Frame();

R_PushDlights();

r_refdef2.time = cl.time;
Expand Down
91 changes: 52 additions & 39 deletions mvd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ double gamestart_time;

double quad_time = 0;
double pent_time = 0;
int quad_is_active = 0;
int pent_is_active = 0;
int pent_mentioned = 0;
int quad_mentioned = 0;
qbool quad_is_active = false;
qbool pent_is_active = false;
powerup_cam_status_id powerup_cam_status = powerup_cam_inactive;
qbool powerup_cam_active[4];

Expand Down Expand Up @@ -228,15 +226,15 @@ cvar_t mvd_status_x = { "mvd_status_x","0" };
cvar_t mvd_status_y = { "mvd_status_y","0" };

// Powerup cams
cvar_t mvd_powerup_cam = { "mvd_powerup_cam","0" };
static cvar_t mvd_powerup_cam = { "mvd_powerup_cam", "0" };

cvar_t mvd_pc_quad_1 = { "mvd_pc_quad_1","1010 -300 150 13 135" };
cvar_t mvd_pc_quad_2 = { "mvd_pc_quad_2","350 -20 157 34 360" };
cvar_t mvd_pc_quad_3 = { "mvd_pc_quad_3","595 360 130 17 360" };
static cvar_t mvd_pc_quad_1 = { "mvd_pc_quad_1", "" };
static cvar_t mvd_pc_quad_2 = { "mvd_pc_quad_2", "" };
static cvar_t mvd_pc_quad_3 = { "mvd_pc_quad_3", "" };

cvar_t mvd_pc_pent_1 = { "mvd_pc_pent_1","1010 -300 150 13 135" };
cvar_t mvd_pc_pent_2 = { "mvd_pc_pent_2","1010 -300 150 13 135" };
cvar_t mvd_pc_pent_3 = { "mvd_pc_pent_3","1010 -300 150 13 135" };
static cvar_t mvd_pc_pent_1 = { "mvd_pc_pent_1", "" };
static cvar_t mvd_pc_pent_2 = { "mvd_pc_pent_2", "" };
static cvar_t mvd_pc_pent_3 = { "mvd_pc_pent_3", "" };

static cvar_t powerup_cam_cvars[4] = {
{ "mvd_pc_view_1", "" },
Expand Down Expand Up @@ -1321,10 +1319,11 @@ void MVD_Status_WP(int i, int* taken) {

void MVD_Stats_Cleanup(void)
{
quad_is_active = 0;
pent_is_active = 0;
quad_is_active = false;
pent_is_active = false;
powerup_cam_status = powerup_cam_inactive;
memset(powerup_cam_active, 0, sizeof(powerup_cam_active));
pent_time = quad_time = 0;
was_standby = true;
while (mvd_clocklist) {
MVD_ClockList_Remove(mvd_clocklist);
Expand Down Expand Up @@ -1501,25 +1500,25 @@ static void MVD_Stats_Gather_AlivePlayer(int player_index)
item->has = 1;

if (x == PENT_INFO && (powerup_cam_status == powerup_cam_quadpent_active || powerup_cam_status == powerup_cam_pent_active)) {
pent_mentioned = 0;
pent_is_active = 1;
pent_is_active = true;
powerup_cam_status -= powerup_cam_pent_active;
pent_time = cls.demopackettime;
}
if (x == QUAD_INFO && (powerup_cam_status == powerup_cam_quadpent_active || powerup_cam_status == powerup_cam_quad_active)) {
quad_mentioned = 0;
quad_is_active = 1;
quad_is_active = true;
powerup_cam_status -= powerup_cam_quad_active;
quad_time = cls.demopackettime;
}
mvd_new_info[i].mvdinfo.itemstats[x].starttime = cls.demopackettime;
mvd_new_info[i].mvdinfo.itemstats[x].count++;
}
if (mvd_new_info[i].mvdinfo.itemstats[x].has && !(mvd_new_info[i].p_info->stats[STAT_ITEMS] & mvd_wp_info[x].it)) {
mvd_new_info[i].mvdinfo.itemstats[x].has = 0;
if (x == QUAD_INFO && quad_is_active) {
quad_is_active = 0;
quad_is_active = false;
}
if (x == PENT_INFO && pent_is_active) {
pent_is_active = 0;
pent_is_active = false;
}
mvd_new_info[i].mvdinfo.itemstats[x].runs[mvd_new_info[i].mvdinfo.itemstats[x].run].starttime = mvd_new_info[i].mvdinfo.itemstats[x].starttime;
mvd_new_info[i].mvdinfo.itemstats[x].runs[mvd_new_info[i].mvdinfo.itemstats[x].run].time = cls.demopackettime - mvd_new_info[i].mvdinfo.itemstats[x].starttime;
Expand Down Expand Up @@ -1715,7 +1714,7 @@ int MVD_Stats_Gather(void)

if (x == QUAD_INFO && mvd_new_info[i].mvdinfo.itemstats[QUAD_INFO].has) {
if (mvd_new_info[i].mvdinfo.itemstats[x].starttime - cls.demopackettime < 30) {
quad_is_active = 0;
quad_is_active = false;
}
mvd_new_info[i].mvdinfo.itemstats[x].run++;
mvd_new_info[i].mvdinfo.itemstats[x].lost++;
Expand All @@ -1737,17 +1736,9 @@ int MVD_Stats_Gather(void)
}

if ((((pent_time + 300) - cls.demopackettime) < 5) && !pent_is_active) {
if (!pent_mentioned) {
pent_mentioned = 1;
// fixme
// Com_Printf("pent in 5 secs\n");
}
powerup_cam_status |= powerup_cam_pent_active;
}
if ((((quad_time + 60) - cls.demopackettime) < 5) && !quad_is_active) {
if (!quad_mentioned) {
quad_mentioned = 1;
}
powerup_cam_status |= powerup_cam_quad_active;
}
mvd_new_info[i].mvdinfo.initialized = true;
Expand Down Expand Up @@ -2017,17 +2008,18 @@ static qbool MVD_PowerupCam_Process(cvar_t* cvar)
qbool found = false;

for (i = 0; i < 6; i++) {
if (!(cam_id[i].filter & powerup_cam_status)) {
continue;
}

if (!strcmp(cvar->string, cam_id[i].tag)) {
VectorCopy(cam_id[i].cam.angles, r_refdef.viewangles);
VectorCopy(cam_id[i].cam.org, r_refdef.vieworg);
active = true;
found = true;

if (cam_id[i].filter & powerup_cam_status) {
VectorCopy(cam_id[i].cam.angles, r_refdef.viewangles);
VectorCopy(cam_id[i].cam.org, r_refdef.vieworg);
active = true;
}
break;
}
}
if (!active) {
if (!found) {
Cvar_Set(cvar, "");
Com_Printf("wrong tag for %s\n", cvar->name);
}
Expand All @@ -2036,20 +2028,41 @@ static qbool MVD_PowerupCam_Process(cvar_t* cvar)
return active;
}

qbool MVD_PowerupCam_Enabled(int view_number)
// If powerup cam configured but not currently enabled
qbool MVD_PowerupCam_Hidden(void)
{
if (view_number < 0 || view_number >= sizeof(powerup_cam_cvars) / sizeof(powerup_cam_cvars[0])) {
int view_number = CL_MultiviewCurrentView();

if (view_number < 1 || view_number > sizeof(powerup_cam_active) / sizeof(powerup_cam_active[0])) {
return false;
}

--view_number;
return powerup_cam_cvars[view_number].string && powerup_cam_cvars[view_number].string[0] && !(powerup_cam_status && powerup_cam_active[view_number]);
}

qbool MVD_PowerupCam_Enabled(void)
{
int view_number = CL_MultiviewCurrentView();

if (view_number < 1 || view_number > sizeof(powerup_cam_active) / sizeof(powerup_cam_active[0])) {
return false;
}

--view_number;
return powerup_cam_cvars[view_number].string && powerup_cam_cvars[view_number].string[0] && powerup_cam_status && powerup_cam_active[view_number];
}

void MVD_PowerupCam_Frame(void)
{
int view_number = CL_MultiviewCurrentView();

if (view_number < 0 || view_number >= sizeof(powerup_cam_active) / sizeof(powerup_cam_active[0]) || !mvd_powerup_cam.integer || powerup_cam_status == powerup_cam_inactive) {
if (view_number < 1 || view_number > sizeof(powerup_cam_active) / sizeof(powerup_cam_active[0])) {
return;
}

--view_number;
if (!mvd_powerup_cam.integer || powerup_cam_status == powerup_cam_inactive) {
memset(powerup_cam_active, 0, sizeof(powerup_cam_active));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion mvd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void MVDAnnouncer_Expired(const char* s);
void MVDAnnouncer_BackpackPickup(const char* s);

// Powerup cams
qbool MVD_PowerupCam_Enabled(int view_number);
qbool MVD_PowerupCam_Enabled(void);
void MVD_PowerupCam_Frame(void);

#endif // MVDUTILS_HEADER

0 comments on commit 198ea7a

Please sign in to comment.