本文整理汇总了C++中RunCallIn函数的典型用法代码示例。如果您正苦于以下问题:C++ RunCallIn函数的具体用法?C++ RunCallIn怎么用?C++ RunCallIn使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunCallIn函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LUA_CALL_IN_CHECK
void CLuaHandle::ProjectileDestroyed(const CProjectile* projectile)
{
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 4);
static const LuaHashString cmdStr("ProjectileDestroyed");
if (!cmdStr.GetGlobalFunc(L)) {
return; // the call is not defined
}
lua_pushnumber(L, projectile->id);
// call the routine
RunCallIn(cmdStr, 1, 0);
return;
}
示例2: LUA_CALL_IN_CHECK
void CLuaIntro::LoadProgress(const std::string& msg, const bool replace_lastline)
{
LUA_CALL_IN_CHECK(L);
luaL_checkstack(L, 4, __FUNCTION__);
static const LuaHashString cmdStr("LoadProgress");
if (!cmdStr.GetGlobalFunc(L)) {
return;
}
lua_pushsstring(L, msg);
lua_pushboolean(L, replace_lastline);
// call the routine
RunCallIn(L, cmdStr, 2, 0);
}
示例3: LUA_CALL_IN_CHECK
bool CLuaHandleSynced::GotChatMsg(const string& msg, int playerID)
{
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 4);
static const LuaHashString cmdStr("GotChatMsg");
if (!cmdStr.GetGlobalFunc(L)) {
return true; // the call is not defined
}
lua_pushstring(L, msg.c_str());
lua_pushnumber(L, playerID);
// call the routine
RunCallIn(cmdStr, 2, 0);
return true;
}
示例4: LUA_CALL_IN_CHECK
void CUnsyncedLuaHandle::RecvFromSynced(lua_State* srcState, int args)
{
if (!IsValid())
return;
LUA_CALL_IN_CHECK(L);
luaL_checkstack(L, 2 + args, __FUNCTION__);
static const LuaHashString cmdStr("RecvFromSynced");
if (!cmdStr.GetGlobalFunc(L))
return; // the call is not defined
LuaUtils::CopyData(L, srcState, args);
// call the routine
RunCallIn(L, cmdStr, args, 0);
}
示例5: LUA_CALL_IN_CHECK
void CLuaHandleSynced::SendCallbacks()
{
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 5);
const int count = (int)cobCallbackEntries.size();
for (int cb = 0; cb < count; cb++) {
static const LuaHashString cmdStr("CobCallback");
if (!cmdStr.GetGlobalFunc(L)) {
return;
}
const CobCallbackData& cbd = cobCallbackEntries[cb];
lua_pushnumber(L, cbd.retCode);
lua_pushnumber(L, cbd.unitID);
lua_pushnumber(L, cbd.floatData);
// call the routine
RunCallIn(cmdStr, 3, 0);
}
cobCallbackEntries.clear();
}
示例6: cmdStr
void CLuaHandleSynced::RecvFromSynced(int args)
{
//LUA_CALL_IN_CHECK(L); -- not valid here
static const LuaHashString cmdStr("RecvFromSynced");
if (!cmdStr.GetRegistryFunc(L)) {
return; // the call is not defined
}
lua_insert(L, 1); // place the function
// call the routine
allowChanges = false;
synced = false;
RunCallIn(cmdStr, args, 0);
synced = true;
allowChanges = true;
return;
}
示例7: LUA_CALL_IN_CHECK
bool CLuaRules::TerraformComplete(const CUnit* unit, const CUnit* build)
{
if (!haveTerraformComplete) {
return false; // the call is not defined
}
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 8);
static const LuaHashString cmdStr("TerraformComplete");
if (!cmdStr.GetGlobalFunc(L)) {
return false; // the call is not defined
}
// push the unit info
lua_pushnumber(L, unit->id);
lua_pushnumber(L, unit->unitDef->id);
lua_pushnumber(L, unit->team);
// push the construction info
lua_pushnumber(L, build->id);
lua_pushnumber(L, build->unitDef->id);
lua_pushnumber(L, build->team);
// call the function
if (!RunCallIn(cmdStr, 6, 1)) {
return false;
}
// get the results
if (!lua_isboolean(L, -1)) {
logOutput.Print("%s() bad return value\n", cmdStr.GetString().c_str());
lua_pop(L, 1);
return false;
}
const bool retval = !!lua_toboolean(L, -1);
lua_pop(L, 1);
// return 'true' to remove the command
return retval;
}
示例8: lua_settop
bool CLuaRules::AllowUnitCreation(const UnitDef* unitDef,
const CUnit* builder, const float3* pos)
{
if (!haveAllowUnitCreation) {
return true; // the call is not defined
}
lua_settop(L, 0);
static const LuaHashString cmdStr("AllowUnitCreation");
if (!cmdStr.GetGlobalFunc(L)) {
lua_settop(L, 0);
return true; // the call is not defined
}
lua_pushnumber(L, unitDef->id);
lua_pushnumber(L, builder->id);
lua_pushnumber(L, builder->team);
if (pos) {
lua_pushnumber(L, pos->x);
lua_pushnumber(L, pos->y);
lua_pushnumber(L, pos->z);
}
// call the function
if (!RunCallIn(cmdStr, pos ? 6 : 4, 1)) {
return true;
}
// get the results
const int args = lua_gettop(L);
if ((args != 1) || !lua_isboolean(L, -1)) {
logOutput.Print("%s() bad return value (%i)\n",
cmdStr.GetString().c_str(), args);
lua_settop(L, 0);
return true;
}
return !!lua_toboolean(L, -1);
}
示例9: LUA_CALL_IN_CHECK
bool CLuaHandle::AddConsoleLine(const string& msg, const CLogSubsystem& /**/)
{
if (!CheckModUICtrl()) {
return true; // FIXME?
}
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 4);
static const LuaHashString cmdStr("AddConsoleLine");
if (!PushUnsyncedCallIn(cmdStr)) {
return true; // the call is not defined
}
lua_pushstring(L, msg.c_str());
// FIXME: makes no sense now, but *gets might expect this
lua_pushnumber(L, 0);
// call the function
if (!RunCallIn(cmdStr, 2, 0)) {
return false;
}
return true;
}