Permalink
Browse files

Fix pitch and yaw of loaded units, when loading maps.

  • Loading branch information...
1 parent cc0e183 commit 060345a5e497f07280ecaec07619467aa7b22c5c @perim perim committed Jun 12, 2011
Showing with 10 additions and 12 deletions.
  1. +1 −1 lib/framework/vector.h
  2. +5 −6 src/droid.cpp
  3. +1 −1 src/droid.h
  4. +2 −3 src/game.cpp
  5. +1 −1 src/multibot.cpp
View
2 lib/framework/vector.h
@@ -64,7 +64,7 @@ struct Vector3f
};
struct Rotation
{
- Rotation() {}
+ Rotation() { direction = 0; pitch = 0; roll = 0; }
Rotation(int direction, int pitch, int roll) : direction(direction), pitch(pitch), roll(roll) {}
Rotation(Vector3i xyz) : direction(xyz.x), pitch(xyz.y), roll(xyz.z) {}
uint16_t direction, pitch, roll; ///< Object rotation in 0..64k range
View
11 src/droid.cpp
@@ -2208,7 +2208,7 @@ UDWORD calcDroidPoints(DROID *psDroid)
}
//Builds an instance of a Droid - the x/y passed in are in world coords.
-DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player, bool onMission)
+DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, Position pos, UDWORD player, bool onMission, Rotation rot)
{
DROID *psDroid;
DROID_GROUP *psGrp;
@@ -2217,7 +2217,7 @@ DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD pl
HIT_SIDE impact_side;
// Don't use this assertion in single player, since droids can finish building while on an away mission
- ASSERT(!bMultiPlayer || worldOnMap(x,y), "the build locations are not on the map");
+ ASSERT(!bMultiPlayer || worldOnMap(pos.x, pos.y), "the build locations are not on the map");
//allocate memory
psDroid = new DROID(generateSynchronisedObjectId(), player);
@@ -2234,9 +2234,8 @@ DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD pl
// Set the droids type
psDroid->droidType = droidTemplateType(pTemplate); // Is set again later to the same thing, in droidSetBits.
-
- psDroid->pos.x = x;
- psDroid->pos.y = y;
+ psDroid->pos = pos;
+ psDroid->rot = rot;
psDroid->sMove.eBitX = 0;
psDroid->sMove.eBitY = 0;
@@ -2398,7 +2397,7 @@ DROID *buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
}
else
{
- return reallyBuildDroid(pTemplate, x, y, player, onMission);
+ return reallyBuildDroid(pTemplate, Position(x, y, 0), player, onMission);
}
}
View
2 src/droid.h
@@ -101,7 +101,7 @@ struct INITIAL_DROID_ORDERS
/// Sends a GAME_DROID message if bMultiMessages is true, or actually creates it if false. Only uses initialOrders if sending a GAME_DROID message.
extern DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player, bool onMission, const INITIAL_DROID_ORDERS *initialOrders);
/// Creates a droid locally, instead of sending a message, even if the bMultiMessages HACK is set to true.
-DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player, bool onMission);
+DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, Position pos, UDWORD player, bool onMission, Rotation rot = Rotation());
/* Set the asBits in a DROID structure given it's template. */
extern void droidSetBits(DROID_TEMPLATE *pTemplate,DROID *psDroid);
View
5 src/game.cpp
@@ -4264,7 +4264,7 @@ bool loadSaveDroidInit(char *pFileData, UDWORD filesize)
}
else
{
- psDroid = reallyBuildDroid(psTemplate, (pDroidInit->x & ~TILE_MASK) + TILE_UNITS/2, (pDroidInit->y & ~TILE_MASK) + TILE_UNITS/2, pDroidInit->player, false);
+ psDroid = reallyBuildDroid(psTemplate, Position((pDroidInit->x & ~TILE_MASK) + TILE_UNITS/2, (pDroidInit->y & ~TILE_MASK) + TILE_UNITS/2, 0), pDroidInit->player, false);
if (psDroid)
{
Vector2i startpos = getPlayerStartPosition(psDroid->player);
@@ -4445,7 +4445,7 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
/* Create the Droid */
turnOffMultiMsg(true);
- psDroid = reallyBuildDroid(psTemplate, pos.x, pos.y, player, onMission);
+ psDroid = reallyBuildDroid(psTemplate, pos, player, onMission, rot);
ASSERT_OR_RETURN(NULL, psDroid != NULL, "Failed to build unit %d", id);
turnOffMultiMsg(false);
@@ -4457,7 +4457,6 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
{
psDroid->body = psDroid->originalBody;
}
- psDroid->rot = rot;
psDroid->inFire = ini.value("inFire", 0).toInt();
psDroid->burnDamage = ini.value("burnDamage", 0).toInt();
psDroid->burnStart = ini.value("burnStart", 0).toInt();
View
2 src/multibot.cpp
@@ -453,7 +453,7 @@ bool recvDroid(NETQUEUE queue)
}
// Create that droid on this machine.
- psDroid = reallyBuildDroid(pT, pos.x, pos.y, player, false);
+ psDroid = reallyBuildDroid(pT, pos, player, false);
// If we were able to build the droid set it up
if (psDroid)

0 comments on commit 060345a

Please sign in to comment.