// // Offer // // The given asset is being offered, do we want it ? // Bool Asset::Request::TypeBase::Offer(Asset &asset) { // Get the unit out of the asset UnitObj *unit = asset.GetUnit(); ASSERT(unit) // Do we have enough of this type ? U32 type = unit->GameType()->Id(); // We should only be offered this type if we asked for it ASSERT(config->GetAmount(type)) // How many of this type do we currently have ? U32 *amount = amounts.Find(type); // Is this less that what we need ? return ((!amount || *amount < config->GetAmount(type)) ? TRUE : FALSE); }
// // Accept // // The given asset has been accepted // void Asset::Request::TypeBase::Accept(Asset &asset, Bool primary) { if (primary) { // Add the object to the list which are assigned to us assigned.Append(&asset); } // Add this type to the amount tree U32 type = asset.GetUnit()->GameType()->Id(); U32 *amount = amounts.Find(type); if (amount) { (*amount)++; } else { amounts.Add(type, new U32(1)); } }