• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CHECK_UNITID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CHECK_UNITID函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_UNITID函数的具体用法?C++ CHECK_UNITID怎么用?C++ CHECK_UNITID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: switch

int CAICheats::HandleCommand(int commandId, void* data)
{
	int ret = 0; // handling failed

	switch (commandId) {
		case AIHCQuerySubVersionId: {
			ret = 1; // current version of Handle Command interface
		} break;

		case AIHCTraceRayId: {
			AIHCTraceRay* cmdData = static_cast<AIHCTraceRay*>(data);

			if (CHECK_UNITID(cmdData->srcUID)) {
				const CUnit* srcUnit = unitHandler->GetUnit(cmdData->srcUID);

				CUnit* hitUnit = nullptr;
				CFeature* hitFeature = nullptr;

				if (srcUnit != nullptr) {
					//FIXME ignore features?
					cmdData->rayLen = TraceRay::TraceRay(cmdData->rayPos, cmdData->rayDir, cmdData->rayLen, cmdData->flags, srcUnit, hitUnit, hitFeature);
					cmdData->hitUID = (hitUnit != nullptr)? hitUnit->id: -1;
				}
			}

			ret = 1;
		} break;

		case AIHCFeatureTraceRayId: {
			AIHCFeatureTraceRay* cmdData = static_cast<AIHCFeatureTraceRay*>(data);

			if (CHECK_UNITID(cmdData->srcUID)) {
				const CUnit* srcUnit = unitHandler->GetUnit(cmdData->srcUID);

				CUnit* hitUnit = nullptr;
				CFeature* hitFeature = nullptr;

				if (srcUnit != nullptr) {
					//FIXME ignore units?
					cmdData->rayLen = TraceRay::TraceRay(cmdData->rayPos, cmdData->rayDir, cmdData->rayLen, cmdData->flags, srcUnit, hitUnit, hitFeature);
					cmdData->hitFID = (hitFeature != nullptr)? hitFeature->id: -1;
				}
			}

			ret = 1;
		} break;

		default: {
			ret = 0; // handling failed
		}
	}

	return ret;
}
开发者ID:nixtux,项目名称:spring,代码行数:54,代码来源:AICheats.cpp


示例2: verify

const UnitDef* CAICallback::GetUnitDef(int unitId)
{
	const UnitDef* def = nullptr;

	verify();
	if (CHECK_UNITID(unitId)) {
		const CUnit* unit = unitHandler->GetUnit(unitId);

		if (unit == nullptr)
			return def;

		const UnitDef* unitDef = unit->unitDef;
		const int allyTeam = teamHandler->AllyTeam(team);
		if (teamHandler->Ally(unit->allyteam, allyTeam)) {
			def = unitDef;
		} else {
			const unsigned short losStatus = unit->losStatus[allyTeam];
			const unsigned short prevMask = (LOS_PREVLOS | LOS_CONTRADAR);
			if (((losStatus & LOS_INLOS) != 0) ||
					((losStatus & prevMask) == prevMask)) {
				const UnitDef* decoyDef = unitDef->decoyDef;
				if (decoyDef == NULL) {
					def = unitDef;
				} else {
					def = decoyDef;
				}
			}
		}
	}

	return def;
}
开发者ID:nixtux,项目名称:spring,代码行数:32,代码来源:AICallback.cpp


示例3: verify

