Use lowerCamelCase in tes3mp client function names like OpenMW does

pull/112/merge
David Cernat 8 years ago
parent 527024a026
commit fa9d6e810e

@ -108,7 +108,7 @@ void OMW::Engine::frame(float frametime)
if (mUseSound) if (mUseSound)
mEnvironment.getSoundManager()->update(frametime); mEnvironment.getSoundManager()->update(frametime);
mwmp::Main::Frame(frametime); mwmp::Main::frame(frametime);
// Main menu opened? Then scripts are also paused. // Main menu opened? Then scripts are also paused.
bool paused = /*mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);*/ false; bool paused = /*mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);*/ false;
@ -240,10 +240,10 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
OMW::Engine::~Engine() OMW::Engine::~Engine()
{ {
mwmp::Main::get().getGUIController()->cleanup(); mwmp::Main::get().getGUIController()->cleanUp();
mEnvironment.cleanup(); mEnvironment.cleanup();
mwmp::Main::Destroy(); mwmp::Main::destroy();
delete mScriptContext; delete mScriptContext;
mScriptContext = NULL; mScriptContext = NULL;
@ -660,9 +660,9 @@ void OMW::Engine::go()
ToUTF8::Utf8Encoder encoder (mEncoding); ToUTF8::Utf8Encoder encoder (mEncoding);
mEncoder = &encoder; mEncoder = &encoder;
mwmp::Main::Init(mContentFiles); mwmp::Main::init(mContentFiles);
prepareEngine (settings); prepareEngine (settings);
mwmp::Main::PostInit(); mwmp::Main::postInit();
mSkipMenu = true; mSkipMenu = true;
if (!mSaveGameFile.empty()) if (!mSaveGameFile.empty())

@ -157,7 +157,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override"); ("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
mwmp::Main::OptionsDesc(&desc); mwmp::Main::optionsDesc(&desc);
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv) bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
.options(desc).allow_unregistered().run(); .options(desc).allow_unregistered().run();
@ -256,7 +256,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>()); engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
engine.enableFontExport(variables["export-fonts"].as<bool>()); engine.enableFontExport(variables["export-fonts"].as<bool>());
mwmp::Main::Configure(&variables); mwmp::Main::configure(&variables);
return true; return true;
} }

