[Gcblue-commits] gcb_wx/src/sim tcAirObject.cpp,1.30,1.31 tcAirfieldObject.cpp,1.8,1.9 tcCarrierObje
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3422/src/sim Modified Files: tcAirObject.cpp tcAirfieldObject.cpp tcCarrierObject.cpp tcESMSensor.cpp tcFlightOpsObject.cpp tcGameObject.cpp tcGoal.cpp tcGoalTracker.cpp tcLauncher.cpp tcMissileObject.cpp tcOpticalSensor.cpp tcPlatformObject.cpp tcRadar.cpp tcSimState.cpp tcSonobuoy.cpp tcSubObject.cpp tcTorpedoObject.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** tcSimState.cpp 23 Mar 2006 01:11:02 -0000 1.95 --- tcSimState.cpp 26 Mar 2006 00:32:15 -0000 1.96 *************** *** 2,6 **** ** @file tcSimState.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. ** --- 2,6 ---- ** @file tcSimState.cpp */ ! /* Copyright (C) 2003-2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** *************** *** 28,32 **** #include "simmath.h" #include "aerror.h" ! #include "ATLComTime.h" #include <vector> #include "tcFile.h" --- 28,32 ---- #include "simmath.h" #include "aerror.h" ! #include <wx/datetime.h> #include <vector> #include "tcFile.h" *************** *** 444,464 **** if (trueRange2 < 0.00001440f) // 12.0 m range { ! bool alreadyDestroyed = target->mfDamageLevel >= 1.0f; float fDamage = missile->mpDBObject->mfDamage; float damageFraction = GetFractionalDamage(fDamage, target); ! float priorTargetDamage = target->mfDamageLevel; ! float priorWeaponDamage = missile->mfDamageLevel; ! ! target->mfDamageLevel += damageFraction; ! missile->mfDamageLevel += 1.0f; // missile destroys itself on impact ! ! UpdateScoreForDamage(0, missile, priorWeaponDamage); if (damageFraction > 0) { ! target->ApplyDamage(damageFraction); ! ! UpdateScoreForDamage(missile, target, priorTargetDamage); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) --- 444,456 ---- if (trueRange2 < 0.00001440f) // 12.0 m range { ! bool alreadyDestroyed = target->GetDamageLevel() >= 1.0f; float fDamage = missile->mpDBObject->mfDamage; float damageFraction = GetFractionalDamage(fDamage, target); ! missile->ApplyDamage(1.0f, 0); // missile destroys itself on impact if (damageFraction > 0) { ! target->ApplyDamage(damageFraction, missile); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) *************** *** 528,546 **** if (trueRange2 < 144.0f) // 12.0 m "range", dz not counted as heavily { ! float priorTargetDamage = target->mfDamageLevel; ! bool alreadyDestroyed = target->mfDamageLevel >= 1.0f; float fDamage = torp->mpDBObject->mfDamage; float damageFraction = GetFractionalDamage(fDamage, target); - target->mfDamageLevel += damageFraction; ! float priorWeaponDamage = torp->mfDamageLevel; ! torp->mfDamageLevel += 1.0f; // torp destroys itself on impact ! UpdateScoreForDamage(0, torp, priorWeaponDamage); if (damageFraction > 0) { ! target->ApplyDamage(damageFraction); ! ! UpdateScoreForDamage(torp, target, priorTargetDamage); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) --- 520,532 ---- if (trueRange2 < 144.0f) // 12.0 m "range", dz not counted as heavily { ! bool alreadyDestroyed = target->GetDamageLevel() >= 1.0f; float fDamage = torp->mpDBObject->mfDamage; float damageFraction = GetFractionalDamage(fDamage, target); ! torp->ApplyDamage(damageFraction, 0); if (damageFraction > 0) { ! target->ApplyDamage(damageFraction, torp); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) *************** *** 630,644 **** if (range_m <= damage_range_m) { - float priorTargetDamage = target->mfDamageLevel; float damageFraction = GetFractionalDamage(fDamage, target); ! bool alreadyDestroyed = target->mfDamageLevel >= 1.0f; ! target->mfDamageLevel += damageFraction; ! if (damageFraction > 0) { ! target->ApplyDamage(damageFraction); - UpdateScoreForDamage(weapon, target, priorTargetDamage); #ifdef _DEBUG tcString s; --- 616,626 ---- if (range_m <= damage_range_m) { float damageFraction = GetFractionalDamage(fDamage, target); ! bool alreadyDestroyed = target->GetDamageLevel() >= 1.0f; if (damageFraction > 0) { ! target->ApplyDamage(damageFraction, weapon); #ifdef _DEBUG tcString s; *************** *** 689,696 **** } - float priorWeaponDamage = weapon->mfDamageLevel; - weapon->mfDamageLevel += 1.0f; - UpdateScoreForDamage(0, weapon, priorWeaponDamage); } --- 671,676 ---- } + weapon->ApplyDamage(1.0, 0); } *************** *** 714,718 **** if (trueRange2 < 2500.0f) // 50.0 m range { - float priorTargetDamage = target->mfDamageLevel; float fDamage = weapon->GetDamage(); float damageFraction = GetFractionalDamage(fDamage, target); --- 694,697 ---- *************** *** 720,734 **** if (randf() < 0.3f) damageFraction = 0; // additional miss chance ! bool alreadyDestroyed = target->mfDamageLevel >= 1.0f; ! target->mfDamageLevel += damageFraction; ! float priorWeaponDamage = weapon->mfDamageLevel; ! weapon->mfDamageLevel += 1.0f; // destroys itself on impact ! UpdateScoreForDamage(0, weapon, priorWeaponDamage); if (damageFraction > 0) { ! target->ApplyDamage(damageFraction); ! UpdateScoreForDamage(weapon, target, priorTargetDamage); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) --- 699,709 ---- if (randf() < 0.3f) damageFraction = 0; // additional miss chance ! bool alreadyDestroyed = target->GetDamageLevel() >= 1.0f; ! weapon->ApplyDamage(1.0f, 0); if (damageFraction > 0) { ! target->ApplyDamage(damageFraction, weapon); if (mpUserInfo->IsOwnAlliance(target->GetAlliance())) *************** *** 879,911 **** } - /** - * Score is scaled to units of $1000. Partial damage gets up to 50% of the value of the object. Full - * damage gets the remaining 50% - * Call after damage has been applied to damagee - */ - void tcSimState::UpdateScoreForDamage(tcGameObject* damager, tcGameObject* damagee, float priorDamage) - { - wxASSERT(damagee); - - if (damagee == 0) return; - if (priorDamage >= 1.0f) return; // already destroyed - - float& damageLevel = damagee->mfDamageLevel; - if (damageLevel <= priorDamage) return; // no damage - - float newDamage = damageLevel - priorDamage; - float damageCredit = 0.0005f * newDamage * damagee->mpDBObject->GetCost(); - - if (damageLevel >= 1.0f) - { - damageCredit += 0.0005f * damagee->mpDBObject->GetCost(); - } - - if (damager != 0) - { - tcGoalTracker::Get()->AdjustAllianceScore(damager->GetAlliance(), damageCredit); - } - tcGoalTracker::Get()->AdjustAllianceScore(damagee->GetAlliance(), -damageCredit); - } /** --- 854,857 ---- *************** *** 1222,1229 **** std::string damageString = "reports light damage"; ! if (obj->mfDamageLevel >= 1.0) damageString = "destroyed"; ! else if (obj->mfDamageLevel >= 0.5) damageString = "reports heavy damage"; ! else if (obj->mfDamageLevel >= 0.2) damageString = "reports moderate damage"; wxString s = wxString::Format("%s: %s (%s) %s\n", --- 1168,1176 ---- std::string damageString = "reports light damage"; ! float damageLevel = obj->GetDamageLevel(); + if (damageLevel >= 1.0) damageString = "destroyed"; + else if (damageLevel >= 0.5) damageString = "reports heavy damage"; + else if (damageLevel >= 0.2) damageString = "reports moderate damage"; wxString s = wxString::Format("%s: %s (%s) %s\n", *************** *** 1902,1911 **** try { ! COleDateTime current; ! current = COleDateTime::GetCurrentTime(); ! tcString str = current.Format(_T("Randomly generated on %A, %B %d, %Y %H:%M:%S")); ! sprintf(msScenarioInfo.mzDescription,"%s",str.GetBuffer()); ! strcpy(msScenarioInfo.mzName,"RANDOM-TEST"); } catch (...) --- 1849,1859 ---- try { ! wxDateTime current = wxDateTime::Now(); ! wxString s = wxString::Format("Randomly generated on %s", ! current.Format().c_str()); ! //tcString str = current.Format(_T("Randomly generated on %A, %B %d, %Y %H:%M:%S")); ! sprintf_s(msScenarioInfo.mzDescription, 1024, "%s", s.c_str()); ! strcpy(msScenarioInfo.mzName, "RANDOM-TEST"); } catch (...) *************** *** 1996,2003 **** UINT platform_type; ! if (mpDatabase == NULL) {return;} ! CTime ctime = CTime::GetCurrentTime(); ! srand((nSeedCount++) + ctime.GetMinute()*ctime.GetSecond()); int rand_num = rand() % 3; --- 1944,1956 ---- UINT platform_type; + wxASSERT(mpDatabase); + if (mpDatabase == 0) return; ! if (nSeedCount == 0) ! { ! nSeedCount++; ! wxDateTime t = wxDateTime::Now(); ! srand(t.GetMinute() * t.GetSecond()); ! } int rand_num = rand() % 3; Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tcMissileObject.cpp 23 Mar 2006 01:11:02 -0000 1.33 --- tcMissileObject.cpp 26 Mar 2006 00:32:15 -0000 1.34 *************** *** 311,328 **** if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m) || seaSurfaceCrash) { ! mfDamageLevel = 1.0f; tcString s; s.Format("Object %s crashed at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); - simState->UpdateScoreForDamage(0, this, priorDamage); } if ((msKState.mfFlightTime > 20.0f)&&(msKState.mfSpeed_mps < mpDBObject->mfShutdownSpeed_mps)) { ! mfDamageLevel = 1.0f; // self-destruct tcString s; s.Format("Object %s shut down at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); - simState->UpdateScoreForDamage(0, this, priorDamage); } --- 311,326 ---- if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m) || seaSurfaceCrash) { ! ApplyDamage(1.0f, 0); tcString s; s.Format("Object %s crashed at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); } if ((msKState.mfFlightTime > 20.0f)&&(msKState.mfSpeed_mps < mpDBObject->mfShutdownSpeed_mps)) { ! ApplyDamage(1.0f, 0); tcString s; s.Format("Object %s shut down at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); } Index: tcGoal.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGoal.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcGoal.cpp 23 Mar 2006 01:11:02 -0000 1.10 --- tcGoal.cpp 26 Mar 2006 00:32:15 -0000 1.11 *************** *** 588,592 **** goalState = FAILED; } ! else if (obj->mfDamageLevel >= 1.0) { goalState = FAILED; --- 588,592 ---- goalState = FAILED; } ! else if (obj->GetDamageLevel() >= 1.0) { goalState = FAILED; Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tcLauncher.cpp 23 Mar 2006 01:11:02 -0000 1.35 --- tcLauncher.cpp 26 Mar 2006 00:32:15 -0000 1.36 *************** *** 36,39 **** --- 36,40 ---- #include "tcRadar.h" #include "tcSimState.h" + #include "tcGoalTracker.h" #include <iostream> #include "common/tcObjStream.h" *************** *** 686,689 **** --- 687,712 ---- } + + /** + * Call after damage to launcher. This assumes all items in launcher are + * destroyed. + */ + void tcLauncher::UpdateScoreForDamage(tcGameObject* damager) + { + if (!isDamaged) return; + + float cost = 0; + if (mpChildDBObj) + { + cost = float(mnCurrent) * mpChildDBObj->GetCost(); + } + + if (damager != 0) + { + tcGoalTracker::Get()->AdjustAllianceScore(damager->GetAlliance(), cost); + } + tcGoalTracker::Get()->AdjustAllianceScore(parent->GetAlliance(), -cost); + } + void tcLauncher::UpdateStatus() { Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** tcPlatformObject.cpp 23 Mar 2006 01:11:02 -0000 1.60 --- tcPlatformObject.cpp 26 Mar 2006 00:32:15 -0000 1.61 *************** *** 412,417 **** * @param fractional amount of new damage */ ! void tcPlatformObject::ApplyDamage(float damage) { float scaledDamage = (mfDamageLevel <= 0.5f) ? (0.4f * damage) : damage; --- 412,422 ---- * @param fractional amount of new damage */ ! void tcPlatformObject::ApplyDamage(float damage, tcGameObject* damager) { + float priorDamage = mfDamageLevel; + mfDamageLevel += damage; + + UpdateScoreForDamage(damager, priorDamage); + float scaledDamage = (mfDamageLevel <= 0.5f) ? (0.4f * damage) : damage; *************** *** 425,428 **** --- 430,434 ---- { launcher->SetDamaged(true); + launcher->UpdateScoreForDamage(damager); } } *************** *** 452,455 **** --- 458,464 ---- void tcPlatformObject::ApplyRepairs(float repair) { + mfDamageLevel -= repair; + if (mfDamageLevel == 0) mfDamageLevel = 0; + float scaledRepairs = (mfDamageLevel <= 0.5f) ? (0.5f * repair) : repair; Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcTorpedoObject.cpp 23 Mar 2006 01:11:02 -0000 1.17 --- tcTorpedoObject.cpp 26 Mar 2006 00:32:15 -0000 1.18 *************** *** 325,334 **** if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { ! mfDamageLevel = 1.0f; tcString s; s.Format("Torpedo %s hit bottom at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); - simState->UpdateScoreForDamage(0, this, priorDamage); } --- 325,333 ---- if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { ! ApplyDamage(1.0f, 0); tcString s; s.Format("Torpedo %s hit bottom at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); } *************** *** 339,348 **** if (battery_kJ <= 0) { ! mfDamageLevel = 1.0f; // self-destruct tcString s; s.Format("Torpedo %s shut down at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); - simState->UpdateScoreForDamage(0, this, priorDamage); } --- 338,346 ---- if (battery_kJ <= 0) { ! ApplyDamage(1.0f, 0); // self-destruct tcString s; s.Format("Torpedo %s shut down at time %.1f lon %.3f, lat %.3f", mzUnit.mz,afStatusTime,mcKin.mfLon_rad*C_180OVERPI,mcKin.mfLat_rad*C_180OVERPI); WTL(s.GetBuffer()); } Index: tcESMSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcESMSensor.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcESMSensor.cpp 23 Mar 2006 01:11:02 -0000 1.17 --- tcESMSensor.cpp 26 Mar 2006 00:32:15 -0000 1.18 *************** *** 291,295 **** (t - mcTrack.mfTimestamp) > 300.0) // set high for now to coast { ! parent->mfDamageLevel += 1.0f; mcTrack.mnID = NULL_INDEX; --- 291,295 ---- (t - mcTrack.mfTimestamp) > 300.0) // set high for now to coast { ! parent->SelfDestruct(); mcTrack.mnID = NULL_INDEX; Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** tcGameObject.cpp 12 Dec 2005 02:37:01 -0000 1.42 --- tcGameObject.cpp 26 Mar 2006 00:32:15 -0000 1.43 *************** *** 2,7 **** ** @file tcGameObject.cpp */ ! /* ! ** Copyright (C) 2003-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. --- 2,6 ---- ** @file tcGameObject.cpp */ ! /* Copyright (C) 2003-2006 Dewitt Colclough (de...@gc...) ** All rights reserved. *************** *** 33,36 **** --- 32,36 ---- #include "tcSimState.h" #include "tcScenarioLogger.h" + #include "tcGoalTracker.h" #include "common/tcStream.h" #include "common/tcObjStream.h" *************** *** 89,93 **** void tcGameObject::SelfDestruct() { ! mfDamageLevel += 1.0f; } --- 89,96 ---- void tcGameObject::SelfDestruct() { ! float priorDamage = mfDamageLevel; ! mfDamageLevel = 1.0f; ! ! UpdateScoreForDamage(0, priorDamage); } *************** *** 490,495 **** ! void tcGameObject::ApplyDamage(float damage) { } --- 493,502 ---- ! void tcGameObject::ApplyDamage(float damage, tcGameObject* damager) { + float priorDamage = mfDamageLevel; + mfDamageLevel += damage; + + UpdateScoreForDamage(damager, priorDamage); } *************** *** 575,578 **** --- 582,634 ---- /** + * Score is units of $. Partial damage gets up to 50% of the value of the object. Full + * damage gets the remaining 50% + * Call after damage has been applied to damagee + */ + void tcGameObject::UpdateScoreForDamage(tcGameObject* damager, float priorDamage) + { + if (priorDamage >= 1.0f) return; // already destroyed + + float& damageLevel = mfDamageLevel; + if (damageLevel <= priorDamage) return; // no damage + if (damageLevel > 1.0f) damageLevel = 1.0f; + + float cost = mpDBObject->GetCost(); + float newDamage = damageLevel - priorDamage; + float damageCredit = 0.5f * newDamage * cost; + + if (damageLevel >= 1.0f) + { + damageCredit += 0.5f * cost; + } + + if (damager != 0) + { + tcGoalTracker::Get()->AdjustAllianceScore(damager->GetAlliance(), damageCredit); + } + tcGoalTracker::Get()->AdjustAllianceScore(GetAlliance(), -damageCredit); + + #ifdef _DEBUG + wxString s; + if (damager != 0) + { + s.Printf("%s damaged by %s, %s adjustment for alliance %d\n", mzUnit.mz, damager->mzUnit.mz, + tcDatabaseObject::CostToString(damageCredit), damager->GetAlliance()); + fprintf(stdout, s.c_str()); + } + s.Printf("%s damaged, %s adjustment for alliance %d\n\n", mzUnit.mz, + tcDatabaseObject::CostToString(-damageCredit), GetAlliance()); + fprintf(stdout, s.c_str()); + + #endif + } + + float tcGameObject::GetDamageLevel() const + { + return mfDamageLevel; + } + + + /** * Loads state from command stream */ Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcAirObject.cpp 23 Mar 2006 01:11:02 -0000 1.30 --- tcAirObject.cpp 26 Mar 2006 00:32:15 -0000 1.31 *************** *** 190,196 **** if ((mcKin.mfAlt_m <= 0) || (mcTerrain.mfHeight_m >= mcKin.mfAlt_m)) { ! float priorDamage = mfDamageLevel; ! mfDamageLevel = 1.0f; ! simState->UpdateScoreForDamage(0, this, priorDamage); } } --- 190,194 ---- if ((mcKin.mfAlt_m <= 0) || (mcTerrain.mfHeight_m >= mcKin.mfAlt_m)) { ! ApplyDamage(1.0f, 0); } } Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcSubObject.cpp 23 Mar 2006 01:11:02 -0000 1.16 --- tcSubObject.cpp 26 Mar 2006 00:32:15 -0000 1.17 *************** *** 343,347 **** if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { ! mfDamageLevel = 1.0f; } --- 343,347 ---- if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { ! ApplyDamage(1.0f, 0); } Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcOpticalSensor.cpp 23 Mar 2006 01:11:02 -0000 1.10 --- tcOpticalSensor.cpp 26 Mar 2006 00:32:15 -0000 1.11 *************** *** 241,245 **** (t - mcTrack.mfTimestamp) > 7.0) { ! parent->mfDamageLevel = 1.0f; mcTrack.mnID = NULL_INDEX; if(simState->mpUserInfo->IsOwnAlliance(parent->GetAlliance())) --- 241,245 ---- (t - mcTrack.mfTimestamp) > 7.0) { ! parent->SelfDestruct(); mcTrack.mnID = NULL_INDEX; if(simState->mpUserInfo->IsOwnAlliance(parent->GetAlliance())) Index: tcFlightOpsObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightOpsObject.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcFlightOpsObject.cpp 10 Dec 2005 16:52:03 -0000 1.13 --- tcFlightOpsObject.cpp 26 Mar 2006 00:32:15 -0000 1.14 *************** *** 388,391 **** --- 388,412 ---- /** + * Call before ::Clear() to update damage level of all children and + * adjust game score for destroying all child objects + */ + void tcFlightOpsObject::DestroyAllChildrenAndUpdateScore(tcGameObject* damager) + { + unsigned nChildren = flight_deck.GetCount(); + + for (unsigned short k=0; k < nChildren; k++) + { + tcAirState* airState = flight_deck.GetAirState(k); + tcGameObject* obj = airState->obj; + wxASSERT(obj); + + obj->ApplyDamage(1.0, damager); + } + + } + + + + /** * Set up default spots and capacities for carrier flightport. */ Index: tcGoalTracker.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGoalTracker.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcGoalTracker.cpp 23 Mar 2006 01:11:02 -0000 1.10 --- tcGoalTracker.cpp 26 Mar 2006 00:32:15 -0000 1.11 *************** *** 332,336 **** if (tcGoal* allianceGoal = allianceGoals[alliance]) { ! const char* offsetString = tcDatabaseObject::CostToString(1000.0f*GetAllianceOffset(alliance)); float score = GetAllianceScore(alliance) * (100.0 / perfectScore); --- 332,336 ---- if (tcGoal* allianceGoal = allianceGoals[alliance]) { ! const char* offsetString = tcDatabaseObject::CostToString(GetAllianceOffset(alliance)); float score = GetAllianceScore(alliance) * (100.0 / perfectScore); Index: tcAirfieldObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirfieldObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcAirfieldObject.cpp 18 Dec 2005 04:10:33 -0000 1.8 --- tcAirfieldObject.cpp 26 Mar 2006 00:32:15 -0000 1.9 *************** *** 114,125 **** ! void tcAirfieldObject::ApplyDamage(float damage) { if (mfDamageLevel >= 1.0f) { tcFlightOpsObject::Clear(); // destroy all captive entities } - - tcPlatformObject::ApplyDamage(damage); } --- 114,126 ---- ! void tcAirfieldObject::ApplyDamage(float damage, tcGameObject* damager) { + tcPlatformObject::ApplyDamage(damage, damager); + if (mfDamageLevel >= 1.0f) { + tcFlightOpsObject::DestroyAllChildrenAndUpdateScore(damager); tcFlightOpsObject::Clear(); // destroy all captive entities } } Index: tcSonobuoy.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSonobuoy.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcSonobuoy.cpp 23 Mar 2006 01:11:02 -0000 1.4 --- tcSonobuoy.cpp 26 Mar 2006 00:32:15 -0000 1.5 *************** *** 157,163 **** if (batteryTimeRemaining_s <= 0) { ! float priorDamage = tcGameObject::mfDamageLevel; ! tcGameObject::mfDamageLevel += 1.0; // destroy buoy ! simState->UpdateScoreForDamage(0, this, priorDamage); } --- 157,161 ---- if (batteryTimeRemaining_s <= 0) { ! ApplyDamage(1.0f, 0); } Index: tcCarrierObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcCarrierObject.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcCarrierObject.cpp 11 Dec 2005 00:34:28 -0000 1.13 --- tcCarrierObject.cpp 26 Mar 2006 00:32:15 -0000 1.14 *************** *** 116,127 **** ! void tcCarrierObject::ApplyDamage(float damage) { if (mfDamageLevel >= 1.0f) { tcFlightOpsObject::Clear(); // destroy all captive entities } - - tcPlatformObject::ApplyDamage(damage); } --- 116,128 ---- ! void tcCarrierObject::ApplyDamage(float damage, tcGameObject* damager) { + tcPlatformObject::ApplyDamage(damage, damager); + if (mfDamageLevel >= 1.0f) { + tcFlightOpsObject::DestroyAllChildrenAndUpdateScore(damager); tcFlightOpsObject::Clear(); // destroy all captive entities } } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** tcRadar.cpp 23 Mar 2006 01:11:02 -0000 1.36 --- tcRadar.cpp 26 Mar 2006 00:32:15 -0000 1.37 *************** *** 539,543 **** // shut down missile if target doesn't exist or can't detect { ! parent->mfDamageLevel = 1.0f; mcTrack.mnID = -1; if(simState->mpUserInfo->IsOwnAlliance(parent->GetAlliance())) --- 539,543 ---- // shut down missile if target doesn't exist or can't detect { ! parent->SelfDestruct(); mcTrack.mnID = -1; if(simState->mpUserInfo->IsOwnAlliance(parent->GetAlliance())) |