Skip to content

Commit

Permalink
Move math functions into shared/qcommon
Browse files Browse the repository at this point in the history
This commit also fixes JACoders#753, by accident more than anything else.
  • Loading branch information
xycaleth committed Aug 4, 2016
1 parent 42f9f57 commit 5c8a2d7
Show file tree
Hide file tree
Showing 109 changed files with 2,298 additions and 3,721 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ endif()

# Files shared across all projects
set(SharedCommonFiles
"${SharedDir}/qcommon/q_color.h"
"${SharedDir}/qcommon/q_color.c"
"${SharedDir}/qcommon/q_math_common.h"
"${SharedDir}/qcommon/q_math_common.c"
"${SharedDir}/qcommon/q_platform.h"
)
set(SharedCommonSafeFiles
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/FxScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ void CFxScheduler::AddScheduledEffects( bool portal )
{
if (cent.gent->ghoul2[(*itr)->mModelNum].mModelindex>=0)
{
doesBoltExist = theFxHelper.GetOriginAxisFromBolt(cent, (*itr)->mModelNum, (*itr)->mBoltNum, origin, axis);
doesBoltExist = (qboolean)(theFxHelper.GetOriginAxisFromBolt(cent, (*itr)->mModelNum, (*itr)->mBoltNum, origin, axis) != 0);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions code/cgame/cg_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CGCam_FollowDisable( void );
void CGCam_TrackDisable( void );
void CGCam_Distance( float distance, qboolean initLerp );
void CGCam_DistanceDisable( void );
extern int CG_CalcFOVFromX( float fov_x );
extern qboolean CG_CalcFOVFromX( float fov_x );
extern void WP_SaberCatch( gentity_t *self, gentity_t *saber, qboolean switchToSaber );

/*
Expand Down Expand Up @@ -418,8 +418,8 @@ void CGCam_SetFade( vec4_t dest )
{//Instant completion
client_camera.info_state &= ~CAMERA_FADING;
client_camera.fade_duration = 0;
Vector4Copy( dest, client_camera.fade_source );
Vector4Copy( dest, client_camera.fade_color );
VectorCopy4( dest, client_camera.fade_source );
VectorCopy4( dest, client_camera.fade_color );
}

/*
Expand All @@ -436,8 +436,8 @@ void CGCam_Fade( vec4_t source, vec4_t dest, float duration )
return;
}

Vector4Copy( source, client_camera.fade_source );
Vector4Copy( dest, client_camera.fade_dest );
VectorCopy4( source, client_camera.fade_source );
VectorCopy4( dest, client_camera.fade_dest );

client_camera.fade_duration = duration;
client_camera.fade_time = cg.time;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ void CGCam_UpdateFade( void )
{
if ( client_camera.fade_time + client_camera.fade_duration < cg.time )
{
Vector4Copy( client_camera.fade_dest, client_camera.fade_color );
VectorCopy4( client_camera.fade_dest, client_camera.fade_color );
client_camera.info_state &= ~CAMERA_FADING;
}
else
Expand Down
8 changes: 4 additions & 4 deletions code/cgame/cg_credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ struct CreditData_t
CreditCards_t CreditCards;
CreditLines_t CreditLines;

bool Running(void)
qboolean Running(void)
{
return !!( CreditCards.size() || CreditLines.size() );
return (qboolean)( CreditCards.size() || CreditLines.size() );
}
};

Expand Down Expand Up @@ -235,12 +235,12 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
// Play the light side end credits music.
if ( g_entities[0].client->sess.mission_objectives[0].status != 2 )
{
cgi_S_StartBackgroundTrack( "music/endcredits.mp3", NULL, false );
cgi_S_StartBackgroundTrack( "music/endcredits.mp3", NULL, qfalse );
}
// Play the dark side end credits music.
else
{
cgi_S_StartBackgroundTrack( "music/vjun3/vjun3_explore.mp3", NULL, false );
cgi_S_StartBackgroundTrack( "music/vjun3/vjun3_explore.mp3", NULL, qfalse );
}

// could make these into parameters later, but for now...
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,7 @@ static void CG_DrawZoomMask( void )

if ( random() > 0.98f && ( cg.time & 1024 ))
{
flip = !flip;
flip = (qboolean)!flip;
}

if ( power )
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ void CG_StartMusic( qboolean bForceStart ) {
Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );
COM_EndParseSession();

cgi_S_StartBackgroundTrack( parm1, parm2, !bForceStart );
cgi_S_StartBackgroundTrack( parm1, parm2, (qboolean)!bForceStart );
}

/*
Expand Down
15 changes: 10 additions & 5 deletions code/cgame/cg_players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ static void CG_PlayerAnimEvents( int animFileIndex, qboolean torso, int oldFrame
{//still in same anim, check for looping anim
inSameAnim = qtrue;
animation_t *animation = &level.knownAnimFileSets[animFileIndex].animations[anim];
animBackward = (animation->frameLerp<0);
animBackward = (qboolean)(animation->frameLerp<0);
if ( animation->loopFrames != -1 )
{//a looping anim!
loopAnim = qtrue;
Expand Down Expand Up @@ -1940,7 +1940,7 @@ static void CG_ATSTLegsYaw( centity_t *cent, vec3_t trailingLegsAngles )

float legAngleDiff = AngleNormalize180(ATSTLegsYaw) - AngleNormalize180(cent->pe.legs.yawAngle);
int legsAnim = cent->currentState.legsAnim;
qboolean moving = (!VectorCompare(cent->gent->client->ps.velocity, vec3_origin));
qboolean moving = (qboolean)!VectorCompare(cent->gent->client->ps.velocity, vec3_origin);
if ( moving || legsAnim == BOTH_TURN_LEFT1 || legsAnim == BOTH_TURN_RIGHT1 || fabs(legAngleDiff) > 45 )
{//moving or turning or beyond the turn allowance
if ( legsAnim == BOTH_STAND1 && !moving )
Expand Down Expand Up @@ -3540,9 +3540,9 @@ static qboolean CG_PlayerShadow( centity_t *const cent, float *const shadowPlane
cgs.model_draw, cent->currentState.modelScale);
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, sideOrigin );
sideOrigin[2] += 30; //fudge up a bit for coplaner
bShadowed = _PlayerShadow(sideOrigin, 0, shadowPlane, 28, cgs.media.shadowMarkShader) || bShadowed;
bShadowed = (qboolean)(_PlayerShadow(sideOrigin, 0, shadowPlane, 28, cgs.media.shadowMarkShader) || bShadowed);

bShadowed = _PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 64, cgs.media.shadowMarkShader) || bShadowed;
bShadowed = (qboolean)( _PlayerShadow(rootOrigin, cent->pe.legs.yawAngle, shadowPlane, 64, cgs.media.shadowMarkShader) || bShadowed);
return bShadowed;
}
else if ( cent->gent->client->NPC_class == CLASS_RANCOR )
Expand Down Expand Up @@ -6728,7 +6728,12 @@ Ghoul2 Insert End
}
// Pass in the renderfx flags attached to the saber weapon model...this is done so that saber glows
// will get rendered properly in a mirror...not sure if this is necessary??
CG_DoSaber( org_, axis_[0], length, client->ps.saber[saberNum].blade[bladeNum].lengthMax, client->ps.saber[saberNum].blade[bladeNum].radius, client->ps.saber[saberNum].blade[bladeNum].color, renderfx, (noDlight==qfalse) );
CG_DoSaber(
org_, axis_[0], length,
client->ps.saber[saberNum].blade[bladeNum].lengthMax,
client->ps.saber[saberNum].blade[bladeNum].radius,
client->ps.saber[saberNum].blade[bladeNum].color,
renderfx, (qboolean)!noDlight );
}

void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, int renderfx, int modelIndex, vec3_t origin, vec3_t angles )
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_predict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void CG_TouchTriggerPrediction( void ) {
return;
}

spectator = ( cg.predicted_player_state.pm_type == PM_SPECTATOR );
spectator = (qboolean)( cg.predicted_player_state.pm_type == PM_SPECTATOR );

if ( cg.predicted_player_state.pm_type != PM_NORMAL && !spectator ) {
return;
Expand Down Expand Up @@ -674,7 +674,7 @@ void CG_PredictPlayerState( void ) {
cg_pmove.trace = CG_Trace;
cg_pmove.pointcontents = CG_PointContents;
cg_pmove.tracemask = MASK_PLAYERSOLID;
cg_pmove.noFootsteps = 0;//( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;
cg_pmove.noFootsteps = qfalse;//( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;

// save the state before the pmove so we can detect transitions
oldPlayerState = cg.predicted_player_state;
Expand Down
14 changes: 7 additions & 7 deletions code/cgame/cg_syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ int cgi_R_Font_HeightPixels(const int iFontIndex, const float scale /*= 1.0f*/)

qboolean cgi_Language_IsAsian( void )
{
return Q_syscall( CG_LANGUAGE_ISASIAN );
return (qboolean)(Q_syscall( CG_LANGUAGE_ISASIAN ) != 0);
}

qboolean cgi_Language_UsesSpaces(void)
{
return Q_syscall( CG_LANGUAGE_USESSPACES );
return (qboolean)(Q_syscall( CG_LANGUAGE_USESSPACES ) != 0);
}

unsigned int cgi_AnyLanguage_ReadCharFromString( const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation /* = NULL */ )
Expand Down Expand Up @@ -310,7 +310,7 @@ void cgi_R_AddRefEntityToScene( const refEntity_t *re ) {

qboolean cgi_R_inPVS( vec3_t p1, vec3_t p2 )
{
return Q_syscall( CG_R_INPVS, p1, p2 );
return (qboolean)(Q_syscall( CG_R_INPVS, p1, p2 ) != 0);
}


Expand Down Expand Up @@ -389,24 +389,24 @@ void cgi_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
}

qboolean cgi_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
return Q_syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );
return (qboolean)(Q_syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot ) != 0);
}