@ -596,17 +596,17 @@ namespace MWClass
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true; mwmp::Main::get().getLocalPlayer()->getAttack()->success = true;
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(victim); mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim);
if (dedicatedPlayer != nullptr) if (dedicatedPlayer != nullptr)
mwmp::Main::get().getLocalPlayer()->GetAttack()->target = dedicatedPlayer->guid; mwmp::Main::get().getLocalPlayer()->getAttack()->target = dedicatedPlayer->guid;
} }
if(Misc::Rng::roll0to99() >= hitchance) if(Misc::Rng::roll0to99() >= hitchance)
{ {
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{ {
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = false; mwmp::Main::get().getLocalPlayer()->getAttack()->success = false;
mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE);
} }
@ -734,11 +734,11 @@ namespace MWClass
float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified() float knockdownTerm = getCreatureStats(ptr).getAttribute(ESM::Attribute::Agility).getModified()
* gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt(); * gmst.iKnockDownOddsMult->getInt() * 0.01f + gmst.iKnockDownOddsBase->getInt();
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(attacker); mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(attacker);
bool isDedicated = dedicatedPlayer != nullptr; bool isDedicated = dedicatedPlayer != nullptr;
bool _knockdown = false; bool _knockdown = false;
if(isDedicated) if(isDedicated)
_knockdown = dedicatedPlayer->GetAttack()->knockdown; _knockdown = dedicatedPlayer->getAttack()->knockdown;
if ((!isDedicated && ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99()) || _knockdown) if ((!isDedicated && ishealth && agilityTerm <= damage && knockdownTerm <= Misc::Rng::roll0to99()) || _knockdown)
{ {
@ -845,10 +845,10 @@ namespace MWClass
} }
mwmp::DedicatedPlayer *victimPlayer = mwmp::Players::GetPlayer(ptr); mwmp::DedicatedPlayer *victimPlayer = mwmp::Players::getPlayer(ptr);
if (attacker == MWMechanics::getPlayer() && victimPlayer != nullptr) if (attacker == MWMechanics::getPlayer() && victimPlayer != nullptr)
{ {
mwmp::Attack *_atk = mwmp::Main::get().getLocalPlayer()->GetAttack(); mwmp::Attack *_atk = mwmp::Main::get().getLocalPlayer()->getAttack();
_atk->damage = damage; _atk->damage = damage;
_atk->attacker = mwmp::Main::get().getLocalPlayer()->guid; _atk->attacker = mwmp::Main::get().getLocalPlayer()->guid;
_atk->target = victimPlayer->guid; _atk->target = victimPlayer->guid;

@ -80,7 +80,7 @@ namespace MWGui
// Get the real count of gold in a stack // Get the real count of gold in a stack
event->cellRef.mGoldValue = dropped.getCellRef().getGoldValue(); event->cellRef.mGoldValue = dropped.getCellRef().getGoldValue();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_PLACE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event);
printf("Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i\n", printf("Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),

@ -638,7 +638,7 @@ namespace MWGui
event->cell = *object.getCell()->getCell(); event->cell = *object.getCell()->getCell();
event->cellRef.mRefID = object.getCellRef().getRefId(); event->cellRef.mRefID = object.getCellRef().getRefId();
event->cellRef.mRefNum = object.getCellRef().getRefNum(); event->cellRef.mRefNum = object.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event);
// remove from world // remove from world
MWBase::Environment::get().getWorld()->deleteObject (object); MWBase::Environment::get().getWorld()->deleteObject (object);

@ -664,7 +664,7 @@ namespace MWInput
void InputManager::keyPressed( const SDL_KeyboardEvent &arg ) void InputManager::keyPressed( const SDL_KeyboardEvent &arg )
{ {
mwmp::Main::PressedKey(arg.keysym.sym); mwmp::Main::pressedKey(arg.keysym.sym);
// HACK: to make Morrowind's default keybinding for the console work without printing an extra "^" upon closing // HACK: to make Morrowind's default keybinding for the console work without printing an extra "^" upon closing
// This assumes that SDL_TextInput events always come *after* the key event // This assumes that SDL_TextInput events always come *after* the key event
// (which is somewhat reasonable, and hopefully true for all SDL platforms) // (which is somewhat reasonable, and hopefully true for all SDL platforms)

@ -1041,7 +1041,7 @@ namespace MWMechanics
mwmp::Main::get().getLocalPlayer()->prepareAttack(mwmp::Attack::MELEE, state); mwmp::Main::get().getLocalPlayer()->prepareAttack(mwmp::Attack::MELEE, state);
} }
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(iter->first); mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(iter->first);
if (dedicatedPlayer != nullptr) if (dedicatedPlayer != nullptr)
dedicatedPlayer->updateActor(iter->second); dedicatedPlayer->updateActor(iter->second);

@ -116,16 +116,16 @@ namespace MWMechanics
x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x)); x = std::min(iBlockMaxChance, std::max(iBlockMinChance, x));
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(blocker); mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(blocker);
bool isDedicated = dedicatedPlayer != nullptr; bool isDedicated = dedicatedPlayer != nullptr;
if (attacker == MWMechanics::getPlayer()) if (attacker == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = false; mwmp::Main::get().getLocalPlayer()->getAttack()->block = false;
if ((!isDedicated && Misc::Rng::roll0to99() < x) || if ((!isDedicated && Misc::Rng::roll0to99() < x) ||
(isDedicated && dedicatedPlayer->GetAttack()->block == 1)) (isDedicated && dedicatedPlayer->getAttack()->block == 1))
{ {
if (attacker == MWMechanics::getPlayer()) if (attacker == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = true; mwmp::Main::get().getLocalPlayer()->getAttack()->block = true;
// Reduce shield durability by incoming damage // Reduce shield durability by incoming damage
int shieldhealth = shield->getClass().getItemHealth(*shield); int shieldhealth = shield->getClass().getItemHealth(*shield);
@ -204,12 +204,12 @@ namespace MWMechanics
weapon.getClass().getEquipmentSkill(weapon)); weapon.getClass().getEquipmentSkill(weapon));
if (attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) if (attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true; mwmp::Main::get().getLocalPlayer()->getAttack()->success = true;
if (Misc::Rng::roll0to99() >= getHitChance(attacker, victim, skillValue)) if (Misc::Rng::roll0to99() >= getHitChance(attacker, victim, skillValue))
{ {
if (attacker == getPlayer()) if (attacker == getPlayer())
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = false; mwmp::Main::get().getLocalPlayer()->getAttack()->success = false;
victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, osg::Vec3f(), false); victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, osg::Vec3f(), false);
MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker); MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker);
return; return;

@ -62,7 +62,7 @@ namespace MWMechanics
event->cell = *lock.getCell()->getCell(); event->cell = *lock.getCell()->getCell();
event->cellRef.mRefID = lock.getCellRef().getRefId(); event->cellRef.mRefID = lock.getCellRef().getRefId();
event->cellRef.mRefNum = lock.getCellRef().getRefNum(); event->cellRef.mRefNum = lock.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_UNLOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event);
lock.getClass().unlock(lock); lock.getClass().unlock(lock);
resultMessage = "#{sLockSuccess}"; resultMessage = "#{sLockSuccess}";

@ -797,14 +797,14 @@ namespace MWMechanics
// Check success // Check success
float successChance = getSpellSuccessChance(spell, mCaster); float successChance = getSpellSuccessChance(spell, mCaster);
mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::GetPlayer(mCaster); mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(mCaster);
bool isDedicated = dedicatedPlayer != nullptr; bool isDedicated = dedicatedPlayer != nullptr;
if (isDedicated) if (isDedicated)
dedicatedPlayer->GetAttack()->pressed = false; dedicatedPlayer->getAttack()->pressed = false;
if ((!isDedicated && !mwmp::Main::get().getLocalPlayer()->GetAttack()->success) || if ((!isDedicated && !mwmp::Main::get().getLocalPlayer()->getAttack()->success) ||
(isDedicated && dedicatedPlayer->GetAttack()->success == 0)) (isDedicated && dedicatedPlayer->getAttack()->success == 0))
{ {
if (mCaster == getPlayer()) if (mCaster == getPlayer())
{ {

@ -29,7 +29,7 @@ std::map<uint64_t, DedicatedPlayer *> Players::players;
DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid) DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid)
{ {
GetAttack()->pressed = 0; getAttack()->pressed = 0;
CreatureStats()->mDead = false; CreatureStats()->mDead = false;
movementFlags = 0; movementFlags = 0;
} }
@ -43,7 +43,7 @@ MWWorld::Ptr DedicatedPlayer::getPtr()
return ptr; return ptr;
} }
void Players::CreatePlayer(RakNet::RakNetGUID guid) void Players::createPlayer(RakNet::RakNetGUID guid)
{ {
LOG_APPEND(Log::LOG_INFO, "%s", "- Setting up character info"); LOG_APPEND(Log::LOG_INFO, "%s", "- Setting up character info");
@ -93,7 +93,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID guid)
dedicPlayer->Npc()->mName.c_str()); dedicPlayer->Npc()->mName.c_str());
dedicPlayer->ptr.getBase()->canChangeCell = true; dedicPlayer->ptr.getBase()->canChangeCell = true;
dedicPlayer->UpdatePtr(world->moveObject(dedicPlayer->ptr, cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2])); dedicPlayer->updatePtr(world->moveObject(dedicPlayer->ptr, cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2]));
npc.mId = players[guid.g]->ptr.get<ESM::NPC>()->mBase->mId; npc.mId = players[guid.g]->ptr.get<ESM::NPC>()->mBase->mId;
@ -116,13 +116,13 @@ void Players::CreatePlayer(RakNet::RakNetGUID guid)
} }
void Players::CleanUp() void Players::cleanUp()
{ {
for (std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++) for (std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
delete it->second; delete it->second;
} }
void Players::DisconnectPlayer(RakNet::RakNetGUID guid) void Players::disconnectPlayer(RakNet::RakNetGUID guid)
{ {
if (players[guid.g]->state > 1) if (players[guid.g]->state > 1)
{ {
@ -144,7 +144,7 @@ void Players::DisconnectPlayer(RakNet::RakNetGUID guid)
} }
} }
DedicatedPlayer *Players::GetPlayer(RakNet::RakNetGUID guid) DedicatedPlayer *Players::getPlayer(RakNet::RakNetGUID guid)
{ {
return players[guid.g]; return players[guid.g];
} }
@ -195,7 +195,7 @@ osg::Vec3f Lerp(osg::Vec3f start, osg::Vec3f end, float percent)
return (start + osg::componentMultiply(p, (end - start))); return (start + osg::componentMultiply(p, (end - start)));
} }
void DedicatedPlayer::Move(float dt) void DedicatedPlayer::move(float dt)
{ {
if (state != 2) return; if (state != 2) return;
@ -219,7 +219,7 @@ void DedicatedPlayer::Move(float dt)
world->rotateObject(ptr, pos.rot[0], pos.rot[1], pos.rot[2]); world->rotateObject(ptr, pos.rot[0], pos.rot[1], pos.rot[2]);
} }
void Players::Update(float dt) void Players::update(float dt)
{ {
for (std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++) for (std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
{ {
@ -259,12 +259,12 @@ void Players::Update(float dt)
ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0); ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
ptrNpcStats->setBaseDisposition(255); ptrNpcStats->setBaseDisposition(255);
pl->Move(dt); pl->move(dt);
pl->UpdateDrawState(); pl->updateDrawState();
} }
} }
void DedicatedPlayer::UpdatePtr(MWWorld::Ptr newPtr) void DedicatedPlayer::updatePtr(MWWorld::Ptr newPtr)
{ {
ptr.mCell = newPtr.mCell; ptr.mCell = newPtr.mCell;
ptr.mRef = newPtr.mRef; ptr.mRef = newPtr.mRef;
@ -276,7 +276,7 @@ void DedicatedPlayer::UpdatePtr(MWWorld::Ptr newPtr)
} }
DedicatedPlayer *Players::NewPlayer(RakNet::RakNetGUID guid) DedicatedPlayer *Players::newPlayer(RakNet::RakNetGUID guid)
{ {
LOG_APPEND(Log::LOG_INFO, "- Creating new DedicatedPlayer with guid %lu", LOG_APPEND(Log::LOG_INFO, "- Creating new DedicatedPlayer with guid %lu",
guid.g); guid.g);
@ -286,7 +286,7 @@ DedicatedPlayer *Players::NewPlayer(RakNet::RakNetGUID guid)
return players[guid.g]; return players[guid.g];
} }
void DedicatedPlayer::UpdateInventory() void DedicatedPlayer::updateInventory()
{ {
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr); MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
@ -326,7 +326,7 @@ void DedicatedPlayer::UpdateInventory()
} }
} }
const std::string DedicatedPlayer::GetAnim() const std::string DedicatedPlayer::getAnim()
{ {
static string anim; static string anim;
static string animDir; static string animDir;
@ -394,7 +394,7 @@ const std::string DedicatedPlayer::GetAnim()
return (anim + animDir + animWeap); return (anim + animDir + animWeap);
} }
DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr) DedicatedPlayer *Players::getPlayer(const MWWorld::Ptr &ptr)
{ {
std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin(); std::map <uint64_t, DedicatedPlayer *>::iterator it = players.begin();
@ -409,7 +409,7 @@ DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr)
return 0; return 0;
} }
void DedicatedPlayer::UpdateDrawState() void DedicatedPlayer::updateDrawState()
{ {
using namespace MWMechanics; using namespace MWMechanics;
@ -461,7 +461,7 @@ void DedicatedPlayer::updateCell()
// Allow this player's reference to move across a cell now that a manual cell // Allow this player's reference to move across a cell now that a manual cell
// update has been called // update has been called
ptr.getBase()->canChangeCell = true; ptr.getBase()->canChangeCell = true;
UpdatePtr(world->moveObject(ptr, cellStore, pos.pos[0], pos.pos[1], pos.pos[2])); updatePtr(world->moveObject(ptr, cellStore, pos.pos[0], pos.pos[1], pos.pos[2]));
} }
@ -504,5 +504,5 @@ void DedicatedPlayer::setMarkerState(bool state)
void DedicatedPlayer::updateActor(MWMechanics::Actor *actor) void DedicatedPlayer::updateActor(MWMechanics::Actor *actor)
{ {
actor->getCharacterController()->setAttackingOrSpell(GetAttack()->pressed); actor->getCharacterController()->setAttackingOrSpell(getAttack()->pressed);
} }

