From 5e75f94daefef68f2d0cfd631116f960d222dab0 Mon Sep 17 00:00:00 2001 From: Alexander Monakov Date: Sun, 26 Dec 2010 13:32:06 +0300 Subject: [PATCH] Make bonuses an enum --- Source/Awards.h | 13 ++++++++++++ Source/Bonuses.def | 48 +++++++++++++++++++++++++++++++++++++++++++++ Source/Constants.h | 27 ------------------------- Source/GameDraw.cpp | 36 +++++++--------------------------- Source/Weapons.cpp | 1 + 5 files changed, 69 insertions(+), 56 deletions(-) create mode 100644 Source/Bonuses.def diff --git a/Source/Awards.h b/Source/Awards.h index 78cb8e1..d146ada 100644 --- a/Source/Awards.h +++ b/Source/Awards.h @@ -22,6 +22,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef AWARDS_H #define AWARDS_H +enum bonus_types { +#define DECLARE_BONUS(id, name) id, +#include "Bonuses.def" +#undef DECLARE_BONUS +bonus_count +}; + +static const char *bonus_names[bonus_count] = { +#define DECLARE_BONUS(id, name) name, +#include "Bonuses.def" +#undef DECLARE_BONUS +}; + enum award_types { #define DECLARE_AWARD(id, name) id, #include "Awards.def" diff --git a/Source/Bonuses.def b/Source/Bonuses.def new file mode 100644 index 0000000..00e0226 --- /dev/null +++ b/Source/Bonuses.def @@ -0,0 +1,48 @@ +/* +Copyright (C) 2010 - Lugaru authors + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +DECLARE_BONUS(nobonus, "") +DECLARE_BONUS(tracheotomy, "Tracheotomy!") +DECLARE_BONUS(backstab, "Backstabber!") +DECLARE_BONUS(spinecrusher, "Spinecrusher!") +DECLARE_BONUS(ninja, "Ninja Bonus!") +DECLARE_BONUS(style, "Style Bonus!") +DECLARE_BONUS(cannon, "Leg Cannon!") +DECLARE_BONUS(aimbonus, "Nice Aim!") +DECLARE_BONUS(deepimpact, "Heavy Impact!") +DECLARE_BONUS(touchofdeath, "Touch of Death!") +DECLARE_BONUS(swordreversebonus, "Sword Disarm!") +DECLARE_BONUS(staffreversebonus, "Staff Disarm!") +DECLARE_BONUS(reverseko, "Reversal KO!") +DECLARE_BONUS(solidhit, "Solid Hit!") +DECLARE_BONUS(twoxcombo, "2X Combo!") +DECLARE_BONUS(threexcombo, "3X Combo!") +DECLARE_BONUS(fourxcombo, "4X COMBO!") +DECLARE_BONUS(megacombo, "MEGA COMBO!") +DECLARE_BONUS(Reversal, "Reversal!") +DECLARE_BONUS(Stabbonus, "Punctured!") +DECLARE_BONUS(Slicebonus, "Sliced!") +DECLARE_BONUS(Bullseyebonus, "Bullseye!") +DECLARE_BONUS(Slashbonus, "Slashed!") +DECLARE_BONUS(Wolfbonus, "WOLF SLAYER!") +DECLARE_BONUS(FinishedBonus, "SLAIN!") +DECLARE_BONUS(TackleBonus, "Tackle!") +DECLARE_BONUS(AboveBonus, "Death from Above!") diff --git a/Source/Constants.h b/Source/Constants.h index d1b9ea5..985e378 100644 --- a/Source/Constants.h +++ b/Source/Constants.h @@ -42,33 +42,6 @@ static const char *editortypenames[] = { "dead1", "dead2", "dead3", "dead4" }; -const int tracheotomy = 1; -const int backstab = 2; -const int spinecrusher = 3; -const int ninja = 4; -const int style = 5; -const int cannon = 6; -const int aimbonus = 7; -const int deepimpact = 8; -const int touchofdeath = 9; -const int swordreversebonus = 10; -const int staffreversebonus = 11; -const int reverseko = 12; -const int solidhit = 13; -const int twoxcombo = 14; -const int threexcombo = 15; -const int fourxcombo = 16; -const int megacombo = 17; -const int Reversal = 18; -const int Stabbonus = 19; -const int Slicebonus = 20; -const int Bullseyebonus = 21; -const int Slashbonus = 22; -const int Wolfbonus = 23; -const int FinishedBonus = 24; -const int TackleBonus = 25; -const int AboveBonus = 26; - const int boneconnect = 0; const int constraint = 1; const int muscle = 2; diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 79625b1..3b93f28 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -586,38 +586,16 @@ int Game::DrawGLScene(StereoSide side) if(!tutoriallevel) if(bonus>0&&bonustime<1&&!winfreeze&&indialogue==-1/*bonustime<4*/){ - if(bonus==tracheotomy)sprintf (string, "Tracheotomy!"); - else if(bonus==backstab)sprintf (string, "Backstabber!"); - else if(bonus==spinecrusher)sprintf (string, "Spinecrusher!"); - else if(bonus==ninja)sprintf (string, "Ninja Bonus!"); - else if(bonus==style)sprintf (string, "Style Bonus!"); - else if(bonus==cannon)sprintf (string, "Leg Cannon!"); - else if(bonus==aimbonus)sprintf (string, "Nice Aim!"); - else if(bonus==deepimpact)sprintf (string, "Heavy Impact!"); - else if(bonus==touchofdeath)sprintf (string, "Touch of Death!"); - else if(bonus==swordreversebonus)sprintf (string, "Sword Disarm!"); - else if(bonus==staffreversebonus)sprintf (string, "Staff Disarm!"); - else if(bonus==reverseko)sprintf (string, "Reversal KO!"); - else if(bonus==solidhit)sprintf (string, "Solid Hit!"); - else if(bonus==twoxcombo)sprintf (string, "2X Combo!"); - else if(bonus==threexcombo)sprintf (string, "3X Combo!"); - else if(bonus==fourxcombo)sprintf (string, "4X COMBO!"); - else if(bonus==megacombo)sprintf (string, "MEGA COMBO!"); - else if(bonus==Reversal)sprintf (string, "Reversal!"); - else if(bonus==Stabbonus)sprintf (string, "Punctured!"); - else if(bonus==Slicebonus)sprintf (string, "Sliced!"); - else if(bonus==Bullseyebonus)sprintf (string, "Bullseye!"); - else if(bonus==Slashbonus)sprintf (string, "Slashed!"); - else if(bonus==Wolfbonus)sprintf (string, "WOLF SLAYER!"); - else if(bonus==FinishedBonus)sprintf (string, "SLAIN!"); - else if(bonus==TackleBonus)sprintf (string, "Tackle!"); - else if(bonus==AboveBonus)sprintf (string, "Death from Above!"); - else sprintf (string, "Excellent!"); + const char *bonus_name; + if (bonus < bonus_count) + bonus_name = bonus_names[bonus]; + else + bonus_name = "Excellent!"; // When does this happen? glColor4f(0,0,0,1-bonustime); - text.glPrintOutline(1024/2-10*strlen(string)-4,768/16-4+768*4/5,string,1,2.5,1024,768); + text.glPrintOutline(1024/2-10*strlen(bonus_name)-4,768/16-4+768*4/5,bonus_name,1,2.5,1024,768); glColor4f(1,0,0,1-bonustime); - text.glPrint(1024/2-10*strlen(string),768/16+768*4/5,string,1,2,1024,768); + text.glPrint(1024/2-10*strlen(bonus_name),768/16+768*4/5,bonus_name,1,2,1024,768); sprintf (string, "%d",(int)bonusvalue); glColor4f(0,0,0,1-bonustime); diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index 7745b89..128e7ce 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Animation.h" #include "Sounds.h" #include "Game.h" +#include "Awards.h" extern float multiplier; extern int channels[100]; -- 2.39.2