From 9fa4ed8bac10047050f29d3415099e9ea6cc36bf Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Fri, 3 Mar 2017 11:45:39 -0700 Subject: [PATCH 01/33] Add IsNullVector and IsNullString natives Let plugins check if a string or vector passed to a function is their NULL_VECTOR or NULL_STRING. --- core/logic/smn_core.cpp | 23 +++++++++++++++++++++++ plugins/include/core.inc | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 8ba74ad7..d12e0fca 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -759,6 +759,27 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params) return 0; } +static cell_t IsNullVector(IPluginContext *pContext, const cell_t *params) +{ + cell_t *pNullVec = pContext->GetNullRef(SP_NULL_VECTOR); + if (!pNullVec) + return 0; + + cell_t *addr; + pContext->LocalToPhysAddr(params[1], &addr); + + return addr == pNullVec; +} + +static cell_t IsNullString(IPluginContext *pContext, const cell_t *params) +{ + char *str; + if (pContext->LocalToStringNULL(params[1], &str) != SP_ERROR_NONE) + return 0; + + return str == nullptr; +} + REGISTER_NATIVES(coreNatives) { {"ThrowError", ThrowError}, @@ -787,5 +808,7 @@ REGISTER_NATIVES(coreNatives) {"RequireFeature", RequireFeature}, {"LoadFromAddress", LoadFromAddress}, {"StoreToAddress", StoreToAddress}, + {"IsNullVector", IsNullVector}, + {"IsNullString", IsNullString}, {NULL, NULL}, }; diff --git a/plugins/include/core.inc b/plugins/include/core.inc index 315f79de..47f05e1c 100644 --- a/plugins/include/core.inc +++ b/plugins/include/core.inc @@ -143,6 +143,22 @@ struct SharedPlugin public float NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */ public const char NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */ +/** + * Check if the given vector is the NULL_VECTOR. + * + * @param vec The vector to test. + * @return True if NULL_VECTOR, false otherwise. + */ +native bool IsNullVector(const float vec[3]); + +/** + * Check if the given string is the NULL_STRING. + * + * @param str The string to test. + * @return True if NULL_STRING, false otherwise. + */ +native bool IsNullString(const char[] str); + /** * Horrible compatibility shim. */ From 3de269946c8d73724c3fc11936a1069fcc64e78e Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Fri, 3 Mar 2017 11:47:03 -0700 Subject: [PATCH 02/33] Add IsNativeParamNullVector and IsNativeParamNullString natives Lets plugins check if some other plugin passed NULL_VECTOR or NULL_STRING to a native in the native callback. --- core/logic/smn_fakenatives.cpp | 54 ++++++++++++++++++++++++++++++++++ plugins/include/functions.inc | 16 ++++++++++ 2 files changed, 70 insertions(+) diff --git a/core/logic/smn_fakenatives.cpp b/core/logic/smn_fakenatives.cpp index c4c7cf8a..b446d623 100644 --- a/core/logic/smn_fakenatives.cpp +++ b/core/logic/smn_fakenatives.cpp @@ -424,6 +424,58 @@ static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params) return SP_ERROR_NONE; } +static cell_t IsNativeParamNullVector(IPluginContext *pContext, const cell_t *params) +{ + if (!s_curnative || (s_curnative->ctx != pContext)) + { + return pContext->ThrowNativeError("Not called from inside a native function"); + } + + cell_t param = params[1]; + if (param < 1 || param > s_curparams[0]) + { + return pContext->ThrowNativeErrorEx(SP_ERROR_PARAM, "Invalid parameter number: %d", param); + } + + int err; + cell_t *addr; + if ((err = s_curcaller->LocalToPhysAddr(s_curparams[param], &addr)) != SP_ERROR_NONE) + { + return err; + } + + cell_t *pNullVec = s_curcaller->GetNullRef(SP_NULL_VECTOR); + if (!pNullVec) + { + return 0; + } + + return addr == pNullVec ? 1 : 0; +} + +static cell_t IsNativeParamNullString(IPluginContext *pContext, const cell_t *params) +{ + if (!s_curnative || (s_curnative->ctx != pContext)) + { + return pContext->ThrowNativeError("Not called from inside a native function"); + } + + cell_t param = params[1]; + if (param < 1 || param > s_curparams[0]) + { + return pContext->ThrowNativeErrorEx(SP_ERROR_PARAM, "Invalid parameter number: %d", param); + } + + int err; + char *str; + if ((err = s_curcaller->LocalToStringNULL(s_curparams[param], &str)) != SP_ERROR_NONE) + { + return err; + } + + return str == nullptr ? 1 : 0; +} + //tee hee REGISTER_NATIVES(nativeNatives) { @@ -439,5 +491,7 @@ REGISTER_NATIVES(nativeNatives) {"SetNativeArray", SetNativeArray}, {"SetNativeCellRef", SetNativeCellRef}, {"SetNativeString", SetNativeString}, + {"IsNativeParamNullVector", IsNativeParamNullVector}, + {"IsNativeParamNullString", IsNativeParamNullString}, {NULL, NULL}, }; diff --git a/plugins/include/functions.inc b/plugins/include/functions.inc index 1c479618..c4afff93 100644 --- a/plugins/include/functions.inc +++ b/plugins/include/functions.inc @@ -465,6 +465,22 @@ native int GetNativeArray(int param, any[] local, int size); */ native int SetNativeArray(int param, const any[] local, int size); +/** + * Check if the native parameter is the NULL_VECTOR. + * + * @param param Parameter number, starting from 1. + * @return True if NULL_VECTOR, false otherwise. + */ +native bool IsNativeParamNullVector(int param); + +/** + * Check if the native parameter is the NULL_STRING. + * + * @param param Parameter number, starting from 1. + * @return True if NULL_STRING, false otherwise. + */ +native bool IsNativeParamNullString(int param); + /** * Formats a string using parameters from a native. * From 41a9889cddc745f4d6cab72693dbf37be16f504c Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Thu, 4 May 2017 22:56:31 -0600 Subject: [PATCH 03/33] Add Call_PushNullVector and Call_PushNullString Be able to push NULL_[VECTOR|STRING] to a forward or direct function call. The callee can check the parameter using the IsNullVector/IsNullString natives. --- core/logic/ForwardSys.cpp | 92 ++++++++++++++++++++++++++++++++++- core/logic/ForwardSys.h | 2 + core/logic/smn_functions.cpp | 84 ++++++++++++++++++++++++++++++++ plugins/include/functions.inc | 20 ++++++++ public/IForwardSys.h | 19 +++++++- 5 files changed, 214 insertions(+), 3 deletions(-) diff --git a/core/logic/ForwardSys.cpp b/core/logic/ForwardSys.cpp index f7932621..88b00998 100644 --- a/core/logic/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -273,7 +273,26 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter) */ if (type == Param_String) { - err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags); + // If NULL_STRING was pushed, push the reference to the pubvar of the callee instead. + if (param->isnull) + { + IPluginRuntime *runtime = func->GetParentRuntime(); + uint32_t null_string_idx; + err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx); + + if (!err) + { + cell_t null_string; + err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr); + + if (!err) + err = func->PushCell(null_string); + } + } + else + { + err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags); + } } else if (type == Param_Float || type == Param_Cell) { @@ -281,7 +300,26 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter) } else { - err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags); + // If NULL_VECTOR was pushed, push the reference to the pubvar of the callee instead. + if (param->isnull && type == Param_Array) + { + IPluginRuntime *runtime = func->GetParentRuntime(); + uint32_t null_vector_idx; + err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx); + + if (!err) + { + cell_t null_vector; + err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr); + + if (!err) + err = func->PushCell(null_vector); + } + } + else + { + err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags); + } assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef); } } @@ -400,6 +438,7 @@ int CForward::PushCell(cell_t cell) m_params[m_curparam].pushedas = Param_Cell; } + m_params[m_curparam].isnull = false; m_params[m_curparam++].val = cell; return SP_ERROR_NONE; @@ -423,6 +462,7 @@ int CForward::PushFloat(float number) m_params[m_curparam].pushedas = Param_Float; } + m_params[m_curparam].isnull = false; m_params[m_curparam++].val = *(cell_t *)&number; return SP_ERROR_NONE; @@ -481,6 +521,7 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags) m_params[m_curparam].byref.cells = cells; m_params[m_curparam].byref.flags = flags; m_params[m_curparam].byref.orig_addr = inarray; + m_params[m_curparam].isnull = false; } int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags) @@ -520,6 +561,7 @@ void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags m_params[m_curparam].byref.flags = cp_flags; m_params[m_curparam].byref.orig_addr = inarray; m_params[m_curparam].byref.sz_flags = sz_flags; + m_params[m_curparam].isnull = false; } int CForward::PushString(const char *string) @@ -570,6 +612,52 @@ int CForward::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_fla return SP_ERROR_NONE; } +int CForward::PushNullString() +{ + if (m_curparam < m_numparams) + { + if (m_types[m_curparam] == Param_Any) + { + m_params[m_curparam].pushedas = Param_String; + } else if (m_types[m_curparam] != Param_String) { + return SetError(SP_ERROR_PARAM); + } + } else { + if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS) + { + return SetError(SP_ERROR_PARAMS_MAX); + } + m_params[m_curparam].pushedas = Param_String; + } + + m_params[m_curparam++].isnull = true; + + return SP_ERROR_NONE; +} + +int CForward::PushNullVector() +{ + if (m_curparam < m_numparams) + { + if (m_types[m_curparam] == Param_Any) + { + m_params[m_curparam].pushedas = Param_Array; + } else if (m_types[m_curparam] != Param_Array) { + return SetError(SP_ERROR_PARAM); + } + } else { + if (!m_varargs || m_numparams > SP_MAX_EXEC_PARAMS) + { + return SetError(SP_ERROR_PARAMS_MAX); + } + m_params[m_curparam].pushedas = Param_Array; + } + + m_params[m_curparam++].isnull = true; + + return SP_ERROR_NONE; +} + void CForward::Cancel() { if (!m_curparam) diff --git a/core/logic/ForwardSys.h b/core/logic/ForwardSys.h index 420335c5..6808fae4 100644 --- a/core/logic/ForwardSys.h +++ b/core/logic/ForwardSys.h @@ -55,6 +55,8 @@ public: //IForward virtual unsigned int GetFunctionCount(); virtual ExecType GetExecType(); virtual int Execute(cell_t *result, IForwardFilter *filter); + virtual int PushNullString(); + virtual int PushNullVector(); public: //IChangeableForward virtual bool RemoveFunction(IPluginFunction *func); virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin); diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index fc4f763b..ef66c493 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -552,6 +552,88 @@ static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params return 1; } +static cell_t sm_CallPushNullVector(IPluginContext *pContext, const cell_t *params) +{ + int err = SP_ERROR_NOT_FOUND; + + if (!s_CallStarted) + { + return pContext->ThrowNativeError("Cannot push parameters when there is no call in progress"); + } + + if (s_pFunction) + { + // Find the NULL_VECTOR pubvar in the target plugin and push the local address. + IPluginRuntime *runtime = s_pFunction->GetParentRuntime(); + uint32_t null_vector_idx; + err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx); + if (err) + { + return pContext->ThrowNativeErrorEx(err, "Target plugin has no NULL_VECTOR."); + } + + cell_t null_vector; + err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr); + + if (!err) + err = s_pCallable->PushCell(null_vector); + } + else if (s_pForward) + { + err = s_pForward->PushNullVector(); + } + + if (err) + { + s_pCallable->Cancel(); + ResetCall(); + return pContext->ThrowNativeErrorEx(err, NULL); + } + + return 1; +} + +static cell_t sm_CallPushNullString(IPluginContext *pContext, const cell_t *params) +{ + int err = SP_ERROR_NOT_FOUND; + + if (!s_CallStarted) + { + return pContext->ThrowNativeError("Cannot push parameters when there is no call in progress"); + } + + if (s_pFunction) + { + // Find the NULL_STRING pubvar in the target plugin and push the local address. + IPluginRuntime *runtime = s_pFunction->GetParentRuntime(); + uint32_t null_string_idx; + err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx); + if (err) + { + return pContext->ThrowNativeErrorEx(err, "Target plugin has no NULL_STRING."); + } + + cell_t null_string; + err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr); + + if (!err) + err = s_pCallable->PushCell(null_string); + } + else if (s_pForward) + { + err = s_pForward->PushNullString(); + } + + if (err) + { + s_pCallable->Cancel(); + ResetCall(); + return pContext->ThrowNativeErrorEx(err, NULL); + } + + return 1; +} + static cell_t sm_CallFinish(IPluginContext *pContext, const cell_t *params) { int err = SP_ERROR_NOT_RUNNABLE; @@ -668,6 +750,8 @@ REGISTER_NATIVES(functionNatives) {"Call_PushArrayEx", sm_CallPushArrayEx}, {"Call_PushString", sm_CallPushString}, {"Call_PushStringEx", sm_CallPushStringEx}, + {"Call_PushNullVector", sm_CallPushNullVector}, + {"Call_PushNullString", sm_CallPushNullString}, {"Call_Finish", sm_CallFinish}, {"Call_Cancel", sm_CallCancel}, {"RequestFrame", sm_AddFrameAction}, diff --git a/plugins/include/functions.inc b/plugins/include/functions.inc index c4afff93..b9bd2f9c 100644 --- a/plugins/include/functions.inc +++ b/plugins/include/functions.inc @@ -290,6 +290,16 @@ native void Call_PushArray(const any[] value, int size); */ native void Call_PushArrayEx(any[] value, int size, int cpflags); +/** + * Pushes the NULL_VECTOR onto the current call. + * @see IsNullVector + * + * @note Cannot be used before a call has been started. + * + * @error Called before a call has been started. + */ +native void Call_PushNullVector(); + /** * Pushes a string onto the current call. * @@ -317,6 +327,16 @@ native void Call_PushString(const char[] value); */ native void Call_PushStringEx(char[] value, int length, int szflags, int cpflags); +/** + * Pushes the NULL_STRING onto the current call. + * @see IsNullString + * + * @note Cannot be used before a call has been started. + * + * @error Called before a call has been started. + */ +native void Call_PushNullString(); + /** * Completes a call to a function or forward's call list. * diff --git a/public/IForwardSys.h b/public/IForwardSys.h index 3ea98739..9040d549 100644 --- a/public/IForwardSys.h +++ b/public/IForwardSys.h @@ -50,7 +50,7 @@ using namespace SourcePawn; #define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager" -#define SMINTERFACE_FORWARDMANAGER_VERSION 3 +#define SMINTERFACE_FORWARDMANAGER_VERSION 4 /* * There is some very important documentation at the bottom of this file. @@ -118,6 +118,7 @@ namespace SourceMod cell_t val; ByrefInfo byref; ParamType pushedas; + bool isnull; }; class IForwardFilter @@ -183,6 +184,22 @@ namespace SourceMod * @return Error code, if any. */ virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0; + + /** + * @brief Pushes the NULL_STRING onto the current call. This will always push the + * correct reference to each function in the forward. + * + * @return Error code, if any. + */ + virtual int PushNullString() =0; + + /** + * @brief Pushes the NULL_VECTOR onto the current call. This will always push the + * correct reference to each function in the forward. + * + * @return Error code, if any. + */ + virtual int PushNullVector() =0; }; /** From e609a33e6d7836576cb9293bd1c4fb600ad91261 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Sat, 22 Jul 2017 23:08:31 +0200 Subject: [PATCH 04/33] Cleanup CForward::Execute using a helper function Flatten out the nesting a bit. --- core/logic/ForwardSys.cpp | 108 +++++++++++++++++++------------------- core/logic/ForwardSys.h | 1 + 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/core/logic/ForwardSys.cpp b/core/logic/ForwardSys.cpp index 88b00998..f599cb56 100644 --- a/core/logic/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -269,59 +269,9 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter) if ((i >= m_numparams) || (type & SP_PARAMFLAG_BYREF)) { /* If we're byref or we're vararg, we always push everything by ref. - * Even if they're byval, we must push them byref. - */ - if (type == Param_String) - { - // If NULL_STRING was pushed, push the reference to the pubvar of the callee instead. - if (param->isnull) - { - IPluginRuntime *runtime = func->GetParentRuntime(); - uint32_t null_string_idx; - err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx); - - if (!err) - { - cell_t null_string; - err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr); - - if (!err) - err = func->PushCell(null_string); - } - } - else - { - err = func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags); - } - } - else if (type == Param_Float || type == Param_Cell) - { - err = func->PushCellByRef(¶m->val); - } - else - { - // If NULL_VECTOR was pushed, push the reference to the pubvar of the callee instead. - if (param->isnull && type == Param_Array) - { - IPluginRuntime *runtime = func->GetParentRuntime(); - uint32_t null_vector_idx; - err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx); - - if (!err) - { - cell_t null_vector; - err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr); - - if (!err) - err = func->PushCell(null_vector); - } - } - else - { - err = func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags); - } - assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef); - } + * Even if they're byval, we must push them byref. + */ + err = _ExecutePushRef(func, type, param); } else { @@ -420,6 +370,58 @@ done: return SP_ERROR_NONE; } +int CForward::_ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param) +{ + /* If we're byref or we're vararg, we always push everything by ref. + * Even if they're byval, we must push them byref. + */ + int err; + IPluginRuntime *runtime = func->GetParentRuntime(); + switch (type) + { + case Param_String: + // Normal string was pushed. + if (!param->isnull) + return func->PushStringEx((char *)param->byref.orig_addr, param->byref.cells, param->byref.sz_flags, param->byref.flags); + + // If NULL_STRING was pushed, push the reference to the pubvar of the callee instead. + uint32_t null_string_idx; + err = runtime->FindPubvarByName("NULL_STRING", &null_string_idx); + if (err) + return err; + + cell_t null_string; + err = runtime->GetPubvarAddrs(null_string_idx, &null_string, nullptr); + if (err) + return err; + + return func->PushCell(null_string); + + case Param_Float: + case Param_Cell: + return func->PushCellByRef(¶m->val); + + default: + assert(type == Param_Array || type == Param_FloatByRef || type == Param_CellByRef); + // No NULL_VECTOR was pushed. + if (type != Param_Array || !param->isnull) + return func->PushArray(param->byref.orig_addr, param->byref.cells, param->byref.flags); + + // If NULL_VECTOR was pushed, push the reference to the pubvar of the callee instead. + uint32_t null_vector_idx; + err = runtime->FindPubvarByName("NULL_VECTOR", &null_vector_idx); + if (err) + return err; + + cell_t null_vector; + err = runtime->GetPubvarAddrs(null_vector_idx, &null_vector, nullptr); + if (err) + return err; + + return func->PushCell(null_vector); + } +} + int CForward::PushCell(cell_t cell) { if (m_curparam < m_numparams) diff --git a/core/logic/ForwardSys.h b/core/logic/ForwardSys.h index 6808fae4..b5037b2d 100644 --- a/core/logic/ForwardSys.h +++ b/core/logic/ForwardSys.h @@ -74,6 +74,7 @@ private: CForward(ExecType et, const char *name, const ParamType *types, unsigned num_params); + int _ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param); void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags); void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags); inline int SetError(int err) From 7eef3948b13c61f4dda8866720c6d3f7d11fe1c4 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Fri, 4 Aug 2017 12:52:19 +0200 Subject: [PATCH 05/33] Don't break backwards compatibility with unmanaged forwards Instead of adding new functions to `IForward`, we just allow NULL to be passed to `PushArray` and `PushString`. --- core/logic/ForwardSys.cpp | 17 +++++++++++++++-- core/logic/ForwardSys.h | 4 ++-- core/logic/smn_functions.cpp | 4 ++-- public/IForwardSys.h | 23 ++++++++--------------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/core/logic/ForwardSys.cpp b/core/logic/ForwardSys.cpp index f599cb56..bc31f7f7 100644 --- a/core/logic/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -528,10 +528,17 @@ void CForward::_Int_PushArray(cell_t *inarray, unsigned int cells, int flags) int CForward::PushArray(cell_t *inarray, unsigned int cells, int flags) { - /* We don't allow this here */ + /* Push a reference to the NULL_VECTOR pubvar if NULL was passed. */ if (!inarray) { - return SetError(SP_ERROR_PARAM); + /* Make sure this was intentional. */ + if (cells == 3) + { + return PushNullVector(); + } else { + /* We don't allow this here */ + return SetError(SP_ERROR_PARAM); + } } if (m_curparam < m_numparams) @@ -568,6 +575,12 @@ void CForward::_Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags int CForward::PushString(const char *string) { + /* Push a reference to the NULL_STRING pubvar if NULL was passed. */ + if (!string) + { + return PushNullString(); + } + if (m_curparam < m_numparams) { if (m_types[m_curparam] == Param_Any) diff --git a/core/logic/ForwardSys.h b/core/logic/ForwardSys.h index b5037b2d..cd1b3b82 100644 --- a/core/logic/ForwardSys.h +++ b/core/logic/ForwardSys.h @@ -55,8 +55,6 @@ public: //IForward virtual unsigned int GetFunctionCount(); virtual ExecType GetExecType(); virtual int Execute(cell_t *result, IForwardFilter *filter); - virtual int PushNullString(); - virtual int PushNullVector(); public: //IChangeableForward virtual bool RemoveFunction(IPluginFunction *func); virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin); @@ -74,6 +72,8 @@ private: CForward(ExecType et, const char *name, const ParamType *types, unsigned num_params); + int PushNullString(); + int PushNullVector(); int _ExecutePushRef(IPluginFunction *func, ParamType type, FwdParamInfo *param); void _Int_PushArray(cell_t *inarray, unsigned int cells, int flags); void _Int_PushString(cell_t *inarray, unsigned int cells, int sz_flags, int cp_flags); diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index ef66c493..792da977 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -580,7 +580,7 @@ static cell_t sm_CallPushNullVector(IPluginContext *pContext, const cell_t *para } else if (s_pForward) { - err = s_pForward->PushNullVector(); + err = s_pForward->PushArray(NULL, 3); } if (err) @@ -621,7 +621,7 @@ static cell_t sm_CallPushNullString(IPluginContext *pContext, const cell_t *para } else if (s_pForward) { - err = s_pForward->PushNullString(); + err = s_pForward->PushString(NULL); } if (err) diff --git a/public/IForwardSys.h b/public/IForwardSys.h index 9040d549..cbd59abb 100644 --- a/public/IForwardSys.h +++ b/public/IForwardSys.h @@ -178,7 +178,8 @@ namespace SourceMod * @brief Pushes an array of cells onto the current call. Different rules than ICallable. * NOTE: On Execute, the pointer passed will be modified according to the copyback rule. * - * @param inarray Array to copy. Cannot be NULL, unlike ICallable's version. + * @param inarray Array to copy. If NULL and cells is 3 pushes a reference to the NULL_VECTOR pubvar to each callee. + * Pushing other number of cells is not allowed, unlike ICallable's version. * @param cells Number of cells to allocate and optionally read from the input array. * @param flags Whether or not changes should be copied back to the input array. * @return Error code, if any. @@ -186,20 +187,12 @@ namespace SourceMod virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0; /** - * @brief Pushes the NULL_STRING onto the current call. This will always push the - * correct reference to each function in the forward. - * - * @return Error code, if any. - */ - virtual int PushNullString() =0; - - /** - * @brief Pushes the NULL_VECTOR onto the current call. This will always push the - * correct reference to each function in the forward. - * - * @return Error code, if any. - */ - virtual int PushNullVector() =0; + * @brief Pushes a string onto the current call. + * + * @param string String to push. If NULL pushes a reference to the NULL_STRING pubvar to each callee. + * @return Error code, if any. + */ + virtual int PushString(const char *string) = 0; }; /** From 3d461ecea189002d7f370129e03a93d7d6371e12 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Date: Fri, 8 Sep 2017 08:37:28 -0400 Subject: [PATCH 06/33] Add support for CreateIitemEntityByName for CS:GO --- extensions/sdktools/vnatives.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 3b9efe01..92694e22 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -929,7 +929,16 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) char *classname; pContext->LocalToString(params[1], &classname); +#if SOURCE_ENGINE != SE_CSGO CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname); +#else + CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateItemEntityByName(classname); + + if(!pEntity) + { + pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname); + } +#endif return gamehelpers->EntityToBCompatRef(pEntity); } #else From 79ba2835f675eb29d9ff0841605c38667d1112f6 Mon Sep 17 00:00:00 2001 From: thewavelength Date: Sun, 10 Sep 2017 02:17:35 +0200 Subject: [PATCH 07/33] Fix build when product.version is mangled (#679) Strip line breaks when reading product.version, as Git can mangle the line breaks if autocrlf is configured, resulting in `SM_BUILD_TAG` getting defined with a linebreak. --- tools/buildbot/generate_headers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/buildbot/generate_headers.py b/tools/buildbot/generate_headers.py index d904ba0a..c2d34944 100644 --- a/tools/buildbot/generate_headers.py +++ b/tools/buildbot/generate_headers.py @@ -50,7 +50,7 @@ def output_version_headers(): count, shorthash, longhash = get_git_version() with open(os.path.join(SourceFolder, 'product.version')) as fp: - contents = fp.read() + contents = fp.read().strip() m = re.match('(\d+)\.(\d+)\.(\d+)-?(.*)', contents) if m == None: raise Exception('Could not detremine product version') From 4e996a116d32d6043518df35bc820de17e15de9a Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Tue, 19 Sep 2017 23:27:35 +0100 Subject: [PATCH 08/33] Allow seeking to end of datapack (#687) --- core/logic/CDataPack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/CDataPack.cpp b/core/logic/CDataPack.cpp index 67ec2146..4c838410 100644 --- a/core/logic/CDataPack.cpp +++ b/core/logic/CDataPack.cpp @@ -185,7 +185,7 @@ size_t CDataPack::GetPosition() const bool CDataPack::SetPosition(size_t pos) const { - if (pos > m_size-1) + if (pos > m_size) { return false; } From 54565c92f765d441c1eb983962403fb89d9b7e03 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 23 Sep 2017 13:45:41 -0400 Subject: [PATCH 09/33] Add target arg to LogAction in basechat sm_psay. (#690) --- plugins/basechat.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/basechat.sp b/plugins/basechat.sp index c51c3930..69cf3b68 100644 --- a/plugins/basechat.sp +++ b/plugins/basechat.sp @@ -392,7 +392,7 @@ void SendPrivateChat(int client, int target, const char[] message) } PrintToChat(target, "\x04(Private to %N) %N: \x01%s", target, client, message); - LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); + LogAction(client, target, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); } void SendPanelToAll(int from, char[] message) From 7e898ee530e3b8031a5c231e3e2cacc041b03f0f Mon Sep 17 00:00:00 2001 From: peace-maker Date: Sun, 24 Sep 2017 02:24:39 +0200 Subject: [PATCH 10/33] Fix core config values not being cached (#673) Valid core config options aren't cached to be retrieved using `GetCoreConfigValue` after they've been loaded from core.cfg or set through the `sm config` root console menu. E.g. `sm config ServerLang` would return `[SM] No such config option "ServerLang" exists.` all the time. Stop notifying other listeners if the config key was consumed, but don't skip adding it to the cache. Also fix `FollowCSGOServerGuidelines` always showing as unhandled command when being changed through `sm config FollowCSGOServerGuidelines yes`. --- core/CoreConfig.cpp | 6 +++--- core/HalfLife2.cpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 2c5326ce..766edbf0 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -277,7 +277,7 @@ SMCResult CoreConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key, ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ConfigSource source, char *error, size_t maxlength) { - ConfigResult result; + ConfigResult result = ConfigResult_Ignore; /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; @@ -285,7 +285,7 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, { if ((result = pBase->OnSourceModConfigChanged(option, value, source, error, maxlength)) != ConfigResult_Ignore) { - return result; + break; } pBase = pBase->m_pGlobalClassNext; } @@ -293,7 +293,7 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ke::AString vstr(value); m_KeyValues.replace(option, ke::Move(vstr)); - return ConfigResult_Ignore; + return result; } const char *CoreConfig::GetCoreConfigValue(const char *key) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index c4060f48..0a071c4e 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -171,13 +171,16 @@ ConfigResult CHalfLife2::OnSourceModConfigChanged(const char *key, const char *v if (strcasecmp(value, "no") == 0) { m_bFollowCSGOServerGuidelines = false; + return ConfigResult_Accept; } else if (strcasecmp(value, "yes") == 0) { m_bFollowCSGOServerGuidelines = true; + return ConfigResult_Accept; } else { + ke::SafeSprintf(error, maxlength, "Invalid value: must be \"yes\" or \"no\""); return ConfigResult_Reject; } #endif From 5d234bb9d68ae56cf7537d4e2bfdd27fc2b55e94 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Sat, 23 Sep 2017 23:27:32 -0700 Subject: [PATCH 11/33] Fix OnPlayerRunCmd crashing with invalid CUserCmd ptr. (#693) --- extensions/sdktools/hooks.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extensions/sdktools/hooks.cpp b/extensions/sdktools/hooks.cpp index d4900e70..3ef57985 100644 --- a/extensions/sdktools/hooks.cpp +++ b/extensions/sdktools/hooks.cpp @@ -191,6 +191,11 @@ void CHookManager::PlayerRunCmdHook(int client, bool post) void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) { + if (!ucmd) + { + RETURN_META(MRES_IGNORED); + } + if (m_usercmdsFwd->GetFunctionCount() == 0) { RETURN_META(MRES_IGNORED); @@ -254,6 +259,11 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) void CHookManager::PlayerRunCmdPost(CUserCmd *ucmd, IMoveHelper *moveHelper) { + if (!ucmd) + { + RETURN_META(MRES_IGNORED); + } + if (m_usercmdsPostFwd->GetFunctionCount() == 0) { RETURN_META(MRES_IGNORED); From aac279322b62d0823a5192f62257d46fac78eab4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 26 Sep 2017 20:22:02 -0400 Subject: [PATCH 12/33] Making blind's LogAction message consistent... (#697) with the other plugin's messages. --- plugins/funcommands/blind.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/funcommands/blind.sp b/plugins/funcommands/blind.sp index e9c22ee6..29bcb480 100644 --- a/plugins/funcommands/blind.sp +++ b/plugins/funcommands/blind.sp @@ -76,7 +76,7 @@ void PerformBlind(int client, int target, int amount) EndMessage(); - LogAction(client, target, "\"%L\" set blind on \"%L\", amount %d.", client, target, amount); + LogAction(client, target, "\"%L\" set blind on \"%L\" (amount \"%d\")", client, target, amount); } public void AdminMenu_Blind(TopMenu topmenu, From f289799c57a63a0bcdc5ce3a8c6eda29c931f16b Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 26 Sep 2017 20:22:30 -0400 Subject: [PATCH 13/33] Making gravity's LogAction message consistent... (#695) with the other plugin's messages. --- plugins/funcommands/gravity.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/funcommands/gravity.sp b/plugins/funcommands/gravity.sp index 1b964bd4..4f2cc833 100644 --- a/plugins/funcommands/gravity.sp +++ b/plugins/funcommands/gravity.sp @@ -36,7 +36,7 @@ int g_GravityTarget[MAXPLAYERS+1]; void PerformGravity(int client, int target, float amount) { SetEntityGravity(target, amount); - LogAction(client, target, "\"%L\" set gravity on \"%L\" to %f.", client, target, amount); + LogAction(client, target, "\"%L\" set gravity on \"%L\" (amount \"%f\")", client, target, amount); } public void AdminMenu_Gravity(TopMenu topmenu, From f67e4ce610714ced1b3da0675e7a7d855c345e74 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 26 Sep 2017 20:22:38 -0400 Subject: [PATCH 14/33] Making rename's LogAction message consistent... (#696) with the other plugin's messages. --- plugins/playercommands/rename.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/playercommands/rename.sp b/plugins/playercommands/rename.sp index 17ceeba4..6a0853e5 100644 --- a/plugins/playercommands/rename.sp +++ b/plugins/playercommands/rename.sp @@ -35,7 +35,7 @@ char g_NewName[MAXPLAYERS+1][MAX_NAME_LENGTH]; void PerformRename(int client, int target) { - LogAction(client, target, "\"%L\" renamed \"%L\" to \"%s\")", client, target, g_NewName[target]); + LogAction(client, target, "\"%L\" renamed \"%L\" (to \"%s\")", client, target, g_NewName[target]); SetClientName(target, g_NewName[target]); From bbdecceb4b243df9b04ca4b745a39c072cbb6c3d Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 2 Oct 2017 07:18:57 -0500 Subject: [PATCH 15/33] Switch to AMBuild 2.1 API. (#694) --- AMBuildScript | 113 +++++++++++++++---------- configure.py | 30 ++++--- core/AMBuilder | 8 +- core/logic/AMBuilder | 10 +-- extensions/bintools/AMBuilder | 4 +- extensions/clientprefs/AMBuilder | 4 +- extensions/curl/AMBuilder | 10 +-- extensions/curl/curl-src/lib/AMBuilder | 8 +- extensions/geoip/AMBuilder | 6 +- extensions/mysql/AMBuilder | 12 +-- extensions/regex/AMBuilder | 10 +-- extensions/sdkhooks/AMBuilder | 2 +- extensions/sdktools/AMBuilder | 2 +- extensions/sqlite/AMBuilder | 6 +- extensions/topmenus/AMBuilder | 4 +- extensions/updater/AMBuilder | 4 +- loader/AMBuilder | 8 +- sourcepawn | 2 +- tools/buildbot/PackageScript | 2 +- versionlib/AMBuilder | 2 +- 20 files changed, 137 insertions(+), 110 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index 0756c274..42c7f47d 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -104,7 +104,7 @@ class SMConfig(object): for sdk_name in PossibleSDKs: sdk = PossibleSDKs[sdk_name] - if builder.target_platform in sdk.platform: + if builder.target.platform in sdk.platform: if builder.options.hl2sdk_root: sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder) else: @@ -148,11 +148,11 @@ class SMConfig(object): def configure(self): builder.AddConfigureFile('pushbuild.txt') - cxx = builder.DetectCompilers() + cxx = builder.DetectCxx() if cxx.like('gcc'): self.configure_gcc(cxx) - elif cxx.vendor == 'msvc': + elif cxx.family == 'msvc': self.configure_msvc(cxx) # Optimizaiton @@ -164,11 +164,11 @@ class SMConfig(object): cxx.defines += ['DEBUG', '_DEBUG'] # Platform-specifics - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': self.configure_linux(cxx) - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': self.configure_mac(cxx) - elif builder.target_platform == 'windows': + elif builder.target.platform == 'windows': self.configure_windows(cxx) # Finish up. @@ -217,10 +217,12 @@ class SMConfig(object): ] cxx.linkflags += ['-m32'] - have_gcc = cxx.vendor == 'gcc' - have_clang = cxx.vendor == 'clang' - if cxx.version >= 'clang-3.6': + have_gcc = cxx.family == 'gcc' + have_clang = cxx.family == 'clang' + if cxx.version >= 'clang-3.6' or cxx.version >= 'apple-clang-7.0': cxx.cxxflags += ['-Wno-inconsistent-missing-override'] + if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0': + cxx.cxxflags += ['-Wno-null-dereference'] if have_clang or (cxx.version >= 'gcc-4.6'): cxx.cflags += ['-Wno-narrowing'] if have_clang or (cxx.version >= 'gcc-4.7'): @@ -292,9 +294,9 @@ class SMConfig(object): def configure_linux(self, cxx): cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64'] cxx.linkflags += ['-Wl,--exclude-libs,ALL', '-lm'] - if cxx.vendor == 'gcc': + if cxx.family == 'gcc': cxx.linkflags += ['-static-libgcc'] - elif cxx.vendor == 'clang': + elif cxx.family == 'clang': cxx.linkflags += ['-lgcc_eh'] def configure_mac(self, cxx): @@ -312,7 +314,7 @@ class SMConfig(object): cxx.defines += ['WIN32', '_WINDOWS'] def AddVersioning(self, binary): - if builder.target_platform == 'windows': + if builder.target.platform == 'windows': binary.sources += ['version.rc'] binary.compiler.rcdefines += [ 'BINARY_NAME="{0}"'.format(binary.outputFile), @@ -320,7 +322,7 @@ class SMConfig(object): ] if self.use_auto_versioning(): binary.compiler.rcdefines += ['SM_GENERATED_BUILD'] - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': if binary.type == 'library': binary.compiler.postlink += [ '-compatibility_version', '1.0.0', @@ -330,18 +332,42 @@ class SMConfig(object): binary.compiler.linkflags += [self.versionlib] binary.compiler.sourcedeps += SM.generated_headers return binary - - def Library(self, context, name): - binary = context.compiler.Library(name) + + def LibraryBuilder(self, compiler, name): + binary = compiler.Library(name) + self.AddVersioning(binary) if binary.compiler.like('msvc'): binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS'] - return self.AddVersioning(binary) + return binary - def Program(self, context, name): - binary = context.compiler.Program(name) + def ProgramBuilder(self, compiler, name): + binary = compiler.Program(name) + self.AddVersioning(binary) + if '-static-libgcc' in binary.compiler.linkflags: + binary.compiler.linkflags.remove('-static-libgcc') + if '-lgcc_eh' in binary.compiler.linkflags: + binary.compiler.linkflags.remove('-lgcc_eh') + if binary.compiler.like('gcc'): + binary.compiler.linkflags += ['-lstdc++'] if binary.compiler.like('msvc'): binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE'] - return self.AddVersioning(binary) + return binary + + def StaticLibraryBuilder(self, compiler, name): + binary = compiler.StaticLibrary(name) + return binary; + + def Library(self, context, name): + compiler = context.cxx.clone() + return self.LibraryBuilder(compiler, name) + + def Program(self, context, name): + compiler = context.cxx.clone() + return self.ProgramBuilder(compiler, name) + + def StaticLibrary(self, context, name): + compiler = context.cxx.clone() + return self.StaticLibraryBuilder(compiler, name) def ConfigureForExtension(self, context, compiler): compiler.cxxincludes += [ @@ -355,9 +381,9 @@ class SMConfig(object): return compiler def ExtLibrary(self, context, name): - binary = context.compiler.Library(name) + binary = self.Library(context, name) self.ConfigureForExtension(context, binary.compiler) - return self.AddVersioning(binary) + return binary def ConfigureForHL2(self, binary, sdk): compiler = binary.compiler @@ -409,29 +435,29 @@ class SMConfig(object): compiler.defines += ['NETWORK_VARS_ENABLED'] if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']: - if builder.target_platform in ['linux', 'mac']: + if builder.target.platform in ['linux', 'mac']: compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE'] - if sdk.name == 'csgo' and builder.target_platform == 'linux': + if sdk.name == 'csgo' and builder.target.platform == 'linux': compiler.linkflags += ['-lstdc++'] for path in paths: compiler.cxxincludes += [os.path.join(sdk.path, *path)] - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': if sdk.name == 'episode1': lib_folder = os.path.join(sdk.path, 'linux_sdk') elif sdk.name in ['sdk2013', 'bms']: lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32') else: lib_folder = os.path.join(sdk.path, 'lib', 'linux') - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': if sdk.name in ['sdk2013', 'bms']: lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32') else: lib_folder = os.path.join(sdk.path, 'lib', 'mac') - if builder.target_platform in ['linux', 'mac']: + if builder.target.platform in ['linux', 'mac']: if sdk.name in ['sdk2013', 'bms']: compiler.postlink += [ compiler.Dep(os.path.join(lib_folder, 'tier1.a')), @@ -446,20 +472,18 @@ class SMConfig(object): if sdk.name in ['blade', 'insurgency', 'csgo']: compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))] - self.AddVersioning(binary) - dynamic_libs = [] - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency']: dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so'] elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo']: dynamic_libs = ['libtier0.so', 'libvstdlib.so'] else: dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so'] - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': compiler.linkflags.append('-liconv') dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib'] - elif builder.target_platform == 'windows': + elif builder.target.platform == 'windows': libs = ['tier0', 'tier1', 'vstdlib', 'mathlib'] if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo']: libs.append('interfaces') @@ -483,17 +507,18 @@ class SMConfig(object): return binary def HL2Library(self, context, name, sdk): - binary = context.compiler.Library(name) + binary = self.Library(context, name) self.ConfigureForExtension(context, binary.compiler) return self.ConfigureForHL2(binary, sdk) def HL2Project(self, context, name): - project = context.compiler.LibraryProject(name) + project = context.cxx.LibraryProject(name) self.ConfigureForExtension(context, project.compiler) return project def HL2Config(self, project, name, sdk): binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name)) + self.AddVersioning(binary) return self.ConfigureForHL2(binary, sdk) SM = SMConfig() @@ -502,23 +527,21 @@ SM.detectSDKs() SM.configure() if SM.use_auto_versioning(): - SM.generated_headers = builder.RunScript( + SM.generated_headers = builder.Build( 'tools/buildbot/Versioning', { 'SM': SM } ) - SM.versionlib = builder.RunScript( + SM.versionlib = builder.Build( 'versionlib/AMBuilder', { 'SM': SM } ) # Build SourcePawn externally. -SourcePawn = builder.RunScript('sourcepawn/AMBuildScript', {}) -SP = SourcePawn( - root = SM, - amtl = os.path.join(builder.sourcePath, 'public', 'amtl'), -) -SP.BuildSpcomp() -SP.BuildVM() +SP = builder.Build('sourcepawn/AMBuildScript', { + 'external_root': SM, + 'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'), + 'external_build': ['core'], +}) SM.spcomp = SP.spcomp SM.binaries += [ SP.libsourcepawn @@ -549,7 +572,7 @@ if builder.backend == 'amb2': 'tools/buildbot/PackageScript', ] -builder.RunBuildScripts(BuildScripts, { 'SM': SM }) +builder.Build(BuildScripts, { 'SM': SM }) if builder.options.breakpad_dump: - builder.RunScript('tools/buildbot/BreakpadSymbols', { 'SM': SM }) + builder.Build('tools/buildbot/BreakpadSymbols', { 'SM': SM }) diff --git a/configure.py b/configure.py index 65324d9f..6bb0358c 100644 --- a/configure.py +++ b/configure.py @@ -1,7 +1,7 @@ # vim: set ts=2 sw=2 tw=99 noet: import sys try: - from ambuild2 import run + from ambuild2 import run, util except: try: import ambuild @@ -12,25 +12,29 @@ except: sys.stderr.write('http://www.alliedmods.net/ambuild\n') sys.exit(1) -run = run.PrepareBuild(sourcePath=sys.path[0]) -run.default_build_folder = 'obj-' + run.target_platform -run.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, +def make_objdir_name(p): + return 'obj-' + util.Platform() + '-' + p.target_arch + +parser = run.BuildParser(sourcePath=sys.path[0], api='2.1') +parser.default_arch = 'x86' +parser.default_build_folder = make_objdir_name +parser.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, help='Root search folder for HL2SDKs') -run.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None, +parser.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None, help='Path to MySQL 5') -run.options.add_option('--mms-path', type=str, dest='mms_path', default=None, +parser.options.add_option('--mms-path', type=str, dest='mms_path', default=None, help='Path to Metamod:Source') -run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', +parser.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', help='Enable debugging symbols') -run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', +parser.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', help='Enable optimization') -run.options.add_option('--no-mysql', action='store_false', default=True, dest='hasMySql', +parser.options.add_option('--no-mysql', action='store_false', default=True, dest='hasMySql', help='Disable building MySQL extension') -run.options.add_option('-s', '--sdks', default='all', dest='sdks', +parser.options.add_option('-s', '--sdks', default='all', dest='sdks', help='Build against specified SDKs; valid args are "all", "present", or ' 'comma-delimited list of engine names (default: %default)') -run.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump', +parser.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump', default=False, help='Dump and upload breakpad symbols') -run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning', +parser.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning', default=False, help='Disable the auto versioning script') -run.Configure() +parser.Configure() diff --git a/core/AMBuilder b/core/AMBuilder index 876c554c..09bca74c 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -60,15 +60,15 @@ for sdk_name in SM.sdks: os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf') ] - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': compiler.postlink += ['-lpthread', '-lrt'] if sdk.name == 'csgo': - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a') - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': lib_path = os.path.join(sdk.path, 'lib', 'osx32', 'release', 'libprotobuf.a') - elif builder.target_platform == 'windows': + elif builder.target.platform == 'windows': msvc_ver = compiler.version vs_year = '' if msvc_ver == 1800: diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index 11e6a7f7..08d086b3 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -16,15 +16,15 @@ binary.compiler.defines += [ 'SM_LOGIC' ] -if builder.target_platform == 'linux': +if builder.target.platform == 'linux': binary.compiler.postlink += ['-lpthread', '-lrt'] -elif builder.target_platform == 'mac': +elif builder.target.platform == 'mac': binary.compiler.cflags += ['-Wno-deprecated-declarations'] binary.compiler.postlink += ['-framework', 'CoreServices'] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.sources += [ @@ -83,7 +83,7 @@ binary.sources += [ 'frame_tasks.cpp', 'smn_halflife.cpp', ] -if builder.target_platform == 'windows': +if builder.target.platform == 'windows': binary.sources += ['thread/WinThreads.cpp'] else: binary.sources += ['thread/PosixThreads.cpp'] diff --git a/extensions/bintools/AMBuilder b/extensions/bintools/AMBuilder index bd778dfc..a7753a7a 100644 --- a/extensions/bintools/AMBuilder +++ b/extensions/bintools/AMBuilder @@ -8,9 +8,9 @@ binary.compiler.cxxincludes += [ os.path.join(builder.sourcePath, 'public', 'jit'), os.path.join(builder.sourcePath, 'public', 'jit', 'x86'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.sources += [ diff --git a/extensions/clientprefs/AMBuilder b/extensions/clientprefs/AMBuilder index b30a9f06..585058ad 100644 --- a/extensions/clientprefs/AMBuilder +++ b/extensions/clientprefs/AMBuilder @@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'clientprefs.ext') binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core', 'sourcehook'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.sources += [ diff --git a/extensions/curl/AMBuilder b/extensions/curl/AMBuilder index b5e6377b..523d94b8 100644 --- a/extensions/curl/AMBuilder +++ b/extensions/curl/AMBuilder @@ -1,21 +1,21 @@ # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python : import os -libcurl = builder.RunScript('curl-src/lib/AMBuilder') +libcurl = builder.Build('curl-src/lib/AMBuilder') binary = SM.ExtLibrary(builder, 'webternet.ext') binary.compiler.includes += [ os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include') ] binary.compiler.defines += ['CURL_STATICLIB'] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.compiler.postlink += [libcurl.binary] -if builder.target_platform == 'linux': +if builder.target.platform == 'linux': binary.compiler.postlink += ['-lrt'] -elif builder.target_platform == 'windows': +elif builder.target.platform == 'windows': binary.compiler.postlink += ['ws2_32.lib'] binary.sources += [ diff --git a/extensions/curl/curl-src/lib/AMBuilder b/extensions/curl/curl-src/lib/AMBuilder index 721af044..b61e8676 100644 --- a/extensions/curl/curl-src/lib/AMBuilder +++ b/extensions/curl/curl-src/lib/AMBuilder @@ -3,24 +3,24 @@ import os, platform builder.SetBuildFolder('libcurl') -binary = builder.compiler.StaticLibrary('curl') +binary = SM.StaticLibrary(builder, 'curl') binary.compiler.includes += [ os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'lib'), os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include') ] -if builder.target_platform == 'mac': +if builder.target.platform == 'mac': mac_version, ignore, ignore = platform.mac_ver() mac_tuple = mac_version.split('.') if int(mac_tuple[0]) >= 10 and int(mac_tuple[1]) >= 9: binary.compiler.defines += ['BUILTIN_STRLCAT'] -elif builder.target_platform == 'windows': +elif builder.target.platform == 'windows': binary.compiler.defines += [ 'BUILDING_LIBCURL', 'CURL_STATICLIB', 'CURL_DISABLE_LDAP', ] -elif builder.target_platform == 'linux': +elif builder.target.platform == 'linux': binary.compiler.defines += ['_GNU_SOURCE'] if binary.compiler.vendor == 'clang': diff --git a/extensions/geoip/AMBuilder b/extensions/geoip/AMBuilder index e54ed7c6..7afcedd1 100644 --- a/extensions/geoip/AMBuilder +++ b/extensions/geoip/AMBuilder @@ -2,11 +2,11 @@ import os binary = SM.ExtLibrary(builder, 'geoip.ext') -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] -if builder.target_platform == 'windows': +if builder.target.platform == 'windows': binary.compiler.postlink += ['wsock32.lib'] binary.sources += [ diff --git a/extensions/mysql/AMBuilder b/extensions/mysql/AMBuilder index cd224dff..3254754d 100644 --- a/extensions/mysql/AMBuilder +++ b/extensions/mysql/AMBuilder @@ -7,21 +7,21 @@ if SM.mysql_root: os.path.join(SM.mysql_root, 'include'), os.path.join(SM.mms_root, 'core', 'sourcehook') ] - if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': + if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] - elif binary.compiler.vendor == 'msvc': + elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] - if builder.target_platform == 'linux' or builder.target_platform == 'mac': + if builder.target.platform == 'linux' or builder.target.platform == 'mac': binary.compiler.postlink += [ os.path.join(SM.mysql_root, 'lib', 'libmysqlclient_r.a'), '-lz', '-lpthread', '-lm', ] - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': binary.compiler.postlink += ['-lrt'] - elif builder.target_platform == 'windows': + elif builder.target.platform == 'windows': binary.compiler.postlink += [ os.path.join(SM.mysql_root, 'lib', 'opt', 'mysqlclient.lib'), os.path.join(SM.mysql_root, 'lib', 'opt', 'zlib.lib'), @@ -38,7 +38,7 @@ if SM.mysql_root: 'extension.cpp' ] - if binary.compiler.vendor == 'msvc' and binary.compiler.version >= 1900: + if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900: binary.sources += [ 'msvc15hack.c' ] binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib'] diff --git a/extensions/regex/AMBuilder b/extensions/regex/AMBuilder index a95959e7..f5d66809 100644 --- a/extensions/regex/AMBuilder +++ b/extensions/regex/AMBuilder @@ -5,16 +5,16 @@ binary = SM.ExtLibrary(builder, 'regex.ext') binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core', 'sourcehook'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] -if builder.target_platform == 'linux': +if builder.target.platform == 'linux': path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux', 'libpcre.a') -elif builder.target_platform == 'windows': +elif builder.target.platform == 'windows': path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_win', 'pcre.lib') -elif builder.target_platform == 'mac': +elif builder.target.platform == 'mac': path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin', 'libpcre.a') binary.compiler.postlink += [binary.Dep(path)] diff --git a/extensions/sdkhooks/AMBuilder b/extensions/sdkhooks/AMBuilder index e0166b32..fa8458ba 100644 --- a/extensions/sdkhooks/AMBuilder +++ b/extensions/sdkhooks/AMBuilder @@ -17,7 +17,7 @@ for sdk_name in SM.sdks: binary.compiler.cxxincludes += [ os.path.join(sdk.path, 'game', 'shared') ] - if binary.compiler.cxx.behavior == 'gcc': + if binary.compiler.behavior == 'gcc': binary.compiler.cxxflags += ['-Wno-invalid-offsetof'] SM.extensions += builder.Add(project) diff --git a/extensions/sdktools/AMBuilder b/extensions/sdktools/AMBuilder index 136410f4..ce0194cc 100644 --- a/extensions/sdktools/AMBuilder +++ b/extensions/sdktools/AMBuilder @@ -42,7 +42,7 @@ for sdk_name in SM.sdks: if sdk.name != 'episode1': binary.compiler.defines += ['HOOKING_ENABLED'] - if binary.compiler.cxx.behavior == 'gcc': + if binary.compiler.behavior == 'gcc': binary.compiler.cxxflags += ['-Wno-invalid-offsetof'] SM.extensions += builder.Add(project) diff --git a/extensions/sqlite/AMBuilder b/extensions/sqlite/AMBuilder index 58b20e15..485a8249 100644 --- a/extensions/sqlite/AMBuilder +++ b/extensions/sqlite/AMBuilder @@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'dbi.sqlite.ext') binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core', 'sourcehook'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.compiler.defines += [ @@ -16,7 +16,7 @@ binary.compiler.defines += [ 'SQLITE_USE_URI', 'SQLITE_ALLOW_URI_AUTHORITY', ] -if builder.target_platform == 'linux': +if builder.target.platform == 'linux': binary.compiler.postlink += ['-ldl', '-lpthread'] binary.sources += [ diff --git a/extensions/topmenus/AMBuilder b/extensions/topmenus/AMBuilder index 249894ee..d901cf80 100644 --- a/extensions/topmenus/AMBuilder +++ b/extensions/topmenus/AMBuilder @@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'topmenus.ext') binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core', 'sourcehook'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.sources += [ diff --git a/extensions/updater/AMBuilder b/extensions/updater/AMBuilder index ed7659c1..1ef40552 100644 --- a/extensions/updater/AMBuilder +++ b/extensions/updater/AMBuilder @@ -5,9 +5,9 @@ binary = SM.ExtLibrary(builder, 'updater.ext') binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core', 'sourcehook'), ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.sources += [ diff --git a/loader/AMBuilder b/loader/AMBuilder index 12e981a9..13e247ee 100644 --- a/loader/AMBuilder +++ b/loader/AMBuilder @@ -1,10 +1,10 @@ # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: import os.path -if builder.target_platform in ['windows', 'mac']: +if builder.target.platform in ['windows', 'mac']: name = 'sourcemod_mm' extra_ldflags = [] -elif builder.target_platform == 'linux': +elif builder.target.platform == 'linux': name = 'sourcemod_mm_i486' extra_ldflags = ['-ldl'] @@ -13,9 +13,9 @@ binary.compiler.cxxincludes += [ os.path.join(SM.mms_root, 'core'), os.path.join(SM.mms_root, 'sourcehook') ] -if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang': +if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang': binary.compiler.cxxflags += ['-fno-rtti'] -elif binary.compiler.vendor == 'msvc': +elif binary.compiler.family == 'msvc': binary.compiler.cxxflags += ['/GR-'] binary.compiler.linkflags += extra_ldflags binary.sources = [ diff --git a/sourcepawn b/sourcepawn index 12365b39..943e7172 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit 12365b39ccc20ab6c5fa28ec56f1c593d177b91c +Subproject commit 943e71720b9cc0e4e477ad982c13061d9e2ddddd diff --git a/tools/buildbot/PackageScript b/tools/buildbot/PackageScript index cae5e317..89bf12a0 100644 --- a/tools/buildbot/PackageScript +++ b/tools/buildbot/PackageScript @@ -474,7 +474,7 @@ CopyFiles('plugins/playercommands', 'addons/sourcemod/scripting/playercommands', ] ) -if builder.target_platform == 'windows': +if builder.target.platform == 'windows': CopyFiles('tools/batchtool', 'addons/sourcemod/scripting', ['compile.exe']) else: CopyFiles('plugins', 'addons/sourcemod/scripting', ['compile.sh']) diff --git a/versionlib/AMBuilder b/versionlib/AMBuilder index 2676d1d6..51eae7af 100644 --- a/versionlib/AMBuilder +++ b/versionlib/AMBuilder @@ -1,7 +1,7 @@ # vim: sts=2 ts=8 sw=2 tw=99 et ft=python: import os -lib = builder.compiler.StaticLibrary('version') +lib = SM.StaticLibrary(builder, 'version') lib.compiler.includes += [ os.path.join(builder.sourcePath, 'public') ] From 82e6d00cea1157b495a8db633f9cf6304da4722c Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 2 Oct 2017 07:40:58 -0500 Subject: [PATCH 16/33] Fix build. --- tools/buildbot/BreakpadSymbols | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/buildbot/BreakpadSymbols b/tools/buildbot/BreakpadSymbols index 1633f343..0959ac64 100644 --- a/tools/buildbot/BreakpadSymbols +++ b/tools/buildbot/BreakpadSymbols @@ -7,19 +7,19 @@ UPLOAD_SCRIPT = os.path.join(builder.sourcePath, 'tools', 'buildbot', 'upload_sy cxx_tasks = SM.binaries + SM.extensions + [SM.spcomp] for cxx_task in cxx_tasks: - if builder.target_platform in ['windows']: + if builder.target.platform in ['windows']: debug_entry = cxx_task.debug else: debug_entry = cxx_task.binary debug_file = os.path.join(builder.buildPath, debug_entry.path) - if builder.target_platform == 'linux': + if builder.target.platform == 'linux': argv = ['dump_syms', debug_file, os.path.dirname(debug_file)] - elif builder.target_platform == 'mac': + elif builder.target.platform == 'mac': # Required once dump_syms is updated on the slaves. #argv = ['dump_syms', '-g', debug_file + '.dSYM', debug_file] argv = ['dump_syms', debug_file + '.dSYM'] - elif builder.target_platform == 'windows': + elif builder.target.platform == 'windows': argv = ['dump_syms.exe', debug_file] base_file = os.path.splitext(os.path.basename(debug_file))[0] From 65a8f3cbf8223a387a765bbcbbcfc312d27dce93 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Tue, 3 Oct 2017 03:24:44 -0500 Subject: [PATCH 17/33] Trigger build. --- pushbuild.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pushbuild.txt b/pushbuild.txt index ef66c968..00942381 100644 --- a/pushbuild.txt +++ b/pushbuild.txt @@ -71,3 +71,5 @@ R.I.P. Wade Boggs Your tier1 tower is under attack.. Christmas!!! the mousse angles are smooth +spoilers + From 22e3d2d1983794aae4c8964ce3512c91d8c9b500 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Mon, 9 Oct 2017 11:51:49 -0700 Subject: [PATCH 18/33] Fix GCC build with SourcePawn. --- sourcepawn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sourcepawn b/sourcepawn index 943e7172..4a17478a 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit 943e71720b9cc0e4e477ad982c13061d9e2ddddd +Subproject commit 4a17478ae3c7122205fb495dc14fd34243679bea From 30f061e81858b83f43edc3695cf19b7a4d46cd8c Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Mon, 9 Oct 2017 13:00:52 -0700 Subject: [PATCH 19/33] Fix unsigned comparison warnings (-Werror + GCC5) from CS:GO fixes. --- extensions/cstrike/util_cstrike.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cstrike/util_cstrike.cpp b/extensions/cstrike/util_cstrike.cpp index f5728663..23fcc65b 100644 --- a/extensions/cstrike/util_cstrike.cpp +++ b/extensions/cstrike/util_cstrike.cpp @@ -321,7 +321,7 @@ const char *GetTranslatedWeaponAlias(const char *weapon) "nvgs", "nightvision" }; - for (int i = 0; i < SM_ARRAYSIZE(szAliases)/2; i++) + for (size_t i = 0; i < SM_ARRAYSIZE(szAliases)/2; i++) { if (stricmp(weapon, szAliases[i * 2]) == 0) return szAliases[i * 2 + 1]; @@ -402,7 +402,7 @@ const char *WeaponIDToAlias(int weaponID) #else int realID = GetRealWeaponID(weaponID); - if (realID < SM_ARRAYSIZE(szWeaponInfo) && realID > 0) + if (static_cast(realID) < SM_ARRAYSIZE(szWeaponInfo) && realID > 0) return szWeaponInfo[realID]; return NULL; From 65bf85fcbefdc5a794c47cbb4ff6aa2058c33671 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Mon, 9 Oct 2017 16:53:19 -0700 Subject: [PATCH 20/33] (Re-)Add support for gcc and clang3.9, 4.0, and 5.0. --- AMBuildScript | 5 +++++ extensions/curl/curl-src/lib/AMBuilder | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AMBuildScript b/AMBuildScript index 42c7f47d..de934810 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -219,6 +219,10 @@ class SMConfig(object): have_gcc = cxx.family == 'gcc' have_clang = cxx.family == 'clang' + if cxx.version >= 'clang-3.9' or cxx.version >= 'apple-clang-8.0': + cxx.cxxflags += ['-Wno-expansion-to-defined'] + if cxx.version == 'clang-3.9' or cxx.version == 'apple-clang-8.0': + cxx.cflags += ['-Wno-varargs'] if cxx.version >= 'clang-3.6' or cxx.version >= 'apple-clang-7.0': cxx.cxxflags += ['-Wno-inconsistent-missing-override'] if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0': @@ -240,6 +244,7 @@ class SMConfig(object): if have_gcc: cxx.cflags += ['-mfpmath=sse'] + cxx.cflags += ['-Wno-maybe-uninitialized'] if builder.options.opt == '1': cxx.cflags += ['-O3'] diff --git a/extensions/curl/curl-src/lib/AMBuilder b/extensions/curl/curl-src/lib/AMBuilder index b61e8676..71859c50 100644 --- a/extensions/curl/curl-src/lib/AMBuilder +++ b/extensions/curl/curl-src/lib/AMBuilder @@ -23,7 +23,7 @@ elif builder.target.platform == 'windows': elif builder.target.platform == 'linux': binary.compiler.defines += ['_GNU_SOURCE'] -if binary.compiler.vendor == 'clang': +if binary.compiler.family == 'clang': # https://llvm.org/bugs/show_bug.cgi?id=16428 binary.compiler.cflags += ['-Wno-attributes'] From 2ccaa376baf3052b8f5c630c10b7744ad1e40c4f Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Mon, 9 Oct 2017 18:34:01 -0700 Subject: [PATCH 21/33] NPOTB: Enable better coverage testing with toolchains (Travis-CI). (#703) NPOTB: Enable better coverage testing with toolchains (Travis-CI). --- .travis.yml | 130 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 107 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index d3cb825d..aeb4bf8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,117 @@ +git: + depth: 3 + +sudo: false +language: cpp +os: linux +dist: trusty addons: apt: - packages: - - lib32stdc++6 - - lib32z1-dev - - libc6-dev-i386 - - linux-libc-dev - - g++-multilib - - g++-4.8 sources: - - ubuntu-toolchain-r-test - cache: - directories: - - ../mysql-5.0 -language: cpp -sudo: false -compiler: - - clang + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + - llvm-toolchain-trusty-5.0 + packages: + - lib32stdc++6 + - lib32z1-dev + - libc6-dev-i386 + - linux-libc-dev + - g++-multilib + packages: +# - clang-3.6 +# - clang-3.8 +# - clang-4.0 +# - clang-5.0 +# - g++-6 +# - g++-6-multilib + - g++-4.8-multilib + - g++-4.8 + - g++-4.9-multilib + - g++-4.9 + - g++-5-multilib + - g++-5 + - g++-7-multilib + - g++-7 + cache: + directories: + - ../mysql-5.0 env: - global: - - LLVM_ARCHIVE_URI=http://sourcemod.net/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz -before_install: - - wget -nc $LLVM_ARCHIVE_URI -O $HOME/clang+llvm.tar.xz - - mkdir -p $HOME/clang+llvm - - tar -xf $HOME/clang+llvm.tar.xz -C $HOME/clang+llvm --strip-components 1 - - export PATH=$HOME/clang+llvm/bin:$PATH + - MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9" + - MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8" + - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" + - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" + +matrix: + fast_finish: true + include: + - os: linux + sudo: false + language: cpp + addons: + apt: + packages: ['clang-3.6', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib'] + cache: + directories: ['../mysql-5.0'] + env: ['MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"'] + + - os: linux + sudo: false + language: cpp + addons: + apt: + packages: ['clang-3.8', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib'] + cache: + directories: ['../mysql-5.0'] + env: ['MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"'] + + - os: linux + sudo: false + language: cpp + addons: + apt: + sources: ['llvm-toolchain-trusty-4.0'] + packages: ['clang-4.0', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib'] + cache: + directories: ['../mysql-5.0'] + env: ['MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"'] + + - os: linux + sudo: false + language: cpp + addons: + apt: + sources: ['llvm-toolchain-trusty-5.0'] + packages: ['clang-5.0', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib'] + cache: + directories: ['../mysql-5.0'] + env: ['MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"'] + + - os: linux + sudo: false + language: cpp + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-6', 'g++-6-multilib', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev', 'g++-multilib'] + cache: + directories: ['../mysql-5.0'] + env: ['MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"'] + + allow_failures: + - env: MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7" + - env: MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9" + - env: MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8" + - env: MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" + - env: MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" + - env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" + + before_script: - CHECKOUT_DIR=$PWD && cd .. && $CHECKOUT_DIR/tools/checkout-deps.sh && cd $CHECKOUT_DIR script: - mkdir build && cd build - PATH="~/.local/bin:$PATH" - - CC=clang-3.8 CXX=clang-3.8 python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota + - eval "${MATRIX_EVAL}" + - python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota - ambuild From 36f9a8ed7a8f5c85799a42822e94be4823eb3fd2 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Tue, 10 Oct 2017 12:00:11 -0700 Subject: [PATCH 22/33] NPOTB: Remove unsupported packages line from Travis-CI. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aeb4bf8f..234f8c37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ addons: - libc6-dev-i386 - linux-libc-dev - g++-multilib - packages: # - clang-3.6 # - clang-3.8 # - clang-4.0 From 4f54df65e92f691f94209f27ca0f3fedca0c9270 Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Sun, 15 Oct 2017 02:32:01 -0700 Subject: [PATCH 23/33] Switch C header & Fix warnings (#702) --- core/logic/smn_float.cpp | 40 +------------------------------ extensions/sdkhooks/extension.cpp | 2 +- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/core/logic/smn_float.cpp b/core/logic/smn_float.cpp index 16aa972e..aabedf01 100644 --- a/core/logic/smn_float.cpp +++ b/core/logic/smn_float.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include #include #include "common_logic.h" @@ -288,44 +288,6 @@ static cell_t sm_ArcTangent2(IPluginContext *pCtx, const cell_t *params) return sp_ftoc(val1); } -#if 0 -static cell_t sm_FloatRound(IPluginContext *pCtx, const cell_t *params) -{ - float val = sp_ctof(params[1]); - - switch (params[2]) - { - case 1: - { - val = floor(val); - break; - } - case 2: - { - val = ceil(val); - break; - } - case 3: - { - if (val >= 0.0f) - { - val = floor(val); - } else { - val = ceil(val); - } - break; - } - default: - { - val = (float)floor(val + 0.5f); - break; - } - } - - return static_cast(val); -} -#endif - class RandomHelpers : public SMGlobalClass, public IPluginsListener diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index f7a64370..85a1de9d 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -957,7 +957,7 @@ bool SDKHooks::Hook_CanBeAutobalanced() // Only update our new ret if different from original // (so if multiple plugins returning different answers, // the one(s) that changed it win) - if (res != origRet) + if ((bool)res != origRet) newRet = !origRet; } From ab303e7394c1f17ac7697293e58833f8335b72d0 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Thu, 19 Oct 2017 23:59:14 -0400 Subject: [PATCH 24/33] Gamedata for 2017-10-20 TF2 update. --- gamedata/sdkhooks.games/engine.ep2v.txt | 62 ++++++++++++------------- gamedata/sdktools.games/game.tf.txt | 56 +++++++++++----------- gamedata/sm-tf2.games.txt | 36 +++++++------- 3 files changed, 77 insertions(+), 77 deletions(-) diff --git a/gamedata/sdkhooks.games/engine.ep2v.txt b/gamedata/sdkhooks.games/engine.ep2v.txt index a30585b1..419849d2 100644 --- a/gamedata/sdkhooks.games/engine.ep2v.txt +++ b/gamedata/sdkhooks.games/engine.ep2v.txt @@ -7,9 +7,9 @@ { "CanBeAutobalanced" { - "windows" "461" - "linux" "462" - "mac" "462" + "windows" "462" + "linux" "463" + "mac" "463" } "EndTouch" { @@ -43,27 +43,27 @@ } "OnTakeDamage_Alive" { - "windows" "274" - "linux" "275" - "mac" "275" + "windows" "275" + "linux" "276" + "mac" "276" } "PreThink" - { - "windows" "335" - "linux" "336" - "mac" "336" - } - "PostThink" { "windows" "336" "linux" "337" "mac" "337" } + "PostThink" + { + "windows" "337" + "linux" "338" + "mac" "338" + } "Reload" { - "windows" "275" - "linux" "281" - "mac" "281" + "windows" "276" + "linux" "282" + "mac" "282" } "SetTransmit" { @@ -127,34 +127,34 @@ } "Weapon_CanSwitchTo" { - "windows" "268" - "linux" "269" - "mac" "269" + "windows" "269" + "linux" "270" + "mac" "270" } "Weapon_CanUse" - { - "windows" "262" - "linux" "263" - "mac" "263" - } - "Weapon_Drop" - { - "windows" "265" - "linux" "266" - "mac" "266" - } - "Weapon_Equip" { "windows" "263" "linux" "264" "mac" "264" } - "Weapon_Switch" + "Weapon_Drop" { "windows" "266" "linux" "267" "mac" "267" } + "Weapon_Equip" + { + "windows" "264" + "linux" "265" + "mac" "265" + } + "Weapon_Switch" + { + "windows" "267" + "linux" "268" + "mac" "268" + } } } diff --git a/gamedata/sdktools.games/game.tf.txt b/gamedata/sdktools.games/game.tf.txt index 3fe74c74..481b40e6 100644 --- a/gamedata/sdktools.games/game.tf.txt +++ b/gamedata/sdktools.games/game.tf.txt @@ -18,33 +18,33 @@ { "GiveNamedItem" { - "windows" "400" - "linux" "404" - "mac" "404" + "windows" "401" + "linux" "405" + "mac" "405" } "RemovePlayerItem" { - "windows" "272" - "linux" "273" - "mac" "273" + "windows" "273" + "linux" "274" + "mac" "274" } "Weapon_GetSlot" { - "windows" "270" - "linux" "271" - "mac" "271" + "windows" "271" + "linux" "272" + "mac" "272" } "Ignite" { - "windows" "211" - "linux" "212" - "mac" "212" + "windows" "212" + "linux" "213" + "mac" "213" } "Extinguish" { - "windows" "215" - "linux" "216" - "mac" "216" + "windows" "216" + "linux" "217" + "mac" "217" } "Teleport" { @@ -54,9 +54,9 @@ } "CommitSuicide" { - "windows" "444" - "linux" "444" - "mac" "444" + "windows" "445" + "linux" "445" + "mac" "445" } "GetVelocity" { @@ -84,9 +84,9 @@ } "WeaponEquip" { - "windows" "263" - "linux" "264" - "mac" "264" + "windows" "264" + "linux" "265" + "mac" "265" } "Activate" { @@ -96,15 +96,15 @@ } "PlayerRunCmd" { - "windows" "421" - "linux" "422" - "mac" "422" + "windows" "422" + "linux" "423" + "mac" "423" } "GiveAmmo" { - "windows" "254" - "linux" "255" - "mac" "255" + "windows" "255" + "linux" "256" + "mac" "256" } } @@ -123,7 +123,7 @@ "FireOutput" { "library" "server" - "windows" "\x55\x8B\xEC\x81\xEC\x24\x01\x00\x00\x53" + "windows" "\x55\x8B\xEC\x81\xEC\x24\x01\x00\x00\x53\x8B\xC1" "linux" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" "mac" "@_ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f" } diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index e5d810fd..d6e15f5a 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -18,21 +18,21 @@ "Burn" { "library" "server" - "windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x8B\x8E\x8C\x01\x00\x00\x8B\x01" + "windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x8B\x8E\x90\x01\x00\x00\x8B\x01" "linux" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayerP13CTFWeaponBasef" "mac" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayerP13CTFWeaponBasef" } "RemoveDisguise" { "library" "server" - "windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x57\xF7\x86" + "windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x57\xF7\x86\xD0\x00\x00\x00\x00\x00\x02\x00" "linux" "@_ZN15CTFPlayerShared14RemoveDisguiseEv" "mac" "@_ZN15CTFPlayerShared14RemoveDisguiseEv" } "Disguise" { "library" "server" - "windows" "\x55\x8B\xEC\x51\x56\x57\x8B\xF9\x8B\x8F\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x8B\x97\x2A\x2A\x2A\x2A\x8B\xF0" + "windows" "\x55\x8B\xEC\x83\xEC\x24\x56\x57\x8B\xF9\x8B\x8F\x90\x01\x00\x00" "linux" "@_ZN15CTFPlayerShared8DisguiseEiiP9CTFPlayerb" "mac" "@_ZN15CTFPlayerShared8DisguiseEiiP9CTFPlayerb" } @@ -53,7 +53,7 @@ "RemoveCondition" { "library" "server" - "windows" "\x55\x8B\xEC\x56\x57\x8B\x7D\x08\x8B\xF1\x57\xE8\x2A\x2A\x2A\x2A\x84\xC0\x0F\x84" + "windows" "\x55\x8B\xEC\x83\xEC\x08\x53\x8B\x5D\x08\x56\x53" "linux" "@_ZN15CTFPlayerShared10RemoveCondE7ETFCondb" "mac" "@_ZN15CTFPlayerShared10RemoveCondE7ETFCondb" } @@ -74,14 +74,14 @@ "StunPlayer" { "library" "server" - "windows" "\x55\x8B\xEC\x83\xEC\x24\x57\x8B\xF9\x8B\x87\xF8\x03\x00\x00" + "windows" "\x55\x8B\xEC\x83\xEC\x20\x57\x8B\xF9\x8B\x87\x58\x04\x00\x00" "linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" "mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" } "MakeBleed" { "library" "server" - "windows" "\x55\x8B\xEC\x83\xEC\x2C\x53\x8B\xD9\x89\x5D\xEC" + "windows" "\x55\x8B\xEC\x83\xEC\x30\x53\x8B\xD9\x89\x5D\xEC" "linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" "mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" } @@ -113,21 +113,21 @@ { "ForceRespawn" { - "windows" "328" - "linux" "329" - "mac" "329" + "windows" "329" + "linux" "330" + "mac" "330" } "CalcIsAttackCriticalHelper" { - "windows" "387" - "linux" "394" - "mac" "394" + "windows" "389" + "linux" "396" + "mac" "396" } "CalcIsAttackCriticalHelperNoCrits" { - "windows" "388" - "linux" "395" - "mac" "395" + "windows" "390" + "linux" "397" + "mac" "397" } // CTFGameRules::IsHolidayActive @@ -140,9 +140,9 @@ "RemoveWearable" { - "windows" "430" - "linux" "431" - "mac" "431" + "windows" "431" + "linux" "432" + "mac" "432" } } } From 5aaea4c2c58cab8d07fb520144636d6aa8006870 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 22 Oct 2017 08:52:02 -0400 Subject: [PATCH 25/33] Update TF2 enums. --- plugins/include/tf2.inc | 12 +++++++++++- plugins/include/tf2_stocks.inc | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index 2a544c31..4116d0f4 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -195,7 +195,17 @@ enum TFCond TFCond_KnockedIntoAir, TFCond_CompetitiveWinner, TFCond_CompetitiveLoser, - TFCond_NoTaunting, + TFCond_NoTaunting_DEPRECATED, + TFCond_HealingDebuff = 118, + TFCond_PasstimePenaltyDebuff, + TFCond_GrappledToPlayer, + TFCond_GrappledByPlayer, + TFCond_ParachuteDeployed, + TFCond_Gas, + TFCond_BurningPyro, + TFCond_RocketPack, + TFCond_LostFooting, + TFCond_AirCurrent, }; const float TFCondDuration_Infinite = -1.0; diff --git a/plugins/include/tf2_stocks.inc b/plugins/include/tf2_stocks.inc index 5069acb1..8e60adad 100644 --- a/plugins/include/tf2_stocks.inc +++ b/plugins/include/tf2_stocks.inc @@ -159,6 +159,11 @@ enum { TF_CUSTOM_KART, TF_CUSTOM_GIANT_HAMMER, TF_CUSTOM_RUNE_REFLECT, + TF_CUSTOM_DRAGONS_FURY_IGNITE, + TF_CUSTOM_DRAGONS_FURY_BONUS_BURNING, + TF_CUSTOM_SLAP_KILL, + TF_CUSTOM_CROC, + TF_CUSTOM_TAUNTATK_GASBLAST, }; // Weapon codes as used in some events, such as player_death @@ -268,6 +273,12 @@ enum { TF_WEAPON_GRAPPLINGHOOK, TF_WEAPON_PASSTIME_GUN, TF_WEAPON_CHARGED_SMG, + TF_WEAPON_BREAKABLE_SIGN, + TF_WEAPON_ROCKETPACK, + TF_WEAPON_SLAP, + TF_WEAPON_JAR_GAS, + TF_WEAPON_GRENADE_JAR_GAS, + TF_WEPON_FLAME_BALL, }; // TF2 Weapon Loadout Slots From 23a1c5f952db647f9179d261d06f65b4405dd005 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 22 Oct 2017 09:32:02 -0400 Subject: [PATCH 26/33] Tyop fix. --- plugins/include/tf2_stocks.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/include/tf2_stocks.inc b/plugins/include/tf2_stocks.inc index 8e60adad..9830f696 100644 --- a/plugins/include/tf2_stocks.inc +++ b/plugins/include/tf2_stocks.inc @@ -278,7 +278,7 @@ enum { TF_WEAPON_SLAP, TF_WEAPON_JAR_GAS, TF_WEAPON_GRENADE_JAR_GAS, - TF_WEPON_FLAME_BALL, + TF_WEAPON_FLAME_BALL, }; // TF2 Weapon Loadout Slots From a5c213ae7d76d8c43bf8288701d4341211385339 Mon Sep 17 00:00:00 2001 From: Benoist3012 Date: Sat, 21 Oct 2017 20:39:26 +0200 Subject: [PATCH 27/33] make bleed linux sig fix --- gamedata/sm-tf2.games.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index d6e15f5a..cc0692c3 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -82,8 +82,8 @@ { "library" "server" "windows" "\x55\x8B\xEC\x83\xEC\x30\x53\x8B\xD9\x89\x5D\xEC" - "linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" - "mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefib" + "linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi" + "mac" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi" } "IsPlayerInDuel" { From 5cf6a0c8758902281dc85606ac14de196206e58c Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 22 Oct 2017 08:37:51 -0400 Subject: [PATCH 28/33] Fix MakeBleed native call (add damage custom param).. --- extensions/tf2/natives.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/tf2/natives.cpp b/extensions/tf2/natives.cpp index 8dedfd04..65c9f142 100644 --- a/extensions/tf2/natives.cpp +++ b/extensions/tf2/natives.cpp @@ -45,7 +45,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) if(!pWrapper) { REGISTER_NATIVE_ADDR("MakeBleed", - PassInfo pass[5]; \ + PassInfo pass[6]; \ pass[0].flags = PASSFLAG_BYVAL; \ pass[0].size = sizeof(CBaseEntity *); \ pass[0].type = PassType_Basic; \ @@ -61,7 +61,10 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) pass[4].flags = PASSFLAG_BYVAL; \ pass[4].size = sizeof(bool); \ pass[4].type = PassType_Basic; \ - pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 5)) + pass[5].flags = PASSFLAG_BYVAL; \ + pass[5].size = sizeof(int); \ + pass[5].type = PassType_Basic; \ + pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 6)) } CBaseEntity *pEntity; @@ -78,7 +81,7 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset); - unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool)]; + unsigned char vstk[sizeof(void *) + 2*sizeof(CBaseEntity *) + sizeof(float) + sizeof(int) + sizeof(bool) + sizeof(int)]; unsigned char *vptr = vstk; *(void **)vptr = obj; @@ -89,9 +92,11 @@ cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params) vptr += sizeof(CBaseEntity *); *(float *)vptr = sp_ctof(params[3]); vptr += sizeof(float); - *(int *)vptr = 4; + *(int *)vptr = 4; // Damage amount vptr += sizeof(int); - *(bool *)vptr = false; + *(bool *)vptr = false; // Permanent + vptr += sizeof(bool); + *(int *)vptr = 34; // Custom Damage type (bleeding) pWrapper->Execute(vstk, NULL); From 858a0ba17d549d8ada182d9c02bc63327f8d3478 Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Tue, 24 Oct 2017 19:16:14 -0700 Subject: [PATCH 29/33] Pin sourcepawn submodule to 1.9-dev --- sourcepawn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sourcepawn b/sourcepawn index 4a17478a..c7834938 160000 --- a/sourcepawn +++ b/sourcepawn @@ -1 +1 @@ -Subproject commit 4a17478ae3c7122205fb495dc14fd34243679bea +Subproject commit c78349382d97d5a9f20b49975c47d9bb805c125d From 373fb4f7760ecbe7fcb6e6284ba049f5b1e280b1 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Thu, 26 Oct 2017 19:36:30 -0500 Subject: [PATCH 30/33] Update amtl to fix macOS build. --- public/amtl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/amtl b/public/amtl index e3a888ea..50dbd2f8 160000 --- a/public/amtl +++ b/public/amtl @@ -1 +1 @@ -Subproject commit e3a888eab7ee73e7fbff9f3e2f0529a87b284d39 +Subproject commit 50dbd2f8f6f13e799037919470064878bd4a3960 From 27b69559a315cc6b0d898130a7082926feb504d0 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Thu, 26 Oct 2017 20:38:25 -0500 Subject: [PATCH 31/33] Really fix macOS build. --- AMBuildScript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index de934810..8b88a5f9 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -219,7 +219,7 @@ class SMConfig(object): have_gcc = cxx.family == 'gcc' have_clang = cxx.family == 'clang' - if cxx.version >= 'clang-3.9' or cxx.version >= 'apple-clang-8.0': + if cxx.version >= 'clang-3.9': cxx.cxxflags += ['-Wno-expansion-to-defined'] if cxx.version == 'clang-3.9' or cxx.version == 'apple-clang-8.0': cxx.cflags += ['-Wno-varargs'] @@ -305,7 +305,7 @@ class SMConfig(object): cxx.linkflags += ['-lgcc_eh'] def configure_mac(self, cxx): - cxx.defines += ['OSX', '_OSX', 'POSIX'] + cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL'] cxx.cflags += ['-mmacosx-version-min=10.5'] cxx.linkflags += [ '-mmacosx-version-min=10.5', From 8807939a14b12d5a66bc1bba3c56369af640ab84 Mon Sep 17 00:00:00 2001 From: JRiipinen Date: Fri, 27 Oct 2017 14:02:38 +0300 Subject: [PATCH 32/33] Update TF2_IsPlayerInCondition (#712) * Update TF2_IsPlayerInCondition * Update conditions too --- extensions/tf2/conditions.cpp | 4 +++- extensions/tf2/conditions.h | 1 + plugins/include/tf2_stocks.inc | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/tf2/conditions.cpp b/extensions/tf2/conditions.cpp index 225df413..d7b74e5c 100644 --- a/extensions/tf2/conditions.cpp +++ b/extensions/tf2/conditions.cpp @@ -143,6 +143,7 @@ PlayerConditionsMgr::PlayerConditionsMgr() m_CondOffset[m_nPlayerCondEx] = 32; m_CondOffset[m_nPlayerCondEx2] = 64; m_CondOffset[m_nPlayerCondEx3] = 96; + m_CondOffset[m_nPlayerCondEx4] = 128; } bool PlayerConditionsMgr::Init() @@ -153,7 +154,8 @@ bool PlayerConditionsMgr::Init() && SetupProp<_condition_bits>("_condition_bits") && SetupProp("m_nPlayerCondEx") && SetupProp("m_nPlayerCondEx2") - && SetupProp("m_nPlayerCondEx3"); + && SetupProp("m_nPlayerCondEx3") + && SetupProp("m_nPlayerCondEx4"); if (!bFoundProps) return false; diff --git a/extensions/tf2/conditions.h b/extensions/tf2/conditions.h index 4aa76091..24404509 100644 --- a/extensions/tf2/conditions.h +++ b/extensions/tf2/conditions.h @@ -52,6 +52,7 @@ public: m_nPlayerCondEx, m_nPlayerCondEx2, m_nPlayerCondEx3, + m_nPlayerCondEx4, CondVar_Count }; diff --git a/plugins/include/tf2_stocks.inc b/plugins/include/tf2_stocks.inc index 9830f696..6b7ae20b 100644 --- a/plugins/include/tf2_stocks.inc +++ b/plugins/include/tf2_stocks.inc @@ -581,6 +581,14 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond) return true; } } + case 4: + { + int bit = (1 << (iCond - 128)); + if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx4") & bit) == bit) + { + return true; + } + } default: ThrowError("Invalid TFCond value %d", iCond); } From 8f6f8819373fe70ac6965f96cd43e2b0e6bf8da6 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 27 Oct 2017 08:03:39 -0400 Subject: [PATCH 33/33] Update tf2 stun and death flags. --- plugins/include/tf2.inc | 1 + plugins/include/tf2_stocks.inc | 1256 ++++++++++++++++---------------- 2 files changed, 630 insertions(+), 627 deletions(-) diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index 4116d0f4..f93d5da5 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -42,6 +42,7 @@ #define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) /**< no sound or particle */ #define TF_STUNFLAG_THIRDPERSON (1 << 6) /**< panic animation */ #define TF_STUNFLAG_GHOSTEFFECT (1 << 7) /**< ghost particles */ +#define TF_STUNFLAG_SOUND (1 << 8) /**< sound */ #define TF_STUNFLAGS_LOSERSTATE TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON #define TF_STUNFLAGS_GHOSTSCARE TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON diff --git a/plugins/include/tf2_stocks.inc b/plugins/include/tf2_stocks.inc index 6b7ae20b..0d68e115 100644 --- a/plugins/include/tf2_stocks.inc +++ b/plugins/include/tf2_stocks.inc @@ -1,586 +1,588 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. - * ============================================================================= - * - * This file is part of the SourceMod/SourcePawn SDK. - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * 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. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - * As a special exception, AlliedModders LLC gives you permission to link the - * code of this program (as well as its derivative works) to "Half-Life 2," the - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software - * by the Valve Corporation. You must obey the GNU General Public License in - * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), - * or . - * - * Version: $Id$ - */ - -#if defined _tf2_stocks_included - #endinput -#endif -#define _tf2_stocks_included - -#include -#include - -#define TF_CONDFLAG_NONE 0 -#define TF_CONDFLAG_SLOWED (1 << 0) -#define TF_CONDFLAG_ZOOMED (1 << 1) -#define TF_CONDFLAG_DISGUISING (1 << 2) -#define TF_CONDFLAG_DISGUISED (1 << 3) -#define TF_CONDFLAG_CLOAKED (1 << 4) -#define TF_CONDFLAG_UBERCHARGED (1 << 5) -#define TF_CONDFLAG_TELEPORTGLOW (1 << 6) -#define TF_CONDFLAG_TAUNTING (1 << 7) -#define TF_CONDFLAG_UBERCHARGEFADE (1 << 8) -#define TF_CONDFLAG_CLOAKFLICKER (1 << 9) -#define TF_CONDFLAG_TELEPORTING (1 << 10) -#define TF_CONDFLAG_KRITZKRIEGED (1 << 11) -#define TF_CONDFLAG_DEADRINGERED (1 << 13) -#define TF_CONDFLAG_BONKED (1 << 14) -#define TF_CONDFLAG_DAZED (1 << 15) -#define TF_CONDFLAG_BUFFED (1 << 16) -#define TF_CONDFLAG_CHARGING (1 << 17) -#define TF_CONDFLAG_DEMOBUFF (1 << 18) -#define TF_CONDFLAG_CRITCOLA (1 << 19) -#define TF_CONDFLAG_INHEALRADIUS (1 << 20) -#define TF_CONDFLAG_HEALING (1 << 21) -#define TF_CONDFLAG_ONFIRE (1 << 22) -#define TF_CONDFLAG_OVERHEALED (1 << 23) -#define TF_CONDFLAG_JARATED (1 << 24) -#define TF_CONDFLAG_BLEEDING (1 << 25) -#define TF_CONDFLAG_DEFENSEBUFFED (1 << 26) -#define TF_CONDFLAG_MILKED (1 << 27) -#define TF_CONDFLAG_MEGAHEAL (1 << 28) -#define TF_CONDFLAG_REGENBUFFED (1 << 29) -#define TF_CONDFLAG_MARKEDFORDEATH (1 << 30) - -#define TF_DEATHFLAG_KILLERDOMINATION (1 << 0) -#define TF_DEATHFLAG_ASSISTERDOMINATION (1 << 1) -#define TF_DEATHFLAG_KILLERREVENGE (1 << 2) -#define TF_DEATHFLAG_ASSISTERREVENGE (1 << 3) -#define TF_DEATHFLAG_FIRSTBLOOD (1 << 4) -#define TF_DEATHFLAG_DEADRINGER (1 << 5) -#define TF_DEATHFLAG_INTERRUPTED (1 << 6) -#define TF_DEATHFLAG_GIBBED (1 << 7) -#define TF_DEATHFLAG_PURGATORY (1 << 8) - -// Custom kill identifiers for the customkill property on the player_death event -enum { - TF_CUSTOM_HEADSHOT = 1, - TF_CUSTOM_BACKSTAB, - TF_CUSTOM_BURNING, - TF_CUSTOM_WRENCH_FIX, - TF_CUSTOM_MINIGUN, - TF_CUSTOM_SUICIDE, - TF_CUSTOM_TAUNT_HADOUKEN, - TF_CUSTOM_BURNING_FLARE, - TF_CUSTOM_TAUNT_HIGH_NOON, - TF_CUSTOM_TAUNT_GRAND_SLAM, - TF_CUSTOM_PENETRATE_MY_TEAM, - TF_CUSTOM_PENETRATE_ALL_PLAYERS, - TF_CUSTOM_TAUNT_FENCING, - TF_CUSTOM_PENETRATE_HEADSHOT, - TF_CUSTOM_TAUNT_ARROW_STAB, - TF_CUSTOM_TELEFRAG, - TF_CUSTOM_BURNING_ARROW, - TF_CUSTOM_FLYINGBURN, - TF_CUSTOM_PUMPKIN_BOMB, - TF_CUSTOM_DECAPITATION, - TF_CUSTOM_TAUNT_GRENADE, - TF_CUSTOM_BASEBALL, - TF_CUSTOM_CHARGE_IMPACT, - TF_CUSTOM_TAUNT_BARBARIAN_SWING, - TF_CUSTOM_AIR_STICKY_BURST, - TF_CUSTOM_DEFENSIVE_STICKY, - TF_CUSTOM_PICKAXE, - TF_CUSTOM_ROCKET_DIRECTHIT, - TF_CUSTOM_TAUNT_UBERSLICE, - TF_CUSTOM_PLAYER_SENTRY, - TF_CUSTOM_STANDARD_STICKY, - TF_CUSTOM_SHOTGUN_REVENGE_CRIT, - TF_CUSTOM_TAUNT_ENGINEER_SMASH, - TF_CUSTOM_BLEEDING, - TF_CUSTOM_GOLD_WRENCH, - TF_CUSTOM_CARRIED_BUILDING, - TF_CUSTOM_COMBO_PUNCH, - TF_CUSTOM_TAUNT_ENGINEER_ARM, - TF_CUSTOM_FISH_KILL, - TF_CUSTOM_TRIGGER_HURT, - TF_CUSTOM_DECAPITATION_BOSS, - TF_CUSTOM_STICKBOMB_EXPLOSION, - TF_CUSTOM_AEGIS_ROUND, - TF_CUSTOM_FLARE_EXPLOSION, - TF_CUSTOM_BOOTS_STOMP, - TF_CUSTOM_PLASMA, - TF_CUSTOM_PLASMA_CHARGED, - TF_CUSTOM_PLASMA_GIB, - TF_CUSTOM_PRACTICE_STICKY, - TF_CUSTOM_EYEBALL_ROCKET, - TF_CUSTOM_HEADSHOT_DECAPITATION, - TF_CUSTOM_TAUNT_ARMAGEDDON, - TF_CUSTOM_FLARE_PELLET, - TF_CUSTOM_CLEAVER, - TF_CUSTOM_CLEAVER_CRIT, - TF_CUSTOM_SAPPER_RECORDER_DEATH, - TF_CUSTOM_MERASMUS_PLAYER_BOMB, - TF_CUSTOM_MERASMUS_GRENADE, - TF_CUSTOM_MERASMUS_ZAP, - TF_CUSTOM_MERASMUS_DECAPITATION, - TF_CUSTOM_CANNONBALL_PUSH, - TF_CUSTOM_TAUNT_ALLCLASS_GUITAR_RIFF, - TF_CUSTOM_THROWABLE, - TF_CUSTOM_THROWABLE_KILL, - TF_CUSTOM_SPELL_TELEPORT, - TF_CUSTOM_SPELL_SKELETON, - TF_CUSTOM_SPELL_MIRV, - TF_CUSTOM_SPELL_METEOR, - TF_CUSTOM_SPELL_LIGHTNING, - TF_CUSTOM_SPELL_FIREBALL, - TF_CUSTOM_SPELL_MONOCULUS, - TF_CUSTOM_SPELL_BLASTJUMP, - TF_CUSTOM_SPELL_BATS, - TF_CUSTOM_SPELL_TINY, - TF_CUSTOM_KART, - TF_CUSTOM_GIANT_HAMMER, - TF_CUSTOM_RUNE_REFLECT, - TF_CUSTOM_DRAGONS_FURY_IGNITE, - TF_CUSTOM_DRAGONS_FURY_BONUS_BURNING, - TF_CUSTOM_SLAP_KILL, - TF_CUSTOM_CROC, - TF_CUSTOM_TAUNTATK_GASBLAST, -}; - -// Weapon codes as used in some events, such as player_death -// (not to be confused with Item Definition Indexes) -enum { - TF_WEAPON_NONE = 0, - TF_WEAPON_BAT, - TF_WEAPON_BAT_WOOD, - TF_WEAPON_BOTTLE, - TF_WEAPON_FIREAXE, - TF_WEAPON_CLUB, - TF_WEAPON_CROWBAR, - TF_WEAPON_KNIFE, - TF_WEAPON_FISTS, - TF_WEAPON_SHOVEL, - TF_WEAPON_WRENCH, - TF_WEAPON_BONESAW, - TF_WEAPON_SHOTGUN_PRIMARY, - TF_WEAPON_SHOTGUN_SOLDIER, - TF_WEAPON_SHOTGUN_HWG, - TF_WEAPON_SHOTGUN_PYRO, - TF_WEAPON_SCATTERGUN, - TF_WEAPON_SNIPERRIFLE, - TF_WEAPON_MINIGUN, - TF_WEAPON_SMG, - TF_WEAPON_SYRINGEGUN_MEDIC, - TF_WEAPON_TRANQ, - TF_WEAPON_ROCKETLAUNCHER, - TF_WEAPON_GRENADELAUNCHER, - TF_WEAPON_PIPEBOMBLAUNCHER, - TF_WEAPON_FLAMETHROWER, - TF_WEAPON_GRENADE_NORMAL, - TF_WEAPON_GRENADE_CONCUSSION, - TF_WEAPON_GRENADE_NAIL, - TF_WEAPON_GRENADE_MIRV, - TF_WEAPON_GRENADE_MIRV_DEMOMAN, - TF_WEAPON_GRENADE_NAPALM, - TF_WEAPON_GRENADE_GAS, - TF_WEAPON_GRENADE_EMP, - TF_WEAPON_GRENADE_CALTROP, - TF_WEAPON_GRENADE_PIPEBOMB, - TF_WEAPON_GRENADE_SMOKE_BOMB, - TF_WEAPON_GRENADE_HEAL, - TF_WEAPON_GRENADE_STUNBALL, - TF_WEAPON_GRENADE_JAR, - TF_WEAPON_GRENADE_JAR_MILK, - TF_WEAPON_PISTOL, - TF_WEAPON_PISTOL_SCOUT, - TF_WEAPON_REVOLVER, - TF_WEAPON_NAILGUN, - TF_WEAPON_PDA, - TF_WEAPON_PDA_ENGINEER_BUILD, - TF_WEAPON_PDA_ENGINEER_DESTROY, - TF_WEAPON_PDA_SPY, - TF_WEAPON_BUILDER, - TF_WEAPON_MEDIGUN, - TF_WEAPON_GRENADE_MIRVBOMB, - TF_WEAPON_FLAMETHROWER_ROCKET, - TF_WEAPON_GRENADE_DEMOMAN, - TF_WEAPON_SENTRY_BULLET, - TF_WEAPON_SENTRY_ROCKET, - TF_WEAPON_DISPENSER, - TF_WEAPON_INVIS, - TF_WEAPON_FLAREGUN, - TF_WEAPON_LUNCHBOX, - TF_WEAPON_JAR, - TF_WEAPON_COMPOUND_BOW, - TF_WEAPON_BUFF_ITEM, - TF_WEAPON_PUMPKIN_BOMB, - TF_WEAPON_SWORD, - TF_WEAPON_DIRECTHIT, - TF_WEAPON_LIFELINE, - TF_WEAPON_LASER_POINTER, - TF_WEAPON_DISPENSER_GUN, - TF_WEAPON_SENTRY_REVENGE, - TF_WEAPON_JAR_MILK, - TF_WEAPON_HANDGUN_SCOUT_PRIMARY, - TF_WEAPON_BAT_FISH, - TF_WEAPON_CROSSBOW, - TF_WEAPON_STICKBOMB, - TF_WEAPON_HANDGUN_SCOUT_SEC, - TF_WEAPON_SODA_POPPER, - TF_WEAPON_SNIPERRIFLE_DECAP, - TF_WEAPON_RAYGUN, - TF_WEAPON_PARTICLE_CANNON, - TF_WEAPON_MECHANICAL_ARM, - TF_WEAPON_DRG_POMSON, - TF_WEAPON_BAT_GIFTWRAP, - TF_WEAPON_GRENADE_ORNAMENT, - TF_WEAPON_RAYGUN_REVENGE, - TF_WEAPON_PEP_BRAWLER_BLASTER, - TF_WEAPON_CLEAVER, - TF_WEAPON_GRENADE_CLEAVER, - TF_WEAPON_STICKY_BALL_LAUNCHER, - TF_WEAPON_GRENADE_STICKY_BALL, - TF_WEAPON_SHOTGUN_BUILDING_RESCUE, - TF_WEAPON_CANNON, - TF_WEAPON_THROWABLE, - TF_WEAPON_GRENADE_THROWABLE, - TF_WEAPON_PDA_SPY_BUILD, - TF_WEAPON_GRENADE_WATERBALLOON, - TF_WEAPON_HARVESTER_SAW, - TF_WEAPON_SPELLBOOK, - TF_WEAPON_SPELLBOOK_PROJECTILE, - TF_WEAPON_SNIPERRIFLE_CLASSIC, - TF_WEAPON_PARACHUTE, - TF_WEAPON_GRAPPLINGHOOK, - TF_WEAPON_PASSTIME_GUN, - TF_WEAPON_CHARGED_SMG, - TF_WEAPON_BREAKABLE_SIGN, - TF_WEAPON_ROCKETPACK, - TF_WEAPON_SLAP, - TF_WEAPON_JAR_GAS, - TF_WEAPON_GRENADE_JAR_GAS, - TF_WEAPON_FLAME_BALL, -}; - -// TF2 Weapon Loadout Slots -enum -{ - TFWeaponSlot_Primary, - TFWeaponSlot_Secondary, - TFWeaponSlot_Melee, - TFWeaponSlot_Grenade, - TFWeaponSlot_Building, - TFWeaponSlot_PDA, - TFWeaponSlot_Item1, - TFWeaponSlot_Item2 -}; - -// Identifiers for the eventtype property on the teamplay_flag_event event -enum { - TF_FLAGEVENT_PICKEDUP = 1, - TF_FLAGEVENT_CAPTURED, - TF_FLAGEVENT_DEFENDED, - TF_FLAGEVENT_DROPPED, - TF_FLAGEVENT_RETURNED -}; - -enum TFResourceType -{ - TFResource_Ping, - TFResource_Score, - TFResource_Deaths, - TFResource_TotalScore, - TFResource_Captures, - TFResource_Defenses, - TFResource_Dominations, - TFResource_Revenge, - TFResource_BuildingsDestroyed, - TFResource_Headshots, - TFResource_Backstabs, - TFResource_HealPoints, - TFResource_Invulns, - TFResource_Teleports, - TFResource_ResupplyPoints, - TFResource_KillAssists, - TFResource_MaxHealth, - TFResource_PlayerClass -}; - -static const char TFResourceNames[TFResourceType][] = -{ - "m_iPing", - "m_iScore", - "m_iDeaths", - "m_iTotalScore", - "m_iCaptures", - "m_iDefenses", - "m_iDominations", - "m_iRevenge", - "m_iBuildingsDestroyed", - "m_iHeadshots", - "m_iBackstabs", - "m_iHealPoints", - "m_iInvulns", - "m_iTeleports", - "m_iResupplyPoints", - "m_iKillAssists", - "m_iMaxHealth", - "m_iPlayerClass" -}; - -/** - * Gets a client's current team. - * - * @param client Client index. - * @return Current TFTeam of client. - * @error Invalid client index. - */ -stock TFTeam TF2_GetClientTeam(int client) -{ - return view_as(GetClientTeam(client)); -} - -/** - * Changes a client's current team. - * - * @param client Client index. - * @param team TFTeam team symbol. - * @error Invalid client index. - */ -stock void TF2_ChangeClientTeam(int client, TFTeam team) -{ - ChangeClientTeam(client, view_as(team)); -} - -/** - * Gets a client's current class. - * - * @param client Player's index. - * @return Current TFClassType of player. - * @error Invalid client index. - */ -stock TFClassType TF2_GetPlayerClass(int client) -{ - return view_as(GetEntProp(client, Prop_Send, "m_iClass")); -} - -/** - * Sets a client's class. - * - * Note: If setting player class in a player spawn hook weapons should be set to false. - * - * @param client Player's index. - * @param classType TFClassType class symbol. - * @param weapons This parameter is ignored. - * @param persistent If true, changes the player's desired class so the change stays after death. - * @error Invalid client index. - */ -stock void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons=true, bool persistent=true) -{ - SetEntProp(client, Prop_Send, "m_iClass", view_as(classType)); - - if (persistent) - { - SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", view_as(classType)); - } -} - -/** - * Retrieves client data from the resource entity - * - * @param client Player's index. - * @param type ResourceType constant - * @return Value or -1 on failure. - * @error Invalid client index, client not in game or failed to find resource entity. - */ -#pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead -stock int TF2_GetPlayerResourceData(int client, TFResourceType type) -{ - if (!IsClientConnected(client)) - { - return -1; - } - - int offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); - - if (offset < 1) - { - return -1; - } - - int entity = TF2_GetResourceEntity(); - - if (entity == -1) - { - return -1; - } - - return GetEntData(entity, offset + (client*4)); -} - -/** - * Sets client data in the resource entity - * - * Note: The game overwrites these values every frame, so changing them will have very little effect. - * - * @param client Player's index. - * @param type ResourceType constant - * @param value Value to set. - * @return Value or -1 on failure. - * @error Invalid client index, client not in game or failed to find resource entity. - */ -#pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead -stock bool TF2_SetPlayerResourceData(int client, TFResourceType type, any value) -{ - if (!IsClientConnected(client)) - { - return false; - } - - int offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); - - if (offset < 1) - { - return false; - } - - int entity = TF2_GetResourceEntity(); - - if (entity == -1) - { - return false; - } - - SetEntData(entity, offset + (client*4), value); - - return true; -} - -/** - * Removes all weapons from a client's weapon slot - * - * @param client Player's index. - * @param slot Slot index (0-5) - * @error Invalid client, invalid slot or lack of mod support - */ -stock void TF2_RemoveWeaponSlot(int client, int slot) -{ - int weaponIndex; - while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1) - { - // bug #6206 - // papering over a valve bug where a weapon's extra wearables aren't properly removed from the weapon's owner - int extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearable"); - if (extraWearable != -1) - { - TF2_RemoveWearable(client, extraWearable); - } - - extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearableViewModel"); - if (extraWearable != -1) - { - TF2_RemoveWearable(client, extraWearable); - } - - RemovePlayerItem(client, weaponIndex); - AcceptEntityInput(weaponIndex, "Kill"); - } -} - -/** - * Removes all weapons from a client - * - * @param client Player's index. - */ -stock void TF2_RemoveAllWeapons(int client) -{ - for (int i = 0; i <= 5; i++) - { - TF2_RemoveWeaponSlot(client, i); - } -} - -/** - * Gets a player's condition bits - * - * @param client Player's index. - * @return Player's condition bits - */ -#pragma deprecated Use TF2_IsPlayerInCondition instead. -stock int TF2_GetPlayerConditionFlags(int client) -{ - return GetEntProp(client, Prop_Send, "m_nPlayerCond")|GetEntProp(client, Prop_Send, "_condition_bits"); -} - -/** - * Check whether or not a condition is set on a player - * - * @param client Player's index. - * @param cond TFCond constant - * @return True if set, false otherwise - */ -stock bool TF2_IsPlayerInCondition(int client, TFCond cond) -{ - // Conditions are stored across multiple netprops now, one for each 32-bit segment. - int iCond = view_as(cond); - switch (iCond / 32) - { - case 0: - { - int bit = 1 << iCond; - if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit) - { - return true; - } - - if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit) - { - return true; - } - } - case 1: - { - int bit = (1 << (iCond - 32)); - if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit) - { - return true; - } - } - case 2: - { - int bit = (1 << (iCond - 64)); - if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit) - { - return true; - } - } - case 3: - { - int bit = (1 << (iCond - 96)); - if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit) - { - return true; - } - } +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#if defined _tf2_stocks_included + #endinput +#endif +#define _tf2_stocks_included + +#include +#include + +#define TF_CONDFLAG_NONE 0 +#define TF_CONDFLAG_SLOWED (1 << 0) +#define TF_CONDFLAG_ZOOMED (1 << 1) +#define TF_CONDFLAG_DISGUISING (1 << 2) +#define TF_CONDFLAG_DISGUISED (1 << 3) +#define TF_CONDFLAG_CLOAKED (1 << 4) +#define TF_CONDFLAG_UBERCHARGED (1 << 5) +#define TF_CONDFLAG_TELEPORTGLOW (1 << 6) +#define TF_CONDFLAG_TAUNTING (1 << 7) +#define TF_CONDFLAG_UBERCHARGEFADE (1 << 8) +#define TF_CONDFLAG_CLOAKFLICKER (1 << 9) +#define TF_CONDFLAG_TELEPORTING (1 << 10) +#define TF_CONDFLAG_KRITZKRIEGED (1 << 11) +#define TF_CONDFLAG_DEADRINGERED (1 << 13) +#define TF_CONDFLAG_BONKED (1 << 14) +#define TF_CONDFLAG_DAZED (1 << 15) +#define TF_CONDFLAG_BUFFED (1 << 16) +#define TF_CONDFLAG_CHARGING (1 << 17) +#define TF_CONDFLAG_DEMOBUFF (1 << 18) +#define TF_CONDFLAG_CRITCOLA (1 << 19) +#define TF_CONDFLAG_INHEALRADIUS (1 << 20) +#define TF_CONDFLAG_HEALING (1 << 21) +#define TF_CONDFLAG_ONFIRE (1 << 22) +#define TF_CONDFLAG_OVERHEALED (1 << 23) +#define TF_CONDFLAG_JARATED (1 << 24) +#define TF_CONDFLAG_BLEEDING (1 << 25) +#define TF_CONDFLAG_DEFENSEBUFFED (1 << 26) +#define TF_CONDFLAG_MILKED (1 << 27) +#define TF_CONDFLAG_MEGAHEAL (1 << 28) +#define TF_CONDFLAG_REGENBUFFED (1 << 29) +#define TF_CONDFLAG_MARKEDFORDEATH (1 << 30) + +#define TF_DEATHFLAG_KILLERDOMINATION (1 << 0) +#define TF_DEATHFLAG_ASSISTERDOMINATION (1 << 1) +#define TF_DEATHFLAG_KILLERREVENGE (1 << 2) +#define TF_DEATHFLAG_ASSISTERREVENGE (1 << 3) +#define TF_DEATHFLAG_FIRSTBLOOD (1 << 4) +#define TF_DEATHFLAG_DEADRINGER (1 << 5) +#define TF_DEATHFLAG_INTERRUPTED (1 << 6) +#define TF_DEATHFLAG_GIBBED (1 << 7) +#define TF_DEATHFLAG_PURGATORY (1 << 8) +#define TF_DEATHFLAG_MINIBOSS (1 << 9) +#define TF_DEATHFLAG_AUSTRALIUM (1 << 10) + +// Custom kill identifiers for the customkill property on the player_death event +enum { + TF_CUSTOM_HEADSHOT = 1, + TF_CUSTOM_BACKSTAB, + TF_CUSTOM_BURNING, + TF_CUSTOM_WRENCH_FIX, + TF_CUSTOM_MINIGUN, + TF_CUSTOM_SUICIDE, + TF_CUSTOM_TAUNT_HADOUKEN, + TF_CUSTOM_BURNING_FLARE, + TF_CUSTOM_TAUNT_HIGH_NOON, + TF_CUSTOM_TAUNT_GRAND_SLAM, + TF_CUSTOM_PENETRATE_MY_TEAM, + TF_CUSTOM_PENETRATE_ALL_PLAYERS, + TF_CUSTOM_TAUNT_FENCING, + TF_CUSTOM_PENETRATE_HEADSHOT, + TF_CUSTOM_TAUNT_ARROW_STAB, + TF_CUSTOM_TELEFRAG, + TF_CUSTOM_BURNING_ARROW, + TF_CUSTOM_FLYINGBURN, + TF_CUSTOM_PUMPKIN_BOMB, + TF_CUSTOM_DECAPITATION, + TF_CUSTOM_TAUNT_GRENADE, + TF_CUSTOM_BASEBALL, + TF_CUSTOM_CHARGE_IMPACT, + TF_CUSTOM_TAUNT_BARBARIAN_SWING, + TF_CUSTOM_AIR_STICKY_BURST, + TF_CUSTOM_DEFENSIVE_STICKY, + TF_CUSTOM_PICKAXE, + TF_CUSTOM_ROCKET_DIRECTHIT, + TF_CUSTOM_TAUNT_UBERSLICE, + TF_CUSTOM_PLAYER_SENTRY, + TF_CUSTOM_STANDARD_STICKY, + TF_CUSTOM_SHOTGUN_REVENGE_CRIT, + TF_CUSTOM_TAUNT_ENGINEER_SMASH, + TF_CUSTOM_BLEEDING, + TF_CUSTOM_GOLD_WRENCH, + TF_CUSTOM_CARRIED_BUILDING, + TF_CUSTOM_COMBO_PUNCH, + TF_CUSTOM_TAUNT_ENGINEER_ARM, + TF_CUSTOM_FISH_KILL, + TF_CUSTOM_TRIGGER_HURT, + TF_CUSTOM_DECAPITATION_BOSS, + TF_CUSTOM_STICKBOMB_EXPLOSION, + TF_CUSTOM_AEGIS_ROUND, + TF_CUSTOM_FLARE_EXPLOSION, + TF_CUSTOM_BOOTS_STOMP, + TF_CUSTOM_PLASMA, + TF_CUSTOM_PLASMA_CHARGED, + TF_CUSTOM_PLASMA_GIB, + TF_CUSTOM_PRACTICE_STICKY, + TF_CUSTOM_EYEBALL_ROCKET, + TF_CUSTOM_HEADSHOT_DECAPITATION, + TF_CUSTOM_TAUNT_ARMAGEDDON, + TF_CUSTOM_FLARE_PELLET, + TF_CUSTOM_CLEAVER, + TF_CUSTOM_CLEAVER_CRIT, + TF_CUSTOM_SAPPER_RECORDER_DEATH, + TF_CUSTOM_MERASMUS_PLAYER_BOMB, + TF_CUSTOM_MERASMUS_GRENADE, + TF_CUSTOM_MERASMUS_ZAP, + TF_CUSTOM_MERASMUS_DECAPITATION, + TF_CUSTOM_CANNONBALL_PUSH, + TF_CUSTOM_TAUNT_ALLCLASS_GUITAR_RIFF, + TF_CUSTOM_THROWABLE, + TF_CUSTOM_THROWABLE_KILL, + TF_CUSTOM_SPELL_TELEPORT, + TF_CUSTOM_SPELL_SKELETON, + TF_CUSTOM_SPELL_MIRV, + TF_CUSTOM_SPELL_METEOR, + TF_CUSTOM_SPELL_LIGHTNING, + TF_CUSTOM_SPELL_FIREBALL, + TF_CUSTOM_SPELL_MONOCULUS, + TF_CUSTOM_SPELL_BLASTJUMP, + TF_CUSTOM_SPELL_BATS, + TF_CUSTOM_SPELL_TINY, + TF_CUSTOM_KART, + TF_CUSTOM_GIANT_HAMMER, + TF_CUSTOM_RUNE_REFLECT, + TF_CUSTOM_DRAGONS_FURY_IGNITE, + TF_CUSTOM_DRAGONS_FURY_BONUS_BURNING, + TF_CUSTOM_SLAP_KILL, + TF_CUSTOM_CROC, + TF_CUSTOM_TAUNTATK_GASBLAST, +}; + +// Weapon codes as used in some events, such as player_death +// (not to be confused with Item Definition Indexes) +enum { + TF_WEAPON_NONE = 0, + TF_WEAPON_BAT, + TF_WEAPON_BAT_WOOD, + TF_WEAPON_BOTTLE, + TF_WEAPON_FIREAXE, + TF_WEAPON_CLUB, + TF_WEAPON_CROWBAR, + TF_WEAPON_KNIFE, + TF_WEAPON_FISTS, + TF_WEAPON_SHOVEL, + TF_WEAPON_WRENCH, + TF_WEAPON_BONESAW, + TF_WEAPON_SHOTGUN_PRIMARY, + TF_WEAPON_SHOTGUN_SOLDIER, + TF_WEAPON_SHOTGUN_HWG, + TF_WEAPON_SHOTGUN_PYRO, + TF_WEAPON_SCATTERGUN, + TF_WEAPON_SNIPERRIFLE, + TF_WEAPON_MINIGUN, + TF_WEAPON_SMG, + TF_WEAPON_SYRINGEGUN_MEDIC, + TF_WEAPON_TRANQ, + TF_WEAPON_ROCKETLAUNCHER, + TF_WEAPON_GRENADELAUNCHER, + TF_WEAPON_PIPEBOMBLAUNCHER, + TF_WEAPON_FLAMETHROWER, + TF_WEAPON_GRENADE_NORMAL, + TF_WEAPON_GRENADE_CONCUSSION, + TF_WEAPON_GRENADE_NAIL, + TF_WEAPON_GRENADE_MIRV, + TF_WEAPON_GRENADE_MIRV_DEMOMAN, + TF_WEAPON_GRENADE_NAPALM, + TF_WEAPON_GRENADE_GAS, + TF_WEAPON_GRENADE_EMP, + TF_WEAPON_GRENADE_CALTROP, + TF_WEAPON_GRENADE_PIPEBOMB, + TF_WEAPON_GRENADE_SMOKE_BOMB, + TF_WEAPON_GRENADE_HEAL, + TF_WEAPON_GRENADE_STUNBALL, + TF_WEAPON_GRENADE_JAR, + TF_WEAPON_GRENADE_JAR_MILK, + TF_WEAPON_PISTOL, + TF_WEAPON_PISTOL_SCOUT, + TF_WEAPON_REVOLVER, + TF_WEAPON_NAILGUN, + TF_WEAPON_PDA, + TF_WEAPON_PDA_ENGINEER_BUILD, + TF_WEAPON_PDA_ENGINEER_DESTROY, + TF_WEAPON_PDA_SPY, + TF_WEAPON_BUILDER, + TF_WEAPON_MEDIGUN, + TF_WEAPON_GRENADE_MIRVBOMB, + TF_WEAPON_FLAMETHROWER_ROCKET, + TF_WEAPON_GRENADE_DEMOMAN, + TF_WEAPON_SENTRY_BULLET, + TF_WEAPON_SENTRY_ROCKET, + TF_WEAPON_DISPENSER, + TF_WEAPON_INVIS, + TF_WEAPON_FLAREGUN, + TF_WEAPON_LUNCHBOX, + TF_WEAPON_JAR, + TF_WEAPON_COMPOUND_BOW, + TF_WEAPON_BUFF_ITEM, + TF_WEAPON_PUMPKIN_BOMB, + TF_WEAPON_SWORD, + TF_WEAPON_DIRECTHIT, + TF_WEAPON_LIFELINE, + TF_WEAPON_LASER_POINTER, + TF_WEAPON_DISPENSER_GUN, + TF_WEAPON_SENTRY_REVENGE, + TF_WEAPON_JAR_MILK, + TF_WEAPON_HANDGUN_SCOUT_PRIMARY, + TF_WEAPON_BAT_FISH, + TF_WEAPON_CROSSBOW, + TF_WEAPON_STICKBOMB, + TF_WEAPON_HANDGUN_SCOUT_SEC, + TF_WEAPON_SODA_POPPER, + TF_WEAPON_SNIPERRIFLE_DECAP, + TF_WEAPON_RAYGUN, + TF_WEAPON_PARTICLE_CANNON, + TF_WEAPON_MECHANICAL_ARM, + TF_WEAPON_DRG_POMSON, + TF_WEAPON_BAT_GIFTWRAP, + TF_WEAPON_GRENADE_ORNAMENT, + TF_WEAPON_RAYGUN_REVENGE, + TF_WEAPON_PEP_BRAWLER_BLASTER, + TF_WEAPON_CLEAVER, + TF_WEAPON_GRENADE_CLEAVER, + TF_WEAPON_STICKY_BALL_LAUNCHER, + TF_WEAPON_GRENADE_STICKY_BALL, + TF_WEAPON_SHOTGUN_BUILDING_RESCUE, + TF_WEAPON_CANNON, + TF_WEAPON_THROWABLE, + TF_WEAPON_GRENADE_THROWABLE, + TF_WEAPON_PDA_SPY_BUILD, + TF_WEAPON_GRENADE_WATERBALLOON, + TF_WEAPON_HARVESTER_SAW, + TF_WEAPON_SPELLBOOK, + TF_WEAPON_SPELLBOOK_PROJECTILE, + TF_WEAPON_SNIPERRIFLE_CLASSIC, + TF_WEAPON_PARACHUTE, + TF_WEAPON_GRAPPLINGHOOK, + TF_WEAPON_PASSTIME_GUN, + TF_WEAPON_CHARGED_SMG, + TF_WEAPON_BREAKABLE_SIGN, + TF_WEAPON_ROCKETPACK, + TF_WEAPON_SLAP, + TF_WEAPON_JAR_GAS, + TF_WEAPON_GRENADE_JAR_GAS, + TF_WEAPON_FLAME_BALL, +}; + +// TF2 Weapon Loadout Slots +enum +{ + TFWeaponSlot_Primary, + TFWeaponSlot_Secondary, + TFWeaponSlot_Melee, + TFWeaponSlot_Grenade, + TFWeaponSlot_Building, + TFWeaponSlot_PDA, + TFWeaponSlot_Item1, + TFWeaponSlot_Item2 +}; + +// Identifiers for the eventtype property on the teamplay_flag_event event +enum { + TF_FLAGEVENT_PICKEDUP = 1, + TF_FLAGEVENT_CAPTURED, + TF_FLAGEVENT_DEFENDED, + TF_FLAGEVENT_DROPPED, + TF_FLAGEVENT_RETURNED +}; + +enum TFResourceType +{ + TFResource_Ping, + TFResource_Score, + TFResource_Deaths, + TFResource_TotalScore, + TFResource_Captures, + TFResource_Defenses, + TFResource_Dominations, + TFResource_Revenge, + TFResource_BuildingsDestroyed, + TFResource_Headshots, + TFResource_Backstabs, + TFResource_HealPoints, + TFResource_Invulns, + TFResource_Teleports, + TFResource_ResupplyPoints, + TFResource_KillAssists, + TFResource_MaxHealth, + TFResource_PlayerClass +}; + +static const char TFResourceNames[TFResourceType][] = +{ + "m_iPing", + "m_iScore", + "m_iDeaths", + "m_iTotalScore", + "m_iCaptures", + "m_iDefenses", + "m_iDominations", + "m_iRevenge", + "m_iBuildingsDestroyed", + "m_iHeadshots", + "m_iBackstabs", + "m_iHealPoints", + "m_iInvulns", + "m_iTeleports", + "m_iResupplyPoints", + "m_iKillAssists", + "m_iMaxHealth", + "m_iPlayerClass" +}; + +/** + * Gets a client's current team. + * + * @param client Client index. + * @return Current TFTeam of client. + * @error Invalid client index. + */ +stock TFTeam TF2_GetClientTeam(int client) +{ + return view_as(GetClientTeam(client)); +} + +/** + * Changes a client's current team. + * + * @param client Client index. + * @param team TFTeam team symbol. + * @error Invalid client index. + */ +stock void TF2_ChangeClientTeam(int client, TFTeam team) +{ + ChangeClientTeam(client, view_as(team)); +} + +/** + * Gets a client's current class. + * + * @param client Player's index. + * @return Current TFClassType of player. + * @error Invalid client index. + */ +stock TFClassType TF2_GetPlayerClass(int client) +{ + return view_as(GetEntProp(client, Prop_Send, "m_iClass")); +} + +/** + * Sets a client's class. + * + * Note: If setting player class in a player spawn hook weapons should be set to false. + * + * @param client Player's index. + * @param classType TFClassType class symbol. + * @param weapons This parameter is ignored. + * @param persistent If true, changes the player's desired class so the change stays after death. + * @error Invalid client index. + */ +stock void TF2_SetPlayerClass(int client, TFClassType classType, bool weapons=true, bool persistent=true) +{ + SetEntProp(client, Prop_Send, "m_iClass", view_as(classType)); + + if (persistent) + { + SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", view_as(classType)); + } +} + +/** + * Retrieves client data from the resource entity + * + * @param client Player's index. + * @param type ResourceType constant + * @return Value or -1 on failure. + * @error Invalid client index, client not in game or failed to find resource entity. + */ +#pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead +stock int TF2_GetPlayerResourceData(int client, TFResourceType type) +{ + if (!IsClientConnected(client)) + { + return -1; + } + + int offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); + + if (offset < 1) + { + return -1; + } + + int entity = TF2_GetResourceEntity(); + + if (entity == -1) + { + return -1; + } + + return GetEntData(entity, offset + (client*4)); +} + +/** + * Sets client data in the resource entity + * + * Note: The game overwrites these values every frame, so changing them will have very little effect. + * + * @param client Player's index. + * @param type ResourceType constant + * @param value Value to set. + * @return Value or -1 on failure. + * @error Invalid client index, client not in game or failed to find resource entity. + */ +#pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead +stock bool TF2_SetPlayerResourceData(int client, TFResourceType type, any value) +{ + if (!IsClientConnected(client)) + { + return false; + } + + int offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]); + + if (offset < 1) + { + return false; + } + + int entity = TF2_GetResourceEntity(); + + if (entity == -1) + { + return false; + } + + SetEntData(entity, offset + (client*4), value); + + return true; +} + +/** + * Removes all weapons from a client's weapon slot + * + * @param client Player's index. + * @param slot Slot index (0-5) + * @error Invalid client, invalid slot or lack of mod support + */ +stock void TF2_RemoveWeaponSlot(int client, int slot) +{ + int weaponIndex; + while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1) + { + // bug #6206 + // papering over a valve bug where a weapon's extra wearables aren't properly removed from the weapon's owner + int extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearable"); + if (extraWearable != -1) + { + TF2_RemoveWearable(client, extraWearable); + } + + extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearableViewModel"); + if (extraWearable != -1) + { + TF2_RemoveWearable(client, extraWearable); + } + + RemovePlayerItem(client, weaponIndex); + AcceptEntityInput(weaponIndex, "Kill"); + } +} + +/** + * Removes all weapons from a client + * + * @param client Player's index. + */ +stock void TF2_RemoveAllWeapons(int client) +{ + for (int i = 0; i <= 5; i++) + { + TF2_RemoveWeaponSlot(client, i); + } +} + +/** + * Gets a player's condition bits + * + * @param client Player's index. + * @return Player's condition bits + */ +#pragma deprecated Use TF2_IsPlayerInCondition instead. +stock int TF2_GetPlayerConditionFlags(int client) +{ + return GetEntProp(client, Prop_Send, "m_nPlayerCond")|GetEntProp(client, Prop_Send, "_condition_bits"); +} + +/** + * Check whether or not a condition is set on a player + * + * @param client Player's index. + * @param cond TFCond constant + * @return True if set, false otherwise + */ +stock bool TF2_IsPlayerInCondition(int client, TFCond cond) +{ + // Conditions are stored across multiple netprops now, one for each 32-bit segment. + int iCond = view_as(cond); + switch (iCond / 32) + { + case 0: + { + int bit = 1 << iCond; + if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit) + { + return true; + } + + if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit) + { + return true; + } + } + case 1: + { + int bit = (1 << (iCond - 32)); + if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit) + { + return true; + } + } + case 2: + { + int bit = (1 << (iCond - 64)); + if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit) + { + return true; + } + } + case 3: + { + int bit = (1 << (iCond - 96)); + if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit) + { + return true; + } + } case 4: { int bit = (1 << (iCond - 128)); @@ -589,47 +591,47 @@ stock bool TF2_IsPlayerInCondition(int client, TFCond cond) return true; } } - default: - ThrowError("Invalid TFCond value %d", iCond); - } - - return false; -} - -/** - * Gets an entity's object type. - * - * @param entity Entity index. - * @return Current TFObjectType of entity. - * @error Invalid entity index. - */ -stock TFObjectType TF2_GetObjectType(int entity) -{ - int offset = GetEntSendPropOffs(entity, "m_iObjectType"); - - if (offset <= 0) - { - ThrowError("Entity index %d is not an object", entity); - } - - return view_as(GetEntData(entity, offset)); -} - -/** - * Gets an entity's object mode. - * - * @param entity Entity index. - * @return Current TFObjectMode of entity. - * @error Invalid entity index. - */ -stock TFObjectMode TF2_GetObjectMode(int entity) -{ - int offset = GetEntSendPropOffs(entity, "m_iObjectMode"); - - if (offset <= 0) - { - ThrowError("Entity index %d is not an object", entity); - } - - return view_as(GetEntData(entity, offset)); -} + default: + ThrowError("Invalid TFCond value %d", iCond); + } + + return false; +} + +/** + * Gets an entity's object type. + * + * @param entity Entity index. + * @return Current TFObjectType of entity. + * @error Invalid entity index. + */ +stock TFObjectType TF2_GetObjectType(int entity) +{ + int offset = GetEntSendPropOffs(entity, "m_iObjectType"); + + if (offset <= 0) + { + ThrowError("Entity index %d is not an object", entity); + } + + return view_as(GetEntData(entity, offset)); +} + +/** + * Gets an entity's object mode. + * + * @param entity Entity index. + * @return Current TFObjectMode of entity. + * @error Invalid entity index. + */ +stock TFObjectMode TF2_GetObjectMode(int entity) +{ + int offset = GetEntSendPropOffs(entity, "m_iObjectMode"); + + if (offset <= 0) + { + ThrowError("Entity index %d is not an object", entity); + } + + return view_as(GetEntData(entity, offset)); +}