mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 09:23:52 +00:00
Fix formatting
This commit is contained in:
parent
b6086ab015
commit
16216b30f7
2 changed files with 37 additions and 29 deletions
|
@ -72,21 +72,23 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate)
|
||||||
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
|
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
|
||||||
|
|
||||||
static float timer = 0;
|
static float timer = 0;
|
||||||
if (((oldHealth != health || oldMagicka != magicka || oldFatigue != fatigue) &&
|
|
||||||
(timer += MWBase::Environment::get().getFrameDuration()) >= 0.5 ) || forceUpdate)
|
if ((timer += MWBase::Environment::get().getFrameDuration()) >= 0.5 || forceUpdate)
|
||||||
{
|
{
|
||||||
oldHealth = health;
|
if (oldHealth != health || oldMagicka != magicka || oldFatigue != fatigue || forceUpdate)
|
||||||
oldMagicka = magicka;
|
{
|
||||||
oldFatigue = fatigue;
|
oldHealth = health;
|
||||||
|
oldMagicka = magicka;
|
||||||
|
oldFatigue = fatigue;
|
||||||
|
|
||||||
health.writeState(CreatureStats()->mDynamic[0]);
|
health.writeState(CreatureStats()->mDynamic[0]);
|
||||||
magicka.writeState(CreatureStats()->mDynamic[1]);
|
magicka.writeState(CreatureStats()->mDynamic[1]);
|
||||||
fatigue.writeState(CreatureStats()->mDynamic[2]);
|
fatigue.writeState(CreatureStats()->mDynamic[2]);
|
||||||
|
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|
||||||
GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(this);
|
|
||||||
|
|
||||||
|
GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,32 +101,37 @@ void LocalPlayer::updateClassStats(bool forceUpdate)
|
||||||
bool isUpdatingSkills = false;
|
bool isUpdatingSkills = false;
|
||||||
bool isUpdatingAttributes = false;
|
bool isUpdatingAttributes = false;
|
||||||
|
|
||||||
for (int i = 0; i < 27; ++i) {
|
for (int i = 0; i < 27; ++i)
|
||||||
|
{
|
||||||
if (_npcStats.getSkill(i).getBase() != NpcStats()->mSkills[i].mBase) {
|
if (_npcStats.getSkill(i).getBase() != NpcStats()->mSkills[i].mBase)
|
||||||
|
{
|
||||||
_npcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
|
_npcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
|
||||||
isUpdatingSkills = true;
|
isUpdatingSkills = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
if (_npcStats.getAttribute(i).getBase() != CreatureStats()->mAttributes[i].mBase) {
|
if (_npcStats.getAttribute(i).getBase() != CreatureStats()->mAttributes[i].mBase)
|
||||||
|
{
|
||||||
_npcStats.getAttribute(i).writeState(CreatureStats()->mAttributes[i]);
|
_npcStats.getAttribute(i).writeState(CreatureStats()->mAttributes[i]);
|
||||||
isUpdatingAttributes = true;
|
isUpdatingAttributes = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_npcStats.getLevel() != CreatureStats()->mLevel) {
|
if (_npcStats.getLevel() != CreatureStats()->mLevel)
|
||||||
|
{
|
||||||
CreatureStats()->mLevel = _npcStats.getLevel();
|
CreatureStats()->mLevel = _npcStats.getLevel();
|
||||||
GetNetworking()->GetPacket(ID_GAME_LEVEL)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_LEVEL)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUpdatingSkills) {
|
if (isUpdatingSkills)
|
||||||
|
{
|
||||||
GetNetworking()->GetPacket(ID_GAME_SKILL)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_SKILL)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUpdatingAttributes) {
|
if (isUpdatingAttributes)
|
||||||
|
{
|
||||||
GetNetworking()->GetPacket(ID_GAME_ATTRIBUTE)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_ATTRIBUTE)->Send(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +157,8 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
||||||
{
|
{
|
||||||
posChanged = isChangedPos;
|
posChanged = isChangedPos;
|
||||||
|
|
||||||
if (!isJumping && !world->isOnGround(player) && !world->isFlying(player)) {
|
if (!isJumping && !world->isOnGround(player) && !world->isFlying(player))
|
||||||
|
{
|
||||||
isJumping = true;
|
isJumping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,14 +170,14 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
||||||
|
|
||||||
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
||||||
}
|
}
|
||||||
else if (isJumping && world->isOnGround(player)) {
|
else if (isJumping && world->isOnGround(player))
|
||||||
|
{
|
||||||
isJumping = false;
|
isJumping = false;
|
||||||
sentJumpEnd = false;
|
sentJumpEnd = false;
|
||||||
}
|
}
|
||||||
// Packet with jump end position has to be sent one tick after above check
|
// Packet with jump end position has to be sent one tick after above check
|
||||||
else if (!sentJumpEnd) {
|
else if (!sentJumpEnd)
|
||||||
|
{
|
||||||
sentJumpEnd = true;
|
sentJumpEnd = true;
|
||||||
(*Position()) = _pos;
|
(*Position()) = _pos;
|
||||||
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
||||||
|
|
|
@ -83,8 +83,8 @@ void Networking::Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errmsg.empty()) {
|
if (!errmsg.empty())
|
||||||
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "%s", errmsg.c_str());
|
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "%s", errmsg.c_str());
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", errmsg.c_str(), 0);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", errmsg.c_str(), 0);
|
||||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
|
@ -212,8 +212,8 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", pl == 0 ? "new player" : pl->Npc()->mName.c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", pl == 0 ? "new player" : pl->Npc()->mName.c_str());
|
||||||
|
|
||||||
if (pl == 0) {
|
if (pl == 0)
|
||||||
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "%s", "- Exchanging data with new player");
|
LOG_APPEND(Log::LOG_INFO, "%s", "- Exchanging data with new player");
|
||||||
pl = Players::NewPlayer(id);
|
pl = Players::NewPlayer(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue