From: <sv...@ww...> - 2007-09-15 20:43:32
|
Author: nsmoooose Date: 2007-09-15 13:43:24 -0700 (Sat, 15 Sep 2007) New Revision: 2180 Modified: trunk/csp/cspsim/battlefield/LocalBattlefield.cpp trunk/csp/cspsim/battlefield/LocalBattlefield.h trunk/csp/cspsim/stores/StoresManagementSystem.cpp trunk/csp/cspsim/swig/CSPSim.i trunk/csp/data/ui/scripts/windows/mainmenu.py trunk/csp/data/ui/tutorials/takeoff/takeoff.py Log: When you pressed the 'Instant Action' button the second time all aircrafts where computer controlled. Fixed this issue by: Changing this behavior by adding a new parameter to the __test__addLocalHumanUnit method. The new method takes a boolean indicating if it is a human or agent controlled object. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2180 Modified: trunk/csp/cspsim/battlefield/LocalBattlefield.cpp =================================================================== --- trunk/csp/cspsim/battlefield/LocalBattlefield.cpp 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/cspsim/battlefield/LocalBattlefield.cpp 2007-09-15 20:43:24 UTC (rev 2180) @@ -559,7 +559,7 @@ _assignObjectId(object, id); } -void LocalBattlefield::__test__addLocalHumanUnit(Unit const &unit) { +void LocalBattlefield::__test__addLocalHumanUnit(Unit const &unit, bool human) { assert(!unit->isStatic()); assert(!unit->isHuman()); assert(unit->id() == 0); @@ -570,12 +570,8 @@ LocalUnitWrapper *wrapper = new LocalUnitWrapper(unit, 0); addUnit(wrapper); - // XXX hack to force the first object to be player controlled. - // all other objects default to agent controlled. - static bool first = true; - if (first) { - first = false; - setHumanUnit(wrapper, true); + if (human) { + setHumanUnit(wrapper, human); } unit->registerUpdate(m_UnitUpdateMaster.get()); Modified: trunk/csp/cspsim/battlefield/LocalBattlefield.h =================================================================== --- trunk/csp/cspsim/battlefield/LocalBattlefield.h 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/cspsim/battlefield/LocalBattlefield.h 2007-09-15 20:43:24 UTC (rev 2180) @@ -82,7 +82,7 @@ void setCamera(Vector3 const &eye_point, const Vector3& look_pos, const Vector3& up_vec); // testing interface - void __test__addLocalHumanUnit(Unit const &unit); + void __test__addLocalHumanUnit(Unit const &unit, bool human); inline bool isConnectionActive() const { return m_ConnectionState == CONNECTION_ACTIVE; Modified: trunk/csp/cspsim/stores/StoresManagementSystem.cpp =================================================================== --- trunk/csp/cspsim/stores/StoresManagementSystem.cpp 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/cspsim/stores/StoresManagementSystem.cpp 2007-09-15 20:43:24 UTC (rev 2180) @@ -194,7 +194,7 @@ object->setVelocity(parent->getVelocity() + (parent->getAngularVelocity() ^ parent->getAttitude().rotate(store_position)) + ejection_velocity); object->setAngularVelocity(parent->getAngularVelocity() + ejection_angular_velocity); - CSPSim::theSim->getBattlefield()->__test__addLocalHumanUnit(object); // XXX TOTAL HACK FOR NOW!!! + CSPSim::theSim->getBattlefield()->__test__addLocalHumanUnit(object, false); // XXX TOTAL HACK FOR NOW!!! } } Modified: trunk/csp/cspsim/swig/CSPSim.i =================================================================== --- trunk/csp/cspsim/swig/CSPSim.i 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/cspsim/swig/CSPSim.i 2007-09-15 20:43:24 UTC (rev 2180) @@ -28,7 +28,7 @@ #include <iostream> void _createVehicleHelper(csp::CSPSim *self, const char *path, csp::Vector3 position, - csp::Vector3 velocity, csp::Vector3 attitude) { + csp::Vector3 velocity, csp::Vector3 attitude, bool human) { csp::Ref<csp::DynamicObject> obj = self->getDataManager().getObject(path); if (!obj) { std::cout << "WARNING: Failed to create object '" << path << "'\n"; @@ -40,7 +40,7 @@ attitude *= 3.1416 / 180.0; q_attitude.makeRotate(attitude.x(), attitude.y(), -attitude.z()); obj->setAttitude(q_attitude); - self->getBattlefield()->__test__addLocalHumanUnit(obj); + self->getBattlefield()->__test__addLocalHumanUnit(obj, human); if (!self->getActiveObject()) self->setActiveObject(obj); } @@ -100,14 +100,14 @@ %extend CSPSim { void createVehicle(const char *path, csp::Vector3 position, - csp::Vector3 velocity, csp::Vector3 attitude) { - _createVehicleHelper(self, path, position, velocity, attitude); + csp::Vector3 velocity, csp::Vector3 attitude, bool human) { + _createVehicleHelper(self, path, position, velocity, attitude, human); } void createVehicle(const char *path, csp::LLA lla, - csp::Vector3 velocity, csp::Vector3 attitude) { + csp::Vector3 velocity, csp::Vector3 attitude, bool human) { csp::Ref<const csp::Projection> map = csp::CSPSim::theSim->getTheater()->getTerrain()->getProjection(); csp::Vector3 position = map->convert(lla); - _createVehicleHelper(self, path, position, velocity, attitude); + _createVehicleHelper(self, path, position, velocity, attitude, human); } std::string const &getTerrainName() { return self->getTheater()->getTerrain()->getName(); } int getTerrainVersion() { return self->getTheater()->getTerrain()->getVersion(); } Modified: trunk/csp/data/ui/scripts/windows/mainmenu.py =================================================================== --- trunk/csp/data/ui/scripts/windows/mainmenu.py 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/data/ui/scripts/windows/mainmenu.py 2007-09-15 20:43:24 UTC (rev 2180) @@ -63,8 +63,8 @@ vec = csp.csplib.Vector3 m2k = "sim:vehicles.aircraft.m2k" f16dj = "sim:vehicles.aircraft.f16dj" - self.cspsim.createVehicle(f16dj, vec(-29495, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0)) - self.cspsim.createVehicle(f16dj, vec(-29510, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0)) + self.cspsim.createVehicle(f16dj, vec(-29495, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0), True) + self.cspsim.createVehicle(f16dj, vec(-29510, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0), False) gameScreenManager = GameScreenManager(self.cspsim) Modified: trunk/csp/data/ui/tutorials/takeoff/takeoff.py =================================================================== --- trunk/csp/data/ui/tutorials/takeoff/takeoff.py 2007-09-11 17:55:09 UTC (rev 2179) +++ trunk/csp/data/ui/tutorials/takeoff/takeoff.py 2007-09-15 20:43:24 UTC (rev 2180) @@ -68,7 +68,7 @@ # We add a single aircraft at the airport. vec = csp.csplib.Vector3 f16dj = "sim:vehicles.aircraft.f16dj" - self.cspsim.createVehicle(f16dj, vec(-29495, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0)) + self.cspsim.createVehicle(f16dj, vec(-29495, -10530, 91.3), vec(0, 0, 0), vec(0.0, 0.0, 180.0), True) # Set the date and time. We want daylight for the first mission. date = csp.csplib.SimDate(2007,6,12,10,0,0) |