Skip to content

Commit

Permalink
sync client, api, and libs with HL25 SDK
Browse files Browse the repository at this point in the history
need to start debugging client crashes
  • Loading branch information
wootguy committed Oct 16, 2024
1 parent 26bec75 commit 017e1b1
Show file tree
Hide file tree
Showing 167 changed files with 38,867 additions and 16,504 deletions.
89 changes: 47 additions & 42 deletions cl_dll/Exports.h
Original file line number Diff line number Diff line change
@@ -1,67 +1,72 @@
#include "Platform.h"
// CL_DLLEXPORT is the client version of dllexport. It's turned off for secure clients.
#ifdef _WIN32
#define CL_DLLEXPORT __declspec(dllexport)
#else
#define CL_DLLEXPORT __attribute__ ((visibility("default")))
#endif

extern "C"
{
// From hl_weapons
void DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );
void CL_DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );

// From cdll_int
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void );
void DLLEXPORT HUD_Init( void );
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void DLLEXPORT HUD_Reset ( void );
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name );
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time );
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
void DLLEXPORT HUD_ChatInputPosition( int *x, int *y );
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int CL_DLLEXPORT HUD_VidInit( void );
void CL_DLLEXPORT HUD_Init( void );
int CL_DLLEXPORT HUD_Redraw( float flTime, int intermission );
int CL_DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void CL_DLLEXPORT HUD_Reset ( void );
void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name );
int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void CL_DLLEXPORT HUD_Frame( double time );
void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y );

// From demo
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
void CL_DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );

// From entity
int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
void DLLEXPORT HUD_CreateEntities( void );
void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
void DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
void DLLEXPORT HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) );
struct cl_entity_s DLLEXPORT *HUD_GetUserEntity( int index );
int CL_DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
void CL_DLLEXPORT HUD_CreateEntities( void );
void CL_DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
void CL_DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
void CL_DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
void CL_DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
void CL_DLLEXPORT HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) );
struct cl_entity_s CL_DLLEXPORT *HUD_GetUserEntity( int index );

// From in_camera
void DLLEXPORT CAM_Think( void );
int DLLEXPORT CL_IsThirdPerson( void );
void DLLEXPORT CL_CameraOffset( float *ofs );
void CL_DLLEXPORT CAM_Think( void );
int CL_DLLEXPORT CL_IsThirdPerson( void );
void CL_DLLEXPORT CL_CameraOffset( float *ofs );

// From input
struct kbutton_s DLLEXPORT *KB_Find( const char *name );
void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
void DLLEXPORT HUD_Shutdown( void );
int DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );
struct kbutton_s CL_DLLEXPORT *KB_Find( const char *name );
void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
void CL_DLLEXPORT HUD_Shutdown( void );
int CL_DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );

// From inputw32
void DLLEXPORT IN_ActivateMouse( void );
void DLLEXPORT IN_DeactivateMouse( void );
void DLLEXPORT IN_MouseEvent (int mstate);
void DLLEXPORT IN_Accumulate (void);
void DLLEXPORT IN_ClearStates (void);
void CL_DLLEXPORT IN_ActivateMouse( void );
void CL_DLLEXPORT IN_DeactivateMouse( void );
void CL_DLLEXPORT IN_MouseEvent (int mstate);
void CL_DLLEXPORT IN_Accumulate (void);
void CL_DLLEXPORT IN_ClearStates (void);

// From tri
void DLLEXPORT HUD_DrawNormalTriangles( void );
void DLLEXPORT HUD_DrawTransparentTriangles( void );
void CL_DLLEXPORT HUD_DrawNormalTriangles( void );
void CL_DLLEXPORT HUD_DrawTransparentTriangles( void );

// From view
void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );
void CL_DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );

// From GameStudioModelRenderer
int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
}

