Fix Goldsource build (#176)

This commit is contained in:
Roman Chistokhodov 2021-06-08 00:05:47 +03:00 committed by GitHub
parent 0557b2dfe3
commit 3f6ab0b2fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 27 deletions

View File

@ -7,21 +7,39 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest]
compiler: [gcc, clang]
include: include:
- compiler: gcc - os: ubuntu-latest
cpp-compiler: g++ cc: gcc
- compiler: clang cxx: g++
cpp-compiler: clang++ - os: ubuntu-latest
cc: clang
cxx: clang++
env: env:
CC: ${{ matrix.compiler }} CC: ${{ matrix.cc }}
CXX: ${{ matrix.cpp-compiler }} CXX: ${{ matrix.cxx }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Get SDL2 headers
uses: actions/checkout@v2
with:
repository: libsdl-org/SDL
ref: release-2.0.9
path: SDL2
- name: Link SDL2 headers into system path
run: |
sudo ln -s "$GITHUB_WORKSPACE/SDL2/include" /usr/local/include/SDL2
- name: Install dependencies - name: Install dependencies
run: sudo apt-get -y install gcc-multilib g++-multilib libgl1-mesa-dev if: startsWith(matrix.os, 'ubuntu')
- name: Build client and server on ${{ matrix.os }} with ${{ matrix.compiler }} run: |
sudo apt-get -y install gcc-multilib g++-multilib
- name: Build with xash3d-fwgs input
run: | run: |
cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" && cmake --build build --target all cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" && cmake --build build --target all
- name: Build with goldsource input
run: |
cmake -B build-gs -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DGOLDSOURCE_SUPPORT=ON && cmake --build build-gs --target all

View File

@ -183,7 +183,7 @@ int *HUD_GetRect( void )
return extent; return extent;
} }
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
class TeamFortressViewport : public vgui::Panel class TeamFortressViewport : public vgui::Panel
{ {
public: public:
@ -238,7 +238,7 @@ so the HUD can reinitialize itself.
int DLLEXPORT HUD_VidInit( void ) int DLLEXPORT HUD_VidInit( void )
{ {
gHUD.VidInit(); gHUD.VidInit();
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel();
if (root) { if (root) {
gEngfuncs.Con_Printf( "Root VGUI panel exists\n" ); gEngfuncs.Con_Printf( "Root VGUI panel exists\n" );
@ -337,7 +337,7 @@ Called by engine every frame that client .dll is loaded
void DLLEXPORT HUD_Frame( double time ) void DLLEXPORT HUD_Frame( double time )
{ {
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
if (!gViewPort) if (!gViewPort)
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
#else #else

View File

@ -10,7 +10,7 @@
#include "input_mouse.h" #include "input_mouse.h"
#if SUPPORT_GOLDSOURCE_INPUT #ifdef SUPPORT_GOLDSOURCE_INPUT
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
@ -27,7 +27,7 @@
#define USE_SDL2 #define USE_SDL2
#endif #endif
#if USE_SDL2 #ifdef USE_SDL2
#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) #define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) )
#include <dlfcn.h> #include <dlfcn.h>
#include <SDL2/SDL_mouse.h> #include <SDL2/SDL_mouse.h>
@ -242,7 +242,7 @@ DWORD joy_oldbuttonstate, joy_oldpovstate;
int joy_id; int joy_id;
DWORD joy_numbuttons; DWORD joy_numbuttons;
#if USE_SDL2 #ifdef USE_SDL2
SDL_GameController *s_pJoystick = NULL; SDL_GameController *s_pJoystick = NULL;
#elif defined(_WIN32) #elif defined(_WIN32)
DWORD joy_flags; DWORD joy_flags;
@ -566,7 +566,7 @@ void GoldSourceInput::IN_Shutdown (void)
} }
#endif #endif
#if USE_SDL2 #ifdef USE_SDL2
for (int j=0; j<ARRAYSIZE(sdlFunctions); ++j) { for (int j=0; j<ARRAYSIZE(sdlFunctions); ++j) {
*(sdlFunctions[j].ppfnFunc) = NULL; *(sdlFunctions[j].ppfnFunc) = NULL;
} }
@ -735,7 +735,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
else else
#endif #endif
{ {
#if USE_SDL2 #ifdef USE_SDL2
safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY );
current_pos.x = deltaX; current_pos.x = deltaX;
current_pos.y = deltaY; current_pos.y = deltaY;
@ -942,7 +942,7 @@ void GoldSourceInput::IN_Accumulate (void)
else else
#endif #endif
{ {
#if USE_SDL2 #ifdef USE_SDL2
int deltaX, deltaY; int deltaX, deltaY;
safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY );
mx_accum += deltaX; mx_accum += deltaX;
@ -997,7 +997,7 @@ void IN_StartupJoystick (void)
// assume no joystick // assume no joystick
joy_avail = 0; joy_avail = 0;
#if USE_SDL2 #ifdef USE_SDL2
int nJoysticks = safe_pfnSDL_NumJoysticks(); int nJoysticks = safe_pfnSDL_NumJoysticks();
if ( nJoysticks > 0 ) if ( nJoysticks > 0 )
{ {
@ -1084,7 +1084,7 @@ void IN_StartupJoystick (void)
#endif #endif
} }
#if USE_SDL2 #ifdef USE_SDL2
int RawValuePointer (int axis) int RawValuePointer (int axis)
{ {
switch (axis) switch (axis)
@ -1216,7 +1216,7 @@ void GoldSourceInput::IN_Commands (void)
// loop through the joystick buttons // loop through the joystick buttons
// key a joystick event or auxillary event for higher number buttons for each state change // key a joystick event or auxillary event for higher number buttons for each state change
#if USE_SDL2 #ifdef USE_SDL2
buttonstate = 0; buttonstate = 0;
for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ )
{ {
@ -1294,7 +1294,7 @@ IN_ReadJoystick
*/ */
int IN_ReadJoystick (void) int IN_ReadJoystick (void)
{ {
#if USE_SDL2 #ifdef USE_SDL2
safe_pfnSDL_JoystickUpdate(); safe_pfnSDL_JoystickUpdate();
return 1; return 1;
#elif defined(_WIN32) #elif defined(_WIN32)
@ -1374,7 +1374,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
for (i = 0; i < JOY_MAX_AXES; i++) for (i = 0; i < JOY_MAX_AXES; i++)
{ {
// get the floating point zero-centered, potentially-inverted data for the current axis // get the floating point zero-centered, potentially-inverted data for the current axis
#if USE_SDL2 #ifdef USE_SDL2
fAxisValue = (float)pdwRawValue[i]; fAxisValue = (float)pdwRawValue[i];
#elif defined(_WIN32) #elif defined(_WIN32)
fAxisValue = (float) *pdwRawValue[i]; fAxisValue = (float) *pdwRawValue[i];
@ -1600,7 +1600,7 @@ void GoldSourceInput::IN_Init (void)
} }
#endif #endif
#if USE_SDL2 #ifdef USE_SDL2
#if __APPLE__ #if __APPLE__
#define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib" #define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib"
#else #else

View File

@ -10,7 +10,7 @@ cvar_t *in_joystick;
FWGSInput fwgsInput; FWGSInput fwgsInput;
#if SUPPORT_GOLDSOURCE_INPUT #ifdef SUPPORT_GOLDSOURCE_INPUT
GoldSourceInput goldSourceInput; GoldSourceInput goldSourceInput;
AbstractInput* currentInput = &goldSourceInput; AbstractInput* currentInput = &goldSourceInput;
#else #else
@ -68,7 +68,7 @@ void IN_Shutdown( void )
void IN_Init( void ) void IN_Init( void )
{ {
#if SUPPORT_GOLDSOURCE_INPUT #ifdef SUPPORT_GOLDSOURCE_INPUT
if (IsXashFWGS()) { if (IsXashFWGS()) {
gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" );
currentInput = &fwgsInput; currentInput = &fwgsInput;