@ -26,13 +26,13 @@ namespace mwmp
class Players class Players
{ {
public: public:
static DedicatedPlayer *NewPlayer(RakNet::RakNetGUID guid); static DedicatedPlayer *newPlayer(RakNet::RakNetGUID guid);
static void CreatePlayer(RakNet::RakNetGUID guid); static void createPlayer(RakNet::RakNetGUID guid);
static void DisconnectPlayer(RakNet::RakNetGUID guid); static void disconnectPlayer(RakNet::RakNetGUID guid);
static void CleanUp(); static void cleanUp();
static DedicatedPlayer *GetPlayer(RakNet::RakNetGUID guid); static DedicatedPlayer *getPlayer(RakNet::RakNetGUID guid);
static DedicatedPlayer *GetPlayer(const MWWorld::Ptr &ptr); static DedicatedPlayer *getPlayer(const MWWorld::Ptr &ptr);
static void Update(float dt); static void update(float dt);
private: private:
static std::map<uint64_t, DedicatedPlayer *> players; static std::map<uint64_t, DedicatedPlayer *> players;
}; };
@ -45,9 +45,9 @@ namespace mwmp
MWWorld::Ptr getPtr(); MWWorld::Ptr getPtr();
MWWorld::Ptr getLiveCellPtr(); MWWorld::Ptr getLiveCellPtr();
MWWorld::ManualRef* getRef(); MWWorld::ManualRef* getRef();
void Move(float dt); void move(float dt);
void UpdateDrawState(); void updateDrawState();
void UpdateInventory(); void updateInventory();
void updateCell(); void updateCell();
@ -58,8 +58,8 @@ namespace mwmp
private: private:
DedicatedPlayer(RakNet::RakNetGUID guid); DedicatedPlayer(RakNet::RakNetGUID guid);
virtual ~DedicatedPlayer(); virtual ~DedicatedPlayer();
void UpdatePtr(MWWorld::Ptr newPtr); void updatePtr(MWWorld::Ptr newPtr);
const std::string GetAnim(); const std::string getAnim();
int state; int state;
MWWorld::ManualRef* reference; MWWorld::ManualRef* reference;

@ -130,8 +130,8 @@ namespace mwmp
*localPlayer->ChatMessage() = str; *localPlayer->ChatMessage() = str;
RakNet::BitStream bs; RakNet::BitStream bs;
networking->GetPlayerPacket(ID_CHAT_MESSAGE)->Packet(&bs, localPlayer, true); networking->getPlayerPacket(ID_CHAT_MESSAGE)->Packet(&bs, localPlayer, true);
networking->SendData(&bs); networking->sendData(&bs);
} }
void GUIChat::clean() void GUIChat::clean()
@ -139,7 +139,7 @@ namespace mwmp
mHistory->clearUserStrings(); mHistory->clearUserStrings();
} }
void GUIChat::PressedChatMode() void GUIChat::pressedChatMode()
{ {
windowState++; windowState++;
if (windowState == 3) windowState = 0; if (windowState == 3) windowState = 0;
@ -169,7 +169,7 @@ namespace mwmp
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(editState ? mCommandLine : nullptr); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(editState ? mCommandLine : nullptr);
} }
void GUIChat::PressedSay() void GUIChat::pressedSay()
{ {
if (windowState == CHAT_DISABLED) if (windowState == CHAT_DISABLED)
return; return;
@ -232,7 +232,7 @@ namespace mwmp
} }
} }
void GUIChat::SetDelay(float delay) void GUIChat::setDelay(float delay)
{ {
this->delay = delay; this->delay = delay;
} }

@ -46,9 +46,9 @@ namespace mwmp
GUIChat(int x, int y, int w, int h); GUIChat(int x, int y, int w, int h);
void PressedChatMode(); //switch chat mode void pressedChatMode(); //switch chat mode
void PressedSay(); // switch chat focus (if chat mode != CHAT_DISABLED) void pressedSay(); // switch chat focus (if chat mode != CHAT_DISABLED)
void SetDelay(float delay); void setDelay(float delay);
void Update(float dt); void Update(float dt);

