summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/charcreatedialog.cpp1
-rw-r--r--src/gui/windows/charselectdialog.cpp41
-rw-r--r--src/gui/windows/chatwindow.cpp2
-rw-r--r--src/gui/windows/clanwindow.cpp1
-rw-r--r--src/gui/windows/connectiondialog.cpp1
-rw-r--r--src/gui/windows/debugwindow.cpp1
-rw-r--r--src/gui/windows/equipmentwindow.cpp1
-rw-r--r--src/gui/windows/inventorywindow.cpp51
-rw-r--r--src/gui/windows/inventorywindow.h6
-rw-r--r--src/gui/windows/killstats.cpp5
-rw-r--r--src/gui/windows/maileditwindow.cpp2
-rw-r--r--src/gui/windows/mailviewwindow.cpp17
-rw-r--r--src/gui/windows/mailviewwindow.h8
-rw-r--r--src/gui/windows/mailwindow.cpp61
-rw-r--r--src/gui/windows/minimap.cpp1
-rw-r--r--src/gui/windows/ministatuswindow.cpp1
-rw-r--r--src/gui/windows/npcdialog.cpp1
-rw-r--r--src/gui/windows/outfitwindow.cpp1
-rw-r--r--src/gui/windows/serverdialog.cpp5
-rw-r--r--src/gui/windows/shopwindow.cpp1
-rw-r--r--src/gui/windows/shortcutwindow.cpp1
-rw-r--r--src/gui/windows/socialwindow.cpp2
-rw-r--r--src/gui/windows/updaterwindow.cpp31
-rw-r--r--src/gui/windows/updaterwindow.h2
-rw-r--r--src/gui/windows/whoisonline.cpp28
25 files changed, 181 insertions, 91 deletions
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index f35eb0874..9dd872bd7 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -51,6 +51,7 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "debug.h"
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 66e7a886d..c7a2e0eef 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -47,6 +47,7 @@
#include "net/character.h"
#include "net/charserverhandler.h"
#include "net/logindata.h"
+#include "net/loginhandler.h"
#ifdef TMWA_SUPPORT
#include "net/net.h"
#endif // TMWA_SUPPORT
@@ -71,9 +72,13 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
ActionListener(),
KeyListener(),
mLoginData(&data),
- // TRANSLATORS: char select dialog. button.
- mSwitchLoginButton(new Button(this, _("Switch"), "switch",
- BUTTON_SKIN, this)),
+ mSwitchLoginButton(new Button(this,
+ (loginHandler != nullptr && loginHandler->getWorlds().size() > 1)
+ // TRANSLATORS: char select dialog. button.
+ ? _("Switch World") : _("Logout"),
+ "switch",
+ BUTTON_SKIN,
+ this)),
// TRANSLATORS: char select dialog. button.
mChangePasswordButton(new Button(this, _("Password"), "change_password",
BUTTON_SKIN, this)),
@@ -102,11 +107,11 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
placer = getPlacer(0, 0);
// disable logout using -S
- int row = 0;
+ int column = 0;
if (!settings.options.uniqueSession)
- placer(row++, 0, mSwitchLoginButton, 1, 1);
- placer(row++, 0, mChangePasswordButton, 1, 1);
- placer(row++, 0, mDeleteButton, 1, 1);
+ placer(column++, 0, mSwitchLoginButton, 1, 1);
+ placer(column++, 0, mChangePasswordButton, 1, 1);
+ placer(column++, 0, mDeleteButton, 1, 1);
#ifdef TMWA_SUPPORT
if (Net::getNetworkType() != ServerType::TMWATHENA)
#endif
@@ -117,7 +122,7 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
"rename",
BUTTON_SKIN,
this);
- placer(row++, 0, mRenameButton, 1, 1);
+ placer(column++, 0, mRenameButton, 1, 1);
}
#ifdef TMWA_SUPPORT
if (serverFeatures->havePincode())
@@ -129,9 +134,9 @@ CharSelectDialog::CharSelectDialog(LoginData &data) :
"changepin",
BUTTON_SKIN,
this);
- placer(row++, 0, mChangePinButton, 1, 1);
+ placer(column++, 0, mChangePinButton, 1, 1);
}
- placer(row++, 0, mInfoButton, 1, 1);
+ placer(column++, 0, mInfoButton, 1, 1);
for (int i = 0; i < CAST_S32(mLoginData->characterSlots); i++)
{
@@ -307,12 +312,16 @@ void CharSelectDialog::action(const ActionEvent &event)
return;
if ((mDeleteDialog != nullptr) && mDeleteIndex != -1)
{
+ const Net::Character *const character
+ = mCharacterEntries[mDeleteIndex]->getCharacter();
if (serverFeatures->haveEmailOnDelete())
{
attemptCharacterDelete(mDeleteIndex, mDeleteDialog->getText());
mDeleteDialog = nullptr;
}
- else if (mDeleteDialog->getText() == LoginDialog::savedPassword)
+ else if (character != nullptr &&
+ character->dummy != nullptr &&
+ mDeleteDialog->getText() == character->dummy->getName())
{
attemptCharacterDelete(mDeleteIndex, "");
mDeleteDialog = nullptr;
@@ -323,7 +332,7 @@ void CharSelectDialog::action(const ActionEvent &event)
// TRANSLATORS: error header
_("Error"),
// TRANSLATORS: error message
- _("Incorrect password"),
+ _("Incorrect character name"),
// TRANSLATORS: ok dialog button
_("OK"),
DialogType::ERROR,
@@ -497,11 +506,11 @@ void CharSelectDialog::askPasswordForDeletion(const int index)
{
CREATEWIDGETV(mDeleteDialog, TextDialog,
// TRANSLATORS: char deletion question.
- _("Enter password for deleting character"),
+ _("Enter character name to confirm deleting the character"),
// TRANSLATORS: email label.
- _("Enter password:"),
+ _("Enter character name:"),
this,
- true);
+ false);
}
mDeleteDialog->setActionEventId("try delete character");
mDeleteDialog->addActionListener(this);
@@ -616,7 +625,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
void CharSelectDialog::close()
{
- client->setState(State::SWITCH_LOGIN);
+ client->setState(State::SWITCH_WORLD);
Window::close();
}
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 8c445adb4..71e94adc6 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -52,6 +52,7 @@
#include "gui/windows/setupwindow.h"
#include "gui/windows/whoisonline.h"
+#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
#include "gui/widgets/chatinput.h"
#include "gui/widgets/createwidget.h"
@@ -77,6 +78,7 @@
#include "utils/copynpaste.h"
#include "utils/delete2.h"
#include "utils/foreach.h"
+#include "utils/performance.h"
#include "utils/translation/podict.h"
diff --git a/src/gui/windows/clanwindow.cpp b/src/gui/windows/clanwindow.cpp
index 3cd88b0c2..c64c81bb8 100644
--- a/src/gui/windows/clanwindow.cpp
+++ b/src/gui/windows/clanwindow.cpp
@@ -32,6 +32,7 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "debug.h"
diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp
index df13c6cc9..61392d914 100644
--- a/src/gui/windows/connectiondialog.cpp
+++ b/src/gui/windows/connectiondialog.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/progressindicator.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "client.h"
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index f750f5500..7a875efa5 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -37,6 +37,7 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "debug.h"
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 7aabce1db..f6c3cc643 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -51,6 +51,7 @@
#include "utils/dtor.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "net/inventoryhandler.h"
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index ef6cee215..5681e8e04 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -1137,38 +1137,53 @@ void InventoryWindow::attributeChanged(const AttributesT id,
}
}
-void InventoryWindow::combineItems(const int index1,
- const int index2)
+void InventoryWindow::combineItems(const int srcIndex,
+ const int dstIndex)
{
if (mInventory == nullptr)
return;
- const Item *item1 = mInventory->getItem(index1);
- if (item1 == nullptr)
+ const Item *srcItem = mInventory->getItem(srcIndex);
+ if (srcItem == nullptr)
return;
- const Item *item2 = mInventory->getItem(index2);
- if (item2 == nullptr)
+ const Item *dstItem = mInventory->getItem(dstIndex);
+ if (dstItem == nullptr)
return;
- if (item1->getType() != ItemType::Card)
- {
- const Item *tmpItem = item1;
- item1 = item2;
- item2 = tmpItem;
- }
+ // Build up a total all-that-could-go-wrong list of messages. (note:
+ // this is a small subset of all the checks that hercules does).
+ // This way insertion will continue to work even if server removes
+ // some checks (I would prefer if the server sent failure messages
+ // itself, but it fails silently).
+ std::string question
+ = strprintf(
+ // TRANSLATORS: question dialog message
+ _("Insert %s into %s?"),
+ srcItem->getName().c_str(),
+ dstItem->getName().c_str());
+
+ if (srcItem->getType() != ItemType::Card)
+ // TRANSLATORS: failure reason appended to card insert question
+ (question += ' ') += _(" Item to be inserted may not be insertable.");
+
+ if (dstItem->isEquipped() == Equipped_true)
+ // TRANSLATORS: failure reason appended to card insert question
+ (question += ' ') += _(" Destination item is equipped.");
+
+ if (dstItem->isEquipment() == Equipm_false)
+ // TRANSLATORS: failure reason appended to card insert question
+ (question += " ") += _("Inserting into non-equipment items may fail.");
ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
// TRANSLATORS: question dialog title
_("Insert card request"),
- // TRANSLATORS: question dialog message
- strprintf(_("Insert %s into %s?"),
- item1->getName().c_str(),
- item2->getName().c_str()),
+ question,
SOUND_REQUEST,
false,
Modal_true,
nullptr);
- insertCardListener.itemIndex = item2->getInvIndex();
- insertCardListener.cardIndex = item1->getInvIndex();
+
+ insertCardListener.itemIndex = dstItem->getInvIndex();
+ insertCardListener.cardIndex = srcItem->getInvIndex();
confirmDlg->addActionListener(&insertCardListener);
}
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 96698d72f..0f4c13b46 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -158,8 +158,10 @@ class InventoryWindow final : public Window,
const int64_t oldVal,
const int64_t newVal) override final;
- void combineItems(const int index1,
- const int index2);
+ /*
+ * Attempt inserting one item (card) into another
+ */
+ void combineItems(const int srcIndex, const int dstIndex);
void moveItemToCraft(const int craftSlot);
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index cfe6886be..210c0d2bc 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -36,10 +36,11 @@
#include "being/playerinfo.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
-#endif // WIN32
+#endif // _WIN32
#include "debug.h"
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index e7fad6aab..bd47710dc 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -67,7 +67,7 @@ MailEditWindow::MailEditWindow() :
// TRANSLATORS: mail edit window label
mMoneyLabel(new Label(this, _("Money:"))),
// TRANSLATORS: mail edit window label
- mItemLabel(new Label(this, _("Item:"))),
+ mItemLabel(new Label(this, _("Items:"))),
// TRANSLATORS: mail edit window label
mMessageLabel(new Label(this, _("Message:"))),
mToField(new TextField(this, std::string(), LoseFocusOnTab_true,
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index e534ce4b4..bddd03f74 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -50,7 +50,7 @@ MailViewWindow *mailViewWindow = nullptr;
MailViewWindow::MailViewWindow(MailMessage *const message,
const int itemsCount) :
// TRANSLATORS: mail view window name
- Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
+ Window(_("View Mail"), Modal_false, nullptr, "mailview.xml"),
ActionListener(),
mMessage(message),
mGetAttachButton(new Button(this,
@@ -153,6 +153,8 @@ MailViewWindow::~MailViewWindow()
{
if (mUseMail2)
{
+ if (mDeleted)
+ delete mMessage;
mMessage = nullptr;
}
else
@@ -282,3 +284,16 @@ void MailViewWindow::removeMoney(const int64_t mailId)
if (mailWindow != nullptr)
mailWindow->refreshMailNames();
}
+
+bool MailViewWindow::notifyDeleteAndTransferOwnership(const int64_t mailId)
+{
+ if (mailId != mMessage->id)
+ return false;
+ setCaption("View Mail (DELETED)");
+ mDeleted = true;
+ // this mail's ID no longer exists, so it no longer has a defined
+ // predecessor or successor.
+ mPrevButton->setEnabled(false);
+ mNextButton->setEnabled(false);
+ return true;
+}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index e275a55ed..edb939b33 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -55,6 +55,13 @@ class MailViewWindow final : public Window,
void removeMoney(const int64_t mailId);
+ /**
+ * notify view window that mail has been deleted.
+ * MailViewWindow will delete the message when it is destroyed.
+ * returns true if mailId is the one being viewed (and thus ownership
+ * was transfered).
+ */
+ bool notifyDeleteAndTransferOwnership(const int64_t mailId);
private:
void updateAttachButton();
@@ -75,6 +82,7 @@ class MailViewWindow final : public Window,
ItemContainer *mItemContainer;
ScrollArea *mItemScrollArea;
bool mUseMail2;
+ bool mDeleted = false;
};
extern MailViewWindow *mailViewWindow;
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
index 4f5f9cac5..cd3c8c6cf 100644
--- a/src/gui/windows/mailwindow.cpp
+++ b/src/gui/windows/mailwindow.cpp
@@ -92,25 +92,38 @@ MailWindow::MailWindow() :
if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- setDefaultSize(310, 180, ImagePosition::CENTER, 0, 0);
- setMinWidth(310);
- setMinHeight(250);
- center();
-
+ // use line wrapping of mail subjects, instead.
mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- ContainerPlacer placer(nullptr, nullptr);
- placer = getPlacer(0, 0);
-
- placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
- placer(4, 0, mRefreshButton, 1, 1);
- placer(4, 1, mOpenButton, 1, 1);
- placer(4, 2, mNewButton, 1, 1);
- placer(4, 3, mDeleteButton, 1, 1);
- placer(4, 4, mReturnButton, 1, 1);
+ // set reasonable minimum width for calculations below
+ mListScrollArea->setWidth(200);
+
+ // at 0,0 and spawns/spans 4 columns and 6 rows
+ place(0, 0, mListScrollArea, 1, 6).setPadding(3);
+ // at column 5 and row 0...
+ place(1, 0, mRefreshButton, 1, 1);
+ place(1, 1, mOpenButton, 1, 1);
+ place(1, 2, mNewButton, 1, 1);
+ // Leave intentional gap in grid so that the button column (and thus,
+ // the whole window) can be resized without resizing any of the buttons.
+ // note: the empty cell still seems to enforce some padding, but this
+ // is fine.
+ place(1, 4, mDeleteButton, 1, 1);
+ place(1, 5, mReturnButton, 1, 1);
Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
+ // scrollarea column and 4th row eat all remaining available screen space.
+ layout.setColWidth(0, LayoutType::SET);
+ layout.setRowHeight(3, LayoutType::SET);
+
+ // Enforce a minimum size.
+ int width = 0;
+ int height = 0;
+ layout.reflow(width, height);
+ setContentSize(width, height);
+ setMinWidth(getWidth());
+ setMinHeight(getHeight());
+ setDefaultSize(getWidth(), getHeight(), ImagePosition::CENTER, 0, 0);
+ center();
loadWindowState();
enableVisibleSound(true);
@@ -244,7 +257,14 @@ void MailWindow::removeMail(const int64_t id)
if ((message != nullptr) && message->id == id)
{
mMessages.erase(it);
- delete message;
+ // passes ownership of message pointer to mailViewWindow,
+ // which will signal to reader that the mail is deleted and
+ // will do the final delete of the message upon destruction.
+ if (mailViewWindow == nullptr ||
+ !mailViewWindow->notifyDeleteAndTransferOwnership(id))
+ {
+ delete message;
+ }
break;
}
}
@@ -255,6 +275,13 @@ void MailWindow::removeMail(const int64_t id)
if (message != nullptr)
mMailModel->add(getMailHeader(message));
}
+
+ // if player deleted the selected mail, then selection does not change
+ // (selects next one in list). However, if they deleted the last one,
+ // then we go to the previous one in list.
+ const auto lastIndex = mMailModel->getNumberOfElements() - 1;
+ if (mListBox->getSelected() > lastIndex)
+ mListBox->setSelected(lastIndex);
}
void MailWindow::showMessage(MailMessage *const mail,
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 40f650807..85e2c9dbf 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -54,6 +54,7 @@
#include "utils/gettext.h"
#include "utils/foreach.h"
+#include "utils/performance.h"
#include "utils/sdlcheckutils.h"
#include "utils/stdmove.h"
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 7e12aac0c..8b5159333 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -50,6 +50,7 @@
#include "utils/dtor.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "debug.h"
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 2d4b58593..2061439af 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -76,6 +76,7 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include <sstream>
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 42d689802..0f9761a92 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -48,6 +48,7 @@
#include "gui/widgets/layout.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "resources/inventory/inventory.h"
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 1b6f3ae73..c28032404 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -49,12 +49,13 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/langs.h"
+#include "utils/performance.h"
#include "debug.h"
-#ifdef WIN32
+#ifdef _WIN32
#undef ERROR
-#endif // WIN32
+#endif // _WIN32
static const int MAX_SERVERLIST = 15;
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 43c5c2b29..cc48d4806 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -82,6 +82,7 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#ifdef TMWA_SUPPORT
#include "resources/iteminfo.h"
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 5a0e83755..93afda6ad 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -38,6 +38,7 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
+#include "utils/performance.h"
#include "debug.h"
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index c7556e58f..0c9f16f5c 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -44,6 +44,8 @@
#include "net/tmwa/guildmanager.h"
#endif // TMWA_SUPPORT
+#include "utils/performance.h"
+
#include "debug.h"
SocialWindow *socialWindow = nullptr;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 55d0ba2b0..f15263d09 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -53,6 +53,7 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include <sys/stat.h>
@@ -430,11 +431,11 @@ void UpdaterWindow::loadNews()
mScrollArea->setVerticalScrollAmount(0);
}
-void UpdaterWindow::loadPatch()
+void UpdaterWindow::checkClientVersion()
{
if (mMemoryBuffer == nullptr)
{
- logger->log1("Couldn't load patch");
+ logger->log1("Couldn't check client version: null buffer");
return;
}
@@ -443,13 +444,17 @@ void UpdaterWindow::loadPatch()
realloc(mMemoryBuffer, mDownloadedBytes + 1));
if (mMemoryBuffer == nullptr)
{
- logger->log1("Couldn't load patch");
+ logger->log1("Couldn't check client version: null buffer");
return;
}
mMemoryBuffer[mDownloadedBytes] = '\0';
std::string version;
+ // The version check file (latest.txt) is composed of two lines:
+ // first, the "machine readable" version (for alphanumeric comparison)
+ // and second, the human readable version, to be displayed.
+
// Tokenize and add each line separately
char *line = strtok(mMemoryBuffer, "\n");
if (line != nullptr)
@@ -460,6 +465,8 @@ void UpdaterWindow::loadPatch()
line = strtok(nullptr, "\n");
if (line != nullptr)
{
+ // if you wonder why this line is above the one below, it's
+ // because add to top is true.
mBrowserBox->addRow(strprintf("##9 Latest client version: "
"##6ManaVerse %s##0", line), true);
}
@@ -470,7 +477,7 @@ void UpdaterWindow::loadPatch()
#if defined(ANDROID)
const std::string url = "androidDownloadUrl";
const std::string text = "androidDownloadUrl";
-#elif defined(WIN32)
+#elif defined(_WIN32)
const std::string url = "windowsDownloadUrl";
const std::string text = "windowsDownloadUrl";
#else // defined(ANDROID)
@@ -588,15 +595,16 @@ void UpdaterWindow::download()
if (mDownloadStatus == UpdateDownloadStatus::UPDATE_PATCH)
{
mDownload = new Net::Download(this,
- branding.getStringValue("updateMirror1") + mCurrentFile,
+ urlJoin(branding.getStringValue("updateMirror1"), mCurrentFile),
&updateProgress,
true, false, mValidateXml);
+
for (int f = 2; f < 8; f ++)
{
const std::string url = branding.getStringValue(
"updateMirror" + toString(f));
if (!url.empty())
- mDownload->addMirror(url + mCurrentFile);
+ mDownload->addMirror(urlJoin(url, mCurrentFile));
}
}
else
@@ -610,9 +618,9 @@ void UpdaterWindow::download()
mDownloadStatus == UpdateDownloadStatus::UPDATE_RESOURCES2)
{
const std::string str = urlJoin(mUpdateServerPath, mCurrentFile);
- mDownload->addMirror(updateServer3 + str);
- mDownload->addMirror(updateServer4 + str);
- mDownload->addMirror(updateServer5 + str);
+ mDownload->addMirror(urlJoin(updateServer3, str));
+ mDownload->addMirror(urlJoin(updateServer4, str));
+ mDownload->addMirror(urlJoin(updateServer5, str));
}
else
{
@@ -824,10 +832,9 @@ void UpdaterWindow::logic()
case UpdateDownloadStatus::UPDATE_PATCH:
if (mDownloadComplete)
{
- // Parse current memory buffer as news and dispose of the data
- loadPatch();
+ checkClientVersion();
- mUpdateHost = updateServer2 + mUpdateServerPath;
+ mUpdateHost = urlJoin(updateServer2, mUpdateServerPath);
mUpdatesDir = pathJoin(mUpdatesDir, "fix");
mCurrentFile = xmlUpdateFile;
mValidateXml = true;
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index d08870e0e..7c5cc114c 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -106,7 +106,7 @@ class UpdaterWindow final : public Window,
*/
void loadNews();
- void loadPatch();
+ void checkClientVersion();
void action(const ActionEvent &event) override final;
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index ca939df47..2cb1c1e16 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -62,6 +62,7 @@
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include "utils/sdlhelper.h"
#ifdef TMWA_SUPPORT
@@ -250,33 +251,22 @@ void WhoIsOnline::updateWindow(size_t numOnline)
std::sort(mFriends.begin(), mFriends.end(), nameCompare);
std::sort(mNeutral.begin(), mNeutral.end(), nameCompare);
std::sort(mDisregard.begin(), mDisregard.end(), nameCompare);
- bool addedFromSection(false);
FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mFriends)
- {
mBrowserBox->addRow((*it)->getText(), false);
- addedFromSection = true;
- }
- if (addedFromSection == true)
- {
+
+ if (!mFriends.empty())
mBrowserBox->addRow("---", false);
- addedFromSection = false;
- }
+
FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mEnemy)
- {
mBrowserBox->addRow((*it)->getText(), false);
- addedFromSection = true;
- }
- if (addedFromSection == true)
- {
+
+ if (!mEnemy.empty())
mBrowserBox->addRow("---", false);
- addedFromSection = false;
- }
+
FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mNeutral)
- {
mBrowserBox->addRow((*it)->getText(), false);
- addedFromSection = true;
- }
- if (addedFromSection == true && !mDisregard.empty())
+
+ if (!mNeutral.empty() && !mDisregard.empty())
mBrowserBox->addRow("---", false);
FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mDisregard)