本文整理汇总了C++中BinTree::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ BinTree::Add方法的具体用法?C++ BinTree::Add怎么用?C++ BinTree::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinTree
的用法示例。
在下文中一共展示了BinTree::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveDeadTransports
//
// FindTransports
//
// Find a suitable list of transports for this squad
//
void Transport::Manager::FindTransports(Script &script)
{
// We have a number of slots we need (provided by the number of units in the squad)
// Use the transports closest to the squad first
U32 slots = script.GetSquad()->GetList().GetCount();
BinTree<Transport, F32> transports;
// Get the current location of the suqad
Vector location;
if (script.GetSquad()->GetLocation(location))
{
// Make sure that there's no dead transports lingering around
RemoveDeadTransports();
// Sort the transports by distance from the squad
for (NBinTree<Transport>::Iterator i(&idle); *i; i++)
{
transports.Add((location - (**i)->Origin()).Magnitude2(), *i);
}
// Now itereate the sorted transports and assign them to the script
for (BinTree<Transport, F32>::Iterator t(&transports); *t; t++)
{
Transport &transport = **t;
// Assign this transport to the script
transport.AssignToSquad(&script);
// How many slots does this transport provide ?
U32 available = transport->TransportType()->GetSpaces();
if (available >= slots)
{
slots = 0;
break;
}
// We still have slots to go .. keep looking
slots -= available;
}
// We're out of transports, did we get enough ?
if (slots)
{
// We didn't get enough, notify the script
script.Notify(0x3BBBD1F7); // "Transport::NotEnough"
}
else
{
// We got enough, notify the script
script.Notify(0x9BA84E05); // "Transport::Enough"
}
transports.UnlinkAll();
}
}
示例2: ProcessCreateCursor
//
// Process a CreateCursor scope
//
void ProcessCreateCursor(FScope *fScope)
{
// Cursor name is first argument
const char *name = fScope->NextArgString();
// Cursor class is second argument
const char *cls = fScope->NextArgString();
// Create the cursor
Base *newCrs = NULL;
U32 key = Crc::CalcStr(cls);
switch (key)
{
case 0x5B2A0A5F: // "Null"
newCrs = new Base;
break;
case 0xE04B5BBC: // "Bitmap"
newCrs = new Bmp;
break;
case 0xE5A51519: // "Geometric"
newCrs = new Geometric;
break;
default:
{
Base *derived;
if ((derived = cursors.Find(key)) != NULL)
{
newCrs = new Derived(derived);
}
else
{
LOG_ERR(("Unknown Cursor Class [%s]", cls));
return;
}
break;
}
}
// Configure the cursor
newCrs->Configure(fScope);
// Add it to the list
cursors.Add(Crc::CalcStr(name), newCrs);
}
示例3: Type
///////////////////////////////////////////////////////////////////////////////
//
// Quake::Type constructor
//
Type( FScope * fScope)
{
name = StdLoad::TypeString( fScope);
Effects::Data data;
FScope * sScope;
while ((sScope = fScope->NextFunction()) != NULL)
{
switch (sScope->NameCrc())
{
default:
{
// effects helper structure
//
if (data.Configure( sScope))
{
lifeTime = data.lifeTime;
sound = data.objectId;
}
break;
}
case 0x9FECAD2F: // "QuakeKey"
{
F32 f, i, s;
f = StdLoad::TypeF32( sScope); // frame
i = StdLoad::TypeF32( sScope); // intensity
s = StdLoad::TypeF32( sScope); // speed
keys.Append( new QuakeKey( f, i, s));
break;
}
//
} // switch
}
ASSERT( keys.GetCount() >= 2);
keys.PostLoad(); // initialize
typeList.Add( name.crc, this);
}