Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Improve client
Browse files Browse the repository at this point in the history
  • Loading branch information
mittorn committed Mar 1, 2016
1 parent 06d38e3 commit d254f1b
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 104 deletions.
1 change: 1 addition & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(call all-subdir-makefiles)
17 changes: 9 additions & 8 deletions cl_dll/MOTD.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
Expand Down Expand Up @@ -90,8 +90,9 @@ int CHudMOTD :: Draw( float fTime )
gHUD.DrawDarkRectangle(xpos-5, ypos_r - 5, xmax - xpos+10, height + 10);
while ( *ch )
{
char *next_line;
int line_length = 0; // count the length of the current line
for ( char *next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
for ( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
line_length += gHUD.m_scrinfo.charWidths[ *next_line ];
char *top = next_line;
if ( *top == '\n' )
Expand All @@ -105,7 +106,7 @@ int CHudMOTD :: Draw( float fTime )

ypos += LINE_HEIGHT;

if ( top ) // restore
if ( top ) // restore
*top = '\n';
ch = next_line;
if ( *ch == '\n' )
Expand All @@ -114,7 +115,7 @@ int CHudMOTD :: Draw( float fTime )
if ( ypos > (ScreenHeight - 20) )
break; // don't let it draw too low
}

return 1;
}

Expand All @@ -133,7 +134,7 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
if ( is_finished )
{
int length = 0;

m_iMaxLength = 0;
m_iFlags |= HUD_ACTIVE;

Expand All @@ -151,7 +152,7 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
}
length++;
}

m_iLines++;
if( length > m_iMaxLength )
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->rcCrosshair = p->rc;
}
else
pWeapon->hCrosshair = NULL;
pWeapon->hCrosshair = 0;

p = GetSpriteList(pList, "autoaim", iRes, i);
if (p)
Expand Down
54 changes: 34 additions & 20 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
#endif

// Macros to hook function calls into the HUD object

#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );

#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
}


#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \
gHUD.y.UserCmd_##x( ); \
}


#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );

#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
}


#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \
gHUD.y.UserCmd_##x( ); \
}


inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
Expand Down Expand Up @@ -82,31 +82,45 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
#define ClientCmd (*gEngfuncs.pfnClientCmd)
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
#define AngleVectors (*gEngfuncs.pfnAngleVectors)


extern cvar_t *hud_textmode;
extern float g_hud_text_color[3];
inline int DrawSetTextColor(float r, float g, float b)
{
if( hud_textmode->value == 1 )
g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b;
else
gEngfuncs.pfnDrawSetTextColor( r, g, b );
}
// Gets the height & width of a sprite, at the specified frame
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }

inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
{
{
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
}

inline int DrawConsoleString( int x, int y, const char *string )
{
if( hud_textmode->value == 1 )
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255*g_hud_text_color[0], 255*g_hud_text_color[1], 255*g_hud_text_color[2]);
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
}

inline void GetConsoleStringSize( const char *string, int *width, int *height )
{
gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
if( hud_textmode->value == 1 )
*height = 13, *width = gHUD.DrawHudStringLen(string);
else
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
}

inline int ConsoleStringLen( const char *string )
{
int _width, _height;
int _width = 0, _height = 0;
if( hud_textmode->value == 1 )
return gHUD.DrawHudStringLen((char*)string);
GetConsoleStringSize( string, &_width, &_height );
return _width;
}
Expand Down
12 changes: 6 additions & 6 deletions cl_dll/death.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int CHudDeathNotice :: Draw( float flTime )
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );

// Only draw if the viewport will let me
// vgui dropped out
// vgui dropped out
//if ( gViewPort && gViewPort->AllowedToPrintText() )
{
// Draw the death notice
Expand All @@ -125,7 +125,7 @@ int CHudDeathNotice :: Draw( float flTime )

// Draw killers name
if ( rgDeathNoticeList[i].KillerColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
}

Expand All @@ -145,7 +145,7 @@ int CHudDeathNotice :: Draw( float flTime )
if (rgDeathNoticeList[i].iNonPlayerKill == FALSE)
{
if ( rgDeathNoticeList[i].VictimColor )
gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
}
}
Expand Down Expand Up @@ -184,8 +184,8 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p

