// // 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(); } }
// // 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); }
/////////////////////////////////////////////////////////////////////////////// // // 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); }