[Gcblue-commits] gcb_wx/include/sim tcPositionRegistry.h,NONE,1.1 tcSensorPlatform.h,NONE,1.1 tcObje
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:59
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/sim Modified Files: tcObjectControl.h tcPlatformObject.h Added Files: tcPositionRegistry.h tcSensorPlatform.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup --- NEW FILE: tcPositionRegistry.h --- /** ** @file tcPositionRegistry.h */ /* Copyright (C) 2005 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 */ #ifndef _POSITIONREGISTRY_H_ #define _POSITIONREGISTRY_H_ #if _MSC_VER > 1000 #pragma once #endif #include <map> #include <vector> /** * Provides fast lookup of platforms within region */ class tcPositionRegistry { public: std::vector<long>& GetAllWithinRegion(double lon_west, double lon_east, double lat_south, double lat_north); void RemoveAll(); void RemoveId(long id); void UpdatePosition(long id, double lon, double lat); tcPositionRegistry(); ~tcPositionRegistry(); private: /// lookup of id map by bin location code std::map<long, std::map<long, bool> > positionMap; /// lookup for bin location by id std::map<long, long> entryLookup; const double pi; const double twopi; const double piovertwo; const double binWidth; ///< size of bin in radians double invBinWidth; ///< 1.0 / binWidth double nLatBins; ///< number of latitude bins from -90 S to 90 N void AddIdToBin(long id, long bin); void RemoveIdFromBin(long id, long bin); void AppendBinContents(std::vector<long>& v, long bin); void ConformLonLat(double& lon_west, double& lon_east, double& lat_south, double& lat_north); long LatToIndex(double lat); long LonToIndex(double lon); long LonLatToBinLocation(double lon, double lat); }; #endif Index: tcObjectControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcObjectControl.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcObjectControl.h 20 Feb 2005 18:20:18 -0000 1.13 --- tcObjectControl.h 4 Mar 2005 00:46:15 -0000 1.14 *************** *** 201,204 **** --- 201,206 ---- tcControl* altitudeControl; + + void CreateHeadingCircles(); void DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal); --- NEW FILE: tcSensorPlatform.h --- /** ** @file tcSensorPlatform.h */ /* Copyright (C) 2005 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 */ #ifndef _TCSENSORPLATFORM_H_ #define _TCSENSORPLATFORM_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "tcFile.h" #include "tcLaunchRequest.h" #include "tcSensorState.h" #include "tcGuidanceState.h" #include "tcCommandObject.h" #include <vector> class tcStream; class tcCommandStream; class tcCreateStream; class tcUpdateStream; class tcGameObject; namespace Database { class tcSensorPlatformDBObject; } using Database::tcSensorPlatformDBObject; /** * Handles sensor-related aspects of platform * */ class tcSensorPlatform { public: std::vector<tcSensorState*> sensorState; tcCommandObject sensorCommandObj; ///< ugly, could fix by handling sensors like launchers unsigned int GetSensorCount() const; bool HasActivatedSensor(); bool IsRadiating(); const tcSensorState* GetSensor(unsigned idx); wxString GetSensorDescription(); tcSensorState* GetSensorMutable(unsigned idx); tcSensorState* GetSensorMutable(const std::string& sensorClass); void Init(tcSensorPlatformDBObject* obj, tcGameObject* parent); void SetSensorState(unsigned idx, bool state); void Update(double t); void PrintToFile(tcFile&); void SaveToFile(tcFile& file); void LoadFromFile(tcFile& file); void Serialize(tcFile& file, bool mbLoad); tcCommandStream& operator<<(tcCommandStream& stream); tcCreateStream& operator<<(tcCreateStream& stream); tcUpdateStream& operator<<(tcUpdateStream& stream); tcCommandStream& operator>>(tcCommandStream& stream); tcCreateStream& operator>>(tcCreateStream& stream); tcUpdateStream& operator>>(tcUpdateStream& stream); void ClearNewCommand(); bool HasNewCommand() const; bool HasUnacknowledgedCommand() const; tcSensorPlatform(); tcSensorPlatform(tcSensorPlatform&); tcSensorPlatform(tcSensorPlatformDBObject* obj, tcGameObject* parent); virtual ~tcSensorPlatform(); protected: }; #endif Index: tcPlatformObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcPlatformObject.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcPlatformObject.h 24 Feb 2005 22:19:14 -0000 1.23 --- tcPlatformObject.h 4 Mar 2005 00:46:15 -0000 1.24 *************** *** 30,33 **** --- 30,34 ---- #include "tcGuidanceState.h" #include "tcGameObject.h" + #include "tcSensorPlatform.h" #include "tcCommandObject.h" #include "tcAIData.h" *************** *** 60,64 **** * @see tcGameObject */ ! class tcPlatformObject : public tcGameObject { public: --- 61,65 ---- * @see tcGameObject */ ! class tcPlatformObject : public tcGameObject, public tcSensorPlatform { public: *************** *** 80,85 **** float fuel_kg; ///< current fuel tcLauncherState mcLauncherState; - //tcSensorState* mapSensorState[MAXSENSORS]; - std::vector<tcSensorState*> mapSensorState; std::vector<tcStores*> magazines; --- 81,84 ---- *************** *** 93,97 **** tcGenericDBObject *mpDBObject; tcCommandObject commandObj; - tcCommandObject sensorCommandObj; ///< ugly, could fix by handling sensors like launchers --- 92,95 ---- *************** *** 112,130 **** unsigned int GetMagazineQuantity(const std::string& item); ! unsigned int GetSensorCount() const; ! // virtual void GetSensorState(tcSensorState** aapSensorState, int& rnCount); ! // virtual void GetSensorStateRef(tcSensorState**& rapSensorState, int& rnCount); ! virtual bool HasActivatedSensor(); virtual bool IsInterceptingTrack(long id); ! virtual bool IsRadiating(); ! //virtual std::vector<tcSensorState*>* GetSensorStateArray() {return &mapSensorState;} ! virtual const tcSensorState* GetSensor(unsigned idx); ! wxString GetSensorDescription(); ! virtual tcSensorState* GetSensorMutable(unsigned idx); virtual void Launch(tnPoolIndex& rnKey, unsigned& rnLauncher); virtual void RandInitNear(float afLon_deg, float afLat_deg); virtual void SetAltitude(float new_altitude_m); virtual void SetHeading(float afNewHeading); - void SetSensorState(unsigned idx, bool state); virtual void SetSpeed(float afNewSpeed); virtual int SetLaunch(int anLauncher, int anQuantity); --- 110,120 ---- unsigned int GetMagazineQuantity(const std::string& item); ! virtual bool IsInterceptingTrack(long id); ! virtual void Launch(tnPoolIndex& rnKey, unsigned& rnLauncher); virtual void RandInitNear(float afLon_deg, float afLat_deg); virtual void SetAltitude(float new_altitude_m); virtual void SetHeading(float afNewHeading); virtual void SetSpeed(float afNewSpeed); virtual int SetLaunch(int anLauncher, int anQuantity); |