along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Game.h"
-#include "openal_wrapper.h"
-#include "Input.h"
-#include "Awards.h"
-#include "Menu.h"
+#include "Game.hpp"
+
+#include "Audio/openal_wrapper.hpp"
+#include "Level/Awards.hpp"
+#include "Level/Dialog.hpp"
+#include "Level/Hotspot.hpp"
+#include "Menu/Menu.hpp"
+#include "Utils/Input.hpp"
extern XYZ viewer;
extern int environment;
extern bool isclient;
extern bool alwaysblur;
extern bool velocityblur;
-extern bool debugmode;
+extern bool devtools;
extern int mainmenu;
extern int bloodtoggle;
extern int difficulty;
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;
blurness -= multiplier * 5;
if (environment == desertenvironment && detail == 2)
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness + .4 );
+ glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4 );
if (environment == desertenvironment) {
glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
}
skybox->draw();
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
+ glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
glPopMatrix();
glTranslatef(-viewer.x, -viewer.y, -viewer.z);
frustum.GetFrustum();
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 (unsigned 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;
}
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 (unsigned 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;
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[fabs(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)
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[fabs(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)
glColor4f(.5, .5, .5, 1);
if (!console) {
if (!tutoriallevel)
- if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) {
+ if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
const char *bonus_name;
if (bonus < bonus_count)
bonus_name = bonus_names[bonus];
}
//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 (unsigned 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;
if (tutorialopac < 0)
tutorialopac = 0;
- sprintf (string, "%s", hotspottext[closest]);
+ sprintf (string, "%s", Hotspot::hotspots[closest].text);
int lastline = 0;
int line = 0;
done = 1;
i++;
}
- } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
- whichdialogue = hotspottype[closest] - 20;
- for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) {
- Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]];
- Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
- Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]];
- Person::players[participantfocus[whichdialogue][j]]->velocity = 0;
- Person::players[participantfocus[whichdialogue][j]]->animTarget = Person::players[participantfocus[whichdialogue][j]]->getIdle();
- Person::players[participantfocus[whichdialogue][j]]->frameTarget = 0;
- }
- directing = 0;
- indialogue = 0;
- dialoguegonethrough[whichdialogue]++;
- if (dialogueboxsound[whichdialogue][indialogue] != 0) {
- int whichsoundplay;
- if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
- if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
- if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
- if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
- if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
- if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
- if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
- if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
- if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
- if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
- if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
- if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
- if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
- emit_sound_at(whichsoundplay, Person::players[participantfocus[whichdialogue][indialogue]]->coords);
- }
+ } 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++;
}
}
}
- if (indialogue != -1 && !mainmenu) {
+ if (Dialog::inDialog() && !mainmenu) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- if (dialogueboxlocation[whichdialogue][indialogue] == 1)
+ if (Dialog::currentScene().location == 1)
glTranslatef(0, screenheight * 3 / 4, 0);
glScalef(screenwidth, screenheight / 4, 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- glColor4f(dialogueboxcolor[whichdialogue][indialogue][0], dialogueboxcolor[whichdialogue][indialogue][1], dialogueboxcolor[whichdialogue][indialogue][2], 0.7);
+ glColor4f(Dialog::currentScene().color[0], Dialog::currentScene().color[1], Dialog::currentScene().color[2], 0.7);
glBegin(GL_QUADS);
glVertex3f(0, 0, 0.0f);
glVertex3f(1, 0, 0.0f);
float starty;
startx = screenwidth * 1 / 5;
- if (dialogueboxlocation[whichdialogue][indialogue] == 1)
+ if (Dialog::currentScene().location == 1) {
starty = screenheight / 16 + screenheight * 4 / 5;
- if (dialogueboxlocation[whichdialogue][indialogue] == 2)
+ } else {
starty = screenheight * 1 / 5 - screenheight / 16;
+ }
+ // FIXME - What is that char[] building for?
char tempname[264];
- bool goodchar;
int tempnum = 0;
for (int i = 0; i < 264; i++) {
tempname[i] = '\0';
}
- for (int i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
- tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
- goodchar = 1;
- if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
- goodchar = 0;
- if (goodchar)
- tempnum++;
- else
+ for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
+ tempname[tempnum] = Dialog::currentScene().name[i];
+ if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
tempname[tempnum] = '\0';
+ else
+ tempnum++;
}
sprintf (string, "%s: ", tempname);
- if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
+ if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
glColor4f(0, 0, 0, tutorialopac);
text->glPrintOutline(startx - 2 * 7.6 * strlen(string)*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
glColor4f(0.7, 0.7, 0.7, tutorialopac);
}
tempnum = 0;
- for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
- tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
- if (dialoguetext[whichdialogue][indialogue][i] != '#')
+ for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
+ tempname[tempnum] = Dialog::currentScene().text[i];
+ if (Dialog::currentScene().text[i] != '#')
tempnum++;
}
int i = 0;
while (!done) {
if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
- if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) {
+ if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
glColor4f(0, 0, 0, tutorialopac);
text->glPrintOutline(startx/*-7.6*(i-lastline)*screenwidth/1024*/ - 4, starty - 4 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
glColor4f(1, 1, 1, tutorialopac);
}
}
- if (!tutoriallevel && !winfreeze && indialogue == -1 && !mainmenu) {
+ if (!tutoriallevel && !winfreeze && !Dialog::inDialog() && !mainmenu) {
if (campaign) {
if (scoreadded)
- sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());
+ sprintf (string, "Score: %d", (int)Account::active().getCampaignScore());
else
- sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
+ sprintf (string, "Score: %d", (int)Account::active().getCampaignScore() + (int)bonustotal);
}
if (!campaign)
sprintf (string, "Score: %d", (int)bonustotal);
glColor4f(.5, .5, .5, 1);
- if ((texttoggle || editorenabled) && debugmode && !mainmenu) {
+ if ((texttoggle || editorenabled) && devtools && !mainmenu) {
sprintf (string, "The framespersecond is %d.", (int)(fps));
text->glPrint(10, 30, string, 0, .8, 1024, 768);
}
}
- if (difficulty < 2 && indialogue == -1) { // minimap
+ if (difficulty < 2 && !Dialog::inDialog()) { // minimap
float mapviewdist = 20000;
glDisable(GL_DEPTH_TEST);
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);
if (!drawtoggle || drawmode != realmotionblurmode || (drawtoggle == 2 || change == 1)) {
if (screentexture) {
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
GLfloat subtractColor[4] = { 0.5, 0.5, 0.5, 0.0 };
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, subtractColor);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
- glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
glBindTexture( GL_TEXTURE_2D, screentexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);