[General] Fix typos and use consistent style for recent additions

sol2-server-rewrite
David Cernat 7 years ago
parent 051f65a4d5
commit ad61d88cb1

@ -52,7 +52,7 @@ Cell *CellController::getCell(ESM::Cell *esmCell)
Cell *CellController::getCellByXY(int x, int y)
{
auto it = find_if (cells.begin(), cells.end(), [x, y](const Cell *c)
auto it = find_if(cells.begin(), cells.end(), [x, y](const Cell *c)
{
return c->cell.mData.mX == x && c->cell.mData.mY == y;
});
@ -68,7 +68,7 @@ Cell *CellController::getCellByXY(int x, int y)
Cell *CellController::getCellByName(std::string cellName)
{
auto it = find_if (cells.begin(), cells.end(), [cellName](const Cell *c)
auto it = find_if(cells.begin(), cells.end(), [cellName](const Cell *c)
{
return c->cell.mName == cellName;
});
@ -85,7 +85,7 @@ Cell *CellController::getCellByName(std::string cellName)
Cell *CellController::addCell(ESM::Cell cellData)
{
LOG_APPEND(Log::LOG_INFO, "- Loaded cells: %d", cells.size());
auto it = find_if (cells.begin(), cells.end(), [cellData](const Cell *c) {
auto it = find_if(cells.begin(), cells.end(), [cellData](const Cell *c) {
// Currently we cannot compare because plugin lists can be loaded in different order
//return c->cell.sRecordId == cellData.sRecordId;
if (c->cell.isExterior() && cellData.isExterior())

@ -123,7 +123,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (packet->data[0] == ID_LOADED)
{
player->setLoadState(Player::LOADED);
player->joinToChannel(0, "Default");
player->joinChannel(0, "Default");
bool result = luaState.getEventCtrl().Call<CoreEvent::ON_PLAYER_CONNECT, bool>(player);
@ -561,9 +561,9 @@ unsigned Networking::createChannel()
{
static unsigned lastChatId = 0;
unsigned id = 0;
for(auto &channel : chatChannels)
for (auto &channel : chatChannels)
{
if(channel.second == nullptr)
if (channel.second == nullptr)
id = channel.first;
}

@ -41,13 +41,13 @@ void Player::Init(LuaState &lua)
"getAvgPing", &Player::getAvgPing,
"message", &Player::message,
"joinToChannel", &Player::joinToChannel,
"joinChannel", &Player::joinChannel,
"cleanChannel", &Player::cleanChannel,
"renameChannel", &Player::renameChannel,
"closeChannel", &Player::closeChannel,
"leaveChannel", &Player::leaveChannel,
"setChannel", &Player::setChannel,
"isChannelOpened", &Player::isChannelOpened,
"isChannelOpen", &Player::isChannelOpen,
"pid", sol::readonly_property(&Player::id),
"guid", sol::readonly_property(&Player::getGUID),
@ -99,7 +99,7 @@ void Player::Init(LuaState &lua)
"createChannel", 0,
"joinChannel", 1,
"closeChannel", 2,
"leftChannel", 3);
"leaveChannel", 3);
}
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid), NetActor(), changedMap(false), cClass(this),
@ -372,7 +372,7 @@ void Player::setCharGenStages(int currentStage, int endStage)
void Player::message(unsigned channelId, const std::string &message, bool toAll)
{
if (isChannelOpened(channelId))
if (isChannelOpen(channelId))
{
mwmp::Chat tmp;
tmp.action = mwmp::Chat::Action::print;
@ -407,7 +407,7 @@ void Player::message(unsigned channelId, const std::string &message, bool toAll)
}
}
bool Player::joinToChannel(unsigned channelId, const std::string &name)
bool Player::joinChannel(unsigned channelId, const std::string &name)
{
auto channel = mwmp::Networking::get().getChannel(channelId);
@ -419,7 +419,7 @@ bool Player::joinToChannel(unsigned channelId, const std::string &name)
if (auto member = weakMember.lock())
{
if (member->guid == guid)
return false; // player already member of the channel
return false; // the player is already a member of the channel
}
}
auto thisPl = Players::getPlayerByGUID(guid);
@ -438,7 +438,7 @@ bool Player::joinToChannel(unsigned channelId, const std::string &name)
void Player::renameChannel(unsigned channelId, const std::string &name)
{
if (isChannelOpened(channelId))
if (isChannelOpen(channelId))
{
chat.action = mwmp::Chat::Action::renamechannel;
chat.channel = channelId;
@ -462,16 +462,16 @@ void Player::leaveChannel(unsigned channelId)
packet->Send(false);
mwmp::Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_CHANNEL_ACTION>(this, channelId, 2); // leaved channel
mwmp::Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_CHANNEL_ACTION>(this, channelId, 2); // left the channel
}
void Player::closeChannel(unsigned channelId)
{
auto channel = mwmp::Networking::get().getChannel(channelId);
for(auto &weakMember : channel->members) // kick members from channel before deleting channel
for (auto &weakMember : channel->members) // kick the channel's members before deleting it
{
if(auto member = weakMember.lock())
if (auto member = weakMember.lock())
member->leaveChannel(channelId);
}
@ -483,7 +483,7 @@ void Player::closeChannel(unsigned channelId)
void Player::setChannel(unsigned channelId)
{
if (isChannelOpened(channelId))
if (isChannelOpen(channelId))
{
chat.action = mwmp::Chat::Action::setchannel;
chat.channel = channelId;
@ -496,12 +496,12 @@ void Player::setChannel(unsigned channelId)
}
}
bool Player::isChannelOpened(unsigned channelId)
bool Player::isChannelOpen(unsigned channelId)
{
auto channel = mwmp::Networking::get().getChannel(channelId);
auto it = std::find_if(channel->members.begin(), channel->members.end(), [this](const auto &weakMember){
if(auto member = weakMember.lock())
if (auto member = weakMember.lock())
return member->guid == guid;
return false;
});

@ -78,12 +78,12 @@ public:
void cleanChannel(unsigned channelId);
void message(unsigned channelId, const std::string &message, bool toAll = false);
bool joinToChannel(unsigned channelId, const std::string &name);
bool joinChannel(unsigned channelId, const std::string &name);
void renameChannel(unsigned channelId, const std::string &name);
void closeChannel(unsigned channelId);
void leaveChannel(unsigned channelId);
void setChannel(unsigned channelId);
bool isChannelOpened(unsigned channelId);
bool isChannelOpen(unsigned channelId);
int getAvgPing();

@ -141,7 +141,7 @@ void EventController::raiseEvent(Event id, sol::table data, const string &module
{
if (!moduleName.empty())
{
auto f = std::find_if (iter->second.begin(), iter->second.end(), [&moduleName](const auto &item){
auto f = std::find_if(iter->second.begin(), iter->second.end(), [&moduleName](const auto &item){
return item.first["ModuleName"]["name"] == moduleName;
});
if (f != iter->second.end())

@ -35,9 +35,9 @@ namespace mwmp
getWidget(mCommandLine, "edit_Command");
getWidget(mHistory, "list_History");
getWidget(mChannelPrevBtn, "btn_prev_ch");
mChannelPrevBtn->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIChat::prevChannels);
mChannelPrevBtn->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIChat::prevChannel);
getWidget(mChannelNextBtn, "btn_next_ch");
mChannelNextBtn->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIChat::nextChannels);
mChannelNextBtn->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIChat::nextChannel);
getWidget(mBoxChannels, "box_channels");
for (int i = 0; i < 3; ++i)
@ -67,7 +67,7 @@ namespace mwmp
currentChannel = 0;
addChannel(0, "Default");
setChannel(0);
redrawChnnels();
redrawChannels();
defaultColor = mChannelPrevBtn->getTextColour();
}
@ -198,12 +198,12 @@ namespace mwmp
void GUIChat::clean(unsigned channelId)
{
if(channelId == currentChannel)
if (channelId == currentChannel)
mHistory->setCaption("");
else
{
auto it = getChannel(channelId);
if(it != channels.end())
if (it != channels.end())
{
it->channelText.clear();
}
@ -313,7 +313,7 @@ namespace mwmp
}
static float time = 0;
time += dt;
if(time >= 1)
if (time >= 1)
{
time = 0;
static bool phase = false;
@ -321,20 +321,20 @@ namespace mwmp
auto color = phase ? MyGUI::Colour::Blue : defaultColor;
for(auto it = channels.begin(); it != channels.end(); ++it)
for (auto it = channels.begin(); it != channels.end(); ++it)
{
if(!it->newMessages || it->channel == currentChannel)
if (!it->newMessages || it->channel == currentChannel)
continue;
long pos = it - channels.begin();
if(pos < page * pageM)
if (pos < page * pageM)
mChannelPrevBtn->setTextColour(color);
else if(pos >= page * pageM + 3)
else if (pos >= page * pageM + 3)
mChannelNextBtn->setTextColour(color);
else
{
for(auto &btn : mChannelBtns)
for (auto &btn : mChannelBtns)
{
if (it->channelName != btn->getCaption().asUTF8())
continue;
@ -364,21 +364,21 @@ namespace mwmp
void GUIChat::addChannel(unsigned ch, const std::string &name)
{
auto channel = getChannel(ch);
if(channel == channels.end())
if (channel == channels.end())
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Adding channel id: %d %s", ch, name);
channels.push_back(ChannelData{ch, name.substr(0, 9), "", false});
}
redrawChnnels();
redrawChannels();
}
void GUIChat::renameChannel(unsigned ch, const std::string &newName)
{
auto it = getChannel(ch);
if(it != channels.end())
if (it != channels.end())
{
it->channelName = newName.substr(0, 9);
redrawChnnels();
redrawChannels();
}
}
@ -409,7 +409,7 @@ namespace mwmp
mHistory->setCaption(it->channelText);
currentChannel = it->channel;
redrawChnnels();
redrawChannels();
}
void GUIChat::closeChannel(unsigned ch)
@ -424,10 +424,10 @@ namespace mwmp
setChannel(0, false); // reset to default channel
channels.erase(it);
}
redrawChnnels();
redrawChannels();
}
void GUIChat::redrawChnnels()
void GUIChat::redrawChannels()
{
mChannelPrevBtn->setVisible(page != 0);
mChannelNextBtn->setVisible(channels.size() > 3 && page != lastPage());
@ -466,19 +466,19 @@ namespace mwmp
}
}
void GUIChat::nextChannels(MyGUI::Widget* _sender)
void GUIChat::nextChannel(MyGUI::Widget* _sender)
{
page++;
if (page > lastPage())
page = lastPage();
redrawChnnels();
redrawChannels();
}
void GUIChat::prevChannels(MyGUI::Widget* _sender)
void GUIChat::prevChannel(MyGUI::Widget* _sender)
{
if (page > 0)
page--;
redrawChnnels();
redrawChannels();
}
void GUIChat::onClickChannel(MyGUI::Widget *_sender)

@ -77,10 +77,10 @@ namespace mwmp
void renameChannel(unsigned ch, const std::string &channel);
void setChannel(unsigned ch, bool saveHistory = true);
void closeChannel(unsigned ch);
void redrawChnnels();
void redrawChannels();
unsigned lastPage();
void nextChannels(MyGUI::Widget* _sender);
void prevChannels(MyGUI::Widget* _sender);
void nextChannel(MyGUI::Widget* _sender);
void prevChannel(MyGUI::Widget* _sender);
void onClickChannel(MyGUI::Widget* _sender);
protected:

@ -90,7 +90,7 @@ void GUICustomWindow::addPassiveData(vector<BasePlayer::GUIWindow::Widget> &widg
if (selected != MyGUI::ITEM_NONE)
{
auto name = list->getUserData<string>(false);
if(name != nullptr)
if (name != nullptr)
{
BasePlayer::GUIWindow::Widget widget;
widget.name = *name;
@ -104,7 +104,7 @@ void GUICustomWindow::addPassiveData(vector<BasePlayer::GUIWindow::Widget> &widg
for (auto &&slider : sliders)
{
auto name = slider->getUserData<string>(false);
if(name != nullptr)
if (name != nullptr)
{
BasePlayer::GUIWindow::Widget widget;
widget.name = *name;
@ -161,14 +161,14 @@ void GUICustomWindow::itemActivated(MyGUI::ListPtr sender, size_t index)
{
/*printf("---------Item Activated---------\n");
auto str = sender->getUserData<string>(false);
if(str != nullptr)
if (str != nullptr)
printf("ID: %s\n", str->c_str());
printf("item: %zu\n", index);
printf("value of item: %s\n", sender->getItemNameAt(index).asUTF8_c_str());
printf("--------------------------------\n");*/
auto str = sender->getUserData<string>(false);
if(str != nullptr)
if (str != nullptr)
{
BasePlayer::GUIWindow::Widget pressedListBox;
pressedListBox.name = *str;
@ -238,7 +238,7 @@ void GUICustomWindow::addEditBox(const BasePlayer::GUIWindow::Widget &widget)
editBox->setSize(widget.width, widget.height);
editBox->setUserData(string(widget.name)); // ID
editBox->setEnabled(!widget.disabled);
if(!widget.disabled)
if (!widget.disabled)
boxes.push_back(editBox);
}
@ -269,7 +269,7 @@ void GUICustomWindow::addListBox(const BasePlayer::GUIWindow::Widget &widget)
MyGUI::Align::Default
);
for(const auto & item : widget.data)
for (const auto & item : widget.data)
lbox->addItem(item);
lbox->setUserData(widget.name);
@ -278,7 +278,7 @@ void GUICustomWindow::addListBox(const BasePlayer::GUIWindow::Widget &widget)
lbox->setSize(widget.width, widget.height);
lbox->setEnabled(!widget.disabled);
if(!widget.disabled)
if (!widget.disabled)
{
if (widget.type == BasePlayer::GUIWindow::WidgetType::ListBoxPassive)
lists.push_back(lbox);

@ -190,7 +190,7 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa
void mwmp::GUIController::showCustomWindow(const mwmp::BasePlayer::GUIWindow &guiMessageBox)
{
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
if(mCustomWindow != nullptr)
if (mCustomWindow != nullptr)
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Deleting mCustomWindow");
windowManager->removeDialog(mCustomWindow);
windowManager->pushGuiMode((MWGui::GuiMode)GM_TES3MP_CustomWindow);
@ -221,7 +221,7 @@ bool mwmp::GUIController::pressedKey(int key)
if (mChat == nullptr || windowManager->getMode() != MWGui::GM_None)
return false;
if(key == SDL_SCANCODE_F2 && (SDL_GetModState() & KMOD_CTRL) > 0)
if (key == SDL_SCANCODE_F2 && (SDL_GetModState() & KMOD_CTRL) > 0)
{
mChat->switchNetstat();
return true;

@ -477,7 +477,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
auto result = ptrInventory.begin();
for (; result != ptrInventory.end(); ++result)
{
if(setItem(item, *result))
if (setItem(item, *result))
continue;
if (item == itemOld)
@ -495,7 +495,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
{
for (const auto &iter : ptrInventory)
{
if(setItem(item, iter))
if (setItem(item, iter))
continue;
auto items = inventoryChanges.items;

Loading…
Cancel
Save