Skip to content

Commit

Permalink
Merge branch 'master' into half-screwed
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Mar 6, 2023
2 parents 1945caa + ad6fb5f commit eb3d011
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 37 deletions.
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ git clone --recursive https://github.com/FWGS/hlsdk-portable

# Build Instructions

## Windows
## Windows x86.

### Prerequisites

Expand Down Expand Up @@ -131,7 +131,7 @@ cmake -G "Visual Studio 16 2019" -A Win32 -B build

After the configuration step, `HLSDK-PORTABLE.sln` should appear in the `build` directory. You can open this solution in Visual Studio and continue developing there.

## Windows. Using Microsoft Visual Studio 6
## Windows x86. Using Microsoft Visual Studio 6

Microsoft Visual Studio 6 is very old, but if you still have it installed, you can use it to build this hlsdk. There are no project files, but two `.bat` files, for server and client libraries. They require variable **MSVCDir** to be set to the installation path of Visual Studio:

Expand All @@ -142,7 +142,7 @@ cd dlls && compile.bat && cd ../cl_dll && compile.bat

`hl.dll` and `client.dll` will appear in `dlls/` and `cl_dll/` diretories. The libraries built with msvc6 should be compatible with Windows XP.

## Linux. Using Steam Runtime in chroot
## Linux x86. Portable steam-compatible build using Steam Runtime in chroot

### Prerequisites

Expand All @@ -168,7 +168,7 @@ schroot --chroot steamrt_scout_i386 -- cmake -B build-in-steamrt -S .
schroot --chroot steamrt_scout_i386 -- cmake --build build-in-steamrt
```

## Linux. Build without Steam Runtime
## Linux x86. Portable steam-compatible build without Steam Runtime

### Prerequisites

Expand All @@ -190,7 +190,7 @@ cmake .. -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc"
```
To ensure portability it's still better to build using Steam Runtime or another chroot of some older distro.

## Linux. Build in your own chroot
## Linux x86. Portable steam-compatible build in your own chroot

### Prerequisites

Expand Down Expand Up @@ -237,13 +237,46 @@ schroot --chroot jessie -- cmake --build build-in-chroot

TODO

## Nintendo Switch

### Prerequisites

1. Set up [`dkp-pacman`](https://devkitpro.org/wiki/devkitPro_pacman).
2. Install dependency packages:
```
sudo dkp-pacman -S switch-dev dkp-toolchain-vars switch-mesa switch-libdrm_nouveau switch-sdl2
```
3. Make sure the `DEVKITPRO` environment variable is set to the devkitPro SDK root:
```
export DEVKITPRO=/opt/devkitpro
```
4. Install libsolder:
```
source $DEVKITPRO/switchvars.sh
git clone https://github.com/fgsfdsfgs/libsolder.git
make -C libsolder install
```

### Building using CMake
```
mkdir build && cd build
aarch64-none-elf-cmake -G"Unix Makefiles" -DCMAKE_PROJECT_HLSDK-PORTABLE_INCLUDE="$DEVKITPRO/portlibs/switch/share/SolderShim.cmake" ..
make -j
```

### Building using waf
```
./waf configure -T release --nswitch
./waf build
```

## Other platforms

Building on other Unix-like platforms (e.g. FreeBSD) is supported.
Building on other architectures (e.g x86_64 or arm) and POSIX-compliant OSes (e.g. FreeBSD) is supported.

### Prerequisites

Install C and C++ compilers (like gcc or clang), cmake and make (or gmake)
Install C and C++ compilers (like gcc or clang), cmake and make.

### Building

Expand Down
14 changes: 8 additions & 6 deletions cl_dll/input_goldsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ extern cvar_t *cl_pitchspeed;
extern cvar_t *cl_movespeedkey;

#if _WIN32
static cvar_t* m_rawinput = NULL;
static double s_flRawInputUpdateTime = 0.0f;
static bool m_bRawInput = false;
static bool m_bMouseThread = false;
Expand All @@ -158,7 +159,6 @@ bool isMouseRelative = false;

#if _WIN32
#include "progdefs.h"
extern globalvars_t *gpGlobals;
#endif

int CL_IsDead( void );
Expand Down Expand Up @@ -386,7 +386,7 @@ void IN_SetMouseMode(bool enable)
if (mouseparmsvalid)
restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);

