[Gcblue-commits] gcb_wx/src/sim tcSimState.cpp,1.47,1.48 tcWeaponObject.cpp,1.5,1.6
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-07-27 00:16:34
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10427/src/sim Modified Files: tcSimState.cpp tcWeaponObject.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** tcSimState.cpp 23 Jul 2004 00:45:47 -0000 1.47 --- tcSimState.cpp 27 Jul 2004 00:16:24 -0000 1.48 *************** *** 382,424 **** /** ! * Used for a missile used against fixed land targets. The region near * the collision point is searched for nearby targets. Damage is applied * to all targets that are close enough. */ ! void tcSimState::EvaluateImpactMissileHit(tcMissileObject* missile) { ! wxASSERT(missile); ! ! #if 0 ! float terrainHeight_m = missile->mcTerrain.mfHeight_m; ! if (missile->mcKin.mfAlt_m > terrainHeight_m + 25.0) return; ! const float blastHeight_m = 3.0f; // height above ground for detonation ! double lon_rad; ! double lat_rad; ! float tImpact = missile->mcKin.CalculateGroundImpactPoint( ! terrainHeight_m + blastHeight_m, lon_rad, lat_rad); ! if (tImpact > 0.03) return; // defer until future time step ! missile->mcKin.mfAlt_m = terrainHeight_m; ! missile->mcKin.mfLon_rad = lon_rad; ! missile->mcKin.mfLat_rad = lat_rad; ! #endif ! if (!missile->IsDetonated()) return; float rLat = 500.0 * C_MTORAD; ! float rLon = rLat / cosf(missile->mcKin.mfLat_rad); long blastPlats[16]; tcRect blastRegion; ! float west = missile->mcKin.mfLon_rad - rLon; ! float east = missile->mcKin.mfLon_rad + rLon; ! float north = missile->mcKin.mfLat_rad + rLat; ! float south = missile->mcKin.mfLat_rad - rLat; if (west < -C_PI) west += C_TWOPI; if (east >= C_PI) east -= C_TWOPI; --- 382,423 ---- /** ! * Used for a weapon used against fixed land targets. The region near * the collision point is searched for nearby targets. Damage is applied * to all targets that are close enough. */ ! void tcSimState::EvaluateImpactWeaponHit(tcWeaponObject* weapon) { ! wxASSERT(weapon); ! if (!weapon->IsDetonated()) return; ! float blastDelay = weapon->GetDetonationDelay(); ! if (blastDelay > 0.033) return; ! if (blastDelay > 0) ! { ! double lon_rad; ! double lat_rad; ! float alt_m; ! weapon->mcKin.PredictPosition(blastDelay, ! lon_rad, lat_rad, alt_m); ! weapon->mcKin.mfAlt_m = alt_m; ! weapon->mcKin.mfLon_rad = lon_rad; ! weapon->mcKin.mfLat_rad = lat_rad; ! } float rLat = 500.0 * C_MTORAD; ! float rLon = rLat / cosf(weapon->mcKin.mfLat_rad); long blastPlats[16]; tcRect blastRegion; ! float west = weapon->mcKin.mfLon_rad - rLon; ! float east = weapon->mcKin.mfLon_rad + rLon; ! float north = weapon->mcKin.mfLat_rad + rLat; ! float south = weapon->mcKin.mfLat_rad - rLat; if (west < -C_PI) west += C_TWOPI; if (east >= C_PI) east -= C_TWOPI; *************** *** 426,437 **** int nPlats = GetPlatformsWithinRegion(blastPlats, 16, &blastRegion); ! float fDamage = missile->mpDBObject->mfDamage; for (int idx = 0; idx < nPlats; idx++) { tcGameObject* target = GetObject(blastPlats[idx]); ! if (target && (target->mnID != missile->mnID)) { ! float range_m = 1000.0f * target->mcKin.RangeToKmAlt(missile->mcKin); if (range_m <= 80.0) { --- 425,436 ---- int nPlats = GetPlatformsWithinRegion(blastPlats, 16, &blastRegion); ! float fDamage = weapon->GetDamage(); for (int idx = 0; idx < nPlats; idx++) { tcGameObject* target = GetObject(blastPlats[idx]); ! if (target && (target->mnID != weapon->mnID)) { ! float range_m = 1000.0f * target->mcKin.RangeToKmAlt(weapon->mcKin); if (range_m <= 80.0) { *************** *** 443,447 **** tcString s; s.Format("weapon (impact) %d hit target %d, range: %3.1f m, time %.1f s", ! missile->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); --- 442,446 ---- tcString s; s.Format("weapon (impact) %d hit target %d, range: %3.1f m, time %.1f s", ! weapon->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); *************** *** 459,463 **** tcString s; s.Format("weapon (DUD) %d target %d, range: %3.1f m, time %.1f s", ! missile->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); } --- 458,462 ---- tcString s; s.Format("weapon (DUD) %d target %d, range: %3.1f m, time %.1f s", ! weapon->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); } *************** *** 468,472 **** tcString s; s.Format("weapon (impact) %d missed target %d, range: %3.1f m, time %.1f s", ! missile->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); } --- 467,471 ---- tcString s; s.Format("weapon (impact) %d missed target %d, range: %3.1f m, time %.1f s", ! weapon->mnID, target->mnID, range_m, mfSimTime); WTL(s.GetBuffer()); } *************** *** 474,478 **** } ! missile->mfDamageLevel += 1.0f; } --- 473,477 ---- } ! weapon->mfDamageLevel += 1.0f; } *************** *** 507,520 **** } } ! else { ! if (missileObj->mcKin.mfAlt_m < missileObj->mcTerrain.mfHeight_m + 200.0) ! { ! EvaluateImpactMissileHit(missileObj); ! } } - ! } } } --- 506,519 ---- } } ! } ! else if (tcWeaponObject* weapon = dynamic_cast<tcWeaponObject*>(obj)) ! { ! if ((weapon->mcKin.mfAlt_m < weapon->mcTerrain.mfHeight_m + 200.0) ! || (weapon->mcKin.mfAlt_m < 100.0)) { ! EvaluateImpactWeaponHit(weapon); } ! } } } *************** *** 762,766 **** } /********************************************************************/ ! int tcSimState::GetAllWeaponObjects(long *apKeyList,int anMaxLength) { tcGameObject *pobj; tnPoolIndex cmappos = maPlatformState.GetStartPosition(); --- 761,766 ---- } /********************************************************************/ ! int tcSimState::GetAllWeaponObjects(long *apKeyList,int anMaxLength) ! { tcGameObject *pobj; tnPoolIndex cmappos = maPlatformState.GetStartPosition(); *************** *** 772,778 **** { maPlatformState.GetNextAssoc(cmappos,nKey,pobj); ! if (pobj->mnModelType == MTYPE_MISSILE) { ! apKeyList[nListIndex++]=nKey; } } --- 772,778 ---- { maPlatformState.GetNextAssoc(cmappos,nKey,pobj); ! if (dynamic_cast<tcWeaponObject*>(pobj)) { ! apKeyList[nListIndex++] = nKey; } } Index: tcWeaponObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcWeaponObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcWeaponObject.cpp 23 Jul 2004 00:45:47 -0000 1.5 --- tcWeaponObject.cpp 27 Jul 2004 00:16:24 -0000 1.6 *************** *** 21,25 **** #include "tcWeaponObject.h" #include "tcGameObject.h" ! #include "tcDatabaseObject.h" #include "tcSensorMap.h" #include "tcSimState.h" --- 21,25 ---- #include "tcWeaponObject.h" #include "tcGameObject.h" ! #include "tcWeaponDBObject.h" #include "tcSensorMap.h" #include "tcSimState.h" *************** *** 55,61 **** * Called when weapon detonates */ ! void tcWeaponObject::Detonate() { fuseHasTriggered = true; } --- 55,77 ---- * Called when weapon detonates */ ! void tcWeaponObject::Detonate(float delay_s) { fuseHasTriggered = true; + fuseDelay = delay_s; + } + + float tcWeaponObject::GetDamage() const + { + return mpDBObject->mfDamage; + } + + float tcWeaponObject::GetDetonationDelay() const + { + return fuseDelay; + } + + long tcWeaponObject::GetIntendedTarget() const + { + return intendedTarget; } *************** *** 74,77 **** --- 90,98 ---- } + void tcWeaponObject::SetDetonationDelay(float delay_s) + { + fuseDelay = delay_s; + } + void tcWeaponObject::SetIntendedTarget(long targetId) { *************** *** 96,100 **** */ tcWeaponObject::tcWeaponObject() ! : fuseHasTriggered(false),intendedTarget(-1) { --- 117,122 ---- */ tcWeaponObject::tcWeaponObject() ! : fuseHasTriggered(false), fuseDelay(0), intendedTarget(-1), ! mpDBObject(0) { *************** *** 112,121 **** * Constructor that initializes using info from database entry. */ ! tcWeaponObject::tcWeaponObject(tcDatabaseObject *obj) ! : tcGameObject(obj), fuseHasTriggered(false) { wxASSERT(simState); - - intendedTarget = -1; } --- 134,143 ---- * Constructor that initializes using info from database entry. */ ! tcWeaponObject::tcWeaponObject(tcWeaponDBObject* obj) ! : tcGameObject(obj), ! fuseHasTriggered(false), fuseDelay(0), intendedTarget(-1), ! mpDBObject(obj) { wxASSERT(simState); } |