Skip to content

Commit

Permalink
client: fix build on Linux, add FWGS input
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed May 22, 2024
1 parent 4ba42ef commit 9d60129
Show file tree
Hide file tree
Showing 23 changed files with 2,235 additions and 990 deletions.
4 changes: 2 additions & 2 deletions cl_dll/StudioModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ HUD_GetStudioModelInterface
Export this function for the engine to use the studio renderer class to render objects.
====================
*/
#define DLLEXPORT __declspec( dllexport )
#include "exportdef.h"
extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
if ( version != STUDIO_INTERFACE_VERSION )
Expand All @@ -1889,4 +1889,4 @@ extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_stud

// Success
return 1;
}
}
35 changes: 25 additions & 10 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@ extern "C"
}

#include <string.h>
#ifdef _WIN32
#include <windows.h>

#define DLLEXPORT __declspec( dllexport )
#endif
#include "exportdef.h"


cl_enginefunc_t gEngfuncs;
render_api_t gRenderfuncs;
CHud gHUD;
int g_iXashEngine = FALSE;
BOOL g_fRenderInitialized = FALSE;
bool g_iXashEngine = false;
static bool g_fRenderInitialized = false;
void InitInput (void);
void EV_HookEvents( void );
void IN_Commands( void );
Expand Down Expand Up @@ -80,6 +81,7 @@ HUD_GetRect
Vgui stub
================================
*/
#ifdef _WIN32
int *HUD_GetRect( void )
{
RECT wrect;
Expand All @@ -102,8 +104,21 @@ int *HUD_GetRect( void )
extent[3] = wrect.bottom - 4; //-4
}
}
return extent;
return extent;
}
#else
int *HUD_GetRect( void )
{
static int extent[4];

extent[0] = gEngfuncs.GetWindowCenterX() - ScreenWidth / 2;
extent[1] = gEngfuncs.GetWindowCenterY() - ScreenHeight / 2;
extent[2] = gEngfuncs.GetWindowCenterX() + ScreenWidth / 2;
extent[3] = gEngfuncs.GetWindowCenterY() + ScreenHeight / 2;

return extent;
}
#endif

/*
================================
Expand Down Expand Up @@ -201,7 +216,7 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));

if (gEngfuncs.pfnGetCvarPointer( "host_clientloaded" ))
g_iXashEngine = TRUE;
g_iXashEngine = true;

return 1;
}
Expand Down Expand Up @@ -368,7 +383,7 @@ int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, re
{
if ( !callback || !renderfuncs || version != CL_RENDER_INTERFACE_VERSION )
{
return FALSE;
return false;
}

size_t iImportSize = sizeof( render_interface_t );
Expand All @@ -380,7 +395,7 @@ int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, re
// fill engine callbacks
memcpy( callback, &gRenderInterface, iImportSize );

g_fRenderInitialized = TRUE;
g_fRenderInitialized = true;

return TRUE;
}
return true;
}
5 changes: 2 additions & 3 deletions cl_dll/cl_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ typedef float vec_t;
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);

#include "util_vector.h"
#define EXPORT _declspec( dllexport )

#include "exportdef.h"
#include "../engine/cdll_int.h"
#include "../dlls/quakedef.h"
#include "render_api.h"

extern cl_enginefunc_t gEngfuncs;
extern render_api_t gRenderfuncs;
extern struct ref_params_s *gpViewParams;
extern struct ref_params_s *gpViewParams;
14 changes: 11 additions & 3 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
//

#include "cvardef.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
#endif

#ifndef TRUE
#define TRUE 1
Expand All @@ -33,14 +37,14 @@

#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \
return gHUD.##y.MsgFunc_##x(pszName, iSize, 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( ); \
gHUD.y.UserCmd_##x( ); \
}

inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); }
Expand Down Expand Up @@ -184,7 +188,11 @@ void AngleQuaternion( float *angles, vec4_t quaternion );

struct mleaf_s *Mod_PointInLeaf( Vector p, struct mnode_s *node );

#ifdef _WIN32
typedef HMODULE dllhandle_t;
#else
typedef void* dllhandle_t;
#endif

typedef struct dllfunc_s
{
Expand All @@ -195,4 +203,4 @@ typedef struct dllfunc_s
// dll managment
bool Sys_LoadLibrary( const char *dllname, dllhandle_t *handle, const dllfunc_t *fcts = NULL );
void *Sys_GetProcAddress( dllhandle_t handle, const char *name );
void Sys_FreeLibrary( dllhandle_t *handle );
void Sys_FreeLibrary( dllhandle_t *handle );
5 changes: 2 additions & 3 deletions cl_dll/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include "pm_shared.h"
#include "r_studioint.h"
#include "com_model.h"

#define DLLEXPORT __declspec( dllexport )
#include "exportdef.h"

void VectorAngles( const float *forward, float *angles );

Expand Down Expand Up @@ -773,4 +772,4 @@ Indices must start at 1, not zero.
cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
{
return NULL;
}
}
6 changes: 5 additions & 1 deletion cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "wrect.h"
#include "cl_dll.h"

#ifndef _WIN32
#define _cdecl
#endif // _WIN32

#define SBAR_HEIGHT 24
#define MAX_SCRAPS 2
#define BLOCK_WIDTH 256
Expand Down Expand Up @@ -444,4 +448,4 @@ extern int g_iTeamNumber;
extern int g_iUser1;
extern int g_iUser2;
extern int g_iUser3;
extern float g_flMsgTime;
extern float g_flMsgTime;
5 changes: 3 additions & 2 deletions cl_dll/hud_redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
{
// find the end of the string
for ( char *szIt = szString; *szIt != 0; szIt++ )
char *szIt;
for ( szIt = szString; *szIt != 0; szIt++ )
{ // we should count the length?
}

Expand All @@ -135,4 +136,4 @@ int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString,
}

return xpos;
}
}
11 changes: 10 additions & 1 deletion cl_dll/in_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@
#include "camera.h"
#include "in_defs.h"
#include "cl_entity.h"
#ifdef _WIN32
#include "windows.h"
#else
typedef struct point_s
{
int x, y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif

float CL_KeyState (kbutton_t *key);

Expand Down Expand Up @@ -618,4 +627,4 @@ int DLLEXPORT CL_IsThirdPerson( void )
void DLLEXPORT CL_CameraOffset( float *ofs )
{
VectorCopy( cam_ofs, ofs );
}
}
6 changes: 3 additions & 3 deletions cl_dll/in_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#define IN_DEFSH
#pragma once

#include "exportdef.h"

// up / down
#define PITCH 0
// left / right
#define YAW 1
// fall over
#define ROLL 2

#define DLLEXPORT __declspec( dllexport )

#endif
#endif
2 changes: 1 addition & 1 deletion cl_dll/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern "C"
extern engine_studio_api_t IEngineStudio;

extern int g_iAlive;
extern int g_iXashEngine;
extern bool g_iXashEngine;
extern cl_enginefunc_t gEngfuncs;

void IN_Init (void);
Expand Down
Loading

0 comments on commit 9d60129

Please sign in to comment.