本文整理汇总了C++中ConCommandBase::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ ConCommandBase::GetName方法的具体用法?C++ ConCommandBase::GetName怎么用?C++ ConCommandBase::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConCommandBase
的用法示例。
在下文中一共展示了ConCommandBase::GetName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
IEntityFactoryDictionary *EntityFactoryDictionary()
{
if(g_entityFactoryDictionary)
return g_entityFactoryDictionary;
if ( g_nServerToolsVersion >= 2 )
{
g_entityFactoryDictionary = servertools->GetEntityFactoryDictionary();
return g_entityFactoryDictionary;
}
#ifdef WIN32
ConCommandBase *pPtr = pAdminOP.GetCommands();
while (pPtr)
{
if (pPtr->IsCommand() && strcmp(pPtr->GetName(), "dumpentityfactories") == 0)
{
ConCommand *ptr = (ConCommand*)pPtr;
//CEntityFactoryDictionary *dict = ( CEntityFactoryDictionary * )*(int *)( ((char*)VFuncs::GetCommandCallback(ptr))+0x14 );
CEntityFactoryDictionary *dict = VFuncs::GetEntityDictionary(ptr);
if ( dict )
{
g_entityFactoryDictionary = dict;
return dict;
}
}
pPtr = const_cast<ConCommandBase*>(pPtr->GetNext());
}
#else
g_entityFactoryDictionary = VFuncs::GetEntityDictionary(NULL);
return g_entityFactoryDictionary;
#endif
return NULL;
}
示例2: CacheCmds
//Thanks to fysh for the idea of extracting info from "echo" and for
// having the original offsets at hand!
bool CSmmAPI::CacheCmds()
{
ICvar *pCvar = g_Engine.icvar;
ConCommandBase *pBase = pCvar->GetCommands();
unsigned char *ptr = NULL;
FnCommandCallback callback = NULL;
int offs = 0;
while (pBase)
{
if ( strcmp(pBase->GetName(), "echo") == 0 )
{
//callback = //*((FnCommandCallback *)((char *)pBase + offsetof(ConCommand, m_fnCommandCallback)));
callback = ((ConCommand *)pBase)->GetCallback();
ptr = (unsigned char *)callback;
#ifdef OS_LINUX
if (UTIL_VerifySignature(ptr, ENGINE486_SIG, SIGLEN))
{
offs = ENGINE486_OFFS;
}
else if (UTIL_VerifySignature(ptr, ENGINE686_SIG, SIGLEN))
{
offs = ENGINE686_OFFS;
}
else if (UTIL_VerifySignature(ptr, ENGINEAMD_SIG, SIGLEN))
{
offs = ENGINEAMD_OFFS;
}
#elif defined OS_WIN32 // Only one Windows engine binary so far...
if (UTIL_VerifySignature(ptr, ENGINEW32_SIG, SIGLEN))
{
offs = ENGINEW32_OFFS;
}
#endif
if (!offs || ptr[offs - 1] != IA32_CALL)
{
m_ConPrintf = (CONPRINTF_FUNC)Msg;
return false;
}
//get the relative offset
m_ConPrintf = *((CONPRINTF_FUNC *)(ptr + offs));
//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
m_ConPrintf = (CONPRINTF_FUNC)((unsigned long)m_ConPrintf + (unsigned long)(ptr + offs) + 4);
m_CmdCache = true;
return true;
}
pBase = const_cast<ConCommandBase *>(pBase->GetNext());
}
m_ConPrintf = (CONPRINTF_FUNC)Msg;
return false;
}
示例3: HookConCommands
void CSourceMMMAP::HookConCommands()
{
//find the commands in the server's CVAR list
#if defined (GAME_CSGO)
pSayCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("say"));
pTeamSayCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("say_team"));
pChangeLevelCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("changelevel"));
pAutoBuyCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("autobuy"));
pReBuyCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("rebuy"));
pRespawnEntities = static_cast<ConCommand *>(g_pCVar->FindCommand("respawn_entities"));
#else
ConCommandBase *pCmd = g_pCVar->GetCommands();
while (pCmd)
{
if (pCmd->IsCommand())
{
if (strcmp(pCmd->GetName(), "say") == 0)
pSayCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "say_team") == 0)
pTeamSayCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "changelevel") == 0)
pChangeLevelCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "autobuy") == 0)
pAutoBuyCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "rebuy") == 0)
pReBuyCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "respawn_entities") == 0)
pRespawnEntities = static_cast<ConCommand *>(pCmd);
}
pCmd = const_cast<ConCommandBase *>(pCmd->GetNext());
}
#endif
#if !defined GAME_ORANGE && defined SOURCEMM
if (pSayCmd) SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pSayCmd, Say_handler, false);
if (pRespawnEntities) SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pRespawnEntities, RespawnEntities_handler, false);
if (pTeamSayCmd) SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pTeamSayCmd, TeamSay_handler, false);
if (pChangeLevelCmd) SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pChangeLevelCmd, ChangeLevel_handler, false);
if (pAutoBuyCmd)
{
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pAutoBuyCmd, AutoBuy_handler, false);
autobuy_cc = SH_GET_CALLCLASS(pAutoBuyCmd);
}
if (pReBuyCmd)
{
SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pReBuyCmd, ReBuy_handler, false);
rebuy_cc = SH_GET_CALLCLASS(pReBuyCmd);
}
#else
if (pSayCmd) SH_ADD_HOOK(ConCommand, Dispatch, pSayCmd, SH_STATIC(Say_handler), false);
if (pRespawnEntities) SH_ADD_HOOK(ConCommand, Dispatch, pRespawnEntities, SH_STATIC(RespawnEntities_handler), false);
if (pTeamSayCmd) SH_ADD_HOOK(ConCommand, Dispatch, pTeamSayCmd, SH_STATIC(TeamSay_handler), false);
if (pChangeLevelCmd) SH_ADD_HOOK(ConCommand, Dispatch, pChangeLevelCmd, SH_STATIC(ChangeLevel_handler), false);
if (pAutoBuyCmd) SH_ADD_HOOK(ConCommand, Dispatch, pAutoBuyCmd, SH_STATIC(AutoBuy_handler), false);
if (pReBuyCmd) SH_ADD_HOOK(ConCommand, Dispatch, pReBuyCmd, SH_STATIC(ReBuy_handler), false);
#endif
}
示例4: OnSourceModGameInitialized
void ChatTriggers::OnSourceModGameInitialized()
{
unsigned int total = 2;
ConCommandBase *pCmd = icvar->GetCommands();
const char *name;
while (pCmd)
{
if (pCmd->IsCommand())
{
name = pCmd->GetName();
if (!m_pSayCmd && strcmp(name, "say") == 0)
{
m_pSayCmd = (ConCommand *)pCmd;
if (--total == 0)
{
break;
}
} else if (!m_pSayTeamCmd && strcmp(name, "say_team") == 0) {
m_pSayTeamCmd = (ConCommand *)pCmd;
if (--total == 0)
{
break;
}
}
}
pCmd = const_cast<ConCommandBase *>(pCmd->GetNext());
}
if (m_pSayCmd)
{
SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayCmd, this, &ChatTriggers::OnSayCommand_Pre, false);
SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayCmd, this, &ChatTriggers::OnSayCommand_Post, true);
}
if (m_pSayTeamCmd)
{
SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayTeamCmd, this, &ChatTriggers::OnSayCommand_Pre, false);
SH_ADD_HOOK_MEMFUNC(ConCommand, Dispatch, m_pSayTeamCmd, this, &ChatTriggers::OnSayCommand_Post, true);
}
}
示例5: if
void ManiSMMHooks::HookConCommands()
{
//find the commands in the server's CVAR list
#if defined (GAME_CSGO)
pSayCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("say"));
pTeamSayCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("say_team"));
pChangeLevelCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("changelevel"));
pAutoBuyCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("autobuy"));
pReBuyCmd = static_cast<ConCommand *>(g_pCVar->FindCommand("rebuy"));
pRespawnEntities = static_cast<ConCommand *>(g_pCVar->FindCommand("respawn_entities"));
#else
ConCommandBase *pCmd = NULL;
pCmd = g_pCVar->GetCommands();
while (pCmd)
{
if (pCmd->IsCommand())
{
if (strcmp(pCmd->GetName(), "say") == 0)
pSayCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "say_team") == 0)
pTeamSayCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "changelevel") == 0)
pChangeLevelCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "autobuy") == 0)
pAutoBuyCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "rebuy") == 0)
pReBuyCmd = static_cast<ConCommand *>(pCmd);
else if (strcmp(pCmd->GetName(), "respawn_entities") == 0)
pRespawnEntities = static_cast<ConCommand *>(pCmd);
}
pCmd = const_cast<ConCommandBase *>(pCmd->GetNext());
}
#endif
if (pSayCmd) SH_ADD_HOOK(ConCommand, Dispatch, pSayCmd, SH_STATIC(Say_handler), false);
if (pRespawnEntities) SH_ADD_HOOK(ConCommand, Dispatch, pRespawnEntities, SH_STATIC(RespawnEntities_handler), false);
if (pTeamSayCmd) SH_ADD_HOOK(ConCommand, Dispatch, pTeamSayCmd, SH_STATIC(TeamSay_handler), false);
if (pChangeLevelCmd) SH_ADD_HOOK(ConCommand, Dispatch, pChangeLevelCmd, SH_STATIC(ChangeLevel_handler), false);
if (pAutoBuyCmd) SH_ADD_HOOK(ConCommand, Dispatch, pAutoBuyCmd, SH_STATIC(AutoBuy_handler), false);
if (pReBuyCmd) SH_ADD_HOOK(ConCommand, Dispatch, pReBuyCmd, SH_STATIC(ReBuy_handler), false);
}
示例6: Load
bool MyPlugin::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
{
serverGameDLL = (IServerGameDLL *)gameServerFactory(INTERFACEVERSION_SERVERGAMEDLL, NULL);
if (serverGameDLL)
{
ServerClass *svrclass = serverGameDLL->GetAllServerClasses();
while (svrclass)
{
const char *classname = svrclass->GetName();
Msg("[%s]\n", classname);
if (strcmp(classname, "CBasePlayer") == 0)
{
SendTable *st = svrclass->m_pTable;
for (int i = 0; i < st->m_nProps; i++)
{
SendProp *sp = st->GetProp(i);
const char *propname = sp->GetName();
Msg("Prop name: %s | Prop Offset: %d | Type: %d | IsSigned: %d\n", propname, sp->GetOffset(), sp->GetType(), sp->IsSigned());
if (strcmp(propname, "m_fFlags") == 0)
{
m_fFlags_off = sp->GetOffset();
continue;
}
if (strcmp(propname, "m_iHealth") == 0)
{
m_iHealth_off = sp->GetOffset();
continue;
}
}
}
if (strcmp(classname, "CBaseEntity") == 0)
{
SendTable *st = svrclass->m_pTable;
for (int i = 0; i < st->m_nProps; i++)
{
SendProp *sp = st->GetProp(i);
const char *propname = sp->GetName();
Msg("Prop name: %s | Prop Offset: %d | Type: %d | IsSigned: %d\n", propname, sp->GetOffset(), sp->GetType(), sp->IsSigned());
if (strcmp(propname, "m_iTeamNum") == 0)
{
m_iTeamNum_off = sp->GetOffset();
continue;
}
if (strcmp(propname, "m_iPendingTeamNum") == 0)
{
m_iPendingTeamNum_off = sp->GetOffset();
continue;
}
if (strcmp(propname, "m_fEffects") == 0)
{
m_fEffects_off = sp->GetOffset();
continue;
}
if (strcmp(propname, "m_nRenderMode") == 0)
{
m_nRenderMode_off = sp->GetOffset();
continue;
}
}
}
/*if (strcmp(classname, "CBaseCombatWeapon") == 0)
{
SendTable *st = svrclass->m_pTable;
for (int i = 0; i < st->m_nProps; i++)
{
SendProp *sp = st->GetProp(i);
const char *propname = sp->GetName();
Msg("Prop name: %s | Prop Offset: %d | Type: %d | IsSigned: %d\n", propname, sp->GetOffset(), sp->GetType(), sp->IsSigned());
}
}*/
svrclass = svrclass->m_pNext;
}
}
else
{
Warning("Unable to load IServerGameDLL.\n");
return false;
}
serverGameEnts = (IServerGameEnts *)gameServerFactory(INTERFACEVERSION_SERVERGAMEENTS, NULL);
if (!serverGameEnts)
{
Warning("Unable to load IServerGameEnts.\n");
return false;
}
playerInfoManager = (IPlayerInfoManager *)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER, NULL);
if (playerInfoManager)
{
globalVars = playerInfoManager->GetGlobalVars();
}
else
//.........这里部分代码省略.........
示例7: FindConPrintf
void FindConPrintf(void)
{
ConCommandBase *pBase = NULL;
unsigned char *ptr = NULL;
#ifdef GAME_ORANGE
FnCommandCallback_t callback = NULL;
#else
FnCommandCallback callback = NULL;
#endif
int offs = 0;
#if !defined ( GAME_CSGO )
pBase = g_pCVar->GetCommands();
while (pBase)
{
if ( strcmp(pBase->GetName(), "echo") == 0 )
{
//callback = //*((FnCommandCallback *)((char *)pBase + offsetof(ConCommand, m_fnCommandCallback)));
callback = ((ConCommand *)pBase)->m_fnCommandCallback;
ptr = (unsigned char *)callback;
if (vcmp(ptr, ENGINE486_SIG, SIGLEN))
{
offs = ENGINE486_OFFS;
} else if (vcmp(ptr, ENGINE686_SIG, SIGLEN)) {
offs = ENGINE686_OFFS;
} else if (vcmp(ptr, ENGINEAMD_SIG, SIGLEN)) {
offs = ENGINEAMD_OFFS;
} else if (vcmp(ptr, ENGINEW32_SIG, SIGLEN)) {
offs = ENGINEW32_OFFS;
}
if (!offs || ptr[offs-1] != IA32_CALL)
{
return;
}
//get the relative offset
MMsg = *((CONPRINTF_FUNC *)(ptr + offs));
//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
MMsg = (CONPRINTF_FUNC)((unsigned long)MMsg + (unsigned long)(ptr + offs) + 4);
Msg("Using conprintf\n");
return;
}
pBase = const_cast<ConCommandBase *>(pBase->GetNext());
}
#else
pBase = g_pCVar->FindCommand("echo");
callback = ((ConCommand *)pBase)->m_fnCommandCallback;
ptr = (unsigned char *)callback;
if (vcmp(ptr, ENGINE486_SIG, SIGLEN))
{
offs = ENGINE486_OFFS;
} else if (vcmp(ptr, ENGINE686_SIG, SIGLEN)) {
offs = ENGINE686_OFFS;
} else if (vcmp(ptr, ENGINEAMD_SIG, SIGLEN)) {
offs = ENGINEAMD_OFFS;
} else if (vcmp(ptr, ENGINEW32_SIG, SIGLEN)) {
offs = ENGINEW32_OFFS;
}
if (!offs || ptr[offs-1] != IA32_CALL)
{
return;
}
//get the relative offset
MMsg = *((CONPRINTF_FUNC *)(ptr + offs));
//add the base offset, to the ip (which is the address+offset + 4 bytes for next instruction)
MMsg = (CONPRINTF_FUNC)((unsigned long)MMsg + (unsigned long)(ptr + offs) + 4);
Msg("Using conprintf\n");
return;
#endif
Msg("Using Msg()\n");
MMsg = (CONPRINTF_FUNC)Msg;
return;
}