forked from teamnwah/openmw-tes3coop
Make formatting consistent
This commit is contained in:
parent
1bbd7c271f
commit
1363c4c5b6
16 changed files with 124 additions and 117 deletions
|
@ -164,7 +164,7 @@ void MasterClient::Stop()
|
|||
|
||||
void MasterClient::SetUpdateRate(unsigned int rate)
|
||||
{
|
||||
if(timeout < min_rate)
|
||||
if (timeout < min_rate)
|
||||
timeout = min_rate;
|
||||
else if (timeout > max_rate)
|
||||
timeout = max_rate;
|
||||
|
|
|
@ -48,7 +48,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
|
||||
Player *player = Players::GetPlayer(packet->guid);
|
||||
|
||||
if(player == 0)
|
||||
if (player == 0)
|
||||
{
|
||||
controller->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
||||
|
||||
|
@ -70,21 +70,21 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
|
||||
BasePacket *myPacket = controller->GetPacket(packet->data[0]);
|
||||
|
||||
if(packet->data[0] == ID_HANDSHAKE)
|
||||
if (packet->data[0] == ID_HANDSHAKE)
|
||||
{
|
||||
DEBUG_PRINTF("ID_HANDSHAKE\n");
|
||||
string passw = "SuperPassword";
|
||||
|
||||
myPacket->Read(player);
|
||||
|
||||
if(player->isHandshaked())
|
||||
if (player->isHandshaked())
|
||||
{
|
||||
DEBUG_PRINTF("Wrong handshake with player %d, name: %s\n", player->GetID(), player->Npc()->mName.c_str());
|
||||
KickPlayer(player->guid);
|
||||
return;
|
||||
}
|
||||
|
||||
if(*player->GetPassw() != passw)
|
||||
if (*player->GetPassw() != passw)
|
||||
{
|
||||
DEBUG_PRINTF("Wrong server password (player %d, name: %s) pass: %s\n", player->GetID(), player->Npc()->mName.c_str(), player->GetPassw()->c_str());
|
||||
KickPlayer(player->guid);
|
||||
|
@ -96,7 +96,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
Script::CallBackReturn<ident> result = true;
|
||||
Script::Call<ident>(result, Players::GetPlayer(packet->guid)->GetID());
|
||||
|
||||
if(!result)
|
||||
if (!result)
|
||||
{
|
||||
controller->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(packet->guid), false);
|
||||
Players::DeletePlayer(packet->guid);
|
||||
|
@ -107,14 +107,14 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
|
||||
}
|
||||
|
||||
if(!player->isHandshaked())
|
||||
if (!player->isHandshaked())
|
||||
{
|
||||
DEBUG_PRINTF("Wrong auth player %d, name: %s\n", player->GetID(), player->Npc()->mName.c_str());
|
||||
//KickPlayer(player->guid);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(packet->data[0])
|
||||
switch (packet->data[0])
|
||||
{
|
||||
case ID_GAME_BASE_INFO:
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
{
|
||||
//DEBUG_PRINTF("ID_GAME_UPDATE_POS \n");
|
||||
|
||||
if(!player->CreatureStats()->mDead)
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
|
@ -141,7 +141,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
{
|
||||
DEBUG_PRINTF("ID_GAME_CELL \n");
|
||||
|
||||
if(!player->CreatureStats()->mDead)
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
|
@ -154,7 +154,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
{
|
||||
DEBUG_PRINTF("ID_GAME_UPDATE_SKILLS\n");
|
||||
|
||||
if(!player->CreatureStats()->mDead)
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
@ -301,9 +301,9 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid)
|
|||
controller->GetPacket(ID_GAME_CELL)->RequestData(guid);
|
||||
controller->GetPacket(ID_GAME_UPDATE_EQUIPED)->RequestData(guid);
|
||||
|
||||
for(TPlayers::iterator pl = players->begin(); pl != players->end(); pl++)
|
||||
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++)
|
||||
{
|
||||
if(pl->first == guid) continue;
|
||||
if (pl->first == guid) continue;
|
||||
|
||||
controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
|
||||
//controller->GetPacket(ID_GAME_UPDATE_SKILLS)->Send(pl->second, guid);
|
||||
|
@ -351,7 +351,7 @@ int Networking::MainLoop()
|
|||
|
||||
while (running)
|
||||
{
|
||||
if(kbhit() && getch() == '\n')
|
||||
if (kbhit() && getch() == '\n')
|
||||
break;
|
||||
for (packet=peer->Receive(); packet; peer->DeallocatePacket(packet), packet=peer->Receive())
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ Timer::Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::strin
|
|||
|
||||
void Timer::Tick()
|
||||
{
|
||||
if(end)
|
||||
if (end)
|
||||
return;
|
||||
|
||||
const auto duration = chrono::system_clock::now().time_since_epoch();
|
||||
|
@ -153,7 +153,7 @@ void TimerAPI::FreeTimer(int timerid)
|
|||
|
||||
try
|
||||
{
|
||||
if(timers.at(timerid) != nullptr)
|
||||
if (timers.at(timerid) != nullptr)
|
||||
{
|
||||
delete timers[timerid];
|
||||
timers[timerid] = nullptr;
|
||||
|
@ -182,7 +182,7 @@ void TimerAPI::StartTimer(int timerid)
|
|||
try
|
||||
{
|
||||
Timer *timer = timers.at(timerid);
|
||||
if(timer == nullptr)
|
||||
if (timer == nullptr)
|
||||
throw 1;
|
||||
timer->Start();
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void TimerAPI::Terminate()
|
|||
{
|
||||
for(auto timer : timers)
|
||||
{
|
||||
if(timer.second != nullptr)
|
||||
if (timer.second != nullptr)
|
||||
delete timer.second;
|
||||
timer.second = nullptr;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ void TimerAPI::Tick()
|
|||
{
|
||||
for (auto timer : timers)
|
||||
{
|
||||
if(timer.second != nullptr)
|
||||
if (timer.second != nullptr)
|
||||
timer.second->Tick();
|
||||
}
|
||||
}
|
|
@ -49,8 +49,8 @@ bool ScriptFunctions::HasItemEquipped(unsigned short pid, const char* itemName)
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, false);
|
||||
|
||||
for(int slot = 0; slot < 27; slot ++)
|
||||
if(Misc::StringUtils::ciEqual(player->EquipedItem(slot)->refid, itemName))
|
||||
for (int slot = 0; slot < 27; slot ++)
|
||||
if (Misc::StringUtils::ciEqual(player->EquipedItem(slot)->refid, itemName))
|
||||
return true;
|
||||
return false;
|
||||
}
|
|
@ -270,7 +270,7 @@ void ScriptFunctions::SetCurrentAttribute(unsigned short pid, unsigned short att
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if(attribute > 7)
|
||||
if (attribute > 7)
|
||||
return;
|
||||
|
||||
player->CreatureStats()->mAttributes[attribute].mCurrent = value;
|
||||
|
@ -281,7 +281,7 @@ int ScriptFunctions::GetSkill(unsigned short pid, unsigned short skill) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
if(skill > 27)
|
||||
if (skill > 27)
|
||||
return 0;
|
||||
|
||||
return player->NpcStats()->mSkills[skill].mBase;
|
||||
|
@ -292,7 +292,7 @@ void ScriptFunctions::SetSkill(unsigned short pid, unsigned short skill, int val
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if(skill > 27)
|
||||
if (skill > 27)
|
||||
return;
|
||||
|
||||
player->NpcStats()->mSkills[skill].mBase = value;
|
||||
|
@ -306,7 +306,7 @@ int ScriptFunctions::GetCurrentSkill(unsigned short pid, unsigned short skill) n
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
if(skill > 27)
|
||||
if (skill > 27)
|
||||
return 0;
|
||||
|
||||
return player->NpcStats()->mSkills[skill].mCurrent;
|
||||
|
@ -317,7 +317,7 @@ void ScriptFunctions::SetCurrentSkill(unsigned short pid, unsigned short skill,
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if(skill > 27)
|
||||
if (skill > 27)
|
||||
return;
|
||||
|
||||
player->NpcStats()->mSkills[skill].mCurrent = value;
|
||||
|
@ -329,7 +329,7 @@ int ScriptFunctions::GetIncreaseSkill(unsigned short pid, unsigned int pos) noex
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
if(pos > 7)
|
||||
if (pos > 7)
|
||||
return 0;
|
||||
|
||||
return player->NpcStats()->mSkillIncrease[pos];
|
||||
|
@ -340,7 +340,7 @@ void ScriptFunctions::SetIncreaseSkill(unsigned short pid, unsigned int pos, int
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if(pos > 7)
|
||||
if (pos > 7)
|
||||
return;
|
||||
|
||||
player->NpcStats()->mSkillIncrease[pos] = value;
|
||||
|
|
|
@ -70,7 +70,7 @@ void ScriptFunctions::SetCell(unsigned short pid, const char *name) noexcept
|
|||
return;*/
|
||||
|
||||
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
||||
if(!player->GetCell()->isExterior())
|
||||
if (!player->GetCell()->isExterior())
|
||||
cout << "\"" << player->GetCell()->mName << "\"";
|
||||
else
|
||||
cout << "exterior";
|
||||
|
@ -98,7 +98,7 @@ void ScriptFunctions::SetExterior(unsigned short pid, int x, int y) noexcept
|
|||
GET_PLAYER(pid, player,);
|
||||
|
||||
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
||||
if(!player->GetCell()->isExterior())
|
||||
if (!player->GetCell()->isExterior())
|
||||
cout << "\"" << player->GetCell()->mName << "\"";
|
||||
else
|
||||
cout << "exterior: " << player->GetCell()->mCellId.mIndex.mX << ", " << player->GetCell()->mCellId.mIndex.mY;
|
||||
|
|
|
@ -13,9 +13,9 @@ inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin,
|
|||
{
|
||||
vector<boost::any> args;
|
||||
|
||||
for(int i = args_begin; i < args_n + args_begin; i++)
|
||||
for (int i = args_begin; i < args_n + args_begin; i++)
|
||||
{
|
||||
switch(types[i - args_begin])
|
||||
switch (types[i - args_begin])
|
||||
{
|
||||
case 'i':
|
||||
{
|
||||
|
@ -84,22 +84,22 @@ int LangLua::CallPublic(lua_State *lua)
|
|||
|
||||
string types = Public::GetDefinition(name);
|
||||
|
||||
if(args_n != (long)types.size())
|
||||
if (args_n != (long)types.size())
|
||||
throw invalid_argument("Script call: Number of arguments does not match definition");
|
||||
|
||||
vector<boost::any> args = DefToVec(lua, types, 2, args_n);
|
||||
|
||||
boost::any result = Public::Call(&name[0], args);
|
||||
if(result.empty())
|
||||
if (result.empty())
|
||||
return 0;
|
||||
|
||||
if(result.type().hash_code() == typeid(signed int).hash_code())
|
||||
if (result.type().hash_code() == typeid(signed int).hash_code())
|
||||
luabridge::Stack<signed int>::push(lua, boost::any_cast<signed int>(result));
|
||||
else if(result.type().hash_code() == typeid(unsigned int).hash_code())
|
||||
else if (result.type().hash_code() == typeid(unsigned int).hash_code())
|
||||
luabridge::Stack<unsigned int>::push(lua, boost::any_cast<unsigned int>(result));
|
||||
else if(result.type().hash_code() == typeid(double).hash_code())
|
||||
else if (result.type().hash_code() == typeid(double).hash_code())
|
||||
luabridge::Stack<double>::push(lua, boost::any_cast<double>(result));
|
||||
else if(result.type().hash_code() == typeid(const char*).hash_code())
|
||||
else if (result.type().hash_code() == typeid(const char*).hash_code())
|
||||
luabridge::Stack<const char*>::push(lua, boost::any_cast<const char*>(result));
|
||||
return 1;
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ int LangLua::CreateTimerEx(lua_State *lua)
|
|||
|
||||
vector<boost::any> args;
|
||||
|
||||
for(int i = 4; i < args_n + 4; i++)
|
||||
for (int i = 4; i < args_n + 4; i++)
|
||||
{
|
||||
switch(types[i - 4])
|
||||
switch (types[i - 4])
|
||||
{
|
||||
case 'i':
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@ boost::any ScriptFunction::Call(const vector<boost::any> &args)
|
|||
LangLua langLua(fLua.lua);
|
||||
boost::any any = langLua.Call(fLua.name.c_str(), def.c_str(), args);
|
||||
|
||||
switch(ret_type)
|
||||
switch (ret_type)
|
||||
{
|
||||
case 'i':
|
||||
result = boost::any_cast<luabridge::LuaRef>(any).cast<unsigned int>();
|
||||
|
|
|
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
setenv("LUA_PATH", Utils::convertPath(plugin_home + "/scripts/?.lua" + ";" + plugin_home + "/scripts/?.t").c_str(), 1);
|
||||
|
||||
for(auto plugin : plugins)
|
||||
for (auto plugin : plugins)
|
||||
Script::LoadScript(plugin.c_str(), plugin_home.c_str());
|
||||
|
||||
RakNet::RakPeerInterface *peer = RakNet::RakPeerInterface::GetInstance();
|
||||
|
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
|||
const char passw[8] = "1234567";
|
||||
peer->SetIncomingPassword(passw, sizeof(passw));
|
||||
|
||||
if(RakNet::NonNumericHostString(addr.c_str()))
|
||||
if (RakNet::NonNumericHostString(addr.c_str()))
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "%s", "You cannot use non numeric addresses for server.");
|
||||
return 1;
|
||||
|
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
|||
bool masterEnabled = mgr.getBool("enabled", "MasterServer");
|
||||
thread thrQuery;
|
||||
MasterClient *mclient;
|
||||
if(masterEnabled)
|
||||
if (masterEnabled)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sharing server query info to master enabled.");
|
||||
string masterAddr = mgr.getString("address", "MasterServer");
|
||||
|
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
RakNet::RakPeerInterface::DestroyInstance(peer);
|
||||
|
||||
if(thrQuery.joinable())
|
||||
if (thrQuery.joinable())
|
||||
{
|
||||
mclient->Stop();
|
||||
thrQuery.join();
|
||||
|
|
|
@ -202,16 +202,16 @@ void DedicatedPlayer::Move(float dt)
|
|||
|
||||
void Players::Update(float dt)
|
||||
{
|
||||
for(std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
|
||||
for (std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
|
||||
{
|
||||
DedicatedPlayer *pl = it->second;
|
||||
if(pl == 0) continue;
|
||||
if (pl == 0) continue;
|
||||
|
||||
MWMechanics::NpcStats *npcStats = &pl->ptr.getClass().getNpcStats(pl->getPtr());
|
||||
|
||||
MWMechanics::DynamicStat<float> value;
|
||||
|
||||
if(pl->CreatureStats()->mDead)
|
||||
if (pl->CreatureStats()->mDead)
|
||||
{
|
||||
value.readState(pl->CreatureStats()->mDynamic[0]);
|
||||
npcStats->setHealth(value);
|
||||
|
@ -286,7 +286,7 @@ void DedicatedPlayer::UpdateInventory()
|
|||
equal = true;
|
||||
}
|
||||
|
||||
if(dedicItem.empty() || equal)
|
||||
if (dedicItem.empty() || equal)
|
||||
continue;
|
||||
|
||||
const int count = EquipedItem(slot)->count;
|
||||
|
@ -319,7 +319,7 @@ const std::string DedicatedPlayer::GetAnim()
|
|||
else
|
||||
anim = "walk";
|
||||
|
||||
if(movementAnim != 0)
|
||||
if (movementAnim != 0)
|
||||
{
|
||||
|
||||
if (movementAnim == 3)
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace mwmp
|
|||
|
||||
void GUIChat::print(const std::string &msg, const std::string &color)
|
||||
{
|
||||
if(windowState == 2 && !isVisible())
|
||||
if (windowState == 2 && !isVisible())
|
||||
{
|
||||
setVisible(true);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ namespace mwmp
|
|||
void GUIChat::PressedChatMode()
|
||||
{
|
||||
windowState++;
|
||||
if(windowState == 3) windowState = 0;
|
||||
if (windowState == 3) windowState = 0;
|
||||
|
||||
switch(windowState)
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ namespace mwmp
|
|||
{
|
||||
if (windowState == CHAT_DISABLED)
|
||||
return;
|
||||
else if(windowState == CHAT_HIDDENMODE)
|
||||
else if (windowState == CHAT_HIDDENMODE)
|
||||
{
|
||||
setVisible(true);
|
||||
curTime = 0;
|
||||
|
@ -189,28 +189,28 @@ namespace mwmp
|
|||
|
||||
void GUIChat::keyPress(MyGUI::Widget *_sender, MyGUI::KeyCode key, MyGUI::Char _char)
|
||||
{
|
||||
if(mCommandHistory.empty()) return;
|
||||
if (mCommandHistory.empty()) return;
|
||||
|
||||
// Traverse history with up and down arrows
|
||||
if(key == MyGUI::KeyCode::ArrowUp)
|
||||
{
|
||||
// If the user was editing a string, store it for later
|
||||
if(mCurrent == mCommandHistory.end())
|
||||
if (mCurrent == mCommandHistory.end())
|
||||
mEditString = mCommandLine->getOnlyText();
|
||||
|
||||
if(mCurrent != mCommandHistory.begin())
|
||||
if (mCurrent != mCommandHistory.begin())
|
||||
{
|
||||
--mCurrent;
|
||||
mCommandLine->setCaption(*mCurrent);
|
||||
}
|
||||
}
|
||||
else if(key == MyGUI::KeyCode::ArrowDown)
|
||||
else if (key == MyGUI::KeyCode::ArrowDown)
|
||||
{
|
||||
if(mCurrent != mCommandHistory.end())
|
||||
{
|
||||
++mCurrent;
|
||||
|
||||
if(mCurrent != mCommandHistory.end())
|
||||
if (mCurrent != mCommandHistory.end())
|
||||
mCommandLine->setCaption(*mCurrent);
|
||||
else
|
||||
// Restore the edit string
|
||||
|
@ -222,10 +222,10 @@ namespace mwmp
|
|||
|
||||
void GUIChat::Update(float dt)
|
||||
{
|
||||
if(windowState == CHAT_HIDDENMODE && !editState && isVisible())
|
||||
if (windowState == CHAT_HIDDENMODE && !editState && isVisible())
|
||||
{
|
||||
curTime += dt;
|
||||
if(curTime >= delay)
|
||||
if (curTime >= delay)
|
||||
{
|
||||
SetEditState(false);
|
||||
this->mMainWidget->setVisible(false);
|
||||
|
|
|
@ -48,7 +48,7 @@ void mwmp::GUIController::setupChat(const Settings::Manager &mgr)
|
|||
|
||||
void mwmp::GUIController::PrintChatMessage(std::string &msg)
|
||||
{
|
||||
if(mChat != nullptr)
|
||||
if (mChat != nullptr)
|
||||
mChat->print(msg);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ std::vector<std::string> splitString(const std::string &str, char delim = ';')
|
|||
std::istringstream ss(str);
|
||||
std::vector<std::string> result;
|
||||
std::string token;
|
||||
while(std::getline(ss, token, delim))
|
||||
while (std::getline(ss, token, delim))
|
||||
result.push_back(token);
|
||||
return result;
|
||||
}
|
||||
|
@ -114,14 +114,14 @@ void mwmp::GUIController::OnInputBoxDone(MWGui::WindowBase *parWindow)
|
|||
bool mwmp::GUIController::pressedKey(int key)
|
||||
{
|
||||
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||
if(mChat == nullptr || windowManager->getMode() != MWGui::GM_None)
|
||||
if (mChat == nullptr || windowManager->getMode() != MWGui::GM_None)
|
||||
return false;
|
||||
if(key == keyChatMode)
|
||||
if (key == keyChatMode)
|
||||
{
|
||||
mChat->PressedChatMode();
|
||||
return true;
|
||||
}
|
||||
else if(key == keySay)
|
||||
else if (key == keySay)
|
||||
{
|
||||
//MyGUI::Widget *oldFocus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
mChat->PressedSay();
|
||||
|
@ -141,11 +141,11 @@ bool mwmp::GUIController::HaveFocusedElement()
|
|||
|
||||
void mwmp::GUIController::update(float dt)
|
||||
{
|
||||
if(mChat != nullptr)
|
||||
if (mChat != nullptr)
|
||||
mChat->Update(dt);
|
||||
|
||||
int pressedButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
|
||||
if(pressedButton != -1 && calledMessageBox)
|
||||
if (pressedButton != -1 && calledMessageBox)
|
||||
{
|
||||
printf("Pressed: %d\n", pressedButton);
|
||||
calledMessageBox = false;
|
||||
|
|
|
@ -222,11 +222,11 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
|
|||
static bool attackPressed = false; // prevent flood
|
||||
MWMechanics::DrawState_ state = player.getClass().getNpcStats(player).getDrawState();
|
||||
//player.getClass().hit(player, 1, ESM::Weapon::AT_Chop);
|
||||
if(world->getPlayer().getAttackingOrSpell() && !attackPressed)
|
||||
if (world->getPlayer().getAttackingOrSpell() && !attackPressed)
|
||||
{
|
||||
MWWorld::Ptr weapon = MWWorld::Ptr(); // hand-to-hand
|
||||
//player.getClass().onHit(player, 0.5, true, weapon, 0, 1);
|
||||
if(state == MWMechanics::DrawState_Spell)
|
||||
if (state == MWMechanics::DrawState_Spell)
|
||||
{
|
||||
//cout << "getAttackingOrSpell" << endl;
|
||||
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
||||
|
@ -240,7 +240,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
|
|||
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
|
||||
GetNetworking()->SendData(&bs);*/
|
||||
}
|
||||
else if(state == MWMechanics::DrawState_Weapon)
|
||||
else if (state == MWMechanics::DrawState_Weapon)
|
||||
{
|
||||
//PrepareAttack(2);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
|
|||
}
|
||||
else if(!world->getPlayer().getAttackingOrSpell() && attackPressed)
|
||||
{
|
||||
if(/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
|
||||
if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
|
||||
{
|
||||
//localNetPlayer->GetAttack()->success = false;
|
||||
//SendAttack(0);
|
||||
|
@ -264,7 +264,7 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
|
|||
MWMechanics::NpcStats *playerStats = &player.getClass().getNpcStats(player);
|
||||
static bool isDead = false;
|
||||
|
||||
if(playerStats->isDead() && !isDead)
|
||||
if (playerStats->isDead() && !isDead)
|
||||
{
|
||||
CreatureStats()->mDead = true;
|
||||
RakNet::BitStream bs;
|
||||
|
@ -272,7 +272,7 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
|
|||
GetNetworking()->SendData(&bs);
|
||||
isDead = true;
|
||||
}
|
||||
else if(playerStats->getHealth().getCurrent() > 0 && isDead)
|
||||
else if (playerStats->getHealth().getCurrent() > 0 && isDead)
|
||||
isDead = false;
|
||||
}
|
||||
|
||||
|
@ -282,10 +282,10 @@ void LocalPlayer::updateAttributesAndSkills(bool forceUpdate)
|
|||
|
||||
const MWMechanics::NpcStats &_npcStats = player.getClass().getNpcStats(player);
|
||||
|
||||
for(int i = 0; i < PacketAttributesAndStats::StatsCount; ++i)
|
||||
for (int i = 0; i < PacketAttributesAndStats::StatsCount; ++i)
|
||||
_npcStats.getSkill(i).writeState( NpcStats()->mSkills[i]);
|
||||
|
||||
for(int i = 0; i < PacketAttributesAndStats::AttributesCount; ++i)
|
||||
for (int i = 0; i < PacketAttributesAndStats::AttributesCount; ++i)
|
||||
_npcStats.getAttribute(i).writeState(CreatureStats()->mAttributes[i]);
|
||||
}
|
||||
|
||||
|
@ -298,12 +298,12 @@ Networking *LocalPlayer::GetNetworking()
|
|||
|
||||
void LocalPlayer::PrepareAttack(char type, bool state)
|
||||
{
|
||||
if(GetAttack()->pressed == state)
|
||||
if (GetAttack()->pressed == state)
|
||||
return;
|
||||
|
||||
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();
|
||||
|
||||
|
@ -332,7 +332,7 @@ void LocalPlayer::SendAttack(char type)
|
|||
{
|
||||
MWMechanics::DrawState_ state = GetPlayerPtr().getClass().getNpcStats(GetPlayerPtr()).getDrawState();
|
||||
|
||||
if(state == MWMechanics::DrawState_Spell)
|
||||
if (state == MWMechanics::DrawState_Spell)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -360,18 +360,23 @@ void LocalPlayer::updateCell(bool forceUpdate)
|
|||
// 2) The LocalPlayer's cell name does not equal the World Player's cell name
|
||||
// 3) The LocalPlayer's exterior cell coordinates do not equal the World Player's
|
||||
// exterior cell coordinates
|
||||
if (forceUpdate) {
|
||||
if (forceUpdate)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (!Misc::StringUtils::ciEqual(_cell->mName, GetCell()->mName)) {
|
||||
else if (!Misc::StringUtils::ciEqual(_cell->mName, GetCell()->mName))
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (_cell->isExterior()) {
|
||||
else if (_cell->isExterior())
|
||||
{
|
||||
|
||||
if (_cell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX) {
|
||||
if (_cell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (_cell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY) {
|
||||
else if (_cell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +424,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
|
|||
MWMechanics::DrawState_ state = player.getClass().getNpcStats(player).getDrawState();
|
||||
static MWMechanics::DrawState_ oldState = player.getClass().getNpcStats(player).getDrawState();
|
||||
//static float timer = 0;
|
||||
if(oldRun != run
|
||||
if (oldRun != run
|
||||
|| oldSneak != sneak || oldForceJump != forceJump
|
||||
|| oldForceMoveJump != forceMoveJump || oldState != state ||
|
||||
((jump || onJump)/* && (timer += MWBase::Environment::get().getFrameDuration() )> 0.5*/)
|
||||
|
@ -480,7 +485,9 @@ bool LocalPlayer::CharGenThread() // ToDo: need fix
|
|||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
(*Npc()) = *player.get<ESM::NPC>()->mBase;
|
||||
|
||||
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Send(this);
|
||||
|
||||
if(CharGenStage()->end != 1)
|
||||
{
|
||||
updateBaseStats(true);
|
||||
|
|
|
@ -134,10 +134,10 @@ void Main::Frame(float dt)
|
|||
void Main::UpdateWorld(float dt) const
|
||||
{
|
||||
|
||||
if(!mLocalPlayer->CharGenThread())
|
||||
if (!mLocalPlayer->CharGenThread())
|
||||
return;
|
||||
|
||||
if(!mNetworking->isConnected())
|
||||
if (!mNetworking->isConnected())
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
MWBase::Environment::get().getMechanicsManager()->toggleAI();
|
||||
|
@ -178,7 +178,7 @@ GUIController *Main::getGUIConroller() const
|
|||
|
||||
void Main::PressedKey(int key)
|
||||
{
|
||||
if(pMain == nullptr) return;
|
||||
if(get().getGUIConroller()->pressedKey(key))
|
||||
if (pMain == nullptr) return;
|
||||
if (get().getGUIConroller()->pressedKey(key))
|
||||
return; // if any gui bind pressed
|
||||
}
|
|
@ -76,7 +76,7 @@ void Networking::Update()
|
|||
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||
break;
|
||||
default:
|
||||
ReciveMessage(packet);
|
||||
ReceiveMessage(packet);
|
||||
//printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
break;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
|
|||
}
|
||||
}
|
||||
|
||||
if(!errmsg.empty())
|
||||
if (!errmsg.empty())
|
||||
{
|
||||
cerr << errmsg << endl;
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "TES3MP", errmsg.c_str(), 0);
|
||||
|
@ -153,11 +153,11 @@ void Networking::Connect(const std::string &ip, unsigned short port)
|
|||
}
|
||||
}
|
||||
|
||||
void Networking::ReciveMessage(RakNet::Packet *packet)
|
||||
void Networking::ReceiveMessage(RakNet::Packet *packet)
|
||||
{
|
||||
RakNet::RakNetGUID id;
|
||||
|
||||
if(packet->length < 2)
|
||||
if (packet->length < 2)
|
||||
return;
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
|
@ -165,7 +165,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
|
||||
DedicatedPlayer *pl = 0;
|
||||
static RakNet::RakNetGUID myid = getLocalPlayer()->guid;
|
||||
if(id != myid)
|
||||
if (id != myid)
|
||||
pl = Players::GetPlayer(id);
|
||||
|
||||
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
|
||||
|
@ -180,7 +180,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_BASE_INFO:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
cout << "TEST: " << packet->length << endl;
|
||||
if(packet->length == myPacket->headerSize())
|
||||
|
@ -197,7 +197,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(pl == 0)
|
||||
if (pl == 0)
|
||||
pl = Players::NewPlayer(id);
|
||||
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
|
@ -207,7 +207,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_UPDATE_POS:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
if (packet->length != myPacket->headerSize())
|
||||
{
|
||||
|
@ -218,7 +218,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
else
|
||||
getLocalPlayer()->updatePosition(true);
|
||||
}
|
||||
else if(pl != 0)
|
||||
else if (pl != 0)
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
break;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_USER_DISCONNECTED:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||
else if(pl != 0)
|
||||
Players::DisconnectPlayer(id);
|
||||
|
@ -239,7 +239,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_UPDATE_EQUIPED:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
getLocalPlayer()->updateInventory(true);
|
||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
||||
|
@ -253,7 +253,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_UPDATE_SKILLS:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
getLocalPlayer()->updateAttributesAndSkills(true);
|
||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
||||
|
@ -280,12 +280,12 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_ATTACK:
|
||||
{
|
||||
if(pl != 0)
|
||||
if (pl != 0)
|
||||
{
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
|
||||
//cout << "Player: " << pl->Npc()->mName << " pressed: " << (pl->GetAttack()->pressed == 1) << endl;
|
||||
if(pl->GetAttack()->pressed == 0)
|
||||
if (pl->GetAttack()->pressed == 0)
|
||||
{
|
||||
cout << "success: " << (pl->GetAttack()->success == 1);
|
||||
if(pl->GetAttack()->success == 1)
|
||||
|
@ -297,16 +297,16 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
stats.getSpells().setSelectedSpell(pl->GetAttack()->refid);
|
||||
|
||||
MWWorld::Ptr victim;
|
||||
if(pl->GetAttack()->target == getLocalPlayer()->guid)
|
||||
if (pl->GetAttack()->target == getLocalPlayer()->guid)
|
||||
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();
|
||||
|
||||
MWWorld::Ptr attacker;
|
||||
attacker = pl->getPtr();
|
||||
|
||||
// Get the weapon used (if hand-to-hand, weapon = inv.end())
|
||||
if(*pl->DrawState() == 1)
|
||||
if (*pl->DrawState() == 1)
|
||||
{
|
||||
MWWorld::InventoryStore &inv = attacker.getClass().getInventoryStore(attacker);
|
||||
MWWorld::ContainerStoreIterator weaponslot = inv.getSlot(
|
||||
|
@ -341,7 +341,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_UPDATE_BASESTATS:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
getLocalPlayer()->updateBaseStats(true);
|
||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
||||
|
@ -363,7 +363,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
case ID_GAME_DIE:
|
||||
{
|
||||
printf("ID_GAME_DIE\n");
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
MWMechanics::DynamicStat<float> health = player.getClass().getCreatureStats(player).getHealth();
|
||||
|
@ -371,7 +371,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
player.getClass().getCreatureStats(player).setHealth(health);
|
||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
||||
}
|
||||
else if(pl != 0)
|
||||
else if (pl != 0)
|
||||
{
|
||||
printf("attempt to kill %s\n", pl->Npc()->mName.c_str());
|
||||
MWMechanics::DynamicStat<float> health;
|
||||
|
@ -416,7 +416,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_CELL:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
if (packet->length == myPacket->headerSize())
|
||||
getLocalPlayer()->updateCell(true);
|
||||
|
@ -426,7 +426,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
getLocalPlayer()->setCell();
|
||||
}
|
||||
}
|
||||
else if(pl != 0)
|
||||
else if (pl != 0)
|
||||
{
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
pl->updateCell();
|
||||
|
@ -435,9 +435,9 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_DRAWSTATE:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
getLocalPlayer()->updateDrawStateAndFlags(true);
|
||||
else if(pl != 0)
|
||||
else if (pl != 0)
|
||||
{
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
pl->UpdateDrawState();
|
||||
|
@ -447,12 +447,12 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
case ID_CHAT_MESSAGE:
|
||||
{
|
||||
std::string message;
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
myPacket->Packet(&bsIn, getLocalPlayer(), false);
|
||||
message = *getLocalPlayer()->ChatMessage();
|
||||
}
|
||||
else if(pl != 0)
|
||||
else if (pl != 0)
|
||||
{
|
||||
myPacket->Packet(&bsIn, pl, false);
|
||||
message = *pl->ChatMessage();
|
||||
|
@ -462,7 +462,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GAME_CHARGEN:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
myPacket->Packet(&bsIn, getLocalPlayer(), false);
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ void Networking::ReciveMessage(RakNet::Packet *packet)
|
|||
}
|
||||
case ID_GUI_MESSAGEBOX:
|
||||
{
|
||||
if(id == myid)
|
||||
if (id == myid)
|
||||
{
|
||||
myPacket->Packet(&bsIn, getLocalPlayer(), false);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace mwmp
|
|||
|
||||
PacketsController controller;
|
||||
|
||||
void ReciveMessage(RakNet::Packet *packet);
|
||||
void ReceiveMessage(RakNet::Packet *packet);
|
||||
LocalPlayer *getLocalPlayer();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue