status_t SharedBufferClient::queue(int buf) { RWLock::AutoRLock _rd(mLock); SharedBufferStack& stack( *mSharedStack ); queued_head = (queued_head + 1) % mNumBuffers; stack.index[queued_head] = buf; QueueUpdate update(this); status_t err = updateCondition( update ); LOGD_IF(DEBUG_ATOMICS, "queued=%d, %s", buf, dump("").string()); const nsecs_t now = systemTime(SYSTEM_TIME_THREAD); stack.stats.totalTime = ns2us(now - mDequeueTime[buf]); return err; }
void ConditionLight::addCondition(Creature* creature, const Condition* addCondition) { if(updateCondition(addCondition)) { setTicks(addCondition->getTicks()); const ConditionLight& conditionLight = static_cast<const ConditionLight&>(*addCondition); lightInfo.level = conditionLight.lightInfo.level; lightInfo.color = conditionLight.lightInfo.color; lightChangeInterval = getTicks() / lightInfo.level; internalLightTicks = 0; creature->setCreatureLight(lightInfo); g_game.changeLight(creature); } }
void ConditionDamage::addCondition(Creature* creature, const Condition* addCondition) { if(addCondition->getType() == conditionType) { const ConditionDamage& conditionDamage = static_cast<const ConditionDamage&>(*addCondition); if(updateCondition(&conditionDamage)) { setTicks(addCondition->getTicks()); owner = conditionDamage.owner; maxDamage = conditionDamage.maxDamage; minDamage = conditionDamage.minDamage; startDamage = conditionDamage.startDamage; tickInterval = conditionDamage.tickInterval; periodDamage = conditionDamage.periodDamage; int32_t nextTimeLeft = tickInterval; if(!damageList.empty()) { //save previous timeLeft IntervalInfo& damageInfo = damageList.front(); nextTimeLeft = damageInfo.timeLeft; damageList.clear(); } damageList = conditionDamage.damageList; if(init()) { if(!damageList.empty()) { //restore last timeLeft IntervalInfo& damageInfo = damageList.front(); damageInfo.timeLeft = nextTimeLeft; } if(!delayed) { int32_t damage = 0; if(getNextDamage(damage)) doDamage(creature, damage); } } } } }
void ConditionAttributes::addCondition(Creature* creature, const Condition* addCondition) { if(!updateCondition(addCondition)) return; setTicks(addCondition->getTicks()); const ConditionAttributes& conditionAttrs = static_cast<const ConditionAttributes&>(*addCondition); endCondition(creature, CONDITIONEND_ABORT); //Apply the new one memcpy(skills, conditionAttrs.skills, sizeof(skills)); memcpy(skillsPercent, conditionAttrs.skillsPercent, sizeof(skillsPercent)); memcpy(stats, conditionAttrs.stats, sizeof(stats)); memcpy(statsPercent, conditionAttrs.statsPercent, sizeof(statsPercent)); if(Player* player = creature->getPlayer()) { updatePercentSkills(player); updateSkills(player); updatePercentStats(player); updateStats(player); } }
void toogleBreakpointFileLine(BreakpointsData* data, PDReader* reader) { const char* filename = 0; uint32_t line; char fileLine[8192]; PDRead_findString(reader, &filename, "filename", 0); PDRead_findU32(reader, &line, "line", 0); if (!filename) return; for (auto i = data->breakpoints.begin(); i != data->breakpoints.end(); ++i) { if ((*i)->location.line == (int)line && !strcmp((*i)->location.filename, filename)) { destroyBreakpoint(*i); data->breakpoints.erase(i); return; } } Breakpoint* breakpoint = createBreakpoint(data); sprintf(fileLine, "%s:%d\n", filename, line); breakpoint->location.filename = (char*)malloc(data->maxPath); breakpoint->location.line = (int)line; strcpy(breakpoint->location.filename, fileLine); updateCondition(breakpoint, reader); data->breakpoints.push_back(breakpoint); }
void ConditionGeneric::addCondition(Creature*, const Condition* addCondition) { if(updateCondition(addCondition)) setTicks(addCondition->getTicks()); }
void doPlayer(void) { self = player; rechargeBoostECM(); if (game.currentMission->challengeData.isChallenge) { applyRestrictions(); } if (player->alive == ALIVE_ALIVE && player->systemPower > 0) { handleKeyboard(); handleMouse(); handleSuspicionLevel(); if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || targetOutOfRange()) { selectTarget(); } } player->angle = ((int)player->angle) % 360; if (player->health <= 0 && battle.status == MS_IN_PROGRESS) { if (game.currentMission->challengeData.isChallenge) { if (!game.currentMission->challengeData.allowPlayerDeath) { updateDeathStats(); failMission(); } } else if (!battle.isEpic) { updateDeathStats(); failMission(); } else if (player->health == -FPS) { updateDeathStats(); updateCondition("PLAYER", TT_DESTROY); if (battle.status == MS_IN_PROGRESS) { initPlayerSelect(); } } } if (battle.status == MS_IN_PROGRESS) { selectMissionTarget(); } if (dev.playerUnlimitedMissiles) { player->missiles = 999; } /* really only used in challenge mode */ if (player->systemPower <= 0 && battle.status == MS_IN_PROGRESS) { if (game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Challenge Failed!")); failMission(); } } if (battle.boostTimer == (int)BOOST_FINISHED_TIME) { deactivateBoost(); } }
ssize_t SharedBufferServer::frameBufferHaveReleased() { ReleaseFBUpdate update(this, mNumBuffers); ssize_t buf = updateCondition( update ); return buf; }
void doFighter(void) { if (self->alive == ALIVE_ALIVE) { if (self != player) { separate(); } if (!(self->flags & EF_DISABLED)) { attachRope(); } if (self->thrust > 0.25) { addEngineEffect(); } if (self->health <= 0) { self->health = 0; self->alive = ALIVE_DYING; self->die(); if (self == battle.missionTarget) { battle.missionTarget = NULL; } } else if (self->systemPower <= 0 || (self->flags & EF_DISABLED)) { self->dx *= 0.99; self->dy *= 0.99; self->thrust = 0; self->shield = self->maxShield = 0; self->action = NULL; if ((self->flags & EF_DISABLED) == 0) { playBattleSound(SND_POWER_DOWN, self->x, self->y); self->flags |= EF_DISABLED; self->flags |= EF_SECONDARY_TARGET; if (self->aiFlags & AIF_SURRENDERING) { self->aiFlags |= AIF_SURRENDERED; self->aiFlags &= ~AIF_SURRENDERING; } battle.stats[STAT_ENEMIES_DISABLED]++; updateObjective(self->name, TT_DISABLE); updateObjective(self->groupName, TT_DISABLE); if (self->side != player->side) { runScriptFunction("ENEMIES_DISABLED %d", battle.stats[STAT_ENEMIES_DISABLED]); } } } if (self->target != NULL && self->target->alive != ALIVE_ALIVE) { self->target = NULL; if (self != player) { self->action = doAI; } } if (self->aiFlags & AIF_SUSPICIOUS) { checkSuspicionLevel(); } if (self->aiFlags & AIF_ZAK_SUSPICIOUS) { checkZackariaSuspicionLevel(); } } if (self->alive == ALIVE_ESCAPED) { if (self == player && !game.currentMission->challengeData.isChallenge) { updateObjective("Player", TT_ESCAPED); completeMission(); } if (self->side != player->side && (!(self->flags & EF_DISABLED))) { addHudMessage(colors.red, _("Mission target has escaped.")); battle.stats[STAT_ENEMIES_ESCAPED]++; } if (strcmp(self->defName, "Civilian") == 0) { battle.stats[STAT_CIVILIANS_RESCUED]++; } /* if you did not escape under your own volition, or with the aid of a friend, you've been stolen */ if (!self->owner || self->side == self->owner->side) { updateObjective(self->name, TT_ESCAPED); updateCondition(self->name, TT_ESCAPED); } else { updateObjective(self->name, TT_STOLEN); updateCondition(self->name, TT_STOLEN); } } if (self->alive == ALIVE_DEAD) { if (player->alive == ALIVE_ALIVE && self != player) { if (self->side != player->side) { if (!(self->flags & EF_NO_KILL_INC)) { battle.stats[STAT_ENEMIES_KILLED]++; runScriptFunction("ENEMIES_KILLED %d", battle.stats[STAT_ENEMIES_KILLED]); } } else { if (strcmp(self->name, "Civilian") == 0) { battle.stats[STAT_CIVILIANS_KILLED]++; if (!battle.isEpic || game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Civilian has been killed")); } runScriptFunction("CIVILIANS_KILLED %d", battle.stats[STAT_CIVILIANS_KILLED]); } else { battle.stats[STAT_ALLIES_KILLED]++; if (!battle.isEpic && !game.currentMission->challengeData.isChallenge) { addHudMessage(colors.red, _("Ally has been killed")); } runScriptFunction("ALLIES_KILLED %d", battle.stats[STAT_ALLIES_KILLED]); } } updateObjective(self->name, TT_DESTROY); updateObjective(self->groupName, TT_DESTROY); if (battle.isEpic && self->killedBy == player) { updateObjective("EPIC_PLAYER_KILLS", TT_DESTROY); } adjustObjectiveTargetValue(self->name, TT_ESCAPED, -1); updateCondition(self->name, TT_DESTROY); updateCondition(self->groupName, TT_DESTROY); /* don't fire if the opposing side is responsible */ if (self->aiFlags & AIF_SURRENDERED && self->killedBy->side == player->side) { updateCondition("SURRENDERED", TT_DESTROY); } } } }
void ConditionSpellGroupCooldown::addCondition(Creature* creature, const Condition* addCondition) { if (updateCondition(addCondition)) { setTicks(addCondition->getTicks()); } }
status_t SharedBufferServer::unlock(int buf) { UnlockUpdate update(this, buf); status_t err = updateCondition( update ); return err; }
// lost my enemy - rethink my next move by flushiing schedules void CHLDMBot :: enemyLost (edict_t *pEnemy) { updateCondition(CONDITION_CHANGED); //m_pSchedules->freeMemory(); }
// update some edicts in my memory if I see them or not bool CHLDMBot :: setVisible ( edict_t *pEntity, bool bVisible ) { static float fDist; const char *szClassname; bool bValid = CBot::setVisible(pEntity,bVisible); fDist = distanceFrom(pEntity); // if no draw effect it is invisible if ( bValid && bVisible && !(CClassInterface::getEffects(pEntity)&EF_NODRAW) ) { szClassname = pEntity->GetClassName(); if ( ( strncmp(szClassname,"item_ammo",9)==0 ) && ( !m_pAmmoKit.get() || (fDist<distanceFrom(m_pAmmoKit.get())) )) { m_pAmmoKit = pEntity; } else if ( ( strncmp(szClassname,"item_health",11)==0 ) && ( !m_pHealthKit.get() || (fDist<distanceFrom(m_pHealthKit.get())) )) { //if ( getHealthPercent() < 1.0f ) // updateCondition(CONDITION_CHANGED); m_pHealthKit = pEntity; } else if ( ( strcmp(szClassname,"item_battery")==0 ) && ( !m_pBattery.get() || (fDist<distanceFrom(m_pBattery.get())) )) { m_pBattery = pEntity; } else if ( ( (strcmp(szClassname,"func_breakable")==0 ) || (strncmp(szClassname,"prop_physics",12)==0) ) && (CClassInterface::getPlayerHealth(pEntity)>0) && ( !m_NearestBreakable.get() || (fDist<distanceFrom(m_NearestBreakable.get())) )) { m_NearestBreakable = pEntity; } else if ( (pEntity != m_pNearestButton) && ( strcmp(szClassname,"func_button")==0 ) ) { if ( !m_pNearestButton.get() || (fDist<distanceFrom(m_pNearestButton.get())) ) m_pNearestButton = pEntity; } // covered above /*else if ( (pEntity != m_pNearestBreakable) && ( strcmp(szClassname,"func_breakable")==0 ) ) { if ( !m_pNearestBreakable.get() || (fDist<distanceFrom(m_pNearestBreakable.get())) ) m_pNearestBreakable = pEntity; }*/ else if ( (pEntity != m_pAmmoCrate ) && ( strcmp(szClassname,"item_ammo_crate") == 0 ) ) { if ( !m_pAmmoCrate.get() || (fDist<distanceFrom(m_pAmmoCrate.get())) ) m_pAmmoCrate = pEntity; } else if ( (pEntity != m_FailedPhysObj) && ( strncmp(szClassname,"prop_physics",12)==0 ) && ( !m_NearestPhysObj.get() || (fDist<distanceFrom(m_NearestPhysObj.get())) )) { //if ( !m_bCarryingObject ) // updateCondition(CONDITION_CHANGED); m_NearestPhysObj = pEntity; } else if ( ( strncmp(szClassname,"item_suitcharger",16)==0 ) && ( !m_pCharger.get() || (fDist<distanceFrom(m_pCharger.get())) )) { if ( m_pCharger.get() ) { // less juice than the current one I see if ( CClassInterface::getAnimCycle(m_pCharger) < CClassInterface::getAnimCycle(pEntity) ) { return bValid; } } if ( m_pPlayerInfo->GetArmorValue() < 50 ) updateCondition(CONDITION_CHANGED); m_pCharger = pEntity; } else if ( ( strncmp(szClassname,"item_healthcharger",18)==0 ) && ( !m_pHealthCharger.get() || (fDist<distanceFrom(m_pHealthCharger.get())) )) { if ( m_pHealthCharger.get() ) { // less juice than the current one I see - forget it if ( CClassInterface::getAnimCycle(m_pHealthCharger) < CClassInterface::getAnimCycle(pEntity) ) { return bValid; } } if ( getHealthPercent() < 1.0f ) updateCondition(CONDITION_CHANGED); // update tasks m_pHealthCharger = pEntity; } else if ( ( strncmp(szClassname,"weapon_",7)==0 ) && ( !m_pNearbyWeapon.get() || (fDist<distanceFrom(m_pNearbyWeapon.get())) )) { /*static CWeapon *pWeapon; pWeapon = CWeapons::getWeapon(pEntity->GetClassName()); if ( pWeapon && !m_pWeapons->hasWeapon(pWeapon->getID()) ) updateCondition(CONDITION_CHANGED);*/ m_pNearbyWeapon = pEntity; } } else { if ( m_pAmmoKit == pEntity ) m_pAmmoKit = NULL; else if ( m_pAmmoCrate == pEntity ) m_pAmmoCrate = NULL; else if ( m_pHealthKit == pEntity ) m_pHealthKit = NULL; else if ( m_pBattery == pEntity ) m_pBattery = NULL; else if ( m_NearestPhysObj == pEntity ) m_NearestPhysObj = NULL; else if ( m_pCharger == pEntity ) m_pCharger = NULL; else if ( m_pHealthCharger == pEntity ) m_pHealthCharger = NULL; else if ( m_NearestBreakable == pEntity ) m_NearestBreakable = NULL; else if ( m_pNearbyWeapon == pEntity ) m_pNearbyWeapon = NULL; else if ( m_pNearestButton == pEntity ) m_pNearestButton = NULL; //else if ( m_pNearestBreakable == pEntity ) // m_pNearestBreakable = NULL; } return bValid; }