Пример #1
0
bool CForwardManager::OnSpectatorExecuteStringCommand(const char *s)
{
	if (!hltvserver)
		RETURN_META_VALUE(MRES_IGNORED, true);

	IClient *client = META_IFACEPTR(IClient);
	if (!s || !s[0])
		RETURN_META_VALUE(MRES_IGNORED, true);

	CCommand args;
	if (!args.Tokenize(s))
		RETURN_META_VALUE(MRES_IGNORED, true);

	// See if the client wants to chat.
	if (!Q_stricmp(args[0], "say") && args.ArgC() > 1)
	{
		// TODO find correct hltvserver this client is connected to!

		// Save the client index and message.
		hltvserver->SetLastChatClient(client);
		hltvserver->SetLastChatMessage(args[1]);
	}

	RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #2
0
EGCResults SteamWorksGCHooks::SendMessage(uint32 unMsgType, const void *pubData, uint32 cubData)
{
	if (this->pGCSendMsg->GetFunctionCount() == 0)
	{
		RETURN_META_VALUE(MRES_IGNORED, k_EGCResultOK);
	}

	cell_t Result = k_EGCResultOK;
	this->pGCSendMsg->PushCell(unMsgType);
	this->pGCSendMsg->PushStringEx(reinterpret_cast<char *>(const_cast<void *>(pubData)), cubData, SM_PARAM_STRING_BINARY | SM_PARAM_STRING_COPY, 0);
	this->pGCSendMsg->PushCell(cubData);
	this->pGCSendMsg->Execute(&Result);

	if (Result != k_EGCResultOK)
	{
		if (Result == -1)
		{
			Result = k_EGCResultOK;
		}

		RETURN_META_VALUE(MRES_SUPERCEDE, static_cast<EGCResults>(Result));
	}

	RETURN_META_VALUE(MRES_IGNORED, k_EGCResultOK);
}
Пример #3
0
// Force steam authentication
// Thanks GoD-Tony :)
int CForwardManager::OnGetChallengeType(const netadr_t &address)
{
	if (!tv_force_steamauth.GetBool())
		RETURN_META_VALUE(MRES_IGNORED, k_EAuthProtocolHashedCDKey);

	RETURN_META_VALUE(MRES_SUPERCEDE, k_EAuthProtocolSteam);
}
Пример #4
0
bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
{
	m_bAnyLevelInited = true;

	UpdateValveGlobals();

	const char *name;
	char key[32];
	int count, n = 1;

	if (!(name=g_pGameConf->GetKeyValue("SlapSoundCount")))
	{
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	count = atoi(name);

	while (n <= count)
	{
		snprintf(key, sizeof(key), "SlapSound%d", n);
		if ((name=g_pGameConf->GetKeyValue(key)))
		{
			engsound->PrecacheSound(name, true);
		}
		n++;
	}

	RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #5
0
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type)
{
	bool is_intercept_empty = m_msgIntercepts[msg_type].empty();
	bool is_hook_empty = m_msgHooks[msg_type].empty();

	if ((is_intercept_empty && is_hook_empty)
		|| (m_InExec && (m_CurFlags & USERMSG_BLOCKHOOKS)))
	{
		m_InHook = false;
		RETURN_META_VALUE(MRES_IGNORED, NULL);
	}

	m_CurId = msg_type;
	m_CurRecFilter = filter;
	m_InHook = true;
	m_BlockEndPost = false;

	if (!is_intercept_empty)
	{
		m_InterceptBuffer.Reset();
		RETURN_META_VALUE(MRES_SUPERCEDE, &m_InterceptBuffer);
	}

	RETURN_META_VALUE(MRES_IGNORED, NULL);
}
Пример #6
0
bool SteamWorksGCHooks::IsMessageAvailable(uint32_t *pcubMsgSize)
{
	if (this->pGCMsgAvail->GetFunctionCount() == 0)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}

	bool res = META_RESULT_ORIG_RET(bool);
	if (!res)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}

	uint32_t shill;
	if (!pcubMsgSize)
	{
		shill = 0;
		SH_CALL(GetSteamGCPointer(), &ISteamGameCoordinator::IsMessageAvailable)(&shill);
		pcubMsgSize = &shill;
	}

	this->pGCMsgAvail->PushCell(*pcubMsgSize);
	this->pGCMsgAvail->Execute(NULL);
	RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #7
0
bool HolidayManager::Hook_IsHolidayActive(int holiday)
{
	void *pGameRules = META_IFACEPTR(void *);

	bool actualres = SH_MCALL(pGameRules, IsHolidayActive)(holiday);
	if (!m_isHolidayForward)
	{
		g_pSM->LogMessage(myself, "Invalid Forward");
		RETURN_META_VALUE(MRES_IGNORED, true);
	}

	cell_t result = 0;
	cell_t newres = actualres ? 1 : 0;

	m_isHolidayForward->PushCell(holiday);
	m_isHolidayForward->PushCellByRef(&newres);
	m_isHolidayForward->Execute(&result);

	if (result > Pl_Continue)
	{
		RETURN_META_VALUE(MRES_SUPERCEDE, (newres == 0) ? false : true);
	}

	RETURN_META_VALUE(MRES_IGNORED, true);
}
qboolean OnClientConnectPost( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
{
    if( Initialized && sv_allowdownload->value > 0 )
    {
        if( cvar_enable_debug->value > 0 )
        {
            ModuleDebug.append( UTIL_VarArgs( "\n\"%s\" (index = %d, address = %s) is connecting.\n", pszName, ENTINDEX( pEntity ), pszAddress ) );
        }

        if( rm_enable_downloadfix.value <= 0 )
        {
            NotifyClientDisconnectHook->Restore();
            RETURN_META_VALUE( MRES_IGNORED, TRUE );
        }
        else
        {
            NotifyClientDisconnectHook->Patch();
        }

        char	ip[ 16 ];
        uint32	player				= ENTINDEX( pEntity );
        time_t	timeSystem			= getSysTime();
        time_t*	nextReconnectTime	= &PlayerNextReconnectTime[ player ];
        String*	currentPlayerIp		= &PlayerCurrentIp[ player ];

        // Retrieve server IP one time from there because
        // we need to let server.cfg be executed in case
        // a specific ip is provided and because I have not
        // found forward to use to put this call at this time.
        retrieveServerIp( &ServerInternetIp );

        // Retrieve the current client's IP without the port.
        retrieveClientIp( ip, pszAddress );

        // Sanity IP address check to make sure the index
        // is our expected player. If not, we consider it
        // as a new player and we reset variables to the default.
        if( currentPlayerIp->compare( ip ) )
        {
            *nextReconnectTime = 0;

            currentPlayerIp->clear();
            currentPlayerIp->assign( ip );
        }

        // We are allowed to reconnect the player.
        // We put a cool down of 3 seconds minimum to avoid possible
        // infinite loop since depending where it will download resources,
        // it can connect/disconnect several times.
        if( *nextReconnectTime < timeSystem )
        {
            *nextReconnectTime = timeSystem + 3;
            CLIENT_COMMAND( pEntity, "Connect %s %d\n", isLocalIp( ip ) ? ServerLocalIp.c_str() : ServerInternetIp.c_str(), RANDOM_LONG( 1, 9999 ) );
        }
    }

    RETURN_META_VALUE( MRES_IGNORED, TRUE );
}
Пример #9
0
/* IGameEventManager2::FireEvent hook */
bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{
	EventHook *pHook;
	IChangeableForward *pForward;
	const char *name;
	cell_t res = Pl_Continue;

	/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
	if (!pEvent)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}

	name = pEvent->GetName();
	
	if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))
	{
		/* Push the event onto the event stack.  The reference count is increased to make sure 
		 * the structure is not garbage collected in between now and the post hook.
		 */
		pHook->refCount++;
		m_EventStack.push(pHook);

		pForward = pHook->pPreHook;

		if (pForward)
		{
			EventInfo info(pEvent, NULL);
			HandleSecurity sec(NULL, g_pCoreIdent);
			Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);

			pForward->PushCell(hndl);
			pForward->PushString(name);
			pForward->PushCell(bDontBroadcast);
			pForward->Execute(&res, NULL);

			g_HandleSys.FreeHandle(hndl, &sec);
		}

		if (pHook->postCopy)
		{
			m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
		}

		if (res)
		{
			gameevents->FreeEvent(pEvent);
			RETURN_META_VALUE(MRES_SUPERCEDE, false);
		}
	}
	else
	{
		m_EventStack.push(NULL);
	}

	RETURN_META_VALUE(MRES_IGNORED, true);
}
bool HLTVServerWrapper::OnHLTVBotExecuteStringCommand_Post(const char *s)
{
	if (!host_client || !g_HostClientOverridden)
		RETURN_META_VALUE(MRES_IGNORED, 0);

	*(void **)host_client = old_host_client;
	g_HostClientOverridden = false;
	RETURN_META_VALUE(MRES_IGNORED, 0);
}
bool	ManiSMMHooks::Weapon_CanUse(CBaseCombatWeapon *pWeapon)
{
	if (!gpManiWeaponMgr->CanPickUpWeapon(META_IFACEPTR(CBasePlayer), pWeapon))
	{
		RETURN_META_VALUE(MRES_SUPERCEDE, false);
	}
	
	RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #12
0
bool TestKeyValue( const char *szKeyName, const char *szValue )
{
    if(!strcmp(szKeyName, "sophooktest"))
    {
        //Msg("You've been hooked already!\n");
        g_hookTest = 1;
        RETURN_META_VALUE(MRES_SUPERCEDE, 0);
    }
    RETURN_META_VALUE(MRES_HANDLED, 0);
}
Пример #13
0
/* IGameEventManager2::FireEvent post hook */
bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
{
	IGameEvent *pEventCopy = NULL;
	EventHook *pHook;
	IChangeableForward *pForward;
	const char *name;
	Handle_t hndl = 0;

	/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
	if (!pEvent)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}

	name = m_EventNames.front();

	if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))
	{
		pForward = pHook->pPostHook;

		if (pForward)
		{
			EventInfo info = { pHook->pEventCopy, NULL };

			if (pHook->postCopy)
			{
				hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);

				pForward->PushCell(hndl);
			} else {
				pForward->PushCell(BAD_HANDLE);
			}

			pForward->PushString(name);
			pForward->PushCell(bDontBroadcast);
			pForward->Execute(NULL);

			if (pHook->postCopy)
			{
				/* Free handle */
				HandleSecurity sec(NULL, g_pCoreIdent);
				g_HandleSys.FreeHandle(hndl, &sec);

				/* Free event structure */
				gameevents->FreeEvent(pEventCopy);
				pHook->pEventCopy = NULL;
			}
		}
	}

	m_EventNames.pop();

	RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #14
