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


C++ CVariable::SetName方法代码示例

本文整理汇总了C++中CVariable::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariable::SetName方法的具体用法?C++ CVariable::SetName怎么用?C++ CVariable::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVariable的用法示例。


在下文中一共展示了CVariable::SetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AtomicSetGlobal

BOOL DETOUR_CGameSprite::AtomicSetGlobal(Action& a) {
	IECString sArg = a.m_s1;
	sArg.MakeUpper();
	IECString sScope = sArg.Left(6);
	IECString sVariable = sArg.Right(sArg.GetLength() - 6);
	CVariable varNew;

	BOOL bIncrement = a.m_wOpcode == ACTION_INCREMENT_GLOBAL;
	int nNewValue;

	CGameSprite* pTarget = NULL;
	Object oOverride = a.m_oOverride;
	if (!oOverride.MatchCriteria(*g_poAny, FALSE, FALSE, FALSE) ||
		!oOverride.m_sName.IsEmpty() ||
		oOverride.m_oids.m_id1 != OBJECT_NOTHING) {
		oOverride.DecodeIdentifiers(*this);
		pTarget = (CGameSprite*)&oOverride.FindTargetOfType(*this, CGAMEOBJECT_TYPE_SPRITE, FALSE);
		if (pTarget) {
			a.m_oOverride = *g_poAny;
		} else {
			return TRUE;
		}
	} else {
		pTarget = this;
	}

	if (a.m_wOpcode == ACTION_SG) {
		sScope = "GLOBAL";
		sVariable = sArg;
	}

	if (!sScope.Compare("GLOBAL")) {
		CVariable& var = g_pChitin->GetInfGame().m_GlobalVariables.Find(sVariable);
		if (&var != NULL) {
			var.m_nValue = bIncrement ? var.m_nValue + a.m_i : a.m_i;
			nNewValue = var.m_nValue;
		} else {
			varNew.SetName(sVariable);
			varNew.m_nValue = a.m_i;
			nNewValue = varNew.m_nValue;
			g_pChitin->GetInfGame().m_GlobalVariables.Add(varNew);
		}

		CMessageModifyVariable* pMsg = new CMessageModifyVariable(
			sVariable,
			sScope,
			nNewValue,
			0,
			pTarget->m_e,
			pTarget->m_e);
		g_pChitin->m_MessageHandler.AddMessage(*pMsg, FALSE);

		return TRUE;
	}

	if (!sScope.Compare("LOCALS")) {
		if (pTarget->GetType() == CGAMEOBJECT_TYPE_CREATURE) {
			CVariable& var = ((CCreatureObject*)pTarget)->m_pLocalVariables->Find(sVariable);
			if (&var != NULL) {
				var.m_nValue = bIncrement ? var.m_nValue + a.m_i : a.m_i;
				nNewValue = var.m_nValue;
			} else {
				varNew.SetName(sVariable);
				varNew.m_nValue = a.m_i;
				nNewValue = varNew.m_nValue;
				((CCreatureObject*)pTarget)->m_pLocalVariables->Add(varNew); //64A2E8
			}

			CMessageModifyVariable* pMsg = new CMessageModifyVariable(
				sVariable,
				sScope,
				nNewValue,
				0,
				pTarget->m_e,
				pTarget->m_e);
			g_pChitin->m_MessageHandler.AddMessage(*pMsg, FALSE);

			return TRUE;
		} else {
			LPCTSTR lpsz = "CGameSprite_AtomicSetGlobal(): pTarget not CGAMEOBJECT_TYPE_CREATURE for setting LOCALS\r\n";
			L.timestamp();
			L.append(lpsz);
			console.write(lpsz);
			return TRUE;
		}
	}

	if (!sScope.Compare("MYAREA")) {
		sScope = pTarget->m_pArea->m_rAreaName.FormatToString();
	}
	CArea& area = g_pChitin->GetInfGame().GetLoadedArea(sScope);
	if (&area != NULL) {
		CVariable& var = area.m_mapAreaVariables.Find(sVariable);
		if (&var != NULL) {
			var.m_nValue = bIncrement ? var.m_nValue + a.m_i : a.m_i;
			nNewValue = var.m_nValue;
		} else {
			varNew.SetName(sVariable);
			varNew.m_nValue = a.m_i;
			nNewValue = varNew.m_nValue;
//.........这里部分代码省略.........
开发者ID:Ascension64,项目名称:TobEx,代码行数:101,代码来源:ObjectCore.cpp


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