From 7c6f3d5a9cc4e83520dc8c2ac75ec987e730d381 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Jan 2015 20:44:02 +0300 Subject: Add min/max race into charcreation.xml. --- src/gui/windows/charcreatedialog.cpp | 12 +++++++----- src/gui/windows/charcreatedialog.h | 2 ++ src/resources/db/chardb.cpp | 16 ++++++++++++++++ src/resources/db/chardb.h | 4 ++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 64346eabe..fe22b0317 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -130,10 +130,12 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mGenderStrip(nullptr), mMaxPoints(0), mUsedPoints(0), - mRace(0), + mRace(CharDB::getMinRace()), mLook(0), mMinLook(CharDB::getMinLook()), mMaxLook(CharDB::getMaxLook()), + mMinRace(CharDB::getMinRace()), + mMaxRace(CharDB::getMaxRace()), mHairStyle(0), mHairColor(0), mSlot(slot), @@ -619,10 +621,10 @@ void CharCreateDialog::updateHair() void CharCreateDialog::updateRace() { - if (mRace < 0) - mRace = Being::getNumOfRaces() - 1; - else if (mRace >= Being::getNumOfRaces()) - mRace = 0; + if (mRace < mMinRace) + mRace = mMaxRace; + else if (mRace > mMaxRace) + mRace = mMinRace; updateLook(); } diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index 45555f869..d179982ad 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -148,6 +148,8 @@ class CharCreateDialog final : public Window, int mLook; int mMinLook; int mMaxLook; + int mMinRace; + int mMaxRace; int mHairStyle; int mHairColor; diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp index b000a21fc..2fab004ad 100644 --- a/src/resources/db/chardb.cpp +++ b/src/resources/db/chardb.cpp @@ -38,6 +38,8 @@ namespace unsigned mSumStat = 0; unsigned mMinLook = 0; unsigned mMaxLook = 0; + unsigned mMinRace = 0; + unsigned mMaxRace = 30; std::vector mDefaultItems; } // namespace @@ -83,6 +85,10 @@ void CharDB::load() if (id > 0) mDefaultItems.push_back(id); } + else if (xmlNameEqual(node, "race")) + { + loadMinMax(node, &mMinRace, &mMaxRace); + } } delete doc; @@ -150,6 +156,16 @@ unsigned CharDB::getMaxLook() return mMaxLook; } +unsigned CharDB::getMinRace() +{ + return mMinRace; +} + +unsigned CharDB::getMaxRace() +{ + return mMaxRace; +} + const std::vector &CharDB::getDefaultItems() { return mDefaultItems; diff --git a/src/resources/db/chardb.h b/src/resources/db/chardb.h index 02a07c723..653b5ff83 100644 --- a/src/resources/db/chardb.h +++ b/src/resources/db/chardb.h @@ -63,6 +63,10 @@ namespace CharDB unsigned getMaxLook() A_WARN_UNUSED; + unsigned getMinRace() A_WARN_UNUSED; + + unsigned getMaxRace() A_WARN_UNUSED; + const std::vector &getDefaultItems() A_WARN_UNUSED; } // namespace CharDB -- cgit v1.2.3-70-g09d2