Make formatting consistent, part 2

coverity_scan^2
David Cernat 8 years ago
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(contentOffset < 0)
if (contentOffset < 0)
return "NO_CONTENT"; // no content
tcpInterface.CloseConnection(sa);
return (response.C_String() + contentOffset);

@ -178,7 +178,7 @@ void Networking::Update(RakNet::Packet *packet)
{
DEBUG_PRINTF("ID_GAME_ATTACK\n");
if(!player->CreatureStats()->mDead)
if (!player->CreatureStats()->mDead)
{
myPacket->Read(player);
@ -250,7 +250,7 @@ void Networking::Update(RakNet::Packet *packet)
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
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() + "\n";

@ -9,7 +9,7 @@ TSlots Players::slots;
void Players::DeletePlayer(RakNet::RakNetGUID id)
{
if(players[id] != 0)
if (players[id] != 0)
{
slots[players[id]->GetID()] = 0;
delete players[id];
@ -22,9 +22,9 @@ void Players::NewPlayer(RakNet::RakNetGUID 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]->SetID(i);

@ -220,7 +220,7 @@ bool TimerAPI::IsEndTimer(int timerid)
void TimerAPI::Terminate()
{
for(auto timer : timers)
for (auto timer : timers)
{
if (timer.second != nullptr)
delete timer.second;

@ -16,7 +16,7 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
DEBUG_PRINTF("System: %s", message);
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);
}

@ -235,7 +235,7 @@ int ScriptFunctions::GetAttribute(unsigned short pid, unsigned short attribute)
Player *player;
GET_PLAYER(pid, player, 0);
if(attribute > 7)
if (attribute > 7)
return 0;
return player->CreatureStats()->mAttributes[attribute].mBase;
@ -246,7 +246,7 @@ void ScriptFunctions::SetAttribute(unsigned short pid, unsigned short attribute,
Player *player;
GET_PLAYER(pid, player,);
if(attribute > 7)
if (attribute > 7)
return;
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;
GET_PLAYER(pid, player, 0);
if(attribute > 7)
if (attribute > 7)
return 0;
return player->CreatureStats()->mAttributes[attribute].mCurrent;

@ -66,7 +66,7 @@ void ScriptFunctions::SetCell(unsigned short pid, const char *name) noexcept
Player *player;
GET_PLAYER(pid, player,);
/*if(player->GetCell()->mName == name)
/*if (player->GetCell()->mName == name)
return;*/
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");
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.endNamespace();

@ -128,16 +128,16 @@ cell LangPAWN::CallPublic(AMX *amx, const cell *params) noexcept
}
boost::any result = Public::Call(&name[0], args);
if(result.empty())
if (result.empty())
return 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);
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);
else if(result.type().hash_code() == typeid(double).hash_code())
else if (result.type().hash_code() == typeid(double).hash_code())
ret = amx_ftoc(result);
return ret;

@ -37,7 +37,7 @@ private:
template<typename R>
R GetScript(const char *name)
{
if(script_type == SCRIPT_CPP)
if (script_type == SCRIPT_CPP)
{
return SystemInterface<R>(lang->GetInterface(), name).result;
}
@ -99,14 +99,14 @@ public:
if (script->script_type == SCRIPT_CPP)
result = reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
#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)...);
result = reinterpret_cast<CallBackReturn<I>> ((int)boost::any_cast<int64_t>(any)); // TODO: WTF?! int?!
}
#endif
#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)...);
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)
reinterpret_cast<FunctionEllipsis<CallBackReturn<I>>>(callback)(std::forward<Args>(args)...);
#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)...);
#endif
#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)...);
#endif
++count;

@ -66,7 +66,7 @@ boost::any ScriptFunction::Call(const vector<boost::any> &args)
cell ret = boost::any_cast<cell>(any);
switch(ret_type)
switch (ret_type)
{
case 'i':
result = static_cast<unsigned int>(ret);

@ -33,8 +33,8 @@ std::string Utils::convertPath(std::string str)
#endif
#if defined(_WIN32) || defined(__APPLE__)
for(auto &ch : str)
if(ch == '/')
for (auto &ch : str)
if (ch == '/')
ch = _SEP_;
#endif //defined(_WIN32) || defined(__APPLE__)
return str;

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
loadSettings(mgr);
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;
LOG_INIT(logLevel);

@ -103,7 +103,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id)
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;
}
@ -225,7 +225,7 @@ void Players::Update(float dt)
value.readState(pl->CreatureStats()->mDynamic[2]);
npcStats->setFatigue(value);
if(npcStats->isDead())
if (npcStats->isDead())
npcStats->resurrect();
@ -274,10 +274,10 @@ void DedicatedPlayer::UpdateInventory()
const string &dedicItem = EquipedItem(slot)->refid;
std::string item = "";
bool equal = false;
if(it != invStore.end())
if (it != invStore.end())
{
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);
store.remove(item, store.count(item), ptr);
@ -353,11 +353,11 @@ const std::string DedicatedPlayer::GetAnim()
type == ESM::Weapon::MarksmanCrossbow ||
type == ESM::Weapon::MarksmanBow*/)
anim_weap = "1h";
else if(type == ESM::Weapon::LongBladeTwoHand ||
else if (type == ESM::Weapon::LongBladeTwoHand ||
type == ESM::Weapon::BluntTwoClose ||
type == ESM::Weapon::AxeTwoHand)
anim_weap = "2c";
else if(type == ESM::Weapon::BluntTwoWide ||
else if (type == ESM::Weapon::BluntTwoWide ||
type == ESM::Weapon::SpearTwoWide)
anim_weap = "2w";
}
@ -376,12 +376,12 @@ DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr)
{
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;
string refid = ptr.getCellRef().getRefId();
if(it->second->getPtr().getCellRef().getRefId() == refid)
if (it->second->getPtr().getCellRef().getRefId() == refid)
return it->second;
}
return 0;
@ -392,9 +392,9 @@ void DedicatedPlayer::UpdateDrawState()
using namespace MWMechanics;
if (drawState == 0)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing);
else if(drawState == 1)
else if (drawState == 1)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon);
else if(drawState == 2)
else if (drawState == 2)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell);
MWMechanics::NpcStats *npcStats = &ptr.getClass().getNpcStats(ptr);