qboolean cgi_GetDefaultState(int entityIndex, entityState_t *state )
{
return Q_syscall( CG_GETDEFAULTSTATE, entityIndex, state );
return (qboolean)(Q_syscall( CG_GETDEFAULTSTATE, entityIndex, state ) != 0);
}

qboolean cgi_GetServerCommand( int serverCommandNumber ) {
return Q_syscall( CG_GETSERVERCOMMAND, serverCommandNumber );
return (qboolean)(Q_syscall( CG_GETSERVERCOMMAND, serverCommandNumber ) != 0);
}

int cgi_GetCurrentCmdNumber( void ) {
return Q_syscall( CG_GETCURRENTCMDNUMBER );
}

qboolean cgi_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {
return Q_syscall( CG_GETUSERCMD, cmdNumber, ucmd );
return (qboolean)(Q_syscall( CG_GETUSERCMD, cmdNumber, ucmd ) != 0);
}

void cgi_SetUserCmdValue( int stateValue, float sensitivityScale, float mPitchOverride, float mYawOverride ) {
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void CG_DrawCaptionText(void)
if((textcolor_caption[0] == 0) && (textcolor_caption[1] == 0) &&
(textcolor_caption[2] == 0) && (textcolor_caption[3] == 0))
{
Vector4Copy( colorTable[CT_WHITE], textcolor_caption );
VectorCopy4( colorTable[CT_WHITE], textcolor_caption );
}

cgi_R_SetColor(textcolor_caption);
Expand Down Expand Up @@ -733,7 +733,7 @@ void CG_DrawCenterString( void )
if((textcolor_center[0] == 0) && (textcolor_center[1] == 0) &&
(textcolor_center[2] == 0) && (textcolor_center[3] == 0))
{
Vector4Copy( colorTable[CT_WHITE], textcolor_center );
VectorCopy4( colorTable[CT_WHITE], textcolor_center );
}

start = cg.centerPrint;
Expand Down
11 changes: 6 additions & 5 deletions code/cgame/cg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,11 +2087,12 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
cg.zoomMode = 0;
}
// decide on third person view
cg.renderingThirdPerson = cg_thirdPerson.integer
|| (cg.snap->ps.stats[STAT_HEALTH] <= 0)
|| (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
|| ((g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
|| (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE) );
cg.renderingThirdPerson = (qboolean)(
cg_thirdPerson.integer
|| (cg.snap->ps.stats[STAT_HEALTH] <= 0)
|| (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
|| ((g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
|| (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE) ));

if ( cg.zoomMode )
{
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2993,7 +2993,7 @@ void CG_MissileHitWall( centity_t *cent, int weapon, vec3_t origin, vec3_t dir,
break;

case WP_EMPLACED_GUN:
FX_EmplacedHitWall( origin, dir, (cent->gent&&cent->gent->alt_fire) );
FX_EmplacedHitWall( origin, dir, (qboolean)(cent->gent&&cent->gent->alt_fire) );
break;

case WP_ATST_MAIN:
Expand Down Expand Up @@ -3134,7 +3134,7 @@ void CG_MissileHitPlayer( centity_t *cent, int weapon, vec3_t origin, vec3_t dir
break;

case WP_EMPLACED_GUN:
FX_EmplacedHitPlayer( origin, dir, (cent->gent&&cent->gent->alt_fire) );
FX_EmplacedHitPlayer( origin, dir, (qboolean)(cent->gent&&cent->gent->alt_fire) );
break;

case WP_TRIP_MINE:
Expand Down
10 changes: 5 additions & 5 deletions code/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
return 0;

case CG_CM_LOADMAP:
CL_CM_LoadMap( (const char *) VMA(1), args[2] );
CL_CM_LoadMap( (const char *) VMA(1), (qboolean)(args[2] != 0) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
Expand Down Expand Up @@ -944,12 +944,12 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
S_UpdateEntityPosition( args[1], (const float *) VMA(2) );
return 0;
case CG_S_RESPATIALIZE:
S_Respatialize( args[1], (const float *) VMA(2), (float(*)[3]) VMA(3), args[4] );
S_Respatialize( args[1], (const float *) VMA(2), (float(*)[3]) VMA(3), (qboolean)(args[4] != 0) );
return 0;
case CG_S_REGISTERSOUND:
return S_RegisterSound( (const char *) VMA(1) );
case CG_S_STARTBACKGROUNDTRACK:
S_StartBackgroundTrack( (const char *) VMA(1), (const char *) VMA(2), args[3]);
S_StartBackgroundTrack( (const char *) VMA(1), (const char *) VMA(2), (qboolean)(args[3] != 0) );
return 0;
case CG_S_GETSAMPLELENGTH:
return S_GetSampleLengthInMilliSeconds( args[1]);
Expand Down Expand Up @@ -1190,7 +1190,7 @@ Ghoul2 Insert End
return 0;

case CG_OPENJK_MENU_PAINT:
Menu_Paint( (menuDef_t *)VMA(1), args[2] );
Menu_Paint( (menuDef_t *)VMA(1), (qboolean)(args[2] != 0) );
return 0;

case CG_OPENJK_GETMENU_BYNAME:
Expand Down Expand Up @@ -1444,7 +1444,7 @@ qboolean CL_GameCommand( void ) {
return qfalse;
}

return VM_Call( CG_CONSOLE_COMMAND );
return (qboolean)(VM_Call( CG_CONSOLE_COMMAND ) != 0);
}


Expand Down
22 changes: 11 additions & 11 deletions code/client/cl_cin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ static void RoQInterrupt(void)
case ZA_SOUND_MONO:
if (!cinTable[currentHandle].silent) {
ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value, 1 );
S_RawSamples( ssize, 22050, 2, 1, (byte *)sbuf, s_volume->value, qtrue );
}
break;
case ZA_SOUND_STEREO:
Expand All @@ -1172,7 +1172,7 @@ static void RoQInterrupt(void)
s_rawend = s_soundtime;
}
ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags);
S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value, 1 );
S_RawSamples( ssize, 22050, 2, 2, (byte *)sbuf, s_volume->value, qtrue );
}
break;
case ROQ_QUAD_INFO:
Expand Down Expand Up @@ -1494,15 +1494,15 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
}

CIN_SetExtents(currentHandle, x, y, w, h);
CIN_SetLooping(currentHandle, (systemBits & CIN_loop)!=0);
CIN_SetLooping(currentHandle, (qboolean)((systemBits & CIN_loop) != 0));

cinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT;
cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH;
cinTable[currentHandle].holdAtEnd = (systemBits & CIN_hold) != 0;
cinTable[currentHandle].alterGameState = (systemBits & CIN_system) != 0;
cinTable[currentHandle].holdAtEnd = (qboolean)((systemBits & CIN_hold) != 0);
cinTable[currentHandle].alterGameState = (qboolean)((systemBits & CIN_system) != 0);
cinTable[currentHandle].playonwalls = 1;
cinTable[currentHandle].silent = (systemBits & CIN_silent) != 0;
cinTable[currentHandle].shader = (systemBits & CIN_shader) != 0;
cinTable[currentHandle].silent = (qboolean)((systemBits & CIN_silent) != 0);
cinTable[currentHandle].shader = (qboolean)((systemBits & CIN_shader) != 0);
if (psAudioFile)
{
cinTable[currentHandle].hSFX = S_RegisterSound(psAudioFile);
Expand Down Expand Up @@ -1625,8 +1625,8 @@ static void CIN_AddTextCrawl()
verts[i].modulate[3] = 255*fadeDown;
}

_VectorScale( verts[2].modulate, 0.1f, verts[2].modulate ); // darken at the top??
_VectorScale( verts[3].modulate, 0.1f, verts[3].modulate );
VectorScaleM( verts[2].modulate, 0.1f, verts[2].modulate ); // darken at the top??
VectorScaleM( verts[3].modulate, 0.1f, verts[3].modulate );

#define TIMEOFFSET +(cls.realtime-CL_iPlaybackStartTime-TC_DELAY)*0.000015f -1
VectorSet( verts[0].xyz, TC_PLANE_NEAR, -TC_PLANE_WIDTH, TC_PLANE_TOP );
Expand Down Expand Up @@ -1856,7 +1856,7 @@ static void PlayCinematic(const char *arg, const char *s, qboolean qbInGame)
// work out associated audio-overlay file, if any...
//
extern cvar_t *s_language;
qboolean bIsForeign = s_language && Q_stricmp(s_language->string,"english") && Q_stricmp(s_language->string,"");
qboolean bIsForeign = (qboolean)(s_language && Q_stricmp(s_language->string,"english") && Q_stricmp(s_language->string,""));
const char *psAudioFile = NULL;
qhandle_t hCrawl = 0;
if (!Q_stricmp(arg,"video/jk0101_sw.roq"))
Expand Down Expand Up @@ -1949,7 +1949,7 @@ qboolean CL_CheckPendingCinematic(void)
if ( gbPendingCinematic && CIN_HardwareReadyToPlayVideos() )
{
gbPendingCinematic = qfalse; // BEFORE next line, or we get recursion
PlayCinematic(sPendingCinematic_Arg,sPendingCinematic_s[0]?sPendingCinematic_s:NULL,false);
PlayCinematic(sPendingCinematic_Arg,sPendingCinematic_s[0]?sPendingCinematic_s:NULL,qfalse);
return qtrue;
}
return qfalse;
Expand Down
Loading

0 comments on commit 5c8a2d7

Please sign in to comment.