|
From: <be...@us...> - 2016-05-03 17:58:48
|
Revision: 1003
http://sourceforge.net/p/freesynd/code/1003
Author: benblan
Date: 2016-05-03 17:58:46 +0000 (Tue, 03 May 2016)
Log Message:
-----------
code refactoring
Modified Paths:
--------------
freesynd/trunk/AUTHORS
freesynd/trunk/NEWS
freesynd/trunk/README
freesynd/trunk/src/freesynd.cpp
freesynd/trunk/src/map.cpp
freesynd/trunk/src/map.h
freesynd/trunk/src/mapobject.h
freesynd/trunk/src/menus/gameplaymenu.cpp
freesynd/trunk/src/missionmanager.cpp
freesynd/trunk/src/ped.cpp
freesynd/trunk/src/ped.h
freesynd/trunk/src/vehicle.cpp
freesynd/trunk/src/vehicle.h
Modified: freesynd/trunk/AUTHORS
===================================================================
--- freesynd/trunk/AUTHORS 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/AUTHORS 2016-05-03 17:58:46 UTC (rev 1003)
@@ -2,7 +2,6 @@
(listed in alphabetical order)
current:
* Benoit Blancard (Developer): <be...@us...>
-* Bohdan Stelmak(Developer): <ch...@us...>
in past:
* Stuart Binge (Developer) : <sk...@us...>
@@ -14,6 +13,7 @@
* Bruce Sutherland <bru...@us...>
* Unavowed <una...@us...>
* Trent Waddington (Developer): <qua...@us...>
+* Bohdan Stelmak(Developer): <ch...@us...>
Contributors
* Tomas Jakobsson - good advices
Modified: freesynd/trunk/NEWS
===================================================================
--- freesynd/trunk/NEWS 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/NEWS 2016-05-03 17:58:46 UTC (rev 1003)
@@ -1,4 +1,4 @@
-FreeSynd 0.7.5 : Release Notes
+FreeSynd 0.8 : Release Notes
----------------------------
Description
@@ -11,14 +11,11 @@
Fixed Bugs
----------
- * When player changes its color, if an enemy syndicate already had that
- color, change the enemy color.
+ *
Features added
----------
- * Mission ownership on map menu changes to simulate syndicate fighting for terrotories.
- * Animation for animated windows
- * Agent's life is now restored automatically if he wears an upgraded chest
+ *
Known issues with this release
------------------------------
@@ -29,9 +26,16 @@
History
-------
+ v0.7.5
+ ------
+ * When player changes its color, if an enemy syndicate already had that
+ color, change the enemy color.
+ * Mission ownership on map menu changes to simulate syndicate fighting for terrotories.
+ * Animation for animated windows
+ * Agent's life is now restored automatically if he wears an upgraded chest
v0.7.1
- ----
+ ------
* Code refactoring
* All tabs coverted to spaces
* Better animation for impact or detonating explosions
Modified: freesynd/trunk/README
===================================================================
--- freesynd/trunk/README 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/README 2016-05-03 17:58:46 UTC (rev 1003)
@@ -1,4 +1,4 @@
-FreeSynd 0.7.5
+FreeSynd 0.8
------------
FreeSynd is a free, cross-platform reimplementation of engine for the classic
Bullfrog game "Syndicate". For more information see:
Modified: freesynd/trunk/src/freesynd.cpp
===================================================================
--- freesynd/trunk/src/freesynd.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/freesynd.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -144,7 +144,7 @@
int main(int argc, char *argv[]) {
- printf("Freesynd v0.7.5 (may 2016)\n");
+ printf("Freesynd v0.8 (may 2016)\n");
#ifdef CHEAP_LEAK_DETECTION
initLeakDetection();
@@ -171,7 +171,7 @@
#ifdef _DEBUG
// This parameter is used in debug phase to accelerate the starting
// of a game and to jump directly to a mission
- // Note : the argument is the index of the block in the structure g_MissionNumbers
+ // Note : the argument is the index of the block in the structure g_MissionNumbers
// as defined in briefmenu.cpp and not the mission number itself.
if (0 == strcmp("-m", argv[i]) || 0 == strcmp("--mission", argv[i])) {
int mission = atoi(argv[i + 1]);
Modified: freesynd/trunk/src/map.cpp
===================================================================
--- freesynd/trunk/src/map.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/map.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -222,6 +222,59 @@
a_tiles_[(y * max_x_ + x) * max_z_ + z] = tile_manager_->getTile(tileNum);
}
+
+/**
+ * Return true if tile at given position is traversable by a car.
+ * \param x int X coordinate
+ * \param y int Y coordinate
+ * \param z int Z coordinate
+ * \return bool
+ *
+ */
+bool Map::isTileWalkableByCar(int x, int y, int z)
+{
+ Tile *pTile = getTileAt(x, y, z);
+ uint8 tileId = pTile->id();
+
+ if(tileId == 80) {
+ Tile::EType near_type = getTileAt(x, y - 1, z)->type();
+ if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
+ && near_type != Tile::kRoadPedCross) {
+ return false;
+ }
+ near_type = getTileAt(x, y + 1, z)->type();
+ if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
+ && near_type != Tile::kRoadPedCross)
+ {
+ return false;
+ }
+ return true;
+ }
+ if(tileId == 81) {
+ Tile::EType near_type = getTileAt(x - 1, y, z)->type();
+ if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
+ && near_type != Tile::kRoadPedCross)
+ {
+ return false;
+ }
+ near_type = getTileAt(x + 1, y, z)->type();
+ if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
+ && near_type != Tile::kRoadPedCross)
+ {
+ return false;
+ }
+ return true;
+ }
+ if(tileId == 72) {
+ return false;
+ }
+
+ if(tileId == 119) {
+ return false;
+ }
+ return pTile->isRoad();
+}
+
const uint8 MiniMap::kOverlayNone = 0;
const uint8 MiniMap::kOverlayOurAgent = 1;
const uint8 MiniMap::kOverlayEnemyAgent = 2;
Modified: freesynd/trunk/src/map.h
===================================================================
--- freesynd/trunk/src/map.h 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/map.h 2016-05-03 17:58:46 UTC (rev 1003)
@@ -66,6 +66,8 @@
Tile * getTileAt(int x, int y, int z);
int tileAt(int x, int y, int z);
void patchMap(int x, int y, int z, uint8 tileNum);
+ //! Return true if tile at given position is traversable by car
+ bool isTileWalkableByCar(int x, int y, int z);
protected:
/*! Every map has a unique ID which is used to identify the
Modified: freesynd/trunk/src/mapobject.h
===================================================================
--- freesynd/trunk/src/mapobject.h 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/mapobject.h 2016-05-03 17:58:46 UTC (rev 1003)
@@ -511,8 +511,6 @@
std::list<TilePoint> dest_path_;
bool updatePlacement(int nOffX, int nOffY);
-
- virtual bool walkable(int x, int y, int z) = 0;
};
/*!
Modified: freesynd/trunk/src/menus/gameplaymenu.cpp
===================================================================
--- freesynd/trunk/src/menus/gameplaymenu.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/menus/gameplaymenu.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -776,6 +776,9 @@
printf(" > target(%i) : %s\n",
target_->id(), target_->natureName());
}
+
+ int tileid = mission_->get_map()->tileAt(mapPt.tx, mapPt.ty, mapPt.tz);
+ printf("Tile id %d\n", tileid);
return;
}
#endif //_DEBUG
Modified: freesynd/trunk/src/missionmanager.cpp
===================================================================
--- freesynd/trunk/src/missionmanager.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/missionmanager.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -636,7 +636,7 @@
pVehicle->addPassenger(p);
if (setDriver) {
VehicleInstance *pCar = dynamic_cast<VehicleInstance *>(pVehicle);
- pCar->forceSetDriver(p);
+ pCar->setDriver(p);
}
}
Modified: freesynd/trunk/src/ped.cpp
===================================================================
--- freesynd/trunk/src/ped.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/ped.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -1022,6 +1022,7 @@
void PedInstance::leaveVehicle() {
assert(map_ == -1 && in_vehicle_);
map_ = in_vehicle_->map();
+ setPosition(in_vehicle_->position());
in_vehicle_ = NULL;
switchActionStateFrom(state_ & (PedInstance::pa_smInCar
| PedInstance::pa_smUsingCar));
Modified: freesynd/trunk/src/ped.h
===================================================================
--- freesynd/trunk/src/ped.h 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/ped.h 2016-05-03 17:58:46 UTC (rev 1003)
@@ -738,8 +738,6 @@
//! Tells whether the panic can react to panic or not
bool panicImmuned_;
- bool walkable(int x, int y, int z) { return true; }
-
private:
inline int getClosestDirs(int dir, int& closest, int& closer);
};
Modified: freesynd/trunk/src/vehicle.cpp
===================================================================
--- freesynd/trunk/src/vehicle.cpp 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/vehicle.cpp 2016-05-03 17:58:46 UTC (rev 1003)
@@ -60,8 +60,16 @@
anims_burnt_ = anims + 12;
}
-void Vehicle::addPassenger(PedInstance *p) {
- passengers_.insert(p);
+/**
+ * Adds given ped to the list of passengers.
+ * \param pPed PedInstance*
+ * \return void
+ *
+ */
+void Vehicle::addPassenger(PedInstance *pPed) {
+ if(!isInsideVehicle(pPed)) {
+ passengers_.insert(pPed);
+ }
}
/*!
@@ -72,7 +80,6 @@
if(isInsideVehicle(pPed)) {
pPed->leaveVehicle();
passengers_.erase(passengers_.find(pPed));
- pPed->setPosition(pos_);
}
}
@@ -109,8 +116,9 @@
}
VehicleInstance::VehicleInstance(VehicleAnimation * vehicle, uint16 anId, int m):
- Vehicle(anId, m, true), vehicle_(vehicle), vehicle_driver_(NULL)
+ Vehicle(anId, m, true), vehicle_(vehicle)
{
+ pDriver_ = NULL;
hold_on_.wayFree = 0;
}
@@ -147,51 +155,6 @@
vehicle_->draw(x, y, getDirection(4), frame_);
}
-bool VehicleInstance::walkable(int x, int y, int z)
-{
- Map *pMap = g_App.maps().map(map());
- Tile *p_this_tile = pMap->getTileAt(x, y, z);
- uint8 this_tile_id = p_this_tile->id();
-
- if(this_tile_id == 80) {
- Tile::EType near_type = pMap->getTileAt(x, y - 1, z)->type();
- if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
- && near_type != Tile::kRoadPedCross) {
- return false;
- }
- near_type = pMap->getTileAt(x, y + 1, z)->type();
- if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
- && near_type != Tile::kRoadPedCross)
- {
- return false;
- }
- return true;
- }
- if(this_tile_id == 81) {
- Tile::EType near_type = pMap->getTileAt(x - 1, y, z)->type();
- if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
- && near_type != Tile::kRoadPedCross)
- {
- return false;
- }
- near_type = pMap->getTileAt(x + 1, y, z)->type();
- if((near_type < Tile::kRoadSideEW || near_type > Tile::kRoadSideNS)
- && near_type != Tile::kRoadPedCross)
- {
- return false;
- }
- return true;
- }
- if(this_tile_id == 72) {
- return false;
- }
-
- if(this_tile_id == 119) {
- return false;
- }
- return p_this_tile->isRoad();
-}
-
uint16 VehicleInstance::tileDir(int x, int y, int z) {
uint16 dir = 0x0;
int near_tile;
@@ -358,8 +321,8 @@
}
bool VehicleInstance::dirWalkable(TilePoint *p, int x, int y, int z) {
-
- if(!(walkable(x,y,z)))
+ Map *pMap = g_App.maps().map(map());
+ if(!(pMap->isTileWalkableByCar(x,y,z)))
return false;
uint16 dirStart = tileDir(p->tx,p->ty,p->tz);
@@ -419,7 +382,7 @@
dest_path_.clear();
setSpeed(0);
- if (map_ == -1 || health_ <= 0 || !(walkable(x, y, z))) {
+ if (map_ == -1 || health_ <= 0 || !(pMap->isTileWalkableByCar(x, y, z))) {
#if 0
#if _DEBUG
if (!(map_ == -1 || health_ <= 0)) {
@@ -433,7 +396,7 @@
return;
}
- if (!walkable(pos_.tx, pos_.ty, z)) {
+ if (!pMap->isTileWalkableByCar(pos_.tx, pos_.ty, z)) {
int dBest = 100000, dCur;
std::vector < TilePoint > path2wtile;
path2wtile.reserve(16);
@@ -444,7 +407,7 @@
break;
pntile.tx = pos_.tx + i;
path2wtile.push_back(pntile);
- if (walkable(pos_.tx + i, pos_.ty, z)) {
+ if (pMap->isTileWalkableByCar(pos_.tx + i, pos_.ty, z)) {
dCur = i * i;
if(dCur < dBest) {
dBest = dCur;
@@ -463,7 +426,7 @@
break;
pntile.tx = (pos_.tx + i);
path2wtile.push_back(pntile);
- if (walkable(pos_.tx + i, pos_.ty, z)) {
+ if (pMap->isTileWalkableByCar(pos_.tx + i, pos_.ty, z)) {
dCur = i * i;
if(dCur < dBest) {
dBest = dCur;
@@ -482,7 +445,7 @@
break;
pntile.ty = (pos_.ty + i);
path2wtile.push_back(pntile);
- if (walkable(pos_.tx, pos_.ty + i, z)) {
+ if (pMap->isTileWalkableByCar(pos_.tx, pos_.ty + i, z)) {
dCur = i * i;
if(dCur < dBest) {
dBest = dCur;
@@ -501,7 +464,7 @@
break;
pntile.ty = pos_.ty + i;
path2wtile.push_back(pntile);
- if (walkable(pos_.tx, pos_.ty + i, z)) {
+ if (pMap->isTileWalkableByCar(pos_.tx, pos_.ty + i, z)) {
dCur = i * i;
if(dCur < dBest) {
dBest = dCur;
@@ -818,7 +781,7 @@
setTimeShowAnim(10000);
break;
}
- vehicle_driver_ = NULL;
+ pDriver_ = NULL;
while (passengers_.size() != 0)
{
PedInstance *p = *(passengers_.begin());
@@ -838,13 +801,11 @@
*/
void VehicleInstance::addPassenger(PedInstance *p) {
Vehicle::addPassenger(p);
- if (hasDriver()) {
- // There's already a driver
- p->putInVehicle(this, PedInstance::pa_smInCar);
- } else {
+ // TODO : move putInVehicle() in Vehicle::addPassenger()
+ p->putInVehicle(this, PedInstance::pa_smInCar);
+ if (pDriver_ == NULL) {
// Ped becomes the driver
- vehicle_driver_ = p;
- p->putInVehicle(this, PedInstance::pa_smUsingCar);
+ pDriver_ = p;
}
}
@@ -854,23 +815,37 @@
*/
void VehicleInstance::dropPassenger(PedInstance *pPed) {
Vehicle::dropPassenger(pPed);
- if (vehicle_driver_ == pPed) {
- vehicle_driver_ = NULL;
+ if (pDriver_ == pPed) {
+ pDriver_ = NULL;
clearDestination();
// find another driver in the remaining passengers
for (std::set<PedInstance *>::iterator it = passengers_.begin();
it != passengers_.end(); it++) {
// take the first one
- vehicle_driver_ = *it;
+ pDriver_ = *it;
break;
}
}
}
-void VehicleInstance::forceSetDriver(PedInstance *vehicleDriver) {
- vehicle_driver_ = vehicleDriver;
- if (!isInsideVehicle(vehicleDriver)) {
- Vehicle::addPassenger(vehicleDriver);
+/**
+ * Set this ped as the driver of the vehicle and add him as a passenger
+ * if he's not already in the vehicle.
+ * \param pPed PedInstance*
+ * \param forceDriver bool if true, set the driver even if there is already
+ * another driver
+ * \return void
+ *
+ */
+void VehicleInstance::setDriver(PedInstance *pPed, bool forceDriver) {
+ if (pPed != NULL) {
+ if (pDriver_ == NULL || forceDriver) {
+ pDriver_ = pPed;
+ }
+
+ if (!isInsideVehicle(pPed)) {
+ Vehicle::addPassenger(pPed);
+ }
}
}
Modified: freesynd/trunk/src/vehicle.h
===================================================================
--- freesynd/trunk/src/vehicle.h 2016-05-02 20:49:22 UTC (rev 1002)
+++ freesynd/trunk/src/vehicle.h 2016-05-03 17:58:46 UTC (rev 1003)
@@ -142,32 +142,30 @@
void dropPassenger(PedInstance *p);
PedInstance *getDriver(void) {
- return vehicle_driver_;
+ return pDriver_;
}
- void setDriver(PedInstance *vehicleDriver) {
- if (vehicle_driver_ == NULL)
- vehicle_driver_ = vehicleDriver;
- passengers_.insert(vehicleDriver);
+ //! Set this ped as the new driver
+ void setDriver(PedInstance *pPed, bool forceDriver = true);
+
+ /*!
+ * Return true given ped is the driver of this vehicle.
+ * \param pPed a Ped.
+ */
+ bool isDriver(PedInstance *pPed) {
+ return (pPed != NULL && pDriver_ == pPed);
}
- void forceSetDriver(PedInstance *vehicleDriver);
- bool hasDriver() { return (vehicle_driver_ != NULL); }
- bool isDriver(PedInstance *vehicleDriver) {
- if (vehicle_driver_ == NULL)
- return false;
- return (vehicle_driver_ == vehicleDriver);
- }
void handleHit(ShootableMapObject::DamageInflictType &d);
protected:
bool move_vehicle(int elapsed);
- bool walkable(int x, int y, int z);
uint16 tileDir(int x, int y, int z);
bool dirWalkable(TilePoint *p, int x, int y, int z);
protected:
VehicleAnimation *vehicle_;
- PedInstance *vehicle_driver_;
+ //! Vehicle driver
+ PedInstance *pDriver_;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|