@ -80,7 +80,7 @@ namespace mwmp
void GUIChat::acceptCommand(MyGUI::EditBox *_sender)
{
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
// the end of the list
@ -150,7 +150,7 @@ namespace mwmp
windowState++;
if (windowState == 3) windowState = 0;
switch(windowState)
switch (windowState)
{
case CHAT_DISABLED:
this->mMainWidget->setVisible(false);
@ -192,7 +192,7 @@ namespace mwmp
if (mCommandHistory.empty()) return;
// 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 (mCurrent == mCommandHistory.end())
@ -206,7 +206,7 @@ namespace mwmp
}
else if (key == MyGUI::KeyCode::ArrowDown)
{
if(mCurrent != mCommandHistory.end())
if (mCurrent != mCommandHistory.end())
{
++mCurrent;

@ -24,7 +24,7 @@ mwmp::GUIController::GUIController(): mInputBox(0)
mwmp::GUIController::~GUIController()
{
/* if(mChat != nullptr)
/* if (mChat != nullptr)
delete mChat;
mChat = nullptr;*/
}

@ -70,7 +70,7 @@ void LocalPlayer::updateBaseStats(bool forceUpdate)
static MWMechanics::DynamicStat<float> oldFatigue(creatureClass->getFatigue());
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)
{
oldHealth = health;
@ -179,16 +179,16 @@ void LocalPlayer::updateInventory(bool forceUpdate)
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++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;
EquipedItem(slot)->refid = it->getCellRef().getRefId();
if(slot == MWWorld::InventoryStore::Slot_CarriedRight)
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{
MWMechanics::WeaponType 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;
}
else
@ -246,7 +246,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
}
attackPressed = true;
}
else if(!world->getPlayer().getAttackingOrSpell() && attackPressed)
else if (!world->getPlayer().getAttackingOrSpell() && attackPressed)
{
if (/*state == MWMechanics::DrawState_Spell ||*/ state == MWMechanics::DrawState_Weapon)
{
@ -455,7 +455,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
else if (state == MWMechanics::DrawState_Spell)
(*DrawState()) = 2;
if(jump)
if (jump)
mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump;
RakNet::BitStream bs;
@ -474,10 +474,10 @@ void LocalPlayer::CharGen(int stageFirst, int stageEnd)
bool LocalPlayer::CharGenThread() // ToDo: need fix
{
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
if(windowManager->isGuiMode())
if (windowManager->isGuiMode())
return false;
if(CharGenStage()->current >= CharGenStage()->end)
if (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();
(*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);
if(CharGenStage()->end != 1)
if (CharGenStage()->end != 1)
{
updateBaseStats(true);
updateAttributesAndSkills(true);

@ -100,7 +100,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
errmsg = "Connection attempt failed.\n";
bool queue = true;
while(queue)
while (queue)
{
for (RakNet::Packet *packet = peer->Receive(); packet; peer->DeallocatePacket(
packet), packet = peer->Receive())
@ -170,7 +170,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
switch(packet->data[0])
switch (packet->data[0])
{
case ID_HANDSHAKE:
{
@ -183,7 +183,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
if (id == myid)
{
cout << "TEST: " << packet->length << endl;
if(packet->length == myPacket->headerSize())
if (packet->length == myPacket->headerSize())
{
cout << "ID_GAME_BASE_INFO request only" << endl;
myPacket->Send(getLocalPlayer(), serverAddr);
@ -233,7 +233,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
{
if (id == myid)
MWBase::Environment::get().getStateManager()->requestQuit();
else if(pl != 0)
else if (pl != 0)
Players::DisconnectPlayer(id);
}
@ -288,7 +288,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
if (pl->GetAttack()->pressed == 0)
{
cout << "success: " << (pl->GetAttack()->success == 1);
if(pl->GetAttack()->success == 1)
if (pl->GetAttack()->success == 1)
cout << " damage: " << pl->GetAttack()->damage;
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());
if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
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);
else if(getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog)
else if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::InputDialog)
Main::get().getGUIConroller()->ShowInputBox(getLocalPlayer()->guiMessageBox);
}
break;
@ -562,7 +562,7 @@ LocalPlayer *Networking::getLocalPlayer()
bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr)
{
if(ptr.mRef == 0)
if (ptr.mRef == 0)
return 0;
DedicatedPlayer *pl = Players::GetPlayer(ptr);
@ -573,7 +573,7 @@ bool Networking::Attack(const MWWorld::Ptr &ptr)
{
DedicatedPlayer *pl = Players::GetPlayer(ptr);
if(pl == 0)
if (pl == 0)
return false;
return pl->GetAttack()->pressed;

@ -97,7 +97,7 @@ namespace mwmp
virtual Item *EquipedItem(int id)
{
if(id >= 18) return &equipedItems[18];
if (id >= 18) return &equipedItems[18];
return &equipedItems[id];
}

@ -21,14 +21,14 @@ Log::Log(int logLevel) : logLevel(logLevel)
void Log::Create(int logLevel)
{
if(sLog != NULL)
if (sLog != NULL)
return;
sLog = new Log(logLevel);
}
void Log::Delete()
{
if(sLog == NULL)
if (sLog == NULL)
return
delete sLog;
sLog = NULL;
@ -52,18 +52,18 @@ const char* getTime()
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;
sstr << "[" << getTime() << "] ";
if(file != 0 && line != 0)
if (file != 0 && line != 0)
{
sstr << "[" << file << ":";
sstr << line << "] ";
}
sstr << "[";
switch(level)
switch (level)
{
case LOG_WARN:
sstr << "WARN";
@ -80,7 +80,7 @@ void Log::print(int level, const char *file, int line, const char *message, ...)
sstr << "]: ";
sstr << message;
char back = *sstr.str().rbegin();
if(back != '\n')
if (back != '\n')
sstr << '\n';
va_list args;
va_start(args, message);

@ -14,7 +14,7 @@ void BasePacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
this->player = player;
this->bs = bs;
if(send)
if (send)
{
bs->Write(packetID);
bs->Write(player->guid);
@ -73,8 +73,8 @@ void BasePacket::RequestData(RakNet::RakNetGUID player)
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
{
if(inStream != 0)
if (inStream != 0)
bsRead = inStream;
if(outStream != 0)
if (outStream != 0)
bsSend = outStream;
}

@ -16,6 +16,6 @@ void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
{
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);
}

@ -17,7 +17,7 @@ void PacketAttributesAndStats::Packet(RakNet::BitStream *bs, BasePlayer *player,
{
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);
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);
for(int i = 0; i < 19; i++)
for (int i = 0; i < 19; i++)
{
RW(player->EquipedItem(i)->refid, 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);
if(player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
RW(player->guiMessageBox.buttons, send);
}

@ -55,7 +55,7 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
mwmp::BasePacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
{
BasePacket * packet;
switch(id)
switch (id)
{
case ID_GAME_UPDATE_POS:
packet = packetPosition;

Loading…
Cancel
Save