[General] Use consistent code style

new-script-api
David Cernat 7 years ago
parent eff3504b05
commit 720ef5f6c5

@ -241,7 +241,7 @@ void ActorController::sendList(std::shared_ptr<Player> player, std::vector<std::
actorList.guid = player->guid;
actorList.action = mwmp::BaseActorList::SET;
for(auto &actor : actors)
for (auto &actor : actors)
{
actorList.baseActors.push_back(actor->actor);
}

@ -106,16 +106,16 @@ std::shared_ptr<Window> GUI::createWindow(short x, short y, sol::function fn, so
{
int id = 0;
for(auto &window : windows)
for (auto &window : windows)
{
if(window.second == nullptr)
if (window.second == nullptr)
{
id = window.first;
break;
}
}
if(id == 0)
if (id == 0)
id = lastWindowId++;
auto window = std::make_shared<Window>(player, id);
@ -129,7 +129,7 @@ std::shared_ptr<Window> GUI::createWindow(short x, short y, sol::function fn, so
void GUI::deleteWindow(std::shared_ptr<Window> window)
{
auto it = windows.find(window->getID());
if(it != windows.end())
if (it != windows.end())
{
it->second = nullptr;
}
@ -138,7 +138,7 @@ void GUI::deleteWindow(std::shared_ptr<Window> window)
void GUI::onGUIWindowAction()
{
auto it = windows.find(player->guiWindow.id);
if(it != windows.end() && it->second != nullptr)
if (it != windows.end() && it->second != nullptr)
{
it->second->call(player->guiWindow);
}

@ -114,7 +114,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!player->isHandshaked())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId());
if(player->handshakeAttempts() > 5)
if (player->handshakeAttempts() > 5)
kickPlayer(player->guid);
return;
}

@ -280,7 +280,7 @@ shared_ptr<vector<shared_ptr<Object>>> ObjectController::copyObjects(mwmp::BaseE
{
auto objects = make_shared<vector<shared_ptr<Object>>>();
for(auto &obj : event.worldObjects)
for (auto &obj : event.worldObjects)
{
auto object = new Object;
object->copied = true;
@ -294,7 +294,7 @@ shared_ptr<vector<shared_ptr<Container>>> ObjectController::copyContainers(mwmp:
{
auto containers = make_shared<vector<shared_ptr<Container>>>();
for(auto &obj : event.worldObjects)
for (auto &obj : event.worldObjects)
{
auto container = new Container;
container->copied = true;
@ -321,7 +321,7 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
mwmp::BaseEvent events[Type::LAST];
bool changed[Type::LAST];
for(auto &e : events)
for (auto &e : events)
{
e.action = mwmp::BaseEvent::SET;
e.guid = player->guid;
@ -329,48 +329,48 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
}
for(auto &object : *objects)
for (auto &object : *objects)
{
//sendObject(player.get(), object.get());
bool validNewObjOrCopy = (!object->copied && object->changedBase) || object->copied;
if(object->changedDoorState && validNewObjOrCopy)
if (object->changedDoorState && validNewObjOrCopy)
{
changed[Type::DOOR_STATE] = true;
events[Type::DOOR_STATE].worldObjects.push_back(object->object);
}
if(object->changedObjectState && validNewObjOrCopy)
if (object->changedObjectState && validNewObjOrCopy)
{
changed[Type::OBJECT_STATE] = true;
events[Type::OBJECT_STATE].worldObjects.push_back(object->object);
}
if(object->changedObjectScale && validNewObjOrCopy)
if (object->changedObjectScale && validNewObjOrCopy)
{
changed[Type::OBJECT_SCALE] = true;
events[Type::OBJECT_SCALE].worldObjects.push_back(object->object);
}
if(object->changedObjectTrap && validNewObjOrCopy)
if (object->changedObjectTrap && validNewObjOrCopy)
{
changed[Type::OBJECT_TRAP] = true;
events[Type::OBJECT_TRAP].worldObjects.push_back(object->object);
}
if(object->changedObjectLock && validNewObjOrCopy)
if (object->changedObjectLock && validNewObjOrCopy)
{
changed[Type::OBJECT_LOCK] = true;
events[Type::OBJECT_LOCK].worldObjects.push_back(object->object);
}
if(object->changedObjectDelete && validNewObjOrCopy)
if (object->changedObjectDelete && validNewObjOrCopy)
{
changed[Type::OBJECT_DELETE] = true;
events[Type::OBJECT_DELETE].worldObjects.push_back(object->object);
}
if(object->changedObjectSpawn && validNewObjOrCopy)
if (object->changedObjectSpawn && validNewObjOrCopy)
{
changed[Type::OBJECT_SPAWN] = true;
events[Type::OBJECT_SPAWN].worldObjects.push_back(object->object);
}
if(object->changedObjectPlace && validNewObjOrCopy)
if (object->changedObjectPlace && validNewObjOrCopy)
{
changed[Type::OBJECT_PLACE] = true;
events[Type::OBJECT_PLACE].worldObjects.push_back(object->object);
@ -379,56 +379,56 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
auto worldCtrl = mwmp::Networking::get().getWorldPacketController();
if(changed[Type::DOOR_STATE])
if (changed[Type::DOOR_STATE])
{
auto packet = worldCtrl->GetPacket(ID_DOOR_STATE);
auto &event = events[Type::DOOR_STATE];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_STATE])
if (changed[Type::OBJECT_STATE])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_STATE);
auto &event = events[Type::OBJECT_STATE];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_SCALE])
if (changed[Type::OBJECT_SCALE])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_SCALE);
auto &event = events[Type::OBJECT_SCALE];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_TRAP])
if (changed[Type::OBJECT_TRAP])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_TRAP);
auto &event = events[Type::OBJECT_TRAP];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_LOCK])
if (changed[Type::OBJECT_LOCK])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_LOCK);
auto &event = events[Type::OBJECT_LOCK];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_DELETE])
if (changed[Type::OBJECT_DELETE])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_DELETE);
auto &event = events[Type::OBJECT_DELETE];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_SCALE])
if (changed[Type::OBJECT_SCALE])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_SPAWN);
auto &event = events[Type::OBJECT_SCALE];
packet->setEvent(&event);
packet->Send(event.guid);
}
if(changed[Type::OBJECT_PLACE])
if (changed[Type::OBJECT_PLACE])
{
auto packet = worldCtrl->GetPacket(ID_OBJECT_PLACE);
auto &event = events[Type::OBJECT_PLACE];
@ -445,10 +445,10 @@ void ObjectController::sendContainers(shared_ptr<Player> player, shared_ptr<vect
event.action = mwmp::BaseEvent::SET;
event.guid = player->guid;
for(auto &object : *objects)
for (auto &object : *objects)
{
bool validNewObjOrCopy = (!object->copied && object->changedBase) || object->copied;
if(object->changed && validNewObjOrCopy)
if (object->changed && validNewObjOrCopy)
event.worldObjects.push_back(object->object);
}

@ -90,9 +90,9 @@ public:
{
lastCalled = functions.end();
_stop = false;
for(CIterator iter = functions.begin(); iter != functions.end(); ++iter)
for (CIterator iter = functions.begin(); iter != functions.end(); ++iter)
{
if(!_stop)
if (!_stop)
iter->second.call(std::forward<Args>(args)...);
else
{
@ -110,7 +110,7 @@ public:
lastCalled = functions.end();
_stop = false;
for(CIterator iter = functions.begin(); iter != functions.end(); ++iter)
for (CIterator iter = functions.begin(); iter != functions.end(); ++iter)
{
if (!_stop)
ret = iter->second.call(std::forward<Args>(args)...);
@ -152,4 +152,4 @@ private:
Container events;
Event lastEvent = CoreEvent::LAST;
LuaState *luaCtrl;
};
};

@ -405,7 +405,7 @@ void checkDependencies(const vector<ServerPluginInfo> &mods, const ServerPluginI
stringstream sstr;
sstr << depNameRequest << ": version \"" << depVersionFound << "\" is not applicable for \""
<< spi.name << "\" expected \"" << depVersionRequest + "\"";
if(fatal)
if (fatal)
throw runtime_error(sstr.str());
else
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", sstr.str().c_str());
@ -415,7 +415,7 @@ void checkDependencies(const vector<ServerPluginInfo> &mods, const ServerPluginI
{
stringstream sstr;
sstr << depNameRequest + " \"" << depVersionRequest << "\" not found.";
if(fatal)
if (fatal)
throw runtime_error(sstr.str());
else
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", sstr.str().c_str());
@ -512,7 +512,7 @@ void LuaState::loadMods(const std::string &modDir, std::vector<std::string> *lis
modInfo.author = pt.get<string>("author");
modInfo.version = pt.get<string>("version");
for(const auto &v : pt.get_child("dependencies"))
for (const auto &v : pt.get_child("dependencies"))
modInfo.dependencies.emplace_back(v.first, v.second.get_value<string>());
auto name = pt.get<string>("name");

@ -98,12 +98,12 @@ void Window::call(const BasePlayer::GUIWindow &window)
void Window::setCallback(sol::function callback)
{
/*int id = 0;
for(auto &&cb : callbacks)
for (auto &&cb : callbacks)
{
if(cb.second.get() == nullptr)
if (cb.second.get() == nullptr)
id = cb.first;
}
if(id == 0)
if (id == 0)
id = lastId++;
callbacks[id] = make_unique(callback);*/
this->callback = callback;
@ -122,7 +122,7 @@ void Window::addButton(short x, short y, const std::string &label, sol::optional
widget.posY = y;
widget.name = label;
widget.type = BasePlayer::GUIWindow::WidgetType::Button;
if(active)
if (active)
widget.disabled = !active.value();
else
widget.disabled = false;
@ -138,7 +138,7 @@ void Window::addEditBox(short x, short y, short w, short h, const std::string &i
widget.height = h;
widget.name = id;
widget.type = BasePlayer::GUIWindow::WidgetType::Editbox;
if(active)
if (active)
widget.disabled = !active.value();
else
widget.disabled = false;
@ -166,7 +166,7 @@ void Window::addPassiveListBox(short x, short y, short w, short h, const std::st
widget.name = id;
widget.type = BasePlayer::GUIWindow::WidgetType::ListBoxPassive;
if(active)
if (active)
widget.disabled = !active.value();
else
widget.disabled = false;
@ -187,7 +187,7 @@ void Window::addActiveListBox(short x, short y, short w, short h, const std::str
widget.height = h;
widget.name = id;
widget.type = BasePlayer::GUIWindow::WidgetType::ListBoxActive;
if(active)
if (active)
widget.disabled = !active.value();
else
widget.disabled = false;
@ -207,7 +207,7 @@ void Window::addSlider(short x, short y, short w, short h, const std::string &id
widget.height = h;
widget.name = id;
widget.type = BasePlayer::GUIWindow::WidgetType::Slider;
if(active)
if (active)
widget.disabled = !active.value();
else
widget.disabled = false;

@ -36,10 +36,10 @@ namespace mwmp
inline void copyCreatureStats(ESM::CreatureStats &stats)
{
for(int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
creatureStats.mDynamic[i] = stats.mDynamic[i];
for(int i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
creatureStats.mAttributes[i] = stats.mAttributes[i];
creatureStats.mLevel = stats.mLevel;

@ -48,13 +48,13 @@ mwmp::ActorPacket *mwmp::ActorPacketController::GetPacket(RakNet::MessageID id)
void mwmp::ActorPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
packet.second->SetStreams(inStream, outStream);
}
bool mwmp::ActorPacketController::ContainsPacket(RakNet::MessageID id)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
{
if (packet.first == id)
return true;

@ -102,13 +102,13 @@ mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id
void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
packet.second->SetStreams(inStream, outStream);
}
bool mwmp::PlayerPacketController::ContainsPacket(RakNet::MessageID id)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
{
if (packet.first == id)
return true;

@ -63,13 +63,13 @@ mwmp::WorldPacket *mwmp::WorldPacketController::GetPacket(RakNet::MessageID id)
void mwmp::WorldPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
packet.second->SetStreams(inStream, outStream);
}
bool mwmp::WorldPacketController::ContainsPacket(RakNet::MessageID id)
{
for(const auto &packet : packets)
for (const auto &packet : packets)
{
if (packet.first == id)
return true;

@ -126,7 +126,7 @@ public:
}
std::string str = Message(message, std::forward<Args&&>(args)...);
if(str.back() != '\n')
if (str.back() != '\n')
std::cout << str << std::endl;
else
std::cout << str << std::flush;

@ -27,7 +27,7 @@ void PacketGUIWindow::Packet(RakNet::BitStream *bs, bool send)
size = static_cast<int32_t>(player->guiWindow.widgets.size());
RW(size, send);
if(!send)
if (!send)
player->guiWindow.widgets.resize(size);
@ -42,7 +42,7 @@ void PacketGUIWindow::Packet(RakNet::BitStream *bs, bool send)
{
RW(widget.disabled, send);
if(widget.type != BasePlayer::GUIWindow::WidgetType::Button)
if (widget.type != BasePlayer::GUIWindow::WidgetType::Button)
{
RW(widget.width, send);
RW(widget.height, send);

@ -28,12 +28,12 @@ void PacketPlayerActiveSkills::Packet(RakNet::BitStream *bs, bool send)
RW(spell.second.mTimeStamp, send);
uint32_t effectsCount;
if(send)
if (send)
effectsCount = static_cast<uint32_t>(spell.second.mEffects.size());
RW(effectsCount, send);
if(!send)
if (!send)
spell.second.mEffects.resize(effectsCount);
for (auto &&effect : spell.second.mEffects)

@ -19,7 +19,7 @@ void PacketPlayerAttribute::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->attributeChanges.attributeIndexes.clear();
player->attributeChanges.attributeIndexes.resize(count);

@ -20,7 +20,7 @@ void PacketPlayerBook::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->bookChanges.books.clear();
player->bookChanges.books.resize(count);

@ -21,7 +21,7 @@ void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->cellStateChanges.cellStates.clear();
player->cellStateChanges.cellStates.resize(count);

@ -22,7 +22,7 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->factionChanges.factions.clear();
player->factionChanges.factions.resize(count);

@ -26,7 +26,7 @@ void PacketPlayerInventory::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->inventoryChanges.items.clear();
player->inventoryChanges.items.resize(count);

@ -20,7 +20,7 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->journalChanges.journalItems.clear();
player->journalChanges.journalItems.resize(count);

@ -17,7 +17,7 @@ void mwmp::PacketPlayerKillCount::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->killChanges.kills.clear();
player->killChanges.kills.resize(count);

@ -20,7 +20,7 @@ void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->mapChanges.cellsExplored.clear();
player->mapChanges.cellsExplored.resize(count);

@ -25,7 +25,7 @@ void PacketPlayerSkill::Packet(RakNet::BitStream *bs, bool send)
RW(count, send);
if(!send)
if (!send)
{
player->skillChanges.skillIndexes.clear();
player->skillChanges.skillIndexes.resize(count);

@ -22,7 +22,7 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
RW(changesCount, send);
if(!send)
if (!send)
{
player->spellbookChanges.spells.clear();
player->spellbookChanges.spells.resize(changesCount);
@ -33,7 +33,7 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
RW(spell.mId, send, true);
if(spell.mId.find("$dynamic") != string::npos)
if (spell.mId.find("$dynamic") != string::npos)
{
RW(spell.mName, send, true);

@ -28,7 +28,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
RW(worldObject.containerItemCount, send);
if(!send)
if (!send)
{
worldObject.containerItems.clear();
worldObject.containerItems.resize(worldObject.containerItemCount);
@ -41,7 +41,7 @@ void PacketContainer::Packet(RakNet::BitStream *bs, bool send)
return;
}
for(auto &&containerItem: worldObject.containerItems)
for (auto &&containerItem: worldObject.containerItems)
{
RW(containerItem.refId, send);
RW(containerItem.count, send);

@ -54,7 +54,7 @@ bool WorldPacket::PacketHeader(RakNet::BitStream *bs, bool send)
return false;
}
if(!send)
if (!send)
{
event->worldObjects.resize(event->worldObjectCount);
}

Loading…
Cancel
Save