From 03e70ebe16a67bd4ce1e3586b5a87ca57ce260a6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 17 Feb 2007 17:25:50 +0000 Subject: [PATCH] reverted project file for now moved printing natives --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40524 --- core/msvc8/sourcemod_mm.vcproj | 8 ------ core/smn_console.cpp | 52 +++++++++++++++++++++++++++++++++- core/smn_player.cpp | 48 ------------------------------- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/core/msvc8/sourcemod_mm.vcproj b/core/msvc8/sourcemod_mm.vcproj index 954a50e2..477f1b5b 100644 --- a/core/msvc8/sourcemod_mm.vcproj +++ b/core/msvc8/sourcemod_mm.vcproj @@ -199,10 +199,6 @@ RelativePath="..\CDbgReporter.cpp" > - - @@ -661,10 +657,6 @@ RelativePath="..\smn_datapacks.cpp" > - - diff --git a/core/smn_console.cpp b/core/smn_console.cpp index aa27d180..ed352fe1 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -17,6 +17,8 @@ #include "CConVarManager.h" #include "CConCmdManager.h" #include "PluginSys.h" +#include "sm_stringutil.h" +#include "CPlayerManager.h" static cell_t sm_CreateConVar(IPluginContext *pContext, const cell_t *params) { @@ -414,7 +416,53 @@ static cell_t sm_GetCmdArgString(IPluginContext *pContext, const cell_t *params) return 1; } -REGISTER_NATIVES(convarNatives) +static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params) +{ + char buffer[1024]; + char *fmt; + int arg = 2; + + pCtx->LocalToString(params[1], &fmt); + size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg); + + buffer[res++] = '\n'; + buffer[res] = '\0'; + + META_CONPRINT(buffer); + + return 1; +} + +static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params) +{ + int index = params[1]; + if ((index < 1) || (index > g_Players.GetMaxClients())) + { + return pCtx->ThrowNativeError("Invalid client index %d", index); + } + + CPlayer *pPlayer = g_Players.GetPlayerByIndex(index); + if (!pPlayer->IsInGame()) + { + return pCtx->ThrowNativeError("Client %d is not in game", index); + } + + char buffer[1024]; + char *fmt; + int arg = 3; + + pCtx->LocalToString(params[2], &fmt); + size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg); + + buffer[res++] = '\n'; + buffer[res] = '\0'; + + engine->ClientPrintf(pPlayer->GetEdict(), buffer); + + return 1; +} + +REGISTER_NATIVES(consoleNatives) { {"CreateConVar", sm_CreateConVar}, {"FindConVar", sm_FindConVar}, @@ -439,5 +487,7 @@ REGISTER_NATIVES(convarNatives) {"GetCmdArgString", sm_GetCmdArgString}, {"GetCmdArgs", sm_GetCmdArgs}, {"GetCmdArg", sm_GetCmdArg}, + {"PrintToServer", sm_PrintToServer}, + {"PrintToConsole", sm_PrintToConsole}, {NULL, NULL} }; diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 006cb0cf..c480bee4 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -159,23 +159,6 @@ static cell_t sm_IsPlayerFakeClient(IPluginContext *pCtx, const cell_t *params) return (pPlayer->IsFakeClient()) ? 1 : 0; } -static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params) -{ - char buffer[1024]; - char *fmt; - int arg = 2; - - pCtx->LocalToString(params[1], &fmt); - size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg); - - buffer[res++] = '\n'; - buffer[res] = '\0'; - - META_CONPRINT(buffer); - - return 1; -} - static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params) { int client = params[1]; @@ -202,35 +185,6 @@ static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params) return 1; } -static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params) -{ - int index = params[1]; - if ((index < 1) || (index > g_Players.GetMaxClients())) - { - return pCtx->ThrowNativeError("Invalid client index %d", index); - } - - CPlayer *pPlayer = g_Players.GetPlayerByIndex(index); - if (!pPlayer->IsInGame()) - { - return pCtx->ThrowNativeError("Client %d is not in game", index); - } - - char buffer[1024]; - char *fmt; - int arg = 3; - - pCtx->LocalToString(params[2], &fmt); - size_t res = atcprintf(buffer, sizeof(buffer)-2, fmt, pCtx, params, &arg); - - buffer[res++] = '\n'; - buffer[res] = '\0'; - - engine->ClientPrintf(pPlayer->GetEdict(), buffer); - - return 1; -} - static cell_t SetUserAdmin(IPluginContext *pContext, const cell_t *params) { int client = params[1]; @@ -402,8 +356,6 @@ REGISTER_NATIVES(playernatives) {"IsPlayerInGame", sm_IsPlayerIngame}, {"IsClientAuthorized", sm_IsPlayerAuthorized}, {"IsFakeClient", sm_IsPlayerFakeClient}, - {"PrintToServer", sm_PrintToServer}, - {"PrintToConsole", sm_PrintToConsole}, {"GetClientInfo", sm_GetClientInfo}, {"SetUserAdmin", SetUserAdmin}, {"GetUserAdmin", GetUserAdmin},