const UnitDef* CAICallback::GetUnitDef(int unitId)
{
	verify ();
	if (CHECK_UNITID(unitId)) {
		CUnit* unit = uh->units[unitId];
		if (unit) {
			const UnitDef* unitDef = unit->unitDef;
			const int allyTeam = gs->AllyTeam(team);
			if (gs->Ally(unit->allyteam, allyTeam)) {
				return unitDef;
			}
			const unsigned short losStatus = unit->losStatus[allyTeam];
			const unsigned short prevMask = (LOS_PREVLOS | LOS_CONTRADAR);
			if (((losStatus & LOS_INLOS) != 0) ||
					((losStatus & prevMask) == prevMask)) {
				const UnitDef* decoyDef = unitDef->decoyDef;
				if (decoyDef == NULL) {
					return unitDef;
				} else {
					return decoyDef;
				}
			}
		}
	}
	return 0;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:26,代码来源:AICallback.cpp


示例4: verify

float CAICallback::GetUnitPower(int unitId)
{
	float power = -1;

	verify();
	if (CHECK_UNITID(unitId)) {
		const CUnit* unit = unitHandler->units[unitId];
		if (unit) {
			const int allyTeam = teamHandler->AllyTeam(team);
			if (teamHandler->Ally(unit->allyteam, allyTeam)) {
				power = unit->power;
			} else if (unit->losStatus[allyTeam] & LOS_INLOS) {
				const UnitDef* unitDef = unit->unitDef;
				const UnitDef* decoyDef = unitDef->decoyDef;
				if (decoyDef == NULL) {
					power = unit->power;
				} else {
					const float scale = (decoyDef->power / unitDef->power);
					power = unit->power * scale;
				}
			}
		}
	}

	return power;
}
开发者ID:AlexDiede,项目名称:spring,代码行数:26,代码来源:AICallback.cpp


示例5: GetUnit

CUnit* CAICheats::GetUnit(int unitId) const
{
	if (CHECK_UNITID(unitId))
		return unitHandler->GetUnit(unitId);

	return nullptr;
}
开发者ID:nixtux,项目名称:spring,代码行数:7,代码来源:AICheats.cpp


示例6: verify

int CAICallback::GiveOrder(int unitid, Command* c)
{
	verify ();

	if (!CHECK_UNITID(unitid) || c == NULL)
		return -1;

	if (noMessages)
		return -1;

	CUnit *unit = uh->units[unitid];

	if (!unit)
		return -1;

	if (group && unit->group != group)
		return -1;

	if (unit->team != team)
		return -1;

	net->SendSTLData<unsigned char, short, int, unsigned char, std::vector<float> >(
			NETMSG_AICOMMAND, gu->myPlayerNum, unitid, c->id, c->options, c->params);
	return 0;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:25,代码来源:AICallback.cpp


示例7: switch

int CAICheats::HandleCommand(int commandId, void *data)
{
	switch (commandId) {
		case AIHCQuerySubVersionId:
			return 1; // current version of Handle Command interface

		case AIHCTraceRayId: {
			AIHCTraceRay* cmdData = (AIHCTraceRay*) data;

			if (CHECK_UNITID(cmdData->srcUID)) {
				const CUnit* srcUnit = uh->units[cmdData->srcUID];
				const CUnit* hitUnit = NULL;

				if (srcUnit != NULL) {
					cmdData->rayLen = helper->TraceRay(cmdData->rayPos, cmdData->rayDir, cmdData->rayLen, 0.0f, srcUnit, hitUnit, cmdData->flags);
					cmdData->hitUID = (hitUnit != NULL)? hitUnit->id: -1;
				}
			}

			return 1;
		}

		default:
			return 0;
	}
}
开发者ID:DeadnightWarrior,项目名称:spring,代码行数:26,代码来源:AICheats.cpp


示例8: GetUnitVelocity

float3 CAICheats::GetUnitVelocity(int unitid)
{
	if (!CHECK_UNITID(unitid)) return ZeroVector;
	const CUnit* unit = uh->units[unitid];
	if (unit != NULL) {
		return unit->speed;
	}
	return ZeroVector;
}
开发者ID:lunixbochs,项目名称:spring,代码行数:9,代码来源:AICheats.cpp


示例9:

const deque<Command>* CAICallback::GetCurrentUnitCommands(int unitid)
{
	if (CHECK_UNITID(unitid)) {
		CUnit *unit = uh->units[unitid];
		if (unit && unit->team == team)
			return &unit->commandAI->commandQue;
	}
	return 0;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:9,代码来源:AICallback.cpp


示例10: GetUnit

CUnit* CAICallback::GetUnit(int unitId) const
{
	CUnit* unit = nullptr;

	if (CHECK_UNITID(unitId))
		unit = unitHandler->GetUnit(unitId);

	return unit;
}
开发者ID:nixtux,项目名称:spring,代码行数:9,代码来源:AICallback.cpp


示例11: AddUnitToGroup

bool CAICallback::AddUnitToGroup(int unitid,int groupid)
{
	if (CHECK_UNITID(unitid) && CHECK_GROUPID(groupid)) {
		CUnit* u=uh->units[unitid];
		if(u && u->team==team && gh->groups[groupid]){
			return u->SetGroup(gh->groups[groupid]);
		}
	}
	return false;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:10,代码来源:AICallback.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CHECK_VALID函数代码示例发布时间:2022-05-30
下一篇:
C++ CHECK_TYPES函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap