forked from teamnwah/openmw-tes3coop
Make variable names more consistent and easier to understand
This commit is contained in:
parent
694ce537b6
commit
bc0aa86bcf
6 changed files with 139 additions and 142 deletions
|
@ -35,7 +35,7 @@ void Players::NewPlayer(RakNet::RakNetGUID id)
|
|||
players[id]->Npc()->blank();
|
||||
players[id]->NpcStats()->blank();
|
||||
players[id]->CreatureStats()->blank();
|
||||
players[id]->klass.blank();
|
||||
players[id]->charClass.blank();
|
||||
|
||||
for (int i = 0; i < mwmp::Networking::Get().MaxConnections(); i++)
|
||||
{
|
||||
|
|
|
@ -22,20 +22,20 @@ void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noe
|
|||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
player->klass.mId = id;
|
||||
player->charClass.mId = id;
|
||||
}
|
||||
void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
player->klass.mName = name;
|
||||
player->klass.mId = "";
|
||||
player->charClass.mName = name;
|
||||
player->charClass.mId = "";
|
||||
}
|
||||
void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
player->klass.mDescription = desc;
|
||||
player->charClass.mDescription = desc;
|
||||
}
|
||||
void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
|
||||
{
|
||||
|
@ -45,14 +45,14 @@ void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned cha
|
|||
if (slot > 1)
|
||||
throw invalid_argument("Incorrect attribute slot id");
|
||||
|
||||
player->klass.mData.mAttribute[slot] = attrId;
|
||||
player->charClass.mData.mAttribute[slot] = attrId;
|
||||
|
||||
}
|
||||
void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
player->klass.mData.mSpecialization = spec;
|
||||
player->charClass.mData.mSpecialization = spec;
|
||||
}
|
||||
void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char sl
|
|||
GET_PLAYER(pid, player,);
|
||||
if (slot > 4)
|
||||
throw invalid_argument("Incorrect skill slot id");
|
||||
player->klass.mData.mSkills[slot][1] = skillId;
|
||||
player->charClass.mData.mSkills[slot][1] = skillId;
|
||||
}
|
||||
void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
|
||||
{
|
||||
|
@ -68,35 +68,35 @@ void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char sl
|
|||
GET_PLAYER(pid, player,);
|
||||
if (slot > 4)
|
||||
throw invalid_argument("Incorrect skill slot id");
|
||||
player->klass.mData.mSkills[slot][0] = skillId;
|
||||
player->charClass.mData.mSkills[slot][0] = skillId;
|
||||
}
|
||||
|
||||
int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,0);
|
||||
return !player->klass.mId.empty(); // true if default
|
||||
return !player->charClass.mId.empty(); // true if default
|
||||
}
|
||||
|
||||
const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,"");
|
||||
return player->klass.mId.c_str();
|
||||
return player->charClass.mId.c_str();
|
||||
}
|
||||
|
||||
const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,"");
|
||||
return player->klass.mName.c_str();
|
||||
return player->charClass.mName.c_str();
|
||||
}
|
||||
|
||||
const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,"");
|
||||
return player->klass.mDescription.c_str();
|
||||
return player->charClass.mDescription.c_str();
|
||||
}
|
||||
|
||||
int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept
|
||||
|
@ -105,14 +105,14 @@ int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char
|
|||
GET_PLAYER(pid, player,0);
|
||||
if (slot > 1)
|
||||
throw invalid_argument("Incorrect attribute slot id");
|
||||
return player->klass.mData.mAttribute[slot];
|
||||
return player->charClass.mData.mAttribute[slot];
|
||||
}
|
||||
|
||||
int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,0);
|
||||
return player->klass.mData.mSpecialization;
|
||||
return player->charClass.mData.mSpecialization;
|
||||
}
|
||||
|
||||
int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept
|
||||
|
@ -121,7 +121,7 @@ int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slo
|
|||
GET_PLAYER(pid, player,0);
|
||||
if (slot > 4)
|
||||
throw invalid_argument("Incorrect skill slot id");
|
||||
return player->klass.mData.mSkills[slot][1];
|
||||
return player->charClass.mData.mSkills[slot][1];
|
||||
}
|
||||
|
||||
int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept
|
||||
|
@ -130,5 +130,5 @@ int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slo
|
|||
GET_PLAYER(pid, player,0);
|
||||
if (slot > 4)
|
||||
throw invalid_argument("Incorrect skill slot id");
|
||||
return player->klass.mData.mSkills[slot][0];
|
||||
return player->charClass.mData.mSkills[slot][0];
|
||||
}
|
||||
|
|
|
@ -48,64 +48,63 @@ void Players::CreatePlayer(RakNet::RakNetGUID id)
|
|||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
ESM::NPC dedic_pl = *player.get<ESM::NPC>()->mBase;
|
||||
DedicatedPlayer *_player = players[id];
|
||||
ESM::NPC npc = *player.get<ESM::NPC>()->mBase;
|
||||
DedicatedPlayer *dedicPlayer = players[id];
|
||||
|
||||
dedic_pl.mRace = _player->Npc()->mRace;
|
||||
dedic_pl.mHead = _player->Npc()->mHead;
|
||||
dedic_pl.mHair = _player->Npc()->mHair;
|
||||
dedic_pl.mClass = _player->Npc()->mClass;
|
||||
dedic_pl.mName = _player->Npc()->mName;
|
||||
dedic_pl.mFlags = _player->Npc()->mFlags;
|
||||
npc.mRace = dedicPlayer->Npc()->mRace;
|
||||
npc.mHead = dedicPlayer->Npc()->mHead;
|
||||
npc.mHair = dedicPlayer->Npc()->mHair;
|
||||
npc.mClass = dedicPlayer->Npc()->mClass;
|
||||
npc.mName = dedicPlayer->Npc()->mName;
|
||||
npc.mFlags = dedicPlayer->Npc()->mFlags;
|
||||
|
||||
if (_player->state == 0)
|
||||
if (dedicPlayer->state == 0)
|
||||
{
|
||||
dedic_pl.mId = "Dedicated Player";
|
||||
npc.mId = "Dedicated Player";
|
||||
|
||||
std::string recid = world->createRecord(dedic_pl)->mId;
|
||||
std::string recid = world->createRecord(npc)->mId;
|
||||
|
||||
|
||||
_player->reference = new MWWorld::ManualRef(world->getStore(), recid, 1);
|
||||
dedicPlayer->reference = new MWWorld::ManualRef(world->getStore(), recid, 1);
|
||||
}
|
||||
|
||||
// Temporarily spawn or move player to ToddTest whenever setting base info
|
||||
ESM::Position _pos;
|
||||
world->findInteriorPosition("ToddTest", _pos);
|
||||
ESM::Position newPos;
|
||||
world->findInteriorPosition("ToddTest", newPos);
|
||||
MWWorld::CellStore *cellStore = world->getInterior("ToddTest");
|
||||
|
||||
if (_player->state == 0)
|
||||
if (dedicPlayer->state == 0)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "- Creating new reference pointer for %s",
|
||||
_player->Npc()->mName.c_str());
|
||||
dedicPlayer->Npc()->mName.c_str());
|
||||
|
||||
MWWorld::Ptr tmp = world->placeObject(_player->reference->getPtr(), cellStore, _pos);
|
||||
MWWorld::Ptr tmp = world->placeObject(dedicPlayer->reference->getPtr(), cellStore, newPos);
|
||||
|
||||
_player->ptr.mCell = tmp.mCell;
|
||||
_player->ptr.mRef = tmp.mRef;
|
||||
dedicPlayer->ptr.mCell = tmp.mCell;
|
||||
dedicPlayer->ptr.mRef = tmp.mRef;
|
||||
|
||||
_player->cell = *_player->ptr.getCell()->getCell();
|
||||
_player->pos = _player->ptr.getRefData().getPosition();
|
||||
dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell();
|
||||
dedicPlayer->pos = dedicPlayer->ptr.getRefData().getPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "- Updating reference pointer for %s",
|
||||
_player->Npc()->mName.c_str());
|
||||
dedicPlayer->Npc()->mName.c_str());
|
||||
|
||||
_player->ptr.getBase()->canChangeCell = true;
|
||||
_player->UpdatePtr(world->moveObject(_player->ptr, cellStore, _pos.pos[0], _pos.pos[1], _pos.pos[2]));
|
||||
dedicPlayer->ptr.getBase()->canChangeCell = true;
|
||||
dedicPlayer->UpdatePtr(world->moveObject(dedicPlayer->ptr, cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2]));
|
||||
|
||||
dedic_pl.mId = players[id]->ptr.get<ESM::NPC>()->mBase->mId;
|
||||
npc.mId = players[id]->ptr.get<ESM::NPC>()->mBase->mId;
|
||||
|
||||
MWWorld::ESMStore *store = const_cast<MWWorld::ESMStore *>(&world->getStore());
|
||||
MWWorld::Store<ESM::NPC> *esm_store = const_cast<MWWorld::Store<ESM::NPC> *> (&store->get<ESM::NPC>());
|
||||
|
||||
esm_store->insert(dedic_pl);
|
||||
esm_store->insert(npc);
|
||||
|
||||
_player->updateCell();
|
||||
dedicPlayer->updateCell();
|
||||
}
|
||||
|
||||
_player->guid = id;
|
||||
_player->state = 2;
|
||||
dedicPlayer->guid = id;
|
||||
dedicPlayer->state = 2;
|
||||
|
||||
world->enable(players[id]->ptr);
|
||||
}
|
||||
|
@ -126,12 +125,12 @@ void Players::DisconnectPlayer(RakNet::RakNetGUID id)
|
|||
world->disable(players[id]->getPtr());
|
||||
|
||||
// Move player to ToddTest
|
||||
ESM::Position _pos;
|
||||
world->findInteriorPosition("ToddTest", _pos);
|
||||
ESM::Position newPos;
|
||||
world->findInteriorPosition("ToddTest", newPos);
|
||||
MWWorld::CellStore *store = world->getInterior("ToddTest");
|
||||
|
||||
players[id]->getPtr().getBase()->canChangeCell = true;
|
||||
world->moveObject(players[id]->getPtr(), store, _pos.pos[0], _pos.pos[1], _pos.pos[2]);
|
||||
world->moveObject(players[id]->getPtr(), store, newPos.pos[0], newPos.pos[1], newPos.pos[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,16 +189,16 @@ void DedicatedPlayer::Move(float dt)
|
|||
{
|
||||
if (state != 2) return;
|
||||
|
||||
ESM::Position ref_pos = ptr.getRefData().getPosition();
|
||||
ESM::Position refPos = ptr.getRefData().getPosition();
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
||||
|
||||
{
|
||||
osg::Vec3f lerp = Lerp(ref_pos.asVec3(), pos.asVec3(), dt * 15);
|
||||
ref_pos.pos[0] = lerp.x();
|
||||
ref_pos.pos[1] = lerp.y();
|
||||
ref_pos.pos[2] = lerp.z();
|
||||
world->moveObject(ptr, ref_pos.pos[0], ref_pos.pos[1], ref_pos.pos[2]);
|
||||
osg::Vec3f lerp = Lerp(refPos.asVec3(), pos.asVec3(), dt * 15);
|
||||
refPos.pos[0] = lerp.x();
|
||||
refPos.pos[1] = lerp.y();
|
||||
refPos.pos[2] = lerp.z();
|
||||
world->moveObject(ptr, refPos.pos[0], refPos.pos[1], refPos.pos[2]);
|
||||
}
|
||||
|
||||
MWMechanics::Movement *move = &ptr.getClass().getMovementSettings(ptr);
|
||||
|
@ -217,39 +216,39 @@ void Players::Update(float dt)
|
|||
DedicatedPlayer *pl = it->second;
|
||||
if (pl == 0) continue;
|
||||
|
||||
MWMechanics::NpcStats *npcStats = &pl->ptr.getClass().getNpcStats(pl->getPtr());
|
||||
MWMechanics::NpcStats *ptrNpcStats = &pl->ptr.getClass().getNpcStats(pl->getPtr());
|
||||
|
||||
MWMechanics::DynamicStat<float> value;
|
||||
|
||||
if (pl->CreatureStats()->mDead)
|
||||
{
|
||||
value.readState(pl->CreatureStats()->mDynamic[0]);
|
||||
npcStats->setHealth(value);
|
||||
ptrNpcStats->setHealth(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
value.readState(pl->CreatureStats()->mDynamic[0]);
|
||||
npcStats->setHealth(value);
|
||||
ptrNpcStats->setHealth(value);
|
||||
value.readState(pl->CreatureStats()->mDynamic[1]);
|
||||
npcStats->setMagicka(value);
|
||||
ptrNpcStats->setMagicka(value);
|
||||
value.readState(pl->CreatureStats()->mDynamic[2]);
|
||||
npcStats->setFatigue(value);
|
||||
ptrNpcStats->setFatigue(value);
|
||||
|
||||
if (npcStats->isDead())
|
||||
npcStats->resurrect();
|
||||
if (ptrNpcStats->isDead())
|
||||
ptrNpcStats->resurrect();
|
||||
|
||||
|
||||
npcStats->setAttacked(false);
|
||||
ptrNpcStats->setAttacked(false);
|
||||
|
||||
npcStats->getAiSequence().stopCombat();
|
||||
ptrNpcStats->getAiSequence().stopCombat();
|
||||
|
||||
npcStats->setAlarmed(false);
|
||||
npcStats->setAiSetting(MWMechanics::CreatureStats::AI_Alarm, 0);
|
||||
npcStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0);
|
||||
npcStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0);
|
||||
npcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
|
||||
ptrNpcStats->setAlarmed(false);
|
||||
ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Alarm, 0);
|
||||
ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0);
|
||||
ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0);
|
||||
ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
|
||||
|
||||
npcStats->setBaseDisposition(255);
|
||||
ptrNpcStats->setBaseDisposition(255);
|
||||
pl->Move(dt);
|
||||
pl->UpdateDrawState();
|
||||
}
|
||||
|
@ -320,8 +319,8 @@ void DedicatedPlayer::UpdateInventory()
|
|||
const std::string DedicatedPlayer::GetAnim()
|
||||
{
|
||||
static string anim;
|
||||
static string anim_dir;
|
||||
static string anim_weap;
|
||||
static string animDir;
|
||||
static string animWeap;
|
||||
|
||||
MWMechanics::NpcStats *npcStats = &ptr.getClass().getNpcStats(ptr);
|
||||
|
||||
|
@ -336,18 +335,18 @@ const std::string DedicatedPlayer::GetAnim()
|
|||
{
|
||||
|
||||
if (movementAnim == 3)
|
||||
anim_dir = "forward";
|
||||
animDir = "forward";
|
||||
else if (movementAnim == 4)
|
||||
anim_dir = "back";
|
||||
animDir = "back";
|
||||
else if (movementAnim == 2)
|
||||
anim_dir = "left";
|
||||
animDir = "left";
|
||||
else if (movementAnim == 1)
|
||||
anim_dir = "right";
|
||||
animDir = "right";
|
||||
}
|
||||
else
|
||||
{
|
||||
anim = "idle";
|
||||
anim_dir = "";
|
||||
animDir = "";
|
||||
}
|
||||
|
||||
if (npcStats->getDrawState() == MWMechanics::DrawState_Weapon)
|
||||
|
@ -365,24 +364,24 @@ const std::string DedicatedPlayer::GetAnim()
|
|||
type == ESM::Weapon::MarksmanThrown ||
|
||||
type == ESM::Weapon::MarksmanCrossbow ||
|
||||
type == ESM::Weapon::MarksmanBow*/)
|
||||
anim_weap = "1h";
|
||||
animWeap = "1h";
|
||||
else if (type == ESM::Weapon::LongBladeTwoHand ||
|
||||
type == ESM::Weapon::BluntTwoClose ||
|
||||
type == ESM::Weapon::AxeTwoHand)
|
||||
anim_weap = "2c";
|
||||
animWeap = "2c";
|
||||
else if (type == ESM::Weapon::BluntTwoWide ||
|
||||
type == ESM::Weapon::SpearTwoWide)
|
||||
anim_weap = "2w";
|
||||
animWeap = "2w";
|
||||
}
|
||||
else
|
||||
anim_weap = "hh";
|
||||
animWeap = "hh";
|
||||
}
|
||||
else if (movementAnim == 0 && npcStats->getDrawState() == MWMechanics::DrawState_Spell)
|
||||
anim_weap = "spell";
|
||||
animWeap = "spell";
|
||||
else
|
||||
anim_weap = "";
|
||||
animWeap = "";
|
||||
|
||||
return (anim + anim_dir + anim_weap);
|
||||
return (anim + animDir + animWeap);
|
||||
}
|
||||
|
||||
DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr)
|
||||
|
@ -411,11 +410,11 @@ void DedicatedPlayer::UpdateDrawState()
|
|||
else if (drawState == 2)
|
||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell);
|
||||
|
||||
MWMechanics::NpcStats *npcStats = &ptr.getClass().getNpcStats(ptr);
|
||||
npcStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
npcStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
|
||||
npcStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);
|
||||
npcStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
|
||||
MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);
|
||||
ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
|
||||
}
|
||||
|
||||
void DedicatedPlayer::updateCell()
|
||||
|
|
|
@ -96,32 +96,32 @@ void LocalPlayer::updateClassStats(bool forceUpdate)
|
|||
{
|
||||
MWWorld::Ptr player = GetPlayerPtr();
|
||||
|
||||
const MWMechanics::NpcStats &_npcStats = player.getClass().getNpcStats(player);
|
||||
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
|
||||
bool isUpdatingSkills = false;
|
||||
bool isUpdatingAttributes = false;
|
||||
|
||||
for (int i = 0; i < 27; ++i)
|
||||
{
|
||||
if (_npcStats.getSkill(i).getBase() != NpcStats()->mSkills[i].mBase)
|
||||
if (ptrNpcStats.getSkill(i).getBase() != NpcStats()->mSkills[i].mBase)
|
||||
{
|
||||
_npcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
|
||||
ptrNpcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
|
||||
isUpdatingSkills = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (_npcStats.getAttribute(i).getBase() != CreatureStats()->mAttributes[i].mBase)
|
||||
if (ptrNpcStats.getAttribute(i).getBase() != CreatureStats()->mAttributes[i].mBase)
|
||||
{
|
||||
_npcStats.getAttribute(i).writeState(CreatureStats()->mAttributes[i]);
|
||||
ptrNpcStats.getAttribute(i).writeState(CreatureStats()->mAttributes[i]);
|
||||
isUpdatingAttributes = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_npcStats.getLevel() != CreatureStats()->mLevel)
|
||||
if (ptrNpcStats.getLevel() != CreatureStats()->mLevel)
|
||||
{
|
||||
CreatureStats()->mLevel = _npcStats.getLevel();
|
||||
CreatureStats()->mLevel = ptrNpcStats.getLevel();
|
||||
GetNetworking()->GetPacket(ID_GAME_LEVEL)->Send(this);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
static bool isJumping = false;
|
||||
static bool sentJumpEnd = true;
|
||||
|
||||
ESM::Position _pos = player.getRefData().getPosition();
|
||||
ESM::Position ptrPos = player.getRefData().getPosition();
|
||||
|
||||
const bool isChangedPos = (move.mPosition[0] != 0 || move.mPosition[1] != 0 || move.mPosition[2] != 0
|
||||
|| move.mRotation[0] != 0 || move.mRotation[1] != 0 || move.mRotation[2] != 0);
|
||||
|
@ -162,7 +162,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
isJumping = true;
|
||||
}
|
||||
|
||||
(*Position()) = _pos;
|
||||
(*Position()) = ptrPos;
|
||||
|
||||
Dir()->pos[0] = move.mPosition[0];
|
||||
Dir()->pos[1] = move.mPosition[1];
|
||||
|
@ -179,7 +179,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
else if (!sentJumpEnd)
|
||||
{
|
||||
sentJumpEnd = true;
|
||||
(*Position()) = _pos;
|
||||
(*Position()) = ptrPos;
|
||||
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,6 @@ void LocalPlayer::setCell()
|
|||
|
||||
int x = GetCell()->mCellId.mIndex.mX;
|
||||
int y = GetCell()->mCellId.mIndex.mY;
|
||||
ESM::CellId curCell = player.mCell->getCell()->mCellId;
|
||||
|
||||
if (GetCell()->isExterior())
|
||||
{
|
||||
|
@ -345,10 +344,10 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
|
|||
{
|
||||
MWWorld::Ptr player = GetPlayerPtr();
|
||||
|
||||
MWMechanics::NpcStats *playerStats = &player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player);
|
||||
static bool isDead = false;
|
||||
|
||||
if (playerStats->isDead() && !isDead)
|
||||
if (ptrNpcStats->isDead() && !isDead)
|
||||
{
|
||||
CreatureStats()->mDead = true;
|
||||
RakNet::BitStream bs;
|
||||
|
@ -356,7 +355,7 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
|
|||
GetNetworking()->SendData(&bs);
|
||||
isDead = true;
|
||||
}
|
||||
else if (playerStats->getHealth().getCurrent() > 0 && isDead)
|
||||
else if (ptrNpcStats->getHealth().getCurrent() > 0 && isDead)
|
||||
isDead = false;
|
||||
}
|
||||
|
||||
|
@ -421,9 +420,7 @@ void LocalPlayer::SendAttack(char type)
|
|||
|
||||
void LocalPlayer::updateCell(bool forceUpdate)
|
||||
{
|
||||
const ESM::Cell *_cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell();
|
||||
static bool isExterior = !_cell->isExterior();
|
||||
|
||||
const ESM::Cell *ptrCell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell();
|
||||
bool shouldUpdate = false;
|
||||
|
||||
// Send a packet to server to update this LocalPlayer's cell if:
|
||||
|
@ -435,17 +432,17 @@ void LocalPlayer::updateCell(bool forceUpdate)
|
|||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (!Misc::StringUtils::ciEqual(_cell->mName, GetCell()->mName))
|
||||
else if (!Misc::StringUtils::ciEqual(ptrCell->mName, GetCell()->mName))
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (_cell->isExterior())
|
||||
else if (ptrCell->isExterior())
|
||||
{
|
||||
if (_cell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX)
|
||||
if (ptrCell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (_cell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY)
|
||||
else if (ptrCell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
|
@ -457,10 +454,9 @@ void LocalPlayer::updateCell(bool forceUpdate)
|
|||
|
||||
LOG_APPEND(Log::LOG_INFO, "- Moved from %s to %s",
|
||||
GetCell()->getDescription().c_str(),
|
||||
_cell->getDescription().c_str());
|
||||
ptrCell->getDescription().c_str());
|
||||
|
||||
(*GetCell()) = *_cell;
|
||||
isExterior = _cell->isExterior();
|
||||
(*GetCell()) = *ptrCell;
|
||||
|
||||
// Make sure the position is updated before a cell packet is sent, or else
|
||||
// cell change events in server scripts will have the wrong player position
|
||||
|
@ -478,18 +474,18 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
|
|||
MWWorld::Ptr player = world->getPlayerPtr();
|
||||
|
||||
|
||||
MWMechanics::NpcStats npcStats = player.getClass().getNpcStats(player);
|
||||
MWMechanics::NpcStats ptrNpcStats = player.getClass().getNpcStats(player);
|
||||
using namespace MWMechanics;
|
||||
|
||||
static bool oldRun = npcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
static bool oldSneak = npcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
static bool oldForceJump = npcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
static bool oldForceMoveJump = npcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
static bool oldRun = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
static bool oldSneak = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
static bool oldForceJump = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
static bool oldForceMoveJump = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
|
||||
bool run = npcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
bool sneak = npcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
bool forceJump = npcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
bool forceMoveJump = npcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
bool run = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
|
||||
bool sneak = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak);
|
||||
bool forceJump = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
|
||||
bool forceMoveJump = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
|
||||
bool jump = !world->isOnGround(player) && !world->isFlying(player);
|
||||
static bool onJump = false;
|
||||
|
||||
|
@ -619,18 +615,20 @@ void LocalPlayer::updateChar()
|
|||
|
||||
void LocalPlayer::SetClass()
|
||||
{
|
||||
if (klass.mId.empty()) // custom class
|
||||
if (charClass.mId.empty()) // custom class
|
||||
{
|
||||
klass.mData.mIsPlayable = 0x1;
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass);
|
||||
MWBase::Environment::get().getWindowManager()->setPlayerClass(klass);
|
||||
charClass.mData.mIsPlayable = 0x1;
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(charClass);
|
||||
MWBase::Environment::get().getWindowManager()->setPlayerClass(charClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass.mId);
|
||||
const ESM::Class *_klass = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(klass.mId);
|
||||
if (_klass)
|
||||
MWBase::Environment::get().getWindowManager()->setPlayerClass(klass);
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(charClass.mId);
|
||||
|
||||
const ESM::Class *existingCharClass = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(charClass.mId);
|
||||
|
||||
if (existingCharClass)
|
||||
MWBase::Environment::get().getWindowManager()->setPlayerClass(charClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,13 +640,13 @@ void LocalPlayer::SendClass()
|
|||
|
||||
if (cpl->mClass.find("$dynamic") != string::npos) // custom class
|
||||
{
|
||||
klass.mId = "";
|
||||
klass.mName = cls->mName;
|
||||
klass.mDescription = cls->mDescription;
|
||||
klass.mData = cls->mData;
|
||||
charClass.mId = "";
|
||||
charClass.mName = cls->mName;
|
||||
charClass.mDescription = cls->mDescription;
|
||||
charClass.mData = cls->mData;
|
||||
}
|
||||
else
|
||||
klass.mId = cls->mId;
|
||||
charClass.mId = cls->mId;
|
||||
|
||||
GetNetworking()->GetPacket(ID_GAME_CHARCLASS)->Send(this);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace mwmp
|
|||
}
|
||||
RakNet::RakNetGUID guid;
|
||||
GUIMessageBox guiMessageBox;
|
||||
ESM::Class klass;
|
||||
ESM::Class charClass;
|
||||
int month;
|
||||
int day;
|
||||
double hour;
|
||||
|
|
|
@ -14,11 +14,11 @@ void mwmp::PacketClass::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player,
|
|||
{
|
||||
BasePacket::Packet(bs, player, send);
|
||||
|
||||
RW(player->klass.mId, send);
|
||||
if (player->klass.mId.empty()) // custom class
|
||||
RW(player->charClass.mId, send);
|
||||
if (player->charClass.mId.empty()) // custom class
|
||||
{
|
||||
RW(player->klass.mName, send);
|
||||
RW(player->klass.mDescription, send);
|
||||
RW(player->klass.mData, send);
|
||||
RW(player->charClass.mName, send);
|
||||
RW(player->charClass.mDescription, send);
|
||||
RW(player->charClass.mData, send);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue