]> git.jsancho.org Git - lugaru.git/commitdiff
Move stats vars and award computation to Awards.cpp
authorAlexander Monakov <amonakov@gmail.com>
Wed, 22 Dec 2010 22:23:09 +0000 (01:23 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Wed, 22 Dec 2010 22:23:09 +0000 (01:23 +0300)
CMakeLists.txt
Source/Awards.cpp [new file with mode: 0644]
Source/Awards.h
Source/GameDraw.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/Person.cpp

index 6ea4e851f1a16e2aa123b40388faa804fd7200a0..663e8a36cbde9dff5eceb64ea778d42b95c4e3bc 100644 (file)
@@ -80,6 +80,7 @@ set(LUGARU_SRCS
        ${SRCDIR}/Stereo.cpp
        ${SRCDIR}/Animation.cpp
        ${SRCDIR}/Sounds.cpp
+       ${SRCDIR}/Awards.cpp
 )
 
 set(LUGARU_H
diff --git a/Source/Awards.cpp b/Source/Awards.cpp
new file mode 100644 (file)
index 0000000..5fe1f7b
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+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.
+*/
+
+#include "Awards.h"
+#include "Person.h"
+#include "Game.h"
+
+float damagetaken;
+int numfalls;
+int numflipfail;
+int numseen;
+int numresponded;
+int numstaffattack;
+int numswordattack;
+int numknifeattack;
+int numunarmedattack;
+int numescaped;
+int numflipped;
+int numwallflipped;
+int numthrowkill;
+int numafterkill;
+int numreversals;
+int numattacks;
+int maxalarmed;
+
+int award_awards(int *awards)
+{
+  int numawards = 0, i;
+  if(damagetaken==0&&player[0].bloodloss==0){
+    awards[numawards]=awardflawless;
+    numawards++;
+  }
+  bool alldead = true;
+  for(i=1;i<numplayers;i++){
+    if(player[i].dead!=2)alldead=0;
+  }
+  if(alldead){
+    awards[numawards]=awardalldead;
+    numawards++;
+  }
+  alldead=1;
+  for(i=1;i<numplayers;i++){
+    if(player[i].dead!=1)alldead=0;
+  }
+  if(alldead){
+    awards[numawards]=awardnodead;
+    numawards++;
+  }
+  if(numresponded==0&&!numthrowkill){
+    awards[numawards]=awardstealth;
+    numawards++;
+  }
+  if(numattacks==numstaffattack&&numattacks>0){
+    awards[numawards]=awardbojutsu;
+    numawards++;
+  }
+  if(numattacks==numswordattack&&numattacks>0){
+    awards[numawards]=awardswordsman;
+    numawards++;
+  }
+  if(numattacks==numknifeattack&&numattacks>0){
+    awards[numawards]=awardknifefighter;
+    numawards++;
+  }
+  if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
+    awards[numawards]=awardkungfu;
+    numawards++;
+  }
+  if(numescaped>0){
+    awards[numawards]=awardevasion;
+    numawards++;
+  }
+  if(numflipfail==0&&numflipped+numwallflipped*2>20){
+    awards[numawards]=awardacrobat;
+    numawards++;
+  }
+  if(numthrowkill==numplayers-1){
+    awards[numawards]=awardlongrange;
+    numawards++;
+  }
+  alldead=1;
+  for(i=1;i<numplayers;i++){
+    if(player[i].dead!=2)alldead=0;
+  }
+  if(numafterkill>0&&alldead){
+    awards[numawards]=awardbrutal;
+    numawards++;
+  }
+  if(numreversals>((float)numattacks)*.8&&numreversals>3){
+    awards[numawards]=awardaikido;
+    numawards++;
+  }
+  if(maxalarmed==1&&numplayers>2){
+    awards[numawards]=awardstrategy;
+    numawards++;
+  }
+  if(numflipfail>3){
+    awards[numawards]=awardklutz;
+    numawards++;
+  }
+  return numawards;
+}
index 46e8c3eaa2c68cf52c113e9f4022836e12680261..78cb8e1ccacd1b4d3ee165e28c109d9a3247829d 100644 (file)
@@ -35,5 +35,24 @@ static const char *award_names[award_count] = {
 #undef DECLARE_AWARD
 };
 
+extern int award_awards(int *);
+
+extern float damagetaken;
+extern int numfalls;
+extern int numflipfail;
+extern int numseen;
+extern int numresponded;
+extern int numstaffattack;
+extern int numswordattack;
+extern int numknifeattack;
+extern int numunarmedattack;
+extern int numescaped;
+extern int numflipped;
+extern int numwallflipped;
+extern int numthrowkill;
+extern int numafterkill;
+extern int numreversals;
+extern int numattacks;
+extern int maxalarmed;
 #endif
 
index 34926564c6b4937fc0bb3921f5a57a808140b204..79625b1795d23be8a81f5bf5f5b539c95cfc098d 100644 (file)
@@ -95,7 +95,6 @@ extern float tutorialmaxtime;
 extern int tutorialstage;
 extern bool againbonus;
 extern float damagedealt;
-extern float damagetaken;
 extern bool invertmouse;
 
 extern int numhotspots;
@@ -107,23 +106,6 @@ extern float hotspotsize[40];
 extern char hotspottext[40][256];
 extern int currenthotspot;;
 
-extern int numfalls;
-extern int numflipfail;
-extern int numseen;
-extern int numstaffattack;
-extern int numswordattack;
-extern int numknifeattack;
-extern int numunarmedattack;
-extern int numescaped;
-extern int numflipped;
-extern int numwallflipped;
-extern int numthrowkill;
-extern int numafterkill;
-extern int numreversals;
-extern int numattacks;
-extern int maxalarmed;
-extern int numresponded;
-
 extern bool campaign;
 extern bool winfreeze;
 
@@ -1738,83 +1720,6 @@ int Game::DrawGLScene(StereoSide side)
 
                        glEnable(GL_TEXTURE_2D);
 
-                       //Awards
-                       int numawards = 0;
-                       int awards[30];
-
-                       if(damagetaken==0&&player[0].bloodloss==0){
-                               awards[numawards]=awardflawless;
-                               numawards++;
-                       }
-                       bool alldead = true;
-                       for(i=1;i<numplayers;i++){              
-                               if(player[i].dead!=2)alldead=0;
-                       }
-                       if(alldead){
-                               awards[numawards]=awardalldead;
-                               numawards++;
-                       }
-                       alldead=1;
-                       for(i=1;i<numplayers;i++){              
-                               if(player[i].dead!=1)alldead=0;
-                       }
-                       if(alldead){
-                               awards[numawards]=awardnodead;
-                               numawards++;
-                       }
-                       if(numresponded==0&&!numthrowkill){
-                               awards[numawards]=awardstealth;
-                               numawards++;
-                       }
-                       if(numattacks==numstaffattack&&numattacks>0){
-                               awards[numawards]=awardbojutsu;
-                               numawards++;
-                       }
-                       if(numattacks==numswordattack&&numattacks>0){
-                               awards[numawards]=awardswordsman;
-                               numawards++;
-                       }
-                       if(numattacks==numknifeattack&&numattacks>0){
-                               awards[numawards]=awardknifefighter;
-                               numawards++;
-                       }
-                       if(numattacks==numunarmedattack&&numthrowkill==0&&weapons.numweapons>0){
-                               awards[numawards]=awardkungfu;
-                               numawards++;
-                       }
-                       if(numescaped>0){
-                               awards[numawards]=awardevasion;
-                               numawards++;
-                       }
-                       if(numflipfail==0&&numflipped+numwallflipped*2>20){
-                               awards[numawards]=awardacrobat;
-                               numawards++;
-                       }
-                       if(numthrowkill==numplayers-1){
-                               awards[numawards]=awardlongrange;
-                               numawards++;
-                       }
-                       alldead=1;
-                       for(i=1;i<numplayers;i++){              
-                               if(player[i].dead!=2)alldead=0;
-                       }
-                       if(numafterkill>0&&alldead){
-                               awards[numawards]=awardbrutal;
-                               numawards++;
-                       }
-                       if(numreversals>((float)numattacks)*.8&&numreversals>3){
-                               awards[numawards]=awardaikido;
-                               numawards++;
-                       }
-                       if(maxalarmed==1&&numplayers>2){
-                               awards[numawards]=awardstrategy;
-                               numawards++;
-                       }
-                       if(numflipfail>3){
-                               awards[numawards]=awardklutz;
-                               numawards++;
-                       }
-
                        //Win Screen Won Victory
 
                        glEnable(GL_TEXTURE_2D);
@@ -1841,6 +1746,10 @@ int Game::DrawGLScene(StereoSide side)
                        strcat(string,temp);
                        text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
 
+                       //Awards
+                       int awards[award_count];
+                       int numawards = award_awards(awards);
+
                        for (i = 0; i < numawards && i < 6; i++)
                          text.glPrintOutlined(1024/30,768*6/8-90-40*i,award_names[awards[i]],1,2,1024,768);
                }
