本文整理汇总了C++中sourcehook::CVector类的典型用法代码示例。如果您正苦于以下问题:C++ CVector类的具体用法?C++ CVector怎么用?C++ CVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVector类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTeamScore
static cell_t GetTeamScore(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
if (!m_iScore)
{
m_iScore = g_pGameConf->GetKeyValue("m_iScore");
if (!m_iScore)
{
return pContext->ThrowNativeError("Failed to get m_iScore key");
}
}
static int offset = -1;
if (offset == -1)
{
SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, m_iScore);
if (!prop)
{
return pContext->ThrowNativeError("Failed to get m_iScore prop");
}
offset = prop->GetOffset();
}
return *(int *)((unsigned char *)g_Teams[teamindex].pEnt + offset);
}
示例2: GetTeamName
static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
if (g_teamname_offset == 0)
{
return pContext->ThrowNativeError("Team names are not available on this game.");
}
if (g_teamname_offset == -1)
{
SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_szTeamname");
if (prop == NULL)
{
g_teamname_offset = 0;
return pContext->ThrowNativeError("Team names are not available on this game.");
}
g_teamname_offset = prop->GetOffset();
}
char *name = (char *)((unsigned char *)g_Teams[teamindex].pEnt + g_teamname_offset);
pContext->StringToLocalUTF8(params[2], params[3], name, NULL);
return 1;
}
示例3: GetTeamEntity
static cell_t GetTeamEntity(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
return gamehelpers->EntityToBCompatRef(g_Teams[teamindex].pEnt);
}
示例4: GetTeamScore
static cell_t GetTeamScore(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
static int offset = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "m_iScore")->GetOffset();
return *(int *)((unsigned char *)g_Teams[teamindex].pEnt + offset);
}
示例5: InitTeamNatives
void InitTeamNatives()
{
g_Teams.clear();
g_Teams.resize(1);
int edictCount = gpGlobals->maxEntities;
for (int i=0; i<edictCount; i++)
{
edict_t *pEdict = PEntityOfEntIndex(i);
if (!pEdict || pEdict->IsFree())
{
continue;
}
if (!pEdict->GetNetworkable())
{
continue;
}
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
if (FindNestedDataTable(pClass->m_pTable, "DT_Team"))
{
SendProp *pTeamNumProp = g_pGameHelpers->FindInSendTable(pClass->GetName(), "m_iTeamNum");
if (pTeamNumProp != NULL)
{
int offset = pTeamNumProp->GetOffset();
CBaseEntity *pEnt = pEdict->GetUnknown()->GetBaseEntity();
int TeamIndex = *(int *)((unsigned char *)pEnt + offset);
if (TeamIndex >= (int)g_Teams.size())
{
g_Teams.resize(TeamIndex+1);
}
g_Teams[TeamIndex].ClassName = pClass->GetName();
g_Teams[TeamIndex].pEnt = pEnt;
}
}
}
}
示例6: GetTeamClientCount
static cell_t GetTeamClientCount(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
SendProp *pProp = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, "\"player_array\"");
ArrayLengthSendProxyFn fn = pProp->GetArrayLengthProxy();
return fn(g_Teams[teamindex].pEnt, 0);
}
示例7: OnCoreMapStart
void SDKTools::OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
{
g_Teams.clear();
g_Teams.resize(1);
for (int i=0; i<edictCount; i++)
{
edict_t *pEdict = engine->PEntityOfEntIndex(i);
if (!pEdict || pEdict->IsFree())
{
continue;
}
if (!pEdict->GetNetworkable())
{
continue;
}
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
if (FindTeamEntities(pClass->m_pTable, "DT_Team"))
{
SendProp *pTeamNumProp = g_pGameHelpers->FindInSendTable(pClass->GetName(), "m_iTeamNum");
if (pTeamNumProp != NULL)
{
int offset = pTeamNumProp->GetOffset();
CBaseEntity *pEnt = pEdict->GetUnknown()->GetBaseEntity();
int TeamIndex = *(int *)((unsigned char *)pEnt + offset);
if (TeamIndex >= (int)g_Teams.size())
{
g_Teams.resize(TeamIndex+1);
}
g_Teams[TeamIndex].ClassName = pClass->GetName();
g_Teams[TeamIndex].pEnt = pEnt;
}
}
}
}
示例8: GetTeamName
static cell_t GetTeamName(IPluginContext *pContext, const cell_t *params)
{
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
if (g_teamname_offset == 0)
return pContext->ThrowNativeError("Team names are not available on this game.");
const char *name = tools_GetTeamName(teamindex);
if (name == NULL)
return pContext->ThrowNativeError("Team names are not available on this game.");
pContext->StringToLocalUTF8(params[2], params[3], name, NULL);
return 1;
}
示例9:
const char *tools_GetTeamName(int team)
{
if (size_t(team) >= g_Teams.size())
return NULL;
if (g_teamname_offset == 0)
return NULL;
if (g_teamname_offset == -1)
{
SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[team].ClassName, "m_szTeamname");
if (prop == NULL)
{
g_teamname_offset = 0;
return NULL;
}
g_teamname_offset = prop->GetOffset();
}
return (const char *)((unsigned char *)g_Teams[team].pEnt + g_teamname_offset);
}
示例10: SetTeamScore
static cell_t SetTeamScore(IPluginContext *pContext, const cell_t *params)
{
if (!g_pSM->IsMapRunning())
{
return pContext->ThrowNativeError("Cannot set team score when no map is running");
}
int teamindex = params[1];
if (teamindex >= (int)g_Teams.size() || !g_Teams[teamindex].ClassName)
{
return pContext->ThrowNativeError("Team index %d is invalid", teamindex);
}
if (m_iScore == NULL)
{
m_iScore = g_pGameConf->GetKeyValue("m_iScore");
if (m_iScore == NULL)
{
return pContext->ThrowNativeError("Failed to get m_iScore key");
}
}
static int offset = -1;
if (offset == -1)
{
SendProp *prop = g_pGameHelpers->FindInSendTable(g_Teams[teamindex].ClassName, m_iScore);
if (!prop)
{
return pContext->ThrowNativeError("Failed to get m_iScore prop");
}
offset = prop->GetOffset();
}
CBaseEntity *pTeam = g_Teams[teamindex].pEnt;
*(int *)((unsigned char *)pTeam + offset) = params[2];
edict_t *pEdict = gameents->BaseEntityToEdict(pTeam);
gamehelpers->SetEdictStateChanged(pEdict, offset);
return 1;
}
示例11: GetProcAddress
void *ResolveDemangledSymbol(void* handle, const char* symbol, int& type, char* argsBuffer, unsigned int len) {
#ifdef PLATFORM_WINDOWS
return GetProcAddress((HMODULE)handle, symbol);
#elif defined PLATFORM_LINUX
struct link_map* dlmap;
struct stat dlstat;
int dlfile;
uintptr_t map_base;
Elf32_Ehdr* file_hdr;
Elf32_Shdr* sections, * shstrtab_hdr, * symtab_hdr, * strtab_hdr;
Elf32_Sym* symtab;
const char* shstrtab, * strtab;
uint16_t section_count;
uint32_t symbol_count;
LibSymbolTable* libtable;
SymbolTable* table;
Symbol* symbol_entry = NULL;
dlmap = (struct link_map*)handle;
symtab_hdr = NULL;
strtab_hdr = NULL;
table = NULL;
/* See if we already have a symbol table for this library */
/*for (size_t i = 0; i < m_SymTables.size(); i++)
{
libtable = m_SymTables[i];
if (libtable->lib_base == dlmap->l_addr)
{
table = &libtable->table;
break;
}
}*/
/* If we don't have a symbol table for this library, then create one */
if (table == NULL)
{
libtable = new LibSymbolTable();
libtable->table.Initialize();
libtable->lib_base = dlmap->l_addr;
libtable->last_pos = 0;
table = &libtable->table;
m_SymTables.push_back(libtable);
}
// TODO Make this work with demangled symbols ?
/* See if the symbol is already cached in our table */
/*symbol_entry = table->FindSymbol(symbol, strlen(symbol));
if (symbol_entry != NULL)
{
return symbol_entry->address;
}*/
/* If symbol isn't in our table, then we have open the actual library */
dlfile = open(dlmap->l_name, O_RDONLY);
if (dlfile == -1 || fstat(dlfile, &dlstat) == -1)
{
close(dlfile);
return NULL;
}
/* Map library file into memory */
file_hdr = (Elf32_Ehdr *)mmap(NULL, dlstat.st_size, PROT_READ, MAP_PRIVATE, dlfile, 0);
map_base = (uintptr_t)file_hdr;
if (file_hdr == MAP_FAILED)
{
close(dlfile);
return NULL;
}
close(dlfile);
if (file_hdr->e_shoff == 0 || file_hdr->e_shstrndx == SHN_UNDEF)
{
munmap(file_hdr, dlstat.st_size);
return NULL;
}
sections = (Elf32_Shdr *)(map_base + file_hdr->e_shoff);
section_count = file_hdr->e_shnum;
/* Get ELF section header string table */
shstrtab_hdr = §ions[file_hdr->e_shstrndx];
shstrtab = (const char *)(map_base + shstrtab_hdr->sh_offset);
/* Iterate sections while looking for ELF symbol table and string table */
for (uint16_t i = 0; i < section_count; i++)
{
Elf32_Shdr &hdr = sections[i];
const char *section_name = shstrtab + hdr.sh_name;
if (strcmp(section_name, ".symtab") == 0)
{
symtab_hdr = &hdr;
}
else if (strcmp(section_name, ".strtab") == 0)
{
strtab_hdr = &hdr;
}
//.........这里部分代码省略.........
示例12: GetTeamCount
static cell_t GetTeamCount(IPluginContext *pContext, const cell_t *params)
{
return g_Teams.size();
}