Skip to content

Commit

Permalink
Rewrite build points code.
Browse files Browse the repository at this point in the history
  • Loading branch information
enneract committed Apr 13, 2015
1 parent e532a5d commit 37ef57f
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 1,203 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -1725,6 +1725,7 @@ GOBJ_ = \
$(B)/base/game/g_weapon.o \
$(B)/base/game/g_admin.o \
$(B)/base/game/g_namelog.o \
$(B)/base/game/g_buildpoints.o \
\
$(B)/base/qcommon/q_math.o \
$(B)/base/qcommon/q_shared.o
Expand Down
36 changes: 36 additions & 0 deletions assets/ui/assets/alien/buildstat.cfg
@@ -0,0 +1,36 @@
// config for the building status indicators that builders see
// NOTES:
// * all characters (text/icons) are square
// * character size is derived totally from frameHeight and vertialMargin
// * healthPadding is NOT used compensated for in the margins

frameShader "ui/assets/alien/buildstat/frame"
frameWidth 150
frameHeight 30

healthPadding 2
healthSevereColor 0.24 0.02 0.02 1
healthHighColor 0.32 0.04 0.04 1
healthElevatedColor 0.40 0.06 0.06 1
healthGuardedColor 0.48 0.08 0.08 1
healthLowColor 0.56 0.10 0.10 1

// this gets drawn over frame and health, but numbers and icons go on top of it
overlayShader "ui/assets/alien/buildstat/overlay"
overlayWidth 156
overlayHeight 36

// PERCENT of frameHeight to use for top/bottom margin of icons/text
// value is for total of top and bottom margins
// valid values between 0.0 and 1.0
verticalMargin 0.5

// number of CHARS worth of space that should be used for left/right margins
// value is for one side only
// char width is determined by frameHeight and verticalMargin
horizontalMargin 1.0

noPowerShader "ui/assets/alien/buildstat/nopower"

backColor 1.0 1.0 1.0 1
foreColor 0.0 0.0 0.0 1
38 changes: 38 additions & 0 deletions assets/ui/assets/human/buildstat.cfg
@@ -0,0 +1,38 @@
// config for the building status indicators that builders see
// NOTES:
// * all characters (text/icons) are square
// * character size is derived totally from frameHeight and vertialMargin
// * healthPadding is NOT used compensated for in the margins

frameShader "ui/assets/human/buildstat/frame"
frameWidth 150
frameHeight 30

healthPadding 2

// Homeworld Security Advisory System
healthSevereColor 0.83 0.03 0.02 1
healthHighColor 0.84 0.48 0.03 1
healthElevatedColor 0.82 0.82 0.00 1
healthGuardedColor 0.19 0.65 0.00 1
healthLowColor 0.27 0.49 0.55 1

// this gets drawn over frame and health, but numbers and icons go on top of it
overlayShader ""
overlayWidth 160
overlayHeight 40

// PERCENT of frameHeight to use for top/bottom margin of icons/text
// value is for total of top and bottom margins
// valid values between 0.0 and 1.0
verticalMargin 0.5

// number of CHARS worth of space that should be used for left/right margins
// value is for one side only
// char width is determined by frameHeight and verticalMargin
horizontalMargin 1.0

noPowerShader "ui/assets/human/buildstat/nopower"

backColor 1.0 1.0 1.0 1
foreColor 0.0 0.0 0.0 1
17 changes: 1 addition & 16 deletions src/cgame/cg_buildable.c
Expand Up @@ -803,12 +803,6 @@ void CG_BuildableStatusParse( const char *filename, buildStat_t *bs )
bs->noPowerShader = trap_R_RegisterShader( s );
continue;
}
else if( !Q_stricmp( token.string, "markedShader" ) )
{
if( PC_String_Parse( handle, &s ) )
bs->markedShader = trap_R_RegisterShader( s );
continue;
}
else if( !Q_stricmp( token.string, "healthSevereColor" ) )
{
if( PC_Color_Parse( handle, &c ) )
Expand Down Expand Up @@ -922,7 +916,7 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
int health;
float x, y;
vec4_t color;
qboolean powered, marked;
qboolean powered;
trace_t tr;
float d;
buildStat_t *bs;
Expand Down Expand Up @@ -1080,7 +1074,6 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
scale = ( picH / d ) * 3;

powered = es->eFlags & EF_B_POWERED;
marked = es->eFlags & EF_B_MARKED;

picH *= scale;
picW *= scale;
Expand Down Expand Up @@ -1161,14 +1154,6 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
CG_DrawPic( pX, subY, subH, subH, bs->noPowerShader );
}

if( marked )
{
float mX;

mX = picX + picW - ( subH * bs->horizontalMargin ) - subH;
CG_DrawPic( mX, subY, subH, subH, bs->markedShader );
}

