Compare commits

..

1 Commits

Author SHA1 Message Date
BotoX
0bda47d85b Added hack to make plugins open a menu with all possible targets on ReplyToTargetError COMMAND_TARGET_AMBIGUOUS.
Explanation:
There are two clients in the server, one named gene, the other one "Ene ~special characters~".
An admin issues "sm_slay Ene" and gets following error message: More than one client matched the given pattern.
What this hack will do is: Use GetCmdArg(0, ...); to get the command name "sm_slay".
Use GetCmdArgString(...); to get the arguments supplied to the command.
Use GetLastProcessTargetString(...); (which was implemented in this commit) to retrieve the arguments that were passed to the last ProcessTargetString call.
It will then pass this data to the DynamicTargeting plugin through its AmbiguousMenu native.
The plugin will open up a menu on the client and list all targets which match the pattern that was supplied to ProcessTargetString.
If the client selects a menu entry, FakeClientCommand will be used to re-execute the command with the correct target.
2019-09-10 11:27:18 +02:00
59 changed files with 299 additions and 1318 deletions

12
.gitattributes vendored
View File

@ -1,12 +0,0 @@
# GitHub views all .h files as C, let's assume it's C++
*.h linguist-language=c++
# Internal tools overriding
tools/* linguist-vendored
editor/* linguist-vendored
# Third-party overriding
extensions/curl/curl-src/* linguist-vendored
extensions/geoip/GeoIP.c linguist-vendored
extensions/geoip/GeoIP.h linguist-vendored
extensions/sqlite/sqlite-source/* linguist-vendored

2
.gitmodules vendored
View File

@ -3,4 +3,4 @@
url = https://github.com/alliedmodders/amtl
[submodule "sourcepawn"]
path = sourcepawn
url = https://github.com/BotoX/sourcepawn.git
url = https://github.com/alliedmodders/sourcepawn

View File

@ -1313,7 +1313,7 @@ bool CHalfLife2::IsMapValid(const char *map)
if (!map || !map[0])
return false;
return FindMap(map) == SMFindMapResult::Found;
return FindMap(map) != SMFindMapResult::NotFound;
}
// TODO: Add ep1 support for this. (No IServerTools available there)

View File

@ -308,7 +308,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
{
ItemDrawInfo &dr = drawItems[foundItems].draw;
/* Is the item valid? */
if (menu->GetItemInfo(i, &dr, client) != NULL)
if (menu->GetItemInfo(i, &dr) != NULL)
{
/* Ask the user to change the style, if necessary */
mh->OnMenuDrawItem(menu, client, i, dr.style);
@ -398,7 +398,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
}
while (++lastItem < totalItems)
{
if (menu->GetItemInfo(lastItem, &dr, client) != NULL)
if (menu->GetItemInfo(lastItem, &dr) != NULL)
{
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
if (IsSlotItem(panel, dr.style))
@ -420,7 +420,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
lastItem--;
while (lastItem != 0)
{
if (menu->GetItemInfo(lastItem, &dr, client) != NULL)
if (menu->GetItemInfo(lastItem, &dr) != NULL)
{
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
if (IsSlotItem(panel, dr.style))

View File

@ -633,7 +633,7 @@ bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw)
return false;
}
CItem item(m_items.length());
CItem item;
item.info = info;
if (draw.display)
@ -655,7 +655,7 @@ bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDr
if (position >= m_items.length())
return false;
CItem item(position);
CItem item;
item.info = info;
if (draw.display)
item.display = new ke::AString(draw.display);
@ -679,16 +679,11 @@ void CBaseMenu::RemoveAllItems()
m_items.clear();
}
const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */, int client/* =0 */)
const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */)
{
if (position >= m_items.length())
return NULL;
if (client > 0 && position < m_RandomMaps[client].length())
{
position = m_RandomMaps[client][position];
}
if (draw)
{
draw->display = m_items[position].display->chars();
@ -698,62 +693,6 @@ const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =
return m_items[position].info.chars();
}
void CBaseMenu::ShufflePerClient(int start, int stop)
{
// limit map len to 255 items since it's using uint8
int length = MIN(GetItemCount(), 255);
if (stop >= 0)
length = MIN(length, stop);
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
{
// populate per-client map ...
m_RandomMaps[i].resize(length);
for (int j = 0; j < length; j++)
m_RandomMaps[i][j] = j;
// ... and random shuffle it
for (int j = length - 1; j > start; j--)
{
int x = rand() % (j - start + 1) + start;
uint8_t tmp = m_RandomMaps[i][x];
m_RandomMaps[i][x] = m_RandomMaps[i][j];
m_RandomMaps[i][j] = tmp;
}
}
}
void CBaseMenu::SetClientMapping(int client, int *array, int length)
{
length = MIN(length, 255);
m_RandomMaps[client].resize(length);
for (int i = 0; i < length; i++)
{
m_RandomMaps[client][i] = array[i];
}
}
bool CBaseMenu::IsPerClientShuffled()
{
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
{
if(m_RandomMaps[i].length() > 0)
return true;
}
return false;
}
unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
{
if (client > 0 && position < m_RandomMaps[client].length())
{
position = m_RandomMaps[client][position];
return m_items[position].index;
}
return position;
}
unsigned int CBaseMenu::GetItemCount()
{
return m_items.length();

View File

@ -44,9 +44,8 @@ using namespace SourceMod;
class CItem
{
public:
CItem(unsigned int index)
CItem()
{
this->index = index;
style = 0;
access = 0;
}
@ -54,13 +53,11 @@ public:
: info(ke::Move(other.info)),
display(ke::Move(other.display))
{
index = other.index;
style = other.style;
access = other.access;
}
CItem & operator =(CItem &&other)
{
index = other.index;
info = ke::Move(other.info);
display = ke::Move(other.display);
style = other.style;
@ -69,7 +66,6 @@ public:
}
public:
unsigned int index;
ke::AString info;
ke::AutoPtr<ke::AString> display;
unsigned int style;
@ -142,7 +138,7 @@ public:
virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
virtual bool RemoveItem(unsigned int position);
virtual void RemoveAllItems();
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL, int client=0);
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
virtual unsigned int GetItemCount();
virtual bool SetPagination(unsigned int itemsPerPage);
virtual unsigned int GetPagination();
@ -156,10 +152,6 @@ public:
virtual unsigned int GetMenuOptionFlags();
virtual void SetMenuOptionFlags(unsigned int flags);
virtual IMenuHandler *GetHandler();
virtual void ShufflePerClient(int start, int stop);
virtual void SetClientMapping(int client, int *array, int length);
virtual bool IsPerClientShuffled();
virtual unsigned int GetRealItemIndex(int client, unsigned int position);
unsigned int GetBaseMemUsage();
private:
void InternalDelete();
@ -176,7 +168,6 @@ protected:
Handle_t m_hHandle;
IMenuHandler *m_pHandler;
unsigned int m_nFlags;
ke::Vector<uint8_t> m_RandomMaps[SM_MAXPLAYERS+1];
};
#endif //_INCLUDE_MENUSTYLE_BASE_H

View File

@ -514,16 +514,15 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
/* Check by our item count, NOT the vote array size */
if (item < m_Items)
{
unsigned int index = menu->GetRealItemIndex(client, item);
m_ClientVotes[client] = index;
m_Votes[index]++;
m_ClientVotes[client] = item;
m_Votes[item]++;
m_NumVotes++;
if (sm_vote_chat.GetBool() || sm_vote_console.GetBool() || sm_vote_client_console.GetBool())
{
static char buffer[1024];
ItemDrawInfo dr;
menu->GetItemInfo(item, &dr, client);
menu->GetItemInfo(item, &dr);
if (sm_vote_console.GetBool())
{

View File

@ -30,7 +30,6 @@
*/
#include "PlayerManager.h"
#include "sourcemod.h"
#include "IAdminSystem.h"
#include "ConCmdManager.h"
#include "MenuStyle_Valve.h"
@ -93,12 +92,6 @@ SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &)
#else
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
#endif
SH_DECL_HOOK2_void(IVEngineServer, ClientPrintf, SH_NOATTRIB, 0, edict_t *, const char *);
static void PrintfBuffer_FrameAction(void *data)
{
g_Players.OnPrintfFrameAction(reinterpret_cast<unsigned int>(data));
}
ConCommand *maxplayersCmd = NULL;
@ -179,7 +172,6 @@ void PlayerManager::OnSourceModAllInitialized()
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox.
SH_ADD_HOOK(IServerGameDLL, SetServerHibernation, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#endif
SH_ADD_HOOK(IVEngineServer, ClientPrintf, engine, SH_MEMBER(this, &PlayerManager::OnClientPrintf), false);
sharesys->AddInterface(NULL, this);
@ -212,9 +204,6 @@ void PlayerManager::OnSourceModAllInitialized()
SH_ADD_HOOK(ConCommand, Dispatch, pCmd, SH_STATIC(CmdMaxplayersCallback), true);
maxplayersCmd = pCmd;
}
gameevents->AddListener(this, "player_connect", true);
gameevents->AddListener(this, "player_disconnect", true);
}
void PlayerManager::OnSourceModShutdown()
@ -236,7 +225,6 @@ void PlayerManager::OnSourceModShutdown()
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox.
SH_REMOVE_HOOK(IServerGameDLL, SetServerHibernation, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#endif
SH_REMOVE_HOOK(IVEngineServer, ClientPrintf, engine, SH_MEMBER(this, &PlayerManager::OnClientPrintf), false);
/* Release forwards */
forwardsys->ReleaseForward(m_clconnect);
@ -262,8 +250,6 @@ void PlayerManager::OnSourceModShutdown()
{
SH_REMOVE_HOOK(ConCommand, Dispatch, maxplayersCmd, SH_STATIC(CmdMaxplayersCallback), true);
}
gameevents->RemoveListener(this);
}
ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
@ -860,88 +846,6 @@ void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)
}
}
void PlayerManager::OnClientPrintf(edict_t *pEdict, const char *szMsg)
{
int client = IndexOfEdict(pEdict);
CPlayer &player = m_Players[client];
if (!player.IsConnected())
RETURN_META(MRES_IGNORED);
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(client));
if (pNetChan == NULL)
RETURN_META(MRES_IGNORED);
size_t nMsgLen = strlen(szMsg);
#if SOURCE_ENGINE == SE_EPISODEONE
static const int nNumBitsWritten = 0;
#else
int nNumBitsWritten = pNetChan->GetNumBitsWritten(false); // SVC_Print uses unreliable netchan
#endif
// if the msg is bigger than allowed then just let it fail
if (nMsgLen + 1 >= SVC_Print_BufferSize) // +1 for NETMSG_TYPE_BITS
RETURN_META(MRES_IGNORED);
// enqueue msgs if we'd overflow the SVC_Print buffer (+7 as ceil)
if (!player.m_PrintfBuffer.empty() || (nNumBitsWritten + NETMSG_TYPE_BITS + 7) / 8 + nMsgLen >= SVC_Print_BufferSize)
{
// Don't send any more messages for this player until the buffer is empty.
// Queue up a gameframe hook to empty the buffer (if we haven't already)
if (player.m_PrintfBuffer.empty())
g_SourceMod.AddFrameAction(PrintfBuffer_FrameAction, (void *)(uintptr_t)player.GetSerial());
player.m_PrintfBuffer.append(szMsg);
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
}
void PlayerManager::OnPrintfFrameAction(unsigned int serial)
{
int client = GetClientFromSerial(serial);
CPlayer &player = m_Players[client];
if (!player.IsConnected())
{
player.ClearNetchannelQueue();
return;
}
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(client));
if (pNetChan == NULL)
{
player.ClearNetchannelQueue();
return;
}
while (!player.m_PrintfBuffer.empty())
{
#if SOURCE_ENGINE == SE_EPISODEONE
static const int nNumBitsWritten = 0;
#else
int nNumBitsWritten = pNetChan->GetNumBitsWritten(false); // SVC_Print uses unreliable netchan
#endif
ke::AString &string = player.m_PrintfBuffer.front();
// stop if we'd overflow the SVC_Print buffer (+7 as ceil)
if ((nNumBitsWritten + NETMSG_TYPE_BITS + 7) / 8 + string.length() >= SVC_Print_BufferSize)
break;
SH_CALL(engine, &IVEngineServer::ClientPrintf)(player.m_pEdict, string.chars());
player.m_PrintfBuffer.popFront();
}
if (!player.m_PrintfBuffer.empty())
{
// continue processing it on the next gameframe as buffer is not empty
g_SourceMod.AddFrameAction(PrintfBuffer_FrameAction, (void *)(uintptr_t)player.GetSerial());
}
}
void ClientConsolePrint(edict_t *e, const char *fmt, ...)
{
char buffer[512];
@ -1429,11 +1333,6 @@ int PlayerManager::GetNumPlayers()
return m_PlayerCount;
}
int PlayerManager::GetNumClients()
{
return m_ClientCount;
}
int PlayerManager::GetClientOfUserId(int userid)
{
if (userid < 0 || userid > USHRT_MAX)
@ -2029,27 +1928,6 @@ bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQue
}
#endif
/* IGameEventListener2::FireGameEvent */
void PlayerManager::FireGameEvent(IGameEvent *pEvent)
{
const char *name = pEvent->GetName();
if (strcmp(name, "player_connect") == 0)
{
const int client = pEvent->GetInt("index") + 1;
const int userid = pEvent->GetInt("userid");
m_ClientCount++;
}
else if (strcmp(name, "player_disconnect") == 0)
{
const int userid = pEvent->GetInt("userid");
const int client = m_UserIdLookUp[userid];
m_ClientCount--;
}
}
/*******************
*** PLAYER CODE ***
@ -2267,13 +2145,6 @@ void CPlayer::Disconnect()
#if SOURCE_ENGINE == SE_CSGO
m_LanguageCookie = InvalidQueryCvarCookie;
#endif
ClearNetchannelQueue();
}
void CPlayer::ClearNetchannelQueue(void)
{
while (!m_PrintfBuffer.empty())
m_PrintfBuffer.popFront();
}
void CPlayer::SetName(const char *name)

View File

@ -43,7 +43,6 @@
#include <sh_list.h>
#include <sh_vector.h>
#include <am-string.h>
#include <am-deque.h>
#include "ConVarManager.h"
#include <steam/steamclientpublic.h>
@ -124,7 +123,6 @@ private:
bool IsAuthStringValidated();
bool SetEngineString();
bool SetCSteamID();
void ClearNetchannelQueue(void);
private:
bool m_IsConnected = false;
bool m_IsInGame = false;
@ -154,13 +152,11 @@ private:
#if SOURCE_ENGINE == SE_CSGO
QueryCvarCookie_t m_LanguageCookie = InvalidQueryCvarCookie;
#endif
ke::Deque<ke::AString> m_PrintfBuffer;
};
class PlayerManager :
public SMGlobalClass,
public IPlayerManager,
public IGameEventListener2
public IPlayerManager
{
friend class CPlayer;
public:
@ -194,8 +190,6 @@ public:
void OnClientSettingsChanged(edict_t *pEntity);
//void OnClientSettingsChanged_Pre(edict_t *pEntity);
void OnServerHibernationUpdate(bool bHibernating);
void OnClientPrintf(edict_t *pEdict, const char *szMsg);
void OnPrintfFrameAction(unsigned int serial);
public: //IPlayerManager
void AddClientListener(IClientListener *listener);
void RemoveClientListener(IClientListener *listener);
@ -203,7 +197,6 @@ public: //IPlayerManager
IGamePlayer *GetGamePlayer(edict_t *pEdict);
int GetMaxClients();
int GetNumPlayers();
int GetNumClients();
int GetClientOfUserId(int userid);
bool IsServerActivated();
int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
@ -214,8 +207,6 @@ public: //IPlayerManager
int GetClientFromSerial(unsigned int serial);
void ClearAdminId(AdminId id);
void RecheckAnyAdmins();
public: // IGameEventListener2
void FireGameEvent(IGameEvent *pEvent);
public:
inline int MaxClients()
{
@ -276,10 +267,6 @@ private:
int m_SourceTVUserId;
int m_ReplayUserId;
bool m_bInCCKVHook;
int m_ClientCount;
private:
static const int NETMSG_TYPE_BITS = 5; // SVC_Print overhead for netmsg type
static const int SVC_Print_BufferSize = 2048 - 1; // -1 for terminating \0
};
#if SOURCE_ENGINE >= SE_ORANGEBOX

View File

@ -85,7 +85,6 @@ for arch in SM.archs:
'smn_halflife.cpp',
'FrameIterator.cpp',
'DatabaseConfBuilder.cpp',
'NativeInvoker.cpp',
]
if arch == 'x64':

View File

@ -1,321 +0,0 @@
// vim: set sts=2 ts=8 sw=2 tw=99 et:
//
// Copyright (C) 2006-2015 AlliedModders LLC
//
// This file is part of SourcePawn. SourcePawn is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// You should have received a copy of the GNU General Public License along with
// SourcePawn. If not, see http://www.gnu.org/licenses/.
//
#include <stdio.h>
#include <string.h>
#include "NativeInvoker.h"
/********************
* FUNCTION CALLING *
********************/
NativeInvoker::NativeInvoker(IPluginContext *pContext, const ke::RefPtr<Native> &native)
: context_(pContext),
m_curparam(0),
m_errorstate(SP_ERROR_NONE),
native_(native)
{
}
NativeInvoker::~NativeInvoker()
{
Cancel();
}
bool
NativeInvoker::IsRunnable()
{
return true;
}
IPluginContext *
NativeInvoker::GetParentContext()
{
return context_;
}
int NativeInvoker::PushCell(cell_t cell)
{
if (m_curparam >= SP_MAX_EXEC_PARAMS)
return SetError(SP_ERROR_PARAMS_MAX);
m_info[m_curparam].marked = false;
m_params[m_curparam] = cell;
m_curparam++;
return SP_ERROR_NONE;
}
int
NativeInvoker::PushCellByRef(cell_t *cell, int flags)
{
return PushArray(cell, 1, flags);
}
int
NativeInvoker::PushFloat(float number)
{
cell_t val = sp::FloatCellUnion(number).cell;
return PushCell(val);
}
int
NativeInvoker::PushFloatByRef(float *number, int flags)
{
return PushCellByRef((cell_t *)number, flags);
}
int
NativeInvoker::PushArray(cell_t *inarray, unsigned int cells, int copyback)
{
if (m_curparam >= SP_MAX_EXEC_PARAMS)
{
return SetError(SP_ERROR_PARAMS_MAX);
}
ParamInfo *info = &m_info[m_curparam];
info->flags = inarray ? copyback : 0;
info->marked = true;
info->size = cells;
info->str.is_sz = false;
info->orig_addr = inarray;
m_curparam++;
return SP_ERROR_NONE;
}
int
NativeInvoker::PushString(const char *string)
{
return _PushString(string, SM_PARAM_STRING_COPY, 0, strlen(string)+1);
}
int
NativeInvoker::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags)
{
return _PushString(buffer, sz_flags, cp_flags, length);
}
int
NativeInvoker::_PushString(const char *string, int sz_flags, int cp_flags, size_t len)
{
if (m_curparam >= SP_MAX_EXEC_PARAMS)
return SetError(SP_ERROR_PARAMS_MAX);
ParamInfo *info = &m_info[m_curparam];
info->marked = true;
info->orig_addr = (cell_t *)string;
info->flags = cp_flags;
info->size = len;
info->str.sz_flags = sz_flags;
info->str.is_sz = true;
m_curparam++;
return SP_ERROR_NONE;
}
void
NativeInvoker::Cancel()
{
if (!m_curparam)
return;
m_errorstate = SP_ERROR_NONE;
m_curparam = 0;
}
int
NativeInvoker::Execute(cell_t *result, cell_t buffer, cell_t size)
{
context_->ClearLastNativeError();
// For backward compatibility, we have to clear the exception state.
// Otherwise code like this:
//
// static cell_t native(cx, params) {
// for (auto callback : callbacks) {
// callback->Execute();
// }
// }
//
// Could unintentionally leak a pending exception back to the caller,
// which wouldn't have happened before the Great Exception Refactoring.
SourcePawn::ExceptionHandler eh(context_);
eh.Debug(!size);
if (!Invoke(result)) {
if(size)
context_->StringToLocalUTF8(buffer, size, eh.Message(), NULL);
int Err = context_->GetLastNativeError();
context_->ClearLastNativeError();
return Err;
}
return SP_ERROR_NONE;
}
bool
NativeInvoker::Invoke(cell_t *result)
{
if (!IsRunnable()) {
Cancel();
context_->ReportErrorNumber(SP_ERROR_NOT_RUNNABLE);
return false;
}
if (int err = m_errorstate) {
Cancel();
context_->ReportErrorNumber(err);
return false;
}
//This is for re-entrancy!
cell_t _temp_params[SP_MAX_EXEC_PARAMS + 1];
cell_t *temp_params = &_temp_params[1];
ParamInfo temp_info[SP_MAX_EXEC_PARAMS];
unsigned int numparams = m_curparam;
unsigned int i;
if (numparams)
{
//Save the info locally, then reset it for re-entrant calls.
memcpy(temp_info, m_info, numparams * sizeof(ParamInfo));
}
m_curparam = 0;
/* Initialize 0th parameter */
_temp_params[0] = numparams;
/* Browse the parameters and build arrays */
bool ok = true;
for (i=0; i<numparams; i++) {
/* Is this marked as an array? */
if (temp_info[i].marked) {
if (!temp_info[i].str.is_sz) {
/* Allocate a normal/generic array */
int err = context_->HeapAlloc(
temp_info[i].size,
&(temp_info[i].local_addr),
&(temp_info[i].phys_addr));
if (err != SP_ERROR_NONE) {
context_->ReportErrorNumber(err);
ok = false;
break;
}
if (temp_info[i].orig_addr)
{
memcpy(temp_info[i].phys_addr, temp_info[i].orig_addr, sizeof(cell_t) * temp_info[i].size);
}
} else {
/* Calculate cells required for the string */
size_t cells = (temp_info[i].size + sizeof(cell_t) - 1) / sizeof(cell_t);
/* Allocate the buffer */
int err = context_->HeapAlloc(
cells,
&(temp_info[i].local_addr),
&(temp_info[i].phys_addr));
if (err != SP_ERROR_NONE) {
context_->ReportErrorNumber(err);
ok = false;
break;
}
/* Copy original string if necessary */
if ((temp_info[i].str.sz_flags & SM_PARAM_STRING_COPY) && (temp_info[i].orig_addr != NULL))
{
/* Cut off UTF-8 properly */
if (temp_info[i].str.sz_flags & SM_PARAM_STRING_UTF8) {
context_->StringToLocalUTF8(
temp_info[i].local_addr,
temp_info[i].size,
(const char *)temp_info[i].orig_addr,
NULL);
}
/* Copy a binary blob */
else if (temp_info[i].str.sz_flags & SM_PARAM_STRING_BINARY)
{
memmove(temp_info[i].phys_addr, temp_info[i].orig_addr, temp_info[i].size);
}
/* Copy ASCII characters */
else
{
context_->StringToLocal(
temp_info[i].local_addr,
temp_info[i].size,
(const char *)temp_info[i].orig_addr);
}
}
} /* End array/string calculation */
/* Update the pushed parameter with the byref local address */
temp_params[i] = temp_info[i].local_addr;
} else {
/* Just copy the value normally */
temp_params[i] = m_params[i];
}
}
/* Make the call if we can */
if (ok)
{
*result = native_->func()(context_, _temp_params);
}
/* i should be equal to the last valid parameter + 1 */
bool docopies = ok;
while (i--) {
if (!temp_info[i].marked)
continue;
if (docopies && (temp_info[i].flags & SM_PARAM_COPYBACK)) {
if (temp_info[i].orig_addr) {
if (temp_info[i].str.is_sz) {
memcpy(temp_info[i].orig_addr, temp_info[i].phys_addr, temp_info[i].size);
} else {
if (temp_info[i].size == 1) {
*temp_info[i].orig_addr = *(temp_info[i].phys_addr);
} else {
memcpy(temp_info[i].orig_addr,
temp_info[i].phys_addr,
temp_info[i].size * sizeof(cell_t));
}
}
}
}
if (int err = context_->HeapPop(temp_info[i].local_addr))
context_->ReportErrorNumber(err);
}
return context_->GetLastNativeError() == SP_ERROR_NONE;
}
int
NativeInvoker::SetError(int err)
{
m_errorstate = err;
return err;
}
int NativeInvoker::CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) { return 0; }
funcid_t NativeInvoker::GetFunctionID() { return 0; }
int NativeInvoker::Execute2(IPluginContext *ctx, cell_t *result) { return 0; }
int NativeInvoker::CallFunction2(IPluginContext *ctx, const cell_t *params, unsigned int num_params, cell_t *result) { return 0; }
IPluginRuntime *NativeInvoker::GetParentRuntime() { return NULL; }

