mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-25 14:03:33 -04:00
Make formatting consistent, part 2
This commit is contained in:
parent
1363c4c5b6
commit
8eda381016
@ -113,7 +113,7 @@ RakNet::RakString MasterClient::Send(std::string motd, unsigned players, unsigne
|
|||||||
|
|
||||||
if (httpConnection->GetResponse(transmitted, hostTransmitted, response, hostReceived, contentOffset))
|
if (httpConnection->GetResponse(transmitted, hostTransmitted, response, hostReceived, contentOffset))
|
||||||
{
|
{
|
||||||
if(contentOffset < 0)
|
if (contentOffset < 0)
|
||||||
return "NO_CONTENT"; // no content
|
return "NO_CONTENT"; // no content
|
||||||
tcpInterface.CloseConnection(sa);
|
tcpInterface.CloseConnection(sa);
|
||||||
return (response.C_String() + contentOffset);
|
return (response.C_String() + contentOffset);
|
||||||
|
@ -178,7 +178,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||||||
{
|
{
|
||||||
DEBUG_PRINTF("ID_GAME_ATTACK\n");
|
DEBUG_PRINTF("ID_GAME_ATTACK\n");
|
||||||
|
|
||||||
if(!player->CreatureStats()->mDead)
|
if (!player->CreatureStats()->mDead)
|
||||||
{
|
{
|
||||||
myPacket->Read(player);
|
myPacket->Read(player);
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||||||
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
|
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player->GetID(), player->ChatMessage()->c_str());
|
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player->GetID(), player->ChatMessage()->c_str());
|
||||||
|
|
||||||
if(result)
|
if (result)
|
||||||
{
|
{
|
||||||
*player->ChatMessage() = player->Npc()->mName + " (" + std::to_string(player->GetID()) + "): "
|
*player->ChatMessage() = player->Npc()->mName + " (" + std::to_string(player->GetID()) + "): "
|
||||||
+ *player->ChatMessage() + "\n";
|
+ *player->ChatMessage() + "\n";
|
||||||
|
@ -9,7 +9,7 @@ TSlots Players::slots;
|
|||||||
|
|
||||||
void Players::DeletePlayer(RakNet::RakNetGUID id)
|
void Players::DeletePlayer(RakNet::RakNetGUID id)
|
||||||
{
|
{
|
||||||
if(players[id] != 0)
|
if (players[id] != 0)
|
||||||
{
|
{
|
||||||
slots[players[id]->GetID()] = 0;
|
slots[players[id]->GetID()] = 0;
|
||||||
delete players[id];
|
delete players[id];
|
||||||
@ -22,9 +22,9 @@ void Players::NewPlayer(RakNet::RakNetGUID id)
|
|||||||
{
|
{
|
||||||
players[id] = new Player(id);
|
players[id] = new Player(id);
|
||||||
|
|
||||||
for(int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if(slots[i] == 0)
|
if (slots[i] == 0)
|
||||||
{
|
{
|
||||||
slots[i] = players[id];
|
slots[i] = players[id];
|
||||||
slots[i]->SetID(i);
|
slots[i]->SetID(i);
|
||||||
|
@ -220,7 +220,7 @@ bool TimerAPI::IsEndTimer(int timerid)
|
|||||||
|
|
||||||
void TimerAPI::Terminate()
|
void TimerAPI::Terminate()
|
||||||
{
|
{
|
||||||
for(auto timer : timers)
|
for (auto timer : timers)
|
||||||
{
|
{
|
||||||
if (timer.second != nullptr)
|
if (timer.second != nullptr)
|
||||||
delete timer.second;
|
delete timer.second;
|
||||||
|
@ -16,7 +16,7 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
|
|||||||
DEBUG_PRINTF("System: %s", message);
|
DEBUG_PRINTF("System: %s", message);
|
||||||
|
|
||||||
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
|
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
|
||||||
if(broadcast)
|
if (broadcast)
|
||||||
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute)
|
|||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
if(attribute > 7)
|
if (attribute > 7)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return player->CreatureStats()->mAttributes[attribute].mBase;
|
return player->CreatureStats()->mAttributes[attribute].mBase;
|
||||||
@ -246,7 +246,7 @@ void ScriptFunctions::SetAttribute(unsigned short pid, unsigned short attribute,
|
|||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
|
|
||||||
if(attribute > 7)
|
if (attribute > 7)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBUG_PRINTF("SetAttribute(%d, %d, %d)\n", pid, attribute, value);
|
DEBUG_PRINTF("SetAttribute(%d, %d, %d)\n", pid, attribute, value);
|
||||||
@ -259,7 +259,7 @@ int ScriptFunctions::GetCurrentAttribute(unsigned short pid, unsigned short attr
|
|||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
if(attribute > 7)
|
if (attribute > 7)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return player->CreatureStats()->mAttributes[attribute].mCurrent;
|
return player->CreatureStats()->mAttributes[attribute].mCurrent;
|
||||||
|
@ -66,7 +66,7 @@ void ScriptFunctions::SetCell(unsigned short pid, const char *name) noexcept
|
|||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
|
|
||||||
/*if(player->GetCell()->mName == name)
|
/*if (player->GetCell()->mName == name)
|
||||||
return;*/
|
return;*/
|
||||||
|
|
||||||
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
cout << "attempt to move player (pid: " << pid << " name: " << player->Npc()->mName << ") from ";
|
||||||
|
@ -108,7 +108,7 @@ void LangLua::LoadProgram(const char *filename)
|
|||||||
|
|
||||||
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
|
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
|
||||||
|
|
||||||
for(unsigned i = 0; i < functions_n; i++)
|
for (unsigned i = 0; i < functions_n; i++)
|
||||||
tes3mp.addCFunction(functions_[i].name, functions_[i].func);
|
tes3mp.addCFunction(functions_[i].name, functions_[i].func);
|
||||||
|
|
||||||
tes3mp.endNamespace();
|
tes3mp.endNamespace();
|
||||||
|
@ -128,16 +128,16 @@ cell LangPAWN::CallPublic(AMX *amx, const cell *params) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
boost::any result = Public::Call(&name[0], args);
|
boost::any result = Public::Call(&name[0], args);
|
||||||
if(result.empty())
|
if (result.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cell ret = 0;
|
cell ret = 0;
|
||||||
|
|
||||||
if(result.type().hash_code() == typeid(signed int).hash_code())
|
if (result.type().hash_code() == typeid(signed int).hash_code())
|
||||||
ret = boost::any_cast<signed int>(result);
|
ret = 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())
|
||||||
ret = boost::any_cast<unsigned int>(result);
|
ret = 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())
|
||||||
ret = amx_ftoc(result);
|
ret = amx_ftoc(result);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -37,7 +37,7 @@ private:
|
|||||||
template<typename R>
|
template<typename R>
|
||||||
R GetScript(const char *name)
|
R GetScript(const char *name)
|
||||||
{
|
{
|
||||||
if(script_type == SCRIPT_CPP)
|
if (script_type == SCRIPT_CPP)
|
||||||
{
|
{
|
||||||
return SystemInterface<R>(lang->GetInterface(), name).result;
|
return SystemInterface<R>(lang->GetInterface(), name).result;
|
||||||
}
|
}
|
||||||
@ -99,14 +99,14 @@ public:
|
|||||||
if (script->script_type == SCRIPT_CPP)
|
if (script->script_type == SCRIPT_CPP)
|
||||||
result = reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
|
result = reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
|
||||||
#if defined (ENABLE_PAWN)
|
#if defined (ENABLE_PAWN)
|
||||||
else if(script->script_type == SCRIPT_PAWN)
|
else if (script->script_type == SCRIPT_PAWN)
|
||||||
{
|
{
|
||||||
boost::any any = script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
boost::any any = script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
||||||
result = reinterpret_cast<CallBackReturn<I>> ((int)boost::any_cast<int64_t>(any)); // TODO: WTF?! int?!
|
result = reinterpret_cast<CallBackReturn<I>> ((int)boost::any_cast<int64_t>(any)); // TODO: WTF?! int?!
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined (ENABLE_LUA)
|
#if defined (ENABLE_LUA)
|
||||||
else if(script->script_type == SCRIPT_LUA)
|
else if (script->script_type == SCRIPT_LUA)
|
||||||
{
|
{
|
||||||
boost::any any = script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
boost::any any = script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
||||||
result = static_cast<CallBackReturn<I>>(boost::any_cast<luabridge::LuaRef>(any).cast<CallBackReturn<I>>());
|
result = static_cast<CallBackReturn<I>>(boost::any_cast<luabridge::LuaRef>(any).cast<CallBackReturn<I>>());
|
||||||
@ -138,11 +138,11 @@ public:
|
|||||||
if (script->script_type == SCRIPT_CPP)
|
if (script->script_type == SCRIPT_CPP)
|
||||||
reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
|
reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
|
||||||
#if defined (ENABLE_PAWN)
|
#if defined (ENABLE_PAWN)
|
||||||
else if(script->script_type == SCRIPT_PAWN)
|
else if (script->script_type == SCRIPT_PAWN)
|
||||||
script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
||||||
#endif
|
#endif
|
||||||
#if defined (ENABLE_LUA)
|
#if defined (ENABLE_LUA)
|
||||||
else if(script->script_type == SCRIPT_LUA)
|
else if (script->script_type == SCRIPT_LUA)
|
||||||
script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
|
||||||
#endif
|
#endif
|
||||||
++count;
|
++count;
|
||||||
|
@ -66,7 +66,7 @@ boost::any ScriptFunction::Call(const vector<boost::any> &args)
|
|||||||
|
|
||||||
cell ret = boost::any_cast<cell>(any);
|
cell ret = boost::any_cast<cell>(any);
|
||||||
|
|
||||||
switch(ret_type)
|
switch (ret_type)
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'i':
|
||||||
result = static_cast<unsigned int>(ret);
|
result = static_cast<unsigned int>(ret);
|
||||||
|
@ -33,8 +33,8 @@ std::string Utils::convertPath(std::string str)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__APPLE__)
|
#if defined(_WIN32) || defined(__APPLE__)
|
||||||
for(auto &ch : str)
|
for (auto &ch : str)
|
||||||
if(ch == '/')
|
if (ch == '/')
|
||||||
ch = _SEP_;
|
ch = _SEP_;
|
||||||
#endif //defined(_WIN32) || defined(__APPLE__)
|
#endif //defined(_WIN32) || defined(__APPLE__)
|
||||||
return str;
|
return str;
|
||||||
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
|
|||||||
loadSettings(mgr);
|
loadSettings(mgr);
|
||||||
|
|
||||||
int logLevel = mgr.getInt("loglevel", "General");
|
int logLevel = mgr.getInt("loglevel", "General");
|
||||||
if(logLevel < Log::LOG_INFO || logLevel > Log::LOG_FATAL)
|
if (logLevel < Log::LOG_INFO || logLevel > Log::LOG_FATAL)
|
||||||
logLevel = Log::LOG_INFO;
|
logLevel = Log::LOG_INFO;
|
||||||
LOG_INIT(logLevel);
|
LOG_INIT(logLevel);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id)
|
|||||||
|
|
||||||
void Players::CleanUp()
|
void Players::CleanUp()
|
||||||
{
|
{
|
||||||
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++)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ void Players::Update(float dt)
|
|||||||
value.readState(pl->CreatureStats()->mDynamic[2]);
|
value.readState(pl->CreatureStats()->mDynamic[2]);
|
||||||
npcStats->setFatigue(value);
|
npcStats->setFatigue(value);
|
||||||
|
|
||||||
if(npcStats->isDead())
|
if (npcStats->isDead())
|
||||||
npcStats->resurrect();
|
npcStats->resurrect();
|
||||||
|
|
||||||
|
|
||||||
@ -274,10 +274,10 @@ void DedicatedPlayer::UpdateInventory()
|
|||||||
const string &dedicItem = EquipedItem(slot)->refid;
|
const string &dedicItem = EquipedItem(slot)->refid;
|
||||||
std::string item = "";
|
std::string item = "";
|
||||||
bool equal = false;
|
bool equal = false;
|
||||||
if(it != invStore.end())
|
if (it != invStore.end())
|
||||||
{
|
{
|
||||||
item = it->getCellRef().getRefId();
|
item = it->getCellRef().getRefId();
|
||||||
if(!Misc::StringUtils::ciEqual(item, dedicItem)) // if other item equiped
|
if (!Misc::StringUtils::ciEqual(item, dedicItem)) // if other item equiped
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore &store = ptr.getClass().getContainerStore(ptr);
|
MWWorld::ContainerStore &store = ptr.getClass().getContainerStore(ptr);
|
||||||
store.remove(item, store.count(item), ptr);
|
store.remove(item, store.count(item), ptr);
|
||||||
@ -353,11 +353,11 @@ const std::string DedicatedPlayer::GetAnim()
|
|||||||
type == ESM::Weapon::MarksmanCrossbow ||
|
type == ESM::Weapon::MarksmanCrossbow ||
|
||||||
type == ESM::Weapon::MarksmanBow*/)
|
type == ESM::Weapon::MarksmanBow*/)
|
||||||
anim_weap = "1h";
|
anim_weap = "1h";
|
||||||
else if(type == ESM::Weapon::LongBladeTwoHand ||
|
else if (type == ESM::Weapon::LongBladeTwoHand ||
|
||||||
type == ESM::Weapon::BluntTwoClose ||
|
type == ESM::Weapon::BluntTwoClose ||
|
||||||
type == ESM::Weapon::AxeTwoHand)
|
type == ESM::Weapon::AxeTwoHand)
|
||||||
anim_weap = "2c";
|
anim_weap = "2c";
|
||||||
else if(type == ESM::Weapon::BluntTwoWide ||
|
else if (type == ESM::Weapon::BluntTwoWide ||
|
||||||
type == ESM::Weapon::SpearTwoWide)
|
type == ESM::Weapon::SpearTwoWide)
|
||||||
anim_weap = "2w";
|
anim_weap = "2w";
|
||||||
}
|
}
|
||||||
@ -376,12 +376,12 @@ DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr)
|
|||||||
{
|
{
|
||||||
std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin();
|
std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin();
|
||||||
|
|
||||||
for(; it != players.end(); it++)
|
for (; it != players.end(); it++)
|
||||||
{
|
{
|
||||||
if(it->second == 0 || it->second->getPtr().mRef == 0)
|
if (it->second == 0 || it->second->getPtr().mRef == 0)
|
||||||
continue;
|
continue;
|
||||||
string refid = ptr.getCellRef().getRefId();
|
string refid = ptr.getCellRef().getRefId();
|
||||||
if(it->second->getPtr().getCellRef().getRefId() == refid)
|
if (it->second->getPtr().getCellRef().getRefId() == refid)
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -392,9 +392,9 @@ void DedicatedPlayer::UpdateDrawState()
|
|||||||
using namespace MWMechanics;
|
using namespace MWMechanics;
|
||||||
if (drawState == 0)
|
if (drawState == 0)
|
||||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing);
|
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing);
|
||||||
else if(drawState == 1)
|
else if (drawState == 1)
|
||||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon);
|
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon);
|
||||||
else if(drawState == 2)
|
else if (drawState == 2)
|
||||||
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell);
|
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell);
|
||||||
|
|
||||||
MWMechanics::NpcStats *npcStats = &ptr.getClass().getNpcStats(ptr);
|
MWMechanics::NpcStats *npcStats = &ptr.getClass().getNpcStats(ptr);
|
||||||
|
@ -80,7 +80,7 @@ namespace mwmp
|
|||||||
void GUIChat::acceptCommand(MyGUI::EditBox *_sender)
|
void GUIChat::acceptCommand(MyGUI::EditBox *_sender)
|
||||||
{
|
{
|
||||||
const std::string &cm = mCommandLine->getOnlyText();
|
const std::string &cm = mCommandLine->getOnlyText();
|
||||||
if(cm.empty()) return;
|
if (cm.empty()) return;
|
||||||
|
|
||||||
// Add the command to the history, and set the current pointer to
|
// Add the command to the history, and set the current pointer to
|
||||||
// the end of the list
|
// the end of the list
|
||||||
@ -150,7 +150,7 @@ namespace mwmp
|
|||||||
windowState++;
|
windowState++;
|
||||||
if (windowState == 3) windowState = 0;
|
if (windowState == 3) windowState = 0;
|
||||||
|
|
||||||
switch(windowState)
|
switch (windowState)
|
||||||
{
|
{
|
||||||
case CHAT_DISABLED:
|
case CHAT_DISABLED:
|
||||||
this->mMainWidget->setVisible(false);
|
this->mMainWidget->setVisible(false);
|
||||||
@ -192,7 +192,7 @@ namespace mwmp
|
|||||||
if (mCommandHistory.empty()) return;
|
if (mCommandHistory.empty()) return;
|
||||||
|
|
||||||
// Traverse history with up and down arrows
|
// Traverse history with up and down arrows
|
||||||
if(key == MyGUI::KeyCode::ArrowUp)
|
if (key == MyGUI::KeyCode::ArrowUp)
|
||||||
{
|
{
|
||||||
// If the user was editing a string, store it for later
|
// If the user was editing a string, store it for later
|
||||||
if (mCurrent == mCommandHistory.end())
|
if (mCurrent == mCommandHistory.end())
|
||||||
@ -206,7 +206,7 @@ namespace mwmp
|
|||||||
}
|
}
|
||||||
else if (key == MyGUI::KeyCode::ArrowDown)
|
else if (key == MyGUI::KeyCode::ArrowDown)
|
||||||
{
|
{
|
||||||
if(mCurrent != mCommandHistory.end())
|
if (mCurrent != mCommandHistory.end())
|
||||||
{
|
{
|
||||||
++mCurrent;
|
++mCurrent;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ mwmp::GUIController::GUIController(): mInputBox(0)
|
|||||||
|
|
||||||
mwmp::GUIController::~GUIController()
|
mwmp::GUIController::~GUIController()
|
||||||
{
|
{
|
||||||
/* if(mChat != nullptr)
|
/* if (mChat != nullptr)
|
||||||
delete mChat;
|
delete mChat;
|
||||||
mChat = nullptr;*/
|
mChat = nullptr;*/
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ void LocalPlayer::updateBaseStats(bool forceUpdate)
|
|||||||
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
|
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
|
||||||
|
|
||||||
static float timer = 0;
|
static float timer = 0;
|
||||||
if(((oldHealth != health || oldMagicka != magicka || oldFatigue != fatigue) &&
|
if (((oldHealth != health || oldMagicka != magicka || oldFatigue != fatigue) &&
|
||||||
(timer += MWBase::Environment::get().getFrameDuration()) >= 0.5 ) || forceUpdate)
|
(timer += MWBase::Environment::get().getFrameDuration()) >= 0.5 ) || forceUpdate)
|
||||||
{
|
{
|
||||||
oldHealth = health;
|
oldHealth = health;
|
||||||
@ -179,16 +179,16 @@ void LocalPlayer::updateInventory(bool forceUpdate)
|
|||||||
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||||
if(it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), EquipedItem(slot)->refid))
|
if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), EquipedItem(slot)->refid))
|
||||||
{
|
{
|
||||||
invChanged = true;
|
invChanged = true;
|
||||||
|
|
||||||
EquipedItem(slot)->refid = it->getCellRef().getRefId();
|
EquipedItem(slot)->refid = it->getCellRef().getRefId();
|
||||||
if(slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
{
|
{
|
||||||
MWMechanics::WeaponType weaptype;
|
MWMechanics::WeaponType weaptype;
|
||||||
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player), player.getClass().getInventoryStore(player), &weaptype);
|
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player), player.getClass().getInventoryStore(player), &weaptype);
|
||||||
if(weaptype != MWMechanics::WeapType_Thrown)
|
if (weaptype != MWMechanics::WeapType_Thrown)
|
||||||
EquipedItem(slot)->count = 1;
|
EquipedItem(slot)->count = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -246,7 +246,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
|
|||||||
}
|
}
|
||||||
attackPressed = true;
|
attackPressed = true;
|
||||||
}
|
}
|
||||||
else if(!world->getPlayer().getAttackingOrSpell() && attackPressed)
|
else if (!world->getPlayer().getAttackingOrSpell() && attackPressed)
|
||||||
{
|
{
|
||||||
if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
|
if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
|
|||||||
else if (state == MWMechanics::DrawState_Spell)
|
else if (state == MWMechanics::DrawState_Spell)
|
||||||
(*DrawState()) = 2;
|
(*DrawState()) = 2;
|
||||||
|
|
||||||
if(jump)
|
if (jump)
|
||||||
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;
|
||||||
@ -474,10 +474,10 @@ void LocalPlayer::CharGen(int stageFirst, int stageEnd)
|
|||||||
bool LocalPlayer::CharGenThread() // ToDo: need fix
|
bool LocalPlayer::CharGenThread() // ToDo: need fix
|
||||||
{
|
{
|
||||||
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||||
if(windowManager->isGuiMode())
|
if (windowManager->isGuiMode())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(CharGenStage()->current >= CharGenStage()->end)
|
if (CharGenStage()->current >= CharGenStage()->end)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (GetNetworking()->isConnected() && CharGenStage()->current == CharGenStage()->end &&
|
if (GetNetworking()->isConnected() && CharGenStage()->current == CharGenStage()->end &&
|
||||||
@ -486,9 +486,10 @@ bool LocalPlayer::CharGenThread() // ToDo: need fix
|
|||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
(*Npc()) = *player.get<ESM::NPC>()->mBase;
|
(*Npc()) = *player.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
|
printf("Sending ID_GAME_BASE_INFO to server with my CharGen info");
|
||||||
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Send(this);
|
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Send(this);
|
||||||
|
|
||||||
if(CharGenStage()->end != 1)
|
if (CharGenStage()->end != 1)
|
||||||
{
|
{
|
||||||
updateBaseStats(true);
|
updateBaseStats(true);
|
||||||
updateAttributesAndSkills(true);
|
updateAttributesAndSkills(true);
|
||||||
|
@ -100,7 +100,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
|
|||||||
errmsg = "Connection attempt failed.\n";
|
errmsg = "Connection attempt failed.\n";
|
||||||
|
|
||||||
bool queue = true;
|
bool queue = true;
|
||||||
while(queue)
|
while (queue)
|
||||||
{
|
{
|
||||||
for (RakNet::Packet *packet = peer->Receive(); packet; peer->DeallocatePacket(
|
for (RakNet::Packet *packet = peer->Receive(); packet; peer->DeallocatePacket(
|
||||||
packet), packet = peer->Receive())
|
packet), packet = peer->Receive())
|
||||||
@ -170,7 +170,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||||||
|
|
||||||
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
|
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
|
||||||
|
|
||||||
switch(packet->data[0])
|
switch (packet->data[0])
|
||||||
{
|
{
|
||||||
case ID_HANDSHAKE:
|
case ID_HANDSHAKE:
|
||||||
{
|
{
|
||||||
@ -183,7 +183,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||||||
if (id == myid)
|
if (id == myid)
|
||||||
{
|
{
|
||||||
cout << "TEST: " << packet->length << endl;
|
cout << "TEST: " << packet->length << endl;
|
||||||
if(packet->length == myPacket->headerSize())
|
if (packet->length == myPacket->headerSize())
|
||||||
{
|
{
|
||||||
cout << "ID_GAME_BASE_INFO request only" << endl;
|
cout << "ID_GAME_BASE_INFO request only" << endl;
|
||||||
myPacket->Send(getLocalPlayer(), serverAddr);
|
myPacket->Send(getLocalPlayer(), serverAddr);
|
||||||
@ -233,7 +233,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||||||
{
|
{
|
||||||
if (id == myid)
|
if (id == myid)
|
||||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||||
else if(pl != 0)
|
else if (pl != 0)
|
||||||
Players::DisconnectPlayer(id);
|
Players::DisconnectPlayer(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||||||
if (pl->GetAttack()->pressed == 0)
|
if (pl->GetAttack()->pressed == 0)
|
||||||
{
|
{
|
||||||
cout << "success: " << (pl->GetAttack()->success == 1);
|
cout << "success: " << (pl->GetAttack()->success == 1);
|
||||||
if(pl->GetAttack()->success == 1)
|
if (pl->GetAttack()->success == 1)
|
||||||
cout << " damage: " << pl->GetAttack()->damage;
|
cout << " damage: " << pl->GetAttack()->damage;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
@ -536,11 +536,11 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
|
|||||||
|
|
||||||
printf("ID_GUI_MESSAGEBOX, Type %d, MSG %s\n", getLocalPlayer()->guiMessageBox.type, getLocalPlayer()->guiMessageBox.label.c_str());
|
printf("ID_GUI_MESSAGEBOX, Type %d, MSG %s\n", getLocalPlayer()->guiMessageBox.type, getLocalPlayer()->guiMessageBox.label.c_str());
|
||||||
|
|
||||||
if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
|
if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
|
||||||
Main::get().getGUIConroller()->ShowMessageBox(getLocalPlayer()->guiMessageBox);
|
Main::get().getGUIConroller()->ShowMessageBox(getLocalPlayer()->guiMessageBox);
|
||||||
else if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
|
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
|
||||||
Main::get().getGUIConroller()->ShowCustomMessageBox(getLocalPlayer()->guiMessageBox);
|
Main::get().getGUIConroller()->ShowCustomMessageBox(getLocalPlayer()->guiMessageBox);
|
||||||
else if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog)
|
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog)
|
||||||
Main::get().getGUIConroller()->ShowInputBox(getLocalPlayer()->guiMessageBox);
|
Main::get().getGUIConroller()->ShowInputBox(getLocalPlayer()->guiMessageBox);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -562,7 +562,7 @@ LocalPlayer *Networking::getLocalPlayer()
|
|||||||
|
|
||||||
bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr)
|
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);
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ 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;
|
||||||
|
@ -97,7 +97,7 @@ namespace mwmp
|
|||||||
|
|
||||||
virtual Item *EquipedItem(int id)
|
virtual Item *EquipedItem(int id)
|
||||||
{
|
{
|
||||||
if(id >= 18) return &equipedItems[18];
|
if (id >= 18) return &equipedItems[18];
|
||||||
return &equipedItems[id];
|
return &equipedItems[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ Log::Log(int logLevel) : logLevel(logLevel)
|
|||||||
|
|
||||||
void Log::Create(int logLevel)
|
void Log::Create(int logLevel)
|
||||||
{
|
{
|
||||||
if(sLog != NULL)
|
if (sLog != NULL)
|
||||||
return;
|
return;
|
||||||
sLog = new Log(logLevel);
|
sLog = new Log(logLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::Delete()
|
void Log::Delete()
|
||||||
{
|
{
|
||||||
if(sLog == NULL)
|
if (sLog == NULL)
|
||||||
return
|
return
|
||||||
delete sLog;
|
delete sLog;
|
||||||
sLog = NULL;
|
sLog = NULL;
|
||||||
@ -52,18 +52,18 @@ const char* getTime()
|
|||||||
|
|
||||||
void Log::print(int level, const char *file, int line, const char *message, ...) const
|
void Log::print(int level, const char *file, int line, const char *message, ...) const
|
||||||
{
|
{
|
||||||
if(level < logLevel) return;
|
if (level < logLevel) return;
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << "[" << getTime() << "] ";
|
sstr << "[" << getTime() << "] ";
|
||||||
|
|
||||||
if(file != 0 && line != 0)
|
if (file != 0 && line != 0)
|
||||||
{
|
{
|
||||||
sstr << "[" << file << ":";
|
sstr << "[" << file << ":";
|
||||||
sstr << line << "] ";
|
sstr << line << "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
sstr << "[";
|
sstr << "[";
|
||||||
switch(level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case LOG_WARN:
|
case LOG_WARN:
|
||||||
sstr << "WARN";
|
sstr << "WARN";
|
||||||
@ -80,7 +80,7 @@ void Log::print(int level, const char *file, int line, const char *message, ...)
|
|||||||
sstr << "]: ";
|
sstr << "]: ";
|
||||||
sstr << message;
|
sstr << message;
|
||||||
char back = *sstr.str().rbegin();
|
char back = *sstr.str().rbegin();
|
||||||
if(back != '\n')
|
if (back != '\n')
|
||||||
sstr << '\n';
|
sstr << '\n';
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, message);
|
va_start(args, message);
|
||||||
|
@ -14,7 +14,7 @@ void BasePacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
|||||||
this->player = player;
|
this->player = player;
|
||||||
this->bs = bs;
|
this->bs = bs;
|
||||||
|
|
||||||
if(send)
|
if (send)
|
||||||
{
|
{
|
||||||
bs->Write(packetID);
|
bs->Write(packetID);
|
||||||
bs->Write(player->guid);
|
bs->Write(player->guid);
|
||||||
@ -73,8 +73,8 @@ void BasePacket::RequestData(RakNet::RakNetGUID player)
|
|||||||
|
|
||||||
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||||
{
|
{
|
||||||
if(inStream != 0)
|
if (inStream != 0)
|
||||||
bsRead = inStream;
|
bsRead = inStream;
|
||||||
if(outStream != 0)
|
if (outStream != 0)
|
||||||
bsSend = outStream;
|
bsSend = outStream;
|
||||||
}
|
}
|
@ -16,6 +16,6 @@ void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
|
|||||||
{
|
{
|
||||||
BasePacket::Packet(bs, player, send);
|
BasePacket::Packet(bs, player, send);
|
||||||
|
|
||||||
for(int i = 0; i < AttributesCount; ++i)
|
for (int i = 0; i < AttributesCount; ++i)
|
||||||
RW(player->CreatureStats()->mAttributes[i], send);
|
RW(player->CreatureStats()->mAttributes[i], send);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ void PacketAttributesAndStats::Packet(RakNet::BitStream *bs, BasePlayer *player,
|
|||||||
{
|
{
|
||||||
BasePacket::Packet(bs, player, send);
|
BasePacket::Packet(bs, player, send);
|
||||||
|
|
||||||
for(int i = 0; i < AttributesCount; ++i)
|
for (int i = 0; i < AttributesCount; ++i)
|
||||||
RW(player->CreatureStats()->mAttributes[i], send);
|
RW(player->CreatureStats()->mAttributes[i], send);
|
||||||
|
|
||||||
for (int i = 0; i < StatsCount; ++i)
|
for (int i = 0; i < StatsCount; ++i)
|
||||||
|
@ -16,7 +16,7 @@ void PacketEquiped::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
|||||||
{
|
{
|
||||||
BasePacket::Packet(bs, player, send);
|
BasePacket::Packet(bs, player, send);
|
||||||
|
|
||||||
for(int i = 0; i < 19; i++)
|
for (int i = 0; i < 19; i++)
|
||||||
{
|
{
|
||||||
RW(player->EquipedItem(i)->refid, send);
|
RW(player->EquipedItem(i)->refid, send);
|
||||||
RW(player->EquipedItem(i)->count, send);
|
RW(player->EquipedItem(i)->count, send);
|
||||||
|
@ -22,7 +22,7 @@ void PacketGUIBoxes::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send
|
|||||||
|
|
||||||
RW(player->guiMessageBox.data, send);
|
RW(player->guiMessageBox.data, send);
|
||||||
|
|
||||||
if(player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
|
if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
|
||||||
RW(player->guiMessageBox.buttons, send);
|
RW(player->guiMessageBox.buttons, send);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
|
|||||||
mwmp::BasePacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
|
mwmp::BasePacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
|
||||||
{
|
{
|
||||||
BasePacket * packet;
|
BasePacket * packet;
|
||||||
switch(id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case ID_GAME_UPDATE_POS:
|
case ID_GAME_UPDATE_POS:
|
||||||
packet = packetPosition;
|
packet = packetPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user