void DifficultyManager::LoadDefaultDifficultySettings() { DM_LOG( LC_DIFFICULTY, LT_INFO )LOGSTRING( "Trying to load default difficulty settings from entityDefs.\r" ); // Construct the entityDef name (e.g. atdm:difficulty_settings_default) idStr defName( DEFAULT_DIFFICULTY_ENTITYDEF ); const idDict *difficultyDict = gameLocal.FindEntityDefDict( defName, true ); // grayman #3391 - don't create a default 'difficultyDict' // We want 'false' here, but FindEntityDefDict() // will print its own warning, so let's not // clutter the console with a redundant message if( difficultyDict != NULL ) { DM_LOG( LC_DIFFICULTY, LT_DEBUG )LOGSTRING( "Found difficulty settings: %s.\r", defName.c_str() ); // greebo: Try to lookup the entityDef for each difficulty level and load the settings for( int i = 0; i < DIFFICULTY_COUNT; i++ ) { // Let the setting structure know which level it is referring to _globalSettings[i].SetLevel( i ); // And load the settings _globalSettings[i].LoadFromEntityDef( *difficultyDict ); // Load the CVAR settings too _cvarSettings[i].SetLevel( i ); _cvarSettings[i].LoadFromEntityDef( *difficultyDict ); } } else { for( int i = 0; i < DIFFICULTY_COUNT; i++ ) { _globalSettings[i].Clear(); _cvarSettings[i].Clear(); } gameLocal.Warning( "DifficultyManager: Could not find default difficulty entityDef!" ); } }
bool MeleeCombatTask::Perform(Subsystem& subsystem) { DM_LOG(LC_AI, LT_INFO)LOGSTRING("Melee Combat Task performing.\r"); idAI* ownerEnt = _owner.GetEntity(); assert(ownerEnt != NULL); idActor* enemy = _enemy.GetEntity(); if ( ( enemy == NULL ) || enemy->IsKnockedOut() || ( enemy->health <= 0 ) ) { DM_LOG(LC_AI, LT_DEBUG)LOGSTRING("No enemy, terminating task!\r"); return true; // terminate me } // Perform the task according to the current action EMeleeActState actState = ownerEnt->m_MeleeStatus.m_ActionState; switch (actState) { case MELEEACTION_READY: PerformReady(ownerEnt); break; case MELEEACTION_ATTACK: PerformAttack(ownerEnt); break; case MELEEACTION_PARRY: PerformParry(ownerEnt); break; default: PerformReady(ownerEnt); }; return false; // not finished yet }
void DifficultySettings::ApplySettings(idDict& target) { std::string eclass = target.GetString("classname"); if (eclass.empty()) { return; // no classname, no rules } // greebo: First, get the list of entity-specific difficulty settings from the dictionary // Everything processed here will be ignored in the second run (where the default settings are applied) idList<Setting> entSettings = Setting::ParseSettingsFromDict(target, _level); DM_LOG(LC_DIFFICULTY, LT_DEBUG)LOGSTRING("Found %d difficulty settings on the entity %s.\r", entSettings.Num(), target.GetString("name")); // Apply the settings one by one for (int i = 0; i < entSettings.Num(); i++) { DM_LOG(LC_DIFFICULTY, LT_DEBUG)LOGSTRING("Applying entity-specific setting: %s => %s.\r", entSettings[i].spawnArg.c_str(), entSettings[i].argument.c_str()); entSettings[i].Apply(target); } // Second step: apply global settings // Get the inheritancechain for the given target dict const InheritanceChain &inheritanceChain = GetInheritanceChain(target); // Go through the inheritance chain front to back and apply the settings for (InheritanceChain::const_iterator c = inheritanceChain.begin(); c != inheritanceChain.end(); ++c) { std::string className = *c; // Process the list of default settings that apply to this entity class, // but ignore all keys that have been addressed by the entity-specific settings. for (SettingsMap::iterator i = _settings.find(className); i != _settings.upper_bound(className) && i != _settings.end(); ++i) { Setting& setting = i->second; bool settingApplicable = true; // Check if the spawnarg has been processed in the entity-specific settings for (int k = 0; k < entSettings.Num(); k++) { if (entSettings[k].spawnArg == setting.spawnArg) { // This target spawnarg has already been processed in the first run, skip it DM_LOG(LC_DIFFICULTY, LT_DEBUG)LOGSTRING("Ignoring global setting: %s => %s.\r", setting.spawnArg.c_str(), setting.argument.c_str()); settingApplicable = false; break; } } if (settingApplicable) { // We have green light, apply the setting DM_LOG(LC_DIFFICULTY, LT_DEBUG)LOGSTRING("Applying global setting: %s => %s.\r", setting.spawnArg.c_str(), setting.argument.c_str()); setting.Apply(target); } } } }
bool CStimResponse::CheckChance() { if( m_Chance < 1.0f ) { // Chance timer still active? if( m_NextChanceTime > gameLocal.GetTime() ) { DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "CStimResponse::checkChance: Timeout still active.\r" ); // Next chance time is still in the future, return false return false; } // The stim only fires if the (hopefully uniformly distributed) // random variable is within the interval (0, m_Chance] if( gameLocal.random.RandomFloat() <= m_Chance ) { // Reset the next chance time m_NextChanceTime = -1; return true; } else { DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "CStimResponse::checkChance: Chance test failed.\r" ); // Test failed, should we use a timeout? if( m_ChanceTimer > 0 ) { // Save the earliest time of the next response chance m_NextChanceTime = gameLocal.GetTime() + m_ChanceTimer; } return false; } } else { // 100% chance => return true return true; } }
void DifficultyManager::Init( idMapFile *mapFile ) { DM_LOG( LC_DIFFICULTY, LT_INFO )LOGSTRING( "Searching for difficulty setting on worldspawn.\r" ); if( mapFile->GetNumEntities() <= 0 ) { return; // no entities! } // Fetch the worldspawn idMapEntity *mapEnt = mapFile->GetEntity( 0 ); idDict spawnArgs = mapEnt->epairs; int mapDifficulty; if( spawnArgs.GetInt( "difficulty", "0", mapDifficulty ) ) { // We have a difficulty spawnarg set on the map's worldspawn, take it as override value DM_LOG( LC_DIFFICULTY, LT_DEBUG )LOGSTRING( "Found overriding difficulty setting on worldspawn entity: %d.\r", mapDifficulty ); _difficulty = mapDifficulty; } // Check for the CVAR, which might override any setting if( cv_tdm_difficulty.GetInteger() >= 0 ) { _difficulty = cv_tdm_difficulty.GetInteger(); DM_LOG( LC_DIFFICULTY, LT_DEBUG )LOGSTRING( "Found overriding CVAR 'tdm_difficulty': %d.\r", _difficulty ); } // Clear the CVAR settings before parsing for( int i = 0; i < DIFFICULTY_COUNT; i++ ) { _cvarSettings[i].Clear(); } // Load the default difficulty settings from the entityDefs LoadDefaultDifficultySettings(); LoadMapDifficultySettings( mapFile ); }
void ConversationSystem::ProcessConversations() { // Remove the dying conversations first for( int i = 0; i < _dyingConversations.Num(); i++ ) { // Remove the dying index from the active conversations list _activeConversations.Remove( _dyingConversations[i] ); } _dyingConversations.Clear(); // What remains is a list of active conversations for( int i = 0; i < _activeConversations.Num(); i++ ) { ConversationPtr conv = GetConversation( _activeConversations[i] ); assert( conv != NULL ); // Let the conversation do its job if( !conv->Process() ) { // Job returned false, terminate this conversation DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "Terminating conversation %s due to error.\r", conv->GetName().c_str() ); EndConversation( _activeConversations[i] ); continue; } // Check if the conversation is done if( conv->IsDone() ) { // Job returned false, terminate this conversation DM_LOG( LC_CONVERSATION, LT_INFO )LOGSTRING( "Conversation %s finished normally.\r", conv->GetName().c_str() ); EndConversation( _activeConversations[i] ); continue; } } }
void CStimResponseCollection::InitFromSpawnargs(const idDict& args, idEntity* owner) { if (owner == NULL) { DM_LOG(LC_STIM_RESPONSE, LT_ERROR)LOGSTRING("Owner set to NULL is not allowed!\r"); return; } idStr name; for (int i = 1; /* in-loop break */; ++i) { idStr name = va("sr_class_%u", i); DM_LOG(LC_STIM_RESPONSE, LT_DEBUG)LOGSTRING("Looking for %s\r", name.c_str()); idStr str; if (!args.GetString(name, "X", str)) { break; } char sr_class = str[0]; if (ParseSpawnArg(args, owner, sr_class, i) == false) { break; } } }
bool PathWaitTask::Perform(Subsystem& subsystem) { DM_LOG(LC_AI, LT_INFO)LOGSTRING("PathWaitTask performing.\r"); idPathCorner* path = _path.GetEntity(); idAI* owner = _owner.GetEntity(); // This task may not be performed with empty entity pointers assert(path != NULL && owner != NULL); if (gameLocal.time >= _endtime) { // Trigger path targets, now that we're done waiting // grayman #3670 - need to keep the owner->Activate() calls to not break // existing maps, but the intent was path->Activate(). owner->ActivateTargets(owner); path->ActivateTargets(owner); // NextPath(); // Wait is done, fall back to PatrolTask DM_LOG(LC_AI, LT_INFO)LOGSTRING("Wait is done.\r"); return true; // finish this task } return false; }
bool MoveToCoverTask::Perform(Subsystem& subsystem) { DM_LOG(LC_AI, LT_INFO)LOGSTRING("Move to Cover Task performing.\r"); idAI* owner = _owner.GetEntity(); // This task may not be performed with empty entity pointer assert(owner != NULL); if (owner->AI_DEST_UNREACHABLE) { //TODO DM_LOG(LC_AI, LT_INFO)LOGSTRING("Destination unreachable.\r"); return true; } if (owner->AI_MOVE_DONE) { // Move is done, DM_LOG(LC_AI, LT_INFO)LOGSTRING("Move is done.\r"); owner->TurnToward(owner->lastVisibleEnemyPos); // finish this task return true; } return false; // not finished yet }
void CMissionManager::UninstallMod() { // To uninstall the current FM, just clear the FM name in currentfm.txt WriteCurrentFmFile(""); #if 0 // Path to the darkmod directory fs::path darkmodPath = GetDarkmodPath(); // Path to file that holds the current FM name fs::path currentFMPath(darkmodPath / cv_tdm_fm_current_file.GetString()); DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Trying to clear current FM name in %s\r", currentFMPath.file_string().c_str()); if (DoRemoveFile(currentFMPath)) { DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("Current FM file removed: %s.\r", currentFMPath.string().c_str()); } else { // Log removal error DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Caught exception while removing current FM file %s.\r", currentFMPath.string().c_str()); } #endif }
void CFrobLock::Event_TriggerUnlockTargets() { bool updateFrobability = spawnArgs.GetBool("update_target_frobability", "0"); for (const idKeyValue* kv = spawnArgs.MatchPrefix("unlock_target"); kv != NULL; kv = spawnArgs.MatchPrefix("unlock_target", kv)) { // Find the entity idEntity* unlockTarget = gameLocal.FindEntity(kv->GetValue()); if (unlockTarget == NULL) { DM_LOG(LC_LOCKPICK, LT_DEBUG)LOGSTRING("Could not find unlock target %s (this: %s)\r", kv->GetValue().c_str(), name.c_str()); continue; } DM_LOG(LC_LOCKPICK, LT_INFO)LOGSTRING("Activating unlock target %s\r", kv->GetValue().c_str()); unlockTarget->Activate(this); if (updateFrobability) { DM_LOG(LC_LOCKPICK, LT_INFO)LOGSTRING("Enabling unlock target frobability: %s\r", unlockTarget->name.c_str()); unlockTarget->SetFrobable(true); } } }
bool CMissionManager::DoCopyFile(const fs::path& source, const fs::path& dest, bool overwrite) { if (overwrite) { try { // According to docs, remove() doesn't throw if file doesn't exist fs::remove(dest); DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("Destination file %s already exists, has been removed before copying.\r", dest.string().c_str()); } catch (fs::filesystem_error& e) { // Don't care about removal error DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Caught exception while removing destination file %s: %s\r", dest.string().c_str(), e.what()); } } // Copy the source file to the destination try { fs::copy_file(source, dest); DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("File successfully copied to %s.\r", dest.string().c_str()); return true; } catch (fs::filesystem_error& e) { DM_LOG(LC_MAINMENU, LT_ERROR)LOGSTRING("Exception while coyping file from %s to %s: %s\r", source.string().c_str(), dest.string().c_str(), e.what()); return false; } }
// ---------------------------------------------------------------------------- // CSamplerPluginLoader::LoadRlibraryL // ---------------------------------------------------------------------------- // void CSamplerPluginLoader::LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray) { LOGSTRING("CSamplerPluginLoader rlibrary loading"); // Load dll iPluginArray = aPluginArray; RLibrary aLib; TInt ret = aLib.Load(_L("PIProfilerGenerals.dll"),_L("c:\\sys\\bin")); LOGSTRING2("RLibrary load returns %d", ret); User::LeaveIfError(ret); const TInt KNewLOrdinal = 2; TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal); if(!NewL) { RDebug::Printf("library.lookup returns null"); } else { LOGSTRING2("library.lookup returns 0x%x", NewL); //CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL(); CSamplerPluginInterface* mydll=(CSamplerPluginInterface*)NewL(); //Generals plugin loaded, samplers enabled. CleanupStack::PushL( mydll ); //InsertPluginInOrderL( mydll, aPluginArray); CleanupStack::Pop(mydll); // call engine to finalize the startup //TRAPD(result, iObserver->HandleSamplerControllerReadyL();); NotifyProgress(); //Begin CActive asynchronous loop. CompleteOwnRequest(); } LOGSTRING("RLibrary and plugins loaded"); }
void CResponseEffect::runScript(idEntity* owner, idEntity* stimEntity, float magnitude) { if (!_scriptFunctionValid) { if (owner == NULL) { DM_LOG(LC_STIM_RESPONSE, LT_ERROR)LOGSTRING("Cannot restore scriptfunction, owner is NULL: %s\r", _scriptName.c_str()); return; } _scriptFunctionValid = true; if (_localScript) { // Local scriptfunction _scriptFunction = owner->scriptObject.GetFunction(_scriptName.c_str()); } else { // Global Method _scriptFunction = gameLocal.program.FindFunction(_scriptName.c_str()); } } if ( _scriptFunction == NULL ) { return; } DM_LOG(LC_STIM_RESPONSE, LT_DEBUG)LOGSTRING("Running ResponseEffect Script %s, effectPostfix = %s...\r", _scriptFunction->Name(), _effectPostfix.c_str()); idThread *pThread = new idThread(_scriptFunction); int n = pThread->GetThreadNum(); pThread->CallFunctionArgs(_scriptFunction, true, "eesff", owner, stimEntity, _effectPostfix.c_str(), magnitude, n); pThread->DelayedStart(0); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::DDFVersionL // Returns ddf version nr // -------------------------------------------------------------------------- void CNSmlDmAOAdapter::DDFVersionL( CBufBase& aDDFVersion ) { LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL: Start" ); aDDFVersion.InsertL( 0, KNSmlDmAOAdapterDDFVersion ); LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL:End" ); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::AddNodeObjectL // Not supported // -------------------------------------------------------------------------- void CNSmlDmAOAdapter::AddNodeObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aParentLUID*/, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::AddNodeObjectL: Start" ); Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); LOGSTRING( "CNSmlDmAOAdapter::AddNodeObjectL: End" ); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::ConstructL // -------------------------------------------------------------------------- void CNSmlDmAOAdapter::ConstructL() { LOGSTRING( "CNSmlDmAOAdapter::CNSmlDmAOAdapter: Start" ); iSettingStore = CNSmlDmAOSettingStore::NewL( this ); LOGSTRING( "CNSmlDmAOAdapter::CNSmlDmAOAdapter: End" ); }
CMissionManager::InstallResult CMissionManager::InstallMod(const idStr& name) { CModInfoPtr info = GetModInfo(name); // result is always non-NULL const idStr& modName = info->modName; // Ensure that the target folder exists fs::path targetFolder = g_Global.GetModPath(modName.c_str()); if (!fs::create_directory(targetFolder)) { // Directory exists, not a problem, but log this DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("FM targetFolder already exists: %s\r", targetFolder.string().c_str()); } #if 0 // Path to the darkmod directory fs::path darkmodPath = GetDarkmodPath(); // greebo: We don't copy PK4s around anymore, they remain in the fms/ subfolders // Copy all PK4s from the FM folder (and all subdirectories) idFileList* pk4Files = fileSystem->ListFilesTree(info->pathToFMPackage, ".pk4", false); for (int i = 0; i < pk4Files->GetNumFiles(); ++i) { // Source file (full OS path) fs::path pk4fileOsPath = GetDarkmodPath() / pk4Files->GetFile(i); // Target location fs::path targetFile = targetFolder / pk4fileOsPath.leaf(); DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Copying file %s to %s\r", pk4fileOsPath.string().c_str(), targetFile.string().c_str()); // Use boost::filesystem instead of id's (comments state that copying large files can be problematic) //fileeSystem->CopyFile(pk4fileOsPath, targetFile.string().c_str()); // Copy the PK4 file and make sure any target file with the same name is removed beforehand if (!DoCopyFile(pk4fileOsPath, targetFile, true)) { // Failed copying return COPY_FAILURE; } } fileSystem->FreeFileList(pk4Files); #endif // Save the name to currentfm.txt WriteCurrentFmFile(modName); // taaaki: now that fms are loaded directly from <basepath>/darkmod/fms/ // we don't need to copy config files around (i.e. just use the // one in <basepath>/darkmod/ (same with config.spec) return INSTALLED_OK; }
CInventoryItemPtr CInventory::ValidateWeapon(idEntity* ent, const bool gotFromShop) // grayman (#2376) { // Sanity check if (ent == NULL) return CInventoryItemPtr(); idStr weaponName = ent->spawnArgs.GetString("inv_weapon_name"); if (weaponName.IsEmpty()) { // Not a weapon item return CInventoryItemPtr(); } // Entity has a weapon name set, check for match in our inventory // Find the weapon category CInventoryCategoryPtr weaponCategory = GetCategory(TDM_PLAYER_WEAPON_CATEGORY); if (weaponCategory == NULL) { DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Could not find weapon category in inventory.\r"); return CInventoryItemPtr(); } // Look for the weapon with the given name for (int i = 0; i < weaponCategory->GetNumItems(); i++) { CInventoryWeaponItemPtr weaponItem = boost::dynamic_pointer_cast<CInventoryWeaponItem>(weaponCategory->GetItem(i)); // Is this the right weapon? (must be a melee weapon, allowed empty) if (weaponItem != NULL && weaponItem->IsAllowedEmpty() && weaponItem->GetWeaponName() == weaponName) { DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Entity %s is matching the melee weapon %s.\r", ent->name.c_str(), weaponName.c_str()); // Enable this weapon if (!gotFromShop) // grayman (#2376) { weaponItem->SetEnabled(true); } if (!ent->spawnArgs.GetBool("inv_map_start", "0") && !ent->spawnArgs.GetBool("inv_no_pickup_message", "0")) { NotifyOwnerAboutPickup( common->Translate( ent->spawnArgs.GetString("inv_name") ), weaponItem); } // We're done return weaponItem; } } DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Couldn't find a match for weapon name: %s.\r", weaponName.c_str()); return CInventoryItemPtr(); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::~CNSmlDmAOAdapter // -------------------------------------------------------------------------- CNSmlDmAOAdapter::~CNSmlDmAOAdapter() { LOGSTRING( "CNSmlDmAOAdapter::~CNSmlDmAOAdapter: Start" ); //iBuffer.ResetAndDestroy(); //iBuffer.Close(); delete iSettingStore; LOGSTRING( "CNSmlDmAOAdapter::~CNSmlDmAOAdapter: End" ); }
// ------------------------------------------------------------------------- // CNSmlDmAOAdapter::ExecuteCommandL // Not supported // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::ExecuteCommandL( const TDesC8& /* aURI */, const TDesC8& /* aLUID */, RWriteStream*& /* aStream */, const TDesC8& /* aType */, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: Start" ); Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: End" ); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::FetchLeafObjectSizeL // Fetches leaf object size. // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& /* aType */, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: Start" ); LOGSTRING3( "\tFetchLeafObjectSizeL \tURI: %S, \tLUID: %S,", &aURI, &aLUID ); CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( ETrue, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetSizeCmd, LastURISeg( aURI ), KNullDesC8); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); // if executed get status if ( cmd->Executed() ) { Callback().SetStatusL( aStatusRef, cmd->Status() ); // if successful get results if ( cmd->Status() == CSmlDmAdapter::EOk ) { LOGSTRING2( "\tCmd executed with result: %S ", cmd->Data() ); CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() ); CleanupStack::PushL( result ); result->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *result, KNullDesC8 ); CleanupStack::PopAndDestroy( result ); } } else { // failed to execute command Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); } CleanupStack::PopAndDestroy( cmd ); LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: End" ); }
void CDownloadMenu::StartDownload( idUserInterface *gui ) { // Add a new download for each selected mission const DownloadableModList &mods = gameLocal.m_MissionManager->GetDownloadableMods(); for( int i = 0; i < _selectedMods.Num(); ++i ) { int missionIndex = _selectedMods[i]; if( missionIndex > mods.Num() ) { continue; } const DownloadableMod &mod = *mods[missionIndex]; // The filename is deduced from the mod name found on the website idStr targetPath = g_Global.GetDarkmodPath().c_str(); targetPath += "/"; targetPath += cv_tdm_fm_path.GetString(); // Final path to the FM file idStr missionPath = targetPath + mod.modName + ".pk4"; DM_LOG( LC_MAINMENU, LT_INFO )LOGSTRING( "Will download the mission PK4 to %s (modName %s).", missionPath.c_str(), mod.modName.c_str() ); // log all the URLs for( int u = 0; u < mod.missionUrls.Num(); u++ ) { DM_LOG( LC_MAINMENU, LT_INFO )LOGSTRING( " URL: '%s'", mod.missionUrls[u].c_str() ); } CDownloadPtr download( new CDownload( mod.missionUrls, missionPath, true ) ); // gnartsch: In case only the language pack needs to be downloaded, do not add the mission itself to the download list. // In that case we did not add any urls for the mission itself anyway. int id = -1; if( mod.missionUrls.Num() > 0 ) { // Check for valid PK4 files after download id = gameLocal.m_DownloadManager->AddDownload( download ); } int l10nId = -1; // Check if there is a Localisation pack available if( mod.l10nPackUrls.Num() > 0 ) { DM_LOG( LC_MAINMENU, LT_INFO )LOGSTRING( "There are l10n pack URLs listed for this FM." ); for( int u = 0; u < mod.l10nPackUrls.Num(); u++ ) { DM_LOG( LC_MAINMENU, LT_INFO )LOGSTRING( " l10n pack URL: '%s'", mod.l10nPackUrls[u].c_str() ); } idStr l10nPackPath = targetPath + mod.modName + "_l10n.pk4"; DM_LOG( LC_MAINMENU, LT_INFO )LOGSTRING( "Will download the l10n pack to %s.", l10nPackPath.c_str() ); CDownloadPtr l10nDownload( new CDownload( mod.l10nPackUrls, l10nPackPath, true ) ); l10nId = gameLocal.m_DownloadManager->AddDownload( l10nDownload ); // Relate these two downloads, so that they might be handled as pair // gnartsch: In case only the language pack needs to be downloaded, we can ignore the mission itself if( id > 0 ) { download->SetRelatedDownloadId( l10nId ); } else { id = l10nId; l10nId = -1; } } // Store these IDs for later reference _downloads[missionIndex] = MissionDownload( id, l10nId ); } // Let the download manager start its downloads gameLocal.m_DownloadManager->ProcessDownloads(); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::NewL // -------------------------------------------------------------------------- CNSmlDmAOAdapter* CNSmlDmAOAdapter::NewL( MSmlDmCallback* aDmCallback ) { LOGSTRING("CNSmlDmAOAdapter::NewL: Start"); CNSmlDmAOAdapter* self = new (ELeave) CNSmlDmAOAdapter( aDmCallback ); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop( self ); LOGSTRING("CNSmlDmAOAdapter::NewL: End"); return self; }
// ------------------------------------------------------------------------- // CNSmlDmAOAdapter::CopyCommandL // Not supported // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::CopyCommandL( const TDesC8& /* aTargetURI */ , const TDesC8& /* aTargetLUID */ , const TDesC8& /* aSourceURI */ , const TDesC8& /* aSourceLUID */, const TDesC8& /* aType */ , TInt aStatusRef ) { //not supported LOGSTRING( "CNSmlDmAOAdapter::CopyCommandL: Sart" ); Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); LOGSTRING( "CNSmlDmAOAdapter::CopyCommandL: End" ); }
void CInventoryItem::RestoreItemEntityFromDict(const idVec3& entPosition) { if (!m_ItemDict) { return; // no saved spawnargs, do nothing } // We have an item dictionary, let's respawn our entity idEntity* ent; // grayman #3723 - When restoring items this way, it's possible // that the name of the object we're about to restore is the same // as an object in the map. If so, change the name of the restored object. idStr error; const char *name; if ( (*m_ItemDict).GetString( "name", "", &name ) ) { sprintf( error, " on '%s'", name); } // check if this name is already in use if (gameLocal.FindEntity(name)) { gameLocal.Warning("Multiple entities named '%s'", name); DM_LOG(LC_INIT, LT_INIT)LOGSTRING("WARNING - Multiple entities named '%s'\r", name); // Rename with a unique name. (*m_ItemDict).Set("name",va("%s_%d",name,gameLocal.random.RandomInt(1000))); } if (!gameLocal.SpawnEntityDef(*m_ItemDict, &ent)) { DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Can't respawn inventory item entity '%s'!\r", m_ItemDict->GetString("name")); gameLocal.Error("Can't respawn inventory item entity '%s'!", m_ItemDict->GetString("name")); } // Place the entity at the given position ent->SetOrigin(entPosition); // Hide the entity (don't delete it) CInventory::RemoveEntityFromMap(ent, false); // Set this as new item entity SetItemEntity(ent); // Finally, remove our saved spawnargs m_ItemDict.reset(); }
// ------------------------------------------------------------------------ // CNSmlDmAOAdapter::ChildURIListL // Fetches child nodes of a node. these may be either all VENDORCONFIG // nodes or leaf nodes under a VENDORCONFIG node. // ------------------------------------------------------------------------ void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" ); LOGSTRING3( "\tChildURIListL URI: %S, LUID: %S ", &aURI, &aLUID ); CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen ); CleanupStack::PushL( resultList ); // get all leaf nodes below VENDORCONFIG node if ( !aURI.Compare( KNSmlDmAOAdapterAO ) ) { CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( EFalse, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetCmd, KNullDesC8, KNullDesC8 ); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); if( cmd->Status() == CSmlDmAdapter::EOk ) { resultList->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *resultList, KNullDesC8 ); } CleanupStack::PopAndDestroy( cmd ); } CleanupStack::PopAndDestroy( resultList ); LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" ); }
void CShop::AddPersistentStartingEquipment() { const CInventory &sourceInventory = *gameLocal.persistentPlayerInventory; // Cycle through all categories to add them for( int c = 0; c < sourceInventory.GetNumCategories(); ++c ) { const CInventoryCategoryPtr &category = sourceInventory.GetCategory( c ); for( int itemIdx = 0; itemIdx < category->GetNumItems(); ++itemIdx ) { const CInventoryItemPtr &item = category->GetItem( itemIdx ); if( item->GetPersistentCount() <= 0 ) { DM_LOG( LC_MAINMENU, LT_DEBUG )LOGSTRING( "Item %s is not marked as persistent, won't add to shop.\r", item->GetName().c_str() ); continue; // not marked as persistent } const idDict *itemDict = item->GetSavedItemEntityDict(); if( itemDict == NULL ) { DM_LOG( LC_MAINMENU, LT_WARNING )LOGSTRING( "Item %s is marked as persistent, but has no saved item dictionary.\r", item->GetName().c_str() ); continue; } idStr className = itemDict->GetString( "classname" ); // Try to look up the corresponding shop item definition for this item's classname CShopItemPtr found = FindShopItemDefByClassName( className ); if( found == NULL ) { DM_LOG( LC_MAINMENU, LT_DEBUG )LOGSTRING( "Can't find shopitem definition for classname %s, skipping.\r", className.c_str() ); continue; } int quantity = GetQuantityForItem( item ); // Don't attempt to merge if we don't have anything to merge in the first place if( quantity == 0 ) { DM_LOG( LC_MAINMENU, LT_DEBUG )LOGSTRING( "Persistent weapon doesn't have ammo, skipping.\r", className.c_str() ); continue; } // Check if this is a weapon CInventoryWeaponItemPtr weaponItem = boost::dynamic_pointer_cast<CInventoryWeaponItem>( item ); bool isWeapon = ( weaponItem != NULL ); bool weaponIsAllowedEmpty = weaponItem ? weaponItem->IsAllowedEmpty() : false; bool itemMerged = MergeIntoStartingEquipment( className, quantity, isWeapon, weaponIsAllowedEmpty ); // Append the item to the list if it didn't contribute quantity to // an existing list item. if( !itemMerged ) { CShopItemPtr anItem( new CShopItem( *found, quantity, 0, false ) ); bool canDrop = itemDict->GetBool( "inv_droppable", "1" ); anItem->SetCanDrop( canDrop ); _startingItems.Append( anItem ); } } } }
ConversationStatePtr Conversation::GetConversationState( int actor ) { idAI *ai = GetActor( actor ); if( ai == NULL ) { DM_LOG( LC_CONVERSATION, LT_ERROR )LOGSTRING( "Conversation %s could not find actor.\r", _name.c_str() ); return ConversationStatePtr(); } // Let's see if the AI can handle this conversation command ConversationStatePtr convState = boost::dynamic_pointer_cast<ConversationState>( ai->GetMind()->GetState() ); if( convState == NULL ) { // AI is not in ConversationState anymore DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "Conversation %s: ai %s is not in conversation mode anymore.\r", _name.c_str(), ai->name.c_str() ); return ConversationStatePtr(); } return convState; }
TInt DMemSamplerImpl::CreateFirstSample() { LOGSTRING("MemSamplerImpl::CreateFirstSample - entry"); this->sampleDescriptor.Zero(); this->sampleDescriptor.Append(_L8("Bappea_V")); this->sampleDescriptor.Append(KMemVersion); this->sampleDescriptor.Append(_L8("_MEM")); sample[0] = this->sampleDescriptor.Size(); LOGSTRING("MemSamplerImpl::CreateFirstSample - exit"); return (TInt)(sample[0]+1); }