View File

@ -1,79 +0,0 @@
// vim: set sts=2 ts=8 sw=2 tw=99 et:
//
// Copyright (C) 2006-2015 AlliedModders LLC
//
// This file is part of SourcePawn. SourcePawn is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// You should have received a copy of the GNU General Public License along with
// SourcePawn. If not, see http://www.gnu.org/licenses/.
//
#ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
#include <sp_vm_api.h>
#include <amtl/am-autoptr.h>
#include <amtl/am-refcounting.h>
#include "Native.h"
struct ParamInfo
{
int flags; /* Copy-back flags */
bool marked; /* Whether this is marked as being used */
cell_t local_addr; /* Local address to free */
cell_t *phys_addr; /* Physical address of our copy */
cell_t *orig_addr; /* Original address to copy back to */
ucell_t size; /* Size of array in bytes */
struct {
bool is_sz; /* is a string */
int sz_flags; /* has sz flags */
} str;
};
class NativeInvoker : public IPluginFunction
{
public:
NativeInvoker(IPluginContext *pContext, const ke::RefPtr<Native> &native);
virtual ~NativeInvoker();
public:
int PushCell(cell_t cell);
int PushCellByRef(cell_t *cell, int flags);
int PushFloat(float number);
int PushFloatByRef(float *number, int flags);
int PushArray(cell_t *inarray, unsigned int cells, int copyback);
int PushString(const char *string);
int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
int Execute(cell_t *result, cell_t buffer=0, cell_t size=0);
void Cancel();
int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
IPluginContext *GetParentContext();
bool Invoke(cell_t *result);
bool IsRunnable();
funcid_t GetFunctionID();
int Execute2(IPluginContext *ctx, cell_t *result);
int CallFunction2(IPluginContext *ctx,
const cell_t *params,
unsigned int num_params,
cell_t *result);
IPluginRuntime *GetParentRuntime();
const char *DebugName() {
return native_->name();
}
private:
int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
int SetError(int err);
private:
IPluginContext *context_;
cell_t m_params[SP_MAX_EXEC_PARAMS];
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
unsigned int m_curparam;
int m_errorstate;
ke::RefPtr<Native> native_;
};
#endif //_INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_

View File

@ -35,8 +35,6 @@
#include <IForwardSys.h>
#include <ISourceMod.h>
#include <amtl/am-autoptr.h>
#include "ShareSys.h"
#include "NativeInvoker.h"
HandleType_t g_GlobalFwdType = 0;
HandleType_t g_PrivateFwdType = 0;
@ -45,7 +43,6 @@ static bool s_CallStarted = false;
static ICallable *s_pCallable = NULL;
static IPluginFunction *s_pFunction = NULL;
static IForward *s_pForward = NULL;
static NativeInvoker *s_pInvoker = NULL;
class ForwardNativeHelpers :
public SMGlobalClass,
@ -105,9 +102,6 @@ inline void ResetCall()
s_pFunction = NULL;
s_pForward = NULL;
s_pCallable = NULL;
if(s_pInvoker)
delete s_pInvoker;
s_pInvoker = NULL;
}
static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *params)
@ -372,27 +366,6 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
return 1;
}
static cell_t sm_CallStartNative(IPluginContext *pContext, const cell_t *params)
{
ResetCall();
char *name;
pContext->LocalToString(params[1], &name);
ke::RefPtr<Native> pNative = g_ShareSys.FindNative(name);
if (!pNative)
return 0;//pContext->ThrowNativeError("Invalid native \"%s\"", name);
s_pInvoker = new NativeInvoker(pContext, pNative);
s_pCallable = static_cast<ICallable *>(s_pInvoker);
s_CallStarted = true;
return 1;
}
static cell_t sm_CallPushCell(IPluginContext *pContext, const cell_t *params)
{
int err;
@ -683,39 +656,6 @@ static cell_t sm_CallFinish(IPluginContext *pContext, const cell_t *params)
IForward *pForward = s_pForward;
ResetCall();
err = pForward->Execute(result, NULL);
} else if (s_pInvoker) {
err = s_pInvoker->Execute(result);
ResetCall();
}
return err;
}
static cell_t sm_CallFinishEx(IPluginContext *pContext, const cell_t *params)
{
int err = SP_ERROR_NOT_RUNNABLE;
cell_t *result;
if (!s_CallStarted)
{
return pContext->ThrowNativeError("Cannot finish call when there is no call in progress");
}
pContext->LocalToPhysAddr(params[1], &result);
// Note: Execute() swallows exceptions, so this is okay.
if (s_pFunction)
{
IPluginFunction *pFunction = s_pFunction;
ResetCall();
err = pFunction->Execute(result, params[2], params[3]);
} else if (s_pForward) {
IForward *pForward = s_pForward;
ResetCall();
err = pForward->Execute(result, NULL);
} else if (s_pInvoker) {
err = s_pInvoker->Execute(result, params[2], params[3]);
ResetCall();
}
return err;
@ -802,7 +742,6 @@ REGISTER_NATIVES(functionNatives)
{"RemoveAllFromForward", sm_RemoveAllFromForward},
{"Call_StartFunction", sm_CallStartFunction},
{"Call_StartForward", sm_CallStartForward},
{"Call_StartNative", sm_CallStartNative},
{"Call_PushCell", sm_CallPushCell},
{"Call_PushCellRef", sm_CallPushCellRef},
{"Call_PushFloat", sm_CallPushFloat},
@ -814,7 +753,6 @@ REGISTER_NATIVES(functionNatives)
{"Call_PushNullVector", sm_CallPushNullVector},
{"Call_PushNullString", sm_CallPushNullString},
{"Call_Finish", sm_CallFinish},
{"Call_FinishEx", sm_CallFinishEx},
{"Call_Cancel", sm_CallCancel},
{"RequestFrame", sm_AddFrameAction},

View File

@ -816,14 +816,8 @@ static cell_t GetMenuItem(IPluginContext *pContext, const cell_t *params)
ItemDrawInfo dr;
const char *info;
cell_t client = (params[0] >= 8) ? params[8] : 0;
if(!client && menu->IsPerClientShuffled())
{
return pContext->ThrowNativeError("This menu has been per-client random shuffled. "
"You have to call GetMenuItem with a client index!");
}
if ((info=menu->GetItemInfo(params[2], &dr, client)) == NULL)
if ((info=menu->GetItemInfo(params[2], &dr)) == NULL)
{
return 0;
}
@ -838,57 +832,6 @@ static cell_t GetMenuItem(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t MenuShufflePerClient(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err = ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
int start = params[2];
int stop = params[3];
if (stop > 0 && !(stop >= start))
{
return pContext->ThrowNativeError("Stop must be -1 or >= start!");
}
menu->ShufflePerClient(start, stop);
return 1;
}
static cell_t MenuSetClientMapping(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err = ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
int client = params[2];
if (client < 1 || client > SM_MAXPLAYERS)
{
return pContext->ThrowNativeError("Invalid client index!");
}
cell_t *array;
pContext->LocalToPhysAddr(params[3], &array);
int length = params[4];
menu->SetClientMapping(client, array, length);
return 1;
}
static cell_t SetMenuPagination(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
@ -1702,8 +1645,6 @@ REGISTER_NATIVES(menuNatives)
{"SetPanelKeys", SetPanelKeys},
{"SetVoteResultCallback", SetVoteResultCallback},
{"VoteMenu", VoteMenu},
{"MenuShufflePerClient", MenuShufflePerClient},
{"MenuSetClientMapping", MenuSetClientMapping},
{"SetMenuNoVoteButton", SetMenuNoVoteButton},
// Transitional syntax support.
@ -1732,8 +1673,6 @@ REGISTER_NATIVES(menuNatives)
{"Menu.ToPanel", CreatePanelFromMenu},
{"Menu.Cancel", CancelMenu},
{"Menu.DisplayVote", VoteMenu},
{"Menu.ShufflePerClient", MenuShufflePerClient},
{"Menu.SetClientMapping", MenuSetClientMapping},
{"Menu.Pagination.get", GetMenuPagination},
{"Menu.Pagination.set", SetMenuPagination},
{"Menu.OptionFlags.get", GetMenuOptionFlags},

View File

@ -64,13 +64,10 @@ static const int kActivityAdmins = 4; // Show admin activity to admins anonymo
static const int kActivityAdminsNames = 8; // If 4 is specified, admin names will be shown.
static const int kActivityRootNames = 16; // Always show admin names to root users.
#define FEATURECAP_MULTITARGETFILTER_CLIENTPARAM "SourceMod MultiTargetFilter ClientParam"
class PlayerLogicHelpers :
public SMGlobalClass,
public IPluginsListener,
public ICommandTargetProcessor,
public IFeatureProvider
public ICommandTargetProcessor
{
struct SimpleMultiTargetFilter
{
@ -144,7 +141,6 @@ public: //ICommandTargetProcessor
smtf->fun->PushString(info->pattern);
smtf->fun->PushCell(ahc.getClone());
smtf->fun->PushCell(info->admin);
cell_t result = 0;
if (smtf->fun->Execute(&result) != SP_ERROR_NONE || !result)
return false;
@ -189,7 +185,6 @@ public: //SMGlobalClass
void OnSourceModAllInitialized()
{
pluginsys->AddPluginsListener(this);
sharesys->AddCapabilityProvider(NULL, this, FEATURECAP_MULTITARGETFILTER_CLIENTPARAM);
}
void OnSourceModShutdown()
@ -199,7 +194,6 @@ public: //SMGlobalClass
playerhelpers->UnregisterCommandTargetProcessor(this);
filterEnabled = false;
}
sharesys->DropCapabilityProvider(NULL, this, FEATURECAP_MULTITARGETFILTER_CLIENTPARAM);
}
public: //IPluginsListener
@ -217,13 +211,6 @@ public: //IPluginsListener
}
}
}
public: //IFeatureProvider
FeatureStatus GetFeatureStatus(FeatureType type, const char *name)
{
return FeatureStatus_Available;
}
} s_PlayerLogicHelpers;
static cell_t
@ -270,7 +257,18 @@ static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
return playerhelpers->GetNumPlayers();
}
return playerhelpers->GetNumClients();
int maxplayers = playerhelpers->GetMaxClients();
int count = 0;
for (int i = 1; i <= maxplayers; ++i)
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(i);
if ((pPlayer->IsConnected()) && !(pPlayer->IsInGame()))
{
count++;
}
}
return (playerhelpers->GetNumPlayers() + count);
}
static cell_t sm_GetMaxClients(IPluginContext *pCtx, const cell_t *params)

