本文整理汇总了C++中idDict类的典型用法代码示例。如果您正苦于以下问题:C++ idDict类的具体用法?C++ idDict怎么用?C++ idDict使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了idDict类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTimer
void CStimResponseCollection::CreateTimer(const idDict& args, const CStimPtr& stim, int index)
{
CStimResponseTimer* timer = stim->GetTimer();
timer->m_Reload = args.GetInt(va("sr_timer_reload_%u", index) , "-1");
idStr str = args.GetString(va("sr_timer_type_%u", index), "");
timer->m_Type = (str == "RELOAD") ? CStimResponseTimer::SRTT_RELOAD : CStimResponseTimer::SRTT_SINGLESHOT;
args.GetString(va("sr_timer_time_%u", index), "0:0:0:0", str);
TimerValue val = CStimResponseTimer::ParseTimeString(str);
// if timer is actually set
if (val.Time.Hour || val.Time.Minute || val.Time.Second || val.Time.Millisecond)
{
// TODO: Return a bool here so that the outer function knows not to add this to m_Stim in the collection?
stim->AddTimerToGame();
timer->SetTimer(val.Time.Hour, val.Time.Minute, val.Time.Second, val.Time.Millisecond);
// timer starts on map startup by default, otherwise wait for start
if (!args.GetBool(va("sr_timer_waitforstart_%u", index), "0"))
{
timer->Start(static_cast<unsigned long>(sys->GetClockTicks()));
}
}
}
示例2: StripReactionPrefix
//
// stripReactionPrefix()
//
void hhReactionHandler::StripReactionPrefix(idDict &dict) {
const idKeyValue *kv = NULL;//dict.MatchPrefix("reaction");
idDict newDict;
for(int i=0;i<dict.GetNumKeyVals();i++) {
kv = dict.GetKeyVal(i);
idStr key;
key = kv->GetKey();
// Do we have a reaction token to strip out?
if(idStr::FindText(key.c_str(), "reaction") != -1) {
int endPrefix = idStr::FindChar(key.c_str(), '_');
if(endPrefix == -1) {
gameLocal.Error("reactionX_ prefix not found.");
}
idStr realKey(key);
realKey = key.Mid(endPrefix+1, key.Length() - endPrefix - 1);
key = realKey;
}
//dict.Delete(kv->GetKey().c_str());
newDict.Set(key.c_str(), kv->GetValue());
kv = dict.MatchPrefix("reaction", kv);
}
dict.Clear();
dict.Copy(newDict);
}
示例3: LoadState
/*
================
idAF::LoadState
================
*/
void idAF::LoadState( const idDict &args )
{
const idKeyValue *kv;
idStr name;
idAFBody *body;
idVec3 origin;
idAngles angles;
kv = args.MatchPrefix( "body ", NULL );
while( kv )
{
name = kv->GetKey();
name.Strip( "body " );
body = physicsObj.GetBody( name );
if( body )
{
sscanf( kv->GetValue(), "%f %f %f %f %f %f", &origin.x, &origin.y, &origin.z, &angles.pitch, &angles.yaw, &angles.roll );
body->SetWorldOrigin( origin );
body->SetWorldAxis( angles.ToMat3() );
}
else
{
gameLocal.DWarning( "Unknown body part %s in articulated figure %s", name.c_str(), this->name.c_str() );
}
kv = args.MatchPrefix( "body ", kv );
}
physicsObj.UpdateClipModels();
}
示例4: ParseSpawnargs
void CInventoryItem::ParseSpawnargs(const idDict& spawnArgs)
{
m_Persistent = spawnArgs.GetBool("inv_persistent", "0");
m_LightgemModifier = spawnArgs.GetInt("inv_lgmodifier", "0");
m_MovementModifier = spawnArgs.GetFloat("inv_movement_modifier", "1");
m_FrobDistanceCap = spawnArgs.GetFloat("inv_frob_distance_cap", "-1");
m_Icon = spawnArgs.GetString("inv_icon", "");
}
示例5: WriteDict
/*
================
idDemoFile::WriteDict
================
*/
void idDemoFile::WriteDict( const idDict &dict ) {
int i, c;
c = dict.GetNumKeyVals();
WriteInt( c );
for( i = 0; i < c; i++ ) {
WriteHashString( dict.GetKeyVal( i )->GetKey() );
WriteHashString( dict.GetKeyVal( i )->GetValue() );
}
}
示例6: MoveCVarsToDict
/*
============
idCVarSystemLocal::MoveCVarsToDict
============
*/
const idDict* idCVarSystemLocal::MoveCVarsToDict( int flags ) const {
moveCVarsToDict.Clear();
for( int i = 0; i < cvars.Num(); i++ ) {
idCVar *cvar = cvars[i];
if ( cvar->GetFlags() & flags ) {
moveCVarsToDict.Set( cvar->GetName(), cvar->GetString() );
}
}
return &moveCVarsToDict;
}
示例7: SetCVarsFromDict
/*
============
idCVarSystemLocal::SetCVarsFromDict
============
*/
void idCVarSystemLocal::SetCVarsFromDict( const idDict &dict ) {
idInternalCVar *internal;
for( int i = 0; i < dict.GetNumKeyVals(); i++ ) {
const idKeyValue *kv = dict.GetKeyVal( i );
internal = FindInternal( kv->GetKey() );
if ( internal ) {
internal->InternalServerSetString( kv->GetValue() );
}
}
}
示例8: ReadDict
/*
================
idDemoFile::ReadDict
================
*/
void idDemoFile::ReadDict( idDict &dict ) {
int i, c;
idStr key, val;
dict.Clear();
ReadInt( c );
for( i = 0; i < c; i++ ) {
key = ReadHashString();
val = ReadHashString();
dict.Set( key, val );
}
}
示例9: ParseFromDict
void Setting::ParseFromDict(const idDict& dict, int level, int index)
{
isValid = true; // in dubio pro reo
// Get the classname, target spawnarg and argument
className = dict.GetString(va(PATTERN_CLASS, level, index));
spawnArg = dict.GetString(va(PATTERN_CHANGE, level, index));
argument = dict.GetString(va(PATTERN_ARG, level, index));
// Parse the application type
appType = EAssign;
if (!argument.IsEmpty())
{
// Check for ignore argument
if (argument == APPTYPE_IGNORE)
{
appType = EIgnore;
argument.Empty(); // clear the argument
}
else if (argument.Find(' ') != -1)
{
// greebo: We have a space in the argument, hence it cannot be
// a mathematical operation. This usually applies to vector arguments
// like '-205 10 20', which can contain a leading minus sign.
}
// Check for special modifiers
else if (argument[0] == '+')
{
appType = EAdd;
// Remove the first character
argument = idStr(argument, 1, argument.Length());
}
else if (argument[0] == '*')
{
appType = EMultiply;
// Remove the first character
argument = idStr(argument, 1, argument.Length());
}
else if (argument[0] == '-')
{
appType = EAdd;
// Leave the "-" sign, it will be the sign of the parsed int
}
}
if (spawnArg.IsEmpty())
{
// Spawnarg must not be empty
isValid = false;
}
// classname can be empty (this is valid for entity-specific difficulties)
}
示例10: Setup
END_CLASS
/*
================
sdVehicleJointAimer::Setup
================
*/
bool sdVehicleJointAimer::Setup( sdTransport* _vehicle, const angleClamp_t& yaw, const angleClamp_t& pitch, const idDict& ikParms ) {
joint = INVALID_JOINT;
if ( !sdVehicleIKSystem::Setup( _vehicle, yaw, pitch, ikParms ) ) {
return false;
}
yawSound = NULL;
if ( clampYaw.sound != NULL ) {
yawSound = vehicle->GetMotorSounds().Alloc();
yawSound->Start( clampYaw.sound );
}
pitchSound = NULL;
if ( clampPitch.sound != NULL ) {
pitchSound = vehicle->GetMotorSounds().Alloc();
pitchSound->Start( clampPitch.sound );
}
idAnimator* animator = vehicle->GetAnimator();
joint = animator->GetJointHandle( ikParms.GetString( "joint" ) );
if ( joint == INVALID_JOINT ) {
return false;
}
animator->GetJointTransform( joint, gameLocal.time, baseAxis );
angles = baseAxis.ToAngles();
const char* weapon2Name = ikParms.GetString( "weapon2" );
if ( *weapon2Name ) {
weapon2 = _vehicle->GetWeapon( weapon2Name );
if ( !weapon2 ) {
gameLocal.Warning( "sdVehicleIKSystem::Setup Invalid Weapon '%s'", weapon2Name );
return false;
}
} else {
weapon2 = NULL;
}
return true;
}
示例11: GetInheritanceChain
DifficultySettings::InheritanceChain DifficultySettings::GetInheritanceChain(const idDict& dict)
{
std::string className = dict.GetString("classname");
// stgatilov: Look the class name up in the chains cache
InheritanceChainsMap::iterator it = _inheritanceChains.find(className);
if (it != _inheritanceChains.end())
return it->second;
InheritanceChain inheritanceChain;
// Add the classname itself to the end of the list
inheritanceChain.push_back(className);
// greebo: Extract the inherit value from the raw declaration text,
// as the "inherit" key has been removed in the given "dict"
for (std::string inherit = GetInheritValue(className);
!inherit.empty();
inherit = GetInheritValue(inherit))
{
// Has parent, add to list
inheritanceChain.push_back(inherit);
}
// stgatilov: reverse the chain so that parents go first
std::reverse(inheritanceChain.begin(), inheritanceChain.end());
// stgatilov: save the chain in cache
_inheritanceChains[className] = inheritanceChain;
return inheritanceChain;
}
示例12: ApplySettings
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);
}
}
}
}
示例13: InitFromSpawnargs
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;
}
}
}
示例14: SavePersistentData
/*
========================
idAchievementManager::SavePersistentData
========================
*/
void idAchievementManager::SavePersistentData( idDict& playerInfo )
{
for( int i = 0; i < ACHIEVEMENTS_NUM; ++i )
{
playerInfo.SetInt( va( "ach_%d", i ), counts[i] );
}
}
示例15: RestorePersistentData
/*
========================
idAchievementManager::RestorePersistentData
========================
*/
void idAchievementManager::RestorePersistentData( const idDict& spawnArgs )
{
for( int i = 0; i < ACHIEVEMENTS_NUM; ++i )
{
counts[i] = spawnArgs.GetInt( va( "ach_%d", i ), "0" );
}
}