本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: GetUnit
CUnit* CAICheats::GetUnit(int unitId) const
{
if (CHECK_UNITID(unitId))
return unitHandler->GetUnit(unitId);
return nullptr;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例10: GetUnit
CUnit* CAICallback::GetUnit(int unitId) const
{
CUnit* unit = nullptr;
if (CHECK_UNITID(unitId))
unit = unitHandler->GetUnit(unitId);
return unit;
}
示例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;
}