merged trunk back into 1.1.0 branch for "safety"
--HG-- branch : sourcemod-1.1.0 extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.1.0%401721
This commit is contained in:
parent
0601988e80
commit
3f49d29274
@ -38,7 +38,7 @@
|
|||||||
// Examples: (do not put // in front of real lines, as // means 'comment')
|
// Examples: (do not put // in front of real lines, as // means 'comment')
|
||||||
//
|
//
|
||||||
// "STEAM_0:1:16" "bce" //kick, ban, slay for this steam ID, no immunity
|
// "STEAM_0:1:16" "bce" //kick, ban, slay for this steam ID, no immunity
|
||||||
// "127.0.0.1" "99:z" //all permissions for this ip, immunity value is 99
|
// "!127.0.0.1" "99:z" //all permissions for this ip, immunity value is 99
|
||||||
// "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, kick, ban
|
// "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, kick, ban
|
||||||
//
|
//
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -93,13 +93,6 @@ sm_hide_slots 0
|
|||||||
// Default: 1
|
// Default: 1
|
||||||
sm_chat_mode 1
|
sm_chat_mode 1
|
||||||
|
|
||||||
// Specifies whether or not non-admins can send private messages to each other
|
|
||||||
// using say @@<target> <message>. Valid values are 0 (disabled) or 1 (enabled)
|
|
||||||
// --
|
|
||||||
// Required: basechat.smx
|
|
||||||
// Default: 1
|
|
||||||
sm_psay_mode 0
|
|
||||||
|
|
||||||
// Specifies whether or not "timeleft" will automaticly be triggered every
|
// Specifies whether or not "timeleft" will automaticly be triggered every
|
||||||
// x seconds. Valid values are 0 (disabled) to 1800 seconds.
|
// x seconds. Valid values are 0 (disabled) to 1800 seconds.
|
||||||
// --
|
// --
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
extern HandleType_t htCellArray;
|
||||||
|
|
||||||
class CellArray
|
class CellArray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -149,6 +151,11 @@ public:
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cell_t *base()
|
||||||
|
{
|
||||||
|
return m_Data;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool GrowIfNeeded(size_t count)
|
bool GrowIfNeeded(size_t count)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public: //IRecipientFilter
|
|||||||
int GetRecipientCount() const;
|
int GetRecipientCount() const;
|
||||||
int GetRecipientIndex(int slot) const;
|
int GetRecipientIndex(int slot) const;
|
||||||
public:
|
public:
|
||||||
void Initialize(cell_t *ptr, size_t count);
|
void Initialize(const cell_t *ptr, size_t count);
|
||||||
void SetToReliable(bool isreliable);
|
void SetToReliable(bool isreliable);
|
||||||
void SetToInit(bool isinitmsg);
|
void SetToInit(bool isinitmsg);
|
||||||
void Reset();
|
void Reset();
|
||||||
@ -98,7 +98,7 @@ inline void CellRecipientFilter::SetToReliable(bool isreliable)
|
|||||||
m_IsReliable = isreliable;
|
m_IsReliable = isreliable;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CellRecipientFilter::Initialize(cell_t *ptr, size_t count)
|
inline void CellRecipientFilter::Initialize(const cell_t *ptr, size_t count)
|
||||||
{
|
{
|
||||||
memcpy(m_Players, ptr, count * sizeof(cell_t));
|
memcpy(m_Players, ptr, count * sizeof(cell_t));
|
||||||
m_Size = count;
|
m_Size = count;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "UserMessages.h"
|
#include "UserMessages.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
|
#include "GameConfigs.h"
|
||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
|
|
||||||
CHalfLife2 g_HL2;
|
CHalfLife2 g_HL2;
|
||||||
@ -308,7 +309,11 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *pre_byte = g_pGameConf->GetKeyValue("HintTextPreByte");
|
||||||
|
if (pre_byte != NULL && strcmp(pre_byte, "yes") == 0)
|
||||||
|
{
|
||||||
pBitBuf->WriteByte(1);
|
pBitBuf->WriteByte(1);
|
||||||
|
}
|
||||||
pBitBuf->WriteString(msg);
|
pBitBuf->WriteString(msg);
|
||||||
g_UserMsgs.EndMessage();
|
g_UserMsgs.EndMessage();
|
||||||
|
|
||||||
|
@ -380,7 +380,9 @@ void Logger::LogError(const char *vafmt, ...)
|
|||||||
LogToOpenFileEx(fp, vafmt, ap);
|
LogToOpenFileEx(fp, vafmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
char error[255];
|
char error[255];
|
||||||
g_LibSys.GetPlatformError(error, sizeof(error));
|
g_LibSys.GetPlatformError(error, sizeof(error));
|
||||||
LogFatal("[SM] Unexpected fatal logging error (file \"%s\")", m_NrmFileName.c_str());
|
LogFatal("[SM] Unexpected fatal logging error (file \"%s\")", m_NrmFileName.c_str());
|
||||||
|
@ -42,9 +42,15 @@ extern const char *g_RadioNumTable[];
|
|||||||
CRadioStyle g_RadioMenuStyle;
|
CRadioStyle g_RadioMenuStyle;
|
||||||
int g_ShowMenuId = -1;
|
int g_ShowMenuId = -1;
|
||||||
bool g_bRadioInit = false;
|
bool g_bRadioInit = false;
|
||||||
|
unsigned int g_RadioMenuTimeout = 0;
|
||||||
|
|
||||||
CRadioStyle::CRadioStyle() : m_players(new CBaseMenuPlayer[256+1])
|
CRadioStyle::CRadioStyle()
|
||||||
{
|
{
|
||||||
|
m_players = new CRadioMenuPlayer[256+1];
|
||||||
|
for (size_t i = 0; i < 256+1; i++)
|
||||||
|
{
|
||||||
|
m_players[i].Radio_SetIndex(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRadioStyle::OnSourceModAllInitialized()
|
void CRadioStyle::OnSourceModAllInitialized()
|
||||||
@ -73,6 +79,16 @@ void CRadioStyle::OnSourceModLevelChange(const char *mapName)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *val = g_pGameConf->GetKeyValue("RadioMenuTimeout");
|
||||||
|
if (val != NULL)
|
||||||
|
{
|
||||||
|
g_RadioMenuTimeout = atoi(val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_RadioMenuTimeout = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_Menus.AddStyle(this);
|
g_Menus.AddStyle(this);
|
||||||
g_Menus.SetDefaultStyle(this);
|
g_Menus.SetDefaultStyle(this);
|
||||||
|
|
||||||
@ -190,7 +206,9 @@ CRadioDisplay *CRadioStyle::MakeRadioDisplay(CRadioMenu *menu)
|
|||||||
if (m_FreeDisplays.empty())
|
if (m_FreeDisplays.empty())
|
||||||
{
|
{
|
||||||
display = new CRadioDisplay();
|
display = new CRadioDisplay();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
display = m_FreeDisplays.front();
|
display = m_FreeDisplays.front();
|
||||||
m_FreeDisplays.pop();
|
m_FreeDisplays.pop();
|
||||||
display->Reset();
|
display->Reset();
|
||||||
@ -198,11 +216,51 @@ CRadioDisplay *CRadioStyle::MakeRadioDisplay(CRadioMenu *menu)
|
|||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMenuPanel *CRadioStyle::MakeRadioDisplay(const char *str, int keys)
|
||||||
|
{
|
||||||
|
CRadioDisplay *pPanel = MakeRadioDisplay(NULL);
|
||||||
|
|
||||||
|
pPanel->DirectSet(str, keys);
|
||||||
|
|
||||||
|
return pPanel;
|
||||||
|
}
|
||||||
|
|
||||||
void CRadioStyle::FreeRadioDisplay(CRadioDisplay *display)
|
void CRadioStyle::FreeRadioDisplay(CRadioDisplay *display)
|
||||||
{
|
{
|
||||||
m_FreeDisplays.push(display);
|
m_FreeDisplays.push(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRadioMenuPlayer *CRadioStyle::GetRadioMenuPlayer(int client)
|
||||||
|
{
|
||||||
|
return &m_players[client];
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRadioStyle::ProcessWatchList()
|
||||||
|
{
|
||||||
|
if (!g_RadioMenuTimeout)
|
||||||
|
{
|
||||||
|
BaseMenuStyle::ProcessWatchList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseMenuStyle::ProcessWatchList();
|
||||||
|
|
||||||
|
CRadioMenuPlayer *pPlayer;
|
||||||
|
unsigned int max_clients = g_Players.GetMaxClients();
|
||||||
|
for (unsigned int i = 1; i <= max_clients; i++)
|
||||||
|
{
|
||||||
|
pPlayer = GetRadioMenuPlayer(i);
|
||||||
|
if (!pPlayer->bInMenu || pPlayer->bInExternMenu)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (pPlayer->Radio_NeedsRefresh())
|
||||||
|
{
|
||||||
|
pPlayer->Radio_Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CRadioDisplay::CRadioDisplay()
|
CRadioDisplay::CRadioDisplay()
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
@ -228,6 +286,13 @@ void CRadioDisplay::Reset()
|
|||||||
keys = 0;
|
keys = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRadioDisplay::DirectSet(const char *str, int keymap)
|
||||||
|
{
|
||||||
|
m_Title.clear();
|
||||||
|
m_BufferText.assign(str);
|
||||||
|
keys = keymap;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CRadioDisplay::GetCurrentKey()
|
unsigned int CRadioDisplay::GetCurrentKey()
|
||||||
{
|
{
|
||||||
return m_NextPos;
|
return m_NextPos;
|
||||||
@ -326,17 +391,60 @@ bool CRadioDisplay::CanDrawItem(unsigned int drawFlags)
|
|||||||
|
|
||||||
void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
|
void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
|
||||||
{
|
{
|
||||||
char buffer[4096];
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
len = UTIL_Format(buffer, sizeof(buffer), "%s\n%s", m_Title.c_str(), m_BufferText.c_str());
|
|
||||||
|
|
||||||
cell_t players[1] = {client};
|
|
||||||
|
|
||||||
int _sel_keys = (keys == 0) ? (1<<9) : keys;
|
int _sel_keys = (keys == 0) ? (1<<9) : keys;
|
||||||
|
CRadioMenuPlayer *pPlayer = g_RadioMenuStyle.GetRadioMenuPlayer(client);
|
||||||
|
pPlayer->Radio_Init(_sel_keys, m_Title.c_str(), m_BufferText.c_str());
|
||||||
|
pPlayer->Radio_Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
char *ptr = buffer;
|
void CRadioMenuPlayer::Radio_SetIndex(unsigned int index)
|
||||||
|
{
|
||||||
|
m_index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CRadioMenuPlayer::Radio_NeedsRefresh()
|
||||||
|
{
|
||||||
|
return (gpGlobals->curtime - display_last_refresh >= g_RadioMenuTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRadioMenuPlayer::Radio_Init(int keys, const char *title, const char *text)
|
||||||
|
{
|
||||||
|
if (title[0] != '\0')
|
||||||
|
{
|
||||||
|
display_len = UTIL_Format(display_pkt,
|
||||||
|
sizeof(display_pkt),
|
||||||
|
"%s\n%s",
|
||||||
|
title,
|
||||||
|
text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
display_len = UTIL_Format(display_pkt,
|
||||||
|
sizeof(display_pkt),
|
||||||
|
"%s",
|
||||||
|
text);
|
||||||
|
}
|
||||||
|
display_keys = keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRadioMenuPlayer::Radio_Refresh()
|
||||||
|
{
|
||||||
|
cell_t players[1] = {m_index};
|
||||||
|
char *ptr = display_pkt;
|
||||||
char save = 0;
|
char save = 0;
|
||||||
|
size_t len = display_len;
|
||||||
|
unsigned int time;
|
||||||
|
|
||||||
|
/* Compute the new time */
|
||||||
|
if (menuHoldTime == 0)
|
||||||
|
{
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
|
||||||
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (len > 240)
|
if (len > 240)
|
||||||
@ -345,7 +453,7 @@ void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
|
|||||||
ptr[240] = '\0';
|
ptr[240] = '\0';
|
||||||
}
|
}
|
||||||
bf_write *buffer = g_UserMsgs.StartMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
bf_write *buffer = g_UserMsgs.StartMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
||||||
buffer->WriteWord(_sel_keys);
|
buffer->WriteWord(display_keys);
|
||||||
buffer->WriteChar(time ? time : -1);
|
buffer->WriteChar(time ? time : -1);
|
||||||
buffer->WriteByte( (len > 240) ? 1 : 0 );
|
buffer->WriteByte( (len > 240) ? 1 : 0 );
|
||||||
buffer->WriteString(ptr);
|
buffer->WriteString(ptr);
|
||||||
@ -355,10 +463,14 @@ void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
|
|||||||
ptr[240] = save;
|
ptr[240] = save;
|
||||||
ptr = &ptr[240];
|
ptr = &ptr[240];
|
||||||
len -= 240;
|
len -= 240;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display_last_refresh = gpGlobals->curtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CRadioDisplay::GetAmountRemaining()
|
int CRadioDisplay::GetAmountRemaining()
|
||||||
|
@ -47,6 +47,21 @@ using namespace SourceMod;
|
|||||||
class CRadioDisplay;
|
class CRadioDisplay;
|
||||||
class CRadioMenu;
|
class CRadioMenu;
|
||||||
|
|
||||||
|
class CRadioMenuPlayer : public CBaseMenuPlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Radio_Init(int keys, const char *title, const char *buffer);
|
||||||
|
bool Radio_NeedsRefresh();
|
||||||
|
void Radio_Refresh();
|
||||||
|
void Radio_SetIndex(unsigned int index);
|
||||||
|
private:
|
||||||
|
unsigned int m_index;
|
||||||
|
size_t display_len;
|
||||||
|
char display_pkt[512];
|
||||||
|
int display_keys;
|
||||||
|
float display_last_refresh;
|
||||||
|
};
|
||||||
|
|
||||||
class CRadioStyle :
|
class CRadioStyle :
|
||||||
public BaseMenuStyle,
|
public BaseMenuStyle,
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
@ -61,6 +76,7 @@ public: //SMGlobalClass
|
|||||||
public: //BaseMenuStyle
|
public: //BaseMenuStyle
|
||||||
CBaseMenuPlayer *GetMenuPlayer(int client);
|
CBaseMenuPlayer *GetMenuPlayer(int client);
|
||||||
void SendDisplay(int client, IMenuPanel *display);
|
void SendDisplay(int client, IMenuPanel *display);
|
||||||
|
void ProcessWatchList();
|
||||||
public: //IMenuStyle
|
public: //IMenuStyle
|
||||||
const char *GetStyleName();
|
const char *GetStyleName();
|
||||||
IMenuPanel *CreatePanel();
|
IMenuPanel *CreatePanel();
|
||||||
@ -75,8 +91,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
|
CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
|
||||||
void FreeRadioDisplay(CRadioDisplay *display);
|
void FreeRadioDisplay(CRadioDisplay *display);
|
||||||
|
CRadioMenuPlayer *GetRadioMenuPlayer(int client);
|
||||||
|
IMenuPanel *MakeRadioDisplay(const char *str, int keys);
|
||||||
private:
|
private:
|
||||||
CBaseMenuPlayer *m_players;
|
CRadioMenuPlayer *m_players;
|
||||||
CStack<CRadioDisplay *> m_FreeDisplays;
|
CStack<CRadioDisplay *> m_FreeDisplays;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,6 +119,8 @@ public: //IMenuPanel
|
|||||||
unsigned int GetCurrentKey();
|
unsigned int GetCurrentKey();
|
||||||
bool SetCurrentKey(unsigned int key);
|
bool SetCurrentKey(unsigned int key);
|
||||||
int GetAmountRemaining();
|
int GetAmountRemaining();
|
||||||
|
public:
|
||||||
|
void DirectSet(const char *str, int keymap);
|
||||||
private:
|
private:
|
||||||
String m_BufferText;
|
String m_BufferText;
|
||||||
String m_Title;
|
String m_Title;
|
||||||
|
@ -1295,12 +1295,32 @@ void CPlayer::Authorize_Post()
|
|||||||
|
|
||||||
void CPlayer::DoPostConnectAuthorization()
|
void CPlayer::DoPostConnectAuthorization()
|
||||||
{
|
{
|
||||||
|
bool delay = false;
|
||||||
|
|
||||||
|
List<IClientListener *>::iterator iter;
|
||||||
|
for (iter = g_Players.m_hooks.begin();
|
||||||
|
iter != g_Players.m_hooks.end();
|
||||||
|
iter++)
|
||||||
|
{
|
||||||
|
IClientListener *pListener = (*iter);
|
||||||
|
#if defined MIN_API_FOR_ADMINCALLS
|
||||||
|
if (pListener->GetClientListenerVersion() < MIN_API_FOR_ADMINCALLS)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!pListener->OnClientPreAdminCheck(m_iIndex))
|
||||||
|
{
|
||||||
|
delay = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cell_t result = 0;
|
cell_t result = 0;
|
||||||
PreAdminCheck->PushCell(m_iIndex);
|
PreAdminCheck->PushCell(m_iIndex);
|
||||||
PreAdminCheck->Execute(&result);
|
PreAdminCheck->Execute(&result);
|
||||||
|
|
||||||
/* Defer, for better or worse */
|
/* Defer, for better or worse */
|
||||||
if ((ResultType)result >= Pl_Handled)
|
if (delay || (ResultType)result >= Pl_Handled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1318,6 +1338,15 @@ void CPlayer::DoPostConnectAuthorization()
|
|||||||
NotifyPostAdminChecks();
|
NotifyPostAdminChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPlayer::RunAdminCacheChecks()
|
||||||
|
{
|
||||||
|
AdminId old_id = GetAdminId();
|
||||||
|
|
||||||
|
DoBasicAdminChecks();
|
||||||
|
|
||||||
|
return (GetAdminId() != old_id);
|
||||||
|
}
|
||||||
|
|
||||||
void CPlayer::NotifyPostAdminChecks()
|
void CPlayer::NotifyPostAdminChecks()
|
||||||
{
|
{
|
||||||
if (m_bAdminCheckSignalled)
|
if (m_bAdminCheckSignalled)
|
||||||
@ -1328,6 +1357,21 @@ void CPlayer::NotifyPostAdminChecks()
|
|||||||
/* Block beforehand so they can't double-call */
|
/* Block beforehand so they can't double-call */
|
||||||
m_bAdminCheckSignalled = true;
|
m_bAdminCheckSignalled = true;
|
||||||
|
|
||||||
|
List<IClientListener *>::iterator iter;
|
||||||
|
for (iter = g_Players.m_hooks.begin();
|
||||||
|
iter != g_Players.m_hooks.end();
|
||||||
|
iter++)
|
||||||
|
{
|
||||||
|
IClientListener *pListener = (*iter);
|
||||||
|
#if defined MIN_API_FOR_ADMINCALLS
|
||||||
|
if (pListener->GetClientListenerVersion() < MIN_API_FOR_ADMINCALLS)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
pListener->OnClientPostAdminCheck(m_iIndex);
|
||||||
|
}
|
||||||
|
|
||||||
PostAdminCheck->PushCell(m_iIndex);
|
PostAdminCheck->PushCell(m_iIndex);
|
||||||
PostAdminCheck->Execute(NULL);
|
PostAdminCheck->Execute(NULL);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@ using namespace SourceHook;
|
|||||||
#define PLAYER_LIFE_ALIVE 1
|
#define PLAYER_LIFE_ALIVE 1
|
||||||
#define PLAYER_LIFE_DEAD 2
|
#define PLAYER_LIFE_DEAD 2
|
||||||
|
|
||||||
|
#define MIN_API_FOR_ADMINCALLS 7
|
||||||
|
|
||||||
class CPlayer : public IGamePlayer
|
class CPlayer : public IGamePlayer
|
||||||
{
|
{
|
||||||
friend class PlayerManager;
|
friend class PlayerManager;
|
||||||
@ -69,8 +71,9 @@ public:
|
|||||||
IPlayerInfo *GetPlayerInfo();
|
IPlayerInfo *GetPlayerInfo();
|
||||||
unsigned int GetLanguageId();
|
unsigned int GetLanguageId();
|
||||||
int GetUserId();
|
int GetUserId();
|
||||||
public:
|
bool RunAdminCacheChecks();
|
||||||
void NotifyPostAdminChecks();
|
void NotifyPostAdminChecks();
|
||||||
|
public:
|
||||||
void DoBasicAdminChecks();
|
void DoBasicAdminChecks();
|
||||||
bool IsInKickQueue();
|
bool IsInKickQueue();
|
||||||
void MarkAsBeingKicked();
|
void MarkAsBeingKicked();
|
||||||
@ -108,6 +111,7 @@ class PlayerManager :
|
|||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
public IPlayerManager
|
public IPlayerManager
|
||||||
{
|
{
|
||||||
|
friend class CPlayer;
|
||||||
public:
|
public:
|
||||||
PlayerManager();
|
PlayerManager();
|
||||||
~PlayerManager();
|
~PlayerManager();
|
||||||
|
@ -48,16 +48,16 @@ SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TimerSystem g_Timers;
|
TimerSystem g_Timers;
|
||||||
float g_fUniversalTime = 0.0f;
|
double g_fUniversalTime = 0.0f;
|
||||||
float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */
|
float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */
|
||||||
float g_fTimerThink = 0.0f; /* Timer's next think time */
|
double g_fTimerThink = 0.0f; /* Timer's next think time */
|
||||||
const float *g_pUniversalTime = &g_fUniversalTime;
|
const double *g_pUniversalTime = &g_fUniversalTime;
|
||||||
ConVar *mp_timelimit = NULL;
|
ConVar *mp_timelimit = NULL;
|
||||||
int g_TimeLeftMode = 0;
|
int g_TimeLeftMode = 0;
|
||||||
|
|
||||||
ConVar sm_time_adjustment("sm_time_adjustment", "0", 0, "Adjusts the server time in seconds");
|
ConVar sm_time_adjustment("sm_time_adjustment", "0", 0, "Adjusts the server time in seconds");
|
||||||
|
|
||||||
inline float GetSimulatedTime()
|
inline double GetSimulatedTime()
|
||||||
{
|
{
|
||||||
return g_fUniversalTime;
|
return g_fUniversalTime;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ private:
|
|||||||
* that a drastic jump in time will continue acting normally. Users
|
* that a drastic jump in time will continue acting normally. Users
|
||||||
* may not expect this, but... I think it is the best solution.
|
* may not expect this, but... I think it is the best solution.
|
||||||
*/
|
*/
|
||||||
inline float CalcNextThink(float last, float interval)
|
inline double CalcNextThink(double last, float interval)
|
||||||
{
|
{
|
||||||
if (g_fUniversalTime - last - interval <= TIMER_MIN_ACCURACY)
|
if (g_fUniversalTime - last - interval <= TIMER_MIN_ACCURACY)
|
||||||
{
|
{
|
||||||
@ -274,7 +274,7 @@ void TimerSystem::RunFrame()
|
|||||||
ITimer *pTimer;
|
ITimer *pTimer;
|
||||||
TimerIter iter;
|
TimerIter iter;
|
||||||
|
|
||||||
float curtime = GetSimulatedTime();
|
double curtime = GetSimulatedTime();
|
||||||
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); )
|
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); )
|
||||||
{
|
{
|
||||||
pTimer = (*iter);
|
pTimer = (*iter);
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
ITimedEvent *m_Listener;
|
ITimedEvent *m_Listener;
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
float m_Interval;
|
float m_Interval;
|
||||||
float m_ToExec;
|
double m_ToExec;
|
||||||
int m_Flags;
|
int m_Flags;
|
||||||
bool m_InExec;
|
bool m_InExec;
|
||||||
bool m_KillMe;
|
bool m_KillMe;
|
||||||
@ -103,7 +103,7 @@ private:
|
|||||||
|
|
||||||
time_t GetAdjustedTime(time_t *buf = NULL);
|
time_t GetAdjustedTime(time_t *buf = NULL);
|
||||||
|
|
||||||
extern const float *g_pUniversalTime;
|
extern const double *g_pUniversalTime;
|
||||||
extern TimerSystem g_Timers;
|
extern TimerSystem g_Timers;
|
||||||
extern int g_TimeLeftMode;
|
extern int g_TimeLeftMode;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bf_write *UserMessages::StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags)
|
bf_write *UserMessages::StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags)
|
||||||
{
|
{
|
||||||
bf_write *buffer;
|
bf_write *buffer;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public: //IUserMessages
|
|||||||
bool GetMessageName(int msgid, char *buffer, size_t maxlength) const;
|
bool GetMessageName(int msgid, char *buffer, size_t maxlength) const;
|
||||||
bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
||||||
bool UnhookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
bool UnhookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false);
|
||||||
bf_write *StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags);
|
bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags);
|
||||||
bool EndMessage();
|
bool EndMessage();
|
||||||
public:
|
public:
|
||||||
bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type);
|
bf_write *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type);
|
||||||
|
@ -290,6 +290,34 @@ CON_COMMAND(sm, "SourceMod Menu")
|
|||||||
g_RootMenu.GotRootCmd(args);
|
g_RootMenu.GotRootCmd(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE *g_pHndlLog = NULL;
|
||||||
|
|
||||||
|
void write_handles_to_log(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(g_pHndlLog, fmt, ap);
|
||||||
|
fprintf(g_pHndlLog, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_handles_to_game(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
va_list ap;
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = UTIL_FormatArgs(buffer, sizeof(buffer)-2, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
buffer[len] = '\n';
|
||||||
|
buffer[len+1] = '\0';
|
||||||
|
|
||||||
|
engine->LogPrint(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle leaks")
|
CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle leaks")
|
||||||
{
|
{
|
||||||
#if !defined ORANGEBOX_BUILD
|
#if !defined ORANGEBOX_BUILD
|
||||||
@ -297,10 +325,12 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
|
|||||||
#endif
|
#endif
|
||||||
if (args.ArgC() < 2)
|
if (args.ArgC() < 2)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("Usage: sm_dump_handles <file>");
|
g_RootMenu.ConsolePrint("Usage: sm_dump_handles <file> or <log> for game logs");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(args.Arg(1), "log") != 0)
|
||||||
|
{
|
||||||
const char *arg = args.Arg(1);
|
const char *arg = args.Arg(1);
|
||||||
FILE *fp = fopen(arg, "wt");
|
FILE *fp = fopen(arg, "wt");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
@ -309,7 +339,14 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_HandleSys.Dump(fp);
|
g_pHndlLog = fp;
|
||||||
|
g_HandleSys.Dump(write_handles_to_log);
|
||||||
|
g_pHndlLog = NULL;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_HandleSys.Dump(write_handles_to_game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,9 @@ void AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
while (string[size++]);
|
while (string[size++]);
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
@ -234,78 +236,125 @@ void AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
|
|||||||
*buf_p = buf;
|
*buf_p = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec)
|
void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, int flags)
|
||||||
{
|
{
|
||||||
char text[32];
|
int digits; // non-fraction part digits
|
||||||
int digits;
|
double tmp; // temporary
|
||||||
double signedVal;
|
char *buf = *buf_p; // output buffer pointer
|
||||||
char *buf;
|
int val; // temporary
|
||||||
int val;
|
int sign = 0; // 0: positive, 1: negative
|
||||||
|
int fieldlength; // for padding
|
||||||
// get the sign
|
int significant_digits = 0; // number of significant digits written
|
||||||
signedVal = fval;
|
const int MAX_SIGNIFICANT_DIGITS = 16;
|
||||||
if (fval < 0)
|
|
||||||
{
|
|
||||||
fval = -fval;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write the float number
|
|
||||||
digits = 0;
|
|
||||||
val = (int)fval;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
text[digits++] = '0' + val % 10;
|
|
||||||
val /= 10;
|
|
||||||
} while (val);
|
|
||||||
|
|
||||||
if (signedVal < 0)
|
|
||||||
{
|
|
||||||
text[digits++] = '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = *buf_p;
|
|
||||||
|
|
||||||
while ((digits < width) && maxlen)
|
|
||||||
{
|
|
||||||
*buf++ = ' ';
|
|
||||||
width--;
|
|
||||||
maxlen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((digits--) && maxlen)
|
|
||||||
{
|
|
||||||
*buf++ = text[digits];
|
|
||||||
maxlen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
*buf_p = buf;
|
|
||||||
|
|
||||||
|
// default precision
|
||||||
if (prec < 0)
|
if (prec < 0)
|
||||||
{
|
{
|
||||||
prec = 6;
|
prec = 6;
|
||||||
}
|
}
|
||||||
// write the fraction
|
|
||||||
digits = 0;
|
// get the sign
|
||||||
while (digits < prec)
|
if (fval < 0)
|
||||||
{
|
{
|
||||||
fval -= (int)fval;
|
fval = -fval;
|
||||||
fval *= 10.0;
|
sign = 1;
|
||||||
val = (int)fval;
|
|
||||||
text[digits++] = '0' + val % 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((digits > 0) && maxlen)
|
// compute whole-part digits count
|
||||||
|
digits = (int)log10(fval) + 1;
|
||||||
|
|
||||||
|
// Only print 0.something if 0 < fval < 1
|
||||||
|
if (digits < 1)
|
||||||
|
{
|
||||||
|
digits = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute the field length
|
||||||
|
fieldlength = digits + prec + ((prec > 0) ? 1 : 0) + sign;
|
||||||
|
|
||||||
|
// minus sign BEFORE left padding if padding with zeros
|
||||||
|
if (sign && maxlen && (flags & ZEROPAD))
|
||||||
|
{
|
||||||
|
*buf++ = '-';
|
||||||
|
maxlen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// right justify if required
|
||||||
|
if ((flags & LADJUST) == 0)
|
||||||
|
{
|
||||||
|
while ((fieldlength < width) && maxlen)
|
||||||
|
{
|
||||||
|
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
|
||||||
|
width--;
|
||||||
|
maxlen--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// minus sign AFTER left padding if padding with spaces
|
||||||
|
if (sign && maxlen && !(flags & ZEROPAD))
|
||||||
|
{
|
||||||
|
*buf++ = '-';
|
||||||
|
maxlen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the whole part
|
||||||
|
tmp = pow(10.0, digits-1);
|
||||||
|
while ((digits--) && maxlen)
|
||||||
|
{
|
||||||
|
if (++significant_digits > MAX_SIGNIFICANT_DIGITS)
|
||||||
|
{
|
||||||
|
*buf++ = '0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
val = (int)(fval / tmp);
|
||||||
|
*buf++ = '0' + val;
|
||||||
|
fval -= val * tmp;
|
||||||
|
tmp *= 0.1;
|
||||||
|
}
|
||||||
|
maxlen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the fraction part
|
||||||
|
if (maxlen)
|
||||||
{
|
{
|
||||||
buf = *buf_p;
|
|
||||||
*buf++ = '.';
|
*buf++ = '.';
|
||||||
maxlen--;
|
maxlen--;
|
||||||
for (prec = 0; maxlen && (prec < digits); prec++)
|
}
|
||||||
|
|
||||||
|
tmp = pow(10.0, prec);
|
||||||
|
|
||||||
|
fval *= tmp;
|
||||||
|
while (prec-- && maxlen)
|
||||||
{
|
{
|
||||||
*buf++ = text[prec];
|
if (++significant_digits > MAX_SIGNIFICANT_DIGITS)
|
||||||
|
{
|
||||||
|
*buf++ = '0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp *= 0.1;
|
||||||
|
val = (int)(fval / tmp);
|
||||||
|
*buf++ = '0' + val;
|
||||||
|
fval -= val * tmp;
|
||||||
|
}
|
||||||
maxlen--;
|
maxlen--;
|
||||||
}
|
}
|
||||||
*buf_p = buf;
|
|
||||||
|
// left justify if required
|
||||||
|
if (flags & LADJUST)
|
||||||
|
{
|
||||||
|
while ((fieldlength < width) && maxlen)
|
||||||
|
{
|
||||||
|
// right-padding only with spaces, ZEROPAD is ignored
|
||||||
|
*buf++ = ' ';
|
||||||
|
width--;
|
||||||
|
maxlen--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update parent's buffer pointer
|
||||||
|
*buf_p = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddUInt(char **buf_p, size_t &maxlen, unsigned int val, int width, int flags)
|
void AddUInt(char **buf_p, size_t &maxlen, unsigned int val, int width, int flags)
|
||||||
@ -366,9 +415,12 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)
|
|||||||
{
|
{
|
||||||
/* we want the unsigned version */
|
/* we want the unsigned version */
|
||||||
unsignedVal = abs(val);
|
unsignedVal = abs(val);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
unsignedVal = val;
|
unsignedVal = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
text[digits++] = '0' + unsignedVal % 10;
|
text[digits++] = '0' + unsignedVal % 10;
|
||||||
@ -422,7 +474,9 @@ void AddHex(char **buf_p, size_t &maxlen, unsigned int val, int width, int flags
|
|||||||
if (flags & UPPERDIGITS)
|
if (flags & UPPERDIGITS)
|
||||||
{
|
{
|
||||||
hexadjust = 'A' - '9' - 1;
|
hexadjust = 'A' - '9' - 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hexadjust = 'a' - '9' - 1;
|
hexadjust = 'a' - '9' - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +641,7 @@ reswitch:
|
|||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
float *value = (float *)args[arg];
|
float *value = (float *)args[arg];
|
||||||
AddFloat(&buf_p, llen, *value, width, prec);
|
AddFloat(&buf_p, llen, *value, width, prec, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -779,7 +833,7 @@ reswitch:
|
|||||||
CHECK_ARGS(0);
|
CHECK_ARGS(0);
|
||||||
cell_t *value;
|
cell_t *value;
|
||||||
pCtx->LocalToPhysAddr(params[arg], &value);
|
pCtx->LocalToPhysAddr(params[arg], &value);
|
||||||
AddFloat(&buf_p, llen, sp_ctof(*value), width, prec);
|
AddFloat(&buf_p, llen, sp_ctof(*value), width, prec, flags);
|
||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -808,7 +862,9 @@ reswitch:
|
|||||||
player->GetName(),
|
player->GetName(),
|
||||||
userid,
|
userid,
|
||||||
auth);
|
auth);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
UTIL_Format(buffer,
|
UTIL_Format(buffer,
|
||||||
sizeof(buffer),
|
sizeof(buffer),
|
||||||
"Console<0><Console><Console>");
|
"Console<0><Console><Console>");
|
||||||
@ -964,7 +1020,9 @@ const char *stristr(const char *str, const char *substr)
|
|||||||
{
|
{
|
||||||
return prevloc;
|
return prevloc;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
haystack = ++prevloc;
|
haystack = ++prevloc;
|
||||||
needle = (char *)substr;
|
needle = (char *)substr;
|
||||||
}
|
}
|
||||||
@ -1001,7 +1059,9 @@ size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
buffer[maxlength - 1] = '\0';
|
buffer[maxlength - 1] = '\0';
|
||||||
return (maxlength - 1);
|
return (maxlength - 1);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1014,7 +1074,9 @@ size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list
|
|||||||
{
|
{
|
||||||
buffer[maxlength - 1] = '\0';
|
buffer[maxlength - 1] = '\0';
|
||||||
return (maxlength - 1);
|
return (maxlength - 1);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1117,7 +1179,9 @@ char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t se
|
|||||||
replaceLen = maxLen - browsed;
|
replaceLen = maxLen - browsed;
|
||||||
/* Note, we add one to the final result for the null terminator */
|
/* Note, we add one to the final result for the null terminator */
|
||||||
strncopy(ptr, replace, replaceLen+1);
|
strncopy(ptr, replace, replaceLen+1);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* EXAMPLE CASE:
|
/* EXAMPLE CASE:
|
||||||
* Subject: AABBBCCC
|
* Subject: AABBBCCC
|
||||||
* Buffer : 12 bytes
|
* Buffer : 12 bytes
|
||||||
@ -1138,7 +1202,9 @@ char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t se
|
|||||||
/* Now, do our replacement. */
|
/* Now, do our replacement. */
|
||||||
memcpy(ptr, replace, replaceLen);
|
memcpy(ptr, replace, replaceLen);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* EXAMPLE CASE:
|
/* EXAMPLE CASE:
|
||||||
* Subject: AABBBCCC
|
* Subject: AABBBCCC
|
||||||
* Buffer : 12 bytes
|
* Buffer : 12 bytes
|
||||||
@ -1158,7 +1224,9 @@ char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t se
|
|||||||
/* Now do our replacement. */
|
/* Now do our replacement. */
|
||||||
memcpy(ptr, replace, replaceLen);
|
memcpy(ptr, replace, replaceLen);
|
||||||
}
|
}
|
||||||
} else if (replaceLen < searchLen) {
|
}
|
||||||
|
else if (replaceLen < searchLen)
|
||||||
|
{
|
||||||
/* EXAMPLE CASE:
|
/* EXAMPLE CASE:
|
||||||
* Subject: AABBBCCC
|
* Subject: AABBBCCC
|
||||||
* Buffer : 12 bytes
|
* Buffer : 12 bytes
|
||||||
@ -1184,7 +1252,9 @@ char *UTIL_ReplaceEx(char *subject, size_t maxLen, const char *search, size_t se
|
|||||||
|
|
||||||
/* Move the rest of the string down */
|
/* Move the rest of the string down */
|
||||||
memmove(moveTo, moveFrom, bytesToCopy);
|
memmove(moveTo, moveFrom, bytesToCopy);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* EXAMPLE CASE:
|
/* EXAMPLE CASE:
|
||||||
* Subject: AABBBCCC
|
* Subject: AABBBCCC
|
||||||
* Buffer : 12 bytes
|
* Buffer : 12 bytes
|
||||||
|
@ -406,6 +406,33 @@ static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_KvJumpToKeySymbol(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
|
HandleError herr;
|
||||||
|
HandleSecurity sec;
|
||||||
|
KeyValueStack *pStk;
|
||||||
|
|
||||||
|
sec.pOwner = NULL;
|
||||||
|
sec.pIdentity = g_pCoreIdent;
|
||||||
|
|
||||||
|
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyValues *pSubKey = pStk->pCurRoot.front();
|
||||||
|
pSubKey = pSubKey->FindKey(params[2]);
|
||||||
|
if (!pSubKey)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pStk->pCurRoot.push(pSubKey);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params)
|
static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
@ -921,6 +948,36 @@ static cell_t smn_FindKeyById(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
|
HandleError herr;
|
||||||
|
HandleSecurity sec;
|
||||||
|
KeyValueStack *pStk;
|
||||||
|
cell_t *val;
|
||||||
|
|
||||||
|
sec.pOwner = NULL;
|
||||||
|
sec.pIdentity = g_pCoreIdent;
|
||||||
|
|
||||||
|
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyValues *pSection = pStk->pCurRoot.front();
|
||||||
|
|
||||||
|
pCtx->LocalToPhysAddr(params[2], &val);
|
||||||
|
*val = pSection->GetNameSymbol();
|
||||||
|
|
||||||
|
if (!*val)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static KeyValueNatives s_KeyValueNatives;
|
static KeyValueNatives s_KeyValueNatives;
|
||||||
|
|
||||||
REGISTER_NATIVES(keyvaluenatives)
|
REGISTER_NATIVES(keyvaluenatives)
|
||||||
@ -937,6 +994,7 @@ REGISTER_NATIVES(keyvaluenatives)
|
|||||||
{"KvGetUInt64", smn_KvGetUInt64},
|
{"KvGetUInt64", smn_KvGetUInt64},
|
||||||
{"CreateKeyValues", smn_CreateKeyValues},
|
{"CreateKeyValues", smn_CreateKeyValues},
|
||||||
{"KvJumpToKey", smn_KvJumpToKey},
|
{"KvJumpToKey", smn_KvJumpToKey},
|
||||||
|
{"KvJumpToKeySymbol", smn_KvJumpToKeySymbol},
|
||||||
{"KvGotoNextKey", smn_KvGotoNextKey},
|
{"KvGotoNextKey", smn_KvGotoNextKey},
|
||||||
{"KvJumpFirstSubKey", smn_KvGotoFirstSubKey}, /* BACKWARDS COMPAT SHIM */
|
{"KvJumpFirstSubKey", smn_KvGotoFirstSubKey}, /* BACKWARDS COMPAT SHIM */
|
||||||
{"KvGotoFirstSubKey", smn_KvGotoFirstSubKey},
|
{"KvGotoFirstSubKey", smn_KvGotoFirstSubKey},
|
||||||
@ -956,5 +1014,6 @@ REGISTER_NATIVES(keyvaluenatives)
|
|||||||
{"KvCopySubkeys", smn_CopySubkeys},
|
{"KvCopySubkeys", smn_CopySubkeys},
|
||||||
{"KvFindKeyById", smn_FindKeyById},
|
{"KvFindKeyById", smn_FindKeyById},
|
||||||
{"KvGetNameSymbol", smn_GetNameSymbol},
|
{"KvGetNameSymbol", smn_GetNameSymbol},
|
||||||
|
{"KvGetSectionSymbol", smn_KvGetSectionSymbol},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "MenuStyle_Radio.h"
|
#include "MenuStyle_Radio.h"
|
||||||
#include "HandleSys.h"
|
#include "HandleSys.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
|
#include "PlayerManager.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
@ -1398,6 +1399,73 @@ static cell_t GetMenuSelectionPosition(IPluginContext *pContext, const cell_t *p
|
|||||||
return *s_CurSelectPosition;
|
return *s_CurSelectPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EmptyMenuHandler : public IMenuHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
} s_EmptyMenuHandler;
|
||||||
|
|
||||||
|
static cell_t InternalShowMenu(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
int client = params[1];
|
||||||
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
|
|
||||||
|
if (pPlayer == NULL)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid client index %d", client);
|
||||||
|
}
|
||||||
|
else if (!pPlayer->IsInGame())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_RadioMenuStyle.IsSupported())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Radio menus are not supported on this mod");
|
||||||
|
}
|
||||||
|
|
||||||
|
char *str;
|
||||||
|
pContext->LocalToString(params[2], &str);
|
||||||
|
|
||||||
|
IMenuPanel *pPanel = g_RadioMenuStyle.MakeRadioDisplay(str, params[4]);
|
||||||
|
|
||||||
|
if (pPanel == NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMenuHandler *pHandler;
|
||||||
|
CPanelHandler *pActualHandler = NULL;
|
||||||
|
if (params[5] != -1)
|
||||||
|
{
|
||||||
|
IPluginFunction *pFunction = pContext->GetFunctionById(params[5]);
|
||||||
|
if (pFunction == NULL)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid function index %x", params[5]);
|
||||||
|
}
|
||||||
|
pActualHandler = g_MenuHelpers.GetPanelHandler(pFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pActualHandler == NULL)
|
||||||
|
{
|
||||||
|
pHandler = &s_EmptyMenuHandler;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pHandler = pActualHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bSuccess = pPanel->SendDisplay(client, pHandler, params[3]);
|
||||||
|
|
||||||
|
pPanel->DeleteThis();
|
||||||
|
|
||||||
|
if (!bSuccess && pActualHandler != NULL)
|
||||||
|
{
|
||||||
|
g_MenuHelpers.FreePanelHandler(pActualHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bSuccess ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(menuNatives)
|
REGISTER_NATIVES(menuNatives)
|
||||||
{
|
{
|
||||||
{"AddMenuItem", AddMenuItem},
|
{"AddMenuItem", AddMenuItem},
|
||||||
@ -1430,6 +1498,7 @@ REGISTER_NATIVES(menuNatives)
|
|||||||
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
||||||
{"GetPanelStyle", GetPanelStyle},
|
{"GetPanelStyle", GetPanelStyle},
|
||||||
{"InsertMenuItem", InsertMenuItem},
|
{"InsertMenuItem", InsertMenuItem},
|
||||||
|
{"InternalShowMenu", InternalShowMenu},
|
||||||
{"IsVoteInProgress", IsVoteInProgress},
|
{"IsVoteInProgress", IsVoteInProgress},
|
||||||
{"RedrawMenuItem", RedrawMenuItem},
|
{"RedrawMenuItem", RedrawMenuItem},
|
||||||
{"RemoveAllMenuItems", RemoveAllMenuItems},
|
{"RemoveAllMenuItems", RemoveAllMenuItems},
|
||||||
|
@ -259,7 +259,7 @@ static cell_t SetUserAdmin(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
return pContext->ThrowNativeError("Client %d is not connected", client);
|
||||||
}
|
}
|
||||||
if (!g_Admins.IsValidAdmin(params[2]))
|
if (!g_Admins.IsValidAdmin(params[2]) && params[2] != INVALID_ADMIN_ID)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("AdminId %x is invalid", params[2]);
|
return pContext->ThrowNativeError("AdminId %x is invalid", params[2]);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "HandleSys.h"
|
||||||
|
#include "CellArray.h"
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
* About the double array hack *
|
* About the double array hack *
|
||||||
@ -373,6 +375,139 @@ static cell_t sm_SortCustom2D(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SortType
|
||||||
|
{
|
||||||
|
Sort_Integer = 0,
|
||||||
|
Sort_Float,
|
||||||
|
Sort_String,
|
||||||
|
};
|
||||||
|
|
||||||
|
int sort_adtarray_strings_asc(const void *str1, const void *str2)
|
||||||
|
{
|
||||||
|
return strcmp((char *) str1, (char *) str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sort_adtarray_strings_desc(const void *str1, const void *str2)
|
||||||
|
{
|
||||||
|
return strcmp((char *) str2, (char *) str1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_SortADTArray(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
CellArray *cArray;
|
||||||
|
HandleError err;
|
||||||
|
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||||
|
|
||||||
|
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t order = params[2];
|
||||||
|
cell_t type = params[3];
|
||||||
|
size_t arraysize = cArray->size();
|
||||||
|
size_t blocksize = cArray->blocksize();
|
||||||
|
cell_t *array = cArray->base();
|
||||||
|
|
||||||
|
if (type == Sort_Integer)
|
||||||
|
{
|
||||||
|
if (order == Sort_Ascending)
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_ints_asc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_ints_desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == Sort_Float)
|
||||||
|
{
|
||||||
|
if (order == Sort_Ascending)
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_floats_asc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_floats_desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == Sort_String)
|
||||||
|
{
|
||||||
|
if (order == Sort_Ascending)
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_adtarray_strings_asc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_adtarray_strings_desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sort_infoADT
|
||||||
|
{
|
||||||
|
IPluginFunction *pFunc;
|
||||||
|
cell_t *array_base;
|
||||||
|
cell_t array_bsize;
|
||||||
|
Handle_t array_hndl;
|
||||||
|
Handle_t hndl;
|
||||||
|
};
|
||||||
|
|
||||||
|
sort_infoADT g_SortInfoADT;
|
||||||
|
|
||||||
|
int sort_adtarray_custom(const void *elem1, const void *elem2)
|
||||||
|
{
|
||||||
|
cell_t result = 0;
|
||||||
|
IPluginFunction *pf = g_SortInfoADT.pFunc;
|
||||||
|
pf->PushCell(((cell_t) ((cell_t *) elem1 - g_SortInfoADT.array_base)) / g_SortInfoADT.array_bsize);
|
||||||
|
pf->PushCell(((cell_t) ((cell_t *) elem2 - g_SortInfoADT.array_base)) / g_SortInfoADT.array_bsize);
|
||||||
|
pf->PushCell(g_SortInfoADT.array_hndl);
|
||||||
|
pf->PushCell(g_SortInfoADT.hndl);
|
||||||
|
pf->Execute(&result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell_t sm_SortADTArrayCustom(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
CellArray *cArray;
|
||||||
|
HandleError err;
|
||||||
|
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||||
|
|
||||||
|
if ((err = g_HandleSys.ReadHandle(params[1], htCellArray, &sec, (void **)&cArray))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPluginFunction *pFunction = pContext->GetFunctionById(params[2]);
|
||||||
|
if (!pFunction)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Function %x is not a valid function", params[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t arraysize = cArray->size();
|
||||||
|
size_t blocksize = cArray->blocksize();
|
||||||
|
cell_t *array = cArray->base();
|
||||||
|
|
||||||
|
sort_infoADT oldinfo = g_SortInfoADT;
|
||||||
|
|
||||||
|
g_SortInfoADT.pFunc = pFunction;
|
||||||
|
g_SortInfoADT.array_base = array;
|
||||||
|
g_SortInfoADT.array_bsize = (cell_t) blocksize;
|
||||||
|
g_SortInfoADT.array_hndl = params[1];
|
||||||
|
g_SortInfoADT.hndl = params[3];
|
||||||
|
|
||||||
|
qsort(array, arraysize, blocksize * sizeof(cell_t), sort_adtarray_custom);
|
||||||
|
|
||||||
|
g_SortInfoADT = oldinfo;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(sortNatives)
|
REGISTER_NATIVES(sortNatives)
|
||||||
{
|
{
|
||||||
{"SortIntegers", sm_SortIntegers},
|
{"SortIntegers", sm_SortIntegers},
|
||||||
@ -380,5 +515,7 @@ REGISTER_NATIVES(sortNatives)
|
|||||||
{"SortStrings", sm_SortStrings},
|
{"SortStrings", sm_SortStrings},
|
||||||
{"SortCustom1D", sm_SortCustom1D},
|
{"SortCustom1D", sm_SortCustom1D},
|
||||||
{"SortCustom2D", sm_SortCustom2D},
|
{"SortCustom2D", sm_SortCustom2D},
|
||||||
|
{"SortADTArray", sm_SortADTArray},
|
||||||
|
{"SortADTArrayCustom", sm_SortADTArrayCustom},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -586,9 +586,11 @@ const char *SourceModBase::GetGamePath() const
|
|||||||
return g_BaseDir.c_str();
|
return g_BaseDir.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceModBase::SetGlobalTarget(unsigned int index)
|
unsigned int SourceModBase::SetGlobalTarget(unsigned int index)
|
||||||
{
|
{
|
||||||
|
unsigned int old = m_target;
|
||||||
m_target = index;
|
m_target = index;
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SourceModBase::GetGlobalTarget() const
|
unsigned int SourceModBase::GetGlobalTarget() const
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Stores the global target index.
|
* @brief Stores the global target index.
|
||||||
*/
|
*/
|
||||||
void SetGlobalTarget(unsigned int index);
|
unsigned int SetGlobalTarget(unsigned int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the global target index.
|
* @brief Returns the global target index.
|
||||||
|
@ -285,7 +285,22 @@ void CExtension::RemovePlugin(IPlugin *pPlugin)
|
|||||||
if ((*iter).pl == pPlugin)
|
if ((*iter).pl == pPlugin)
|
||||||
{
|
{
|
||||||
iter = m_WeakNatives.erase(iter);
|
iter = m_WeakNatives.erase(iter);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = m_ReplacedNatives.begin();
|
||||||
|
while (iter != m_ReplacedNatives.end())
|
||||||
|
{
|
||||||
|
if ((*iter).pl == pPlugin)
|
||||||
|
{
|
||||||
|
iter = m_ReplacedNatives.erase(iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -703,6 +718,7 @@ void CExtensionManager::BindAllNativesToPlugin(IPlugin *pPlugin)
|
|||||||
uint32_t natives = pContext->GetNativesNum();
|
uint32_t natives = pContext->GetNativesNum();
|
||||||
sp_native_t *native;
|
sp_native_t *native;
|
||||||
sm_extnative_t *x_native;
|
sm_extnative_t *x_native;
|
||||||
|
sm_repnative_t *r_native;
|
||||||
for (uint32_t i=0; i<natives; i++)
|
for (uint32_t i=0; i<natives; i++)
|
||||||
{
|
{
|
||||||
/* Make sure the native is valid */
|
/* Make sure the native is valid */
|
||||||
@ -710,11 +726,26 @@ void CExtensionManager::BindAllNativesToPlugin(IPlugin *pPlugin)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the native is not already bound */
|
/* Make sure the native is not already bound */
|
||||||
if (native->status == SP_NATIVE_BOUND)
|
if (native->status == SP_NATIVE_BOUND)
|
||||||
|
{
|
||||||
|
/* If it is bound, see if there is a replacement. */
|
||||||
|
if ((r_native = m_RepNatives.retrieve(native->name)) == NULL)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Rewrite the address. Whee! */
|
||||||
|
native->pfn = r_native->info.func;
|
||||||
|
|
||||||
|
/* Make sure this will unload safely */
|
||||||
|
WeakNative wn((CPlugin *)pPlugin, i);
|
||||||
|
r_native->owner->m_ReplacedNatives.push_back(wn);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* See if we've got this native in our cache */
|
/* See if we've got this native in our cache */
|
||||||
if ((x_native = m_ExtNatives.retrieve(native->name)) == NULL)
|
if ((x_native = m_ExtNatives.retrieve(native->name)) == NULL)
|
||||||
{
|
{
|
||||||
@ -789,7 +820,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
|||||||
g_PluginSys.OnLibraryAction((*s_iter).c_str(), false, true);
|
g_PluginSys.OnLibraryAction((*s_iter).c_str(), false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unbound weak natives */
|
/* Unbind weak natives */
|
||||||
List<WeakNative>::iterator wkn_iter;
|
List<WeakNative>::iterator wkn_iter;
|
||||||
for (wkn_iter=pExt->m_WeakNatives.begin(); wkn_iter!=pExt->m_WeakNatives.end(); wkn_iter++)
|
for (wkn_iter=pExt->m_WeakNatives.begin(); wkn_iter!=pExt->m_WeakNatives.end(); wkn_iter++)
|
||||||
{
|
{
|
||||||
@ -798,6 +829,21 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
|||||||
ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
|
ctx->natives[wkn.idx].status = SP_NATIVE_UNBOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unbind replacement natives, link them back to their originals */
|
||||||
|
for (wkn_iter = pExt->m_ReplacedNatives.begin();
|
||||||
|
wkn_iter != pExt->m_ReplacedNatives.end();
|
||||||
|
wkn_iter++)
|
||||||
|
{
|
||||||
|
WeakNative & wkn = (*wkn_iter);
|
||||||
|
sp_context_t *ctx = wkn.pl->GetContext();
|
||||||
|
sm_repnative_t *r_native = m_RepNatives.retrieve(ctx->natives[wkn.idx].name);
|
||||||
|
if (r_native == NULL || ctx->natives[wkn.idx].pfn != r_native->info.func)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ctx->natives[wkn.idx].pfn = r_native->original;
|
||||||
|
}
|
||||||
|
|
||||||
/* Notify and/or unload all dependencies */
|
/* Notify and/or unload all dependencies */
|
||||||
List<CExtension *>::iterator c_iter;
|
List<CExtension *>::iterator c_iter;
|
||||||
CExtension *pDep;
|
CExtension *pDep;
|
||||||
@ -871,6 +917,22 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unbind our replacement natives */
|
||||||
|
List<sm_repnative_t>::iterator rep_iter = m_RepNativeList.begin();
|
||||||
|
while (rep_iter != m_RepNativeList.end())
|
||||||
|
{
|
||||||
|
sm_repnative_t & r_native = (*rep_iter);
|
||||||
|
if (r_native.owner == pExt)
|
||||||
|
{
|
||||||
|
m_RepNatives.remove(r_native.info.name);
|
||||||
|
rep_iter = m_RepNativeList.erase(rep_iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rep_iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell it to unload */
|
/* Tell it to unload */
|
||||||
pAPI = pExt->GetAPI();
|
pAPI = pExt->GetAPI();
|
||||||
pAPI->OnExtensionUnload();
|
pAPI->OnExtensionUnload();
|
||||||
@ -919,6 +981,25 @@ void CExtensionManager::AddNatives(IExtension *pOwner, const sp_nativeinfo_t *na
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CExtensionManager::OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives)
|
||||||
|
{
|
||||||
|
SPVM_NATIVE_FUNC orig;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; natives[i].func != NULL && natives[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if ((orig = g_PluginSys.FindCoreNative(natives[i].name)) == NULL)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sm_repnative_t rep;
|
||||||
|
rep.info = natives[i];
|
||||||
|
rep.owner = (CExtension *)myself;
|
||||||
|
rep.original = orig;
|
||||||
|
m_RepNativeList.push_back(rep);
|
||||||
|
m_RepNatives.insert(natives[i].name, rep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CExtensionManager::MarkAllLoaded()
|
void CExtensionManager::MarkAllLoaded()
|
||||||
{
|
{
|
||||||
List<CExtension *>::iterator iter;
|
List<CExtension *>::iterator iter;
|
||||||
|
@ -55,6 +55,14 @@ struct sm_extnative_t
|
|||||||
const sp_nativeinfo_t *info;
|
const sp_nativeinfo_t *info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Replacement native */
|
||||||
|
struct sm_repnative_t
|
||||||
|
{
|
||||||
|
CExtension *owner;
|
||||||
|
sp_nativeinfo_t info;
|
||||||
|
SPVM_NATIVE_FUNC original;
|
||||||
|
};
|
||||||
|
|
||||||
class CExtension : public IExtension
|
class CExtension : public IExtension
|
||||||
{
|
{
|
||||||
friend class CExtensionManager;
|
friend class CExtensionManager;
|
||||||
@ -98,6 +106,7 @@ protected:
|
|||||||
List<IPlugin *> m_Plugins;
|
List<IPlugin *> m_Plugins;
|
||||||
List<const sp_nativeinfo_t *> m_Natives;
|
List<const sp_nativeinfo_t *> m_Natives;
|
||||||
List<WeakNative> m_WeakNatives;
|
List<WeakNative> m_WeakNatives;
|
||||||
|
List<WeakNative> m_ReplacedNatives;
|
||||||
List<String> m_Libraries;
|
List<String> m_Libraries;
|
||||||
unsigned int unload_code;
|
unsigned int unload_code;
|
||||||
bool m_bFullyLoaded;
|
bool m_bFullyLoaded;
|
||||||
@ -168,6 +177,7 @@ public:
|
|||||||
void TryAutoload();
|
void TryAutoload();
|
||||||
void AddLibrary(IExtension *pSource, const char *library);
|
void AddLibrary(IExtension *pSource, const char *library);
|
||||||
bool LibraryExists(const char *library);
|
bool LibraryExists(const char *library);
|
||||||
|
void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives);
|
||||||
public:
|
public:
|
||||||
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
@ -175,6 +185,8 @@ private:
|
|||||||
CExtension *FindByOrder(unsigned int num);
|
CExtension *FindByOrder(unsigned int num);
|
||||||
private:
|
private:
|
||||||
List<CExtension *> m_Libs;
|
List<CExtension *> m_Libs;
|
||||||
|
List<sm_repnative_t> m_RepNativeList;
|
||||||
|
KTrie<sm_repnative_t> m_RepNatives;
|
||||||
KTrie<sm_extnative_t> m_ExtNatives;
|
KTrie<sm_extnative_t> m_ExtNatives;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -994,10 +994,10 @@ bool HandleSystem::TryAndFreeSomeHandles()
|
|||||||
return g_PluginSys.UnloadPlugin(highest_owner);
|
return g_PluginSys.UnloadPlugin(highest_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleSystem::Dump(FILE *fp)
|
void HandleSystem::Dump(HANDLE_REPORTER rep)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%-10.10s\t%-20.20s\t%-20.20s\n", "Handle", "Owner", "Type");
|
rep("%-10.10s\t%-20.20s\t%-20.20s", "Handle", "Owner", "Type");
|
||||||
fprintf(fp, "---------------------------------------------\n");
|
rep("---------------------------------------------");
|
||||||
for (unsigned int i = 1; i <= m_HandleTail; i++)
|
for (unsigned int i = 1; i <= m_HandleTail; i++)
|
||||||
{
|
{
|
||||||
if (m_Handles[i].set != HandleSet_Used)
|
if (m_Handles[i].set != HandleSet_Used)
|
||||||
@ -1046,7 +1046,7 @@ void HandleSystem::Dump(FILE *fp)
|
|||||||
{
|
{
|
||||||
type = m_strtab->GetString(pType->nameIdx);
|
type = m_strtab->GetString(pType->nameIdx);
|
||||||
}
|
}
|
||||||
fprintf(fp, "0x%08x\t%-20.20s\t%-20.20s\n", index, owner, type);
|
rep("0x%08x\t%-20.20s\t%-20.20s", index, owner, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,8 @@ struct QHandleType
|
|||||||
int nameIdx;
|
int nameIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (HANDLE_REPORTER)(const char *str, ...);
|
||||||
|
|
||||||
class HandleSystem :
|
class HandleSystem :
|
||||||
public IHandleSys
|
public IHandleSys
|
||||||
{
|
{
|
||||||
@ -155,7 +157,7 @@ public: //IHandleSystem
|
|||||||
const HandleAccess *pAccess,
|
const HandleAccess *pAccess,
|
||||||
HandleError *err);
|
HandleError *err);
|
||||||
|
|
||||||
void Dump(FILE *fp);
|
void Dump(HANDLE_REPORTER rep);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Decodes a handle with sanity and security checking.
|
* Decodes a handle with sanity and security checking.
|
||||||
|
@ -1440,6 +1440,18 @@ void CPluginManager::AddCoreNativesToPlugin(CPlugin *pPlugin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPVM_NATIVE_FUNC CPluginManager::FindCoreNative(const char *name)
|
||||||
|
{
|
||||||
|
SPVM_NATIVE_FUNC pfn;
|
||||||
|
|
||||||
|
if (!sm_trie_retrieve(m_pCoreNatives, name, (void **)&pfn))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pfn;
|
||||||
|
}
|
||||||
|
|
||||||
void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
||||||
{
|
{
|
||||||
assert(pPlugin->GetBaseContext() != NULL);
|
assert(pPlugin->GetBaseContext() != NULL);
|
||||||
|
@ -489,6 +489,7 @@ public:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
bool AddFakeNative(IPluginFunction *pFunction, const char *name, SPVM_FAKENATIVE_FUNC func);
|
bool AddFakeNative(IPluginFunction *pFunction, const char *name, SPVM_FAKENATIVE_FUNC func);
|
||||||
|
SPVM_NATIVE_FUNC FindCoreNative(const char *name);
|
||||||
private:
|
private:
|
||||||
void AddFakeNativesToPlugin(CPlugin *pPlugin);
|
void AddFakeNativesToPlugin(CPlugin *pPlugin);
|
||||||
void TryRefreshDependencies(CPlugin *pOther);
|
void TryRefreshDependencies(CPlugin *pOther);
|
||||||
|
@ -243,3 +243,8 @@ void ShareSystem::RegisterLibrary(IExtension *myself, const char *name)
|
|||||||
{
|
{
|
||||||
g_Extensions.AddLibrary(myself, name);
|
g_Extensions.AddLibrary(myself, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShareSystem::OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives)
|
||||||
|
{
|
||||||
|
g_Extensions.OverrideNatives(myself, natives);
|
||||||
|
}
|
||||||
|
@ -81,6 +81,7 @@ public: //IShareSys
|
|||||||
void DestroyIdentity(IdentityToken_t *identity);
|
void DestroyIdentity(IdentityToken_t *identity);
|
||||||
void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload);
|
void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload);
|
||||||
void RegisterLibrary(IExtension *myself, const char *name);
|
void RegisterLibrary(IExtension *myself, const char *name);
|
||||||
|
void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives);
|
||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
/* Pre-empt in case anything tries to register idents early */
|
/* Pre-empt in case anything tries to register idents early */
|
||||||
void OnSourceModStartup(bool late);
|
void OnSourceModStartup(bool late);
|
||||||
|
@ -13,7 +13,7 @@ HL2SDK = ../../../hl2sdk
|
|||||||
PROJECT = game.cstrike
|
PROJECT = game.cstrike
|
||||||
|
|
||||||
#Uncomment for SourceMM-enabled extensions
|
#Uncomment for SourceMM-enabled extensions
|
||||||
#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
||||||
|
|
||||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ HL2SDK = ../../../hl2sdk-ob
|
|||||||
PROJECT = game.cstrike
|
PROJECT = game.cstrike
|
||||||
|
|
||||||
#Uncomment for SourceMM-enabled extensions
|
#Uncomment for SourceMM-enabled extensions
|
||||||
#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
||||||
|
|
||||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ HL2SDK = ../../../hl2sdk
|
|||||||
PROJECT = game.cstrike
|
PROJECT = game.cstrike
|
||||||
|
|
||||||
#Uncomment for SourceMM-enabled extensions
|
#Uncomment for SourceMM-enabled extensions
|
||||||
#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
||||||
|
|
||||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp timeleft.cpp
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ IBinTools *g_pBinTools = NULL;
|
|||||||
IGameConfig *g_pGameConf = NULL;
|
IGameConfig *g_pGameConf = NULL;
|
||||||
IGameEventManager2 *gameevents = NULL;
|
IGameEventManager2 *gameevents = NULL;
|
||||||
bool hooked_everything = false;
|
bool hooked_everything = false;
|
||||||
|
int g_msgHintText = -1;
|
||||||
|
|
||||||
SMEXT_LINK(&g_CStrike);
|
SMEXT_LINK(&g_CStrike);
|
||||||
|
|
||||||
@ -67,6 +68,11 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
sharesys->AddNatives(myself, g_CSNatives);
|
sharesys->AddNatives(myself, g_CSNatives);
|
||||||
sharesys->RegisterLibrary(myself, "cstrike");
|
sharesys->RegisterLibrary(myself, "cstrike");
|
||||||
|
|
||||||
|
if ((g_msgHintText = usermsgs->GetMessageIndex("HintText")) != -1)
|
||||||
|
{
|
||||||
|
sharesys->OverrideNatives(myself, g_CS_PrintHintText);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,5 +122,7 @@ public:
|
|||||||
/* Interfaces from SourceMod */
|
/* Interfaces from SourceMod */
|
||||||
extern IBinTools *g_pBinTools;
|
extern IBinTools *g_pBinTools;
|
||||||
extern IGameConfig *g_pGameConf;
|
extern IGameConfig *g_pGameConf;
|
||||||
|
extern int g_msgHintText;
|
||||||
|
extern sp_nativeinfo_t g_CS_PrintHintText[];
|
||||||
|
|
||||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||||
|
@ -69,6 +69,45 @@ inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
|
|||||||
return pUnk->GetBaseEntity();
|
return pUnk->GetBaseEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t CS_PrintHintText(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
int client = params[1];
|
||||||
|
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(params[1]);
|
||||||
|
|
||||||
|
if (!pPlayer)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pPlayer->IsInGame())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pSM->SetGlobalTarget(client);
|
||||||
|
|
||||||
|
char buffer[192];
|
||||||
|
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
|
||||||
|
|
||||||
|
/* Check for an error before printing to the client */
|
||||||
|
if (pContext->GetContext()->n_err != SP_ERROR_NONE)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bf_write *pBitBuf = usermsgs->StartMessage(g_msgHintText, ¶ms[1], 1, USERMSG_RELIABLE);
|
||||||
|
if (pBitBuf == NULL)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Could not send a usermessage");
|
||||||
|
}
|
||||||
|
pBitBuf->WriteByte(1);
|
||||||
|
pBitBuf->WriteString(buffer);
|
||||||
|
usermsgs->EndMessage();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
|
static cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
static ICallWrapper *pWrapper = NULL;
|
static ICallWrapper *pWrapper = NULL;
|
||||||
@ -124,3 +163,9 @@ sp_nativeinfo_t g_CSNatives[] =
|
|||||||
{"CS_SwitchTeam", CS_SwitchTeam},
|
{"CS_SwitchTeam", CS_SwitchTeam},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sp_nativeinfo_t g_CS_PrintHintText[] =
|
||||||
|
{
|
||||||
|
{"PrintHintText", CS_PrintHintText},
|
||||||
|
{NULL, NULL},
|
||||||
|
};
|
||||||
|
@ -71,5 +71,6 @@
|
|||||||
#define SMEXT_ENABLE_TIMERSYS
|
#define SMEXT_ENABLE_TIMERSYS
|
||||||
//#define SMEXT_ENABLE_THREADER
|
//#define SMEXT_ENABLE_THREADER
|
||||||
//#define SMEXT_ENABLE_LIBSYS
|
//#define SMEXT_ENABLE_LIBSYS
|
||||||
|
#define SMEXT_ENABLE_USERMSGS
|
||||||
|
|
||||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||||
|
@ -79,6 +79,9 @@ IThreader *threader = NULL;
|
|||||||
#if defined SMEXT_ENABLE_LIBSYS
|
#if defined SMEXT_ENABLE_LIBSYS
|
||||||
ILibrarySys *libsys = NULL;
|
ILibrarySys *libsys = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
IUserMessages *usermsgs = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Exports the main interface */
|
/** Exports the main interface */
|
||||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||||
@ -149,6 +152,9 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error,
|
|||||||
#if defined SMEXT_ENABLE_LIBSYS
|
#if defined SMEXT_ENABLE_LIBSYS
|
||||||
SM_GET_IFACE(LIBRARYSYS, libsys);
|
SM_GET_IFACE(LIBRARYSYS, libsys);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
SM_GET_IFACE(USERMSGS, usermsgs);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SDK_OnLoad(error, maxlength, late))
|
if (SDK_OnLoad(error, maxlength, late))
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,9 @@
|
|||||||
#if defined SMEXT_ENABLE_LIBSYS
|
#if defined SMEXT_ENABLE_LIBSYS
|
||||||
#include <ILibrarySys.h>
|
#include <ILibrarySys.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
#include <IUserMessages.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined SMEXT_CONF_METAMOD
|
#if defined SMEXT_CONF_METAMOD
|
||||||
#include <ISmmPlugin.h>
|
#include <ISmmPlugin.h>
|
||||||
@ -260,6 +263,9 @@ extern IThreader *threader;
|
|||||||
#if defined SMEXT_ENABLE_LIBSYS
|
#if defined SMEXT_ENABLE_LIBSYS
|
||||||
extern ILibrarySys *libsys;
|
extern ILibrarySys *libsys;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
extern IUserMessages *usermsgs;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined SMEXT_CONF_METAMOD
|
#if defined SMEXT_CONF_METAMOD
|
||||||
PLUGIN_GLOBALVARS();
|
PLUGIN_GLOBALVARS();
|
||||||
|
@ -266,6 +266,20 @@ const char *TopMenu::GetObjectInfoString(unsigned int object_id)
|
|||||||
return obj->info;
|
return obj->info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *TopMenu::GetObjectName(unsigned int object_id)
|
||||||
|
{
|
||||||
|
if (object_id == 0
|
||||||
|
|| object_id > m_Objects.size()
|
||||||
|
|| m_Objects[object_id - 1]->is_free)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
topmenu_object_t *obj = m_Objects[object_id - 1];
|
||||||
|
|
||||||
|
return obj->name;
|
||||||
|
}
|
||||||
|
|
||||||
void TopMenu::RemoveFromMenu(unsigned int object_id)
|
void TopMenu::RemoveFromMenu(unsigned int object_id)
|
||||||
{
|
{
|
||||||
if (object_id == 0
|
if (object_id == 0
|
||||||
|
@ -131,6 +131,7 @@ public: //ITopMenu
|
|||||||
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
|
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
|
||||||
virtual unsigned int FindCategory(const char *name);
|
virtual unsigned int FindCategory(const char *name);
|
||||||
const char *GetObjectInfoString(unsigned int object_id);
|
const char *GetObjectInfoString(unsigned int object_id);
|
||||||
|
const char *GetObjectName(unsigned int object_id);
|
||||||
public: //IMenuHandler
|
public: //IMenuHandler
|
||||||
virtual void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page);
|
virtual void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page);
|
||||||
virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
|
virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
|
||||||
|
@ -345,6 +345,30 @@ static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *param
|
|||||||
return strncopy(buffer, str, params[4]);
|
return strncopy(buffer, str, params[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
HandleError err;
|
||||||
|
ITopMenu *pMenu;
|
||||||
|
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||||
|
|
||||||
|
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *str;
|
||||||
|
if ((str = pMenu->GetObjectName(params[2])) == NULL)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buffer;
|
||||||
|
pContext->LocalToString(params[3], &buffer);
|
||||||
|
|
||||||
|
return strncopy(buffer, str, params[4]);
|
||||||
|
}
|
||||||
|
|
||||||
sp_nativeinfo_t g_TopMenuNatives[] =
|
sp_nativeinfo_t g_TopMenuNatives[] =
|
||||||
{
|
{
|
||||||
{"AddToTopMenu", AddToTopMenu},
|
{"AddToTopMenu", AddToTopMenu},
|
||||||
@ -354,5 +378,6 @@ sp_nativeinfo_t g_TopMenuNatives[] =
|
|||||||
{"RemoveFromTopMenu", RemoveFromTopMenu},
|
{"RemoveFromTopMenu", RemoveFromTopMenu},
|
||||||
{"FindTopMenuCategory", FindTopMenuCategory},
|
{"FindTopMenuCategory", FindTopMenuCategory},
|
||||||
{"GetTopMenuInfoString", GetTopMenuInfoString},
|
{"GetTopMenuInfoString", GetTopMenuInfoString},
|
||||||
|
{"GetTopMenuObjName", GetTopMenuName},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -62,6 +62,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which games use an extra byte in the HintText
|
||||||
|
* message? Even though it's in the SDK, apparently
|
||||||
|
* only CS:S does this right now.
|
||||||
|
*/
|
||||||
|
"#default"
|
||||||
|
{
|
||||||
|
"#supported"
|
||||||
|
{
|
||||||
|
"game" "cstrike"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Keys"
|
||||||
|
{
|
||||||
|
"HintTextPreByte" "yes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
"cstrike"
|
"cstrike"
|
||||||
{
|
{
|
||||||
"Keys"
|
"Keys"
|
||||||
@ -69,4 +87,12 @@
|
|||||||
"GameExtension" "game.cstrike"
|
"GameExtension" "game.cstrike"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"tf"
|
||||||
|
{
|
||||||
|
"Keys"
|
||||||
|
{
|
||||||
|
"RadioMenuTimeout" "4"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ new String:g_ColorNames[13][10] = {"White", "Red", "Green", "Blue", "Yellow", "P
|
|||||||
new g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{255,128,0},{255,0,128},{128,255,0},{0,255,128},{128,0,255},{0,128,255}};
|
new g_Colors[13][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255},{255,128,0},{255,0,128},{128,255,0},{0,255,128},{128,0,255},{0,128,255}};
|
||||||
|
|
||||||
new Handle:g_Cvar_Chatmode = INVALID_HANDLE;
|
new Handle:g_Cvar_Chatmode = INVALID_HANDLE;
|
||||||
new Handle:g_Cvar_Psaymode = INVALID_HANDLE;
|
|
||||||
|
|
||||||
new bool:g_DoColor = true;
|
new bool:g_DoColor = true;
|
||||||
|
|
||||||
@ -59,7 +58,6 @@ public OnPluginStart()
|
|||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
|
|
||||||
g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0);
|
g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0);
|
||||||
g_Cvar_Psaymode = CreateConVar("sm_psay_mode", "0", "Allows player's to use psay 'say @@' alias.", 0, true, 0.0, true, 1.0);
|
|
||||||
|
|
||||||
RegConsoleCmd("say", Command_SayChat);
|
RegConsoleCmd("say", Command_SayChat);
|
||||||
RegConsoleCmd("say_team", Command_SayAdmin);
|
RegConsoleCmd("say_team", Command_SayAdmin);
|
||||||
@ -114,17 +112,17 @@ public Action:Command_SayChat(client, args)
|
|||||||
decl String:name[64];
|
decl String:name[64];
|
||||||
GetClientName(client, name, sizeof(name));
|
GetClientName(client, name, sizeof(name));
|
||||||
|
|
||||||
if (msgStart == 1 && CheckAdminForChat(client)) // sm_say alias
|
if (msgStart == 1 && CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT)) // sm_say alias
|
||||||
{
|
{
|
||||||
SendChatToAll(name, message);
|
SendChatToAll(name, message);
|
||||||
LogAction(client, -1, "%L triggered sm_say (text %s)", client, message);
|
LogAction(client, -1, "%L triggered sm_say (text %s)", client, message);
|
||||||
}
|
}
|
||||||
else if (msgStart == 3 && CheckAdminForChat(client)) // sm_csay alias
|
else if (msgStart == 3 && CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT)) // sm_csay alias
|
||||||
{
|
{
|
||||||
PrintCenterTextAll("%s: %s", name, message);
|
PrintCenterTextAll("%s: %s", name, message);
|
||||||
LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text);
|
LogAction(client, -1, "%L triggered sm_csay (text %s)", client, text);
|
||||||
}
|
}
|
||||||
else if (msgStart == 2 && (CheckAdminForChat(client) || GetConVarBool(g_Cvar_Psaymode))) // sm_psay alias
|
else if (msgStart == 2 && CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT)) // sm_psay alias
|
||||||
{
|
{
|
||||||
decl String:arg[64];
|
decl String:arg[64];
|
||||||
|
|
||||||
@ -158,7 +156,7 @@ public Action:Command_SayChat(client, args)
|
|||||||
|
|
||||||
public Action:Command_SayAdmin(client, args)
|
public Action:Command_SayAdmin(client, args)
|
||||||
{
|
{
|
||||||
if (!CheckAdminForChat(client) && !GetConVarBool(g_Cvar_Chatmode))
|
if (!CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT) && !GetConVarBool(g_Cvar_Chatmode))
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@ -359,16 +357,6 @@ public Action:Command_SmMsay(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool:CheckAdminForChat(client)
|
|
||||||
{
|
|
||||||
if (client == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CheckCommandAccess(client, "sm_chat", ADMFLAG_CHAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
FindColor(String:color[])
|
FindColor(String:color[])
|
||||||
{
|
{
|
||||||
for (new i = 0; i < 13; i++)
|
for (new i = 0; i < 13; i++)
|
||||||
@ -400,7 +388,7 @@ SendChatToAdmins(String:name[], String:message[])
|
|||||||
{
|
{
|
||||||
if (IsClientInGame(i))
|
if (IsClientInGame(i))
|
||||||
{
|
{
|
||||||
if (CheckAdminForChat(i))
|
if (CheckCommandAccess(i, "sm_chat", ADMFLAG_CHAT))
|
||||||
{
|
{
|
||||||
if (g_DoColor)
|
if (g_DoColor)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ DisplayGagPlayerMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, false);
|
AddTargetsToMenu(menu, client, true, false);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ DisplayBurnMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, true);
|
AddTargetsToMenu(menu, client, true, true);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ DisplaySlapTargetMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, true);
|
AddTargetsToMenu(menu, client, true, true);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ DisplaySlayMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, true);
|
AddTargetsToMenu(menu, client, true, true);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ DisplayBurnTargetMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, true);
|
AddTargetsToMenu(menu, client, true, true);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ DisplaySlayTargetMenu(client)
|
|||||||
SetMenuTitle(menu, title);
|
SetMenuTitle(menu, title);
|
||||||
SetMenuExitBackButton(menu, true);
|
SetMenuExitBackButton(menu, true);
|
||||||
|
|
||||||
AddTargetsToMenu(menu, client, false, true);
|
AddTargetsToMenu(menu, client, true, true);
|
||||||
|
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,6 @@ public Plugin:myinfo =
|
|||||||
|
|
||||||
new Handle:g_hVoteMenu = INVALID_HANDLE;
|
new Handle:g_hVoteMenu = INVALID_HANDLE;
|
||||||
|
|
||||||
new Handle:g_hBanForward = INVALID_HANDLE;
|
|
||||||
|
|
||||||
new Handle:g_Cvar_Limits[3] = {INVALID_HANDLE, ...};
|
new Handle:g_Cvar_Limits[3] = {INVALID_HANDLE, ...};
|
||||||
//new Handle:g_Cvar_VoteSay = INVALID_HANDLE;
|
//new Handle:g_Cvar_VoteSay = INVALID_HANDLE;
|
||||||
|
|
||||||
@ -111,8 +109,6 @@ public OnPluginStart()
|
|||||||
g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);
|
g_Cvar_Limits[1] = CreateConVar("sm_vote_kick", "0.60", "percent required for successful kick vote.", 0, true, 0.05, true, 1.0);
|
||||||
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
|
g_Cvar_Limits[2] = CreateConVar("sm_vote_ban", "0.60", "percent required for successful ban vote.", 0, true, 0.05, true, 1.0);
|
||||||
|
|
||||||
g_hBanForward = CreateGlobalForward("OnClientBanned", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_String);
|
|
||||||
|
|
||||||
/* Account for late loading */
|
/* Account for late loading */
|
||||||
new Handle:topmenu;
|
new Handle:topmenu;
|
||||||
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
|
||||||
@ -350,14 +346,6 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
|
|||||||
|
|
||||||
case (voteType:ban):
|
case (voteType:ban):
|
||||||
{
|
{
|
||||||
/* Fire the ban forward */
|
|
||||||
Call_StartForward(g_hBanForward);
|
|
||||||
Call_PushCell(0);
|
|
||||||
Call_PushCell(g_voteClient[VOTE_USERID]);
|
|
||||||
Call_PushCell(30);
|
|
||||||
Call_PushString(g_voteArg);
|
|
||||||
Call_Finish();
|
|
||||||
|
|
||||||
if (g_voteArg[0] == '\0')
|
if (g_voteArg[0] == '\0')
|
||||||
{
|
{
|
||||||
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
|
strcopy(g_voteArg, sizeof(g_voteArg), "Votebanned");
|
||||||
@ -366,8 +354,12 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
|
|||||||
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
|
PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
|
||||||
LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg);
|
LogAction(-1, g_voteClient[VOTE_CLIENTID], "Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg);
|
||||||
|
|
||||||
ServerCommand("banid %d %s", 30, g_voteClient[VOTE_AUTHID]);
|
BanClient(g_voteClient[VOTE_CLIENTID],
|
||||||
ServerCommand("kickid %d \"%s\"", g_voteClient[VOTE_USERID], g_voteArg);
|
30,
|
||||||
|
BANFLAG_AUTO,
|
||||||
|
g_voteArg,
|
||||||
|
"Banned by vote",
|
||||||
|
"sm_voteban");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2)
|
|||||||
|
|
||||||
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
|
||||||
|
|
||||||
if (IsStringInArray(g_SelectedMaps, info))
|
if (FindStringInArray(g_SelectedMaps, info) != -1)
|
||||||
{
|
{
|
||||||
return ITEMDRAW_IGNORE;
|
return ITEMDRAW_IGNORE;
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,15 @@ native KvGetUInt64(Handle:kv, const String:key[], value[2], defvalue[2]={0,0});
|
|||||||
*/
|
*/
|
||||||
native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
|
native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current position in the KeyValues tree to the given key.
|
||||||
|
*
|
||||||
|
* @param kv KeyValues Handle.
|
||||||
|
* @param id KeyValues id.
|
||||||
|
* @return True if the key exists, false if it does not.
|
||||||
|
*/
|
||||||
|
native bool:KvJumpToKeySymbol(Handle:kv, id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position in the KeyValues tree to the first sub key.
|
* Sets the current position in the KeyValues tree to the first sub key.
|
||||||
* This native adds to the internal traversal stack.
|
* This native adds to the internal traversal stack.
|
||||||
@ -385,3 +394,13 @@ native bool:KvFindKeyById(Handle:kv, id, String:name[], maxlength);
|
|||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGetNameSymbol(Handle:kv, const String:key[], &id);
|
native bool:KvGetNameSymbol(Handle:kv, const String:key[], &id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the current section id.
|
||||||
|
*
|
||||||
|
* @param kv KeyValues Handle.
|
||||||
|
* @param id Id of the current section.
|
||||||
|
* @return True on success, false on failure.
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native bool:KvGetSectionSymbol(Handle:kv, &id);
|
||||||
|
@ -732,6 +732,26 @@ native bool:SetPanelCurrentKey(Handle:panel, key);
|
|||||||
*/
|
*/
|
||||||
native RedrawMenuItem(const String:text[]);
|
native RedrawMenuItem(const String:text[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is provided for legacy code only. Some older plugins may use
|
||||||
|
* network messages instead of the panel API. This function wraps the panel
|
||||||
|
* API for eased portability into the SourceMod menu system.
|
||||||
|
*
|
||||||
|
* This function is only usable with the Radio Menu style. You do not need to
|
||||||
|
* split up your menu into multiple packets; SourceMod will break the string
|
||||||
|
* up internally.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @param str Full menu string as would be passed over the network.
|
||||||
|
* @param time Time to hold the menu for.
|
||||||
|
* @param keys Selectable key bitstring.
|
||||||
|
* @param handler Optional handler function, with the same rules as
|
||||||
|
* SendPanelToClient().
|
||||||
|
* @return True on success, false on failure.
|
||||||
|
* @error Invalid client index, or radio menus not supported.
|
||||||
|
*/
|
||||||
|
native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHandler:handler=MenuHandler:-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves voting information from MenuAction_VoteEnd.
|
* Retrieves voting information from MenuAction_VoteEnd.
|
||||||
*
|
*
|
||||||
|
@ -45,6 +45,16 @@ enum SortOrder
|
|||||||
Sort_Descending = 1, /**< Descending order */
|
Sort_Descending = 1, /**< Descending order */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data types for ADT Array Sorts
|
||||||
|
*/
|
||||||
|
enum SortType
|
||||||
|
{
|
||||||
|
Sort_Integer = 0,
|
||||||
|
Sort_Float,
|
||||||
|
Sort_String,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array of integers.
|
* Sorts an array of integers.
|
||||||
*
|
*
|
||||||
@ -128,3 +138,38 @@ funcenum SortFunc2D
|
|||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);
|
native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort an ADT Array. Specify the type as Integer, Float, or String.
|
||||||
|
*
|
||||||
|
* @param array Array Handle to sort
|
||||||
|
* @param order Sort order to use, same as other sorts.
|
||||||
|
* @param type Data type stored in the ADT Array
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native SortADTArray(Handle:array, SortOrder:order = Sort_Ascending, SortType:type = Sort_Integer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort comparison function for ADT Array elements. Function provides you with
|
||||||
|
* indexes currently being sorted, use ADT Array functions to retrieve the
|
||||||
|
* index values and compare.
|
||||||
|
*
|
||||||
|
* @param index1 First index to compare.
|
||||||
|
* @param index2 Second index to compare.
|
||||||
|
* @param array Array that is being sorted (order is undefined).
|
||||||
|
* @param hndl Handle optionally passed in while sorting.
|
||||||
|
* @return -1 if first should go before second
|
||||||
|
* 0 if first is equal to second
|
||||||
|
* 1 if first should go after second
|
||||||
|
*/
|
||||||
|
functag SortFuncADTArray public(index1, index2, Handle:array, Handle:hndl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom sorts an ADT Array. You must pass in a comparison function.
|
||||||
|
*
|
||||||
|
* @param array Array Handle to sort
|
||||||
|
* @param sortfunc Sort comparision function to use
|
||||||
|
* @param hndl Optional Handle to pass through the comparison calls.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native SortADTArrayCustom(Handle:array, SortFuncADTArray:sortfunc, Handle:hndl=INVALID_HANDLE);
|
@ -210,6 +210,19 @@ native TopMenuObject:AddToTopMenu(Handle:topmenu,
|
|||||||
*/
|
*/
|
||||||
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
|
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the name string of a top menu item.
|
||||||
|
*
|
||||||
|
* @param topmenu TopMenu Handle.
|
||||||
|
* @param object TopMenuObject ID.
|
||||||
|
* @param buffer Buffer to store info string.
|
||||||
|
* @param maxlength Maximum size of info string.
|
||||||
|
* @return Number of bytes written, not including the
|
||||||
|
* null terminator.
|
||||||
|
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||||
|
*/
|
||||||
|
native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an object from a TopMenu.
|
* Removes an object from a TopMenu.
|
||||||
*
|
*
|
||||||
|
@ -74,6 +74,7 @@ new Handle:g_NextMapList = INVALID_HANDLE;
|
|||||||
new Handle:g_TeamScores = INVALID_HANDLE;
|
new Handle:g_TeamScores = INVALID_HANDLE;
|
||||||
new Handle:g_VoteMenu = INVALID_HANDLE;
|
new Handle:g_VoteMenu = INVALID_HANDLE;
|
||||||
|
|
||||||
|
new g_TotalRounds;
|
||||||
new bool:g_HasVoteStarted;
|
new bool:g_HasVoteStarted;
|
||||||
new g_mapFileTime;
|
new g_mapFileTime;
|
||||||
|
|
||||||
@ -87,7 +88,6 @@ public OnPluginStart()
|
|||||||
g_MapList = CreateArray(arraySize);
|
g_MapList = CreateArray(arraySize);
|
||||||
g_OldMapList = CreateArray(arraySize);
|
g_OldMapList = CreateArray(arraySize);
|
||||||
g_NextMapList = CreateArray(arraySize);
|
g_NextMapList = CreateArray(arraySize);
|
||||||
g_TeamScores = CreateArray(2);
|
|
||||||
|
|
||||||
g_Cvar_StartTime = CreateConVar("sm_mapvote_start", "3.0", "Specifies when to start the vote based on time remaining.", _, true, 1.0);
|
g_Cvar_StartTime = CreateConVar("sm_mapvote_start", "3.0", "Specifies when to start the vote based on time remaining.", _, true, 1.0);
|
||||||
g_Cvar_StartRounds = CreateConVar("sm_mapvote_startround", "2.0", "Specifies when to start the vote based on rounds remaining.", _, true, 1.0);
|
g_Cvar_StartRounds = CreateConVar("sm_mapvote_startround", "2.0", "Specifies when to start the vote based on rounds remaining.", _, true, 1.0);
|
||||||
@ -139,6 +139,14 @@ public OnConfigsExecuted()
|
|||||||
SetupTimeleftTimer();
|
SetupTimeleftTimer();
|
||||||
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
|
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_TeamScores != INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
CloseHandle(g_TeamScores);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_TeamScores = CreateArray(2);
|
||||||
|
g_TotalRounds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnMapEnd()
|
public OnMapEnd()
|
||||||
@ -225,8 +233,7 @@ public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static total;
|
g_TotalRounds++;
|
||||||
total++;
|
|
||||||
|
|
||||||
new team[2], teamPos = -1;
|
new team[2], teamPos = -1;
|
||||||
for (new i; i < GetArraySize(g_TeamScores); i++)
|
for (new i; i < GetArraySize(g_TeamScores); i++)
|
||||||
@ -268,7 +275,7 @@ public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
|
|||||||
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
|
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
|
||||||
if (maxrounds)
|
if (maxrounds)
|
||||||
{
|
{
|
||||||
if (total >= (maxrounds - GetConVarInt(g_Cvar_StartRounds)))
|
if (g_TotalRounds >= (maxrounds - GetConVarInt(g_Cvar_StartRounds)))
|
||||||
{
|
{
|
||||||
InitiateVote();
|
InitiateVote();
|
||||||
}
|
}
|
||||||
|
@ -90,10 +90,8 @@ public OnConfigsExecuted()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:OnTimedKick(Handle:timer, any:value)
|
public Action:OnTimedKick(Handle:timer, any:client)
|
||||||
{
|
{
|
||||||
new client = GetClientOfUserId(value);
|
|
||||||
|
|
||||||
if (!client || !IsClientInGame(client))
|
if (!client || !IsClientInGame(client))
|
||||||
{
|
{
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -101,6 +99,11 @@ public Action:OnTimedKick(Handle:timer, any:value)
|
|||||||
|
|
||||||
KickClient(client, "%T", "Slot reserved", client);
|
KickClient(client, "%T", "Slot reserved", client);
|
||||||
|
|
||||||
|
if (GetConVarBool(sm_hide_slots))
|
||||||
|
{
|
||||||
|
SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
|
||||||
|
}
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +117,10 @@ public OnClientPostAdminCheck(client)
|
|||||||
new limit = g_MaxClients - reserved;
|
new limit = g_MaxClients - reserved;
|
||||||
new flags = GetUserFlagBits(client);
|
new flags = GetUserFlagBits(client);
|
||||||
|
|
||||||
|
new type = GetConVarInt(sm_reserve_type);
|
||||||
|
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
||||||
{
|
{
|
||||||
if (GetConVarBool(sm_hide_slots))
|
if (GetConVarBool(sm_hide_slots))
|
||||||
@ -121,24 +128,33 @@ public OnClientPostAdminCheck(client)
|
|||||||
SetVisibleMaxSlots(clients, limit);
|
SetVisibleMaxSlots(clients, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
new type = GetConVarInt(sm_reserve_type);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 1)
|
/* Kick player because there are no public slots left */
|
||||||
|
CreateTimer(0.1, OnTimedKick, client);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (clients > limit)
|
||||||
|
{
|
||||||
|
if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
|
||||||
{
|
{
|
||||||
new target = SelectKickClient();
|
new target = SelectKickClient();
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
/* Kick public player to free the reserved slot again */
|
/* Kick public player to free the reserved slot again */
|
||||||
CreateTimer(0.1, OnTimedKick, GetClientUserId(target));
|
CreateTimer(0.1, OnTimedKick, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
/* Kick player because there are no public slots left */
|
/* Kick player because there are no public slots left */
|
||||||
CreateTimer(0.1, OnTimedKick, GetClientUserId(client));
|
CreateTimer(0.1, OnTimedKick, client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +177,7 @@ public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValu
|
|||||||
|
|
||||||
SetVisibleMaxSlots(clients, limit)
|
SetVisibleMaxSlots(clients, limit)
|
||||||
{
|
{
|
||||||
new num = clients + 1;
|
new num = clients;
|
||||||
|
|
||||||
if (clients == g_MaxClients)
|
if (clients == g_MaxClients)
|
||||||
{
|
{
|
||||||
@ -199,9 +215,13 @@ SelectKickClient()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
latency = 0.0;
|
||||||
|
|
||||||
if (IsClientInGame(i))
|
if (IsClientInGame(i))
|
||||||
{
|
{
|
||||||
latency = GetClientAvgLatency(i, NetFlow_Both);
|
latency = GetClientAvgLatency(i, NetFlow_Outgoing);
|
||||||
|
|
||||||
|
LogMessage("Latency : %f",latency);
|
||||||
|
|
||||||
if (IsClientObserver(i))
|
if (IsClientObserver(i))
|
||||||
{
|
{
|
||||||
@ -214,12 +234,8 @@ SelectKickClient()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
latency = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (latency > highestLatency)
|
if (latency >= highestLatency)
|
||||||
{
|
{
|
||||||
highestLatency = latency;
|
highestLatency = latency;
|
||||||
highestLatencyId = i;
|
highestLatencyId = i;
|
||||||
|
@ -89,6 +89,21 @@ public OnPluginStart()
|
|||||||
AutoExecConfig(true, "rtv");
|
AutoExecConfig(true, "rtv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OnMapStart()
|
||||||
|
{
|
||||||
|
g_Voters = 0;
|
||||||
|
g_Votes = 0;
|
||||||
|
g_VotesNeeded = 0;
|
||||||
|
g_RTVStarted = false;
|
||||||
|
g_RTVEnded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnMapEnd()
|
||||||
|
{
|
||||||
|
g_CanRTV = false;
|
||||||
|
g_RTVAllowed = false;
|
||||||
|
}
|
||||||
|
|
||||||
public OnConfigsExecuted()
|
public OnConfigsExecuted()
|
||||||
{
|
{
|
||||||
if (g_RTVMapList != INVALID_HANDLE)
|
if (g_RTVMapList != INVALID_HANDLE)
|
||||||
@ -96,12 +111,6 @@ public OnConfigsExecuted()
|
|||||||
ClearArray(g_RTVMapList);
|
ClearArray(g_RTVMapList);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Voters = 0;
|
|
||||||
g_Votes = 0;
|
|
||||||
g_VotesNeeded = 0;
|
|
||||||
g_RTVStarted = false;
|
|
||||||
g_RTVEnded = false;
|
|
||||||
|
|
||||||
if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_File))
|
if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_File))
|
||||||
{
|
{
|
||||||
BuildMapMenu();
|
BuildMapMenu();
|
||||||
@ -110,16 +119,9 @@ public OnConfigsExecuted()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnMapEnd()
|
|
||||||
{
|
|
||||||
g_CanRTV = false;
|
|
||||||
g_RTVAllowed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
||||||
{
|
{
|
||||||
if(IsFakeClient(client))
|
if(!g_CanRTV || IsFakeClient(client))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
g_Voted[client] = false;
|
g_Voted[client] = false;
|
||||||
@ -133,7 +135,7 @@ public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
|
|||||||
|
|
||||||
public OnClientDisconnect(client)
|
public OnClientDisconnect(client)
|
||||||
{
|
{
|
||||||
if(IsFakeClient(client))
|
if(!g_CanRTV || IsFakeClient(client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(g_Voted[client])
|
if(g_Voted[client])
|
||||||
@ -145,8 +147,9 @@ public OnClientDisconnect(client)
|
|||||||
|
|
||||||
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
g_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
|
||||||
|
|
||||||
if (g_Votes && g_Voters && g_Votes >= g_VotesNeeded && g_RTVAllowed)
|
if (g_Votes && g_Voters && g_Votes >= g_VotesNeeded && g_RTVAllowed && !g_RTVStarted)
|
||||||
{
|
{
|
||||||
|
g_RTVStarted = true;
|
||||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,6 +162,12 @@ public Action:Command_Addmap(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!g_CanRTV)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] RockTheVote is not available.");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
decl String:mapname[64];
|
decl String:mapname[64];
|
||||||
GetCmdArg(1, mapname, sizeof(mapname));
|
GetCmdArg(1, mapname, sizeof(mapname));
|
||||||
|
|
||||||
@ -209,7 +218,9 @@ public Action:Command_Addmap(client, args)
|
|||||||
public Action:Command_Say(client, args)
|
public Action:Command_Say(client, args)
|
||||||
{
|
{
|
||||||
if (!g_CanRTV || !client)
|
if (!g_CanRTV || !client)
|
||||||
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
decl String:text[192];
|
decl String:text[192];
|
||||||
if (!GetCmdArgString(text, sizeof(text)))
|
if (!GetCmdArgString(text, sizeof(text)))
|
||||||
@ -266,6 +277,7 @@ public Action:Command_Say(client, args)
|
|||||||
|
|
||||||
if (g_Votes >= g_VotesNeeded)
|
if (g_Votes >= g_VotesNeeded)
|
||||||
{
|
{
|
||||||
|
g_RTVStarted = true;
|
||||||
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,8 +330,6 @@ public Action:Timer_StartRTV(Handle:timer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_RTVStarted = true;
|
|
||||||
|
|
||||||
if (IsVoteInProgress())
|
if (IsVoteInProgress())
|
||||||
{
|
{
|
||||||
// Can't start a vote, try again in 5 seconds.
|
// Can't start a vote, try again in 5 seconds.
|
||||||
@ -430,6 +440,7 @@ public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
|
|||||||
if (param1 == VoteCancel_NoVotes)
|
if (param1 == VoteCancel_NoVotes)
|
||||||
{
|
{
|
||||||
PrintToChatAll("[SM] %t", "No Votes");
|
PrintToChatAll("[SM] %t", "No Votes");
|
||||||
|
g_RTVEnded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,13 +9,17 @@ public Plugin:myinfo =
|
|||||||
url = "http://www.sourcemod.net/"
|
url = "http://www.sourcemod.net/"
|
||||||
};
|
};
|
||||||
|
|
||||||
public OnPluginStart(Handle:myself)
|
public OnPluginStart()
|
||||||
{
|
{
|
||||||
RegServerCmd("test_sort_ints", Command_TestSortInts)
|
RegServerCmd("test_sort_ints", Command_TestSortInts)
|
||||||
RegServerCmd("test_sort_floats", Command_TestSortFloats)
|
RegServerCmd("test_sort_floats", Command_TestSortFloats)
|
||||||
RegServerCmd("test_sort_strings", Command_TestSortStrings)
|
RegServerCmd("test_sort_strings", Command_TestSortStrings)
|
||||||
RegServerCmd("test_sort_1d", Command_TestSort1D)
|
RegServerCmd("test_sort_1d", Command_TestSort1D)
|
||||||
RegServerCmd("test_sort_2d", Command_TestSort2D)
|
RegServerCmd("test_sort_2d", Command_TestSort2D)
|
||||||
|
RegServerCmd("test_adtsort_ints", Command_TestSortADTInts)
|
||||||
|
RegServerCmd("test_adtsort_floats", Command_TestSortADTFloats)
|
||||||
|
RegServerCmd("test_adtsort_strings", Command_TestSortADTStrings)
|
||||||
|
RegServerCmd("test_adtsort_custom", Command_TestSortADTCustom)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
@ -138,7 +142,7 @@ public Action:Command_TestSortStrings(args)
|
|||||||
|
|
||||||
public Custom2DSort(String:elem1[], String:elem2[], String:array[][], Handle:hndl)
|
public Custom2DSort(String:elem1[], String:elem2[], String:array[][], Handle:hndl)
|
||||||
{
|
{
|
||||||
return StrCompare(elem1, elem2)
|
return strcmp(elem1, elem2)
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:Command_TestSort2D(args)
|
public Action:Command_TestSort2D(args)
|
||||||
@ -162,3 +166,142 @@ public Action:Command_TestSort2D(args)
|
|||||||
|
|
||||||
return Plugin_Handled
|
return Plugin_Handled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************
|
||||||
|
* ADT ARRAY TESTS *
|
||||||
|
*******************/
|
||||||
|
// Int and floats work the same as normal comparisions. Strings are direct
|
||||||
|
// comparisions with no hacky memory stuff like Pawn arrays.
|
||||||
|
|
||||||
|
PrintADTArrayIntegers(Handle:array)
|
||||||
|
{
|
||||||
|
new size = GetArraySize(array);
|
||||||
|
for (new i=0; i<size;i++)
|
||||||
|
{
|
||||||
|
PrintToServer("array[%d] = %d", i, GetArrayCell(array, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:Command_TestSortADTInts(args)
|
||||||
|
{
|
||||||
|
new Handle:array = CreateArray();
|
||||||
|
PushArrayCell(array, 6);
|
||||||
|
PushArrayCell(array, 7);
|
||||||
|
PushArrayCell(array, 3);
|
||||||
|
PushArrayCell(array, 2);
|
||||||
|
PushArrayCell(array, 8);
|
||||||
|
PushArrayCell(array, 5);
|
||||||
|
PushArrayCell(array, 0);
|
||||||
|
PushArrayCell(array, 1);
|
||||||
|
PushArrayCell(array, 4);
|
||||||
|
PushArrayCell(array, 9);
|
||||||
|
|
||||||
|
PrintToServer("Testing ascending sort:")
|
||||||
|
SortADTArray(array, Sort_Ascending, Sort_Integer)
|
||||||
|
PrintADTArrayIntegers(array)
|
||||||
|
|
||||||
|
PrintToServer("Testing descending sort:")
|
||||||
|
SortADTArray(array, Sort_Descending, Sort_Integer)
|
||||||
|
PrintADTArrayIntegers(array)
|
||||||
|
|
||||||
|
return Plugin_Handled
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintADTArrayFloats(Handle:array)
|
||||||
|
{
|
||||||
|
new size = GetArraySize(array);
|
||||||
|
for (new i=0; i<size;i++)
|
||||||
|
{
|
||||||
|
PrintToServer("array[%d] = %f", i, float:GetArrayCell(array, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:Command_TestSortADTFloats(args)
|
||||||
|
{
|
||||||
|
new Handle:array = CreateArray();
|
||||||
|
PushArrayCell(array, 6.0);
|
||||||
|
PushArrayCell(array, 7.0);
|
||||||
|
PushArrayCell(array, 3.0);
|
||||||
|
PushArrayCell(array, 2.0);
|
||||||
|
PushArrayCell(array, 8.0);
|
||||||
|
PushArrayCell(array, 5.0);
|
||||||
|
PushArrayCell(array, 0.0);
|
||||||
|
PushArrayCell(array, 1.0);
|
||||||
|
PushArrayCell(array, 4.0);
|
||||||
|
PushArrayCell(array, 9.0);
|
||||||
|
|
||||||
|
PrintToServer("Testing ascending sort:")
|
||||||
|
SortADTArray(array, Sort_Ascending, Sort_Float)
|
||||||
|
PrintADTArrayFloats(array)
|
||||||
|
|
||||||
|
PrintToServer("Testing descending sort:")
|
||||||
|
SortADTArray(array, Sort_Descending, Sort_Float)
|
||||||
|
PrintADTArrayFloats(array)
|
||||||
|
|
||||||
|
return Plugin_Handled
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintADTArrayStrings(Handle:array)
|
||||||
|
{
|
||||||
|
new size = GetArraySize(array);
|
||||||
|
decl String:buffer[64];
|
||||||
|
for (new i=0; i<size;i++)
|
||||||
|
{
|
||||||
|
GetArrayString(array, i, buffer, sizeof(buffer));
|
||||||
|
PrintToServer("array[%d] = %s", i, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:Command_TestSortADTStrings(args)
|
||||||
|
{
|
||||||
|
new Handle:array = CreateArray(ByteCountToCells(64));
|
||||||
|
PushArrayString(array, "faluco");
|
||||||
|
PushArrayString(array, "bailopan");
|
||||||
|
PushArrayString(array, "pm onoto");
|
||||||
|
PushArrayString(array, "damaged soul");
|
||||||
|
PushArrayString(array, "sniperbeamer");
|
||||||
|
PushArrayString(array, "sidluke");
|
||||||
|
PushArrayString(array, "johnny got his gun");
|
||||||
|
PushArrayString(array, "gabe newell");
|
||||||
|
PushArrayString(array, "hello");
|
||||||
|
PushArrayString(array, "WHAT?!");
|
||||||
|
|
||||||
|
PrintToServer("Testing ascending sort:")
|
||||||
|
SortADTArray(array, Sort_Ascending, Sort_String)
|
||||||
|
PrintADTArrayStrings(array)
|
||||||
|
|
||||||
|
PrintToServer("Testing descending sort:")
|
||||||
|
SortADTArray(array, Sort_Descending, Sort_String)
|
||||||
|
PrintADTArrayStrings(array)
|
||||||
|
|
||||||
|
return Plugin_Handled
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayADTCustomCallback(index1, index2, Handle:array, Handle:hndl)
|
||||||
|
{
|
||||||
|
decl String:buffer1[64], String:buffer2[64];
|
||||||
|
GetArrayString(array, index1, buffer1, sizeof(buffer1));
|
||||||
|
GetArrayString(array, index2, buffer2, sizeof(buffer2));
|
||||||
|
|
||||||
|
return strcmp(buffer1, buffer2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:Command_TestSortADTCustom(args)
|
||||||
|
{
|
||||||
|
new Handle:array = CreateArray(ByteCountToCells(64));
|
||||||
|
PushArrayString(array, "faluco");
|
||||||
|
PushArrayString(array, "bailopan");
|
||||||
|
PushArrayString(array, "pm onoto");
|
||||||
|
PushArrayString(array, "damaged soul");
|
||||||
|
PushArrayString(array, "sniperbeamer");
|
||||||
|
PushArrayString(array, "sidluke");
|
||||||
|
PushArrayString(array, "johnny got his gun");
|
||||||
|
PushArrayString(array, "gabe newell");
|
||||||
|
PushArrayString(array, "hello");
|
||||||
|
PushArrayString(array, "WHAT?!");
|
||||||
|
|
||||||
|
PrintToServer("Testing custom sort:")
|
||||||
|
SortADTArrayCustom(array, ArrayADTCustomCallback)
|
||||||
|
PrintADTArrayStrings(array);
|
||||||
|
}
|
||||||
|
@ -624,7 +624,7 @@ namespace SourceMod
|
|||||||
/**
|
/**
|
||||||
* @brief Reads a single character as a flag.
|
* @brief Reads a single character as a flag.
|
||||||
*
|
*
|
||||||
* @param flag Flag character.
|
* @param c Flag character.
|
||||||
* @param pAdmFlag Pointer to store the admin flag.
|
* @param pAdmFlag Pointer to store the admin flag.
|
||||||
* @return True on success, false if invalid.
|
* @return True on success, false if invalid.
|
||||||
*/
|
*/
|
||||||
@ -707,7 +707,7 @@ namespace SourceMod
|
|||||||
* @brief Computers access to an override.
|
* @brief Computers access to an override.
|
||||||
*
|
*
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @param override Override name.
|
* @param cmd Override name.
|
||||||
* @param flags Default flags.
|
* @param flags Default flags.
|
||||||
* @param override_only If false, if a command matches the override,
|
* @param override_only If false, if a command matches the override,
|
||||||
* then its flags will override the default.
|
* then its flags will override the default.
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file IDBDriver.h
|
||||||
|
* @brief Defines interfaces for interacting with relational databases.
|
||||||
|
*/
|
||||||
|
|
||||||
#define SMINTERFACE_DBI_NAME "IDBI"
|
#define SMINTERFACE_DBI_NAME "IDBI"
|
||||||
#define SMINTERFACE_DBI_VERSION 5
|
#define SMINTERFACE_DBI_VERSION 5
|
||||||
|
|
||||||
@ -784,7 +789,7 @@ namespace SourceMod
|
|||||||
* @param type A DBHandleType value.
|
* @param type A DBHandleType value.
|
||||||
* @param ptr A pointer corrresponding to a DBHandleType
|
* @param ptr A pointer corrresponding to a DBHandleType
|
||||||
* object.
|
* object.
|
||||||
* @param token Identity pointer of the owning identity.
|
* @param pToken Identity pointer of the owning identity.
|
||||||
* @return A new Handle_t handle, or 0 on failure.
|
* @return A new Handle_t handle, or 0 on failure.
|
||||||
*/
|
*/
|
||||||
virtual Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken) =0;
|
virtual Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken) =0;
|
||||||
@ -814,7 +819,7 @@ namespace SourceMod
|
|||||||
* @brief Given a driver name, attempts to find it. If it is not found, SourceMod
|
* @brief Given a driver name, attempts to find it. If it is not found, SourceMod
|
||||||
* will attempt to load it. This function is not thread safe.
|
* will attempt to load it. This function is not thread safe.
|
||||||
*
|
*
|
||||||
* @param name Driver identifier name.
|
* @param driver Driver identifier name.
|
||||||
* @return IDBDriver pointer on success, NULL otherwise.
|
* @return IDBDriver pointer on success, NULL otherwise.
|
||||||
*/
|
*/
|
||||||
virtual IDBDriver *FindOrLoadDriver(const char *driver) =0;
|
virtual IDBDriver *FindOrLoadDriver(const char *driver) =0;
|
||||||
|
@ -127,8 +127,11 @@ namespace SourceMod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Version code of the IExtensionInterface API itself.
|
* @brief Version code of the IExtensionInterface API itself.
|
||||||
|
*
|
||||||
|
* Note: This is bumped when IShareSys is changed, because IShareSys
|
||||||
|
* itself is not versioned.
|
||||||
*/
|
*/
|
||||||
#define SMINTERFACE_EXTENSIONAPI_VERSION 2
|
#define SMINTERFACE_EXTENSIONAPI_VERSION 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The interface an extension must expose.
|
* @brief The interface an extension must expose.
|
||||||
@ -337,7 +340,6 @@ namespace SourceMod
|
|||||||
*
|
*
|
||||||
* @param path Path to extension file, relative to the
|
* @param path Path to extension file, relative to the
|
||||||
* extensions folder.
|
* extensions folder.
|
||||||
* @param lifetime Lifetime of the extension (currently ignored).
|
|
||||||
* @param error Error buffer.
|
* @param error Error buffer.
|
||||||
* @param maxlength Maximum error buffer length.
|
* @param maxlength Maximum error buffer length.
|
||||||
* @return New IExtension on success, NULL on failure.
|
* @return New IExtension on success, NULL on failure.
|
||||||
|
@ -37,6 +37,11 @@
|
|||||||
#define SMINTERFACE_MEMORYUTILS_NAME "IMemoryUtils"
|
#define SMINTERFACE_MEMORYUTILS_NAME "IMemoryUtils"
|
||||||
#define SMINTERFACE_MEMORYUTILS_VERSION 1
|
#define SMINTERFACE_MEMORYUTILS_VERSION 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file IMemoryUtils.h
|
||||||
|
* @brief Interface for finding patterns in memory.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace SourceMod
|
namespace SourceMod
|
||||||
{
|
{
|
||||||
class IMemoryUtils : public SMInterface
|
class IMemoryUtils : public SMInterface
|
||||||
|
@ -265,7 +265,7 @@ namespace SourceMod
|
|||||||
* @brief Returns whether the display is capable of rendering an item
|
* @brief Returns whether the display is capable of rendering an item
|
||||||
* with the given flags.
|
* with the given flags.
|
||||||
*
|
*
|
||||||
* @param flags ITEMDRAW flags.
|
* @param drawFlags ITEMDRAW flags.
|
||||||
* @return True if renderable, false otherwise.
|
* @return True if renderable, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool CanDrawItem(unsigned int drawFlags) =0;
|
virtual bool CanDrawItem(unsigned int drawFlags) =0;
|
||||||
@ -289,7 +289,7 @@ namespace SourceMod
|
|||||||
* @brief Sets the selectable key map. Returns false if the function
|
* @brief Sets the selectable key map. Returns false if the function
|
||||||
* is not supported.
|
* is not supported.
|
||||||
*
|
*
|
||||||
* @param keys A bit string where each bit N-1 specifies
|
* @param keymap A bit string where each bit N-1 specifies
|
||||||
* that key N is selectable (key 0 is bit 9).
|
* that key N is selectable (key 0 is bit 9).
|
||||||
* If the selectable key map is 0, it will be
|
* If the selectable key map is 0, it will be
|
||||||
* automatically set to allow 0.
|
* automatically set to allow 0.
|
||||||
@ -662,6 +662,7 @@ namespace SourceMod
|
|||||||
* @brief A display/selection cycle has ended.
|
* @brief A display/selection cycle has ended.
|
||||||
*
|
*
|
||||||
* @param menu Menu pointer.
|
* @param menu Menu pointer.
|
||||||
|
* @param reason MenuEndReason reason.
|
||||||
*/
|
*/
|
||||||
virtual void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
virtual void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
||||||
{
|
{
|
||||||
@ -740,6 +741,7 @@ namespace SourceMod
|
|||||||
* always be called.
|
* always be called.
|
||||||
*
|
*
|
||||||
* @param menu Menu pointer.
|
* @param menu Menu pointer.
|
||||||
|
* @param reason VoteCancelReason reason.
|
||||||
*/
|
*/
|
||||||
virtual void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason)
|
virtual void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason)
|
||||||
{
|
{
|
||||||
@ -823,6 +825,7 @@ namespace SourceMod
|
|||||||
*
|
*
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @param states Menu states.
|
* @param states Menu states.
|
||||||
|
* @param order Order to search for items.
|
||||||
* @return IMenuPanel pointer, or NULL if no items could be
|
* @return IMenuPanel pointer, or NULL if no items could be
|
||||||
* found in the IBaseMenu pointer, or NULL if any
|
* found in the IBaseMenu pointer, or NULL if any
|
||||||
* other error occurred. Any valid pointer must
|
* other error occurred. Any valid pointer must
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
|
|
||||||
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
||||||
#define SMINTERFACE_PLAYERMANAGER_VERSION 6
|
#define SMINTERFACE_PLAYERMANAGER_VERSION 7
|
||||||
|
|
||||||
struct edict_t;
|
struct edict_t;
|
||||||
class IPlayerInfo;
|
class IPlayerInfo;
|
||||||
@ -147,6 +147,42 @@ namespace SourceMod
|
|||||||
* @return IPlayerInfo pointer, or NULL if none.
|
* @return IPlayerInfo pointer, or NULL if none.
|
||||||
*/
|
*/
|
||||||
virtual IPlayerInfo *GetPlayerInfo() =0;
|
virtual IPlayerInfo *GetPlayerInfo() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Runs through Core's admin authorization checks. If the
|
||||||
|
* client is already an admin, no checks are performed.
|
||||||
|
*
|
||||||
|
* Note that this function operates solely against the in-memory admin
|
||||||
|
* cache. It will check steamids, IPs, names, and verify a password
|
||||||
|
* if one exists. To implement other authentication schemes, simply
|
||||||
|
* don't call this function and use IGamePlayer::SetAdminId() instead.
|
||||||
|
*
|
||||||
|
* @return True if access changed, false otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool RunAdminCacheChecks() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Notifies all listeners that the client has completed
|
||||||
|
* all of your post-connection (in-game, auth, admin) checks.
|
||||||
|
*
|
||||||
|
* If you returned "false" from OnClientPreAdminCheck(), you must
|
||||||
|
* ALWAYS manually invoke this function, even if RunAdminCacheChecks()
|
||||||
|
* failed or you did not assign an AdminId. Failure to call this
|
||||||
|
* function could result in plugins (such as reservedslots) not
|
||||||
|
* working properly.
|
||||||
|
*
|
||||||
|
* If you are implementing asynchronous fetches, and the client
|
||||||
|
* disconnects during your fetching process, you should make sure to
|
||||||
|
* recognize that case and not call this function. That is, do not
|
||||||
|
* call this function on mismatched PreCheck calls, or on disconnected
|
||||||
|
* clients. A good way to check this is to pass userids around, which
|
||||||
|
* are unique per client connection.
|
||||||
|
*
|
||||||
|
* Calling this has no effect if it has already been called on the
|
||||||
|
* given client (thus it is safe for multiple asynchronous plugins to
|
||||||
|
* call it at various times).
|
||||||
|
*/
|
||||||
|
virtual void NotifyPostAdminChecks() =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,6 +266,41 @@ namespace SourceMod
|
|||||||
virtual void OnServerActivated(int max_clients)
|
virtual void OnServerActivated(int max_clients)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called once a client is authorized and fully in-game, but
|
||||||
|
* before admin checks are done. This can be used to override the
|
||||||
|
* default admin checks for a client.
|
||||||
|
*
|
||||||
|
* By default, this function allows the authentication process to
|
||||||
|
* continue as normal. If you need to delay the cache searching
|
||||||
|
* process in order to get asynchronous data, then return false here.
|
||||||
|
*
|
||||||
|
* If you return false, you must call IPlayerManager::NotifyPostAdminCheck
|
||||||
|
* for the same client, or else the OnClientPostAdminCheck callback will
|
||||||
|
* never be called.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return True to continue normally, false to override
|
||||||
|
* the authentication process.
|
||||||
|
*/
|
||||||
|
virtual bool OnClientPreAdminCheck(int client)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called once a client is authorized and fully in-game, and
|
||||||
|
* after all post-connection authorizations have been passed. If the
|
||||||
|
* client does not have an AdminId by this stage, it means that no
|
||||||
|
* admin entry was in the cache that matched, and the user could not
|
||||||
|
* be authenticated as an admin.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
*/
|
||||||
|
virtual void OnClientPostAdminCheck(int client)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
|
#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
|
||||||
|
@ -200,6 +200,29 @@ namespace SourceMod
|
|||||||
* @param name Library name.
|
* @param name Library name.
|
||||||
*/
|
*/
|
||||||
virtual void RegisterLibrary(IExtension *myself, const char *name) =0;
|
virtual void RegisterLibrary(IExtension *myself, const char *name) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adds a list of natives to the global native pool, to be
|
||||||
|
* bound on plugin load.
|
||||||
|
*
|
||||||
|
* Unlike AddNatives(), this function implements natives that are
|
||||||
|
* ALWAYS bound, regardless of whether a previous function is bound.
|
||||||
|
* That means extensions can override Core natives.
|
||||||
|
*
|
||||||
|
* A Core version of each native must exist. If one does not, then
|
||||||
|
* Core will simply ignore that entry.
|
||||||
|
*
|
||||||
|
* Override natives represent a weak coupling. If the extension is
|
||||||
|
* unloaded, the native will be re-bound to the Core version.
|
||||||
|
*
|
||||||
|
* @param myself Identity token of parent object.
|
||||||
|
* @param natives Array of natives to add. The last entry in
|
||||||
|
* the array must be filled with NULLs to
|
||||||
|
* terminate the array. The array must be static
|
||||||
|
* as Core will cache the pointer for the
|
||||||
|
* lifetime of the extension.
|
||||||
|
*/
|
||||||
|
virtual void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
|
#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
|
||||||
#define SMINTERFACE_SOURCEMOD_VERSION 3
|
#define SMINTERFACE_SOURCEMOD_VERSION 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Forward declaration of the KeyValues class.
|
* @brief Forward declaration of the KeyValues class.
|
||||||
@ -199,6 +199,23 @@ namespace SourceMod
|
|||||||
* @return Adjusted server time.
|
* @return Adjusted server time.
|
||||||
*/
|
*/
|
||||||
virtual time_t GetAdjustedTime() =0;
|
virtual time_t GetAdjustedTime() =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the global client SourceMod will use for assisted
|
||||||
|
* translations (that is, %t).
|
||||||
|
*
|
||||||
|
* @param index Client index.
|
||||||
|
* @return Old global client value.
|
||||||
|
*/
|
||||||
|
virtual unsigned int SetGlobalTarget(unsigned int index) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the global client SourceMod is currently using
|
||||||
|
* for assisted translations (that is, %t).
|
||||||
|
*
|
||||||
|
* @return Global client value.
|
||||||
|
*/
|
||||||
|
virtual unsigned int GetGlobalTarget() const =0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,6 @@ namespace SourceMod
|
|||||||
* @param key Key string.
|
* @param key Key string.
|
||||||
* @param value Value string. If no quotes were specified, this will be NULL,
|
* @param value Value string. If no quotes were specified, this will be NULL,
|
||||||
* and key will contain the entire string.
|
* and key will contain the entire string.
|
||||||
* @param Number of line in file.
|
|
||||||
* @return SMCResult directive.
|
* @return SMCResult directive.
|
||||||
*/
|
*/
|
||||||
virtual SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value)
|
virtual SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value)
|
||||||
@ -291,7 +290,7 @@ namespace SourceMod
|
|||||||
/**
|
/**
|
||||||
* @brief Called when leaving the current section.
|
* @brief Called when leaving the current section.
|
||||||
*
|
*
|
||||||
* @param Parsing states.
|
* @param states Parsing states.
|
||||||
* @return SMCResult directive.
|
* @return SMCResult directive.
|
||||||
*/
|
*/
|
||||||
virtual SMCResult ReadSMC_LeavingSection(const SMCStates *states)
|
virtual SMCResult ReadSMC_LeavingSection(const SMCStates *states)
|
||||||
|
@ -144,7 +144,7 @@ namespace SourceMod
|
|||||||
* @param flags Flags to use for sending the message.
|
* @param flags Flags to use for sending the message.
|
||||||
* @return bf_write structure to write message with, or NULL on failure.
|
* @return bf_write structure to write message with, or NULL on failure.
|
||||||
*/
|
*/
|
||||||
virtual bf_write *StartMessage(int msg_id, cell_t players[], unsigned int playersNum, int flags) =0;
|
virtual bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags) =0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wrapper around UserMessageEnd for use with StartMessage().
|
* @brief Wrapper around UserMessageEnd for use with StartMessage().
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define SMINTERFACE_TOPMENUS_NAME "ITopMenus"
|
#define SMINTERFACE_TOPMENUS_NAME "ITopMenus"
|
||||||
#define SMINTERFACE_TOPMENUS_VERSION 3
|
#define SMINTERFACE_TOPMENUS_VERSION 4
|
||||||
|
|
||||||
namespace SourceMod
|
namespace SourceMod
|
||||||
{
|
{
|
||||||
@ -268,6 +268,14 @@ namespace SourceMod
|
|||||||
* @return Object's info string, or NULL if none.
|
* @return Object's info string, or NULL if none.
|
||||||
*/
|
*/
|
||||||
virtual const char *GetObjectInfoString(unsigned int object_id) =0;
|
virtual const char *GetObjectInfoString(unsigned int object_id) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns an object's name string.
|
||||||
|
*
|
||||||
|
* @param object_id Object ID.
|
||||||
|
* @return Object's name string, or NULL if none.
|
||||||
|
*/
|
||||||
|
virtual const char *GetObjectName(unsigned int object_id) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,5 +74,6 @@
|
|||||||
//#define SMEXT_ENABLE_PLUGINSYS
|
//#define SMEXT_ENABLE_PLUGINSYS
|
||||||
//#define SMEXT_ENABLE_ADMINSYS
|
//#define SMEXT_ENABLE_ADMINSYS
|
||||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||||
|
#define SMEXT_ENABLE_USERMSGS
|
||||||
|
|
||||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||||
|
@ -91,6 +91,9 @@ IAdminSystem *adminsys = NULL;
|
|||||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||||
ITextParsers *textparsers = NULL;
|
ITextParsers *textparsers = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
IUserMessages *usermsgs = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Exports the main interface */
|
/** Exports the main interface */
|
||||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||||
@ -173,6 +176,9 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error,
|
|||||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||||
SM_GET_IFACE(TEXTPARSERS, textparsers);
|
SM_GET_IFACE(TEXTPARSERS, textparsers);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
SM_GET_IFACE(USERMSGS, usermsgs);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SDK_OnLoad(error, maxlength, late))
|
if (SDK_OnLoad(error, maxlength, late))
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||||
#include <ITextParsers.h>
|
#include <ITextParsers.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
#include <IUserMessages.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined SMEXT_CONF_METAMOD
|
#if defined SMEXT_CONF_METAMOD
|
||||||
#include <ISmmPlugin.h>
|
#include <ISmmPlugin.h>
|
||||||
@ -277,6 +280,9 @@ extern IMenuManager *menus;
|
|||||||
#if defined SMEXT_ENABLE_ADMINSYS
|
#if defined SMEXT_ENABLE_ADMINSYS
|
||||||
extern IAdminSystem *adminsys;
|
extern IAdminSystem *adminsys;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined SMEXT_ENABLE_USERMSGS
|
||||||
|
extern IUserMessages *usermsgs;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined SMEXT_CONF_METAMOD
|
#if defined SMEXT_CONF_METAMOD
|
||||||
PLUGIN_GLOBALVARS();
|
PLUGIN_GLOBALVARS();
|
||||||
|
Loading…
Reference in New Issue
Block a user