@ -45,7 +45,7 @@ mwmp::GUIController::~GUIController()
} }
void mwmp::GUIController::cleanup() void mwmp::GUIController::cleanUp()
{ {
mPlayerMarkers.clear(); mPlayerMarkers.clear();
if (mChat != nullptr) if (mChat != nullptr)
@ -67,10 +67,10 @@ void mwmp::GUIController::setupChat(const Settings::Manager &mgr)
keyChatMode = SDL_GetKeyFromName(mgr.getString("keyChatMode", "Chat").c_str()); keyChatMode = SDL_GetKeyFromName(mgr.getString("keyChatMode", "Chat").c_str());
mChat = new GUIChat(chatX, chatY, chatW, chatH); mChat = new GUIChat(chatX, chatY, chatW, chatH);
mChat->SetDelay(chatDelay); mChat->setDelay(chatDelay);
} }
void mwmp::GUIController::PrintChatMessage(std::string &msg) void mwmp::GUIController::printChatMessage(std::string &msg)
{ {
if (mChat != nullptr) if (mChat != nullptr)
mChat->print(msg); mChat->print(msg);
@ -82,7 +82,7 @@ void mwmp::GUIController::setChatVisible(bool chatVisible)
mChat->setVisible(chatVisible); mChat->setVisible(chatVisible);
} }
void mwmp::GUIController::ShowDialogList(const mwmp::BasePlayer::GUIMessageBox &guiMessageBox) void mwmp::GUIController::showDialogList(const mwmp::BasePlayer::GUIMessageBox &guiMessageBox)
{ {
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
windowManager->removeDialog(mListBox); windowManager->removeDialog(mListBox);
@ -109,7 +109,7 @@ void mwmp::GUIController::ShowDialogList(const mwmp::BasePlayer::GUIMessageBox &
windowManager->pushGuiMode((MWGui::GuiMode)GM_TES3MP_ListBox); windowManager->pushGuiMode((MWGui::GuiMode)GM_TES3MP_ListBox);
} }
void mwmp::GUIController::ShowMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox) void mwmp::GUIController::showMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox)
{ {
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
std::vector<std::string> buttons; std::vector<std::string> buttons;
@ -128,7 +128,7 @@ std::vector<std::string> splitString(const std::string &str, char delim = ';')
return result; return result;
} }
void mwmp::GUIController::ShowCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox) void mwmp::GUIController::showCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox)
{ {
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
std::vector<std::string> buttons = splitString(guiMessageBox.buttons); std::vector<std::string> buttons = splitString(guiMessageBox.buttons);
@ -136,7 +136,7 @@ void mwmp::GUIController::ShowCustomMessageBox(const BasePlayer::GUIMessageBox &
calledMessageBox = true; calledMessageBox = true;
} }
void mwmp::GUIController::ShowInputBox(const BasePlayer::GUIMessageBox &guiMessageBox) void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessageBox)
{ {
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
@ -145,17 +145,17 @@ void mwmp::GUIController::ShowInputBox(const BasePlayer::GUIMessageBox &guiMessa
mInputBox = 0; mInputBox = 0;
mInputBox = new MWGui::TextInputDialog(); mInputBox = new MWGui::TextInputDialog();
mInputBox->setTextLabel(guiMessageBox.label); mInputBox->setTextLabel(guiMessageBox.label);
mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::OnInputBoxDone); mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::onInputBoxDone);
} }
void mwmp::GUIController::OnInputBoxDone(MWGui::WindowBase *parWindow) void mwmp::GUIController::onInputBoxDone(MWGui::WindowBase *parWindow)
{ {
//MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); //MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
printf("GUIController::OnInputBoxDone: %s.\n",mInputBox->getTextInput().c_str()); printf("GUIController::OnInputBoxDone: %s.\n",mInputBox->getTextInput().c_str());
Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput(); Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput();
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox); MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox);
mInputBox = 0; mInputBox = 0;
@ -169,18 +169,18 @@ bool mwmp::GUIController::pressedKey(int key)
return false; return false;
if (key == keyChatMode) if (key == keyChatMode)
{ {
mChat->PressedChatMode(); mChat->pressedChatMode();
return true; return true;
} }
else if (key == keySay) else if (key == keySay)
{ {
mChat->PressedSay(); mChat->pressedSay();
return true; return true;
} }
return false; return false;
} }
bool mwmp::GUIController::HaveFocusedElement() bool mwmp::GUIController::hasFocusedElement()
{ {
return false; return false;
} }
@ -197,7 +197,7 @@ void mwmp::GUIController::update(float dt)
printf("Pressed: %d\n", pressedButton); printf("Pressed: %d\n", pressedButton);
calledMessageBox = false; calledMessageBox = false;
Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton); Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton);
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
} }
blockConsole(); blockConsole();
@ -258,7 +258,7 @@ private:
ESM::CustomMarker mwmp::GUIController::CreateMarker(const RakNet::RakNetGUID &guid) ESM::CustomMarker mwmp::GUIController::CreateMarker(const RakNet::RakNetGUID &guid)
{ {
DedicatedPlayer *player = Players::GetPlayer(guid); DedicatedPlayer *player = Players::getPlayer(guid);
ESM::CustomMarker mEditingMarker; ESM::CustomMarker mEditingMarker;
if (!player) if (!player)
{ {

@ -32,20 +32,20 @@ namespace mwmp
}; };
GUIController(); GUIController();
~GUIController(); ~GUIController();
void cleanup(); void cleanUp();
void setupChat(const Settings::Manager &manager); void setupChat(const Settings::Manager &manager);
void PrintChatMessage(std::string &msg); void printChatMessage(std::string &msg);
void setChatVisible(bool chatVisible); void setChatVisible(bool chatVisible);
void ShowMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox); void showMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox);
void ShowCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox); void showCustomMessageBox(const BasePlayer::GUIMessageBox &guiMessageBox);
void ShowInputBox(const BasePlayer::GUIMessageBox &guiMessageBox); void showInputBox(const BasePlayer::GUIMessageBox &guiMessageBox);
void ShowDialogList(const BasePlayer::GUIMessageBox &guiMessageBox); void showDialogList(const BasePlayer::GUIMessageBox &guiMessageBox);
/// Return true if any tes3mp gui element in active state /// Return true if any tes3mp gui element in active state
bool HaveFocusedElement(); bool hasFocusedElement();
/// Returns 0 if there was no events /// Returns 0 if there was no events
bool pressedKey(int key); bool pressedKey(int key);
@ -70,7 +70,7 @@ namespace mwmp
bool calledMessageBox; bool calledMessageBox;
MWGui::TextInputDialog *mInputBox; MWGui::TextInputDialog *mInputBox;
GUIDialogList *mListBox; GUIDialogList *mListBox;
void OnInputBoxDone(MWGui::WindowBase* parWindow); void onInputBoxDone(MWGui::WindowBase* parWindow);
//MyGUI::Widget *oldFocusWidget, *currentFocusWidget; //MyGUI::Widget *oldFocusWidget, *currentFocusWidget;
void blockConsole(); void blockConsole();
}; };

@ -37,7 +37,7 @@ void GUIDialogList::mousePressed(MyGUI::Widget * /*widget*/)
size_t id = mListBox->getIndexSelected(); size_t id = mListBox->getIndexSelected();
Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(id); Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(id);
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer()); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id);
if(id == MyGUI::ITEM_NONE) if(id == MyGUI::ITEM_NONE)

