本文整理汇总了C++中log::Logger::Notice方法的典型用法代码示例。如果您正苦于以下问题:C++ Logger::Notice方法的具体用法?C++ Logger::Notice怎么用?C++ Logger::Notice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log::Logger
的用法示例。
在下文中一共展示了Logger::Notice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConsiderSpread
void IgnitableComponent::ConsiderSpread(int timeDelta) {
if (!onFire) return;
if (level.time < spreadAt) return;
fireLogger.Notice("Trying to spread.");
ForEntities<IgnitableComponent>([&](Entity &other, IgnitableComponent &ignitable){
if (&other == &entity) return;
// Don't re-ignite.
if (ignitable.onFire) return;
// TODO: Use LocationComponent.
float distance = G_Distance(other.oldEnt, entity.oldEnt);
if (distance > SPREAD_RADIUS) return;
float distanceFrac = distance / SPREAD_RADIUS;
float distanceMod = 1.0f - distanceFrac;
float spreadChance = distanceMod;
if (random() < spreadChance) {
if (G_LineOfSight(entity.oldEnt, other.oldEnt) && other.Ignite(fireStarter)) {
fireLogger.Notice("Ignited a neighbour, chance to do so was %.0f%%.",
spreadChance*100.0f);
}
}
});
// Don't spread again until re-ignited.
spreadAt = INT_MAX;
}
示例2: HandleIgnite
void IgnitableComponent::HandleIgnite(gentity_t* fireStarter) {
if (!fireStarter) {
// TODO: Find out why this happens.
fireLogger.Notice("Received ignite message with no fire starter.");
}
if (level.time < immuneUntil) {
fireLogger.Debug("Not ignited: Immune against fire.");
return;
}
// Start burning on initial ignition.
if (!onFire) {
onFire = true;
this->fireStarter = fireStarter;
fireLogger.Notice("Ignited.");
} else {
if (alwaysOnFire && !this->fireStarter) {
// HACK: Igniting an alwaysOnFire entity will initialize the fire starter.
this->fireStarter = fireStarter;
fireLogger.Debug("Firestarter set.");
} else {
fireLogger.Debug("Re-ignited.");
}
}
// Refresh ignite time even if already burning.
igniteTime = level.time;
// The spread delay follows a normal distribution: More likely to spread early than late.
int spreadTarget = level.time + (int)std::abs(normalDistribution(randomGenerator));
// Allow re-ignition to update the spread delay to a lower value.
if (spreadTarget < spreadAt) {
fireLogger.DoNoticeCode([&]{
int newDelay = spreadTarget - level.time;
if (spreadAt == INT_MAX) {
fireLogger.Notice("Spread delay set to %.1fs.", newDelay * 0.001f);
} else {
int oldDelay = spreadAt - level.time;
fireLogger.Notice("Spread delay updated from %.1fs to %.1fs.",
oldDelay * 0.001f, newDelay * 0.001f);
}
});
spreadAt = spreadTarget;
}
}
示例3: HandleIgnite
void IgnitableComponent::HandleIgnite(gentity_t* fireStarter) {
if (!fireStarter) {
// TODO: Find out why this happens.
fireLogger.Notice("Received ignite message with no fire starter.");
}
if (level.time < immuneUntil) {
fireLogger.Debug("Not ignited: Immune against fire.");
return;
}
// Refresh ignite time even if already burning.
igniteTime = level.time;
if (!onFire) {
onFire = true;
this->fireStarter = fireStarter;
fireLogger.Debug("Ignited.");
} else {
if (alwaysOnFire && !this->fireStarter) {
// HACK: Igniting an alwaysOnFire entity will initialize the fire starter.
this->fireStarter = fireStarter;
fireLogger.Debug("Firestarter initialized.");
} else {
fireLogger.Debug("Re-Ignited.");
}
}
}
示例4: HandleDie
void ResourceStorageComponent::HandleDie(gentity_t* killer, meansOfDeath_t meansOfDeath) {
// TODO: Add TeamComponent and/or Utility::Team.
team_t team = entity.oldEnt->buildableTeam;
float storedFraction = GetStoredFraction();
// Removes some of the owner's team's build points, proportional to the amount this structure
// acquired and the amount of health lost (before deconstruction).
float loss = (1.0f - entity.oldEnt->deconHealthFrac) * storedFraction *
level.team[team].buildPoints * g_buildPointLossFraction.value;
resourceStorageLogger.Notice(
"A resource storage died, removing %.0f BP from the team's pool "
"(%.1f × %.0f%% stored × %.0f%% health lost × %.0f total).",
loss, g_buildPointLossFraction.value, 100.0f * storedFraction,
100.0f * (1.0f - entity.oldEnt->deconHealthFrac), level.team[team].buildPoints
);
G_ModifyBuildPoints(team, -loss);
// Main structures keep their account of acquired build points across lifecycles, it's saved
// in a per-team variable and copied over to the ResourceStorageComponent whenever it's modified.
if (!entity.Get<MainBuildableComponent>()) {
G_ModifyTotalBuildPointsAcquired(team, -acquiredBuildPoints);
}
acquiredBuildPoints = 0.0f;
}
示例5: ConsiderStop
void IgnitableComponent::ConsiderStop(int timeDelta) {
if (!onFire) return;
// Don't stop freshly (re-)ignited fires.
if (igniteTime + MIN_BURN_TIME > level.time) {
fireLogger.DoDebugCode([&]{
int elapsed = level.time - igniteTime;
int remaining = MIN_BURN_TIME - elapsed;
fireLogger.Debug("Burning for %.1fs, skipping stop check for another %.1fs.",
(float)elapsed/1000.0f, (float)remaining/1000.0f);
});
return;
}
float averagePostMinBurnTime = BASE_AVERAGE_BURN_TIME - MIN_BURN_TIME;
// Increase average burn time dynamically for burning entities in range.
ForEntities<IgnitableComponent>([&](Entity &other, IgnitableComponent &ignitable){
if (&other == &entity) return;
if (!ignitable.onFire) return;
// TODO: Use LocationComponent.
float distance = G_Distance(other.oldEnt, entity.oldEnt);
if (distance > EXTRA_BURN_TIME_RADIUS) return;
float distanceFrac = distance / EXTRA_BURN_TIME_RADIUS;
float distanceMod = 1.0f - distanceFrac;
averagePostMinBurnTime += EXTRA_AVERAGE_BURN_TIME * distanceMod;
});
// The burn stop chance follows an exponential distribution.
float lambda = 1.0f / averagePostMinBurnTime;
float burnStopChance = 1.0f - std::exp(-1.0f * lambda * (float)timeDelta);
float averageTotalBurnTime = averagePostMinBurnTime + (float)MIN_BURN_TIME;
// Attempt to stop burning.
if (random() < burnStopChance) {
fireLogger.Notice("Stopped burning after %.1fs, target average lifetime was %.1fs.",
(float)(level.time - igniteTime) / 1000.0f, averageTotalBurnTime / 1000.0f);
entity.Extinguish(0);
return;
} else {
fireLogger.Debug("Burning for %.1fs, target average lifetime is %.1fs.",
(float)(level.time - igniteTime) / 1000.0f, averageTotalBurnTime / 1000.0f);
}
}
示例6: HandleDamage
//.........这里部分代码省略.........
}
// Update combat timers.
// TODO: Add a message to update combat timers.
if (client && source->client && entity.oldEnt != source) {
client->lastCombatTime = entity.oldEnt->client->lastCombatTime = level.time;
}
if (client) {
// Save damage w/o armor modifier.
client->damage_received += (int)(amount + 0.5f);
// Save damage direction.
if (direction) {
VectorCopy(direction.value().Data(), client->damage_from);
client->damage_fromWorld = false;
} else {
VectorCopy(entity.oldEnt->r.currentOrigin, client->damage_from);
client->damage_fromWorld = true;
}
// Drain jetpack fuel.
// TODO: Have another component handle jetpack fuel drain.
client->ps.stats[STAT_FUEL] = std::max(0, client->ps.stats[STAT_FUEL] -
(int)(amount + 0.5f) * JETPACK_FUEL_PER_DMG);
// If boosted poison every attack.
// TODO: Add a poison message and a PoisonableComponent.
if (source->client && (source->client->ps.stats[STAT_STATE] & SS_BOOSTED) &&
client->pers.team == TEAM_HUMANS && client->poisonImmunityTime < level.time) {
switch (meansOfDeath) {
case MOD_POISON:
case MOD_LEVEL2_ZAP:
break;
default:
client->ps.stats[STAT_STATE] |= SS_POISONED;
client->lastPoisonTime = level.time;
client->lastPoisonClient = source;
break;
}
}
}
healthLogger.Notice("Taking damage: %3.1f (%3.1f → %3.1f)", take, health, health - take);
// Do the damage.
health -= take;
// Update team overlay info.
if (client) client->pers.infoChangeTime = level.time;
// TODO: Move lastDamageTime to HealthComponent.
entity.oldEnt->lastDamageTime = level.time;
// HACK: gentity_t.nextRegenTime only affects alien clients.
// TODO: Catch damage message in a new RegenerationComponent.
entity.oldEnt->nextRegenTime = level.time + ALIEN_CLIENT_REGEN_WAIT;
// Handle non-self damage.
if (entity.oldEnt != source) {
float loss = take;
if (health < 0.0f) loss += health;
// TODO: Use ClientComponent.
if (source->client) {
// Add to the attacker's account on the target.
// TODO: Move damage account array to HealthComponent.
entity.oldEnt->credits[source->client->ps.clientNum].value += loss;
entity.oldEnt->credits[source->client->ps.clientNum].time = level.time;
entity.oldEnt->credits[source->client->ps.clientNum].team = (team_t)source->client->pers.team;
}
}
// Handle death.
// TODO: Send a Die/Pain message and handle details where appropriate.
if (health <= 0) {
healthLogger.Notice("Dying with %.1f health.", health);
// Disable knockback.
if (client) entity.oldEnt->flags |= FL_NO_KNOCKBACK;
// Call legacy die function.
if (entity.oldEnt->die) entity.oldEnt->die(entity.oldEnt, source, source, meansOfDeath);
// Send die message.
entity.Die(source, meansOfDeath);
// Trigger ON_DIE event.
if(!client) G_EventFireEntity(entity.oldEnt, source, ON_DIE);
} else if (entity.oldEnt->pain) {
entity.oldEnt->pain(entity.oldEnt, source, (int)std::ceil(take));
}
if (entity.oldEnt != source && source->client) {
bool lethal = (health <= 0);
CombatFeedback::HitNotify(source, entity.oldEnt, location, take, meansOfDeath, lethal);
}
}