m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
m_bRawInput = m_rawinput && m_rawinput->value != 0;
if(m_bRawInput)
{
#if USE_SDL2
Expand Down Expand Up @@ -781,13 +781,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)

#if _WIN32
// update m_bRawInput occasionally:
if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f )
const float currentTime = gEngfuncs.GetClientTime();
if ( currentTime - s_flRawInputUpdateTime > 1.0f || s_flRawInputUpdateTime == 0.0f )
{
s_flRawInputUpdateTime = gpGlobals->time;
s_flRawInputUpdateTime = currentTime;

bool lockEntered = MouseThread_ActiveLock_Enter();

m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
m_bRawInput = m_rawinput && m_rawinput->value != 0;

if(m_bRawInput && !isMouseRelative)
{
Expand Down Expand Up @@ -1571,7 +1572,8 @@ void GoldSourceInput::IN_Init (void)
m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE );

#if _WIN32
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
m_rawinput = gEngfuncs.pfnGetCvarPointer("m_rawinput");
m_bRawInput = m_rawinput && m_rawinput->value != 0;
m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL;
m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz

Expand Down
3 changes: 3 additions & 0 deletions cmake/LibraryNaming.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ check_symbol_exists(XASH_SERENITY "build.h" XASH_SERENITY)
check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32)
check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64)
check_symbol_exists(XASH_X86 "build.h" XASH_X86)
check_symbol_exists(XASH_NSWITCH "build.h" XASH_NSWITCH)
unset(CMAKE_REQUIRED_INCLUDES)

# engine/common/build.c
Expand All @@ -63,6 +64,8 @@ elseif(XASH_HAIKU)
set(BUILDOS "haiku")
elseif(XASH_SERENITY)
set(BUILDOS "serenityos")
elseif(XASH_NSWITCH)
set(BUILDOS "nswitch")
else()
message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug")
endif()
Expand Down
8 changes: 4 additions & 4 deletions dlls/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *

mstudioseqdesc_t *pseqdesc;

if( pev->sequence >= pstudiohdr->numseq )
if( pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq )
{
*pflFrameRate = 0.0f;
*pflGroundSpeed = 0.0f;
Expand All @@ -265,7 +265,7 @@ int GetSequenceFlags( void *pmodel, entvars_t *pev )
studiohdr_t *pstudiohdr;

pstudiohdr = (studiohdr_t *)pmodel;
if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq )
if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq )
return 0;

mstudioseqdesc_t *pseqdesc;
Expand All @@ -279,7 +279,7 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve
studiohdr_t *pstudiohdr;

pstudiohdr = (studiohdr_t *)pmodel;
if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent )
if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent )
return 0;

mstudioseqdesc_t *pseqdesc;
Expand Down Expand Up @@ -379,7 +379,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue )
studiohdr_t *pstudiohdr;

pstudiohdr = (studiohdr_t *)pmodel;
if( !pstudiohdr )
if( !pstudiohdr || pev->sequence < 0 || pev->sequence >= pstudiohdr->numseq )
return flValue;

mstudioseqdesc_t *pseqdesc;
Expand Down
28 changes: 24 additions & 4 deletions dlls/func_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "func_break.h"
#include "decals.h"
#include "explode.h"
#include "game.h"

int RESPAWN_TIME = 60;

Expand Down Expand Up @@ -972,12 +973,24 @@ void CPushable::Move( CBaseEntity *pOther, int push )
return;
}

// g-cont. fix pushable acceleration bug (reverted as it used in mods)
if( pOther->IsPlayer() )
{
// Don't push unless the player is pushing forward and NOT use (pull)
if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) )
return;
// g-cont. fix pushable acceleration bug (now implemented as cvar)
if (pushablemode.value == 1)
{
// Allow player push when moving right, left and back too
if ( push && !(pevToucher->button & (IN_FORWARD|IN_MOVERIGHT|IN_MOVELEFT|IN_BACK)) )
return;
// Require player walking back when applying '+use' on pushable
if ( !push && !(pevToucher->button & (IN_BACK)) )
return;
}
else
{
// Don't push unless the player is pushing forward and NOT use (pull)
if( push && !( pevToucher->button & ( IN_FORWARD | IN_USE ) ) )
return;
}
playerTouch = 1;
}

Expand All @@ -998,6 +1011,13 @@ void CPushable::Move( CBaseEntity *pOther, int push )
else
factor = 0.25f;