index ef7598485386444b5a3476c33efc27419acb6818..466da3ed7f5cae785acc2b96faf596baf2dfa50b 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Settings.h"
 #include "Input.h"
 #include "Animation.h"
+#include "Awards.h"
 
 using namespace std;
 
@@ -140,7 +141,6 @@ extern bool reversaltrain;
 extern bool canattack;
 extern bool cananger;
 extern float damagedealt;
-extern float damagetaken;
 extern int maptype;
 extern int editoractive;
 extern int editorpathtype;
@@ -165,23 +165,6 @@ extern int hostile;
 extern bool stillloading;
 extern bool winfreeze;
 
-extern int numfalls;
-extern int numflipfail;
-extern int numseen;
-extern int numstaffattack;
-extern int numswordattack;
-extern int numknifeattack;
-extern int numunarmedattack;
-extern int numescaped;
-extern int numflipped;
-extern int numwallflipped;
-extern int numthrowkill;
-extern int numafterkill;
-extern int numreversals;
-extern int numattacks;
-extern int maxalarmed;
-extern int numresponded;
-
 extern int numdialogues;
 extern int numdialogueboxes[max_dialogues];
 extern int dialoguetype[max_dialogues];
index 44281cb896f07f1cd3f5c6864e9685e6d6ed9fd4..bf622bf128de9c0d712caf8fc235acd19a62539f 100644 (file)
@@ -181,7 +181,6 @@ float tutorialsuccess = 0;
 bool againbonus = 0;
 
 float damagedealt = 0;