0
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type)
{
	if (!m_InHook)
	{
		RETURN_META_VALUE(MRES_IGNORED, NULL);
	}

	m_OrigBuffer = META_RESULT_ORIG_RET(bf_write *);

	RETURN_META_VALUE(MRES_IGNORED, NULL);
}
Пример #15
0
// Reset the pointers after the command was executed.
bool CForwardManager::OnSpectatorExecuteStringCommand_Post(const char *s)
{
	if (!hltvserver)
		RETURN_META_VALUE(MRES_IGNORED, true);

	// TODO find correct hltvserver this client is connected to!

	hltvserver->SetLastChatClient(nullptr);
	hltvserver->SetLastChatMessage(nullptr);

	RETURN_META_VALUE(MRES_IGNORED, true);
}
bf_write *ManiSMMHooks::UserMessageBegin(IRecipientFilter *filter, int msg_type)
#endif
{

	if ( mani_hint_sounds.GetBool() ) 
	{
#if defined ( GAME_CSGO )
		RETURN_META(MRES_IGNORED);
#else	
		RETURN_META_VALUE(MRES_IGNORED,NULL);
#endif		
	}

	player_t player;
	if ( msg_type == hintMsg_message_index ) 
	{
#if defined ( GAME_CSGO )
		for ( int i = 0; i < filter.GetRecipientCount(); i++ ) 
		{
			player.index = filter.GetRecipientIndex(i);
#else	
		for ( int i = 0; i < filter->GetRecipientCount(); i++ ) 
		{
			player.index = filter->GetRecipientIndex(i);
#endif			
			if ( !FindPlayerByIndex(&player) ) continue;

			//Stop Sound!!!
#if defined ( GAME_CSGO )
			esounds->StopSound( player.index, 6, "UI/hint.wav", 0 );
#else
			esounds->StopSound( player.index, 6, "UI/hint.wav");
#endif
		}
	}
#if defined ( GAME_CSGO )
	RETURN_META(MRES_IGNORED);
#else	
	RETURN_META_VALUE(MRES_IGNORED,NULL);
#endif	
}
#endif // GAME_ORANGE

#ifdef GAME_ORANGE
void RespawnEntities_handler(const CCommand &command)
#else
void RespawnEntities_handler()
#endif
{
	//Override exploit
	RETURN_META(MRES_SUPERCEDE);
} 
Пример #17
0
/* IGameEventManager2::FireEvent hook */
bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{
	EventHook *pHook;
	IChangeableForward *pForward;
	const char *name;
	cell_t res = Pl_Continue;

	/* The engine accepts NULL without crashing, so to prevent a crash in SM we ignore these */
	if (!pEvent)
	{
		RETURN_META_VALUE(MRES_IGNORED, false);
	}
	
	/* Get the event name, we're going to need this for passing to post hooks */
	name = pEvent->GetName();

	m_EventNames.push(name);

	if (sm_trie_retrieve(m_EventHooks, name, reinterpret_cast<void **>(&pHook)))
	{
		pForward = pHook->pPreHook;

		if (pForward)
		{
			EventInfo info = { pEvent, NULL };

			Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
			pForward->PushCell(hndl);
			pForward->PushString(name);
			pForward->PushCell(bDontBroadcast);
			pForward->Execute(&res, NULL);

			HandleSecurity sec(NULL, g_pCoreIdent);
			g_HandleSys.FreeHandle(hndl, &sec);
		}

		if (pHook->postCopy)
		{
			pHook->pEventCopy = gameevents->DuplicateEvent(pEvent);
		}

		if (res)
		{
			gameevents->FreeEvent(pEvent);
			RETURN_META_VALUE(MRES_SUPERCEDE, false);
		}
	}

	RETURN_META_VALUE(MRES_IGNORED, true);
}
bool HLTVServerWrapperManager::OnHLTVBotNetChanSendNetMsg(INetMessage &msg, bool bForceReliable, bool bVoice)
{
	// No need to worry about the right selected hltvserver, because there can only be one.
	IClient *pClient = iserver->GetClient(hltvserver->GetHLTVServer()->GetHLTVSlot());
	if (!pClient)
		RETURN_META_VALUE(MRES_SUPERCEDE, false);

	// Let the message flow through the intended path like CGameClient::SendNetMsg wants to.
	bool bRetSent = pClient->SendNetMsg(msg, bForceReliable);

	// It's important to supercede, because there is no original function to call.
	// (the "vtable" was empty before hooking it)
	// See FakeNetChan variable at the top.
	RETURN_META_VALUE(MRES_SUPERCEDE, bRetSent);
}
bool	ManiSMMHooks::SetClientListening(int iReceiver, int iSender, bool bListen)
{
	bool new_listen = false;

	if ( iSender == iReceiver )
		RETURN_META_VALUE ( MRES_IGNORED, bListen );

	if (ProcessMuteTalk(iReceiver, iSender, &new_listen))
		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, new_listen));

	if (ProcessDeadAllTalk(iReceiver, iSender, &new_listen))
		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, new_listen));

	RETURN_META_VALUE(MRES_IGNORED, bListen );
}
Пример #20
0
void *PvAllocEntPrivateData(edict_t *pEdict, long cb) {
#else
void *PvAllocEntPrivateData(edict_t *pEdict, int32 cb) {
#endif
	ENGINE_TRACE(pfnPvAllocEntPrivateData, P_PRE, (""));
	RETURN_META_VALUE(MRES_IGNORED, NULL);
}
Пример #21
0
edict_s* OnCreateNamedEntity(int classname)
{
	if (NoKifesMode)
	{
		if (!strcmp(STRING(classname), "weapon_knife"))
		{
			RETURN_META_VALUE(MRES_SUPERCEDE, nullptr);
		}
	}
	else
	{
		g_pengfuncsTable->pfnCreateNamedEntity = nullptr;
	}

	RETURN_META_VALUE(MRES_IGNORED, 0);
}
Пример #22
0
float [!output PLUGIN_CLASS]::HookedProcessUsercmds(edict_t* player, bf_read* buf, int num_cmds, int total_cmds, 
                                                    int dropped_packets, bool ignore, bool paused)
{
  // TODO: Implement Method

  RETURN_META_VALUE(MRES_IGNORED, 0.0f);
}
Пример #23
0
bool [!output PLUGIN_CLASS]::HookedLevelInit(const char* map_name, char const* map_entities, char const* old_level,
                                             char const* landmark_name, bool load_game, bool bkgnd)
{
  // TODO: Implement Method

  RETURN_META_VALUE(MRES_IGNORED, true);
}
Пример #24
0
// Reset player data here..
qboolean ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ])
{
    // Client's connecting.  Freshen up his save data, and mark him as being connected.
    GET_PLAYER_E(pEntity)->Connect();

    RETURN_META_VALUE(MRES_HANDLED,0);
}
Пример #25
0
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ]  ) {
	if ( META_RESULT_ORIG_RET(BOOL) ) {
		PlayerConnect(pEntity, pszName, pszAddress);
	}

	RETURN_META_VALUE(MRES_IGNORED, TRUE);
}
Пример #26
0
const char *TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2)
{
	PREPARE_VECTOR(v1);
	PREPARE_VECTOR(v2);
	FM_ENG_HANDLE(FM_TraceTexture, (Engine[FM_TraceTexture].at(i), (cell)ENTINDEX(pTextureEntity), p_v1, p_v2));
	RETURN_META_VALUE(mswi(lastFmRes), mlStringResult);
}
Пример #27
0
unsigned int GetPlayerWONId(edict_t *e) {
	// more output in Post
	edict_t *ed = e;
	ENGINE_TRACE(pfnGetPlayerWONId, P_PRE, ("netname=%s",
				ed ? STRING(ed->v.netname) : "nil"));
	RETURN_META_VALUE(MRES_IGNORED, 0U);
}
Пример #28
0
const char *NameForFunction( unsigned long function ) {
#else
const char *NameForFunction( uint32 function ) {
#endif
	ENGINE_TRACE(pfnNameForFunction, P_PRE, (""));
	RETURN_META_VALUE(MRES_IGNORED, NULL);
}
Пример #29
0
unsigned long FunctionFromName( const char *pName ) {
#else
uint32 FunctionFromName( const char *pName ) {
#endif
	ENGINE_TRACE(pfnFunctionFromName, P_PRE, ("name=%s", pName));
	RETURN_META_VALUE(MRES_IGNORED, 0UL);
}
Пример #30
0
int EntOffsetOfPEntity(const edict_t *pEdict) {
	const edict_t *ed=pEdict;
	ENGINE_TRACE(pfnEntOffsetOfPEntity, P_PRE, ("classname=%s netname=%s",
				ed ? STRING(ed->v.classname) : "nil",
				ed ? STRING(ed->v.netname) : "nil"));
	RETURN_META_VALUE(MRES_IGNORED, 0);
}