// Spirit fix for pushable acceleration
if (pushablemode.value == 2)
{
if (!push)
factor *= 0.5f;
}

pev->velocity.x += pevToucher->velocity.x * factor;
pev->velocity.y += pevToucher->velocity.y * factor;

Expand Down
2 changes: 2 additions & 0 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cvar_t satchelfix = { "satchelfix", "0", FCVAR_SERVER };
cvar_t explosionfix = { "explosionfix", "0", FCVAR_SERVER };
cvar_t monsteryawspeedfix = { "monsteryawspeedfix", "1", FCVAR_SERVER };
cvar_t corpsephysics = { "corpsephysics", "0", FCVAR_SERVER };
cvar_t pushablemode = { "pushablemode", "0", FCVAR_SERVER };
cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER };
cvar_t flashlight = { "mp_flashlight","1", FCVAR_SERVER };
cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER };
Expand Down Expand Up @@ -597,6 +598,7 @@ void GameDLLInit( void )
CVAR_REGISTER( &explosionfix );
CVAR_REGISTER( &monsteryawspeedfix );
CVAR_REGISTER( &corpsephysics );
CVAR_REGISTER( &pushablemode );
CVAR_REGISTER( &forcerespawn );
CVAR_REGISTER( &flashlight );
CVAR_REGISTER( &aimcrosshair );
Expand Down
1 change: 1 addition & 0 deletions dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern cvar_t satchelfix;
extern cvar_t explosionfix;
extern cvar_t monsteryawspeedfix;
extern cvar_t corpsephysics;
extern cvar_t pushablemode;
extern cvar_t forcerespawn;
extern cvar_t flashlight;
extern cvar_t aimcrosshair;
Expand Down
2 changes: 0 additions & 2 deletions dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class CGrenade : public CBaseMonster
#define GLOCK_MAX_CLIP 13 //RE4
#define PYTHON_MAX_CLIP 6
#define MP5_MAX_CLIP 50
#define MP5_DEFAULT_AMMO 25
#define SHOTGUN_MAX_CLIP 150
#define CROSSBOW_MAX_CLIP 5
#define RPG_MAX_CLIP 1
Expand All @@ -184,7 +183,6 @@ class CGrenade : public CBaseMonster
#define GLOCK_DEFAULT_GIVE 17
#define PYTHON_DEFAULT_GIVE 6
#define MP5_DEFAULT_GIVE 25
#define MP5_DEFAULT_AMMO 25
#define MP5_M203_DEFAULT_GIVE 0
#define SHOTGUN_DEFAULT_GIVE 150
#define CROSSBOW_DEFAULT_GIVE 5
Expand Down
7 changes: 6 additions & 1 deletion public/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ For more information, please refer to <http://unlicense.org/>
#undef XASH_WIN32
#undef XASH_WIN64
#undef XASH_X86
#undef XASH_NSWITCH

//================================================================
//
Expand All @@ -96,6 +97,10 @@ For more information, please refer to <http://unlicense.org/>
#if defined(_WIN64)
#define XASH_WIN64 1
#endif
#elif defined __SWITCH__
#define XASH_NSWITCH 1
#define XASH_LITTLE_ENDIAN 1
#define XASH_POSIX 1
#elif defined(__linux__)
#define XASH_LINUX 1
#if defined(__ANDROID__)
Expand Down Expand Up @@ -134,7 +139,7 @@ For more information, please refer to <http://unlicense.org/>
#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug"
#endif

#if defined XASH_ANDROID || defined XASH_IOS
#if defined XASH_ANDROID || defined XASH_IOS || defined XASH_NSWITCH
#define XASH_MOBILE_PLATFORM 1
#endif

Expand Down
3 changes: 3 additions & 0 deletions scripts/waifulib/library_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'XASH_WIN32',
'XASH_WIN64',
'XASH_X86',
'XASH_NSWITCH',
]

def configure(conf):
Expand Down Expand Up @@ -92,6 +93,8 @@ def configure(conf):
buildos = "haiku"
elif conf.env.XASH_SERENITY:
buildos = "serenityos"
elif conf.env.XASH_NSWITCH:
buildos = "nswitch"
else:
conf.fatal("Place your operating system name in build.h and library_naming.py!\n"
"If this is a mistake, try to fix conditions above and report a bug")
Expand Down
Loading

0 comments on commit eb3d011

Please sign in to comment.