[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.142,1.143 tcAirfieldObject.cpp,1.5,1.6 tcCarrierObject.cp
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-12-10 16:52:12
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29922/src/sim Modified Files: Game.cpp tcAirfieldObject.cpp tcCarrierObject.cpp tcFlightOpsObject.cpp tcGameObjIterator.cpp tcGameObject.cpp tcSensorMap.cpp tcSimState.cpp Log Message: Start of save to python feature Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcSensorMap.cpp 10 Sep 2005 21:47:38 -0000 1.23 --- tcSensorMap.cpp 10 Dec 2005 16:52:03 -0000 1.24 *************** *** 449,452 **** --- 449,457 ---- } + bool tcSensorMap::MapExists(UINT8 alliance) const + { + return (maMapIdxForAlliance[alliance] != -1); + } + /** * Gets sensor map for alliance, creating if necessary Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** tcGameObject.cpp 27 Nov 2005 22:21:29 -0000 1.40 --- tcGameObject.cpp 10 Dec 2005 16:52:03 -0000 1.41 *************** *** 32,35 **** --- 32,36 ---- #include "tc3DModel.h" #include "tcSimState.h" + #include "tcScenarioLogger.h" #include "common/tcStream.h" #include "common/tcObjStream.h" *************** *** 714,717 **** --- 715,746 ---- } + void tcGameObject::SaveToPython(scriptinterface::tcScenarioLogger& logger) + { + wxString s; + + logger.AddScenarioText("unit = SM.GetDefaultUnit()"); + + s.Printf("unit.className = '%s'", mzClass.mz); + logger.AddScenarioText(s.c_str()); + + s.Printf("unit.unitName = '%s'", mzUnit.mz); + logger.AddScenarioText(s.c_str()); + + s.Printf("unit.SetPosition(%f, %f, %.1f)", C_180OVERPI*mcKin.mfLon_rad, + C_180OVERPI*mcKin.mfLat_rad, mcKin.mfAlt_m); + logger.AddScenarioText(s.c_str()); + + s.Printf("unit.heading = %.2f", C_180OVERPI*mcKin.mfHeading_rad); + logger.AddScenarioText(s.c_str()); + + s.Printf("unit.speed = %.1f", mcKin.mfSpeed_kts); + logger.AddScenarioText(s.c_str()); + + s.Printf("SM.AddUnitToAlliance(unit, %d)", GetAlliance()); + logger.AddScenarioText(s.c_str()); + + logger.AddScenarioText("UI = SM.GetUnitInterface(unit.unitName)"); + } + /** * Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** tcSimState.cpp 27 Nov 2005 22:21:29 -0000 1.90 --- tcSimState.cpp 10 Dec 2005 16:52:03 -0000 1.91 *************** *** 32,35 **** --- 32,36 ---- #include "tcFile.h" #include "tcSimPythonInterface.h" + #include "tcScenarioInterface.h" #include "osg/Group" #include "tcCommandQueue.h" *************** *** 64,67 **** --- 65,69 ---- #include "tcPositionRegistry.h" #include "network/tcMultiplayerInterface.h" + #include "tcScenarioLogger.h" #ifdef _DEBUG *************** *** 2568,2571 **** --- 2570,2635 ---- /** + * Saves game state to python scenario file + */ + void tcSimState::SaveToPython(const std::string& scenarioName) + { + tcScenarioLogger logger(scenarioName); + + wxString s; + + std::vector<unsigned> alliances; + + // add CreateAlliance commands for alliances that exist in sensor map + for (unsigned alliance = 1; alliance <= 255; alliance++) + { + if (mcSensorMap.MapExists(alliance)) + { + alliances.push_back(alliance); + + s.Printf("SM.CreateAlliance(%d, 'add alliance title here')", alliance); + logger.AddScenarioText(s.c_str()); + } + } + + // time and date, offset previous scenario with sim time + s.Printf("SM.SetDateTime(%d,%d,%d,%d,%d,%d)", dateZulu.getYear(), dateZulu.getMonth(), + dateZulu.getDay(), dateZulu.getHour(), dateZulu.getMinute(), dateZulu.getSecond()); + logger.AddScenarioText(s.c_str()); + + tcGeoRect theater; + mpMapData->GetTheaterArea(theater); + float lon_deg = C_180OVERPI * theater.XCenter(); + float lat_deg = C_180OVERPI * theater.YCenter(); + s.Printf("SM.SetStartTheater(%f, %f) # (lon, lat) in degrees, negative is West or South", + lon_deg, lat_deg); + logger.AddScenarioText(s.c_str()); + logger.AddScenarioText("SM.SetScenarioLoaded(1)\n"); + + + + // save all entities to file, grouped by alliance + for (size_t k=0; k<alliances.size(); k++) + { + tcGameObjIterator iter; + iter.SetAllianceFilter(alliances[k]); + + logger.AddScenarioText("##############################"); + s.Printf("### Alliance %d units", alliances[k]); + logger.AddScenarioText(s.c_str()); + logger.AddScenarioText("##############################\n"); + + for (iter.First();iter.NotDone();iter.Next()) + { + tcGameObject *obj = iter.Get(); + obj->SaveToPython(logger); + logger.AddScenarioText(""); + } + } + + + logger.WriteAll(); + } + + /** * Saves sim time and date zulu to stream */ Index: tcFlightOpsObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightOpsObject.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcFlightOpsObject.cpp 2 Jul 2005 16:51:12 -0000 1.12 --- tcFlightOpsObject.cpp 10 Dec 2005 16:52:03 -0000 1.13 *************** *** 2,7 **** ** @file tcFlightOpsObject.cpp */ ! /* ! ** Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcFlightOpsObject.cpp */ ! /* Copyright (C) 2004-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. *************** *** 32,35 **** --- 31,35 ---- #include "tcDatabase.h" #include "tcLauncher.h" + #include "tcScenarioLogger.h" #include "common/tcStream.h" #include "common/tcObjStream.h" *************** *** 369,372 **** --- 369,390 ---- + void tcFlightOpsObject::SaveToPython(scriptinterface::tcScenarioLogger& logger) + { + wxString s; + unsigned nChildren = flight_deck.GetCount(); + + for (unsigned short k=0; k < nChildren; k++) + { + tcAirState* airState = flight_deck.GetAirState(k); + tcGameObject* obj = airState->obj; + wxASSERT(obj); + + s.Printf("SM.AddUnitToFlightDeck('%s', '%s', '%s', %d)", gameObj->mzUnit.mz, + obj->mzClass.mz, obj->mzUnit.mz, airState->current_location); + logger.AddScenarioText(s.c_str()); + } + + } + /** * Set up default spots and capacities for carrier flightport. Index: tcGameObjIterator.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObjIterator.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcGameObjIterator.cpp 2 Nov 2004 04:23:56 -0000 1.5 --- tcGameObjIterator.cpp 10 Dec 2005 16:52:03 -0000 1.6 *************** *** 1,20 **** ! /** @file tcGameObjIterator.cpp */ ! /** ! * Copyright (C) 2003 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 */ --- 1,21 ---- ! /** ! ** @file tcGameObjIterator.cpp ! */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@gc...) ! ** 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 */ *************** *** 23,29 **** #ifndef WX_PRECOMP #include "wx/wx.h" - #ifdef WIN32 - #include "wx/msw/private.h" // for MS Windows specific definitions - #endif #endif --- 24,27 ---- *************** *** 96,99 **** --- 94,101 ---- } + void tcGameObjIterator::SetAllianceFilter(unsigned alliance) + { + allianceFilter = alliance; + } /** *************** *** 104,109 **** bool tcGameObjIterator::PassesFilter(const tcGameObject *obj) { - if (!useRegion) return true; if (obj == NULL) return false; return region.ContainsPoint(obj->mcKin.mfLon_rad, obj->mcKin.mfLat_rad); --- 106,113 ---- bool tcGameObjIterator::PassesFilter(const tcGameObject *obj) { if (obj == NULL) return false; + if ((allianceFilter != 0) && (obj->GetAlliance() != allianceFilter)) return false; + + if (!useRegion) return true; return region.ContainsPoint(obj->mcKin.mfLon_rad, obj->mcKin.mfLat_rad); *************** *** 112,115 **** --- 116,120 ---- tcGameObjIterator::tcGameObjIterator(const tcGeoRect& filterRegion) + : allianceFilter(0) { wxASSERT(simState); *************** *** 122,125 **** --- 127,131 ---- tcGameObjIterator::tcGameObjIterator() + : allianceFilter(0) { wxASSERT(simState); Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** Game.cpp 27 Nov 2005 22:21:29 -0000 1.142 --- Game.cpp 10 Dec 2005 16:52:03 -0000 1.143 *************** *** 2464,2467 **** --- 2464,2471 ---- messageCenter->ActivateChannel("Mission"); } + else if (cmd_info.meCmd == GC_SAVEGAME) + { + simState->SaveToPython("scenarios//Saved"); + } else { Index: tcCarrierObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcCarrierObject.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcCarrierObject.cpp 29 Apr 2005 18:52:55 -0000 1.11 --- tcCarrierObject.cpp 10 Dec 2005 16:52:03 -0000 1.12 *************** *** 1,4 **** ! /* ! ** Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcCarrierObject.cpp ! */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. *************** *** 17,20 **** --- 19,23 ---- ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "stdwx.h" *************** *** 30,33 **** --- 33,37 ---- #include "common/tcStream.h" #include "common/tcObjStream.h" + #include "tcScenarioLogger.h" #ifdef _DEBUG *************** *** 196,199 **** --- 200,210 ---- } + + void tcCarrierObject::SaveToPython(scriptinterface::tcScenarioLogger& logger) + { + tcGameObject::SaveToPython(logger); + tcFlightOpsObject::SaveToPython(logger); + } + /** * Index: tcAirfieldObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirfieldObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcAirfieldObject.cpp 11 Jun 2005 21:01:45 -0000 1.5 --- tcAirfieldObject.cpp 10 Dec 2005 16:52:03 -0000 1.6 *************** *** 1,6 **** ! /* @file tcAirfieldObject.cpp */ ! /* ! ** Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcAirfieldObject.cpp */ ! /* Copyright (C) 2004-2005 Dewitt Colclough (de...@gc...) ** All rights reserved. *************** *** 31,34 **** --- 31,35 ---- #include "common/tcStream.h" #include "common/tcObjStream.h" + #include "tcScenarioLogger.h" #ifdef _DEBUG *************** *** 194,197 **** --- 195,204 ---- } + void tcAirfieldObject::SaveToPython(scriptinterface::tcScenarioLogger& logger) + { + tcGameObject::SaveToPython(logger); + tcFlightOpsObject::SaveToPython(logger); + } + /** * Update method calls flightops update and updates that are not |