本文整理汇总了C++中DROID_GROUP类的典型用法代码示例。如果您正苦于以下问题:C++ DROID_GROUP类的具体用法?C++ DROID_GROUP怎么用?C++ DROID_GROUP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DROID_GROUP类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scrOrderGroup
// Give a group an order
bool scrOrderGroup(void)
{
DROID_GROUP *psGroup;
DROID_ORDER order;
if (!stackPopParams(2, ST_GROUP, &psGroup, VAL_INT, &order))
{
return false;
}
ASSERT(psGroup != NULL,
"scrOrderGroup: Invalid group pointer");
if (order != DORDER_STOP &&
order != DORDER_RETREAT &&
order != DORDER_DESTRUCT &&
order != DORDER_RTR &&
order != DORDER_RTB &&
order != DORDER_RUN)
{
ASSERT(false,
"scrOrderGroup: Invalid order");
return false;
}
debug(LOG_NEVER, "group %p (%u) order %d", psGroup, psGroup->getNumMembers(), order);
psGroup->orderGroup(order);
return true;
}
示例2: scrGroupAddArea
// Add droids in an area to a group
bool scrGroupAddArea(void)
{
DROID_GROUP *psGroup;
DROID *psDroid;
SDWORD x1, y1, x2, y2, player;
if (!stackPopParams(6, ST_GROUP, &psGroup, VAL_INT, &player,
VAL_INT, &x1, VAL_INT, &y1, VAL_INT, &x2, VAL_INT, &y2))
{
return false;
}
ASSERT(psGroup != NULL,
"scrGroupAdd: Invalid group pointer");
if (player < 0 || player >= MAX_PLAYERS)
{
ASSERT(false, "scrGroupAddArea: invalid player");
return false;
}
for (psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
{
if (((SDWORD)psDroid->pos.x >= x1) && ((SDWORD)psDroid->pos.x <= x2) &&
((SDWORD)psDroid->pos.y >= y1) && ((SDWORD)psDroid->pos.y <= y2) &&
psDroid->droidType != DROID_COMMAND &&
(psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER))
{
psGroup->add(psDroid);
}
}
return true;
}
示例3: scrGroupAddDroid
// Add a droid to a group
bool scrGroupAddDroid(void)
{
DROID_GROUP *psGroup;
DROID *psDroid;
if (!stackPopParams(2, ST_GROUP, &psGroup, ST_DROID, &psDroid))
{
return false;
}
ASSERT(psGroup != NULL,
"scrGroupAdd: Invalid group pointer");
ASSERT(psDroid != NULL,
"scrGroupAdd: Invalid droid pointer");
if (psDroid == NULL)
{
return false;
}
if (psDroid->droidType == DROID_COMMAND)
{
debug(LOG_ERROR,
"scrGroupAdd: cannot add a command droid to a group");
return false;
}
if (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER)
{
debug(LOG_ERROR,
"scrGroupAdd: cannot add a transporter to a group");
return false;
}
psGroup->add(psDroid);
return true;
}
示例4: cmdDroidAddDroid
/** This function adds the droid to the command group commanded by psCommander.
* It creates a group if it doesn't exist.
* If the group is not full, it adds the droid to it and sets all the droid's states and orders to the group's.
*/
void cmdDroidAddDroid(DROID *psCommander, DROID *psDroid)
{
DROID_GROUP *psGroup;
if (psCommander->psGroup == NULL)
{
psGroup = grpCreate();
psGroup->add(psCommander);
psDroid->group = UBYTE_MAX;
}
if (psCommander->psGroup->getNumMembers() < cmdDroidMaxGroup(psCommander))
{
psCommander->psGroup->add(psDroid);
psDroid->group = UBYTE_MAX;
// set the secondary states for the unit
secondarySetState(psDroid, DSO_REPAIR_LEVEL, (SECONDARY_STATE)(psCommander->secondaryOrder & DSS_REPLEV_MASK), ModeImmediate);
secondarySetState(psDroid, DSO_ATTACK_LEVEL, (SECONDARY_STATE)(psCommander->secondaryOrder & DSS_ALEV_MASK), ModeImmediate);
orderDroidObj(psDroid, DORDER_GUARD, (BASE_OBJECT *)psCommander, ModeImmediate);
}
else
{
audio_PlayTrack( ID_SOUND_BUILD_FAIL );
addConsoleMessage(_("Commander needs a higher level to command more units"), DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
}
}
示例5: scrCBTransporterLandedB
bool scrCBTransporterLandedB( void )
{
SDWORD player;
DROID_GROUP *psGroup;
DROID *psTransporter, *psDroid, *psNext;
bool retval;
DROID **ppsTransp;
if (!stackPopParams(3, ST_GROUP, &psGroup, VAL_INT, &player,
VAL_REF|ST_DROID, &ppsTransp))
{
debug(LOG_ERROR, "scrCBTransporterLandedB(): stack failed");
return false;
}
psTransporter = transporterGetScriptCurrent();
if ( (psTransporter == NULL) ||
(psTransporter->player != (UDWORD)player) )
{
retval = false;
}
else
{
*ppsTransp = psTransporter; //return landed transporter
/* if not selectedPlayer unload droids */
//if ( (UDWORD)player != selectedPlayer )
//{
/* transfer droids from transporter group to current group */
for(psDroid=psTransporter->psGroup->psList; psDroid; psDroid=psNext)
{
psNext = psDroid->psGrpNext;
if ( psDroid != psTransporter )
{
psGroup->add(psDroid);
}
}
//}
retval = true;
}
scrFunctionResult.v.bval = retval;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
{
debug(LOG_ERROR, "scrCBTransporterLandedB: push landed");
return false;
}
return true;
}
示例6: scrvReleaseGroup
// release a ST_GROUP variable
void scrvReleaseGroup(INTERP_VAL *psVal)
{
DROID_GROUP *psGroup;
psGroup = (DROID_GROUP*)psVal->v.oval;
psGroup->removeAll();
ASSERT( psGroup->refCount == 1,
"scrvReleaseGroup: ref count is wrong" );
// do a final Remove to free the group
psGroup->remove(NULL);
}
示例7: js_groupAddDroid
static QScriptValue js_groupAddDroid(QScriptContext *context, QScriptEngine *engine)
{
int groupId = context->argument(0).toInt32();
DROID_GROUP *psGroup = grpFind(groupId);
QScriptValue droidVal = context->argument(1);
int droidId = droidVal.property("id").toInt32();
int droidPlayer = droidVal.property("player").toInt32();
DROID *psDroid = IdToDroid(droidId, droidPlayer);
SCRIPT_ASSERT(context, psGroup, "Invalid group index %d", groupId);
SCRIPT_ASSERT(context, psDroid, "Invalid droid index %d", droidId);
psGroup->add(psDroid);
return QScriptValue();
}
示例8: scrCBTransporterLanded
bool scrCBTransporterLanded( void )
{
SDWORD player;
DROID_GROUP *psGroup;
DROID *psTransporter, *psDroid, *psNext;
bool retval;
if (!stackPopParams(2, ST_GROUP, &psGroup, VAL_INT, &player))
{
return false;
}
psTransporter = transporterGetScriptCurrent();
if ( (psTransporter == NULL) ||
(psTransporter->player != (UDWORD)player) )
{
retval = false;
}
else
{
/* if not selectedPlayer unload droids */
if ( (UDWORD)player != selectedPlayer )
{
/* transfer droids from transporter group to current group */
for(psDroid=psTransporter->psGroup->psList; psDroid; psDroid=psNext)
{
psNext = psDroid->psGrpNext;
if ( psDroid != psTransporter )
{
psGroup->add(psDroid);
}
}
}
retval = true;
}
scrFunctionResult.v.bval = retval;
if (!stackPushResult(VAL_BOOL, &scrFunctionResult))
{
return false;
}
return true;
}
示例9: scrSetGroupSecondary
// set the secondary state for a droid
bool scrSetGroupSecondary(void)
{
DROID_GROUP *psGroup;
SECONDARY_ORDER sec;
SECONDARY_STATE state;
if (!stackPopParams(3, ST_GROUP, &psGroup, VAL_INT, &sec, VAL_INT, &state))
{
return false;
}
ASSERT(psGroup != NULL,
"scrSetGroupSecondary: invalid group pointer");
psGroup->setSecondary(sec, state);
return true;
}
示例10: js_groupAddArea
static QScriptValue js_groupAddArea(QScriptContext *context, QScriptEngine *engine)
{
int groupId = context->argument(0).toInt32();
int player = engine->globalObject().property("me").toInt32();
int x1 = context->argument(1).toInt32();
int y1 = context->argument(2).toInt32();
int x2 = context->argument(3).toInt32();
int y2 = context->argument(4).toInt32();
DROID_GROUP *psGroup = grpFind(groupId);
SCRIPT_ASSERT(context, psGroup, "Invalid group index %d", groupId);
for (DROID *psDroid = apsDroidLists[player]; psGroup && psDroid; psDroid = psDroid->psNext)
{
if (psDroid->pos.x >= x1 && psDroid->pos.x <= x2 && psDroid->pos.y >= y1 && psDroid->pos.y <= y2
&& psDroid->droidType != DROID_COMMAND && psDroid->droidType != DROID_TRANSPORTER)
{
psGroup->add(psDroid);
}
}
return QScriptValue();
}
示例11: scrOrderGroupObj
// Give a group an order to an object
bool scrOrderGroupObj(void)
{
DROID_GROUP *psGroup;
DROID_ORDER order;
BASE_OBJECT *psObj;
if (!stackPopParams(3, ST_GROUP, &psGroup, VAL_INT, &order, ST_BASEOBJECT, &psObj))
{
return false;
}
ASSERT(psGroup != NULL,
"scrOrderGroupObj: Invalid group pointer");
ASSERT(psObj != NULL,
"scrOrderGroupObj: Invalid object pointer");
if (order != DORDER_ATTACK &&
order != DORDER_HELPBUILD &&
order != DORDER_DEMOLISH &&
order != DORDER_REPAIR &&
order != DORDER_OBSERVE &&
order != DORDER_EMBARK &&
order != DORDER_FIRESUPPORT &&
order != DORDER_DROIDREPAIR)
{
ASSERT(false,
"scrOrderGroupObj: Invalid order");
return false;
}
debug(LOG_NEVER, "group %p (%u) order %d, obj type %d player %d id %d",
psGroup, psGroup->getNumMembers(), order, psObj->type, psObj->player, psObj->id);
psGroup->orderGroup(order, psObj);
return true;
}
示例12: scrOrderGroupLoc
// Give a group an order to a location
bool scrOrderGroupLoc(void)
{
DROID_GROUP *psGroup;
DROID_ORDER order;
SDWORD x, y;
if (!stackPopParams(4, ST_GROUP, &psGroup, VAL_INT, &order, VAL_INT, &x, VAL_INT, &y))
{
return false;
}
ASSERT(psGroup != NULL,
"scrOrderGroupLoc: Invalid group pointer");
if (order != DORDER_MOVE &&
order != DORDER_SCOUT)
{
ASSERT(false,
"scrOrderGroupLoc: Invalid order");
return false;
}
if (x < 0
|| x > world_coord(mapWidth)
|| y < 0
|| y > world_coord(mapHeight))
{
ASSERT(false, "Invalid map location (%d, %d), max is (%d, %d)", x, y, world_coord(mapWidth), world_coord(mapHeight));
return false;
}
debug(LOG_NEVER, "group %p (%u) order %d (%d,%d)",
psGroup, psGroup->getNumMembers(), order, x, y);
psGroup->orderGroup(order, (UDWORD)x, (UDWORD)y);
return true;
}
示例13: scrValDefLoad
/// default value load routine
bool scrValDefLoad(INTERP_VAL *psVal, WzConfig &ini)
{
DROID *psCDroid;
SDWORD index, members;
UDWORD id;
LEVEL_DATASET *psLevel;
DROID_GROUP *psGroup = NULL;
switch ((unsigned)psVal->type) // Unsigned cast to suppress compiler warnings due to enum abuse.
{
case ST_INTMESSAGE:
if (ini.contains("data"))
{
psVal->v.oval = (void*)getViewData(ini.value("data").toString().toAscii().constData());
}
else
{
psVal->v.oval = NULL;
}
break;
case ST_BASEOBJECT:
case ST_DROID:
case ST_STRUCTURE:
case ST_FEATURE:
if (ini.contains("data"))
{
psVal->v.oval = (void*)getBaseObjFromId(ini.value("data").toInt());
}
else
{
psVal->v.oval = NULL;
}
break;
case ST_BASESTATS:
case ST_COMPONENT:
break;
case ST_STRUCTURESTAT:
index = 0;
if (ini.contains("data"))
{
index = getStructStatFromName(ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug( LOG_FATAL, "Could not find stat");
index = 0;
}
}
psVal->v.ival = index;
break;
case ST_FEATURESTAT:
index = 0;
if (ini.contains("data"))
{
index = getFeatureStatFromName(ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug( LOG_FATAL, "Could not find stat");
index = 0;
}
}
psVal->v.ival = index;
break;
case ST_BODY:
index = getCompFromResName(COMP_BODY, ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug(LOG_FATAL, "Could not find body component");
index = 0;
}
psVal->v.ival = index;
break;
case ST_PROPULSION:
index = getCompFromResName(COMP_PROPULSION, ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug(LOG_FATAL, "Could not find propulsion component");
index = 0;
}
psVal->v.ival = index;
break;
case ST_ECM:
index = getCompFromResName(COMP_ECM, ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug(LOG_FATAL, "Could not find ECM component");
index = 0;
}
psVal->v.ival = index;
break;
case ST_SENSOR:
index = getCompFromResName(COMP_SENSOR, ini.value("data").toString().toAscii().constData());
if (index == -1)
{
debug(LOG_FATAL, "Could not find sensor component");
index = 0;
}
psVal->v.ival = index;
break;
case ST_CONSTRUCT:
//.........这里部分代码省略.........
示例14: scrValDefLoad
/// default value load routine
bool scrValDefLoad(SDWORD version, INTERP_VAL *psVal, char *pBuffer, UDWORD size)
{
char *pPos;
DROID *psCDroid;
SDWORD index, members, savedMembers;
UDWORD id;
LEVEL_DATASET *psLevel;
DROID_GROUP *psGroup = NULL;
const char *pName;
bool bObjectDefined;
switch ((unsigned)psVal->type) // Unsigned cast to suppress compiler warnings due to enum abuse.
{
case ST_INTMESSAGE:
if ((size == 1) &&
(*pBuffer == 0))
{
psVal->v.oval = NULL;
}
else
{
psVal->v.oval = (void*)getViewData(pBuffer);
if (psVal->v.oval == NULL)
{
return false;
}
}
break;
case ST_BASEOBJECT:
case ST_DROID:
case ST_STRUCTURE:
case ST_FEATURE:
id = *((UDWORD *)pBuffer);
endian_udword(&id);
if (id == UDWORD_MAX)
{
psVal->v.oval = NULL;
}
else
{
psVal->v.oval = (void*)getBaseObjFromId(id);
if (!psVal->v.oval)
{
debug(LOG_ERROR, "Could not find object id %d", id);
}
}
break;
case ST_BASESTATS:
case ST_COMPONENT:
break;
case ST_STRUCTURESTAT:
index = getStructStatFromName(pBuffer);
if (index == -1)
{
debug( LOG_FATAL, "scrValDefLoad: couldn't find structure stat %s", pBuffer );
abort();
index = 0;
}
psVal->v.ival = index;
break;
case ST_FEATURESTAT:
index = getFeatureStatFromName(pBuffer);
if (index == -1)
{
debug( LOG_FATAL, "scrValDefLoad: couldn't find feature stat %s", pBuffer );
abort();
index = 0;
}
psVal->v.ival = index;
break;
case ST_BODY:
index = getCompFromResName(COMP_BODY, pBuffer);
if (index == -1)
{
debug( LOG_FATAL, "scrValDefLoad: couldn't find body component %s", pBuffer );
abort();
index = 0;
}
psVal->v.ival = index;
break;
case ST_PROPULSION:
index = getCompFromResName(COMP_PROPULSION, pBuffer);
if (index == -1)
{
debug( LOG_FATAL, "scrValDefLoad: couldn't find propulsion component %s", pBuffer );
abort();
index = 0;
}
psVal->v.ival = index;
break;
case ST_ECM:
index = getCompFromResName(COMP_ECM, pBuffer);
if (index == -1)
{
debug( LOG_FATAL, "scrValDefLoad: couldn't find ECM component %s", pBuffer );
abort();
index = 0;
}
//.........这里部分代码省略.........