From c4cef10f92a8ff3fc668e0644d38744dccd06392 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 13 Jul 2014 12:49:11 +0300 Subject: Fix signed/unsigned type for some vars. --- src/gui/widgets/passwordfield.cpp | 3 ++- src/gui/widgets/passwordfield.h | 2 +- src/gui/windows/charcreatedialog.cpp | 14 ++++++++++++-- src/resources/dyepalette.cpp | 3 ++- src/resources/dyepalette.h | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp index b85eff686..d6d310616 100644 --- a/src/gui/widgets/passwordfield.cpp +++ b/src/gui/widgets/passwordfield.cpp @@ -29,7 +29,8 @@ PasswordField::PasswordField(const Widget2 *const widget, const std::string &text) : TextField(widget, text), - mPasswordChar(mSkin ? mSkin->getOption("passwordChar", 42) : 42) + mPasswordChar(mSkin ? static_cast( + mSkin->getOption("passwordChar", 42)) : 42U) { } diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 4c05afd40..f9f677d0d 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -47,7 +47,7 @@ class PasswordField final : public TextField void draw(Graphics *graphics) override final; protected: - char mPasswordChar; + unsigned char mPasswordChar; }; #endif // GUI_WIDGETS_PASSWORDFIELD_H diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 02ff66354..ddd6ac873 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -166,13 +166,23 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, maxHairStyle = mPlayer->getNumOfHairstyles(); if (maxHairStyle) - mHairStyle = (rand() % maxHairStyle) + minHairStyle; + { + mHairStyle = (static_cast(rand()) + % maxHairStyle) + minHairStyle; + } else + { mHairStyle = 0; + } if (maxHairColor) - mHairColor = (rand() % maxHairColor) + minHairColor; + { + mHairColor = (static_cast(rand()) + % maxHairColor) + minHairColor; + } else + { mHairColor = 0; + } mNameField->setMaximum(24); diff --git a/src/resources/dyepalette.cpp b/src/resources/dyepalette.cpp index 4c62abd1c..753ff6823 100644 --- a/src/resources/dyepalette.cpp +++ b/src/resources/dyepalette.cpp @@ -99,7 +99,8 @@ unsigned int DyePalette::hexDecode(const signed char c) return 0; } -void DyePalette::getColor(const int intensity, int color[3]) const +void DyePalette::getColor(const unsigned int intensity, + unsigned int color[3]) const { if (intensity == 0) { diff --git a/src/resources/dyepalette.h b/src/resources/dyepalette.h index a2f555b4f..39576002e 100644 --- a/src/resources/dyepalette.h +++ b/src/resources/dyepalette.h @@ -49,7 +49,8 @@ class DyePalette final * Gets a pixel color depending on its intensity. First color is * implicitly black (0, 0, 0). */ - void getColor(const int intensity, int color[3]) const; + void getColor(const unsigned int intensity, + unsigned int color[3]) const; /** * Gets a pixel color depending on its intensity. -- cgit v1.2.3-70-g09d2