From 9718062e6ed305d9f8f1674ff172079688e78088 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 21 Aug 2012 22:24:24 +0200 Subject: [PATCH 01/16] moved monster's position to Monster --- src/battle/BattleState.cpp | 9 ++++++--- src/battle/BattleState.h | 2 -- src/battle/Monster.h | 6 ++++++ src/battle/TargetSelection.cpp | 10 +++++----- src/battle/states/PerformAttacks.cpp | 18 +++++++++++++----- src/battle/states/SelectTarget.cpp | 4 ++-- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index aae4635..fe1b309 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -78,7 +78,6 @@ void BattleState::Resize(int w, int h) { void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { - monstersLayout->CalculatePositions(background->w, background->h, monsterPositions); for (int i(0); i < 4; ++i) { heroes[i].Position() = heroesLayout->CalculatePosition(i, background->w, background->h); heroes[i].SpellMenu() = res->spellMenuPrototype; @@ -89,6 +88,10 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { smallHeroTags[i] = SmallHeroTag(this, i); } + for (int i(0); i < int(monsters.size()); ++i) { + monsters[i].Position() = monstersLayout->CalculatePosition(i, background->w, background->h); + } + int tagHeight(attackTypeMenu.Height()); int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2); int xOffset((Width() - 2 * tagWidth) / 2); @@ -369,9 +372,9 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { if (MonsterPositionOccupied(i)) { if (monsters[i].GetAnimation().Running()) { - monsters[i].GetAnimation().DrawCenter(screen, monsterPositions[i] + offset); + monsters[i].GetAnimation().DrawCenter(screen, monsters[i].Position() + offset); } else { - monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); + monsters[i].Sprite()->DrawCenter(screen, monsters[i].Position() + offset); } } } diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index f5268dd..654e147 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -109,7 +109,6 @@ public: int MaxHeroes() const { return 4; } int MaxMonsters() const { return monsters.size(); } - const std::vector > &MonsterPositions() const { return monsterPositions; } bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; } bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; } @@ -162,7 +161,6 @@ private: AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; // TODO: combine all data about heros or monsters - std::vector > monsterPositions; std::vector monsters; std::vector attackOrder; Hero heroes[4]; diff --git a/src/battle/Monster.h b/src/battle/Monster.h index 232da8f..8338cb1 100644 --- a/src/battle/Monster.h +++ b/src/battle/Monster.h @@ -10,6 +10,7 @@ #include "AttackChoice.h" #include "Stats.h" +#include "../geometry/Point.h" #include "../graphics/Animation.h" #include @@ -61,6 +62,9 @@ public: const graphics::Animation *AttackAnimation() const { return attackAnimation; } const graphics::Animation *SpellAnimation() const { return spellAnimation; } + geometry::Point &Position() { return position; } + const geometry::Point &Position() const { return position; } + // temporary setters until loader is implemented public: void SetName(const char *n) { name = n; } @@ -93,6 +97,8 @@ private: graphics::AnimationRunner animation; + geometry::Point position; + AttackChoice attackChoice; Uint16 maxHealth, health; diff --git a/src/battle/TargetSelection.cpp b/src/battle/TargetSelection.cpp index b24772d..1906c2b 100644 --- a/src/battle/TargetSelection.cpp +++ b/src/battle/TargetSelection.cpp @@ -13,7 +13,7 @@ namespace battle { TargetSelection::TargetSelection(BattleState *battle, bool multiple, bool atEnemy) : battle(battle) -, selected(battle ? ((int)battle->MonsterPositions().size() > battle->NumHeroes() ? (int)battle->MonsterPositions().size() : battle->NumHeroes()) : 0, State()) +, selected(battle ? (battle->MaxMonsters() > battle->NumHeroes() ? battle->MaxMonsters() : battle->NumHeroes()) : 0, State()) , selection(-1) , cursor(0) , multiple(multiple) @@ -59,9 +59,9 @@ void TargetSelection::MoveUp() { void TargetSelection::MoveRight() { if (TargetsEnemies()) { - cursor = (cursor + 1) % battle->MonsterPositions().size(); + cursor = (cursor + 1) % battle->MaxMonsters(); while (!battle->MonsterPositionOccupied(cursor)) { - cursor = (cursor + 1) % battle->MonsterPositions().size(); + cursor = (cursor + 1) % battle->MaxMonsters(); } } else { cursor = (cursor + 1) % battle->NumHeroes(); @@ -81,7 +81,7 @@ void TargetSelection::MoveDown() { void TargetSelection::MoveLeft() { if (TargetsEnemies()) { - cursor = (cursor + battle->MonsterPositions().size() - 1) % battle->MonsterPositions().size(); + cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters(); FindNextEnemy(); } else { cursor = (cursor + battle->NumHeroes() - 1) % battle->NumHeroes(); @@ -91,7 +91,7 @@ void TargetSelection::MoveLeft() { void TargetSelection::FindNextEnemy() { int start(cursor); while (!battle->MonsterPositionOccupied(cursor)) { - cursor = (cursor + battle->MonsterPositions().size() - 1) % battle->MonsterPositions().size(); + cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters(); if (cursor == start) break; } } diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index acb8194..4483179 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -145,11 +145,11 @@ void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) { if (ts.IsBad(i)) { numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); numberPosition.push_back( - battle->MonsterPositions()[i]); + battle->MonsterAt(i).Position()); } else if (ts.IsGood(i)) { numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite)); numberPosition.push_back( - battle->MonsterPositions()[i]); + battle->MonsterAt(i).Position()); } } } else { @@ -251,9 +251,17 @@ void PerformAttacks::RenderNumbers(SDL_Surface *screen, const Vector &offse void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector &offset) const { if (!targetAnimation.Valid() || !targetAnimation.Running()) return; const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection()); - for (vector >::size_type i(0), end(ts.TargetsHeroes() ? battle->NumHeroes() : battle->MaxMonsters()); i < end; ++i) { - if (ts.IsSelected(i)) { - targetAnimation.DrawCenter(screen, (ts.TargetsHeroes() ? battle->HeroAt(i).Position() : battle->MonsterPositions()[i]) + offset); + if (ts.TargetsHeroes()) { + for (vector >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) { + if (ts.IsSelected(i)) { + targetAnimation.DrawCenter(screen, battle->HeroAt(i).Position() + offset); + } + } + } else { + for (vector >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) { + if (ts.IsSelected(i)) { + targetAnimation.DrawCenter(screen, battle->MonsterAt(i).Position() + offset); + } } } } diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index 2583857..591da67 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -95,8 +95,8 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); vector > positions; if (selection->TargetsEnemies()) { - for (vector >::const_iterator i(battle->MonsterPositions().begin()), end(battle->MonsterPositions().end()); i != end; ++i) { - positions.push_back(*i); + for (int i(0), end(battle->MaxMonsters()); i < end; ++i) { + positions.push_back(battle->MonsterAt(i).Position()); } } else { for (int i(0), end(battle->NumHeroes()); i < end; ++i) { -- 2.39.2 From cb86f68c08eec5c2e131037116bf9a9f5cf9f2c7 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 21 Aug 2012 22:28:25 +0200 Subject: [PATCH 02/16] removed battleState TODOs this current version should do for the next few days --- src/battle/BattleState.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 654e147..d22d689 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -78,7 +78,6 @@ public: virtual void UpdateWorld(float deltaT); virtual void Render(SDL_Surface *); - // TODO: turn this mess into a well stuctured interface public: const Resources &Res() const { return *res; } AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } @@ -160,7 +159,6 @@ private: const Resources *res; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; - // TODO: combine all data about heros or monsters std::vector monsters; std::vector attackOrder; Hero heroes[4]; -- 2.39.2 From b53c2ec2621ccc654e819cb203dc26e0a482bd41 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 21 Aug 2012 23:27:32 +0200 Subject: [PATCH 03/16] added target selection type detection for weapons --- src/battle/TargetSelection.cpp | 16 +++++++++++++++ src/battle/TargetSelection.h | 4 ++++ src/battle/states/SelectAttackType.cpp | 28 +++++++++++++++++++------- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/battle/TargetSelection.cpp b/src/battle/TargetSelection.cpp index 1906c2b..5fbf785 100644 --- a/src/battle/TargetSelection.cpp +++ b/src/battle/TargetSelection.cpp @@ -8,6 +8,7 @@ #include "TargetSelection.h" #include "BattleState.h" +#include "../common/TargetingMode.h" namespace battle { @@ -23,6 +24,21 @@ TargetSelection::TargetSelection(BattleState *battle, bool multiple, bool atEnem } } + +void TargetSelection::ReadMode(const common::TargetingMode &tm) { + if (tm.TargetsEnemy()) { + SelectEnemies(); + } else { + SelectHeroes(); + } + if (tm.TargetsSingle()) { + SelectSingle(); + } else if (tm.TargetsMultiple()) { + SelectMultiple(); + } +} + + void TargetSelection::SelectEnemies() { if (TargetsEnemies()) return; enemy = true; diff --git a/src/battle/TargetSelection.h b/src/battle/TargetSelection.h index 70c95b5..b57a41d 100644 --- a/src/battle/TargetSelection.h +++ b/src/battle/TargetSelection.h @@ -10,6 +10,8 @@ #include +namespace common { class TargetingMode; } + namespace battle { class BattleState; @@ -31,6 +33,8 @@ public: bool SelectSingle() const { return !SelectMultiple(); } void SetSingle() { multiple = false; } + void ReadMode(const common::TargetingMode &); + void SelectEnemies(); void SelectHeroes(); void Select(int index) { selected[index].type = State::SELECTED; selection = index; } diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index 4bac0bb..a6e288a 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -16,12 +16,14 @@ #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" +#include "../../common/Item.h" #include "../../geometry/operators.h" #include using app::Application; using app::Input; +using common::Item; using geometry::Point; using geometry::Vector; @@ -69,21 +71,33 @@ void SelectAttackType::HandleEvents(const Input &input) { battle->GetAttackTypeMenu().Select(AttackChoice::SWORD); } + Hero &hero(battle->ActiveHero()); + AttackChoice &ac(hero.GetAttackChoice()); if (input.JustPressed(Input::ACTION_A)) { switch (battle->GetAttackTypeMenu().Selected()) { case AttackChoice::SWORD: - // TODO: detect single/multiple/all attack mode - battle->ActiveHero().GetAttackChoice().Selection().SetSingle(); - battle->ActiveHero().GetAttackChoice().Selection().Reset(); - ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHero().GetAttackChoice().Selection(), battle->Res().weaponTargetCursor)); + if (hero.HasWeapon()) { + if (hero.Weapon()->GetTargetingMode().TargetsAll()) { + ac.SetType(AttackChoice::SWORD); + battle->NextHero(); + break; + } else { + ac.Selection().ReadMode(hero.Weapon()->GetTargetingMode()); + } + } else { + ac.Selection().SetSingle(); + } + ac.Selection().Reset(); + ctrl->PushState(new SelectTarget(battle, this, &ac.Selection(), battle->Res().weaponTargetCursor)); break; case AttackChoice::MAGIC: + // TODO: detect single/multiple/all attack mode if (battle->ActiveHero().CanUseMagic()) { ctrl->PushState(new SelectSpell(battle, this)); } break; case AttackChoice::DEFEND: - battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::DEFEND); + ac.SetType(AttackChoice::DEFEND); battle->NextHero(); break; case AttackChoice::IKARI: @@ -96,12 +110,12 @@ void SelectAttackType::HandleEvents(const Input &input) { throw std::logic_error("selected invalid attack type"); } } else if (input.JustPressed(Input::ACTION_B)) { - battle->ActiveHero().GetAttackChoice().Reset(); + ac.Reset(); battle->PreviousHero(); if (battle->BeforeFirstHero()) { ctrl->ChangeState(new SelectMoveAction(battle)); } else { - battle->ActiveHero().GetAttackChoice().Reset(); + ac.Reset(); } } -- 2.39.2 From 19f0f64186c38fab38fe802bc1b797b1418d573a Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 21:05:55 +0200 Subject: [PATCH 04/16] removed invalid TODO :o --- src/battle/states/SelectAttackType.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index a6e288a..3157ca7 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -91,7 +91,6 @@ void SelectAttackType::HandleEvents(const Input &input) { ctrl->PushState(new SelectTarget(battle, this, &ac.Selection(), battle->Res().weaponTargetCursor)); break; case AttackChoice::MAGIC: - // TODO: detect single/multiple/all attack mode if (battle->ActiveHero().CanUseMagic()) { ctrl->PushState(new SelectSpell(battle, this)); } -- 2.39.2 From 0f5f8a6eaa938f88fd3d1e92dec2462b30840e21 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 21:45:10 +0200 Subject: [PATCH 05/16] randomized monsters' attack target selection --- src/battle/BattleState.cpp | 56 ++++++++++++++++++++++++++++++-------- src/battle/BattleState.h | 1 + src/main.cpp | 4 +++ 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index fe1b309..fe821fc 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -22,6 +22,7 @@ #include #include +#include #include using app::Application; @@ -33,6 +34,7 @@ using geometry::Point; using geometry::Vector; using graphics::Menu; +using std::rand; using std::vector; namespace battle { @@ -220,26 +222,43 @@ bool BattleState::AttacksFinished() const { } void BattleState::CalculateDamage() { + if (CurrentAttack().isMonster) { + DecideMonsterAttack(MonsterAt(CurrentAttack().index)); + } AttackChoice &ac(CurrentAttack().isMonster ? MonsterAt(CurrentAttack().index).GetAttackChoice() : HeroAt(CurrentAttack().index).GetAttackChoice()); if (ac.GetType() == AttackChoice::DEFEND) return; + TargetSelection &ts(ac.Selection()); + // TODO: this only evaluates SWORD type attacks if (CurrentAttack().isMonster) { const Stats &attackerStats(MonsterAt(CurrentAttack().index).GetStats()); - // TODO: run monster's attack script - ac.SetType(AttackChoice::SWORD); - ac.Selection().SelectSingle(); - ac.Selection().SelectHeroes(); - for (int i(0); i < NumHeroes(); ++i) { - if (HeroAt(i).Health() > 0) { - const Stats &defenderStats(HeroAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ac.Selection().SetBad(0, damage); - break; + if (ts.TargetsEnemies()) { + for (int i(0); i < MaxMonsters(); ++i) { + if (ts.IsSelected(i)) { + if (MonsterAt(i).Health() > 0) { + const Stats &defenderStats(MonsterAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + } else { + ts.Unselect(i); + } + } + } + } else { + for (int i(0); i < NumHeroes(); ++i) { + if (ts.IsSelected(i)) { + if (HeroAt(i).Health() > 0) { + const Stats &defenderStats(HeroAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + } else { + ts.Unselect(i); + } + } } } } else { const Stats &attackerStats(HeroAt(CurrentAttack().index).GetStats()); - TargetSelection &ts(ac.Selection()); bool hitSome(false); if (ts.TargetsEnemies()) { for (int i(0); i < MaxMonsters(); ++i) { @@ -289,6 +308,21 @@ void BattleState::CalculateDamage() { } } +void BattleState::DecideMonsterAttack(Monster &m) { + AttackChoice &ac(m.GetAttackChoice()); + TargetSelection &ts(ac.Selection()); + ac.Reset(); + // TODO: run monster's attack script + int target(rand() % NumHeroes()); + while (!HeroPositionOccupied(target)) { + target = rand() % NumHeroes(); + } + ac.SetType(AttackChoice::SWORD); + ts.SelectHeroes(); + ts.SetSingle(); + ts.Select(target); +} + Uint16 BattleState::CalculateDamage(const Stats &attacker, const Stats &defender) const { // TODO: find out real formula and add some randomness return attacker.Attack() / 2 - defender.Defense() / 4; diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index d22d689..4fd9a15 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -150,6 +150,7 @@ public: private: void LoadInventory(); + void DecideMonsterAttack(Monster &); Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const; private: diff --git a/src/main.cpp b/src/main.cpp index cf6e78b..71a29e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,8 @@ #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" +#include +#include #include #include #include @@ -70,6 +72,8 @@ int main(int argc, char **argv) { const int framerate = 33; +// std::srand(std::time(0)); + try { InitSDL sdl; InitImage image(IMG_INIT_PNG); -- 2.39.2 From fde7b27297882a7f033641df92e732abd137b532 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 21:49:34 +0200 Subject: [PATCH 06/16] renamed TargetSelections Enemies to Monsters --- src/battle/BattleState.cpp | 6 +++--- src/battle/TargetSelection.cpp | 18 +++++++++--------- src/battle/TargetSelection.h | 6 +++--- src/battle/states/PerformAttacks.cpp | 2 +- src/battle/states/SelectIkari.cpp | 2 +- src/battle/states/SelectItem.cpp | 2 +- src/battle/states/SelectSpell.cpp | 2 +- src/battle/states/SelectTarget.cpp | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index fe821fc..3f28f5c 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -232,7 +232,7 @@ void BattleState::CalculateDamage() { // TODO: this only evaluates SWORD type attacks if (CurrentAttack().isMonster) { const Stats &attackerStats(MonsterAt(CurrentAttack().index).GetStats()); - if (ts.TargetsEnemies()) { + if (ts.TargetsMonsters()) { for (int i(0); i < MaxMonsters(); ++i) { if (ts.IsSelected(i)) { if (MonsterAt(i).Health() > 0) { @@ -260,7 +260,7 @@ void BattleState::CalculateDamage() { } else { const Stats &attackerStats(HeroAt(CurrentAttack().index).GetStats()); bool hitSome(false); - if (ts.TargetsEnemies()) { + if (ts.TargetsMonsters()) { for (int i(0); i < MaxMonsters(); ++i) { if (ts.IsSelected(i)) { if (MonsterAt(i).Health() > 0) { @@ -332,7 +332,7 @@ void BattleState::ApplyDamage() { if (attackCursor < 0) return; AttackChoice &ac(CurrentAttack().isMonster ? MonsterAt(CurrentAttack().index).GetAttackChoice() : HeroAt(CurrentAttack().index).GetAttackChoice()); TargetSelection &ts(ac.Selection()); - if (ts.TargetsEnemies()) { + if (ts.TargetsMonsters()) { for (int i(0); i < MaxMonsters(); ++i) { Monster &monster(MonsterAt(i)); if (ts.IsBad(i)) { diff --git a/src/battle/TargetSelection.cpp b/src/battle/TargetSelection.cpp index 5fbf785..8769330 100644 --- a/src/battle/TargetSelection.cpp +++ b/src/battle/TargetSelection.cpp @@ -27,7 +27,7 @@ TargetSelection::TargetSelection(BattleState *battle, bool multiple, bool atEnem void TargetSelection::ReadMode(const common::TargetingMode &tm) { if (tm.TargetsEnemy()) { - SelectEnemies(); + SelectMonsters(); } else { SelectHeroes(); } @@ -39,8 +39,8 @@ void TargetSelection::ReadMode(const common::TargetingMode &tm) { } -void TargetSelection::SelectEnemies() { - if (TargetsEnemies()) return; +void TargetSelection::SelectMonsters() { + if (TargetsMonsters()) return; enemy = true; UnselectAll(); cursor = 0; @@ -58,23 +58,23 @@ void TargetSelection::SelectHeroes() { void TargetSelection::Reset() { UnselectAll(); cursor = 0; - if (TargetsEnemies()) { + if (TargetsMonsters()) { FindNextEnemy(); } } void TargetSelection::MoveUp() { - if (TargetsEnemies()) return; + if (TargetsMonsters()) return; if (cursor < 2) { - SelectEnemies(); + SelectMonsters(); } else { cursor -= 2; } } void TargetSelection::MoveRight() { - if (TargetsEnemies()) { + if (TargetsMonsters()) { cursor = (cursor + 1) % battle->MaxMonsters(); while (!battle->MonsterPositionOccupied(cursor)) { cursor = (cursor + 1) % battle->MaxMonsters(); @@ -85,7 +85,7 @@ void TargetSelection::MoveRight() { } void TargetSelection::MoveDown() { - if (TargetsEnemies()) { + if (TargetsMonsters()) { SelectHeroes(); return; } @@ -96,7 +96,7 @@ void TargetSelection::MoveDown() { } void TargetSelection::MoveLeft() { - if (TargetsEnemies()) { + if (TargetsMonsters()) { cursor = (cursor + battle->MaxMonsters() - 1) % battle->MaxMonsters(); FindNextEnemy(); } else { diff --git a/src/battle/TargetSelection.h b/src/battle/TargetSelection.h index b57a41d..fd1d041 100644 --- a/src/battle/TargetSelection.h +++ b/src/battle/TargetSelection.h @@ -22,8 +22,8 @@ public: explicit TargetSelection(BattleState *battle = 0, bool multiple = false, bool atEnemy = true); public: - bool TargetsEnemies() const { return enemy; } - bool TargetsHeroes() const { return !TargetsEnemies(); } + bool TargetsMonsters() const { return enemy; } + bool TargetsHeroes() const { return !TargetsMonsters(); } bool IsSelected(int index) const { return index >= 0 && index < int(selected.size()) && selected[index].type != State::IGNORE; } bool HasSelected() const { return selection >= 0; } int SingleSelection() const { return selection; } @@ -35,7 +35,7 @@ public: void ReadMode(const common::TargetingMode &); - void SelectEnemies(); + void SelectMonsters(); void SelectHeroes(); void Select(int index) { selected[index].type = State::SELECTED; selection = index; } void Unselect(int index) { selected[index].type = State::IGNORE; } diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 4483179..6aae5d7 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -140,7 +140,7 @@ void PerformAttacks::HandleEvents(const Input &input) { } void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) { - if (ts.TargetsEnemies()) { + if (ts.TargetsMonsters()) { for (int i(0); i < battle->MaxMonsters(); ++i) { if (ts.IsBad(i)) { numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 5c1a27a..4fce8c7 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -62,7 +62,7 @@ void SelectIkari::HandleEvents(const Input &input) { if (ikari->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); } else { - ac.Selection().SelectEnemies(); + ac.Selection().SelectMonsters(); } if (ikari->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::MAGIC); diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index bd09da6..4c197ff 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -61,7 +61,7 @@ void SelectItem::HandleEvents(const Input &input) { if (item->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); } else { - ac.Selection().SelectEnemies(); + ac.Selection().SelectMonsters(); } if (item->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::ITEM); diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index 0708196..1bc195c 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -62,7 +62,7 @@ void SelectSpell::HandleEvents(const Input &input) { if (spell->GetTargetingMode().TargetsAlly()) { ac.Selection().SelectHeroes(); } else { - ac.Selection().SelectEnemies(); + ac.Selection().SelectMonsters(); } if (spell->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::MAGIC); diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index 591da67..37f2da9 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -94,7 +94,7 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); vector > positions; - if (selection->TargetsEnemies()) { + if (selection->TargetsMonsters()) { for (int i(0), end(battle->MaxMonsters()); i < end; ++i) { positions.push_back(battle->MonsterAt(i).Position()); } -- 2.39.2 From 6db6d2adbc3e36b385d6c508e416060afa44dd7a Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 21:50:25 +0200 Subject: [PATCH 07/16] fixed attack choice reset bug did not reset the first hero's attack choice when cancelling the second hero's selection --- src/battle/states/SelectAttackType.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index 3157ca7..7f36681 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -114,7 +114,7 @@ void SelectAttackType::HandleEvents(const Input &input) { if (battle->BeforeFirstHero()) { ctrl->ChangeState(new SelectMoveAction(battle)); } else { - ac.Reset(); + battle->ActiveHero().GetAttackChoice().Reset(); } } -- 2.39.2 From e845e0acd0c097c84510499ebc17d74373db829f Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 21:54:47 +0200 Subject: [PATCH 08/16] set targeting mode for weapons in main --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 71a29e5..eed7397 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -485,6 +485,7 @@ int main(int argc, char **argv) { Item zircoSword; zircoSword.SetName("Zirco sword"); zircoSword.SetMenuIcon(&swordIcon); + zircoSword.GetTargetingMode().TargetSingleEnemy(); Ikari firestorm; firestorm.SetName("Firestorm"); firestorm.SetCost(224); @@ -547,6 +548,7 @@ int main(int argc, char **argv) { Item zircoWhip; zircoWhip.SetName("Zirco whip"); zircoWhip.SetMenuIcon(&rodIcon); + zircoWhip.GetTargetingMode().TargetSingleEnemy(); Ikari thundershriek; thundershriek.SetName("Thundershriek"); thundershriek.SetCost(224); @@ -608,6 +610,7 @@ int main(int argc, char **argv) { Item zircoAx; zircoAx.SetName("Zirco ax"); zircoAx.SetMenuIcon(&axIcon); + zircoAx.GetTargetingMode().TargetSingleEnemy(); Ikari torrent; torrent.SetName("Torrent"); torrent.SetCost(224); @@ -652,6 +655,7 @@ int main(int argc, char **argv) { Item lizardBlow; lizardBlow.SetName("Lizard blow"); lizardBlow.SetMenuIcon(&swordIcon); + lizardBlow.GetTargetingMode().TargetSingleEnemy(); Ikari dragonRush; dragonRush.SetName("Dragon rush"); dragonRush.SetCost(164); -- 2.39.2 From c20927cf8ab9bb7526f641850c3997f14c66f06e Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 22:14:53 +0200 Subject: [PATCH 09/16] extracted damage calculation once more --- src/battle/BattleState.cpp | 124 ++++++++++++++++--------------------- src/battle/BattleState.h | 3 +- 2 files changed, 54 insertions(+), 73 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 3f28f5c..ae88731 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -232,83 +232,14 @@ void BattleState::CalculateDamage() { // TODO: this only evaluates SWORD type attacks if (CurrentAttack().isMonster) { const Stats &attackerStats(MonsterAt(CurrentAttack().index).GetStats()); - if (ts.TargetsMonsters()) { - for (int i(0); i < MaxMonsters(); ++i) { - if (ts.IsSelected(i)) { - if (MonsterAt(i).Health() > 0) { - const Stats &defenderStats(MonsterAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - } else { - ts.Unselect(i); - } - } - } - } else { - for (int i(0); i < NumHeroes(); ++i) { - if (ts.IsSelected(i)) { - if (HeroAt(i).Health() > 0) { - const Stats &defenderStats(HeroAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - } else { - ts.Unselect(i); - } - } - } - } + CalculateDamage(attackerStats, ts); } else { const Stats &attackerStats(HeroAt(CurrentAttack().index).GetStats()); - bool hitSome(false); - if (ts.TargetsMonsters()) { - for (int i(0); i < MaxMonsters(); ++i) { - if (ts.IsSelected(i)) { - if (MonsterAt(i).Health() > 0) { - const Stats &defenderStats(MonsterAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - hitSome = true; - } else { - ts.Unselect(i); - } - } - } - if (hitSome) return; - for (int i(0); i < MaxMonsters(); ++i) { - if (MonsterAt(i).Health() > 0) { - const Stats &defenderStats(MonsterAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - break; - } - } - } else { - for (int i(0); i < NumHeroes(); ++i) { - if (ts.IsSelected(i)) { - if (HeroAt(i).Health() > 0) { - const Stats &defenderStats(HeroAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - hitSome = true; - } else { - ts.Unselect(i); - } - } - } - if (hitSome) return; - for (int i(0); i < NumHeroes(); ++i) { - if (HeroAt(i).Health() > 0) { - const Stats &defenderStats(HeroAt(i).GetStats()); - Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - ts.SetBad(i, damage); - break; - } - } - } + CalculateDamage(attackerStats, ts); } } -void BattleState::DecideMonsterAttack(Monster &m) { +void BattleState::DecideMonsterAttack(Monster &m) const { AttackChoice &ac(m.GetAttackChoice()); TargetSelection &ts(ac.Selection()); ac.Reset(); @@ -323,6 +254,55 @@ void BattleState::DecideMonsterAttack(Monster &m) { ts.Select(target); } +void BattleState::CalculateDamage(const Stats &attackerStats, TargetSelection &ts) const { + bool hitSome(false); + if (ts.TargetsMonsters()) { + for (int i(0); i < MaxMonsters(); ++i) { + if (ts.IsSelected(i)) { + if (MonsterAt(i).Health() > 0) { + const Stats &defenderStats(MonsterAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + hitSome = true; + } else { + ts.Unselect(i); + } + } + } + if (hitSome) return; + for (int i(0); i < MaxMonsters(); ++i) { + if (MonsterAt(i).Health() > 0) { + const Stats &defenderStats(MonsterAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + break; + } + } + } else { + for (int i(0); i < NumHeroes(); ++i) { + if (ts.IsSelected(i)) { + if (HeroAt(i).Health() > 0) { + const Stats &defenderStats(HeroAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + hitSome = true; + } else { + ts.Unselect(i); + } + } + } + if (hitSome) return; + for (int i(0); i < NumHeroes(); ++i) { + if (HeroAt(i).Health() > 0) { + const Stats &defenderStats(HeroAt(i).GetStats()); + Uint16 damage(CalculateDamage(attackerStats, defenderStats)); + ts.SetBad(i, damage); + break; + } + } + } +} + Uint16 BattleState::CalculateDamage(const Stats &attacker, const Stats &defender) const { // TODO: find out real formula and add some randomness return attacker.Attack() / 2 - defender.Defense() / 4; diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 4fd9a15..a6ba398 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -150,7 +150,8 @@ public: private: void LoadInventory(); - void DecideMonsterAttack(Monster &); + void DecideMonsterAttack(Monster &) const; + void CalculateDamage(const Stats &attackerStats, TargetSelection &targets) const; Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const; private: -- 2.39.2 From 0542849dfccfec1ce1477265fa0fee2401a8fb23 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 22:35:37 +0200 Subject: [PATCH 10/16] merged Point into Vector this should make some stuff a lot easier --- src/battle/AttackTypeMenu.cpp | 4 +- src/battle/AttackTypeMenu.h | 4 +- src/battle/BattleState.cpp | 18 +++---- src/battle/BattleState.h | 7 ++- src/battle/Hero.h | 8 +-- src/battle/HeroTag.cpp | 4 +- src/battle/HeroTag.h | 3 +- src/battle/Monster.h | 8 +-- src/battle/MoveMenu.cpp | 4 +- src/battle/MoveMenu.h | 4 +- src/battle/NumberAnimation.cpp | 6 +-- src/battle/NumberAnimation.h | 4 +- src/battle/PartyLayout.cpp | 3 -- src/battle/PartyLayout.h | 18 +++---- src/battle/SmallHeroTag.cpp | 4 +- src/battle/SmallHeroTag.h | 4 +- src/battle/states/PerformAttacks.cpp | 11 ++-- src/battle/states/PerformAttacks.h | 2 +- src/battle/states/RunState.cpp | 8 ++- src/battle/states/SelectAttackType.cpp | 4 +- src/battle/states/SelectIkari.cpp | 9 ++-- src/battle/states/SelectItem.cpp | 9 ++-- src/battle/states/SelectMoveAction.cpp | 4 +- src/battle/states/SelectSpell.cpp | 9 ++-- src/battle/states/SelectTarget.cpp | 7 +-- src/battle/states/SwapHeroes.cpp | 7 +-- src/geometry/Point.h | 31 ----------- src/geometry/Vector.h | 48 +++++++++++++++++ src/geometry/operators.h | 72 -------------------------- src/graphics/Animation.h | 10 ++-- src/graphics/Font.cpp | 16 +++--- src/graphics/Font.h | 10 ++-- src/graphics/Frame.cpp | 4 +- src/graphics/Frame.h | 4 +- src/graphics/Gauge.cpp | 4 +- src/graphics/Gauge.h | 4 +- src/graphics/Menu.h | 6 +-- src/graphics/Sprite.cpp | 4 +- src/graphics/Sprite.h | 10 ++-- src/main.cpp | 18 +++---- 40 files changed, 153 insertions(+), 261 deletions(-) delete mode 100644 src/geometry/Point.h delete mode 100644 src/geometry/operators.h diff --git a/src/battle/AttackTypeMenu.cpp b/src/battle/AttackTypeMenu.cpp index 2ec7a1f..b18c522 100644 --- a/src/battle/AttackTypeMenu.cpp +++ b/src/battle/AttackTypeMenu.cpp @@ -7,16 +7,14 @@ #include "AttackTypeMenu.h" -#include "../geometry/operators.h" #include "../geometry/Vector.h" #include "../graphics/Sprite.h" -using geometry::Point; using geometry::Vector; namespace battle { -void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Point &position) { +void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Vector &position) { Vector swordOffset(IconWidth(), IconHeight()); Vector magicOffset(IconWidth(), 0); Vector defendOffset(2 * IconWidth(), IconHeight()); diff --git a/src/battle/AttackTypeMenu.h b/src/battle/AttackTypeMenu.h index 4b38dd3..d31d63b 100644 --- a/src/battle/AttackTypeMenu.h +++ b/src/battle/AttackTypeMenu.h @@ -9,7 +9,7 @@ #define BATTLE_ATTACKTYPEMENU_H_ #include "AttackChoice.h" -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include "../graphics/Sprite.h" #include @@ -25,7 +25,7 @@ public: public: void Select(AttackChoice::Type t) { selected = t; } AttackChoice::Type Selected() const { return selected; } - void Render(SDL_Surface *screen, const geometry::Point &position); + void Render(SDL_Surface *screen, const geometry::Vector &position); int Width() const { return 3 * IconWidth(); } int Height() const { return 3 * IconHeight(); } diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index ae88731..f548f2d 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -16,7 +16,6 @@ #include "../common/Inventory.h" #include "../common/Item.h" #include "../common/Spell.h" -#include "../geometry/operators.h" #include "../graphics/Frame.h" #include "../graphics/Sprite.h" @@ -30,7 +29,6 @@ using app::Input; using common::Inventory; using common::Item; using common::Spell; -using geometry::Point; using geometry::Vector; using graphics::Menu; @@ -97,19 +95,19 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { int tagHeight(attackTypeMenu.Height()); int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2); int xOffset((Width() - 2 * tagWidth) / 2); - heroTagPositions[0] = Point(xOffset, Height() - 2 * tagHeight); - heroTagPositions[1] = Point(xOffset + tagWidth, Height() - 2 * tagHeight); - heroTagPositions[2] = Point(xOffset, Height() - tagHeight); - heroTagPositions[3] = Point(xOffset + tagWidth, Height() - tagHeight); + heroTagPositions[0] = Vector(xOffset, Height() - 2 * tagHeight); + heroTagPositions[1] = Vector(xOffset + tagWidth, Height() - 2 * tagHeight); + heroTagPositions[2] = Vector(xOffset, Height() - tagHeight); + heroTagPositions[3] = Vector(xOffset + tagWidth, Height() - tagHeight); tagHeight = res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2; tagWidth = res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2; xOffset = (Width() - 4 * tagWidth) / 2; int yOffset(Height() - tagHeight); - smallHeroTagPositions[0] = Point(xOffset, yOffset); - smallHeroTagPositions[1] = Point(xOffset + 2 * tagWidth, yOffset); - smallHeroTagPositions[2] = Point(xOffset + tagWidth, yOffset); - smallHeroTagPositions[3] = Point(xOffset + 3 * tagWidth, yOffset); + smallHeroTagPositions[0] = Vector(xOffset, yOffset); + smallHeroTagPositions[1] = Vector(xOffset + 2 * tagWidth, yOffset); + smallHeroTagPositions[2] = Vector(xOffset + tagWidth, yOffset); + smallHeroTagPositions[3] = Vector(xOffset + 3 * tagWidth, yOffset); itemMenu = res->itemMenuPrototype; LoadInventory(); diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index a6ba398..27953cd 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -16,7 +16,6 @@ #include "Resources.h" #include "SmallHeroTag.h" #include "../app/State.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include "../graphics/Animation.h" #include "../graphics/Menu.h" @@ -99,7 +98,7 @@ public: const Monster &MonsterAt(int index) const { assert(index >= 0 && index < NumHeroes()); return monsters[index]; } const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; } - const geometry::Point &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } + const geometry::Vector &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } @@ -167,8 +166,8 @@ private: graphics::Menu itemMenu; HeroTag heroTags[4]; SmallHeroTag smallHeroTags[4]; - geometry::Point heroTagPositions[4]; - geometry::Point smallHeroTagPositions[4]; + geometry::Vector heroTagPositions[4]; + geometry::Vector smallHeroTagPositions[4]; int numHeroes; int activeHero; int attackCursor; diff --git a/src/battle/Hero.h b/src/battle/Hero.h index 7444902..1cce110 100644 --- a/src/battle/Hero.h +++ b/src/battle/Hero.h @@ -10,7 +10,7 @@ #include "AttackChoice.h" #include "Stats.h" -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include "../graphics/Animation.h" #include "../graphics/Menu.h" @@ -88,8 +88,8 @@ public: const graphics::Animation *AttackAnimation() const { return attackAnimation; } const graphics::Animation *SpellAnimation() const { return spellAnimation; } - geometry::Point &Position() { return position; } - const geometry::Point &Position() const { return position; } + geometry::Vector &Position() { return position; } + const geometry::Vector &Position() const { return position; } graphics::Menu &SpellMenu() { return spellMenu; } const graphics::Menu &SpellMenu() const { return spellMenu; } @@ -147,7 +147,7 @@ private: graphics::AnimationRunner animation; - geometry::Point position; + geometry::Vector position; graphics::Menu spellMenu; graphics::Menu ikariMenu; diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 228bfda..7938250 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -11,14 +11,12 @@ #include "BattleState.h" #include "Hero.h" #include "Resources.h" -#include "../geometry/operators.h" #include "../geometry/Vector.h" #include "../graphics/Font.h" #include "../graphics/Frame.h" #include "../graphics/Gauge.h" #include "../graphics/Sprite.h" -using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -28,7 +26,7 @@ const graphics::Sprite *HeroTag::HeroSprite() const { return battle->HeroAt(index).Sprite(); } -void HeroTag::Render(SDL_Surface *screen, int width, int height, Point position, bool active) const { +void HeroTag::Render(SDL_Surface *screen, int width, int height, Vector position, bool active) const { const Resources &r(battle->Res()); // frame diff --git a/src/battle/HeroTag.h b/src/battle/HeroTag.h index f1408fd..43dc661 100644 --- a/src/battle/HeroTag.h +++ b/src/battle/HeroTag.h @@ -9,7 +9,6 @@ #define BATTLE_HEROTAG_H_ #include "Hero.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include @@ -36,7 +35,7 @@ public: const graphics::Sprite *HeroSprite() const; geometry::Vector HeroOffset() const; - void Render(SDL_Surface *screen, int width, int height, geometry::Point position, bool active) const; + void Render(SDL_Surface *screen, int width, int height, geometry::Vector position, bool active) const; private: const BattleState *battle; diff --git a/src/battle/Monster.h b/src/battle/Monster.h index 8338cb1..c125672 100644 --- a/src/battle/Monster.h +++ b/src/battle/Monster.h @@ -10,7 +10,7 @@ #include "AttackChoice.h" #include "Stats.h" -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include "../graphics/Animation.h" #include @@ -62,8 +62,8 @@ public: const graphics::Animation *AttackAnimation() const { return attackAnimation; } const graphics::Animation *SpellAnimation() const { return spellAnimation; } - geometry::Point &Position() { return position; } - const geometry::Point &Position() const { return position; } + geometry::Vector &Position() { return position; } + const geometry::Vector &Position() const { return position; } // temporary setters until loader is implemented public: @@ -97,7 +97,7 @@ private: graphics::AnimationRunner animation; - geometry::Point position; + geometry::Vector position; AttackChoice attackChoice; diff --git a/src/battle/MoveMenu.cpp b/src/battle/MoveMenu.cpp index 4d5ff79..849f694 100644 --- a/src/battle/MoveMenu.cpp +++ b/src/battle/MoveMenu.cpp @@ -7,16 +7,14 @@ #include "MoveMenu.h" -#include "../geometry/operators.h" #include "../geometry/Vector.h" #include "../graphics/Sprite.h" -using geometry::Point; using geometry::Vector; namespace battle { -void MoveMenu::Render(SDL_Surface *screen, const geometry::Point &position) { +void MoveMenu::Render(SDL_Surface *screen, const geometry::Vector &position) { Vector attackOffset(0, IconHeight()); Vector changeOffset(0, 0); Vector runOffset(0, 2 * IconHeight()); diff --git a/src/battle/MoveMenu.h b/src/battle/MoveMenu.h index 771fcb8..63b9d88 100644 --- a/src/battle/MoveMenu.h +++ b/src/battle/MoveMenu.h @@ -8,7 +8,7 @@ #ifndef BATTLE_MOVEMENU_H_ #define BATTLE_MOVEMENU_H_ -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include "../graphics/Sprite.h" namespace battle { @@ -30,7 +30,7 @@ public: public: void Select(Icon i) { selected = i; } Icon Selected() const { return selected; } - void Render(SDL_Surface *screen, const geometry::Point &position); + void Render(SDL_Surface *screen, const geometry::Vector &position); int Width() const { return IconWidth(); } int Height() const { return 3 * IconHeight(); } diff --git a/src/battle/NumberAnimation.cpp b/src/battle/NumberAnimation.cpp index 17eb771..fcc707f 100644 --- a/src/battle/NumberAnimation.cpp +++ b/src/battle/NumberAnimation.cpp @@ -7,11 +7,9 @@ #include "NumberAnimation.h" -#include "../geometry/operators.h" #include "../geometry/Vector.h" using app::State; -using geometry::Point; using geometry::Vector; using graphics::Animation; using graphics::AnimationRunner; @@ -87,8 +85,8 @@ int NumberAnimation::Height() const { return animation[0].GetSprite()->Height(); } -void NumberAnimation::Draw(SDL_Surface *dest, const Point &positionIn) const { - Point position(positionIn); +void NumberAnimation::Draw(SDL_Surface *dest, const Vector &positionIn) const { + Vector position(positionIn); Vector step(animation[0].GetSprite()->Width(), 0); if (number > 999) { if (animation[0].Running()) { diff --git a/src/battle/NumberAnimation.h b/src/battle/NumberAnimation.h index 08ca01f..f753056 100644 --- a/src/battle/NumberAnimation.h +++ b/src/battle/NumberAnimation.h @@ -10,7 +10,7 @@ #include "../graphics/Animation.h" -#include "../geometry/Point.h" +#include "../geometry/Vector.h" namespace app { class Application; @@ -33,7 +33,7 @@ public: int Width() const; int Height() const; - void Draw(SDL_Surface *dest, const geometry::Point &position) const; + void Draw(SDL_Surface *dest, const geometry::Vector &position) const; private: int number; diff --git a/src/battle/PartyLayout.cpp b/src/battle/PartyLayout.cpp index e1fd33f..6389327 100644 --- a/src/battle/PartyLayout.cpp +++ b/src/battle/PartyLayout.cpp @@ -7,9 +7,6 @@ #include "PartyLayout.h" -using geometry::Point; -using std::vector; - namespace battle { } diff --git a/src/battle/PartyLayout.h b/src/battle/PartyLayout.h index 6844139..1d72aa8 100644 --- a/src/battle/PartyLayout.h +++ b/src/battle/PartyLayout.h @@ -8,7 +8,7 @@ #ifndef BATTLE_PARTYLAYOUT_H_ #define BATTLE_PARTYLAYOUT_H_ -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include #include @@ -22,34 +22,34 @@ public: PartyLayout() { } public: - std::vector >::size_type NumPositions() const { return positions.size(); } + std::vector >::size_type NumPositions() const { return positions.size(); } template - void CalculatePositions(U width, U height, std::vector > &dest) const { + void CalculatePositions(U width, U height, std::vector > &dest) const { dest.clear(); dest.reserve(positions.size()); - for (std::vector >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) { - dest.push_back(geometry::Point( + for (std::vector >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) { + dest.push_back(geometry::Vector( i->X() * width / 255, i->Y() * height / 223 )); } } template - geometry::Point CalculatePosition(std::vector >::size_type index, U width, U height) const { + geometry::Vector CalculatePosition(std::vector >::size_type index, U width, U height) const { assert(index >= 0 && index < positions.size()); - return geometry::Point( + return geometry::Vector( positions[index].X() * width / 255, positions[index].Y() * height / 223 ); } public: - void AddPosition(const geometry::Point &p) { + void AddPosition(const geometry::Vector &p) { positions.push_back(p); } private: - std::vector > positions; + std::vector > positions; }; diff --git a/src/battle/SmallHeroTag.cpp b/src/battle/SmallHeroTag.cpp index 7843cc0..0bc160a 100644 --- a/src/battle/SmallHeroTag.cpp +++ b/src/battle/SmallHeroTag.cpp @@ -8,13 +8,11 @@ #include "SmallHeroTag.h" #include "BattleState.h" -#include "../geometry/operators.h" #include "../geometry/Vector.h" #include "../graphics/Font.h" #include "../graphics/Frame.h" #include "../graphics/Gauge.h" -using geometry::Point; using geometry::Vector; using graphics::Font; using graphics::Frame; @@ -22,7 +20,7 @@ using graphics::Sprite; namespace battle { -void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Point position) const { +void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Vector position) const { const Resources &r(battle->Res()); const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame); const Font *font(r.normalFont); diff --git a/src/battle/SmallHeroTag.h b/src/battle/SmallHeroTag.h index 1f392c3..acd2d31 100644 --- a/src/battle/SmallHeroTag.h +++ b/src/battle/SmallHeroTag.h @@ -8,7 +8,7 @@ #ifndef BATTLE_SMALLHEROTAG_H_ #define BATTLE_SMALLHEROTAG_H_ -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include @@ -29,7 +29,7 @@ public: SmallHeroTag(const BattleState *battle, int heroIndex) : battle(battle), index(heroIndex) { } - void Render(SDL_Surface *screen, int width, int height, geometry::Point position) const; + void Render(SDL_Surface *screen, int width, int height, geometry::Vector position) const; private: const BattleState *battle; diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 6aae5d7..a01a8fe 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -15,8 +15,6 @@ #include "../../common/Ikari.h" #include "../../common/Item.h" #include "../../common/Spell.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" #include "../../graphics/Animation.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -25,7 +23,6 @@ using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; using graphics::AnimationRunner; using std::vector; @@ -231,9 +228,9 @@ void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector &offs if (!titleBarText || !titleBarTimer.Running()) return; int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); - battle->Res().titleFrame->Draw(screen, Point(offset.X(), offset.Y()), battle->Width(), height); + battle->Res().titleFrame->Draw(screen, Vector(offset.X(), offset.Y()), battle->Width(), height); - Point textPosition( + Vector textPosition( (battle->Width() - (std::strlen(titleBarText) * battle->Res().titleFont->CharWidth())) / 2, battle->Res().titleFrame->BorderHeight()); battle->Res().titleFont->DrawString(titleBarText, screen, textPosition + offset); @@ -252,13 +249,13 @@ void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry:: if (!targetAnimation.Valid() || !targetAnimation.Running()) return; const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection()); if (ts.TargetsHeroes()) { - for (vector >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) { + for (vector >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) { if (ts.IsSelected(i)) { targetAnimation.DrawCenter(screen, battle->HeroAt(i).Position() + offset); } } } else { - for (vector >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) { + for (vector >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) { if (ts.IsSelected(i)) { targetAnimation.DrawCenter(screen, battle->MonsterAt(i).Position() + offset); } diff --git a/src/battle/states/PerformAttacks.h b/src/battle/states/PerformAttacks.h index d060d5a..19c6967 100644 --- a/src/battle/states/PerformAttacks.h +++ b/src/battle/states/PerformAttacks.h @@ -59,7 +59,7 @@ private: app::Timer titleBarTimer; app::Timer targetAnimationTimer; std::vector numberAnimation; - std::vector > numberPosition; + std::vector > numberPosition; int cursor; }; diff --git a/src/battle/states/RunState.cpp b/src/battle/states/RunState.cpp index 155313f..a22f438 100644 --- a/src/battle/states/RunState.cpp +++ b/src/battle/states/RunState.cpp @@ -10,8 +10,7 @@ #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" +#include "../../geometry/Vector.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -19,7 +18,6 @@ using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; namespace battle { @@ -70,9 +68,9 @@ void RunState::Render(SDL_Surface *screen) { void RunState::RenderTitleBar(SDL_Surface *screen, const Vector &offset) { int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); - battle->Res().titleFrame->Draw(screen, Point(offset.X(), offset.Y()), battle->Width(), height); + battle->Res().titleFrame->Draw(screen, Vector(offset.X(), offset.Y()), battle->Width(), height); - Point textPosition( + Vector textPosition( (battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2, battle->Res().titleFrame->BorderHeight()); battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset); diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index 7f36681..fbd4333 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -17,14 +17,12 @@ #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Item.h" -#include "../../geometry/operators.h" #include using app::Application; using app::Input; using common::Item; -using geometry::Point; using geometry::Vector; namespace battle { @@ -136,7 +134,7 @@ void SelectAttackType::Render(SDL_Surface *screen) { } void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector &offset) { - Point position( + Vector position( (battle->Width() - battle->GetAttackTypeMenu().Width()) / 2, battle->Height() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2); battle->GetAttackTypeMenu().Render(screen, position + offset); diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 4fce8c7..7647e28 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -14,14 +14,11 @@ #include "../../app/Input.h" #include "../../common/Ikari.h" #include "../../common/Item.h" -#include "../../geometry/Point.h" -#include "../../geometry/operators.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; using common::Ikari; -using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -111,7 +108,7 @@ void SelectIkari::Render(SDL_Surface *screen) { void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Point position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderWidth(), frame->BorderHeight()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); @@ -119,7 +116,7 @@ void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector &offset) { void SelectIkari::RenderHeadline(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight()); res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset); @@ -127,7 +124,7 @@ void SelectIkari::RenderHeadline(SDL_Surface *screen, const Vector &offset) void SelectIkari::RenderMenu(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight()); battle->ActiveHero().IkariMenu().Draw(screen, position + offset); diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 4c197ff..f58a78e 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -13,14 +13,11 @@ #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Item.h" -#include "../../geometry/Point.h" -#include "../../geometry/operators.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; using common::Item; -using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -110,7 +107,7 @@ void SelectItem::Render(SDL_Surface *screen) { void SelectItem::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Point position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderWidth(), frame->BorderHeight()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); @@ -118,7 +115,7 @@ void SelectItem::RenderFrame(SDL_Surface *screen, const Vector &offset) { void SelectItem::RenderHeadline(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight()); res.normalFont->DrawString(res.itemMenuHeadline, screen, position + offset); @@ -126,7 +123,7 @@ void SelectItem::RenderHeadline(SDL_Surface *screen, const Vector &offset) void SelectItem::RenderMenu(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight()); battle->ItemMenu().Draw(screen, position + offset); diff --git a/src/battle/states/SelectMoveAction.cpp b/src/battle/states/SelectMoveAction.cpp index 7eb8fbe..b2cac81 100644 --- a/src/battle/states/SelectMoveAction.cpp +++ b/src/battle/states/SelectMoveAction.cpp @@ -14,11 +14,9 @@ #include "../MoveMenu.h" #include "../../app/Application.h" #include "../../app/Input.h" -#include "../../geometry/operators.h" using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; namespace battle { @@ -83,7 +81,7 @@ void SelectMoveAction::Render(SDL_Surface *screen) { } void SelectMoveAction::RenderMenu(SDL_Surface *screen, const Vector &offset) { - Point position( + Vector position( (battle->Width() - battle->GetMoveMenu().Width()) / 2, battle->Height() - battle->GetMoveMenu().Height() - battle->GetMoveMenu().Height() / 2); battle->GetMoveMenu().Render(screen, position + offset); diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index 1bc195c..65cd8cc 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -14,14 +14,11 @@ #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Spell.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; using common::Spell; -using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -111,7 +108,7 @@ void SelectSpell::Render(SDL_Surface *screen) { void SelectSpell::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Point position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderWidth(), frame->BorderHeight()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); @@ -119,7 +116,7 @@ void SelectSpell::RenderFrame(SDL_Surface *screen, const Vector &offset) { void SelectSpell::RenderHeadline(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight()); res.normalFont->DrawString(res.spellMenuHeadline, screen, position + offset); @@ -127,7 +124,7 @@ void SelectSpell::RenderHeadline(SDL_Surface *screen, const Vector &offset) void SelectSpell::RenderMenu(SDL_Surface *screen, const Vector &offset) { const Resources &res(battle->Res()); - Point position( + Vector position( 2 * res.selectFrame->BorderWidth() + res.normalFont->CharWidth(), 2 * res.selectFrame->BorderHeight() + 2 * res.normalFont->CharHeight()); battle->ActiveHero().SpellMenu().Draw(screen, position + offset); diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index 37f2da9..f15f455 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -11,12 +11,9 @@ #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; using std::vector; @@ -93,7 +90,7 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height()); // offset the indicator by 1/8th to the right and top Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); - vector > positions; + vector > positions; if (selection->TargetsMonsters()) { for (int i(0), end(battle->MaxMonsters()); i < end; ++i) { positions.push_back(battle->MonsterAt(i).Position()); @@ -104,7 +101,7 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector >::size_type i(0); i < positions.size(); ++i) { + for (vector >::size_type i(0); i < positions.size(); ++i) { if (selection->IsSelected(i)) { cursorIcon->DrawTopRight(screen, positions[i] + indicatorOffset + offset); } diff --git a/src/battle/states/SwapHeroes.cpp b/src/battle/states/SwapHeroes.cpp index 568fe88..5c83f74 100644 --- a/src/battle/states/SwapHeroes.cpp +++ b/src/battle/states/SwapHeroes.cpp @@ -11,12 +11,9 @@ #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; using std::vector; @@ -127,7 +124,7 @@ void SwapHeroes::RenderCursors(SDL_Surface *screen, const geometry::Vector // offset the cursor by 1/8th to the left and bottom Vector cursorOffset(battle->Res().swapCursor->Width() / -8, battle->Res().swapCursor->Height() / 8); Vector indicatorOffset(0, 0); - vector > positions; + vector > positions; for (int i(0), end(battle->NumHeroes()); i < end; ++i) { Vector positionCorrection(battle->Res().swapCursor->Width() / 2, battle->HeroTagAt(i).HeroSprite()->Height() - battle->Res().swapCursor->Height() / 2); // indicator offsets are inverted for heroes @@ -135,7 +132,7 @@ void SwapHeroes::RenderCursors(SDL_Surface *screen, const geometry::Vector positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset() + positionCorrection); } if (flipFlop) { - for (vector >::size_type i(0); i < positions.size(); ++i) { + for (vector >::size_type i(0); i < positions.size(); ++i) { if (selected == int(i)) { battle->Res().swapCursor->DrawTopRight(screen, positions[i] + offset); } diff --git a/src/geometry/Point.h b/src/geometry/Point.h deleted file mode 100644 index 9d4bd85..0000000 --- a/src/geometry/Point.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Point.h - * - * Created on: Aug 5, 2012 - * Author: holy - */ - -#ifndef GEOMETRY_POINT_H_ -#define GEOMETRY_POINT_H_ - -namespace geometry { - -template -class Point { - -public: - Point() : x(0), y(0) { } - Point(T x, T y) : x(x), y(y) { } - -public: - T X() const { return x; } - T Y() const { return y; } - -private: - T x, y; - -}; - -} - -#endif /* GEOMETRY_POINT_H_ */ diff --git a/src/geometry/Vector.h b/src/geometry/Vector.h index d7d0f3d..bf64713 100644 --- a/src/geometry/Vector.h +++ b/src/geometry/Vector.h @@ -8,6 +8,8 @@ #ifndef GEOMETRY_VECTOR_H_ #define GEOMETRY_VECTOR_H_ +#include + namespace geometry { template @@ -30,6 +32,52 @@ private: }; + +template +inline Vector operator +(const Vector &lhs, const Vector &rhs) { + return Vector(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); +} + +template +inline Vector &operator +=(Vector &lhs, const Vector &rhs) { + return lhs = lhs + rhs; +} + +template +inline Vector operator -(const Vector &lhs, const Vector &rhs) { + return Vector(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); +} + +template +inline Vector &operator -=(Vector &lhs, const Vector &rhs) { + return lhs = lhs - rhs; +} + +template +inline Vector operator -(const Vector &v) { + return Vector(-v.X(), -v.Y()); +} + +template +inline Vector operator *(const Vector &v, T s) { + return Vector(v.X() * s, v.Y() * s); +} +template +inline Vector operator *(T s, const Vector &v) { + return Vector(s * v.X(), s * v.Y()); +} + +template +inline Vector operator /(const Vector &v, T s) { + return Vector(v.X() / s, v.Y() / s); +} + +template +inline std::ostream &operator <<(std::ostream &out, const Vector &v) { + out << '<' << v.X() << ", " << v.Y() << '>'; + return out; +} + } #endif /* GEOMETRY_VECTOR_H_ */ diff --git a/src/geometry/operators.h b/src/geometry/operators.h deleted file mode 100644 index 295daa1..0000000 --- a/src/geometry/operators.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * operators.h - * - * Created on: Aug 6, 2012 - * Author: holy - */ - -#ifndef GEOMETRY_OPERATORS_H_ -#define GEOMETRY_OPERATORS_H_ - -#include "Point.h" -#include "Vector.h" - -#include - -namespace geometry { - -template -inline Vector operator +(const Vector &lhs, const Vector &rhs) { - return Vector(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); -} -template -inline Point operator +(const Point &lhs, const Vector &rhs) { - return Point(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); -} - -template -inline Vector &operator +=(Vector &lhs, const Vector &rhs) { - return lhs = lhs + rhs; -} -template -inline Point &operator +=(Point &lhs, const Vector &rhs) { - return lhs = lhs + rhs; -} - -template -inline Vector operator -(const Vector &lhs, const Vector &rhs) { - return Vector(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); -} -template -inline Point operator -(const Point &lhs, const Vector &rhs) { - return Point(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); -} - -template -inline Vector &operator -=(Vector &lhs, const Vector &rhs) { - return lhs = lhs - rhs; -} -template -inline Point &operator -=(Point &lhs, const Vector &rhs) { - return lhs = lhs - rhs; -} - -template -inline Vector operator -(const Vector &v) { - return Vector(-v.X(), -v.Y()); -} - -template -inline std::ostream &operator <<(std::ostream &out, const Point &p) { - out << '(' << p.X() << ", " << p.Y() << ')'; - return out; -} -template -inline std::ostream &operator <<(std::ostream &out, const Vector &v) { - out << '<' << v.X() << ", " << v.Y() << '>'; - return out; -} - -} - -#endif /* GEOMETRY_OPERATORS_H_ */ diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 0baba35..e26bca9 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -12,8 +12,6 @@ #include "../app/Application.h" #include "../app/State.h" #include "../app/Timer.h" -#include "../geometry/operators.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include @@ -91,18 +89,18 @@ public: void ChangeSprite(const Sprite *s) { sprite = s; } const Sprite *GetSprite() const { return sprite; } - void Draw(SDL_Surface *dest, geometry::Point position) const { + void Draw(SDL_Surface *dest, geometry::Vector position) const { sprite->Draw(dest, position + animation->Offset(Frame()), animation->Col(Frame()) + ColOffset(), animation->Row(Frame()) + RowOffset()); } - void DrawTopRight(SDL_Surface *dest, geometry::Point position) const { + void DrawTopRight(SDL_Surface *dest, geometry::Vector position) const { geometry::Vector offset(-sprite->Width(), 0); Draw(dest, position + offset); } - void DrawCenter(SDL_Surface *dest, geometry::Point position) const { + void DrawCenter(SDL_Surface *dest, geometry::Vector position) const { geometry::Vector offset(-sprite->Width() / 2, -sprite->Height() / 2); Draw(dest, position + offset); } - void DrawCenterBottom(SDL_Surface *dest, geometry::Point position) const { + void DrawCenterBottom(SDL_Surface *dest, geometry::Vector position) const { geometry::Vector offset(-sprite->Width() / 2, -sprite->Height()); Draw(dest, position + offset); } diff --git a/src/graphics/Font.cpp b/src/graphics/Font.cpp index 1dc9051..a118500 100644 --- a/src/graphics/Font.cpp +++ b/src/graphics/Font.cpp @@ -7,42 +7,38 @@ #include "Font.h" -#include "../geometry/operators.h" -#include "../geometry/Vector.h" - #include -using geometry::Point; using geometry::Vector; using std::pow; namespace graphics { -void Font::DrawChar(char c, SDL_Surface *dest, const Point &position) const { +void Font::DrawChar(char c, SDL_Surface *dest, const Vector &position) const { int col(colOffset + (c % 0x10)); int row(rowOffset + (c / 0x10)); sprite->Draw(dest, position, col, row); } -void Font::DrawString(const char *s, SDL_Surface *dest, const Point &positionIn, int maxChars) const { - Point position(positionIn); +void Font::DrawString(const char *s, SDL_Surface *dest, const Vector &positionIn, int maxChars) const { + Vector position(positionIn); Vector step(CharWidth(), 0); for (int i(0); s[i] && (maxChars <= 0 || i < maxChars); ++i, position += step) { DrawChar(s[i], dest, position); } } -void Font::DrawDigit(int digit, SDL_Surface *dest, const Point &position) const { +void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector &position) const { DrawChar(digit + 0x30, dest, position); } -void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Point &positionIn, int digits) const { +void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector &positionIn, int digits) const { int number(numberIn); if (digits > 0 && numberIn >= pow(10.0, digits)) { numberIn = pow(10.0, digits) - 1; } - Point position(positionIn); + Vector position(positionIn); Vector step(sprite->Width(), 0); if (digits > 0) { diff --git a/src/graphics/Font.h b/src/graphics/Font.h index c48ea16..8644802 100644 --- a/src/graphics/Font.h +++ b/src/graphics/Font.h @@ -9,7 +9,7 @@ #define GRAPHICS_FONT_H_ #include "Sprite.h" -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include @@ -26,10 +26,10 @@ public: public: int CharWidth() const { return sprite->Width(); } int CharHeight() const { return sprite->Height(); } - void DrawChar(char c, SDL_Surface *dest, const geometry::Point &position) const; - void DrawString(const char *s, SDL_Surface *dest, const geometry::Point &position, int maxChars = 0) const; - void DrawDigit(int d, SDL_Surface *dest, const geometry::Point &position) const; - void DrawNumber(int n, SDL_Surface *dest, const geometry::Point &position, int digits = 0) const; + void DrawChar(char c, SDL_Surface *dest, const geometry::Vector &position) const; + void DrawString(const char *s, SDL_Surface *dest, const geometry::Vector &position, int maxChars = 0) const; + void DrawDigit(int d, SDL_Surface *dest, const geometry::Vector &position) const; + void DrawNumber(int n, SDL_Surface *dest, const geometry::Vector &position, int digits = 0) const; private: const Sprite *sprite; diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index c682fa0..1c51c45 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -7,12 +7,12 @@ #include "Frame.h" -using geometry::Point; +using geometry::Vector; namespace graphics { // TODO: maybe create a cache for frames? -void Frame::Draw(SDL_Surface *dest, const Point &position, int width, int height) const { +void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int height) const { // top-left corner SDL_Rect srcRect; srcRect.x = xOffset; diff --git a/src/graphics/Frame.h b/src/graphics/Frame.h index d2e8dd4..74ce1f7 100644 --- a/src/graphics/Frame.h +++ b/src/graphics/Frame.h @@ -8,7 +8,7 @@ #ifndef GRAPHICS_FRAME_H_ #define GRAPHICS_FRAME_H_ -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include @@ -25,7 +25,7 @@ public: int MinHeight() const { return 2 * borderHeight; } int BorderWidth() const { return borderWidth; } int BorderHeight() const { return borderHeight; } - void Draw(SDL_Surface *dest, const geometry::Point &position, int width, int height) const; + void Draw(SDL_Surface *dest, const geometry::Vector &position, int width, int height) const; private: SDL_Surface *surface; diff --git a/src/graphics/Gauge.cpp b/src/graphics/Gauge.cpp index 027d6b1..eda9942 100644 --- a/src/graphics/Gauge.cpp +++ b/src/graphics/Gauge.cpp @@ -7,11 +7,11 @@ #include "Gauge.h" -using geometry::Point; +using geometry::Vector; namespace graphics { -void Gauge::Draw(SDL_Surface *dest, const Point &position, int width, Uint8 fill) const { +void Gauge::Draw(SDL_Surface *dest, const Vector &position, int width, Uint8 fill) const { SDL_Rect srcRect, destRect; int filledWidth = fill * (width - startWidth - endWidth) / 255; diff --git a/src/graphics/Gauge.h b/src/graphics/Gauge.h index b5e30c2..fd81877 100644 --- a/src/graphics/Gauge.h +++ b/src/graphics/Gauge.h @@ -8,7 +8,7 @@ #ifndef GRAPHICS_GAUGE_H_ #define GRAPHICS_GAUGE_H_ -#include "../geometry/Point.h" +#include "../geometry/Vector.h" #include @@ -23,7 +23,7 @@ public: public: int MinWidth() const { return startWidth + endWidth; } int Height() const { return height; } - void Draw(SDL_Surface *dest, const geometry::Point &position, int width, Uint8 fill) const; + void Draw(SDL_Surface *dest, const geometry::Vector &position, int width, Uint8 fill) const; private: SDL_Surface *surface; diff --git a/src/graphics/Menu.h b/src/graphics/Menu.h index c879cc9..f1a6d25 100644 --- a/src/graphics/Menu.h +++ b/src/graphics/Menu.h @@ -10,8 +10,6 @@ #include "Font.h" #include "Sprite.h" -#include "../geometry/operators.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include @@ -61,7 +59,7 @@ public: void Reserve(int n) { entries.reserve(n); } void Clear() { entries.clear(); } - void Draw(SDL_Surface *dest, const geometry::Point &position) const; + void Draw(SDL_Surface *dest, const geometry::Vector &position) const; private: int GetRow(int index) const { return index / cols; } @@ -196,7 +194,7 @@ void Menu::SelectIndex(int index) { template -void Menu::Draw(SDL_Surface *dest, const geometry::Point &position) const { +void Menu::Draw(SDL_Surface *dest, const geometry::Vector &position) const { int start(topRow * cols); int slots(rows * cols); int items(entries.size() - start); diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index 87ce8af..2c092de 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -7,11 +7,11 @@ #include "Sprite.h" -using geometry::Point; +using geometry::Vector; namespace graphics { -void Sprite::Draw(SDL_Surface *dest, const Point &position, int col, int row) const { +void Sprite::Draw(SDL_Surface *dest, const Vector &position, int col, int row) const { SDL_Rect srcRect, destRect; srcRect.x = xOffset + col * Width(); srcRect.y = yOffset + row * Height(); diff --git a/src/graphics/Sprite.h b/src/graphics/Sprite.h index 6aa6c94..942d98e 100644 --- a/src/graphics/Sprite.h +++ b/src/graphics/Sprite.h @@ -8,8 +8,6 @@ #ifndef GRAPHICS_SPRITE_H_ #define GRAPHICS_SPRITE_H_ -#include "../geometry/operators.h" -#include "../geometry/Point.h" #include "../geometry/Vector.h" #include @@ -25,16 +23,16 @@ public: public: int Width() const { return width; } int Height() const { return height; } - void Draw(SDL_Surface *dest, const geometry::Point &position, int col = 0, int row = 0) const; - void DrawTopRight(SDL_Surface *dest, const geometry::Point &position, int col = 0, int row = 0) const { + void Draw(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const; + void DrawTopRight(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { geometry::Vector offset(-Width(), 0); Draw(dest, position + offset, col, row); } - void DrawCenter(SDL_Surface *dest, const geometry::Point &position, int col = 0, int row = 0) const { + void DrawCenter(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { geometry::Vector offset(-Width() / 2, -Height() / 2); Draw(dest, position + offset, col, row); } - void DrawCenterBottom(SDL_Surface *dest, const geometry::Point &position, int col = 0, int row = 0) const { + void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { geometry::Vector offset(-Width() / 2, -Height()); Draw(dest, position + offset, col, row); } diff --git a/src/main.cpp b/src/main.cpp index eed7397..bebeed1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,6 @@ #include "common/Inventory.h" #include "common/Item.h" #include "common/Spell.h" -#include "geometry/Point.h" #include "geometry/Vector.h" #include "graphics/ComplexAnimation.h" #include "graphics/Font.h" @@ -48,7 +47,6 @@ using common::Ikari; using common::Inventory; using common::Item; using common::Spell; -using geometry::Point; using geometry::Vector; using graphics::ComplexAnimation; using graphics::Font; @@ -82,15 +80,15 @@ int main(int argc, char **argv) { // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout; - monstersLayout.AddPosition(Point(88, 88)); - monstersLayout.AddPosition(Point(128, 88)); - monstersLayout.AddPosition(Point(168, 88)); - monstersLayout.AddPosition(Point(208, 88)); + monstersLayout.AddPosition(Vector(88, 88)); + monstersLayout.AddPosition(Vector(128, 88)); + monstersLayout.AddPosition(Vector(168, 88)); + monstersLayout.AddPosition(Vector(208, 88)); PartyLayout heroesLayout; - heroesLayout.AddPosition(Point(48, 136)); - heroesLayout.AddPosition(Point(128, 136)); - heroesLayout.AddPosition(Point(80, 152)); - heroesLayout.AddPosition(Point(160, 152)); + heroesLayout.AddPosition(Vector(48, 136)); + heroesLayout.AddPosition(Vector(128, 136)); + heroesLayout.AddPosition(Vector(80, 152)); + heroesLayout.AddPosition(Vector(160, 152)); SDL_Surface *monsterImg(IMG_Load("test-data/monster.png")); Sprite monsterSprite(monsterImg, 64, 64); -- 2.39.2 From d20fa78a0dcbc95a69bb6077d2081d42b74a2d1a Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 22 Aug 2012 23:17:03 +0200 Subject: [PATCH 11/16] switched some (x,y) and (w,h) pairs to vectors --- src/battle/AttackTypeMenu.cpp | 10 ++-- src/battle/AttackTypeMenu.h | 2 + src/battle/BattleState.h | 1 + src/battle/HeroTag.cpp | 4 +- src/battle/HeroTag.h | 2 +- src/battle/SmallHeroTag.cpp | 4 +- src/battle/SmallHeroTag.h | 2 +- src/battle/states/PerformAttacks.cpp | 2 +- src/battle/states/RunState.cpp | 2 +- src/battle/states/SelectIkari.cpp | 2 +- src/battle/states/SelectItem.cpp | 2 +- src/battle/states/SelectSpell.cpp | 2 +- src/graphics/Animation.h | 3 +- src/graphics/Frame.cpp | 76 ++++++++++++++-------------- src/graphics/Frame.h | 23 +++++---- src/graphics/Sprite.cpp | 4 +- src/graphics/Sprite.h | 16 +++--- 17 files changed, 79 insertions(+), 78 deletions(-) diff --git a/src/battle/AttackTypeMenu.cpp b/src/battle/AttackTypeMenu.cpp index b18c522..f9786fb 100644 --- a/src/battle/AttackTypeMenu.cpp +++ b/src/battle/AttackTypeMenu.cpp @@ -15,11 +15,11 @@ using geometry::Vector; namespace battle { void AttackTypeMenu::Render(SDL_Surface *screen, const geometry::Vector &position) { - Vector swordOffset(IconWidth(), IconHeight()); - Vector magicOffset(IconWidth(), 0); - Vector defendOffset(2 * IconWidth(), IconHeight()); - Vector ikariOffset(IconWidth(), 2 * IconHeight()); - Vector itemOffset(0, IconHeight()); + const Vector &swordOffset(IconSize()); + const Vector magicOffset(IconWidth(), 0); + const Vector defendOffset(2 * IconWidth(), IconHeight()); + const Vector ikariOffset(IconWidth(), 2 * IconHeight()); + const Vector itemOffset(0, IconHeight()); icons->Draw(screen, position + swordOffset, AttackChoice::SWORD, (selected == AttackChoice::SWORD) ? 1 : 0); icons->Draw(screen, position + magicOffset, AttackChoice::MAGIC, (selected == AttackChoice::MAGIC) ? 1 : 0); diff --git a/src/battle/AttackTypeMenu.h b/src/battle/AttackTypeMenu.h index d31d63b..db07443 100644 --- a/src/battle/AttackTypeMenu.h +++ b/src/battle/AttackTypeMenu.h @@ -29,8 +29,10 @@ public: int Width() const { return 3 * IconWidth(); } int Height() const { return 3 * IconHeight(); } + geometry::Vector Size() const { return 3 * IconSize(); } int IconWidth() const { return icons->Width(); } int IconHeight() const { return icons->Height(); } + const geometry::Vector &IconSize() const { return icons->Size(); } private: const graphics::Sprite *icons; diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 27953cd..806b4af 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -139,6 +139,7 @@ public: } int Width() const { return background->w; } int Height() const { return background->h; } + geometry::Vector Size() const { return geometry::Vector(Width(), Height()); } void RenderBackground(SDL_Surface *screen, const geometry::Vector &offset); void RenderMonsters(SDL_Surface *screen, const geometry::Vector &offset); diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 7938250..f94581b 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -26,12 +26,12 @@ const graphics::Sprite *HeroTag::HeroSprite() const { return battle->HeroAt(index).Sprite(); } -void HeroTag::Render(SDL_Surface *screen, int width, int height, Vector position, bool active) const { +void HeroTag::Render(SDL_Surface *screen, int width, int height, const Vector &position, bool active) const { const Resources &r(battle->Res()); // frame const Frame *frame(active ? r.activeHeroTagFrame : r.heroTagFrame); - Vector frameOffset(frame->BorderWidth(), frame->BorderHeight()); + Vector frameOffset(frame->BorderSize()); Vector alignOffset((index % 2) ? 4 * r.heroTagFont->CharWidth() : 0, 0); frame->Draw(screen, position, width, height); diff --git a/src/battle/HeroTag.h b/src/battle/HeroTag.h index 43dc661..8750081 100644 --- a/src/battle/HeroTag.h +++ b/src/battle/HeroTag.h @@ -35,7 +35,7 @@ public: const graphics::Sprite *HeroSprite() const; geometry::Vector HeroOffset() const; - void Render(SDL_Surface *screen, int width, int height, geometry::Vector position, bool active) const; + void Render(SDL_Surface *screen, int width, int height, const geometry::Vector &position, bool active) const; private: const BattleState *battle; diff --git a/src/battle/SmallHeroTag.cpp b/src/battle/SmallHeroTag.cpp index 0bc160a..a70dbfe 100644 --- a/src/battle/SmallHeroTag.cpp +++ b/src/battle/SmallHeroTag.cpp @@ -20,7 +20,7 @@ using graphics::Sprite; namespace battle { -void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Vector position) const { +void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, const geometry::Vector &position) const { const Resources &r(battle->Res()); const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame); const Font *font(r.normalFont); @@ -32,7 +32,7 @@ void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry:: const Hero &hero(battle->HeroAt(index)); int gaugeWidth(width - 2 * frame->BorderWidth() - labels->Width()); - Vector nameOffset(frame->BorderWidth(), frame->BorderHeight()); + Vector nameOffset(frame->BorderSize()); Vector hpLabelOffset(nameOffset.X(), nameOffset.Y() + font->CharHeight()); Vector mpLabelOffset(hpLabelOffset.X(), hpLabelOffset.Y() + font->CharHeight()); Vector ipLabelOffset(mpLabelOffset.X(), mpLabelOffset.Y() + font->CharHeight()); diff --git a/src/battle/SmallHeroTag.h b/src/battle/SmallHeroTag.h index acd2d31..c17d540 100644 --- a/src/battle/SmallHeroTag.h +++ b/src/battle/SmallHeroTag.h @@ -29,7 +29,7 @@ public: SmallHeroTag(const BattleState *battle, int heroIndex) : battle(battle), index(heroIndex) { } - void Render(SDL_Surface *screen, int width, int height, geometry::Vector position) const; + void Render(SDL_Surface *screen, int width, int height, const geometry::Vector &position) const; private: const BattleState *battle; diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index a01a8fe..19fccb0 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -228,7 +228,7 @@ void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector &offs if (!titleBarText || !titleBarTimer.Running()) return; int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); - battle->Res().titleFrame->Draw(screen, Vector(offset.X(), offset.Y()), battle->Width(), height); + battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height); Vector textPosition( (battle->Width() - (std::strlen(titleBarText) * battle->Res().titleFont->CharWidth())) / 2, diff --git a/src/battle/states/RunState.cpp b/src/battle/states/RunState.cpp index a22f438..e1f6f4b 100644 --- a/src/battle/states/RunState.cpp +++ b/src/battle/states/RunState.cpp @@ -68,7 +68,7 @@ void RunState::Render(SDL_Surface *screen) { void RunState::RenderTitleBar(SDL_Surface *screen, const Vector &offset) { int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); - battle->Res().titleFrame->Draw(screen, Vector(offset.X(), offset.Y()), battle->Width(), height); + battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height); Vector textPosition( (battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2, diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 7647e28..87436b0 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -108,7 +108,7 @@ void SelectIkari::Render(SDL_Surface *screen) { void SelectIkari::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Vector position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderSize()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index f58a78e..68f844f 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -107,7 +107,7 @@ void SelectItem::Render(SDL_Surface *screen) { void SelectItem::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Vector position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderSize()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index 65cd8cc..0c1dec4 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -108,7 +108,7 @@ void SelectSpell::Render(SDL_Surface *screen) { void SelectSpell::RenderFrame(SDL_Surface *screen, const Vector &offset) { const Frame *frame(battle->Res().selectFrame); - Vector position(frame->BorderWidth(), frame->BorderHeight()); + Vector position(frame->BorderSize()); int width(battle->Width() - 2 * frame->BorderWidth()); int height(battle->Res().normalFont->CharHeight() * 13); frame->Draw(screen, position + offset, width, height); diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index e26bca9..208f6bd 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -97,8 +97,7 @@ public: Draw(dest, position + offset); } void DrawCenter(SDL_Surface *dest, geometry::Vector position) const { - geometry::Vector offset(-sprite->Width() / 2, -sprite->Height() / 2); - Draw(dest, position + offset); + Draw(dest, position - (sprite->Size() / 2)); } void DrawCenterBottom(SDL_Surface *dest, geometry::Vector position) const { geometry::Vector offset(-sprite->Width() / 2, -sprite->Height()); diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index 1c51c45..a152ee7 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -15,83 +15,83 @@ namespace graphics { void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int height) const { // top-left corner SDL_Rect srcRect; - srcRect.x = xOffset; - srcRect.y = yOffset; - srcRect.w = borderWidth; - srcRect.h = borderHeight; + srcRect.x = offset.X(); + srcRect.y = offset.Y(); + srcRect.w = BorderWidth(); + srcRect.h = BorderHeight(); SDL_Rect destRect; destRect.x = position.X(); destRect.y = position.Y(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); // top border - srcRect.x += borderWidth; - srcRect.w = repeatWidth; - destRect.x += borderWidth; - int fullRepeatWidth(width - (2 * borderWidth)); + srcRect.x += BorderWidth(); + srcRect.w = RepeatWidth(); + destRect.x += BorderWidth(); + int fullRepeatWidth(width - (2 * BorderWidth())); int repeatCursor(0); while (repeatCursor < fullRepeatWidth) { SDL_BlitSurface(surface, &srcRect, dest, &destRect); - destRect.x += repeatWidth; - repeatCursor += repeatWidth; + destRect.x += RepeatWidth(); + repeatCursor += RepeatWidth(); } // top-right corner - srcRect.x += repeatWidth; - srcRect.w = borderWidth; + srcRect.x += RepeatWidth(); + srcRect.w = BorderWidth(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); // middle - destRect.y += borderHeight; - int fullRepeatHeight(height - (2 * borderHeight)); + destRect.y += BorderHeight(); + int fullRepeatHeight(height - (2 * BorderHeight())); int hRepeatCursor(0); while (hRepeatCursor < fullRepeatHeight) { // left border - srcRect.x = xOffset; - srcRect.y = yOffset + borderHeight; - srcRect.w = borderWidth; - srcRect.h = repeatHeight; + srcRect.x = offset.X(); + srcRect.y = offset.Y() + BorderHeight(); + srcRect.w = BorderWidth(); + srcRect.h = RepeatHeight(); destRect.x = position.X(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); // fill repeatCursor = 0; - srcRect.x += borderWidth; - srcRect.w = repeatWidth; - destRect.x += borderWidth; + srcRect.x += BorderWidth(); + srcRect.w = RepeatWidth(); + destRect.x += BorderWidth(); while (repeatCursor < fullRepeatWidth) { SDL_BlitSurface(surface, &srcRect, dest, &destRect); - destRect.x += repeatWidth; - repeatCursor += repeatWidth; + destRect.x += RepeatWidth(); + repeatCursor += RepeatWidth(); } // right border - srcRect.x += repeatWidth; - srcRect.w = borderWidth; + srcRect.x += RepeatWidth(); + srcRect.w = BorderWidth(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); - destRect.y += repeatHeight; - hRepeatCursor += repeatHeight; + destRect.y += RepeatHeight(); + hRepeatCursor += RepeatHeight(); } // bottom-left corner - srcRect.x = xOffset; - srcRect.y = yOffset + borderHeight + repeatHeight; - srcRect.w = borderWidth; - srcRect.h = borderHeight; + srcRect.x = offset.X(); + srcRect.y = offset.Y() + BorderHeight() + RepeatHeight(); + srcRect.w = BorderWidth(); + srcRect.h = BorderHeight(); destRect.x = position.X(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); // bottom border - srcRect.x += borderWidth; - srcRect.w = repeatWidth; - destRect.x += borderWidth; + srcRect.x += BorderWidth(); + srcRect.w = RepeatWidth(); + destRect.x += BorderWidth(); repeatCursor = 0; while (repeatCursor < fullRepeatWidth) { SDL_BlitSurface(surface, &srcRect, dest, &destRect); - destRect.x += repeatWidth; - repeatCursor += repeatWidth; + destRect.x += RepeatWidth(); + repeatCursor += RepeatWidth(); } if (fullRepeatWidth < fullRepeatWidth) { srcRect.w = fullRepeatWidth - fullRepeatWidth; @@ -100,8 +100,8 @@ void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int } // bottom-right corner - srcRect.x += repeatWidth; - srcRect.w = borderWidth; + srcRect.x += RepeatWidth(); + srcRect.w = BorderWidth(); SDL_BlitSurface(surface, &srcRect, dest, &destRect); } diff --git a/src/graphics/Frame.h b/src/graphics/Frame.h index 74ce1f7..09674cc 100644 --- a/src/graphics/Frame.h +++ b/src/graphics/Frame.h @@ -18,23 +18,24 @@ class Frame { public: Frame(SDL_Surface *s, int borderWidth, int borderHeight, int repeatWidth = 1, int repeatHeight = 1, int xOffset = 0, int yOffset = 0) - : surface(s), borderWidth(borderWidth), borderHeight(borderHeight), repeatWidth(repeatWidth), repeatHeight(repeatHeight), xOffset(xOffset), yOffset(yOffset) { } + : surface(s), borderSize(borderWidth, borderHeight), repeatSize(repeatWidth, repeatHeight), offset(xOffset, yOffset) { } public: - int MinWidth() const { return 2 * borderWidth; } - int MinHeight() const { return 2 * borderHeight; } - int BorderWidth() const { return borderWidth; } - int BorderHeight() const { return borderHeight; } + int MinWidth() const { return 2 * BorderWidth(); } + int MinHeight() const { return 2 * BorderHeight(); } + int BorderWidth() const { return BorderSize().X(); } + int BorderHeight() const { return BorderSize().Y(); } + const geometry::Vector BorderSize() const { return borderSize; } + int RepeatWidth() const { return RepeatSize().X(); } + int RepeatHeight() const { return RepeatSize().Y(); } + const geometry::Vector RepeatSize() const { return repeatSize; } void Draw(SDL_Surface *dest, const geometry::Vector &position, int width, int height) const; private: SDL_Surface *surface; - int borderWidth; - int borderHeight; - int repeatWidth; - int repeatHeight; - int xOffset; - int yOffset; + geometry::Vector borderSize; + geometry::Vector repeatSize; + geometry::Vector offset; }; diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index 2c092de..67bde8d 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -13,8 +13,8 @@ namespace graphics { void Sprite::Draw(SDL_Surface *dest, const Vector &position, int col, int row) const { SDL_Rect srcRect, destRect; - srcRect.x = xOffset + col * Width(); - srcRect.y = yOffset + row * Height(); + srcRect.x = offset.X() + col * Width(); + srcRect.y = offset.Y() + row * Height(); srcRect.w = Width(); srcRect.h = Height(); destRect.x = position.X(); diff --git a/src/graphics/Sprite.h b/src/graphics/Sprite.h index 942d98e..f6f3b7b 100644 --- a/src/graphics/Sprite.h +++ b/src/graphics/Sprite.h @@ -18,19 +18,19 @@ class Sprite { public: Sprite(SDL_Surface *s, int width, int height, int xOffset = 0, int yOffset = 0) - : surface(s), width(width), height(height), xOffset(xOffset), yOffset(yOffset) { } + : surface(s), size(width, height), offset(xOffset, yOffset) { } public: - int Width() const { return width; } - int Height() const { return height; } + int Width() const { return size.X(); } + int Height() const { return size.Y(); } + const geometry::Vector &Size() const { return size; } void Draw(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const; void DrawTopRight(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { geometry::Vector offset(-Width(), 0); Draw(dest, position + offset, col, row); } void DrawCenter(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { - geometry::Vector offset(-Width() / 2, -Height() / 2); - Draw(dest, position + offset, col, row); + Draw(dest, position - (Size() / 2), col, row); } void DrawCenterBottom(SDL_Surface *dest, const geometry::Vector &position, int col = 0, int row = 0) const { geometry::Vector offset(-Width() / 2, -Height()); @@ -39,10 +39,8 @@ public: private: SDL_Surface *surface; - int width; - int height; - int xOffset; - int yOffset; + geometry::Vector size; + geometry::Vector offset; }; -- 2.39.2 From 93cd8cb0f16c1809d76faa33ed6f281a3276140b Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 25 Aug 2012 19:46:22 +0200 Subject: [PATCH 12/16] removed pasting fail from ikari selection --- src/battle/states/SelectIkari.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 87436b0..d1506fa 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -62,8 +62,7 @@ void SelectIkari::HandleEvents(const Input &input) { ac.Selection().SelectMonsters(); } if (ikari->GetTargetingMode().TargetsAll()) { - ac.SetType(AttackChoice::MAGIC); - // TODO: remove item from inventory + ac.SetType(AttackChoice::IKARI); ac.SetItem(battle->ActiveHero().IkariMenu().Selected()); battle->NextHero(); ctrl->PopState(); -- 2.39.2 From 8f62df5268be941f20198b4f9331dab58ff309ce Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 25 Aug 2012 19:47:29 +0200 Subject: [PATCH 13/16] removed invalid TODO from spell selection no need to remove items when selecting a spell ^^ --- src/battle/states/SelectSpell.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle/states/SelectSpell.cpp b/src/battle/states/SelectSpell.cpp index 0c1dec4..df92733 100644 --- a/src/battle/states/SelectSpell.cpp +++ b/src/battle/states/SelectSpell.cpp @@ -63,7 +63,6 @@ void SelectSpell::HandleEvents(const Input &input) { } if (spell->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::MAGIC); - // TODO: remove item from inventory ac.SetSpell(spell); battle->NextHero(); ctrl->PopState(); -- 2.39.2 From 70641f2eb3f9fce8c89dcbf345e202050609a142 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 25 Aug 2012 20:14:08 +0200 Subject: [PATCH 14/16] moved TODOs to tracker see: http://luke.redirectme.net/redmine/projects/l2e/issues --- src/battle/BattleState.cpp | 5 ----- src/battle/states/RunState.cpp | 1 - src/battle/states/SelectItem.cpp | 1 - src/battle/states/SelectTarget.cpp | 1 - src/common/Ikari.h | 2 -- src/common/Spell.h | 2 -- src/graphics/Menu.h | 1 - src/main.cpp | 11 +++++------ 8 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index f548f2d..5ba60d6 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -138,12 +138,10 @@ void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) { return; } if (Victory()) { - // TODO: push victory state ctrl.PopState(); return; } if (Defeat()) { - // TODO: push defeat state ctrl.PopState(); return; } @@ -227,7 +225,6 @@ void BattleState::CalculateDamage() { if (ac.GetType() == AttackChoice::DEFEND) return; TargetSelection &ts(ac.Selection()); - // TODO: this only evaluates SWORD type attacks if (CurrentAttack().isMonster) { const Stats &attackerStats(MonsterAt(CurrentAttack().index).GetStats()); CalculateDamage(attackerStats, ts); @@ -241,7 +238,6 @@ void BattleState::DecideMonsterAttack(Monster &m) const { AttackChoice &ac(m.GetAttackChoice()); TargetSelection &ts(ac.Selection()); ac.Reset(); - // TODO: run monster's attack script int target(rand() % NumHeroes()); while (!HeroPositionOccupied(target)) { target = rand() % NumHeroes(); @@ -302,7 +298,6 @@ void BattleState::CalculateDamage(const Stats &attackerStats, TargetSelection &t } Uint16 BattleState::CalculateDamage(const Stats &attacker, const Stats &defender) const { - // TODO: find out real formula and add some randomness return attacker.Attack() / 2 - defender.Defense() / 4; } diff --git a/src/battle/states/RunState.cpp b/src/battle/states/RunState.cpp index e1f6f4b..c75255c 100644 --- a/src/battle/states/RunState.cpp +++ b/src/battle/states/RunState.cpp @@ -24,7 +24,6 @@ namespace battle { void RunState::EnterState(Application &c, SDL_Surface *screen) { ctrl = &c; - // TODO: push battle animation if enemy is faster } void RunState::ExitState(Application &c, SDL_Surface *screen) { diff --git a/src/battle/states/SelectItem.cpp b/src/battle/states/SelectItem.cpp index 68f844f..e0f6aeb 100644 --- a/src/battle/states/SelectItem.cpp +++ b/src/battle/states/SelectItem.cpp @@ -62,7 +62,6 @@ void SelectItem::HandleEvents(const Input &input) { } if (item->GetTargetingMode().TargetsAll()) { ac.SetType(AttackChoice::ITEM); - // TODO: remove item from inventory ac.SetItem(item); battle->NextHero(); ctrl->PopState(); diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index f15f455..e857288 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -86,7 +86,6 @@ void SelectTarget::Render(SDL_Surface *screen) { } void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector &offset) { - // TODO: this should be related to the enemy's width Vector cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height()); // offset the indicator by 1/8th to the right and top Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); diff --git a/src/common/Ikari.h b/src/common/Ikari.h index a575106..2999538 100644 --- a/src/common/Ikari.h +++ b/src/common/Ikari.h @@ -28,8 +28,6 @@ public: bool IsMagical() const { return !isPhysical; } bool IsPhysical() const { return isPhysical; } - // TODO: add missing ikari properties - // temporary setters public: void SetName(const char *n) { name = n; } diff --git a/src/common/Spell.h b/src/common/Spell.h index 38d2395..d32de46 100644 --- a/src/common/Spell.h +++ b/src/common/Spell.h @@ -32,8 +32,6 @@ public: HeroGroup &UsableBy() { return usableBy; } const HeroGroup &UsableBy() const { return usableBy; } - // TODO: add missing spell properties - // temporary setters public: void SetName(const char *n) { name = n; } diff --git a/src/graphics/Menu.h b/src/graphics/Menu.h index f1a6d25..02a88c0 100644 --- a/src/graphics/Menu.h +++ b/src/graphics/Menu.h @@ -19,7 +19,6 @@ namespace graphics { class Sprite; -// TODO: animation when top row changes template class Menu { diff --git a/src/main.cpp b/src/main.cpp index bebeed1..3dc37d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,8 +123,7 @@ int main(int argc, char **argv) { maxim.SetIP(0); maxim.SetStats(Stats(28, 22, 28, 17, 14, 100, 10)); ComplexAnimation maximAttackAnimation(&maximSprite, framerate); - // TODO: cross check double frames; could be related to differences in framerates - maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); // TODO: maybe this could also be a pause before the battle animation + maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); maximAttackAnimation.AddFrames(1, 0, Vector(4, -1), 2); maximAttackAnimation.AddFrames(2, 0, Vector(4, -2), 2); maximAttackAnimation.AddFrames(2, 0, Vector(6, -2), 2); @@ -133,7 +132,7 @@ int main(int argc, char **argv) { maximAttackAnimation.AddFrames(2, 1, Vector(0, 0), 1); maximAttackAnimation.AddFrames(2, 2, Vector(0, 0), 2); maximAttackAnimation.AddFrames(2, 2, Vector(2, 0), 1); - maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); // TODO: maybe this could also be a pause between two animations + maximAttackAnimation.AddFrames(1, 0, Vector(0, 0), 7); maxim.SetAttackAnimation(&maximAttackAnimation); ComplexAnimation maximSpellAnimation(&maximSprite, 5 * framerate); maximSpellAnimation.AddFrames(3, 0, Vector(), 2); @@ -508,7 +507,7 @@ int main(int argc, char **argv) { Ikari lightGuard; lightGuard.SetName("Light guard"); lightGuard.SetCost(128); - lightGuard.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self lightGuard.SetMagical(); holyShield.SetIkari(&lightGuard); maxim.SetShield(&holyShield); @@ -518,7 +517,7 @@ int main(int argc, char **argv) { Ikari boomerang; boomerang.SetName("Boomerang"); boomerang.SetCost(164); - boomerang.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self boomerang.SetMagical(); legendHelm.SetIkari(&boomerang); maxim.SetHelmet(&legendHelm); @@ -623,7 +622,7 @@ int main(int argc, char **argv) { Ikari ironBarrier; ironBarrier.SetName("Iron barrier"); ironBarrier.SetCost(255); - ironBarrier.GetTargetingMode().TargetAllAllies(); // FIXME: actually only targets self + ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self ironBarrier.SetMagical(); megaShield.SetIkari(&ironBarrier); guy.SetShield(&megaShield); -- 2.39.2 From f42fe2adaaa05ca87109dc4d24e0d4212be928c2 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 26 Aug 2012 20:48:57 +0200 Subject: [PATCH 15/16] fixed order of initializer list of battle::Stats --- src/battle/Stats.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle/Stats.cpp b/src/battle/Stats.cpp index ba15898..c35a14a 100644 --- a/src/battle/Stats.cpp +++ b/src/battle/Stats.cpp @@ -15,8 +15,8 @@ Stats::Stats() , strength(0) , agility(0) , intelligence(0) -, gut(0) -, magicResistance(0) { +, magicResistance(0) +, gut(0) { } @@ -26,8 +26,8 @@ Stats::Stats(Uint16 attack, Uint16 defense, Uint16 strength, Uint16 agility, Uin , strength(strength) , agility(agility) , intelligence(intelligence) -, gut(gut) -, magicResistance(magicResistance) { +, magicResistance(magicResistance) +, gut(gut) { } -- 2.39.2 From 7f63e99b87e052f92fcd9b98358d7779119e9a69 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 29 Aug 2012 23:00:40 +0200 Subject: [PATCH 16/16] fixed sword attack animation dimensions --- test-data/attack-sword.png | Bin 933 -> 1695 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test-data/attack-sword.png b/test-data/attack-sword.png index 82fe9461f44c087fa71e1d3e2e8687ee6e182116..555604eeef73dc2d470f79e97a608b6d1a617632 100644 GIT binary patch literal 1695 zcmah|YgAKL7Cv__y;w->2q=$gk**Q6T1`lU;t+0B6vIo3uHuRyK}8hAmKD$pkZ?;u zODk%LVh}K?$Y4tiv;`Gx%msYK2}Bua7!WZM0p$^i$W6#iGI#oO=Er=0&fecS`<%1B z{q55DxJbI2pBn&x&f6Z5K&=7*AZ!6bMF|b*3jsh5@*+0v5)DiZaq@aM`kYABwQk_h z-Lavj;`pXT3FT$+xJQ5NZtlg|RR!Nf2)|ys_4>%qZ-pq`J2mj#TH-OGDfFXm!#)VL zE~sESEE^VfGH7yjn8aWw#@5|bOUO5bZp?pHkFJya?zC+8jgNfZcr+zW#0WUc{4nH8 zh_*8SG%CIss?x|#y-V95JMJNmBD)$IcjU5p-7SXtwcF_{17<261=B?7F#1&de#*p& zqEv&OCctlNQmQN(B0nmxdYngiTHb0la=m*uo454T?&nAsXNM7}owN|Cm|uLPIVd@< zV9lX}de15xAib@U-4{uV*f8viV-IP&MS*LM?>Z0B##vUHfcrvIxbgb0pUhC<3MA~* z$hXcvm#c%R6b}~?uUN_1W|sc#Z;KIz;!&uxLz52Rxf+`^ky&gsof9Em+tw%ETOpO- z^K>qs`}9n3m==CnI4o4e0vJY;M&*$x7IP?f#(Qg`BB`qI~uiG!nC%A z7EWBG6kZc!?%WU_{Y9_p%4avT%_IB6+s~?Q1t8-^6)T*xrkAsq7tKV4NJ(CzSE0Sb zj>5fINwG`N?MstyYKgjX^u`hfm%eiU^p0bZ-!Cbyt#~E>((y4JnSJ_B+8K3Fx&P=q zU#bJ_XSr~>=1e!NOXoBN#^|6Fqpr7`T2s< zbnYN>Wje|Q9th!@eIEryqS+PD*#d-00Og$jfu%}iI{8H*-d>#%GtQt@p=B?w*0X{E z%QKJ23PUqN@nFr=d1QS)06sjX^7aMUM2@V;r?}p4*nOpZ(@acC{H%RpBq{*Bz$& z)O@r*;bcUWK(zi4YYRtJLrq3zH|6u-zj$zXjwk1j8cr~t2^J22nmX zW;%8-&`CPVy00?1-p!wu3x}e#4~_aBJ410J7oSuHEmfyflKeJ*r1>cRT!MZ_-c5ht z(YUUUhBRMa*#D7r#wHYtKNh1fpDj47MtKhVTSid3P*)tfq_~DI3w3Rbl{7FEbGi5) zsd`oxo3%O_Y39SDfy@i!q|II3Spp6Hj%k^GnsjazdpVm3(iysAB&+p#!HPaVhAMb! z^h1p)YpWLP$>h#C24c)RleMkUuMQ~Fxh+TpuO_J`jAixEVQn;-);^Qu|6p0)@`P`m|D9Vib3>Ua*$G&Lxmr(!u z@9QdYpg{w_tCQgX768Gti68{nss{iEK44rjPpW(bZoz;75P;x+kUjwZ<0PN~8U|qy z0~}hEc#nyDxlr{qkh5ia(N`21@BU=fdm_GDQ`$Zb(>+&bxO8!Wn9M})ONEak&3j59 zS0P_&N%c8lcyr!B>w*CFhPTyuPK!LY4E<(9kQ1oxp-W5Io literal 933 zcmV;W16urvP)Zh_+;QVvzjyBJe*gNtbH|Ny$Bn}W4}trAG7#8|PX>k-L=Id6Mgg2%`v6Mn zIXo}RC>7+Q@J0U@fWlTw^UlYNjXFUg(>K5R3mBp{8%=%n#`*8Sv@66{%d~mxn=JUhY*Kg~= z?d!M23_xb~0zUxE1YazGuv=Uc+^bt60Q>wN!AkghZd|)~YgD;}D2k#eilQirq9}@@ zD2k#eiqa=_liIa|=}>_6*$deyO9;AeJk|z_6Ps+6`%9)7u^g0(0jmpK}Yui z+7DH#SDCU8t1z`D{r-uYS_Qm{MQbB?zi3SZc&byTC*!hfpzYZiNj#lqy z)Q8bH45D&*hLM$G7_2_S@j)HGD5 zHS_fY2tWt;i=ynK7+kaaW@YA&VVloV_(!xr^C5HDpYVc0T!GcYmvpD0c56)o^I|UEbWlr6Udf>&)cMTrSiW5D66vDS+wUc$f z-5I~y!uKSHRTr17IH4?O$rl$0n;BBMq<5Y4SvMxi{BRB^>)ohajEUjJIs5!>Azg|? znXGNUbE83{^(~tAJCDkTZY_$UD2k#eY88Ti<<=B<>2VeCDgwFbZExty(p3d<4+y4X zYYi>VlAode3Un-=#-GI!VgL+)0Wbgtz|I^yb1We~k^P5PLG{Rl>an4A*2}^#h8$YF zr^efFKdX9cDou_R!b8AoFmq?Kt{T45KIkoELukJ6yMcZH23`}s-~10r00000NkvXX Hu0mjfq7uc& -- 2.39.2