X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameDraw.cpp;h=51edee1a289e28dd437392c1f8bc969cb5787293;hb=acc0e37a142590af4d878d2b92e4e3a0d8c51653;hp=bb3f00cbe8ae8d06161120bc3264a86382e96867;hpb=24004d6ab1e68faaf85ece11b566449997da5013;p=lugaru.git diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index bb3f00c..51edee1 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -3,20 +3,18 @@ Copyright (C) 2003, 2010 - Wolfire Games 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. +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, +Lugaru 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. +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. +along with Lugaru. If not, see . */ #include "Game.h" @@ -42,7 +40,6 @@ extern Light light; extern Objects objects; extern int detail; extern float usermousesensitivity; -extern bool osx; extern float camerashake; extern int slomo; extern float slomodelay; @@ -137,8 +134,7 @@ int Game::DrawGLScene(StereoSide side) { static float texcoordwidth, texcoordheight; static float texviewwidth, texviewheight; - static int i, j, k, l; - static GLubyte color; + static int l; static XYZ checkpoint; static float tempmult; float tutorialopac; @@ -155,6 +151,8 @@ int Game::DrawGLScene(StereoSide side) case stereoRight: glColorMask( 1.0, 0.0, 0.0, 1.0 ); break; + default: + break; } } else { glColorMask( 1.0, 1.0, 1.0, 1.0 ); @@ -172,8 +170,9 @@ int Game::DrawGLScene(StereoSide side) if (!mainmenu) { if (editorenabled) { numboundaries = mapradius * 2; - if (numboundaries > 360)numboundaries = 360; - for (i = 0; i < numboundaries; i++) { + if (numboundaries > 360) + numboundaries = 360; + for (int i = 0; i < numboundaries; i++) { boundary[i] = 0; boundary[i].z = 1; boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0); @@ -187,12 +186,12 @@ int Game::DrawGLScene(StereoSide side) int olddrawmode = drawmode; if (ismotionblur && !loading) { - if ((findLengthfast(&player[0].velocity) > 200) && velocityblur && !cameramode) { + if ((findLengthfast(&Person::players[0]->velocity) > 200) && velocityblur && !cameramode) { drawmode = motionblurmode; - motionbluramount = 200 / (findLengthfast(&player[0].velocity)); + motionbluramount = 200 / (findLengthfast(&Person::players[0]->velocity)); changed = 1; } - if (player[0].damage - player[0].superpermanentdamage > (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) { + if (Person::players[0]->damage - Person::players[0]->superpermanentdamage > (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2 && damageeffects && !cameramode) { drawmode = doublevisionmode; changed = 1; } @@ -227,17 +226,8 @@ int Game::DrawGLScene(StereoSide side) if ((freeze || winfreeze) && ismotionblur && !mainmenu) drawmode = radialzoommode; - if (winfreeze || mainmenu)drawmode = normalmode; - -#if PLATFORM_MACOSX - if (drawmode == glowmode) { - RGBColor color2; - color2.red = 0; - color2.green = 0; - color2.blue = 0; - DSpContext_FadeGamma(NULL, 200, &color2); - } -#endif + if (winfreeze || mainmenu) + drawmode = normalmode; if (drawtoggle != 2) drawtoggle = 1 - drawtoggle; @@ -261,7 +251,6 @@ int Game::DrawGLScene(StereoSide side) glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); - //glFinish(); static XYZ terrainlight; static float distance; if (drawmode == normalmode) @@ -288,8 +277,8 @@ int Game::DrawGLScene(StereoSide side) //shake glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1); //sway - glRotatef(pitch + sin(woozy / 2) * (player[0].damage / player[0].damagetolerance) * 5, 1, 0, 0); - glRotatef(yaw + sin(woozy) * (player[0].damage / player[0].damagetolerance) * 5, 0, 1, 0); + glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0); + glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0); } if (cameramode || freeze || winfreeze) { glRotatef(pitch, 1, 0, 0); @@ -329,22 +318,22 @@ int Game::DrawGLScene(StereoSide side) static XYZ point; static float size, opacity, rotation; rotation = 0; - for (k = 0; k < numplayers; k++) { - if (!player[k].skeleton.free && player[k].playerdetail && player[k].howactive < typesleeping) - if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y + player[k].scale * 3, player[k].coords.z, player[k].scale * 7) && player[k].occluded < 25) - for (i = 0; i < player[k].skeleton.num_joints; i++) { - if (player[k].skeleton.joints[i].label == leftknee || player[k].skeleton.joints[i].label == rightknee || player[k].skeleton.joints[i].label == groin) { - point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords; + 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++) { + 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; - opacity = .4 - player[k].skeleton.joints[i].position.y * player[k].scale / 5 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 10; + opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10; if (k != 0 && tutoriallevel == 1) { - opacity = .2 + .2 * sin(smoketex * 6 + i) - player[k].skeleton.joints[i].position.y * player[k].scale / 5 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 10; + opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10; } terrain.MakeDecal(shadowdecal, point, size, opacity, rotation); - for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) { - j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l]; - if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { - point = DoRotation(DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0); + for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { + point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); size = .4f; opacity = .4f; if (k != 0 && tutoriallevel == 1) { @@ -355,25 +344,27 @@ int Game::DrawGLScene(StereoSide side) } } } - if ((player[k].skeleton.free || player[k].howactive >= typesleeping) && player[k].playerdetail) - if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5) && player[k].occluded < 25) - for (i = 0; i < player[k].skeleton.num_joints; i++) { - if (player[k].skeleton.joints[i].label == leftknee || player[k].skeleton.joints[i].label == rightknee || player[k].skeleton.joints[i].label == groin || player[k].skeleton.joints[i].label == leftelbow || player[k].skeleton.joints[i].label == rightelbow || player[k].skeleton.joints[i].label == neck) { - if (player[k].skeleton.free) - point = player[k].skeleton.joints[i].position * player[k].scale + player[k].coords; + 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++) { + 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; else - point = DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords; + 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; - opacity = .4 - player[k].skeleton.joints[i].position.y * player[k].scale / 5 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 5; + opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5; if (k != 0 && tutoriallevel == 1) { - opacity = .2 + .2 * sin(smoketex * 6 + i) - player[k].skeleton.joints[i].position.y * player[k].scale / 5 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 10; + opacity = .2 + .2 * sin(smoketex * 6 + i) - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 10; } terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation); - for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) { - j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l]; - if (objects.position[j].y < player[k].coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { - if (player[k].skeleton.free)point = DoRotation(player[k].skeleton.joints[i].position * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0); - else point = DoRotation(DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0); + for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { + if (Person::players[k]->skeleton.free) + point = DoRotation(Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); + else + point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); size = .4f; opacity = .4f; if (k != 0 && tutoriallevel == 1) { @@ -385,15 +376,15 @@ int Game::DrawGLScene(StereoSide side) } } - if (!player[k].playerdetail) - if (frustum.SphereInFrustum(player[k].coords.x, player[k].coords.y, player[k].coords.z, player[k].scale * 5)) { - point = player[k].coords; + if (!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)) { + point = Person::players[k]->coords; size = .7; - opacity = .4 - (player[k].coords.y - terrain.getHeight(player[k].coords.x, player[k].coords.z)) / 5; + opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5; terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation); - for (l = 0; l < terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]; l++) { - j = terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l]; - point = DoRotation(player[k].coords - objects.position[j], 0, -objects.yaw[j], 0); + for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); size = .7; opacity = .4f; objects.model[j].MakeDecal(shadowdecal, &point, &size, &opacity, &rotation); @@ -413,9 +404,6 @@ int Game::DrawGLScene(StereoSide side) terrain.draw(0); terraintexture2.bind(); terrain.draw(1); - //glBindTexture( GL_TEXTURE_2D, terraintexture3); - //glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - //terrain.draw(2); terrain.drawdecals(); @@ -445,37 +433,39 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); glDepthMask(1); - for (k = 0; k < numplayers; k++) { + for (unsigned k = 0; k < Person::players.size(); k++) { if (k == 0 || tutoriallevel != 1) { glEnable(GL_BLEND); glEnable(GL_LIGHTING); - terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z); - distance = distsq(&viewer, &player[k].coords); + terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z); + distance = distsq(&viewer, &Person::players[k]->coords); distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance; glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance); if (distance >= 1) glDisable(GL_BLEND); if (distance >= .5) { - checkpoint = DoRotation(player[k].skeleton.joints[abs(Random() % player[k].skeleton.num_joints)].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords; + 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.y += 1; - if (!player[k].occluded == 0) - i = checkcollide(viewer, checkpoint, player[k].lastoccluded); - if (i == -1 || player[k].occluded == 0) + int i = -1; + if (Person::players[k]->occluded != 0) + i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); + if (i == -1) i = checkcollide(viewer, checkpoint); if (i != -1) { - player[k].occluded += 1; - player[k].lastoccluded = i; - } else - player[k].occluded = 0; - if (player[k].occluded < 25) - player[k].DrawSkeleton(); + Person::players[k]->occluded += 1; + Person::players[k]->lastoccluded = i; + } else { + Person::players[k]->occluded = 0; + } + if (Person::players[k]->occluded < 25) + Person::players[k]->DrawSkeleton(); } } } } if (!cameramode && musictype == stream_fighttheme) - playerdist = distsqflat(&player[0].coords, &viewer); + playerdist = distsqflat(&Person::players[0]->coords, &viewer); else playerdist = -100; glPushMatrix(); @@ -508,30 +498,32 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); glDepthMask(1); - for (k = 0; k < numplayers; k++) { + for (unsigned k = 0; k < Person::players.size(); k++) { if (!(k == 0 || tutoriallevel != 1)) { glEnable(GL_BLEND); glEnable(GL_LIGHTING); - terrainlight = terrain.getLighting(player[k].coords.x, player[k].coords.z); - distance = distsq(&viewer, &player[k].coords); + terrainlight = terrain.getLighting(Person::players[k]->coords.x, Person::players[k]->coords.z); + distance = distsq(&viewer, &Person::players[k]->coords); distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance; glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance); if (distance >= 1) glDisable(GL_BLEND); if (distance >= .5) { - checkpoint = DoRotation(player[k].skeleton.joints[abs(Random() % player[k].skeleton.num_joints)].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords; + 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.y += 1; - if (!player[k].occluded == 0) - i = checkcollide(viewer, checkpoint, player[k].lastoccluded); - if (i == -1 || player[k].occluded == 0) + int i = -1; + if (Person::players[k]->occluded != 0) + i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); + if (i == -1) i = checkcollide(viewer, checkpoint); if (i != -1) { - player[k].occluded += 1; - player[k].lastoccluded = i; - } else - player[k].occluded = 0; - if (player[k].occluded < 25) - player[k].DrawSkeleton(); + Person::players[k]->occluded += 1; + Person::players[k]->lastoccluded = i; + } else { + Person::players[k]->occluded = 0; + } + if (Person::players[k]->occluded < 25) + Person::players[k]->DrawSkeleton(); } } } @@ -559,11 +551,11 @@ int Game::DrawGLScene(StereoSide side) glDisable(GL_COLOR_MATERIAL); glColor4f(1, 1, 0, 1); - for (k = 0; k < numplayers; k++) { - if (player[k].numwaypoints > 1) { + for (unsigned k = 0; k < Person::players.size(); k++) { + if (Person::players[k]->numwaypoints > 1) { glBegin(GL_LINE_LOOP); - for (i = 0; i < player[k].numwaypoints; i++) { - glVertex3f(player[k].waypoints[i].x, player[k].waypoints[i].y + .5, player[k].waypoints[i].z); + for (int i = 0; i < Person::players[k]->numwaypoints; i++) { + glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z); } glEnd(); } @@ -572,9 +564,9 @@ int Game::DrawGLScene(StereoSide side) if (numpathpoints > 1) { glColor4f(0, 1, 0, 1); - for (k = 0; k < numpathpoints; k++) { + for (unsigned k = 0; int(k) < numpathpoints; k++) { if (numpathpointconnect[k]) { - for (i = 0; i < numpathpointconnect[k]; i++) { + for (int i = 0; i < numpathpointconnect[k]; i++) { glBegin(GL_LINE_LOOP); glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z); glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z); @@ -595,9 +587,6 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glColor4f(.5, .5, .5, 1); if (!console) { - sprintf (string, " ", (int)(fps)); - text->glPrint(10, 30, string, 0, .8, screenwidth, screenheight); - if (!tutoriallevel) if (bonus > 0 && bonustime < 1 && !winfreeze && indialogue == -1/*bonustime<4*/) { const char *bonus_name; @@ -621,8 +610,10 @@ int Game::DrawGLScene(StereoSide side) if (tutoriallevel == 1) { tutorialopac = tutorialmaxtime - tutorialstagetime; - if (tutorialopac > 1)tutorialopac = 1; - if (tutorialopac < 0)tutorialopac = 0; + if (tutorialopac > 1) + tutorialopac = 1; + if (tutorialopac < 0) + tutorialopac = 0; sprintf (string, " "); sprintf (string2, " "); @@ -688,7 +679,7 @@ int Game::DrawGLScene(StereoSide side) sprintf (string3, "Be sure to use the movement keys to press against the wall"); } if (tutorialstage == 12) { - sprintf (string, "While in the air, you can press crouch to flip.", Input::keyToChar(jumpkey)); + sprintf (string, "While in the air, you can press crouch to flip."); sprintf (string2, "Walljumps and flips confuse enemies and give you more control."); sprintf (string3, " "); } @@ -703,8 +694,10 @@ int Game::DrawGLScene(StereoSide side) sprintf (string3, " "); } if (tutorialstage == 15) { - if (attackkey == MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy."); - else sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey)); + if (attackkey == MOUSEBUTTON1) + sprintf (string, "Click to attack when you are near an enemy."); + else + sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey)); sprintf (string2, "You can punch by standing still near an enemy and attacking."); sprintf (string3, " "); } @@ -730,15 +723,19 @@ int Game::DrawGLScene(StereoSide side) } if (tutorialstage == 20) { sprintf (string, "Your most powerful individual attack is the rabbit kick."); - if (attackkey == MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press"); - else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey)); + if (attackkey == MOUSEBUTTON1) + sprintf (string2, "Run at the enemy while holding the mouse button, and press"); + else + sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey)); sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey)); } if (tutorialstage == 21) { sprintf (string, "This attack is devastating if timed correctly."); sprintf (string2, "Even if timed incorrectly, it will knock the enemy over."); - if (againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again."); - else sprintf (string3, "Try rabbit-kicking the imaginary enemy."); + if (againbonus) + sprintf (string3, "Try rabbit-kicking the imaginary enemy again."); + else + sprintf (string3, "Try rabbit-kicking the imaginary enemy."); } if (tutorialstage == 22) { sprintf (string, "If you sneak behind an enemy unnoticed, you can kill"); @@ -752,8 +749,10 @@ int Game::DrawGLScene(StereoSide side) } if (tutorialstage == 24) { sprintf (string, "You can tackle enemies by running at them animal-style"); - if (attackkey == MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey)); - else sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey)); + if (attackkey == MOUSEBUTTON1) + sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey)); + else + sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey)); sprintf (string3, "This is especially useful when they are running away."); } if (tutorialstage == 25) { @@ -901,7 +900,7 @@ int Game::DrawGLScene(StereoSide side) text->glPrint(screenwidth / 2 - 7.6 * strlen(string2)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight); text->glPrint(screenwidth / 2 - 7.6 * strlen(string3)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 40 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight); - sprintf (string, "Press 'tab' to skip to the next item.", Input::keyToChar(jumpkey)); + sprintf (string, "Press 'tab' to skip to the next item."); sprintf (string2, "Press escape at any time to"); sprintf (string3, "pause or exit the tutorial."); @@ -917,14 +916,13 @@ int Game::DrawGLScene(StereoSide side) //Hot spots if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) { - int closest = -1; float closestdist = -1; float distance = 0; - closest = currenthotspot; - for (i = 0; i < numhotspots; i++) { - distance = distsq(&player[0].coords, &hotspot[i]); + int closest = currenthotspot; + for (int i = 0; i < numhotspots; i++) { + distance = distsq(&Person::players[0]->coords, &hotspot[i]); if (closestdist == -1 || distance < closestdist) { - if (distsq(&player[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[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) { closestdist = distance; closest = i; } @@ -934,19 +932,21 @@ int Game::DrawGLScene(StereoSide side) currenthotspot = closest; if (currenthotspot != -1) { if (hotspottype[closest] <= 10) { - if (distsq(&player[0].coords, &hotspot[closest]) < hotspotsize[closest]) + if (distsq(&Person::players[0]->coords, &hotspot[closest]) < hotspotsize[closest]) tutorialstagetime = 0; tutorialmaxtime = 1; tutorialopac = tutorialmaxtime - tutorialstagetime; - if (tutorialopac > 1)tutorialopac = 1; - if (tutorialopac < 0)tutorialopac = 0; + if (tutorialopac > 1) + tutorialopac = 1; + if (tutorialopac < 0) + tutorialopac = 0; sprintf (string, "%s", hotspottext[closest]); int lastline = 0; int line = 0; bool done = false; - i = 0; + int i = 0; while (!done) { if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') { glColor4f(0, 0, 0, tutorialopac); @@ -955,82 +955,85 @@ int Game::DrawGLScene(StereoSide side) text->glPrint(screenwidth / 2 - 7.6 * (i - lastline)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i); lastline = i + 1; line++; - if (string[i] == '\0')done = 1; + if (string[i] == '\0') + done = 1; } - if (i >= 255)done = 1; + if (i >= 255) + done = 1; i++; } } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) { whichdialogue = hotspottype[closest] - 20; - for (j = 0; j < numdialogueboxes[whichdialogue]; j++) { - player[participantfocus[whichdialogue][j]].coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]]; - player[participantfocus[whichdialogue][j]].yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]]; - player[participantfocus[whichdialogue][j]].targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]]; - player[participantfocus[whichdialogue][j]].velocity = 0; - player[participantfocus[whichdialogue][j]].animTarget = player[participantfocus[whichdialogue][j]].getIdle(); - player[participantfocus[whichdialogue][j]].frameTarget = 0; + 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, player[participantfocus[whichdialogue][indialogue]].coords); + 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); } } } } if (indialogue != -1 && !mainmenu) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix - if (dialogueboxlocation[whichdialogue][indialogue] == 1)glTranslatef(0, screenheight * 3 / 4, 0); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + if (dialogueboxlocation[whichdialogue][indialogue] == 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); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(1, 0, 0.0f); - glVertex3f(1, 1, 0.0f); - glVertex3f(0, 1, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(1, 0, 0.0f); + glVertex3f(1, 1, 0.0f); + glVertex3f(0, 1, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); @@ -1050,14 +1053,15 @@ int Game::DrawGLScene(StereoSide side) char tempname[264]; bool goodchar; int tempnum = 0; - for (i = 0; i < 264; i++) { + for (int i = 0; i < 264; i++) { tempname[i] = '\0'; } - for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) { + 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 (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0') + goodchar = 0; if (goodchar) tempnum++; else @@ -1077,9 +1081,10 @@ int Game::DrawGLScene(StereoSide side) } tempnum = 0; - for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) { + for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) { tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i]; - if (dialoguetext[whichdialogue][indialogue][i] != '#')tempnum++; + if (dialoguetext[whichdialogue][indialogue][i] != '#') + tempnum++; } sprintf (string, "%s", tempname); @@ -1087,7 +1092,7 @@ int Game::DrawGLScene(StereoSide side) int lastline = 0; int line = 0; bool done = false; - i = 0; + 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) { @@ -1101,9 +1106,11 @@ int Game::DrawGLScene(StereoSide side) } lastline = i + 1; line++; - if (string[i] == '\0')done = 1; + if (string[i] == '\0') + done = 1; } - if (i >= 255)done = 1; + if (i >= 255) + done = 1; i++; } } @@ -1115,30 +1122,31 @@ int Game::DrawGLScene(StereoSide side) else sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal); } - if (!campaign)sprintf (string, "Score: %d", (int)bonustotal); + if (!campaign) + sprintf (string, "Score: %d", (int)bonustotal); glColor4f(0, 0, 0, 1); text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768); glColor4f(1, 0, 0, 1); text->glPrint(1024 / 40, 768 / 16 + 768 * 14 / 16, string, 1, 1.5, 1024, 768); if (showdamagebar) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glTranslatef(15, screenheight * 17.5 / 20, 0); glScalef(screenwidth / 3 + 20, screenheight / 20, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0.0, 0.4, 0.0, 0.7); - float bar = ((float)player[0].damage) / player[0].damagetolerance; + float bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance; glBegin(GL_QUADS); glVertex3f((bar < 1 ? bar : 1), 0, 0.0f); glVertex3f(1, 0, 0.0f); @@ -1146,7 +1154,7 @@ int Game::DrawGLScene(StereoSide side) glVertex3f((bar < 1 ? bar : 1), 1, 0.0f); glEnd(); glColor4f(0.1, 0.0, 0.0, 1); - bar = ((float)player[0].bloodloss) / player[0].damagetolerance; + bar = ((float)Person::players[0]->bloodloss) / Person::players[0]->damagetolerance; glBegin(GL_QUADS); glVertex3f(0, 0, 0.0f); glVertex3f((bar < 1 ? bar : 1), 0, 0.0f); @@ -1154,7 +1162,7 @@ int Game::DrawGLScene(StereoSide side) glVertex3f(0, 1, 0.0f); glEnd(); glColor4f(0.4, 0.0, 0.0, 0.7); - bar = ((float)player[0].damage) / player[0].damagetolerance; + bar = ((float)Person::players[0]->damage) / Person::players[0]->damagetolerance; glBegin(GL_QUADS); glVertex3f(0, 0, 0.0f); glVertex3f((bar < 1 ? bar : 1), 0, 0.0f); @@ -1162,7 +1170,7 @@ int Game::DrawGLScene(StereoSide side) glVertex3f(0, 1, 0.0f); glEnd(); glColor4f(0.4, 0.0, 0.0, 0.7); - bar = ((float)player[0].permanentdamage) / player[0].damagetolerance; + bar = ((float)Person::players[0]->permanentdamage) / Person::players[0]->damagetolerance; glBegin(GL_QUADS); glVertex3f(0, 0, 0.0f); glVertex3f((bar < 1 ? bar : 1), 0, 0.0f); @@ -1170,7 +1178,7 @@ int Game::DrawGLScene(StereoSide side) glVertex3f(0, 1, 0.0f); glEnd(); glColor4f(0.4, 0.0, 0.0, 0.7); - bar = ((float)player[0].superpermanentdamage) / player[0].damagetolerance; + bar = ((float)Person::players[0]->superpermanentdamage) / Person::players[0]->damagetolerance; glBegin(GL_QUADS); glVertex3f(0, 0, 0.0f); glVertex3f((bar < 1 ? bar : 1), 0, 0.0f); @@ -1187,18 +1195,18 @@ int Game::DrawGLScene(StereoSide side) glVertex3f(0, 0, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); glEnable(GL_TEXTURE_2D); // writing the numbers : - sprintf (string, "Damages : %d/%d (%d)", (int)(player[0].damage), (int)(player[0].damagetolerance), (int)(player[0].bloodloss)); + sprintf (string, "Damages : %d/%d (%d)", (int)(Person::players[0]->damage), (int)(Person::players[0]->damagetolerance), (int)(Person::players[0]->bloodloss)); glColor4f(0, 0, 0, 1); text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16 - 40, string, 1, 1.5 * 1.25, 1024, 768); glColor4f(1, 0, 0, 1); @@ -1221,11 +1229,15 @@ int Game::DrawGLScene(StereoSide side) if (editorenabled) { sprintf (string, "Object size: %f", editorsize); text->glPrint(10, 75, string, 0, .8, 1024, 768); - if (editoryaw >= 0)sprintf (string, "Object yaw: %f", editoryaw); - else sprintf (string, "Object yaw: Random"); + if (editoryaw >= 0) + sprintf (string, "Object yaw: %f", editoryaw); + else + sprintf (string, "Object yaw: Random"); text->glPrint(10, 90, string, 0, .8, 1024, 768); - if (editorpitch >= 0)sprintf (string, "Object pitch: %f", editorpitch); - else sprintf (string, "Object pitch: Random"); + if (editorpitch >= 0) + sprintf (string, "Object pitch: %f", editorpitch); + else + sprintf (string, "Object pitch: Random"); text->glPrint(10, 105, string, 0, .8, 1024, 768); sprintf (string, "Object type: %d", editortype); text->glPrint(10, 120, string, 0, .8, 1024, 768); @@ -1269,9 +1281,9 @@ int Game::DrawGLScene(StereoSide side) } text->glPrint(130, 120, string, 0, .8, 1024, 768); - sprintf (string, "Numplayers: %d", numplayers); + sprintf (string, "Numplayers: %lu", Person::players.size()); text->glPrint(10, 155, string, 0, .8, 1024, 768); - sprintf (string, "Player %d: numwaypoints: %d", numplayers, player[numplayers - 1].numwaypoints); + sprintf (string, "Player %d: numwaypoints: %d", (int(Person::players.size()) - 1), Person::players.back()->numwaypoints); text->glPrint(10, 140, string, 0, .8, 1024, 768); } sprintf (string, "Difficulty: %d", difficulty); @@ -1281,115 +1293,122 @@ int Game::DrawGLScene(StereoSide side) } if (drawmode == glowmode) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0, 0, 0, .5); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); } - if ((((blackout && damageeffects) || (player[0].bloodloss > 0 && damageeffects && player[0].blooddimamount > 0) || player[0].dead) && !cameramode) || console) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + if ((((blackout && damageeffects) || (Person::players[0]->bloodloss > 0 && damageeffects && Person::players[0]->blooddimamount > 0) || Person::players[0]->dead) && !cameramode) || console) { + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - if (player[0].dead)blackout += multiplier * 3; - if (player[0].dead == 1)blackout = .4f; - if (player[0].dead == 2 && blackout > .6)blackout = .6; + if (Person::players[0]->dead) + blackout += multiplier * 3; + if (Person::players[0]->dead == 1) + blackout = .4f; + if (Person::players[0]->dead == 2 && blackout > .6) + blackout = .6; glColor4f(0, 0, 0, blackout); - if (!player[0].dead) { - if ((player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) { - glColor4f(0, 0, 0, player[0].blooddimamount * player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5)*.3); - blackout = player[0].blooddimamount * player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5) * .3; + if (!Person::players[0]->dead) { + if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) { + glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3); + blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3; } else { - glColor4f(0, 0, 0, player[0].blooddimamount * .3); - blackout = player[0].blooddimamount * .3; + glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3); + blackout = Person::players[0]->blooddimamount * .3; } } - if (console)glColor4f(.7, 0, 0, .2); + if (console) + glColor4f(.7, 0, 0, .2); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); } if (flashamount > 0 && damageeffects) { - if (flashamount > 1)flashamount = 1; - if (flashdelay <= 0)flashamount -= multiplier; + if (flashamount > 1) + flashamount = 1; + if (flashdelay <= 0) + flashamount -= multiplier; flashdelay--; - if (flashamount < 0)flashamount = 0; - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + if (flashamount < 0) + flashamount = 0; + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(flashr, flashg, flashb, flashamount); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); @@ -1399,22 +1418,12 @@ int Game::DrawGLScene(StereoSide side) displaytime[0] = 0; glEnable(GL_TEXTURE_2D); glColor4f(1, 1, 1, 1); - if (chatting) { - sprintf (string, " ]"); - text->glPrint(10, 30 + screenheight - 330, string, 0, 1, screenwidth, screenheight); - if (displayblink) { - sprintf (string, "_"); - text->glPrint(30 + (float)(displayselected) * 10, 30 + (screenheight - 330), string, 0, 1, screenwidth, screenheight); - } - } - for (i = 0; i < 15; i++) - if ((i != 0 || chatting) && displaytime[i] < 4) - for (j = 0; j < displaychars[i]; j++) { + for (unsigned i = 1; i < 15; i++) + if (displaytime[i] < 4) + for (unsigned j = 0; j < displaytext[i].size(); j++) { glColor4f(1, 1, 1, 4 - displaytime[i]); - if (j < displaychars[i]) { - sprintf (string, "%c", displaytext[i][j]); - text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight); - } + sprintf (string, "%c", displaytext[i][j]); + text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight); } } @@ -1427,17 +1436,17 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_TEXTURE_2D); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef((float)screenwidth / 2, (float)screenwidth / 2, 1); glTranslatef(1.75, .25, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1450,57 +1459,57 @@ int Game::DrawGLScene(StereoSide side) float distcheck; int numliveplayers = 0; center = 0; - for (i = 0; i < numplayers; i++) { - if (!player[i].dead) numliveplayers++; + for (unsigned i = 0; i < Person::players.size(); i++) { + if (!Person::players[i]->dead) + numliveplayers++; } int numadd = 0; - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) { center += objects.position[i]; numadd++; } } - for (i = 0; i < numplayers; i++) { - if (!player[i].dead)center += player[i].coords; + for (unsigned i = 0; i < Person::players.size(); i++) { + if (!Person::players[i]->dead) + center += Person::players[i]->coords; } center /= numadd + numliveplayers; - center = player[0].coords; + center = Person::players[0]->coords; float maxdistance = 0; float tempdist; //~ int whichclosest; - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { tempdist = distsq(¢er, &objects.position[i]); if (tempdist > maxdistance) { //~ whichclosest=i; maxdistance = tempdist; } } - for (i = 0; i < numplayers; i++) { - if (!player[i].dead) { - tempdist = distsq(¢er, &player[i].coords); + for (unsigned i = 0; i < Person::players.size(); i++) { + if (!Person::players[i]->dead) { + tempdist = distsq(¢er, &Person::players[i]->coords); if (tempdist > maxdistance) { //~ whichclosest=i; maxdistance = tempdist; } } } - radius = fast_sqrt(maxdistance); - radius = 110; glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1); glPushMatrix(); glScalef(1 / (1 / radius * 256 * terrain.scale * .4), 1 / (1 / radius * 256 * terrain.scale * .4), 1); glPopMatrix(); - glRotatef(player[0].lookyaw * -1 + 180, 0, 0, 1); + glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1); glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0); - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { if (objects.type[i] == treetrunktype) { - distcheck = distsq(&player[0].coords, &objects.position[i]); + distcheck = distsq(&Person::players[0]->coords, &objects.position[i]); if (distcheck < mapviewdist) { Mapcircletexture.bind(); glColor4f(0, .3, 0, opac * (1 - distcheck / mapviewdist)); @@ -1510,19 +1519,19 @@ int Game::DrawGLScene(StereoSide side) glScalef(.003, .003, .003); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1, 1); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, 1); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } } if (objects.type[i] == boxtype) { - distcheck = distsq(&player[0].coords, &objects.position[i]); + distcheck = distsq(&Person::players[0]->coords, &objects.position[i]); if (distcheck < mapviewdist) { Mapboxtexture.bind(); glColor4f(.4, .4, .4, opac * (1 - distcheck / mapviewdist)); @@ -1532,13 +1541,13 @@ int Game::DrawGLScene(StereoSide side) glScalef(.01 * objects.scale[i], .01 * objects.scale[i], .01 * objects.scale[i]); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1, 1); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, 1); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } @@ -1546,91 +1555,97 @@ int Game::DrawGLScene(StereoSide side) } if (editorenabled) { Mapcircletexture.bind(); - for (i = 0; i < numboundaries; i++) { + for (int i = 0; i < numboundaries; i++) { glColor4f(0, 0, 0, opac / 3); glPushMatrix(); glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0); glScalef(.002, .002, .002); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1, 1); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, 1); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } } - for (i = 0; i < numplayers; i++) { - distcheck = distsq(&player[0].coords, &player[i].coords); + for (unsigned i = 0; i < Person::players.size(); i++) { + distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords); if (distcheck < mapviewdist) { glPushMatrix(); Maparrowtexture.bind(); - if (i == 0)glColor4f(1, 1, 1, opac); - else if (player[i].dead == 2 || player[i].howactive > typesleeping)glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist)); - else if (player[i].dead)glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist)); - else if (player[i].aitype == attacktypecutoff)glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist)); - else if (player[i].aitype == passivetype)glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist)); - else glColor4f(1, 1, 0, 1); - glTranslatef(player[i].coords.x / terrain.scale / 256 * -2 + 1, player[i].coords.z / terrain.scale / 256 * 2 - 1, 0); - glRotatef(player[i].yaw + 180, 0, 0, 1); + if (i == 0) + glColor4f(1, 1, 1, opac); + else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping) + glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist)); + else if (Person::players[i]->dead) + glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist)); + else if (Person::players[i]->aitype == attacktypecutoff) + glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist)); + else if (Person::players[i]->aitype == passivetype) + glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist)); + else + glColor4f(1, 1, 0, 1); + glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0); + glRotatef(Person::players[i]->yaw + 180, 0, 0, 1); glScalef(.005, .005, .005); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1, 1); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, 1); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } } glPopMatrix(); glDisable(GL_TEXTURE_2D); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); } - if (loading && !stealthloading && (!campaign || player[0].dead)) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + if (loading && !stealthloading && (!campaign || Person::players[0]->dead)) { + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0, 0, 0, .7); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); @@ -1650,38 +1665,37 @@ int Game::DrawGLScene(StereoSide side) text->glPrint(1024 / 2 - 90, 768 / 2, string, 1, 2, 1024, 768); } loading = 2; - //if(ismotionblur)drawmode=motionblurmode; drawmode = normalmode; } if (winfreeze && !campaign) { - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0, 0, 0, .4); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); @@ -1710,10 +1724,12 @@ int Game::DrawGLScene(StereoSide side) char temp[255]; - for (i = 0; i < 255; i++)string[i] = '\0'; + for (int i = 0; i < 255; i++) + string[i] = '\0'; sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60)); strcat(string, temp); - if ((int)(leveltime) % 60 < 10)strcat(string, "0"); + if ((int)(leveltime) % 60 < 10) + strcat(string, "0"); sprintf (temp, "%d", (int)(leveltime) % 60); strcat(string, temp); text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768); @@ -1722,7 +1738,7 @@ int Game::DrawGLScene(StereoSide side) int awards[award_count]; int numawards = award_awards(awards); - for (i = 0; i < numawards && i < 6; i++) + for (int 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); } @@ -1735,7 +1751,6 @@ int Game::DrawGLScene(StereoSide side) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); 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_COMBINE_RGB_EXT, GL_SUBTRACT); 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); @@ -1763,7 +1778,6 @@ int Game::DrawGLScene(StereoSide side) glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0); } } - //glFlush(); } glClear(GL_DEPTH_BUFFER_BIT); @@ -1782,35 +1796,35 @@ int Game::DrawGLScene(StereoSide side) glBindTexture( GL_TEXTURE_2D, screentexture); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef((float)screenwidth / 2, (float)screenheight / 2, 1); glTranslatef(1, 1, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); if (drawmode == motionblurmode) { - if (motionbluramount < .2)motionbluramount = .2; - //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount); + if (motionbluramount < .2) + motionbluramount = .2; glColor4f(1, 1, 1, motionbluramount); glPushMatrix(); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } @@ -1823,13 +1837,13 @@ int Game::DrawGLScene(StereoSide side) glPushMatrix(); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glBindTexture( GL_TEXTURE_2D, screentexture2); @@ -1837,35 +1851,37 @@ int Game::DrawGLScene(StereoSide side) glPushMatrix(); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if (drawmode == doublevisionmode) { static float crosseyedness; - crosseyedness = abs(player[0].damage - player[0].superpermanentdamage - (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2) / 30; - if (crosseyedness > 1)crosseyedness = 1; - if (crosseyedness < 0)crosseyedness = 0; + crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30; + if (crosseyedness > 1) + crosseyedness = 1; + if (crosseyedness < 0) + crosseyedness = 0; glColor4f(1, 1, 1, 1); glDisable(GL_BLEND); glPushMatrix(); glScalef(1, 1, 1); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); if (crosseyedness) { @@ -1876,13 +1892,13 @@ int Game::DrawGLScene(StereoSide side) glScalef(1, 1, 1); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } @@ -1895,80 +1911,79 @@ int Game::DrawGLScene(StereoSide side) glTranslatef(.01, 0, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(-.01, 0, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(.0, .01, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glPushMatrix(); glTranslatef(0, -.01, 0); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } if (drawmode == radialzoommode) { - for (i = 0; i < 3; i++) { - //glRotatef((float)i*.1,0,0,1); + for (int i = 0; i < 3; i++) { glColor4f(1, 1, 1, 1 / ((float)i + 1)); glPushMatrix(); glScalef(1 + (float)i * .01, 1 + (float)i * .01, 1); glBegin(GL_QUADS); glTexCoord2f(0, 0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(texcoordwidth, 0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(texcoordwidth, texcoordheight); - glVertex3f(1, 1, 0.0f); + glVertex3f(1, 1, 0.0f); glTexCoord2f(0, texcoordheight); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); } } glDisable(GL_TEXTURE_2D); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); @@ -1986,13 +2001,11 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "_"); text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768); } - for (i = 0; i < 15; i++) - for (j = 0; j < consolechars[i]; j++) { + for (unsigned i = 0; i < 15; i++) + for (unsigned j = 0; j < consoletext[i].size(); j++) { glColor4f(1, 1, 1, 1 - (float)(i) / 16); - if (j < consolechars[i]) { - sprintf (string, "%c", consoletext[i][j]); - text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768); - } + sprintf (string, "%c", consoletext[i][j]); + text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768); } } } @@ -2010,21 +2023,19 @@ int Game::DrawGLScene(StereoSide side) multiplier = 0; } - //glFlush(); if ( side == stereoRight || side == stereoCenter ) { if (drawmode != motionblurmode || mainmenu) { swap_gl_buffers(); } } - //myassert(glGetError() == GL_NO_ERROR); glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); - //glFlush(); weapons.DoStuff(); - if (drawtoggle == 2)drawtoggle = 0; + if (drawtoggle == 2) + drawtoggle = 0; if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) { multiplier = tempmult; @@ -2048,17 +2059,17 @@ void DrawMenu() glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.001f); glEnable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glTranslatef(screenwidth / 2, screenheight / 2, 0); glPushMatrix(); glScalef((float)screenwidth / 2, (float)screenheight / 2, 1); @@ -2092,36 +2103,36 @@ void DrawMenu() glEnd(); glPopMatrix(); glPopMatrix(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glMatrixMode(GL_PROJECTION); glPopMatrix(); - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glMatrixMode(GL_MODELVIEW); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, 640, 0, 480, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, 640, 0, 480, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glEnable(GL_TEXTURE_2D); Menu::drawItems(); //draw mouse cursor - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glMatrixMode(GL_PROJECTION); glPopMatrix(); - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix + glMatrixMode(GL_MODELVIEW); glPopMatrix(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glTranslatef(screenwidth / 2, screenheight / 2, 0); glPushMatrix(); glScalef((float)screenwidth / 2, (float)screenheight / 2, 1); @@ -2141,7 +2152,6 @@ void DrawMenu() glColor4f(1, 1, 1, 1); Game::cursortexture.bind(); glPushMatrix(); - //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3f(-1, -1, 0.0f); @@ -2156,43 +2166,46 @@ void DrawMenu() glPopMatrix(); } glPopMatrix(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix + glMatrixMode(GL_PROJECTION); glPopMatrix(); //draw screen flash if (flashamount > 0) { - if (flashamount > 1)flashamount = 1; - if (flashdelay <= 0)flashamount -= multiplier; + if (flashamount > 1) + flashamount = 1; + if (flashdelay <= 0) + flashamount -= multiplier; flashdelay--; - if (flashamount < 0)flashamount = 0; - glDisable(GL_DEPTH_TEST); // Disables Depth Testing + if (flashamount < 0) + flashamount = 0; + glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glDepthMask(0); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPushMatrix(); // Store The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPushMatrix(); // Store The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screenwidth, 0, screenheight, -100, 100); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); glScalef(screenwidth, screenheight, 1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(flashr, flashg, flashb, flashamount); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); - glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); + glVertex3f(256, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glPopMatrix(); // Restore The Old Projection Matrix - glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1);