Fix SetPos and SetAngle functions

Fix types for SetPos and SetAngle
coverity_scan^2
Koncord 9 years ago
parent 645a21af21
commit 6f07d590d4

@ -48,7 +48,7 @@ double ScriptFunctions::GetPosZ(unsigned short pid) noexcept
return player->Position()->pos[2];
}
void ScriptFunctions::SetPos(unsigned short pid, float x, float y, float z) noexcept
void ScriptFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -140,7 +140,7 @@ double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept
return player->Position()->rot[2];
}
void ScriptFunctions::SetAngle(unsigned short pid, float x, float y, float z) noexcept
void ScriptFunctions::SetAngle(unsigned short pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player,);

@ -36,14 +36,14 @@ public:
static double GetPosX(unsigned short pid) noexcept;
static double GetPosY(unsigned short pid) noexcept;
static double GetPosZ(unsigned short pid) noexcept;
static void SetPos(unsigned short pid, float x, float y, float z) noexcept;
static void SetPos(unsigned short pid, double x, double y, double z) noexcept;
static void GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept;
static double GetAngleX(unsigned short pid) noexcept;
static double GetAngleY(unsigned short pid) noexcept;
static double GetAngleZ(unsigned short pid) noexcept;
static void SetAngle(unsigned short pid, float x, float y, float z) noexcept;
static void SetAngle(unsigned short pid, double x, double y, double z) noexcept;
static void SetCell(unsigned short pid, const char *name) noexcept;
static const char *GetCell(unsigned short pid) noexcept;

@ -117,6 +117,18 @@ void LocalPlayer::updatePosition(bool forceUpdate)
}
}
void LocalPlayer::setPosition()
{
MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr();
world->getPlayer().setTeleported(true);
world->moveObject(player, Position()->pos[0], Position()->pos[1], Position()->pos[2]);
world->rotateObject(player, Position()->rot[0], Position()->rot[1], Position()->rot[2]);
}
void LocalPlayer::updateInventory(bool forceUpdate)
{
MWWorld::Ptr player = GetPlayerPtr();

@ -29,6 +29,8 @@ namespace mwmp
void updateCell(bool forceUpdate = false);
void updateDrawStateAndFlags(bool forceUpdate = false);
void setPosition();
void CharGen(int stageFirst, int stageEnd);
bool CharGenThread(); // return true if CGStage::current == CGStage::end

@ -204,7 +204,16 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
case ID_GAME_UPDATE_POS:
{
if(id == myid)
getLocalPlayer()->updatePosition(true);
{
if (packet->length != myPacket->headerSize())
{
cout << "ID_GAME_UPDATE_POS changed by server" << endl;
myPacket->Packet(&bsIn, getLocalPlayer(), false);
getLocalPlayer()->setPosition();
}
else
getLocalPlayer()->updatePosition(true);
}
else if(pl != 0)
myPacket->Packet(&bsIn, pl, false);
break;

Loading…
Cancel
Save