/*
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/GameStudioModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
// RecClStudioInterface(version, ppinterface, pstudio);

Expand Down
68 changes: 51 additions & 17 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
{
int i, iRes;

if (ScreenWidth < 640)
iRes = 320;
#if !defined( _TFC )
if (ScreenWidth > 2560 && ScreenHeight > 1600)
iRes = 2560;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
iRes = 1280;
else
#endif
if (ScreenWidth >= 640)
iRes = 640;
else
iRes = 320;

char sz[256];
char sz[128];

if ( !pWeapon )
return;
Expand Down Expand Up @@ -109,7 +116,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->rcCrosshair = p->rc;
}
else
pWeapon->hCrosshair = 0;
pWeapon->hCrosshair = NULL;

p = GetSpriteList(pList, "autoaim", iRes, i);
if (p)
Expand Down Expand Up @@ -325,16 +332,20 @@ int CHudAmmo::VidInit(void)
// If we've already loaded weapons, let's get new sprites
gWR.LoadAllWeaponSprites();

int nScale = 1;

#if !defined( _TFC )
if (ScreenWidth > 2560 && ScreenHeight > 1600)
nScale = 4;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
nScale = 3;
else
#endif
if (ScreenWidth >= 640)
{
giABWidth = 20;
giABHeight = 4;
}
else
{
giABWidth = 10;
giABHeight = 2;
}
nScale = 2;

giABWidth = 10 * nScale;
giABHeight = 2 * nScale;

return 1;
}
Expand Down Expand Up @@ -641,7 +652,9 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf )

WEAPON Weapon;

strcpy( Weapon.szName, READ_STRING() );
strncpy( Weapon.szName, READ_STRING(), MAX_WEAPON_NAME );
Weapon.szName[ sizeof(Weapon.szName) - 1 ] = '\0';

Weapon.iAmmoType = (int)READ_CHAR();

Weapon.iMax1 = READ_BYTE();
Expand All @@ -659,6 +672,27 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf )
Weapon.iFlags = READ_BYTE();
Weapon.iClip = 0;

if (Weapon.iId < 0 || Weapon.iId >= MAX_WEAPONS)
return 0;

if (Weapon.iSlot < 0 || Weapon.iSlot >= MAX_WEAPON_SLOTS+1)
return 0;

if (Weapon.iSlotPos < 0 || Weapon.iSlotPos >= MAX_WEAPON_POSITIONS+1)
return 0;

if (Weapon.iAmmoType < -1 || Weapon.iAmmoType >= MAX_AMMO_TYPES)
return 0;

if (Weapon.iAmmo2Type < -1 || Weapon.iAmmo2Type >= MAX_AMMO_TYPES)
return 0;

if (Weapon.iAmmoType >= 0 && Weapon.iMax1 == 0)
return 0;

if (Weapon.iAmmo2Type >= 0 && Weapon.iMax2 == 0)
return 0;

gWR.AddWeapon( &Weapon );

return 1;
Expand Down Expand Up @@ -871,8 +905,8 @@ int CHudAmmo::Draw(float flTime)

ScaleColors(r, g, b, a );

// Does this weapon have a clip?
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
y += (int)(gHUD.m_iFontHeight * 0.2f);

// Does weapon have any ammo at all?
if (m_pWeapon->iAmmoType > 0)
Expand Down Expand Up @@ -1188,10 +1222,10 @@ client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes

int i = iCount;
client_sprite_t *p = pList;

while(i--)
{
if ((!strcmp(psz, p->szName)) && (p->iRes == iRes))
if ((p->iRes == iRes) && (!strcmp(psz, p->szName)))
return p;
p++;
}
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )

// Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24;
int xpos = ScreenWidth - (rcPic.right - rcPic.left) - 4;
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
{ // the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b );
Expand Down
9 changes: 7 additions & 2 deletions cl_dll/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ int CHudBattery::Draw(float flTime)
int iOffset = (m_prc1->bottom - m_prc1->top)/6;

y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = ScreenWidth/5;

int width = (m_prc1->right - m_prc1->left);

// this used to just be ScreenWidth/5 but that caused real issues at higher resolutions. Instead, base it on the width of this sprite.
x = 3 * width;

// make sure we have the right sprite handles
if ( !m_hSprite1 )
Expand All @@ -151,7 +155,8 @@ int CHudBattery::Draw(float flTime)
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
}

x += (m_prc1->right - m_prc1->left);
x += width;
y += (int)(gHUD.m_iFontHeight * 0.2f);
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);

return 1;
Expand Down
Loading

0 comments on commit 017e1b1

Please sign in to comment.