@ -44,17 +44,17 @@ LocalPlayer::~LocalPlayer()
} }
Networking *LocalPlayer::GetNetworking() Networking *LocalPlayer::getNetworking()
{ {
return mwmp::Main::get().getNetworking(); return mwmp::Main::get().getNetworking();
} }
MWWorld::Ptr LocalPlayer::GetPlayerPtr() MWWorld::Ptr LocalPlayer::getPlayerPtr()
{ {
return MWBase::Environment::get().getWorld()->getPlayerPtr(); return MWBase::Environment::get().getWorld()->getPlayerPtr();
} }
void LocalPlayer::Update() void LocalPlayer::update()
{ {
updateCell(); updateCell();
updatePosition(); updatePosition();
@ -106,7 +106,7 @@ bool LocalPlayer::charGenThread()
windowManager->pushGuiMode(MWGui::GM_Review); windowManager->pushGuiMode(MWGui::GM_Review);
break; break;
} }
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_CHARGEN)->Send(this);
CharGenStage()->current++; CharGenStage()->current++;
return false; return false;
@ -122,7 +122,7 @@ bool LocalPlayer::charGenThread()
(*BirthSign()) = world->getPlayer().getBirthSign(); (*BirthSign()) = world->getPlayer().getBirthSign();
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server with my CharGen info"); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server with my CharGen info");
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_BASE_INFO)->Send(this);
// Send stats packets if this is the 2nd round of CharGen that // Send stats packets if this is the 2nd round of CharGen that
// only happens for new characters // only happens for new characters
@ -133,7 +133,7 @@ bool LocalPlayer::charGenThread()
updateSkills(true); updateSkills(true);
updateLevel(true); updateLevel(true);
sendClass(); sendClass();
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_CHARGEN)->Send(this);
} }
// Set the last stage variable to 0 to indicate that CharGen is finished // Set the last stage variable to 0 to indicate that CharGen is finished
@ -145,7 +145,7 @@ bool LocalPlayer::charGenThread()
void LocalPlayer::updateDynamicStats(bool forceUpdate) void LocalPlayer::updateDynamicStats(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player); MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player);
MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth()); MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth());
@ -172,14 +172,14 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate)
timer = 0; timer = 0;
GetNetworking()->GetPlayerPacket(ID_GAME_DYNAMICSTATS)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_DYNAMICSTATS)->Send(this);
} }
} }
} }
void LocalPlayer::updateAttributes(bool forceUpdate) void LocalPlayer::updateAttributes(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
bool isUpdating = false; bool isUpdating = false;
@ -194,13 +194,13 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
if (isUpdating || forceUpdate) if (isUpdating || forceUpdate)
{ {
GetNetworking()->GetPlayerPacket(ID_GAME_ATTRIBUTE)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_ATTRIBUTE)->Send(this);
} }
} }
void LocalPlayer::updateSkills(bool forceUpdate) void LocalPlayer::updateSkills(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
bool isUpdating = false; bool isUpdating = false;
@ -230,19 +230,19 @@ void LocalPlayer::updateSkills(bool forceUpdate)
if (isUpdating || forceUpdate) if (isUpdating || forceUpdate)
{ {
NpcStats()->mLevelProgress = ptrNpcStats.getLevelProgress(); NpcStats()->mLevelProgress = ptrNpcStats.getLevelProgress();
GetNetworking()->GetPlayerPacket(ID_GAME_SKILL)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_SKILL)->Send(this);
} }
} }
void LocalPlayer::updateLevel(bool forceUpdate) void LocalPlayer::updateLevel(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player);
if (ptrNpcStats.getLevel() != CreatureStats()->mLevel || forceUpdate) if (ptrNpcStats.getLevel() != CreatureStats()->mLevel || forceUpdate)
{ {
CreatureStats()->mLevel = ptrNpcStats.getLevel(); CreatureStats()->mLevel = ptrNpcStats.getLevel();
GetNetworking()->GetPlayerPacket(ID_GAME_LEVEL)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_LEVEL)->Send(this);
// Also update skills to refresh level progress and attribute bonuses // Also update skills to refresh level progress and attribute bonuses
// for next level up // for next level up
@ -282,7 +282,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
Dir()->pos[1] = move.mPosition[1]; Dir()->pos[1] = move.mPosition[1];
Dir()->pos[2] = move.mPosition[2]; Dir()->pos[2] = move.mPosition[2];
GetNetworking()->GetPlayerPacket(ID_GAME_POS)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_POS)->Send(this);
} }
else if (isJumping && world->isOnGround(player)) else if (isJumping && world->isOnGround(player))
{ {
@ -294,7 +294,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
{ {
sentJumpEnd = true; sentJumpEnd = true;
(*Position()) = ptrPos; (*Position()) = ptrPos;
GetNetworking()->GetPlayerPacket(ID_GAME_POS)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_POS)->Send(this);
} }
} }
@ -343,8 +343,8 @@ void LocalPlayer::updateCell(bool forceUpdate)
updatePosition(true); updatePosition(true);
RakNet::BitStream bs; RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_CELL)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_CELL)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
// Also update skill progress // Also update skill progress
updateSkills(true); updateSkills(true);
@ -367,7 +367,7 @@ void LocalPlayer::updateChar()
void LocalPlayer::updateEquipped(bool forceUpdate) void LocalPlayer::updateEquipped(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
static bool equipChanged = false; static bool equipChanged = false;
@ -407,8 +407,8 @@ void LocalPlayer::updateEquipped(bool forceUpdate)
{ {
RakNet::BitStream bs; RakNet::BitStream bs;
bs.ResetWritePointer(); bs.ResetWritePointer();
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_EQUIPMENT)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_EQUIPMENT)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
equipChanged = false; equipChanged = false;
} }
} }
@ -419,7 +419,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
if (forceUpdate) if (forceUpdate)
invChanged = true; invChanged = true;
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player); MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
mwmp::Item item; mwmp::Item item;
@ -490,13 +490,13 @@ void LocalPlayer::updateInventory(bool forceUpdate)
inventory.count = (unsigned int) inventory.items.size(); inventory.count = (unsigned int) inventory.items.size();
inventory.action = Inventory::UPDATE; inventory.action = Inventory::UPDATE;
Main::get().getNetworking()->GetPlayerPacket(ID_GAME_INVENTORY)->Send(this); Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
} }
void LocalPlayer::updateAttackState(bool forceUpdate) void LocalPlayer::updateAttackState(bool forceUpdate)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
using namespace MWMechanics; using namespace MWMechanics;
@ -511,14 +511,14 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
{ {
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
GetAttack()->attacker = guid; getAttack()->attacker = guid;
GetAttack()->type = Attack::MAGIC; getAttack()->type = Attack::MAGIC;
GetAttack()->pressed = true; getAttack()->pressed = true;
GetAttack()->refid = spell; getAttack()->refid = spell;
/*RakNet::BitStream bs; /*RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);*/ getNetworking()->SendData(&bs);*/
} }
else if (state == MWMechanics::DrawState_Weapon) else if (state == MWMechanics::DrawState_Weapon)
{ {
@ -530,7 +530,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
{ {
if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon) if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
{ {
//localNetPlayer->GetAttack()->success = false; //localNetPlayer->getAttack()->success = false;
//SendAttack(0); //SendAttack(0);
} }
attackPressed = false; attackPressed = false;
@ -539,7 +539,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
void LocalPlayer::updateDeadState(bool forceUpdate) void LocalPlayer::updateDeadState(bool forceUpdate)
{ {
MWWorld::Ptr player = GetPlayerPtr(); MWWorld::Ptr player = getPlayerPtr();
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player); MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player);
static bool isDead = false; static bool isDead = false;
@ -548,8 +548,8 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
{ {
CreatureStats()->mDead = true; CreatureStats()->mDead = true;
RakNet::BitStream bs; RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID)ID_GAME_DIE)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID)ID_GAME_DIE)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
isDead = true; isDead = true;
} }
else if (ptrNpcStats->getHealth().getCurrent() > 0 && isDead) else if (ptrNpcStats->getHealth().getCurrent() > 0 && isDead)
@ -615,8 +615,8 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump; mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump;
RakNet::BitStream bs; RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_DRAWSTATE)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_DRAWSTATE)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
//timer = 0; //timer = 0;
} }
} }
@ -771,7 +771,7 @@ void LocalPlayer::setClass()
void LocalPlayer::setInventory() void LocalPlayer::setInventory()
{ {
MWWorld::Ptr ptrPlayer = GetPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer); MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
@ -811,48 +811,48 @@ void LocalPlayer::sendClass()
else else
charClass.mId = cls->mId; charClass.mId = cls->mId;
GetNetworking()->GetPlayerPacket(ID_GAME_CHARCLASS)->Send(this); getNetworking()->getPlayerPacket(ID_GAME_CHARCLASS)->Send(this);
} }
void LocalPlayer::sendAttack(Attack::TYPE type) void LocalPlayer::sendAttack(Attack::TYPE type)
{ {
MWMechanics::DrawState_ state = GetPlayerPtr().getClass().getNpcStats(GetPlayerPtr()).getDrawState(); MWMechanics::DrawState_ state = getPlayerPtr().getClass().getNpcStats(getPlayerPtr()).getDrawState();
GetAttack()->type = type; getAttack()->type = type;
GetAttack()->pressed = false; getAttack()->pressed = false;
RakNet::BitStream bs; RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
} }
void LocalPlayer::prepareAttack(Attack::TYPE type, bool state) void LocalPlayer::prepareAttack(Attack::TYPE type, bool state)
{ {
if (GetAttack()->pressed == state && type != Attack::MAGIC) if (getAttack()->pressed == state && type != Attack::MAGIC)
return; return;
MWMechanics::DrawState_ dstate = GetPlayerPtr().getClass().getNpcStats(GetPlayerPtr()).getDrawState(); MWMechanics::DrawState_ dstate = getPlayerPtr().getClass().getNpcStats(getPlayerPtr()).getDrawState();
if (dstate == MWMechanics::DrawState_Spell) if (dstate == MWMechanics::DrawState_Spell)
{ {
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
GetAttack()->success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, GetPlayerPtr()); getAttack()->success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, getPlayerPtr());
state = true; state = true;
GetAttack()->refid = spell; getAttack()->refid = spell;
} }
else else
{ {
GetAttack()->success = false; getAttack()->success = false;
} }
GetAttack()->pressed = state; getAttack()->pressed = state;
GetAttack()->type = type; getAttack()->type = type;
GetAttack()->knockdown = false; getAttack()->knockdown = false;
GetAttack()->block = false; getAttack()->block = false;
GetAttack()->target = RakNet::RakNetGUID(); getAttack()->target = RakNet::RakNetGUID();
GetAttack()->attacker = guid; getAttack()->attacker = guid;
RakNet::BitStream bs; RakNet::BitStream bs;
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true); getNetworking()->getPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs); getNetworking()->sendData(&bs);
} }

@ -18,7 +18,7 @@ namespace mwmp
LocalPlayer(); LocalPlayer();
virtual ~LocalPlayer(); virtual ~LocalPlayer();
void Update(); void update();
void charGen(int stageFirst, int stageEnd); void charGen(int stageFirst, int stageEnd);
bool charGenThread(); // return true if CGStage::current == CGStage::end bool charGenThread(); // return true if CGStage::current == CGStage::end
@ -53,8 +53,8 @@ namespace mwmp
private: private:
Networking *GetNetworking(); Networking *getNetworking();
MWWorld::Ptr GetPlayerPtr(); MWWorld::Ptr getPlayerPtr();
}; };
} }

