]> git.jsancho.org Git - lugaru.git/commitdiff
Make bonuses an enum
authorAlexander Monakov <amonakov@gmail.com>
Sun, 26 Dec 2010 10:32:06 +0000 (13:32 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Sun, 26 Dec 2010 10:32:06 +0000 (13:32 +0300)
Source/Awards.h
Source/Bonuses.def [new file with mode: 0644]
Source/Constants.h
Source/GameDraw.cpp
Source/Weapons.cpp

index 78cb8e1ccacd1b4d3ee165e28c109d9a3247829d..d146ada3fcad8e556d2421143a9945fccff4bf2c 100644 (file)
@@ -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 (file)
index 0000000..00e0226
--- /dev/null
@@ -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!")
index d1b9ea534ec471daf00d5116aad662043fd33c7f..985e378279999380697da8b06f9b02638c739f7b 100644 (file)
@@ -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;
index 79625b1795d23be8a81f5bf5f5b539c95cfc098d..3b93f28ddbe4831fd6a92dd976845f8fe92316a3 100644 (file)
@@ -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);
index 7745b8996670fe5f0c7def5647ddc5c8fbfc5e00..128e7cebf235c4188a19bc5e169c95f349270778 100644 (file)
@@ -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];