//if (gViewPort)
// gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();

gHUD.m_Scoreboard.GetAllPlayersInfo();


// Get the Killer's name
char *killer_name = g_PlayerInfoList[ killer ].name;
Expand Down Expand Up @@ -279,7 +279,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
ConsolePrint( rgDeathNoticeList[i].szVictim );
}

if ( killedwith && *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
if ( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill )
{
ConsolePrint( " with " );

Expand Down
8 changes: 7 additions & 1 deletion cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ void CBasePlayerWeapon::PrintState( void )
COM_Log( "c:\\hl.log", "%i ", m_iClip );
}

int RandomLong( int a, int b )
{
return gEngfuncs.pfnRandomLong(a, b);
}


/*
=====================
HUD_InitClientWeapons
Expand Down Expand Up @@ -615,7 +621,7 @@ void HUD_InitClientWeapons( void )
// Pass through to engine
g_engfuncs.pfnPrecacheEvent = gEngfuncs.pfnPrecacheEvent;
g_engfuncs.pfnRandomFloat = gEngfuncs.pfnRandomFloat;
g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong;
g_engfuncs.pfnRandomLong = RandomLong;

// Allocate a slot for the local player
HUD_PrepEntity( &player , NULL );
Expand Down
17 changes: 9 additions & 8 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
#include <stdio.h>
#include "parsemsg.h"
#include "hud_servers.h"



#include "demo.h"
#include "demo_api.h"


cvar_t *hud_textmode;
float g_hud_text_color[3];


extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount);
Expand Down Expand Up @@ -186,7 +187,7 @@ void CHud :: Init( void )

CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round

hud_textmode = CVAR_CREATE ( "hud_textmode", "0", FCVAR_ARCHIVE );

m_iLogo = 0;
m_iFOV = 0;
Expand Down Expand Up @@ -229,8 +230,8 @@ void CHud :: Init( void )
m_AmmoSecondary.Init();
m_TextMessage.Init();
m_StatusIcons.Init();
m_MOTD.Init();
m_Scoreboard.Init();
m_MOTD.Init();
m_Scoreboard.Init();

m_Menu.Init();

Expand Down Expand Up @@ -258,7 +259,7 @@ CHud :: ~CHud()
m_pHudList = NULL;
}



}

// GetSpriteIndex()
Expand Down Expand Up @@ -400,8 +401,8 @@ void CHud :: VidInit( void )
m_AmmoSecondary.VidInit();
m_TextMessage.VidInit();
m_StatusIcons.VidInit();
m_Scoreboard.VidInit();
m_MOTD.VidInit();
m_Scoreboard.VidInit();
m_MOTD.VidInit();

}

Expand Down
9 changes: 5 additions & 4 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class CHudScoreboard: public CHudBase

void GetAllPlayersInfo( void );
};



//
//-----------------------------------------------------
Expand Down Expand Up @@ -610,7 +610,8 @@ class CHud
int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b );
int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b );
int GetNumWidth(int iNumber, int iFlags);
void DrawDarkRectangle( int x, int y, int wide, int tall);
int DrawHudStringLen( char *szIt );
void DrawDarkRectangle( int x, int y, int wide, int tall);

private:
// the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded.
Expand Down Expand Up @@ -651,7 +652,7 @@ class CHud
CHudStatusIcons m_StatusIcons;
CHudScoreboard m_Scoreboard;
CHudMOTD m_MOTD;



void Init( void );
void VidInit( void );
Expand Down Expand Up @@ -682,7 +683,7 @@ class CHud
// sprite indexes
int m_HUD_number_0;

int m_iNoConsolePrint;
int m_iNoConsolePrint;

void AddHudElem(CHudBase *p);

Expand Down
Loading

0 comments on commit d254f1b

Please sign in to comment.