Merge pull request #95 from z33ky/gcc-linux

gcc/Linux update
This commit is contained in:
Blixibon 2021-04-07 17:40:17 -05:00 committed by GitHub
commit d4311587c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 119 additions and 73 deletions

View File

@ -6,10 +6,11 @@ MAKEFILE_LINK:=$(THISFILE).link
-include $(MAKEFILE_LINK)
$(MAKEFILE_LINK): $(shell which $(CC)) $(THISFILE)
if [ "$(shell printf "$(shell $(CC) -dumpversion)\n8" | sort -Vr | head -1)" = 8 ]; then \
$(COMPILE.cpp) -o gcc9+support.o gcc9+support.c ;\
# depend on CXX so the correct makefile can be selected when the system is updated
$(MAKEFILE_LINK): $(shell which $(CXX)) $(THISFILE) $(SRCROOT)/devtools/gcc9+support.cpp
@ if [ "$(shell printf "$(shell $(CXX) -dumpversion)\n8" | sort -Vr | head -1)" = 8 ]; then \
ln -sf $(MAKEFILE_BASE).default $@ ;\
else \
$(COMPILE.cpp) -o $(SRCROOT)/devtools/gcc9+support.o $(SRCROOT)/devtools/gcc9+support.cpp &&\
ln -sf $(MAKEFILE_BASE).gcc8 $@ ;\
fi

View File

@ -400,7 +400,7 @@ public:
#ifdef MAPBASE_VSCRIPT
// "I don't know why but wrapping entindex() works, while calling it directly crashes."
inline int C_BaseEntity::GetEntityIndex() const { return entindex(); }
inline int GetEntityIndex() const { return entindex(); }
#endif
// This works for client-only entities and returns the GetEntryIndex() of the entity's handle,

View File

