本文整理汇总了C++中NativeHandle::create方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeHandle::create方法的具体用法?C++ NativeHandle::create怎么用?C++ NativeHandle::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeHandle
的用法示例。
在下文中一共展示了NativeHandle::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadGameConfigFile
// native GameConfig:LoadGameConfigFile(const file[]);
static cell AMX_NATIVE_CALL LoadGameConfigFile(AMX *amx, cell *params)
{
int length;
const char *filename = get_amxstring(amx, params[1], 0, length);
IGameConfig *config = nullptr;
char error[128];
if (!ConfigManager.LoadGameConfigFile(filename, &config, error, sizeof(error)))
{
LogError(amx, AMX_ERR_NATIVE, "Unable to open %s: %s", filename, error);
return 0;
}
int handle = GameConfigHandle.create();
auto configHandle = GameConfigHandle.lookup(handle);
if (!configHandle)
{
return 0;
}
configHandle->m_config = config;
return handle;
}
示例2: ArrayCreate
// Array:ArrayCreate(cellsize=1, reserved=32);
static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
{
// params[1] (cellsize) is how big in cells each element is.
// this MUST be greater than 0!
int cellsize = params[1];
// params[2] (reserved) is how many elements to allocate
// immediately when the list is created.
int reserved = params[2];
if (cellsize <= 0)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array size (%d)", cellsize);
return -1;
}
if (reserved < 0)
{
reserved = 0;
}
return ArrayHandles.create(cellsize, reserved);
}
示例3: TrieSnapshotCreate
static cell AMX_NATIVE_CALL TrieSnapshotCreate(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
int index = TrieSnapshotHandles.create();
TrieSnapshot *snapshot = TrieSnapshotHandles.lookup(index);
snapshot->length = t->map.elements();
snapshot->keys = new int[snapshot->length];
size_t i = 0;
for (StringHashMap<Entry>::iterator iter = t->map.iter(); !iter.empty(); iter.next(), i++)
{
snapshot->keys[i] = snapshot->strings.AddString(iter->key.chars(), iter->key.length());
}
assert(i == snapshot->length);
return static_cast<cell>(index);
}
示例4: TrieCreate
// native Trie:TrieCreate();
static cell AMX_NATIVE_CALL TrieCreate(AMX *amx, cell *params)
{
return static_cast<cell>(TrieHandles.create());
}
示例5: createParser
cell createParser()
{
return TextParsersHandles.create();
}