[Gcblue-commits] gcb_wx/include/sim tcESMSensor.h,1.1,1.2 tcPool.h,1.3,1.4 tcRadar.h,1.1,1.2 tcSenso
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-02-12 01:59:23
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26928/include/sim Modified Files: tcESMSensor.h tcPool.h tcRadar.h tcSensorState.h tcSimState.h Log Message: Index: tcESMSensor.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcESMSensor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcESMSensor.h 7 Feb 2004 02:19:54 -0000 1.1 --- tcESMSensor.h 12 Feb 2004 01:54:49 -0000 1.2 *************** *** 28,46 **** class tcGameObject; using namespace Database; - /** - * - */ - typedef struct _ESMtargetinfo - { - float mfLat_rad; - float mfLon_rad; - float mfAlt_m; - float mfEmitterAz_rad; // azimuth of center of emitter coverage - float mfEmitterFOV_rad; - float mfEmitterERP_dBW; - } tsESMTargetInfo; /** --- 28,35 ---- class tcGameObject; + class tcRadar; using namespace Database; /** *************** *** 53,57 **** bool InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad); ! bool IsDetected(const tsESMTargetInfo& asETI, float& rfAz_rad); void Serialize(tcFile& file, bool mbLoad); virtual void Update(double t); --- 42,46 ---- bool InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad); ! bool IsDetected(const tcRadar* emitter, float& rfAz_rad); void Serialize(tcFile& file, bool mbLoad); virtual void Update(double t); Index: tcPool.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcPool.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcPool.h 7 Feb 2004 02:19:54 -0000 1.3 --- tcPool.h 12 Feb 2004 01:54:49 -0000 1.4 *************** *** 24,27 **** --- 24,28 ---- #include "wx/wx.h" // for NULL definition + #include <iostream> #define NULL_INDEX -1 *************** *** 70,73 **** --- 71,78 ---- { pt = NULL; + if (n >=0) + { + std::cerr << "error - invalid pool index" << std::endl; + } return false; } *************** *** 80,83 **** --- 85,89 ---- newkey = NULL_INDEX; pt = NULL; + std::cerr << "error - pool out of memory" << std::endl; return false; // out of memory } *************** *** 103,106 **** --- 109,113 ---- if (mnSize >= POOLSIZE) { newkey = NULL_INDEX; + std::cerr << "error - pool out of memory" << std::endl; return false; // out of memory } *************** *** 135,139 **** tnPoolIndex nDefaultKey; ! if (mnSize >= POOLSIZE) { return false; // out of memory } --- 142,148 ---- tnPoolIndex nDefaultKey; ! if (mnSize >= POOLSIZE) ! { ! std::cerr << "error - pool out of memory" << std::endl; return false; // out of memory } *************** *** 149,153 **** } } ! if (!bFound) {return false;} // return without adding element if not found mnCheckoutIndex++; mnSize++; --- 158,166 ---- } } ! if (!bFound) ! { ! std::cerr << "error - AddElementForceKey - pool element not found" << std::endl; ! return false; ! } // return without adding element if not found mnCheckoutIndex++; mnSize++; *************** *** 186,189 **** --- 199,206 ---- pt = NULL; index = NULL_INDEX; + if (pos >=0) + { + std::cerr << "error - bad pool index" << std::endl; + } return; } *************** *** 195,243 **** template <class T, int POOLSIZE> tnPoolIndex tcPool<T,POOLSIZE>::GetNextKey(tnPoolIndex pos){ ! if ((pos < 0)||(pos >= POOLSIZE)) { ! return NULL_INDEX; ! } ! if (maNext[pos] == NULL_INDEX) { ! return mnBase; // end of list, circle to beginning ! } ! else { ! return maNext[pos]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! tnPoolIndex tcPool<T,POOLSIZE>::GetPrevKey(tnPoolIndex pos){ ! if ((pos < 0)||(pos >= POOLSIZE)) { ! return NULL_INDEX; ! } ! if (maPrev[pos] == NULL_INDEX) { ! return mnTail; // beginning of list, circle to end ! } ! else { ! return maPrev[pos]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! T tcPool<T,POOLSIZE>::operator[] (tnPoolIndex index) const { ! if ((index < 0)||(index >= POOLSIZE)) { ! return *mpool[0]; ! } ! else { ! return *mpool[index]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! bool tcPool<T,POOLSIZE>::RemoveKey(tnPoolIndex n) { ! if ((mnSize == 0)||(mnReturnIndex==mnCheckoutIndex)) { ! return false; // empty pool, nothing to remove ! } ! if (n < 0) return false; // return key to available maAvailable[mnReturnIndex++] = n; if (mnReturnIndex == POOLSIZE) { ! mnReturnIndex = 0; } // remove from list --- 212,285 ---- template <class T, int POOLSIZE> tnPoolIndex tcPool<T,POOLSIZE>::GetNextKey(tnPoolIndex pos){ ! if ((pos < 0)||(pos >= POOLSIZE)) ! { ! if (pos >=0) ! { ! std::cerr << "error - bad pool index" << std::endl; ! } ! return NULL_INDEX; ! } ! if (maNext[pos] == NULL_INDEX) ! { ! return mnBase; // end of list, circle to beginning ! } ! else { ! return maNext[pos]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! tnPoolIndex tcPool<T,POOLSIZE>::GetPrevKey(tnPoolIndex pos) ! { ! if ((pos < 0)||(pos >= POOLSIZE)) ! { ! if (pos >=0) ! { ! std::cerr << "error - bad pool index" << std::endl; ! } ! return NULL_INDEX; ! } ! if (maPrev[pos] == NULL_INDEX) ! { ! return mnTail; // beginning of list, circle to end ! } ! else ! { ! return maPrev[pos]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! T tcPool<T,POOLSIZE>::operator[] (tnPoolIndex index) const ! { ! if ((index < 0)||(index >= POOLSIZE)) ! { ! std::cerr << "error - operator[] - bad pool index" << std::endl; ! return *mpool[0]; ! } ! else ! { ! return *mpool[index]; ! } } /**********************************************************/ template <class T, int POOLSIZE> ! bool tcPool<T,POOLSIZE>::RemoveKey(tnPoolIndex n) ! { ! if ((mnSize == 0)||(mnReturnIndex==mnCheckoutIndex)) ! { ! std::cerr << "error - RemoveKey - empty pool, nothing to remove" << std::endl; ! return false; // empty pool, nothing to remove ! } ! if (n < 0) ! { ! std::cerr << "error - RemoveKey - bad pool index" << std::endl; ! return false; ! } // return key to available maAvailable[mnReturnIndex++] = n; if (mnReturnIndex == POOLSIZE) { ! mnReturnIndex = 0; } // remove from list *************** *** 245,258 **** mpool[n] = NULL; if (n==mnBase) { ! mnBase = maNext[n]; // if n is base then n next becomes new base } if (n==mnTail) { ! mnTail = maPrev[n]; // if n is tail then n prev becomes new tail } if (maPrev[n] < POOLSIZE) { ! maNext[maPrev[n]] = maNext[n]; // maNext[n] can be invalid } if (maNext[n] < POOLSIZE) { ! maPrev[maNext[n]] = maPrev[n]; // maPrev[n] can be invalid } mnSize--; --- 287,300 ---- mpool[n] = NULL; if (n==mnBase) { ! mnBase = maNext[n]; // if n is base then n next becomes new base } if (n==mnTail) { ! mnTail = maPrev[n]; // if n is tail then n prev becomes new tail } if (maPrev[n] < POOLSIZE) { ! maNext[maPrev[n]] = maNext[n]; // maNext[n] can be invalid } if (maNext[n] < POOLSIZE) { ! maPrev[maNext[n]] = maPrev[n]; // maPrev[n] can be invalid } mnSize--; *************** *** 265,300 **** */ template <class T, int POOLSIZE> ! bool tcPool<T,POOLSIZE>::RemoveKeyWithoutDelete(tnPoolIndex n) { ! if ((mnSize == 0)||(mnReturnIndex==mnCheckoutIndex)) { ! return false; // empty pool, nothing to remove ! } ! if (n < 0) return false; ! // return key to available ! maAvailable[mnReturnIndex++] = n; ! if (mnReturnIndex == POOLSIZE) { ! mnReturnIndex = 0; ! } ! // remove from list ! mpool[n] = NULL; ! if (n==mnBase) { ! mnBase = maNext[n]; // if n is base then n next becomes new base ! } ! if (n==mnTail) { ! mnTail = maPrev[n]; // if n is tail then n prev becomes new tail ! } ! if (maPrev[n] < POOLSIZE) { ! maNext[maPrev[n]] = maNext[n]; // maNext[n] can be invalid ! } ! if (maNext[n] < POOLSIZE) { ! maPrev[maNext[n]] = maPrev[n]; // maPrev[n] can be invalid ! } ! mnSize--; ! return true; } /**********************************************************/ template <class T, int POOLSIZE> ! void tcPool<T,POOLSIZE>::RemoveAll(void) { ! for(tnPoolIndex k=0;k<POOLSIZE;k++) { ! if (mpool[k] != NULL) { delete mpool[k]; mpool[k] = NULL; --- 307,354 ---- */ template <class T, int POOLSIZE> ! bool tcPool<T,POOLSIZE>::RemoveKeyWithoutDelete(tnPoolIndex n) ! { ! if ((mnSize == 0)||(mnReturnIndex==mnCheckoutIndex)) ! { ! std::cerr << ! "error - RemoveKeyWithoutDelete - empty pool, nothing to remove" ! << std::endl; ! return false; // empty pool, nothing to remove ! } ! if ((n < 0)||(n >= POOLSIZE)||(mpool[n]==NULL)) ! { ! std::cerr << "error - RemoveKeyWithoutDelete - bad index" << std::endl; ! return false; ! } ! // return key to available ! maAvailable[mnReturnIndex++] = n; ! if (mnReturnIndex == POOLSIZE) { ! mnReturnIndex = 0; ! } ! // remove from list ! mpool[n] = NULL; ! if (n==mnBase) { ! mnBase = maNext[n]; // if n is base then n next becomes new base ! } ! if (n==mnTail) { ! mnTail = maPrev[n]; // if n is tail then n prev becomes new tail ! } ! if (maPrev[n] < POOLSIZE) { ! maNext[maPrev[n]] = maNext[n]; // maNext[n] can be invalid ! } ! if (maNext[n] < POOLSIZE) { ! maPrev[maNext[n]] = maPrev[n]; // maPrev[n] can be invalid ! } ! mnSize--; ! return true; } /**********************************************************/ template <class T, int POOLSIZE> ! void tcPool<T,POOLSIZE>::RemoveAll(void) ! { ! for(tnPoolIndex k=0;k<POOLSIZE;k++) ! { ! if (mpool[k] != NULL) ! { delete mpool[k]; mpool[k] = NULL; *************** *** 312,316 **** /**********************************************************/ template <class T, int POOLSIZE> ! tcPool<T,POOLSIZE>::tcPool<T,POOLSIZE>() { mnSize = 0; mnBase = NULL_INDEX; // value NULL_INDEX is OOB and used as invalid --- 366,371 ---- /**********************************************************/ template <class T, int POOLSIZE> ! tcPool<T,POOLSIZE>::tcPool<T,POOLSIZE>() ! { mnSize = 0; mnBase = NULL_INDEX; // value NULL_INDEX is OOB and used as invalid *************** *** 318,322 **** mnCheckoutIndex = 0; mnReturnIndex = 0; ! for(tnPoolIndex k=0;k<POOLSIZE;k++) { mpool[k] = NULL; maPrev[k] = NULL_INDEX; --- 373,378 ---- mnCheckoutIndex = 0; mnReturnIndex = 0; ! for(tnPoolIndex k=0;k<POOLSIZE;k++) ! { mpool[k] = NULL; maPrev[k] = NULL_INDEX; *************** *** 327,335 **** /**********************************************************/ template <class T, int POOLSIZE> ! tcPool<T,POOLSIZE>::~tcPool<T,POOLSIZE>() { ! for(tnPoolIndex k=0;k<POOLSIZE;k++) { // TODO: without the extra check this occasionally causes an exception/ // due to deleting an invalid memory location ! if ((mpool[k] != NULL)&&(mpool[k] > (void*)0x000000FF)) { delete mpool[k]; mpool[k] = NULL; --- 383,394 ---- /**********************************************************/ template <class T, int POOLSIZE> ! tcPool<T,POOLSIZE>::~tcPool<T,POOLSIZE>() ! { ! for(tnPoolIndex k=0;k<POOLSIZE;k++) ! { // TODO: without the extra check this occasionally causes an exception/ // due to deleting an invalid memory location ! if ((mpool[k] != NULL)&&(mpool[k] > (void*)0x000000FF)) ! { delete mpool[k]; mpool[k] = NULL; *************** *** 339,345 **** /**********************************************************/ template <class T, int POOLSIZE> ! tnPoolIndex tcPool<T,POOLSIZE>::GetPoolSize() { return POOLSIZE; } ! #endif // !defined(AFX_TCPOOL_H__755B583F_35DC_4BB0_96E0_AF9BC7EB29DE__INCLUDED_) --- 398,405 ---- /**********************************************************/ template <class T, int POOLSIZE> ! tnPoolIndex tcPool<T,POOLSIZE>::GetPoolSize() ! { return POOLSIZE; } ! #endif Index: tcRadar.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcRadar.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcRadar.h 7 Feb 2004 02:19:54 -0000 1.1 --- tcRadar.h 12 Feb 2004 01:54:49 -0000 1.2 *************** *** 69,73 **** virtual bool IsCommandReceiver() {return isCommandReceiver;} ! virtual bool IsSemiactive() {return isSemiactive;} virtual void SetIlluminator(long illum_id, unsigned sensor_idx); --- 69,73 ---- virtual bool IsCommandReceiver() {return isCommandReceiver;} ! virtual bool IsSemiactive() const {return isSemiactive;} virtual void SetIlluminator(long illum_id, unsigned sensor_idx); Index: tcSensorState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorState.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcSensorState.h 7 Feb 2004 02:19:54 -0000 1.6 --- tcSensorState.h 12 Feb 2004 01:54:49 -0000 1.7 *************** *** 54,59 **** int mnMode; tcTrack mcTrack; ! tsGeoPoint msCurrentPos; ///< current true position of sensor ! float mfLookAz_rad; ///< azimuth of center of coverage relative to north float mountAz_rad; ///< mounted azimuth of boresight relative to nose/bow of platform float mfSensorHeight_m; ///< height of sensor relative to platform altitude --- 54,59 ---- int mnMode; tcTrack mcTrack; ! //tsGeoPoint msCurrentPos; ///< current true position of sensor ! //float mfLookAz_rad; ///< azimuth of center of coverage relative to north float mountAz_rad; ///< mounted azimuth of boresight relative to nose/bow of platform float mfSensorHeight_m; ///< height of sensor relative to platform altitude *************** *** 63,69 **** virtual bool InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad); void Serialize(tcFile& file, bool mbLoad); void SetParent(tcGameObject *obj) {parent = obj;} virtual void Update(double t); - void UpdateCoverage(tsGeoPoint p,float az_rad); int UpdateScan(double afTime); tcSensorState& operator=(tcSensorState& ss); --- 63,69 ---- virtual bool InitFromDB(tcDatabase *apDatabase, tnPoolIndex anKey, float mountAzimuth_rad); void Serialize(tcFile& file, bool mbLoad); + void SetMountAz(float az) {mountAz_rad = az;} void SetParent(tcGameObject *obj) {parent = obj;} virtual void Update(double t); int UpdateScan(double afTime); tcSensorState& operator=(tcSensorState& ss); Index: tcSimState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSimState.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcSimState.h 7 Feb 2004 02:19:54 -0000 1.14 --- tcSimState.h 12 Feb 2004 01:54:49 -0000 1.15 *************** *** 102,107 **** void AttachUserInfo(tcUserInfo *apUserInfo) {mpUserInfo=apUserInfo;} void BuildCollisionGroups(); - bool RadarCanDetect(tnPoolIndex anSensorKey, const tcGameObject* target, - tsGeoPoint asSensorLocation, float afSensorAz, long fcID = -1, unsigned fcIdx = 0); void ChangeHeading(long anKey, float afNewHeading); void ChangeHeadingForced(tnPoolIndex anKey, float afNewHeading); // for scen edit mode --- 102,105 ---- *************** *** 144,147 **** --- 142,147 ---- void PrintToFile(tcString); void ProcessLanding(tcGameObject *receiver, tcGameObject *landing_unit); + bool RadarCanDetect(tnPoolIndex anSensorKey, const tcGameObject* target, + tcGameObject* reference, float afSensorAz, long fcID = -1, unsigned fcIdx = 0); void RandInit(void); void RemoveDestroyedObjects(void); *************** *** 174,179 **** float GetFractionalDamage(float afDamage, tcGameObject *apGameObj); ! bool IsDetectedESM(tcESMSensor *apESM, tcRadar *apEmitterRadar, ! tcGameObject *apEmitterPlatform, float& rfAz_rad); void PerformAutoEngage(tcGameObject* apGameObj, double afTime); void ProcessRadarDetection(tcGameObject *apRadarPlat,tcGameObject *apTarget, --- 174,178 ---- float GetFractionalDamage(float afDamage, tcGameObject *apGameObj); ! bool IsDetectedESM(tcESMSensor *apESM, tcRadar *apEmitterRadar, float& rfAz_rad); void PerformAutoEngage(tcGameObject* apGameObj, double afTime); void ProcessRadarDetection(tcGameObject *apRadarPlat,tcGameObject *apTarget, |