[Gcblue-commits] gcb_wx/src/sim tcSubObject.cpp,NONE,1.1 Game.cpp,1.105,1.106 tcAirObject.cpp,1.14,1
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-11-23 23:33:06
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29552/src/sim Modified Files: Game.cpp tcAirObject.cpp tcESMSensor.cpp tcGameObject.cpp tcLauncherState.cpp tcMissileObject.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorState.cpp tcSimState.cpp tcSurfaceObject.cpp tcUserInfo.cpp Added Files: tcSubObject.cpp Log Message: Text message "message center" GUI screen Index: tcUserInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcUserInfo.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcUserInfo.cpp 2 Nov 2004 04:23:57 -0000 1.5 --- tcUserInfo.cpp 23 Nov 2004 23:31:18 -0000 1.6 *************** *** 31,40 **** #endif ! UINT8 tcUserInfo::GetOwnAlliance(void) { return mnOwnAlliance; } ! int tcUserInfo::IsOwnAlliance(UINT anAlliance) { return (anAlliance == mnOwnAlliance); --- 31,40 ---- #endif ! UINT8 tcUserInfo::GetOwnAlliance() const { return mnOwnAlliance; } ! int tcUserInfo::IsOwnAlliance(UINT anAlliance) const { return (anAlliance == mnOwnAlliance); Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcMissileObject.cpp 7 Nov 2004 03:40:45 -0000 1.20 --- tcMissileObject.cpp 23 Nov 2004 23:31:14 -0000 1.21 *************** *** 31,34 **** --- 31,35 ---- #include "tcSimState.h" #include "tc3DPoint.h" + #include "tcSubObject.h" #ifdef _DEBUG *************** *** 120,123 **** --- 121,128 ---- mcKin.mfLat_rad = pos.mfLat_rad; mcKin.mfAlt_m = pos.mfAlt_m; + if (tcSubObject* sub = dynamic_cast<tcSubObject*>(obj)) + { + subSurfaceLaunch = true; + } } else *************** *** 132,143 **** ! if (dynamic_cast<tcSurfaceObject*>(obj)) { ! // point surface launched missiles up ! mcKin.mfPitch_rad = 0.45f * C_PI; } else { ! mcKin.mfPitch_rad = obj->mcKin.mfPitch_rad; } --- 137,148 ---- ! if (dynamic_cast<tcAirObject*>(obj)) { ! mcKin.mfPitch_rad = obj->mcKin.mfPitch_rad; } else { ! // point surface launched missiles up ! mcKin.mfPitch_rad = 0.45f * C_PI; } *************** *** 145,152 **** msKState.mfAltitude_m = mcKin.mfAlt_m; ! if (msKState.mfAltitude_m < 5.0f) { msKState.mfAltitude_m = 5.0f; } msKState.mfSpeed_mps = obj->mcKin.mfSpeed_kts * (float)C_KTSTOMPS; --- 150,158 ---- msKState.mfAltitude_m = mcKin.mfAlt_m; ! if (!subSurfaceLaunch && (msKState.mfAltitude_m < 5.0f)) { msKState.mfAltitude_m = 5.0f; } + msKState.mfSpeed_mps = obj->mcKin.mfSpeed_kts * (float)C_KTSTOMPS; *************** *** 261,265 **** /*** check for crash ***/ ! if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m)||(mcKin.mfAlt_m <=0.0f)) { mfDamageLevel = 1.0f; tcString s; --- 267,278 ---- /*** check for crash ***/ ! bool underWater = (mcKin.mfAlt_m <= 0.0f); ! bool seaSurfaceCrash = (!subSurfaceLaunch) && underWater; ! ! // clear subSurfaceLaunch once weapon breaks surface ! if (!underWater) subSurfaceLaunch = false; ! ! if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m) || seaSurfaceCrash) ! { mfDamageLevel = 1.0f; tcString s; *************** *** 645,649 **** */ tcMissileObject::tcMissileObject() ! : tcWeaponObject() { Clear(); --- 658,662 ---- */ tcMissileObject::tcMissileObject() ! : tcWeaponObject(), subSurfaceLaunch(false) { Clear(); *************** *** 672,675 **** --- 685,689 ---- mfGoalSpeed_kts = o.mfGoalSpeed_kts; mfInterceptTime = o.mfInterceptTime; + subSurfaceLaunch = o.subSurfaceLaunch; mfLastGuidanceUpdate = o.mfLastGuidanceUpdate; guidanceStatusTime = o.guidanceStatusTime; *************** *** 686,690 **** */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcWeaponObject(obj) { mpDBObject = obj; --- 700,704 ---- */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcWeaponObject(obj), subSurfaceLaunch(false) { mpDBObject = obj; Index: tcESMSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcESMSensor.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcESMSensor.cpp 6 Nov 2004 15:13:42 -0000 1.9 --- tcESMSensor.cpp 23 Nov 2004 23:31:13 -0000 1.10 *************** *** 150,153 **** --- 150,161 ---- /** + * Alternative to dynamic_cast + */ + bool tcESMSensor::IsESM() const + { + return true; + } + + /** * */ Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcObjectControl.cpp 7 Nov 2004 03:40:45 -0000 1.22 --- tcObjectControl.cpp 23 Nov 2004 23:31:14 -0000 1.23 *************** *** 30,33 **** --- 30,34 ---- #include "tcObjectControl.h" #include "tcMissileObject.h" + #include "tcSubObject.h" #include "tcOptions.h" #include "tcUserInfo.h" *************** *** 40,43 **** --- 41,47 ---- #include "tcTime.h" #include "tcLauncher.h" + #include "tcControl.h" + #include "tcAltitudeBarControl.h" + #include <osg/Geometry> *************** *** 218,222 **** float width = mar[0][mnColumns-1].GetRight() - mar[0][0].left + 10.0f; ! float height = mar[0][0].GetBottom() - mfyloc + 15.0f; context->DrawRectangleR(mar[0][0].left - 5.0f, mfyloc, width, height, lineColor, tc3DWindow::FILL_OFF); --- 222,226 ---- float width = mar[0][mnColumns-1].GetRight() - mar[0][0].left + 10.0f; ! float height = mar[0][0].GetBottom() - mfyloc + 20.0f; context->DrawRectangleR(mar[0][0].left - 5.0f, mfyloc, width, height, lineColor, tc3DWindow::FILL_OFF); *************** *** 460,467 **** --- 464,473 ---- /*** mnClassID, mnModelType, mnType (classification) ***/ + /* GetObjectInfo(s ,mpHookedGameObj->mpDBObject, mpHookedGameObj); DrawTextR(s.GetBuffer(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 12; + */ /*** speed, heading, altitude, terrain info ***/ *************** *** 554,563 **** (mpHookedGameObj->mnModelType == MTYPE_HELO); ! bool mbDrawSpeed = mbSurface || mbAir; ! bool mbDrawAltitude = mbAir; // bool mbDrawEngagement = mbSurface; if (mbDrawSpeed) {DrawBarObject(&msSOI, pkin->mfSpeed_kts, mfGoalSpeed_kts);} ! if (mbDrawAltitude) {DrawBarObject(&msAltitude, pkin->mfAlt_m, mfGoalAlt_m);} //if (mbDrawEngagement) {DrawEngagementInfo(pGraphics);} --- 560,571 ---- (mpHookedGameObj->mnModelType == MTYPE_HELO); ! bool mbSub = (mpHookedGameObj->mnModelType == MTYPE_SUBMARINE); ! ! bool mbDrawSpeed = mbSurface || mbAir || mbSub; ! // bool mbDrawEngagement = mbSurface; if (mbDrawSpeed) {DrawBarObject(&msSOI, pkin->mfSpeed_kts, mfGoalSpeed_kts);} ! //if (mbDrawEngagement) {DrawEngagementInfo(pGraphics);} *************** *** 566,570 **** DrawSensorControl(); DrawLandingInfo(); ! DrawFuelInfo(); DrawBorder(); --- 574,581 ---- DrawSensorControl(); DrawLandingInfo(); ! ! if (!mbSub) DrawFuelInfo(); ! ! DrawControls(); DrawBorder(); *************** *** 622,626 **** const float barWidth = 8.0f; const float barHeight = 60.0f; ! const float xbar = 100.0f; const float ybar = 120.0f; //mnHeight-21-barHeight; --- 633,637 ---- const float barWidth = 8.0f; const float barHeight = 60.0f; ! const float xbar = 120.0f; const float ybar = 120.0f; //mnHeight-21-barHeight; *************** *** 778,783 **** { // place next to altitude bar ! float x = msAltitude.mrectbar.GetRight() + 8.0f; ! float y = msAltitude.mrectbar.GetBottom() - 2.0f; // negative is up osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); DrawTextR("Gear down", x, y, defaultFont.get(), --- 789,794 ---- { // place next to altitude bar ! float x = 70.0f; ! float y = 80.0f; osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); DrawTextR("Gear down", x, y, defaultFont.get(), *************** *** 931,934 **** --- 942,958 ---- } + + /** + * Calls Draw method of tcControl objects in controls vector + */ + void tcObjectControl::DrawControls() + { + size_t nControls = controls.size(); + for (size_t n=0; n<nControls; n++) + { + controls[n]->Draw(this); + } + } + /******************************************************************************/ void tcObjectControl::DrawEngagementInfo() *************** *** 971,975 **** #endif } ! /******************************************************************************/ void tcObjectControl::DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal) --- 995,1002 ---- #endif } ! ! /** ! * ! */ void tcObjectControl::DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal) *************** *** 1024,1035 **** DrawRectangleR(rcurrent, color, FILL_OFF); if (apBOI->mbVertical) { rcurrent.top = apBOI->mrectbar.GetTop(); ! rcurrent.bottom = rcurrent.top - (afValue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); } else { ! rcurrent.right = rcurrent.left + (afValue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); } color.set(0.4f, 1.0f, 0.4f, 1.0f); --- 1051,1065 ---- DrawRectangleR(rcurrent, color, FILL_OFF); + float valueRange = apBOI->mfmaxvalue - apBOI->mfminvalue; + float fractionalValue = (afValue - apBOI->mfminvalue) / valueRange; + if (apBOI->mbVertical) { rcurrent.top = apBOI->mrectbar.GetTop(); ! rcurrent.bottom = rcurrent.top - (fractionalValue)*(apBOI->mrectbar.Height()); } else { ! rcurrent.right = rcurrent.left + (fractionalValue)*(apBOI->mrectbar.Width()); } color.set(0.4f, 1.0f, 0.4f, 1.0f); *************** *** 1041,1044 **** --- 1071,1075 ---- if (fabsf(dVal) >= 0.0078125f) { + float fractionalGoalValue = (afValueGoal - apBOI->mfminvalue) / valueRange; float x1,x2,y1,y2; if (apBOI->mbVertical) *************** *** 1046,1050 **** x1 = rcurrent.GetLeft() - 2.0f; x2 = rcurrent.GetRight() + 2.0f; ! y1 = rcurrent.GetTop() - (afValueGoal/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); y2 = y1; } --- 1077,1081 ---- x1 = rcurrent.GetLeft() - 2.0f; x2 = rcurrent.GetRight() + 2.0f; ! y1 = rcurrent.GetTop() - (fractionalGoalValue)*(apBOI->mrectbar.Height()); y2 = y1; } *************** *** 1053,1057 **** y1 = rcurrent.GetBottom() - 2.0f; y2 = rcurrent.GetTop() + 2.0f; ! x1 = rcurrent.left + (afValueGoal/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); x2 = x1; } --- 1084,1088 ---- y1 = rcurrent.GetBottom() - 2.0f; y2 = rcurrent.GetTop() + 2.0f; ! x1 = rcurrent.left + (fractionalGoalValue)*(apBOI->mrectbar.Width()); x2 = x1; } *************** *** 1064,1067 **** --- 1095,1101 ---- if (apBOI->mfmousevalue > apBOI->mfmaxvalue) {apBOI->mfmousevalue = apBOI->mfmaxvalue;} if (apBOI->mfmousevalue < apBOI->mfminvalue) {apBOI->mfmousevalue = apBOI->mfminvalue;} + + float fractionalMouseValue = (apBOI->mfmousevalue - apBOI->mfminvalue) / valueRange; + color.set(1, 1, 1, 0.63f); *************** *** 1070,1079 **** rcurrent.top = apBOI->mrectbar.GetTop(); rcurrent.bottom = rcurrent.top - ! (apBOI->mfmousevalue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); } else { rcurrent.right = rcurrent.left + ! (apBOI->mfmousevalue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); } DrawRectangleR(rcurrent, color, FILL_ON); --- 1104,1113 ---- rcurrent.top = apBOI->mrectbar.GetTop(); rcurrent.bottom = rcurrent.top - ! (fractionalMouseValue)*(apBOI->mrectbar.Height()); } else { rcurrent.right = rcurrent.left + ! (fractionalMouseValue)*(apBOI->mrectbar.Width()); } DrawRectangleR(rcurrent, color, FILL_ON); *************** *** 1166,1169 **** --- 1200,1206 ---- strcpy(zModel,"FIELD"); break; + case MTYPE_SUBMARINE: + strcpy(zModel,"SUB"); + break; default: strcpy(zModel,"ERR"); *************** *** 1296,1317 **** } } - else if (msAltitude.mrectcontrol.ContainsPoint((float)point.x,(float)point.y)) - { - tcAirObject *pAirObj = dynamic_cast<tcAirObject*>(mpHookedGameObj); - if (pAirObj != NULL) - { - pAirObj->mcGS.SetAltitude(msAltitude.mfmousevalue); - } - msAltitude.mbMouseOver = false; - } ! else { ! return; } - } bool tcObjectControl::ProcessWeaponPanelButton(int anLauncher, int anButton) { --- 1333,1350 ---- } } ! ! event.m_y = mnHeight - event.m_y; ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) { ! controls[n]->OnLButtonDown(event); } } + /** + * + */ bool tcObjectControl::ProcessWeaponPanelButton(int anLauncher, int anButton) { *************** *** 1416,1420 **** return false; } ! /******************************************************************************/ void tcObjectControl::OnMouseMove(wxMouseEvent& event) { --- 1449,1469 ---- return false; } ! ! /** ! * Calls SetGameObject method of tcControl objects in controls ! * vector. ! */ ! void tcObjectControl::SetControlGameObject(tcGameObject* obj) ! { ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! controls[n]->SetGameObject(obj); ! } ! } ! ! /** ! * ! */ void tcObjectControl::OnMouseMove(wxMouseEvent& event) { *************** *** 1449,1460 **** msFormRange.mfmaxvalue; } - else if (msAltitude.mrectcontrol.ContainsPoint(fx, fy)) - { - msAltitude.mbMouseOver = true; - //msAltitude.mfmousevalue = msAltitude.mfmaxvalue; - msAltitude.mfmousevalue = (msAltitude.mrectbar.GetTop()-fy)/(msAltitude.mrectbar.Height())* - msAltitude.mfmaxvalue; - - } else { --- 1498,1501 ---- *************** *** 1463,1467 **** msFormHeading.mbMouseOver = false; msFormRange.mbMouseOver = false; ! msAltitude.mbMouseOver = false; } --- 1504,1514 ---- msFormHeading.mbMouseOver = false; msFormRange.mbMouseOver = false; ! } ! ! event.m_y = mnHeight - event.m_y; ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! controls[n]->OnMouseMove(event); } *************** *** 1518,1529 **** msFormRange.mbVertical = false; ! // altitude control ! msAltitude.mbMouseOver = false; ! msAltitude.mrectcontrol.left = 60.0f; ! msAltitude.mrectcontrol.bottom = 120.0f; ! msAltitude.mrectcontrol.right = msAltitude.mrectcontrol.left + 8.0f; ! msAltitude.mrectcontrol.top = msAltitude.mrectcontrol.bottom + 60.0f; ! msAltitude.mrectbar = msAltitude.mrectcontrol; ! msAltitude.mbVertical = true; } --- 1565,1574 ---- msFormRange.mbVertical = false; ! ! ! altitudeControl = new tcAltitudeBarControl(60, 17, 10, 60); ! altitudeControl->SetActive(true); ! controls.push_back(altitudeControl); ! } *************** *** 1536,1539 **** --- 1581,1587 ---- if (mnHookID==NULL_INDEX) {mpHookedGameObj=NULL;return;} bFound = mpSS->GetPlatformState(mnHookID,mpHookedGameObj); + + SetControlGameObject(mpHookedGameObj); + if (!bFound) {return;} *************** *** 1550,1560 **** --- 1598,1612 ---- } + altitudeControl->SetActive(true); + switch (mpHookedGameObj->mnModelType) { case MTYPE_SURFACE: case MTYPE_CARRIER: + altitudeControl->SetActive(false); case MTYPE_FIXEDWING: case MTYPE_FIXEDWINGX: case MTYPE_HELO: + case MTYPE_SUBMARINE: { //tcSurfaceObject *pSurfaceObj = (tcSurfaceObject*)mpHookedGameObj; *************** *** 1575,1582 **** msFormRange.mrectbar.right -= 5.0f; - msAltitude.mrectbar = msAltitude.mrectcontrol; - msAltitude.mfminvalue = 50.0f; - msAltitude.mfmaxvalue = pGenericData->mfMaxAltitude_m; - } break; --- 1627,1630 ---- *************** *** 1667,1670 **** tcObjectControl::~tcObjectControl() { ! } --- 1715,1723 ---- tcObjectControl::~tcObjectControl() { ! // delete controls ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! delete controls[n]; ! } } Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcSurfaceObject.cpp 2 Nov 2004 04:23:57 -0000 1.13 --- tcSurfaceObject.cpp 23 Nov 2004 23:31:18 -0000 1.14 *************** *** 210,213 **** --- 210,214 ---- mnModelType = MTYPE_SURFACE; mcEngagementData.mnCount = 0; + mcGS.mfGoalAltitude_m = 0; } Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcGameObject.cpp 6 Nov 2004 15:13:42 -0000 1.24 --- tcGameObject.cpp 23 Nov 2004 23:31:13 -0000 1.25 *************** *** 170,173 **** --- 170,183 ---- } + /** + * Used to decide when to display info messages and play sound + * effects. + * @return true if object is under user control + */ + bool tcGameObject::IsOwnAlliance() const + { + return simState->mpUserInfo->IsOwnAlliance(mnAlliance) != 0; + } + tsGeoPoint tcGameObject::RelPosToLatLonAlt(const tsRelativePosition& rel_pos) const { --- NEW FILE: tcSubObject.cpp --- /** ** @file tcSubObject.cpp ** Basic submarine model */ /* Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcSubObject.h" #include "tcGenericDBObject.h" #include "tc3DModel.h" #include "tcParticleEffect.h" #include "common/tcObjStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /******************************************************************************/ /****************************** tcSubObject *******************************/ /******************************************************************************/ /** * */ tcCommandStream& tcSubObject::operator<<(tcCommandStream& stream) { tcPlatformObject::operator<<(stream); return stream; } /** * */ tcCommandStream& tcSubObject::operator>>(tcCommandStream& stream) { tcPlatformObject::operator>>(stream); return stream; } /** * */ tcUpdateStream& tcSubObject::operator<<(tcUpdateStream& stream) { tcPlatformObject::operator<<(stream); return stream; } /** * */ tcUpdateStream& tcSubObject::operator>>(tcUpdateStream& stream) { tcPlatformObject::operator>>(stream); return stream; } /** * */ void tcSubObject::ClearNewCommand() { tcPlatformObject::ClearNewCommand(); commandObj.ClearNewCommand(); } bool tcSubObject::HasNewCommand() const { return tcPlatformObject::HasNewCommand() || commandObj.HasNewCommand(); } /** * */ bool tcSubObject::HasUnacknowledgedCommand() const { return tcPlatformObject::HasUnacknowledgedCommand() || commandObj.HasUnacknowledgedCommand(); } /** * */ void tcSubObject::Clear() { tcPlatformObject::Clear(); } /** * */ void tcSubObject::RandInitNear(float afLon_deg, float afLat_deg) { if (mpDBObject == NULL) {return;} strcpy(mzClass.mz, mpDBObject->mzClass.mz); mzUnit = "SUB_"; mzUnit.AssignRandomSuffix(); mnAlliance = 0; mfStatusTime = 0; mcKin.mfLon_rad = C_PIOVER180*(afLon_deg + randfc(1.1f)); mcKin.mfLat_rad = C_PIOVER180*(afLat_deg + randfc(1.1f)); mcKin.mfAlt_m = -65.0f; mcKin.mfHeading_rad = C_TWOPI*randf(); mcKin.mfSpeed_kts = 0.20f*mpDBObject->mfMaxSpeed_kts; mcKin.mfPitch_rad = 0; mcKin.mfRoll_rad = 0; mfDamageLevel = 0; SetHeading(mcKin.mfHeading_rad); SetSpeed(mcKin.mfSpeed_kts); SetAltitude(mcKin.mfAlt_m); } /** * */ void tcSubObject::PrintToFile(tcFile& file) { tcPlatformObject::PrintToFile(file); } /** * */ void tcSubObject::SaveToFile(tcFile& file) { tcPlatformObject::SaveToFile(file); } /** * */ void tcSubObject::LoadFromFile(tcFile& file) { tcPlatformObject::LoadFromFile(file); } /** * */ void tcSubObject::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); } else { SaveToFile(file); } } /** * @return periscope depth in meters (negative number) */ float tcSubObject::GetPeriscopeDepth() const { return periscopeDepth_m; } /** * */ bool tcSubObject::GetPeriscopeState() const { return periscopeRaised; } /** * */ bool tcSubObject::GetRadarMastState() const { return radarMastRaised; } bool tcSubObject::IsAtPeriscopeDepth() const { return mcKin.mfAlt_m >= -periscopeDepth_m; } bool tcSubObject::IsSurfaced() const { return mcKin.mfAlt_m == 0; } /** * */ void tcSubObject::SetPeriscopeState(bool state) { periscopeRaised = state; } /** * */ void tcSubObject::SetRadarMastState(bool state) { radarMastRaised = state; } /** * */ void tcSubObject::ApplyRestrictions() { // check for crash (bottom) if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { mfDamageLevel = 1.0f; } if (mcKin.mfAlt_m < -periscopeDepth_m) { SetPeriscopeState(false); SetRadarMastState(false); } else if (mcKin.mfAlt_m > 0) { mcKin.mfAlt_m = 0; // subs can't fly } } /** * Update climb related parameters. This has problems for large time * steps, > about 1 sec */ void tcSubObject::UpdateClimb(float dt_s) { // restrict to max depth if (mcGS.mfGoalAltitude_m < -mpDBObject->mfMaxDepth_m) { mcGS.mfGoalAltitude_m = -mpDBObject->mfMaxDepth_m; } // avoid bottoming out if (mcGS.mfGoalAltitude_m < mcTerrain.mfHeight_m + 10) { mcGS.mfGoalAltitude_m = mcTerrain.mfHeight_m + 10; } else if (mcGS.mfGoalAltitude_m > 0) { mcGS.mfGoalAltitude_m = 0; } float dalt_m = mcGS.mfGoalAltitude_m - mcKin.mfAlt_m; const float levelThresh_rad = 0.0035f; // 0.2 deg if ((dalt_m > -0.05f)&&(dalt_m < 0.05f)&& (mcKin.mfClimbAngle_rad < levelThresh_rad)&&(mcKin.mfClimbAngle_rad > -levelThresh_rad)) { mcKin.mfClimbAngle_rad = 0; mcKin.mfPitch_rad = 0; mcKin.mfAlt_m += dalt_m; return; } const float fHighZone = 25.0f; const float fLowZone = -25.0f; float goalPitch = 0; float maxPitch = maxPitch_rad; if (mcKin.mfAlt_m > -10) maxPitch *= 0.5f; if (dalt_m > fHighZone) { goalPitch = maxPitch_rad; } else if (dalt_m < fLowZone) { goalPitch = -maxPitch_rad; } else { goalPitch = 0.04f * dalt_m * maxPitch_rad; } if (goalPitch > maxPitch) goalPitch = maxPitch; else if (goalPitch < -maxPitch) goalPitch = -maxPitch; float oldAngle_rad = mcKin.mfClimbAngle_rad; float alpha = 0.5f * dt_s; mcKin.mfClimbAngle_rad = alpha*goalPitch + (1-alpha)*oldAngle_rad; mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; // add slow vertical ascent/descent component if (mcKin.mfAlt_m > -5) { float dz = (dalt_m > 0) ? 0.5f * dt_s : -0.5f * dt_s; mcKin.mfAlt_m += dz; } } /** * */ void tcSubObject::UpdateEffects() { if (model) { if ((mcKin.mfAlt_m < -10)&&(mcKin.mfSpeed_kts > 10)) { model->SetSmokeMode(tcParticleEffect::BUBBLES); } else { model->SetSmokeMode(tcParticleEffect::OFF); } model->UpdateEffects(); } } /** * */ void tcSubObject::UpdateHeading(float dt_s) { if (dt_s == 0) {return;} tcPlatformObject::UpdateHeading(dt_s); mcKin.mfRoll_rad = 0; } /** * Update radars if radar mast is raised * Update visual sensors if periscope is raised * Deactivate sensors that do not have mast/periscope in required state * Update sensor height for periscope and radar mast to be 4.0 m above water */ void tcSubObject::UpdateSensors(double t) { if (clientMode) return; // no sensor update for client unsigned nSensors = mapSensorState.size(); for(unsigned n=0; n<nSensors; n++) { tcSensorState* sensor = mapSensorState[n]; wxASSERT(sensor); if (sensor->IsSonar()) { sensor->Update(t); } else if (sensor->IsRadar() && radarMastRaised) { sensor->mfSensorHeight_m = 4.0f + mcKin.mfAlt_m; sensor->Update(t); } else if ((sensor->IsESM() && radarMastRaised) || (sensor->IsOptical() && periscopeRaised)) { sensor->mfSensorHeight_m = 4.0f + mcKin.mfAlt_m; sensor->SetActive(true); // assume ESM and optical always active if possible sensor->Update(t); } else { sensor->SetActive(false); } } } /** * */ void tcSubObject::UpdateSpeed(float dt_s) { tcPlatformObject::UpdateSpeed(dt_s); } /** * */ void tcSubObject::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); UpdateEffects(); // shouldn't be called for child objects if (parent != NULL) {return;} // captive, let parent update if applicable if (dt_s <= min_update_s) {return;} // added for pause case wxASSERT(mpDBObject); UpdateFormationGuidance(); // formation heading/speed calculation UpdateHeading(dt_s); UpdateSpeed(dt_s); UpdateClimb(dt_s); ApplyRestrictions(); // crash check Move(dt_s); UpdateLauncherState(dt_s); UpdateSensors(afStatusTime); mfStatusTime = afStatusTime; } /** * */ tcSubObject::tcSubObject() : maxPitch_rad(0.5), periscopeDepth_m(18) { mnModelType = MTYPE_SUBMARINE; SetAltitude(-100.0f); SetHeading(75.0f); SetSpeed(7.0f); } /** * Constructor that initializes using info from database entry. */ tcSubObject::tcSubObject(tcGenericDBObject *obj) : tcPlatformObject(obj), maxPitch_rad(0.5), periscopeDepth_m(18) { mpDBObject = obj; mnModelType = MTYPE_SUBMARINE; } /** * */ tcSubObject::~tcSubObject() { } Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcOpticalSensor.cpp 6 Nov 2004 15:13:42 -0000 1.1 --- tcOpticalSensor.cpp 23 Nov 2004 23:31:17 -0000 1.2 *************** *** 174,177 **** --- 174,185 ---- /** + * Alternative to dynamic_cast + */ + bool tcOpticalSensor::IsOptical() const + { + return true; + } + + /** * */ Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcAirObject.cpp 14 Nov 2004 22:52:22 -0000 1.14 --- tcAirObject.cpp 23 Nov 2004 23:31:12 -0000 1.15 *************** *** 199,202 **** --- 199,208 ---- } + // avoid crashing + if (mcGS.mfGoalAltitude_m < mcTerrain.mfHeight_m + 20) + { + mcGS.mfGoalAltitude_m = mcTerrain.mfHeight_m + 20; + } + float dalt_m = mcGS.mfGoalAltitude_m - mcKin.mfAlt_m; // float valt_kts = (daltitude_m/dt_s)*C_MPSTOKTS; Index: tcSensorState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorState.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcSensorState.cpp 6 Nov 2004 15:13:42 -0000 1.12 --- tcSensorState.cpp 23 Nov 2004 23:31:18 -0000 1.13 *************** *** 121,125 **** bool tcSensorState::IsHidden() const { ! return isHidden; } --- 121,157 ---- bool tcSensorState::IsHidden() const { ! return isHidden; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsESM() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsRadar() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsSonar() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsOptical() const ! { ! return false; } Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** tcSimState.cpp 14 Nov 2004 22:52:22 -0000 1.58 --- tcSimState.cpp 23 Nov 2004 23:31:18 -0000 1.59 *************** *** 42,45 **** --- 42,46 ---- #include "tcBallisticDBObject.h" #include "tcHeloObject.h" + #include "tcSubObject.h" #include "tcLauncher.h" *************** *** 1435,1438 **** --- 1436,1443 ---- return new tcAirfieldObject(pGenericData); } + else if (apDBObject->mnModelType == MTYPE_SUBMARINE) + { + return new tcSubObject(pGenericData); + } else { Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcLauncherState.cpp 2 Nov 2004 04:23:56 -0000 1.20 --- tcLauncherState.cpp 23 Nov 2004 23:31:14 -0000 1.21 *************** *** 231,234 **** --- 231,244 ---- if (!ldata.mbActive) {return LAUNCHER_INACTIVE;} // launcher inactive or damaged + wxASSERT(simState); + wxASSERT(parent); + + // limit depth for launching sub-launched missiles + if (tcMissileDBObject* missile = + dynamic_cast<tcMissileDBObject*>(ldata.mpChildDBObj)) + { + if (parent->mcKin.mfAlt_m < -30.0) return TOO_DEEP; + } + if (ldata.meLaunchMode == DATUM_ONLY) // needs a datum programmed to launch { *************** *** 243,248 **** } ! wxASSERT(simState); ! wxASSERT(parent); --- 253,257 ---- } ! *************** *** 546,549 **** --- 555,562 ---- return "No fire control sensor (database error)"; } + if (status == TOO_DEEP) + { + return "Too deep for launch"; + } std::cerr << "Bad launcher status code"; Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** Game.cpp 14 Nov 2004 22:52:21 -0000 1.105 --- Game.cpp 23 Nov 2004 23:30:58 -0000 1.106 *************** *** 331,335 **** viewer->SetTerrainActive(false); viewer->SetClearMode(1); // depth clearing ! viewer->SetText(""); size3D = MODE3D_START; --- 331,335 ---- viewer->SetTerrainActive(false); viewer->SetClearMode(1); // depth clearing ! viewer->SetText(" "); size3D = MODE3D_START; *************** *** 456,460 **** r.y = 2; r.width = mnWidth-margin; ! r.height = mnHeight-mnBottomMargin-1; } else if (size3D == MODE3D_FULL) --- 456,460 ---- r.y = 2; r.width = mnWidth-margin; ! r.height = mnHeight-mnBottomMargin-3; } else if (size3D == MODE3D_FULL) Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcRadar.cpp 7 Nov 2004 03:40:45 -0000 1.16 --- tcRadar.cpp 23 Nov 2004 23:31:17 -0000 1.17 *************** *** 30,33 **** --- 30,34 ---- #include "tcAirfieldObject.h" #include "tcBallisticWeapon.h" + #include "tcSubObject.h" #include "tcGenericDBObject.h" *************** *** 129,132 **** --- 130,139 ---- return false; } + else if (const tcSubObject* sub = dynamic_cast<const tcSubObject*>(target)) + { + if (sub->mcKin.mfAlt_m < -2.0f) return false; + rcs_dBsm = sub->mpDBObject->mfRcs_dbsm; + isSurface = true; + } else { *************** *** 279,282 **** --- 286,297 ---- /** + * Alternative to dynamic_cast + */ + bool tcRadar::IsRadar() const + { + return true; + } + + /** * Does not test if radar can detect target. * @return true if track is available. *************** *** 446,449 **** --- 461,469 ---- teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_MISSILE) {eAffil = HOSTILE;} + // surfaced sub classified as small surface + if (nClassification & PTYPE_SUBMARINE) + { + nClassification = PTYPE_SMALLSURFACE; + } pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); pReport->mbClassified = 1; *************** *** 478,481 **** --- 498,502 ---- float range_km = 0; bool bDetected = (parent->mnAlliance != target->mnAlliance) && + (target->mcKin.mfAlt_m > -2.0f) && // ignore subsurface CanDetectTarget(target,range_km); if (bDetected) UpdateSensorMap(t, target, range_km); |