当前位置: 首页>>代码示例>>C++>>正文


C++ NativeHandle::create方法代码示例

本文整理汇总了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;
}
开发者ID:Javivi,项目名称:amxmodx,代码行数:28,代码来源:gameconfigs.cpp

示例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);
}
开发者ID:Javivi,项目名称:amxmodx,代码行数:24,代码来源:datastructs.cpp

示例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);
}
开发者ID:VasilVasilev93,项目名称:amxmodx,代码行数:24,代码来源:trie_natives.cpp

示例4: TrieCreate

// native Trie:TrieCreate();
static cell AMX_NATIVE_CALL TrieCreate(AMX *amx, cell *params)
{
	return static_cast<cell>(TrieHandles.create());
}
开发者ID:VasilVasilev93,项目名称:amxmodx,代码行数:5,代码来源:trie_natives.cpp

示例5: createParser

cell createParser()
{
	return TextParsersHandles.create();
}
开发者ID:Misiaczek,项目名称:amxmodx,代码行数:4,代码来源:textparse.cpp


注:本文中的NativeHandle::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。