View File

@ -356,27 +356,6 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
return sp_ftoc(value);
}
static cell_t sm_GetClientIClient(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", client);
}
else if (!pPlayer->IsConnected())
{
return pContext->ThrowNativeError("Client %d is not connected", client);
}
else if (pPlayer->IsFakeClient())
{
return pContext->ThrowNativeError("Client %d is a bot", client);
}
return (cell_t)pPlayer->GetIClient();
}
static cell_t RunAdminCacheChecks(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
@ -413,7 +392,6 @@ REGISTER_NATIVES(playernatives)
{"GetClientAvgChoke", GetAvgChoke},
{"GetClientAvgData", GetAvgData},
{"GetClientAvgPackets", GetAvgPackets},
{"GetClientIClient", sm_GetClientIClient },
{"RunAdminCacheChecks", RunAdminCacheChecks},
{NULL, NULL}
};

View File

@ -112,7 +112,6 @@ IServerTools *servertools = NULL;
// global hooks and forwards
IForward *g_pOnEntityCreated = NULL;
IForward *g_pOnEntitySpawned = NULL;
IForward *g_pOnEntityDestroyed = NULL;
#ifdef GAMEDESC_CAN_CHANGE
@ -253,7 +252,6 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
plsys->AddPluginsListener(&g_Interface);
g_pOnEntityCreated = forwards->CreateForward("OnEntityCreated", ET_Ignore, 2, NULL, Param_Cell, Param_String);
g_pOnEntitySpawned = forwards->CreateForward("OnEntitySpawned", ET_Ignore, 2, NULL, Param_Cell, Param_String);
g_pOnEntityDestroyed = forwards->CreateForward("OnEntityDestroyed", ET_Ignore, 1, NULL, Param_Cell);
#ifdef GAMEDESC_CAN_CHANGE
g_pOnGetGameNameDescription = forwards->CreateForward("OnGetGameDescription", ET_Hook, 2, NULL, Param_String);
@ -346,7 +344,6 @@ void SDKHooks::SDK_OnUnload()
#endif
forwards->ReleaseForward(g_pOnEntityCreated);
forwards->ReleaseForward(g_pOnEntitySpawned);
forwards->ReleaseForward(g_pOnEntityDestroyed);
#ifdef GAMEDESC_CAN_CHANGE
forwards->ReleaseForward(g_pOnGetGameNameDescription);
@ -423,7 +420,6 @@ void SDKHooks::OnClientPutInServer(int client)
CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
HandleEntityCreated(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
HandleEntitySpawned(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
}
void SDKHooks::OnClientDisconnecting(int client)
@ -883,27 +879,6 @@ void SDKHooks::OnEntityCreated(CBaseEntity *pEntity)
}
}
void SDKHooks::OnEntitySpawned(CBaseEntity *pEntity)
{
// Call OnEntitySpawned forward
int ref = gamehelpers->EntityToReference(pEntity);
int index = gamehelpers->ReferenceToIndex(ref);
// This can be -1 for player ents before any players have connected
if ((unsigned)index == INVALID_EHANDLE_INDEX || (index > 0 && index <= playerhelpers->GetMaxClients()))
{
return;
}
if (!IsEntityIndexInRange(index))
{
g_pSM->LogError(myself, "SDKHooks::OnEntitySpawned - Got entity index out of range (%d)", index);
return;
}
HandleEntitySpawned(pEntity, index, ref);
}
#ifdef GAMEDESC_CAN_CHANGE
const char *SDKHooks::Hook_GetGameDescription()
{
@ -1816,32 +1791,6 @@ void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref)
m_EntityCache[index] = ref;
}
void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
{
if (g_pOnEntitySpawned->GetFunctionCount() || m_EntListeners.size())
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
const char *pName = gamehelpers->GetEntityClassname(pEntity);
if (!pName)
pName = "";
// Send OnEntitySpawned to SM listeners
for (SourceHook::List<ISMEntityListener *>::iterator iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
{
ISMEntityListener *pListener = (*iter);
pListener->OnEntitySpawned(pEntity, pName);
}
// Call OnEntitySpawned forward
if (g_pOnEntitySpawned->GetFunctionCount())
{
g_pOnEntitySpawned->PushCell(bcompatRef);
g_pOnEntitySpawned->PushString(pName);
g_pOnEntitySpawned->Execute(NULL);
}
}
}
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);

View File

@ -238,7 +238,6 @@ public: // IFeatureProvider
public: // IEntityListener
virtual void OnEntityCreated(CBaseEntity *pEntity);
virtual void OnEntitySpawned(CBaseEntity *pEntity);
virtual void OnEntityDeleted(CBaseEntity *pEntity);
public: // IClientListener
@ -331,7 +330,6 @@ public:
private:
void HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref);
void HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref);
void HandleEntityDeleted(CBaseEntity *pEntity);
void Unhook(CBaseEntity *pEntity);
void Unhook(IPluginContext *pContext);

View File

@ -175,13 +175,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
vecDamagePosition = vec3_origin;
}
int iDamageCustom = 0;
if (params[0] >= 9)
{
iDamageCustom = params[9];
}
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition, iDamageCustom);
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition);
SH_MCALL(pVictim, OnTakeDamage)((CTakeDamageInfoHack &)info);
#endif

View File

@ -34,7 +34,7 @@
CTakeDamageInfo::CTakeDamageInfo(){}
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom )
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition )
{
m_hInflictor = pInflictor;
if ( pAttacker )
@ -63,9 +63,9 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
m_iAmmoType = -1;
#if SOURCE_ENGINE < SE_ORANGEBOX
m_iCustomKillType = iDamageCustom;
m_iCustomKillType = 0;
#else
m_iDamageCustom = iDamageCustom;
m_iDamageCustom = 0;
#endif
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \

View File

@ -58,7 +58,7 @@
class CTakeDamageInfoHack : public CTakeDamageInfo
{
public:
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0);
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition );
inline int GetAttacker() const { return m_hAttacker.IsValid() ? m_hAttacker.GetEntryIndex() : -1; }
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }
#if SOURCE_ENGINE >= SE_ORANGEBOX && SOURCE_ENGINE != SE_LEFT4DEAD

View File

