[Gcblue-commits] gcb_wx/src/sim tcWeaponObject.cpp,NONE,1.1 Game.cpp,1.58,1.59 tcGameObject.cpp,1.9,
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8158/src/sim Modified Files: Game.cpp tcGameObject.cpp tcHookInfo.cpp tcMissileObject.cpp tcPlatformObject.cpp tcSensorMap.cpp tcSimState.cpp Added Files: tcWeaponObject.cpp Log Message: --- NEW FILE: tcWeaponObject.cpp --- /** @file tcWeaponObject.cpp */ /* * Copyright (C) 2003 Dewitt "Cole" Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "tcWeaponObject.h" #include "tcGameObject.h" #include "tcDatabaseObject.h" #include "tcSensorMap.h" #include "tcSimState.h" bool tcWeaponObject::IsIntendedTarget(long id) { if (id == -1) return false; return intendedTarget == id; } void tcWeaponObject::SetIntendedTarget(long targetId) { using namespace Sensor; intendedTarget = targetId; if (targetId == -1) return; tcSensorMapTrack *smtrack = simState->mcSensorMap.GetSensorMapTrack(targetId, tcGameObject::mnAlliance); if (smtrack == NULL) { std::cerr << "tcWeaponObject::SetIntendedTarget - targetId not found in sensor map" << std::endl; return; } smtrack->AddEngagement(tcGameObject::mnID); } /** * */ tcWeaponObject::tcWeaponObject() { intendedTarget = -1; } /** * Copy constructor. */ tcWeaponObject::tcWeaponObject(tcWeaponObject& o) { wxASSERT(false); // not supported } /** * Constructor that initializes using info from database entry. */ tcWeaponObject::tcWeaponObject(tcDatabaseObject *obj) : tcGameObject(obj) { wxASSERT(simState); intendedTarget = -1; } /** * */ tcWeaponObject::~tcWeaponObject() { } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** Game.cpp 13 Feb 2004 01:31:33 -0000 1.58 --- Game.cpp 15 Feb 2004 19:47:23 -0000 1.59 *************** *** 1194,1200 **** if (!bResult) { ! wxMessageBox("Error - high performance counter"); ! return true; ! } nLastCount = nPerformanceCount.QuadPart; --- 1194,1200 ---- if (!bResult) { ! wxMessageBox("Error - high performance counter"); ! return true; ! } nLastCount = nPerformanceCount.QuadPart; *************** *** 1202,1211 **** fdt = (1.0f/30.0f); ! snStartCount = nPerformanceCount; if (mcOptions.debugLevel > 0) ! { ! wxMessageBox("UpdateFrame(game mode) init2\n"); ! } } --- 1202,1211 ---- fdt = (1.0f/30.0f); ! snStartCount = nPerformanceCount; if (mcOptions.debugLevel > 0) ! { ! wxMessageBox("UpdateFrame(game mode) init2\n"); ! } } *************** *** 1224,1228 **** gameTime = mcSimState.GetTime(); mcSimState.GetDateZulu(gameDateZulu); ! if (!mbPaused) { gameTime += fdt; --- 1224,1228 ---- gameTime = mcSimState.GetTime(); mcSimState.GetDateZulu(gameDateZulu); ! if (!mbPaused) { gameTime += fdt; *************** *** 1260,1264 **** viewer->SetGameTime(gameTime); ! if (mbScenarioEdit) { tacticalMap->mnGameMode = GAMEMODE_EDIT; --- 1260,1264 ---- viewer->SetGameTime(gameTime); ! if (mbScenarioEdit) { tacticalMap->mnGameMode = GAMEMODE_EDIT; *************** *** 1276,1279 **** --- 1276,1280 ---- } + if (mbSaveScenario) { Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcGameObject.cpp 10 Jan 2004 21:55:31 -0000 1.9 --- tcGameObject.cpp 15 Feb 2004 19:47:23 -0000 1.10 *************** *** 28,34 **** --- 28,36 ---- #include "tcDatabase.h" #include "tc3DModel.h" + #include "tcSimState.h" tcMapData* tcGameObject::mapData = NULL; Database::tcDatabase* tcGameObject::database = NULL; + tcSimState* tcGameObject::simState = NULL; /** *************** *** 303,307 **** /** ! * initializes using database object. Database must be set * before using this method. * @see SetGameObjectDatabase --- 305,309 ---- /** ! * initializes using database object. database and simState must be set * before using this method. * @see SetGameObjectDatabase *************** *** 310,313 **** --- 312,316 ---- { wxASSERT(database); + wxASSERT(simState); wxASSERT(obj); Index: tcHookInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcHookInfo.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcHookInfo.cpp 8 Dec 2003 03:06:36 -0000 1.7 --- tcHookInfo.cpp 15 Feb 2004 19:47:23 -0000 1.8 *************** *** 24,27 **** --- 24,29 ---- #endif + #include <wx/string.h> + #include "tcHookInfo.h" #include "aerror.h" *************** *** 40,44 **** } ! void tcHookInfo::DrawTrack(Graphics *apGraphics, tnPoolIndex anID) { tcSensorMapTrack *pSMTrack; --- 42,50 ---- } ! /** ! * Draw hook info display when track is hooked (vs. own-alliance platform) ! */ ! // This method needs to be broken up ! void tcHookInfo::DrawTrack(Gdiplus::Graphics *apGraphics, tnPoolIndex anID) { tcSensorMapTrack *pSMTrack; *************** *** 125,131 **** } } ! void tcHookInfo::DrawOwn(Graphics *apGraphics, tcGameObject *pHookedObj) { std::string s; --- 131,228 ---- } + //*********** draw engagement info ************** + DrawTrackEngaged(apGraphics, pSMTrack, ftextx, ftexty); + } ! /** ! * Draws list of weapons that have engaged track. ! * For drawEngageMode = 0 draws a list of IDs, ! * for drawEngageMode = 1 draws class name and quantity ! * x and y are start coordinates of drawing text. ! * x and y are modified by this method so that other ! * drawing methods can draw underneath. ! */ ! void tcHookInfo::DrawTrackEngaged(Gdiplus::Graphics *graphics, ! const Sensor::tcSensorMapTrack *smtrack, float& x, float& y) ! { ! char zBuff[128]; ! SizeF textSize; ! ! int nEngaged = (int)smtrack->GetEngagedCount(); ! if (nEngaged) ! { ! ! DrawText(graphics,mpFont,mpBrush,"Engaged with: ",x,y); ! MeasureText(graphics, mpFont, "Engaged with: ", textSize); ! } ! ! if (drawEngagedMode == 0) ! { ! x += textSize.Width + 3.0f; ! for (int nE=0;nE<nEngaged;nE++) ! { ! sprintf(zBuff,"%d ",smtrack->engaged[nE]); ! DrawText(graphics,mpFont,mpBrush,zBuff,x,y); ! MeasureText(graphics, mpFont, zBuff, textSize); ! x += textSize.Width + 2.0f; ! if (x > (float) mnWidth - 10.0f) ! { ! x = 20.0f; ! y += 15; ! } ! } ! y+=15; ! return; ! } ! ! std::vector<long> classID; ! std::vector<unsigned> quantity; ! wxArrayString className; ! ! for (int nE=0;nE<nEngaged;nE++) ! { ! long id; ! wxString name; ! ! if (tcGameObject *obj = mpSS->GetObject(smtrack->engaged[nE])) ! { ! id = obj->mnDBKey; ! name = obj->mpDBObject->mzClass.mz; ! } ! else ! { ! id = -1; ! name = "Error"; ! } ! bool matches = false; ! for(unsigned k=0;(k<classID.size())&&(!matches);k++) ! { ! if (classID[k] == id) ! { ! matches = true; ! quantity[k]++; ! } ! } ! if (!matches) ! { ! classID.push_back(id); ! quantity.push_back(1); ! className.Add(name); ! } ! } ! ! y += 15; ! for (unsigned k=0;k<classID.size();k++) ! { ! sprintf(zBuff," %s (%d)", className[k].c_str(), quantity[k]); ! DrawText(graphics, mpFont, mpBrush, zBuff, x, y); ! MeasureText(graphics, mpFont, zBuff, textSize); ! y += textSize.Height + 2.0f; ! } ! ! } ! ! void tcHookInfo::DrawOwn(Gdiplus::Graphics *apGraphics, tcGameObject *pHookedObj) { std::string s; *************** *** 404,407 **** --- 501,505 ---- mpOptions = NULL; mpUserInfo = NULL; + drawEngagedMode = 1; mpPen = new Pen(Color(0xFEFFFFFF),2); Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcMissileObject.cpp 13 Feb 2004 01:31:33 -0000 1.7 --- tcMissileObject.cpp 15 Feb 2004 19:47:23 -0000 1.8 *************** *** 142,145 **** --- 142,150 ---- mcSensorState.mfCurrentScanPeriod_s = 0.2f; } + else if (tti_s <= 2.0f) + { + mfGuidanceUpdateInterval = 0.1f; + mcSensorState.mfCurrentScanPeriod_s = 0.1f; + } *************** *** 358,361 **** --- 363,367 ---- */ tcMissileObject::tcMissileObject() + : tcWeaponObject() { Clear(); *************** *** 375,378 **** --- 381,385 ---- */ tcMissileObject::tcMissileObject(tcMissileObject& o) + : tcWeaponObject(o) { mnModelType = MTYPE_MISSILE; *************** *** 394,398 **** */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcGameObject(obj) { mpDBObject = obj; --- 401,405 ---- */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcWeaponObject(obj) { mpDBObject = obj; Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcPlatformObject.cpp 13 Feb 2004 01:31:33 -0000 1.17 --- tcPlatformObject.cpp 15 Feb 2004 19:47:23 -0000 1.18 *************** *** 259,262 **** --- 259,273 ---- return false; } + + /** + * @return true if platform is intercepting (has targeted) track with id + */ + bool tcPlatformObject::IsInterceptingTrack(long id) + { + wxASSERT(id >= 0); + + return mcAI.GetTarget() == id; + } + /******************************************************************************/ // consider only active radars Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcSensorMap.cpp 13 Feb 2004 01:31:33 -0000 1.5 --- tcSensorMap.cpp 15 Feb 2004 19:47:23 -0000 1.6 *************** *** 25,28 **** --- 25,30 ---- #include "aerror.h" #include "simmath.h" + #include "tcSimState.h" + #include "tcWeaponObject.h" using namespace Sensor; *************** *** 30,119 **** [...1348 lines suppressed...] ! return true; } tcSensorMap::tcSensorMap() { ! for(int n=0;n<MAX_MAPS;n++) { ! mapMap[n] = NULL; ! } ! mnMaps = 0; ! Clear(); } tcSensorMap::~tcSensorMap() { ! for(int n=0;n<MAX_MAPS;n++) { ! if (mapMap[n] != NULL) { ! delete mapMap[n]; ! } ! } } \ No newline at end of file Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** tcSimState.cpp 13 Feb 2004 01:31:33 -0000 1.33 --- tcSimState.cpp 15 Feb 2004 19:47:23 -0000 1.34 *************** *** 1209,1217 **** } // add heading and pitch initializers eventually, have to deal with launcher angle pnew = static_cast<tcGameObject*>(pMissileObj); - - pnew->mfStatusTime = plaunchingplatform->mfStatusTime; pnew->mcKin = plaunchingplatform->mcKin; --- 1209,1216 ---- } + // add heading and pitch initializers eventually, have to deal with launcher angle pnew = static_cast<tcGameObject*>(pMissileObj); pnew->mfStatusTime = plaunchingplatform->mfStatusTime; pnew->mcKin = plaunchingplatform->mcKin; *************** *** 1223,1227 **** --- 1222,1231 ---- pnew->mzUnit = s.GetBuffer(); pnew->mnAlliance = plaunchingplatform->mnAlliance; + AddPlatform(pnew); + + // set intended target (has to be done after alliance and id is set) + pMissileObj->SetIntendedTarget(pLauncher->mnTargetID); + if (mpUserInfo->IsOwnAlliance(plaunchingplatform->mnAlliance)) { *************** *** 1796,1799 **** --- 1800,1805 ---- tcSensorState::AttachSimState(this); tcGameObjIterator::SetSimState(this); + tcGameObject::SetSimState(this); + tcSensorMapTrack::AttachSimState(this); mcSensorMap.CreateMapForAlliance(1); |