]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameDraw.cpp
Oops, should be ifdef not ifndef
[lugaru.git] / Source / GameDraw.cpp
index d8cf5bcec0119eab9a4440c5bf65d11a184e0ba6..a0c92d50e0f93542ef5930cd567c302fe7b5bf6f 100644 (file)
@@ -24,6 +24,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Awards.h"
 #include "Menu.h"
 #include "Dialog.h"
+#include "Hotspot.h"
 
 extern XYZ viewer;
 extern int environment;
@@ -77,14 +78,6 @@ extern bool againbonus;
 extern float damagedealt;
 extern bool invertmouse;
 
-extern int numhotspots;
-extern int killhotspot;
-extern XYZ hotspot[40];
-extern int hotspottype[40];
-extern float hotspotsize[40];
-extern char hotspottext[40][256];
-extern int currenthotspot;
-
 extern bool campaign;
 extern bool winfreeze;
 
@@ -311,7 +304,7 @@ int Game::DrawGLScene(StereoSide side)
         for (unsigned k = 0; k < Person::players.size(); k++) {
             if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
                 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25)
-                    for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+                    for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
                         if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
                             point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                             size = .4f;
@@ -336,7 +329,7 @@ int Game::DrawGLScene(StereoSide side)
                     }
             if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
                 if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25)
-                    for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) {
+                    for (int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
                         if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
                             if (Person::players[k]->skeleton.free)
                                 point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
@@ -422,7 +415,7 @@ int Game::DrawGLScene(StereoSide side)
                     if (distance >= 1)
                         glDisable(GL_BLEND);
                     if (distance >= .5) {
-                        checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+                        checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                         checkpoint.y += 1;
                         int i = -1;
                         if (Person::players[k]->occluded != 0)
@@ -487,7 +480,7 @@ int Game::DrawGLScene(StereoSide side)
                 if (distance >= 1)
                     glDisable(GL_BLEND);
                 if (distance >= .5) {
-                    checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+                    checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
                     checkpoint.y += 1;
                     int i = -1;
                     if (Person::players[k]->occluded != 0)
@@ -893,23 +886,23 @@ int Game::DrawGLScene(StereoSide side)
             }
 
             //Hot spots
-            if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
+            if (Hotspot::hotspots.size() && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
                 float closestdist = -1;
                 float distance = 0;
-                int closest = currenthotspot;
-                for (int i = 0; i < numhotspots; i++) {
-                    distance = distsq(&Person::players[0]->coords, &hotspot[i]);
+                int closest = Hotspot::current;
+                for (int i = 0; i < Hotspot::hotspots.size(); i++) {
+                    distance = distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position);
                     if (closestdist == -1 || distance < closestdist) {
-                        if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) {
+                        if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[i].position) < Hotspot::hotspots[i].size && ((Hotspot::hotspots[i].type <= 10 && Hotspot::hotspots[i].type >= 0) || (Hotspot::hotspots[i].type <= 40 && Hotspot::hotspots[i].type >= 20))) {
                             closestdist = distance;
                             closest = i;
                         }
                     }
                 }
                 if (closest != -1) {
-                    currenthotspot = closest;
-                    if (hotspottype[closest] <= 10) {
-                        if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest])
+                    Hotspot::current = closest;
+                    if (Hotspot::hotspots[closest].type <= 10) {
+                        if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
                             tutorialstagetime = 0;
                         tutorialmaxtime = 1;
                         tutorialopac = tutorialmaxtime - tutorialstagetime;
@@ -918,7 +911,7 @@ int Game::DrawGLScene(StereoSide side)
                         if (tutorialopac < 0)
                             tutorialopac = 0;
 
-                        sprintf (string, "%s", hotspottext[closest]);
+                        sprintf (string, "%s", Hotspot::hotspots[closest].text);
 
                         int lastline = 0;
                         int line = 0;
@@ -939,8 +932,8 @@ int Game::DrawGLScene(StereoSide side)
                                 done = 1;
                             i++;
                         }
-                    } else if ((hotspottype[closest] >= 20) && (Dialog::dialogs[hotspottype[closest] - 20].gonethrough == 0)) {
-                        Dialog::whichdialogue = hotspottype[closest] - 20;
+                    } else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
+                        Dialog::whichdialogue = Hotspot::hotspots[closest].type - 20;
                         Dialog::currentDialog().play();
                         Dialog::currentDialog().gonethrough++;
                     }
@@ -1617,21 +1610,19 @@ int Game::DrawGLScene(StereoSide side)
             sprintf (string, "Score:     %d", (int)(bonustotal - startbonustotal));
             text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768);
 
-            if (campaign)
-                sprintf (string, "Press Escape or Space to continue");
-            else
-                sprintf (string, "Press Escape to return to menu or Space to continue");
+            sprintf (string, "Press Escape to return to menu or Space to continue");
             text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480);
 
             char temp[255];
 
             for (int i = 0; i < 255; i++)
                 string[i] = '\0';
-            sprintf (temp, "Time:      %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60));
+            int wontime = (int)round(wonleveltime);
+            sprintf (temp, "Time:      %d:", int((wontime - wontime % 60) / 60));
             strcat(string, temp);
-            if ((int)(leveltime) % 60 < 10)
+            if (wontime % 60 < 10)
                 strcat(string, "0");
-            sprintf (temp, "%d", (int)(leveltime) % 60);
+            sprintf (temp, "%d", wontime % 60);
             strcat(string, temp);
             text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768);