From 3e2808de62e479e83068c075cb88b4f177f9acc7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 28 Nov 2021 23:04:50 +0300 Subject: [PATCH 01/30] Fix possible bug with talkmonster facing during the script (#213) --- dlls/talkmonster.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index 581d87a9..2b3ac14f 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -847,7 +847,8 @@ void CTalkMonster::Touch( CBaseEntity *pOther ) if( speed > 50.0f ) { SetConditions( bits_COND_CLIENT_PUSH ); - MakeIdealYaw( pOther->pev->origin ); + if ( m_MonsterState != MONSTERSTATE_SCRIPT ) + MakeIdealYaw( pOther->pev->origin ); } } } From 7f8f73c6798dffa4e7bbcdcafa579f67f3dbcfda Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Wed, 1 Dec 2021 02:14:12 -0500 Subject: [PATCH 02/30] Remove unused source files (#212) * Delete AI_BaseNPC_Schedule.cpp * Delete soundsystem.cpp --- cl_dll/soundsystem.cpp | 163 ---- dlls/AI_BaseNPC_Schedule.cpp | 1514 ---------------------------------- 2 files changed, 1677 deletions(-) delete mode 100644 cl_dll/soundsystem.cpp delete mode 100644 dlls/AI_BaseNPC_Schedule.cpp diff --git a/cl_dll/soundsystem.cpp b/cl_dll/soundsystem.cpp deleted file mode 100644 index 9ee33861..00000000 --- a/cl_dll/soundsystem.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//======== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ======== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// Purpose: -// -// $Workfile: $ -// $Date: $ -// -//----------------------------------------------------------------------------- -// $Log: $ -// -// $NoKeywords: $ -//============================================================================= - -#include -#include -#include -#include "r_studioint.h" - -extern engine_studio_api_t IEngineStudio; - -#define RENDERTYPE_UNDEFINED 0 -#define RENDERTYPE_SOFTWARE 1 -#define RENDERTYPE_HARDWARE 2 - -#define ENGINE_LAUNCHER_API_VERSION 1 - -LPDIRECTSOUND lpDS = NULL; -LPDIRECTSOUNDBUFFER lpDSBuf = NULL; -LPHWAVEOUT lpHW = NULL; - -static HMODULE hEngine = 0; - -typedef struct engine_api_s -{ - int version; - int rendertype; - int size; - - // Functions - void ( *unused1 ) ( void ); - void ( *unused2 ) ( void ); - void ( *unused3 ) ( void ); - void ( *unused4 ) ( void ); - void ( *unused5 ) ( void ); - void ( *unused6 ) ( void ); - void ( *unused7 ) ( void ); - void ( *unused8 ) ( void ); - void ( *unused9 ) ( void ); - void ( *unused10 ) ( void ); - void ( *unused11 ) ( void ); - void ( *unused12 ) ( void ); - void ( *unused13 ) ( void ); - void ( *unused14 ) ( void ); - void ( *unused15 ) ( void ); - void ( *unused16 ) ( void ); - void ( *unused17 ) ( void ); - void ( *unused18 ) ( void ); - void ( *unused19 ) ( void ); - void ( *unused20 ) ( void ); - void ( *unused21 ) ( void ); - void ( *unused22 ) ( void ); - void ( *unused23 ) ( void ); - void ( *unused24 ) ( void ); - void ( *unused25 ) ( void ); - void ( *unused26 ) ( void ); - void ( *unused27 ) ( void ); - void ( *unused28 ) ( void ); - void ( *unused29 ) ( void ); - void ( *unused30 ) ( void ); - void ( *unused31 ) ( void ); - void ( *unused32 ) ( void ); - void ( *unused33 ) ( void ); - void ( *unused34 ) ( void ); - - void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf ); - void *( *S_GetWAVPointer ) ( void ); - - void ( *unused35 ) ( void ); - void ( *unused36 ) ( void ); - void ( *unused37 ) ( void ); - void ( *unused38 ) ( void ); - void ( *unused39 ) ( void ); - void ( *unused40 ) ( void ); - void ( *unused41 ) ( void ); - void ( *unused42 ) ( void ); - void ( *unused43 ) ( void ); - void ( *unused44 ) ( void ); - void ( *unused45 ) ( void ); - void ( *unused46 ) ( void ); - void ( *unused47 ) ( void ); - void ( *unused48 ) ( void ); - void ( *unused49 ) ( void ); - void ( *unused50 ) ( void ); - void ( *unused51 ) ( void ); - void ( *unused52 ) ( void ); - void ( *unused53 ) ( void ); - void ( *unused54 ) ( void ); - void ( *unused55 ) ( void ); -} engine_api_t; - -static engine_api_t engineapi; - -typedef int (*engine_api_func)( int version, int size, struct engine_api_s *api ); - -//----------------------------------------------------------------------------- -// Purpose: Get launcher/engine interface from engine module -// Input : hMod - -// Output : int -//----------------------------------------------------------------------------- -int Eng_LoadFunctions( HMODULE hMod ) -{ - engine_api_func pfnEngineAPI; - - pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" ); - if( !pfnEngineAPI ) - return 0; - - if( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) ) - return 0; - - // All is okay - return 1; -} - -//----------------------------------------------------------------------------- -// Purpose: Load proper engine .dll and get pointer to either DSound and primary buffer or HWAVEOUT ( NT 4.0, e.g. ) -//----------------------------------------------------------------------------- -void LoadSoundAPIs( void ) -{ - hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" ); - if( hEngine ) - { - if( Eng_LoadFunctions( hEngine ) ) - { - if( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer ) - { - engineapi.S_GetDSPointer(&lpDS, &lpDSBuf); - lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer(); - } - } - } -} - -//----------------------------------------------------------------------------- -// Purpose: Close engine library, release sound pointers -//----------------------------------------------------------------------------- -void ShutdownSoundAPIs( void ) -{ - if( hEngine ) - { - FreeLibrary( hEngine ); - hEngine = 0; - } - - lpDS = 0; - lpDSBuf = 0; - lpHW = 0; -} diff --git a/dlls/AI_BaseNPC_Schedule.cpp b/dlls/AI_BaseNPC_Schedule.cpp deleted file mode 100644 index a6e4962b..00000000 --- a/dlls/AI_BaseNPC_Schedule.cpp +++ /dev/null @@ -1,1514 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* This source code contains proprietary and confidential information of -* Valve LLC and its suppliers. Access to this code is restricted to -* persons who have executed a written SDK license with Valve. Any access, -* use or distribution of this code by or to any unlicensed person is illegal. -* -****/ -//========================================================= -// schedule.cpp - functions and data pertaining to the -// monsters' AI scheduling system. -//========================================================= -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "animation.h" -#include "scripted.h" -#include "nodes.h" -#include "defaultai.h" -#include "soundent.h" - -extern CGraph WorldGraph; - -//========================================================= -// FHaveSchedule - Returns TRUE if monster's m_pSchedule -// is anything other than NULL. -//========================================================= -BOOL CBaseMonster :: FHaveSchedule( void ) -{ - if ( m_pSchedule == NULL ) - { - return FALSE; - } - - return TRUE; -} - -//========================================================= -// ClearSchedule - blanks out the caller's schedule pointer -// and index. -//========================================================= -void CBaseMonster :: ClearSchedule( void ) -{ - m_iTaskStatus = TASKSTATUS_NEW; - m_pSchedule = NULL; - m_iScheduleIndex = 0; -} - -//========================================================= -// FScheduleDone - Returns TRUE if the caller is on the -// last task in the schedule -//========================================================= -BOOL CBaseMonster :: FScheduleDone ( void ) -{ - ASSERT( m_pSchedule != NULL ); - - if ( m_iScheduleIndex == m_pSchedule->cTasks ) - { - return TRUE; - } - - return FALSE; -} - -//========================================================= -// ChangeSchedule - replaces the monster's schedule pointer -// with the passed pointer, and sets the ScheduleIndex back -// to 0 -//========================================================= -void CBaseMonster :: ChangeSchedule ( Schedule_t *pNewSchedule ) -{ - ASSERT( pNewSchedule != NULL ); - - m_pSchedule = pNewSchedule; - m_iScheduleIndex = 0; - m_iTaskStatus = TASKSTATUS_NEW; - m_afConditions = 0;// clear all of the conditions - m_failSchedule = SCHED_NONE; - - if ( m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND && !(m_pSchedule->iSoundMask) ) - { - ALERT ( at_aiconsole, "COND_HEAR_SOUND with no sound mask!\n" ); - } - else if ( m_pSchedule->iSoundMask && !(m_pSchedule->iInterruptMask & bits_COND_HEAR_SOUND) ) - { - ALERT ( at_aiconsole, "Sound mask without COND_HEAR_SOUND!\n" ); - } - -#if _DEBUG - if ( !ScheduleFromName( pNewSchedule->pName ) ) - { - ALERT( at_console, "Schedule %s not in table!!!\n", pNewSchedule->pName ); - } -#endif - -// this is very useful code if you can isolate a test case in a level with a single monster. It will notify -// you of every schedule selection the monster makes. -#if 0 - if ( FClassnameIs( pev, "monster_human_grunt" ) ) - { - Task_t *pTask = GetTask(); - - if ( pTask ) - { - const char *pName = NULL; - - if ( m_pSchedule ) - { - pName = m_pSchedule->pName; - } - else - { - pName = "No Schedule"; - } - - if ( !pName ) - { - pName = "Unknown"; - } - - ALERT( at_aiconsole, "%s: picked schedule %s\n", STRING( pev->classname ), pName ); - } - } -#endif// 0 - -} - -//========================================================= -// NextScheduledTask - increments the ScheduleIndex -//========================================================= -void CBaseMonster :: NextScheduledTask ( void ) -{ - ASSERT( m_pSchedule != NULL ); - - m_iTaskStatus = TASKSTATUS_NEW; - m_iScheduleIndex++; - - if ( FScheduleDone() ) - { - // just completed last task in schedule, so make it invalid by clearing it. - SetConditions( bits_COND_SCHEDULE_DONE ); - //ClearSchedule(); - } -} - -//========================================================= -// IScheduleFlags - returns an integer with all Conditions -// bits that are currently set and also set in the current -// schedule's Interrupt mask. -//========================================================= -int CBaseMonster :: IScheduleFlags ( void ) -{ - if( !m_pSchedule ) - { - return 0; - } - - // strip off all bits excepts the ones capable of breaking this schedule. - return m_afConditions & m_pSchedule->iInterruptMask; -} - -//========================================================= -// FScheduleValid - returns TRUE as long as the current -// schedule is still the proper schedule to be executing, -// taking into account all conditions -//========================================================= -BOOL CBaseMonster :: FScheduleValid ( void ) -{ - if ( m_pSchedule == NULL ) - { - // schedule is empty, and therefore not valid. - return FALSE; - } - - if ( HasConditions( m_pSchedule->iInterruptMask | bits_COND_SCHEDULE_DONE | bits_COND_TASK_FAILED ) ) - { -#if DEBUG - if ( HasConditions ( bits_COND_TASK_FAILED ) && m_failSchedule == SCHED_NONE ) - { - // fail! Send a visual indicator. - ALERT ( at_aiconsole, "Schedule: %s Failed\n", m_pSchedule->pName ); - - Vector tmp = pev->origin; - tmp.z = pev->absmax.z + 16; - UTIL_Sparks( tmp ); - } -#endif // DEBUG - - // some condition has interrupted the schedule, or the schedule is done - return FALSE; - } - - return TRUE; -} - -//========================================================= -// MaintainSchedule - does all the per-think schedule maintenance. -// ensures that the monster leaves this function with a valid -// schedule! -//========================================================= -void CBaseMonster :: MaintainSchedule ( void ) -{ - Schedule_t *pNewSchedule; - int i; - - // UNDONE: Tune/fix this 10... This is just here so infinite loops are impossible - for ( i = 0; i < 10; i++ ) - { - if ( m_pSchedule != NULL && TaskIsComplete() ) - { - NextScheduledTask(); - } - - // validate existing schedule - if ( !FScheduleValid() || m_MonsterState != m_IdealMonsterState ) - { - // if we come into this block of code, the schedule is going to have to be changed. - // if the previous schedule was interrupted by a condition, GetIdealState will be - // called. Else, a schedule finished normally. - - // Notify the monster that his schedule is changing - ScheduleChange(); - - // Call GetIdealState if we're not dead and one or more of the following... - // - in COMBAT state with no enemy (it died?) - // - conditions bits (excluding SCHEDULE_DONE) indicate interruption, - // - schedule is done but schedule indicates it wants GetIdealState called - // after successful completion (by setting bits_COND_SCHEDULE_DONE in iInterruptMask) - // DEAD & SCRIPT are not suggestions, they are commands! - if ( m_IdealMonsterState != MONSTERSTATE_DEAD && - (m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState) ) - { - if ( (m_afConditions && !HasConditions(bits_COND_SCHEDULE_DONE)) || - (m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE)) || - ((m_MonsterState == MONSTERSTATE_COMBAT) && (m_hEnemy == NULL)) ) - { - GetIdealState(); - } - } - if ( HasConditions( bits_COND_TASK_FAILED ) && m_MonsterState == m_IdealMonsterState ) - { - if ( m_failSchedule != SCHED_NONE ) - pNewSchedule = GetScheduleOfType( m_failSchedule ); - else - pNewSchedule = GetScheduleOfType( SCHED_FAIL ); - // schedule was invalid because the current task failed to start or complete - ALERT ( at_aiconsole, "Schedule Failed at %d!\n", m_iScheduleIndex ); - ChangeSchedule( pNewSchedule ); - } - else - { - SetState( m_IdealMonsterState ); - if ( m_MonsterState == MONSTERSTATE_SCRIPT || m_MonsterState == MONSTERSTATE_DEAD ) - pNewSchedule = CBaseMonster::GetSchedule(); - else - pNewSchedule = GetSchedule(); - ChangeSchedule( pNewSchedule ); - } - } - - if ( m_iTaskStatus == TASKSTATUS_NEW ) - { - Task_t *pTask = GetTask(); - ASSERT( pTask != NULL ); - TaskBegin(); - StartTask( pTask ); - } - - // UNDONE: Twice?!!! - if ( m_Activity != m_IdealActivity ) - { - SetActivity ( m_IdealActivity ); - } - - if ( !TaskIsComplete() && m_iTaskStatus != TASKSTATUS_NEW ) - break; - } - - if ( TaskIsRunning() ) - { - Task_t *pTask = GetTask(); - ASSERT( pTask != NULL ); - RunTask( pTask ); - } - - // UNDONE: We have to do this so that we have an animation set to blend to if RunTask changes the animation - // RunTask() will always change animations at the end of a script! - // Don't do this twice - if ( m_Activity != m_IdealActivity ) - { - SetActivity ( m_IdealActivity ); - } -} - -//========================================================= -// RunTask -//========================================================= -void CBaseMonster :: RunTask ( Task_t *pTask ) -{ - switch ( pTask->iTask ) - { - case TASK_TURN_RIGHT: - case TASK_TURN_LEFT: - { - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - - case TASK_PLAY_SEQUENCE_FACE_ENEMY: - case TASK_PLAY_SEQUENCE_FACE_TARGET: - { - CBaseEntity *pTarget; - - if ( pTask->iTask == TASK_PLAY_SEQUENCE_FACE_TARGET ) - pTarget = m_hTargetEnt; - else - pTarget = m_hEnemy; - if ( pTarget ) - { - pev->ideal_yaw = UTIL_VecToYaw( pTarget->pev->origin - pev->origin ); - ChangeYaw( pev->yaw_speed ); - } - if ( m_fSequenceFinished ) - TaskComplete(); - } - break; - - case TASK_PLAY_SEQUENCE: - case TASK_PLAY_ACTIVE_IDLE: - { - if ( m_fSequenceFinished ) - { - TaskComplete(); - } - break; - } - - - case TASK_FACE_ENEMY: - { - MakeIdealYaw( m_vecEnemyLKP ); - - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - case TASK_FACE_HINTNODE: - case TASK_FACE_LASTPOSITION: - case TASK_FACE_TARGET: - case TASK_FACE_IDEAL: - case TASK_FACE_ROUTE: - { - ChangeYaw( pev->yaw_speed ); - - if ( FacingIdeal() ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_PVS: - { - if ( !FNullEnt(FIND_CLIENT_IN_PVS(edict())) ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_INDEFINITE: - { - // don't do anything. - break; - } - case TASK_WAIT: - case TASK_WAIT_RANDOM: - { - if ( gpGlobals->time >= m_flWaitFinished ) - { - TaskComplete(); - } - break; - } - case TASK_WAIT_FACE_ENEMY: - { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw( pev->yaw_speed ); - - if ( gpGlobals->time >= m_flWaitFinished ) - { - TaskComplete(); - } - break; - } - case TASK_MOVE_TO_TARGET_RANGE: - { - float distance; - - if ( m_hTargetEnt == NULL ) - TaskFail(); - else - { - distance = ( m_vecMoveGoal - pev->origin ).Length2D(); - // Re-evaluate when you think your finished, or the target has moved too far - if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 ) - { - m_vecMoveGoal = m_hTargetEnt->pev->origin; - distance = ( m_vecMoveGoal - pev->origin ).Length2D(); - FRefreshRoute(); - } - - // Set the appropriate activity based on an overlapping range - // overlap the range to prevent oscillation - if ( distance < pTask->flData ) - { - TaskComplete(); - RouteClear(); // Stop moving - } - else if ( distance < 190 && m_movementActivity != ACT_WALK ) - m_movementActivity = ACT_WALK; - else if ( distance >= 270 && m_movementActivity != ACT_RUN ) - m_movementActivity = ACT_RUN; - } - - break; - } - case TASK_WAIT_FOR_MOVEMENT: - { - if (MovementIsComplete()) - { - TaskComplete(); - RouteClear(); // Stop moving - } - break; - } - case TASK_DIE: - { - if ( m_fSequenceFinished && pev->frame >= 255 ) - { - pev->deadflag = DEAD_DEAD; - - SetThink( NULL ); - StopAnimation(); - - if ( !BBoxFlat() ) - { - // a bit of a hack. If a corpses' bbox is positioned such that being left solid so that it can be attacked will - // block the player on a slope or stairs, the corpse is made nonsolid. -// pev->solid = SOLID_NOT; - UTIL_SetSize ( pev, Vector ( -4, -4, 0 ), Vector ( 4, 4, 1 ) ); - } - else // !!!HACKHACK - put monster in a thin, wide bounding box until we fix the solid type/bounding volume problem - UTIL_SetSize ( pev, Vector ( pev->mins.x, pev->mins.y, pev->mins.z ), Vector ( pev->maxs.x, pev->maxs.y, pev->mins.z + 1 ) ); - - if ( ShouldFadeOnDeath() ) - { - // this monster was created by a monstermaker... fade the corpse out. - SUB_StartFadeOut(); - } - else - { - // body is gonna be around for a while, so have it stink for a bit. - CSoundEnt::InsertSound ( bits_SOUND_CARCASS, pev->origin, 384, 30 ); - } - } - break; - } - case TASK_RANGE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK2_NOTURN: - case TASK_RANGE_ATTACK2_NOTURN: - case TASK_RELOAD_NOTURN: - { - if ( m_fSequenceFinished ) - { - m_Activity = ACT_RESET; - TaskComplete(); - } - break; - } - case TASK_RANGE_ATTACK1: - case TASK_MELEE_ATTACK1: - case TASK_MELEE_ATTACK2: - case TASK_RANGE_ATTACK2: - case TASK_SPECIAL_ATTACK1: - case TASK_SPECIAL_ATTACK2: - case TASK_RELOAD: - { - MakeIdealYaw ( m_vecEnemyLKP ); - ChangeYaw ( pev->yaw_speed ); - - if ( m_fSequenceFinished ) - { - m_Activity = ACT_RESET; - TaskComplete(); - } - break; - } - case TASK_SMALL_FLINCH: - { - if ( m_fSequenceFinished ) - { - TaskComplete(); - } - } - break; - case TASK_WAIT_FOR_SCRIPT: - { - if ( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) - { - TaskComplete(); - m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszPlay, TRUE ); - if ( m_fSequenceFinished ) - ClearSchedule(); - pev->framerate = 1.0; - //ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING(pev->classname) ); - } - break; - } - case TASK_PLAY_SCRIPT: - { - if (m_fSequenceFinished) - { - m_pCine->SequenceDone( this ); - } - break; - } - } -} - -//========================================================= -// SetTurnActivity - measures the difference between the way -// the monster is facing and determines whether or not to -// select one of the 180 turn animations. -//========================================================= -void CBaseMonster :: SetTurnActivity ( void ) -{ - float flYD; - flYD = FlYawDiff(); - - if ( flYD <= -45 && LookupActivity ( ACT_TURN_RIGHT ) != ACTIVITY_NOT_AVAILABLE ) - {// big right turn - m_IdealActivity = ACT_TURN_RIGHT; - } - else if ( flYD > 45 && LookupActivity ( ACT_TURN_LEFT ) != ACTIVITY_NOT_AVAILABLE ) - {// big left turn - m_IdealActivity = ACT_TURN_LEFT; - } -} - -//========================================================= -// Start task - selects the correct activity and performs -// any necessary calculations to start the next task on the -// schedule. -//========================================================= -void CBaseMonster :: StartTask ( Task_t *pTask ) -{ - switch ( pTask->iTask ) - { - case TASK_TURN_RIGHT: - { - float flCurrentYaw; - - flCurrentYaw = UTIL_AngleMod( pev->angles.y ); - pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw - pTask->flData ); - SetTurnActivity(); - break; - } - case TASK_TURN_LEFT: - { - float flCurrentYaw; - - flCurrentYaw = UTIL_AngleMod( pev->angles.y ); - pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw + pTask->flData ); - SetTurnActivity(); - break; - } - case TASK_REMEMBER: - { - Remember ( (int)pTask->flData ); - TaskComplete(); - break; - } - case TASK_FORGET: - { - Forget ( (int)pTask->flData ); - TaskComplete(); - break; - } - case TASK_FIND_HINTNODE: - { - m_iHintNode = FindHintNode(); - - if ( m_iHintNode != NO_NODE ) - { - TaskComplete(); - } - else - { - TaskFail(); - } - break; - } - case TASK_STORE_LASTPOSITION: - { - m_vecLastPosition = pev->origin; - TaskComplete(); - break; - } - case TASK_CLEAR_LASTPOSITION: - { - m_vecLastPosition = g_vecZero; - TaskComplete(); - break; - } - case TASK_CLEAR_HINTNODE: - { - m_iHintNode = NO_NODE; - TaskComplete(); - break; - } - case TASK_STOP_MOVING: - { - if ( m_IdealActivity == m_movementActivity ) - { - m_IdealActivity = GetStoppedActivity(); - } - - RouteClear(); - TaskComplete(); - break; - } - case TASK_PLAY_SEQUENCE_FACE_ENEMY: - case TASK_PLAY_SEQUENCE_FACE_TARGET: - case TASK_PLAY_SEQUENCE: - { - m_IdealActivity = ( Activity )( int )pTask->flData; - break; - } - case TASK_PLAY_ACTIVE_IDLE: - { - // monsters verify that they have a sequence for the node's activity BEFORE - // moving towards the node, so it's ok to just set the activity without checking here. - m_IdealActivity = ( Activity )WorldGraph.m_pNodes[ m_iHintNode ].m_sHintActivity; - break; - } - case TASK_SET_SCHEDULE: - { - Schedule_t *pNewSchedule; - - pNewSchedule = GetScheduleOfType( (int)pTask->flData ); - - if ( pNewSchedule ) - { - ChangeSchedule( pNewSchedule ); - } - else - { - TaskFail(); - } - - break; - } - case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, pTask->flData ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, pTask->flData, CoverRadius() ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_NODE_COVER_FROM_ENEMY: - { - if ( m_hEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, CoverRadius() ) ) - { - // try for cover farther than the FLData from the schedule. - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_COVER_FROM_ENEMY: - { - entvars_t *pevCover; - - if ( m_hEnemy == NULL ) - { - // Find cover from self if no enemy available - pevCover = pev; -// TaskFail(); -// return; - } - else - pevCover = m_hEnemy->pev; - - if ( FindLateralCover( pevCover->origin, pevCover->view_ofs ) ) - { - // try lateral first - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else if ( FindCover( pevCover->origin, pevCover->view_ofs, 0, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no coverwhatsoever. - TaskFail(); - } - break; - } - case TASK_FIND_COVER_FROM_ORIGIN: - { - if ( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no cover! - TaskFail(); - } - } - break; - case TASK_FIND_COVER_FROM_BEST_SOUND: - { - CSound *pBestSound; - - pBestSound = PBestSound(); - - ASSERT( pBestSound != NULL ); - /* - if ( pBestSound && FindLateralCover( pBestSound->m_vecOrigin, g_vecZero ) ) - { - // try lateral first - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - */ - - if ( pBestSound && FindCover( pBestSound->m_vecOrigin, g_vecZero, pBestSound->m_iVolume, CoverRadius() ) ) - { - // then try for plain ole cover - m_flMoveWaitFinished = gpGlobals->time + pTask->flData; - TaskComplete(); - } - else - { - // no coverwhatsoever. or no sound in list - TaskFail(); - } - break; - } - case TASK_FACE_HINTNODE: - { - pev->ideal_yaw = WorldGraph.m_pNodes[ m_iHintNode ].m_flHintYaw; - SetTurnActivity(); - break; - } - - case TASK_FACE_LASTPOSITION: - MakeIdealYaw ( m_vecLastPosition ); - SetTurnActivity(); - break; - - case TASK_FACE_TARGET: - if ( m_hTargetEnt != NULL ) - { - MakeIdealYaw ( m_hTargetEnt->pev->origin ); - SetTurnActivity(); - } - else - TaskFail(); - break; - case TASK_FACE_ENEMY: - { - MakeIdealYaw ( m_vecEnemyLKP ); - SetTurnActivity(); - break; - } - case TASK_FACE_IDEAL: - { - SetTurnActivity(); - break; - } - case TASK_FACE_ROUTE: - { - if (FRouteClear()) - { - ALERT(at_aiconsole, "No route to face!\n"); - TaskFail(); - } - else - { - MakeIdealYaw(m_Route[m_iRouteIndex].vecLocation); - SetTurnActivity(); - } - break; - } - case TASK_WAIT_PVS: - case TASK_WAIT_INDEFINITE: - { - // don't do anything. - break; - } - case TASK_WAIT: - case TASK_WAIT_FACE_ENEMY: - {// set a future time that tells us when the wait is over. - m_flWaitFinished = gpGlobals->time + pTask->flData; - break; - } - case TASK_WAIT_RANDOM: - {// set a future time that tells us when the wait is over. - m_flWaitFinished = gpGlobals->time + RANDOM_FLOAT( 0.1, pTask->flData ); - break; - } - case TASK_MOVE_TO_TARGET_RANGE: - { - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) - TaskComplete(); - else - { - m_vecMoveGoal = m_hTargetEnt->pev->origin; - if ( !MoveToTarget( ACT_WALK, 2 ) ) - TaskFail(); - } - break; - } - case TASK_RUN_TO_TARGET: - case TASK_WALK_TO_TARGET: - { - Activity newActivity; - - if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 ) - TaskComplete(); - else - { - if ( pTask->iTask == TASK_WALK_TO_TARGET ) - newActivity = ACT_WALK; - else - newActivity = ACT_RUN; - // This monster can't do this! - if ( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE ) - TaskComplete(); - else - { - if ( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) - { - TaskFail(); - ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING(pev->classname) ); - RouteClear(); - } - } - } - TaskComplete(); - break; - } - case TASK_CLEAR_MOVE_WAIT: - { - m_flMoveWaitFinished = gpGlobals->time; - TaskComplete(); - break; - } - case TASK_MELEE_ATTACK1_NOTURN: - case TASK_MELEE_ATTACK1: - { - m_IdealActivity = ACT_MELEE_ATTACK1; - break; - } - case TASK_MELEE_ATTACK2_NOTURN: - case TASK_MELEE_ATTACK2: - { - m_IdealActivity = ACT_MELEE_ATTACK2; - break; - } - case TASK_RANGE_ATTACK1_NOTURN: - case TASK_RANGE_ATTACK1: - { - m_IdealActivity = ACT_RANGE_ATTACK1; - break; - } - case TASK_RANGE_ATTACK2_NOTURN: - case TASK_RANGE_ATTACK2: - { - m_IdealActivity = ACT_RANGE_ATTACK2; - break; - } - case TASK_RELOAD_NOTURN: - case TASK_RELOAD: - { - m_IdealActivity = ACT_RELOAD; - break; - } - case TASK_SPECIAL_ATTACK1: - { - m_IdealActivity = ACT_SPECIAL_ATTACK1; - break; - } - case TASK_SPECIAL_ATTACK2: - { - m_IdealActivity = ACT_SPECIAL_ATTACK2; - break; - } - case TASK_SET_ACTIVITY: - { - m_IdealActivity = (Activity)(int)pTask->flData; - TaskComplete(); - break; - } - case TASK_GET_PATH_TO_ENEMY_LKP: - { - if ( BuildRoute ( m_vecEnemyLKP, bits_MF_TO_LOCATION, NULL ) ) - { - TaskComplete(); - } - else if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, 0, (m_vecEnemyLKP - pev->origin).Length() )) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_ENEMY: - { - CBaseEntity *pEnemy = m_hEnemy; - - if ( pEnemy == NULL ) - { - TaskFail(); - return; - } - - if ( BuildRoute ( pEnemy->pev->origin, bits_MF_TO_ENEMY, pEnemy ) ) - { - TaskComplete(); - } - else if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, 0, (pEnemy->pev->origin - pev->origin).Length() )) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_ENEMY_CORPSE: - { - UTIL_MakeVectors( pev->angles ); - if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 64, bits_MF_TO_LOCATION, NULL ) ) - { - TaskComplete(); - } - else - { - ALERT ( at_aiconsole, "GetPathToEnemyCorpse failed!!\n" ); - TaskFail(); - } - } - break; - case TASK_GET_PATH_TO_SPOT: - { - CBaseEntity *pPlayer = CBaseEntity::Instance( FIND_ENTITY_BY_CLASSNAME( NULL, "player" ) ); - if ( BuildRoute ( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); - TaskFail(); - } - break; - } - - case TASK_GET_PATH_TO_TARGET: - { - RouteClear(); - if ( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_HINTNODE:// for active idles! - { - if ( MoveToLocation( m_movementActivity, 2, WorldGraph.m_pNodes[ m_iHintNode ].m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToHintNode failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_LASTPOSITION: - { - m_vecMoveGoal = m_vecLastPosition; - - if ( MoveToLocation( m_movementActivity, 2, m_vecMoveGoal ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToLastPosition failed!!\n" ); - TaskFail(); - } - break; - } - case TASK_GET_PATH_TO_BESTSOUND: - { - CSound *pSound; - - pSound = PBestSound(); - - if ( pSound && MoveToLocation( m_movementActivity, 2, pSound->m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToBestSound failed!!\n" ); - TaskFail(); - } - break; - } -case TASK_GET_PATH_TO_BESTSCENT: - { - CSound *pScent; - - pScent = PBestScent(); - - if ( pScent && MoveToLocation( m_movementActivity, 2, pScent->m_vecOrigin ) ) - { - TaskComplete(); - } - else - { - // no way to get there =( - ALERT ( at_aiconsole, "GetPathToBestScent failed!!\n" ); - - TaskFail(); - } - break; - } - case TASK_RUN_PATH: - { - // UNDONE: This is in some default AI and some monsters can't run? -- walk instead? - if ( LookupActivity( ACT_RUN ) != ACTIVITY_NOT_AVAILABLE ) - { - m_movementActivity = ACT_RUN; - } - else - { - m_movementActivity = ACT_WALK; - } - TaskComplete(); - break; - } - case TASK_WALK_PATH: - { - if ( pev->movetype == MOVETYPE_FLY ) - { - m_movementActivity = ACT_FLY; - } - if ( LookupActivity( ACT_WALK ) != ACTIVITY_NOT_AVAILABLE ) - { - m_movementActivity = ACT_WALK; - } - else - { - m_movementActivity = ACT_RUN; - } - TaskComplete(); - break; - } - case TASK_STRAFE_PATH: - { - Vector2D vec2DirToPoint; - Vector2D vec2RightSide; - - // to start strafing, we have to first figure out if the target is on the left side or right side - UTIL_MakeVectors ( pev->angles ); - - vec2DirToPoint = ( m_Route[ 0 ].vecLocation - pev->origin ).Make2D().Normalize(); - vec2RightSide = gpGlobals->v_right.Make2D().Normalize(); - - if ( DotProduct ( vec2DirToPoint, vec2RightSide ) > 0 ) - { - // strafe right - m_movementActivity = ACT_STRAFE_RIGHT; - } - else - { - // strafe left - m_movementActivity = ACT_STRAFE_LEFT; - } - TaskComplete(); - break; - } - - - case TASK_WAIT_FOR_MOVEMENT: - { - if (FRouteClear()) - { - TaskComplete(); - } - break; - } - - case TASK_EAT: - { - Eat( pTask->flData ); - TaskComplete(); - break; - } - case TASK_SMALL_FLINCH: - { - m_IdealActivity = GetSmallFlinchActivity(); - break; - } - case TASK_DIE: - { - RouteClear(); - - m_IdealActivity = GetDeathActivity(); - - pev->deadflag = DEAD_DYING; - break; - } - case TASK_SOUND_WAKE: - { - AlertSound(); - TaskComplete(); - break; - } - case TASK_SOUND_DIE: - { - DeathSound(); - TaskComplete(); - break; - } - case TASK_SOUND_IDLE: - { - IdleSound(); - TaskComplete(); - break; - } - case TASK_SOUND_PAIN: - { - PainSound(); - TaskComplete(); - break; - } - case TASK_SOUND_DEATH: - { - DeathSound(); - TaskComplete(); - break; - } - case TASK_SOUND_ANGRY: - { - // sounds are complete as soon as we get here, cause we've already played them. - ALERT ( at_aiconsole, "SOUND\n" ); - TaskComplete(); - break; - } - case TASK_WAIT_FOR_SCRIPT: - { - if (m_pCine->m_iszIdle) - { - m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE ); - if (FStrEq( STRING(m_pCine->m_iszIdle), STRING(m_pCine->m_iszPlay))) - { - pev->framerate = 0; - } - } - else - m_IdealActivity = ACT_IDLE; - - break; - } - case TASK_PLAY_SCRIPT: - { - pev->movetype = MOVETYPE_FLY; - ClearBits(pev->flags, FL_ONGROUND); - m_scriptState = SCRIPT_PLAYING; - break; - } - case TASK_ENABLE_SCRIPT: - { - m_pCine->DelayStart( 0 ); - TaskComplete(); - break; - } - case TASK_PLANT_ON_SCRIPT: - { - if ( m_hTargetEnt != NULL ) - { - pev->origin = m_hTargetEnt->pev->origin; // Plant on target - } - - TaskComplete(); - break; - } - case TASK_FACE_SCRIPT: - { - if ( m_hTargetEnt != NULL ) - { - pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); - } - - TaskComplete(); - m_IdealActivity = ACT_IDLE; - RouteClear(); - break; - } - - case TASK_SUGGEST_STATE: - { - m_IdealMonsterState = (MONSTERSTATE)(int)pTask->flData; - TaskComplete(); - break; - } - - case TASK_SET_FAIL_SCHEDULE: - m_failSchedule = (int)pTask->flData; - TaskComplete(); - break; - - case TASK_CLEAR_FAIL_SCHEDULE: - m_failSchedule = SCHED_NONE; - TaskComplete(); - break; - - default: - { - ALERT ( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask ); - break; - } - } -} - -//========================================================= -// GetTask - returns a pointer to the current -// scheduled task. NULL if there's a problem. -//========================================================= -Task_t *CBaseMonster :: GetTask ( void ) -{ - if ( m_iScheduleIndex < 0 || m_iScheduleIndex >= m_pSchedule->cTasks ) - { - // m_iScheduleIndex is not within valid range for the monster's current schedule. - return NULL; - } - else - { - return &m_pSchedule->pTasklist[ m_iScheduleIndex ]; - } -} - -//========================================================= -// GetSchedule - Decides which type of schedule best suits -// the monster's current state and conditions. Then calls -// monster's member function to get a pointer to a schedule -// of the proper type. -//========================================================= -Schedule_t *CBaseMonster :: GetSchedule ( void ) -{ - switch ( m_MonsterState ) - { - case MONSTERSTATE_PRONE: - { - return GetScheduleOfType( SCHED_BARNACLE_VICTIM_GRAB ); - break; - } - case MONSTERSTATE_NONE: - { - ALERT ( at_aiconsole, "MONSTERSTATE IS NONE!\n" ); - break; - } - case MONSTERSTATE_IDLE: - { - if ( HasConditions ( bits_COND_HEAR_SOUND ) ) - { - return GetScheduleOfType( SCHED_ALERT_FACE ); - } - else if ( FRouteClear() ) - { - // no valid route! - return GetScheduleOfType( SCHED_IDLE_STAND ); - } - else - { - // valid route. Get moving - return GetScheduleOfType( SCHED_IDLE_WALK ); - } - break; - } - case MONSTERSTATE_ALERT: - { - if ( HasConditions( bits_COND_ENEMY_DEAD ) && LookupActivity( ACT_VICTORY_DANCE ) != ACTIVITY_NOT_AVAILABLE ) - { - return GetScheduleOfType ( SCHED_VICTORY_DANCE ); - } - - if ( HasConditions(bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE) ) - { - if ( fabs( FlYawDiff() ) < (1.0 - m_flFieldOfView) * 60 ) // roughly in the correct direction - { - return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ORIGIN ); - } - else - { - return GetScheduleOfType( SCHED_ALERT_SMALL_FLINCH ); - } - } - - else if ( HasConditions ( bits_COND_HEAR_SOUND ) ) - { - return GetScheduleOfType( SCHED_ALERT_FACE ); - } - else - { - return GetScheduleOfType( SCHED_ALERT_STAND ); - } - break; - } - case MONSTERSTATE_COMBAT: - { - if ( HasConditions( bits_COND_ENEMY_DEAD ) ) - { - // clear the current (dead) enemy and try to find another. - m_hEnemy = NULL; - - if ( GetEnemy() ) - { - ClearConditions( bits_COND_ENEMY_DEAD ); - return GetSchedule(); - } - else - { - SetState( MONSTERSTATE_ALERT ); - return GetSchedule(); - } - } - - if ( HasConditions(bits_COND_NEW_ENEMY) ) - { - return GetScheduleOfType ( SCHED_WAKE_ANGRY ); - } - else if (HasConditions(bits_COND_LIGHT_DAMAGE) && !HasMemory( bits_MEMORY_FLINCHED) ) - { - return GetScheduleOfType( SCHED_SMALL_FLINCH ); - } - else if ( !HasConditions(bits_COND_SEE_ENEMY) ) - { - // we can't see the enemy - if ( !HasConditions(bits_COND_ENEMY_OCCLUDED) ) - { - // enemy is unseen, but not occluded! - // turn to face enemy - return GetScheduleOfType( SCHED_COMBAT_FACE ); - } - else - { - // chase! - return GetScheduleOfType( SCHED_CHASE_ENEMY ); - } - } - else - { - // we can see the enemy - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK1) ) - { - return GetScheduleOfType( SCHED_RANGE_ATTACK1 ); - } - if ( HasConditions(bits_COND_CAN_RANGE_ATTACK2) ) - { - return GetScheduleOfType( SCHED_RANGE_ATTACK2 ); - } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK1) ) - { - return GetScheduleOfType( SCHED_MELEE_ATTACK1 ); - } - if ( HasConditions(bits_COND_CAN_MELEE_ATTACK2) ) - { - return GetScheduleOfType( SCHED_MELEE_ATTACK2 ); - } - if ( !HasConditions(bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1) ) - { - // if we can see enemy but can't use either attack type, we must need to get closer to enemy - return GetScheduleOfType( SCHED_CHASE_ENEMY ); - } - else if ( !FacingIdeal() ) - { - //turn - return GetScheduleOfType( SCHED_COMBAT_FACE ); - } - else - { - ALERT ( at_aiconsole, "No suitable combat schedule!\n" ); - } - } - break; - } - case MONSTERSTATE_DEAD: - { - return GetScheduleOfType( SCHED_DIE ); - break; - } - case MONSTERSTATE_SCRIPT: - { - ASSERT( m_pCine != NULL ); - if ( !m_pCine ) - { - ALERT( at_aiconsole, "Script failed for %s\n", STRING(pev->classname) ); - CineCleanup(); - return GetScheduleOfType( SCHED_IDLE_STAND ); - } - - return GetScheduleOfType( SCHED_AISCRIPT ); - } - default: - { - ALERT ( at_aiconsole, "Invalid State for GetSchedule!\n" ); - break; - } - } - - return &slError[ 0 ]; -} From 4596f19734fe5cb23ff24808abcd7e1dd579e56c Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 2 Dec 2021 02:19:12 +0300 Subject: [PATCH 03/30] Update windows and visual studio version (#214) * Update windows and visual studio versions in CI * Try without XP toolchain * Revert "Try without XP toolchain" This reverts commit d80321a81880c4200d2e4e14f7bbed3bf9346ab0. * Force 32-bit --- .github/workflows/.github.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/.github.yml b/.github/workflows/.github.yml index 34c449d1..796110fa 100644 --- a/.github/workflows/.github.yml +++ b/.github/workflows/.github.yml @@ -14,7 +14,7 @@ jobs: - os: ubuntu-latest cc: clang cxx: clang++ - - os: windows-2016 + - os: windows-2019 cc: cl cxx: cl env: @@ -81,12 +81,12 @@ jobs: - name: Build with msvc if: startsWith(matrix.os, 'windows') run: | - cmake -G "Visual Studio 15 2017" -B build -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="dist" + cmake -G "Visual Studio 16 2019" -A Win32 -B build -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="dist" msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj - name: Build with msvc and vgui if: startsWith(matrix.os, 'windows') run: | - cmake -G "Visual Studio 15 2017" -B build -DGOLDSOURCE_SUPPORT=ON -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui" + cmake -G "Visual Studio 16 2019" -A Win32 -B build -DGOLDSOURCE_SUPPORT=ON -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui" msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj - name: Extract branch name From ac2a757b9092de9102f07361f0ab07f7d475e07c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sun, 5 Dec 2021 14:13:44 -0500 Subject: [PATCH 04/30] Added missing tracerCount for EV_HLDM_FireBullets. (#216) --- cl_dll/ev_hldm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index f3ed52f8..00835bc8 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -500,7 +500,7 @@ void EV_FireGlock1( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, 0, args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } void EV_FireGlock2( event_args_t *args ) @@ -798,7 +798,7 @@ void EV_FirePython( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== // PHYTON END From 0a0952e186a81a3b219d8c373fd6ce7cc401c42e Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sun, 5 Dec 2021 14:14:31 -0500 Subject: [PATCH 05/30] Use sound array macros. (#215) * Use random sound array. * Use random sound array. * Use random sound array. * Use random sound array. * Use random sound array. --- dlls/agrunt.cpp | 45 ++++++++++++----------------------- dlls/gargantua.cpp | 59 ++++++++++++++-------------------------------- dlls/islave.cpp | 29 ++++++++--------------- dlls/leech.cpp | 12 ++++------ dlls/zombie.cpp | 45 +++++++++++++---------------------- 5 files changed, 63 insertions(+), 127 deletions(-) diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 28374a6b..6c58ba8c 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -335,7 +335,7 @@ void CAGrunt::DeathSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pDieSounds[RANDOM_LONG( 0, ARRAYSIZE( pDieSounds ) - 1 )], 1.0f, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pDieSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -345,7 +345,7 @@ void CAGrunt::AlertSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0f, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -355,7 +355,7 @@ void CAGrunt::AttackSound( void ) { StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0f, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -372,7 +372,7 @@ void CAGrunt::PainSound( void ) StopTalking(); - EMIT_SOUND( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0f, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0f, ATTN_NORM ); } //========================================================= @@ -528,7 +528,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250.0f; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); @@ -537,7 +537,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; @@ -557,7 +557,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250.0f; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); Vector vecArmPos, vecArmAng; GetAttachment( 0, vecArmPos, vecArmAng ); @@ -566,7 +566,7 @@ void CAGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0f, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } } break; @@ -608,30 +608,15 @@ void CAGrunt::Spawn() //========================================================= void CAGrunt::Precache() { - size_t i; - PRECACHE_MODEL( "models/agrunt.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND( pDieSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pDieSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index bc4205e5..f99b4913 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -471,7 +471,7 @@ void CGargantua::StompAttack( void ) UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace ); CStomp::StompCreate( vecStart, trace.vecEndPos, 0 ); UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 ); - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pStompSounds[RANDOM_LONG( 0, ARRAYSIZE( pStompSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pStompSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace ); if( trace.flFraction < 1.0f ) @@ -759,8 +759,6 @@ void CGargantua::Spawn() //========================================================= void CGargantua::Precache() { - size_t i; - PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); PRECACHE_MODEL( GARG_BEAM_SPRITE_NAME ); @@ -769,38 +767,17 @@ void CGargantua::Precache() gGargGibModel = PRECACHE_MODEL( GARG_GIB_MODEL ); PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND( pBeamAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND( pRicSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND( pFootSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND( pStompSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND( pBreatheSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pBeamAttackSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pRicSounds ); + PRECACHE_SOUND_ARRAY( pFootSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pStompSounds ); + PRECACHE_SOUND_ARRAY( pBreatheSounds ); } void CGargantua::UpdateOnRemove() @@ -831,7 +808,7 @@ void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vec { if( m_painSoundTime < gpGlobals->time ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM ); m_painSoundTime = gpGlobals->time + RANDOM_FLOAT( 2.5, 4 ); } } @@ -976,10 +953,10 @@ void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) //UTIL_MakeVectors( pev->angles ); // called by CheckTraceHullAttack pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN( edict(), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG( 0, 15 ) ); Vector forward; UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL ); @@ -988,14 +965,14 @@ void CGargantua::HandleAnimEvent( MonsterEvent_t *pEvent ) case GARG_AE_RIGHT_FOOT: case GARG_AE_LEFT_FOOT: UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 750 ); - EMIT_SOUND_DYN( edict(), CHAN_BODY, pFootSounds[RANDOM_LONG( 0, ARRAYSIZE( pFootSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_BODY, RANDOM_SOUND_ARRAY( pFootSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; case GARG_AE_STOMP: StompAttack(); m_seeTime = gpGlobals->time + 12.0f; break; case GARG_AE_BREATHE: - EMIT_SOUND_DYN( edict(), CHAN_VOICE, pBreatheSounds[RANDOM_LONG( 0, ARRAYSIZE( pBreatheSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); + EMIT_SOUND_DYN( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pBreatheSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; default: CBaseMonster::HandleAnimEvent( pEvent ); @@ -1071,7 +1048,7 @@ void CGargantua::StartTask( Task_t *pTask ) break; case TASK_SOUND_ATTACK: if( RANDOM_LONG( 0, 100 ) < 30 ) - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_GARG, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_GARG, 0, PITCH_NORM ); TaskComplete(); break; case TASK_DIE: diff --git a/dlls/islave.cpp b/dlls/islave.cpp index 51883be3..577eda24 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -235,7 +235,7 @@ void CISlave::PainSound( void ) { if( RANDOM_LONG( 0, 2 ) == 0 ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } @@ -244,7 +244,7 @@ void CISlave::PainSound( void ) //========================================================= void CISlave::DeathSound( void ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pDeathSounds[RANDOM_LONG( 0, ARRAYSIZE( pDeathSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pDeathSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } //========================================================= @@ -315,12 +315,12 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; } // Play a random attack hit sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } else { // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; @@ -334,11 +334,11 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } else { - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, m_voicePitch ); + EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, m_voicePitch ); } } break; @@ -531,8 +531,6 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - size_t i; - PRECACHE_MODEL( "models/islave.mdl" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); PRECACHE_SOUND( "debris/zap1.wav" ); @@ -543,17 +541,10 @@ void CISlave::Precache() PRECACHE_SOUND( "headcrab/hc_headbite.wav" ); PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND( pDeathSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); + PRECACHE_SOUND_ARRAY( pDeathSounds ); UTIL_PrecacheOther( "test_effect" ); } diff --git a/dlls/leech.cpp b/dlls/leech.cpp index 092f338e..fd912510 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -259,27 +259,23 @@ void CLeech::AttackSound( void ) { if( gpGlobals->time > m_attackSoundTime ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0f, ATTN_NORM, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0f, ATTN_NORM, 0, PITCH_NORM ); m_attackSoundTime = gpGlobals->time + 0.5f; } } void CLeech::AlertSound( void ) { - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0f, ATTN_NORM * 0.5f, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0f, ATTN_NORM * 0.5f, 0, PITCH_NORM ); } void CLeech::Precache( void ) { - size_t i; - //PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_MODEL( "models/leech.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 7f891a36..b44dba38 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -154,14 +154,14 @@ void CZombie::PainSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); if( RANDOM_LONG( 0, 5 ) < 2 ) - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pPainSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AlertSound( void ) { int pitch = 95 + RANDOM_LONG( 0, 9 ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[ RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAlertSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::IdleSound( void ) @@ -169,7 +169,7 @@ void CZombie::IdleSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random idle sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pIdleSounds ), 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AttackSound( void ) @@ -177,7 +177,7 @@ void CZombie::AttackSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random attack sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, ATTN_NORM, 0, pitch ); } //========================================================= @@ -202,10 +202,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } // Play a random attack hit sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5 , 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5 , 5 ) ); } else // Play a random attack miss sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -224,10 +224,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 100; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -244,10 +244,10 @@ void CZombie::HandleAnimEvent( MonsterEvent_t *pEvent ) pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * -100; } - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackHitSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackHitSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); } else - EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackMissSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, RANDOM_SOUND_ARRAY( pAttackMissSounds ), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); if( RANDOM_LONG( 0, 1 ) ) AttackSound(); @@ -286,27 +286,14 @@ void CZombie::Spawn() //========================================================= void CZombie::Precache() { - size_t i; - PRECACHE_MODEL( "models/zombie.mdl" ); - for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( pAttackHitSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( pAttackMissSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( pAttackSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( pIdleSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( pAlertSounds[i] ); - - for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( pPainSounds[i] ); + PRECACHE_SOUND_ARRAY( pAttackHitSounds ); + PRECACHE_SOUND_ARRAY( pAttackMissSounds ); + PRECACHE_SOUND_ARRAY( pAttackSounds ); + PRECACHE_SOUND_ARRAY( pIdleSounds ); + PRECACHE_SOUND_ARRAY( pAlertSounds ); + PRECACHE_SOUND_ARRAY( pPainSounds ); } //========================================================= From f7fa565c3fffcb09dd33e32b5d7835de65eafca9 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sun, 5 Dec 2021 14:14:52 -0500 Subject: [PATCH 06/30] Removed unused variables in ev_hldm.cpp (#218) --- cl_dll/ev_hldm.cpp | 14 +++++++------- dlls/egon.cpp | 4 ++-- dlls/hornetgun.cpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 00835bc8..c05d6630 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -514,7 +514,7 @@ void EV_FireGlock2( event_args_t *args ) vec3_t ShellOrigin; int shell; vec3_t vecSrc, vecAiming; - vec3_t vecSpread; + //vec3_t vecSpread; vec3_t up, right, forward; idx = args->entindex; @@ -567,7 +567,7 @@ void EV_FireShotGunDouble( event_args_t *args ) vec3_t ShellOrigin; int shell; vec3_t vecSrc, vecAiming; - vec3_t vecSpread; + //vec3_t vecSpread; vec3_t up, right, forward; //float flSpread = 0.01; @@ -621,7 +621,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t ShellOrigin; int shell; vec3_t vecSrc, vecAiming; - vec3_t vecSpread; + //vec3_t vecSpread; vec3_t up, right, forward; //float flSpread = 0.01; @@ -1150,8 +1150,8 @@ void EV_Crowbar( event_args_t *args ) { int idx; vec3_t origin; - vec3_t angles; - vec3_t velocity; + //vec3_t angles; + //vec3_t velocity; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -1588,7 +1588,7 @@ enum hgun_e void EV_HornetGunFire( event_args_t *args ) { int idx; //, iFireMode; - vec3_t origin, angles, vecSrc, forward, right, up; + vec3_t origin, angles; //, vecSrc, forward, right, up; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -1694,7 +1694,7 @@ enum squeak_e void EV_SnarkFire( event_args_t *args ) { int idx; - vec3_t vecSrc, angles, view_ofs, forward; + vec3_t vecSrc, angles, /*view_ofs,*/ forward; pmtrace_t tr; idx = args->entindex; diff --git a/dlls/egon.cpp b/dlls/egon.cpp index efbe4449..d315e26f 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -197,7 +197,7 @@ void CEgon::Attack( void ) m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, m_fireState, m_fireMode, 1, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, m_fireMode, 1, 0 ); m_shakeTime = 0; @@ -216,7 +216,7 @@ void CEgon::Attack( void ) if( pev->fuser1 <= UTIL_WeaponTimeBase() ) { - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, m_fireState, m_fireMode, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } diff --git a/dlls/hornetgun.cpp b/dlls/hornetgun.cpp index f8c54fbe..4223ddd6 100644 --- a/dlls/hornetgun.cpp +++ b/dlls/hornetgun.cpp @@ -150,7 +150,7 @@ void CHgun::PrimaryAttack() #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, FIREMODE_TRACK, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, 0, 0 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -231,7 +231,7 @@ void CHgun::SecondaryAttack( void ) #else flags = 0; #endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, FIREMODE_FAST, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0f, g_vecZero, g_vecZero, 0.0f, 0.0f, 0, 0, 0, 0 ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; From b776a2b4fc366e7b266cdae166ba031ae7cdb3b3 Mon Sep 17 00:00:00 2001 From: James Davies Date: Sun, 5 Dec 2021 16:12:41 +0000 Subject: [PATCH 07/30] Add PowerPC support --- cmake/LibraryNaming.cmake | 10 ++++++++++ public/build.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/cmake/LibraryNaming.cmake b/cmake/LibraryNaming.cmake index 514313ff..22a70eb3 100644 --- a/cmake/LibraryNaming.cmake +++ b/cmake/LibraryNaming.cmake @@ -28,6 +28,7 @@ check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX) check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN) check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW) check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS) +check_symbol_exists(XASH_PPC "build.h" XASH_PPC) check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM) check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC) check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD) @@ -97,6 +98,15 @@ elseif(XASH_MIPS) if(XASH_LITTLE_ENDIAN) set(BUILDARCH "${BUILDARCH}el") endif() +elseif(XASH_PPC) + set(BUILDARCH "powerpc") + if(XASH_64BIT) + set(BUILDARCH "${BUILDARCH}64") + endif() + + if(XASH_LITTLE_ENDIAN) + set(BUILDARCH "${BUILDARCH}le") + endif() elseif(XASH_RISCV) set(BUILDARCH "riscv") if(XASH_64BIT) diff --git a/public/build.h b/public/build.h index 6e1f326d..3692cf17 100644 --- a/public/build.h +++ b/public/build.h @@ -65,6 +65,7 @@ For more information, please refer to #undef XASH_LITTLE_ENDIAN #undef XASH_MINGW #undef XASH_MIPS +#undef XASH_PPC #undef XASH_MOBILE_PLATFORM #undef XASH_MSVC #undef XASH_NETBSD @@ -212,6 +213,11 @@ For more information, please refer to #endif // __SOFTFP__ #elif defined __mips__ #define XASH_MIPS 1 +#elif defined __powerpc__ + #define XASH_PPC 1 + #if defined __powerpc64__ + #define XASH_64BIT 1 + #endif #elif defined __EMSCRIPTEN__ #define XASH_JS 1 #elif defined __e2k__ From a754219217cadb2e5cd2024a20b8516d44607848 Mon Sep 17 00:00:00 2001 From: James Davies Date: Sun, 5 Dec 2021 18:38:33 +0000 Subject: [PATCH 08/30] Add PowerPC support --- scripts/waifulib/library_naming.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/waifulib/library_naming.py b/scripts/waifulib/library_naming.py index dd825088..a3929067 100644 --- a/scripts/waifulib/library_naming.py +++ b/scripts/waifulib/library_naming.py @@ -47,6 +47,7 @@ DEFINES = [ 'XASH_LITTLE_ENDIAN', 'XASH_MINGW', 'XASH_MIPS', +'XASH_PPC', 'XASH_MOBILE_PLATFORM', 'XASH_MSVC', 'XASH_NETBSD', @@ -123,6 +124,12 @@ def configure(conf): buildarch += "64" if conf.env.XASH_LITTLE_ENDIAN: buildarch += "el" + elif conf.env.XASH_PPC: + buildarch = "powerpc" + if conf.env.XASH_64BIT: + buildarch += "64" + if conf.env.XASH_LITTLE_ENDIAN: + buildarch += "le" elif conf.env.XASH_RISCV: buildarch = "riscv" if conf.env.XASH_64BIT: From 46d642b72b2ef414e6f4aa3202845c3753103864 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 7 Dec 2021 08:30:54 +0300 Subject: [PATCH 09/30] waifulib: update xcompile --- scripts/waifulib/xcompile.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index 752a0794..5d7082b3 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -20,12 +20,12 @@ import os import sys ANDROID_NDK_ENVVARS = ['ANDROID_NDK_HOME', 'ANDROID_NDK'] -ANDROID_NDK_SUPPORTED = [10, 19, 20] +ANDROID_NDK_SUPPORTED = [10, 19, 20, 23] ANDROID_NDK_HARDFP_MAX = 11 # latest version that supports hardfp ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15 ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag -ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16 } # minimal API level ndk revision supports +ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16, 23: 16 } # minimal API level ndk revision supports ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets # This class does support ONLY r10e and r19c/r20 NDK @@ -196,6 +196,8 @@ class Android: return os.path.join(self.gen_gcc_toolchain_path(), 'bin', triplet) def gen_binutils_path(self): + if self.ndk_rev >= 23: + return os.path.join(self.gen_gcc_toolchain_path(), 'bin') return os.path.join(self.gen_gcc_toolchain_path(), self.ndk_triplet(), 'bin') def cc(self): @@ -227,6 +229,9 @@ class Android: if 'STRIP' in environ: return environ['STRIP'] return 'llvm-strip' + + if self.ndk_rev >= 23: + return os.path.join(self.gen_binutils_path(), 'llvm-strip') return os.path.join(self.gen_binutils_path(), 'strip') def system_stl(self): @@ -322,9 +327,16 @@ class Android: return linkflags def ldflags(self): - ldflags = ['-lgcc', '-no-canonical-prefixes'] + ldflags = [] + + if self.ndk_rev < 23: + ldflags += ['-lgcc'] + + ldflags += ['-no-canonical-prefixes'] + if self.is_clang() or self.is_host(): ldflags += ['-stdlib=libstdc++'] + if self.is_arm(): if self.arch == 'armeabi-v7a': ldflags += ['-march=armv7-a', '-mthumb'] From 8a43dfbaabf5094514021c6462acff77b47d1717 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 7 Dec 2021 09:00:35 +0300 Subject: [PATCH 10/30] waifulib: migrate to compiler_optimizations waf tool --- scripts/waifulib/compiler_optimizations.py | 167 +++++++++++++++++++++ wscript | 89 +---------- 2 files changed, 170 insertions(+), 86 deletions(-) create mode 100644 scripts/waifulib/compiler_optimizations.py diff --git a/scripts/waifulib/compiler_optimizations.py b/scripts/waifulib/compiler_optimizations.py new file mode 100644 index 00000000..e964c812 --- /dev/null +++ b/scripts/waifulib/compiler_optimizations.py @@ -0,0 +1,167 @@ +# encoding: utf-8 +# compiler_optimizations.py -- main entry point for configuring C/C++ compilers +# Copyright (C) 2021 a1batross +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +try: from fwgslib import get_flags_by_type, get_flags_by_compiler +except: from waflib.extras.fwgslib import get_flags_by_type, get_flags_by_compiler +from waflib.Configure import conf +from waflib import Logs + +''' +Flags can be overriden and new types can be added +by importing this as normal Python module + +Example: +#!/usr/bin/env python +from waflib.extras import compiler_optimizations + +compiler_optimizations.VALID_BUILD_TYPES += 'gottagofast' +compiler_optimizations.CFLAGS['gottagofast'] = { + 'gcc': ['-Ogentoo'] +} +''' + +VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none'] + +LINKFLAGS = { + 'common': { + 'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries + 'gcc': ['-Wl,--no-undefined'], + 'owcc': ['-Wl,option stack=512k'] + }, + 'sanitize': { + 'clang': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'gcc': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], + }, + 'debug': { + 'msvc': ['/INCREMENTAL', '/SAFESEH:NO'] + } +} + +CFLAGS = { + 'common': { + # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP + 'msvc': ['/D_USING_V110_SDK71_', '/FS', '/Zc:threadSafeInit-', '/MT'], + 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics'], + 'gcc': ['-g', '-fvisibility=hidden'], + 'owcc': ['-fno-short-enum', '-ffloat-store', '-g3'] + }, + 'fast': { + 'msvc': ['/O2', '/Oy', '/Zi'], + 'gcc': { + '3': ['-O3', '-fomit-frame-pointer'], + 'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'] + }, + 'clang': ['-Ofast'], + 'default': ['-O3'] + }, + 'fastnative': { + 'msvc': ['/O2', '/Oy', '/Zi'], + 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], + 'clang': ['-Ofast', '-march=native'], + 'default': ['-O3'] + }, + 'release': { + 'msvc': ['/O2', '/Zi'], + 'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'], + 'default': ['-O3'] + }, + 'debug': { + 'msvc': ['/Od', '/ZI'], + 'owcc': ['-O0', '-fno-omit-frame-pointer', '-funwind-tables', '-fno-omit-leaf-frame-pointer'], + 'default': ['-O0'] + }, + 'sanitize': { + 'msvc': ['/Od', '/RTC1', '/Zi'], + 'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'clang': ['-O0', '-fsanitize=undefined', '-fsanitize=address', '-pthread'], + 'default': ['-O0'] + }, + 'nooptimize': { + 'msvc': ['/Od', '/Zi'], + 'default': ['-O0'] + } +} + +LTO_CFLAGS = { + 'msvc': ['/GL'], + 'gcc': ['-flto'], + 'clang': ['-flto'] +} + +LTO_LINKFLAGS = { + 'msvc': ['/LTCG'], + 'gcc': ['-flto'], + 'clang': ['-flto'] +} + +POLLY_CFLAGS = { + 'gcc': ['-fgraphite-identity'], + 'clang': ['-mllvm', '-polly'] + # msvc sosat :( +} + +def options(opt): + grp = opt.add_option_group('Compiler optimization options') + + grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default=None, + help = 'build type: debug, release or none(custom flags)') + + grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False, + help = 'enable Link Time Optimization if possible [default: %default]') + + grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False, + help = 'enable polyhedral optimization if possible [default: %default]') + +def configure(conf): + conf.start_msg('Build type') + if conf.options.BUILD_TYPE == None: + conf.end_msg('not set', color='RED') + conf.fatal('Set a build type, for example "-T release"') + elif not conf.options.BUILD_TYPE in VALID_BUILD_TYPES: + conf.end_msg(conf.options.BUILD_TYPE, color='RED') + conf.fatal('Invalid build type. Valid are: %s' % ', '.join(VALID_BUILD_TYPES)) + conf.end_msg(conf.options.BUILD_TYPE) + + conf.msg('LTO build', 'yes' if conf.options.LTO else 'no') + conf.msg('PolyOpt build', 'yes' if conf.options.POLLY else 'no') + + # -march=native should not be used + if conf.options.BUILD_TYPE.startswith('fast'): + Logs.warn('WARNING: \'%s\' build type should not be used in release builds', conf.options.BUILD_TYPE) + + try: + conf.env.CC_VERSION[0] + except IndexError: + conf.env.CC_VERSION = (0,) + +@conf +def get_optimization_flags(conf): + '''Returns a list of compile flags, + depending on build type and options set by user + + NOTE: it doesn't filter out unsupported flags + + :returns: tuple of cflags and linkflags + ''' + linkflags = conf.get_flags_by_type(LINKFLAGS, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) + + cflags = conf.get_flags_by_type(CFLAGS, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) + + if conf.options.LTO: + linkflags+= conf.get_flags_by_compiler(LTO_LINKFLAGS, conf.env.COMPILER_CC) + cflags += conf.get_flags_by_compiler(LTO_CFLAGS, conf.env.COMPILER_CC) + + if conf.options.POLLY: + cflags += conf.get_flags_by_compiler(POLLY_CFLAGS, conf.env.COMPILER_CC) + + return cflags, linkflags diff --git a/wscript b/wscript index 200b1e82..336e8d34 100644 --- a/wscript +++ b/wscript @@ -22,9 +22,6 @@ def get_taskgen_count(self): def options(opt): grp = opt.add_option_group('Common options') - grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default = None, - help = 'build type: debug, release or none(custom flags)') - grp.add_option('-8', '--64bits', action = 'store_true', dest = 'ALLOW64', default = False, help = 'allow targetting 64-bit engine(Linux/Windows/OSX x86 only) [default: %default]') @@ -34,13 +31,7 @@ def options(opt): grp.add_option('--enable-goldsrc-support', action = 'store_true', dest = 'GOLDSRC', default = False, help = 'enable GoldSource engine support [default: %default]') - grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False, - help = 'enable Link Time Optimization [default: %default]') - - grp.add_option('--enable-poly-opt', action = 'store_true', dest = 'POLLY', default = False, - help = 'enable polyhedral optimization if possible [default: %default]') - - opt.load('subproject') + opt.load('compiler_optimizations subproject') opt.add_subproject(['cl_dll', 'dlls']) @@ -57,23 +48,9 @@ def configure(conf): conf.env.SERVER_NAME = 'hl' conf.env.PREFIX = '' - conf.load('fwgslib reconfigure enforce_pic') + conf.load('fwgslib reconfigure compiler_optimizations enforce_pic') enforce_pic = True # modern defaults - valid_build_types = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none'] - conf.load('fwgslib reconfigure') - conf.start_msg('Build type') - if conf.options.BUILD_TYPE == None: - conf.end_msg('not set', color='RED') - conf.fatal('Please set a build type, for example "-T release"') - elif not conf.options.BUILD_TYPE in valid_build_types: - conf.end_msg(conf.options.BUILD_TYPE, color='RED') - conf.fatal('Invalid build type. Valid are: %s' % ', '.join(valid_build_types)) - conf.end_msg(conf.options.BUILD_TYPE) - - # -march=native should not be used - if conf.options.BUILD_TYPE == 'fast': - Logs.warn('WARNING: \'fast\' build type should not be used in release builds') conf.env.VOICEMGR = conf.options.VOICEMGR conf.env.GOLDSRC = conf.options.GOLDSRC @@ -96,11 +73,6 @@ def configure(conf): conf.load('msvs msdev strip_on_install') - try: - conf.env.CC_VERSION[0] - except IndexError: - conf.env.CC_VERSION = (0, ) - if conf.env.DEST_OS == 'android': conf.options.GOLDSRC = False conf.env.SERVER_NAME = 'server' # can't be any other name, until specified @@ -121,60 +93,6 @@ def configure(conf): conf.env.BIT32_MANDATORY = not conf.env.BIT32_ALLOW64 conf.load('force_32bit library_naming') - linker_flags = { - 'common': { - 'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries - 'gcc': ['-Wl,--no-undefined'] - }, - 'sanitize': { - 'clang': ['-fsanitize=undefined', '-fsanitize=address'], - 'gcc': ['-fsanitize=undefined', '-fsanitize=address'], - } - } - - compiler_c_cxx_flags = { - 'common': { - # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP - 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], - 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'], - 'gcc': ['-g'] - }, - 'fast': { - 'msvc': ['/O2', '/Oy'], - 'gcc': { - '3': ['-O3', '-Os', '-funsafe-math-optimizations', '-fomit-frame-pointer'], - 'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'] - }, - 'clang': ['-Ofast'], - 'default': ['-O3'] - }, - 'fastnative': { - 'msvc': ['/O2', '/Oy'], - 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], - 'clang': ['-Ofast', '-march=native'], - 'default': ['-O3'] - }, - 'release': { - 'msvc': ['/O2'], - 'default': ['-O3'] - }, - 'debug': { - 'msvc': ['/O1'], - 'gcc': ['-Og'], - 'default': ['-O1'] - }, - 'sanitize': { - 'msvc': ['/Od', '/RTC1'], - 'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address'], - 'clang': ['-O0', '-fsanitize=undefined', '-fsanitize=address'], - 'default': ['-O0'] - }, - 'nooptimize': { - 'msvc': ['/Od'], - 'default': ['-O0'] - } - } - compiler_optional_flags = [ '-fdiagnostics-color=always', '-Werror=return-type', @@ -194,8 +112,7 @@ def configure(conf): '-Werror=declaration-after-statement' ] - linkflags = conf.get_flags_by_type(linker_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) - cflags = conf.get_flags_by_type(compiler_c_cxx_flags, conf.options.BUILD_TYPE, conf.env.COMPILER_CC, conf.env.CC_VERSION[0]) + cflags, linkflags = conf.get_optimization_flags() # Here we don't differentiate C or C++ flags if conf.options.LTO: From 9d65397325db05da88c8cf21dd6a9c9691f1eb99 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 7 Dec 2021 19:50:05 -0500 Subject: [PATCH 11/30] Fixed incorrect field types. (#219) --- dlls/animating.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/animating.cpp b/dlls/animating.cpp index cab2c198..d6cb4190 100644 --- a/dlls/animating.cpp +++ b/dlls/animating.cpp @@ -28,11 +28,11 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = { - DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ), - DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ), - DEFINE_FIELD( CBaseMonster, m_flLastEventCheck, FIELD_TIME ), - DEFINE_FIELD( CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN ), - DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ), + DEFINE_FIELD( CBaseAnimating, m_flFrameRate, FIELD_FLOAT ), + DEFINE_FIELD( CBaseAnimating, m_flGroundSpeed, FIELD_FLOAT ), + DEFINE_FIELD( CBaseAnimating, m_flLastEventCheck, FIELD_TIME ), + DEFINE_FIELD( CBaseAnimating, m_fSequenceFinished, FIELD_BOOLEAN ), + DEFINE_FIELD( CBaseAnimating, m_fSequenceLoops, FIELD_BOOLEAN ), }; IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay ) From dcb83a68565d06d46d963f70ac0fda1c2ef4ab8d Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 7 Dec 2021 19:50:25 -0500 Subject: [PATCH 12/30] Fixed wrong base class specified. (#221) --- dlls/buttons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 87e08ce7..9a63fe34 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -130,7 +130,7 @@ TYPEDESCRIPTION CMultiSource::m_SaveData[] = DEFINE_FIELD( CMultiSource, m_globalstate, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CMultiSource, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CMultiSource, CPointEntity ) LINK_ENTITY_TO_CLASS( multisource, CMultiSource ) From 9aff6c088d2236c28e647834b2ae757fa29c9b1f Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 7 Dec 2021 19:50:45 -0500 Subject: [PATCH 13/30] Fixed wrong base class specified. (#220) --- dlls/buttons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 9a63fe34..7ca7c2fd 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -57,7 +57,7 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = DEFINE_FIELD( CEnvGlobal, m_initialstate, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEnvGlobal, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CEnvGlobal, CPointEntity ) LINK_ENTITY_TO_CLASS( env_global, CEnvGlobal ) From 59fe50125403b0bddd23ad829ac7e9e4570dc926 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Wed, 8 Dec 2021 20:02:49 -0500 Subject: [PATCH 14/30] Fixed wrong base class specified. (#222) --- dlls/func_break.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 98432d06..916913f2 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -139,7 +139,7 @@ TYPEDESCRIPTION CBreakable::m_SaveData[] = // Explosion magnitude is stored in pev->impulse }; -IMPLEMENT_SAVERESTORE( CBreakable, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CBreakable, CBaseDelay ) void CBreakable::Spawn( void ) { From ccfe0c659e2b9d2a44b70c278dc54ad475ed4c62 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Wed, 8 Dec 2021 20:03:12 -0500 Subject: [PATCH 15/30] Fixed wrong base class specified. (#224) --- dlls/h_battery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index f0cf612b..77559cc5 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -60,7 +60,7 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] = DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CRecharge, CBaseToggle ) LINK_ENTITY_TO_CLASS( func_recharge, CRecharge ) From 0df2d289bb5a1b0135dc51c674b77eebb89c538e Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Wed, 8 Dec 2021 20:03:47 -0500 Subject: [PATCH 16/30] Fixed wrong base class specified. (#223) --- dlls/healthkit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index 9e111300..37e4624a 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -127,7 +127,7 @@ TYPEDESCRIPTION CWallHealth::m_SaveData[] = DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME ), }; -IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CWallHealth, CBaseToggle ) LINK_ENTITY_TO_CLASS( func_healthcharger, CWallHealth ) From a5344eb4ccaf10c1deaec27e6e10de90aa92438f Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Thu, 9 Dec 2021 21:38:48 -0500 Subject: [PATCH 17/30] Fixed wrong base class specified. (#226) --- dlls/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 688b4016..3dbd097a 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -825,7 +825,7 @@ TYPEDESCRIPTION CEnvSound::m_SaveData[] = DEFINE_FIELD( CEnvSound, m_flRoomtype, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE( CEnvSound, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CEnvSound, CPointEntity ) void CEnvSound::KeyValue( KeyValueData *pkvd ) { From f0ed7d1bc194f66be5c5df084d8dc7f76706a56c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Thu, 9 Dec 2021 21:39:06 -0500 Subject: [PATCH 18/30] Fixed wrong base class specified. (#225) --- dlls/pathcorner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/pathcorner.cpp b/dlls/pathcorner.cpp index bc999675..c563bf69 100644 --- a/dlls/pathcorner.cpp +++ b/dlls/pathcorner.cpp @@ -125,7 +125,7 @@ TYPEDESCRIPTION CPathTrack::m_SaveData[] = DEFINE_FIELD( CPathTrack, m_altName, FIELD_STRING ), }; -IMPLEMENT_SAVERESTORE( CPathTrack, CBaseEntity ) +IMPLEMENT_SAVERESTORE( CPathTrack, CPointEntity ) LINK_ENTITY_TO_CLASS( path_track, CPathTrack ) // From f43961e4d044bbc82dae0c7aac0797008cd7adf4 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 14 Dec 2021 09:23:07 -0500 Subject: [PATCH 19/30] Simplify glock fire events (#231) * Refactor EV_FireGlock2. * Moved EV_FireGlock1 implementation to static function. --- cl_dll/ev_hldm.cpp | 51 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index c05d6630..6eee0328 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -458,7 +458,8 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int //====================== // GLOCK START //====================== -void EV_FireGlock1( event_args_t *args ) +// Shared Glock fire implementation for EV_FireGlock1 and EV_FireGlock2. +static void EV_FireGlock_Impl( event_args_t *args ) { int idx; vec3_t origin; @@ -503,50 +504,14 @@ void EV_FireGlock1( event_args_t *args ) EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } -void EV_FireGlock2( event_args_t *args ) +void EV_FireGlock1( event_args_t *args ) { - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t ShellVelocity; - vec3_t ShellOrigin; - int shell; - vec3_t vecSrc, vecAiming; - //vec3_t vecSpread; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - int empty = args->bparam1; - - AngleVectors( angles, forward, right, up ); - - shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell - - if( EV_IsLocal( idx ) ) - { - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); - - V_PunchAxis( 0, -2.0 ); - } - - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - VectorCopy( forward, vecAiming ); + EV_FireGlock_Impl( args ); +} - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); +void EV_FireGlock2( event_args_t *args ) +{ + EV_FireGlock_Impl( args ); } //====================== // GLOCK END From 215ac04f7094880c04d5eb40c9c63dd8853b6ed8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 17 Dec 2021 03:16:35 +0300 Subject: [PATCH 20/30] waifulib: update xcompile from engine branch --- scripts/waifulib/xcompile.py | 52 +++++++++++++++++------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index 5d7082b3..0abf53f1 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -26,6 +26,8 @@ ANDROID_NDK_GCC_MAX = 17 # latest NDK that ships with GCC ANDROID_NDK_UNIFIED_SYSROOT_MIN = 15 ANDROID_NDK_SYSROOT_FLAG_MAX = 19 # latest NDK that need --sysroot flag ANDROID_NDK_API_MIN = { 10: 3, 19: 16, 20: 16, 23: 16 } # minimal API level ndk revision supports + +ANDROID_STPCPY_API_MIN = 21 # stpcpy() introduced in SDK 21 ANDROID_64BIT_API_MIN = 21 # minimal API level that supports 64-bit targets # This class does support ONLY r10e and r19c/r20 NDK @@ -266,47 +268,43 @@ class Android: '-isystem', '%s/usr/include/' % (self.sysroot()) ] - cflags += ['-I%s' % (self.system_stl()), '-DANDROID', '-D__ANDROID__'] + cflags += ['-I%s' % (self.system_stl())] + if not self.is_clang(): + cflags += ['-DANDROID', '-D__ANDROID__'] if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']: cflags += ['-fno-sized-deallocation'] - def fixup_host_clang_with_old_ndk(): - cflags = [] - # Clang builtin redefine w/ different calling convention bug - # NOTE: I did not added complex.h functions here, despite - # that NDK devs forgot to put __NDK_FPABI_MATH__ for complex - # math functions - # I personally don't need complex numbers support, but if you want it - # just run sed to patch header - for f in ['strtod', 'strtof', 'strtold']: - cflags += ['-fno-builtin-%s' % f] - return cflags - + if self.is_clang(): + # stpcpy() isn't available in early Android versions + # disable it here so Clang won't use it + if self.api < ANDROID_STPCPY_API_MIN: + cflags += ['-fno-builtin-stpcpy'] if self.is_arm(): if self.arch == 'armeabi-v7a': # ARMv7 support - cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS'] - - if not self.is_clang() and not self.is_host(): - cflags += [ '-mvectorize-with-neon-quad' ] - - if self.is_host() and self.ndk_rev <= ANDROID_NDK_HARDFP_MAX: - cflags += fixup_host_clang_with_old_ndk() + cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9'] if self.is_hardfp(): cflags += ['-D_NDK_MATH_NO_SOFTFP=1', '-mfloat-abi=hard', '-DLOAD_HARDFP', '-DSOFTFP_LINK'] + + if self.is_host(): + # Clang builtin redefine w/ different calling convention bug + # NOTE: I did not added complex.h functions here, despite + # that NDK devs forgot to put __NDK_FPABI_MATH__ for complex + # math functions + # I personally don't need complex numbers support, but if you want it + # just run sed to patch header + for f in ['strtod', 'strtof', 'strtold']: + cflags += ['-fno-builtin-%s' % f] else: cflags += ['-mfloat-abi=softfp'] else: - if self.is_host() and self.ndk_rev <= ANDROID_NDK_HARDFP_MAX: - cflags += fixup_host_clang_with_old_ndk() - # ARMv5 support cflags += ['-march=armv5te', '-msoft-float'] elif self.is_x86(): - cflags += ['-mtune=atom', '-march=atom', '-mssse3', '-mfpmath=sse', '-DVECTORIZE_SINCOS', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS'] + cflags += ['-mtune=atom', '-march=atom', '-mssse3', '-mfpmath=sse'] return cflags # they go before object list @@ -322,8 +320,9 @@ class Android: if self.is_clang() or self.is_host(): linkflags += ['-fuse-ld=lld'] + else: linkflags += ['-no-canonical-prefixes'] - linkflags += ['-Wl,--hash-style=sysv', '-Wl,--no-undefined', '-no-canonical-prefixes'] + linkflags += ['-Wl,--hash-style=sysv', '-Wl,--no-undefined'] return linkflags def ldflags(self): @@ -332,10 +331,9 @@ class Android: if self.ndk_rev < 23: ldflags += ['-lgcc'] - ldflags += ['-no-canonical-prefixes'] - if self.is_clang() or self.is_host(): ldflags += ['-stdlib=libstdc++'] + else: ldflags += ['-no-canonical-prefixes'] if self.is_arm(): if self.arch == 'armeabi-v7a': From db95d4a1ccdfdbcf379155c9122b11c557cfb05d Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Mon, 20 Dec 2021 09:17:49 -0500 Subject: [PATCH 21/30] Removed duplicate field in CShotgun save data table. (#233) --- dlls/weapons.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 773213b3..f4ad57c4 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1603,7 +1603,6 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] = { DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), DEFINE_FIELD( CShotgun, m_fInSpecialReload, FIELD_INTEGER ), - DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), // DEFINE_FIELD( CShotgun, m_iShell, FIELD_INTEGER ), DEFINE_FIELD( CShotgun, m_flPumpTime, FIELD_TIME ), }; From 8768594509cfd330613211fb2e176117ad4eaa37 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Mon, 20 Dec 2021 18:00:54 -0500 Subject: [PATCH 22/30] Decrement rocket count only if it was successfully created. (#234) In addition, make smoke effect and swap sides only if rocket was successfully created. --- dlls/apache.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/dlls/apache.cpp b/dlls/apache.cpp index 0844e2c4..f37f8cb1 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -757,23 +757,25 @@ void CApache::FireRocket( void ) break; } - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); - WRITE_BYTE( TE_SMOKE ); - WRITE_COORD( vecSrc.x ); - WRITE_COORD( vecSrc.y ); - WRITE_COORD( vecSrc.z ); - WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( 20 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate - MESSAGE_END(); - CBaseEntity *pRocket = CBaseEntity::Create( "hvr_rocket", vecSrc, pev->angles, edict() ); if( pRocket ) + { + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc ); + WRITE_BYTE( TE_SMOKE ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_SHORT( g_sModelIndexSmoke ); + WRITE_BYTE( 20 ); // scale * 10 + WRITE_BYTE( 12 ); // framerate + MESSAGE_END(); + pRocket->pev->velocity = pev->velocity + gpGlobals->v_forward * 100.0f; - m_iRockets--; + m_iRockets--; - side = - side; + side = - side; + } } BOOL CApache::FireGun() From 1f23bff236b9d3a3bd717ea533cee42b931d564c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Fri, 31 Dec 2021 12:03:05 -0500 Subject: [PATCH 23/30] Restore Hornetgun fire phase. (#238) --- dlls/weapons.cpp | 1 + dlls/weapons.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index f4ad57c4..76e5408d 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1637,6 +1637,7 @@ IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) TYPEDESCRIPTION CHgun::m_SaveData[] = { DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_TIME ), + DEFINE_FIELD( CHgun, m_iFirePhase, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 7e33de78..c5f0d46a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -870,7 +870,7 @@ public: float m_flRechargeTime; - int m_iFirePhase;// don't save me. + int m_iFirePhase; virtual BOOL UseDecrement( void ) { From e7ef84c83db25f5b5b4c8549069135331b5ceeb2 Mon Sep 17 00:00:00 2001 From: a1batross Date: Fri, 21 Jan 2022 03:58:52 +0300 Subject: [PATCH 24/30] engine: delete obsolete engine VC6 project --- engine/engine.dsp | 621 ---------------------------------------------- 1 file changed, 621 deletions(-) delete mode 100644 engine/engine.dsp diff --git a/engine/engine.dsp b/engine/engine.dsp deleted file mode 100644 index b79d1bfe..00000000 --- a/engine/engine.dsp +++ /dev/null @@ -1,621 +0,0 @@ -# Microsoft Developer Studio Project File - Name="engine" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=engine - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "engine.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "engine.mak" CFG="engine - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "engine - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "engine - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "engine - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\Release" -# PROP BASE Intermediate_Dir ".\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\engine\!release" -# PROP Intermediate_Dir "..\temp\engine\!release" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "common/imagelib" /I "common/soundlib" /I "server" /I "client" /I "client/vgui" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /Fr /YX -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /opt:nowin98 -# ADD LINK32 msvcrt.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc" /out:"..\temp\engine\!release/xash.dll" /libpath:"./common/soundlib" /opt:nowin98 -# SUBTRACT LINK32 /debug /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\engine\!release -InputPath=\Xash3D\src_main\temp\engine\!release\xash.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" - -# End Custom Build - -!ELSEIF "$(CFG)" == "engine - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\Debug" -# PROP BASE Intermediate_Dir ".\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\engine\!debug" -# PROP Intermediate_Dir "..\temp\engine\!debug" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "common/imagelib" /I "common/soundlib" /I "server" /I "client" /I "client/vgui" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FAs /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 -# ADD LINK32 msvcrtd.lib user32.lib gdi32.lib shell32.lib advapi32.lib winmm.lib mpeg_dbg.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libcd.lib" /out:"..\temp\engine\!debug/xash.dll" /pdbtype:sept /libpath:"./common/soundlib" -# SUBTRACT LINK32 /incremental:no /map /nodefaultlib -# Begin Custom Build -TargetDir=\Xash3D\src_main\temp\engine\!debug -InputPath=\Xash3D\src_main\temp\engine\!debug\xash.dll -SOURCE="$(InputPath)" - -"D:\Xash3D\xash.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\xash.dll "D:\Xash3D\xash.dll" - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "engine - Win32 Release" -# Name "engine - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\common\avikit.c -# End Source File -# Begin Source File - -SOURCE=.\common\build.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_cmds.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_demo.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_events.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_frame.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_game.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_main.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_menu.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_parse.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_pmove.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_remap.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_scrn.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_tent.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_video.c -# End Source File -# Begin Source File - -SOURCE=.\client\cl_view.c -# End Source File -# Begin Source File - -SOURCE=.\common\cmd.c -# End Source File -# Begin Source File - -SOURCE=.\common\common.c -# End Source File -# Begin Source File - -SOURCE=.\common\con_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\console.c -# End Source File -# Begin Source File - -SOURCE=.\common\crclib.c -# End Source File -# Begin Source File - -SOURCE=.\common\crtlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\cvar.c -# End Source File -# Begin Source File - -SOURCE=.\common\filesystem.c -# End Source File -# Begin Source File - -SOURCE=.\common\gamma.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_backend.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_beams.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_cull.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_decals.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_draw.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_image.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_mirror.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_refrag.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rlight.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmain.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmath.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rmisc.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rpart.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_rsurf.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_sprite.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_studio.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_vidnt.c -# End Source File -# Begin Source File - -SOURCE=.\client\gl_warp.c -# End Source File -# Begin Source File - -SOURCE=.\common\host.c -# End Source File -# Begin Source File - -SOURCE=.\common\hpak.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_bmp.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_dds.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_main.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_quant.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_tga.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\img_wad.c -# End Source File -# Begin Source File - -SOURCE=.\common\infostring.c -# End Source File -# Begin Source File - -SOURCE=.\common\input.c -# End Source File -# Begin Source File - -SOURCE=.\common\keys.c -# End Source File -# Begin Source File - -SOURCE=.\common\library.c -# End Source File -# Begin Source File - -SOURCE=.\common\mathlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\matrixlib.c -# End Source File -# Begin Source File - -SOURCE=.\common\mod_studio.c -# End Source File -# Begin Source File - -SOURCE=.\common\model.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_buffer.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_chan.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_encode.c -# End Source File -# Begin Source File - -SOURCE=.\common\net_huff.c -# End Source File -# Begin Source File - -SOURCE=.\common\network.c -# End Source File -# Begin Source File - -SOURCE=.\common\pm_surface.c -# End Source File -# Begin Source File - -SOURCE=.\common\pm_trace.c -# End Source File -# Begin Source File - -SOURCE=.\common\random.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_backend.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_dsp.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_load.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_main.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_mix.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_mouth.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_stream.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_utils.c -# End Source File -# Begin Source File - -SOURCE=.\client\s_vox.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_main.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_mp3.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_utils.c -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\snd_wav.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_client.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_cmds.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_custom.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_frame.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_game.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_init.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_main.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_move.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_phys.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_pmove.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_save.c -# End Source File -# Begin Source File - -SOURCE=.\server\sv_world.c -# End Source File -# Begin Source File - -SOURCE=.\common\sys_con.c -# End Source File -# Begin Source File - -SOURCE=.\common\sys_win.c -# End Source File -# Begin Source File - -SOURCE=.\common\titles.c -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_clip.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_draw.c -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_font.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_input.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_int.cpp -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_surf.cpp -# End Source File -# Begin Source File - -SOURCE=.\common\world.c -# End Source File -# Begin Source File - -SOURCE=.\common\zone.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\client\cl_tent.h -# End Source File -# Begin Source File - -SOURCE=.\client\client.h -# End Source File -# Begin Source File - -SOURCE=.\common\common.h -# End Source File -# Begin Source File - -SOURCE=.\common\crtlib.h -# End Source File -# Begin Source File - -SOURCE=.\common\filesystem.h -# End Source File -# Begin Source File - -SOURCE=.\client\gl_export.h -# End Source File -# Begin Source File - -SOURCE=.\client\gl_local.h -# End Source File -# Begin Source File - -SOURCE=.\common\imagelib\imagelib.h -# End Source File -# Begin Source File - -SOURCE=.\common\library.h -# End Source File -# Begin Source File - -SOURCE=.\common\mathlib.h -# End Source File -# Begin Source File - -SOURCE=.\common\mod_local.h -# End Source File -# Begin Source File - -SOURCE=.\common\net_buffer.h -# End Source File -# Begin Source File - -SOURCE=.\common\net_encode.h -# End Source File -# Begin Source File - -SOURCE=.\common\protocol.h -# End Source File -# Begin Source File - -SOURCE=.\server\server.h -# End Source File -# Begin Source File - -SOURCE=.\client\sound.h -# End Source File -# Begin Source File - -SOURCE=.\common\soundlib\soundlib.h -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_draw.h -# End Source File -# Begin Source File - -SOURCE=.\client\vgui\vgui_main.h -# End Source File -# Begin Source File - -SOURCE=.\client\vox.h -# End Source File -# Begin Source File - -SOURCE=.\common\world.h -# End Source File -# End Group -# End Target -# End Project From 808be9442f60b4388f68fcef8b2659d0cd6db17b Mon Sep 17 00:00:00 2001 From: a1batross Date: Sun, 24 Apr 2022 01:43:45 +0300 Subject: [PATCH 25/30] Use filtered command buffer when string came from network (#241) * cdll_int: add undocumented FilteredClientCmd function to client interface * client: use filtered command buffer where we have to execute command from server * client: use normal pfnClientCmd in place of pfnFilteredClientCmd in case of engine doesn't supports it * client: don't read out of bounds if engine interface is old and don't have pfnFilteredClientCmd * client: fix incorrect cvar pointer comparison --- cl_dll/cdll_int.cpp | 12 +++++++++++- cl_dll/hud_spectator.cpp | 2 +- cl_dll/vgui_TeamFortressViewport.h | 2 +- engine/cdll_int.h | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 23da5ae7..17fc06f3 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -167,7 +167,17 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) if( iVersion != CLDLL_INTERFACE_VERSION ) return 0; - memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) ); + // for now filterstuffcmd is last in the engine interface + memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) - sizeof( void * ) ); + + if( gEngfuncs.pfnGetCvarPointer( "cl_filterstuffcmd" ) == 0 ) + { + gEngfuncs.pfnFilteredClientCmd = gEngfuncs.pfnClientCmd; + } + else + { + gEngfuncs.pfnFilteredClientCmd = pEnginefuncs->pfnFilteredClientCmd; + } EV_HookEvents(); diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index bfd8112b..c20e6ba0 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -577,7 +577,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf ) case DRC_CMD_FADE: break; case DRC_CMD_STUFFTEXT: - ClientCmd( READ_STRING() ); + gEngfuncs.pfnFilteredClientCmd( READ_STRING() ); break; default: gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd ); diff --git a/cl_dll/vgui_TeamFortressViewport.h b/cl_dll/vgui_TeamFortressViewport.h index 39c6b26f..ee295b59 100644 --- a/cl_dll/vgui_TeamFortressViewport.h +++ b/cl_dll/vgui_TeamFortressViewport.h @@ -667,7 +667,7 @@ public: virtual void actionPerformed(Panel *panel) { - gEngfuncs.pfnClientCmd( m_pszCommand ); + gEngfuncs.pfnFilteredClientCmd( m_pszCommand ); if( m_iCloseVGUIMenu ) gViewPort->HideTopMenu(); diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 02d277dd..64620497 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -303,6 +303,9 @@ typedef struct cl_enginefuncs_s int (*pfnGetAppID)( void ); cmdalias_t *(*pfnGetAliases)( void ); void (*pfnVguiWrap2_GetMouseDelta)( int *x, int *y ); + + // added in 2019 update, not documented yet + int (*pfnFilteredClientCmd)( const char *cmd ); } cl_enginefunc_t; #define CLDLL_INTERFACE_VERSION 7 From cf4d2a74dce92c737b8757d0240960d48f9748ec Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Fri, 3 Jun 2022 21:43:06 +0500 Subject: [PATCH 26/30] Change default thirdperson view. --- cl_dll/in_camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index ac68be5e..7a81a15f 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -535,9 +535,9 @@ void CAM_Init( void ) cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view - cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw + cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "0", 0 ); // thirdperson yaw cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch - cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance + cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "128", 0 ); // thirdperson distance cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 ); From e2da6954c85e092d80ab182290aeaaa4d162f16f Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:13:28 +0500 Subject: [PATCH 27/30] Fix crowbar not showing in weapon list if there are empty weapon slots with lower id. Same as https://github.com/SamVanheer/halflife-updated/commit/ffe736252c45ad953ad709572f0c9d42db06dd33 --- cl_dll/ammo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 94952df7..0e3d0a07 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -359,7 +359,7 @@ void CHudAmmo::Think( void ) { WEAPON *p = gWR.GetWeapon( i ); - if( p ) + if( p && p->iId ) { if( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) gWR.PickupWeapon( p ); From 630217f0b111a51cce24a83c7377958588d0a083 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sat, 4 Jun 2022 21:17:26 +0500 Subject: [PATCH 28/30] cmake: fix wrong library naming scheme --- CMakeLists.txt | 2 +- cmake/LibraryNaming.cmake | 6 +++++- dlls/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab3160c1..2c6e0987 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ option(64BIT "Disable auto -m32 appending to compiler flags" OFF) set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") -set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows") +set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for PC platforms") #----------------- # MAIN BUILD CODE \ diff --git a/cmake/LibraryNaming.cmake b/cmake/LibraryNaming.cmake index 22a70eb3..ca6fb42e 100644 --- a/cmake/LibraryNaming.cmake +++ b/cmake/LibraryNaming.cmake @@ -65,7 +65,11 @@ endif() if(XASH_AMD64) set(BUILDARCH "amd64") elseif(XASH_X86) - set(BUILDARCH "") + if(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE) + set(BUILDARCH "") # no prefix for default OS + else() + set(BUILDARCH "i386") + endif() elseif(XASH_ARM AND XASH_64BIT) set(BUILDARCH "arm64") elseif(XASH_ARM) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 4f8e60ac..77cd47e6 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -169,7 +169,7 @@ add_library (${SVDLL_LIBRARY} SHARED ${SVDLL_SOURCES}) set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) -if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(SVDLL_NAME "${SERVER_LIBRARY_NAME}") set_target_properties(${SVDLL_LIBRARY} PROPERTIES From c3f77a2ea5f6890620dc7935cbc8e5b63a5b14c6 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sat, 4 Jun 2022 22:23:41 +0500 Subject: [PATCH 29/30] cmake: disable 64BIT flag by default only for 32-bit archs and 64-bit windows and linux --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c6e0987..e07c471c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,17 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) -option(64BIT "Disable auto -m32 appending to compiler flags" OFF) + +if (CMAKE_SIZEOF_VOID_P EQUAL 4 OR + (WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x64" + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")) + option(64BIT "Disable auto -m32 appending to compiler flags" OFF) +else() + option(64BIT "Disable auto -m32 appending to compiler flags" ON) +endif() + set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") From 3db3772bff576cc0cb7fd0a380090d3c8794de5c Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Sat, 4 Jun 2022 22:49:11 +0500 Subject: [PATCH 30/30] cmake: add a missing brackets --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e07c471c..123cd838 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,10 @@ option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) if (CMAKE_SIZEOF_VOID_P EQUAL 4 OR - (WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + ((WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" - OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")) + OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64"))) option(64BIT "Disable auto -m32 appending to compiler flags" OFF) else() option(64BIT "Disable auto -m32 appending to compiler flags" ON)