diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 23:28:26 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-03 23:41:59 +0200 |
commit | f4e01badebdc5975c9ded35a93f7ac501e4f73c8 (patch) | |
tree | 5024e9be339bd47be410278072153c8fd9a1ad8c /src | |
parent | 3a274b8e8c1183e2ef37a5ac0d75849db5560fb3 (diff) | |
download | mana-client-f4e01badebdc5975c9ded35a93f7ac501e4f73c8.tar.gz mana-client-f4e01badebdc5975c9ded35a93f7ac501e4f73c8.tar.bz2 mana-client-f4e01badebdc5975c9ded35a93f7ac501e4f73c8.tar.xz mana-client-f4e01badebdc5975c9ded35a93f7ac501e4f73c8.zip |
Fixed compile warnings and other tweaks
Warnings were about initialization order and signed variables compared
to unsigned variables. Please pay attention to these things.
Also made some getters const and turned some std::string parameters into
const std::string &.
Diffstat (limited to 'src')
-rw-r--r-- | src/animatedsprite.h | 4 | ||||
-rw-r--r-- | src/gui/chat.cpp | 2 | ||||
-rw-r--r-- | src/gui/chat.h | 2 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 22 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 22 | ||||
-rw-r--r-- | src/resources/animation.h | 4 | ||||
-rw-r--r-- | src/simpleanimation.cpp | 4 | ||||
-rw-r--r-- | src/simpleanimation.h | 8 |
8 files changed, 35 insertions, 33 deletions
diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 43248731..fc7bdbbc 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -101,8 +101,8 @@ class AnimatedSprite SpriteDirection mDirection; /**< The sprite direction. */ int mLastTime; /**< The last time update was called. */ - unsigned int mFrameIndex; /**< The index of the current frame. */ - unsigned int mFrameTime; /**< The time since start of frame. */ + int mFrameIndex; /**< The index of the current frame. */ + int mFrameTime; /**< The time since start of frame. */ SpriteDef *mSprite; /**< The sprite definition. */ Action *mAction; /**< The currently active action. */ diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 81c2abd8..479e45a6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -264,7 +264,7 @@ bool ChatWindow::requestChatFocus() return true; } -bool ChatWindow::isInputFocused() +bool ChatWindow::isInputFocused() const { return mChatInput->isFocused(); } diff --git a/src/gui/chat.h b/src/gui/chat.h index e4865ed8..efd0b02e 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -129,7 +129,7 @@ class ChatWindow : public Window, /** * Checks whether ChatWindow is Focused or not. */ - bool isInputFocused(); + bool isInputFocused() const; /** * Passes the text to the current tab as input diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 5b1d1a07..64101c0c 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -46,15 +46,13 @@ NpcDialog::NpcDialog() : Window(_("NPC")), - mActionState(NPC_ACTION_WAIT), - mInputState(NPC_INPUT_NONE), mNpcId(0), - mDefaultString(""), mDefaultInt(0), - mText("") + mInputState(NPC_INPUT_NONE), + mActionState(NPC_ACTION_WAIT) { // Basic Window Setup - setWindowName("NPCText"); + setWindowName("NpcText"); setResizable(true); setMinWidth(200); @@ -197,11 +195,11 @@ void NpcDialog::action(const gcn::ActionEvent &event) mIntField->setValue(mDefaultInt); } } - else if(event.getId() == "plus") + else if (event.getId() == "plus") { mIntField->setValue(mIntField->getValue() + 1); } - else if(event.getId() == "minus") + else if (event.getId() == "minus") { mIntField->setValue(mIntField->getValue() - 1); } @@ -235,7 +233,7 @@ void NpcDialog::choiceRequest() buildLayout(); } -void NpcDialog::addChoice(std::string choice) +void NpcDialog::addChoice(const std::string &choice) { mItems.push_back(choice); } @@ -249,7 +247,7 @@ void NpcDialog::parseListItems(const std::string &itemString) mItems.push_back(tmp); } -void NpcDialog::textRequest(std::string defaultText) +void NpcDialog::textRequest(const std::string &defaultText) { mActionState = NPC_ACTION_INPUT; mInputState = NPC_INPUT_STRING; @@ -258,7 +256,7 @@ void NpcDialog::textRequest(std::string defaultText) buildLayout(); } -bool NpcDialog::isInputFocused() +bool NpcDialog::isInputFocused() const { return mTextField->isFocused() || mIntField->isFocused(); } @@ -310,14 +308,14 @@ void NpcDialog::buildLayout() place(0, 3, mListScrollArea, 5, 3); place(3, 6, mButton, 2); } - else if(mInputState == NPC_INPUT_STRING) + else if (mInputState == NPC_INPUT_STRING) { place(0, 0, mScrollArea, 5, 3); place(0, 3, mTextField, 5); place(0, 4, mResetButton, 2); place(3, 4, mButton, 2); } - else if(mInputState == NPC_INPUT_INTEGER) + else if (mInputState == NPC_INPUT_INTEGER) { place(0, 0, mScrollArea, 5, 3); place(0, 3, mMinusButton, 1); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 2adcc9c1..7800d828 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -111,14 +111,14 @@ class NpcDialog : public Window, public gcn::ActionListener, std::string getElementAt(int i); /** - * Makes this dialog request a choice selection from the user + * Makes this dialog request a choice selection from the user. */ void choiceRequest(); /** - * Adds a choice to the list box + * Adds a choice to the list box. */ - void addChoice(std::string); + void addChoice(const std::string &); /** * Fills the options list for an NPC dialog. @@ -130,9 +130,9 @@ class NpcDialog : public Window, public gcn::ActionListener, /** * Requests a text string from the user. */ - void textRequest(std::string defaultText = ""); + void textRequest(const std::string &defaultText = ""); - bool isInputFocused(); + bool isInputFocused() const; /** * Requests a interger from the user. @@ -176,24 +176,28 @@ class NpcDialog : public Window, public gcn::ActionListener, // Will reset the text and integer input to the provided default Button *mResetButton; - enum NPCInputState { + enum NpcInputState + { NPC_INPUT_NONE, NPC_INPUT_LIST, NPC_INPUT_STRING, NPC_INPUT_INTEGER }; - NPCInputState mInputState; - enum NPCActionState { + enum NpcActionState + { NPC_ACTION_WAIT, NPC_ACTION_NEXT, NPC_ACTION_INPUT, NPC_ACTION_CLOSE }; - NPCActionState mActionState; + + NpcInputState mInputState; + NpcActionState mActionState; }; // TODO: This should be made not to be global, later. extern NpcDialog* npcDialog; + #endif // NPCDIALOG_H diff --git a/src/resources/animation.h b/src/resources/animation.h index f309dbf8..80e0781a 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -34,7 +34,7 @@ class Image; struct Frame { Image *image; - unsigned int delay; + int delay; int offsetX; int offsetY; }; @@ -68,7 +68,7 @@ class Animation /** * Returns the length of this animation in frames. */ - unsigned int getLength() const { return mFrames.size(); } + int getLength() const { return mFrames.size(); } /** * Returns the duration of this animation. diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 7038f446..678116cc 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -139,7 +139,7 @@ void SimpleAnimation::setFrame(int frame) mCurrentFrame = mAnimation->getFrame(mAnimationPhase); } -void SimpleAnimation::update(unsigned int timePassed) +void SimpleAnimation::update(int timePassed) { mAnimationTime += timePassed; @@ -155,7 +155,7 @@ void SimpleAnimation::update(unsigned int timePassed) } } -int SimpleAnimation::getLength() +int SimpleAnimation::getLength() const { return mAnimation->getLength(); } diff --git a/src/simpleanimation.h b/src/simpleanimation.h index 508810b1..e1e1f5da 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -50,9 +50,9 @@ class SimpleAnimation void setFrame(int frame); - int getLength(); + int getLength() const; - void update(unsigned int timePassed); + void update(int timePassed); bool draw(Graphics* graphics, int posX, int posY) const; @@ -68,10 +68,10 @@ class SimpleAnimation Animation *mAnimation; /** Time in game ticks the current frame is shown. */ - unsigned int mAnimationTime; + int mAnimationTime; /** Index of current animation phase. */ - unsigned int mAnimationPhase; + int mAnimationPhase; /** Current animation phase. */ Frame *mCurrentFrame; |