[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.87,1.88 tcBallisticWeapon.cpp,1.2,1.3 tcLauncher.cpp,1.3,
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-08-05 02:22:44
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29972/src/sim Modified Files: Game.cpp tcBallisticWeapon.cpp tcLauncher.cpp tcLauncherState.cpp tcSimState.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** tcSimState.cpp 29 Jul 2004 00:14:19 -0000 1.49 --- tcSimState.cpp 5 Aug 2004 02:22:35 -0000 1.50 *************** *** 1320,1327 **** --- 1320,1337 ---- { missile->LaunchFrom(launchingPlatform, nLauncher); + + if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) + { + tcSound::Get()->PlayEffect(SEFFECT_MISSILELAUNCH); + } } else if (tcBallisticWeapon* ballistic = dynamic_cast<tcBallisticWeapon*>(launched)) { ballistic->LaunchFrom(launchingPlatform, nLauncher); + + if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) + { + tcSound::Get()->PlayEffect(SEFFECT_NAVALGUN); + } } else *************** *** 1334,1341 **** ! if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) ! { ! tcSound::Get()->PlayEffect(SEFFECT_MISSILELAUNCH); ! } } --- 1344,1348 ---- ! } *************** *** 1406,1410 **** } ! if (obj->mnModelType != MTYPE_MISSILE) { tcString s; --- 1413,1417 ---- } ! if (dynamic_cast<tcWeaponObject*>(obj) == 0) { tcString s; Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcLauncher.cpp 27 Jul 2004 23:26:07 -0000 1.3 --- tcLauncher.cpp 5 Aug 2004 02:22:35 -0000 1.4 *************** *** 147,152 **** } ! ! #if 0 --- 147,158 ---- } ! /** ! * Accessor for database cycle time parameter ! * @return cycle time for launcher in seconds ! */ ! float tcLauncher::GetCycleTime() const ! { ! return mpLauncherDBObj->cycleTime; ! } #if 0 Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcLauncherState.cpp 29 Jul 2004 00:14:19 -0000 1.14 --- tcLauncherState.cpp 5 Aug 2004 02:22:35 -0000 1.15 *************** *** 1,5 **** ! /** @file tcLauncherState.cpp ! ** ! ** Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** --- 1,6 ---- ! /** ! ** @file tcLauncherState.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** *************** *** 25,28 **** --- 26,30 ---- #include "tcLauncherDBObject.h" #include "tcMissileDBObject.h" + #include "tcBallisticDBObject.h" #include "tcRadar.h" #include "tcSimState.h" *************** *** 320,324 **** key = pLauncher->mnChildDBKey; nLauncher = n; ! pLauncher->mfTimeToReady = 2.0f; // TODO: add db parameter for this return; } --- 322,326 ---- key = pLauncher->mnChildDBKey; nLauncher = n; ! pLauncher->mfTimeToReady = pLauncher->GetCycleTime(); return; } *************** *** 404,407 **** --- 406,426 ---- return false; } + + // do not set datum if not in range of launcher (only check for guns for now) + if (tcBallisticDBObject* ballDB = dynamic_cast<tcBallisticDBObject*> + (launchers[nLauncher].mpChildDBObj)) + { + float maxRange_km = ballDB->GetMaxLevelGunRangeKm(); + if (maxRange_km == 0) maxRange_km = 20.0f; // hack for non-guns for now + + if (parent->mcKin.RangeToKm(lon_rad, lat_rad) > maxRange_km) + { + wxString msg = wxString::Format("Out of range (%.1f km)", + maxRange_km); + tcGame::DisplayMessage(msg.c_str()); + return false; + } + } + launchers[nLauncher].msDatum.Set(lon_rad, lat_rad, alt_m); commandObj.SetNewCommand(GetLauncherFlag(nLauncher)); Index: tcBallisticWeapon.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcBallisticWeapon.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcBallisticWeapon.cpp 29 Jul 2004 00:14:18 -0000 1.2 --- tcBallisticWeapon.cpp 5 Aug 2004 02:22:35 -0000 1.3 *************** *** 50,80 **** } - /** - * Gets elevation for ballistic shell to hit (non-moving) target at a - * horizontal range of range_m and altitude difference of dz_m - * (Altitude difference is ignored for now.) - */ - float tcBallisticWeapon::GetGunneryElevation(float range_m, float dz_m) - { - wxASSERT(mpDBObject); - - float launchSpeed = mpDBObject->launchSpeed_mps; - float c = 0.25f * range_m * range_m * C_G * C_G; - float b = -launchSpeed * launchSpeed; - - float b2 = b * b; - float fac = 4.0f * c; - if (b2 < fac) - { - fprintf(stdout, "Warning - Gun out of range\n"); - return 0.25f * C_PI; - } - - float vz = sqrtf( 0.5f * (-b + sqrt(b2 - fac)) ); - - float elevation_rad = asinf(vz / launchSpeed); - - return elevation_rad; - } /** --- 50,53 ---- *************** *** 105,110 **** float range_m = 1000.0f * obj->mcKin.RangeToKm(&targetDatum); float dz_m = targetDatum.mfAlt_m - obj->mcKin.mfAlt_m; - mcKin.mfPitch_rad = GetGunneryElevation(range_m, dz_m); } --- 78,93 ---- float range_m = 1000.0f * obj->mcKin.RangeToKm(&targetDatum); float dz_m = targetDatum.mfAlt_m - obj->mcKin.mfAlt_m; + float tti_s; + + mcKin.mfPitch_rad = mpDBObject->GetGunneryElevation(range_m, dz_m, tti_s); + + /* + fprintf(stdout, "Gun launched from (%.3f, %.3f) to (%.3f, %.3f), " + "range %.1f m, spd %.1f m/s\n", + obj->mcKin.mfLat_rad * C_180OVERPI, obj->mcKin.mfLon_rad * C_180OVERPI, + targetDatum.mfLat_rad * C_180OVERPI, targetDatum.mfLon_rad * C_180OVERPI, + range_m, mpDBObject->launchSpeed_mps); + */ } *************** *** 121,124 **** --- 104,110 ---- // This is a tcWeaponObject method SetIntendedTarget(pLauncher->mnTargetID); + + + } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** Game.cpp 18 Jul 2004 03:18:01 -0000 1.87 --- Game.cpp 5 Aug 2004 02:22:35 -0000 1.88 *************** *** 473,477 **** if (tcOptions::Get()->mbPlayMusic) { ! tcSound::Get()->PlayMusic("loop1"); } --- 473,477 ---- if (tcOptions::Get()->mbPlayMusic) { ! tcSound::Get()->PlayMusic("gcb_theme2"); } |