Skip to content

Commit

Permalink
NWN: Be more consistent with types in Chargen
Browse files Browse the repository at this point in the history
  • Loading branch information
Supermanu committed Jun 3, 2016
1 parent 8b4f4a0 commit c517e57
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/engines/nwn/gui/chargen/charattributes.cpp
Expand Up @@ -220,7 +220,7 @@ void CharAttributes::hide() {
// Get previous choice.
uint sum = 0;
for (size_t ab = 0; ab < 6; ++ab) {
_attributes[ab] = _choices->getAbility(ab);
_attributes[ab] = _choices->getAbility(static_cast<Ability>(ab));
sum += _attributes[ab];
}
_pointLeft = 0;
Expand Down
15 changes: 7 additions & 8 deletions src/engines/nwn/gui/chargen/chargenchoices.cpp
Expand Up @@ -376,27 +376,26 @@ bool CharGenChoices::getAlign(uint8 &goodness, uint8 &loyalty) const {
return true;
}

uint8 CharGenChoices::getAbility(size_t ability) const {
uint8 CharGenChoices::getAbility(Ability ability) const {
return _abilities[ability];
}

uint8 CharGenChoices::getTotalAbility(size_t ability) const {
uint8 CharGenChoices::getTotalAbility(Ability ability) const {
return _abilities[ability] + _racialAbilities[ability];
}

int32 CharGenChoices::getAbilityModifier(Ability ability) {
uint32 totalAbility = _abilities[ability] + _racialAbilities[ability];
totalAbility -= 6;
int32 modifier = (totalAbility - totalAbility % 2) / 2;
modifier -= 2;
int8 CharGenChoices::getAbilityModifier(Ability ability) {
uint8 totalAbility = getTotalAbility(ability);
int8 modifier = (totalAbility - totalAbility % 2) / 2;
modifier -= 5;
return modifier;
}

uint8 CharGenChoices::getPackage() const {
return _package;
}

uint32 CharGenChoices::getSpellSchool() const {
uint8 CharGenChoices::getSpellSchool() const {
return _spellSchool;
}

Expand Down
8 changes: 4 additions & 4 deletions src/engines/nwn/gui/chargen/chargenchoices.h
Expand Up @@ -72,12 +72,12 @@ class CharGenChoices {
uint32 getClass() const;
uint32 getRace() const;
bool getAlign(uint8 &goodness, uint8 &loyalty) const;
uint8 getAbility(size_t ability) const;
uint8 getTotalAbility(size_t ability) const;
int32 getAbilityModifier(Ability ability);
uint8 getAbility(Ability ability) const;
uint8 getTotalAbility(Ability ability) const;
int8 getAbilityModifier(Ability ability);
std::vector<uint32> getFeats();
uint8 getPackage() const;
uint32 getSpellSchool() const;
uint8 getSpellSchool() const;

private:
Creature *_creature;
Expand Down
2 changes: 1 addition & 1 deletion src/engines/nwn/gui/chargen/charschool.cpp
Expand Up @@ -75,7 +75,7 @@ void CharSchool::hide() {
if (_returnCode == 1) {
// Set previous choice if any.
if (_choices->getSpellSchool() < UINT8_MAX)
_buttons->setActive(_choices->getSpellSchool());
_buttons->setActive((size_t) _choices->getSpellSchool());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/engines/nwn/gui/chargen/charspells.cpp
Expand Up @@ -354,7 +354,7 @@ void CharSpells::makeSpellsList() {
for (size_t ab = 0; ab < twodaAbilities.getRowCount(); ++ab) {
const Aurora::TwoDARow &abilityRow = twodaAbilities.getRow(ab);
if (abilityStr.toLower() == abilityRow.getString("Label").toLower()) {
_abilityLimit = _choices->getTotalAbility(ab) - 10U;
_abilityLimit = _choices->getTotalAbility(static_cast<Ability>(ab)) - 10U;
break;
}
}
Expand Down

0 comments on commit c517e57

Please sign in to comment.