@ -484,7 +484,7 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
IPlayerInfo *plinfo = player->GetPlayerInfo();
if (plinfo == NULL)
continue;
if ((plinfo->GetTeamIndex() == 0 || plinfo->GetTeamIndex() == 1) &&
if (plinfo->GetTeamIndex() == 1 &&
playerhelpers->FilterCommandTarget(pAdmin, player, info->flags) ==
COMMAND_TARGET_VALID)
{

View File

@ -53,10 +53,6 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname)
if (network == NULL)
continue;
IHandleEntity *pHandleEnt = network->GetEntityHandle();
if (pHandleEnt == NULL)
continue;
ServerClass *sClass = network->GetServerClass();
const char *name = sClass->GetName();

View File

@ -52,6 +52,7 @@ void EntityOutputManager::Shutdown()
return;
}
EntityOutputs->Destroy();
ClassNames->Destroy();
fireOutputDetour->Destroy();
}
@ -65,6 +66,7 @@ void EntityOutputManager::Init()
return;
}
EntityOutputs = adtfactory->CreateBasicTrie();
ClassNames = adtfactory->CreateBasicTrie();
}
@ -118,30 +120,45 @@ bool EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator
return true;
}
char sOutput[20];
ke::SafeSprintf(sOutput, sizeof(sOutput), "%p", pOutput);
// attempt to directly lookup a hook using the pOutput pointer
OutputNameStruct *pOutputName = NULL;
const char *classname = gamehelpers->GetEntityClassname(pCaller);
if (!classname)
{
return true;
}
bool fastLookup = false;
const char *outputname = FindOutputName(pOutput, pCaller);
if (!outputname)
// Fast lookup failed - check the slow way for hooks that haven't fired yet
if ((fastLookup = EntityOutputs->Retrieve(sOutput, (void **)&pOutputName)) == false)
{
return true;
}
const char *classname = gamehelpers->GetEntityClassname(pCaller);
if (!classname)
{
return true;
}
pOutputName = FindOutputPointer(classname, outputname, false);
const char *outputname = FindOutputName(pOutput, pCaller);
if (!outputname)
{
return true;
}
if (!pOutputName)
{
return true;
pOutputName = FindOutputPointer(classname, outputname, false);
if (!pOutputName)
{
return true;
}
}
if (!pOutputName->hooks.empty())
{
if (!fastLookup)
{
// hook exists on this classname and output - map it into our quick find trie
EntityOutputs->Insert(sOutput, pOutputName);
}
SourceHook::List<omg_hooks *>::iterator _iter;
omg_hooks *hook;

View File

@ -121,6 +121,8 @@ private:
const char *FindOutputName(void *pOutput, CBaseEntity *pCaller);
//Maps CEntityOutput * to a OutputNameStruct
IBasicTrie *EntityOutputs;
// Maps classname to a ClassNameStruct
IBasicTrie *ClassNames;

View File

@ -998,22 +998,6 @@ static cell_t smn_TRGetHitGroup(IPluginContext *pContext, const cell_t *params)
return tr->hitgroup;
}
static cell_t smn_TRGetHitBoxIndex(IPluginContext *pContext, const cell_t *params)
{
sm_trace_t *tr;
HandleError err;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if (params[1] == BAD_HANDLE)
{
tr = &g_Trace;
} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
}
return tr->hitbox;
}
static cell_t smn_TRGetEntityIndex(IPluginContext *pContext, const cell_t *params)
{
sm_trace_t *tr;
@ -1118,7 +1102,6 @@ sp_nativeinfo_t g_TRNatives[] =
{"TR_StartSolid", smn_TRStartSolid},
{"TR_DidHit", smn_TRDidHit},
{"TR_GetHitGroup", smn_TRGetHitGroup},
{"TR_GetHitBoxIndex", smn_TRGetHitBoxIndex},
{"TR_ClipRayToEntity", smn_TRClipRayToEntity},
{"TR_ClipRayToEntityEx", smn_TRClipRayToEntityEx},
{"TR_ClipRayHullToEntity", smn_TRClipRayHullToEntity},

View File

@ -255,12 +255,10 @@ ValveCall *CreateValveVCall(unsigned int vtableIdx,
/* Get return information - encode only */
PassInfo retBuf;
ObjectField retFieldBuf[16];
size_t retBufSize = 0;
bool retbuf_needs_extra;
if (retInfo)
{
retBuf.fields = retFieldBuf;
if ((size = ValveParamToBinParam(retInfo->vtype, retInfo->type, retInfo->flags, &retBuf, retbuf_needs_extra)) == 0)
{
delete vc;
@ -271,14 +269,12 @@ ValveCall *CreateValveVCall(unsigned int vtableIdx,
/* Get parameter info */
PassInfo paramBuf[32];
ObjectField fieldBuf[32][16];
size_t sizes[32];
size_t normSize = 0;
size_t extraSize = 0;
for (unsigned int i=0; i<numParams; i++)
{
bool needs_extra;
paramBuf[i].fields = fieldBuf[i];
if ((size = ValveParamToBinParam(params[i].vtype,
params[i].type,
params[i].flags,

View File

@ -1,14 +1,15 @@
SOURCEMOD LICENSE INFORMATION
VERSION: 2019-9-30
VERSION: JUNE-13-2008
-----------------------------
SourceMod is licensed under the GNU General Public License, version 3.
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" 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.
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.
As an additional special exception to the GNU General Public License 3.0,
AlliedModders LLC permits dual-licensing of DERIVATIVE WORKS ONLY (that is,
@ -26,6 +27,7 @@ License version 2 (without an "or any higher version" clause) if and only if
the work was already GNU General Public License 2.0 exclusive. This clause is
provided for backwards compatibility only.
A copy of the JIT License is available in JIT.txt.
A copy of the GNU General Public License 2.0 is available in GPLv2.txt.
A copy of the GNU General Public License 3.0 is available in GPLv3.txt.
@ -33,4 +35,5 @@ SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
Source is Copyright (C) Valve Corporation.
All trademarks are property of their respective owners in the US and other countries.
All trademarks are property of their respective owners in the US and other

View File

@ -4,26 +4,26 @@
#define ARRAY_STRING_LENGTH 32
enum struct GroupCommands
enum GroupCommands
{
ArrayList groupListName;
ArrayList groupListCommand;
}
ArrayList:groupListName,
ArrayList:groupListCommand
};
GroupCommands g_groupList;
int g_groupList[GroupCommands];
int g_groupCount;
SMCParser g_configParser;
enum struct Places
enum Places
{
int category;
int item;
int replaceNum;
}
Place_Category,
Place_Item,
Place_ReplaceNum
};
char g_command[MAXPLAYERS+1][CMD_LENGTH];
Places g_currentPlace[MAXPLAYERS+1];
int g_currentPlace[MAXPLAYERS+1][Places];
/**
* What to put in the 'info' menu field (for PlayerList and Player_Team menus only)
@ -331,11 +331,11 @@ void ParseConfigs()
g_configParser.OnKeyValue = KeyValue;
g_configParser.OnLeaveSection = EndSection;
delete g_groupList.groupListName;
delete g_groupList.groupListCommand;
delete g_groupList[groupListName];
delete g_groupList[groupListCommand];
g_groupList.groupListName = new ArrayList(ARRAY_STRING_LENGTH);
g_groupList.groupListCommand = new ArrayList(ARRAY_STRING_LENGTH);
g_groupList[groupListName] = new ArrayList(ARRAY_STRING_LENGTH);
g_groupList[groupListCommand] = new ArrayList(ARRAY_STRING_LENGTH);
char configPath[256];
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
@ -376,13 +376,13 @@ public SMCResult NewSection(SMCParser smc, const char[] name, bool opt_quotes)
public SMCResult KeyValue(SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes)
{
g_groupList.groupListName.PushString(key);
g_groupList.groupListCommand.PushString(value);
g_groupList[groupListName].PushString(key);
g_groupList[groupListCommand].PushString(value);
}
public SMCResult EndSection(SMCParser smc)
{
g_groupCount = g_groupList.groupListName.Length;
g_groupCount = g_groupList[groupListName].Length;
}
public void DynamicMenuCategoryHandler(TopMenu topmenu,
@ -421,8 +421,8 @@ public void DynamicMenuItemHandler(TopMenu topmenu,
strcopy(g_command[param], sizeof(g_command[]), output.cmd);
g_currentPlace[param].item = location;
g_currentPlace[param].replaceNum = 1;
g_currentPlace[param][Place_Item] = location;
g_currentPlace[param][Place_ReplaceNum] = 1;
ParamCheck(param);
}
@ -436,19 +436,19 @@ public void ParamCheck(int client)
Item outputItem;
Submenu outputSubmenu;
g_DataArray.GetArray(g_currentPlace[client].item, outputItem);
g_DataArray.GetArray(g_currentPlace[client][Place_Item], outputItem);
if (g_currentPlace[client].replaceNum < 1)
if (g_currentPlace[client][Place_ReplaceNum] < 1)
{
g_currentPlace[client].replaceNum = 1;
g_currentPlace[client][Place_ReplaceNum] = 1;
}
Format(buffer, 5, "#%i", g_currentPlace[client].replaceNum);
Format(buffer2, 5, "@%i", g_currentPlace[client].replaceNum);
Format(buffer, 5, "#%i", g_currentPlace[client][Place_ReplaceNum]);
Format(buffer2, 5, "@%i", g_currentPlace[client][Place_ReplaceNum]);
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
{
outputItem.submenus.GetArray(g_currentPlace[client].replaceNum - 1, outputSubmenu);
outputItem.submenus.GetArray(g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu);
Menu itemMenu = new Menu(Menu_Selection);
itemMenu.ExitBackButton = true;
@ -460,8 +460,8 @@ public void ParamCheck(int client)
for (int i = 0; i<g_groupCount; i++)
{
g_groupList.groupListName.GetString(i, nameBuffer, sizeof(nameBuffer));
g_groupList.groupListCommand.GetString(i, commandBuffer, sizeof(commandBuffer));
g_groupList[groupListName].GetString(i, nameBuffer, sizeof(nameBuffer));
g_groupList[groupListCommand].GetString(i, commandBuffer, sizeof(commandBuffer));
itemMenu.AddItem(commandBuffer, nameBuffer);
}
}
@ -591,7 +591,7 @@ public void ParamCheck(int client)
}
g_command[client][0] = '\0';
g_currentPlace[client].replaceNum = 1;
g_currentPlace[client][Place_ReplaceNum] = 1;
}
}
@ -622,16 +622,16 @@ public int Menu_Selection(Menu menu, MenuAction action, int param1, int param2)
char infobuffer[NAME_LENGTH+2];
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
Format(buffer, 5, "#%i", g_currentPlace[param1].replaceNum);
Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
//replace #num with the selected option (quoted)
Format(buffer, 5, "@%i", g_currentPlace[param1].replaceNum);
Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
//replace @num with the selected option (unquoted)
// Increment the parameter counter.
g_currentPlace[param1].replaceNum++;
g_currentPlace[param1][Place_ReplaceNum]++;
ParamCheck(param1);
}

View File

@ -34,7 +34,6 @@
#pragma semicolon 1
#include <sourcemod>
#include <basecomm>
#pragma newdecls required
@ -81,9 +80,6 @@ public void OnPluginStart()
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
{
if (client <= 0 || BaseComm_IsClientGagged(client))
return Plugin_Continue;
int startidx;
if (sArgs[startidx] != CHAT_SYMBOL)
return Plugin_Continue;
@ -92,20 +88,51 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
if (strcmp(command, "say", false) == 0)
{
if (!CheckCommandAccess(client, "sm_psay_chat", ADMFLAG_CHAT))
if (sArgs[startidx] != CHAT_SYMBOL) // sm_say alias
{
if (!CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT))
{
return Plugin_Continue;
}
SendChatToAll(client, sArgs[startidx]);
LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, sArgs[startidx]);
return Plugin_Stop;
}
startidx++;
if (sArgs[startidx] != CHAT_SYMBOL) // sm_psay alias
{
if (!CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT))
{
return Plugin_Continue;
}
char arg[64];
int len = BreakString(sArgs[startidx], arg, sizeof(arg));
int target = FindTarget(client, arg, true, false);
if (target == -1 || len == -1)
return Plugin_Stop;
SendPrivateChat(client, target, sArgs[startidx+len]);
return Plugin_Stop;
}
startidx++;
// sm_csay alias
if (!CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT))
{
return Plugin_Continue;
}
char arg[64];
int len = BreakString(sArgs[startidx], arg, sizeof(arg));
int target = FindTarget(client, arg, true, false);
if (target == -1 || len == -1)
return Plugin_Stop;
SendPrivateChat(client, target, sArgs[startidx+len]);
DisplayCenterTextToAll(client, sArgs[startidx]);
LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, sArgs[startidx]);
return Plugin_Stop;
}

View File

@ -186,53 +186,52 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
{
case CommType_Mute:
{
PerformMute(target);
LogAction(param1, target, "\"%L\" muted \"%L\"", param1, target);
PerformMute(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
}
case CommType_UnMute:
{
PerformUnMute(target);
LogAction(param1, target, "\"%L\" unmuted \"%L\"", param1, target);
PerformUnMute(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
}
case CommType_Gag:
{
PerformGag(target);
LogAction(param1, target, "\"%L\" gagged \"%L\"", param1, target);
PerformGag(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
}
case CommType_UnGag:
{
PerformUnGag(target);
LogAction(param1, target, "\"%L\" ungagged \"%L\"", param1, target);
PerformUnGag(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
}
case CommType_Silence:
{
PerformSilence(target);
LogAction(param1, target, "\"%L\" silenced \"%L\"", param1, target);
PerformSilence(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
}
case CommType_UnSilence:
{
PerformUnSilence(target);
LogAction(param1, target, "\"%L\" unsilenced \"%L\"", param1, target);
PerformUnSilence(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
}
}
}
}
void PerformMute(int target)
void PerformMute(int client, int target, bool silent=false)
{
playerstate[target].isMuted = true;
SetClientListeningFlags(target, VOICE_MUTED);
FireOnClientMute(target, true);
if (!silent)
{
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
}
}
void PerformUnMute(int target)
void PerformUnMute(int client, int target, bool silent=false)
{
playerstate[target].isMuted = false;
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
@ -249,21 +248,36 @@ void PerformUnMute(int target)
}
FireOnClientMute(target, false);
if (!silent)
{
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
}
}
void PerformGag(int target)
void PerformGag(int client, int target, bool silent=false)
{
playerstate[target].isGagged = true;
FireOnClientGag(target, true);
if (!silent)
{
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
}
}
void PerformUnGag(int target)
void PerformUnGag(int client, int target, bool silent=false)
{
playerstate[target].isGagged = false;
FireOnClientGag(target, false);
if (!silent)
{
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
}
}
void PerformSilence(int target)
void PerformSilence(int client, int target)
{
if (!playerstate[target].isGagged)
{
@ -277,9 +291,11 @@ void PerformSilence(int target)
SetClientListeningFlags(target, VOICE_MUTED);
FireOnClientMute(target, true);
}
LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
}
void PerformUnSilence(int target)
void PerformUnSilence(int client, int target)
{
if (playerstate[target].isGagged)
{
@ -305,6 +321,8 @@ void PerformUnSilence(int target)
}
FireOnClientMute(target, false);
}
LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
}
public Action Command_Mute(int client, int args)
@ -340,18 +358,16 @@ public Action Command_Mute(int client, int args)
{
int target = target_list[i];
PerformMute(target);
PerformMute(client, target);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
LogAction(client, -1, "\"%L\" muted \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" muted \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
@ -390,18 +406,16 @@ public Action Command_Gag(int client, int args)
{
int target = target_list[i];
PerformGag(target);
PerformGag(client, target);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
LogAction(client, -1, "\"%L\" gagged \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" gagged \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
@ -440,18 +454,16 @@ public Action Command_Silence(int client, int args)
{
int target = target_list[i];
PerformSilence(target);
PerformSilence(client, target);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
LogAction(client, -1, "\"%L\" silenced \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" silenced \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
@ -495,11 +507,9 @@ public Action Command_Unmute(int client, int args)
continue;
}
PerformUnMute(target);
PerformUnMute(client, target);
}
LogAction(client, -1, "\"%L\" unmuted \"%s\"", client, target_name);
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
@ -545,18 +555,16 @@ public Action Command_Ungag(int client, int args)
{
int target = target_list[i];
PerformUnGag(target);
PerformUnGag(client, target);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
LogAction(client, -1, "\"%L\" ungagged \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" ungagged \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
@ -595,18 +603,16 @@ public Action Command_Unsilence(int client, int args)
{
int target = target_list[i];
PerformUnSilence(target);
PerformUnSilence(client, target);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
LogAction(client, -1, "\"%L\" unsilenced \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" unsilenced \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -85,7 +85,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
return false;
}
PerformGag(client);
PerformGag(-1, client, true);
}
else
{
@ -94,7 +94,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
return false;
}
PerformUnGag(client);
PerformUnGag(-1, client, true);
}
return true;
@ -122,7 +122,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
return false;
}
PerformMute(client);
PerformMute(-1, client, true);
}
else
{
@ -131,7 +131,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
return false;
}
PerformUnMute(client);
PerformUnMute(-1, client, true);
}
return true;

View File

@ -31,8 +31,10 @@
* Version: $Id$
*/
void PerformKick(int target, const char[] reason)
void PerformKick(int client, int target, const char[] reason)
{
LogAction(client, target, "\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
if (reason[0] == '\0')
{
KickClient(target, "%t", "Kicked by admin");
@ -108,8 +110,7 @@ public int MenuHandler_Kick(Menu menu, MenuAction action, int param1, int param2
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_s", name);
PerformKick(target, "");
LogAction(param1, target, "\"%L\" kicked \"%L\"", param1, target);
PerformKick(param1, target, "");
}
/* Re-draw the menu if they're still valid */
@ -200,22 +201,13 @@ public Action Command_Kick(int client, int args)
}
else
{
PerformKick(target_list[i], reason);
PerformKick(client, target_list[i], reason);
}
}
if (kick_self)
{
PerformKick(client, reason);
}
if (tn_is_ml)
{
LogAction(client, -1, "\"%L\" kicked \"%s\" (reason \"%s\")", client, target_name, reason);
}
else
{
LogAction(client, target_list[0], "\"%L\" kicked \"%L\" (reason \"%s\")", client, target_list[0], reason);
PerformKick(client, client, reason);
}
}
else

View File

@ -46,11 +46,6 @@ public int MenuHandler_ChangeMap(Menu menu, MenuAction action, int param1, int p
menu.GetItem(param2, map, sizeof(map));
if (!map[0])
{
GetCurrentMap(map, sizeof(map));
}
ShowActivity2(param1, "[SM] ", "%t", "Changing map", map);
LogAction(param1, -1, "\"%L\" changed map to \"%s\"", param1, map);
@ -162,14 +157,10 @@ int LoadMapList(Menu menu)
char map_name[PLATFORM_MAX_PATH];
int map_count = GetArraySize(g_map_array);
menu.AddItem("", "Restart Current Map");
for (int i = 0; i < map_count; i++)
{
char displayName[PLATFORM_MAX_PATH];
GetArrayString(g_map_array, i, map_name, sizeof(map_name));
GetMapDisplayName(map_name, displayName, sizeof(displayName));
menu.AddItem(map_name, displayName);
menu.AddItem(map_name, map_name);
}
return map_count;

View File

@ -59,12 +59,18 @@ void KillAllBeacons()
}
}
void PerformBeacon(int target)
void PerformBeacon(int client, int target)
{
if (g_BeaconSerial[target] == 0)
{
CreateBeacon(target);
LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
}
else
{
KillBeacon(target);
LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
}
}
public Action Timer_Beacon(Handle timer, any value)
@ -181,9 +187,8 @@ public int MenuHandler_Beacon(Menu menu, MenuAction action, int param1, int para
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
PerformBeacon(target);
PerformBeacon(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled beacon on target", "_s", name);
LogAction(param1, target, "\"%L\" toggled beacon on \"%L\"", param1, target);
}
/* Re-draw the menu if they're still valid */
@ -225,18 +230,16 @@ public Action Command_Beacon(int client, int args)
for (int i = 0; i < target_count; i++)
{
PerformBeacon(target_list[i]);
PerformBeacon(client, target_list[i]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", target_name);
LogAction(client, -1, "\"%L\" toggled beacon on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled beacon on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -33,7 +33,7 @@
int g_BlindTarget[MAXPLAYERS+1];
void PerformBlind(int target, int amount)
void PerformBlind(int client, int target, int amount)
{
int targets[2];
targets[0] = target;
@ -75,6 +75,8 @@ void PerformBlind(int target, int amount)
}
EndMessage();
LogAction(client, target, "\"%L\" set blind on \"%L\" (amount \"%d\")", client, target, amount);
}
public void AdminMenu_Blind(TopMenu topmenu,
@ -209,8 +211,7 @@ public int MenuHandler_Amount(Menu menu, MenuAction action, int param1, int para
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
PerformBlind(target, amount);
LogAction(param1, target, "\"%L\" set blind on \"%L\", amount %d.", param1, target, amount);
PerformBlind(param1, target, amount);
ShowActivity2(param1, "[SM] ", "%t", "Set blind on target", "_s", name, amount);
}
@ -275,18 +276,16 @@ public Action Command_Blind(int client, int args)
for (int i = 0; i < target_count; i++)
{
PerformBlind(target_list[i], amount);
PerformBlind(client, target_list[i], amount);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Set blind on target", target_name);
LogAction(client, -1, "\"%L\" set blind on \"%s\", amount %d.", client, target_name, amount);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Set blind on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" set blind on \"%L\", amount %d.", client, target_list[0], amount);
}
return Plugin_Handled;

View File

@ -106,7 +106,7 @@ void KillAllDrugs()
}
}
void PerformDrug(int target, int toggle)
void PerformDrug(int client, int target, int toggle)
{
switch (toggle)
{
@ -115,10 +115,12 @@ void PerformDrug(int target, int toggle)
if (g_DrugTimers[target] == null)
{
CreateDrug(target);
LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
}
else
{
KillDrug(target);
LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
}
}
@ -127,6 +129,7 @@ void PerformDrug(int target, int toggle)
if (g_DrugTimers[target] == null)
{
CreateDrug(target);
LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
}
}
@ -135,6 +138,7 @@ void PerformDrug(int target, int toggle)
if (g_DrugTimers[target] != null)
{
KillDrug(target);
LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
}
}
}
@ -264,8 +268,7 @@ public int MenuHandler_Drug(Menu menu, MenuAction action, int param1, int param2
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
PerformDrug(target, 2);
LogAction(param1, target, "\"%L\" toggled drugs on \"%L\"", param1, target);
PerformDrug(param1, target, 2);
ShowActivity2(param1, "[SM] ", "%t", "Toggled drug on target", "_s", name);
}
@ -323,18 +326,16 @@ public Action Command_Drug(int client, int args)
for (int i = 0; i < target_count; i++)
{
PerformDrug(target_list[i], toggle);
PerformDrug(client, target_list[i], toggle);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", target_name);
LogAction(client, -1, "\"%L\" toggled drugs on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled drugs on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -64,16 +64,24 @@ void KillAllFireBombs()
}
}
void PerformBurn(int client, int target, float seconds)
{
IgniteEntity(target, seconds);
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
}
void PerformFireBomb(int client, int target)
{
if (g_FireBombSerial[client] == 0)
{
CreateFireBomb(target);
LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
}
else
{
KillFireBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
}
}
@ -298,8 +306,7 @@ public int MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2
{
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
IgniteEntity(target, 20.0);
LogAction(param1, target, "\"%L\" ignited \"%L\" (seconds \"20\")", param1, target);
PerformBurn(param1, target, 20.0);
ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
}
@ -346,7 +353,6 @@ public int MenuHandler_FireBomb(Menu menu, MenuAction action, int param1, int pa
GetClientName(target, name, sizeof(name));
PerformFireBomb(param1, target);
LogAction(param1, target, "\"%L\" toggled FireBomb on \"%L\"", param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled FireBomb on target", "_s", name);
}
@ -402,18 +408,16 @@ public Action Command_Burn(int client, int args)
for (int i = 0; i < target_count; i++)
{
IgniteEntity(target_list[i], seconds);
PerformBurn(client, target_list[i], seconds);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", target_name);
LogAction(client, -1, "\"%L\" ignited \"%s\" (seconds \"%f\")", client, target_name, seconds);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target_list[0], seconds);
}
return Plugin_Handled;
@ -456,12 +460,10 @@ public Action Command_FireBomb(int client, int args)
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", target_name);
LogAction(client, -1, "\"%L\" toggled FireBomb on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled FireBomb on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
}

View File

@ -33,6 +33,12 @@
int g_GravityTarget[MAXPLAYERS+1];
void PerformGravity(int client, int target, float amount)
{
SetEntityGravity(target, amount);
LogAction(client, target, "\"%L\" set gravity on \"%L\" (amount \"%f\")", client, target, amount);
}
public void AdminMenu_Gravity(TopMenu topmenu,
TopMenuAction action,
TopMenuObject object_id,
@ -163,8 +169,7 @@ public int MenuHandler_GravityAmount(Menu menu, MenuAction action, int param1, i
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
SetEntityGravity(target, amount);
LogAction(param1, target, "\"%L\" set gravity on \"%L\" to %f.", param1, target, amount);
PerformGravity(param1, target, amount);
ShowActivity2(param1, "[SM] ", "%t", "Set gravity on target", "_s", name, amount);
}
@ -224,18 +229,16 @@ public Action Command_Gravity(int client, int args)
for (int i = 0; i < target_count; i++)
{
SetEntityGravity(target_list[i], amount);
PerformGravity(client, target_list[i], amount);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", target_name);
LogAction(client, -1, "\"%L\" set gravity on \"%s\" to %f.", client, target_name, amount);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" set gravity on \"%L\" to %f.", client, target_list[0], amount);
}
return Plugin_Handled;

View File

@ -125,12 +125,24 @@ void KillAllFreezes()
}
}
void PerformFreezeBomb(int target)
void PerformFreeze(int client, int target, int time)
{
FreezeClient(target, time);
LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
}
void PerformFreezeBomb(int client, int target)
{
if (g_FreezeBombSerial[target] != 0)
{
KillFreezeBomb(target);
LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
}
else
{
CreateFreezeBomb(target);
LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
}
}
public Action Timer_Freeze(Handle timer, any value)
@ -409,8 +421,7 @@ public int MenuHandler_Freeze(Menu menu, MenuAction action, int param1, int para
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
FreezeClient(target, g_Cvar_FreezeDuration.IntValue);
LogAction(param1, target, "\"%L\" froze \"%L\"", param1, target);
PerformFreeze(param1, target, g_Cvar_FreezeDuration.IntValue);
ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
}
@ -456,8 +467,7 @@ public int MenuHandler_FreezeBomb(Menu menu, MenuAction action, int param1, int
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
PerformFreezeBomb(target);
LogAction(param1, target, "\"%L\" toggled FreezeBomb on \"%L\"", param1, target);
PerformFreezeBomb(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
}
@ -513,18 +523,16 @@ public Action Command_Freeze(int client, int args)
for (int i = 0; i < target_count; i++)
{
FreezeClient(target_list[i], seconds);
PerformFreeze(client, target_list[i], seconds);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Froze target", target_name);
LogAction(client, -1, "\"%L\" froze \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Froze target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" froze \"%L\"", client, target_list[0]);
}
return Plugin_Handled;
@ -561,18 +569,16 @@ public Action Command_FreezeBomb(int client, int args)
for (int i = 0; i < target_count; i++)
{
PerformFreezeBomb(target_list[i]);
PerformFreezeBomb(client, target_list[i]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", target_name);
LogAction(client, -1, "\"%L\" toggled FreezeBomb on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled FreezeBomb on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -31,7 +31,7 @@
* Version: $Id$
*/
void PerformNoClip(int target)
void PerformNoClip(int client, int target)
{
MoveType movetype = GetEntityMoveType(target);
@ -43,6 +43,8 @@ void PerformNoClip(int target)
{
SetEntityMoveType(target, MOVETYPE_WALK);
}
LogAction(client, target, "\"%L\" toggled noclip on \"%L\"", client, target);
}
public void AdminMenu_NoClip(TopMenu topmenu,
@ -110,8 +112,7 @@ public int MenuHandler_NoClip(Menu menu, MenuAction action, int param1, int para
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
PerformNoClip(target);
LogAction(param1, target, "\"%L\" toggled noclip on \"%L\"", param1, target);
PerformNoClip(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled noclip on target", "_s", name);
}
@ -154,18 +155,16 @@ public Action Command_NoClip(int client, int args)
for (int i = 0; i < target_count; i++)
{
PerformNoClip(target_list[i]);
PerformNoClip(client, target_list[i]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", target_name);
LogAction(client, -1, "\"%L\" toggled noclip on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled noclip on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -68,11 +68,13 @@ void PerformTimeBomb(int client, int target)
if (g_TimeBombSerial[target] == 0)
{
CreateTimeBomb(target);
LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
}
else
{
KillTimeBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
}
}
@ -277,7 +279,6 @@ public int MenuHandler_TimeBomb(Menu menu, MenuAction action, int param1, int pa
GetClientName(target, name, sizeof(name));
PerformTimeBomb(param1, target);
LogAction(param1, target, "\"%L\" toggled TimeBomb on \"%L\"", param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", name);
}
@ -326,12 +327,10 @@ public Action Command_TimeBomb(int client, int args)
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", target_name);
LogAction(client, -1, "\"%L\" toggled TimeBomb on \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" toggled TimeBomb on \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -741,15 +741,6 @@ native float GetClientAvgData(int client, NetFlow flow);
*/
native float GetClientAvgPackets(int client, NetFlow flow);
/**
* Returns the client's baseserver IClient pointer.
*
* @param client Player's index.
* @return IClient address.
* @error Invalid client index, client not connected, or fake client.
*/
native Address GetClientIClient(int client);
/**
* Translates an userid index to the real player index.
*

View File

@ -179,23 +179,16 @@ stock void ReplyToTargetError(int client, int reason, bool dynamic=true)
}
}
#define FEATURECAP_MULTITARGETFILTER_CLIENTPARAM "SourceMod MultiTargetFilter ClientParam"
/**
* Adds clients to a multi-target filter.
*
* @param pattern Pattern name.
* @param clients Array to fill with unique, valid client indexes.
* @param client Client that triggered this filter.
* @return True if pattern was recognized, false otherwise.
*
* @note To see if the client param is available, use FeatureType_Capability and FEATURECAP_MULTITARGETFILTER_CLIENTPARAM.
*/
typeset MultiTargetFilter {
function bool (const char[] pattern, Handle clients);
function bool (const char[] pattern, ArrayList clients);
function bool (const char[] pattern, Handle clients, int client);
function bool (const char[] pattern, ArrayList clients, int client);
}
/**

View File

@ -293,17 +293,6 @@ native void Call_StartForward(Handle fwd);
*/
native void Call_StartFunction(Handle plugin, Function func);
/**
* Starts a call to a native.
*
* @note Cannot be used during an incomplete call.
*
* @param name Name of the native.
* @return True on success, false otherwise.
* @error Invalid function, or called before another call has completed.
*/
native bool Call_StartNative(const char[] name);
/**
* Pushes a cell onto the current call.
*
@ -427,20 +416,6 @@ native void Call_PushNullString();
*/
native int Call_Finish(any &result=0);
/**
* Completes a call to a function or forward's call list.
* Catches exceptions thrown by the native.
*
* @note Cannot be used before a call has been started.
*
* @param result Return value of function or forward's call list.
* @param exception Buffer to store the exception in.
* @param maxlength Maximum length of the buffer.
* @return SP_ERROR_NONE on success, any other integer on failure.
* @error Called before a call has been started.
*/
native int Call_FinishEx(any &result=0, char[] exception, int maxlength);
/**
* Cancels a call to a function or forward's call list.
*

View File

@ -307,23 +307,9 @@ methodmap Menu < Handle
// @param style By-reference variable to store drawing flags.
// @param dispBuf Display buffer.
// @param dispBufLen Maximum length of the display buffer.
// @param client Client index. Must be specified if menu is per-client random shuffled, -1 to ignore.
// @return True on success, false if position is invalid.
public native bool GetItem(int position, char[] infoBuf, int infoBufLen,
int &style=0, char[] dispBuf="", int dispBufLen=0, int client=0);
// Generates a per-client random mapping for the current vote options.
//
// @param start Menu item index to start randomizing from.
// @param stop Menu item index to stop randomizing at. -1 = infinite
public native void ShufflePerClient(int start=0, int stop=-1);
// Fills the client vote option mapping with user supplied values.
//
// @param client Client index.
// @param array Integer array with mapping.
// @param length Length of array.
public native void SetClientMapping(int client, int[] array, int length);
int &style=0, char[] dispBuf="", int dispBufLen=0);
// Sets the menu's default title/instruction message.
//
@ -551,7 +537,6 @@ native void RemoveAllMenuItems(Handle menu);
* @param style By-reference variable to store drawing flags.
* @param dispBuf Display buffer.
* @param dispBufLen Maximum length of the display buffer.
* @param client Client index. Must be specified if menu is per-client random shuffled, -1 to ignore.
* @return True on success, false if position is invalid.
* @error Invalid Handle.
*/
@ -561,27 +546,7 @@ native bool GetMenuItem(Handle menu,
int infoBufLen,
int &style=0,
char[] dispBuf="",
int dispBufLen=0,
int client=0);
/**
* Generates a per-client random mapping for the current vote options.
*
* @param menu Menu Handle.
* @param start Menu item index to start randomizing from.
* @param stop Menu item index to stop randomizing at. -1 = infinite
*/
native void MenuShufflePerClient(Handle menu, int start=0, int stop=-1);
/*
* Fills the client vote option mapping with user supplied values.
*
* @param menu Menu Handle.
* @param client Client index.
* @param array Integer array with mapping.
* @param length Length of array.
*/
native void MenuSetClientMapping(Handle menu, int client, int[] array, int length);
int dispBufLen=0);
/**
* Returns the first item on the page of a currently selected menu.

View File

@ -333,14 +333,6 @@ typeset SDKHookCB
*/
forward void OnEntityCreated(int entity, const char[] classname);
/**
* When an entity is spawned
*
* @param entity Entity index
* @param classname Class name
*/
forward void OnEntitySpawned(int entity, const char[] classname);
/**
* When an entity is destroyed
*
@ -408,11 +400,10 @@ native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback);
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
* @param damageForce Velocity of damage force
* @param damagePosition Origin of damage
* @param damageCustom User custom
*/
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
float damage, int damageType=DMG_GENERIC, int weapon=-1,
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR, int damageCustom=0);
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR);
/**
* Forces a client to drop the specified weapon

View File

@ -633,18 +633,6 @@ native bool TR_DidHit(Handle hndl=INVALID_HANDLE);
*/
native int TR_GetHitGroup(Handle hndl=INVALID_HANDLE);
/**
* Returns in which hitbox the trace collided if any.
*
* Note: if the entity that collided with the trace is the world entity,
* then this function doesn't return an hitbox index but a static prop index.
*
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Hitbox index (Or static prop index).
* @error Invalid Handle.
*/
native int TR_GetHitBoxIndex(Handle hndl=INVALID_HANDLE);
/**
* Find the normal vector to the collision plane of a trace.
*

View File

@ -33,8 +33,10 @@
char g_NewName[MAXPLAYERS+1][MAX_NAME_LENGTH];
void PerformRename(int target)
void PerformRename(int client, int target)
{
LogAction(client, target, "\"%L\" renamed \"%L\" (to \"%s\")", client, target, g_NewName[target]);
SetClientName(target, g_NewName[target]);
g_NewName[target][0] = '\0';
@ -107,8 +109,7 @@ public int MenuHandler_Rename(Menu menu, MenuAction action, int param1, int para
RandomizeName(target);
ShowActivity2(param1, "[SM] ", "%t", "Renamed target", "_s", name);
LogAction(param1, target, "\"%L\" renamed \"%L\" to \"%s\")", param1, target, g_NewName[target]);
PerformRename(target);
PerformRename(param1, target);
}
DisplayRenameTargetMenu(param1);
}
@ -167,12 +168,10 @@ public Action Command_Rename(int client, int args)
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Renamed target", target_name);
LogAction(client, -1, "\"%L\" renamed \"%s\" to \"%s\")", client, target_name, arg2);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Renamed target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" renamed \"%L\" to \"%s\")", client, target_list[0], arg2);
}
for (int i = 0; i < target_count; i++)
@ -192,7 +191,7 @@ public Action Command_Rename(int client, int args)
Format(g_NewName[target_list[i]], MAX_NAME_LENGTH, "%s", arg2);
}
}
PerformRename(target_list[i]);
PerformRename(client, target_list[i]);
}
}
else

View File

@ -33,6 +33,12 @@
int g_SlapDamage[MAXPLAYERS+1];
void PerformSlap(int client, int target, int damage)
{
LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
SlapPlayer(target, damage, true);
}
void DisplaySlapDamageMenu(int client)
{
Menu menu = new Menu(MenuHandler_SlapDamage);
@ -145,8 +151,7 @@ public int MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2
{
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
SlapPlayer(target, g_SlapDamage[param1]);
LogAction(param1, target, "\"%L\" slapped \"%L\" (damage \"%d\")", param1, target, g_SlapDamage[param1]);
PerformSlap(param1, target, g_SlapDamage[param1]);
ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name);
}
@ -197,18 +202,16 @@ public Action Command_Slap(int client, int args)
for (int i = 0; i < target_count; i++)
{
SlapPlayer(target_list[i], damage);
PerformSlap(client, target_list[i], damage);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Slapped target", target_name);
LogAction(client, -1, "\"%L\" slapped \"%s\" (damage \"%d\")", client, target_name, damage);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Slapped target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" slapped \"%L\" (damage \"%d\")", client, target_list[0], damage);
}
return Plugin_Handled;

View File

@ -31,6 +31,12 @@
* Version: $Id$
*/
void PerformSlay(int client, int target)
{
LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
ForcePlayerSuicide(target);
}
void DisplaySlayMenu(int client)
{
Menu menu = new Menu(MenuHandler_Slay);
@ -99,8 +105,7 @@ public int MenuHandler_Slay(Menu menu, MenuAction action, int param1, int param2
{
char name[MAX_NAME_LENGTH];
GetClientName(target, name, sizeof(name));
ForcePlayerSuicide(target);
LogAction(param1, target, "\"%L\" slayed \"%L\"", param1, target);
PerformSlay(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name);
}
@ -139,18 +144,16 @@ public Action Command_Slay(int client, int args)
for (int i = 0; i < target_count; i++)
{
ForcePlayerSuicide(target_list[i]);
PerformSlay(client, target_list[i]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Slayed target", target_name);
LogAction(client, -1, "\"%L\" slayed \"%s\"", client, target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Slayed target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" slayed \"%L\"", client, target_list[0]);
}
return Plugin_Handled;

View File

@ -107,17 +107,16 @@ public Action Command_Play(int client, int args)
for (int i = 0; i < target_count; i++)
{
ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
LogAction(client, -1, "\"%L\" played sound on \"%s\" (file \"%s\")", client, target_name, Arguments[len]);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
LogAction(client, target_list[0], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[0], Arguments[len]);
}
return Plugin_Handled;

View File

@ -1 +1 @@
1.11.0
1.10.0

View File

@ -48,11 +48,6 @@
#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
#define DETOUR_STATIC_CALL(name) (name##_Actual)
#define DETOUR_MEMBER_MCALL_CALLBACK(name, classptr) \
((name##Class *)classptr->*(&name##Class::name))
#define DETOUR_MEMBER_MCALL_ORIGINAL(name, classptr) \
((name##Class *)classptr->*(name##Class::name##_Actual))
#define DETOUR_DECL_STATIC0(name, ret) \
ret (*name##_Actual)(void) = NULL; \
ret name(void)
@ -89,14 +84,6 @@ ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5na
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
#define DETOUR_DECL_STATIC9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
#define DETOUR_DECL_STATIC10(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name) \
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type) = NULL; \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name)
#define DETOUR_DECL_MEMBER0(name, ret) \
class name##Class \
{ \
@ -187,65 +174,6 @@ public: \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
#define DETOUR_DECL_MEMBER9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
#define DETOUR_DECL_MEMBER10(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name)
#define DETOUR_DECL_MEMBER11(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name)
#define DETOUR_DECL_MEMBER12(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name)
#define DETOUR_DECL_MEMBER13(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name, p13type, p13name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name)
#define DETOUR_DECL_MEMBER14(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name, p13type, p13name, p14type, p14name) \
class name##Class \
{ \
public: \
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name, p14type p14name); \
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type, p14type); \
}; \
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type, p14type) = NULL; \
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name, p14type p14name)
#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)

View File

@ -36,7 +36,7 @@
#include <IHandleSys.h>
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
#define SMINTERFACE_MENUMANAGER_VERSION 17
#define SMINTERFACE_MENUMANAGER_VERSION 16
/**
* @file IMenuManager.h
@ -485,10 +485,9 @@ namespace SourceMod
*
* @param position Position, starting from 0.
* @param draw Optional pointer to store a draw information.
* @param client Client index. (Important for randomized menus.)
* @return Info string pointer, or NULL if position was invalid.
*/
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw, int client=0) =0;
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw) =0;
/**
* @brief Returns the number of items.
@ -637,35 +636,6 @@ namespace SourceMod
* @return Approximate number of bytes being used.
*/
virtual unsigned int GetApproxMemUsage() =0;
/**
* @brief Generates a per-client random mapping for the current vote options.
* @param start Menu item index to start randomizing from.
* @param stop Menu item index to stop randomizing at. -1 = infinite
*/
virtual void ShufflePerClient(int start=0, int stop=-1) =0;
/**
* @brief Fills the client vote option mapping with user supplied values.
* @param client Client index.
* @param array Integer array with mapping.
* @param length Length of array.
*/
virtual void SetClientMapping(int client, int *array, int length) =0;
/**
* @brief Returns true if the menu has a per-client random mapping.
* @return True on success, false otherwise.
*/
virtual bool IsPerClientShuffled() =0;
/**
* @brief Returns the actual (not shuffled) item index from the client position.
* @param client Client index.
* @param position Position, starting from 0.
* @return Actual item index in menu.
*/
virtual unsigned int GetRealItemIndex(int client, unsigned int position) =0;
};
/**

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 22
#define SMINTERFACE_PLAYERMANAGER_VERSION 21
struct edict_t;
class IPlayerInfo;
@ -543,16 +543,9 @@ namespace SourceMod
/**
* @brief Returns the number of players currently connected.
*
* @return Current number of connected players.
*/
virtual int GetNumPlayers() =0;
/**
* @brief Returns the number of clients currently connected.
*
* @return Current number of connected clients.
*/
virtual int GetNumClients() =0;
virtual int GetNumPlayers() =0;
/**
* @brief Returns the client index by its userid.

@ -1 +1 @@
Subproject commit e00a845c6bc415995ddc4b7ec538d1704fdd0122
Subproject commit 2be66bdbdf965ebf19dacc2e0874f81f22fd6fa8

View File

@ -36,7 +36,7 @@
#include <IShareSys.h>
#define SMINTERFACE_SDKHOOKS_NAME "ISDKHooks"
#define SMINTERFACE_SDKHOOKS_VERSION 2
#define SMINTERFACE_SDKHOOKS_VERSION 1
class CBaseEntity;
@ -71,16 +71,6 @@ namespace SourceMod
virtual void OnEntityDestroyed(CBaseEntity *pEntity)
{
}
/**
* @brief When an entity is spawned
*
* @param pEntity CBaseEntity entity.
* @param classname Entity classname.
*/
virtual void OnEntitySpawned(CBaseEntity *pEntity, const char *classname)
{
}
};
/**

@ -1 +1 @@
Subproject commit 04eafd88631e7a3ba1de6bc7228af0e3d5443f0b
Subproject commit a98c996b166166350e7f022d2f8db60b1ee2b53e