@ -76,17 +76,17 @@ Main::~Main()
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "tes3mp stopped"); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "tes3mp stopped");
delete mNetworking; delete mNetworking;
delete mLocalPlayer; delete mLocalPlayer;
Players::CleanUp(); Players::cleanUp();
} }
void Main::OptionsDesc(boost::program_options::options_description *desc) void Main::optionsDesc(boost::program_options::options_description *desc)
{ {
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
desc->add_options()("connect", bpo::value<std::string>()->default_value(""), desc->add_options()("connect", bpo::value<std::string>()->default_value(""),
"connect to server (e.g. --connect=127.0.0.1:25565)"); "connect to server (e.g. --connect=127.0.0.1:25565)");
} }
void Main::Configure(const boost::program_options::variables_map &variables) void Main::configure(const boost::program_options::variables_map &variables)
{ {
Main::addr = variables["connect"].as<string>(); Main::addr = variables["connect"].as<string>();
} }
@ -113,7 +113,7 @@ void RestoreMgr(Settings::Manager &mgr)
mgr.mChangedSettings = saveChangedSettings; mgr.mChangedSettings = saveChangedSettings;
} }
void Main::Init(std::vector<std::string> &content) void Main::init(std::vector<std::string> &content)
{ {
assert(!pMain); assert(!pMain);
pMain = new Main(); pMain = new Main();
@ -136,11 +136,11 @@ void Main::Init(std::vector<std::string> &content)
} }
pMain->mNetworking->Connect(pMain->server, pMain->port); pMain->mNetworking->connect(pMain->server, pMain->port);
RestoreMgr(mgr); RestoreMgr(mgr);
} }
void Main::PostInit() void Main::postInit()
{ {
Settings::Manager mgr; Settings::Manager mgr;
InitMgr(mgr); InitMgr(mgr);
@ -153,7 +153,7 @@ void Main::PostInit()
MWBase::Environment::get().getMechanicsManager()->toggleAI(); MWBase::Environment::get().getMechanicsManager()->toggleAI();
} }
void Main::Destroy() void Main::destroy()
{ {
assert(pMain); assert(pMain);
@ -161,20 +161,20 @@ void Main::Destroy()
pMain = 0; pMain = 0;
} }
void Main::Frame(float dt) void Main::frame(float dt)
{ {
const MWBase::Environment &environment = MWBase::Environment::get(); const MWBase::Environment &environment = MWBase::Environment::get();
get().getNetworking()->Update(); get().getNetworking()->update();
Players::Update(dt); Players::update(dt);
get().UpdateWorld(dt); get().updateWorld(dt);
get().getGUIController()->update(dt); get().getGUIController()->update(dt);
} }
void Main::UpdateWorld(float dt) const void Main::updateWorld(float dt) const
{ {
if (!mLocalPlayer->charGenThread()) if (!mLocalPlayer->charGenThread())
@ -186,13 +186,13 @@ void Main::UpdateWorld(float dt) const
init = false; init = false;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server"); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server");
mNetworking->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(getLocalPlayer()); mNetworking->getPlayerPacket(ID_GAME_BASE_INFO)->Send(getLocalPlayer());
mNetworking->GetPlayerPacket(ID_LOADED)->Send(getLocalPlayer()); mNetworking->getPlayerPacket(ID_LOADED)->Send(getLocalPlayer());
mLocalPlayer->updateDynamicStats(true); mLocalPlayer->updateDynamicStats(true);
get().getGUIController()->setChatVisible(true); get().getGUIController()->setChatVisible(true);
} }
else else
mLocalPlayer->Update(); mLocalPlayer->update();
} }
const Main &Main::get() const Main &Main::get()
@ -221,7 +221,7 @@ WorldController *Main::getWorldController() const
return mWorldController; return mWorldController;
} }
void Main::PressedKey(int key) void Main::pressedKey(int key)
{ {
if (pMain == nullptr) return; if (pMain == nullptr) return;
if (get().getGUIController()->pressedKey(key)) if (get().getGUIController()->pressedKey(key))

@ -13,14 +13,14 @@ namespace mwmp
Main(); Main();
~Main(); ~Main();
static void OptionsDesc(boost::program_options::options_description *desc); static void optionsDesc(boost::program_options::options_description *desc);
static void Configure(const boost::program_options::variables_map &variables); static void configure(const boost::program_options::variables_map &variables);
static void Init(std::vector<std::string> &content); static void init(std::vector<std::string> &content);
static void PostInit(); static void postInit();
static void Destroy(); static void destroy();
static const Main &get(); static const Main &get();
static void Frame(float dt); static void frame(float dt);
static void PressedKey(int key); static void pressedKey(int key);
static bool isValidPacketScript(std::string script); static bool isValidPacketScript(std::string script);
@ -29,7 +29,7 @@ namespace mwmp
GUIController *getGUIController() const; GUIController *getGUIController() const;
WorldController *getWorldController() const; WorldController *getWorldController() const;
void UpdateWorld(float dt) const; void updateWorld(float dt) const;
private: private:
static std::string addr; static std::string addr;

@ -53,7 +53,7 @@ Networking::~Networking()
RakNet::RakPeerInterface::DestroyInstance(peer); RakNet::RakPeerInterface::DestroyInstance(peer);
} }
void Networking::Update() void Networking::update()
{ {
RakNet::Packet *packet; RakNet::Packet *packet;
std::string errmsg = ""; std::string errmsg = "";
@ -87,7 +87,7 @@ void Networking::Update()
errmsg = "Connection lost."; errmsg = "Connection lost.";
break; break;
default: default:
ReceiveMessage(packet); receiveMessage(packet);
//LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Message with identifier %i has arrived.", packet->data[0]); //LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Message with identifier %i has arrived.", packet->data[0]);
break; break;
} }
@ -101,12 +101,12 @@ void Networking::Update()
} }
} }
void Networking::SendData(RakNet::BitStream *bs) void Networking::sendData(RakNet::BitStream *bs)
{ {
peer->Send(bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, serverAddr, false); peer->Send(bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, serverAddr, false);
} }
void Networking::Connect(const std::string &ip, unsigned short port) void Networking::connect(const std::string &ip, unsigned short port)
{ {
RakNet::SystemAddress master; RakNet::SystemAddress master;
master.SetBinaryAddress(ip.c_str()); master.SetBinaryAddress(ip.c_str());
@ -173,7 +173,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
} }
} }
void Networking::ProcessPlayerPacket(RakNet::Packet *packet) void Networking::processPlayerPacket(RakNet::Packet *packet)
{ {
RakNet::RakNetGUID guid; RakNet::RakNetGUID guid;
RakNet::BitStream bsIn(&packet->data[1], packet->length, false); RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
@ -182,7 +182,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
DedicatedPlayer *pl = 0; DedicatedPlayer *pl = 0;
static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid;
if (guid != myGuid) if (guid != myGuid)
pl = Players::GetPlayer(guid); pl = Players::getPlayer(guid);
PlayerPacket *myPacket = playerController.GetPacket(packet->data[0]); PlayerPacket *myPacket = playerController.GetPacket(packet->data[0]);
@ -190,7 +190,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
{ {
case ID_HANDSHAKE: case ID_HANDSHAKE:
{ {
(*getLocalPlayer()->GetPassw()) = "SuperPassword"; (*getLocalPlayer()->getPassw()) = "SuperPassword";
myPacket->Send(getLocalPlayer(), serverAddr); myPacket->Send(getLocalPlayer(), serverAddr);
break; break;
} }
@ -221,11 +221,11 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
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(guid); pl = Players::newPlayer(guid);
} }
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
Players::CreatePlayer(guid); Players::createPlayer(guid);
} }
break; break;
} }
@ -261,7 +261,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
if (guid == myGuid) if (guid == myGuid)
MWBase::Environment::get().getStateManager()->requestQuit(); MWBase::Environment::get().getStateManager()->requestQuit();
else if (pl != 0) else if (pl != 0)
Players::DisconnectPlayer(guid); Players::disconnectPlayer(guid);
} }
case ID_GAME_EQUIPMENT: case ID_GAME_EQUIPMENT:
@ -281,7 +281,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
else if (pl != 0) else if (pl != 0)
{ {
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
pl->UpdateInventory(); pl->updateInventory();
} }
break; break;
} }
@ -293,7 +293,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
{ {
printf("ID_GAME_INVENTORY update only\n"); printf("ID_GAME_INVENTORY update only\n");
getLocalPlayer()->updateInventory(true); getLocalPlayer()->updateInventory(true);
GetPlayerPacket(ID_GAME_INVENTORY)->Send(getLocalPlayer()); getPlayerPacket(ID_GAME_INVENTORY)->Send(getLocalPlayer());
} }
else else
{ {
@ -341,27 +341,27 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
{ {
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
//cout << "Player: " << pl->Npc()->mName << " pressed: " << (pl->GetAttack()->pressed == 1) << endl; //cout << "Player: " << pl->Npc()->mName << " pressed: " << (pl->getAttack()->pressed == 1) << endl;
if (pl->GetAttack()->pressed == 0) if (pl->getAttack()->pressed == 0)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s",
pl->GetAttack()->success ? "true" : "false"); pl->getAttack()->success ? "true" : "false");
if (pl->GetAttack()->success == 1) if (pl->getAttack()->success == 1)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f",
pl->GetAttack()->damage); pl->getAttack()->damage);
} }
} }
MWMechanics::CreatureStats &stats = pl->getPtr().getClass().getNpcStats(pl->getPtr()); MWMechanics::CreatureStats &stats = pl->getPtr().getClass().getNpcStats(pl->getPtr());
stats.getSpells().setSelectedSpell(pl->GetAttack()->refid); stats.getSpells().setSelectedSpell(pl->getAttack()->refid);
MWWorld::Ptr victim; MWWorld::Ptr victim;
if (pl->GetAttack()->target == getLocalPlayer()->guid) if (pl->getAttack()->target == getLocalPlayer()->guid)
victim = MWBase::Environment::get().getWorld()->getPlayerPtr(); victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
else if (Players::GetPlayer(pl->GetAttack()->target) != 0) else if (Players::getPlayer(pl->getAttack()->target) != 0)
victim = Players::GetPlayer(pl->GetAttack()->target)->getPtr(); victim = Players::getPlayer(pl->getAttack()->target)->getPtr();
MWWorld::Ptr attacker; MWWorld::Ptr attacker;
attacker = pl->getPtr(); attacker = pl->getPtr();
@ -388,16 +388,16 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
} }
if (!weapon.isEmpty()) if (!weapon.isEmpty())
MWMechanics::blockMeleeAttack(attacker, victim, weapon, pl->GetAttack()->damage, 1); MWMechanics::blockMeleeAttack(attacker, victim, weapon, pl->getAttack()->damage, 1);
pl->getPtr().getClass().onHit(victim, pl->GetAttack()->damage, healthdmg, weapon, attacker, osg::Vec3f(), pl->getPtr().getClass().onHit(victim, pl->getAttack()->damage, healthdmg, weapon, attacker, osg::Vec3f(),
pl->GetAttack()->success); pl->getAttack()->success);
} }
} }
else else
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s",
pl->GetAttack()->refid.c_str()); pl->getAttack()->refid.c_str());
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", pl->GetAttack()->success); LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", pl->getAttack()->success);
} }
} }
break; break;
@ -512,7 +512,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
else if (pl != 0) else if (pl != 0)
{ {
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
pl->UpdateDrawState(); pl->updateDrawState();
} }
break; break;
} }
@ -529,7 +529,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
myPacket->Packet(&bsIn, pl, false); myPacket->Packet(&bsIn, pl, false);
message = *pl->ChatMessage(); message = *pl->ChatMessage();
} }
Main::get().getGUIController()->PrintChatMessage(message); Main::get().getGUIController()->printChatMessage(message);
break; break;
} }
@ -637,13 +637,13 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
getLocalPlayer()->guiMessageBox.label.c_str()); getLocalPlayer()->guiMessageBox.label.c_str());
if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox) if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
Main::get().getGUIController()->ShowMessageBox(getLocalPlayer()->guiMessageBox); Main::get().getGUIController()->showMessageBox(getLocalPlayer()->guiMessageBox);
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox) else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
Main::get().getGUIController()->ShowCustomMessageBox(getLocalPlayer()->guiMessageBox); Main::get().getGUIController()->showCustomMessageBox(getLocalPlayer()->guiMessageBox);
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog) else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog)
Main::get().getGUIController()->ShowInputBox(getLocalPlayer()->guiMessageBox); Main::get().getGUIController()->showInputBox(getLocalPlayer()->guiMessageBox);
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::ListBox) else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::ListBox)
Main::get().getGUIController()->ShowDialogList(getLocalPlayer()->guiMessageBox); Main::get().getGUIController()->showDialogList(getLocalPlayer()->guiMessageBox);
} }
break; break;
} }
@ -687,7 +687,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
} }
} }
void Networking::ProcessWorldPacket(RakNet::Packet *packet) void Networking::processWorldPacket(RakNet::Packet *packet)
{ {
RakNet::RakNetGUID guid; RakNet::RakNetGUID guid;
RakNet::BitStream bsIn(&packet->data[1], packet->length, false); RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
@ -696,7 +696,7 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
DedicatedPlayer *pl = 0; DedicatedPlayer *pl = 0;
static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid;
if (guid != myGuid) if (guid != myGuid)
pl = Players::GetPlayer(guid); pl = Players::getPlayer(guid);
WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); WorldPacket *myPacket = worldController.GetPacket(packet->data[0]);
WorldEvent *event = new WorldEvent(guid); WorldEvent *event = new WorldEvent(guid);
@ -1050,27 +1050,27 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet)
} }
} }
void Networking::ReceiveMessage(RakNet::Packet *packet) void Networking::receiveMessage(RakNet::Packet *packet)
{ {
if (packet->length < 2) if (packet->length < 2)
return; return;
if (playerController.ContainsPacket(packet->data[0])) if (playerController.ContainsPacket(packet->data[0]))
{ {
ProcessPlayerPacket(packet); processPlayerPacket(packet);
} }
else if (worldController.ContainsPacket(packet->data[0])) else if (worldController.ContainsPacket(packet->data[0]))
{ {
ProcessWorldPacket(packet); processWorldPacket(packet);
} }
} }
PlayerPacket *Networking::GetPlayerPacket(RakNet::MessageID id) PlayerPacket *Networking::getPlayerPacket(RakNet::MessageID id)
{ {
return playerController.GetPacket(id); return playerController.GetPacket(id);
} }
WorldPacket *Networking::GetWorldPacket(RakNet::MessageID id) WorldPacket *Networking::getWorldPacket(RakNet::MessageID id)
{ {
return worldController.GetPacket(id); return worldController.GetPacket(id);
} }
@ -1089,19 +1089,19 @@ bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr)
{ {
if (ptr.mRef == 0) if (ptr.mRef == 0)
return 0; return 0;
DedicatedPlayer *pl = Players::GetPlayer(ptr); DedicatedPlayer *pl = Players::getPlayer(ptr);
return pl != 0; return pl != 0;
} }
bool Networking::Attack(const MWWorld::Ptr &ptr) bool Networking::attack(const MWWorld::Ptr &ptr)
{ {
DedicatedPlayer *pl = Players::GetPlayer(ptr); DedicatedPlayer *pl = Players::getPlayer(ptr);
if (pl == 0) if (pl == 0)
return false; return false;
return pl->GetAttack()->pressed; return pl->getAttack()->pressed;
} }
bool Networking::isConnected() bool Networking::isConnected()

