Skip to content

Commit

Permalink
Merge branch 'master' into rend2
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Mar 2, 2014
2 parents 353acce + a0adf82 commit fa08890
Show file tree
Hide file tree
Showing 22 changed files with 126 additions and 127 deletions.
2 changes: 1 addition & 1 deletion code/cgame/cg_syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" Q_EXPORT void QDECL dllEntry( intptr_t (QDECL *syscallptr)( intptr_t


inline int PASSFLOAT( float x ) {
floatint_t fi;
byteAlias_t fi;
fi.f = x;
return fi.i;
}
Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ FloatAsInt
*/
static int FloatAsInt( float f )
{
floatint_t fi;
byteAlias_t fi;
fi.f = f;
return fi.i;
}
Expand Down
5 changes: 4 additions & 1 deletion code/qcommon/cm_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void CM_ParseShader( CCMShader *shader, const char **text )
}
// sun parms
// q3map_sun deprecated as of 11 Jan 01
else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) )
else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) )
{
// float a, b;

Expand All @@ -436,6 +436,9 @@ void CM_ParseShader( CCMShader *shader, const char **text )
// shader->sunDirection[0] = cos( a ) * cos( b );
// shader->sunDirection[1] = sin( a ) * cos( b );
// shader->sunDirection[2] = sin( b );

SkipRestOfLine( text );
continue;
}
else if ( !Q_stricmp( token, "surfaceParm" ) )
{
Expand Down
4 changes: 2 additions & 2 deletions code/qcommon/q_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up) {
*/
float Q_rsqrt( float number )
{
floatint_t t;
byteAlias_t t;
float x2, y;
const float threehalfs = 1.5F;

Expand All @@ -554,7 +554,7 @@ float Q_rsqrt( float number )
}

float Q_fabs( float f ) {
floatint_t fi;
byteAlias_t fi;
fi.f = f;
fi.i &= 0x7FFFFFFF;
return fi.f;
Expand Down
2 changes: 1 addition & 1 deletion code/qcommon/q_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int LongNoSwap (int l)
}

float FloatSwap (const float *f) {
floatint_t out;
byteAlias_t out;

out.f = *f;
out.ui = LongSwap(out.ui);
Expand Down
51 changes: 25 additions & 26 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ This file is part of Jedi Academy.
//JAC: Added
#define ARRAY_LEN( x ) ( sizeof( x ) / sizeof( *(x) ) )
#define STRING( a ) #a
#define XSTRING( a ) STRING( a )

#ifndef FINAL_BUILD
#ifdef _WIN32
Expand Down Expand Up @@ -134,35 +135,14 @@ float FloatSwap( const float *f );
// TYPE DEFINITIONS
// ================================================================

typedef unsigned long ulong;
typedef unsigned short word;
typedef unsigned char byte;
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long ulong;

typedef enum {qfalse, qtrue} qboolean;
typedef enum { qfalse=0, qtrue } qboolean;
#define qboolean int //don't want strict type checking on the qboolean

typedef union {
float f;
int i;
unsigned int ui;
} floatint_t;

typedef int qhandle_t;
typedef int thandle_t;
typedef int fxHandle_t;
typedef int sfxHandle_t;
typedef int fileHandle_t;
typedef int clipHandle_t;

#define NULL_HANDLE ((qhandle_t) 0)
#define NULL_SOUND ((sfxHandle_t) 0)
#define NULL_FX ((fxHandle_t) 0)
#define NULL_SFX ((sfxHandle_t) 0)
#define NULL_FILE ((fileHandle_t) 0)
#define NULL_CLIP ((clipHandle_t) 0)

//Raz: can't think of a better place to put this atm,
// should probably be in the platform specific definitions

#if defined (_MSC_VER) && (_MSC_VER >= 1600)

#include <stdint.h>
Expand Down Expand Up @@ -195,6 +175,25 @@ typedef int clipHandle_t;

#endif

// 32 bit field aliasing
typedef union byteAlias_u {
float f;
int32_t i;
uint32_t ui;
qboolean qb;
byte b[4];
char c[4];
} byteAlias_t;

typedef int32_t qhandle_t, thandle_t, fxHandle_t, sfxHandle_t, fileHandle_t, clipHandle_t;

#define NULL_HANDLE ((qhandle_t)0)
#define NULL_SOUND ((sfxHandle_t)0)
#define NULL_FX ((fxHandle_t)0)
#define NULL_SFX ((sfxHandle_t)0)
#define NULL_FILE ((fileHandle_t)0)
#define NULL_CLIP ((clipHandle_t)0)

#define PAD(base, alignment) (((base)+(alignment)-1) & ~((alignment)-1))
#define PADLEN(base, alignment) (PAD((base), (alignment)) - (base))

Expand Down
16 changes: 15 additions & 1 deletion code/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,25 @@ enum clc_ops_e {
clc_clientCommand // [string] message
};

/*
==============================================================
VIRTUAL MACHINE
==============================================================
*/

typedef enum vmSlots_e {
VM_GAME=0,
VM_CGAME,
VM_UI,
MAX_VM
} vmSlots_t;

#define VMA(x) ((void*)args[x])
inline float _vmf(intptr_t x)
{
floatint_t fi;
byteAlias_t fi;
fi.i = (int) x;
return fi.f;
}
Expand Down
5 changes: 4 additions & 1 deletion code/rd-vanilla/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ static qboolean ParseShader( const char **text )
continue;
}
// sun parms
else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "sun" )) {
else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
float a, b;

token = COM_ParseExt( text, qfalse );
Expand All @@ -2339,6 +2339,9 @@ static qboolean ParseShader( const char **text )
tr.sunDirection[0] = cos( a ) * cos( b );
tr.sunDirection[1] = sin( a ) * cos( b );
tr.sunDirection[2] = sin( b );

SkipRestOfLine( text );
continue;
}
else if ( !Q_stricmp( token, "deformVertexes" ) ) {
ParseDeform( text );
Expand Down
72 changes: 35 additions & 37 deletions code/rd-vanilla/tr_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,47 +936,42 @@ void RB_SurfacePolychain( srfPoly_t *p ) {
tess.numVertexes = numv;
}

inline static ulong ComputeFinalVertexColor(const byte *colors)
{
int k;
byte result[4];
ulong r, g, b;
inline static uint32_t ComputeFinalVertexColor( const byte *colors ) {
int k;
byteAlias_t result;
uint32_t r, g, b;

*(int *)result = *(int *)colors;
if (tess.shader->lightmapIndex[0] != LIGHTMAP_BY_VERTEX )
{
return *(ulong *)result;
}
if (r_fullbright->integer)
{
result[0] = 255;
result[1] = 255;
result[2] = 255;
return *(ulong *)result;
for ( k=0; k<4; k++ )
result.b[k] = colors[k];

if ( tess.shader->lightmapIndex[0] != LIGHTMAP_BY_VERTEX )
return result.ui;

if ( r_fullbright->integer ) {
result.b[0] = 255;
result.b[1] = 255;
result.b[2] = 255;
return result.ui;
}
// an optimization could be added here to compute the style[0] (which is always the world normal light)
r = g = b = 0;
for(k = 0; k < MAXLIGHTMAPS; k++)
{
if (tess.shader->styles[k] < LS_UNUSED)
{
byte *styleColor = styleColors[tess.shader->styles[k]];
for( k=0; k<MAXLIGHTMAPS; k++ ) {
if ( tess.shader->styles[k] < LS_UNUSED ) {
byte *styleColor = styleColors[tess.shader->styles[k]];

r += (ulong)(*colors++) * (ulong)(*styleColor++);
g += (ulong)(*colors++) * (ulong)(*styleColor++);
b += (ulong)(*colors++) * (ulong)(*styleColor);
r += (uint32_t)(*colors++) * (uint32_t)(*styleColor++);
g += (uint32_t)(*colors++) * (uint32_t)(*styleColor++);
b += (uint32_t)(*colors++) * (uint32_t)(*styleColor);
colors++;
}
else
{
break;
}
}
result[0] = Com_Clamp(0, 255, r >> 8);
result[1] = Com_Clamp(0, 255, g >> 8);
result[2] = Com_Clamp(0, 255, b >> 8);
result.b[0] = Com_Clamp( 0, 255, r >> 8 );
result.b[1] = Com_Clamp( 0, 255, g >> 8 );
result.b[2] = Com_Clamp( 0, 255, b >> 8 );

return *(ulong *)result;
return result.ui;
}

/*
Expand Down Expand Up @@ -1041,7 +1036,7 @@ void RB_SurfaceTriangles( srfTriangles_t *srf ) {
}
texCoords += NUM_TEX_COORDS*2;

*(unsigned int*)color = ComputeFinalVertexColor((byte *)dv->color);
*(unsigned *)color = ComputeFinalVertexColor((byte *)dv->color);
color += 4;
}

Expand Down Expand Up @@ -1327,15 +1322,16 @@ RB_SurfaceFace
==============
*/
void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
int i, k;
int i, j, k;
unsigned int *indices;
glIndex_t *tessIndexes;
float *v;
float *normal;
int ndx;
int Bob;
int numPoints;
int dlightBits;
unsigned int *indices;
glIndex_t *tessIndexes;
float *v;
byteAlias_t ba;

RB_CHECKOVERFLOW( surf->numPoints, surf->numIndices );

Expand Down Expand Up @@ -1382,7 +1378,9 @@ void RB_SurfaceFace( srfSurfaceFace_t *surf ) {
break;
}
}
*(unsigned int*) &tess.vertexColors[ndx] = ComputeFinalVertexColor((byte *)&v[VERTEX_COLOR]);
ba.ui = ComputeFinalVertexColor( (byte *)&v[VERTEX_COLOR] );
for ( j=0; j<4; j++ )
tess.vertexColors[ndx][j] = ba.b[j];
tess.vertexDlightBits[ndx] = dlightBits;
}

Expand Down Expand Up @@ -2095,7 +2093,7 @@ void RB_SurfaceFlare( srfFlare_t *surf ) {


void RB_SurfaceDisplayList( srfDisplayList_t *surf ) {
// all apropriate state must be set in RB_BeginSurface
// all appropriate state must be set in RB_BeginSurface
// this isn't implemented yet...
qglCallList( surf->listNum );
}
Expand Down
4 changes: 0 additions & 4 deletions code/ui/ui_syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ This file is part of Jedi Academy.
float trap_Cvar_VariableValue( const char *var_name )
{
return Cvar_VariableValue( var_name );
// floatint_t fi;
// fi.i = syscall( UI_CVAR_VARIABLEVALUE, var_name );
// fi.i = Cvar_VariableValue( var_name );
// return fi.f;
}


Expand Down
1 change: 0 additions & 1 deletion codemp/cgame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ set(MPCGameCgameFiles
"${MPDir}/cgame/fx_heavyrepeater.c"
"${MPDir}/cgame/fx_rocketlauncher.c"
"${MPDir}/cgame/animtable.h"
"${MPDir}/cgame/cg_lights.h"
"${MPDir}/cgame/cg_local.h"
"${MPDir}/cgame/cg_public.h"
"${MPDir}/cgame/cg_xcvar.h"
Expand Down
19 changes: 11 additions & 8 deletions codemp/cgame/cg_light.c
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
#include "cg_local.h"
#include "cg_lights.h"

typedef struct clightstyle_s {
int length;
color4ub_t value;
color4ub_t map[MAX_QPATH];
} clightstyle_t;

static clightstyle_t cl_lightstyle[MAX_LIGHT_STYLES];
static int lastofs;

/*
================
FX_ClearLightStyles
CG_ClearLightStyles
================
*/
void CG_ClearLightStyles (void)
{
int i;

memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
memset( cl_lightstyle, 0, sizeof( cl_lightstyle ) );
lastofs = -1;

for(i=0;i<MAX_LIGHT_STYLES*3;i++)
{
CG_SetLightstyle (i);
}
for ( i=0; i<MAX_LIGHT_STYLES*3; i++ )
CG_SetLightstyle( i );
}

/*
================
FX_RunLightStyles
CG_RunLightStyles
================
*/
void CG_RunLightStyles (void)
Expand Down
11 changes: 0 additions & 11 deletions codemp/cgame/cg_lights.h

This file was deleted.

5 changes: 5 additions & 0 deletions codemp/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ typedef struct cgs_s {
int fDisable;

char mapname[MAX_QPATH];
char rawmapname[MAX_QPATH];
// char redTeam[MAX_QPATH];
// char blueTeam[MAX_QPATH];

Expand Down Expand Up @@ -2040,6 +2041,10 @@ void CG_CheckPlayerG2Weapons(playerState_t *ps, centity_t *cent);

void CG_SetSiegeTimerCvar( int msec );

void CG_ClearLightStyles (void);
void CG_RunLightStyles (void);
void CG_SetLightstyle (int i);

/*
Ghoul2 Insert End
*/
Expand Down
Loading

0 comments on commit fa08890

Please sign in to comment.