-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gcc/Linux update #95
gcc/Linux update #95
Changes from all commits
49836ab
a5fb07d
718186f
e009126
761f065
28e87ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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## ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A note to the changes here: The |
||
#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 ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 @@ class IScriptManager : public IAppSystem | |
// | ||
//----------------------------------------------------------------------------- | ||
|
||
#ifdef MAPBASE_VSCRIPT | ||
template <typename T> T *HScriptToClass( HSCRIPT hObj ) | ||
{ | ||
return (hObj) ? (T*)g_pScriptVM->GetInstanceValue( hObj, GetScriptDesc( (T*)NULL ) ) : NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
#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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gcc complained that it can't discern how to create a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll still need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, and fix the return-type from |
||
// 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 @@ class IScriptVM | |
#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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is that
DispatchUserMessage()
expects a (non-const
)bf_read&
. rvalues (unnamed temporaries) are normally not allowed to be used as non-const
references (const
would be fine). MSVC seems to allow it anyways. By using an explicit variable, it is no longer an rvalue and thus can be passed as non-const
reference.While looking into this I read the implementation of
DispatchUserMessage()
. For every hook it copies thebf_read
, which seems unnecessary to me, considering there's aReset()
function on it. So if you wanted to you can probably optimize it to avoid making the copies and instead reset it before invoking each hook.