diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index ab705af4..edf61517 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -88,7 +88,6 @@ SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp -SRCS+=./overview.cpp SRCS+=./parsemsg.cpp SRCS_C+=../pm_shared/pm_debug.c SRCS_C+=../pm_shared/pm_math.c diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 9808a063..7812cb56 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -116,7 +116,6 @@ set (CLDLL_SOURCES input_xash3d.cpp menu.cpp message.cpp - overview.cpp parsemsg.cpp ../pm_shared/pm_debug.c ../pm_shared/pm_math.c diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index c48a9af1..1ca1c0f8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -134,7 +134,8 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf ) BEGIN_READ( pbuf, iSize ); int is_finished = READ_BYTE(); - strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - 1 ); + strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - strlen(m_szMOTD) - 1 ); + m_szMOTD[sizeof(m_szMOTD) - 1] = '\0'; if( is_finished ) { diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat index cc4ed5ac..720d1e3f 100644 --- a/cl_dll/compile.bat +++ b/cl_dll/compile.bat @@ -54,7 +54,6 @@ set SOURCES=../dlls/crossbow.cpp ^ input_xash3d.cpp ^ menu.cpp ^ message.cpp ^ - overview.cpp ^ parsemsg.cpp ^ ../pm_shared/pm_debug.c ^ ../pm_shared/pm_math.c ^ diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index e57d04be..a2738b70 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -173,6 +173,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu char killedwith[32]; strcpy( killedwith, "d_" ); strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 ); + killedwith[sizeof(killedwith) - 1] = '\0'; #if USE_VGUI if (gViewPort) @@ -209,7 +210,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu else { rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); - strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); + strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH - 1 ); rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0; } @@ -235,7 +236,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu else { rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); - strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); + strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH - 1 ); rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0; } diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index f8030f77..6123ce13 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -261,7 +261,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe ) } else if( pe->rendermode != kRenderNormal ) { - sprintf( decalname, "{bproof1" ); + strcpy( decalname, "{bproof1" ); } else { diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index fba05d30..6ea2084f 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -572,8 +572,8 @@ void CHud::VidInit( void ) sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; - strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); - + strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 ); + m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0'; index++; } @@ -615,8 +615,8 @@ void CHud::VidInit( void ) sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; - strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); - + strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 ); + m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0'; index++; } diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index a0bd5576..9c83d8cc 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -243,9 +243,7 @@ int CHud::Redraw( float flTime, int intermission ) if( m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - m_hsprCursor = SPR_Load( sz ); + m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } SPR_Set( m_hsprCursor, 250, 250, 250 ); diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index c20e6ba0..7e115f51 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -448,12 +448,12 @@ int CHudSpectator::Draw( float flTime ) color = GetClientColor( i + 1 ); // draw the players name and health underneath - sprintf( string, "%s", g_PlayerInfoList[i + 1].name ); + strcpy( string, g_PlayerInfoList[i + 1].name ); lx = strlen( string ) * 3; // 3 is avg. character length :) DrawSetTextColor( color[0], color[1], color[2] ); - DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); + DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); } return 1; @@ -537,7 +537,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf ) msg->holdtime = READ_FLOAT(); // holdtime msg->fxtime = READ_FLOAT(); // fxtime; - strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 128 ); + strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 127 ); m_HUDMessageText[m_lastHudMessage][127] = 0; // text msg->pMessage = m_HUDMessageText[m_lastHudMessage]; diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index e9166979..45147e78 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -157,7 +157,7 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) { if( !m_fWaitingForMore ) // this is the start of a new menu { - strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); + strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - 1 ); } else { @@ -169,13 +169,13 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) if( !NeedMore ) { // we have the whole string, so we can localise it now - strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); + strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING - 1 ); g_szMenuString[MAX_MENU_STRING - 1] = '\0'; // Swap in characters if( KB_ConvertString( g_szMenuString, &temp ) ) { - strncpy( g_szMenuString, temp, MAX_MENU_STRING ); + strncpy( g_szMenuString, temp, MAX_MENU_STRING - 1 ); g_szMenuString[MAX_MENU_STRING - 1] = '\0'; free( temp ); } diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp deleted file mode 100644 index 81f028e2..00000000 --- a/cl_dll/overview.cpp +++ /dev/null @@ -1,161 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#include "hud.h" -#include "cl_util.h" -#include "cl_entity.h" -#include "triangleapi.h" -#include "overview.h" - -// these are included for the math functions -#include "com_model.h" -#include "studio_util.h" - -#pragma warning(disable: 4244) - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -int CHudOverview::Init() -{ - gHUD.AddHudElem(this); - - m_iFlags |= HUD_ACTIVE; - - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: Loads new icons -//----------------------------------------------------------------------------- -int CHudOverview::VidInit() -{ - m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" ); - m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" ); - - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: -// Input : flTime - -// intermission - -//----------------------------------------------------------------------------- -int CHudOverview::Draw( float flTime ) -{ -#if 0 - // only draw in overview mode - if( !gEngfuncs.Overview_GetOverviewState() ) - return 1; - - // make sure we have player info - //gViewPort->GetAllPlayersInfo(); - gHUD.m_Scoreboard.GetAllPlayersInfo(); - - // calculate player size on the overview - int x1, y1, x2, y2; - float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f }; - gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 ); - gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 ); - float scale = abs( x2 - x1 ); - - // loop through all the players and draw them on the map - for( int i = 1; i < MAX_PLAYERS; i++ ) - { - cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i ); - - if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT ) - { - int x, y, z = 0; - float v[3] = { pl->origin[0], pl->origin[1], 0 }; - gEngfuncs.Overview_WorldToScreen( v, &x, &y ); - - // hack in some team colors - float r, g, bc; - if( g_PlayerExtraInfo[i].teamnumber == 1 ) - { - r = 0.0f; g = 0.0f; bc = 1.0f; - } - else if( g_PlayerExtraInfo[i].teamnumber == 2 ) - { - r = 1.0f; g = 0.0f; bc = 0.0f; - } - else - { - // just use the default orange color if the team isn't set - r = 1.0f; g = 0.7f; bc = 0.0f; - } - - // set the current texture - gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 ); - - // additive render mode - gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); - - // no culling - gEngfuncs.pTriAPI->CullFace( TRI_NONE ); - - // draw a square - gEngfuncs.pTriAPI->Begin( TRI_QUADS ); - - // set the color to be that of the team - gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f ); - - // calculate rotational matrix - vec3_t a, b, angles; - float rmatrix[3][4]; // transformation matrix - VectorCopy( pl->angles, angles ); - angles[0] = 0.0f; - angles[1] += 90.f; - angles[1] = -angles[1]; - angles[2] = 0.0f; - AngleMatrix( angles, rmatrix ); - a[2] = 0; - - a[0] = -scale; a[1] = -scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = -scale; a[1] = scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = scale; a[1] = scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - a[0] = scale; a[1] = -scale; - VectorTransform( a, rmatrix, b ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - - // finish up - gEngfuncs.pTriAPI->End(); - gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); - - // draw the players name and health underneath - char string[256]; - sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health ); - DrawConsoleString( x, y + ( 1.1 * scale ), string ); - } - } -#endif - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: called every time a server is connected to -//----------------------------------------------------------------------------- -void CHudOverview::InitHUDData() -{ - //this block would force the spectator view to be on - //gEngfuncs.Overview_SetDrawOverview( 1 ); - //gEngfuncs.Overview_SetDrawInset( 0 ); -} diff --git a/cl_dll/overview.h b/cl_dll/overview.h deleted file mode 100644 index 4c1dc4d8..00000000 --- a/cl_dll/overview.h +++ /dev/null @@ -1,27 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= -#pragma once -#if !defined(OVERVIEW_H) -#define OVERVIEW_H - -//----------------------------------------------------------------------------- -// Purpose: Handles the drawing of the top-down map and all the things on it -//----------------------------------------------------------------------------- -class CHudOverview : public CHudBase -{ -public: - int Init(); - int VidInit(); - - int Draw( float flTime ); - void InitHUDData( void ); - -private: - HSPRITE m_hsprPlayer; - HSPRITE m_hsprViewcone; -}; -#endif // OVERVIEW_H diff --git a/cl_dll/saytext.cpp b/cl_dll/saytext.cpp index d7a7dd98..35d08bec 100644 --- a/cl_dll/saytext.cpp +++ b/cl_dll/saytext.cpp @@ -133,7 +133,7 @@ int CHudSayText::Draw( float flTime ) static char buf[MAX_PLAYER_NAME_LENGTH + 32]; // draw the first x characters in the player color - strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) ); + strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 ) ); buf[Q_min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0; DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); int x = DrawConsoleString( LINE_START, y, buf ); diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index ccd4f3f0..82664b43 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -453,7 +453,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( g_PlayerInfoList[best_player].packetloss >= 63 ) { UnpackRGB( r, g, b, RGB_REDISH ); - sprintf( buf, " !!!!" ); + strcpy( buf, " !!!!" ); } else { @@ -524,7 +524,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf if( cl > 0 && cl <= MAX_PLAYERS ) { // set the players team - strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME ); + strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME - 1 ); } // rebuild the list of teams @@ -566,7 +566,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf } m_iNumTeams = Q_max( j, m_iNumTeams ); - strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME ); + strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME - 1 ); g_TeamInfo[j].players = 0; } diff --git a/cl_dll/statusbar.cpp b/cl_dll/statusbar.cpp index 79f30b7e..41b5008e 100644 --- a/cl_dll/statusbar.cpp +++ b/cl_dll/statusbar.cpp @@ -141,7 +141,8 @@ void CHudStatusBar::ParseStatusString( int line_num ) GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] ); if( g_PlayerInfoList[indexval].name != NULL ) { - strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH ); + strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH - 1 ); + szRepString[MAX_PLAYER_NAME_LENGTH - 1] = '\0'; m_pflNameColors[line_num] = GetClientColor( indexval ); } else @@ -231,7 +232,7 @@ int CHudStatusBar::MsgFunc_StatusText( const char *pszName, int iSize, void *pbu if( line < 0 || line >= MAX_STATUSBAR_LINES ) return 1; - strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH ); + strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH - 1 ); m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) if( m_szStatusText[0] == 0 ) diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 0c45307c..0088daf3 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -50,9 +50,7 @@ void Draw_Triangles( void ) if( gHUD.m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - gHUD.m_hsprCursor = SPR_Load( sz ); + gHUD.m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) ) diff --git a/cl_dll/vgui_ClassMenu.cpp b/cl_dll/vgui_ClassMenu.cpp index 568ed98c..02a0a389 100644 --- a/cl_dll/vgui_ClassMenu.cpp +++ b/cl_dll/vgui_ClassMenu.cpp @@ -100,147 +100,6 @@ CClassMenuPanel::CClassMenuPanel( int iTrans, int iRemoveMe, int x, int y, int w m_pScrollPanel->setScrollBarVisible( false, false ); m_pScrollPanel->validate(); - // Create the Class buttons -#ifdef _TFC - for( int i = 0; i <= PC_RANDOM; i++ ) - { - char sz[256]; - int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y + ( ( CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y ) * i ); - - ActionSignal *pASignal = new CMenuHandler_StringCommandClassSelect( sTFClassSelection[i], true ); - - // Class button - sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ) ); - m_pButtons[i] = new ClassButton( i, sz, CLASSMENU_TOPLEFT_BUTTON_X, iYPos, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y, true ); - - // RandomPC uses '0' - if( i >= 1 && i <= 9 ) - { - sprintf( sz, "%d", i ); - } - else - { - strcpy( sz, "0" ); - } - m_pButtons[i]->setBoundKey( sz[0] ); - m_pButtons[i]->setContentAlignment( vgui::Label::a_west ); - m_pButtons[i]->addActionSignal( pASignal ); - m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver(this, i) ); - m_pButtons[i]->setParent( this ); - - // Create the Class Info Window - // m_pClassInfoPanel[i] = new CTransparentPanel( 255, CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y ); - m_pClassInfoPanel[i] = new CTransparentPanel( 255, 0, 0, clientWide, CLASSMENU_WINDOW_SIZE_Y ); - m_pClassInfoPanel[i]->setParent( m_pScrollPanel->getClient() ); - // m_pClassInfoPanel[i]->setVisible( false ); - - // don't show class pic in lower resolutions - int textOffs = XRES( 8 ); - - if( bShowClassGraphic ) - { - textOffs = CLASSMENU_WINDOW_NAME_X; - } - - // Create the Class Name Label - sprintf( sz, "#Title_%s", sTFClassSelection[i] ); - char *localName=CHudTextMessage::BufferedLocaliseTextString( sz ); - Label *pNameLabel = new Label( "", textOffs, CLASSMENU_WINDOW_NAME_Y ); - pNameLabel->setFont( pSchemes->getFont( hTitleScheme ) ); - pNameLabel->setParent( m_pClassInfoPanel[i] ); - pSchemes->getFgColor( hTitleScheme, r, g, b, a ); - pNameLabel->setFgColor( r, g, b, a ); - pSchemes->getBgColor( hTitleScheme, r, g, b, a ); - pNameLabel->setBgColor( r, g, b, a ); - pNameLabel->setContentAlignment( vgui::Label::a_west ); - // pNameLabel->setBorder( new LineBorder() ); - pNameLabel->setText( "%s", localName); - - // Create the Class Image - if( bShowClassGraphic ) - { - for( int team = 0; team < 2; team++ ) - { - if( team == 1 ) - { - sprintf( sz, "%sred", sTFClassSelection[i] ); - } - else - { - sprintf( sz, "%sblue", sTFClassSelection[i] ); - } - - m_pClassImages[team][i] = new CImageLabel( sz, 0, 0, CLASSMENU_WINDOW_TEXT_X, CLASSMENU_WINDOW_TEXT_Y ); - - CImageLabel *pLabel = m_pClassImages[team][i]; - pLabel->setParent( m_pClassInfoPanel[i] ); - // pLabel->setBorder( new LineBorder() ); - - if( team != 1 ) - { - pLabel->setVisible( false ); - } - - // Reposition it based upon it's size - int xOut, yOut; - pNameLabel->getTextSize( xOut, yOut ); - pLabel->setPos( ( CLASSMENU_WINDOW_TEXT_X - pLabel->getWide() ) / 2, yOut / 2 ); - } - } - - // Create the Player count string - gHUD.m_TextMessage.LocaliseTextString( "#Title_CurrentlyOnYourTeam", m_sPlayersOnTeamString, STRLENMAX_PLAYERSONTEAM ); - m_pPlayers[i] = new Label( "", textOffs, CLASSMENU_WINDOW_PLAYERS_Y ); - m_pPlayers[i]->setParent( m_pClassInfoPanel[i] ); - m_pPlayers[i]->setBgColor( 0, 0, 0, 255 ); - m_pPlayers[i]->setContentAlignment( vgui::Label::a_west ); - m_pPlayers[i]->setFont( pSchemes->getFont( hClassWindowText ) ); - - // Open up the Class Briefing File - sprintf(sz, "classes/short_%s.txt", sTFClassSelection[i]); - char *cText = "Class Description not available."; - char *pfile = (char *)gEngfuncs.COM_LoadFile( sz, 5, NULL ); - if( pfile ) - { - cText = pfile; - } - - // Create the Text info window - TextPanel *pTextWindow = new TextPanel( cText, textOffs, CLASSMENU_WINDOW_TEXT_Y, ( CLASSMENU_WINDOW_SIZE_X - textOffs ) - 5, CLASSMENU_WINDOW_SIZE_Y - CLASSMENU_WINDOW_TEXT_Y ); - pTextWindow->setParent( m_pClassInfoPanel[i] ); - pTextWindow->setFont( pSchemes->getFont( hClassWindowText ) ); - pSchemes->getFgColor( hClassWindowText, r, g, b, a ); - pTextWindow->setFgColor( r, g, b, a ); - pSchemes->getBgColor( hClassWindowText, r, g, b, a ); - pTextWindow->setBgColor( r, g, b, a ); - - // Resize the Info panel to fit it all - int wide,tall; - pTextWindow->getTextImage()->getTextSizeWrapped( wide, tall ); - pTextWindow->setSize( wide, tall ); - - int xx, yy; - pTextWindow->getPos( xx, yy ); - int maxX = xx + wide; - int maxY = yy + tall; - - //check to see if the image goes lower than the text - //just use the red teams [0] images - if( m_pClassImages[0][i] != null ) - { - m_pClassImages[0][i]->getPos( xx, yy ); - if( ( yy + m_pClassImages[0][i]->getTall() ) > maxY ) - { - maxY = yy + m_pClassImages[0][i]->getTall(); - } - } - - m_pClassInfoPanel[i]->setSize( maxX , maxY ); - if( pfile ) - gEngfuncs.COM_FreeFile( pfile ); - // m_pClassInfoPanel[i]->setBorder( new LineBorder() ); - } -#endif // Create the Cancel button m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y ); m_pCancelButton->setParent( this ); @@ -258,96 +117,6 @@ void CClassMenuPanel::Update() int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y; - // Cycle through the rest of the buttons -#ifdef _TFC - for( int i = 0; i <= PC_RANDOM; i++ ) - { - bool bCivilian = ( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 ); - - if( bCivilian ) - { - // If this team can only be civilians, only the civilian button's visible - if( i == 0 ) - { - m_pButtons[0]->setVisible( true ); - SetActiveInfo( 0 ); - iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y; - } - else - { - m_pButtons[i]->setVisible( false ); - } - } - else - { - if( m_pButtons[i]->IsNotValid() || i == 0 ) - { - m_pButtons[i]->setVisible( false ); - } - else - { - m_pButtons[i]->setVisible( true ); - m_pButtons[i]->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos ); - iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y; - - // Start with the first option up - if( !m_iCurrentInfo ) - SetActiveInfo( i ); - } - } - - // Now count the number of teammembers of this class - int iTotal = 0; - for( int j = 1; j < MAX_PLAYERS; j++ ) - { - if( g_PlayerInfoList[j].name == 0 ) - continue; // empty player slot, skip - if( g_PlayerExtraInfo[j].teamname[0] == 0 ) - continue; // skip over players who are not in a team - if( g_PlayerInfoList[j].thisplayer ) - continue; // skip this player - if( g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber ) - continue; // skip over players in other teams - - // If this team is forced to be civilians, just count the number of teammates - if( g_PlayerExtraInfo[j].playerclass != i && !bCivilian ) - continue; - - iTotal++; - } - - char sz[256]; - sprintf( sz, m_sPlayersOnTeamString, iTotal ); - m_pPlayers[i]->setText( "%s", sz ); - - // Set the text color to the teamcolor - m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0], - iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1], - iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2], - 0 ); - - // set the graphic to be the team pick - for( int team = 0; team < MAX_TEAMS; team++ ) - { - // unset all the other images - if( m_pClassImages[team][i] ) - { - m_pClassImages[team][i]->setVisible( false ); - } - - // set the current team image - if( m_pClassImages[g_iTeamNumber - 1][i] != 0 ) - { - m_pClassImages[g_iTeamNumber - 1][i]->setVisible( true ); - } - else if( m_pClassImages[0][i] ) - { - m_pClassImages[0][i]->setVisible( true ); - } - } - } -#endif - // If the player already has a class, make the cancel button visible if( g_iPlayerClass ) { @@ -415,16 +184,7 @@ void CClassMenuPanel::Initialize( void ) void CClassMenuPanel::SetActiveInfo( int iInput ) { // Remove all the Info panels and bring up the specified one -#ifdef _TFC - for( int i = 0; i <= PC_RANDOM; i++ ) - { - m_pButtons[i]->setArmed( false ); - m_pClassInfoPanel[i]->setVisible( false ); - } - - if( iInput > PC_RANDOM || iInput < 0 ) -#endif - iInput = 0; + iInput = 0; m_pButtons[iInput]->setArmed( true ); m_pClassInfoPanel[iInput]->setVisible( true ); diff --git a/cl_dll/vgui_CustomObjects.cpp b/cl_dll/vgui_CustomObjects.cpp index 920956a3..d14e59bc 100644 --- a/cl_dll/vgui_CustomObjects.cpp +++ b/cl_dll/vgui_CustomObjects.cpp @@ -154,7 +154,7 @@ void CommandButton::RecalculateText( void ) void CommandButton::setText( const char *text ) { - strncpy( m_sMainText, text, MAX_BUTTON_SIZE ); + strncpy( m_sMainText, text, MAX_BUTTON_SIZE - 1 ); m_sMainText[MAX_BUTTON_SIZE - 1] = 0; RecalculateText(); @@ -304,21 +304,12 @@ int ClassButton::IsNotValid() return false; } - // Is it an illegal class? -#ifdef _TFC - if( ( gViewPort->GetValidClasses( 0 ) & sTFValidClassInts[m_iPlayerClass] ) || ( gViewPort->GetValidClasses( g_iTeamNumber ) & sTFValidClassInts[m_iPlayerClass] ) ) - return true; -#endif - // Only check current class if they've got autokill on bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0; if( bAutoKill ) { // Is it the player's current class? if ( -#ifdef _TFC - (gViewPort->IsRandomPC() && m_iPlayerClass == PC_RANDOM) || -#endif (!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) ) return true; } @@ -539,13 +530,11 @@ void CMenuHandler_StringCommandClassSelect::actionPerformed( Panel *panel ) { CMenuHandler_StringCommand::actionPerformed( panel ); - // THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN + // THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN // HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS". -#if !defined _TFC bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0; if( bAutoKill && g_iPlayerClass != 0 ) gEngfuncs.pfnClientCmd( "kill" ); -#endif } diff --git a/cl_dll/vgui_SchemeManager.cpp b/cl_dll/vgui_SchemeManager.cpp index dddd268c..e50e5b73 100644 --- a/cl_dll/vgui_SchemeManager.cpp +++ b/cl_dll/vgui_SchemeManager.cpp @@ -205,7 +205,7 @@ CSchemeManager::CSchemeManager( int xRes, int yRes ) static const int tokenSize = 64; char paramName[tokenSize], paramValue[tokenSize]; - strncpy( paramName, token, tokenSize ); + strncpy( paramName, token, tokenSize - 1 ); paramName[tokenSize-1] = 0; // ensure null termination // get the '=' character @@ -225,7 +225,7 @@ CSchemeManager::CSchemeManager( int xRes, int yRes ) // get paramValue pFile = gEngfuncs.COM_ParseFile( pFile, token ); - strncpy( paramValue, token, tokenSize ); + strncpy( paramValue, token, tokenSize - 1 ); paramValue[tokenSize-1] = 0; // ensure null termination // is this a new scheme? @@ -278,7 +278,7 @@ CSchemeManager::CSchemeManager( int xRes, int yRes ) pScheme = &tmpSchemes[currentScheme]; hasFgColor = hasBgColor = hasArmedFgColor = hasArmedBgColor = hasMouseDownFgColor = hasMouseDownBgColor = false; - strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH ); + strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH - 1 ); pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH-1] = '\0'; // ensure null termination of string } @@ -291,7 +291,7 @@ CSchemeManager::CSchemeManager( int xRes, int yRes ) // pull the data out into the scheme if ( !stricmp(paramName, "FontName") ) { - strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH ); + strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH - 1 ); pScheme->fontName[CScheme::FONT_NAME_LENGTH-1] = 0; } else if ( !stricmp(paramName, "FontSize") ) diff --git a/cl_dll/vgui_ScorePanel.cpp b/cl_dll/vgui_ScorePanel.cpp index d71685ef..13c2fb19 100644 --- a/cl_dll/vgui_ScorePanel.cpp +++ b/cl_dll/vgui_ScorePanel.cpp @@ -256,10 +256,7 @@ void ScorePanel::Update() // Set the title if( gViewPort->m_szServerName[0] != '\0' ) { - char sz[MAX_SERVERNAME_LENGTH + 16]; - - sprintf( sz, "%s", gViewPort->m_szServerName ); - m_TitleLabel.setText( sz ); + m_TitleLabel.setText( gViewPort->m_szServerName ); } m_iRows = 0; @@ -502,7 +499,7 @@ void ScorePanel::RebuildTeams() } m_iNumTeams = Q_max( j, m_iNumTeams ); - strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME ); + strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME - 1 ); g_TeamInfo[j].players = 0; } @@ -684,7 +681,7 @@ void ScorePanel::FillGrid() } // Fill out with the correct data - strcpy(sz, ""); + sz[0] = '\0'; if ( m_iIsATeam[row] ) { char sz2[128]; @@ -694,11 +691,11 @@ void ScorePanel::FillGrid() case COLUMN_NAME: if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { - sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); + strcpy( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); } else { - sprintf( sz2, "%s", gViewPort->GetTeamName(team_info->teamnumber) ); + strcpy( sz2, gViewPort->GetTeamName(team_info->teamnumber) ); } strcpy(sz, sz2); @@ -776,11 +773,6 @@ void ScorePanel::FillGrid() // Don't show classes if this client hasnt picked a team yet if ( g_iTeamNumber == 0 ) bShowClass = false; -#ifdef _TFC - // in TFC show all classes in spectator mode - if ( g_iUser1 ) - bShowClass = true; -#endif if (bShowClass) { @@ -795,7 +787,7 @@ void ScorePanel::FillGrid() if (bNoClass) sz[0] = '\0'; else - sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); + strcpy( sz, CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); } else { @@ -819,21 +811,6 @@ void ScorePanel::FillGrid() } */ break; - -#ifdef _TFC - case COLUMN_KILLS: - if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber) - sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags ); - break; - case COLUMN_DEATHS: - if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber) - sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].deaths ); - break; - case COLUMN_LATENCY: - if (g_PlayerExtraInfo[ m_iSortedRows[row] ].teamnumber) - sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping ); - break; -#else case COLUMN_KILLS: sprintf(sz, "%d", g_PlayerExtraInfo[ m_iSortedRows[row] ].frags ); break; @@ -843,7 +820,6 @@ void ScorePanel::FillGrid() case COLUMN_LATENCY: sprintf(sz, "%d", g_PlayerInfoList[ m_iSortedRows[row] ].ping ); break; -#endif default: break; } @@ -930,14 +906,12 @@ void ScorePanel::mousePressed(MouseCode code, Panel* panel) else { char string1[1024]; - char string2[1024]; // mute the player GetClientVoiceMgr()->SetPlayerBlockedState(iPlayer, true); sprintf( string1, CHudTextMessage::BufferedLocaliseTextString( "#Muted" ), pl_info->name ); - sprintf( string2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#No_longer_hear_that_player" ) ); - sprintf( string, "%c** %s %s\n", HUD_PRINTTALK, string1, string2 ); + sprintf( string, "%c** %s %s\n", HUD_PRINTTALK, string1, CHudTextMessage::BufferedLocaliseTextString( "#No_longer_hear_that_player" ) ); gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string)+1, string ); } diff --git a/cl_dll/vgui_TeamFortressViewport.cpp b/cl_dll/vgui_TeamFortressViewport.cpp index e1d5e58d..21a8a928 100644 --- a/cl_dll/vgui_TeamFortressViewport.cpp +++ b/cl_dll/vgui_TeamFortressViewport.cpp @@ -136,32 +136,6 @@ const char *sTFClassSelection[] = "civilian", }; -#ifdef _TFC -int iBuildingCosts[] = -{ - BUILD_COST_DISPENSER, - BUILD_COST_SENTRYGUN, - BUILD_COST_TELEPORTER -}; - -// This maps class numbers to the Invalid Class bit. -// This is needed for backwards compatability in maps that were finished before -// all the classes were in TF. Hence the wacky sequence. -int sTFValidClassInts[] = -{ - 0, - TF_ILL_SCOUT, - TF_ILL_SNIPER, - TF_ILL_SOLDIER, - TF_ILL_DEMOMAN, - TF_ILL_MEDIC, - TF_ILL_HVYWEP, - TF_ILL_PYRO, - TF_ILL_SPY, - TF_ILL_ENGINEER, - TF_ILL_RANDOMPC, -}; -#endif // Get the name of TGA file, based on GameDir char *GetVGUITGAName( const char *pszName ) @@ -760,7 +734,7 @@ int TeamFortressViewport::CreateCommandMenu( const char *menuFile, int direction { // Get the mapname pfile = gEngfuncs.COM_ParseFile( pfile, token ); - strncpy( szMap, token, MAX_MAPNAME ); + strncpy( szMap, token, MAX_MAPNAME - 1 ); szMap[MAX_MAPNAME - 1] = '\0'; // Get the next token @@ -784,20 +758,6 @@ int TeamFortressViewport::CreateCommandMenu( const char *menuFile, int direction else { // See if it's a Class -#ifdef _TFC - for( int i = 1; i <= PC_ENGINEER; i++ ) - { - if( !strcmp( token, sTFClasses[i] ) ) - { - // Save it off - iPlayerClass = i; - - // Get the button text - pfile = gEngfuncs.COM_ParseFile( pfile, token ); - break; - } - } -#endif } // Get the button bound key @@ -946,21 +906,6 @@ CCommandMenu *TeamFortressViewport::CreateDisguiseSubmenu( CommandButton *pButto CCommandMenu *pMenu = CreateSubMenu( pButton, pParentMenu, iYOffset, iXOffset ); m_pCommandMenus[m_iNumMenus] = pMenu; m_iNumMenus++; - - // create the class choice buttons -#ifdef _TFC - for( int i = PC_SCOUT; i <= PC_ENGINEER; i++ ) - { - CommandButton *pDisguiseButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[i] ), 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - - char sz[256]; - - sprintf( sz, "%s %d", commandText, i ); - pDisguiseButton->addActionSignal( new CMenuHandler_StringCommand( sz ) ); - - pMenu->AddButton( pDisguiseButton ); - } -#endif return pMenu; } @@ -1018,268 +963,7 @@ CommandButton *TeamFortressViewport::CreateCustomButton( char *pButtonText, char pMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset ); m_pCommandMenus[m_iNumMenus] = pMenu; m_iNumMenus++; - -#ifdef _TFC - for( int i = PC_SCOUT; i <= PC_RANDOM; i++ ) - { - char sz[256]; - - // ChangeClass buttons - CHudTextMessage::LocaliseTextString( sLocalisedClasses[i], sz, 256 ); - ClassButton *pClassButton = new ClassButton( i, sz, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y, false ); - - sprintf( sz, "%s", sTFClassSelection[i] ); - pClassButton->addActionSignal( new CMenuHandler_StringCommandClassSelect( sz ) ); - pMenu->AddButton( pClassButton ); - } -#endif - } -#ifdef _TFC - // Map Briefing - else if( !strcmp( pButtonName, "!MAPBRIEFING" ) ) - { - pButton = new CommandButton( pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_MAPBRIEFING ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Class Descriptions - else if( !strcmp( pButtonName, "!CLASSDESC" ) ) - { - pButton = new ClassButton( 0, pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y, false ); - pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_CLASSHELP ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!SERVERINFO" ) ) - { - pButton = new ClassButton( 0, pButtonText, 0, BUTTON_SIZE_Y * m_pCurrentCommandMenu->GetNumButtons(), CMENU_SIZE_X, BUTTON_SIZE_Y, false ); - pButton->addActionSignal( new CMenuHandler_TextWindow( MENU_INTRO ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Spy abilities - else if( !strcmp( pButtonName, "!SPY" ) ) - { - pButton = new DisguiseButton( 0, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - } - // Feign - else if( !strcmp( pButtonName, "!FEIGN" ) ) - { - pButton = new FeignButton( FALSE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "feign" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Feign Silently - else if( !strcmp( pButtonName, "!FEIGNSILENT" ) ) - { - pButton = new FeignButton( FALSE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "sfeign" ) ); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Stop Feigning - else if( !strcmp( pButtonName, "!FEIGNSTOP" ) ) - { - pButton = new FeignButton( TRUE, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "feign" ) ); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Disguise - else if( !strcmp( pButtonName, "!DISGUISEENEMY" ) ) - { - // Create the disguise enemy button, which active only if there are 2 teams - pButton = new DisguiseButton(DISGUISE_TEAM2, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y); - CreateDisguiseSubmenu( pButton, m_pCurrentCommandMenu, "disguise_enemy", iYOffset); - } - else if( !strcmp( pButtonName, "!DISGUISEFRIENDLY" ) ) - { - // Create the disguise friendly button, which active only if there are 1 or 2 teams - pButton = new DisguiseButton( DISGUISE_TEAM1 | DISGUISE_TEAM2, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - CreateDisguiseSubmenu( pButton, m_pCurrentCommandMenu, "disguise_friendly", iYOffset ); - } - else if( !strcmp( pButtonName, "!DISGUISE" ) ) - { - // Create the Disguise button - pButton = new DisguiseButton( DISGUISE_TEAM3 | DISGUISE_TEAM4, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - CCommandMenu *pDisguiseMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset ); - m_pCommandMenus[m_iNumMenus] = pDisguiseMenu; - m_iNumMenus++; - - // Disguise Enemy submenu buttons - for( int i = 1; i <= 4; i++ ) - { - // only show the 4th disguise button if we have 4 teams - m_pDisguiseButtons[i] = new DisguiseButton( ( ( i < 4 ) ? DISGUISE_TEAM3 : 0) | DISGUISE_TEAM4, "Disguise", 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - - pDisguiseMenu->AddButton( m_pDisguiseButtons[i] ); - m_pDisguiseButtons[i]->setParentMenu( pDisguiseMenu ); - - char sz[256]; - - sprintf( sz, "disguise %d", i ); - CreateDisguiseSubmenu( m_pDisguiseButtons[i], pDisguiseMenu, sz, iYOffset, CMENU_SIZE_X - 1 ); - } - } - // Start setting a Detpack - else if( !strcmp( pButtonName, "!DETPACKSTART" ) ) - { - // Detpack Submenu - pButton = new DetpackButton( 2, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - - // Create the submenu - pMenu = CreateSubMenu( pButton, m_pCurrentCommandMenu, iYOffset ); - m_pCommandMenus[m_iNumMenus] = pMenu; - m_iNumMenus++; - - // Set detpack buttons - CommandButton *pDetButton; - pDetButton = new CommandButton( m_sDetpackStrings[0], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 5" ) ); - pMenu->AddButton( pDetButton ); - pDetButton = new CommandButton( m_sDetpackStrings[1], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 20" ) ); - pMenu->AddButton( pDetButton ); - pDetButton = new CommandButton( m_sDetpackStrings[2], 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pDetButton->addActionSignal( new CMenuHandler_StringCommand( "detstart 50" ) ); - pMenu->AddButton( pDetButton ); - } - // Stop setting a Detpack - else if( !strcmp( pButtonName, "!DETPACKSTOP" ) ) - { - pButton = new DetpackButton( 1, pButtonText, 0, BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "detstop" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Engineer building - else if( !strcmp( pButtonName, "!BUILD" ) ) - { - // only appears if the player is an engineer, and either they have built something or have enough metal to build - pButton = new BuildButton( BUILDSTATE_BASE, 0, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - } - else if( !strcmp( pButtonName, "!BUILDSENTRY" ) ) - { - pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "build 2" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!BUILDDISPENSER" ) ) - { - pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "build 1" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!ROTATESENTRY180" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "rotatesentry180" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!ROTATESENTRY" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "rotatesentry" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if( !strcmp( pButtonName, "!DISMANTLEDISPENSER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "dismantle 1" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); } - else if( !strcmp( pButtonName, "!DISMANTLESENTRY" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "dismantle 2" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!DETONATEDISPENSER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::DISPENSER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "detdispenser" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - else if( !strcmp( pButtonName, "!DETONATESENTRY" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::SENTRYGUN, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "detsentry" ) ); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!BUILDENTRYTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("build 4")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!DISMANTLEENTRYTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("dismantle 4")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!DETONATEENTRYTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::ENTRY_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("detentryteleporter")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!BUILDEXITTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_CANBUILD, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("build 5")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!DISMANTLEEXITTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("dismantle 5")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput(pButton, m_pCurrentCommandMenu) ); - } - else if ( !strcmp( pButtonName, "!DETONATEEXITTELEPORTER" ) ) - { - pButton = new BuildButton( BUILDSTATE_HASBUILDING, BuildButton::EXIT_TELEPORTER, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y); - pButton->addActionSignal(new CMenuHandler_StringCommand("detexitteleporter")); - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } - // Stop building - else if( !strcmp( pButtonName, "!BUILDSTOP" ) ) - { - pButton = new BuildButton( BUILDSTATE_BUILDING, 0, pButtonText, 0, BUTTON_SIZE_Y * 2, CMENU_SIZE_X, BUTTON_SIZE_Y ); - pButton->addActionSignal( new CMenuHandler_StringCommand( "build" ) ); - - // Create an input signal that'll popup the current menu - pButton->addInputSignal( new CMenuHandler_PopupSubMenuInput( pButton, m_pCurrentCommandMenu ) ); - } -#endif return pButton; } @@ -1433,22 +1117,8 @@ void TeamFortressViewport::InputPlayerSpecial( void ) if( !m_iInitialized ) return; -#ifdef _TFC - if( g_iPlayerClass == PC_ENGINEER || g_iPlayerClass == PC_SPY ) - { - ShowCommandMenu( gViewPort->m_StandardMenu ); - - if( m_pCurrentCommandMenu ) - { - m_pCurrentCommandMenu->KeyInput( '7' ); - } - } - else -#endif - { - // if it's any other class, just send the command down to the server - ClientCmd( "_special" ); - } + // if it's any other class, just send the command down to the server + ClientCmd( "_special" ); } // Set the submenu of the Command Menu @@ -1573,7 +1243,7 @@ void TeamFortressViewport::UpdateSpectatorPanel() // create player & health string if( player && name ) { - strncpy( bottomText, name, sizeof(bottomText) ); + strncpy( bottomText, name, sizeof(bottomText) - 1 ); bottomText[ sizeof(bottomText) - 1 ] = 0; pBottomText = bottomText; } @@ -1639,9 +1309,9 @@ void TeamFortressViewport::UpdateSpectatorPanel() if( timer < 0 ) timer = 0; - _snprintf( szText, 63, "%d:%02d\n", ( timer / 60 ), ( timer % 60 ) ); + _snprintf( szText, sizeof(szText) - 1, "%d:%02d\n", ( timer / 60 ), ( timer % 60 ) ); - szText[63] = 0; + szText[sizeof(szText) - 1] = '\0'; m_pSpectatorPanel->m_CurrentTime->setText( szText ); */ @@ -1764,54 +1434,9 @@ CMenuPanel *TeamFortressViewport::CreateTextWindow( int iTextToShow ) cText = pfile; - strncpy( cTitle, m_sMapName, MAX_TITLE_LENGTH ); + strncpy( cTitle, m_sMapName, MAX_TITLE_LENGTH - 1 ); cTitle[MAX_TITLE_LENGTH - 1] = 0; } -#ifdef _TFC - else if( iTextToShow == SHOW_CLASSDESC ) - { - switch( g_iPlayerClass ) - { - case PC_SCOUT: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_scout" ); - CHudTextMessage::LocaliseTextString( "#Title_scout", cTitle, MAX_TITLE_LENGTH ); break; - case PC_SNIPER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_sniper" ); - CHudTextMessage::LocaliseTextString( "#Title_sniper", cTitle, MAX_TITLE_LENGTH ); break; - case PC_SOLDIER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_soldier" ); - CHudTextMessage::LocaliseTextString( "#Title_soldier", cTitle, MAX_TITLE_LENGTH ); break; - case PC_DEMOMAN: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_demoman" ); - CHudTextMessage::LocaliseTextString( "#Title_demoman", cTitle, MAX_TITLE_LENGTH ); break; - case PC_MEDIC: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_medic" ); - CHudTextMessage::LocaliseTextString( "#Title_medic", cTitle, MAX_TITLE_LENGTH ); break; - case PC_HVYWEAP: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_hwguy" ); - CHudTextMessage::LocaliseTextString( "#Title_hwguy", cTitle, MAX_TITLE_LENGTH ); break; - case PC_PYRO: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_pyro" ); - CHudTextMessage::LocaliseTextString( "#Title_pyro", cTitle, MAX_TITLE_LENGTH ); break; - case PC_SPY: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_spy" ); - CHudTextMessage::LocaliseTextString( "#Title_spy", cTitle, MAX_TITLE_LENGTH ); break; - case PC_ENGINEER: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_engineer" ); - CHudTextMessage::LocaliseTextString( "#Title_engineer", cTitle, MAX_TITLE_LENGTH ); break; - case PC_CIVILIAN: cText = CHudTextMessage::BufferedLocaliseTextString( "#Help_civilian" ); - CHudTextMessage::LocaliseTextString( "#Title_civilian", cTitle, MAX_TITLE_LENGTH ); break; - default: - return NULL; - } - - if( g_iPlayerClass == PC_CIVILIAN ) - { - strcpy(sz, "classes/long_civilian.txt"); - } - else - { - sprintf( sz, "classes/long_%s.txt", sTFClassSelection[g_iPlayerClass] ); - } - - char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL ); - if( pfile ) - { - cText = pfile; - } - } -#endif else if( iTextToShow == SHOW_SPECHELP ) { CHudTextMessage::LocaliseTextString( "#Spec_Help_Title", cTitle, MAX_TITLE_LENGTH ); @@ -2413,7 +2038,7 @@ int TeamFortressViewport::MsgFunc_ServerName( const char *pszName, int iSize, vo { BEGIN_READ( pbuf, iSize ); - strncpy( m_szServerName, READ_STRING(), sizeof(m_szServerName) ); + strncpy( m_szServerName, READ_STRING(), sizeof(m_szServerName) - 1 ); m_szServerName[sizeof(m_szServerName) - 1] = 0; return 1; @@ -2534,100 +2159,14 @@ int TeamFortressViewport::MsgFunc_AllowSpec( const char *pszName, int iSize, voi return 1; } -#if defined( _TFC ) -const Vector& GetTeamColor( int team_no ); -extern globalvars_t *gpGlobals; -#endif - // used to reset the player's screen immediately int TeamFortressViewport::MsgFunc_ResetFade( const char *pszName, int iSize, void *pbuf ) { -#if defined( _TFC ) - if ( !gpGlobals ) - return 0; - - screenfade_t sf; - gEngfuncs.pfnGetScreenFade( &sf ); - - sf.fader = 0; - sf.fadeg = 0; - sf.fadeb = 0; - sf.fadealpha = 0; - - sf.fadeEnd = 0.1; - sf.fadeReset = 0.0; - sf.fadeSpeed = 0.0; - - sf.fadeFlags = FFADE_IN; - - sf.fadeReset += gpGlobals->time; - sf.fadeEnd += sf.fadeReset; - - gEngfuncs.pfnSetScreenFade( &sf ); -#endif - return 1; } // used to fade a player's screen out/in when they're spectating someone who is teleported int TeamFortressViewport::MsgFunc_SpecFade( const char *pszName, int iSize, void *pbuf ) { -#if defined( _TFC ) - BEGIN_READ( pbuf, iSize ); - - int iIndex = READ_BYTE(); - - // we're in first-person spectator mode (...not first-person in the PIP) - if ( g_iUser1 == OBS_IN_EYE ) - { - // this is the person we're watching - if ( g_iUser2 == iIndex ) - { - int iFade = READ_BYTE(); - int iTeam = READ_BYTE(); - float flTime = ( (float)READ_SHORT() / 100.0 ); - int iAlpha = READ_BYTE(); - - Vector team = GetTeamColor( iTeam ); - - screenfade_t sf; - gEngfuncs.pfnGetScreenFade( &sf ); - - sf.fader = team[0]; - sf.fadeg = team[1]; - sf.fadeb = team[2]; - sf.fadealpha = iAlpha; - - sf.fadeEnd = flTime; - sf.fadeReset = 0.0; - sf.fadeSpeed = 0.0; - - if ( iFade == BUILD_TELEPORTER_FADE_OUT ) - { - sf.fadeFlags = FFADE_OUT; - sf.fadeReset = flTime; - - if ( sf.fadeEnd ) - sf.fadeSpeed = -(float)sf.fadealpha / sf.fadeEnd; - - sf.fadeTotalEnd = sf.fadeEnd += gpGlobals->time; - sf.fadeReset += sf.fadeEnd; - } - else - { - sf.fadeFlags = FFADE_IN; - - if ( sf.fadeEnd ) - sf.fadeSpeed = (float)sf.fadealpha / sf.fadeEnd; - - sf.fadeReset += gpGlobals->time; - sf.fadeEnd += sf.fadeReset; - } - - gEngfuncs.pfnSetScreenFade( &sf ); - } - } -#endif - return 1; } diff --git a/cl_dll/vgui_TeamFortressViewport.h b/cl_dll/vgui_TeamFortressViewport.h index ee295b59..023d716d 100644 --- a/cl_dll/vgui_TeamFortressViewport.h +++ b/cl_dll/vgui_TeamFortressViewport.h @@ -32,9 +32,6 @@ #include "vgui_SchemeManager.h" #define TF_DEFS_ONLY -#ifdef _TFC -#include "../tfc/tf_defs.h" -#else #define PC_LASTCLASS 10 #define PC_UNDEFINED 0 #define MENU_DEFAULT 1 @@ -46,7 +43,6 @@ #define MENU_CLASSHELP2 7 #define MENU_REPEATHELP 8 #define MENU_SPECHELP 9 -#endif using namespace vgui; class Cursor; @@ -850,7 +846,7 @@ protected: public: CMenuHandler_SpectateFollow( char *player ) { - strncpy( m_szplayer, player, MAX_COMMAND_SIZE); + strncpy( m_szplayer, player, MAX_COMMAND_SIZE - 1 ); m_szplayer[MAX_COMMAND_SIZE-1] = '\0'; } @@ -1031,12 +1027,6 @@ public: virtual int IsNotValid() { - // Only visible for spies -#ifdef _TFC - if( g_iPlayerClass != PC_SPY ) - return true; -#endif - if( m_iFeignState == gViewPort->GetIsFeigning() ) return false; @@ -1079,12 +1069,6 @@ public: virtual int IsNotValid() { -#ifdef _TFC - // Only visible for spies - if( g_iPlayerClass != PC_SPY ) - return true; -#endif - // if it's not tied to a specific team, then always show (for spies) if( !m_iValidTeamsBits ) return false; @@ -1110,12 +1094,6 @@ public: virtual int IsNotValid() { -#ifdef _TFC - // Only visible for demomen - if( g_iPlayerClass != PC_DEMOMAN ) - return true; -#endif - if( m_iDetpackState == gViewPort->GetIsSettingDetpack() ) return false; @@ -1152,64 +1130,6 @@ public: virtual int IsNotValid() { -#ifdef _TFC - // Only visible for engineers - if( g_iPlayerClass != PC_ENGINEER ) - return true; - - // If this isn't set, it's only active when they're not building - if( m_iBuildState & BUILDSTATE_BUILDING ) - { - // Make sure the player's building - if( !( gViewPort->GetBuildState() & BS_BUILDING ) ) - return true; - } - else - { - // Make sure the player's not building - if( gViewPort->GetBuildState() & BS_BUILDING ) - return true; - } - - if( m_iBuildState & BUILDSTATE_BASE ) - { - // Only appear if we've got enough metal to build something, or something already built - if ( gViewPort->GetBuildState() & (BS_HAS_SENTRYGUN | BS_HAS_DISPENSER | BS_CANB_SENTRYGUN | BS_CANB_DISPENSER | BS_HAS_ENTRY_TELEPORTER | BS_HAS_EXIT_TELEPORTER | BS_CANB_ENTRY_TELEPORTER | BS_CANB_EXIT_TELEPORTER) ) - return false; - - return true; - } - - // Must have a building - if( m_iBuildState & BUILDSTATE_HASBUILDING ) - { - if( m_iBuildData == BuildButton::DISPENSER && !( gViewPort->GetBuildState() & BS_HAS_DISPENSER ) ) - return true; - - if( m_iBuildData == BuildButton::SENTRYGUN && !( gViewPort->GetBuildState() & BS_HAS_SENTRYGUN ) ) - return true; - if ( m_iBuildData == BuildButton::ENTRY_TELEPORTER && !(gViewPort->GetBuildState() & BS_HAS_ENTRY_TELEPORTER) ) - return true; - if ( m_iBuildData == BuildButton::EXIT_TELEPORTER && !(gViewPort->GetBuildState() & BS_HAS_EXIT_TELEPORTER) ) - return true; - } - - // Can build something - if( m_iBuildState & BUILDSTATE_CANBUILD ) - { - // Make sure they've got the ammo and don't have one already - if( m_iBuildData == BuildButton::DISPENSER && ( gViewPort->GetBuildState() & BS_CANB_DISPENSER ) ) - return false; - if( m_iBuildData == BuildButton::SENTRYGUN && ( gViewPort->GetBuildState() & BS_CANB_SENTRYGUN ) ) - return false; - if ( m_iBuildData == BuildButton::ENTRY_TELEPORTER && (gViewPort->GetBuildState() & BS_CANB_ENTRY_TELEPORTER) ) - return false; - if ( m_iBuildData == BuildButton::EXIT_TELEPORTER && (gViewPort->GetBuildState() & BS_CANB_EXIT_TELEPORTER) ) - return false; - - return true; - } -#endif return false; } }; diff --git a/cl_dll/voice_status.cpp b/cl_dll/voice_status.cpp index 53cd9d5f..1f1c33ac 100644 --- a/cl_dll/voice_status.cpp +++ b/cl_dll/voice_status.cpp @@ -5,16 +5,7 @@ // $NoKeywords: $ //============================================================================= -// There are hud.h's coming out of the woodwork so this ensures that we get the right one. -#if defined(THREEWAVE) || defined(DMC_BUILD) - #include "../dmc/cl_dll/hud.h" -#elif defined(CSTRIKE) - #include "../cstrike/cl_dll/hud.h" -#elif defined(DOD) - #include "../dod/cl_dll/hud.h" -#else - #include "hud.h" -#endif +#include "hud.h" #include "cl_util.h" #include @@ -89,16 +80,14 @@ int g_BannedPlayerPrintCount; void ForEachBannedPlayer(char id[16]) { char str[256]; - sprintf(str, "Ban %d: %2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x\n", + sprintf(str, "BAN %d: %2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X\n", g_BannedPlayerPrintCount++, id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7], id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15] ); -#ifdef _WIN32 - strupr(str); -#endif + gEngfuncs.pfnConsolePrint(str); } @@ -400,7 +389,7 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking ) if ( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) ) { char msg[256]; - _snprintf( msg, sizeof( msg ), "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking ); + sprintf( msg, "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking ); gEngfuncs.pfnConsolePrint( msg ); } @@ -455,7 +444,8 @@ void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking ) gEngfuncs.pfnGetPlayerInfo( entindex, &info ); char paddedName[512]; - _snprintf( paddedName, sizeof( paddedName ), "%s ", info.name ); + _snprintf( paddedName, sizeof( paddedName ) - 1, "%s ", info.name ); + paddedName[sizeof(paddedName) - 1] = '\0'; int color[3]; m_pHelper->GetPlayerTextColor( entindex, color ); @@ -516,7 +506,7 @@ void CVoiceStatus::UpdateServerState(bool bForce) m_bServerModEnable = bCVarModEnable; char str[256]; - _snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable); + sprintf(str, "VModEnable %d", m_bServerModEnable); ServerCmd(str); if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug")) @@ -527,8 +517,7 @@ void CVoiceStatus::UpdateServerState(bool bForce) } } - char str[2048]; - sprintf(str, "vban"); + char str[2048] = "vban"; bool bChange = false; for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++) diff --git a/cl_dll/wscript b/cl_dll/wscript index b516fe5f..b368ebd8 100644 --- a/cl_dll/wscript +++ b/cl_dll/wscript @@ -73,7 +73,6 @@ def build(bld): 'input_xash3d.cpp', 'menu.cpp', 'message.cpp', - 'overview.cpp', 'parsemsg.cpp', 'saytext.cpp', 'scoreboard.cpp', diff --git a/dlls/client.cpp b/dlls/client.cpp index 46d76a11..411a9a77 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -167,18 +167,19 @@ void ClientDisconnect( edict_t *pEntity ) switch( RANDOM_LONG( 0, 3 ) ) { case 0: - snprintf( text, sizeof(text), "- %s has busted the fuck out\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "- %s has busted the fuck out\n", STRING( pEntity->v.netname ) ); break; case 1: - snprintf( text, sizeof(text),"- %s has ran away\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1,"- %s has ran away\n", STRING( pEntity->v.netname ) ); break; case 2: - snprintf( text, sizeof(text), "- %s ragequitted.\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "- %s ragequitted.\n", STRING( pEntity->v.netname ) ); break; case 3: - snprintf( text, sizeof(text), "- %s is out.\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text) - 1, "- %s is out.\n", STRING( pEntity->v.netname ) ); break; } + text[sizeof(text) - 1] = '\0'; } MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); @@ -909,7 +910,8 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) if( gpGlobals->maxClients > 1 ) { char text[256]; - _snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + _snprintf( text, sizeof(text) - 1, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + text[sizeof(text) - 1] = '\0'; MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -1442,7 +1444,7 @@ void StartFrame( void ) // END BOT int oldBhopcap = g_bhopcap; - g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; + g_bhopcap = ( g_pGameRules && g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; if( g_bhopcap != oldBhopcap ) { MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL ); diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 99b097c4..f556be4f 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -47,7 +47,8 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() m_szTeamList[0] = 0; // Cache this because the team code doesn't want to deal with changing this in the middle of a game - strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH ); + strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH - 1 ); + m_szTeamList[TEAMPLAY_TEAMLISTLENGTH - 1] = '\0'; edict_t *pWorld = INDEXENT( 0 ); if( pWorld && pWorld->v.team ) @@ -57,7 +58,8 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() const char *pTeamList = STRING( pWorld->v.team ); if( pTeamList && pTeamList[0] != '\0' ) { - strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH ); + strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH - 1 ); + m_szTeamList[TEAMPLAY_TEAMLISTLENGTH - 1] = '\0'; } } } @@ -189,7 +191,8 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { // copy out the team name from the model char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" ); - strncpy( pPlayer->m_szTeamName, mdls, TEAM_NAME_LENGTH ); + strncpy( pPlayer->m_szTeamName, mdls, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; RecountTeams(); @@ -206,7 +209,8 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { pTeamName = TeamWithFewestPlayers(); } - strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH ); + strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; } return pPlayer->m_szTeamName; @@ -293,8 +297,10 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea // copy out the team name from the model if( pPlayer->m_szTeamName != pTeamName ) - strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH ); - + { + strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH - 1 ); + pPlayer->m_szTeamName[TEAM_NAME_LENGTH - 1] = '\0'; + } g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName ); g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName ); @@ -610,7 +616,8 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) tm = num_teams; num_teams++; team_scores[tm] = 0; - strncpy( team_names[tm], pTeamName, MAX_TEAMNAME_LENGTH ); + strncpy( team_names[tm], pTeamName, MAX_TEAMNAME_LENGTH - 1 ); + team_names[tm][MAX_TEAMNAME_LENGTH - 1] = '\0'; } } diff --git a/scripts/waifulib/library_naming.py b/scripts/waifulib/library_naming.py index 44ade2fd..f3b9762a 100644 --- a/scripts/waifulib/library_naming.py +++ b/scripts/waifulib/library_naming.py @@ -99,7 +99,10 @@ def configure(conf): if conf.env.XASH_AMD64: buildarch = "amd64" elif conf.env.XASH_X86: - buildarch = "" + if conf.env.XASH_WIN32 or conf.env.XASH_LINUX or conf.env.XASH_APPLE: + buildarch = "" + else: + buildarch = "i386" elif conf.env.XASH_ARM and conf.env.XASH_64BIT: buildarch = "arm64" elif conf.env.XASH_ARM: