diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-11 17:32:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-11 17:32:57 +0300 |
commit | 86b8c903900a59f99b2e1f02232476d600ae5a12 (patch) | |
tree | 6cb05135934459df645e4e82119536bc579980a2 | |
parent | fdfe2900f11958b7851f6c57a15ad0dc80334a11 (diff) | |
download | manaplus-86b8c903900a59f99b2e1f02232476d600ae5a12.tar.gz manaplus-86b8c903900a59f99b2e1f02232476d600ae5a12.tar.bz2 manaplus-86b8c903900a59f99b2e1f02232476d600ae5a12.tar.xz manaplus-86b8c903900a59f99b2e1f02232476d600ae5a12.zip |
Improve a bit variables order in some classes.
-rw-r--r-- | src/client.cpp | 9 | ||||
-rw-r--r-- | src/client.h | 5 | ||||
-rw-r--r-- | src/dragdrop.h | 22 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 20 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.h | 50 | ||||
-rw-r--r-- | src/net/download.cpp | 4 | ||||
-rw-r--r-- | src/net/download.h | 2 | ||||
-rw-r--r-- | src/net/serverinfo.h | 7 |
8 files changed, 62 insertions, 57 deletions
diff --git a/src/client.cpp b/src/client.cpp index 00da29af0..d8cd1f6f2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -76,6 +76,7 @@ #include "gui/widgets/desktop.h" #include "net/chathandler.h" +#include "net/download.h" #include "net/gamehandler.h" #include "net/generalhandler.h" #include "net/guildhandler.h" @@ -186,6 +187,7 @@ int serverVersion = 0; unsigned int tmwServerVersion = 0; int start_time; unsigned int mLastHost = 0; +unsigned long mSearchHash = 0; int textures_count = 0; #ifdef WIN32 @@ -244,13 +246,13 @@ Client::Client(const Options &options) : mOldState(STATE_START), mIcon(nullptr), mCaption(), + mOldUpdates(), mFpsManager(), mSkin(nullptr), + mGuiAlpha(1.0F), mButtonPadding(1), mButtonSpacing(3), mKeyboardHeight(0), - mOldUpdates(), - mGuiAlpha(1.0F), mLimitFps(false), mConfigAutoSaved(false), mIsMinimized(false), @@ -1301,6 +1303,9 @@ int Client::gameExec() loginData.updateType = serverConfig.getValue("updateType", 1); + mSearchHash = Net::Download::adlerBuffer( + const_cast<char*>(mCurrentServer.hostname.c_str()), + mCurrentServer.hostname.size()); if (mOptions.username.empty() || mOptions.password.empty()) { diff --git a/src/client.h b/src/client.h index fd1942684..0d7749e3f 100644 --- a/src/client.h +++ b/src/client.h @@ -438,13 +438,13 @@ private: SDL_Surface *mIcon; std::string mCaption; + std::string mOldUpdates; FPSmanager mFpsManager; Skin *mSkin; + float mGuiAlpha; int mButtonPadding; int mButtonSpacing; int mKeyboardHeight; - std::string mOldUpdates; - float mGuiAlpha; bool mLimitFps; bool mConfigAutoSaved; bool mIsMinimized; @@ -455,5 +455,6 @@ private: extern Client *client; extern unsigned int mLastHost; +extern unsigned long mSearchHash; #endif // CLIENT_H diff --git a/src/dragdrop.h b/src/dragdrop.h index 99cfb1ee7..3623d548c 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -54,14 +54,14 @@ class DragDrop final { public: DragDrop(Item *const item, const DragDropSource source) : - mItem(item ? item->getId() : 0), - mItemColor(item ? item->getColor() : 1), mItemImage(item ? item->getImage() : nullptr), - mSelItem(0), - mSelItemColor(1), - mSource(source), mText(), - mTag(-1) + mSource(source), + mItem(item ? item->getId() : 0), + mSelItem(0), + mTag(-1), + mItemColor(item ? item->getColor() : 1), + mSelItemColor(1) { if (mItemImage) mItemImage->incRef(); @@ -250,14 +250,14 @@ class DragDrop final } private: - int mItem; - uint8_t mItemColor; Image *mItemImage; - int mSelItem; - uint8_t mSelItemColor; - DragDropSource mSource; std::string mText; + DragDropSource mSource; + int mItem; + int mSelItem; int mTag; + uint8_t mItemColor; + uint8_t mSelItemColor; }; extern DragDrop dragDrop; diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index e72308da7..507cdfd16 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -159,27 +159,19 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, Window(_("Updating..."), false, nullptr, "update.xml"), ActionListener(), KeyListener(), + mDownloadProgress(0.0F), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), mUpdatesDirReal(updatesDir), mCurrentFile("news.txt"), mNewLabelCaption(), - mDownloadProgress(0.0F), mDownloadMutex(), mCurrentChecksum(0), - mStoreInMemory(true), - mDownloadComplete(true), - mUserCancel(false), - mDownloadedBytes(0), mMemoryBuffer(nullptr), mDownload(nullptr), mUpdateFiles(), mTempUpdateFiles(), - mUpdateIndex(0), - mUpdateIndexOffset(0), - mLoadUpdates(applyUpdates), - mUpdateType(updateType), // TRANSLATORS: updater window label mLabel(new Label(this, _("Connecting..."))), // TRANSLATORS: updater window button @@ -192,7 +184,15 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, "browserbox.xml")), mScrollArea(new ScrollArea(this, mBrowserBox, true, "update_background.xml")), - mUpdateServerPath(mUpdateHost) + mUpdateServerPath(mUpdateHost), + mDownloadedBytes(0), + mUpdateIndex(0), + mUpdateIndexOffset(0), + mUpdateType(updateType), + mStoreInMemory(true), + mDownloadComplete(true), + mUserCancel(false), + mLoadUpdates(applyUpdates) { setWindowName("UpdaterWindow"); setResizable(true); diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index 79d764752..638f88faf 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -198,6 +198,9 @@ private: UPDATE_RESOURCES2 }; + /** The new progress value to be set in the logic method. */ + float mDownloadProgress; + /** Status of the current download. */ UpdateDownloadStatus mDownloadStatus; @@ -215,9 +218,6 @@ private: /** The new label caption to be set in the logic method. */ std::string mNewLabelCaption; - /** The new progress value to be set in the logic method. */ - float mDownloadProgress; - // The mutex used to guard access to mNewLabelCaption // and mDownloadProgress. Mutex mDownloadMutex; @@ -225,18 +225,6 @@ private: /** The Adler32 checksum of the file currently downloading. */ unsigned long mCurrentChecksum; - /** A flag to indicate whether to use a memory buffer or a regular file. */ - bool mStoreInMemory; - - /** Flag that show if current download is complete. */ - bool mDownloadComplete; - - /** Flag that show if the user has canceled the update. */ - bool mUserCancel; - - /** Byte count currently downloaded in mMemoryBuffer. */ - int mDownloadedBytes; - /** Buffer for files downloaded to memory. */ char *mMemoryBuffer; @@ -249,24 +237,36 @@ private: /** List of temp files to download. */ std::vector<UpdateFile> mTempUpdateFiles; + Label *mLabel; /**< Progress bar caption. */ + Button *mCancelButton; /**< Button to stop the update process. */ + Button *mPlayButton; /**< Button to start playing. */ + ProgressBar *mProgressBar; /**< Update progress bar. */ + BrowserBox *mBrowserBox; /**< Box to display news. */ + ScrollArea *mScrollArea; /**< Used to scroll news box. */ + std::string mUpdateServerPath; + + /** Byte count currently downloaded in mMemoryBuffer. */ + int mDownloadedBytes; + /** Index of the file to be downloaded. */ unsigned int mUpdateIndex; /** Index offset for disaplay downloaded file. */ unsigned int mUpdateIndexOffset; - /** Tells ~UpdaterWindow() if it should load updates */ - bool mLoadUpdates; - int mUpdateType; - Label *mLabel; /**< Progress bar caption. */ - Button *mCancelButton; /**< Button to stop the update process. */ - Button *mPlayButton; /**< Button to start playing. */ - ProgressBar *mProgressBar; /**< Update progress bar. */ - BrowserBox *mBrowserBox; /**< Box to display news. */ - ScrollArea *mScrollArea; /**< Used to scroll news box. */ - std::string mUpdateServerPath; + /** A flag to indicate whether to use a memory buffer or a regular file. */ + bool mStoreInMemory; + + /** Flag that show if current download is complete. */ + bool mDownloadComplete; + + /** Flag that show if the user has canceled the update. */ + bool mUserCancel; + + /** Tells ~UpdaterWindow() if it should load updates */ + bool mLoadUpdates; }; #endif // GUI_WINDOWS_UPDATERWINDOW_H diff --git a/src/net/download.cpp b/src/net/download.cpp index 141a7772f..6d127d0a4 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -148,11 +148,11 @@ unsigned long Download::fadler32(FILE *const file) return adler; } -unsigned long Download::adlerBuffer(char *buffer, int size) +unsigned long Download::adlerBuffer(char *const buffer, int size) { unsigned long adler = adler32(0L, Z_NULL, 0); return adler32(static_cast<uInt>(adler), - reinterpret_cast<Bytef*>(buffer), size); + reinterpret_cast<const Bytef*>(buffer), size); } void Download::addHeader(const std::string &header) diff --git a/src/net/download.h b/src/net/download.h index bc06f1974..7dae8913f 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -104,7 +104,7 @@ class Download final static void secureCurl(CURL *const curl); - static unsigned long adlerBuffer(char *buffer, int size); + static unsigned long adlerBuffer(char *const buffer, int size); static std::string getUploadResponse() { return mUploadResponse; } diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 48f216855..899400598 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -49,12 +49,11 @@ public: std::string name; std::string hostname; std::string althostname; - uint16_t port; - std::string description; std::string registerUrl; std::string onlineListUrl; std::string supportUrl; + uint16_t port; VersionString version; bool save; @@ -64,11 +63,11 @@ public: name(), hostname(), althostname(), - port(6901), description(), registerUrl(), onlineListUrl(), supportUrl(), + port(6901), version(), save(false) { @@ -80,11 +79,11 @@ public: name(info.name), hostname(info.hostname), althostname(info.althostname), - port(info.port), description(info.description), registerUrl(info.registerUrl), onlineListUrl(info.onlineListUrl), supportUrl(info.supportUrl), + port(info.port), version(), save(info.save) { |