@ -31,15 +31,15 @@ namespace mwmp
public: public:
Networking(); Networking();
~Networking(); ~Networking();
void Connect(const std::string& ip, unsigned short port); void connect(const std::string& ip, unsigned short port);
void Update(); void update();
void SendData(RakNet::BitStream *bitStream); void sendData(RakNet::BitStream *bitStream);
PlayerPacket *GetPlayerPacket(RakNet::MessageID id); PlayerPacket *getPlayerPacket(RakNet::MessageID id);
WorldPacket *GetWorldPacket(RakNet::MessageID id); WorldPacket *getWorldPacket(RakNet::MessageID id);
bool isDedicatedPlayer(const MWWorld::Ptr &ptr); bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
bool Attack(const MWWorld::Ptr &ptr); bool attack(const MWWorld::Ptr &ptr);
RakNet::SystemAddress serverAddress() RakNet::SystemAddress serverAddress()
{ {
@ -59,9 +59,9 @@ namespace mwmp
PlayerPacketController playerController; PlayerPacketController playerController;
WorldPacketController worldController; WorldPacketController worldController;
void ProcessPlayerPacket(RakNet::Packet *packet); void processPlayerPacket(RakNet::Packet *packet);
void ProcessWorldPacket(RakNet::Packet *packet); void processWorldPacket(RakNet::Packet *packet);
void ReceiveMessage(RakNet::Packet *packet); void receiveMessage(RakNet::Packet *packet);
LocalPlayer *getLocalPlayer(); LocalPlayer *getLocalPlayer();
}; };
} }

