[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.48,1.49 tcCarrierObject.cpp,1.4,1.5 tcESMSensorState.cpp,
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-01-04 22:24:56
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1:/tmp/cvs-serv2798/src/sim Modified Files: Game.cpp tcCarrierObject.cpp tcESMSensorState.cpp tcFlightPort.cpp tcLauncherState.cpp tcMissileObject.cpp tcObjectControl.cpp tcPlatformObject.cpp tcPopupControl.cpp tcRadarSensorState.cpp tcSensorState.cpp tcSimState.cpp Log Message: Added database class for flightports Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Game.cpp 3 Jan 2004 03:51:17 -0000 1.48 --- Game.cpp 4 Jan 2004 22:24:52 -0000 1.49 *************** *** 1,2 **** --- 1,3 ---- + /** @file Game.cpp main application class */ /** * Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) *************** *** 333,337 **** mcDatabase.LoadDBCSV(); ! //mcDatabase.SaveDBCSV(); tcGameObject::SetGameObjectDatabase(&mcDatabase); // added to allow objects to init themselves --- 334,341 ---- mcDatabase.LoadDBCSV(); ! // uncomment the SaveDBCSV line to save copy of database to _out suffix, ! // warning, this erroneously puts a copy of air DB objects into the generic file ! // need to fix DB obj structure so that only leaf classes are used by game objects ! //mcDatabase.SaveDBCSV("_out"); tcGameObject::SetGameObjectDatabase(&mcDatabase); // added to allow objects to init themselves *************** *** 1569,1573 **** else { ! //* ProcessCommand(cmd_info.meCmd,cmd_info.mfData,cmd_info.mnData,cmd_info.mnData2); } } --- 1573,1581 ---- else { ! if (cmd_info.meCmd == GC_QUIT) // a hack for now ! { ! mbQuit = true; ! } ! // ProcessCommand(cmd_info.meCmd,cmd_info.mfData,cmd_info.mnData,cmd_info.mnData2); } } *************** *** 1855,1861 **** switch (aeCmd) { ! case GC_NULL: ! WTL("tcGame::ProcessCommand GC_NULL"); ! break; case GC_TOGGLEEDIT: mbScenarioEdit = !mbScenarioEdit; --- 1863,1867 ---- switch (aeCmd) { ! /* case GC_TOGGLEEDIT: mbScenarioEdit = !mbScenarioEdit; *************** *** 1870,1877 **** mbPaused = true; break; case GC_QUIT: WTL("tcGame::ProcessCommand GC_QUIT"); ! PostMessage(WM_QUIT, 0, 0); break; case GC_RESETMAP: WTL("tcGame::ProcessCommand GC_RESETMAP"); --- 1876,1885 ---- mbPaused = true; break; + */ case GC_QUIT: WTL("tcGame::ProcessCommand GC_QUIT"); ! mbQuit = true; break; + /* case GC_RESETMAP: WTL("tcGame::ProcessCommand GC_RESETMAP"); *************** *** 2006,2009 **** --- 2014,2018 ---- mcObjectControl.SetHookID(NULL_INDEX); break; + */ default: WTL("tcGame::ProcessCommand unrecognized game command"); Index: tcCarrierObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcCarrierObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcCarrierObject.cpp 8 Dec 2003 03:06:36 -0000 1.4 --- tcCarrierObject.cpp 4 Jan 2004 22:24:52 -0000 1.5 *************** *** 22,26 **** #include "tcAeroAirObject.h" #include "tcAirDBObject.h" ! /******************************************************************************/ --- 22,26 ---- #include "tcAeroAirObject.h" #include "tcAirDBObject.h" ! #include "tcFlightportDBObject.h" /******************************************************************************/ *************** *** 73,76 **** --- 73,97 ---- mcGS.SetAltitude(mcKin.mfAlt_m); + int nAircraft = flight_deck.GetHangarCapacity(); + for(int i=0;i<nAircraft;i++) + { + // add FW air child for test + tcDatabaseObject *dbObj = database->GetRandomOfType(MTYPE_FIXEDWINGX); + tcAirDBObject *airDBObj = dynamic_cast<tcAirDBObject*>(dbObj); + tcAeroAirObject *child = NULL; + if (airDBObj) child = new tcAeroAirObject(airDBObj); + wxASSERT(child); + if (child != NULL) + { + child->mzUnit = "AIRX_"; + child->mzUnit.AssignRandomSuffix(); + float z = -20.0f + (float)i * 18.0f; + child->SetRelativePosition(7.5,12.0,z); + child->SetRelativeOrientation(0,0,0); + AddChild(child); + flight_deck.AddObject(child, LAUNCH); + } + } + } *************** *** 146,150 **** Clear(); ! SetFlightportDefaults(); mpDBObject = NULL; --- 167,171 ---- Clear(); ! //SetFlightportDefaults(); mpDBObject = NULL; *************** *** 168,193 **** : tcSurfaceObject(obj) { mpDBObject = obj; ! SetFlightportDefaults(); ! ! for(int i=0;i<8;i++) { ! // add FW air child for test ! tcDatabaseObject *dbObj = database->GetRandomOfType(MTYPE_FIXEDWINGX); ! tcAirDBObject *airDBObj = dynamic_cast<tcAirDBObject*>(dbObj); ! tcAeroAirObject *child = NULL; ! if (airDBObj) child = new tcAeroAirObject(airDBObj); ! if (child != NULL) ! { ! child->mzUnit = "AIRX_"; ! child->mzUnit.AssignRandomSuffix(); ! float z = -20.0f + (float)i * 18.0f; ! child->SetRelativePosition(7.5,12.0,z); ! child->SetRelativeOrientation(0,0,0); ! AddChild(child); ! flight_deck.AddObject(child, LAUNCH); ! } } } /******************************************************************************/ --- 189,207 ---- : tcSurfaceObject(obj) { + wxASSERT(database); mpDBObject = obj; ! ! tcFlightportDBObject* flightportDBObj = dynamic_cast<tcFlightportDBObject*> ! (database->GetObject(obj->flightportClass.mz)); ! wxASSERT(flightportDBObj); ! if (flightportDBObj == NULL) { ! std::cerr << "Flightport database obj not found for carrier obj: "; ! std::cerr << mzUnit.mz << "\n"; ! return; } + + flight_deck.InitFromDatabase(flightportDBObj); } /******************************************************************************/ Index: tcESMSensorState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcESMSensorState.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcESMSensorState.cpp 4 Dec 2003 05:15:22 -0000 1.1 --- tcESMSensorState.cpp 4 Jan 2004 22:24:53 -0000 1.2 *************** *** 25,31 **** * */ ! bool tcESMSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey) { ! tcSensorState::InitFromDB(apDatabase, anKey); mpDBObj = dynamic_cast<tcESMDBObject*>(apDatabase->GetObject(anKey)); --- 25,31 ---- * */ ! bool tcESMSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad) { ! tcSensorState::InitFromDB(apDatabase, anKey, mountAzimuth_rad); mpDBObj = dynamic_cast<tcESMDBObject*>(apDatabase->GetObject(anKey)); Index: tcFlightPort.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightPort.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcFlightPort.cpp 30 Oct 2003 01:21:46 -0000 1.3 --- tcFlightPort.cpp 4 Jan 2004 22:24:53 -0000 1.4 *************** *** 1,8 **** ! #ifdef WX_PRECOMP ! #include "stdwx.h" #endif #include "tcFlightPort.h" #include "tcAirObject.h" --- 1,34 ---- ! /** @file tcFlightport.cpp */ ! /** ! * Copyright (C) 2003 Dewitt "Cole" 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" // precompiled header file ! ! #ifndef WX_PRECOMP ! #include "wx/wx.h" ! #ifdef WIN32 ! #include "wx/msw/private.h" // for MS Windows specific definitions ! #endif #endif #include "tcFlightPort.h" #include "tcAirObject.h" + #include "tcFlightportDBObject.h" *************** *** 312,315 **** --- 338,364 ---- } } + + /** + * Initialize flightport using data in dbObj. + */ + void tcFlightPort::InitFromDatabase(Database::tcFlightportDBObject *dbObj) + { + wxASSERT(dbObj); + + Clear(); + hangarCapacity = dbObj->hangarCapacity; + inHangarCount = 0; + + size_t nSpots = dbObj->spotInfo.size(); + for(size_t spot=0;spot<nSpots;spot++) + { + tcFlightportDBObject::spotDBInfo info = dbObj->spotInfo[spot]; + + teLocation loc = (info.isLaunch) ? LAUNCH : READY; + AddSpot(loc, info.x, info.y, info.z, C_PIOVER180*info.orientation_deg, info.length); + } + + } + /** * Set unit position and orientation to match that of current spot. Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcLauncherState.cpp 4 Dec 2003 05:15:22 -0000 1.1 --- tcLauncherState.cpp 4 Jan 2004 22:24:53 -0000 1.2 *************** *** 25,29 **** * */ ! void tcLauncherState::AddFullLauncher(tcDatabase *pDatabase, tnPoolIndex anKey) { tcLauncherDBObject *ldata; --- 25,29 ---- * */ ! void tcLauncherState::AddFullLauncher(tcDatabase *pDatabase, tnPoolIndex anKey, float azimuth_rad) { tcLauncherDBObject *ldata; *************** *** 68,71 **** --- 68,72 ---- ma[mnCount].meLaunchMode = AUTO; ma[mnCount].mnPending = 0; + ma[mnCount].pointingAngle = azimuth_rad; // set detailed launch mode if missile tcMissileDBObject* pMissileDBObj = dynamic_cast<tcMissileDBObject*>(pDatabase->GetObject(nChildKey)); Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcMissileObject.cpp 14 Dec 2003 20:58:47 -0000 1.3 --- tcMissileObject.cpp 4 Jan 2004 22:24:53 -0000 1.4 *************** *** 407,411 **** // init sensors, only one sensor (primary) supported in this version tnPoolIndex nSensorKey = database->GetKey(obj->maSensorClass[0]); ! mcSensorState.InitFromDB(database,nSensorKey); } --- 407,411 ---- // init sensors, only one sensor (primary) supported in this version tnPoolIndex nSensorKey = database->GetKey(obj->maSensorClass[0]); ! mcSensorState.InitFromDB(database,nSensorKey, 0); // missile seeker always points forward } Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcObjectControl.cpp 8 Dec 2003 03:06:36 -0000 1.8 --- tcObjectControl.cpp 4 Jan 2004 22:24:53 -0000 1.9 *************** *** 1501,1505 **** msOCSymbolList.maSymbol[k].mfLatExtent_rad = fRangeY_rad; msOCSymbolList.maSymbol[k].mfLonExtent_rad = fRangeX_rad; ! msOCSymbolList.maSymbol[k].mfArcCenter_deg = mpHookedGameObj->mcKin.mfHeading_rad*C_180OVERPI; msOCSymbolList.maSymbol[k].mfArcLength_deg = pRadarSS->mpDBObj->mfFieldOfView_deg; if (msOCSymbolList.maSymbol[k].mfArcLength_deg < 360.0f) --- 1501,1507 ---- msOCSymbolList.maSymbol[k].mfLatExtent_rad = fRangeY_rad; msOCSymbolList.maSymbol[k].mfLonExtent_rad = fRangeX_rad; ! float sensorAz_deg = (mpHookedGameObj->mcKin.mfHeading_rad + pRadarSS->mountAz_rad) ! * C_180OVERPI; ! msOCSymbolList.maSymbol[k].mfArcCenter_deg = sensorAz_deg; // wrt North msOCSymbolList.maSymbol[k].mfArcLength_deg = pRadarSS->mpDBObj->mfFieldOfView_deg; if (msOCSymbolList.maSymbol[k].mfArcLength_deg < 360.0f) Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcPlatformObject.cpp 8 Dec 2003 03:06:36 -0000 1.7 --- tcPlatformObject.cpp 4 Jan 2004 22:24:53 -0000 1.8 *************** *** 411,415 **** { tnPoolIndex nLauncherKey = database->GetKey(mpDBObject->maLauncherClass[nLauncher]); ! mcLauncherState.AddFullLauncher(database,nLauncherKey); } --- 411,416 ---- { tnPoolIndex nLauncherKey = database->GetKey(mpDBObject->maLauncherClass[nLauncher]); ! float launcherAz_deg = mpDBObject->launcherAz[nLauncher]; ! mcLauncherState.AddFullLauncher(database, nLauncherKey, C_PIOVER180*launcherAz_deg); } *************** *** 425,432 **** tnPoolIndex nSensorKey = database->GetKey(mpDBObject->maSensorClass[i]); tcDatabaseObject *pDBObj = database->GetObject(nSensorKey); if (tcRadarDBObject *pRadarDBObj = dynamic_cast<tcRadarDBObject*>(pDBObj)) { tcRadarSensorState *pRadarSS = new tcRadarSensorState; ! pRadarSS->InitFromDB(database,nSensorKey); pRadarSS->mpDBObj = pRadarDBObj; pSensorState = pRadarSS; --- 426,435 ---- tnPoolIndex nSensorKey = database->GetKey(mpDBObject->maSensorClass[i]); tcDatabaseObject *pDBObj = database->GetObject(nSensorKey); + float lookAz_rad = C_PIOVER180 * mpDBObject->sensorAz[i]; + if (tcRadarDBObject *pRadarDBObj = dynamic_cast<tcRadarDBObject*>(pDBObj)) { tcRadarSensorState *pRadarSS = new tcRadarSensorState; ! pRadarSS->InitFromDB(database, nSensorKey, lookAz_rad); pRadarSS->mpDBObj = pRadarDBObj; pSensorState = pRadarSS; *************** *** 435,439 **** { tcESMSensorState *pESMSS = new tcESMSensorState; ! pESMSS->InitFromDB(database,nSensorKey); pESMSS->mpDBObj = pESMDBObj; pSensorState = pESMSS; --- 438,442 ---- { tcESMSensorState *pESMSS = new tcESMSensorState; ! pESMSS->InitFromDB(database, nSensorKey, lookAz_rad); pESMSS->mpDBObj = pESMDBObj; pSensorState = pESMSS; Index: tcPopupControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPopupControl.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcPopupControl.cpp 30 Nov 2003 17:23:52 -0000 1.4 --- tcPopupControl.cpp 4 Jan 2004 22:24:53 -0000 1.5 *************** *** 96,107 **** mcGameMenu.Clear(); ! mcGameMenu.AddItem("Switch to scenedit mode", GC_TOGGLEEDIT); ! mcGameMenu.AddItem("File", 0); ! mcGameMenu.BeginSubMenu(); ! mcGameMenu.AddItem("Save scenario", GC_SAVESCEN); ! mcGameMenu.AddItem("Load scenario", GC_LOADSCEN); mcGameMenu.AddItem("Quit", GC_QUIT); ! mcGameMenu.EndSubMenu(); mcPlatformMenu.Clear(); --- 96,107 ---- mcGameMenu.Clear(); ! //mcGameMenu.AddItem("Switch to scenedit mode", GC_TOGGLEEDIT); ! //mcGameMenu.AddItem("File", 0); ! // mcGameMenu.BeginSubMenu(); ! //mcGameMenu.AddItem("Save scenario", GC_SAVESCEN); ! //mcGameMenu.AddItem("Load scenario", GC_LOADSCEN); mcGameMenu.AddItem("Quit", GC_QUIT); ! //mcGameMenu.EndSubMenu(); mcPlatformMenu.Clear(); Index: tcRadarSensorState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadarSensorState.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcRadarSensorState.cpp 4 Dec 2003 05:15:22 -0000 1.1 --- tcRadarSensorState.cpp 4 Jan 2004 22:24:53 -0000 1.2 *************** *** 25,31 **** * */ ! bool tcRadarSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey) { ! tcSensorState::InitFromDB(apDatabase, anKey); mpDBObj = dynamic_cast<tcRadarDBObject*>(apDatabase->GetObject(anKey)); --- 25,31 ---- * */ ! bool tcRadarSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad) { ! tcSensorState::InitFromDB(apDatabase, anKey, mountAzimuth_rad); mpDBObj = dynamic_cast<tcRadarDBObject*>(apDatabase->GetObject(anKey)); Index: tcSensorState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorState.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSensorState.cpp 4 Dec 2003 05:15:22 -0000 1.1 --- tcSensorState.cpp 4 Jan 2004 22:24:53 -0000 1.2 *************** *** 38,42 **** /** ! * */ void tcSensorState::UpdateCoverage(tsGeoPoint p,float az_rad) --- 38,45 ---- /** ! * may want to change this to use a pointer to the platform ! * to get platform info vs. passing this information with ! * methods like this. ! * @param az_rad platform heading */ void tcSensorState::UpdateCoverage(tsGeoPoint p,float az_rad) *************** *** 44,55 **** msCurrentPos.mfLon_rad = p.mfLon_rad; msCurrentPos.mfLat_rad = p.mfLat_rad; ! mfLookAz_rad = az_rad; msCurrentPos.mfAlt_m = p.mfAlt_m + mfSensorHeight_m; } /** ! * */ ! bool tcSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey) { mpDBObj = dynamic_cast<tcSensorDBObject*>(apDatabase->GetObject(anKey)); --- 47,58 ---- msCurrentPos.mfLon_rad = p.mfLon_rad; msCurrentPos.mfLat_rad = p.mfLat_rad; ! mfLookAz_rad = az_rad + mountAz_rad; msCurrentPos.mfAlt_m = p.mfAlt_m + mfSensorHeight_m; } /** ! * @param lookAz_rad azimuth of center of coverage in radians, 0 points forward */ ! bool tcSensorState::InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad) { mpDBObj = dynamic_cast<tcSensorDBObject*>(apDatabase->GetObject(anKey)); *************** *** 64,67 **** --- 67,71 ---- mfCurrentScanPeriod_s = mpDBObj->mfScanPeriod_s; mfSensorHeight_m = 0; + mountAz_rad = mountAzimuth_rad; return true; } *************** *** 80,83 **** --- 84,88 ---- file.Read(&mfLastScan,sizeof(mfLastScan)); file.Read(&mfLookAz_rad,sizeof(mfLookAz_rad)); + file.Read(&mountAz_rad,sizeof(mountAz_rad)); file.Read(&mfSensorHeight_m,sizeof(mfSensorHeight_m)); file.Read(&mnMode,sizeof(mnMode)); *************** *** 91,94 **** --- 96,100 ---- file.Write(&mfLastScan,sizeof(mfLastScan)); file.Write(&mfLookAz_rad,sizeof(mfLookAz_rad)); + file.Write(&mountAz_rad,sizeof(mountAz_rad)); file.Write(&mfSensorHeight_m,sizeof(mfSensorHeight_m)); file.Write(&mnMode,sizeof(mnMode)); *************** *** 127,130 **** --- 133,137 ---- mfLastScan = ss.mfLastScan; mfLookAz_rad = ss.mfLookAz_rad; + mountAz_rad = ss.mountAz_rad; mfSensorHeight_m =ss.mfSensorHeight_m; mnDBKey = ss.mnDBKey; Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcSimState.cpp 1 Jan 2004 23:44:47 -0000 1.20 --- tcSimState.cpp 4 Jan 2004 22:24:53 -0000 1.21 *************** *** 116,125 **** } /********************************************************************/ ! bool tcSimState::RadarCanDetect(tnPoolIndex anSensorKey, const tsRadarTargetInfo& asRTI, tsGeoPoint asSensorLocation, float afSensorAz) { float fRange_km; ! if (mcDefaultRadar.InitFromDB(mpDatabase,anSensorKey)==false) {return false;} mcDefaultRadar.UpdateCoverage(asSensorLocation,afSensorAz); return mcDefaultRadar.IsDetected(asRTI,fRange_km); --- 116,133 ---- } /********************************************************************/ ! /** ! * This method is not named well. The intent is to use this to check if ! * a target is detectable with a radar that does not exist yet. So e.g. ! * to simulate a missile seeker locking on before launch. This allows a ! * detection test without creating the object. ! * Since normal use is with missiles, the sensor az is assumed to be 0. ! * If this is used with a non forward looking radar, it will not work ! * correctly. ! */ bool tcSimState::RadarCanDetect(tnPoolIndex anSensorKey, const tsRadarTargetInfo& asRTI, tsGeoPoint asSensorLocation, float afSensorAz) { float fRange_km; ! if (mcDefaultRadar.InitFromDB(mpDatabase,anSensorKey,0)==false) {return false;} mcDefaultRadar.UpdateCoverage(asSensorLocation,afSensorAz); return mcDefaultRadar.IsDetected(asRTI,fRange_km); |