[Gcblue-commits] gcb_wx/src/database tcFlightportDBObject.cpp,NONE,1.1 tcAirDBObject.cpp,1.4,1.5 tcD
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1:/tmp/cvs-serv2798/src/database Modified Files: tcAirDBObject.cpp tcDatabase.cpp tcESMDBObject.cpp tcFixedDBObject.cpp tcGenericDBObject.cpp tcRadarDBObject.cpp Added Files: tcFlightportDBObject.cpp Log Message: Added database class for flightports --- NEW FILE: tcFlightportDBObject.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" #pragma warning(disable:4786) // suppress warning for STL bug in VC6, see Q167355 in the MSDN Library. #include "tcFlightportDBObject.h" #include "math_constants.h" #include "randfn.h" #include "CsvTranslator.h" using namespace std; namespace Database { void tcFlightportDBObject::RandInit() { static int bSeedRand = 1; if (bSeedRand) { SYSTEMTIME stime; GetSystemTime(&stime); srand(60*stime.wMinute + stime.wSecond); bSeedRand = 0; } } int tcFlightportDBObject::SerializeCSV(Database::CsvTranslator *csv, bool mbLoad) { tcDatabaseObject::SerializeCSV(csv, mbLoad); if (mbLoad) { std::string s; *csv >> heloOnly; ///< set non-zero for helo-only flight port *csv >> hangarCapacity; spotInfo.clear(); int i; for(i=0;i<MAX_DB_SPOTS;i++) { spotDBInfo info; *csv >> info.isLaunch; *csv >> info.x; *csv >> info.y; // y and z swapped in header due to OSG coord change *csv >> info.z; *csv >> info.orientation_deg; *csv >> info.length; bool isValid = (info.x != 0)||(info.y !=0)||(info.z != 0); if (isValid) { spotInfo.push_back(info); } } } else { *csv << (long)heloOnly; ///< set non-zero for helo-only flight port *csv << (long)hangarCapacity; size_t numSpots = spotInfo.size(); size_t i; for(i=0;i<MAX_DB_SPOTS;i++) { if (i<numSpots) { spotDBInfo info = spotInfo[i]; *csv << (long)info.isLaunch; *csv << info.x; *csv << info.y; // y and z swapped in header due to OSG coord change *csv << info.z; *csv << info.orientation_deg; *csv << info.length; } else { *csv << ""; *csv << ""; *csv << ""; *csv << ""; *csv << ""; *csv << ""; } } csv->WriteLine(); } return 1; } int tcFlightportDBObject::WriteCSVHeader(Database::CsvTranslator *csv) { tcDatabaseObject::WriteCSVHeader(csv); *csv << "Helo only?"; *csv << "Hangar capacity"; int i; for(i=0;i<MAX_DB_SPOTS;i++) { tcString s; s.Format("S%d-Launch",i+1); *csv << s.GetBuffer(); s.Format("S%d-x[m]",i+1); *csv << s.GetBuffer(); s.Format("S%d-z",i+1); // y and z swapped due to OSG coord change *csv << s.GetBuffer(); s.Format("S%d-y",i+1); *csv << s.GetBuffer(); s.Format("S%d-orientation[deg]",i+1); *csv << s.GetBuffer(); s.Format("S%d-length[m]",i+1); *csv << s.GetBuffer(); } csv->WriteLine(); return 1; } tcFlightportDBObject::tcFlightportDBObject() : tcDatabaseObject() { mnClassID = DTYPE_FLIGHTPORT; mnModelType = MTYPE_OBJECT; heloOnly = 0; ///< set non-zero for helo-only flight port hangarCapacity = 0; spotInfo.clear(); } tcFlightportDBObject::tcFlightportDBObject(tcFlightportDBObject& obj) : tcDatabaseObject(obj) { heloOnly = obj.heloOnly; hangarCapacity = obj.hangarCapacity; spotInfo.clear(); size_t nSpots = obj.spotInfo.size(); for(size_t i=0;i<nSpots;i++) { spotInfo.push_back(obj.spotInfo[i]); } } tcFlightportDBObject::~tcFlightportDBObject() { } } Index: tcAirDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcAirDBObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcAirDBObject.cpp 8 Dec 2003 03:06:36 -0000 1.4 --- tcAirDBObject.cpp 4 Jan 2004 22:24:52 -0000 1.5 *************** *** 108,111 **** --- 108,112 ---- : tcGenericDBObject(obj) { + mnClassID = DTYPE_AIR; mfAfterburnFuelRate_kgps = obj.mfAfterburnFuelRate_kgps; mfAfterburnThrust_N = obj.mfAfterburnThrust_N; Index: tcDatabase.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcDatabase.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcDatabase.cpp 8 Dec 2003 03:06:36 -0000 1.4 --- tcDatabase.cpp 4 Jan 2004 22:24:52 -0000 1.5 *************** *** 41,45 **** #include "tcFixedDBObject.h" #include "tcAirDBObject.h" ! using namespace std; --- 41,45 ---- #include "tcFixedDBObject.h" #include "tcAirDBObject.h" ! #include "tcFlightportDBObject.h" using namespace std; *************** *** 68,71 **** --- 68,72 ---- std::string esmFileName = path + string("esm") + suffix + ".csv"; std::string airFileName = path + string("air") + suffix + ".csv"; + std::string flightportFileName = path + string("flightport") + suffix + ".csv"; if (mbLoad) *************** *** 102,105 **** --- 103,111 ---- serializer.LoadCsv(); } + // tcFlightportDBObject + { + tcDBObjSerializer<tcFlightportDBObject> serializer(flightportFileName, this); + serializer.LoadCsv(); + } } else *************** *** 134,137 **** --- 140,148 ---- { tcDBObjSerializer<tcAirDBObject> serializer(airFileName, this); + serializer.SaveCsv(); + } + // tcFlightportDBObject + { + tcDBObjSerializer<tcFlightportDBObject> serializer(flightportFileName, this); serializer.SaveCsv(); } Index: tcESMDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcESMDBObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcESMDBObject.cpp 7 Dec 2003 01:53:36 -0000 1.2 --- tcESMDBObject.cpp 4 Jan 2004 22:24:52 -0000 1.3 *************** *** 86,89 **** --- 86,90 ---- : tcSensorDBObject(obj) { + mnClassID = DTYPE_ESM; } Index: tcFixedDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcFixedDBObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcFixedDBObject.cpp 7 Dec 2003 01:53:36 -0000 1.2 --- tcFixedDBObject.cpp 4 Jan 2004 22:24:52 -0000 1.3 *************** *** 80,84 **** : tcDatabaseObject(obj) { ! } --- 80,84 ---- : tcDatabaseObject(obj) { ! mnClassID = DTYPE_FIXED; } Index: tcGenericDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcGenericDBObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcGenericDBObject.cpp 7 Dec 2003 14:29:32 -0000 1.3 --- tcGenericDBObject.cpp 4 Jan 2004 22:24:52 -0000 1.4 *************** *** 68,71 **** --- 68,72 ---- mnNumLaunchers = 0; mnNumSensors = 0; + flightportClass = ""; } *************** *** 172,187 **** *csv >> mfMaxThrust_N; *csv >> mfRange_km; int i; mnNumLaunchers = 0; for(i=0;i<MAXLAUNCHERS;i++) { *csv >> s; ! if (s.size() > 0) maLauncherClass[mnNumLaunchers++] = s.c_str(); } mnNumSensors = 0; for(i=0;i<MAXSENSORS;i++) { *csv >> s; ! if (s.size() > 0) maSensorClass[mnNumSensors++] = s.c_str(); } } --- 173,203 ---- *csv >> mfMaxThrust_N; *csv >> mfRange_km; + *csv >> s; + flightportClass = s.c_str(); + int i; mnNumLaunchers = 0; for(i=0;i<MAXLAUNCHERS;i++) { + float az; *csv >> s; ! *csv >> az; ! if (s.size() > 0) ! { ! maLauncherClass[mnNumLaunchers] = s.c_str(); ! launcherAz[mnNumLaunchers++] = az; ! } } mnNumSensors = 0; for(i=0;i<MAXSENSORS;i++) { + float az; *csv >> s; ! *csv >> az; ! if (s.size() > 0) ! { ! maSensorClass[mnNumSensors] = s.c_str(); ! sensorAz[mnNumSensors++] = az; ! } } } *************** *** 202,215 **** *csv << mfMaxThrust_N; *csv << mfRange_km; int i; for(i=0;i<MAXLAUNCHERS;i++) { ! if (i<mnNumLaunchers) *csv << string(maLauncherClass[i].mz); ! else *csv << ""; } for(i=0;i<MAXSENSORS;i++) { ! if (i<mnNumSensors) *csv << string(maSensorClass[i].mz); ! else *csv << ""; } csv->WriteLine(); --- 218,249 ---- *csv << mfMaxThrust_N; *csv << mfRange_km; + *csv << flightportClass.mz; + int i; for(i=0;i<MAXLAUNCHERS;i++) { ! if (i<mnNumLaunchers) ! { ! *csv << string(maLauncherClass[i].mz); ! *csv << launcherAz[i]; ! } ! else ! { ! *csv << ""; ! *csv << ""; ! } } for(i=0;i<MAXSENSORS;i++) { ! if (i<mnNumSensors) ! { ! *csv << string(maSensorClass[i].mz); ! *csv << sensorAz[i]; ! } ! else ! { ! *csv << ""; ! *csv << ""; ! } } csv->WriteLine(); *************** *** 235,238 **** --- 269,273 ---- *csv << "MaxThrust[N]"; *csv << "Range_km"; + *csv << "Flightport Class"; int i; for(i=0;i<MAXLAUNCHERS;i++) *************** *** 241,244 **** --- 276,281 ---- s.Format("Launcher%d",i+1); *csv << s.GetBuffer(); + s.Format("Launcher%d-angle",i+1); + *csv << s.GetBuffer(); } for(i=0;i<MAXSENSORS;i++) *************** *** 247,250 **** --- 284,289 ---- s.Format("Sensor%d",i+1); *csv << s.GetBuffer(); + s.Format("Sensor%d-angle",i+1); + *csv << s.GetBuffer(); } csv->WriteLine(); *************** *** 272,275 **** --- 311,315 ---- mnNumLaunchers = 0; mnNumSensors = 0; + flightportClass = ""; } *************** *** 277,280 **** --- 317,321 ---- : tcDatabaseObject(obj) { + mnClassID = DTYPE_GENERIC; mfRcs_dbsm = obj.mfRcs_dbsm; mfMaxSpeed_kts = obj.mfMaxSpeed_kts; *************** *** 298,306 **** --- 339,350 ---- { maLauncherClass[i] = obj.maLauncherClass[i]; + launcherAz[i] = obj.launcherAz[i]; } for(i=0;i<MAXSENSORS;i++) { maSensorClass[i] = obj.maSensorClass[i]; + sensorAz[i] = obj.sensorAz[i]; } + flightportClass = obj.flightportClass; } Index: tcRadarDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcRadarDBObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcRadarDBObject.cpp 7 Dec 2003 01:53:36 -0000 1.2 --- tcRadarDBObject.cpp 4 Jan 2004 22:24:52 -0000 1.3 *************** *** 159,162 **** --- 159,163 ---- : tcSensorDBObject(obj) { + mnClassID = DTYPE_RADAR; mfMinRange_km = obj.mfMinRange_km; mfERP_dBW = obj.mfERP_dBW; |