From d5e398dcff2676b44cc3c06122a8c5861cbfc24d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 18 Dec 2005 09:57:44 +0000 Subject: Minor simplification. svn-id: r19804 --- gob/goblin.cpp | 24 +++++++----------------- gob/map.cpp | 7 +++---- gob/map.h | 8 +++++--- 3 files changed, 15 insertions(+), 24 deletions(-) (limited to 'gob') diff --git a/gob/goblin.cpp b/gob/goblin.cpp index 6bc2ddedce..5313bb5a23 100644 --- a/gob/goblin.cpp +++ b/gob/goblin.cpp @@ -969,9 +969,7 @@ void gob_targetItem(void) { void gob_initiateMove(void) { map_findNearestToDest(); map_findNearestToGob(); - - map_nearestWayPoint = - map_optimizePoints(map_curGoblinX, map_curGoblinY); + map_optimizePoints(); gob_pathExistence = map_checkDirectPath(map_curGoblinX, map_curGoblinY, gob_pressedMapX, gob_pressedMapY); @@ -1237,8 +1235,7 @@ void gob_movePathFind(Gob_Object *gobDesc, int16 nextAct) { map_curGoblinX = gob_gobPositions[gob_currentGoblin].x; map_curGoblinY = gob_gobPositions[gob_currentGoblin].y; - if (map_curGoblinX == gob_gobDestX && - map_curGoblinY == gob_gobDestY) { + if (map_curGoblinX == gob_gobDestX && map_curGoblinY == gob_gobDestY) { gob_pathExistence = 1; map_destX = gob_pressedMapX; map_destY = gob_pressedMapY; @@ -1248,13 +1245,10 @@ void gob_movePathFind(Gob_Object *gobDesc, int16 nextAct) { gob_gobDestX, gob_gobDestY) == 1) { map_destX = gob_gobDestX; map_destY = gob_gobDestY; - } else if (map_curGoblinX == map_destX - && map_curGoblinY == map_destY) { + } else if (map_curGoblinX == map_destX && map_curGoblinY == map_destY) { if (map_nearestWayPoint > map_nearestDest) { - map_nearestWayPoint = - map_optimizePoints(map_curGoblinX, - map_curGoblinY); + map_optimizePoints(); map_destX = map_wayPoints[map_nearestWayPoint]. @@ -1263,14 +1257,10 @@ void gob_movePathFind(Gob_Object *gobDesc, int16 nextAct) { map_wayPoints[map_nearestWayPoint]. y; - if (map_nearestWayPoint > - map_nearestDest) + if (map_nearestWayPoint > map_nearestDest) map_nearestWayPoint--; - } else if (map_nearestWayPoint < - map_nearestDest) { - map_nearestWayPoint = - map_optimizePoints(map_curGoblinX, - map_curGoblinY); + } else if (map_nearestWayPoint < map_nearestDest) { + map_optimizePoints(); map_destX = map_wayPoints[map_nearestWayPoint]. diff --git a/gob/map.cpp b/gob/map.cpp index efe1f5a9bc..afd51b6f01 100644 --- a/gob/map.cpp +++ b/gob/map.cpp @@ -376,23 +376,22 @@ int16 map_checkLongPath(int16 x0, int16 y0, int16 x1, int16 y1, int16 i0, int16 } } -int16 map_optimizePoints(int16 xPos, int16 yPos) { +void map_optimizePoints(void) { int16 i; if (map_nearestWayPoint < map_nearestDest) { for (i = map_nearestWayPoint; i <= map_nearestDest; i++) { - if (map_checkDirectPath(xPos, yPos, + if (map_checkDirectPath(map_curGoblinX, map_curGoblinY, map_wayPoints[i].x, map_wayPoints[i].y) == 1) map_nearestWayPoint = i; } } else if (map_nearestWayPoint > map_nearestDest) { for (i = map_nearestWayPoint; i >= map_nearestDest; i--) { - if (map_checkDirectPath(xPos, yPos, + if (map_checkDirectPath(map_curGoblinX, map_curGoblinY, map_wayPoints[i].x, map_wayPoints[i].y) == 1) map_nearestWayPoint = i; } } - return map_nearestWayPoint; } void map_loadDataFromAvo(char *dest, int16 size) { diff --git a/gob/map.h b/gob/map.h index ff362b701d..5e4ac8f86a 100644 --- a/gob/map.h +++ b/gob/map.h @@ -38,18 +38,20 @@ enum { }; #pragma START_PACK_STRUCTS -#define szMap_Point 4 + typedef struct Map_Point { int16 x; int16 y; } GCC_PACK Map_Point; #define szMap_ItemPos 3 -typedef struct Map_ItemPos { + + typedef struct Map_ItemPos { int8 x; int8 y; int8 orient; // ?? } GCC_PACK Map_ItemPos; + #pragma END_PACK_STRUCTS extern int8 map_passMap[28][26]; // [y][x] @@ -74,7 +76,7 @@ void map_findNearestToGob(void); void map_findNearestToDest(void); int16 map_checkDirectPath(int16 x0, int16 y0, int16 x1, int16 y1); int16 map_checkLongPath(int16 x0, int16 y0, int16 x1, int16 y1, int16 i0, int16 i1); -int16 map_optimizePoints(int16 xPos, int16 yPos); +void map_optimizePoints(void); void map_loadItemToObject(void); void map_loadMapObjects(char *avjFile); void map_loadDataFromAvo(int8 *dest, int16 size); -- cgit v1.2.3