-float damagetaken = 0;
 
 int maptype = 0;
 
@@ -231,23 +230,6 @@ bool won = 0;
 
 bool campaign = 0;
 
-int numfalls = 0;
-int numflipfail = 0;
-int numseen = 0;
-int numresponded = 0;
-int numstaffattack = 0;
-int numswordattack = 0;
-int numknifeattack = 0;
-int numunarmedattack = 0;
-int numescaped = 0;
-int numflipped = 0;
-int numwallflipped = 0;
-int numthrowkill = 0;
-int numafterkill = 0;
-int numreversals = 0;
-int numattacks = 0;
-int maxalarmed = 0;
-
 bool gamestarted = 0;
 
 //TextureList textures;
index 05eeb5f7218bc9fa9bb48a02b4fbdc25dbdd59cc..d77c81e6b47b3cb341ccc12f691158970f1a79f8 100644 (file)
@@ -83,24 +83,9 @@ extern bool reversaltrain;
 extern bool canattack;
 extern bool cananger;
 extern float damagedealt;
-extern float damagetaken;
 extern int hostile;
 extern float hostiletime;
 
-extern int numfalls;
-extern int numflipfail;
-extern int numseen;
-extern int numswordattack;
-extern int numknifeattack;
-extern int numunarmedattack;
-extern int numescaped;
-extern int numflipped;
-extern int numwallflipped;
-extern int numthrowkill;
-extern int numafterkill;
-extern int numreversals;
-extern int numattacks;
-extern int maxalarmed;
 extern int indialogue;
 
 extern bool gamestarted;