gcblue-commits Mailing List for Global Conflict Blue (Page 32)
Status: Alpha
Brought to you by:
ddcforge
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(112) |
Feb
(106) |
Mar
(88) |
Apr
(111) |
May
(53) |
Jun
(60) |
Jul
(58) |
Aug
(61) |
Sep
(45) |
Oct
(31) |
Nov
(71) |
Dec
(70) |
| 2005 |
Jan
(33) |
Feb
(57) |
Mar
(98) |
Apr
(47) |
May
(53) |
Jun
(79) |
Jul
(79) |
Aug
|
Sep
(33) |
Oct
(1) |
Nov
(20) |
Dec
(64) |
| 2006 |
Jan
(20) |
Feb
(1) |
Mar
(43) |
Apr
(11) |
May
(8) |
Jun
(23) |
Jul
|
Aug
(28) |
Sep
(58) |
Oct
(25) |
Nov
(47) |
Dec
(70) |
|
From: Dewitt C. <ddc...@us...> - 2005-03-05 22:38:29
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21843 Modified Files: GCblue.vcproj Log Message: Added sonobuoy model. 2525 view now uses small symbol for ballistic and sonobuoy instead of unknown symbol Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** GCblue.vcproj 4 Mar 2005 00:46:14 -0000 1.87 --- GCblue.vcproj 5 Mar 2005 22:37:49 -0000 1.88 *************** *** 524,527 **** --- 524,530 ---- </File> <File + RelativePath=".\src\sim\tcSonobuoy.cpp"> + </File> + <File RelativePath=".\src\sim\tcStores.cpp"> </File> *************** *** 606,609 **** --- 609,615 ---- </File> <File + RelativePath=".\src\database\tcSonobuoyDBObject.cpp"> + </File> + <File RelativePath=".\src\database\tcSqlReader.cpp"> </File> *************** *** 1467,1470 **** --- 1473,1479 ---- </File> <File + RelativePath=".\include\sim\tcSonobuoy.h"> + </File> + <File RelativePath=".\include\sim\tcStores.h"> </File> *************** *** 1558,1561 **** --- 1567,1573 ---- </File> <File + RelativePath=".\include\database\tcSonobuoyDBObject.h"> + </File> + <File RelativePath=".\include\database\tcSqlReader.h"> </File> |
|
From: Dewitt C. <ddc...@us...> - 2005-03-05 22:38:14
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21843/src/sim Modified Files: tcSensorMap.cpp tcSimState.cpp tcSonar.cpp Added Files: tcSonobuoy.cpp Log Message: Added sonobuoy model. 2525 view now uses small symbol for ballistic and sonobuoy instead of unknown symbol Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** tcSimState.cpp 2 Mar 2005 22:28:45 -0000 1.68 --- tcSimState.cpp 5 Mar 2005 22:38:03 -0000 1.69 *************** *** 43,46 **** --- 43,48 ---- #include "tcBallisticDBObject.h" #include "tcGroundObject.h" + #include "tcSonobuoy.h" + #include "tcSonobuoyDBObject.h" #include "tcTorpedoObject.h" #include "tcTorpedoDBObject.h" *************** *** 1524,1527 **** --- 1526,1533 ---- } } + else if (tcSonobuoy* sonobuoy = dynamic_cast<tcSonobuoy*>(launched)) + { + sonobuoy->LaunchFrom(launchingPlatform, nLauncher); + } else { *************** *** 1599,1602 **** --- 1605,1612 ---- return new tcBallisticWeapon(ballisticData); } + else if (tcSonobuoyDBObject* sonobuoyData = dynamic_cast<tcSonobuoyDBObject*>(apDBObject)) + { + return new tcSonobuoy(sonobuoyData); + } else { Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** tcSensorMap.cpp 2 Mar 2005 22:28:45 -0000 1.15 --- tcSensorMap.cpp 5 Mar 2005 22:38:03 -0000 1.16 *************** *** 150,153 **** --- 150,180 ---- } + /** + * @return number of contributors to this track + */ + unsigned tcSensorMapTrack::GetContributorCount() const + { + return (unsigned)mnContributors; + } + + /** + * @return name of contributing platform <idx> or pointer to "" if bad idx + */ + const char* tcSensorMapTrack::GetContributorName(unsigned idx) const + { + static const std::string emptyString(""); + + if (idx >= (unsigned)mnContributors) return emptyString.c_str(); + + long contributorId = maSensorReport[idx].mnSensorPlatformID; + if (tcGameObject* obj = simState->GetObject(contributorId)) + { + return obj->mzUnit.mz; + } + else + { + return emptyString.c_str(); + } + } --- NEW FILE: tcSonobuoy.cpp --- /** ** @file tcSonobuoy.cpp */ /* 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 */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcSonobuoy.h" #include "tc3DPoint.h" #include "math_constants.h" #include "tcGameObject.h" #include "tcGenericDBObject.h" #include "tcLauncher.h" #include "tcPlatformObject.h" #include "tcSimState.h" #include "tcSonobuoyDBObject.h" #ifdef _DEBUG #define new DEBUG_NEW #endif void tcSonobuoy::Clear() { tcGameObject::Clear(); } void tcSonobuoy::PrintToFile(tcFile& file) { tcGameObject::PrintToFile(file); tcSensorPlatform::PrintToFile(file); } void tcSonobuoy::SaveToFile(tcFile& file) { tcGameObject::SaveToFile(file); tcSensorPlatform::SaveToFile(file); } void tcSonobuoy::LoadFromFile(tcFile& file) { tcGameObject::LoadFromFile(file); tcSensorPlatform::LoadFromFile(file); } void tcSonobuoy::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); } else { SaveToFile(file); } } /** * Initializes sonobuoy for launch from game object. * Adds self to simulation * * @param obj launching game object * @param launcher index of launcher */ void tcSonobuoy::LaunchFrom(tcGameObject* obj, unsigned nLauncher) { if (tcPlatformObject* platObj = dynamic_cast<tcPlatformObject*>(obj)) { tc3DPoint launcherPos = platObj->mpDBObject->GetLauncherPosition(nLauncher); GeoPoint pos = obj->RelPosToLatLonAlt(launcherPos.x, launcherPos.y, launcherPos.z); mcKin.mfLon_rad = pos.mfLon_rad; mcKin.mfLat_rad = pos.mfLat_rad; mcKin.mfAlt_m = pos.mfAlt_m; } else { wxASSERT(false); mcKin.mfLon_rad = obj->mcKin.mfLon_rad; mcKin.mfLat_rad = obj->mcKin.mfLat_rad; mcKin.mfAlt_m = obj->mcKin.mfAlt_m; } mcKin.mfSpeed_kts = obj->mcKin.mfSpeed_kts; parentId = obj->mnID; const tcLauncher* pLauncher = obj->GetLauncher(nLauncher); mcKin.mfHeading_rad = obj->mcKin.mfHeading_rad + pLauncher->pointingAngle; mcKin.mfPitch_rad = obj->mcKin.mfPitch_rad + pLauncher->pointingElevation; mcKin.mfClimbAngle_rad = mcKin.mfPitch_rad; mfStatusTime = obj->mfStatusTime; wxString s = wxString::Format("Sonobuoy %d-%d", obj->mnID, rand() % 1000); mzUnit = s.c_str(); mnAlliance = obj->mnAlliance; simState->AddPlatform(static_cast<tcGameObject*>(this)); } /** * */ void tcSonobuoy::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); if (dt_s <= min_update_s) {return;} // added for pause case // air launched buoys drop into water first bool outOfWater = (mcKin.mfAlt_m > 0.0f); if (outOfWater) { UpdateDrop(dt_s); mfStatusTime = afStatusTime; return; } // cheesy wave bob effect mcKin.mfAlt_m = 0.45f * cos(0.7f * afStatusTime) - 0.5f; // TODO: Check that parent platform is in range before updating sensors tcSensorPlatform::Update(afStatusTime); batteryTimeRemaining_s -= dt_s; if (batteryTimeRemaining_s <= 0) { tcGameObject::mfDamageLevel += 1.0; // destroy buoy } mfStatusTime = afStatusTime; } /** * */ void tcSonobuoy::UpdateDrop(float dt_s) { float heading_rad = mcKin.mfHeading_rad; float fGroundSpeed_kts = cosf(mcKin.mfClimbAngle_rad) * mcKin.mfSpeed_kts; float vz_mps = C_KTSTOMPS * sinf(mcKin.mfClimbAngle_rad) * mcKin.mfSpeed_kts; float vxy_mps = C_KTSTOMPS * fGroundSpeed_kts; float z = mcKin.mfAlt_m; float dvz = C_G * dt_s; if (vz_mps < -50.0f) { dvz = 0; } else if (vz_mps < -40.0f) { dvz = 0.1f * (vz_mps + 50.0f) * dvz; // gradually limit acceleration } vz_mps = vz_mps - dvz; if (vxy_mps > 0) { vxy_mps = vxy_mps - dt_s * 0.02f * vxy_mps * vxy_mps; // air drag } if (vxy_mps < 0) { vxy_mps = 0; } double fDistance_rad = fGroundSpeed_kts*dt_s*(float)C_KTSTORADPS; mcKin.mfLon_rad += fDistance_rad*(double)(sinf(heading_rad)/cosf((float)mcKin.mfLat_rad)); mcKin.mfLat_rad += (double)cosf(heading_rad)*fDistance_rad; mcKin.mfAlt_m += vz_mps*dt_s; mcKin.mfClimbAngle_rad = atan2(vz_mps, vxy_mps); mcKin.mfPitch_rad = 0; mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vz_mps*vz_mps + vxy_mps*vxy_mps); // stop and activate all sensors after hitting water if (mcKin.mfAlt_m <= 0) { mcKin.mfAlt_m = 0; mcKin.mfSpeed_kts = 0; unsigned nSensors = tcSensorPlatform::GetSensorCount(); for (unsigned n=0; n<nSensors; n++) { tcSensorPlatform::SetSensorState(n, true); } } } /** * */ tcSonobuoy::tcSonobuoy() : mpDBObject(0) { wxASSERT(false); Clear(); mnModelType = MTYPE_SONOBUOY; } /** * Constructor that initializes using info from database entry. */ tcSonobuoy::tcSonobuoy(tcSonobuoyDBObject *obj) : tcGameObject(obj), tcSensorPlatform(), mpDBObject(obj), batteryTimeRemaining_s(obj->batteryLife_s), parentId(-1) { tcSensorPlatform::Init(obj, this); mcKin.mfSpeed_kts = 0; mnModelType = MTYPE_SONOBUOY; } tcSonobuoy::~tcSonobuoy() { } Index: tcSonar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSonar.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcSonar.cpp 27 Jan 2005 01:02:06 -0000 1.6 --- tcSonar.cpp 5 Mar 2005 22:38:03 -0000 1.7 *************** *** 611,614 **** --- 611,615 ---- mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0.0f; + mbActive = isPassive; // passive sonar default to "on" state } |
|
From: Dewitt C. <ddc...@us...> - 2005-03-05 22:38:13
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21843/src/graphics Modified Files: tc3DViewer.cpp tcGameView.cpp tcHookInfo.cpp tcMapView.cpp Log Message: Added sonobuoy model. 2525 view now uses small symbol for ballistic and sonobuoy instead of unknown symbol Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcMapView.cpp 2 Mar 2005 22:28:43 -0000 1.18 --- tcMapView.cpp 5 Mar 2005 22:38:02 -0000 1.19 *************** *** 967,970 **** --- 967,1010 ---- } + /** + * "Mark" symbol is for known objects such as shells and sonobuoys that do + * not have individual symbols, but may be shown on the map in some modes. + */ + osg::Geometry* tcTacticalMapView::DrawDefaultMark(teAffiliation affil) + { + float w = 2.0f; // symbol size + float h = 2.0f; + + osg::Geometry* symbol = CreateSymbolGeometry(); + + // set color + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(GetAffiliationColor(affil)); + symbol->setColorArray(colors); + symbol->setColorBinding(osg::Geometry::BIND_OVERALL); + + // create vertex array + osg::Vec3Array* vertices = new osg::Vec3Array; + symbol->setVertexArray(vertices); + + + switch (affil) + { + case FRIENDLY: + case NEUTRAL: + case UNKNOWN: + case HOSTILE: + { + vertices->push_back(osg::Vec3(-w, h, 0)); + vertices->push_back(osg::Vec3(-w, -h, 0)); + vertices->push_back(osg::Vec3(w, -h, 0)); + vertices->push_back(osg::Vec3(w, h, 0)); + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINE_LOOP,0,4)); + break; + } + } + + return symbol; + } /** *************** *** 1412,1416 **** osg::Geometry* pTorpedo = DrawNTDSTorpedo((teAffiliation)nAffiliation); ! // unknown (small square, not strictly NTDS --- 1452,1457 ---- osg::Geometry* pTorpedo = DrawNTDSTorpedo((teAffiliation)nAffiliation); ! // mark symbol ! osg::Geometry* pMark = DrawDefaultMark((teAffiliation)nAffiliation); // unknown (small square, not strictly NTDS *************** *** 1449,1452 **** --- 1490,1496 ---- pSymbol = pGround; break; + case SYMBOL_MARK: + pSymbol = pMark; + break; default: pSymbol = pUnknown; *************** *** 1508,1511 **** --- 1552,1557 ---- osg::Geometry* pTorpedo = CreateTexturedSymbol(zBuff); + osg::Geometry* pMark = DrawDefaultMark((teAffiliation)nAffiliation); + osg::Geometry* pUnknown = CreateTexturedSymbol("unknown.png"); *************** *** 1544,1547 **** --- 1590,1596 ---- pSymbol = pFixed; break; + case SYMBOL_MARK: + pSymbol = pMark; + break; default: pSymbol = pUnknown; *************** *** 1669,1672 **** --- 1718,1726 ---- symbsize = 30.0f; } + else if (type == SYMBOL_MARK) + { + symbsize = 8.0f; + vectsize = 10.0f; + } osg::Vec4 penColor = GetAffiliationColor(pMO->meAffiliation); *************** *** 1814,1826 **** } ! if ((mbShowTrackID) && (pMO->mnID!=NULL_INDEX) && (type != SYMBOL_UNKNOWN)) { wxString s = wxString::Format("%04d", pMO->mnID); - // char zBuff[16]; - //mpBrush->SetColor(0xFEFFFFFF); - //sprintf(zBuff,"%04d",pMO->mnID); DrawTextR(s.c_str(), x-9.0f, y+15.0f, defaultFont.get(), symbolColor, 8.0, LEFT_BASE_LINE); } // draw focus box if applicable if ((pMO->mbFocus)&&(pMO->mnID!=NULL_INDEX)) --- 1868,1880 ---- } + bool suppressTrackId = (pMO->mnID == NULL_INDEX) || (type == SYMBOL_UNKNOWN) || + (type == SYMBOL_MARK); ! if (mbShowTrackID && !suppressTrackId) { wxString s = wxString::Format("%04d", pMO->mnID); DrawTextR(s.c_str(), x-9.0f, y+15.0f, defaultFont.get(), symbolColor, 8.0, LEFT_BASE_LINE); } + // draw focus box if applicable if ((pMO->mbFocus)&&(pMO->mnID!=NULL_INDEX)) Index: tcHookInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcHookInfo.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcHookInfo.cpp 7 Nov 2004 03:40:44 -0000 1.6 --- tcHookInfo.cpp 5 Mar 2005 22:38:02 -0000 1.7 *************** *** 134,138 **** DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ! ftexty += 15; --- 134,148 ---- DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ! ftexty += 15; ! ! // Draw reporting platform info ! unsigned nContributors = pSMTrack->mnContributors; ! s = "Detected by: "; ! for (unsigned k=0; k<nContributors; k++) ! { ! s += std::string(pSMTrack->GetContributorName(k)); ! if (k < nContributors-1) s += ","; ! } ! DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 15; Index: tc3DViewer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DViewer.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tc3DViewer.cpp 21 Feb 2005 18:26:11 -0000 1.10 --- tc3DViewer.cpp 5 Mar 2005 22:37:52 -0000 1.11 *************** *** 1059,1062 **** --- 1059,1074 ---- } + bool shakeEligible = ((obj->mpDBObject->mnType & (PTYPE_AIR | PTYPE_MISSILE)) != 0) && + (cameraRange < 25.0f); + if (shakeAirCamera && shakeEligible) + { + osg::Vec3 walkOffset(randfc(0.1f), randfc(0.1f), randfc(0.08f)); + osg::Vec3 filteredOffset = walkOffset * 0.1f + lastWalkOffset * 0.9f; + lastWalkOffset = filteredOffset; + cameraWalkOffset += filteredOffset; + + cameraPosition += cameraWalkOffset; + } + sceneView->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); sceneViewFar->setViewMatrixAsLookAt(cameraPosition, cameraTarget, osg::Vec3(0,0,1)); *************** *** 1792,1796 **** const wxString& name) : wxWindow(parent, -1, pos, size, wxTRANSPARENT_WINDOW | wxNO_FULL_REPAINT_ON_RESIZE, name), ! mnHeight(size.GetHeight()), mnWidth(size.GetWidth()) { glCanvas = parent; --- 1804,1809 ---- const wxString& name) : wxWindow(parent, -1, pos, size, wxTRANSPARENT_WINDOW | wxNO_FULL_REPAINT_ON_RESIZE, name), ! mnHeight(size.GetHeight()), mnWidth(size.GetWidth()), ! cameraWalkOffset(0, 0, 0) { glCanvas = parent; *************** *** 1879,1882 **** --- 1892,1897 ---- tc3DModel::LoadUnknowns(); + shakeAirCamera = tcOptions::Get()->OptionStringExists("ShakeAirCamera"); + // rootnode->addChild(tcSound::Get()->GetSoundRoot()); } Index: tcGameView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcGameView.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcGameView.cpp 2 Mar 2005 22:28:43 -0000 1.5 --- tcGameView.cpp 5 Mar 2005 22:38:02 -0000 1.6 *************** *** 107,110 **** --- 107,114 ---- return SYMBOL_TORPEDO; break; + case PTYPE_BALLISTIC: + case PTYPE_SONOBUOY: + return SYMBOL_MARK; + break; case PTYPE_FIXED: return SYMBOL_FIXED; *************** *** 621,625 **** mpMapView->maMapObj[rnIndex].mnColor = 0; ! if (mpMapView->maMapObj[rnIndex].meSymbol != SYMBOL_FIXED) { mpMapView->maMapObj[rnIndex].mfHeading = po->mcKin.mfHeading_rad; --- 625,630 ---- mpMapView->maMapObj[rnIndex].mnColor = 0; ! if ((mpMapView->maMapObj[rnIndex].meSymbol != SYMBOL_FIXED) && ! (po->mcKin.mfSpeed_kts > 0)) { mpMapView->maMapObj[rnIndex].mfHeading = po->mcKin.mfHeading_rad; |
|
From: Dewitt C. <ddc...@us...> - 2005-03-05 22:38:13
|
Update of /cvsroot/gcblue/gcb_wx/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21843/xml Modified Files: options.xml Log Message: Added sonobuoy model. 2525 view now uses small symbol for ballistic and sonobuoy instead of unknown symbol Index: options.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/options.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** options.xml 4 Mar 2005 00:46:18 -0000 1.14 --- options.xml 5 Mar 2005 22:38:03 -0000 1.15 *************** *** 2,7 **** <HostAddress>192.168.0.102</HostAddress> <DisplaySettings>default</DisplaySettings> ! <LastScenarioPath>Test.Type42.py</LastScenarioPath> ! <LastScenarioName>Type42</LastScenarioName> <noCopyDatabase /> <noWriteXmlDatabase /> --- 2,7 ---- <HostAddress>192.168.0.102</HostAddress> <DisplaySettings>default</DisplaySettings> ! <LastScenarioPath>Test.SubTestII.py</LastScenarioPath> ! <LastScenarioName>SubTestII</LastScenarioName> <noCopyDatabase /> <noWriteXmlDatabase /> *************** *** 9,11 **** --- 9,12 ---- <UsePositionRegistry /> <AutoKillAssessment /> + <ShakeAirCamera /> </Options> |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:19
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/graphics Modified Files: tcLauncherPopup.h tcMapView.h tcMessageChannel.h tcNumberWidget.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcMessageChannel.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMessageChannel.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageChannel.h 14 Nov 2004 22:52:20 -0000 1.1 --- tcMessageChannel.h 4 Mar 2005 00:46:15 -0000 1.2 *************** *** 56,60 **** void SetTextRect(tcRect r); ! tcMessageChannel(std::string name); virtual ~tcMessageChannel(); --- 56,60 ---- void SetTextRect(tcRect r); ! tcMessageChannel(const std::string& name); virtual ~tcMessageChannel(); Index: tcLauncherPopup.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcLauncherPopup.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcLauncherPopup.h 21 Dec 2004 02:26:17 -0000 1.3 --- tcLauncherPopup.h 4 Mar 2005 00:46:15 -0000 1.4 *************** *** 68,74 **** --- 68,76 ---- virtual void OnLaunchCommand(wxCommandEvent& event); + virtual void OnChar(wxKeyEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); virtual void OnLButtonUp(wxMouseEvent& event); virtual void OnMouseMove(wxMouseEvent& event); + virtual void OnRButtonDown(wxMouseEvent& event); Index: tcMapView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapView.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcMapView.h 2 Mar 2005 22:28:37 -0000 1.13 --- tcMapView.h 4 Mar 2005 00:46:15 -0000 1.14 *************** *** 326,330 **** void ClearMapObjects(); void Init(); ! void SetDateTime(std::string s) {dateTime = s;} void SetHookID(long id); void SetGroupHook(std::vector<long>& hookedUnits); --- 326,330 ---- void ClearMapObjects(); void Init(); ! void SetDateTime(const std::string& s) {dateTime = s;} void SetHookID(long id); void SetGroupHook(std::vector<long>& hookedUnits); Index: tcNumberWidget.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcNumberWidget.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcNumberWidget.h 31 Jan 2005 01:32:36 -0000 1.2 --- tcNumberWidget.h 4 Mar 2005 00:46:15 -0000 1.3 *************** *** 76,79 **** --- 76,80 ---- unsigned int buttonDownTime; + virtual void OnChar(wxKeyEvent& event); virtual void OnEnterWindow(wxMouseEvent& event); virtual void OnLButtonDown(wxMouseEvent& event); *************** *** 84,87 **** --- 85,92 ---- void SendRedraw(); void UpdateAutoChange(); + private: + const unsigned int keyboardTimeout; + bool keyboardWait; ///< true to update value with keyboard + unsigned int lastKeypressTime; }; |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:16
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821 Modified Files: GCblue.vcproj Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** GCblue.vcproj 2 Mar 2005 22:28:34 -0000 1.86 --- GCblue.vcproj 4 Mar 2005 00:46:14 -0000 1.87 *************** *** 509,512 **** --- 509,515 ---- </File> <File + RelativePath=".\src\sim\tcSensorPlatform.cpp"> + </File> + <File RelativePath="src\sim\tcSensorState.cpp"> </File> *************** *** 597,600 **** --- 600,606 ---- </File> <File + RelativePath=".\src\database\tcSensorPlatformDBObject.cpp"> + </File> + <File RelativePath=".\src\database\tcSonarDBObject.cpp"> </File> *************** *** 1446,1449 **** --- 1452,1458 ---- </File> <File + RelativePath=".\include\sim\tcSensorPlatform.h"> + </File> + <File RelativePath="include\sim\tcSensorState.h"> </File> *************** *** 1543,1546 **** --- 1552,1558 ---- </File> <File + RelativePath=".\include\database\tcSensorPlatformDBObject.h"> + </File> + <File RelativePath=".\include\database\tcSonarDBObject.h"> </File> |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:14
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/network Modified Files: tcMultiplayerInterface.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcMultiplayerInterface.h 1 Sep 2004 02:55:36 -0000 1.17 --- tcMultiplayerInterface.h 4 Mar 2005 00:46:15 -0000 1.18 *************** *** 98,112 **** void InitMessageHandlers(); bool IsChatTextAvail(); ! bool IsCommand(std::string text); bool IsServer(); void MakeClient(); void MakeServer(); ! void OpenConnection(std::string hostName); ! void ProcessCommandClient(int connectionId, std::string text); ! void ProcessCommandServer(std::string text); void RemoveChatSubscriber(tcConsoleBox* subscriber); ! void SendChatText(int destination, std::string message); void SendControlMessage(int destination, int messageCode, int param = 0); ! void SendTestUDP(int destination, std::string message); void SendUpdateMessage(int destination, tcStream& stream); void SetChatProtocol(int code); --- 98,112 ---- void InitMessageHandlers(); bool IsChatTextAvail(); ! bool IsCommand(const std::string& text); bool IsServer(); void MakeClient(); void MakeServer(); ! void OpenConnection(const std::string& hostName); ! void ProcessCommandClient(int connectionId, const std::string& text); ! void ProcessCommandServer(const std::string& text); void RemoveChatSubscriber(tcConsoleBox* subscriber); ! void SendChatText(int destination, const std::string& message); void SendControlMessage(int destination, int messageCode, int param = 0); ! void SendTestUDP(int destination, const std::string& message); void SendUpdateMessage(int destination, tcStream& stream); void SetChatProtocol(int code); |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:14
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/common Modified Files: tcSound.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSound.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcSound.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcSound.cpp 2 Mar 2005 22:28:42 -0000 1.25 --- tcSound.cpp 4 Mar 2005 00:46:16 -0000 1.26 *************** *** 169,173 **** } ! void tcSound::PlayMusic(std::string song) { if (!mbInitialized) return; --- 169,173 ---- } ! void tcSound::PlayMusic(const std::string& song) { if (!mbInitialized) return; *************** *** 183,187 **** } ! void tcSound::QueueMusic(std::string song) { if (!mbInitialized) return; --- 183,187 ---- } ! void tcSound::QueueMusic(const std::string& song) { if (!mbInitialized) return; *************** *** 382,386 **** ! void tcSound::PlayEffect(std::string effectName) { if (!mbInitialized) return; --- 382,386 ---- ! void tcSound::PlayEffect(const std::string& effectName) { if (!mbInitialized) return; |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:01
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/graphics Modified Files: tc3DModel.cpp tc3DWindow.cpp tcLauncherPopup.cpp tcMessageChannel.cpp tcNumberWidget.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tc3DModel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DModel.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tc3DModel.cpp 21 Feb 2005 18:26:09 -0000 1.23 --- tc3DModel.cpp 4 Mar 2005 00:46:16 -0000 1.24 *************** *** 653,657 **** if (tcPlatformObject *plat = dynamic_cast<tcPlatformObject*>(obj)) { ! if (info.param >= (int)plat->mapSensorState.size()) { std::cerr << "sensor animation param out of range\n"; --- 653,657 ---- if (tcPlatformObject *plat = dynamic_cast<tcPlatformObject*>(obj)) { ! if (info.param >= (int)plat->GetSensorCount()) { std::cerr << "sensor animation param out of range\n"; *************** *** 659,664 **** return; } ! info.switchVariable = &plat->mapSensorState[info.param]->mbActive; ! float tscan = plat->mapSensorState[info.param]->mfCurrentScanPeriod_s; info.omega = (tscan) ? C_TWOPI/tscan : 0; } --- 659,666 ---- return; } ! ! tcSensorState* sensor = plat->GetSensorMutable(info.param); ! info.switchVariable = &sensor->mbActive; ! float tscan = (sensor != 0) ? sensor->mfCurrentScanPeriod_s : 1.0f; info.omega = (tscan) ? C_TWOPI/tscan : 0; } Index: tc3DWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tc3DWindow.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tc3DWindow.cpp 2 Mar 2005 22:28:42 -0000 1.16 --- tc3DWindow.cpp 4 Mar 2005 00:46:17 -0000 1.17 *************** *** 156,160 **** void tc3DWindow::OnLeaveWindow(wxMouseEvent& event) { - event.Skip(); } --- 156,159 ---- *************** *** 403,406 **** --- 402,407 ---- void tc3DWindow::SetActive(bool abActive) { + UpdateChildren(); // complete pending removes before accessing children + size_t nChildren = children.size(); for(size_t n=0;n<nChildren;n++) Index: tcMessageChannel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageChannel.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcMessageChannel.cpp 23 Nov 2004 23:30:56 -0000 1.2 --- tcMessageChannel.cpp 4 Mar 2005 00:46:17 -0000 1.3 *************** *** 181,185 **** * */ ! tcMessageChannel::tcMessageChannel(std::string name) : channelName(name), isActive(false), --- 181,185 ---- * */ ! tcMessageChannel::tcMessageChannel(const std::string& name) : channelName(name), isActive(false), Index: tcLauncherPopup.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcLauncherPopup.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcLauncherPopup.cpp 10 Jan 2005 00:30:54 -0000 1.4 --- tcLauncherPopup.cpp 4 Mar 2005 00:46:17 -0000 1.5 *************** *** 131,136 **** else { ! launchButton->SetFillColors(osg::Vec4(0.5, 0.2, 0.2, 1.0), osg::Vec4(0.5, 0.2, 0.2, 1.0), ! osg::Vec4(0.5, 0.2, 0.2, 1.0)); } --- 131,136 ---- else { ! launchButton->SetFillColors(osg::Vec4(0.5, 0.2, 0.2, 1.0), osg::Vec4(1.0, 0.4, 0.4, 1.0), ! osg::Vec4(1.0, 0.4, 0.4, 1.0)); } *************** *** 164,172 **** void tcLauncherPopup::InitTorpedoControls() { ! const int widgetWidth = 40; ! const int widgetHeight = 12; ! const float widgetFontSize = 12.0; const float widgetAlpha = 1.0f; ! int x = 80; int y = 20; --- 164,172 ---- void tcLauncherPopup::InitTorpedoControls() { ! const int widgetWidth = 44; ! const int widgetHeight = 14; ! const float widgetFontSize = 14.0; const float widgetAlpha = 1.0f; ! int x = 90; int y = 20; *************** *** 175,179 **** if (!launcher) return; ! launchButton = new tcButton(this, wxPoint(mnWidth - 40, 5), wxSize(widgetHeight, widgetHeight)); launchButton->SetActive(true); --- 175,179 ---- if (!launcher) return; ! launchButton = new tcButton(this, wxPoint(mnWidth - 40, 20), wxSize(widgetHeight, widgetHeight)); launchButton->SetActive(true); *************** *** 181,188 **** launchButton->SetCaption("L"); launchButton->SetCommand(LP_LAUNCH); ! launchButton->SetFontSize(11.0); launchButton->SetSendRedraw(true); ! selectDatumButton = new tcButton(this, wxPoint(mnWidth - 55, 5), wxSize(widgetHeight, widgetHeight)); selectDatumButton->SetActive(true); --- 181,189 ---- launchButton->SetCaption("L"); launchButton->SetCommand(LP_LAUNCH); ! launchButton->SetFontSize(12.0); launchButton->SetSendRedraw(true); ! ! selectDatumButton = new tcButton(this, wxPoint(mnWidth - 55, 20), wxSize(widgetHeight, widgetHeight)); selectDatumButton->SetActive(true); *************** *** 190,196 **** selectDatumButton->SetCaption("D"); selectDatumButton->SetCommand(LP_SETDATUM); ! selectDatumButton->SetFontSize(11.0); selectDatumButton->SetSendRedraw(true); runToEnableAdjust = new tcNumberWidget(runToEnable, this, wxPoint(x, y), wxSize(widgetWidth, widgetHeight)); --- 191,198 ---- selectDatumButton->SetCaption("D"); selectDatumButton->SetCommand(LP_SETDATUM); ! selectDatumButton->SetFontSize(12.0); selectDatumButton->SetSendRedraw(true); + runToEnableAdjust = new tcNumberWidget(runToEnable, this, wxPoint(x, y), wxSize(widgetWidth, widgetHeight)); *************** *** 263,266 **** --- 265,284 ---- } + void tcLauncherPopup::OnChar(wxKeyEvent& event) + { + int nChar = event.GetKeyCode(); + + + switch(nChar) + { + case WXK_ESCAPE: + destroy = true; + break; + default: + event.Skip(); + break; + } + } + /** * Intended to be overrided to intercept command events from GUI *************** *** 363,366 **** --- 381,389 ---- + void tcLauncherPopup::OnRButtonDown(wxMouseEvent& event) + { + // do nothing, but keep event from getting passed upward + } + /** * @param id Id of platform with launcher to control Index: tcNumberWidget.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcNumberWidget.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcNumberWidget.cpp 2 Mar 2005 22:28:43 -0000 1.3 --- tcNumberWidget.cpp 4 Mar 2005 00:46:17 -0000 1.4 *************** *** 56,64 **** UpdateAutoChange(); // non-image drawing osg::Vec4 backgroundColor; osg::Vec4 textColor; ! if (isMouseOver) { backgroundColor.set(0.1, 0.1, 0.1, backgroundAlpha); --- 56,80 ---- UpdateAutoChange(); + // clear keyboardWait if timeout reached + if (keyboardWait) + { + unsigned t = tcTime::Get()->Get30HzCount(); + unsigned dt = t - lastKeypressTime; + if (dt >= keyboardTimeout) + { + keyboardWait = false; + } + } + // non-image drawing osg::Vec4 backgroundColor; osg::Vec4 textColor; ! if (keyboardWait) ! { ! backgroundColor.set(0.1, 0.5, 0.1, backgroundAlpha); ! textColor.set(1, 1, 1, 1); ! } ! else if (isMouseOver) { backgroundColor.set(0.1, 0.1, 0.1, backgroundAlpha); *************** *** 89,92 **** --- 105,145 ---- + void tcNumberWidget::OnChar(wxKeyEvent& event) + { + int nChar = event.GetKeyCode(); + + unsigned t = tcTime::Get()->Get30HzCount(); + unsigned dt = t - lastKeypressTime; + + bool addDigit = (keyboardWait && (dt < keyboardTimeout)); + keyboardWait = true; + lastKeypressTime = t; + + + const int val0 = '0'; + const int val9 = '9'; + + if (nChar == WXK_RETURN) + { + keyboardWait = false; + tcSound::Get()->PlayEffect("MutedBeep"); + } + else if ((nChar >= val0) && (nChar <= val9)) + { + if (addDigit) + { + val = 10.0f * val + (nChar - val0); + } + else + { + val = (nChar - val0); + } + tcSound::Get()->PlayEffect("MutedBeep"); + } + else + { + event.Skip(); + } + } /** *************** *** 106,109 **** --- 159,164 ---- SendRedraw(); } + + wxWindow::SetFocus(); } *************** *** 123,127 **** // measure could be done once per font size change instead wxSize numberSize; ! MeasureText(defaultFont.get(), fontSize, "8", numberSize); float digitIdx = floorf(float(mnWidth - pos.x - 2.0f) / float(numberSize.GetWidth())); --- 178,182 ---- // measure could be done once per font size change instead wxSize numberSize; ! MeasureText(defaultFont.get(), 1.1f * fontSize, "8", numberSize); float digitIdx = floorf(float(mnWidth - pos.x - 2.0f) / float(numberSize.GetWidth())); *************** *** 185,189 **** void tcNumberWidget::OnRButtonDown(wxMouseEvent& event) { - event.Skip(); } --- 240,243 ---- *************** *** 256,260 **** changeIncrement(0), leftButtonDown(false), ! buttonDownTime(0) { --- 310,315 ---- changeIncrement(0), leftButtonDown(false), ! buttonDownTime(0), ! keyboardTimeout(30) { |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:47:01
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/database Modified Files: tcDatabase.cpp tcGenericDBObject.cpp Added Files: tcSensorPlatformDBObject.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcGenericDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcGenericDBObject.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcGenericDBObject.cpp 2 Mar 2005 22:28:42 -0000 1.20 --- tcGenericDBObject.cpp 4 Mar 2005 00:46:16 -0000 1.21 *************** *** 2,6 **** ** @file tcGenericDBObject.cpp */ ! /* Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcGenericDBObject.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 113,143 **** } - /** - * This checks that the database object has all of the emitters in the - * emitters vector. Somewhat expensive, nEmitters * nSensors - * comparisons for positive result, fewer for negative result. - * @return true if this database object has all of the emitters - */ - bool tcGenericDBObject::HasAllEmitters(std::vector<long>& emitters) - { - unsigned int nEmitters = emitters.size(); - if ((int)nEmitters > mnNumSensors) return false; - - /* watch out for problems with this lazy init done inside this method - ** sensorId will not be available until this is called first */ - if (sensorId.size() == 0) UpdateSensorList(); - - for (unsigned int k=0; k<nEmitters; k++) - { - bool bFound = false; - long emitterId = emitters[k]; - for (int n=0; (n<mnNumSensors) && !bFound; n++) - { - if (sensorId[n] == emitterId) bFound = true; - } - if (!bFound) return false; - } - return true; - } /** --- 113,116 ---- *************** *** 185,189 **** mnNumLaunchers = 0; mnNumMagazines = 0; - mnNumSensors = 0; flightportClass = ""; } --- 158,161 ---- *************** *** 205,208 **** --- 177,182 ---- file.WriteString(s.GetBuffer()); } + + tcSensorPlatformDBObject::PrintToFile(file); for(int i=0; i<mnNumMagazines; i++) *************** *** 250,258 **** ! file.Read(&mnNumSensors,sizeof(mnNumSensors)); ! for(i=0;i<mnNumSensors;i++) ! { ! file.Read(&maSensorClass[i],sizeof(tcDBString)); ! } } else --- 224,229 ---- ! // sensor serialization not supported ! wxASSERT(false); } else *************** *** 285,293 **** } ! file.Write(&mnNumSensors,sizeof(mnNumSensors)); ! for(i=0;i<mnNumSensors;i++) ! { ! file.Write(&maSensorClass[i],sizeof(tcDBString)); ! } } return true; --- 256,261 ---- } ! // sensor serialization not supported ! wxASSERT(false); } return true; *************** *** 329,344 **** } } ! 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; ! } ! } wxASSERT(false); // need magazine code --- 297,303 ---- } } ! ! tcSensorPlatformDBObject::SerializeCSV(csv, mbLoad); ! wxASSERT(false); // need magazine code *************** *** 391,407 **** wxASSERT(false); // need magazine code ! for(i=0;i<MAXSENSORS;i++) ! { ! if (i<mnNumSensors) ! { ! *csv << string(maSensorClass[i].mz); ! *csv << sensorAz[i]; ! } ! else ! { ! *csv << ""; ! *csv << ""; ! } ! } size_t nAnimations = animationInfo.size(); for(size_t i=0;i<MAXANIMATIONS;i++) --- 350,355 ---- wxASSERT(false); // need magazine code ! tcSensorPlatformDBObject::SerializeCSV(csv, mbLoad); ! size_t nAnimations = animationInfo.size(); for(size_t i=0;i<MAXANIMATIONS;i++) *************** *** 473,482 **** } ! for(i=0;(i<mnNumSensors)&&(i<MAXSENSORS);i++) ! { ! TiXmlElement* childNode = node->InsertEndChild(TiXmlElement("sensor"))->ToElement(); ! childNode->SetAttribute("class", maSensorClass[i].mz); ! childNode->SetAttribute("az", sensorAz[i]); ! } for(std::vector<animationDBInfo>::iterator iter = animationInfo.begin() --- 421,427 ---- } ! ! tcSensorPlatformDBObject::SerializeXml(node, load); ! for(std::vector<animationDBInfo>::iterator iter = animationInfo.begin() *************** *** 519,530 **** *csv << s.GetBuffer(); } ! for(i=0;i<MAXSENSORS;i++) ! { ! tcString s; ! s.Format("Sensor%d",i+1); ! *csv << s.GetBuffer(); ! s.Format("Sensor%d-angle",i+1); ! *csv << s.GetBuffer(); ! } wxASSERT(false); // need magazine code --- 464,469 ---- *csv << s.GetBuffer(); } ! ! tcSensorPlatformDBObject::WriteCSVHeader(csv); wxASSERT(false); // need magazine code *************** *** 544,569 **** } ! /** ! * Updates sensorId vector with database ids for each sensor ! */ ! void tcGenericDBObject::UpdateSensorList() ! { ! sensorId.clear(); ! for(int n=0; n<mnNumSensors; n++) ! { ! std::string sensorClass = maSensorClass[n].mz; ! tcDatabaseObject* obj = database->GetObject(sensorClass); ! if (obj) ! { ! sensorId.push_back(obj->mnKey); ! } ! else ! { ! fprintf(stderr, "Error - tcGenericDBObject::UpdateSensorList - sensor %s not found\n", ! sensorClass.c_str()); ! sensorId.push_back(-1); ! } ! } ! } /** --- 483,487 ---- } ! /** *************** *** 609,628 **** { tcString s; ! s.Format("M%d_class varchar(30),", i+1); ! columnString += s.GetBuffer(); ! } ! ! for(i=0;i<MAXSENSORS;i++) ! { ! tcString s; ! s.Format("S%d_class varchar(30),",i+1); ! columnString += s.GetBuffer(); ! ! s.Format("S%d_az number(8)",i+1); columnString += s.GetBuffer(); ! if (i < MAXSENSORS - 1) columnString += ","; } } --- 527,540 ---- { tcString s; ! s.Format("M%d_class varchar(30)", i+1); columnString += s.GetBuffer(); ! if (i < MAXMAGAZINES - 1) ! { ! columnString += ","; ! } } + tcSensorPlatformDBObject::AddSqlColumns(columnString); } *************** *** 693,718 **** } ! ! // read sensors ! mnNumSensors = 0; ! for(i=0;i<MAXSENSORS;i++) ! { ! std::string sensorClass; ! tcString s; ! ! s.Format("S%d_class", i+1); ! sensorClass = entry.GetString(s.GetBuffer()); ! ! if (sensorClass.size() > 0) ! { ! maSensorClass[mnNumSensors] = sensorClass.c_str(); ! ! s.Format("S%d_az", i+1); ! sensorAz[mnNumSensors++] = entry.GetDouble(s.GetBuffer()); ! } ! ! } ! ! } --- 605,609 ---- } ! tcSensorPlatformDBObject::ReadSql(entry); } *************** *** 746,750 **** int i; ! for(i=0;i<MAXLAUNCHERS;i++) { if (i < mnNumLaunchers) --- 637,641 ---- int i; ! for(i=0; i<MAXLAUNCHERS; i++) { if (i < mnNumLaunchers) *************** *** 765,800 **** if (i < mnNumMagazines) { ! s << "'" << string(maMagazineClass[i].mz) << "',"; } else { ! s << "'',"; } - } - - - for(i=0;i<MAXSENSORS;i++) - { - if (i<mnNumSensors) - { - s << "'" << string(maSensorClass[i].mz) << "',"; - s << sensorAz[i]; - } - else - { - s << "'',"; - s << "0"; - } - if (i < MAXSENSORS - 1) s << ","; - } - valueString += s.str(); ! } ! tcGenericDBObject::tcGenericDBObject() : tcDatabaseObject() { mnClassID = DTYPE_GENERIC; --- 656,680 ---- if (i < mnNumMagazines) { ! s << "'" << string(maMagazineClass[i].mz) << "'"; } else { ! s << "''"; } + if (i < MAXMAGAZINES - 1) + { + s << ","; + } + } valueString += s.str(); ! ! tcSensorPlatformDBObject::WriteSql(valueString); } ! tcGenericDBObject::tcGenericDBObject() : tcDatabaseObject(), ! tcSensorPlatformDBObject() { mnClassID = DTYPE_GENERIC; *************** *** 815,820 **** mfRange_km = 0; mnNumLaunchers = 0; ! mnNumMagazines = 0; ! mnNumSensors = 0; flightportClass = ""; animationInfo.clear(); --- 695,699 ---- mfRange_km = 0; mnNumLaunchers = 0; ! mnNumMagazines = 0; flightportClass = ""; animationInfo.clear(); *************** *** 822,826 **** tcGenericDBObject::tcGenericDBObject(tcGenericDBObject& obj) ! : tcDatabaseObject(obj) { mnClassID = DTYPE_GENERIC; --- 701,705 ---- tcGenericDBObject::tcGenericDBObject(tcGenericDBObject& obj) ! : tcDatabaseObject(obj), tcSensorPlatformDBObject(obj) { mnClassID = DTYPE_GENERIC; *************** *** 842,846 **** mnNumLaunchers = obj.mnNumLaunchers; mnNumMagazines = obj.mnNumMagazines; ! mnNumSensors = obj.mnNumSensors; int i; for(i=0;i<mnNumLaunchers;i++) --- 721,725 ---- mnNumLaunchers = obj.mnNumLaunchers; mnNumMagazines = obj.mnNumMagazines; ! int i; for(i=0;i<mnNumLaunchers;i++) *************** *** 855,864 **** } - for(i=0;i<MAXSENSORS;i++) - { - maSensorClass[i] = obj.maSensorClass[i]; - sensorAz[i] = obj.sensorAz[i]; - } - flightportClass = obj.flightportClass; animationInfo.clear(); --- 734,737 ---- --- NEW FILE: tcSensorPlatformDBObject.cpp --- /** ** @file tcSensorPlatformDBObject.cpp */ /* 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 */ #include "stdwx.h" #if _MSC_VER > 1000 #pragma warning(disable:4786) // suppress warning for STL bug in VC6, see Q167355 in the MSDN Library. #endif #include "tcSensorPlatformDBObject.h" #include "tcDatabase.h" #include "math_constants.h" #include "randfn.h" #include "CsvTranslator.h" #include "common/tinyxml.h" #include "common/tcFile.h" #include "database/tcSqlReader.h" #include "database/CsvTranslator.h" #include <sstream> #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace std; namespace Database { /** * This checks that the database object has all of the emitters in the * emitters vector. Somewhat expensive, nEmitters * nSensors * comparisons for positive result, fewer for negative result. * @return true if this database object has all of the emitters */ bool tcSensorPlatformDBObject::HasAllEmitters(std::vector<long>& emitters) { unsigned int nEmitters = emitters.size(); size_t nSensors = sensorClass.size(); if ((int)nEmitters > nSensors) return false; /* watch out for problems with this lazy init done inside this method ** sensorId will not be available until this is called first */ if (sensorId.size() == 0) UpdateSensorList(); for (unsigned int k=0; k<nEmitters; k++) { bool bFound = false; long emitterId = emitters[k]; for (size_t n=0; (n<nSensors) && !bFound; n++) { if (sensorId[n] == emitterId) bFound = true; } if (!bFound) return false; } return true; } void tcSensorPlatformDBObject::PrintToFile(tcFile& file) { } int tcSensorPlatformDBObject::SerializeCSV(Database::CsvTranslator *csv, bool mbLoad) { if (mbLoad) { sensorClass.clear(); sensorAz.clear(); sensorId.clear(); for(int i=0; i<MAXSENSORS; i++) { std::string s; float az; *csv >> s; *csv >> az; if (s.size() > 0) { sensorClass.push_back(s); sensorAz.push_back(az); } } } else { size_t nSensors = sensorClass.size(); for(size_t i=0; i<MAXSENSORS; i++) { if (i<nSensors) { *csv << sensorClass[i]; *csv << sensorAz[i]; } else { *csv << ""; *csv << ""; } } csv->WriteLine(); } return 1; } /** * Loads/saves XML data for database object * @param load true to load, false to save */ void tcSensorPlatformDBObject::SerializeXml(TiXmlElement* node, bool load) { if (load) return; // write only for now wxASSERT(node); for(size_t i=0;(i<sensorClass.size())&&(i<MAXSENSORS);i++) { TiXmlElement* childNode = node->InsertEndChild(TiXmlElement("sensor"))->ToElement(); childNode->SetAttribute("class", sensorClass[i]); childNode->SetAttribute("az", sensorAz[i]); } } int tcSensorPlatformDBObject::WriteCSVHeader(Database::CsvTranslator *csv) { int i; for(i=0;i<MAXSENSORS;i++) { tcString s; s.Format("Sensor%d",i+1); *csv << s.GetBuffer(); s.Format("Sensor%d-angle",i+1); *csv << s.GetBuffer(); } csv->WriteLine(); return 1; } /** * Updates sensorId vector with database ids for each sensor */ void tcSensorPlatformDBObject::UpdateSensorList() { sensorId.clear(); tcDatabase* database = tcDatabase::Get(); for(size_t n=0; n<sensorClass.size(); n++) { tcDatabaseObject* obj = database->GetObject(sensorClass[n]); if (obj) { sensorId.push_back(obj->mnKey); } else { fprintf(stderr, "Error - tcSensorPlatformDBObject::UpdateSensorList - sensor %s not found\n", sensorClass[n].c_str()); sensorId.push_back(-1); } } } /** * Adds sql column definitions to columnString. This is used for * SQL create table command */ void tcSensorPlatformDBObject::AddSqlColumns(std::string& columnString) { columnString += ","; for(int i=0;i<MAXSENSORS;i++) { tcString s; s.Format("S%d_class varchar(30),",i+1); columnString += s.GetBuffer(); s.Format("S%d_az number(8)",i+1); columnString += s.GetBuffer(); if (i < MAXSENSORS - 1) columnString += ","; } } void tcSensorPlatformDBObject::ReadSql(tcSqlReader& entry) { sensorClass.clear(); sensorAz.clear(); sensorId.clear(); for(int i=0;i<MAXSENSORS;i++) { std::string className; tcString s; s.Format("S%d_class", i+1); className = entry.GetString(s.GetBuffer()); if (className.size() > 0) { sensorClass.push_back(className); s.Format("S%d_az", i+1); sensorAz.push_back(entry.GetDouble(s.GetBuffer())); } } } void tcSensorPlatformDBObject::WriteSql(std::string& valueString) { std::stringstream s; s << ","; for(size_t i=0; i<MAXSENSORS; i++) { if (i < sensorClass.size()) { s << "'" << sensorClass[i] << "',"; s << sensorAz[i]; } else { s << "'',"; s << "0"; } if (i < MAXSENSORS - 1) s << ","; } valueString += s.str(); } tcSensorPlatformDBObject::tcSensorPlatformDBObject() { } tcSensorPlatformDBObject::tcSensorPlatformDBObject(tcSensorPlatformDBObject& obj) : sensorClass(obj.sensorClass), sensorAz(obj.sensorAz), sensorId(obj.sensorId) { } tcSensorPlatformDBObject::~tcSensorPlatformDBObject() { } } Index: tcDatabase.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcDatabase.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcDatabase.cpp 5 Dec 2004 02:49:47 -0000 1.22 --- tcDatabase.cpp 4 Mar 2005 00:46:16 -0000 1.23 *************** *** 1072,1076 **** * @return NULL if not found */ ! tcDatabaseObject* tcDatabase::GetObject(std::string className) { std::map<std::string, long>::iterator mapIter = nameToKey.find(className); --- 1072,1076 ---- * @return NULL if not found */ ! tcDatabaseObject* tcDatabase::GetObject(const std::string& className) { std::map<std::string, long>::iterator mapIter = nameToKey.find(className); *************** *** 1082,1113 **** return GetObject(mapIter->second); - #if 0 - tcDatabaseIterator iter(0xFFF0); - for (iter.First(); !iter.IsDone(); iter.Next()) - { - tcDatabaseObject* obj = iter.Get(); - wxASSERT(obj); - wxASSERT(obj->mnKey != -1); - - std::string className = obj->mzClass.mz; - - - - - tnPoolIndex nPoolSize = mcObjectData.GetCount(); - tnPoolIndex key = mcObjectData.GetStartPosition(); - tcDatabaseObject *obj; - - for (int i=0;i<nPoolSize;i++) - { - key = mcObjectData.GetNextKey(key); - if (mcObjectData.Lookup(key,obj)==false) {return NULL;} // error - if (className == obj->mzClass.mz) - { - return obj; - } - } - return NULL; // not found - #endif } --- 1082,1085 ---- |
|
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); |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:58
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/database Modified Files: tcDatabase.h tcGenericDBObject.h Added Files: tcSensorPlatformDBObject.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcGenericDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcGenericDBObject.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcGenericDBObject.h 31 Jan 2005 01:32:35 -0000 1.16 --- tcGenericDBObject.h 4 Mar 2005 00:46:14 -0000 1.17 *************** *** 28,31 **** --- 28,32 ---- #include "tcDatabaseObject.h" + #include "tcSensorPlatformDBObject.h" #include <vector> #include "tc3DPoint.h" *************** *** 46,50 **** * for a simple surface ship or aircraft model. */ ! class tcGenericDBObject : public tcDatabaseObject { public: --- 47,53 ---- * for a simple surface ship or aircraft model. */ ! class tcGenericDBObject : ! public tcDatabaseObject, ! public tcSensorPlatformDBObject { public: *************** *** 52,56 **** { MAXLAUNCHERS = 10, - MAXSENSORS = 8, MAXANIMATIONS = 4, MAXMAGAZINES = 3 --- 55,58 ---- *************** *** 73,87 **** int mnNumLaunchers; int mnNumMagazines; ! int mnNumSensors; tcDBString maLauncherClass[MAXLAUNCHERS]; tcDBString maMagazineClass[MAXMAGAZINES]; - tcDBString maSensorClass[MAXSENSORS]; - std::vector<long> sensorId; ///< database id's of sensors std::vector<std::string> launcherName; ///< display names of launchers, e.g. "Tube 1" - float sensorAz[MAXSENSORS]; ///< pointing angles of sensors in degrees - - tcDBString flightportClass; ///< database class name of flightport (or empty if none) std::vector<animationDBInfo> animationInfo; --- 75,84 ---- int mnNumLaunchers; int mnNumMagazines; ! tcDBString maLauncherClass[MAXLAUNCHERS]; tcDBString maMagazineClass[MAXMAGAZINES]; std::vector<std::string> launcherName; ///< display names of launchers, e.g. "Tube 1" tcDBString flightportClass; ///< database class name of flightport (or empty if none) std::vector<animationDBInfo> animationInfo; *************** *** 93,97 **** float GetLauncherAz(unsigned n); tc3DPoint GetLauncherPosition(unsigned n); ! bool HasAllEmitters(std::vector<long>& emitters); void RandInit(); virtual void PrintToFile(tcFile& file); --- 90,94 ---- float GetLauncherAz(unsigned n); tc3DPoint GetLauncherPosition(unsigned n); ! void RandInit(); virtual void PrintToFile(tcFile& file); *************** *** 109,114 **** virtual ~tcGenericDBObject(); - private: - void UpdateSensorList(); }; --- 106,109 ---- --- NEW FILE: tcSensorPlatformDBObject.h --- /** ** @file tcSensorPlatformDBObject.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 _SENSORPLATFORMDBOBJECT_H_ #define _SENSORPLATFORMDBOBJECT_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <vector> class TiXmlElement; class tcFile; namespace Database { class tcDatabase; class tcSqlReader; class CsvTranslator; /** * Sensor info for platform */ class tcSensorPlatformDBObject { public: enum { MAXSENSORS = 8 ///< number of sensor entries supported in database }; std::vector<std::string> sensorClass; std::vector<long> sensorId; ///< database id's of sensors std::vector<float> sensorAz; ///< pointing angles of sensors in degrees virtual const char* GetClassName() {return "Generic";} ///< returns class name of database object bool HasAllEmitters(std::vector<long>& emitters); void PrintToFile(tcFile& file); int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization void ReadSql(tcSqlReader& entry); void WriteSql(std::string& valueString); static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings static void AddSqlColumns(std::string& columnString); tcSensorPlatformDBObject(); tcSensorPlatformDBObject(tcSensorPlatformDBObject& obj); ///< copy constructor virtual ~tcSensorPlatformDBObject(); private: void UpdateSensorList(); }; } #endif Index: tcDatabase.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabase.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcDatabase.h 6 Nov 2004 15:13:39 -0000 1.9 --- tcDatabase.h 4 Mar 2005 00:46:14 -0000 1.10 *************** *** 84,88 **** int GetObject(tnPoolIndex anKey, tcDatabaseObject*& rpobj); tcDatabaseObject* GetObject(tnPoolIndex anKey); ! tcDatabaseObject* GetObject(std::string className); ///< gets object by class name int GetObjectClass(tnPoolIndex anKey, tcDBString& rzClass); tnPoolIndex GetFirstObjectOfClass(UINT anClassID); --- 84,88 ---- int GetObject(tnPoolIndex anKey, tcDatabaseObject*& rpobj); tcDatabaseObject* GetObject(tnPoolIndex anKey); ! tcDatabaseObject* GetObject(const std::string& className); ///< gets object by class name int GetObjectClass(tnPoolIndex anKey, tcDBString& rzClass); tnPoolIndex GetFirstObjectOfClass(UINT anClassID); *************** *** 96,100 **** void LoadDBCSV(std::string suffix = ""); void SaveDBCSV(std::string suffix = ""); ! void LoadDBXml(std::string suffix = ""); void SaveDBXml(std::string suffix = ""); void RandomizePlatforms(); --- 96,101 ---- void LoadDBCSV(std::string suffix = ""); void SaveDBCSV(std::string suffix = ""); ! void LoadDBXml(std::string suffix = ""); ! void SaveDBXml(std::string suffix = ""); void RandomizePlatforms(); |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:57
|
Update of /cvsroot/gcblue/gcb_wx/include/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/common Modified Files: tcSound.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSound.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/common/tcSound.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcSound.h 2 Mar 2005 22:28:36 -0000 1.20 --- tcSound.h 4 Mar 2005 00:46:14 -0000 1.21 *************** *** 71,78 **** bool GetMusicPause() const; ! void PlayEffect(std::string effectName); void PlayMusic(int anTrack); ! void PlayMusic(std::string song); ! void QueueMusic(std::string song); void QueueRandomMusic(); void SeekMusic(double seekTime); --- 71,78 ---- bool GetMusicPause() const; ! void PlayEffect(const std::string& effectName); void PlayMusic(int anTrack); ! void PlayMusic(const std::string& song); ! void QueueMusic(const std::string& song); void QueueRandomMusic(); void SeekMusic(double seekTime); |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:43
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/network Modified Files: tcMultiplayerInterface.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcMultiplayerInterface.cpp 2 Nov 2004 04:23:56 -0000 1.18 --- tcMultiplayerInterface.cpp 4 Mar 2005 00:46:17 -0000 1.19 *************** *** 299,303 **** * @return true if text is a (server) command */ ! bool tcMultiplayerInterface::IsCommand(std::string text) { wxString candidate(text.c_str()); --- 299,303 ---- * @return true if text is a (server) command */ ! bool tcMultiplayerInterface::IsCommand(const std::string& text) { wxString candidate(text.c_str()); *************** *** 342,346 **** } ! void tcMultiplayerInterface::OpenConnection(std::string hostName) { networkInterface->OpenConnection(hostName.c_str()); --- 342,346 ---- } ! void tcMultiplayerInterface::OpenConnection(const std::string& hostName) { networkInterface->OpenConnection(hostName.c_str()); *************** *** 375,379 **** * @return string to send back to client */ ! void tcMultiplayerInterface::ProcessCommandClient(int connectionId, std::string text) { wxString candidate(text.c_str()); --- 375,380 ---- * @return string to send back to client */ ! void tcMultiplayerInterface::ProcessCommandClient(int connectionId, ! const std::string& text) { wxString candidate(text.c_str()); *************** *** 434,438 **** * text commands start with a forward slash '/' */ ! void tcMultiplayerInterface::ProcessCommandServer(std::string text) { wxASSERT(IsServer()); --- 435,439 ---- * text commands start with a forward slash '/' */ ! void tcMultiplayerInterface::ProcessCommandServer(const std::string& text) { wxASSERT(IsServer()); *************** *** 526,530 **** * Sends a test message of text to destination */ ! void tcMultiplayerInterface::SendChatText(int destination, std::string message) { char buff[256]; --- 527,531 ---- * Sends a test message of text to destination */ ! void tcMultiplayerInterface::SendChatText(int destination, const std::string& message) { char buff[256]; *************** *** 554,558 **** ! void tcMultiplayerInterface::SendTestUDP(int destination, std::string message) { size_t messageLength = message.length(); --- 555,559 ---- ! void tcMultiplayerInterface::SendTestUDP(int destination, const std::string& message) { size_t messageLength = message.length(); *************** *** 603,607 **** * Sets identification name string for player using this interface */ ! void tcMultiplayerInterface::SetName(const std::string &name) { myName = name; --- 604,608 ---- * Sets identification name string for player using this interface */ ! void tcMultiplayerInterface::SetName(const std::string& name) { myName = name; |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:29
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/sim Modified Files: tcPlatformObject.cpp tcSubObject.cpp Added Files: tcPositionRegistry.cpp tcSensorPlatform.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup --- NEW FILE: tcPositionRegistry.cpp --- /** ** @file tcPositionRegistry.cpp */ /* 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 */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcPositionRegistry.h" #include <math.h> #ifdef _DEBUG #define new DEBUG_NEW #endif /** * Adds contents of bin <bin> to back of vector <v>. If the bin is empty * nothing is added */ void tcPositionRegistry::AppendBinContents(std::vector<long>& v, long bin) { std::map<long, std::map<long, bool> >::const_iterator iter = positionMap.find(bin); if (iter == positionMap.end()) return; std::map<long, bool>::const_iterator binIter = iter->second.begin(); while (binIter != iter->second.end()) { v.push_back(binIter->first); ++binIter; } } void tcPositionRegistry::ConformLonLat(double& lon_west, double& lon_east, double& lat_south, double& lat_north) { // put lon into [-pi, pi) and saturate lat to [-pi/2, pi/2] wxASSERT((lat_south >= -piovertwo) && (lat_south <= piovertwo)); wxASSERT((lat_north >= -piovertwo) && (lat_north <= piovertwo)); wxASSERT((lon_west >= -twopi) && (lon_west <= twopi)); wxASSERT((lon_east >= -twopi) && (lon_east <= twopi)); if (lon_west < -pi) lon_west += twopi; else if (lon_west >= pi) lon_west -= twopi; if (lon_east < -pi) lon_east += twopi; else if (lon_east >= pi) lon_east -= twopi; if (lat_south < -piovertwo) lat_south = -piovertwo; else if (lat_south > piovertwo) lat_south = piovertwo; if (lat_north < -piovertwo) lat_north = -piovertwo; else if (lat_north > piovertwo) lat_north = piovertwo; } std::vector<long>& tcPositionRegistry::GetAllWithinRegion(double lon_west, double lon_east, double lat_south, double lat_north) { static std::vector<long> idVect; idVect.clear(); wxASSERT(lat_north >= lat_south); ConformLonLat(lon_west, lon_east, lat_south, lat_north); long lat_south_idx = LatToIndex(lat_south); long lat_north_idx = LatToIndex(lat_north); long lon_west_idx = LonToIndex(lon_west); long lon_east_idx = LonToIndex(lon_east); for (long lat_idx = lat_south_idx; lat_idx <= lat_north_idx; lat_idx++) { long lat_offset = nLatBins * lat_idx; for (long lon_idx = lon_west_idx; lon_idx <= lon_east_idx; lon_idx++) { long bin = lat_offset + lon_idx; AppendBinContents(idVect, bin); } } return idVect; } void tcPositionRegistry::AddIdToBin(long id, long bin) { positionMap[bin][id] = true; } void tcPositionRegistry::RemoveAll() { //fprintf(stdout, "removing all (%d)\n", entryLookup.size()); positionMap.clear(); entryLookup.clear(); } void tcPositionRegistry::RemoveIdFromBin(long id, long bin) { std::map<long, std::map<long, bool> >::iterator posIter = positionMap.find(bin); if (posIter == positionMap.end()) { fprintf(stderr, "tcPositionRegistry::RemoveIdFromBin - " "bin not found in positionMap (%d)\n", bin); return; } std::map<long, bool>::iterator binIter = posIter->second.find(id); if (binIter == posIter->second.end()) { fprintf(stderr, "tcPositionRegistry::RemoveIdFromBin - " "id not found in bin map (%d, %d)\n", bin, id); return; } // remove id from bin map posIter->second.erase(binIter); // if bin map is now empty, remove this bin from positionMap if (posIter->second.size() == 0) { positionMap.erase(posIter); } } void tcPositionRegistry::RemoveId(long id) { // check if id exists in entryLookup std::map<long, long>::iterator entryIter = entryLookup.find(id); if (entryIter == entryLookup.end()) { fprintf(stderr, "tcPositionRegistry::RemoveId - " "id not found in entryLoookup (%d)\n", id); return; } long bin = entryIter->second; entryLookup.erase(entryIter); //fprintf(stdout, "removing id %d from bin %d\n", id, bin); RemoveIdFromBin(bin, id); } void tcPositionRegistry::UpdatePosition(long id, double lon, double lat) { wxASSERT(id != -1); wxASSERT((lon >= -pi) && (lon < pi)); wxASSERT((lat >= -piovertwo) && (lat < piovertwo)); long bin = LonLatToBinLocation(lon, lat); // check if id exists in entryLookup std::map<long, long>::iterator entryIter = entryLookup.find(id); if (entryIter == entryLookup.end()) { entryLookup[id] = bin; // add for first time AddIdToBin(id, bin); //fprintf(stdout, "new add, id %d to bin %d\n", id, bin); return; } long previousBin = entryIter->second; if (previousBin == bin) return; // no change, return RemoveIdFromBin(id, previousBin); AddIdToBin(id, bin); //fprintf(stdout, "transfering id %d from bin %d to %d\n", id, previousBin, bin); entryLookup[id] = bin; // update bin for id } long tcPositionRegistry::LatToIndex(double lat) { double idx = floor((lat + piovertwo) * invBinWidth); return long(idx); } long tcPositionRegistry::LonToIndex(double lon) { double idx = floor((lon + pi) * invBinWidth); return long(idx); } long tcPositionRegistry::LonLatToBinLocation(double lon, double lat) { double bin = (nLatBins * LatToIndex(lat)) + LonToIndex(lon); long nBin = long(bin); return nBin; } /** * */ tcPositionRegistry::tcPositionRegistry() : pi(3.141592653589793), twopi(6.283185307179586), piovertwo(1.570796326794897), binWidth(0.25 * 0.017453293) // 0.25 degrees lon/lat { invBinWidth = 1.0 / binWidth; nLatBins = ceil(pi * invBinWidth); } /** * */ tcPositionRegistry::~tcPositionRegistry() { } --- NEW FILE: tcSensorPlatform.cpp --- /** ** @file tcSensorPlatform.cpp */ /* 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 */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcSensorPlatform.h" #include "tcSensorPlatformDBObject.h" #include "tcRadar.h" #include "tcESMSensor.h" #include "common/tcStream.h" #include "common/tcObjStream.h" #include "common/tcString.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /** * @return number of sensors on platform */ unsigned tcSensorPlatform::GetSensorCount() const { return (unsigned)sensorState.size(); } /** * @return description of sensors for display */ wxString tcSensorPlatform::GetSensorDescription() { wxString description; unsigned nSensors = GetSensorCount(); for (unsigned n=0; n < nSensors; n++) { const tcSensorState* sensor = GetSensor(n); description += wxString::Format("%s\n", sensor->mpDBObj->mzClass.mz); } if (nSensors == 0) { description = "No sensors\n"; } return description; } /** * consider all active (mbActive) sensors */ bool tcSensorPlatform::HasActivatedSensor() { int nSensors = (int)sensorState.size(); for (int k=0;k<nSensors;k++) { tcSensorState *pSensorState = sensorState[k]; if (pSensorState->GetActive()) {return true;} } return false; } /** * consider only active radars */ bool tcSensorPlatform::IsRadiating() { int nSensors = (int)sensorState.size(); for (int k=0;k<nSensors;k++) { tcSensorState *pSensorState = sensorState[k]; if (dynamic_cast<tcRadar*>(pSensorState)) { if (pSensorState->GetActive()) {return true;} } } return false; } const tcSensorState* tcSensorPlatform::GetSensor(unsigned int idx) { if (idx >= sensorState.size()) return 0; else return sensorState[idx]; } /** * This version is used for non-const access to the sensor */ tcSensorState* tcSensorPlatform::GetSensorMutable(unsigned idx) { if (idx >= sensorState.size()) return 0; else return sensorState[idx]; } /** * @returns mutable pointer to first sensor matching sensorClass or 0 if not found */ tcSensorState* tcSensorPlatform::GetSensorMutable(const std::string& sensorClass) { for(size_t n=0; n<sensorState.size(); n++) { if (sensorClass == sensorState[n]->mpDBObj->mzClass.mz) { return sensorState[n]; } } return 0; } /** * Used to active/deactive sensor on platform */ void tcSensorPlatform::SetSensorState(unsigned idx, bool state) { if (idx >= sensorState.size()) return; // error sensorState[idx]->SetActive(state); sensorCommandObj.SetNewCommand(0x01 << idx); } void tcSensorPlatform::PrintToFile(tcFile& file) { tcString s; int nSensors = (int)sensorState.size(); for(int i=0;i<nSensors;i++) { tcSensorState*& pSS = sensorState[i]; if (pSS != NULL) { s.Format(" SENSOR%d: %s\n",i,pSS->mpDBObj->mzClass.mz); } else { s = " BAD SENSOR\n"; } file.WriteString(s.GetBuffer()); } } void tcSensorPlatform::SaveToFile(tcFile& file) { size_t nSensors = sensorState.size(); for(size_t i=0;i<nSensors;i++) { tcSensorState*& pss = sensorState[i]; pss->Serialize(file, false); } } /** * */ void tcSensorPlatform::LoadFromFile(tcFile& file) { // assumes that sensors already created by higher level serialize method size_t nSensors = sensorState.size(); for(size_t i=0;i<nSensors;i++) { tcSensorState*& pss = sensorState[i]; pss->Serialize(file,true); } } /** * */ void tcSensorPlatform::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); } else { SaveToFile(file); } } /** * Loads state from command stream */ tcCommandStream& tcSensorPlatform::operator<<(tcCommandStream& stream) { size_t nSensors = sensorState.size(); for(size_t n=0; n < nSensors; n++) { sensorCommandObj.LoadCommandParam(stream, sensorState[n]->mbActive, (0x01) << n); } return stream; } /** * Saves state to command stream */ tcCommandStream& tcSensorPlatform::operator>>(tcCommandStream& stream) { size_t nSensors = sensorState.size(); for(size_t n=0; n < nSensors; n++) { stream << sensorState[n]->mbActive; } return stream; } /** * Loads state from create stream */ tcCreateStream& tcSensorPlatform::operator<<(tcCreateStream& stream) { return stream; } /** * Saves state to create stream */ tcCreateStream& tcSensorPlatform::operator>>(tcCreateStream& stream) { return stream; } /** * Loads state from update stream */ tcUpdateStream& tcSensorPlatform::operator<<(tcUpdateStream& stream) { return stream; } /** * Saves state to update stream */ tcUpdateStream& tcSensorPlatform::operator>>(tcUpdateStream& stream) { return stream; } void tcSensorPlatform::ClearNewCommand() { sensorCommandObj.ClearNewCommand(); } bool tcSensorPlatform::HasNewCommand() const { return sensorCommandObj.HasNewCommand(); } bool tcSensorPlatform::HasUnacknowledgedCommand() const { return sensorCommandObj.HasUnacknowledgedCommand(); } /** * If the default constructor is used, this should be used to initialize * this object. */ void tcSensorPlatform::Init(tcSensorPlatformDBObject* obj, tcGameObject* parent) { using namespace Database; // add sensors if (obj->sensorClass.size() > tcSensorPlatformDBObject::MAXSENSORS) { fprintf(stderr, "tcSensorPlatform::Init - Warning - " "DB sensor count exceeded limit\n"); } sensorState.clear(); tcDatabase* database = tcDatabase::Get(); for(size_t i=0; i<obj->sensorClass.size(); i++) { tcDatabaseObject *pDBObj = database->GetObject(obj->sensorClass[i]); if (tcSensorDBObject *pSensorDBObj = dynamic_cast<tcSensorDBObject*>(pDBObj)) { tcSensorState* sensor = pSensorDBObj->CreateSensor(parent); // factory method wxASSERT(sensor); float lookAz_rad = C_PIOVER180 * obj->sensorAz[i]; sensor->SetMountAz(lookAz_rad); sensorState.push_back(sensor); } else { fprintf(stderr, "Error - tcSensorPlatform::Init" "(tcSensorPlatformDBObject* obj *obj) - Sensor not found\n"); } } } /** * */ tcSensorPlatform::tcSensorPlatform() { } tcSensorPlatform::tcSensorPlatform(tcSensorPlatformDBObject* obj, tcGameObject* parent) { Init(obj, parent); // This way avoids using this pointer in base class initializer } /** * */ void tcSensorPlatform::Update(double t) { size_t nSensors = sensorState.size(); for(size_t n=0; n<nSensors; n++) { tcSensorState *sensor = sensorState[n]; wxASSERT(sensor); sensor->Update(t); } } /** * */ tcSensorPlatform::tcSensorPlatform(tcSensorPlatform& o) : sensorCommandObj(o.sensorCommandObj) { // copy sensor state array sensorState.clear(); size_t nSensors = o.sensorState.size(); for (size_t n=0;n<nSensors;n++) { tcSensorState*& pSensorState = o.sensorState[n]; tcSensorState* pNewSensorState = pSensorState->Clone(); sensorState.push_back(pNewSensorState); } } /** * */ tcSensorPlatform::~tcSensorPlatform() { size_t nSensors = sensorState.size(); for (size_t n=0; n<nSensors; n++) { delete sensorState[n]; } } Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** tcPlatformObject.cpp 24 Feb 2005 22:19:16 -0000 1.38 --- tcPlatformObject.cpp 4 Mar 2005 00:46:18 -0000 1.39 *************** *** 272,282 **** { 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); ! sensor->Update(t); ! } } --- 272,277 ---- { if (clientMode) return; // no sensor update for client ! ! tcSensorPlatform::Update(t); } *************** *** 363,410 **** } - /** - * @return number of sensors on platform - */ - unsigned tcPlatformObject::GetSensorCount() const - { - return (unsigned)mapSensorState.size(); - } - - /** - * @return description of sensors for display - */ - wxString tcPlatformObject::GetSensorDescription() - { - wxString description; - unsigned nSensors = GetSensorCount(); - for (unsigned n=0; n < nSensors; n++) - { - const tcSensorState* sensor = GetSensor(n); - description += wxString::Format("%s\n", - sensor->mpDBObj->mzClass.mz); - } - - if (nSensors == 0) - { - description = "No sensors\n"; - } - - return description; - } - - /** - * consider all active (mbActive) sensors - */ - bool tcPlatformObject::HasActivatedSensor() - { - int nSensors = (int)mapSensorState.size(); - for (int k=0;k<nSensors;k++) - { - tcSensorState *pSensorState = mapSensorState[k]; - if (pSensorState->GetActive()) {return true;} - } - return false; - } /** --- 358,362 ---- *************** *** 418,437 **** } ! /** ! * consider only active radars ! */ ! bool tcPlatformObject::IsRadiating() ! { ! int nSensors = (int)mapSensorState.size(); ! for (int k=0;k<nSensors;k++) ! { ! tcSensorState *pSensorState = mapSensorState[k]; ! if (dynamic_cast<tcRadar*>(pSensorState)) ! { ! if (pSensorState->GetActive()) {return true;} ! } ! } ! return false; ! } void tcPlatformObject::Clear() --- 370,374 ---- } ! void tcPlatformObject::Clear() *************** *** 482,500 **** - const tcSensorState* tcPlatformObject::GetSensor(unsigned int idx) - { - if (idx >= mapSensorState.size()) return 0; - else return mapSensorState[idx]; - } - - /** - * This version is used for non-const access to the sensor - */ - tcSensorState* tcPlatformObject::GetSensorMutable(unsigned idx) - { - if (idx >= mapSensorState.size()) return 0; - else return mapSensorState[idx]; - } - /** * @return key of object to launch, otherwise NULL_INDEX --- 419,422 ---- *************** *** 523,535 **** } - /** - * Used to active/deactive sensor on platform - */ - void tcPlatformObject::SetSensorState(unsigned idx, bool state) - { - if (idx >= mapSensorState.size()) return; // error - mapSensorState[idx]->SetActive(state); - sensorCommandObj.SetNewCommand(0x01 << idx); - } /** --- 445,448 ---- *************** *** 602,616 **** file.WriteString(s.GetBuffer()); } ! int nSensors = (int)mapSensorState.size(); ! for(i=0;i<nSensors;i++) { ! tcSensorState*& pSS = mapSensorState[i]; ! if (pSS != NULL) { ! s.Format(" SENSOR%d: %s\n",i,pSS->mpDBObj->mzClass.mz); ! } ! else { ! s = " BAD SENSOR\n"; ! } ! file.WriteString(s.GetBuffer()); ! } } --- 515,521 ---- file.WriteString(s.GetBuffer()); } ! ! tcSensorPlatform::PrintToFile(file); ! } *************** *** 620,630 **** file.Write(&fuel_kg,sizeof(fuel_kg)); ! // sensor array ! int nSensors = (int)mapSensorState.size(); ! for(int i=0;i<nSensors;i++) ! { ! tcSensorState*& pss = mapSensorState[i]; ! pss->Serialize(file,false); ! } // other data mcLauncherState.Serialize(file, false); --- 525,531 ---- file.Write(&fuel_kg,sizeof(fuel_kg)); ! ! tcSensorPlatform::SaveToFile(file); ! // other data mcLauncherState.Serialize(file, false); *************** *** 632,636 **** file.Write(&msFormationParameters,sizeof(msFormationParameters)); } ! /******************************************************************************/ void tcPlatformObject::LoadFromFile(tcFile& file) { --- 533,540 ---- file.Write(&msFormationParameters,sizeof(msFormationParameters)); } ! ! /** ! * ! */ void tcPlatformObject::LoadFromFile(tcFile& file) { *************** *** 638,649 **** file.Read(&fuel_kg,sizeof(fuel_kg)); ! // sensor array ! // assumes that sensors already created by higher level serialize method ! int nSensors = (int)mapSensorState.size(); ! for(int i=0;i<nSensors;i++) ! { ! tcSensorState*& pss = mapSensorState[i]; ! pss->Serialize(file,true); ! } // other data --- 542,547 ---- file.Read(&fuel_kg,sizeof(fuel_kg)); ! ! tcSensorPlatform::LoadFromFile(file); // other data *************** *** 652,657 **** file.Read(&msFormationParameters,sizeof(msFormationParameters)); } ! /******************************************************************************/ ! void tcPlatformObject::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { --- 550,559 ---- file.Read(&msFormationParameters,sizeof(msFormationParameters)); } ! ! /** ! * ! */ ! void tcPlatformObject::Serialize(tcFile& file, bool mbLoad) ! { if (mbLoad) { *************** *** 696,704 **** if (updateMask & UPDATE_SENSORS) { ! size_t nSensors = mapSensorState.size(); ! for(size_t n=0; n < nSensors; n++) ! { ! sensorCommandObj.LoadCommandParam(stream, mapSensorState[n]->mbActive, (0x01) << n); ! } } --- 598,602 ---- if (updateMask & UPDATE_SENSORS) { ! tcSensorPlatform::operator<<(stream); } *************** *** 720,724 **** updateMask |= UPDATE_LAUNCHERS; } ! if (stream.isAck || sensorCommandObj.HasUnacknowledgedCommand()) { updateMask |= UPDATE_SENSORS; --- 618,622 ---- updateMask |= UPDATE_LAUNCHERS; } ! if (stream.isAck || tcSensorPlatform::HasUnacknowledgedCommand()) { updateMask |= UPDATE_SENSORS; *************** *** 748,756 **** if (updateMask & UPDATE_SENSORS) { ! size_t nSensors = mapSensorState.size(); ! for(size_t n=0; n < nSensors; n++) ! { ! stream << mapSensorState[n]->mbActive; ! } } --- 646,650 ---- if (updateMask & UPDATE_SENSORS) { ! tcSensorPlatform::operator>>(stream); } *************** *** 766,769 **** --- 660,665 ---- tcGameObject::operator<<(stream); + tcSensorPlatform::operator<<(stream); + return stream; } *************** *** 775,778 **** --- 671,676 ---- { tcGameObject::operator>>(stream); + + tcSensorPlatform::operator>>(stream); return stream; *************** *** 789,792 **** --- 687,692 ---- mcLauncherState.operator<<(stream); + tcSensorPlatform::operator<<(stream); + return stream; } *************** *** 801,804 **** --- 701,706 ---- mcLauncherState.operator>>(stream); + tcSensorPlatform::operator>>(stream); + return stream; } *************** *** 808,812 **** commandObj.ClearNewCommand(); mcLauncherState.ClearNewCommand(); ! sensorCommandObj.ClearNewCommand(); } --- 710,714 ---- commandObj.ClearNewCommand(); mcLauncherState.ClearNewCommand(); ! tcSensorPlatform::ClearNewCommand(); } *************** *** 814,818 **** { return commandObj.HasNewCommand() || mcLauncherState.HasNewCommand() || ! sensorCommandObj.HasNewCommand(); } --- 716,720 ---- { return commandObj.HasNewCommand() || mcLauncherState.HasNewCommand() || ! tcSensorPlatform::HasNewCommand(); } *************** *** 820,837 **** { return commandObj.HasUnacknowledgedCommand() || mcLauncherState.HasNewCommand() || ! sensorCommandObj.HasUnacknowledgedCommand(); } ! /******************************************************************************/ ! tcPlatformObject::tcPlatformObject() ! { ! Clear(); ! brain = new Brain(this); ! mpDBObject = NULL; ! mcLauncherState.mnCount = 0; ! mapSensorState.clear(); ! mnModelType = MTYPE_PLATFORM; ! } --- 722,730 ---- { return commandObj.HasUnacknowledgedCommand() || mcLauncherState.HasNewCommand() || ! tcSensorPlatform::HasUnacknowledgedCommand(); } ! *************** *** 843,856 **** void tcPlatformObject::SetFireControlSensors() { // ! for(int nLauncher=0;nLauncher<mpDBObject->mnNumLaunchers;nLauncher++) { std::string fcSensor = mcLauncherState.GetFireControlSensorClass(nLauncher); // search for sensor and add if match bool bSearching = fcSensor.length() > 1; ! for(size_t n=0; (n<mapSensorState.size()) && bSearching; n++) { ! tcRadar* radar = dynamic_cast<tcRadar*>(mapSensorState[n]); if (radar) { --- 736,752 ---- void tcPlatformObject::SetFireControlSensors() { + size_t nSensors = tcSensorPlatform::GetSensorCount(); + // ! for(int nLauncher=0; nLauncher<mpDBObject->mnNumLaunchers; nLauncher++) { std::string fcSensor = mcLauncherState.GetFireControlSensorClass(nLauncher); + // search for sensor and add if match bool bSearching = fcSensor.length() > 1; ! for(size_t n=0; (n<nSensors) && bSearching; n++) { ! tcRadar* radar = dynamic_cast<tcRadar*>(tcSensorPlatform::GetSensorMutable(n)); if (radar) { *************** *** 862,865 **** --- 758,762 ---- } } + if (bSearching) { *************** *** 870,880 **** } tcPlatformObject::tcPlatformObject(tcGenericDBObject *obj) ! : tcGameObject(obj) { using namespace Database; brain = new Brain(this); - //brain->AddTask("TestTask", 1.0); mpDBObject = obj; --- 767,794 ---- } + + /** + * + */ + tcPlatformObject::tcPlatformObject() + : mpDBObject(0) + { + wxASSERT(false); + + Clear(); + brain = new Brain(this); + mcLauncherState.mnCount = 0; + mnModelType = MTYPE_PLATFORM; + } + + tcPlatformObject::tcPlatformObject(tcGenericDBObject *obj) ! : tcGameObject(obj), tcSensorPlatform() { using namespace Database; + tcSensorPlatform::Init(obj, this); + brain = new Brain(this); mpDBObject = obj; *************** *** 888,918 **** fuel_kg = mpDBObject->mfFuelCapacity_kg; // start with max fuel - // add sensors - if (mpDBObject->mnNumSensors > tcGenericDBObject::MAXSENSORS) - { - mpDBObject->mnNumSensors = tcGenericDBObject::MAXSENSORS; // limit number of sensors - fprintf(stderr, "tcPlatformObject::tcPlatformObject - Warning - " - "DB sensor count exceeded limit\n"); - } - mapSensorState.clear(); - for(int i=0;i<mpDBObject->mnNumSensors;i++) - { - tnPoolIndex nSensorKey = database->GetKey(mpDBObject->maSensorClass[i]); - tcDatabaseObject *pDBObj = database->GetObject(nSensorKey); - - if (tcSensorDBObject *pSensorDBObj = dynamic_cast<tcSensorDBObject*>(pDBObj)) - { - tcSensorState* sensorState = pSensorDBObj->CreateSensor(this); // factory method - float lookAz_rad = C_PIOVER180 * mpDBObject->sensorAz[i]; - sensorState->SetMountAz(lookAz_rad); - mapSensorState.push_back(sensorState); - } - else - { - fprintf(stderr, "Error - tcPlatformObject::tcPlatformObject(tcGenericDBObject *obj)" - " - Sensor not found\n"); - } - - } // add magazines --- 802,805 ---- *************** *** 962,968 **** lastHeadingDelta = 0; } ! /******************************************************************************/ tcPlatformObject::tcPlatformObject(tcPlatformObject& o) : tcGameObject(o), commandObj(o.commandObj) { --- 849,860 ---- lastHeadingDelta = 0; } ! ! ! /** ! * ! */ tcPlatformObject::tcPlatformObject(tcPlatformObject& o) : tcGameObject(o), + tcSensorPlatform(o), commandObj(o.commandObj) { *************** *** 986,1000 **** } - // copy sensor state array - mapSensorState.clear(); - int nSensors = (int)o.mapSensorState.size(); - for (int n=0;n<nSensors;n++) - { - tcSensorState*& pSensorState = o.mapSensorState[n]; - tcSensorState* pNewSensorState = pSensorState->Clone(); - mapSensorState.push_back(pNewSensorState); - } } ! /******************************************************************************/ tcPlatformObject::~tcPlatformObject() { --- 878,885 ---- } } ! /** ! * ! */ tcPlatformObject::~tcPlatformObject() { *************** *** 1006,1017 **** } - int nSensors = (int)mapSensorState.size(); - for (int n=0;n<nSensors;n++) - { - tcSensorState*& pSensorState = mapSensorState[n]; - delete pSensorState; - pSensorState = NULL; - } - mapSensorState.clear(); } --- 891,894 ---- Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcSubObject.cpp 2 Dec 2004 04:17:27 -0000 1.3 --- tcSubObject.cpp 4 Mar 2005 00:46:18 -0000 1.4 *************** *** 408,415 **** { 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()) --- 408,416 ---- { if (clientMode) return; // no sensor update for client ! ! unsigned nSensors = GetSensorCount(); for(unsigned n=0; n<nSensors; n++) { ! tcSensorState* sensor = GetSensorMutable(n); wxASSERT(sensor); if (sensor->IsSonar()) |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:29
|
Update of /cvsroot/gcblue/gcb_wx/include/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/include/ai Added Files: Nav.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup --- NEW FILE: Nav.h --- /** ** @file Nav.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 _NAV_H_ #define _NAV_H_ #if _MSC_VER > 1000 #pragma once #endif #include "ai/Task.h" #include <map> #include <string> #include <vector> class tcPlatformObject; class GeoPoint; namespace ai { /** * Basic navigation with waypoints */ class Nav : public Task { public: void AddWaypoint(double lon_rad, double lat_rad, float alt_m); void ClearWaypoints(); const std::vector<GeoPoint>& GetWaypoints() const; void Update(double t); Nav(tcPlatformObject* platform_, Blackboard* bb, long id_, double priority_, const std::string& taskName_); ~Nav(); private: std::vector<GeoPoint> waypoints; unsigned currentWaypoint; }; } #endif |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:29
|
Update of /cvsroot/gcblue/gcb_wx/src/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/src/ai Added Files: Nav.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup --- NEW FILE: Nav.cpp --- /** ** @file Nav.cpp */ /* 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 */ #include "stdwx.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "ai/Nav.h" #include "scriptinterface/tcPlatformInterface.h" #include "simmath.h" #ifdef _DEBUG #define new DEBUG_NEW #endif using namespace ai; using ScriptInterface::tcPlatformInterface; void Nav::AddWaypoint(double lon_rad, double lat_rad, float alt_m) { GeoPoint waypoint; waypoint.Set(lon_rad, lat_rad, alt_m); waypoints.push_back(waypoint); } void Nav::ClearWaypoints() { waypoints.clear(); } /** * @return waypoint vector of GeoPoint */ const std::vector<GeoPoint>& Nav::GetWaypoints() const { return waypoints; } void Nav::Update(double t) { if (!IsReadyForUpdate(t)) return; if (currentWaypoint >= waypoints.size()) { EndTask(); return; } // return if conn is locked by another higher priority task if (!Write("ConnLock", "")) return; tcPlatformInterface platformInterface = GetPlatformInterface(); GeoPoint& waypoint = waypoints[currentWaypoint]; double lon_rad = waypoint.mfLon_rad; double lat_rad = waypoint.mfLat_rad; float alt_m = waypoint.mfAlt_m; float heading_deg = platformInterface.GetHeadingToDatum(lon_rad, lat_rad); float range_m = 1000.0f * platformInterface.GetRangeToDatum(lon_rad, lat_rad); float speed_mps = C_KTSTOMPS * platformInterface.GetSpeed(); float eta_s = (speed_mps > 0) ? (range_m / speed_mps) : 9999.0f; if (eta_s >= 30.0f) { SetUpdateInterval(20.0f); } else if (eta_s >= 2.0f) { SetUpdateInterval(1.0f); } else { SetUpdateInterval(1.0f); currentWaypoint++; } platformInterface.SetHeading(heading_deg); FinishUpdate(t); } Nav::Nav(tcPlatformObject* platform_, Blackboard* bb, long id_, double priority_, const std::string& taskName_) : Task(platform_, bb, id_, priority_, taskName_), currentWaypoint(0) { wxASSERT(platform); } Nav::~Nav() { } |
|
From: Dewitt C. <ddc...@us...> - 2005-03-04 00:46:29
|
Update of /cvsroot/gcblue/gcb_wx/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821/xml Modified Files: options.xml Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: options.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/options.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** options.xml 2 Mar 2005 22:28:45 -0000 1.13 --- options.xml 4 Mar 2005 00:46:18 -0000 1.14 *************** *** 2,9 **** <HostAddress>192.168.0.102</HostAddress> <DisplaySettings>default</DisplaySettings> ! <LastScenarioPath>Test.SubTestII.py</LastScenarioPath> ! <LastScenarioName>SubTestII</LastScenarioName> ! <xCopyDatabase /> ! <xWriteXmlDatabase /> <Log3DModelDetails /> <UsePositionRegistry /> --- 2,9 ---- <HostAddress>192.168.0.102</HostAddress> <DisplaySettings>default</DisplaySettings> ! <LastScenarioPath>Test.Type42.py</LastScenarioPath> ! <LastScenarioName>Type42</LastScenarioName> ! <noCopyDatabase /> ! <noWriteXmlDatabase /> <Log3DModelDetails /> <UsePositionRegistry /> |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtension.cpp tcPlatformInterfaceExtensionB.cpp tcScenarioInterface.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcPlatformInterfaceExtensionB.cpp 24 Feb 2005 22:19:15 -0000 1.20 --- tcPlatformInterfaceExtensionB.cpp 2 Mar 2005 22:28:44 -0000 1.21 *************** *** 1,6 **** ! /* ! ** tcPlatformInterfaceExtensionB.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcPlatformInterfaceExtensionB.cpp ! */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 36,39 **** --- 36,40 ---- #include "tcPlatformInterface.h" #include "tcSoundConsole.h" + #include "ai/BlackboardInterface.h" #ifdef _DEBUG *************** *** 43,46 **** --- 44,48 ---- using namespace boost::python; using namespace AI; + using ai::BlackboardInterface; namespace ScriptInterface { *************** *** 77,81 **** .def("IsHelo", &tcPlatformInterface::IsHelo) .def("IsSub", &tcPlatformInterface::IsSub) - .def("SetUpdate", &tcPlatformInterface::SetUpdateInterval) .def("SetActionText", &tcPlatformInterface::SetActionText) .def("GetSubInterface", &tcPlatformInterface::GetSubInterface) --- 79,82 ---- *************** *** 108,120 **** // orders ! .def("AddNavOrder",&tcPlatformInterface::AddNavOrder) ! .def("AddOrder",&tcPlatformInterface::AddOrder) ! .def("ClearOrders",&tcPlatformInterface::ClearOrders) ! .def("CompletedOrder",&tcPlatformInterface::CompletedOrder) ! .def("GetCurrentOrder",&tcPlatformInterface::GetCurrentOrder) .def("GetLocalObj",&tcPlatformInterface::GetLocalObj) - .def("GetOrder",&tcPlatformInterface::GetOrder) - .def("GetOrderCount",&tcPlatformInterface::GetOrderCount) - .def("HasOrders",&tcPlatformInterface::HasOrders) // sensors --- 109,121 ---- // orders ! .def("AddNavWaypoint", &tcPlatformInterface::AddNavWaypoint) ! .def("AddTask", &tcPlatformInterface::AddTask) ! .def("ClearTasks", &tcPlatformInterface::ClearTasks) ! .def("DeleteTask", &tcPlatformInterface::DeleteTask) ! .def("GetBlackboardInterface", &tcPlatformInterface::GetBlackboardInterface) ! .def("TaskExists", &tcPlatformInterface::TaskExists) ! ! // TODO why is this exposed?? .def("GetLocalObj",&tcPlatformInterface::GetLocalObj) // sensors *************** *** 142,147 **** // miscellaneous ! .def("GetVar", &tcPlatformInterface::GetVar) ! .def("SetVar", &tcPlatformInterface::SetVar) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) .def("IsValid",&tcPlatformInterface::IsValid) --- 143,149 ---- // miscellaneous ! .def("GetTime", &tcPlatformInterface::GetTime) ! .def("LookupFriendlyId", &tcPlatformInterface::LookupFriendlyId) ! .def("LookupFriendlyName", &tcPlatformInterface::LookupFriendlyName) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) .def("IsValid",&tcPlatformInterface::IsValid) Index: tcPlatformInterfaceExtension.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtension.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcPlatformInterfaceExtension.cpp 24 Feb 2005 22:19:15 -0000 1.14 --- tcPlatformInterfaceExtension.cpp 2 Mar 2005 22:28:44 -0000 1.15 *************** *** 42,46 **** namespace ScriptInterface { ! void tcPlatformInterface::InitPythonClassesA(void) { object class_track = class_<tcTrack>("tcTrack") .def_readwrite("Alt",&tcTrack::mfAlt_m) --- 42,47 ---- namespace ScriptInterface { ! void tcPlatformInterface::InitPythonClassesA() ! { object class_track = class_<tcTrack>("tcTrack") .def_readwrite("Alt",&tcTrack::mfAlt_m) *************** *** 56,59 **** --- 57,61 ---- .def("IsMissile", &tcTrack::IsMissile) .def("IsSurface", &tcTrack::IsSurface) + .def("IsGround", &tcTrack::IsGround) .def("IsValid", &tcTrack::IsValid) .def("Offset", &tcTrack::Offset) *************** *** 74,77 **** --- 76,80 ---- .def("IsMissile", &tcSensorMapTrack::IsMissile) .def("IsSurface", &tcSensorMapTrack::IsSurface) + .def("IsGround", &tcSensorMapTrack::IsGround) .def("IsValid", &tcSensorMapTrack::IsValid) .def("Offset", &tcSensorMapTrack::Offset) Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcScenarioInterface.cpp 24 Feb 2005 22:19:15 -0000 1.20 --- tcScenarioInterface.cpp 2 Mar 2005 22:28:44 -0000 1.21 *************** *** 47,50 **** --- 47,51 ---- #include "tcSubObject.h" #include "ai/Brain.h" + #include "tcPlatformInterface.h" #include "wxcommands.h" *************** *** 141,146 **** .def("AddUnitTask", &tcScenarioInterface::AddUnitTask) .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) ! .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) --- 142,148 ---- .def("AddUnitTask", &tcScenarioInterface::AddUnitTask) .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) + .def("GetUnitInterface", &tcScenarioInterface::GetUnitInterface) .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) ! .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) *************** *** 353,356 **** --- 355,372 ---- + tcPlatformInterface tcScenarioInterface::GetUnitInterface(const std::string& unitName) + { + wxASSERT(simState); + tcGameObject* obj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(obj)) + { + return tcPlatformInterface(platform); + } + else + { + return tcPlatformInterface(0); + } + } + /** * Sets launcher item and quantity of unit Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tcPlatformInterface.cpp 24 Feb 2005 22:19:15 -0000 1.37 --- tcPlatformInterface.cpp 2 Mar 2005 22:28:44 -0000 1.38 *************** *** 2,6 **** ** @file tcPlatformInterface.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcPlatformInterface.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 715,742 **** - bool tcPlatformInterface::HasOrders() - { - return mpPlatformObj->mcAI.HasOrders(); - } - - tcOrder tcPlatformInterface::GetCurrentOrder() - { - return mpPlatformObj->mcAI.GetCurrentOrder(); - } - - void tcPlatformInterface::CompletedOrder() - { - mpPlatformObj->mcAI.CompletedOrder(); - } ! void tcPlatformInterface::AddOrder(std::string order_text, long data) { ! tcOrder o; ! o.mstrOrdername = order_text; ! o.data = data; ! mpPlatformObj->mcAI.AddOrder(o); } ! void tcPlatformInterface::AddNavOrder(float afLon_rad, float afLat_rad) { ai::Brain* brain = mpPlatformObj->GetBrain(); --- 715,728 ---- ! void tcPlatformInterface::AddTask(const std::string& taskName, double priority) { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! brain->AddTask(taskName, priority); } ! void tcPlatformInterface::AddNavWaypoint(float afLon_rad, float afLat_rad) { ai::Brain* brain = mpPlatformObj->GetBrain(); *************** *** 746,750 **** if (!nav) { ! brain->AddTask("Nav", 1.5f); nav = brain->GetNavTask(); } --- 732,736 ---- if (!nav) { ! brain->AddTask("Nav", 1.0f); nav = brain->GetNavTask(); } *************** *** 755,784 **** /** ! * Only removes Nav task at the moment */ ! void tcPlatformInterface::ClearOrders() { ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); ! mpPlatformObj->GetBrain()->RemoveTask("Nav"); } void tcPlatformInterface::DeleteTask(const std::string& taskName) { ! mpPlatformObj->GetBrain()->RemoveTask(taskName); } ! int tcPlatformInterface::GetOrderCount() { ! return (int)mpPlatformObj->mcAI.maOrder.size(); } ! tcOrder tcPlatformInterface::GetOrder(int n) ! { ! tcOrder order; ! mpPlatformObj->mcAI.GetOrder(order, n); ! return order; } void tcPlatformInterface::GetSensorMap() --- 741,781 ---- /** ! * Remove all tasks from ai brain */ ! void tcPlatformInterface::ClearTasks() { ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); ! brain->RemoveAllTasks(); } void tcPlatformInterface::DeleteTask(const std::string& taskName) { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! brain->RemoveTask(taskName); } ! /** ! * Used to pass parameters to tasks by posting for all tasks to see ! */ ! ai::BlackboardInterface tcPlatformInterface::GetBlackboardInterface() { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! return brain->GetBlackboardInterface(); } ! bool tcPlatformInterface::TaskExists(const std::string& taskName) ! { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! return brain->TaskExists(taskName); } + void tcPlatformInterface::GetSensorMap() *************** *** 1070,1075 **** ! /* Request user input. Python callback function is called after input is ! ** obtained */ void tcPlatformInterface::GetUserInput(std::string callback, std::string uitype) { --- 1067,1080 ---- ! double tcPlatformInterface::GetTime() const ! { ! wxASSERT(mpPlatformObj); ! return mpPlatformObj->mfStatusTime; ! } ! ! /** ! * Request user input. Python callback function is called after input is ! * obtained ! */ void tcPlatformInterface::GetUserInput(std::string callback, std::string uitype) { *************** *** 1077,1083 **** mpCommandQueue->GetUserInput(callback.c_str(),uitype.c_str()); } ! /* Send command through command queue, used for special commands to game engine ! ** such as activating the flight deck control panel. */ void tcPlatformInterface::SendCommand(std::string command) --- 1082,1115 ---- mpCommandQueue->GetUserInput(callback.c_str(),uitype.c_str()); } + + long tcPlatformInterface::LookupFriendlyId(const std::string& unitName) + { + tcGameObject* obj = mpSimState->GetObjectByName(unitName); + if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->mnAlliance)) + { + return -1; + } + else + { + return obj->mnID; + } + } + + std::string tcPlatformInterface::LookupFriendlyName(long id) + { + tcGameObject* obj = mpSimState->GetObject(id); + if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->mnAlliance)) + { + return std::string(""); + } + else + { + return std::string(obj->mzUnit.mz); + } + } ! /** ! * Send command through command queue, used for special commands to game engine ! * such as activating the flight deck control panel. */ void tcPlatformInterface::SendCommand(std::string command) *************** *** 1096,1100 **** ! // print message to user console void tcPlatformInterface::DisplayMessage(std::string text) { --- 1128,1134 ---- ! /** ! * print message to user console ! */ void tcPlatformInterface::DisplayMessage(std::string text) { *************** *** 1140,1144 **** * Heading_rad has runway orientation * ! * @returns track with landing data for platform id */ tcTrack tcPlatformInterface::GetLandingData(long id) --- 1174,1178 ---- * Heading_rad has runway orientation * ! * @returns track with landing data for platform matching id */ tcTrack tcPlatformInterface::GetLandingData(long id) |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/src/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/ai Modified Files: Brain.cpp ScriptedTaskInterface.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: ScriptedTaskInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/ScriptedTaskInterface.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScriptedTaskInterface.cpp 24 Feb 2005 22:19:15 -0000 1.2 --- ScriptedTaskInterface.cpp 2 Mar 2005 22:28:42 -0000 1.3 *************** *** 123,126 **** --- 123,128 ---- { wxASSERT(task); + + if (interval < 0.1f) interval = 0.1f; // 10 Hz maximum task->SetUpdateInterval(interval); } Index: Brain.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Brain.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Brain.cpp 24 Feb 2005 22:19:15 -0000 1.5 --- Brain.cpp 2 Mar 2005 22:28:41 -0000 1.6 *************** *** 27,30 **** --- 27,31 ---- #include "ai/Brain.h" + #include "ai/BlackboardInterface.h" #include "ai/Task.h" #include "ai/Nav.h" *************** *** 52,55 **** --- 53,64 ---- /** + * gets a low priority, anonymous interface to board + */ + BlackboardInterface Brain::GetBlackboardInterface() + { + return BlackboardInterface(&board, 0, 0.0); + } + + /** * @return pointer to Nav task or 0 if none exists */ *************** *** 161,164 **** --- 170,189 ---- /** + * Removes all tasks. Cannot be called in the middle of an + * update (i.e. can't be called by task) + */ + void Brain::RemoveAllTasks() + { + if (updating) return; + + std::map<std::string, Task*>::iterator iter = taskMap.begin(); + while (iter != taskMap.end()) + { + delete iter->second; + taskMap.erase(iter++); + } + } + + /** * Removes tasks in removeList. This allows a task to safely delete itself. */ *************** *** 212,215 **** --- 237,242 ---- RemovePending(); + updating = true; + // iterate through task map and update tasks std::map<std::string, Task*>::iterator iter = taskMap.begin(); *************** *** 223,226 **** --- 250,255 ---- lastUpdateTime = t; + + updating = false; } *************** *** 228,233 **** : platform(platform_), updateInterval(0.125f), ! nextId(0), ! target(-1) { wxASSERT(platform); --- 257,263 ---- : platform(platform_), updateInterval(0.125f), ! nextId(1), ! target(-1), ! updating(false) { wxASSERT(platform); |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/common Modified Files: tcSound.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSound.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcSound.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcSound.cpp 24 Feb 2005 22:19:15 -0000 1.24 --- tcSound.cpp 2 Mar 2005 22:28:42 -0000 1.25 *************** *** 413,424 **** } - /** - * DEPRECATED - */ - void tcSound::PlayEffect(int anEffect) - { - wxASSERT(false); - - } --- 413,416 ---- |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/include/sim Modified Files: tcSensorMap.h tcSensorState.h tcSimState.h Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSimState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSimState.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tcSimState.h 24 Feb 2005 22:19:14 -0000 1.33 --- tcSimState.h 2 Mar 2005 22:28:40 -0000 1.34 *************** *** 66,69 **** --- 66,70 ---- class tcMissileObject; class tcTorpedoObject; + class tcPositionRegistry; #define N_GAME_OBJECTS 1024 *************** *** 148,152 **** int GetPlatformState(long anKey, tcGameObject*& pplat); tcGameObject* GetObject(tnPoolIndex anKey); ! tcGameObject* GetObjectByName(std::string unitName); int GetPlatformsWithinRegion(tnPoolIndex *apKeyList, int anLength, tcRect *apRegion); long GetRandomPlatform(); --- 149,153 ---- int GetPlatformState(long anKey, tcGameObject*& pplat); tcGameObject* GetObject(tnPoolIndex anKey); ! tcGameObject* GetObjectByName(const std::string& unitName); int GetPlatformsWithinRegion(tnPoolIndex *apKeyList, int anLength, tcRect *apRegion); long GetRandomPlatform(); *************** *** 195,198 **** --- 196,201 ---- MultiplayerMode multiplayerMode; ///< multiplayer mode, default = MM_OFF long timeAcceleration; ///< 0 - paused, 1 - normal, N - Nx accelerated time + std::map<std::string, long> objectNameMap; ///< for fast lookup by object name + tcPositionRegistry* positionRegistry; ///< for fast(er) lookup by region void EvaluateGuidedMissileHit(tcMissileObject* missile, tcGameObject* target); *************** *** 206,209 **** --- 209,213 ---- void ProcessESMDetection(tcGameObject *apESMPlat,tcGameObject *apTarget, tcESMSensor *apESMSS); + void RegisterPlatform(tcGameObject* obj); void ReportDamage(tcGameObject* obj); void UpdateFireControl(tcGameObject *apGameObj, tcRadar *apRadarSS); Index: tcSensorMap.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorMap.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcSensorMap.h 6 Nov 2004 15:13:40 -0000 1.10 --- tcSensorMap.h 2 Mar 2005 22:28:39 -0000 1.11 *************** *** 1,4 **** ! /* ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,7 ---- ! /** ! ** @file tcSensorMap.h ! ** TODO needs cleanup, this area is a mess ! */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 99,105 **** { enum {MAX_SENSOR_REPORTS = 2, MAX_EMITTERS = 4}; public: - //tcTrack track; - double mfLastUpdateTime; tcSensorReport maSensorReport[MAX_SENSOR_REPORTS]; ///< most recent data from contributing sensors int mnContributors; --- 102,107 ---- { enum {MAX_SENSOR_REPORTS = 2, MAX_EMITTERS = 4}; + public: tcSensorReport maSensorReport[MAX_SENSOR_REPORTS]; ///< most recent data from contributing sensors int mnContributors; *************** *** 107,113 **** int mnEmitters; long mnDatabaseID; ///< database ID of track, -1 for unknown ! float matchupRating; ///< matchup rating for platforms that have targeted this track ! float expectedDamage; ///< rating of expected fractional damage of weapons launched at target, 0 - none, 1.0 - totally destroyed ! float assessedDamage; ///< fractional damage assessment std::vector<long> intercepts; ///< vector of platform ids that are intercepting this track std::vector<long> engaged; ///< vector of weapon ids that are tracking / engaging --- 109,113 ---- int mnEmitters; long mnDatabaseID; ///< database ID of track, -1 for unknown ! float assessedDamage; std::vector<long> intercepts; ///< vector of platform ids that are intercepting this track std::vector<long> engaged; ///< vector of weapon ids that are tracking / engaging *************** *** 122,125 **** --- 122,126 ---- bool AddReport(const tcSensorReport& report); + void RemoveReport(int n); ///< static method to set pointer to tcSimState object *************** *** 144,148 **** const tcTrack* GetTrack() {return this;} bool IsNew() {return mfTimestamp == 0;} ! bool UpdateActiveReport(tcSensorReport*& rpReport, tnPoolIndex anSensorID); --- 145,153 ---- const tcTrack* GetTrack() {return this;} bool IsNew() {return mfTimestamp == 0;} ! bool IsDestroyed() const; ! bool IsStale() const; ! void MarkDestroyed(); ! void MarkStale(); ! void ClearStale(); bool UpdateActiveReport(tcSensorReport*& rpReport, tnPoolIndex anSensorID); *************** *** 170,178 **** ~tcSensorMapTrack(); ! void RemoveReport(int n); ! private: static tcSimState* simState; static tcDatabase* database; }; --- 175,187 ---- ~tcSensorMapTrack(); ! static void SetAutoKillAssess(bool state); private: static tcSimState* simState; static tcDatabase* database; + static bool autoKillAssess; ///< set to true to automatically mark destroyed tracks + enum {TRACK_STALE = 1, TRACK_DESTROYED = 2}; + unsigned int sensorFlags; ///< 1 - stale, 2 - destroyed + + void KillAssess(); }; *************** *** 212,215 **** --- 221,226 ---- double lastEngagementsUpdate; const unsigned int alliance; + float ageOutTime; ///< time to drop track + float staleTime; ///< time to indicate track as stale }; Index: tcSensorState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorState.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcSensorState.h 24 Feb 2005 22:19:14 -0000 1.14 --- tcSensorState.h 2 Mar 2005 22:28:40 -0000 1.15 *************** *** 39,48 **** using Database::tcSensorDBObject; ! #define SSMODE_SURVEILLANCE 1 #define SSMODE_SEEKERTRACK 2 ///< seeker is tracking target #define SSMODE_SEEKERSEARCH 3 ///< seeker searching for target #define SSMODE_SEEKERACQUIRE 4 ///< seeker has target cue and attempting to track #define SSMODE_FC 5 // fire control only - #define SSMODE_FCSURVEILLANCE 6 // both class tcSimState; --- 39,47 ---- using Database::tcSensorDBObject; ! #define SSMODE_SURVEILLANCE 1 ///< surveillance or both FC and surveillance #define SSMODE_SEEKERTRACK 2 ///< seeker is tracking target #define SSMODE_SEEKERSEARCH 3 ///< seeker searching for target #define SSMODE_SEEKERACQUIRE 4 ///< seeker has target cue and attempting to track #define SSMODE_FC 5 // fire control only class tcSimState; |
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/sim Modified Files: tcLauncher.cpp tcMenu.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorMap.cpp tcSimState.cpp tcTorpedoObject.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** tcSimState.cpp 24 Feb 2005 22:19:16 -0000 1.67 --- tcSimState.cpp 2 Mar 2005 22:28:45 -0000 1.68 *************** *** 55,58 **** --- 55,59 ---- #include "common/tcStream.h" #include "tcMessageInterface.h" + #include "tcPositionRegistry.h" #ifdef _DEBUG *************** *** 65,69 **** using namespace ScriptInterface; [...1013 lines suppressed...] } ! /********************************************************************/ --- 2550,2566 ---- s.Format("tcSimState size: %d kB",sizeof(tcSimState)/1024); WTL(s.GetBuffer()); + #endif } ! ! /** ! * ! */ tcSimState::~tcSimState() { Clear(); if (goalTracker) delete goalTracker; + if (positionRegistry) delete positionRegistry; } ! ! Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcOpticalSensor.cpp 27 Jan 2005 01:02:06 -0000 1.5 --- tcOpticalSensor.cpp 2 Mar 2005 22:28:45 -0000 1.6 *************** *** 426,430 **** wxASSERT(parent); ! if ((mnMode == SSMODE_SURVEILLANCE) || (mnMode == SSMODE_FCSURVEILLANCE)) { UpdateSurveillance(t); --- 426,430 ---- wxASSERT(parent); ! if (mnMode == SSMODE_SURVEILLANCE) { UpdateSurveillance(t); *************** *** 453,457 **** wxASSERT(dbObj); ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; mbActive = true; // optical defaults to always on --- 453,457 ---- wxASSERT(dbObj); ! mnMode = dbObj->isSurveillance ? SSMODE_SURVEILLANCE : SSMODE_FC; mfSensorHeight_m = 10.0f; mbActive = true; // optical defaults to always on Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTorpedoObject.cpp 24 Feb 2005 22:19:16 -0000 1.5 --- tcTorpedoObject.cpp 2 Mar 2005 22:28:45 -0000 1.6 *************** *** 370,374 **** mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vz_mps*vz_mps + vxy_mps*vxy_mps); ! if (mcKin.mfAlt_m <= 0) mcKin.mfSpeed_kts *= 0.1f; // lose speed after hitting water --- 370,378 ---- mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vz_mps*vz_mps + vxy_mps*vxy_mps); ! if (mcKin.mfAlt_m <= 0) ! { ! mcKin.mfSpeed_kts *= 0.1f; // lose speed after hitting water ! if (mcKin.mfSpeed_kts < 5.0) mcKin.mfSpeed_kts = 5.0f; ! } Index: tcMenu.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMenu.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcMenu.cpp 1 Feb 2005 02:29:15 -0000 1.11 --- tcMenu.cpp 2 Mar 2005 22:28:45 -0000 1.12 *************** *** 449,453 **** tcMenu::tcMenu() ! : fontSize(16.0) { maMenuData.clear(); --- 449,453 ---- tcMenu::tcMenu() ! : fontSize(14.0) { maMenuData.clear(); *************** *** 463,467 **** tcMenu::tcMenu(tcMenu* apParent) ! : fontSize(16.0) { maMenuData.clear(); --- 463,467 ---- tcMenu::tcMenu(tcMenu* apParent) ! : fontSize(14.0) { maMenuData.clear(); Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcRadar.cpp 21 Feb 2005 18:26:26 -0000 1.25 --- tcRadar.cpp 2 Mar 2005 22:28:45 -0000 1.26 *************** *** 233,237 **** return false; } ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; --- 233,244 ---- return false; } ! if (mpDBObj->isSurveillance) ! { ! mnMode = SSMODE_SURVEILLANCE; ! } ! else ! { ! mnMode = SSMODE_FC; ! } mfSensorHeight_m = 10.0f; *************** *** 565,569 **** wxASSERT(parent); ! if ((mnMode == SSMODE_SURVEILLANCE) || (mnMode == SSMODE_FCSURVEILLANCE)) { UpdateSurveillance(t); --- 572,576 ---- wxASSERT(parent); ! if (mnMode == SSMODE_SURVEILLANCE) { UpdateSurveillance(t); *************** *** 592,596 **** wxASSERT(dbObj); ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; --- 599,611 ---- wxASSERT(dbObj); ! if (dbObj->isSurveillance) ! { ! mnMode = SSMODE_SURVEILLANCE; ! } ! else ! { ! mnMode = SSMODE_FC; // do not do surveillance updates ! } ! mfSensorHeight_m = 10.0f; Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcLauncher.cpp 18 Feb 2005 17:41:51 -0000 1.11 --- tcLauncher.cpp 2 Mar 2005 22:28:44 -0000 1.12 *************** *** 285,289 **** // TODO: called here as quick way to add autopoint feature, move to better location ! if (IsAutoPoint()) { pointingAngle = parent->BearingToRad(*targetObj) - parent->mcKin.mfHeading_rad; --- 285,289 ---- // TODO: called here as quick way to add autopoint feature, move to better location ! if (IsAutoPoint() && (targetObj != 0)) { pointingAngle = parent->BearingToRad(*targetObj) - parent->mcKin.mfHeading_rad; Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcSensorMap.cpp 2 Dec 2004 04:17:27 -0000 1.14 --- tcSensorMap.cpp 2 Mar 2005 22:28:45 -0000 1.15 *************** *** 40,43 **** --- 40,57 ---- tcSimState* tcSensorMapTrack::simState = NULL; unsigned int tcSensorMapTrack::ambiguityListUpdates = 0; + bool tcSensorMapTrack::autoKillAssess = false; + + + /** + * Set to true to automatically check and mark stale tracks that + * are destroyed. + */ + void tcSensorMapTrack::SetAutoKillAssess(bool state) + { + autoKillAssess = state; + } + + + /** *************** *** 71,75 **** /* - double mfLastUpdateTime; tcSensorReport maSensorReport[MAX_SENSOR_REPORTS]; // most recent data from contributing sensors int mnContributors; --- 85,88 ---- *************** *** 127,137 **** } - mfLastUpdateTime = 0; mnContributors = 0; mnEmitters = 0; mnDatabaseID = -1; ! matchupRating = 0; ! expectedDamage = 0; ! assessedDamage = 0; intercepts.clear(); engaged.clear(); --- 140,147 ---- } mnContributors = 0; mnEmitters = 0; mnDatabaseID = -1; ! assessedDamage = 0; intercepts.clear(); engaged.clear(); *************** *** 232,236 **** ! bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) { int nPassiveIdx = -1; --- 242,247 ---- ! bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) ! { int nPassiveIdx = -1; *************** *** 251,255 **** // add new report if there is room ! if (mnContributors < MAX_SENSOR_REPORTS) { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); --- 262,267 ---- // add new report if there is room ! if (mnContributors < MAX_SENSOR_REPORTS) ! { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); *************** *** 260,264 **** // overwrite passive with active if one exists ! if (nPassiveIdx >= 0) { tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; pSensorReport->Clear(); --- 272,277 ---- // overwrite passive with active if one exists ! if (nPassiveIdx >= 0) ! { tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; pSensorReport->Clear(); *************** *** 402,410 **** /** * check for update reports and update track */ void tcSensorMapTrack::UpdateTrack() { ! //bool bUpdated = false; // find first new active report since last update and update track --- 415,449 ---- /** + * Queries simState to check if track object exists. If + * not the track is marked as destroyed. + * This assumes that the track id matches the simState object + * id. This assumption will be invalid someday once the two + * sets of ids are decoupled. + * TODO repair for this + */ + void tcSensorMapTrack::KillAssess() + { + if (simState->GetObject(mnID) == 0) + { + MarkDestroyed(); + #ifdef _DEBUG + fprintf(stdout, "Track %d marked destroyed\n", mnID); + #endif + } + } + + /** * check for update reports and update track */ void tcSensorMapTrack::UpdateTrack() { ! ! if (autoKillAssess) ! { ! if (IsStale() && !IsDestroyed()) ! { ! KillAssess(); ! } ! } // find first new active report since last update and update track *************** *** 482,485 **** --- 521,551 ---- } + bool tcSensorMapTrack::IsDestroyed() const + { + return (sensorFlags & TRACK_DESTROYED) != 0; + } + + bool tcSensorMapTrack::IsStale() const + { + return (sensorFlags & TRACK_STALE) != 0; + } + + void tcSensorMapTrack::MarkDestroyed() + { + sensorFlags |= TRACK_DESTROYED; + } + + void tcSensorMapTrack::MarkStale() + { + sensorFlags |= TRACK_STALE; + } + + void tcSensorMapTrack::ClearStale() + { + sensorFlags &= (~TRACK_STALE); + } + + + tcSensorMapTrack& tcSensorMapTrack::operator= (const tcSensorMapTrack& t) *************** *** 487,491 **** *(tcTrack*)this = t ; - mfLastUpdateTime = t.mfLastUpdateTime; for(int i=0;i<MAX_SENSOR_REPORTS;i++) { --- 553,556 ---- *************** *** 501,514 **** mnEmitters = t.mnEmitters; mnDatabaseID = t.mnDatabaseID; ! matchupRating = t.matchupRating; ! expectedDamage = t.expectedDamage; ! assessedDamage = t.assessedDamage; intercepts = t.intercepts; engaged = t.engaged; return(*this); } ! tcSensorMapTrack::tcSensorMapTrack() { tcTrack::mnID = NULL_INDEX; --- 566,583 ---- mnEmitters = t.mnEmitters; mnDatabaseID = t.mnDatabaseID; ! sensorFlags = t.sensorFlags; intercepts = t.intercepts; engaged = t.engaged; + assessedDamage = t.assessedDamage; return(*this); } ! tcSensorMapTrack::tcSensorMapTrack() ! : sensorFlags(0), ! mnEmitters(0), ! mnContributors(0), ! mnDatabaseID(-1), ! assessedDamage(0) { tcTrack::mnID = NULL_INDEX; *************** *** 518,529 **** tcTrack::mfTimestamp = 0; tcTrack::mnFlags = 0; - mnEmitters = 0; - mnContributors = 0; - mfLastUpdateTime = 0; - - mnDatabaseID = -1; - matchupRating = 0; - expectedDamage = 0; - assessedDamage = 0; } --- 587,590 ---- *************** *** 770,786 **** for(int n=0;(n<psmtrack->mnContributors)&&(!bAgedReport);n++) { ! float ageOutTime = SENSORMAP_AGEOUTTIME; ! if (psmtrack->maSensorReport[n].mnFlags & TRACK_BEARING_ONLY) ! { ! ageOutTime *= 3; ! } ! ! if (afStatusTime - psmtrack->maSensorReport[n].mfTimestamp > ageOutTime) { psmtrack->RemoveReport(n); bAgedReport = true; } } ! if (psmtrack->mnContributors <= 0) { if (psmtrack->mnID >= 0) --- 831,860 ---- for(int n=0;(n<psmtrack->mnContributors)&&(!bAgedReport);n++) { ! double timeSinceUpdate = afStatusTime - psmtrack->maSensorReport[n].mfTimestamp; ! if (timeSinceUpdate >= ageOutTime) { psmtrack->RemoveReport(n); bAgedReport = true; } + else if (timeSinceUpdate >= staleTime) + { + psmtrack->MarkStale(); + if (psmtrack->IsDestroyed() && (timeSinceUpdate >= staleTime + 3.0)) + { + psmtrack->RemoveReport(n); + bAgedReport = true; + } + } + else + { + psmtrack->ClearStale(); + } } ! ! // updated to never drop ground tracks ! bool dropTrack = ((psmtrack->mnContributors <= 0) && (!psmtrack->IsGround())); ! ! ! if (dropTrack) { if (psmtrack->mnID >= 0) *************** *** 898,907 **** tcAllianceSensorMap::tcAllianceSensorMap(unsigned int mapAlliance) ! : alliance(mapAlliance) { Clear(); } ! tcAllianceSensorMap::~tcAllianceSensorMap() { } --- 972,988 ---- tcAllianceSensorMap::tcAllianceSensorMap(unsigned int mapAlliance) ! : alliance(mapAlliance), ! ageOutTime(90.0f), ! staleTime(30.0f) { Clear(); + + bool autoKillAssessment = tcOptions::Get()->OptionStringExists("AutoKillAssessment"); + tcSensorMapTrack::SetAutoKillAssess(autoKillAssessment); + } ! tcAllianceSensorMap::~tcAllianceSensorMap() ! { } *************** *** 982,992 **** ! void tcSensorMap::Clear(void) { int n; ! for(n=0;n<MAX_ALLIANCES;n++) { maMapIdxForAlliance[n] = -1; } ! for(n=0;n<mnMaps;n++) { ! if (mapMap[n] != NULL) { delete mapMap[n]; mapMap[n] = NULL; --- 1063,1077 ---- ! void tcSensorMap::Clear() ! { int n; ! for(n=0;n<MAX_ALLIANCES;n++) ! { maMapIdxForAlliance[n] = -1; } ! for(n=0;n<mnMaps;n++) ! { ! if (mapMap[n] != NULL) ! { delete mapMap[n]; mapMap[n] = NULL; Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tcObjectControl.cpp 20 Feb 2005 18:20:20 -0000 1.31 --- tcObjectControl.cpp 2 Mar 2005 22:28:45 -0000 1.32 *************** *** 133,137 **** : brain(0), ! mzCaption("ORDERS STATUS") { } --- 133,137 ---- : brain(0), ! mzCaption("TASK STATUS") { } |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:26
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/database Modified Files: tcGenericDBObject.cpp tcSensorDBObject.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSensorDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcSensorDBObject.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcSensorDBObject.cpp 29 Nov 2004 03:55:05 -0000 1.10 --- tcSensorDBObject.cpp 2 Mar 2005 22:28:42 -0000 1.11 *************** *** 97,100 **** --- 97,103 ---- *csv >> mfFieldOfView_deg; *csv >> mfScanPeriod_s; + long temp; + *csv >> temp; + isSurveillance = (temp != 0); } else *************** *** 104,107 **** --- 107,111 ---- *csv << mfFieldOfView_deg; *csv << mfScanPeriod_s; + *csv << (long)isSurveillance; // csv->WriteLine(); // do not writeline since this isn't a leaf class } *************** *** 124,127 **** --- 128,132 ---- localNode->SetAttribute("fieldOfView_deg", mfFieldOfView_deg); localNode->SetAttribute("scanPeriod_s", mfScanPeriod_s); + localNode->SetAttribute("IsSurveillance", isSurveillance); tcDatabaseObject::SerializeXml(node, load); *************** *** 136,139 **** --- 141,145 ---- *csv << "FieldOfView_deg"; *csv << "ScanPeriod_s"; + *csv << "IsSurveillance"; return 1; } *************** *** 152,156 **** columnString += "RefRange_km number(6),"; columnString += "FieldOfView_deg number(3),"; ! columnString += "ScanPeriod_s number(5)"; } --- 158,163 ---- columnString += "RefRange_km number(6),"; columnString += "FieldOfView_deg number(3),"; ! columnString += "ScanPeriod_s number(5),"; ! columnString += "IsSurveillance number(1)"; } *************** *** 163,166 **** --- 170,174 ---- mfFieldOfView_deg = entry.GetDouble("FieldOfView_deg"); mfScanPeriod_s = entry.GetDouble("ScanPeriod_s"); + isSurveillance = entry.GetInt("IsSurveillance") != 0; } *************** *** 176,180 **** s << mfRefRange_km << ","; s << mfFieldOfView_deg << ","; ! s << mfScanPeriod_s; valueString += s.str(); --- 184,189 ---- s << mfRefRange_km << ","; s << mfFieldOfView_deg << ","; ! s << mfScanPeriod_s << ","; ! s << isSurveillance; valueString += s.str(); *************** *** 191,194 **** --- 200,204 ---- mfFieldOfView_deg = 360.0f; mfScanPeriod_s = 4.0f; + isSurveillance = true; } *************** *** 202,205 **** --- 212,216 ---- mfFieldOfView_deg = obj.mfFieldOfView_deg; mfScanPeriod_s = obj.mfScanPeriod_s; + isSurveillance = obj.isSurveillance; } Index: tcGenericDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcGenericDBObject.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** tcGenericDBObject.cpp 31 Jan 2005 01:33:07 -0000 1.19 --- tcGenericDBObject.cpp 2 Mar 2005 22:28:42 -0000 1.20 *************** *** 619,643 **** columnString += s.GetBuffer(); ! s.Format("S%d_az number(8),",i+1); ! columnString += s.GetBuffer(); ! } ! ! for(i=0;i<MAXANIMATIONS;i++) ! { ! tcString s; ! s.Format("Anim%d_obj varchar(30),",i+1); columnString += s.GetBuffer(); ! s.Format("Anim%d_type varchar(30),",i+1); ! columnString += s.GetBuffer(); - s.Format("Anim%d_param number(3)",i+1); - columnString += s.GetBuffer(); - if (i < MAXANIMATIONS - 1) columnString += ","; - } - - - } --- 619,629 ---- columnString += s.GetBuffer(); ! s.Format("S%d_az number(8)",i+1); columnString += s.GetBuffer(); ! if (i < MAXSENSORS - 1) columnString += ","; ! } } |
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:26
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/scripts Modified Files: AI.py Menu.py UnitCommands.py Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AI.py 18 Feb 2005 17:42:08 -0000 1.17 --- AI.py 2 Mar 2005 22:28:41 -0000 1.18 *************** *** 111,114 **** --- 111,199 ---- UI.SetActionText('Patrol') + def GetMessageParam(BB, messageName): + msg = BB.ReadMessage(messageName) + if (msg == ''): + return 0 + else: + return float(msg) + + # patrol task, roughly circles same point, stays within 10 km of station + def PatrolCircle(TI): + UI = TI.GetPlatformInterface() + BB = TI.GetBlackboardInterface() + + iteration = TI.GetMemoryValue(1) # will return 0 first time + if (iteration == 0): # do initialization + TI.SetMemoryValue(2, UI.GetHeading()) + TI.SetMemoryValue(3, 0) # 1 is heading to station, 0 patroling + TI.SetMemoryValue(4, 30.0 + 15.0 * UI.Rand()) # random turn interval in seconds + TI.SetMemoryText('Description', 'Perform surveillance along a zig-zag course') + + station_lon = GetMessageParam(BB, 'StationLongitude') + station_lat = GetMessageParam(BB, 'StationLatitude') + station_alt = GetMessageParam(BB, 'StationAltitude') + station_speed = GetMessageParam(BB, 'StationSpeed') # in kts + TI.SetMemoryValue(10, station_lon) + TI.SetMemoryValue(11, station_lat) + TI.SetMemoryValue(12, station_alt) + TI.SetMemoryValue(13, station_speed) + + + iteration = iteration + 1 + TI.SetMemoryValue(1, iteration) + + # activate all sensors + can_radiate = GetSensorControl(BB) + if (can_radiate): + ActivateAllSensors(UI) + else: + ActivatePassiveSensors(UI) + + # return if conn is not available + if (not GetConnControl(BB)): + return + + station_lon = TI.GetMemoryValue(10) + station_lat = TI.GetMemoryValue(11) + station_alt = TI.GetMemoryValue(12) + station_speed = TI.GetMemoryValue(13) + + if (UI.IsAir()): + if (station_alt > 0): + UI.SetAlt(station_alt) + + if (station_speed > 0): + UI.SetSpeed(station_speed) + + if ((station_lon != 0) or (station_lat != 0)): + station_range = UI.GetRangeToDatum(station_lon, station_lat) + else: + station_range = 0 # effectively ignore station range if missing station info + + isTravelingToStation = TI.GetMemoryValue(3) + if (isTravelingToStation): + range_thresh = 1.0 + UI.SetSpeedToMax() + else: + range_thresh = 10.0 + + if (UI.IsAir()): + range_thresh = range_thresh * 4.0 + + if (station_range > range_thresh): + new_heading = UI.GetHeadingToDatum(station_lon, station_lat) + TI.SetMemoryValue(3, 1) # to indicate traveling to station + UI.SetActionText('-> Station') + TI.SetUpdateInterval(10.0) + else: + new_heading = UI.GetHeading() + 30 + TI.SetMemoryValue(3, 0) # to indicate traveling to station + UI.SetActionText('Patrol-Circ') + TI.SetUpdateInterval(TI.GetMemoryValue(4)) + + UI.SetHeading(new_heading) + + + # shoot hostiles and unknowns within range, but do not intercept. *************** *** 182,187 **** ! # returns id of closest target that is in-range, engageable, and not already ! # overwhelmingly engaged # returns -1 if none def GetImmediateTarget(UI): --- 267,272 ---- ! # returns id of closest target that is in-range, engageable, not already ! # overwhelmingly engaged, and not a stale track # returns -1 if none def GetImmediateTarget(UI): *************** *** 198,210 **** track_list = UI.GetTrackList(0x0FFF, 150, 3) nTracks = track_list.Size() best_range = 1e6 best_target = -1 best_launcher = -1 ! for n in range(0, nTracks): track_info = track_list.GetTrack(n) track_id = track_info.ID ! engaged_count = track_info.GetEngagedCount() if (track_info.IsAir() or track_info.IsMissile()): --- 283,296 ---- track_list = UI.GetTrackList(0x0FFF, 150, 3) + current_time = UI.GetTime() nTracks = track_list.Size() best_range = 1e6 best_target = -1 best_launcher = -1 ! for n in range(0, nTracks): track_info = track_list.GetTrack(n) track_id = track_info.ID ! staleness = track_info.Time - current_time engaged_count = track_info.GetEngagedCount() if (track_info.IsAir() or track_info.IsMissile()): *************** *** 213,217 **** max_engaged_count = 6 ! if (engaged_count < max_engaged_count): UI.SetTarget(track_id) launcher_info = UI.GetBestLauncher() --- 299,303 ---- max_engaged_count = 6 ! if ((engaged_count < max_engaged_count) and (staleness < 15.0)): UI.SetTarget(track_id) launcher_info = UI.GetBestLauncher() *************** *** 409,417 **** return 0 ! # modified this to adjust altitude based on altitude of landing ! # site ! def Land(UI,dest_id): ! # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! land_state = UI.GetVar(0) track_info = UI.GetTrackById(dest_id) --- 495,520 ---- return 0 ! # for non-helo aircraft ! def Land(TI): ! UI = TI.GetPlatformInterface() ! BB = TI.GetBlackboardInterface() ! ! if (not GetConnControl(BB)): ! return ! ! iteration = TI.GetMemoryValue(1) # will return 0 first time ! if (iteration == 0): # do initialization ! TI.SetMemoryText('Description', 'Land at designated airbase') ! TI.SetMemoryValue(2, 0) # 0 - init, 1 - distant, 2 - init approach, 3 - final approach ! dest_name = BB.ReadMessage('LandingTarget') ! dest_id = UI.LookupFriendlyId(dest_name) ! TI.SetMemoryValue(3, dest_id) ! ! iteration = iteration + 1 ! TI.SetMemoryValue(1, iteration) ! ! ! land_state = TI.GetMemoryValue(2) ! dest_id = long(TI.GetMemoryValue(3)) track_info = UI.GetTrackById(dest_id) *************** *** 419,423 **** if (track_info.ID == -1): UI.DisplayMessage('Bad track ID for landing') ! UI.CompletedOrder() return # invalid id --- 522,526 ---- if (track_info.ID == -1): UI.DisplayMessage('Bad track ID for landing') ! TI.EndTask() return # invalid id *************** *** 425,429 **** if (landing_data.ID == -1): UI.DisplayMessage('Invalid landing platform') ! UI.CompletedOrder() return # invalid id --- 528,532 ---- if (landing_data.ID == -1): UI.DisplayMessage('Invalid landing platform') ! TI.EndTask() return # invalid id *************** *** 437,441 **** UI.DisplayMessage('Landing on platform %d' % track_info.ID) UI.SetAlt(1200 + alt_m) ! UI.SetVar(0,1) track_info.Offset(8, landing_data.Heading_rad + 3.1416) # approach from rear for now elif (land_state == 2): --- 540,544 ---- UI.DisplayMessage('Landing on platform %d' % track_info.ID) UI.SetAlt(1200 + alt_m) ! TI.SetMemoryValue(2, 1) track_info.Offset(8, landing_data.Heading_rad + 3.1416) # approach from rear for now elif (land_state == 2): *************** *** 453,462 **** if (TTI <= 4): ! UI.SetVar(0,land_state+1) # move to next landing state ! UI.SetUpdate(4) elif (TTI <= 20): ! UI.SetUpdate(3) else: ! UI.SetUpdate(10) --- 556,565 ---- if (TTI <= 4): ! TI.SetMemoryValue(2, land_state+1) # move to next landing state ! TI.SetUpdateInterval(4) elif (TTI <= 20): ! TI.SetUpdateInterval(3) else: ! TI.SetUpdateInterval(10) Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** UnitCommands.py 11 Dec 2004 01:09:06 -0000 1.13 --- UnitCommands.py 2 Mar 2005 22:28:41 -0000 1.14 *************** *** 1,2 **** --- 1,6 ---- + + def AddEngageAllOrder(UI): + UI.AddTask('EngageAll', 2.0) + def AddWaypointOrderGroup(GI, lon, lat): unit_count = GI.GetUnitCount() *************** *** 6,10 **** def AddWaypointOrder(UI, lon, lat): ! UI.AddNavOrder(lon,lat) --- 10,14 ---- def AddWaypointOrder(UI, lon, lat): ! UI.AddNavWaypoint(lon, lat) *************** *** 16,51 **** def AddPatrolOrder(UI): ! UI.AddOrder('Patrol',0) def AddLandingOrder(UI, dest_id): if (UI.IsHelo()): ! UI.AddOrder('LandHelo', dest_id) else: ! UI.AddOrder('Land', dest_id) ! def ClearOrdersGroup(GI): unit_count = GI.GetUnitCount() for n in range(0, unit_count): UnitInfo = GI.GetPlatformInterface(n) ! ClearOrders(UnitInfo) - def ClearOrders(UI): - UI.ClearOrders() - def EraseLastOrder(UI): - n_orders = UI.GetOrderCount() - if (n_orders > 0): - UI.DeleteOrder(n_orders-1) # clears all orders, moves to location and starts patrol def MoveToAndPatrol(UI, lon, lat): ! ClearOrders(UI) AddWaypointOrder(UI, lon, lat) - AddPatrolOrder(UI) ! def AddCrashOrder(UI): ! UI.AddOrder('Crash',0) def LaunchDatum(UI, lon, lat, launcher_num): --- 20,67 ---- def AddPatrolOrder(UI): ! UI.AddTask('Patrol', 1.0) ! ! def AddPatrolStation(UI, lon, lat): ! UI.AddTask('PatrolCircle', 1.0) ! BB = UI.GetBlackboardInterface() ! BB.Write('StationLongitude', '%f' % lon) ! BB.Write('StationLatitude', '%f' % lat) ! BB.Write('StationAltitude', '%f' % UI.GetAlt()) def AddLandingOrder(UI, dest_id): if (UI.IsHelo()): ! UI.AddTask('LandHelo', 3.0) else: ! UI.AddTask('Land', 3.0) ! ! dest_name = UI.LookupFriendlyName(dest_id) ! BB = UI.GetBlackboardInterface() ! BB.Write('LandingTarget', dest_name) ! def ClearTasksGroup(GI): unit_count = GI.GetUnitCount() for n in range(0, unit_count): UnitInfo = GI.GetPlatformInterface(n) ! ClearTasks(UnitInfo) ! ! def ClearTasks(UI): ! UI.ClearTasks() ! ! def ClearWaypoints(UI): ! UI.DeleteTask('Nav') # clears all orders, moves to location and starts patrol def MoveToAndPatrol(UI, lon, lat): ! ClearTasks(UI) ! UI.AddTask('Patrol', 1.0) ! UI.AddTask('Nav', 2.0) ! UI.AddTask('EngageAll', 3.0) AddWaypointOrder(UI, lon, lat) ! def LaunchDatum(UI, lon, lat, launcher_num): *************** *** 241,249 **** for n in range(0, n_sensors): sens_info = UI.GetSensorInfo(n) ! if (sens_info.type == 0): # 0 is radar, 1 is ESM, 255 is error if (sens_info.isActive): UI.SetSensorState(n, 0) else: UI.SetSensorState(n, 1) ! UI.PlaySound(11) --- 257,267 ---- for n in range(0, n_sensors): sens_info = UI.GetSensorInfo(n) ! ! # 1 radar, 2 ESM, 4 passive sonar, 8 active sonar, 16 optical, 0 error ! if (sens_info.type == 1): if (sens_info.isActive): UI.SetSensorState(n, 0) else: UI.SetSensorState(n, 1) ! UI.PlaySound('Ping') Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Menu.py 5 Dec 2004 02:49:46 -0000 1.10 --- Menu.py 2 Mar 2005 22:28:41 -0000 1.11 *************** *** 46,54 **** # Group orders ! GroupMenu.AddItem('Orders','') GroupMenu.BeginSubMenu() ! GroupMenu.AddItem('Add patrol order','AddPatrolOrderGroup') ! GroupMenu.AddItemUI('Add waypoint order', 'AddWaypointOrderGroup', 'Datum') ! GroupMenu.AddItem('Clear orders','ClearOrdersGroup') GroupMenu.EndSubMenu() --- 46,54 ---- # Group orders ! GroupMenu.AddItem('Tasks','') GroupMenu.BeginSubMenu() ! GroupMenu.AddItem('Zig-zag patrol','AddPatrolOrderGroup') ! GroupMenu.AddItemUI('Add waypoint', 'AddWaypointOrderGroup', 'Datum') ! GroupMenu.AddItem('Clear all tasks','ClearTasksGroup') GroupMenu.EndSubMenu() *************** *** 80,88 **** # Orders test ! UnitMenu.AddItem('Orders','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItem('Add patrol order','AddPatrolOrder') ! UnitMenu.AddItemUI('Add waypoint order', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItem('Clear orders','ClearOrders') UnitMenu.EndSubMenu() --- 80,91 ---- # Orders test ! UnitMenu.AddItem('Tasks','') UnitMenu.BeginSubMenu() ! UnitMenu.AddItem('ZigZag patrol','AddPatrolOrder') ! UnitMenu.AddItemUI('Patrol station','AddPatrolStation', 'Datum') ! UnitMenu.AddItemUI('Add waypoint', 'AddWaypointOrder', 'Datum') ! UnitMenu.AddItem('EngageAll', 'AddEngageAllOrder') ! UnitMenu.AddItem('Clear waypoints','ClearWaypoints') ! UnitMenu.AddItem('Clear all tasks','ClearTasks') UnitMenu.EndSubMenu() |