{
float nX;
int healthMax;
Expand Down
2 changes: 0 additions & 2 deletions src/cgame/cg_local.h
Expand Up @@ -1360,7 +1360,6 @@ typedef struct
qhandle_t frameShader;
qhandle_t overlayShader;
qhandle_t noPowerShader;
qhandle_t markedShader;
vec4_t healthSevereColor;
vec4_t healthHighColor;
vec4_t healthElevatedColor;
Expand Down Expand Up @@ -1400,7 +1399,6 @@ typedef struct
int timelimit;
int maxclients;
char mapname[ MAX_QPATH ];
qboolean markDeconstruct; // Whether or not buildables are marked

int voteTime[ NUM_TEAMS ];
int voteYes[ NUM_TEAMS ];
Expand Down
9 changes: 2 additions & 7 deletions src/cgame/cg_servercmds.c
Expand Up @@ -119,7 +119,6 @@ void CG_ParseServerinfo( void )
info = CG_ConfigString( CS_SERVERINFO );
cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) );
cgs.maxclients = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
cgs.markDeconstruct = atoi( Info_ValueForKey( info, "g_markDeconstruct" ) );
mapname = Info_ValueForKey( info, "mapname" );
Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname );
}
Expand Down Expand Up @@ -692,12 +691,8 @@ void CG_Menu( int menu, int arg )
//===============================

case MN_H_NOBP:
if( cgs.markDeconstruct )
longMsg = "^5There is no power remaining. Free up power by marking "
"existing buildable objects.";
else
longMsg = "There is no power remaining. Free up power by deconstructing "
"existing buildable objects.";
longMsg = "There is no power remaining. Free up power by deconstructing "
"existing buildable objects.";
shortMsg = "^5There is no power remaining";
type = DT_BUILD;
break;
Expand Down
48 changes: 6 additions & 42 deletions src/cgame/cg_tutorial.c
Expand Up @@ -199,27 +199,9 @@ static void CG_AlienBuilderText( char *text, playerState_t *ps )

if( ( es = CG_BuildableInRange( ps, NULL ) ) )
{
if( cgs.markDeconstruct )
{
if( es->eFlags & EF_B_MARKED )
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to unmark this structure for replacement\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to mark this structure for replacement\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to destroy this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to destroy this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}

if( ( ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) == BA_NONE )
Expand Down Expand Up @@ -375,27 +357,9 @@ static void CG_HumanCkitText( char *text, playerState_t *ps )

if( ( es = CG_BuildableInRange( ps, NULL ) ) )
{
if( cgs.markDeconstruct )
{
if( es->eFlags & EF_B_MARKED )
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to unmark this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to mark this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
}
else
{
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to destroy this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
Q_strcat( text, MAX_TUTORIAL_TEXT,
va( "Press %s to destroy this structure\n",
CG_KeyNameForCommand( "deconstruct" ) ) );
}
}

Expand Down
1 change: 0 additions & 1 deletion src/game/bg_public.h
Expand Up @@ -315,7 +315,6 @@ typedef enum
// buildable flags:
#define EF_B_SPAWNED 0x0008
#define EF_B_POWERED 0x0010
#define EF_B_MARKED 0x0020

#define EF_WARN_CHARGE 0x0020 // Lucifer Cannon is about to overcharge
#define EF_WALLCLIMB 0x0040 // wall walking
Expand Down
23 changes: 2 additions & 21 deletions src/game/g_active.c
Expand Up @@ -881,20 +881,6 @@ void ClientTimerActions( gentity_t *ent, int msec )
client->ps.stats[ STAT_BUILDABLE ] |= SB_VALID_TOGGLEBIT;
else
client->ps.stats[ STAT_BUILDABLE ] &= ~SB_VALID_TOGGLEBIT;

// Let the client know which buildables will be removed by building
for( i = 0; i < MAX_MISC; i++ )
{
if( i < level.numBuildablesForRemoval )
client->ps.misc[ i ] = level.markedBuildables[ i ]->s.number;
else
client->ps.misc[ i ] = 0;
}
}
else
{
for( i = 0; i < MAX_MISC; i++ )
client->ps.misc[ i ] = 0;
}
break;

Expand Down Expand Up @@ -2203,13 +2189,8 @@ void ClientThink_real( gentity_t *ent )
}
}

client->ps.persistant[ PERS_BP ] = G_GetBuildPoints( client->ps.origin,
client->ps.stats[ STAT_TEAM ] );
client->ps.persistant[ PERS_MARKEDBP ] = G_GetMarkedBuildPoints( client->ps.origin,
client->ps.stats[ STAT_TEAM ] );
//no more zero bp?
// if( client->ps.persistant[ PERS_BP ] < 0 )
// client->ps.persistant[ PERS_BP ] = 0;
client->ps.persistant[ PERS_BP ] =
G_GetBuildPoints( client->ps.origin, client->ps.stats[ STAT_TEAM ] );

// perform once-a-second actions
ClientTimerActions( ent, msec );
Expand Down

0 comments on commit 37ef57f

Please sign in to comment.