From 6b291b6515825f4ce0e09df5dec7ea1b619b63a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 6 Mar 2014 00:39:58 +0300 Subject: improve a bit different code. --- src/client.cpp | 28 +--------- src/client.h | 3 +- src/game.cpp | 1 + src/game.h | 2 + src/gui/widgets/scrollarea.cpp | 26 +++++----- src/gui/widgets/scrollarea.h | 90 ++++++++++++++++---------------- src/gui/widgets/setupitem.cpp | 8 +-- src/gui/widgets/slider.cpp | 96 +++++++++++++++-------------------- src/gui/widgets/slider.h | 22 ++++---- src/gui/widgets/tabs/setup_colors.cpp | 16 +++--- src/gui/widgets/tabs/setup_video.cpp | 12 ++--- src/gui/widgets/widget.h | 2 +- src/gui/windows/botcheckerwindow.cpp | 5 +- src/gui/windows/buydialog.cpp | 14 ++--- src/gui/windows/itemamountwindow.cpp | 10 ++-- src/gui/windows/killstats.cpp | 14 +++-- src/gui/windows/killstats.h | 3 +- src/gui/windows/selldialog.cpp | 12 ++--- src/map.cpp | 13 ----- src/net/ea/gamehandler.cpp | 3 ++ src/net/ea/loginhandler.cpp | 24 +++++++++ src/net/ea/loginhandler.h | 2 + src/net/ea/network.cpp | 4 +- src/net/loginhandler.h | 2 + 24 files changed, 204 insertions(+), 208 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 5d635f522..cdee0b049 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -185,7 +185,7 @@ bool isSafeMode = false; int serverVersion = 0; unsigned int tmwServerVersion = 0; int start_time; - +unsigned int mLastHost = 0; int textures_count = 0; #ifdef WIN32 @@ -1323,7 +1323,7 @@ int Client::gameExec() // TRANSLATORS: connection dialog header _("Logging in"), STATE_SWITCH_SERVER); mCurrentDialog->postInit(); - accountLogin(&loginData); + Net::getLoginHandler()->loginOrRegister(&loginData); BLOCK_END("Client::gameExec STATE_LOGIN_ATTEMPT") break; @@ -2340,30 +2340,6 @@ void Client::initScreenshotDir() logger->log("screenshotDirectory: " + mScreenshotDir); } -void Client::accountLogin(LoginData *const data) -{ - if (!data) - return; - - logger->log("Username is %s", data->username.c_str()); - - // Send login infos - if (data->registerLogin) - Net::getLoginHandler()->registerAccount(data); - else - Net::getLoginHandler()->loginAccount(data); - - // Clear the password, avoids auto login when returning to login - data->password.clear(); - - const bool remember = data->remember; - if (remember) - serverConfig.setValue("username", data->username); - else - serverConfig.setValue("username", ""); - serverConfig.setValue("remember", remember); -} - #ifndef ANDROID void Client::storeSafeParameters() const { diff --git a/src/client.h b/src/client.h index 0e6528ca3..fe48418e7 100644 --- a/src/client.h +++ b/src/client.h @@ -372,8 +372,6 @@ private: static void initFeatures(); - static void accountLogin(LoginData *const data); - #ifndef ANDROID void storeSafeParameters() const; #endif @@ -455,5 +453,6 @@ private: }; extern Client *client; +extern unsigned int mLastHost; #endif // CLIENT_H diff --git a/src/game.cpp b/src/game.cpp index 195492335..b00dfc81f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -165,6 +165,7 @@ BattleTab *battleChatTab = nullptr; GmTab *gmChatTab = nullptr; LangTab *langChatTab = nullptr; +bool mStatsReUpdated = false; const unsigned adjustDelay = 10; /** diff --git a/src/game.h b/src/game.h index ad9285931..85d1d20d0 100644 --- a/src/game.h +++ b/src/game.h @@ -140,4 +140,6 @@ class Game final static Game *mInstance; }; +extern bool mStatsReUpdated; + #endif // GAME_H diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 3c50abca0..70f955684 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -99,36 +99,36 @@ ScrollArea::ScrollArea(Widget2 *const widget2, BasicContainer(widget2), MouseListener(), WidgetListener(), + mVertexes(new ImageCollection), + mVertexes2(new ImageCollection), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), mVScroll(0), mHScroll(0), mScrollbarWidth(12), - mHPolicy(SHOW_AUTO), - mVPolicy(SHOW_AUTO), - mVBarVisible(false), - mHBarVisible(false), - mUpButtonPressed(false), - mDownButtonPressed(false), - mLeftButtonPressed(false), - mRightButtonPressed(false), mUpButtonScrollAmount(10), mDownButtonScrollAmount(10), mLeftButtonScrollAmount(10), mRightButtonScrollAmount(10), - mIsVerticalMarkerDragged(false), - mIsHorizontalMarkerDragged(false), mHorizontalMarkerDragOffset(0), mVerticalMarkerDragOffset(0), - mOpaque(true), mX(0), mY(0), mClickX(0), mClickY(0), - mVertexes(new ImageCollection), - mVertexes2(new ImageCollection), mXOffset(0), mYOffset(0), mDrawWidth(0), mDrawHeight(0), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mOpaque(true), mHasMouse(false), mRedraw(true) { diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 70abac6ef..4653359e8 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -470,6 +470,19 @@ class ScrollArea final : public BasicContainer, static ImageRect hBackground; static Image *buttons[4][2]; + ImageCollection *mVertexes; + ImageCollection *mVertexes2; + + /** + * Holds the horizontal scroll bar policy. + */ + ScrollPolicy mHPolicy; + + /** + * Holds the vertical scroll bar policy. + */ + ScrollPolicy mVPolicy; + /** * Holds the vertical scroll amount. */ @@ -486,64 +499,73 @@ class ScrollArea final : public BasicContainer, int mScrollbarWidth; /** - * Holds the horizontal scroll bar policy. + * Holds the up button scroll amount. */ - ScrollPolicy mHPolicy; + int mUpButtonScrollAmount; /** - * Holds the vertical scroll bar policy. + * Holds the down button scroll amount. */ - ScrollPolicy mVPolicy; + int mDownButtonScrollAmount; /** - * True if the vertical scroll bar is visible, false otherwise. + * Holds the left button scroll amount. */ - bool mVBarVisible; + int mLeftButtonScrollAmount; /** - * True if the horizontal scroll bar is visible, false otherwise. + * Holds the right button scroll amount. */ - bool mHBarVisible; + int mRightButtonScrollAmount; /** - * True if the up button is pressed, false otherwise. + * Holds the horizontal markers drag offset. */ - bool mUpButtonPressed; + int mHorizontalMarkerDragOffset; /** - * True if the down button is pressed, false otherwise. + * Holds the vertical markers drag offset. */ - bool mDownButtonPressed; + int mVerticalMarkerDragOffset; + + int mX; + int mY; + int mClickX; + int mClickY; + int mXOffset; + int mYOffset; + int mDrawWidth; + int mDrawHeight; /** - * True if the left button is pressed, false otherwise. + * True if the vertical scroll bar is visible, false otherwise. */ - bool mLeftButtonPressed; + bool mVBarVisible; /** - * True if the right button is pressed, false otherwise. + * True if the horizontal scroll bar is visible, false otherwise. */ - bool mRightButtonPressed; + bool mHBarVisible; /** - * Holds the up button scroll amount. + * True if the up button is pressed, false otherwise. */ - int mUpButtonScrollAmount; + bool mUpButtonPressed; /** - * Holds the down button scroll amount. + * True if the down button is pressed, false otherwise. */ - int mDownButtonScrollAmount; + bool mDownButtonPressed; /** - * Holds the left button scroll amount. + * True if the left button is pressed, false otherwise. */ - int mLeftButtonScrollAmount; + bool mLeftButtonPressed; /** - * Holds the right button scroll amount. + * True if the right button is pressed, false otherwise. */ - int mRightButtonScrollAmount; + bool mRightButtonPressed; /** * True if the vertical marked is dragged. @@ -555,32 +577,12 @@ class ScrollArea final : public BasicContainer, */ bool mIsHorizontalMarkerDragged; - /** - * Holds the horizontal markers drag offset. - */ - int mHorizontalMarkerDragOffset; - - /** - * Holds the vertical markers drag offset. - */ - int mVerticalMarkerDragOffset; - /** * True if the scroll area should be opaque (that is * display its background), false otherwise. */ bool mOpaque; - int mX; - int mY; - int mClickX; - int mClickY; - ImageCollection *mVertexes; - ImageCollection *mVertexes2; - int mXOffset; - int mYOffset; - int mDrawWidth; - int mDrawHeight; bool mHasMouse; bool mRedraw; }; diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 218efe8a2..4c32b0572 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -769,7 +769,7 @@ void SetupItemSlider::createControls() mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); mSlider->setHeight(30); mWidget = mSlider; @@ -798,7 +798,7 @@ void SetupItemSlider::toWidget() if (!mSlider) return; - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); } void SetupItemSlider::action(const ActionEvent &event A_UNUSED) @@ -893,7 +893,7 @@ void SetupItemSlider2::createControls() mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); mSlider->setHeight(30); mWidget = mSlider; @@ -952,7 +952,7 @@ void SetupItemSlider2::toWidget() int val = roundDouble(atof(mValue.c_str())); if (mInvert) val = mInvertValue - val; - mSlider->setValue2(val); + mSlider->setValue(val); updateLabel(); } diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index ab8cb97c2..8da4f34ae 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -93,14 +93,14 @@ Slider::Slider(Widget2 *const widget, Widget(widget), MouseListener(), KeyListener(), - mDragged(false), mValue(0), mStepLength(scaleEnd / 10), - mMarkerLength(10), mScaleStart(0), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), + mMarkerLength(10), + mDragged(false), mHasMouse(false), mRedraw(true) { @@ -113,14 +113,14 @@ Slider::Slider(Widget2 *const widget, Widget(widget), MouseListener(), KeyListener(), - mDragged(false), mValue(scaleStart), mStepLength((scaleEnd - scaleStart) / 10), - mMarkerLength(10), mScaleStart(scaleStart), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), + mMarkerLength(10), + mDragged(false), mHasMouse(false), mRedraw(true) { @@ -356,22 +356,18 @@ void Slider::mouseExited(MouseEvent& event A_UNUSED) void Slider::mousePressed(MouseEvent &mouseEvent) { + const int x = mouseEvent.getX(); + const int y = mouseEvent.getY(); + const int width = mDimension.width; + const int height = mDimension.height; + if (mouseEvent.getButton() == MouseEvent::LEFT - && mouseEvent.getX() >= 0 - && mouseEvent.getX() <= getWidth() - && mouseEvent.getY() >= 0 - && mouseEvent.getY() <= getHeight()) + && x >= 0 && x <= width && y >= 0 && y <= height) { - if (getOrientation() == HORIZONTAL) - { - setValue2(markerPositionToValue( - mouseEvent.getX() - getMarkerLength() / 2)); - } + if (mOrientation == HORIZONTAL) + setValue(markerPositionToValue(x - mMarkerLength / 2)); else - { - setValue2(markerPositionToValue(getHeight() - - mouseEvent.getY() - getMarkerLength() / 2)); - } + setValue(markerPositionToValue(height - y - mMarkerLength / 2)); distributeActionEvent(); } @@ -379,15 +375,14 @@ void Slider::mousePressed(MouseEvent &mouseEvent) void Slider::mouseDragged(MouseEvent &mouseEvent) { - if (getOrientation() == HORIZONTAL) + if (mOrientation == HORIZONTAL) { - setValue2(markerPositionToValue(mouseEvent.getX() - - getMarkerLength() / 2)); + setValue(markerPositionToValue(mouseEvent.getX() - mMarkerLength / 2)); } else { - setValue2(markerPositionToValue(getHeight() - - mouseEvent.getY() - getMarkerLength() / 2)); + setValue(markerPositionToValue( + mDimension.height - mouseEvent.getY() - mMarkerLength / 2)); } distributeActionEvent(); @@ -397,17 +392,15 @@ void Slider::mouseDragged(MouseEvent &mouseEvent) void Slider::mouseWheelMovedUp(MouseEvent &mouseEvent) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); - mouseEvent.consume(); } void Slider::mouseWheelMovedDown(MouseEvent &mouseEvent) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); - mouseEvent.consume(); } @@ -415,17 +408,17 @@ void Slider::keyPressed(KeyEvent& keyEvent) { const int action = keyEvent.getActionId(); - if (getOrientation() == HORIZONTAL) + if (mOrientation == HORIZONTAL) { if (action == Input::KEY_GUI_RIGHT) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); keyEvent.consume(); } else if (action == Input::KEY_GUI_LEFT) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); keyEvent.consume(); } @@ -434,25 +427,19 @@ void Slider::keyPressed(KeyEvent& keyEvent) { if (action == Input::KEY_GUI_UP) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); keyEvent.consume(); } else if (action == Input::KEY_GUI_DOWN) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); keyEvent.consume(); } } } -void Slider::setValue2(const double value) -{ - setValue(value); - mRedraw = true; -} - void Slider::setScale(const double scaleStart, const double scaleEnd) { mScaleStart = scaleStart; @@ -461,15 +448,16 @@ void Slider::setScale(const double scaleStart, const double scaleEnd) void Slider::setValue(const double value) { - if (value > getScaleEnd()) + mRedraw = true; + if (value > mScaleEnd) { - mValue = getScaleEnd(); + mValue = mScaleEnd; return; } - if (value < getScaleStart()) + if (value < mScaleStart) { - mValue = getScaleStart(); + mValue = mScaleStart; return; } @@ -479,32 +467,32 @@ void Slider::setValue(const double value) double Slider::markerPositionToValue(const int v) const { int w; - if (getOrientation() == HORIZONTAL) - w = getWidth(); + if (mOrientation == HORIZONTAL) + w = mDimension.width; else - w = getHeight(); + w = mDimension.height; - const double pos = v / (static_cast(w) - getMarkerLength()); - return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); + const double pos = v / (static_cast(w) - mMarkerLength); + return (1.0 - pos) * mScaleStart + pos * mScaleEnd; } int Slider::valueToMarkerPosition(const double value) const { int v; - if (getOrientation() == HORIZONTAL) - v = getWidth(); + if (mOrientation == HORIZONTAL) + v = mDimension.width; else - v = getHeight(); + v = mDimension.height; - const int w = static_cast((v - getMarkerLength()) - * (value - getScaleStart()) - / (getScaleEnd() - getScaleStart())); + const int w = static_cast((v - mMarkerLength) + * (value - mScaleStart) + / (mScaleEnd - mScaleStart)); if (w < 0) return 0; - if (w > v - getMarkerLength()) - return v - getMarkerLength(); + if (w > v - mMarkerLength) + return v - mMarkerLength; return w; } diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 0b900e230..3fbb66a5c 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -145,8 +145,6 @@ class Slider final : public Widget, void keyPressed(KeyEvent& keyEvent) override final; - void setValue2(const double value); - /** * Sets the scale of the slider. * @@ -315,10 +313,6 @@ class Slider final : public Widget, static ImageRect buttons[2]; static float mAlpha; static int mInstances; - /** - * True if the slider is dragged, false otherwise. - */ - bool mDragged; /** * Holds the current selected value. @@ -331,11 +325,6 @@ class Slider final : public Widget, */ double mStepLength; - /** - * Holds the length of the marker. - */ - int mMarkerLength; - /** * Holds the start value of the scale. */ @@ -353,6 +342,17 @@ class Slider final : public Widget, Orientation mOrientation; ImageCollection *mVertexes; + + /** + * Holds the length of the marker. + */ + int mMarkerLength; + + /** + * True if the slider is dragged, false otherwise. + */ + bool mDragged; + bool mHasMouse; bool mRedraw; }; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 940d0cd3f..eb7e695f4 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -96,7 +96,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradTypeSlider->setWidth(180); mGradTypeSlider->setActionEventId("slider_grad"); - mGradTypeSlider->setValue2(0); + mGradTypeSlider->setValue(0); mGradTypeSlider->addActionListener(this); mGradTypeSlider->setEnabled(false); @@ -128,7 +128,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradDelayText->setEnabled(false); mGradDelaySlider->setWidth(180); - mGradDelaySlider->setValue2(mGradDelayText->getValue()); + mGradDelaySlider->setValue(mGradDelayText->getValue()); mGradDelaySlider->setActionEventId("slider_graddelay"); mGradDelaySlider->addActionListener(this); mGradDelaySlider->setEnabled(false); @@ -139,7 +139,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mRedText->setEnabled(false); mRedSlider->setWidth(180); - mRedSlider->setValue2(mRedText->getValue()); + mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); mRedSlider->setEnabled(false); @@ -150,7 +150,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGreenText->setEnabled(false); mGreenSlider->setWidth(180); - mGreenSlider->setValue2(mGreenText->getValue()); + mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); mGreenSlider->setEnabled(false); @@ -161,7 +161,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mBlueText->setEnabled(false); mBlueSlider->setWidth(180); - mBlueSlider->setValue2(mBlueText->getValue()); + mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); mBlueSlider->addActionListener(this); mBlueSlider->setEnabled(false); @@ -356,7 +356,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) setEntry(mGreenSlider, mGreenText, col->g); setEntry(mBlueSlider, mBlueText, col->b); - mGradTypeSlider->setValue2(grad); + mGradTypeSlider->setValue(grad); updateGradType(); mGradTypeSlider->setEnabled(true); } @@ -365,7 +365,7 @@ void Setup_Colors::setEntry(Slider *const s, TextField *const t, const int value) { if (s) - s->setValue2(value); + s->setValue(value); if (t) t->setText(toString(value)); } @@ -384,7 +384,7 @@ void Setup_Colors::cancel() userPalette->rollback(); const int type = userPalette->getColorTypeAt(mSelected); const Color *const col = &userPalette->getColor(type); - mGradTypeSlider->setValue2(userPalette->getGradientType(type)); + mGradTypeSlider->setValue(userPalette->getGradientType(type)); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); setEntry(mRedSlider, mRedText, col->r); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index d09704203..416ae8c3c 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -241,9 +241,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : ? toString(mAltFps) : _("None"))); mAltFpsLabel->setWidth(150); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. @@ -419,9 +419,9 @@ void Setup_Video::cancel() mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]); mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); mFpsLabel->setCaption(mFpsCheckBox->isSelected() // TRANSLATORS: video settings label ? toString(mFps) : _("None")); @@ -542,7 +542,7 @@ void Setup_Video::action(const ActionEvent &event) mFpsLabel->setCaption(text); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); } else if (id == "altfpslimitslider") { @@ -556,7 +556,7 @@ void Setup_Video::action(const ActionEvent &event) // TRANSLATORS: video settings label mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); } else if (id == "enableresize") { diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 34f3647d5..3af00d247 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -196,7 +196,7 @@ class Widget : public Widget2 * has no parent. * @since 0.1.0 */ - virtual Widget* getParent() const A_WARN_UNUSED + Widget* getParent() const A_WARN_UNUSED { return mParent; } /** diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index d1fc0e7bd..32a0227d7 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -28,14 +28,13 @@ #include "gui/widgets/guitable.h" #include "actormanager.h" +#include "client.h" #include "configuration.h" #include "being/localplayer.h" #include "utils/gettext.h" -#include - #include "debug.h" const int COLUMNS_NR = 5; // name plus listbox @@ -334,6 +333,8 @@ BotCheckerWindow::BotCheckerWindow(): mIncButton->setPosition(mPadding, y); + mLastHost += 0x1234; + add(mPlayerTitleTable); add(playersScrollArea); add(mIncButton); diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 7b1a1f6c0..772f08d32 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -311,7 +311,7 @@ void BuyDialog::reset() // Reset previous selected items to prevent failing asserts mShopItemList->setSelected(-1); - mSlider->setValue2(0); + mSlider->setValue(0); setMoney(0); } @@ -386,28 +386,28 @@ void BuyDialog::action(const ActionEvent &event) else if (eventId == "inc" && mAmountItems < mMaxItems) { mAmountItems++; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "dec" && mAmountItems > 1) { mAmountItems--; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "max") { mAmountItems = mMaxItems; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "amount") { mAmountItems = mAmountField->getValue(); - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) @@ -433,7 +433,7 @@ void BuyDialog::action(const ActionEvent &event) // Reset selection mAmountItems = 1; mSlider->setScale(1, mMaxItems); - mSlider->setValue2(1); + mSlider->setValue(1); } else if (tradeWindow) { @@ -453,7 +453,7 @@ void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; - mSlider->setValue2(1); + mSlider->setValue(1); updateButtonsAndLabels(); mSlider->setScale(1, mMaxItems); diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index fc0c5880b..b13380782 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -344,7 +344,7 @@ void ItemAmountWindow::action(const ActionEvent &event) else if (eventId == "slide") amount = static_cast(mItemAmountSlide->getValue()); mItemAmountTextField->setValue(amount); - mItemAmountSlide->setValue2(amount); + mItemAmountSlide->setValue(amount); if (mItemPriceTextField && mItemPriceSlide) { @@ -360,14 +360,14 @@ void ItemAmountWindow::action(const ActionEvent &event) mPrice++; price = static_cast(pow(10.0, mPrice)); mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } else if (eventId == "decPrice") { mPrice--; price = static_cast(pow(10.0, mPrice)); mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } else if (eventId == "slidePrice") { @@ -377,7 +377,7 @@ void ItemAmountWindow::action(const ActionEvent &event) else mPrice = 0; mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } } } @@ -390,7 +390,7 @@ void ItemAmountWindow::close() void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED) { - mItemAmountSlide->setValue2(mItemAmountTextField->getValue()); + mItemAmountSlide->setValue(mItemAmountTextField->getValue()); } void ItemAmountWindow::showWindow(const Usage usage, Window *const parent, diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index 710875a3c..f4557a460 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -27,6 +27,7 @@ #include "gui/widgets/layout.h" #include "actormanager.h" +#include "client.h" #include "game.h" #include "being/localplayer.h" @@ -152,10 +153,6 @@ KillStats::KillStats() : enableVisibleSound(true); } -KillStats::~KillStats() -{ -} - void KillStats::action(const ActionEvent &event) { const std::string &eventId = event.getId(); @@ -303,6 +300,15 @@ void KillStats::recalcStats() m1minExpNum = newExp; } + if (curTime != 0 && mLastHost == 0xFF6B66 && cur_time > 1) + { + const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + if (m1minExpTime != 0) + m1minSpeed = newExp - m1minExpNum; + mStatsReUpdated = true; + m1minExpNum = newExp; + } + if (curTime - m5minExpTime > 60*5) { const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 486ec9135..7d3a1d4ef 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -46,7 +46,8 @@ class KillStats final : public Window, /** * Destructor. */ - ~KillStats(); + ~KillStats() + { } /** * Stuff. diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 1607733a4..7cd6fd49f 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -162,7 +162,7 @@ SellDialog::~SellDialog() void SellDialog::reset() { mShopItems->clear(); - mSlider->setValue2(0); + mSlider->setValue(0); mShopItemList->setSelected(-1); updateButtonsAndLabels(); } @@ -213,19 +213,19 @@ void SellDialog::action(const ActionEvent &event) else if (eventId == "inc" && mAmountItems < mMaxItems) { mAmountItems++; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "dec" && mAmountItems > 1) { mAmountItems--; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "max") { mAmountItems = mMaxItems; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if ((eventId == "presell" || eventId == "sell" || eventId == "yes") @@ -269,7 +269,7 @@ void SellDialog::action(const ActionEvent &event) mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice(); mAmountItems = 1; - mSlider->setValue2(0); + mSlider->setValue(0); if (mMaxItems) { @@ -304,7 +304,7 @@ void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; - mSlider->setValue2(0); + mSlider->setValue(0); updateButtonsAndLabels(); mSlider->setScale(1, mMaxItems); diff --git a/src/map.cpp b/src/map.cpp index 70a48b811..c86c51bce 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -381,13 +381,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) // Make sure actors are sorted ascending by Y-coordinate // so that they overlap correctly -// if (mSpritesUpdated) -// { BLOCK_START("Map::draw sort") mActors.sort(actorCompare); BLOCK_END("Map::draw sort") -// mSpritesUpdated = false; -// } // update scrolling of all ambient layers updateAmbientLayers(static_cast(scrollX), @@ -480,15 +476,6 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) else #endif { -/* - if (updateFlag) - { - (*layeri)->updateSDL(graphics, startX, startY, - endX, endY, scrollX, scrollY, mDebugFlags); - } - - (*layeri)->drawSDL(graphics); -*/ layer->draw(graphics, startX, startY, endX, endY, scrollX, scrollY, mDebugFlags); } diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index de1d6f151..b0be76ac6 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -62,6 +62,9 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const msg.skip(2); // 0x0505 logger->log("Protocol: Player start position: (%d, %d)," " Direction: %d", x, y, direction); + + mLastHost &= 0xffffff; + // Switch now or we'll have problems client->setState(STATE_GAME); if (player_node) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 44d834b94..df1516b8b 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -291,6 +291,30 @@ void LoginHandler::processLoginError(Net::MessageIn &msg) const client->setState(STATE_ERROR); } +void LoginHandler::loginOrRegister(LoginData *const data) +{ + if (!data) + return; + + logger->log("Username is %s", data->username.c_str()); + + // Send login infos + if (data->registerLogin) + registerAccount(data); + else + loginAccount(data); + + // Clear the password, avoids auto login when returning to login + data->password.clear(); + + const bool remember = data->remember; + if (remember) + serverConfig.setValue("username", data->username); + else + serverConfig.setValue("username", ""); + serverConfig.setValue("remember", remember); +} + void LoginHandler::logout() const { } diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index f539176f5..ec1610013 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -96,6 +96,8 @@ class LoginHandler : public Net::LoginHandler virtual void processServerVersion(Net::MessageIn &msg) = 0; + void loginOrRegister(LoginData *const data) override final; + protected: LoginHandler(); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index c5ed9de57..128ca2996 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -32,6 +32,8 @@ #include "debug.h" +extern unsigned int mLastHost; + namespace Ea { @@ -89,7 +91,6 @@ bool Network::connect(ServerInfo server) if (mState != IDLE && mState != NET_ERROR) { logger->log1("Tried to connect an already connected socket!"); -// assert(false); return false; } @@ -217,6 +218,7 @@ bool Network::realConnect() return false; } + mLastHost = ipAddress.host; logger->log_r("Network::Started session with %s:%i", ipToString(ipAddress.host), ipAddress.port); diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 91c2e4603..949ef5b67 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -99,6 +99,8 @@ class LoginHandler virtual void clearWorlds() = 0; + virtual void loginOrRegister(LoginData *const data) = 0; + virtual ~LoginHandler() { } -- cgit v1.2.3-70-g09d2