@ -70,7 +70,7 @@ namespace MWScript
event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
event->animGroup = group; event->animGroup = group;
event->animMode = mode; event->animMode = mode;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event);
} }
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true); MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits<int>::max(), true);

@ -190,7 +190,7 @@ namespace MWScript
event->cellRef.mRefNum = mReference.getCellRef().getRefNum(); event->cellRef.mRefNum = mReference.getCellRef().getRefNum();
event->index = index; event->index = index;
event->shortVal = value; event->shortVal = value;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(event);
printf("Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i\n", printf("Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),
@ -227,7 +227,7 @@ namespace MWScript
event->cellRef.mRefNum = mReference.getCellRef().getRefNum(); event->cellRef.mRefNum = mReference.getCellRef().getRefNum();
event->index = index; event->index = index;
event->floatVal = value; event->floatVal = value;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(event);
printf("Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f\n", printf("Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),
@ -285,7 +285,7 @@ namespace MWScript
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->varName = name; event->varName = name;
event->shortVal = value; event->shortVal = value;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(event);
printf("Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i\n", printf("Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i\n",
event->varName.c_str(), event->varName.c_str(),
@ -615,7 +615,7 @@ namespace MWScript
event->cellRef.mRefID = id; event->cellRef.mRefID = id;
event->index = index; event->index = index;
event->shortVal = value; event->shortVal = value;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(event);
printf("Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i\n", printf("Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),

@ -92,7 +92,7 @@ namespace MWScript
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
event->video = name; event->video = name;
event->allowSkipping = allowSkipping; event->allowSkipping = allowSkipping;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_VIDEO_PLAY)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(event);
MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping); MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping);
} }
@ -198,7 +198,7 @@ namespace MWScript
event->cellRef.mRefID = ptr.getCellRef().getRefId(); event->cellRef.mRefID = ptr.getCellRef().getRefId();
event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
event->lockLevel = lockLevel; event->lockLevel = lockLevel;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_LOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(event);
ptr.getClass().lock (ptr, lockLevel); ptr.getClass().lock (ptr, lockLevel);
@ -231,7 +231,7 @@ namespace MWScript
event->cell = *ptr.getCell()->getCell(); event->cell = *ptr.getCell()->getCell();
event->cellRef.mRefID = ptr.getCellRef().getRefId(); event->cellRef.mRefID = ptr.getCellRef().getRefId();
event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_UNLOCK)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event);
ptr.getClass().unlock (ptr); ptr.getClass().unlock (ptr);
} }
@ -698,7 +698,7 @@ namespace MWScript
event->cell = *ptr.getCell()->getCell(); event->cell = *ptr.getCell()->getCell();
event->cellRef.mRefID = ptr.getCellRef().getRefId(); event->cellRef.mRefID = ptr.getCellRef().getRefId();
event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event);
MWBase::Environment::get().getWorld()->deleteObject(ptr); MWBase::Environment::get().getWorld()->deleteObject(ptr);
} }

@ -51,7 +51,7 @@ namespace MWScript
event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
event->cellRef.mPos = ptr.getCellRef().getPosition(); event->cellRef.mPos = ptr.getCellRef().getPosition();
event->scale = scale; event->scale = scale;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_SCALE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(event);
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale); MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
} }
@ -555,7 +555,7 @@ namespace MWScript
event->pos = ptr.getRefData().getPosition(); event->pos = ptr.getRefData().getPosition();
event->count = 1; event->count = 1;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_PLACE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event);
printf("Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i\n", printf("Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),

@ -27,7 +27,7 @@ namespace MWWorld
event->cell = *getTarget().getCell()->getCell(); event->cell = *getTarget().getCell()->getCell();
event->cellRef.mRefID = getTarget().getCellRef().getRefId(); event->cellRef.mRefID = getTarget().getCellRef().getRefId();
event->cellRef.mRefNum = getTarget().getCellRef().getRefNum(); event->cellRef.mRefNum = getTarget().getCellRef().getRefNum();
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_OBJECT_DELETE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event);
printf("Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s\n", printf("Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s\n",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),

@ -2257,7 +2257,7 @@ namespace MWWorld
event->cellRef.mRefID = door.getCellRef().getRefId(); event->cellRef.mRefID = door.getCellRef().getRefId();
event->cellRef.mRefNum = door.getCellRef().getRefNum(); event->cellRef.mRefNum = door.getCellRef().getRefNum();
event->state = state; event->state = state;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_DOOR_ACTIVATE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_ACTIVATE)->Send(event);
printf("Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s", printf("Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),
@ -2277,7 +2277,7 @@ namespace MWWorld
event->cellRef.mRefID = door.getCellRef().getRefId(); event->cellRef.mRefID = door.getCellRef().getRefId();
event->cellRef.mRefNum = door.getCellRef().getRefNum(); event->cellRef.mRefNum = door.getCellRef().getRefNum();
event->state = state; event->state = state;
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_DOOR_ACTIVATE)->Send(event); mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_ACTIVATE)->Send(event);
printf("Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s", printf("Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s",
event->cellRef.mRefID.c_str(), event->cellRef.mRefID.c_str(),

@ -143,7 +143,7 @@ namespace mwmp
return &dir; return &dir;
} }
virtual Attack *GetAttack() virtual Attack *getAttack()
{ {
return &attack; return &attack;
} }
@ -163,7 +163,7 @@ namespace mwmp
return &stage; return &stage;
} }
virtual std::string *GetPassw() virtual std::string *getPassw()
{ {
return &passw; return &passw;
} }

@ -16,14 +16,14 @@ void PacketAttack::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool
{ {
PlayerPacket::Packet(bs, player, send); PlayerPacket::Packet(bs, player, send);
RW(player->GetAttack()->attacker, send); RW(player->getAttack()->attacker, send);
RW(player->GetAttack()->target, send); RW(player->getAttack()->target, send);
RW(player->GetAttack()->refid, send); RW(player->getAttack()->refid, send);
RW(player->GetAttack()->type, send); RW(player->getAttack()->type, send);
RW(player->GetAttack()->success, send); RW(player->getAttack()->success, send);
RW(player->GetAttack()->damage, send); RW(player->getAttack()->damage, send);
// //
RW(player->GetAttack()->pressed, send); RW(player->getAttack()->pressed, send);
RW(player->GetAttack()->knockdown, send); RW(player->getAttack()->knockdown, send);
RW(player->GetAttack()->block, send); RW(player->getAttack()->block, send);
} }

@ -16,5 +16,5 @@ void PacketHandshake::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
{ {
PlayerPacket::Packet(bs, player, send); PlayerPacket::Packet(bs, player, send);
RW(player->Npc()->mName, send); RW(player->Npc()->mName, send);
RW(*player->GetPassw(), send); RW(*player->getPassw(), send);
} }

Loading…
Cancel
Save