Skip to content

Commit

Permalink
Happy April Fools day
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Mar 31, 2018
1 parent d6e3ae4 commit e464ebb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
7 changes: 7 additions & 0 deletions engine/client/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,17 @@ static void R_SetupGL( void )
f = sin( cl.time * r_underwater_distortion->value * ( M_PI * 2.7f ));
RI.refdef.fov_x += f;
RI.refdef.fov_y -= f;


}

R_SetupModelviewMatrix( &RI.refdef, RI.worldviewMatrix );
R_SetupProjectionMatrix( &RI.refdef, RI.projectionMatrix );
// if( RI.params & RP_MIRRORVIEW ) RI.projectionMatrix[0][0] = -RI.projectionMatrix[0][0];
if( host.joke )
{
RI.projectionMatrix[0][0] = -RI.projectionMatrix[0][0];
}

Matrix4x4_Concat( RI.worldviewProjectionMatrix, RI.projectionMatrix, RI.worldviewMatrix );

Expand Down Expand Up @@ -1293,6 +1299,7 @@ void R_RenderFrame( const ref_params_t *fd, qboolean drawWorld )
if( drawWorld ) r_lastRefdef = *fd;

RI.params = RP_NONE;
if( host.joke ) RI.params |= RP_FLIPFRONTFACE;
RI.farClip = 0;
RI.clipFlags = 15;
RI.drawWorld = drawWorld;
Expand Down
6 changes: 6 additions & 0 deletions engine/client/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,12 @@ void Host_InputFrame( void )
inputstate.lastyaw = yaw;
}

if( host.joke )
{
yaw = -yaw;
side = -side;
}

if( cls.key_dest == key_game )
{
clgame.dllFuncs.pfnLookEvent( yaw, pitch );
Expand Down
7 changes: 6 additions & 1 deletion engine/client/s_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ SND_Spatialize
void SND_Spatialize( channel_t *ch )
{
vec3_t source_vec;
vec3_t right;
float dist, dot, gain = 1.0f;
qboolean fplayersound = false;
qboolean looping = false;
Expand Down Expand Up @@ -810,7 +811,11 @@ void SND_Spatialize( channel_t *ch )

// normalize source_vec and get distance from listener to source
dist = VectorNormalizeLength( source_vec );
dot = DotProduct( s_listener.right, source_vec );
if( host.joke )
VectorNegate( s_listener.right, right );
else
VectorCopy( s_listener.right, right );
dot = DotProduct( right, source_vec );

// for sounds with a radius, spatialize left/right evenly within the radius

Expand Down
2 changes: 2 additions & 0 deletions engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ typedef struct host_parm_s
qboolean enabledll;
qboolean textmode;
qboolean daemonized;

qboolean joke; // 1st April 2018
} host_parm_t;

extern host_parm_t host;
Expand Down
24 changes: 24 additions & 0 deletions engine/common/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ GNU General Public License for more details.
#include <stdarg.h> // va_args
#include <errno.h> // errno
#include <string.h> // strerror
#include <time.h>

#ifndef _WIN32
#include <unistd.h> // fork
Expand Down Expand Up @@ -70,6 +71,9 @@ convar_t *host_build, *host_ver; // fork info
convar_t *host_mapdesign_fatal;
convar_t *cmd_scripting = NULL;

static convar_t *host_nojoke;
static convar_t *host_forcejoke;

static int num_decals;

void Sys_PrintUsage( void )
Expand Down Expand Up @@ -1265,6 +1269,8 @@ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bCh
host_ver = Cvar_Get( "host_ver", va("%i %s %s %s %s", Q_buildnum(), XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildcommit() ), CVAR_INIT, "detailed info about this build" );
host_mapdesign_fatal = Cvar_Get( "host_mapdesign_fatal", "1", CVAR_ARCHIVE, "make map design errors fatal" );
host_xashds_hacks = Cvar_Get( "xashds_hacks", "0", 0, "hacks for xashds in singleplayer" );
host_nojoke = Cvar_Get( "host_nojoke", "0", CVAR_ARCHIVE, "disable april fools joke");
host_forcejoke = Cvar_Get( "host_forcejoke", "0", 0, "let april fools continue" );

// content control
Cvar_Get( "violence_hgibs", "1", CVAR_ARCHIVE, "show human gib entities" );
Expand Down Expand Up @@ -1384,6 +1390,24 @@ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bCh
if( host.state == HOST_INIT )
host.state = HOST_FRAME; // initialization is finished

if( host_forcejoke->value )
{
host.joke = true;
}
else
{
#ifndef __ANDROID__
time_t timeval;
struct tm *timeinfo;

timeval = time( NULL );
timeinfo = localtime( &timeval );

host.joke = !host_nojoke->value && ( timeinfo->tm_year == 118 && timeinfo->tm_mday == 1 && timeinfo->tm_mon == 3 );
#else
host.joke = false;
#endif
}
Host_FrameLoop();

// never reached
Expand Down

0 comments on commit e464ebb

Please sign in to comment.