@ -15,7 +15,7 @@
#include "ammodef.h"
#include "vprof.h"
#include "view.h"
#include "vstdlib/ikeyvaluessystem.h"
#include "vstdlib/IKeyValuesSystem.h"
#ifdef MAPBASE
#include "usermessages.h"
#endif
@ -666,7 +666,8 @@ void CIconLesson::UpdateInactive()
CUtlBuffer msg_data;
msg_data.PutChar( 1 );
msg_data.PutString( m_szHudHint.String() );
usermessages->DispatchUserMessage( usermessages->LookupUserMessage( "KeyHintText" ), bf_read( msg_data.Base(), msg_data.TellPut() ) );
bf_read msg( msg_data.Base(), msg_data.TellPut() );
usermessages->DispatchUserMessage( usermessages->LookupUserMessage( "KeyHintText" ), msg );
}
#endif
@ -1039,40 +1040,40 @@ Vector CIconLesson::GetIconTargetPosition( C_BaseEntity *pIconTarget )
#define LESSON_VARIABLE_INIT_SYMBOL( _varEnum, _varName, _varType ) g_n##_varEnum##Symbol = KeyValuesSystem()->GetSymbolForString( #_varEnum );
#define LESSON_SCRIPT_STRING_ADD_TO_MAP( _varEnum, _varName, _varType ) g_NameToTypeMap.Insert( #_varEnum, LESSON_VARIABLE_##_varEnum## );
#define LESSON_SCRIPT_STRING_ADD_TO_MAP( _varEnum, _varName, _varType ) g_NameToTypeMap.Insert( #_varEnum, LESSON_VARIABLE_##_varEnum );
// Create enum value
#define LESSON_VARIABLE_ENUM( _varEnum, _varName, _varType ) LESSON_VARIABLE_##_varEnum##,
#define LESSON_VARIABLE_ENUM( _varEnum, _varName, _varType ) LESSON_VARIABLE_##_varEnum,
// Init info call
#define LESSON_VARIABLE_INIT_INFO_CALL( _varEnum, _varName, _varType ) g_pLessonVariableInfo[ LESSON_VARIABLE_##_varEnum## ].Init_##_varEnum##();
#define LESSON_VARIABLE_INIT_INFO_CALL( _varEnum, _varName, _varType ) g_pLessonVariableInfo[ LESSON_VARIABLE_##_varEnum ].Init_##_varEnum();
// Init info
#define LESSON_VARIABLE_INIT_INFO( _varEnum, _varName, _varType ) \
void Init_##_varEnum##() \
void Init_##_varEnum() \
{ \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::##_varName## ); \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::_varName ); \
varType = LessonParamTypeFromString( #_varType ); \
}
#define LESSON_VARIABLE_INIT_INFO_BOOL( _varEnum, _varName, _varType ) \
void Init_##_varEnum##() \
void Init_##_varEnum() \
{ \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::##_varName## ); \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::_varName ); \
varType = FIELD_BOOLEAN; \
}
#define LESSON_VARIABLE_INIT_INFO_EHANDLE( _varEnum, _varName, _varType ) \
void Init_##_varEnum##() \
void Init_##_varEnum() \
{ \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::##_varName## ); \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::_varName ); \
varType = FIELD_EHANDLE; \
}
#define LESSON_VARIABLE_INIT_INFO_STRING( _varEnum, _varName, _varType ) \
void Init_##_varEnum##() \
void Init_##_varEnum() \
{ \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::##_varName## ); \
iOffset = offsetof( CScriptedIconLesson, CScriptedIconLesson::_varName ); \
varType = FIELD_STRING; \
}
@ -1094,15 +1095,15 @@ Vector CIconLesson::GetIconTargetPosition( C_BaseEntity *pIconTarget )
// Process the element action on this variable
#define PROCESS_LESSON_ACTION( _varEnum, _varName, _varType ) \
case LESSON_VARIABLE_##_varEnum##:\
case LESSON_VARIABLE_##_varEnum:\
return ProcessElementAction( pLessonElement->iAction, pLessonElement->bNot, #_varName, _varName, &pLessonElement->szParam, eventParam_float );
#define PROCESS_LESSON_ACTION_EHANDLE( _varEnum, _varName, _varType ) \
case LESSON_VARIABLE_##_varEnum##:\
case LESSON_VARIABLE_##_varEnum:\
return ProcessElementAction( pLessonElement->iAction, pLessonElement->bNot, #_varName, _varName, &pLessonElement->szParam, eventParam_float, eventParam_BaseEntity, eventParam_string );
#define PROCESS_LESSON_ACTION_STRING( _varEnum, _varName, _varType ) \
case LESSON_VARIABLE_##_varEnum##:\
case LESSON_VARIABLE_##_varEnum:\
return ProcessElementAction( pLessonElement->iAction, pLessonElement->bNot, #_varName, &_varName, &pLessonElement->szParam, eventParam_string );
// Init the variable from the script (or a convar)
@ -2957,7 +2958,7 @@ bool CScriptedIconLesson::ProcessElementAction( int iAction, bool bNot, const ch
{
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
{
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HealthFraction() ", pchVarName, pchVarName );
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HealthFraction() ", pchVarName );
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "... " );
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( ">= [%s] " ) : ( "< [%s] " ), pchParamName->String() );
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%f\n", fParam );
@ -2969,7 +2970,7 @@ bool CScriptedIconLesson::ProcessElementAction( int iAction, bool bNot, const ch
if ( gameinstructor_verbose.GetInt() > 0 && ShouldShowSpew() )
{
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HealthFraction() ", pchVarName, pchVarName );
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, "\t[%s]->HealthFraction() ", pchVarName );
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%f ", pVar->HealthFraction() );
ConColorMsg( CBaseLesson::m_rgbaVerbosePlain, ( bNot ) ? ( ">= [%s] " ) : ( "< [%s] " ), pchParamName->String() );
ConColorMsg( CBaseLesson::m_rgbaVerboseName, "%f\n", fParam );

View File

@ -426,7 +426,7 @@ private:
LessonEvent_t * AddUpdateEvent( void );
private:
static CUtlDict< int, int > CScriptedIconLesson::LessonActionMap;
static CUtlDict< int, int > LessonActionMap;
EHANDLE m_hLocalPlayer;
float m_fOutput;

View File

@ -9,7 +9,7 @@
#include "GameEventListener.h"
#include "vgui_controls/phandle.h"
#include "vgui_controls/PHandle.h"
class CBaseLesson;

View File

@ -10,7 +10,7 @@
#include "iclientmode.h"
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui/IVGUI.h>
#include <vgui/IVGui.h>
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/Controls.h>
#include <vgui_controls/Label.h>

View File

@ -34,7 +34,7 @@
#define LOCATOR_ICON_FX_FADE_OUT 0x00000800 // Set when deactivated so it can smoothly vanish
#define LOCATOR_ICON_FX_FADE_IN 0x00001000 // Set when activated so it can smoothly appear
#include "tier1/UtlSymbol.h"
#include "tier1/utlsymbol.h"
// See comments in UtlSymbol on why this is useful
DECLARE_PRIVATE_SYMBOLTYPE( CGameInstructorSymbol );

View File

@ -7,16 +7,16 @@
#include "cbase.h"
#include "c_vguiscreen.h"
#include "vgui_controls/Label.h"
#include "vgui_BitmapPanel.h"
#include <vgui/IVGUI.h>
#include "vgui_bitmappanel.h"
#include <vgui/IVGui.h>
#include "c_slideshow_display.h"
#include "ienginevgui.h"
#include "fmtstr.h"
#include "vgui_controls/ImagePanel.h"
#include <vgui/ISurface.h>
#include "video/ivideoservices.h"
#include "engine/ienginesound.h"
#include "VGUIMatSurface/IMatSystemSurface.h"
#include "engine/IEngineSound.h"
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "c_movie_display.h"
// NOTE: This has to be the last file included!
@ -368,7 +368,7 @@ bool CMovieDisplayScreen::BeginPlayback( const char *pFilename )
Q_strncpy( szMaterialName, pFilename, sizeof(szMaterialName) );
}
const char *pszMaterialName = CFmtStrN<128>( "VideoMaterial_", m_hScreenEntity->GetEntityName() );
const char *pszMaterialName = CFmtStrN<128>( "VideoMaterial_%s", m_hScreenEntity->GetEntityName() );
m_VideoMaterial = g_pVideo->CreateVideoMaterial( pszMaterialName, pFilename, "GAME",
VideoPlaybackFlags::DEFAULT_MATERIAL_OPTIONS,
VideoSystem::DETERMINE_FROM_FILE_EXTENSION/*, m_bAllowAlternateMedia*/ );

View File

@ -303,7 +303,7 @@ public:
virtual bool IsHoldingEntity( CBaseEntity *pEnt );
virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldindThis );
virtual float GetHeldObjectMass( IPhysicsObject *pHeldObject );
virtual CBaseEntity *CHL2_Player::GetHeldObject( void );
virtual CBaseEntity *GetHeldObject( void );
virtual bool IsFollowingPhysics( void ) { return (m_afPhysicsFlags & PFLAG_ONBARNACLE) > 0; }
void InputForceDropPhysObjects( inputdata_t &data );

View File

@ -199,7 +199,7 @@ void CLogicExternalData::InputWriteKeyValue( inputdata_t &inputdata )
// Separate key from value
char *delimiter = Q_strstr(szValue, " ");
if (delimiter && (delimiter + 1) != '\0')
if (delimiter && delimiter[1] != '\0')
{
Q_strncpy(key, szValue, MIN((delimiter - szValue) + 1, sizeof(key)));
Q_strncpy(value, delimiter + 1, sizeof(value));

View File

@ -483,7 +483,8 @@ void RegisterSharedScriptConstants()
//ScriptRegisterConstant( g_pScriptVM, AISS_AUTO_PVS_AFTER_PVS, "" );
ScriptRegisterConstant( g_pScriptVM, AI_SLEEP_FLAGS_NONE, "No sleep flags. (NPC sleep flag used in Add/Remove/HasSleepFlags())" );
ScriptRegisterConstant( g_pScriptVM, AI_SLEEP_FLAG_AUTO_PVS, "Indicates a NPC will sleep upon exiting PVS. (NPC sleep flag used in Add/Remove/HasSleepFlags())" );
ScriptRegisterConstant( g_pScriptVM, AI_SLEEP_FLAG_AUTO_PVS_AFTER_PVS, "Indicates a NPC will sleep upon exiting PVS after entering PVS for the first time(?????) (NPC sleep flag used in Add/Remove/HasSleepFlags())" );
// note: the one "?" is escaped to prevent evaluation of a trigraph
ScriptRegisterConstant( g_pScriptVM, AI_SLEEP_FLAG_AUTO_PVS_AFTER_PVS, "Indicates a NPC will sleep upon exiting PVS after entering PVS for the first time(????\?) (NPC sleep flag used in Add/Remove/HasSleepFlags())" );
ScriptRegisterConstantNamed( g_pScriptVM, CAI_BaseNPC::SCRIPT_PLAYING, "SCRIPT_PLAYING", "Playing the action animation." );
ScriptRegisterConstantNamed( g_pScriptVM, CAI_BaseNPC::SCRIPT_WAIT, "SCRIPT_WAIT", "Waiting on everyone in the script to be ready. Plays the pre idle animation if there is one." );

View File

@ -7,9 +7,9 @@
#include "BaseVSShader.h"
#include "cpp_shader_constant_register_map.h"
#include "sdk_windowimposter_vs20.inc"
#include "sdk_windowimposter_ps20.inc"
#include "sdk_windowimposter_ps20b.inc"
#include "SDK_windowimposter_vs20.inc"
#include "SDK_windowimposter_ps20.inc"
#include "SDK_windowimposter_ps20b.inc"

View File

@ -21,7 +21,7 @@
#include "tier1/utlvector.h"
#include "tier1/utlstring.h"
#include "icvar.h"
#include "color.h"
#include "Color.h"
#ifdef _WIN32
#define FORCEINLINE_CVAR FORCEINLINE

View File

@ -18,6 +18,15 @@
namespace vgui
{
typedef ButtonCode_t MouseCode;
static inline int MouseButtonBit(MouseCode code)
{
if (code < MOUSE_FIRST || code > MOUSE_LAST) {
Assert(false);
return 0;
}
return 1 << (code - MOUSE_FIRST);
}
}
#endif // MOUSECODE_H

View File

@ -95,6 +95,9 @@
#ifndef IVSCRIPT_H
#define IVSCRIPT_H
#include <type_traits>
#include <utility>
#include "platform.h"
#include "datamap.h"
#include "appframework/IAppSystem.h"
@ -163,20 +166,6 @@ public:
//
//-----------------------------------------------------------------------------
#ifdef MAPBASE_VSCRIPT
template <typename T> T *HScriptToClass( HSCRIPT hObj )
{
return (hObj) ? (T*)g_pScriptVM->GetInstanceValue( hObj, GetScriptDesc( (T*)NULL ) ) : NULL;
}
#else
DECLARE_POINTER_HANDLE( HSCRIPT );
#define INVALID_HSCRIPT ((HSCRIPT)-1)
#endif
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
enum ExtendedFieldType
{
FIELD_TYPEUNKNOWN = FIELD_TYPECOUNT,
@ -645,8 +634,21 @@ struct ScriptEnumDesc_t
//
//-----------------------------------------------------------------------------
// forwards T (and T&) if T is neither enum or an unsigned integer
// the overload for int below captures enums and unsigned integers and "bends" them to int
template<typename T>
static inline typename std::enable_if<!std::is_enum<typename std::remove_reference<T>::type>::value && !std::is_unsigned<typename std::remove_reference<T>::type>::value, T&&>::type ToConstantVariant(T &&value)
{
return std::forward<T>(value);
}
static inline int ToConstantVariant(int value)
{
return value;
}
#define ScriptRegisterConstant( pVM, constant, description ) ScriptRegisterConstantNamed( pVM, constant, #constant, description )
#define ScriptRegisterConstantNamed( pVM, constant, scriptName, description ) do { static ScriptConstantBinding_t binding; binding.m_pszScriptName = scriptName; binding.m_pszDescription = description; binding.m_data = constant; pVM->RegisterConstant( &binding ); } while (0)
#define ScriptRegisterConstantNamed( pVM, constant, scriptName, description ) do { static ScriptConstantBinding_t binding; binding.m_pszScriptName = scriptName; binding.m_pszDescription = description; binding.m_data = ToConstantVariant(constant); pVM->RegisterConstant( &binding ); } while (0)
// Could probably use a better name.
// This is used for registering variants (particularly vectors) not tied to existing variables.
@ -1090,6 +1092,20 @@ public:
#endif
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
#ifdef MAPBASE_VSCRIPT
template <typename T> T *HScriptToClass( HSCRIPT hObj )
{
extern IScriptVM *g_pScriptVM;
return (hObj) ? (T*)g_pScriptVM->GetInstanceValue( hObj, GetScriptDesc( (T*)NULL ) ) : NULL;
}
#else
DECLARE_POINTER_HANDLE( HSCRIPT );
#define INVALID_HSCRIPT ((HSCRIPT)-1)
#endif
//-----------------------------------------------------------------------------
// Script scope helper class

View File

@ -137,29 +137,25 @@ inline void *ScriptConvertFuncPtrToVoid( FUNCPTR_TYPE pFunc )
#elif defined( GNUC )
else if ( ( sizeof( FUNCPTR_TYPE ) == sizeof( void * ) + sizeof( int ) ) )
{
AssertMsg( 0, "Note: This path has not been verified yet. See comments below in #else case." );
struct GnuMFP
{
union
{
void *funcadr; // If vtable_index_2 is even, then this is the function pointer.
int vtable_index_2; // If vtable_index_2 is odd, then this = vindex*2+1.
int vtable_index_2; // If vtable_index_2 is odd, then (vtable_index_2 - 1) * 2 is the index into the vtable.
};
int delta;
int delta; // Offset from this-ptr to vtable
};
GnuMFP *p = (GnuMFP*)&pFunc;
if ( p->vtable_index_2 & 1 )
{
char **delta = (char**)p->delta;
char *pCur = *delta + (p->vtable_index_2+1)/2;
return (void*)( pCur + 4 );
}
else
if ( p->delta == 0 )
{
// No need to check whether this is a direct function pointer or not,
// this gets converted back to a "proper" member-function pointer in
// ScriptConvertFuncPtrFromVoid() to get invoked
return p->funcadr;
}
AssertMsg( 0, "Function pointer must be from primary vtable" );
}
#else
#error "Need to implement code to crack non-offset member function pointer case"
@ -257,8 +253,30 @@ inline FUNCPTR_TYPE ScriptConvertFuncPtrFromVoid( void *p )
convert.mfp.m_delta = 0;
return convert.pFunc;
}
#elif defined( POSIX )
AssertMsg( 0, "Note: This path has not been implemented yet." );
#elif defined( GNUC )
if ( ( sizeof( FUNCPTR_TYPE ) == sizeof( void * ) + sizeof( int ) ) )
{
struct GnuMFP
{
union
{
void *funcadr; // If vtable_index_2 is even, then this is the function pointer.
int vtable_index_2; // If vtable_index_2 is odd, then (vtable_index_2 - 1) * 2 is the index into the vtable.
};
int delta; // Offset from this-ptr to vtable
};
union FuncPtrConvertGnu
{
GnuMFP mfp;
FUNCPTR_TYPE pFunc;
};
FuncPtrConvertGnu convert;
convert.mfp.funcadr = p;
convert.mfp.delta = 0;
return convert.pFunc;
}
#else
#error "Need to implement code to crack non-offset member function pointer case"
#endif

View File

@ -162,6 +162,6 @@ void CGMsg( int level, int nGroup, const tchar* pMsg, ... )
}
else
{
ConColorMsg(level, pGroup->GetColor(), string);
ConColorMsg(level, pGroup->GetColor(), "%s", string);
}
}

View File

@ -695,12 +695,12 @@ void Button::SetMouseClickEnabled(MouseCode code,bool state)
if(state)
{
//set bit to 1
_mouseClickMask|=1<<((int)(code+1));
_mouseClickMask|=MouseButtonBit(code);
}
else
{
//set bit to 0
_mouseClickMask&=~(1<<((int)(code+1)));
_mouseClickMask&=~MouseButtonBit(code);
}
}
@ -709,7 +709,7 @@ void Button::SetMouseClickEnabled(MouseCode code,bool state)
//-----------------------------------------------------------------------------
bool Button::IsMouseClickEnabled(MouseCode code)
{
if(_mouseClickMask&(1<<((int)(code+1))))
if(_mouseClickMask&MouseButtonBit(code))
{
return true;
}

View File

@ -241,7 +241,7 @@ public:
HSQOBJECT regexpClass_;
};
SQUserPointer TYPETAG_VECTOR = "VectorTypeTag";
static char TYPETAG_VECTOR[] = "VectorTypeTag";
namespace SQVector
{
@ -1089,7 +1089,7 @@ void PushVariant(HSQUIRRELVM vm, const ScriptVariant_t& value)
sq_createinstance(vm, -1);
SQUserPointer p;
sq_getinstanceup(vm, -1, &p, 0);
new(p) Vector(value);
new(p) Vector(static_cast<const Vector&>(value));
sq_remove(vm, -2);
break;
}