From e2afd3690c0f2495a1efd12576e5ed91c3dab932 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 6 Oct 2017 10:54:25 +0400 Subject: [PATCH 1/9] Remove item by id from InventoryStore --- apps/openmw/mwmechanics/actors.cpp | 6 +----- apps/openmw/mwworld/inventorystore.cpp | 19 +++++++++++++++++++ apps/openmw/mwworld/inventorystore.hpp | 3 +++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 0715eb177..a144911c5 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -70,11 +70,7 @@ void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& a } } else - { - MWWorld::Ptr itemPtr = actor.getClass().getInventoryStore(actor).search(item); - if (!itemPtr.isEmpty()) - actor.getClass().getInventoryStore(actor).remove(itemPtr, 1, actor, true); - } + actor.getClass().getInventoryStore(actor).remove(item, 1, actor, true); } class CheckActorCommanded : public MWMechanics::EffectSourceVisitor diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index b599b3583..77141f269 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -654,11 +654,30 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem( return mSelectedEnchantItem; } +int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor) +{ + return remove(itemId, count, actor, false); +} + int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor) { return remove(item, count, actor, false); } +int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement) +{ + int toRemove = count; + + for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter) + if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId)) + toRemove -= remove(*iter, toRemove, actor, equipReplacement); + + flagAsModified(); + + // number of removed items + return count - toRemove; +} + int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement) { int retCount = ContainerStore::remove(item, count, actor); diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 851abf408..49991c164 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -177,6 +177,9 @@ namespace MWWorld virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const; ///< @return true if the two specified objects can stack with each other + virtual int remove(const std::string& itemId, int count, const Ptr& actor); + virtual int remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement); + virtual int remove(const Ptr& item, int count, const Ptr& actor); virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement); ///< Remove \a count item(s) designated by \a item from this inventory. From ad27e0f945ed2bafca11b4fdeff5cefd01e52863 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 6 Oct 2017 11:38:27 +0400 Subject: [PATCH 2/9] Fix owned tooltip in the spellwindow --- apps/openmw/mwgui/tooltips.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index af6bf4726..b2991a034 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -191,8 +191,7 @@ namespace MWGui else if (type == "ItemPtr") { mFocusObject = *focus->getUserData(); - bool isAllowedToUse = checkOwned(); - tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, !isAllowedToUse); + tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, checkOwned()); } else if (type == "ItemModelIndex") { From 280578154222556506c3c293c63e7ea5b7a0b4b7 Mon Sep 17 00:00:00 2001 From: scrawl <720642+scrawl@users.noreply.github.com> Date: Fri, 6 Oct 2017 16:18:57 +0000 Subject: [PATCH 3/9] Fix a crash when exit() already hides the window (Fixes #4148) --- apps/openmw/mwgui/windowmanagerimp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index a81c3a614..ccdd6916c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1729,9 +1729,10 @@ namespace MWGui { if (!mCurrentModals.empty()) { - if (!mCurrentModals.back()->exit()) + WindowModal* window = mCurrentModals.back(); + if (!window->exit()) return; - mCurrentModals.back()->setVisible(false); + window->setVisible(false); } } From b14404e9cccbb3c8a91d7f5e6476b15d30be1850 Mon Sep 17 00:00:00 2001 From: Kyle Cooley Date: Fri, 6 Oct 2017 20:05:06 -0400 Subject: [PATCH 4/9] Fix region colors --- apps/opencs/model/world/columnimp.hpp | 17 ++++------------- apps/opencs/view/world/colordelegate.cpp | 15 +++++++++------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index e36e386c9..f1025acb9 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -692,32 +692,23 @@ namespace CSMWorld } }; - /// \todo QColor is a GUI class and should not be in model. Need to think of an alternative - /// solution. template struct MapColourColumn : public Column { - /// \todo Replace Display_Integer with something that displays the colour value more directly. MapColourColumn() : Column (Columns::ColumnId_MapColour, ColumnBase::Display_Colour) {} virtual QVariant get (const Record& record) const { - int colour = record.get().mMapColor; - - return QColor (colour & 0xff, (colour>>8) & 0xff, (colour>>16) & 0xff); + return record.get().mMapColor; } virtual void set (Record& record, const QVariant& data) { - ESXRecordT record2 = record.get(); - - QColor colour = data.value(); - - record2.mMapColor = (colour.blue() << 16) | (colour.green() << 8) | colour.red(); - - record.setModified (record2); + ESXRecordT copy = record.get(); + copy.mMapColor = data.toInt(); + record.setModified (copy); } virtual bool isEditable() const diff --git a/apps/opencs/view/world/colordelegate.cpp b/apps/opencs/view/world/colordelegate.cpp index 1a89fc675..15a07b42c 100644 --- a/apps/opencs/view/world/colordelegate.cpp +++ b/apps/opencs/view/world/colordelegate.cpp @@ -5,29 +5,32 @@ #include "../widget/coloreditor.hpp" -CSVWorld::ColorDelegate::ColorDelegate(CSMWorld::CommandDispatcher *dispatcher, - CSMDoc::Document& document, +CSVWorld::ColorDelegate::ColorDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document& document, QObject *parent) : CommandDelegate(dispatcher, document, parent) {} -void CSVWorld::ColorDelegate::paint(QPainter *painter, +void CSVWorld::ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + int colorInt = index.data().toInt(); + QColor color(colorInt & 0xff, (colorInt >> 8) & 0xff, (colorInt >> 16) & 0xff); + QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0), option.rect.y() + qRound(option.rect.height() / 4.0), option.rect.width() / 2, option.rect.height() / 2); painter->save(); - painter->fillRect(coloredRect, index.data().value()); + painter->fillRect(coloredRect, color); painter->setPen(Qt::black); painter->drawRect(coloredRect); painter->restore(); } -CSVWorld::CommandDelegate *CSVWorld::ColorDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher, - CSMDoc::Document &document, +CSVWorld::CommandDelegate *CSVWorld::ColorDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher, + CSMDoc::Document &document, QObject *parent) const { return new ColorDelegate(dispatcher, document, parent); From 711c4d83daefd5c812596dbfdc2c8f013786cf58 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 7 Oct 2017 23:33:36 +0300 Subject: [PATCH 5/9] [Client] Fix build after recent OpenMW changes to GUI --- apps/openmw/mwbase/dialoguemanager.hpp | 2 +- apps/openmw/mwgui/container.cpp | 2 +- apps/openmw/mwmp/CellController.cpp | 8 ++++---- apps/openmw/mwmp/CellController.hpp | 2 +- apps/openmw/mwmp/GUI/GUIChat.cpp | 7 ++++--- apps/openmw/mwmp/GUI/GUIChat.hpp | 7 +++---- apps/openmw/mwmp/GUI/TextInputDialog.cpp | 4 ++-- apps/openmw/mwmp/GUI/TextInputDialog.hpp | 2 +- apps/openmw/mwmp/LocalPlayer.cpp | 5 ++--- apps/openmw/mwmp/LocalPlayer.hpp | 2 +- apps/openmw/mwmp/WorldEvent.cpp | 2 +- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 386f73382..f777f838f 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -105,7 +105,7 @@ namespace MWBase Declare this method here so it can be used from outside of MWDialogue::DialogueManager */ - virtual void updateTopics() = 0; + virtual void updateActorKnownTopics() = 0; /* End of tes3mp addition */ diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 5663f5c5d..085404fcc 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -226,7 +226,7 @@ namespace MWGui Mark this container as open for multiplayer logic purposes */ - mwmp::Main::get().getCellController()->openContainer(container, loot); + mwmp::Main::get().getCellController()->openContainer(container); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index aac250775..466a63c58 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -338,14 +338,14 @@ bool CellController::isSameCell(const ESM::Cell& cell, const ESM::Cell& otherCel return false; } -void CellController::openContainer(const MWWorld::Ptr &container, bool loot) +void CellController::openContainer(const MWWorld::Ptr &container) { // Record this as the player's current open container - Main::get().getLocalPlayer()->storeCurrentContainer(container, loot); + Main::get().getLocalPlayer()->storeCurrentContainer(container); const auto &cellRef = container.getCellRef(); - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is opened. Loot: %s", - cellRef.getRefId().c_str(), cellRef.getRefNum().mIndex, loot ? "true" : "false"); + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Container \"%s\" (%d) is opened", + cellRef.getRefId().c_str(), cellRef.getRefNum().mIndex); for (const auto &ptr : container.getClass().getContainerStore(container)) { diff --git a/apps/openmw/mwmp/CellController.hpp b/apps/openmw/mwmp/CellController.hpp index ae2de1862..4b28043d3 100644 --- a/apps/openmw/mwmp/CellController.hpp +++ b/apps/openmw/mwmp/CellController.hpp @@ -59,7 +59,7 @@ namespace mwmp bool isSameCell(const ESM::Cell& cell, const ESM::Cell& otherCell); - void openContainer(const MWWorld::Ptr& container, bool loot); + void openContainer(const MWWorld::Ptr& container); void closeContainer(const MWWorld::Ptr& container); int getCellSize() const; diff --git a/apps/openmw/mwmp/GUI/GUIChat.cpp b/apps/openmw/mwmp/GUI/GUIChat.cpp index 7e464ce47..414f40269 100644 --- a/apps/openmw/mwmp/GUI/GUIChat.cpp +++ b/apps/openmw/mwmp/GUI/GUIChat.cpp @@ -46,7 +46,7 @@ namespace mwmp delay = 3; // 3 sec. } - void GUIChat::open() + void GUIChat::onOpen() { // Give keyboard focus to the combo box whenever the console is // turned on @@ -54,7 +54,7 @@ namespace mwmp windowState = CHAT_ENABLED; } - void GUIChat::close() + void GUIChat::onClose() { // Apparently, hidden widgets can retain key focus // Remove for MyGUI 3.2.2 @@ -62,9 +62,10 @@ namespace mwmp SetEditState(0); } - void GUIChat::exit() + bool GUIChat::exit() { //WindowBase::exit(); + return true; } void GUIChat::acceptCommand(MyGUI::EditBox *_sender) diff --git a/apps/openmw/mwmp/GUI/GUIChat.hpp b/apps/openmw/mwmp/GUI/GUIChat.hpp index ca75ec21d..059882561 100644 --- a/apps/openmw/mwmp/GUI/GUIChat.hpp +++ b/apps/openmw/mwmp/GUI/GUIChat.hpp @@ -43,11 +43,10 @@ namespace mwmp void Update(float dt); + virtual void onOpen(); + virtual void onClose(); - virtual void open(); - virtual void close(); - - virtual void exit(); + virtual bool exit(); void setFont(const std::string &fntName); diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.cpp b/apps/openmw/mwmp/GUI/TextInputDialog.cpp index 484bb64d0..38793a6eb 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.cpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.cpp @@ -55,9 +55,9 @@ namespace mwmp setText("TextNote", note); } - void TextInputDialog::open() + void TextInputDialog::onOpen() { - WindowModal::open(); + WindowModal::onOpen(); // Make sure the edit box has focus MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit); } diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.hpp b/apps/openmw/mwmp/GUI/TextInputDialog.hpp index 1c755e12d..cf6b3a1ff 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.hpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.hpp @@ -29,7 +29,7 @@ namespace mwmp void setEditPassword(bool value); - virtual void open(); + virtual void onOpen(); /** Event : Dialog finished, OK button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 16a3d4441..691eab1f3 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -719,7 +719,7 @@ void LocalPlayer::addTopics() env.getDialogueManager()->addTopic(topicId); if (env.getWindowManager()->containsMode(MWGui::GM_Dialogue)) - env.getDialogueManager()->updateTopics(); + env.getDialogueManager()->updateActorKnownTopics(); } } @@ -1369,10 +1369,9 @@ void LocalPlayer::storeCellState(ESM::Cell cell, int stateType) cellStateChanges.cellStates.push_back(cellState); } -void LocalPlayer::storeCurrentContainer(const MWWorld::Ptr &container, bool loot) +void LocalPlayer::storeCurrentContainer(const MWWorld::Ptr &container) { currentContainer.refId = container.getCellRef().getRefId(); currentContainer.refNumIndex = container.getCellRef().getRefNum().mIndex; currentContainer.mpNum = container.getCellRef().getMpNum(); - currentContainer.loot = loot; } diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 23308428c..7c0a06353 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -86,7 +86,7 @@ namespace mwmp void clearCurrentContainer(); void storeCellState(ESM::Cell cell, int stateType); - void storeCurrentContainer(const MWWorld::Ptr& container, bool loot); + void storeCurrentContainer(const MWWorld::Ptr& container); private: Networking *getNetworking(); diff --git a/apps/openmw/mwmp/WorldEvent.cpp b/apps/openmw/mwmp/WorldEvent.cpp index c7f304ec1..43f663447 100644 --- a/apps/openmw/mwmp/WorldEvent.cpp +++ b/apps/openmw/mwmp/WorldEvent.cpp @@ -142,7 +142,7 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore) currentContainer->mpNum == ptrFound.getCellRef().getMpNum()) { MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container); - MWBase::Environment::get().getWindowManager()->openContainer(ptrFound, currentContainer->loot); + MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container, ptrFound); } } } From 08f34e53560417354c3452f8fb7bcd9f530dda70 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 8 Oct 2017 02:42:41 +0300 Subject: [PATCH 6/9] [Client] Fix recent problems with password window --- apps/openmw/mwmp/GUI/TextInputDialog.cpp | 5 +++++ apps/openmw/mwmp/GUI/TextInputDialog.hpp | 1 + apps/openmw/mwmp/GUIController.cpp | 3 ++- files/mygui/tes3mp_text_input.layout | 18 ++++++++++++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.cpp b/apps/openmw/mwmp/GUI/TextInputDialog.cpp index 38793a6eb..eaa687f09 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.cpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.cpp @@ -62,6 +62,11 @@ namespace mwmp MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit); } + bool TextInputDialog::exit() + { + return false; + } + // widget controls void TextInputDialog::onOkClicked(MyGUI::Widget *_sender) diff --git a/apps/openmw/mwmp/GUI/TextInputDialog.hpp b/apps/openmw/mwmp/GUI/TextInputDialog.hpp index cf6b3a1ff..a79759ffd 100644 --- a/apps/openmw/mwmp/GUI/TextInputDialog.hpp +++ b/apps/openmw/mwmp/GUI/TextInputDialog.hpp @@ -30,6 +30,7 @@ namespace mwmp void setEditPassword(bool value); virtual void onOpen(); + virtual bool exit(); /** Event : Dialog finished, OK button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index 9f4678819..9cd496887 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -158,12 +158,13 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa mInputBox->eventDone += MyGUI::newDelegate(this, &GUIController::onInputBoxDone); + mInputBox->setVisible(true); } void mwmp::GUIController::onInputBoxDone(MWGui::WindowBase *parWindow) { //MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager(); - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "GUIController::OnInputBoxDone: %s.",mInputBox->getTextInput().c_str()); + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "GUIController::onInputBoxDone: %s.",mInputBox->getTextInput().c_str()); Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput(); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->setPlayer(Main::get().getLocalPlayer()); diff --git a/files/mygui/tes3mp_text_input.layout b/files/mygui/tes3mp_text_input.layout index fd73ab168..7898d3d96 100644 --- a/files/mygui/tes3mp_text_input.layout +++ b/files/mygui/tes3mp_text_input.layout @@ -24,10 +24,20 @@ - - - - + + + + + + + + + + + + + + From 61b1a59814a5632c5519cc32a6a67d584fee5f0a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 8 Oct 2017 04:16:30 +0300 Subject: [PATCH 7/9] [General] Move server's version printing method to Utils --- apps/openmw-mp/main.cpp | 39 +--------------------------------- components/openmw-mp/Utils.cpp | 36 +++++++++++++++++++++++++++++++ components/openmw-mp/Utils.hpp | 1 + 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/apps/openmw-mp/main.cpp b/apps/openmw-mp/main.cpp index 342c77eda..97f7e352f 100644 --- a/apps/openmw-mp/main.cpp +++ b/apps/openmw-mp/main.cpp @@ -29,41 +29,6 @@ using namespace std; using namespace mwmp; -void printVersion(string version, Version::Version ver, int protocol) -{ - cout << "TES3:MP dedicated server " << version; - cout << " ("; -#if defined(_WIN32) - cout << "Windows"; -#elif defined(__linux) - cout << "Linux"; -#elif defined(__APPLE__) - cout << "OS X"; -#else - cout << "Unknown OS"; -#endif - cout << " "; -#ifdef __x86_64__ - cout << "64-bit"; -#elif defined(__i386__) || defined(_M_I86) - cout << "32-bit"; -#elif defined(__ARM_ARCH) - cout << "ARMv" << __ARM_ARCH << " "; - #ifdef __aarch64__ - cout << "64-bit"; - #else - cout << "32-bit"; - #endif -#else - cout << "Unknown architecture"; -#endif - cout << ")" << endl; - cout << "Protocol version: " << protocol << endl; - cout << "Commit hash: " << ver.mCommitHash.substr(0, 10) << endl; - - cout << "------------------------------------------------------------" << endl; -} - #ifdef ENABLE_BREAKPAD google_breakpad::ExceptionHandler *pHandler = 0; #if defined(_WIN32) @@ -230,9 +195,7 @@ int main(int argc, char *argv[]) vector plugins (Utils::split(mgr.getString("plugins", "Plugins"), ',')); - - printVersion(TES3MP_VERSION, version, TES3MP_PROTO_VERSION); - + Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION); setenv("AMXFILE", moddir.c_str(), 1); setenv("MOD_DIR", moddir.c_str(), 1); // hack for lua diff --git a/components/openmw-mp/Utils.cpp b/components/openmw-mp/Utils.cpp index 14a194268..ea5161b0a 100644 --- a/components/openmw-mp/Utils.cpp +++ b/components/openmw-mp/Utils.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -149,6 +150,41 @@ unsigned int ::Utils::crc32Checksum(const std::string &file) return crc32.checksum(); } +void Utils::printVersion(std::string appName, std::string version, std::string commitHash, int protocol) +{ + cout << appName << " " << version; + cout << " ("; +#if defined(_WIN32) + cout << "Windows"; +#elif defined(__linux) + cout << "Linux"; +#elif defined(__APPLE__) + cout << "OS X"; +#else + cout << "Unknown OS"; +#endif + cout << " "; +#ifdef __x86_64__ + cout << "64-bit"; +#elif defined(__i386__) || defined(_M_I86) + cout << "32-bit"; +#elif defined(__ARM_ARCH) + cout << "ARMv" << __ARM_ARCH << " "; +#ifdef __aarch64__ + cout << "64-bit"; +#else + cout << "32-bit"; +#endif +#else + cout << "Unknown architecture"; +#endif + cout << ")" << endl; + cout << "Protocol version: " << protocol << endl; + cout << "Commit hash: " << commitHash.substr(0, 10) << endl; + + cout << "------------------------------------------------------------" << endl; +} + void Utils::printWithWidth(ostringstream &sstr, string str, size_t width) { sstr << left << setw(width) << setfill(' ') << str; diff --git a/components/openmw-mp/Utils.hpp b/components/openmw-mp/Utils.hpp index 00cbd8cab..448cb13d7 100644 --- a/components/openmw-mp/Utils.hpp +++ b/components/openmw-mp/Utils.hpp @@ -36,6 +36,7 @@ namespace Utils unsigned int crc32Checksum(const std::string &file); + void printVersion(std::string appName, std::string version, std::string commitHash, int protocol); void printWithWidth(std::ostringstream &sstr, std::string str, size_t width); std::string intToHexStr(unsigned val); From 3d38da0e85a635e78f5301416e22206dfd67b6c0 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 8 Oct 2017 05:17:14 +0300 Subject: [PATCH 8/9] [Server] Put includes in a specific order --- apps/openmw-mp/main.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/openmw-mp/main.cpp b/apps/openmw-mp/main.cpp index 97f7e352f..f9c490a08 100644 --- a/apps/openmw-mp/main.cpp +++ b/apps/openmw-mp/main.cpp @@ -1,26 +1,29 @@ -#include -#include -#include "Player.hpp" -#include "Networking.hpp" -#include "MasterClient.hpp" -#include -#include -#include -#include -#include #include -#include -#include + +#include #include #include -#include + +#include +#include +#include +#include + +#include +#include #include -#include "Utils.hpp" +#include +#include +#include +#include + +#include "Player.hpp" +#include "Networking.hpp" #include "MasterClient.hpp" +#include "Utils.hpp" -#include -#include +#include #ifdef ENABLE_BREAKPAD #include From 182f8c1f06cb9acee49b262e58c58b8d590796b7 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 8 Oct 2017 06:17:53 +0300 Subject: [PATCH 9/9] [General] Print client version on startup --- apps/openmw/main.cpp | 25 +++++++++++++++++++++++-- components/openmw-mp/Utils.cpp | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 1421930e2..65a706c95 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -49,9 +49,11 @@ extern int is_debugger_attached(void); /* Start of tes3mp addition - Include the header of the logger added for multiplayer + Include additional headers for multiplayer purposes */ #include +#include +#include /* End of tes3mp addition */ @@ -207,7 +209,26 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat cfgMgr.readConfiguration(variables, desc); Version::Version v = Version::getOpenmwVersion(variables["resources"].as().toStdString()); - std::cout << v.describe() << std::endl; + + /* + Start of tes3mp addition + + Print the multiplayer version first + */ + Utils::printVersion("TES3MP client", TES3MP_VERSION, v.mCommitHash, TES3MP_PROTO_VERSION); + /* + End of tes3mp addition + */ + + /* + Start of tes3mp change (minor) + + Because there is no need to print the commit hash again, only print OpenMW's version + */ + std::cout << "OpenMW version " << v.mVersion << std::endl; + /* + End of tes3mp change (minor) + */ engine.setGrabMouse(!variables["no-grab"].as()); diff --git a/components/openmw-mp/Utils.cpp b/components/openmw-mp/Utils.cpp index ea5161b0a..a4a4b6e7b 100644 --- a/components/openmw-mp/Utils.cpp +++ b/components/openmw-mp/Utils.cpp @@ -164,7 +164,7 @@ void Utils::printVersion(std::string appName, std::string version, std::string c cout << "Unknown OS"; #endif cout << " "; -#ifdef __x86_64__ +#if defined(__x86_64__) || defined(_M_X64) cout << "64-bit"; #elif defined(__i386__) || defined(_M_I86) cout << "32-bit";