]> git.jsancho.org Git - lugaru.git/commitdiff
HUGE refactoring:
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Thu, 3 Jun 2010 17:40:28 +0000 (19:40 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Thu, 3 Jun 2010 17:40:28 +0000 (19:40 +0200)
-Accounts are now handled by a pretty Account class.
-Keys inputs are now handled the Input class (with static methods) and use directly SDL, no more #define MAC_CRAP
-For that I had to add thread for two things:
-the entername field
-the key configuration
Maybe when the menu system will have been cleaned up (reorganized) the threads won't be needed anymore.
This commit can read old Users files, but not completely old config.txt files (you'll have to reconfigure keyboards bindings)

12 files changed:
CMakeLists.txt
Source/Game.h
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/OpenGL_Windows.cpp
Source/Person.cpp
Source/Settings.cpp
Source/Weapons.cpp
Source/WinInput.cpp
Source/WinInput.h

index 766bd3768640f4d3152b7458b5168d6b8a442499..aa0374f1320259b9806505d38998def466ca60d6 100644 (file)
@@ -52,6 +52,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 
 set(LUGARU_SRCS
        ${SRCDIR}/Frustum.cpp
+       ${SRCDIR}/Account.cpp
+       ${SRCDIR}/Game.cpp
        ${SRCDIR}/GameDraw.cpp
        ${SRCDIR}/GameInitDispose.cpp
        ${SRCDIR}/GameTick.cpp
@@ -77,6 +79,7 @@ set(LUGARU_SRCS
        ${SRCDIR}/OpenGL_Windows.cpp
        ${SRCDIR}/openal_wrapper.cpp
        ${SRCDIR}/WinInput.cpp
+       ${SRCDIR}/Input.cpp
        ${SRCDIR}/Settings.cpp
        ${SRCDIR}/Stereo.cpp
 )
@@ -84,6 +87,7 @@ set(LUGARU_SRCS
 set(LUGARU_H
        ${SRCDIR}/Constants.h
        ${SRCDIR}/Frustum.h
+       ${SRCDIR}/Account.h
        ${SRCDIR}/Game.h
        ${SRCDIR}/Lights.h
        ${SRCDIR}/LinkedList.h
@@ -102,6 +106,7 @@ set(LUGARU_H
        ${SRCDIR}/Text.h
        ${SRCDIR}/Weapons.h
        ${SRCDIR}/WinInput.h
+       ${SRCDIR}/Input.h
        ${SRCDIR}/alstubs.h
        ${SRCDIR}/binio.h
        ${SRCDIR}/openal_wrapper.h
index 1297fbdc4f6c016076c7bdbe308e563b2a53b5d7..8846493e07be874e29a4c9a3a83d09c8cfa8de53 100644 (file)
@@ -63,238 +63,251 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <fstream>
 #include "gamegl.h"
 #include "Stereo.h"
+#include "Account.h"
 
 extern GLuint rabbittexture;
 
 class Game
 {
-public:
-
-       typedef std::map<std::string, GLuint> TextureList;
-       typedef std::map<GLuint, std::string> GLTextureList;
-       typedef TextureList::iterator TexIter;
-       static TextureList textures;
-
-       GLuint terraintexture;
-       GLuint terraintexture2;
-       GLuint terraintexture3;
-       GLuint screentexture;
-       GLuint screentexture2;
-       GLuint logotexture;
-       GLuint loadscreentexture;
-       GLuint Maparrowtexture;
-       GLuint Mapboxtexture;
-       GLuint Mapcircletexture;
-       GLuint cursortexture;
-       GLuint Mainmenuitems[10];
-
-       int nummenuitems;
-       int startx[100];
-       int starty[100];
-       int endx[100];
-       int endy[100];
-       float selectedlong[100];
-       float offsetx[100];
-       float offsety[100];
-       float movex[100];
-       float movey[100];
-       float transition;
-       int anim;
-       int selected;
-       int loaddistrib;
-       int keyselect;
-       int indemo;
-
-       bool won;
-
-       bool entername;
-
-       char menustring[100][256];
-       char registrationname[256];
-       float registrationnumber;
-
-       int newdetail;
-       int newscreenwidth;
-       int newscreenheight;
-
-       bool gameon;
-       float deltah,deltav;
-       int mousecoordh,mousecoordv;
-       int oldmousecoordh,oldmousecoordv;
-       float rotation,rotation2;
-       SkyBox skybox;
-       bool cameramode;
-       bool cameratogglekeydown;
-       bool chattogglekeydown;
-       int olddrawmode;
-       int drawmode;
-       bool drawmodetogglekeydown;
-       bool explodetogglekeydown;
-       bool detailtogglekeydown;
-       bool firstload;
-       bool oldbutton;
-
-       float leveltime;
-       float loadtime;
-
-       Model hawk;
-       XYZ hawkcoords;
-       XYZ realhawkcoords;
-       GLuint hawktexture;
-       float hawkrotation;
-       float hawkcalldelay;
-
-       Model eye;
-       Model iris;
-       Model cornea;
-
-       bool stealthloading;
-
-       int campaignnumlevels;
-       char campaignmapname[50][256];
-       char campaigndescription[50][256];
-       int campaignchoosenext[50];
-       int campaignnumnext[50];
-       int campaignnextlevel[50][10];
-       int campaignchoicesmade;
-       int campaignchoices[5000];
-       int campaignlocationx[50];
-       int campaignlocationy[50];
-       int campaignchoicenum;
-       int campaignchoicewhich[10];
-       int whichchoice;
-
-       int numlevelspassed;
-       int levelorder[5000];
-       int levelvisible[50];
-       int levelhighlight[50];
-
-       bool minimap;
-
-       int musictype,oldmusictype,oldoldmusictype;
-       bool realthreat;
-
-       Model rabbit;
-       XYZ rabbitcoords;
-
-       XYZ mapcenter;
-       float mapradius;
-
-       Text text;
-       float fps;
-
-       XYZ cameraloc;
-       float cameradist;
-
-       bool envtogglekeydown;
-       bool slomotogglekeydown;
-       bool texturesizetogglekeydown;
-       bool freezetogglekeydown;
-       int drawtoggle;
-
-       bool editorenabled;
-       int editortype;
-       float editorsize;
-       float editorrotation;
-       float editorrotation2;
-
-       float brightness;
-
-       int quit;
-       int tryquit;
-
-       XYZ pathpoint[30];
-       int numpathpoints;
-       int numpathpointconnect[30];
-       int pathpointconnect[30][30];
-       int pathpointselected;
-
-       int endgame;
-       bool scoreadded;
-       int numchallengelevels;
-
-       bool console;
-       int archiveselected;
-       char consoletext[15][256];
-       int consolechars[15];
-       bool chatting;
-       char displaytext[15][256];
-       int displaychars[15];
-       float displaytime[15];
-       float displayblinkdelay;
-       bool displayblink;
-       int displayselected;
-       bool consolekeydown;
-       bool consoletogglekeydown;
-       float consoleblinkdelay;
-       bool consoleblink;
-       int consoleselected;
-       int togglekey[140];
-       float togglekeydelay[140];
-       bool registernow;
-       bool autocam;
-
-       unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
-       bool oldattackkey;
-
-       long long MD5_string (char *string);
-       static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
-       static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
-       void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
-       bool AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
-       void InitGame();
-       void LoadStuff();
-       void LoadingScreen();
-       void FadeLoadingScreen(float howmuch);
-       void Dispose();
-       int DrawGLScene(StereoSide side);
-       void Tick();
-       void TickOnce();
-       void TickOnceAfter();
-       void SetUpLighting();
-       void Loadlevel(int which);
-       void Loadlevel(char *name);
-       void LoadSounds();
-       void Setenvironment(int which);
-       GLvoid ReSizeGLScene(float fov, float near);
-       int findPathDist(int start,int end);
-       int checkcollide(XYZ startpoint, XYZ endpoint);
-       int checkcollide(XYZ startpoint, XYZ endpoint, int what);
-       int loading;
-       float talkdelay;
-
-       int numboundaries;
-       XYZ boundary[360];
-
-       int whichlevel;
-       int oldenvironment;
-       int targetlevel;
-       float changedelay;
-
-       float musicvolume[4];
-       float oldmusicvolume[4];
-       int musicselected;
-       int change;
-       Game();
-       ~Game() {
-               for(int i=0;i<10;i++){
-                       if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
+       public:
+               typedef std::map<std::string, GLuint> TextureList;
+               typedef std::map<GLuint, std::string> GLTextureList;
+               typedef TextureList::iterator TexIter;
+               static TextureList textures;
+
+               GLuint terraintexture;
+               GLuint terraintexture2;
+               GLuint terraintexture3;
+               GLuint screentexture;
+               GLuint screentexture2;
+               GLuint logotexture;
+               GLuint loadscreentexture;
+               GLuint Maparrowtexture;
+               GLuint Mapboxtexture;
+               GLuint Mapcircletexture;
+               GLuint cursortexture;
+               GLuint Mainmenuitems[10];
+
+               int nummenuitems;
+               int startx[100];
+               int starty[100];
+               int endx[100];
+               int endy[100];
+               float selectedlong[100];
+               float offsetx[100];
+               float offsety[100];
+               float movex[100];
+               float movey[100];
+               float transition;
+               int anim;
+               int selected;
+               int keyselect;
+               int loaddistrib;
+               int indemo;
+
+               bool won;
+
+               bool entername;
+
+               char menustring[100][256];
+               char registrationname[256];
+               float registrationnumber;
+
+               int newdetail;
+               int newscreenwidth;
+               int newscreenheight;
+
+               bool gameon;
+               float deltah,deltav;
+               int mousecoordh,mousecoordv;
+               int oldmousecoordh,oldmousecoordv;
+               float rotation,rotation2;
+               SkyBox skybox;
+               bool cameramode;
+               bool cameratogglekeydown;
+               bool chattogglekeydown;
+               int olddrawmode;
+               int drawmode;
+               bool drawmodetogglekeydown;
+               bool explodetogglekeydown;
+               bool detailtogglekeydown;
+               bool firstload;
+               bool oldbutton;
+
+               float leveltime;
+               float loadtime;
+
+               Model hawk;
+               XYZ hawkcoords;
+               XYZ realhawkcoords;
+               GLuint hawktexture;
+               float hawkrotation;
+               float hawkcalldelay;
+
+               Model eye;
+               Model iris;
+               Model cornea;
+
+               bool stealthloading;
+
+               int campaignnumlevels;
+               char campaignmapname[50][256];
+               char campaigndescription[50][256];
+               int campaignchoosenext[50];
+               int campaignnumnext[50];
+               int campaignnextlevel[50][10];
+               int campaignchoicesmade;
+               int campaignchoices[5000];
+               int campaignlocationx[50];
+               int campaignlocationy[50];
+               int campaignchoicenum;
+               int campaignchoicewhich[10];
+               int whichchoice;
+
+               int numlevelspassed;
+               int levelorder[5000];
+               int levelvisible[50];
+               int levelhighlight[50];
+
+               bool minimap;
+
+               int musictype,oldmusictype,oldoldmusictype;
+               bool realthreat;
+
+               Model rabbit;
+               XYZ rabbitcoords;
+
+               XYZ mapcenter;
+               float mapradius;
+
+               Text text;
+               float fps;
+
+               XYZ cameraloc;
+               float cameradist;
+
+               bool envtogglekeydown;
+               bool slomotogglekeydown;
+               bool texturesizetogglekeydown;
+               bool freezetogglekeydown;
+               int drawtoggle;
+
+               bool editorenabled;
+               int editortype;
+               float editorsize;
+               float editorrotation;
+               float editorrotation2;
+
+               float brightness;
+
+               int quit;
+               int tryquit;
+
+               XYZ pathpoint[30];
+               int numpathpoints;
+               int numpathpointconnect[30];
+               int pathpointconnect[30][30];
+               int pathpointselected;
+
+               int endgame;
+               bool scoreadded;
+               int numchallengelevels;
+
+               bool console;
+               int archiveselected;
+               char consoletext[15][256];
+               int consolechars[15];
+               bool chatting;
+               char displaytext[15][256];
+               int displaychars[15];
+               float displaytime[15];
+               float displayblinkdelay;
+               bool displayblink;
+               int displayselected;
+               bool consolekeydown;
+               bool consoletogglekeydown;
+               float consoleblinkdelay;
+               bool consoleblink;
+               int consoleselected;
+               int togglekey[140];
+               float togglekeydelay[140];
+               bool registernow;
+               bool autocam;
+
+               unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
+               bool oldattackkey;
+
+               long long MD5_string (char *string);
+               static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
+               static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
+               void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
+               bool AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
+               void InitGame();
+               void LoadStuff();
+               void LoadingScreen();
+               void FadeLoadingScreen(float howmuch);
+               void Dispose();
+               int DrawGLScene(StereoSide side);
+               void Tick();
+               void TickOnce();
+               void TickOnceAfter();
+               void SetUpLighting();
+               void Loadlevel(int which);
+               void Loadlevel(char *name);
+               void LoadSounds();
+               void Setenvironment(int which);
+               GLvoid ReSizeGLScene(float fov, float near);
+               int findPathDist(int start,int end);
+               int checkcollide(XYZ startpoint, XYZ endpoint);
+               int checkcollide(XYZ startpoint, XYZ endpoint, int what);
+               int loading;
+               float talkdelay;
+               
+               void fireSound(int sound=fireendsound);
+               void setKeySelected();
+
+               int numboundaries;
+               XYZ boundary[360];
+
+               int whichlevel;
+               int oldenvironment;
+               int targetlevel;
+               float changedelay;
+
+               float musicvolume[4];
+               float oldmusicvolume[4];
+               int musicselected;
+               int change;
+               Game();
+               ~Game() {
+                       for(int i=0;i<10;i++){
+                               if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
+                       }
+                       glDeleteTextures( 1, &cursortexture );
+                       glDeleteTextures( 1, &Maparrowtexture );
+                       glDeleteTextures( 1, &Mapboxtexture );
+                       glDeleteTextures( 1, &Mapcircletexture );
+                       glDeleteTextures( 1, &terraintexture );
+                       glDeleteTextures( 1, &terraintexture2 );
+                       if(screentexture>0)glDeleteTextures( 1, &screentexture );
+                       if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
+                       glDeleteTextures( 1, &hawktexture );
+                       glDeleteTextures( 1, &logotexture );
+                       glDeleteTextures( 1, &loadscreentexture );
+
+                       Dispose();
                }
-               glDeleteTextures( 1, &cursortexture );
-               glDeleteTextures( 1, &Maparrowtexture );
-               glDeleteTextures( 1, &Mapboxtexture );
-               glDeleteTextures( 1, &Mapcircletexture );
-               glDeleteTextures( 1, &terraintexture );
-               glDeleteTextures( 1, &terraintexture2 );
-               if(screentexture>0)glDeleteTextures( 1, &screentexture );
-               if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
-               glDeleteTextures( 1, &hawktexture );
-               glDeleteTextures( 1, &logotexture );
-               glDeleteTextures( 1, &loadscreentexture );
-
-               Dispose();
-       }
-
+               bool isWaiting() { return waiting; };
+       private:
+               void setKeySelected_thread();
+               static int thread(void *data);
+               void inputText();
+               void inputText_thread();
+               void flash();
+               bool waiting;
+               bool mainmenutogglekeydown;
+               //int mainmenu;
+               Account* accountactive;
 };
 
 #ifndef __forceinline
index 039df019d220a28189bd057da65770d8f6873e30..97c2b66925dee2bc129e6fc4e3a90f6293ea6e40 100644 (file)
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "Game.h"
 #include "openal_wrapper.h"
+#include "Input.h"
 
 using namespace std;
 
@@ -72,7 +73,6 @@ extern bool midweird;
 extern bool proportionweird;
 extern bool vertexweird[6];
 extern bool velocityblur;
-extern bool buttons[3];
 extern bool debugmode;
 extern int mainmenu;
 extern int oldmainmenu;
@@ -107,17 +107,7 @@ extern XYZ hotspot[40];
 extern int hotspottype[40];
 extern float hotspotsize[40];
 extern char hotspottext[40][256];
-extern int currenthotspot;
-
-extern int numaccounts;
-extern int accountactive;
-extern int accountdifficulty[10];
-extern int accountprogress[10];
-extern float accountpoints[10];
-extern float accounthighscore[10][50];
-extern float accountfasttime[10][50];
-extern bool accountunlocked[10][60];
-extern char accountname[10][256];
+extern int currenthotspot;;
 
 extern int numfalls;
 extern int numflipfail;
@@ -165,14 +155,6 @@ extern int directing;
 extern float dialoguetime;
 extern int dialoguegonethrough[20];
 
-extern int accountcampaignchoicesmade[10];
-extern int accountcampaignchoices[10][5000];
-
-extern float accountcampaignhighscore[10];
-extern float accountcampaignfasttime[10];
-extern float accountcampaignscore[10];
-extern float accountcampaigntime[10];
-
 extern bool gamestarted;
 
 extern bool showdamagebar;
@@ -181,6 +163,13 @@ extern OPENAL_SAMPLE       *samp[100];
 extern int channels[100];
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
+void Game::flash() { // shouldn't be that way, these should be attributes and Person class should not change rendering.
+       flashr=1;
+       flashg=0;
+       flashb=0;
+       flashamount=1;
+       flashdelay=1;
+}
 /*********************> DrawGLScene() <*****/
 long long Game::MD5_string (char *string){
        char temp[256]="";
@@ -567,29 +556,6 @@ int Game::DrawGLScene(StereoSide side)
                }
                glPopMatrix();
 
-               //if(cellophane){
-               /*glEnable(GL_CULL_FACE);
-               glCullFace(GL_FRONT);
-               glDepthMask(1);
-               for(k=0;k<numplayers;k++){
-               glEnable(GL_BLEND);
-               glEnable(GL_LIGHTING);
-               terrainlight=terrain.getLighting(player[k].coords.x,player[k].coords.z);
-               distance=findDistancefast(&viewer,&player[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>0){
-               checkpoint=DoRotation(player[k].skeleton.joints[abs(Random()%player[k].skeleton.num_joints)].position,0,player[k].rotation,0)*player[k].scale+player[k].coords;
-               checkpoint.y+=1;
-               if(checkcollide(viewer,checkpoint)){
-               player[k].occluded+=1;
-               }
-               else player[k].occluded=0;
-               if(player[k].occluded<25)player[k].DrawSkeleton();
-               }
-               }*/
-
                glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
                glEnable(GL_CULL_FACE);
                glCullFace(GL_FRONT);
@@ -752,22 +718,22 @@ int Game::DrawGLScene(StereoSide side)
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==4){
-                                               sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",KeyToChar(forwardkey),KeyToChar(leftkey),KeyToChar(backkey),KeyToChar(rightkey));
+                                               sprintf (string, "Try using the %s, %s, %s and %s keys to move around.",Input::keyToChar(forwardkey),Input::keyToChar(leftkey),Input::keyToChar(backkey),Input::keyToChar(rightkey));
                                                sprintf (string2, "All movement is relative to the camera.");
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==5){
-                                               sprintf (string, "Please press %s to jump.",KeyToChar(jumpkey));
+                                               sprintf (string, "Please press %s to jump.",Input::keyToChar(jumpkey));
                                                sprintf (string2, "You can hold it longer to jump higher.");
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==6){
-                                               sprintf (string, "You can press %s to crouch.",KeyToChar(crouchkey));
+                                               sprintf (string, "You can press %s to crouch.",Input::keyToChar(crouchkey));
                                                sprintf (string2, "You can jump higher from a crouching position.");
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==7){
-                                               sprintf (string, "While running, you can press %s to roll.",KeyToChar(crouchkey));
+                                               sprintf (string, "While running, you can press %s to roll.",Input::keyToChar(crouchkey));
                                                sprintf (string2, " ");
                                                sprintf (string3, " ");
                                        }
@@ -787,12 +753,12 @@ int Game::DrawGLScene(StereoSide side)
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==11){
-                                               sprintf (string, "When you jump at a wall, you can hold %s again",KeyToChar(jumpkey));
+                                               sprintf (string, "When you jump at a wall, you can hold %s again",Input::keyToChar(jumpkey));
                                                sprintf (string2, "during impact to perform a walljump.");
                                                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.",KeyToChar(jumpkey));
+                                               sprintf (string, "While in the air, you can press crouch to flip.",Input::keyToChar(jumpkey));
                                                sprintf (string2, "Walljumps and flips confuse enemies and give you more control.");
                                                sprintf (string3, " ");
                                        }
@@ -807,8 +773,8 @@ int Game::DrawGLScene(StereoSide side)
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==15){
-                                               if(attackkey==MAC_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.",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, " ");
                                        }
@@ -834,9 +800,9 @@ int Game::DrawGLScene(StereoSide side)
                                        }
                                        if(tutorialstage==20){
                                                sprintf (string, "Your most powerful individual attack is the rabbit kick.");
-                                               if(attackkey==MAC_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", KeyToChar(attackkey));
-                                               sprintf (string3, "the jump key (%s) to attack.",KeyToChar(jumpkey));
+                                               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.");
@@ -856,8 +822,8 @@ int Game::DrawGLScene(StereoSide side)
                                        }
                                        if(tutorialstage==24){
                                                sprintf (string, "You can tackle enemies by running at them animal-style");
-                                               if(attackkey==MAC_MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).",KeyToChar(jumpkey));
-                                               else sprintf (string2, "and pressing jump (%s) or attack(%s).",KeyToChar(jumpkey),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){
@@ -878,7 +844,7 @@ int Game::DrawGLScene(StereoSide side)
                                        if(tutorialstage==28){
                                                sprintf (string, "If you attack, you will notice that the enemy now sometimes");
                                                sprintf (string2, "catches your attack and uses it against you. Hold");
-                                               sprintf (string3, "crouch (%s) after attacking to escape from reversals.",KeyToChar(crouchkey));
+                                               sprintf (string3, "crouch (%s) after attacking to escape from reversals.",Input::keyToChar(crouchkey));
                                        }
                                        if(tutorialstage==29){
                                                sprintf (string, "Try escaping from two more reversals in a row.");
@@ -891,7 +857,7 @@ int Game::DrawGLScene(StereoSide side)
                                                sprintf (string3, " ");
                                        }
                                        if(tutorialstage==31){
-                                               sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",KeyToChar(crouchkey));
+                                               sprintf (string, "To reverse an attack, you must tap crouch (%s) during the",Input::keyToChar(crouchkey));
                                                sprintf (string2, "enemy's attack. You must also be close to the enemy;");
                                                sprintf (string3, "this is especially important against armed opponents.");
                                        }
@@ -937,11 +903,11 @@ int Game::DrawGLScene(StereoSide side)
                                        }
                                        if(tutorialstage==40){
                                                sprintf (string, "Stand, roll or handspring over the knife");
-                                               sprintf (string2, "while pressing %s to pick it up.",KeyToChar(throwkey));
+                                               sprintf (string2, "while pressing %s to pick it up.",Input::keyToChar(throwkey));
                                                sprintf (string3, "You can crouch and press the same key to drop it again.");
                                        }
                                        if(tutorialstage==41){
-                                               sprintf (string, "You can equip and unequip weapons using the %s key.",KeyToChar(drawkey));
+                                               sprintf (string, "You can equip and unequip weapons using the %s key.",Input::keyToChar(drawkey));
                                                sprintf (string2, "Sometimes it is best to keep them unequipped to");
                                                sprintf (string3, "prevent enemies from taking them. ");
                                        }
@@ -981,7 +947,7 @@ int Game::DrawGLScene(StereoSide side)
                                                sprintf (string3, "spin smash is slower and more powerful.");
                                        }
                                        if(tutorialstage==49){
-                                               sprintf (string, "When facing an enemy, you can throw the knife with %s.",KeyToChar(throwkey));
+                                               sprintf (string, "When facing an enemy, you can throw the knife with %s.",Input::keyToChar(throwkey));
                                                sprintf (string2, "It is possible to throw the knife while flipping,");
                                                sprintf (string3, "but it is very inaccurate.");
                                        }
@@ -1005,7 +971,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.",KeyToChar(jumpkey));
+                                       sprintf (string, "Press 'tab' to skip to the next item.",Input::keyToChar(jumpkey));
                                        sprintf (string2, "Press escape at any time to");
                                        sprintf (string3, "pause or exit the tutorial.");
 
@@ -1235,8 +1201,8 @@ int Game::DrawGLScene(StereoSide side)
 
                                if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){
                                        if(campaign){
-                                               if(!scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]+(int)bonustotal);//(int)bonustotal);
-                                               if(scoreadded)sprintf (string, "Score: %d", (int)accountcampaignscore[accountactive]);//(int)bonustotal);
+                                               if(!scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);//(int)bonustotal);
+                                               if(scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());//(int)bonustotal);
                                        }
                                        if(!campaign)sprintf (string, "Score: %d", (int)bonustotal);
                                        glColor4f(0,0,0,1);
@@ -2378,7 +2344,7 @@ int Game::DrawGLScene(StereoSide side)
                        if(mainmenu==5){
                                ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
                                //campaignnumlevels=0;
-                               //accountcampaignchoicesmade[accountactive]=0;
+                               //accountactive->getCampaignChoicesMade()=0;
                                ipstream.ignore(256,':');
                                ipstream >> campaignnumlevels;
                                for(i=0;i<campaignnumlevels;i++){
@@ -2417,16 +2383,16 @@ int Game::DrawGLScene(StereoSide side)
 
                                levelorder[0]=0;
                                levelvisible[0]=1;
-                               if(accountcampaignchoicesmade[accountactive])
-                                       for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
-                                               levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
+                               if(accountactive->getCampaignChoicesMade())
+                                       for(i=0;i<accountactive->getCampaignChoicesMade();i++){
+                                               levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
                                                levelvisible[levelorder[i+1]]=1;
                                        }
                                        int whichlevelstart;
-                                       whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
+                                       whichlevelstart=accountactive->getCampaignChoicesMade()-1;
                                        if(whichlevelstart<0){
-                                               accountcampaignscore[accountactive]=0;
-                                               accountcampaignfasttime[accountactive]=0;
+                                               accountactive->setCampaignScore(0);
+                                               accountactive->resetFasttime();
                                                campaignchoicenum=1;
                                                campaignchoicewhich[0]=0;
                                        }
@@ -2434,8 +2400,7 @@ int Game::DrawGLScene(StereoSide side)
                                        {
                                                campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
                                                if(campaignchoicenum==0){
-                                                       if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
-                                                       if(accountcampaignfasttime[accountactive]==0||accountcampaigntime[accountactive]<accountcampaignfasttime[accountactive])accountcampaignfasttime[accountactive]=accountcampaigntime[accountactive];              
+                                                       //if(accountactive->getCampaignFasttime()==0||accountcampaigntime[accountactive]<accountactive->getCampaignFasttime())accountactive->getCampaignFasttime()=accountcampaigntime[accountactive];          
                                                }
                                                if(campaignchoicenum)
                                                        for(i=0;i<campaignchoicenum;i++){
@@ -2650,7 +2615,7 @@ int Game::DrawGLScene(StereoSide side)
 
                        if(mainmenu==4){                        
                                nummenuitems=10;
-                               if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",KeyToChar(forwardkey));
+                               if(keyselect!=0)sprintf (menustring[0], "Forwards: %s",Input::keyToChar(forwardkey));
                                else sprintf (menustring[0], "Forwards: _");
                                startx[0]=10;
                                starty[0]=400;
@@ -2659,7 +2624,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[0]=0;
                                movey[0]=0;
 
-                               if(keyselect!=1)sprintf (menustring[1], "Back: %s",KeyToChar(backkey));
+                               if(keyselect!=1)sprintf (menustring[1], "Back: %s",Input::keyToChar(backkey));
                                else sprintf (menustring[1], "Back: _");
                                startx[1]=10+40;
                                starty[1]=360;
@@ -2668,7 +2633,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[1]=0;
                                movey[1]=0;
 
-                               if(keyselect!=2)sprintf (menustring[2], "Left: %s",KeyToChar(leftkey));
+                               if(keyselect!=2)sprintf (menustring[2], "Left: %s",Input::keyToChar(leftkey));
                                else sprintf (menustring[2], "Left: _");
                                startx[2]=10+40;
                                starty[2]=320;
@@ -2677,7 +2642,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[2]=0;
                                movey[2]=0;
 
-                               if(keyselect!=3)sprintf (menustring[3], "Right: %s",KeyToChar(rightkey));
+                               if(keyselect!=3)sprintf (menustring[3], "Right: %s",Input::keyToChar(rightkey));
                                else sprintf (menustring[3], "Right: _");
                                startx[3]=10+30;
                                starty[3]=280;
@@ -2686,7 +2651,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[3]=0;
                                movey[3]=0;
 
-                               if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",KeyToChar(crouchkey));
+                               if(keyselect!=4)sprintf (menustring[4], "Crouch: %s",Input::keyToChar(crouchkey));
                                else sprintf (menustring[4], "Crouch: _");
                                startx[4]=10+20;
                                starty[4]=240;
@@ -2695,7 +2660,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[4]=0;
                                movey[4]=0;
 
-                               if(keyselect!=5)sprintf (menustring[5], "Jump: %s",KeyToChar(jumpkey));
+                               if(keyselect!=5)sprintf (menustring[5], "Jump: %s",Input::keyToChar(jumpkey));
                                else sprintf (menustring[5], "Jump: _");
                                startx[5]=10+40;
                                starty[5]=200;
@@ -2704,7 +2669,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[5]=0;
                                movey[5]=0;
 
-                               if(keyselect!=6)sprintf (menustring[6], "Draw: %s",KeyToChar(drawkey));
+                               if(keyselect!=6)sprintf (menustring[6], "Draw: %s",Input::keyToChar(drawkey));
                                else sprintf (menustring[6], "Draw: _");
                                startx[6]=10+40;
                                starty[6]=160;
@@ -2713,7 +2678,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[6]=0;
                                movey[6]=0;
 
-                               if(keyselect!=7)sprintf (menustring[7], "Throw: %s",KeyToChar(throwkey));
+                               if(keyselect!=7)sprintf (menustring[7], "Throw: %s",Input::keyToChar(throwkey));
                                else sprintf (menustring[7], "Throw: _");
                                startx[7]=10+30;
                                starty[7]=120;
@@ -2722,7 +2687,7 @@ int Game::DrawGLScene(StereoSide side)
                                movex[7]=0;
                                movey[7]=0;
 
-                               if(keyselect!=8)sprintf (menustring[8], "Attack: %s",KeyToChar(attackkey));
+                               if(keyselect!=8)sprintf (menustring[8], "Attack: %s",Input::keyToChar(attackkey));
                                else sprintf (menustring[8], "Attack: _");
                                startx[8]=10+20;
                                starty[8]=80;
@@ -2742,9 +2707,9 @@ int Game::DrawGLScene(StereoSide side)
                                movey[9]=0;
                        }
                        if(mainmenu==5){                        
-                               nummenuitems=7+accountcampaignchoicesmade[accountactive]+campaignchoicenum;
+                               nummenuitems=7+accountactive->getCampaignChoicesMade()+campaignchoicenum;
 
-                               sprintf (menustring[0], "%s",accountname[accountactive]);
+                               sprintf (menustring[0], "%s",accountactive->getName());
                                startx[0]=5;
                                starty[0]=400;
                                endx[0]=startx[0]+strlen(menustring[0])*10;
@@ -2802,8 +2767,8 @@ int Game::DrawGLScene(StereoSide side)
                                movex[6]=0;
                                movey[6]=0;
 
-                               if(accountcampaignchoicesmade[accountactive])
-                                       for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
+                               if(accountactive->getCampaignChoicesMade())
+                                       for(i=0;i<accountactive->getCampaignChoicesMade();i++){
                                                sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
                                                startx[7+i]=30+120+campaignlocationx[levelorder[i]]*400/512;
                                                starty[7+i]=30+30+(512-campaignlocationy[levelorder[i]])*400/512;
@@ -2814,10 +2779,10 @@ int Game::DrawGLScene(StereoSide side)
                                        }
 
                                        if(campaignchoicenum>0)
-                                               for(i=accountcampaignchoicesmade[accountactive];i<accountcampaignchoicesmade[accountactive]+campaignchoicenum;i++){
+                                               for(i=accountactive->getCampaignChoicesMade();i<accountactive->getCampaignChoicesMade()+campaignchoicenum;i++){
                                                        sprintf (menustring[7+i], "%s", campaigndescription[levelorder[i]]);
-                                                       startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]]*400/512;
-                                                       starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountcampaignchoicesmade[accountactive])]])*400/512;
+                                                       startx[7+i]=30+120+campaignlocationx[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]]*400/512;
+                                                       starty[7+i]=30+30+(512-campaignlocationy[campaignchoicewhich[i-(accountactive->getCampaignChoicesMade())]])*400/512;
                                                        endx[7+i]=startx[7+i]+10;
                                                        endy[7+i]=starty[7+i]+10;
                                                        movex[7+i]=0;
@@ -2917,12 +2882,12 @@ int Game::DrawGLScene(StereoSide side)
                                movey[5]=0;
                        }
 
-                       if(mainmenu==7){                        
-                               nummenuitems=numaccounts+2;
+                       if(mainmenu==7){        
+                               nummenuitems=Account::getNbAccounts()+2;
 
                                int num;
 
-                               if(numaccounts<8)
+                               if(Account::getNbAccounts()<8)
                                        sprintf (menustring[0], "New User");
                                else
                                        sprintf (menustring[0], "No More Users");
@@ -2933,30 +2898,30 @@ int Game::DrawGLScene(StereoSide side)
                                movex[0]=0;
                                movey[0]=0;
 
-                               if(entername)startx[0]+=10;
+                               if(entername)
+                                       startx[0]+=10;
 
 
                                num=1;
-                               if(numaccounts)
-                                       for(i=0;i<numaccounts;i++){
-                                               sprintf (menustring[num], "%s",accountname[i]);
-                                               startx[num]=10;
-                                               starty[num]=360-20-20*num;
-                                               endx[num]=startx[num]+strlen(menustring[num])*10;
-                                               endy[num]=starty[num]+20;
-                                               movex[num]=0;
-                                               movey[num]=0;
-
-                                               num++;
-                                       }
-
-                                       sprintf (menustring[num], "Back");
+                               for(i=0;i<Account::getNbAccounts();i++){
+                                       sprintf (menustring[num], "%s",Account::get(i)->getName());
                                        startx[num]=10;
+                                       starty[num]=360-20-20*num;
                                        endx[num]=startx[num]+strlen(menustring[num])*10;
-                                       starty[num]=10;
                                        endy[num]=starty[num]+20;
                                        movex[num]=0;
                                        movey[num]=0;
+
+                                       num++;
+                               }
+
+                               sprintf (menustring[num], "Back");
+                               startx[num]=10;
+                               endx[num]=startx[num]+strlen(menustring[num])*10;
+                               starty[num]=10;
+                               endy[num]=starty[num]+20;
+                               movex[num]=0;
+                               movey[num]=0;
                        }
                        if(mainmenu==8){                        
                                nummenuitems=3;
@@ -2998,14 +2963,14 @@ int Game::DrawGLScene(StereoSide side)
                                        strcpy(menustring[j],temp);
                                        for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
                                        menustring[j][17]='\0';
-                                       sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
+                                       sprintf (temp, "%d",(int)accountactive->getHighScore(j));
                                        strcat(menustring[j],temp);
                                        for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
                                        menustring[j][32]='\0';
-                                       sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
+                                       sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
                                        strcat(menustring[j],temp);
-                                       if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
-                                       sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
+                                       if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
+                                       sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
                                        strcat(menustring[j],temp);
 
                                        startx[j]=10;
@@ -3045,14 +3010,14 @@ int Game::DrawGLScene(StereoSide side)
                                        strcpy(menustring[j],temp);
                                        for(i=0;i<17;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
                                        menustring[j][17]='\0';
-                                       sprintf (temp, "%d",(int)accounthighscore[accountactive][j]);
+                                       sprintf (temp, "%d",(int)accountactive->getHighScore(j));
                                        strcat(menustring[j],temp);
                                        for(i=18;i<32;i++)if(menustring[j][i]=='\0')menustring[j][i]=' ';
                                        menustring[j][32]='\0';
-                                       sprintf (temp, "%d:",(int)(((int)accountfasttime[accountactive][j]-(int)(accountfasttime[accountactive][j])%60)/60));
+                                       sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(j)-(int)(accountactive->getFastTime(j))%60)/60));
                                        strcat(menustring[j],temp);
-                                       if((int)(accountfasttime[accountactive][j])%60<10)strcat(menustring[j],"0");
-                                       sprintf (temp, "%d",(int)(accountfasttime[accountactive][j])%60);
+                                       if((int)(accountactive->getFastTime(j))%60<10)strcat(menustring[j],"0");
+                                       sprintf (temp, "%d",(int)(accountactive->getFastTime(j))%60);
                                        strcat(menustring[j],temp);
 
                                        startx[j]=10;
@@ -3121,7 +3086,7 @@ int Game::DrawGLScene(StereoSide side)
                                strcpy(menustring[4],temp);
                                for(i=0;i<20;i++)if(menustring[4][i]=='\0')menustring[4][i]=' ';
                                menustring[4][20]='\0';
-                               sprintf (temp, "%d",(int)accountcampaignscore[accountactive]);
+                               sprintf (temp, "%d",(int)accountactive->getCampaignScore());
                                strcat(menustring[4],temp);
                                startx[4]=190;
                                endx[4]=startx[4]+strlen(menustring[4])*10;
@@ -3149,7 +3114,7 @@ int Game::DrawGLScene(StereoSide side)
                                strcpy(menustring[5],temp);
                                for(i=0;i<20;i++)if(menustring[5][i]=='\0')menustring[5][i]=' ';
                                menustring[5][20]='\0';
-                               sprintf (temp, "%d",(int)accountcampaignhighscore[accountactive]);
+                               sprintf (temp, "%d",(int)accountactive->getCampaignHighScore());
                                strcat(menustring[5],temp);
                                startx[5]=190;
                                endx[5]=startx[5]+strlen(menustring[5])*10;
@@ -3163,7 +3128,7 @@ int Game::DrawGLScene(StereoSide side)
                                strcpy(menustring[7],temp);
                                for(i=0;i<20;i++)if(menustring[7][i]=='\0')menustring[7][i]=' ';
                                menustring[7][20]='\0';
-                               sprintf (temp, "%d",(int)accountcampaignfasttime[accountactive]);
+                               sprintf (temp, "%d",(int)accountactive->getCampaignFasttime());
                                strcat(menustring[7],temp);
                                startx[7]=200;
                                endx[7]=startx[7]+strlen(menustring[7])*10;
@@ -3593,34 +3558,25 @@ int Game::DrawGLScene(StereoSide side)
                                                                                if(mainmenu!=5||j<6)
                                                                                {
                                                                                        glColor4f(1,0,0,1);
-                                                                                       if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
-                                                                                       if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,1);
+                                                                                       if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
+                                                                                       if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,1);
                                                                                        //if(1-((float)i)/10-(1-selectedlong[j])>0){
                                                                                        glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
                                                                                        glPushMatrix();
-                                                                                               if(mainmenu!=7||j!=0||!entername)text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
+                                                                                               if(mainmenu!=7||j!=0||!entername)
+                                                                                                       text.glPrint(startx[j],starty[j],menustring[j],0,1,640,480);
                                                                                                else
                                                                                                {
                                                                                                        if(displayblink){
                                                                                                                sprintf (string, "_");
                                                                                                                text.glPrint(startx[j]+(float)(displayselected)*10,starty[j],string,0,1,640,480);
                                                                                                        }
-                                                                                                       k=0;
-                                                                                                       for(l=0;l<displaychars[k];l++){
-                                                                                                               if(l<displaychars[k]){
-                                                                                                                       sprintf (string, "%c",displaytext[k][l]);
-                                                                                                                       text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
-                                                                                                               }
+                                                                                                       for(l=0;l<displaychars[0];l++){
+                                                                                                               sprintf (string, "%c",displaytext[0][l]);
+                                                                                                               text.glPrint(startx[j]+l*10,starty[j],string,0,1,640,480);
                                                                                                        }
                                                                                                }
                                                                                        glPopMatrix();
-                                                                                       /*}
-                                                                                       else{
-                                                                                       glPushMatrix();
-                                                                                       sprintf (string, "Hooo!");
-                                                                                       text.glPrint(startx[0],starty[0],string,0,1,640,480);
-                                                                                       glPopMatrix();
-                                                                                       }*/
                                                                                        glEnable(GL_BLEND);
                                                                                        glBlendFunc(GL_SRC_ALPHA,GL_ONE);
                                                                                        for(i=0;i<15;i++)
@@ -3628,13 +3584,13 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                if(1-((float)i)/15-(1-selectedlong[j])>0)
                                                                                                {
                                                                                                        glColor4f(1,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
-                                                                                                       if(mainmenu==9&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
-                                                                                                       if(mainmenu==11&&j>accountprogress[accountactive]&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+                                                                                                       if(mainmenu==9&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
+                                                                                                       if(mainmenu==11&&j>accountactive->getProgress()&&j<numchallengelevels)glColor4f(0.5,0,0,(1-((float)i)/10-(1-selectedlong[j]))*.25);
                                                                                                        if(mainmenu==3)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4-((/*1*/+((float)i)/70)*strlen(menustring[j]))*3,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==4)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==5)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==6)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
-                                                                                                       if(mainmenu==7&&(j!=0||!entername))text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
+                                                                                                       if(mainmenu==7&&(j!=0||!entername)) text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4,starty[j]+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==8)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==9)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
                                                                                                        if(mainmenu==11)text.glPrint(startx[j]-((float)i)+offsetx[j]*((float)i)/4/*-((((float)i)/70)*strlen(menustring[j]))*3*/,starty[j]/*-i*1/2*/+offsety[j]*((float)i)/4,menustring[j],0,1+((float)i)/70,640,480);
@@ -3694,9 +3650,9 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                                        //float linestartx,lineendx,linestarty,lineendy,offsetx,offsety;
                                                                                                                        linestart.x=(startx[j]+endx[j])/2;
                                                                                                                        linestart.y=(starty[j]+endy[j])/2;
-                                                                                                                       if(j>=6+accountcampaignchoicesmade[accountactive]){
-                                                                                                                               linestart.x=(startx[6+accountcampaignchoicesmade[accountactive]]+endx[6+accountcampaignchoicesmade[accountactive]])/2;
-                                                                                                                               linestart.y=(starty[6+accountcampaignchoicesmade[accountactive]]+endy[6+accountcampaignchoicesmade[accountactive]])/2;
+                                                                                                                       if(j>=6+accountactive->getCampaignChoicesMade()){
+                                                                                                                               linestart.x=(startx[6+accountactive->getCampaignChoicesMade()]+endx[6+accountactive->getCampaignChoicesMade()])/2;
+                                                                                                                               linestart.y=(starty[6+accountactive->getCampaignChoicesMade()]+endy[6+accountactive->getCampaignChoicesMade()])/2;
                                                                                                                        }
                                                                                                                        lineend.x=(startx[j+1]+endx[j+1])/2;
                                                                                                                        lineend.y=(starty[j+1]+endy[j+1])/2;
@@ -3707,12 +3663,12 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                                        Normalise(&offset);
                                                                                                                        glDisable(GL_TEXTURE_2D);                                                       
 
-                                                                                                                       if(j<6+accountcampaignchoicesmade[accountactive]){
+                                                                                                                       if(j<6+accountactive->getCampaignChoicesMade()){
                                                                                                                                glColor4f(0.5,0,0,1);
                                                                                                                                startsize=.5;
                                                                                                                                endsize=.5;
                                                                                                                        }
-                                                                                                                       if(j>=6+accountcampaignchoicesmade[accountactive]){
+                                                                                                                       if(j>=6+accountactive->getCampaignChoicesMade()){
                                                                                                                                glColor4f(1,0,0,1);
                                                                                                                                endsize=1;
                                                                                                                                startsize=.5;
@@ -3721,7 +3677,7 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                                        linestart+=fac*4*startsize;
                                                                                                                        lineend-=fac*4*endsize;
 
-                                                                                                                       if(!(j>7+accountcampaignchoicesmade[accountactive]+campaignchoicenum)){
+                                                                                                                       if(!(j>7+accountactive->getCampaignChoicesMade()+campaignchoicenum)){
                                                                                                                                glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
                                                                                                                                glPushMatrix();
                                                                                                                                        glBegin(GL_QUADS);
@@ -3744,8 +3700,8 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                                else glBindTexture( GL_TEXTURE_2D, Mapcircletexture);
                                                                                                                glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
                                                                                                                glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
-                                                                                                               if(j-7<accountcampaignchoicesmade[accountactive])glColor4f(0.5,0,0,1);
-                                                                                                               if(j-7>=accountcampaignchoicesmade[accountactive])glColor4f(1,0,0,1);
+                                                                                                               if(j-7<accountactive->getCampaignChoicesMade())glColor4f(0.5,0,0,1);
+                                                                                                               if(j-7>=accountactive->getCampaignChoicesMade())glColor4f(1,0,0,1);
                                                                                                                if(j==6)glColor4f(1,1,1,1);
                                                                                                                XYZ midpoint;
                                                                                                                float itemsize;
@@ -3753,8 +3709,8 @@ int Game::DrawGLScene(StereoSide side)
                                                                                                                midpoint=0;
                                                                                                                midpoint.x=(startx[j]+endx[j])/2;
                                                                                                                midpoint.y=(starty[j]+endy[j])/2;
-                                                                                                               if(j>6&&(j-7<accountcampaignchoicesmade[accountactive]))itemsize*=.5;
-                                                                                                               if(!(j-7>accountcampaignchoicesmade[accountactive]+campaignchoicenum))
+                                                                                                               if(j>6&&(j-7<accountactive->getCampaignChoicesMade()))itemsize*=.5;
+                                                                                                               if(!(j-7>accountactive->getCampaignChoicesMade()+campaignchoicenum))
                                                                                                                {
                                                                                                                        glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
                                                                                                                        glPushMatrix();
@@ -3799,7 +3755,7 @@ int Game::DrawGLScene(StereoSide side)
                                                                                        glPopMatrix();
                                                                                        glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
 
-                                                                                       if(j-7>=accountcampaignchoicesmade[accountactive]){
+                                                                                       if(j-7>=accountactive->getCampaignChoicesMade()){
                                                                                                //glColor4f(0,0,0,1);
                                                                                                //text.glPrintOutline(startx[j]+10-1.5,starty[j]-4-1.5,menustring[j],0,0.6*1.25,640,480);
                                                                                                //glColor4f(1,0,0,1);
@@ -3873,27 +3829,29 @@ int Game::DrawGLScene(StereoSide side)
                                                                                        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
                                                                                        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
                                                                                glPopMatrix();
-                                                                               glPushMatrix();
-                                                                                       glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
-                                                                                       glScalef((float)screenwidth/64,(float)screenwidth/64,1);
-                                                                                       glTranslatef(1,-1,0);
-                                                                                       glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-                                                                                       glColor4f(1,1,1,1);
-                                                                                       glBindTexture( GL_TEXTURE_2D, cursortexture);
+                                                                               if(!waiting) { // hide the cursor while waiting for a key
                                                                                        glPushMatrix();
-                                                                                               //glScalef(.25,.25,.25);
-                                                                                               glBegin(GL_QUADS);
-                                                                                               glTexCoord2f(0,0);
-                                                                                               glVertex3f(-1,          -1,      0.0f);
-                                                                                               glTexCoord2f(1,0);
-                                                                                               glVertex3f(1,   -1,      0.0f);
-                                                                                               glTexCoord2f(1,1);
-                                                                                               glVertex3f(1,   1, 0.0f);
-                                                                                               glTexCoord2f(0,1);
-                                                                                               glVertex3f(-1,  1, 0.0f);
-                                                                                               glEnd();
+                                                                                               glTranslatef(mousecoordh-screenwidth/2,mousecoordv*-1+screenheight/2,0);
+                                                                                               glScalef((float)screenwidth/64,(float)screenwidth/64,1);
+                                                                                               glTranslatef(1,-1,0);
+                                                                                               glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+                                                                                               glColor4f(1,1,1,1);
+                                                                                               glBindTexture( GL_TEXTURE_2D, cursortexture);
+                                                                                               glPushMatrix();
+                                                                                                       //glScalef(.25,.25,.25);
+                                                                                                       glBegin(GL_QUADS);
+                                                                                                       glTexCoord2f(0,0);
+                                                                                                       glVertex3f(-1,          -1,      0.0f);
+                                                                                                       glTexCoord2f(1,0);
+                                                                                                       glVertex3f(1,   -1,      0.0f);
+                                                                                                       glTexCoord2f(1,1);
+                                                                                                       glVertex3f(1,   1, 0.0f);
+                                                                                                       glTexCoord2f(0,1);
+                                                                                                       glVertex3f(-1,  1, 0.0f);
+                                                                                                       glEnd();
+                                                                                               glPopMatrix();
                                                                                        glPopMatrix();
-                                                                               glPopMatrix();
+                                                                               }
                                                                        glPopMatrix();
                                                                        glMatrixMode(GL_PROJECTION);                                            // Select The Projection Matrix
                                                                glPopMatrix();
@@ -3944,7 +3902,6 @@ int Game::DrawGLScene(StereoSide side)
                multiplier=0;
        }
 
-
        //glFlush();
        if ( side == stereoRight || side == stereoCenter ) {
                if(drawmode!=motionblurmode||mainmenu){
index 47ceb900ff29b8add71b672243465a4a60723e62..ea0d7366be409a3f4631fce30776b438c60a394f 100644 (file)
@@ -78,16 +78,6 @@ extern float slomospeed;
 extern char mapname[256];
 extern bool gamestarted;
 
-extern int numaccounts;
-extern int accountactive;
-extern int accountdifficulty[10];
-extern int accountprogress[10];
-extern float accountpoints[10];
-extern float accounthighscore[10][50];
-extern float accountfasttime[10][50];
-extern bool accountunlocked[10][60];
-extern char accountname[10][256];
-
 extern int numdialogues;
 extern int numdialogueboxes[20];
 extern int dialoguetype[20];
@@ -131,59 +121,11 @@ void Game::Dispose()
        LOGFUNC;
 
        if(endgame==2){
-               accountcampaignchoicesmade[accountactive]=0;
-               accountcampaignscore[accountactive]=0;
-               accountcampaigntime[accountactive]=0;
+               accountactive->endGame();
                endgame=0;
        }
 
-
-       sprintf (mapname, ":Data:Users");
-
-       FILE                    *tfile;
-       tfile=fopen( ConvertFileName(mapname), "wb" );
-       if (tfile)
-       {
-               fpackf(tfile, "Bi", numaccounts);
-               fpackf(tfile, "Bi", accountactive);
-               if(numaccounts>0)
-               {
-                       for(i=0;i<numaccounts;i++)
-                       {
-                               fpackf(tfile, "Bf", accountcampaigntime[i]);
-                               fpackf(tfile, "Bf", accountcampaignscore[i]);
-                               fpackf(tfile, "Bf", accountcampaignfasttime[i]);
-                               fpackf(tfile, "Bf", accountcampaignhighscore[i]);
-                               fpackf(tfile, "Bi", accountdifficulty[i]);
-                               fpackf(tfile, "Bi", accountprogress[i]);
-                               fpackf(tfile, "Bi", accountcampaignchoicesmade[i]);
-                               for(j=0;j<accountcampaignchoicesmade[i];j++)
-                               {
-                                       fpackf(tfile, "Bi", accountcampaignchoices[i][j]);
-                               }
-                               fpackf(tfile, "Bf", accountpoints[i]);
-                               for(j=0;j<50;j++)
-                               {
-                                       fpackf(tfile, "Bf", accounthighscore[i][j]);
-                                       fpackf(tfile, "Bf", accountfasttime[i][j]);
-                               }
-                               for(j=0;j<60;j++)
-                               {
-                                       fpackf(tfile, "Bb",  accountunlocked[i][j]);
-                               }
-                               fpackf(tfile, "Bi",  strlen(accountname[i]));
-                               if(strlen(accountname[i])>0)
-                               {
-                                       for(j=0;j<(int)strlen(accountname[i]);j++)
-                                       {
-                                               fpackf(tfile, "Bb",  accountname[i][j]);
-                                       }
-                               }
-                       }
-               }
-
-               fclose(tfile);
-       }
+       Account::saveFile(":Data:Users", accountactive);
 
        TexIter it = textures.begin();
        for (; it != textures.end(); ++it)
@@ -996,73 +938,7 @@ void Game::InitGame()
 
        numchallengelevels=14;
 
-       /*char tempstring[256];
-       sprintf (tempstring, "%s", registrationname);
-       long num1;
-       long num2;
-       long num3;
-       long num4;
-       long long longnum;
-       longnum = MD5_string ( tempstring);
-       //longnum = 1111111111111111;
-       num1 = longnum/100000000;
-       num2 = longnum%100000000;
-       sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
-       */
-
-       FILE                    *tfile;
-
-       accountactive=-1;
-
-       sprintf (mapname, ":Data:Users");
-       tfile=fopen( ConvertFileName(mapname), "rb" );
-       if(tfile)
-       {
-               funpackf(tfile, "Bi", &numaccounts);
-               funpackf(tfile, "Bi", &accountactive);
-               if(numaccounts>0)
-               {
-                       for(i=0;i<numaccounts;i++)
-                       {
-                               funpackf(tfile, "Bf", &accountcampaigntime[i]);
-                               funpackf(tfile, "Bf", &accountcampaignscore[i]);
-                               funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
-                               funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
-                               funpackf(tfile, "Bi", &accountdifficulty[i]);
-                               funpackf(tfile, "Bi", &accountprogress[i]);
-                               funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
-                               for(j=0;j<accountcampaignchoicesmade[i];j++)
-                               {
-                                       funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
-                                       if (accountcampaignchoices[i][j] >= 10)
-                                       {
-                                               accountcampaignchoices[i][j] = 0;
-                                       }
-                               }
-                               funpackf(tfile, "Bf", &accountpoints[i]);
-                               for(j=0;j<50;j++)
-                               {
-                                       funpackf(tfile, "Bf", &accounthighscore[i][j]);
-                                       funpackf(tfile, "Bf", &accountfasttime[i][j]);
-                               }
-                               for(j=0;j<60;j++)
-                               {
-                                       funpackf(tfile, "Bb",  &accountunlocked[i][j]);
-                               }
-                               int temp;
-                               funpackf(tfile, "Bi",  &temp);
-                               if(temp>0)
-                               {
-                                       for(j=0;j<temp;j++)
-                                       {
-                                               funpackf(tfile, "Bb",  &accountname[i][j]);
-                                       }
-                               }
-                       }
-               }
-
-               fclose(tfile);
-       }
+       accountactive=Account::loadFile(":Data:Users");
 
        tintr=1;
        tintg=1;
@@ -1321,25 +1197,6 @@ void Game::InitGame()
        newdetail=detail;
        newscreenwidth=screenwidth;
        newscreenheight=screenheight;
-
-
-
-       /*
-       float gLoc[3]={0,0,0};
-       float vel[3]={0,0,0};
-       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-       OPENAL_SetVolume(channels[firestartsound], 256);
-       OPENAL_SetPaused(channels[firestartsound], false);
-       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-       flashr=1;
-       flashg=0;
-       flashb=0;
-       flashamount=1;
-       flashdelay=1;
-       */
 }
 
 
@@ -1831,200 +1688,3 @@ void Game::LoadStuff()
        visibleloading=0;
 }
 
-Game::Game()
-{
-       terraintexture = 0;
-       terraintexture2 = 0;
-       terraintexture3 = 0;
-       screentexture = 0;
-       screentexture2 = 0;
-       logotexture = 0;
-       loadscreentexture = 0;
-       Maparrowtexture = 0;
-       Mapboxtexture = 0;
-       Mapcircletexture = 0;
-       cursortexture = 0;
-
-       memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
-
-       nummenuitems = 0;
-
-       memset(startx, 0, sizeof(startx));
-       memset(starty, 0, sizeof(starty));
-       memset(endx, 0, sizeof(endx));
-       memset(endy, 0, sizeof(endy));
-
-       memset(selectedlong, 0, sizeof(selectedlong));
-       memset(offsetx, 0, sizeof(offsetx));
-       memset(offsety, 0, sizeof(offsety));
-       memset(movex, 0, sizeof(movex));
-       memset(movey, 0, sizeof(movey));
-       memset(endy, 0, sizeof(endy));
-
-       transition = 0;
-       anim = 0;
-       selected = 0;
-       loaddistrib = 0;
-       keyselect = 0;
-       indemo = 0;
-
-       won = 0;
-
-       entername = 0;
-
-       memset(menustring, 0, sizeof(menustring));
-       memset(registrationname, 0, sizeof(registrationname));
-       registrationnumber = 0;
-
-       newdetail = 0;
-       newscreenwidth = 0;
-       newscreenheight = 0;
-
-       gameon = 0;
-       deltah = 0,deltav = 0;
-       mousecoordh = 0,mousecoordv = 0;
-       oldmousecoordh = 0,oldmousecoordv = 0;
-       rotation = 0,rotation2 = 0;
-
-//     SkyBox skybox;
-
-       cameramode = 0;
-       cameratogglekeydown = 0;
-       chattogglekeydown = 0;
-       olddrawmode = 0;
-       drawmode = 0;
-       drawmodetogglekeydown = 0;
-       explodetogglekeydown = 0;
-       detailtogglekeydown = 0;
-       firstload = 0;
-       oldbutton = 0;
-
-       leveltime = 0;
-       loadtime = 0;
-
-//     Model hawk;
-
-//     XYZ hawkcoords;
-//     XYZ realhawkcoords;
-
-       hawktexture = 0;
-       hawkrotation = 0;
-       hawkcalldelay = 0;
-/*
-       Model eye;
-       Model iris;
-       Model cornea;
-*/
-       stealthloading = 0;
-
-       campaignnumlevels = 0;
-
-       memset(campaignmapname, 0, sizeof(campaignmapname));
-       memset(campaigndescription, 0, sizeof(campaigndescription));
-       memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
-       memset(campaignnumnext, 0, sizeof(campaignnumnext));
-       memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
-       int campaignchoicesmade;
-       memset(campaignchoices, 0, sizeof(campaignchoices));
-       memset(campaignlocationx, 0, sizeof(campaignlocationx));
-       memset(campaignlocationy, 0, sizeof(campaignlocationy));
-       memset(campaignlocationy, 0, sizeof(campaignlocationy));
-
-       campaignchoicenum = 0;
-
-       memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
-
-       whichchoice = 0;
-
-       numlevelspassed = 0;
-
-       memset(levelorder, 0, sizeof(levelorder));
-       memset(levelvisible, 0, sizeof(levelvisible));
-       memset(levelhighlight, 0, sizeof(levelhighlight));
-
-       minimap = 0;
-
-       musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
-       realthreat = 0;
-
-//     Model rabbit;
-//     XYZ rabbitcoords;
-
-//     XYZ mapcenter;
-       mapradius = 0;
-
-//     Text text;
-       fps = 0;
-
-//     XYZ cameraloc;
-       cameradist = 0;
-
-       envtogglekeydown = 0;
-       slomotogglekeydown = 0;
-       texturesizetogglekeydown = 0;
-       freezetogglekeydown = 0;
-       drawtoggle = 0;
-
-       editorenabled = 0;
-       editortype = 0;
-       editorsize = 0;
-       editorrotation = 0;
-       editorrotation2 = 0;
-
-       brightness = 0;
-
-       quit = 0;
-       tryquit = 0;
-
-//     XYZ pathpoint[30];
-       numpathpoints = 0;
-       memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
-       memset(pathpointconnect, 0, sizeof(pathpointconnect));
-       pathpointselected = 0;
-
-       endgame = 0;
-       scoreadded = 0;
-       numchallengelevels = 0;
-
-       console = 0;
-       archiveselected = 0;
-
-       memset(consoletext, 0, sizeof(consoletext));
-       memset(consolechars, 0, sizeof(consolechars));
-       chatting = 0;
-       memset(displaytext, 0, sizeof(displaytext));
-       memset(displaychars, 0, sizeof(displaychars));
-       memset(displaytime, 0, sizeof(displaytime));
-       displayblinkdelay = 0;
-       displayblink = 0;
-       displayselected = 0;
-       consolekeydown = 0;
-       consoletogglekeydown = 0;
-       consoleblinkdelay = 0;
-       consoleblink = 0;
-       consoleselected = 0;
-       memset(togglekey, 0, sizeof(togglekey));
-       memset(togglekeydelay, 0, sizeof(togglekeydelay));
-       registernow = 0;
-       autocam = 0;
-
-       crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
-       oldattackkey = 0;
-
-       loading = 0;
-       talkdelay = 0;
-
-       numboundaries = 0;
-//     XYZ boundary[360];
-
-       whichlevel = 0;
-       oldenvironment = 0;
-       targetlevel = 0;
-       changedelay = 0;
-
-       memset(musicvolume, 0, sizeof(musicvolume));
-       memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
-       musicselected = 0;
-       change = 0;
-}
-
index 2328eb8f0ce50367d660c7126c2b856466d8ab2a..e5e619a6e95a1a3ca4a223ddbb978d8f7f233231 100644 (file)
@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Game.h"
 #include "openal_wrapper.h"
 #include "Settings.h"
+#include "Input.h"
 
 using namespace std;
 
@@ -39,7 +40,7 @@ extern XYZ viewer;
 extern int environment;
 extern float texscale;
 extern Terrain terrain;
-extern OPENAL_SAMPLE   *samp[100];
+extern OPENAL_SAMPLE *samp[100];
 extern int channels[100];
 extern Sprites sprites;
 extern int kTextureSize;
@@ -82,7 +83,6 @@ extern int netdatanew;
 extern bool loadingstuff;
 extern char mapname[256];
 extern XYZ windvector;
-extern bool buttons[3];
 extern bool debugmode;
 static int music1;
 extern int mainmenu;
@@ -142,7 +142,6 @@ extern float damagetaken;
 extern int maptype;
 extern int editoractive;
 extern int editorpathtype;
-extern bool oldbuttons[3];
 
 extern float hostiletime;
 
@@ -161,16 +160,6 @@ extern int currenthotspot;
 extern int kBitsPerPixel;
 extern int hostile;
 
-extern int numaccounts;
-extern int accountactive;
-extern int accountdifficulty[10];
-extern int accountprogress[10];
-extern float accountpoints[10];
-extern float accounthighscore[10][50];
-extern float accountfasttime[10][50];
-extern bool accountunlocked[10][60];
-extern char accountname[10][256];
-
 extern bool stillloading;
 extern bool winfreeze;
 
@@ -1188,8 +1177,6 @@ static void cmd_dispatch(Game *game, const char *cmd)
     }
 }
 
-
-
 /********************> Tick() <*****/
 extern void ScreenShot(const char * fname);
 void Screenshot        (void)
@@ -1205,192 +1192,7 @@ void Screenshot (void)
        mkdir("Screenshots", S_IRWXU);
        #endif
 
-       ScreenShot(temp/*"Screenshots\\Screenshot.png"*/);
-
-       /*FSSpec                                MAC_file;
-       GraphicsExportComponent QT_exporter;
-       OSErr                           MAC_error_code;
-       CGrafPtr                        MAC_currentPort;
-       GDHandle                        MAC_currentDevice;
-       unsigned char*          MAC_pixels;
-       Rect                            MAC_picture_rectangle;
-       GWorldPtr                       MAC_offscreen_graphics_port;
-
-       static int numscreenshots=0;
-
-       // Make an FSSpec
-       static char buf[256];
-       if(numscreenshots==0){
-       buf[0]=26;
-       buf[1]=':';
-       buf[2]='S';
-       buf[3]='c';
-       buf[4]='r';
-       buf[5]='e';
-       buf[6]='e';
-       buf[7]='n';
-       buf[8]='s';
-       buf[9]='h';
-       buf[10]='o';
-       buf[11]='t';
-       buf[12]='s';
-       buf[13]=':';
-       buf[14]='S';
-       buf[15]='c';
-       buf[16]='r';
-       buf[17]='e';
-       buf[18]='e';
-       buf[19]='n';
-       buf[20]='s';
-       buf[21]='h';
-       buf[22]='o';
-       buf[23]='t';
-       buf[24]='0';
-       buf[25]='0';
-       buf[26]='0';
-       }
-
-       FInfo *fndrInfo;
-       FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
-       while(!FSpGetFInfo (&MAC_file, fndrInfo)){
-       FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file);
-       if(!FSpGetFInfo (&MAC_file, fndrInfo)){
-       numscreenshots++;
-       buf[26]++;
-       if(buf[26]==':'){
-       buf[26]='0';
-       buf[25]++;
-       if(buf[25]==':'){
-       buf[25]='0';
-       buf[24]++;
-       if(buf[24]==':'){
-       buf[24]='9';
-       buf[25]='9';
-       buf[26]='9';
-       }
-       }
-       }
-       }
-       }
-
-
-       // Get the GWorld
-       GWorldPtr                       MAC_gWorld = (CGrafPtr) FrontWindow();
-       //assert(MAC_gWorld != NULL);
-
-       // Allocate memory for loading image
-       MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)];
-       if (MAC_pixels == NULL) {
-       //UTIL_Error("Could not create Texture data.");
-       return;
-       }
-
-       // Get GWorld
-       ::GetGWorld(&MAC_currentPort, &MAC_currentDevice);
-
-       // Make a picture Rectangle
-       MAC_picture_rectangle.left = 0;
-       MAC_picture_rectangle.right = screenwidth;
-       MAC_picture_rectangle.top = 0;
-       MAC_picture_rectangle.bottom = screenheight;
-
-       // Create new offscreen GWorld
-       MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4);
-       if (MAC_error_code)     {
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       delete MAC_pixels;
-       //UTIL_Error("Could not create offscreen GWorld. ");
-       return;
-
-       }
-
-       // Copy OpenGL Context to new GWorld
-       glReadBuffer(GL_FRONT);
-       glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels);
-
-       // Swizzle texture
-       for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) {
-       unsigned char temp = MAC_pixels[byte+0];
-       MAC_pixels[byte+0] = MAC_pixels[byte+3];
-       MAC_pixels[byte+3] = MAC_pixels[byte+2];
-       MAC_pixels[byte+2] = MAC_pixels[byte+1];
-       MAC_pixels[byte+1] = temp;
-       }
-
-       // Flip the image  :(   This could probably be optimized
-       int vert;
-       int src_index;
-       int dst_index;
-       unsigned char temp;
-       for (int horz = 0; horz < screenwidth; ++horz)
-       for (vert = 0; vert < screenheight / 2; ++vert) {
-       src_index = (screenwidth * vert + horz) * 4;
-       dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4;
-
-       temp=MAC_pixels[src_index+0];
-       MAC_pixels[src_index+0]=MAC_pixels[dst_index+0];
-       MAC_pixels[dst_index+0]=temp;
-
-       temp=MAC_pixels[src_index+1];
-       MAC_pixels[src_index+1]=MAC_pixels[dst_index+1];
-       MAC_pixels[dst_index+1]=temp;
-
-       temp=MAC_pixels[src_index+2];
-       MAC_pixels[src_index+2]=MAC_pixels[dst_index+2];
-       MAC_pixels[dst_index+2]=temp;
-
-       temp=MAC_pixels[src_index+3];
-       MAC_pixels[src_index+3]=MAC_pixels[dst_index+3];
-       MAC_pixels[dst_index+3]=temp;
-       }
-
-
-
-       // Export the Gworld
-       MAC_error_code =  OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter);
-       if (MAC_error_code) {
-       //UTIL_Warning("Unable to export screenshot.");
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       ::DisposeGWorld(MAC_offscreen_graphics_port);
-       delete MAC_pixels;
-       return;
-       }
-
-       MAC_error_code =  GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port);
-       if (MAC_error_code) {
-       ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       ::DisposeGWorld(MAC_offscreen_graphics_port);
-       delete MAC_pixels;
-       //UTIL_Warning("Unable to export screenshot.");
-       return;
-       }
-
-       MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file);
-       if (MAC_error_code) {
-       ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       ::DisposeGWorld(MAC_offscreen_graphics_port);
-       delete MAC_pixels;
-       //UTIL_Warning("Unable to export screenshot.");
-       return;
-       }
-
-       MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL);
-       if (MAC_error_code) {
-       ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       ::DisposeGWorld(MAC_offscreen_graphics_port);
-       delete MAC_pixels;
-       //UTIL_Warning("Unable to export screenshot.");
-       return;
-       }
-
-       ::CloseComponent(QT_exporter);
-       ::SetGWorld(MAC_currentPort, MAC_currentDevice);
-       ::DisposeGWorld(MAC_offscreen_graphics_port);
-
-       delete MAC_pixels;*/
+       ScreenShot(temp);
 }
 
 
@@ -1881,7 +1683,7 @@ void      Game::Loadlevel(char *name){
                damagedealt=0;
                damagetaken=0;
 
-               if(accountactive!=-1)difficulty=accountdifficulty[accountactive];
+               if(accountactive)difficulty=accountactive->getDifficulty();
 
                if(difficulty!=2)minimap=1;
                else minimap=0;
@@ -2525,12 +2327,7 @@ void     Game::Loadlevel(char *name){
                        weapons.position[i]=-1000;
                        weapons.tippoint[i]=-1000;
                }
-
-/*             for(i=0;i<32;i++){
-                       //if(i<16||i>20)
-                       OPENAL_StopSound(i);
-               }
-*/
+               
                LOG("Starting background music...");
 
                OPENAL_StopSound(OPENAL_ALL);
@@ -2570,17 +2367,6 @@ void     Game::Loadlevel(char *name){
                oldmusicvolume[2]=0;
                oldmusicvolume[3]=0;
 
-
-               /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
-               LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
-               LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
-               LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
-               LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
-               LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
-               LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
-               LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
-               */
-
                if(!firstload)
                {
                        firstload=1;
@@ -2614,16 +2400,10 @@ void    Game::Tick()
                displaytime[i]+=multiplier;
        }
 
-       static unsigned char    theKeyMap[16];
-       GetKeys( theKeyMap );
-
        keyboardfrozen=0;
 
-
-       static bool mainmenutogglekeydown;
-
-       if (IsKeyDown(theKeyMap, MAC_F6_KEY) && !freezetogglekeydown) {
-               if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) {
+       if (Input::isKeyDown(SDLK_F6) && !freezetogglekeydown) {
+               if (Input::isKeyDown(SDLK_LSHIFT)) {
                        stereoreverse=true;
                } else {
                        stereoreverse=false;
@@ -2637,8 +2417,8 @@ void      Game::Tick()
                freezetogglekeydown=1;
        }
 
-       if (IsKeyDown(theKeyMap, MAC_F7_KEY)) {
-               if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) {
+       if (Input::isKeyDown(SDLK_F7)) {
+               if (Input::isKeyDown(SDLK_LSHIFT)) {
                        stereoseparation -= 0.001;
                } else {
                        stereoseparation -= 0.010;
@@ -2647,8 +2427,8 @@ void      Game::Tick()
                printf("Stereo decreased increased to %f\n", stereoseparation);
        }
 
-       if (IsKeyDown(theKeyMap, MAC_F8_KEY)) {
-               if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) {
+       if (Input::isKeyDown(SDLK_F8)) {
+               if (Input::isKeyDown(SDLK_LSHIFT)) {
                        stereoseparation += 0.001;
                } else {
                        stereoseparation += 0.010;
@@ -2660,109 +2440,16 @@ void   Game::Tick()
 
        if(!console){
                if(mainmenu&&endgame==1)mainmenu=10;
-               if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){
-                       for(j=0;j<255;j++){
-                               displaytext[0][j]=' ';
-                       }
-                       displaychars[0]=0;
-                       displayselected=0;
-                       entername=0;
-                       mainmenutogglekeydown=1;
-               }
-               if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10)){
+               if( (Input::isKeyDown(SDLK_ESCAPE)||(mainmenu==0&&((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))
+                   && !mainmenutogglekeydown
+                   && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10)
+                 ) { // go back
                        selected=-1;
                        if(mainmenu==1||mainmenu==2||mainmenu==0){
                                if(mainmenu==0&&!winfreeze)mainmenu=2;
                                else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100;
                                else if(mainmenu==0&&winfreeze){
-                                       /*      if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2)
-                                       stealthloading=1;
-                                       else stealthloading=0;
-
-                                       if(!stealthloading){
-                                       float gLoc[3]={0,0,0};
-                                       float vel[3]={0,0,0};
-                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                       OPENAL_SetVolume(channels[firestartsound], 256);
-                                       OPENAL_SetPaused(channels[firestartsound], false);
-                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                                       flashr=1;
-                                       flashg=0;
-                                       flashb=0;
-                                       flashamount=1;
-                                       flashdelay=1;
-                                       }
-
-                                       startbonustotal=0;
-
-                                       for(i=0;i<campaignnumlevels;i++){
-                                       levelvisible[i]=0;
-                                       levelhighlight[i]=0;
-                                       }
-
-                                       levelorder[0]=0;
-                                       levelvisible[0]=1;
-                                       if(accountcampaignchoicesmade[accountactive])
-                                       for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
-                                       levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
-                                       levelvisible[levelorder[i+1]]=1;
-                                       }
-                                       int whichlevelstart;
-                                       whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
-                                       if(whichlevelstart<0){
-                                       campaignchoicenum=1;
-                                       campaignchoicewhich[0]=0;
-                                       }
-                                       else
-                                       {
-                                       campaignchoicenum=campaignnumnext[levelorder[whichlevelstart]];
-                                       if(campaignchoicenum)
-                                       for(i=0;i<campaignchoicenum;i++){
-                                       campaignchoicewhich[i]=campaignnextlevel[levelorder[whichlevelstart]][i];
-                                       levelvisible[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
-                                       levelhighlight[campaignnextlevel[levelorder[whichlevelstart]][i]]=1;
-                                       }
-                                       }
-
-                                       loading=2;
-                                       loadtime=0;
-                                       targetlevel=7;
-                                       if(firstload)TickOnceAfter();
-                                       if(!firstload)LoadStuff();
-                                       //else {
-                                       for(i=0;i<255;i++){
-                                       mapname[i]='\0';
-                                       }
-                                       mapname[0]=':';
-                                       mapname[1]='D';
-                                       mapname[2]='a';
-                                       mapname[3]='t';
-                                       mapname[4]='a';
-                                       mapname[5]=':';
-                                       mapname[6]='M';
-                                       mapname[7]='a';
-                                       mapname[8]='p';
-                                       mapname[9]='s';
-                                       mapname[10]=':';
-
-                                       //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
-                                       //accountcampaignchoicesmade[accountactive]++;
-
-
-                                       strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
-                                       whichchoice=0;
-                                       visibleloading=1;
-                                       stillloading=1;
-                                       Loadlevel(mapname);
-                                       campaign=1;
-                                       mainmenu=0;
-                                       gameon=1;
-                                       OPENAL_SetPaused(channels[music3], true);
-
-                                       stealthloading=0;*/
+                                       
                                }
                                else if(mainmenu==1||mainmenu==2)mainmenu=0;
                                if(mainmenu&&musictoggle){
@@ -2780,20 +2467,9 @@ void     Game::Tick()
                                }
                        }
                        if(mainmenu==3){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
@@ -2803,20 +2479,9 @@ void     Game::Tick()
                                SaveSettings(*this);
                        }
                        if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
                        }
                        if(mainmenu==3&&gameon)mainmenu=2;
                        if(mainmenu==3&&!gameon)mainmenu=1;
@@ -2836,23 +2501,23 @@ void    Game::Tick()
                        }
                        mainmenutogglekeydown=1;
                }
-               if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
+               if(!Input::isKeyDown(SDLK_ESCAPE)){
                        mainmenutogglekeydown=0;
                }
        }
 
        /*static bool minimaptogglekeydown;
-       if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){
+       if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown){
        minimap=1-minimap;
        minimaptogglekeydown=1;
        }
-       if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
+       if(!Input::isKeyDown(SDLK_TAB)){
        minimaptogglekeydown=0;
        }
        */
 
        static bool minimaptogglekeydown;
-       if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){
+       if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){
                if(tutorialstage!=51)
                        tutorialstagetime=tutorialmaxtime;
                PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true);
@@ -2860,7 +2525,7 @@ void      Game::Tick()
                OPENAL_SetPaused(channels[consolefailsound], false);
                minimaptogglekeydown=1;
        }
-       if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){
+       if(!Input::isKeyDown(SDLK_TAB)){
                minimaptogglekeydown=0;
        }
 
@@ -2869,37 +2534,17 @@ void    Game::Tick()
                if(mainmenu==1||mainmenu==2){
                        if(Button()&&!oldbutton&&selected==1){
                                if(!gameon){
-                                       float gLoc[3]={0,0,0};
-                                       float vel[3]={0,0,0};
-                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                       OPENAL_SetVolume(channels[firestartsound], 256);
-                                       OPENAL_SetPaused(channels[firestartsound], false);
-                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                                       flashr=1;
-                                       flashg=0;
-                                       flashb=0;
-                                       flashamount=1;
-                                       flashdelay=1;
+                                       fireSound(firestartsound);
+
+                                       flash();
 
                                        //new game
-                                       if(accountactive!=-1)mainmenu=5;
-                                       else mainmenu=7;
-                                       /*
-                                       startbonustotal=0;
-
-                                       loading=2;
-                                       loadtime=0;
-                                       if(firstload)TickOnceAfter();
-                                       if(!firstload)LoadStuff();
-                                       else {
-                                       Loadlevel(0);
+                                       if(accountactive) {
+                                               mainmenu=5;
+                                       } else {
+                                               mainmenu=7;
                                        }
-                                       mainmenu=0;
-                                       gameon=1;
-                                       OPENAL_SetPaused(channels[music3], true);       */
+                                       selected=-1;
                                }
                                else
                                {
@@ -2911,20 +2556,9 @@ void     Game::Tick()
                        }
 
                        if(Button()&&!oldbutton&&selected==2){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                //options
 
@@ -2939,20 +2573,9 @@ void     Game::Tick()
                        }
 
                        if(Button()&&!oldbutton&&selected==3){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                if(!gameon){
                                        //quit
@@ -2965,20 +2588,10 @@ void    Game::Tick()
                                        mainmenu=1;
                                }
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
-
                if(mainmenu==3){
                        if(Button()&&!oldbutton&&selected!=-1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
+                               fireSound();
                        }
                        if(Button()&&!oldbutton&&selected==0){
                        
@@ -3079,55 +2692,30 @@ void    Game::Tick()
                                OPENAL_SetSFXMasterVolume((int)(volume*255));
                        }
                        if(Button()&&!oldbutton&&selected==7){
-                               /*float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
+                               /*fireSound();
                                */
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               flash();
 
                                //options
 
                                mainmenu=4;
+                               selected=-1;
                                keyselect=-1;
                        }
                        if(Button() && !oldbutton && selected == 12) {
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               flash();
                                
                                newstereomode = stereomode;
                                mainmenu=18;
-                               keyselect = -1;
+                               keyselect=-1;
                        }
                        if(Button() && !oldbutton && selected == 13) {
                                showdamagebar=!showdamagebar;
                        }
                        if(Button()&&!oldbutton&&selected==8){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                if(newdetail>2)newdetail=detail;
                                if(newdetail<0)newdetail=detail;
@@ -3139,112 +2727,40 @@ void   Game::Tick()
                                if(mainmenu==3&&gameon)mainmenu=2;
                                if(mainmenu==3&&!gameon)mainmenu=1;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==4){
-                       if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-                       }
-                       if(Button()&&!oldbutton&&selected<9&&keyselect==-1){
-                               keyselect=selected;
-                               oldbuttons[0]=1;
-                               oldbuttons[1]=1;
-                               oldbuttons[2]=1;
-                       }
-                       if(keyselect!=-1){
-                               for(i=0;i<3;i++)
-                                       if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0;
-                               for(i=0;i<140;i++){
-                                       if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){
-                                               if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){
-                                                       float gLoc[3]={0,0,0};
-                                                       float vel[3]={0,0,0};
-                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                                                       PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                                                       OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                       OPENAL_SetVolume(channels[fireendsound], 256);
-                                                       OPENAL_SetPaused(channels[fireendsound], false);
-                                                       OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                                                       int keynum;
-                                                       keynum=i;
-                                                       if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1;
-                                                       if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2;
-
-
-
-                                                       if(keyselect==0)forwardkey=keynum;
-                                                       if(keyselect==1)backkey=keynum;
-                                                       if(keyselect==2)leftkey=keynum;
-                                                       if(keyselect==3)rightkey=keynum;
-                                                       if(keyselect==4)crouchkey=keynum;
-                                                       if(keyselect==5)jumpkey=keynum;
-                                                       if(keyselect==6)drawkey=keynum;
-                                                       if(keyselect==7)throwkey=keynum;
-                                                       if(keyselect==8)attackkey=keynum;
-                                                       keyselect=-1;
-                                               }
-                                       }
-                               }}
-                       if(Button()&&!oldbutton&&selected==9){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               mainmenu=3;
-
-                               if(newdetail>2)newdetail=detail;
-                               if(newdetail<0)newdetail=detail;
-                               if(newscreenwidth>3000)newscreenwidth=screenwidth;
-                               if(newscreenwidth<0)newscreenwidth=screenwidth;
-                               if(newscreenheight>3000)newscreenheight=screenheight;
-                               if(newscreenheight<0)newscreenheight=screenheight;
+                       if(Button()&&!oldbutton&&selected!=-1&&!waiting){
+                               fireSound();
+                               if(selected<9&&keyselect==-1)
+                                       keyselect=selected;
+                               if(keyselect!=-1)
+                                       setKeySelected();
+                               if(selected==9){
+                                       flash();
+
+                                       mainmenu=3;
+
+                                       if(newdetail>2)newdetail=detail;
+                                       if(newdetail<0)newdetail=detail;
+                                       if(newscreenwidth>3000)newscreenwidth=screenwidth;
+                                       if(newscreenwidth<0)newscreenwidth=screenwidth;
+                                       if(newscreenheight>3000)newscreenheight=screenheight;
+                                       if(newscreenheight<0)newscreenheight=screenheight;
+                               }
                        }
                }
 
                if(mainmenu==5){
 
                        if(endgame==2){
-                               accountcampaignchoicesmade[accountactive]=0;
-                               accountcampaignscore[accountactive]=0;
-                               accountcampaigntime[accountactive]=0;
+                               accountactive->endGame();
                                endgame=0;
                        }
 
                        if(Button()&&!oldbutton&&selected==1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                startbonustotal=0;
 
@@ -3261,30 +2777,18 @@ void    Game::Tick()
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                       if(Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){
+                               fireSound();
+
+                               flash();
 
                                startbonustotal=0;
 
                                loading=2;
                                loadtime=0;
                                targetlevel=7;
-                               if(firstload)TickOnceAfter();
-                               if(!firstload)LoadStuff();
-                               //else {
+                               if(firstload) TickOnceAfter();
+                               else LoadStuff();
                                for(i=0;i<255;i++){
                                        mapname[i]='\0';
                                }
@@ -3299,110 +2803,52 @@ void   Game::Tick()
                                mapname[8]='p';
                                mapname[9]='s';
                                mapname[10]=':';
-                               strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]);
-                               whichchoice=selected-7-accountcampaignchoicesmade[accountactive];
+                               strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountactive->getCampaignChoicesMade()]]);
+                               whichchoice=selected-7-accountactive->getCampaignChoicesMade();
                                visibleloading=1;
                                stillloading=1;
                                Loadlevel(mapname);
                                //Loadlevel(campaignmapname[levelorder[selected-7]]);
-                               //}
                                campaign=1;
                                mainmenu=0;
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==4){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                if(mainmenu==5&&gameon)mainmenu=2;
                                if(mainmenu==5&&!gameon)mainmenu=1;
                        }
                        if(Button()&&!oldbutton&&selected==5){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=7;
                        }
                        if(Button()&&!oldbutton&&selected==3){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=6;
                        }
                        if(Button()&&!oldbutton&&selected==2){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=9;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==9){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
+                               fireSound();
+
+                               flash();
 
                                startbonustotal=0;
 
@@ -3421,53 +2867,29 @@ void    Game::Tick()
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==numchallengelevels){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=5;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==11){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountprogress[accountactive]){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
+                               fireSound();
+
+                               flash();
 
                                startbonustotal=0;
 
                                loading=2;
                                loadtime=0;
                                targetlevel=selected;
-                               if(firstload)TickOnceAfter();
-                               if(!firstload)LoadStuff();
-                               else {
+                               if(firstload) {
+                                       TickOnceAfter();
                                        Loadlevel(selected);
-                               }
+                               } else
+                                       LoadStuff();
                                campaign=0;
 
                                mainmenu=0;
@@ -3475,211 +2897,78 @@ void   Game::Tick()
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
                        if(Button()&&!oldbutton&&selected==numchallengelevels){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=5;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==10){
                        endgame=2;
                        if(Button()&&!oldbutton&&selected==3){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               fireSound();
+
+                               flash();
 
                                mainmenu=5;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
 
                if(mainmenu==6){
-                       if(Button()&&!oldbutton&&selected!=-1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-                       }
-                       if(Button()&&!oldbutton&&selected==1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               for(i=accountactive;i<numaccounts-1;i++){
-                                       accountdifficulty[i]=accountdifficulty[i+1];
-                                       accountcampaignchoicesmade[i]=accountcampaignchoicesmade[i+1];
-                                       for(j=0;j<accountcampaignchoicesmade[i+1];j++){
-                                               accountcampaignchoices[i][j]=accountcampaignchoices[i+1][j];
-                                       }
-                                       accountpoints[i]=accountpoints[i+1];
-                                       for(j=0;j<50;j++){
-                                               accounthighscore[i][j]=accounthighscore[i+1][j];
-                                               accountfasttime[i][j]=accountfasttime[i+1][j];
-                                       }
-                                       for(j=0;j<60;j++){
-                                               accountunlocked[i][j]=accountunlocked[i+1][j];
-                                       }
-                                       for(j=0;j<256;j++){
-                                               accountname[i][j]=accountname[i+1][j];
+                       if(Button()&&!oldbutton) {
+                               if(selected>-1){
+                                       fireSound();
+                                       if(selected==1) {
+                                               flash();
+                                               accountactive = Account::destroy(accountactive);
+                                               mainmenu=7;
+                                       } else if(selected==2) {
+                                               flash();
+                                               mainmenu=5;
                                        }
-                                       accountcampaignhighscore[i]=accountcampaignhighscore[i+1];
-                                       accountprogress[i]=accountprogress[i+1];
-                                       accountcampaignfasttime[i]=accountcampaignfasttime[i+1];
-                                       accountcampaignscore[i]=accountcampaignscore[i+1];
-                                       accountcampaigntime[i]=accountcampaigntime[i+1];
                                }
-
-                               numaccounts--;
-                               accountactive=-1;
-
-
-                               mainmenu=7;
-                       }
-                       if(Button()&&!oldbutton&&selected==2){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               mainmenu=5;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==7){
-                       if(Button()&&!oldbutton&&selected!=-1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-                       }
-                       if(Button()&&!oldbutton&&selected==0&&numaccounts<8){
-                               entername=1;
-                       }
-                       if(Button()&&!oldbutton&&selected>0&&selected<numaccounts+1){
-                               accountactive=selected-1;
-                               mainmenu=5;
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-                       }
-                       if(Button()&&!oldbutton&&selected==numaccounts+1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[fireendsound], 256);
-                               OPENAL_SetPaused(channels[fireendsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
-
-                               mainmenu=1;
-
-                               for(j=0;j<255;j++){
-                                       displaytext[0][j]=' ';
+                       if(Button()&&!oldbutton) {
+                               if(selected!=-1){
+                                       fireSound();
+                                       if(selected==0&&Account::getNbAccounts()<8){
+                                               entername=1;
+                                       } else if (selected<Account::getNbAccounts()+1) {
+                                               accountactive=Account::get(selected-1);
+                                               mainmenu=5;
+                                               flash();
+                                       } else if (selected==Account::getNbAccounts()+1) {
+                                               flash();
+
+                                               mainmenu=1;
+
+                                               for(j=0;j<255;j++){
+                                                       displaytext[0][j]=' ';
+                                               }
+                                               displaychars[0]=0;
+                                               displayselected=0;
+                                               entername=0;
+                                       }
                                }
-                               displaychars[0]=0;
-                               displayselected=0;
-                               entername=0;
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
                if(mainmenu==8){
-                       if(Button()&&!oldbutton&&selected!=-1){
-                               float gLoc[3]={0,0,0};
-                               float vel[3]={0,0,0};
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                               OPENAL_SetVolume(channels[firestartsound], 256);
-                               OPENAL_SetPaused(channels[firestartsound], false);
-                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                               if(selected==0)accountdifficulty[accountactive]=0;
-                               if(selected==1)accountdifficulty[accountactive]=1;
-                               if(selected==2)accountdifficulty[accountactive]=2;
+                       if(Button()&&!oldbutton&&selected>-1){
+                               fireSound();
+
+                               if(selected<=2)
+                                       accountactive->setDifficulty(selected);
 
                                mainmenu=5;
 
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               flash();
 
                        }
-                       if(Button())oldbutton=1;
-                       else oldbutton=0;
                }
-               if (mainmenu==18) {
-                       if(Button()&&!oldbutton) {
-                               printf("Button %i pressed\n", selected);
-                       }
-                       
+               if (mainmenu==18) {                     
                        if(Button()&&!oldbutton&&selected==0) {
                                newstereomode = (StereoMode)(newstereomode + 1);
                                while(!CanInitStereo(newstereomode)) {
@@ -3691,10 +2980,10 @@ void    Game::Tick()
                                }
                        }
                        
-                       if(buttons[0]&&!oldbutton&&selected==1) {
+                       if(Input::isKeyDown(MOUSEBUTTON1)&&!oldbutton&&selected==1) {
                                stereoseparation+=0.001;
                        }
-                       if(buttons[1]&&!oldbutton&&selected==1) {
+                       if(Input::isKeyDown(MOUSEBUTTON2)&&!oldbutton&&selected==1) {
                                stereoseparation-=0.001;
                        }
 
@@ -3703,27 +2992,20 @@ void    Game::Tick()
                        }
                        
                        if(Button()&&!oldbutton&&selected==3) {
-                               flashr=1;
-                               flashg=0;
-                               flashb=0;
-                               flashamount=1;
-                               flashdelay=1;
+                               flash();
 
                                stereomode = newstereomode;
                                InitStereo(stereomode);
                                
                                mainmenu=3;
                        }
-                       
-                       if(Button() || buttons[1])oldbutton=1;
-                       else oldbutton=0;
                }
 
 
-               if(Button()||buttons[1])oldbutton=1;
+               if(Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1;
                else oldbutton=0;
 
-               if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
+               if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
                        tryquit=1;
                        if(mainmenu==3){
                                if(newdetail>2)newdetail=detail;
@@ -3746,130 +3028,9 @@ void    Game::Tick()
                }
                OPENAL_SetFrequency(channels[stream_music3], 22050);
 
-               if(entername){
-                       for(i=0;i<140;i++){
-                               if(IsKeyDown(theKeyMap, i)){
-                                       togglekeydelay[i]+=multiplier;
-                                       if(togglekeydelay[i]>.4){
-                                               togglekey[i]=0;
-                                               togglekeydelay[i]=.36;
-                                       }
-                                       if(!togglekey[i]){
-                                               if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){
-                                                       for(j=255;j>=displayselected+1;j--){
-                                                               displaytext[0][j]=displaytext[0][j-1];
-                                                       }
-                                                       displaytext[0][displayselected]=KeyToSingleChar(i);
-                                                       if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
-                                                       displayselected++;
-                                                       displaychars[0]++;
-                                               }
-                                               if(i==MAC_DELETE_KEY&&displayselected!=0){
-                                                       for(j=displayselected-1;j<255;j++){
-                                                               displaytext[0][j]=displaytext[0][j+1];
-                                                       }
-                                                       displaytext[0][255]=' ';
-                                                       displayselected--;
-                                                       displaychars[0]--;
-                                               }
-                                               if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
-                                                       displayselected--;
-                                               }
-                                               if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
-                                                       displayselected++;
-                                               }
-                                               if(i==MAC_RETURN_KEY&&entername){
-                                                       if(displaychars[0]){
-                                                               numaccounts++;
-                                                               strcpy(accountname[numaccounts-1],displaytext[0]);
-                                                               accountactive=numaccounts-1;
-                                                               accountdifficulty[accountactive]=1;
-                                                               accountprogress[accountactive]=0;
-                                                               accountpoints[accountactive]=0;
-                                                               accountcampaigntime[accountactive]=0;
-                                                               accountcampaignscore[accountactive]=0;
-                                                               accountcampaignfasttime[accountactive]=0;
-                                                               accountcampaignhighscore[accountactive]=0;
-                                                               for(j=0;j<50;j++){
-                                                                       accounthighscore[accountactive][j]=0;
-                                                                       accountfasttime[accountactive][j]=0;
-                                                               }
-                                                               for(j=0;j<60;j++){
-                                                                       accountunlocked[accountactive][j]=0;
-                                                               }
-                                                               accountcampaignchoicesmade[accountactive]=0;
-
-                                                               for(j=0;j<255;j++){
-                                                                       displaytext[0][j]=' ';
-                                                               }
-                                                               displaychars[0]=0;
-                                                               displayselected=0;
-                                                               entername=0;
-
-                                                               mainmenu=8;
-
-                                                               flashr=1;
-                                                               flashg=0;
-                                                               flashb=0;
-                                                               flashamount=1;
-                                                               flashdelay=1;
-
-                                                               float gLoc[3]={0,0,0};
-                                                               float vel[3]={0,0,0};
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                                                               for(j=0;j<255;j++){
-                                                                       displaytext[0][j]=' ';
-                                                               }
-                                                               displaychars[0]=0;
-
-
-                                                               displayselected=0;
-                                                       }}
-
-                                               if(i==MAC_RETURN_KEY&&mainmenu==13){
-                                                       if(displaychars[0]){
-                                                               sprintf (registrationname, "%s", displaytext[0]);
-                                                               if(displaychars[0]<254)registrationname[displaychars[0]]='\0';
-
-                                                               mainmenu=5;
-                        
-                                                               flashr=1;
-                                                               flashg=0;
-                                                               flashb=0;
-                                                               flashamount=1;
-                                                               flashdelay=1;
-
-                                                               float gLoc[3]={0,0,0};
-                                                               float vel[3]={0,0,0};
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                                                               for(j=0;j<255;j++){
-                                                                       displaytext[0][j]=' ';
-                                                               }
-                                                               displaychars[0]=0;
-                        
-                                                               displayselected=0;
-                                                       }}
-                                       }
-                                       togglekey[i]=1;
-                               }
-                               else {
-                                       togglekey[i]=0;
-                                       togglekeydelay[i]=0;
-                               }
-                       }
-
+               if(entername) {
+                       if(!waiting) inputText();
+                       
                        displayblinkdelay-=multiplier;
                        if(displayblinkdelay<=0){
                                displayblinkdelay=.3;
@@ -3882,27 +3043,27 @@ void    Game::Tick()
                if(hostile==1)hostiletime+=multiplier;
                else hostiletime=0;
                if(!winfreeze)leveltime+=multiplier;
-               if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){
+               if(Input::isKeyDown(SDLK_ESCAPE)){
                        chatting=0;
                        console=0;
                        freeze=0;
                        displaychars[0]=0;
                }
 
-               if(IsKeyDown(theKeyMap, chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
+               if(Input::isKeyDown(chatkey)&&!chattogglekeydown&&!console&&!chatting&&debugmode){
                        chatting=1;
                        chattogglekeydown=1;
                        togglekey[chatkey]=1;
                        togglekeydelay[chatkey]=-20;
                }
 
-               if(!IsKeyDown(theKeyMap, chatkey)){
+               if(!Input::isKeyDown(chatkey)){
                        chattogglekeydown=0;
                }
 
                if(chatting){
                        for(i=0;i<140;i++){
-                               if(IsKeyDown(theKeyMap, i)){
+                               if(Input::isKeyDown(i)){
                                        togglekeydelay[i]+=multiplier;
                                        if(togglekeydelay[i]>.4){
                                                togglekey[i]=0;
@@ -3914,11 +3075,11 @@ void    Game::Tick()
                                                                displaytext[0][j]=displaytext[0][j-1];
                                                        }
                                                        displaytext[0][displayselected]=KeyToSingleChar(i);
-                                                       if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
+                                                       if(Input::isKeyDown(SDLK_LSHIFT))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]);
                                                        displayselected++;
                                                        displaychars[0]++;
                                                }
-                                               if(i==MAC_DELETE_KEY&&displayselected!=0){
+                                               if(i==SDLK_DELETE&&displayselected!=0){
                                                        for(j=displayselected-1;j<255;j++){
                                                                displaytext[0][j]=displaytext[0][j+1];
                                                        }
@@ -3926,13 +3087,13 @@ void    Game::Tick()
                                                        displayselected--;
                                                        displaychars[0]--;
                                                }
-                                               if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){
+                                               if(i==SDLK_LEFT&&displayselected!=0){
                                                        displayselected--;
                                                }
-                                               if(i==MAC_ARROW_RIGHT_KEY&&displayselected<displaychars[0]){
+                                               if(i==SDLK_RIGHT&&displayselected<displaychars[0]){
                                                        displayselected++;
                                                }
-                                               if(i==MAC_RETURN_KEY){
+                                               if(i==SDLK_RETURN){
                                                        if(displaychars[0]){
                                                                /*for(j=0;j<displaychars[0];j++){
                                                                talkname[j]=displaytext[0][j];
@@ -3967,7 +3128,7 @@ void      Game::Tick()
 
                if(chatting)keyboardfrozen=1;
 
-               if(IsKeyDown(theKeyMap, MAC_V_KEY)&&!freezetogglekeydown&&debugmode){
+               if(Input::isKeyDown(SDLK_v)&&!freezetogglekeydown&&debugmode){
                        freeze=1-freeze;
                        if(freeze){
                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
@@ -3975,11 +3136,11 @@ void    Game::Tick()
                        freezetogglekeydown=1;
                }
 
-               if(!IsKeyDown(theKeyMap, MAC_V_KEY)&&!IsKeyDown(theKeyMap, MAC_F1_KEY)){
+               if(!Input::isKeyDown(SDLK_v)&&!Input::isKeyDown(SDLK_F1)){
                        freezetogglekeydown=0;
                }
 
-               if(IsKeyDown(theKeyMap, MAC_TILDE_KEY)&&!consoletogglekeydown&&debugmode){
+               if(Input::isKeyDown(SDLK_BACKQUOTE)&&!consoletogglekeydown&&debugmode){
                        console=1-console;
                        if(!console)freeze=0;
                        if(console){
@@ -3988,15 +3149,15 @@ void    Game::Tick()
                        consoletogglekeydown=1;
                }
 
-               if(!IsKeyDown(theKeyMap, MAC_TILDE_KEY)){
+               if(!Input::isKeyDown(SDLK_BACKQUOTE)){
                        consoletogglekeydown=0;
                }
 
                if(console)freeze=1;
 
-               if(console&&!IsKeyDown(theKeyMap,MAC_COMMAND_KEY)){
+               if(console&&!Input::isKeyDown(SDLK_LMETA)){
                        for(i=0;i<140;i++){
-                               if(IsKeyDown(theKeyMap, i)){
+                               if(Input::isKeyDown(i)){
                                        togglekeydelay[i]+=multiplier;
                                        if(togglekeydelay[i]>.4){
                                                togglekey[i]=0;
@@ -4008,11 +3169,11 @@ void    Game::Tick()
                                                                consoletext[0][j]=consoletext[0][j-1];
                                                        }
                                                        consoletext[0][consoleselected]=KeyToSingleChar(i);
-                                                       if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
+                                                       if(Input::isKeyDown(SDLK_LSHIFT))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]);
                                                        consoleselected++;
                                                        consolechars[0]++;
                                                }
-                                               else if(i==MAC_ENTER_KEY){
+                                               else if(i==SDLK_RETURN){
                                                        for(j=255;j>=consoleselected+1;j--){
                                                                consoletext[0][j]=consoletext[0][j-1];
                                                        }
@@ -4020,7 +3181,7 @@ void      Game::Tick()
                                                        consoleselected++;
                                                        consolechars[0]++;
                                                }
-                                               if(i==MAC_DELETE_KEY&&consoleselected!=0){
+                                               if(i==SDLK_DELETE&&consoleselected!=0){
                                                        for(j=consoleselected-1;j<255;j++){
                                                                consoletext[0][j]=consoletext[0][j+1];
                                                        }
@@ -4028,7 +3189,7 @@ void      Game::Tick()
                                                        consoleselected--;
                                                        consolechars[0]--;
                                                }
-                                               if(i==MAC_ARROW_UP_KEY){
+                                               if(i==SDLK_UP){
                                                        if(archiveselected<14)archiveselected++;
                                                        for(j=0;j<255;j++){
                                                                consolechars[0]=consolechars[archiveselected];
@@ -4036,7 +3197,7 @@ void      Game::Tick()
                                                                consoleselected=consolechars[0];
                                                        }
                                                }
-                                               if(i==MAC_ARROW_DOWN_KEY){
+                                               if(i==SDLK_DOWN){
                                                        if(archiveselected>0)archiveselected--;
                                                        for(j=0;j<255;j++){
                                                                consolechars[0]=consolechars[archiveselected];
@@ -4044,13 +3205,13 @@ void    Game::Tick()
                                                                consoleselected=consolechars[0];
                                                        }
                                                }
-                                               if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){
+                                               if(i==SDLK_LEFT&&consoleselected!=0){
                                                        consoleselected--;
                                                }
-                                               if(i==MAC_ARROW_RIGHT_KEY&&consoleselected<consolechars[0]){
+                                               if(i==SDLK_RIGHT&&consoleselected<consolechars[0]){
                                                        consoleselected++;
                                                }
-                                               if(i==MAC_RETURN_KEY){
+                                               if(i==SDLK_RETURN){
                                                        archiveselected=0;
                                                        cmd_dispatch(this, consoletext[0]);
 
@@ -4084,7 +3245,7 @@ void      Game::Tick()
                        }
                }
 
-               if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){
+               if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
                        tryquit=1;
                        if(mainmenu==3){
                                if(newdetail>2)newdetail=detail;
@@ -4106,20 +3267,20 @@ void    Game::Tick()
                if(winfreeze==0)oldwinfreeze=winfreeze;
                else oldwinfreeze++;
 
-               if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){
+               if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))&&!oldjumpkeydown&&!campaign){
                        if(winfreeze)winfreeze=0;
                        oldjumpkeydown=1;
                }
-               if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){
+               if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon){
                        if(winfreeze){
                                mainmenu=9;
                                gameon=0;
                        }
                }
-               if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){
+               if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))){
                        oldjumpkeydown=1;
                }
-               if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0;
+               if(!Input::isKeyDown(jumpkey)&&!Input::isKeyDown(SDLK_SPACE))oldjumpkeydown=0;
 
                if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){
 
@@ -4157,7 +3318,7 @@ void      Game::Tick()
                                                        realdialoguetype=dialoguetype[i];
                                                        special=0;
                                                }
-                                               if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){
+                                               if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype<numplayers&&realdialoguetype>0&&(dialoguegonethrough[i]==0||!special)&&(special||(Input::isKeyDown(attackkey)&&!oldbuttondialogue))){
                                                        if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){
                                                                whichdialogue=i;
                                                                for(j=0;j<numdialogueboxes[whichdialogue];j++){
@@ -4212,7 +3373,7 @@ void      Game::Tick()
                                                                        OPENAL_SetVolume(channels[whichsoundplay], 256);
                                                                        OPENAL_SetPaused(channels[whichsoundplay], false);
                                                                }
-                                                               if(IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=1;
+                                                               if(Input::isKeyDown(attackkey))oldbuttondialogue=1;
                                                        }
                                                }
                                        }
@@ -4259,44 +3420,31 @@ void    Game::Tick()
                                                }
                                                if(tutorialstage==1){
                                                        tutorialmaxtime=5;
-                                               }
-                                               if(tutorialstage==2){
+                                               } else if(tutorialstage==2){
                                                        tutorialmaxtime=2;
-                                               }
-                                               if(tutorialstage==3){
+                                               } else if(tutorialstage==3){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==4){
+                                               } else if(tutorialstage==4){
                                                        tutorialmaxtime=1000;
-                                               }
-                                               if(tutorialstage==5){
+                                               } else if(tutorialstage==5){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==6){
+                                               } else if(tutorialstage==6){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==7){
+                                               } else if(tutorialstage==7){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==8){
+                                               } else if(tutorialstage==8){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==9){
+                                               } else if(tutorialstage==9){
                                                        tutorialmaxtime=600;
-                                               }
-                                               if(tutorialstage==10){
+                                               } else if(tutorialstage==10){
                                                        tutorialmaxtime=2;
-                                               }
-                                               if(tutorialstage==11){
+                                               } else if(tutorialstage==11){
                                                        tutorialmaxtime=1000;
-                                               }
-                                               if(tutorialstage==12){
+                                               } else if(tutorialstage==12){
                                                        tutorialmaxtime=1000;
-                                               }
-                                               if(tutorialstage==13){
+                                               } else if(tutorialstage==13){
                                                        tutorialmaxtime=2;
-                                               }
-                                               if(tutorialstage==14){
+                                               } else if(tutorialstage==14){
                                                        tutorialmaxtime=3;
 
                                                        XYZ temp,temp2;
@@ -4333,107 +3481,82 @@ void   Game::Tick()
                                                                }
                                                        }
 
-                                               }
-                                               if(tutorialstage==15){
+                                               } else if(tutorialstage==15){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==16){
+                                               } else if(tutorialstage==16){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==17){
+                                               } else if(tutorialstage==17){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==18){
+                                               } else if(tutorialstage==18){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==19){
+                                               } else if(tutorialstage==19){
                                                        tutorialstage=20;
                                                        //tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==20){
+                                               } else if(tutorialstage==20){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==21){
+                                               } else if(tutorialstage==21){
                                                        tutorialmaxtime=500;
                                                        if(bonus==cannon){
                                                                bonus=Slicebonus;
                                                                againbonus=1;
                                                        }
                                                        else againbonus=0;
-                                               }
-                                               if(tutorialstage==22){
+                                               } else if(tutorialstage==22){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==23){
+                                               } else if(tutorialstage==23){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==24){
+                                               } else if(tutorialstage==24){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==25){
+                                               } else if(tutorialstage==25){
                                                        tutorialmaxtime=500;
-                                               }
-                                               if(tutorialstage==26){
+                                               } else if(tutorialstage==26){
                                                        tutorialmaxtime=2;
-                                               }
-                                               if(tutorialstage==27){
+                                               } else if(tutorialstage==27){
                                                        tutorialmaxtime=4;
                                                        reversaltrain=1;
                                                        cananger=1;
                                                        player[1].aitype=attacktypecutoff;
-                                               }
-                                               if(tutorialstage==28){
+                                               } else if(tutorialstage==28){
                                                        tutorialmaxtime=400;
-                                               }
-                                               if(tutorialstage==29){
+                                               } else if(tutorialstage==29){
                                                        tutorialmaxtime=400;
                                                        player[0].escapednum=0;
-                                               }
-                                               if(tutorialstage==30){
+                                               } else if(tutorialstage==30){
                                                        tutorialmaxtime=4;
                                                        reversaltrain=0;
                                                        cananger=0;
                                                        player[1].aitype=passivetype;
-                                               }
-                                               if(tutorialstage==31){
+                                               } else if(tutorialstage==31){
                                                        tutorialmaxtime=13;
-                                               }
-                                               if(tutorialstage==32){
+                                               } else if(tutorialstage==32){
                                                        tutorialmaxtime=8;
-                                               }
-                                               if(tutorialstage==33){
+                                               } else if(tutorialstage==33){
                                                        tutorialmaxtime=400;
                                                        cananger=1;
                                                        canattack=1;
                                                        player[1].aitype=attacktypecutoff;
-                                               }
-                                               if(tutorialstage==34){
+                                               } else if(tutorialstage==34){
                                                        tutorialmaxtime=400;
-                                               }
-                                               if(tutorialstage==35){
+                                               } else if(tutorialstage==35){
                                                        tutorialmaxtime=400;
-                                               }
-                                               if(tutorialstage==36){
+                                               } else if(tutorialstage==36){
                                                        tutorialmaxtime=2;
                                                        reversaltrain=0;
                                                        cananger=0;
                                                        player[1].aitype=passivetype;
-                                               }
-                                               if(tutorialstage==37){
+                                               } else if(tutorialstage==37){
                                                        damagedealt=0;
                                                        damagetaken=0;
                                                        tutorialmaxtime=50;
                                                        cananger=1;
                                                        canattack=1;
                                                        player[1].aitype=attacktypecutoff;
-                                               }
-                                               if(tutorialstage==38){
+                                               } else if(tutorialstage==38){
                                                        tutorialmaxtime=4;
                                                        canattack=0;
                                                        cananger=0;
                                                        player[1].aitype=passivetype;
-                                               }
-                                               if(tutorialstage==39){
+                                               } else if(tutorialstage==39){
                                                        XYZ temp,temp2;
 
                                                        temp.x=1011;
@@ -4462,20 +3585,15 @@ void    Game::Tick()
                                                        weapons.physics[weapons.numweapons]=1;
 
                                                        weapons.numweapons++;
-                                               }
-                                               if(tutorialstage==40){
+                                               } else if(tutorialstage==40){
                                                        tutorialmaxtime=300;
-                                               }
-                                               if(tutorialstage==41){
+                                               } else if(tutorialstage==41){
                                                        tutorialmaxtime=300;
-                                               }
-                                               if(tutorialstage==42){
+                                               } else if(tutorialstage==42){
                                                        tutorialmaxtime=8;
-                                               }
-                                               if(tutorialstage==43){
+                                               } else if(tutorialstage==43){
                                                        tutorialmaxtime=300;
-                                               }
-                                               if(tutorialstage==44){
+                                               } else if(tutorialstage==44){
                                                        weapons.owner[0]=1;
                                                        player[0].weaponactive=-1;
                                                        player[0].num_weapons=0;
@@ -4488,8 +3606,7 @@ void      Game::Tick()
                                                        player[1].aitype=attacktypecutoff;
 
                                                        tutorialmaxtime=300;
-                                               }
-                                               if(tutorialstage==45){
+                                               } else if(tutorialstage==45){
                                                        weapons.owner[0]=1;
                                                        player[0].weaponactive=-1;
                                                        player[0].num_weapons=0;
@@ -4498,8 +3615,7 @@ void      Game::Tick()
                                                        player[1].weaponids[0]=0;
 
                                                        tutorialmaxtime=300;
-                                               }
-                                               if(tutorialstage==46){
+                                               } else if(tutorialstage==46){
                                                        weapons.owner[0]=1;
                                                        player[0].weaponactive=-1;
                                                        player[0].num_weapons=0;
@@ -4510,9 +3626,7 @@ void      Game::Tick()
                                                        weapons.type[0]=sword;
 
                                                        tutorialmaxtime=300;
-                                               }
-
-                                               if(tutorialstage==47){
+                                               } else if(tutorialstage==47){
                                                        tutorialmaxtime=10;
 
                                                        XYZ temp,temp2;
@@ -4551,8 +3665,7 @@ void      Game::Tick()
                                                        player[1].weaponids[0]=0;
 
                                                        weapons.numweapons++;
-                                               }
-                                               if(tutorialstage==48){
+                                               } else if(tutorialstage==48){
                                                        canattack=0;
                                                        cananger=0;
                                                        player[1].aitype=passivetype;
@@ -4572,8 +3685,7 @@ void      Game::Tick()
                                                        else weapons.type[0]=staff;
 
                                                        weapons.numweapons++;
-                                               }
-                                               if(tutorialstage==49){
+                                               } else if(tutorialstage==49){
                                                        canattack=0;
                                                        cananger=0;
                                                        player[1].aitype=passivetype;
@@ -4594,8 +3706,7 @@ void      Game::Tick()
                                                        weapons.type[0]=knife;
 
                                                        weapons.numweapons++;
-                                               }
-                                               if(tutorialstage==50){
+                                               } else if(tutorialstage==50){
                                                        tutorialmaxtime=8;
 
                                                        XYZ temp,temp2;
@@ -4636,8 +3747,7 @@ void      Game::Tick()
                                                        weapons.freetime[0]=0;
                                                        weapons.firstfree[0]=1;
                                                        weapons.physics[0]=1;
-                                               }
-                                               if(tutorialstage==51){
+                                               } else if(tutorialstage==51){
                                                        tutorialmaxtime=80000;
                                                }
                                                if(tutorialstage<=51)tutorialstagetime=0;
@@ -5235,14 +4345,14 @@ void    Game::Tick()
                                                static XYZ oldviewer;
 
                                                if(indialogue==-1){
-                                                       player[0].forwardkeydown=IsKeyDown(theKeyMap, forwardkey);
-                                                       player[0].leftkeydown=IsKeyDown(theKeyMap, leftkey);
-                                                       player[0].backkeydown=IsKeyDown(theKeyMap, backkey);
-                                                       player[0].rightkeydown=IsKeyDown(theKeyMap, rightkey);
-                                                       player[0].jumpkeydown=IsKeyDown(theKeyMap, jumpkey);
-                                                       player[0].crouchkeydown=IsKeyDown(theKeyMap, crouchkey);
-                                                       player[0].drawkeydown=IsKeyDown(theKeyMap, drawkey);
-                                                       player[0].throwkeydown=IsKeyDown(theKeyMap, throwkey);
+                                                       player[0].forwardkeydown=Input::isKeyDown(forwardkey);
+                                                       player[0].leftkeydown=Input::isKeyDown(leftkey);
+                                                       player[0].backkeydown=Input::isKeyDown(backkey);
+                                                       player[0].rightkeydown=Input::isKeyDown(rightkey);
+                                                       player[0].jumpkeydown=Input::isKeyDown(jumpkey);
+                                                       player[0].crouchkeydown=Input::isKeyDown(crouchkey);
+                                                       player[0].drawkeydown=Input::isKeyDown(drawkey);
+                                                       player[0].throwkeydown=Input::isKeyDown(throwkey);
                                                }
                                                else
                                                {
@@ -5274,27 +4384,27 @@ void    Game::Tick()
 
                                                                flatfacing=DoRotation(flatfacing,0,-rotation,0);
 
-                                                               if(IsKeyDown(theKeyMap, forwardkey))viewer+=facing*multiplier*4;
-                                                               if(IsKeyDown(theKeyMap, backkey))viewer-=facing*multiplier*4;
-                                                               if(IsKeyDown(theKeyMap, leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
-                                                               if(IsKeyDown(theKeyMap, rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
-                                                               if(IsKeyDown(theKeyMap, jumpkey))viewer.y+=multiplier*4;
-                                                               if(IsKeyDown(theKeyMap, crouchkey))viewer.y-=multiplier*4;
-                                                               if(!endkeydown&&(IsKeyDown(theKeyMap, MAC_1_KEY)||IsKeyDown(theKeyMap, MAC_2_KEY)||IsKeyDown(theKeyMap, MAC_3_KEY)||IsKeyDown(theKeyMap, MAC_4_KEY)||IsKeyDown(theKeyMap, MAC_5_KEY)
-                                                                       ||IsKeyDown(theKeyMap, MAC_6_KEY)||IsKeyDown(theKeyMap, MAC_7_KEY)||IsKeyDown(theKeyMap, MAC_8_KEY)||IsKeyDown(theKeyMap, MAC_9_KEY)||IsKeyDown(theKeyMap, MAC_0_KEY)
-                                                                       ||IsKeyDown(theKeyMap, MAC_MINUS_KEY))){
+                                                               if(Input::isKeyDown(forwardkey))viewer+=facing*multiplier*4;
+                                                               if(Input::isKeyDown(backkey))viewer-=facing*multiplier*4;
+                                                               if(Input::isKeyDown(leftkey))viewer+=DoRotation(flatfacing*multiplier,0,90,0)*4;
+                                                               if(Input::isKeyDown(rightkey))viewer+=DoRotation(flatfacing*multiplier,0,-90,0)*4;
+                                                               if(Input::isKeyDown(jumpkey))viewer.y+=multiplier*4;
+                                                               if(Input::isKeyDown(crouchkey))viewer.y-=multiplier*4;
+                                                               if(!endkeydown&&(Input::isKeyDown(SDLK_1)||Input::isKeyDown(SDLK_2)||Input::isKeyDown(SDLK_3)||Input::isKeyDown(SDLK_4)||Input::isKeyDown(SDLK_5)
+                                                                       ||Input::isKeyDown(SDLK_6)||Input::isKeyDown(SDLK_7)||Input::isKeyDown(SDLK_8)||Input::isKeyDown(SDLK_9)||Input::isKeyDown(SDLK_0)
+                                                                       ||Input::isKeyDown(SDLK_MINUS))){
                                                                                int whichend;
-                                                                               if(IsKeyDown(theKeyMap, MAC_1_KEY))whichend=1;
-                                                                               if(IsKeyDown(theKeyMap, MAC_2_KEY))whichend=2;
-                                                                               if(IsKeyDown(theKeyMap, MAC_3_KEY))whichend=3;
-                                                                               if(IsKeyDown(theKeyMap, MAC_4_KEY))whichend=4;
-                                                                               if(IsKeyDown(theKeyMap, MAC_5_KEY))whichend=5;
-                                                                               if(IsKeyDown(theKeyMap, MAC_6_KEY))whichend=6;
-                                                                               if(IsKeyDown(theKeyMap, MAC_7_KEY))whichend=7;
-                                                                               if(IsKeyDown(theKeyMap, MAC_8_KEY))whichend=8;
-                                                                               if(IsKeyDown(theKeyMap, MAC_9_KEY))whichend=9;
-                                                                               if(IsKeyDown(theKeyMap, MAC_0_KEY))whichend=0;
-                                                                               if(IsKeyDown(theKeyMap, MAC_MINUS_KEY))whichend=-1;
+                                                                               if(Input::isKeyDown(SDLK_1))whichend=1;
+                                                                               if(Input::isKeyDown(SDLK_2))whichend=2;
+                                                                               if(Input::isKeyDown(SDLK_3))whichend=3;
+                                                                               if(Input::isKeyDown(SDLK_4))whichend=4;
+                                                                               if(Input::isKeyDown(SDLK_5))whichend=5;
+                                                                               if(Input::isKeyDown(SDLK_6))whichend=6;
+                                                                               if(Input::isKeyDown(SDLK_7))whichend=7;
+                                                                               if(Input::isKeyDown(SDLK_8))whichend=8;
+                                                                               if(Input::isKeyDown(SDLK_9))whichend=9;
+                                                                               if(Input::isKeyDown(SDLK_0))whichend=0;
+                                                                               if(Input::isKeyDown(SDLK_MINUS))whichend=-1;
                                                                                if(whichend!=-1){
                                                                                        participantfocus[whichdialogue][indialogue]=whichend;
                                                                                        participantlocation[whichdialogue][whichend]=player[whichend].coords;
@@ -5361,25 +4471,25 @@ void    Game::Tick()
 
                                                                                endkeydown=1;
                                                                        }
-                                                                       if((IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY)
-                                                                               ||IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY)||IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY)
+                                                                       if((Input::isKeyDown(SDLK_KP1)||Input::isKeyDown(SDLK_KP2)||Input::isKeyDown(SDLK_KP3)||Input::isKeyDown(SDLK_KP4)||Input::isKeyDown(SDLK_KP5)
+                                                                               ||Input::isKeyDown(SDLK_KP6)||Input::isKeyDown(SDLK_KP7)||Input::isKeyDown(SDLK_KP8)||Input::isKeyDown(SDLK_KP9)||Input::isKeyDown(SDLK_KP0)
                                                                                )){
                                                                                        int whichend;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_1_KEY))whichend=1;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_2_KEY))whichend=2;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_3_KEY))whichend=3;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_4_KEY))whichend=4;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_5_KEY))whichend=5;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_6_KEY))whichend=6;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_7_KEY))whichend=7;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_8_KEY))whichend=8;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_9_KEY))whichend=9;
-                                                                                       if(IsKeyDown(theKeyMap, MAC_NUMPAD_0_KEY))whichend=0;
+                                                                                       if(Input::isKeyDown(SDLK_KP1))whichend=1;
+                                                                                       if(Input::isKeyDown(SDLK_KP2))whichend=2;
+                                                                                       if(Input::isKeyDown(SDLK_KP3))whichend=3;
+                                                                                       if(Input::isKeyDown(SDLK_KP4))whichend=4;
+                                                                                       if(Input::isKeyDown(SDLK_KP5))whichend=5;
+                                                                                       if(Input::isKeyDown(SDLK_KP6))whichend=6;
+                                                                                       if(Input::isKeyDown(SDLK_KP7))whichend=7;
+                                                                                       if(Input::isKeyDown(SDLK_KP8))whichend=8;
+                                                                                       if(Input::isKeyDown(SDLK_KP9))whichend=9;
+                                                                                       if(Input::isKeyDown(SDLK_KP0))whichend=0;
                                                                                        participantfacing[whichdialogue][indialogue][whichend]=facing;
                                                                                }
-                                                                               if(!IsKeyDown(theKeyMap, MAC_1_KEY)&&!IsKeyDown(theKeyMap, MAC_2_KEY)&&!IsKeyDown(theKeyMap, MAC_3_KEY)&&!IsKeyDown(theKeyMap, MAC_4_KEY)&&!IsKeyDown(theKeyMap, MAC_5_KEY)
-                                                                                       &&!IsKeyDown(theKeyMap, MAC_6_KEY)&&!IsKeyDown(theKeyMap, MAC_7_KEY)&&!IsKeyDown(theKeyMap, MAC_8_KEY)&&!IsKeyDown(theKeyMap, MAC_9_KEY)&&!IsKeyDown(theKeyMap, MAC_0_KEY)
-                                                                                       &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
+                                                                               if(!Input::isKeyDown(SDLK_1)&&!Input::isKeyDown(SDLK_2)&&!Input::isKeyDown(SDLK_3)&&!Input::isKeyDown(SDLK_4)&&!Input::isKeyDown(SDLK_5)
+                                                                                       &&!Input::isKeyDown(SDLK_6)&&!Input::isKeyDown(SDLK_7)&&!Input::isKeyDown(SDLK_8)&&!Input::isKeyDown(SDLK_9)&&!Input::isKeyDown(SDLK_0)
+                                                                                       &&!Input::isKeyDown(SDLK_MINUS)){
                                                                                                endkeydown=0;
                                                                                        }
                                                                                        if(indialogue>=numdialogueboxes[whichdialogue]){
@@ -5397,9 +4507,9 @@ void      Game::Tick()
                                                                rotation=dialoguecamerarotation[whichdialogue][indialogue];
                                                                rotation2=dialoguecamerarotation2[whichdialogue][indialogue];
                                                                if(dialoguetime>0.5)
-                                                                       if((!endkeydown&&(IsKeyDown(theKeyMap, MAC_1_KEY)||IsKeyDown(theKeyMap, MAC_2_KEY)||IsKeyDown(theKeyMap, MAC_3_KEY)||IsKeyDown(theKeyMap, MAC_4_KEY)||IsKeyDown(theKeyMap, MAC_5_KEY)
-                                                                               ||IsKeyDown(theKeyMap, MAC_6_KEY)||IsKeyDown(theKeyMap, MAC_7_KEY)||IsKeyDown(theKeyMap, MAC_8_KEY)||IsKeyDown(theKeyMap, MAC_9_KEY)||IsKeyDown(theKeyMap, MAC_0_KEY)
-                                                                               ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){
+                                                                       if((!endkeydown&&(Input::isKeyDown(SDLK_1)||Input::isKeyDown(SDLK_2)||Input::isKeyDown(SDLK_3)||Input::isKeyDown(SDLK_4)||Input::isKeyDown(SDLK_5)
+                                                                               ||Input::isKeyDown(SDLK_6)||Input::isKeyDown(SDLK_7)||Input::isKeyDown(SDLK_8)||Input::isKeyDown(SDLK_9)||Input::isKeyDown(SDLK_0)
+                                                                               ||Input::isKeyDown(SDLK_MINUS)))||(Input::isKeyDown(attackkey)&&!oldbuttondialogue)){
                                                                                        indialogue++;
                                                                                        endkeydown=1;
                                                                                        if(indialogue<numdialogueboxes[whichdialogue]){
@@ -5464,9 +4574,9 @@ void      Game::Tick()
                                                                                                }
                                                                                        }
                                                                                }
-                                                                               if(!IsKeyDown(theKeyMap, MAC_1_KEY)&&!IsKeyDown(theKeyMap, MAC_2_KEY)&&!IsKeyDown(theKeyMap, MAC_3_KEY)&&!IsKeyDown(theKeyMap, MAC_4_KEY)&&!IsKeyDown(theKeyMap, MAC_5_KEY)
-                                                                                       &&!IsKeyDown(theKeyMap, MAC_6_KEY)&&!IsKeyDown(theKeyMap, MAC_7_KEY)&&!IsKeyDown(theKeyMap, MAC_8_KEY)&&!IsKeyDown(theKeyMap, MAC_9_KEY)&&!IsKeyDown(theKeyMap, MAC_0_KEY)
-                                                                                       &&!IsKeyDown(theKeyMap, MAC_MINUS_KEY)){
+                                                                               if(!Input::isKeyDown(SDLK_1)&&!Input::isKeyDown(SDLK_2)&&!Input::isKeyDown(SDLK_3)&&!Input::isKeyDown(SDLK_4)&&!Input::isKeyDown(SDLK_5)
+                                                                                       &&!Input::isKeyDown(SDLK_6)&&!Input::isKeyDown(SDLK_7)&&!Input::isKeyDown(SDLK_8)&&!Input::isKeyDown(SDLK_9)&&!Input::isKeyDown(SDLK_0)
+                                                                                       &&!Input::isKeyDown(SDLK_MINUS)){
                                                                                                endkeydown=0;
                                                                                        }
                                                                                        if(indialogue>=numdialogueboxes[whichdialogue]){
@@ -5489,120 +4599,11 @@ void   Game::Tick()
                                                        }
                                                }
 
-                                               if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0;
+                                               if(!Input::isKeyDown(attackkey))oldbuttondialogue=0;
                                                else oldbuttondialogue=1;
 
                                                static float keyrefreshdelay=0,bigrefreshdelay=0;
 
-                                               //Net updates
-
-                                               /*keyrefreshdelay-=multiplier;
-                                               bigrefreshdelay-=multiplier;
-
-                                               if(keyrefreshdelay<=0){
-                                               static int concat[4];
-
-                                               concat[0]=player[0].forwardkeydown;
-                                               concat[0]=concat[0]*2+player[0].forwardstogglekeydown;
-                                               concat[0]=concat[0]*2+player[0].rightkeydown;
-                                               concat[0]=concat[0]*2+player[0].leftkeydown;
-                                               concat[0]=concat[0]*2+player[0].backkeydown;
-                                               concat[0]=concat[0]*2+player[0].jumpkeydown;
-                                               concat[0]=concat[0]*2+player[0].jumptogglekeydown;
-                                               concat[0]=concat[0]*2+player[0].crouchkeydown;
-
-                                               concat[1]=player[0].crouchtogglekeydown;
-                                               concat[1]=concat[1]*2+player[0].drawkeydown;
-                                               concat[1]=concat[1]*2+player[0].drawtogglekeydown;
-                                               concat[1]=concat[1]*2+player[0].throwkeydown;
-                                               concat[1]=concat[1]*2+player[0].throwtogglekeydown;
-                                               concat[1]=concat[1]*2+player[0].attackkeydown;
-
-                                               //concat[2]=(char)((int)(rotation/2)%180);
-
-                                               //concat[3]=(char)((int)(rotation2/2)%180);
-
-                                               chatname[0]=concat[0]-128;
-                                               chatname[1]=concat[1]-128;
-                                               //chatname[2]=concat[2]-128;
-                                               //chatname[3]=concat[3]-128;
-                                               int temppoint=2;
-                                               memcpy(chatname+temppoint,&rotation,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&rotation2,sizeof(float));
-                                               temppoint+=sizeof(float);
-
-                                               chatname[temppoint]='\0';
-
-                                               //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys );
-                                               //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys );
-                                               //keyrefreshdelay=.01;
-                                               keyrefreshdelay=.03;
-                                               }
-
-                                               if(bigrefreshdelay<=0){
-                                               for(i=0;i<1;i++){
-                                               /*int temppoint=0;
-                                               memcpy(chatname+temppoint,&i,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].damage,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].target,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].rotation,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float));
-                                               temppoint+=sizeof(float);
-                                               memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int));
-                                               temppoint+=sizeof(int);
-                                               chatname[temppoint]='\0';
-
-                                               sprintf (chatname, "%d %f %f %f %f %f %d %d %f %f %f %d %d %f %f %f",i,player[i].coords.x,player[i].coords.y,player[i].coords.z,player[i].damage,player[i].target, player[i].targetanimation, player[i].currentanimation, player[i].velocity.x, player[i].velocity.y, player[i].velocity.z, player[i].targetframe, player[i].currentframe, player[i].rotation, player[i].targetrotation);
-                                               //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState );
-                                               //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState );
-
-                                               sprintf (chatname, "%d %f %d %d %d %d %d %d %d %d %f",i,player[i].bloodloss, player[i].weaponactive, player[i].num_weapons, player[i].weaponids[0], player[i].weaponids[1], player[i].weaponids[2], player[i].weaponids[3],player[i].dead,player[i].skeleton.free,player[i].permanentdamage);
-
-                                               //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc );
-                                               //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc );
-                                               }
-                                               //bigrefreshdelay=.02;
-                                               bigrefreshdelay=.1;
-                                               }
-                                               }*/
-
                                                if(!player[0].jumpkeydown){
                                                        player[0].jumptogglekeydown=0;
                                                }
@@ -5637,20 +4638,15 @@ void    Game::Tick()
                                                static float temptexdetail;
 
 
-                                               if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_h)&&debugmode){
                                                        player[0].damagetolerance=200000;
                                                        player[0].damage=0;
                                                        player[0].burnt=0;
                                                        player[0].permanentdamage=0;
                                                        player[0].superpermanentdamage=0;
-                                                       /*
-                                                       int whichchar;
-                                                       whichchar = abs(Random()%7);
-                                                       registrationname[whichchar]+=1;
-                                                       */
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_j)&&!envtogglekeydown&&debugmode){
                                                        environment++;
                                                        if(environment>2)environment=0;
                                                        Setenvironment(environment);
@@ -5659,20 +4655,20 @@ void    Game::Tick()
                                                }
 
 
-                                               if(!IsKeyDown(theKeyMap, MAC_J_KEY)){
+                                               if(!Input::isKeyDown(SDLK_j)){
                                                        envtogglekeydown=0;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_c)&&!cameratogglekeydown&&debugmode){
                                                        cameramode=1-cameramode;
                                                        cameratogglekeydown=1;
                                                }
 
-                                               if(!IsKeyDown(theKeyMap, MAC_C_KEY)){
+                                               if(!Input::isKeyDown(SDLK_c)){
                                                        cameratogglekeydown=0;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_x)&&!Input::isKeyDown(SDLK_LSHIFT)&&!detailtogglekeydown&&debugmode){
                                                        if(player[0].num_weapons>0){
                                                                if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff;
                                                                else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife;
@@ -5694,20 +4690,10 @@ void    Game::Tick()
                                                                        weapons.length[player[0].weaponids[0]]=.25;
                                                                }
                                                        }
-
-                                                       /*for(i=0;i<objects.numobjects;i++){
-                                                       if(objects.type[i]==treeleavestype){
-                                                       for(j=0;j<objects.numobjects;j++){
-                                                       if(objects.type[j]==treetrunktype)
-                                                       if(findDistancefast(&objects.position[i],&objects.position[j])<.5)
-                                                       objects.scale[i]=objects.scale[j];
-                                                       }
-                                                       }
-                                                       }*/
                                                        detailtogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_X_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_x)&&Input::isKeyDown(SDLK_LSHIFT)&&!detailtogglekeydown&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -5764,7 +4750,7 @@ void      Game::Tick()
                                                                detailtogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_U_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_u)&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -5782,7 +4768,7 @@ void      Game::Tick()
                                                }
 
 
-                                               if(IsKeyDown(theKeyMap, MAC_O_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_o)&&!Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -5794,7 +4780,7 @@ void      Game::Tick()
                                                                                closest=i;
                                                                        }
                                                                }
-                                                               if(IsKeyDown(theKeyMap, MAC_CONTROL_KEY))closest=0;
+                                                               if(Input::isKeyDown(SDLK_LCTRL))closest=0;
 
                                                                if(closest!=-1){
                                                                        player[closest].whichskin++;
@@ -5818,7 +4804,7 @@ void      Game::Tick()
                                                                detailtogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_O_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_o)&&Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -5899,18 +4885,18 @@ void    Game::Tick()
                                                                detailtogglekeydown=1;
                                                }
 
-                                               if(!IsKeyDown(theKeyMap, MAC_X_KEY)){
+                                               if(!Input::isKeyDown(SDLK_x)){
                                                        detailtogglekeydown=0;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_B_KEY)&&!slomotogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_b)&&!slomotogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
                                                        slomo=1-slomo;
                                                        slomodelay=1000;
                                                        slomotogglekeydown=1;
                                                }
 
 
-                                               if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[1]*/)&&!explodetogglekeydown&&debugmode){
+                                               if(((Input::isKeyDown(SDLK_i)&&!Input::isKeyDown(SDLK_LSHIFT)))&&!explodetogglekeydown&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -5976,7 +4962,7 @@ void      Game::Tick()
                                                                explodetogglekeydown=1;
                                                }
 
-                                               if(((IsKeyDown(theKeyMap, MAC_I_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY))/*||buttons[2]*/)&&!explodetogglekeydown&&debugmode){
+                                               if(((Input::isKeyDown(SDLK_i)&&Input::isKeyDown(SDLK_LSHIFT)))&&!explodetogglekeydown&&debugmode){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -6095,70 +5081,16 @@ void    Game::Tick()
                                                                explodetogglekeydown=1;
                                                }
 
-                                               if(!IsKeyDown(theKeyMap, MAC_I_KEY)){
+                                               if(!Input::isKeyDown(SDLK_i)){
                                                        explodetogglekeydown=0;
                                                }
 
-                                               /*
-                                               if(IsKeyDown(theKeyMap, MAC_S_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&!slomotogglekeydown){
-                                               FILE                    *tfile;
-                                               //tfile=fopen( ":Data:Maps:mapsave", "wb" );
-                                               if(whichlevel==0)tfile=fopen( ":Data:Maps:map1", "wb" );
-                                               else if(whichlevel==1)tfile=fopen( ":Data:Maps:map2", "wb" );
-                                               else if(whichlevel==2)tfile=fopen( ":Data:Maps:map3", "wb" );
-                                               else if(whichlevel==3)tfile=fopen( ":Data:Maps:map4", "wb" );
-                                               else if(whichlevel==4)tfile=fopen( ":Data:Maps:map5", "wb" );
-                                               else tfile=fopen( ":Data:Maps:mapsave", "wb" );
-
-                                               fwrite( &player[0].coords, 1, sizeof(XYZ), tfile );
-                                               fwrite( &player[0].rotation, 1, sizeof(float), tfile );
-                                               fwrite( &player[0].targetrotation, 1, sizeof(float), tfile );
-                                               fwrite( &player[0].num_weapons, 1, sizeof(int), tfile );
-                                               for(j=0;j<player[0].num_weapons;j++){
-                                               fwrite( &weapons.type[player[0].weaponids[j]], 1, sizeof(int), tfile );
-                                               }
-                                               fwrite( &environment, 1, sizeof(int), tfile );
-
-                                               fwrite( &objects.numobjects, 1, sizeof(int), tfile );
-                                               fwrite( &objects.type, 1, sizeof(int)*objects.numobjects, tfile );
-                                               fwrite( &objects.rotation, 1, sizeof(float)*objects.numobjects, tfile );
-                                               fwrite( &objects.position, 1, sizeof(XYZ)*objects.numobjects, tfile );
-                                               fwrite( &objects.scale, 1, sizeof(float)*objects.numobjects, tfile );
-
-                                               fwrite( &numplayers, 1, sizeof(int), tfile );
-                                               if(numplayers>1&&numplayers<maxplayers)
-                                               for(i=1;i<numplayers;i++){
-                                               fwrite( &player[i].coords, 1, sizeof(XYZ), tfile );
-                                               fwrite( &player[i].num_weapons, 1, sizeof(int), tfile );
-                                               for(j=0;j<player[i].num_weapons;j++){
-                                               fwrite( &weapons.type[player[i].weaponids[j]], 1, sizeof(int), tfile );
-                                               }
-                                               if(player[i].numwaypoints<30){
-                                               fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
-                                               fwrite( &player[i].waypoints, 1, sizeof(XYZ)*player[i].numwaypoints, tfile );
-                                               fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
-                                               //fwrite( &player[i].jumppath, 1, sizeof(bool), tfile );
-                                               }
-                                               else{
-                                               player[i].numwaypoints=0;
-                                               player[i].waypoint=0;
-                                               fwrite( &player[i].numwaypoints, 1, sizeof(int), tfile );
-                                               fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
-                                               fwrite( &player[i].waypoint, 1, sizeof(int), tfile );
-                                               }
-                                               }
-
-                                               fclose(tfile);
-
-                                               slomotogglekeydown=1;
-                                               }*/
-
-                                               if(!IsKeyDown(theKeyMap, MAC_B_KEY)&&!IsKeyDown(theKeyMap, MAC_F_KEY)&&!IsKeyDown(theKeyMap, MAC_K_KEY)&&!IsKeyDown(theKeyMap, MAC_S_KEY)){
+                                               if(!Input::isKeyDown(SDLK_b)&&!Input::isKeyDown(SDLK_f)&&!Input::isKeyDown(SDLK_k)&&!Input::isKeyDown(SDLK_s)){
                                                        slomotogglekeydown=0;
                                                }
 
 
-                                               if(IsKeyDown(theKeyMap, MAC_F_KEY)&&!slomotogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_f)&&!slomotogglekeydown&&debugmode){
                                                        player[0].onfire=1-player[0].onfire;
                                                        if(player[0].onfire){
                                                                player[0].CatchFire();
@@ -6180,14 +5112,8 @@ void     Game::Tick()
                                                        }
                                                        slomotogglekeydown=1;
                                                }
-                                               /*
-                                               if(IsKeyDown(theKeyMap, MAC_L_KEY)){
-                                               if(player[0].bleeding<=0)
-                                               player[0].DoBlood(1,255);
-                                               }*/
-
 
-                                               if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
+                                               if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -6207,7 +5133,7 @@ void      Game::Tick()
                                                                drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LCTRL)){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -6225,7 +5151,7 @@ void      Game::Tick()
                                                                drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled&&debugmode){
+                                               if(Input::isKeyDown(SDLK_m)&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&editorenabled&&debugmode){
                                                        //drawmode++;
                                                        //if(drawmode>2)drawmode=0;
                                                        if(objects.numobjects<max_objects-1){
@@ -6250,7 +5176,7 @@ void      Game::Tick()
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)&&editorenabled){
                                                        if(numplayers<maxplayers-1){
                                                                player[numplayers].scale=.2*5*player[0].scale;
                                                                player[numplayers].creature=rabbittype;
@@ -6398,7 +5324,7 @@ void      Game::Tick()
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)&&editorenabled){
                                                        if(player[numplayers-1].numwaypoints<90){
                                                                player[numplayers-1].waypoints[player[numplayers-1].numwaypoints]=player[0].coords;
                                                                player[numplayers-1].waypointtype[player[numplayers-1].numwaypoints]=editorpathtype;
@@ -6407,7 +5333,7 @@ void      Game::Tick()
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_P_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_p)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LCTRL)&&editorenabled){
                                                        if(numpathpoints<30){
                                                                bool connected,alreadyconnected;
                                                                connected=0;
@@ -6439,17 +5365,18 @@ void    Game::Tick()
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!drawmodetogglekeydown&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_PERIOD)&&!drawmodetogglekeydown&&editorenabled){
                                                        pathpointselected++;
                                                        if(pathpointselected>=numpathpoints)pathpointselected=-1;
                                                        drawmodetogglekeydown=1;
                                                }
-                                               if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){
                                                        pathpointselected--;
-                                                       if(pathpointselected<=-2)pathpointselected=numpathpoints-1;
+                                                       if(pathpointselected<=-2)
+                                                               pathpointselected=numpathpoints-1;
                                                        drawmodetogglekeydown=1;
                                                }
-                                               if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){
+                                               if(Input::isKeyDown(SDLK_COMMA)&&Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){
                                                        if(pathpointselected!=-1){
                                                                numpathpoints--;
                                                                pathpoint[pathpointselected]=pathpoint[numpathpoints];
@@ -6473,96 +5400,74 @@ void    Game::Tick()
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){
+                                               if(Input::isKeyDown(SDLK_m)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)&&debugmode){
                                                        editorenabled=1-editorenabled;
                                                        if(editorenabled){
                                                                player[0].damagetolerance=100000;
-                                                               player[0].damage=0;
-                                                               player[0].superpermanentdamage=0;
-                                                               player[0].bloodloss=0;
-                                                               player[0].deathbleeding=0;
-                                                       }
-                                                       if(!editorenabled){
+                                                       } else {
                                                                player[0].damagetolerance=200;
-                                                               player[0].damage=0;
-                                                               player[0].permanentdamage=0;
-                                                               player[0].superpermanentdamage=0;
-                                                               player[0].bloodloss=0;
-                                                               player[0].deathbleeding=0;
                                                        }
+                                                       player[0].damage=0; // these lines were in both if and else, but I think they would better fit in the if
+                                                       player[0].permanentdamage=0;
+                                                       player[0].superpermanentdamage=0;
+                                                       player[0].bloodloss=0;
+                                                       player[0].deathbleeding=0;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editortype--;
                                                        if(editortype==treeleavestype||editortype==10)editortype--;
                                                        if(editortype<0)editortype=firetype;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editortype++;
                                                        if(editortype==treeleavestype||editortype==10)editortype++;
                                                        if(editortype>firetype)editortype=0;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_LEFT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editorrotation-=multiplier*100;
                                                        if(editorrotation<-.01)editorrotation=-.01;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_RIGHT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editorrotation+=multiplier*100;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_UP)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editorsize+=multiplier;
                                                        drawmodetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){
                                                        editorsize-=multiplier;
                                                        if(editorsize<.1)editorsize=.1;
                                                        drawmodetogglekeydown=1;
                                                }
 
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){
                                                        mapradius-=multiplier*10;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){
                                                        mapradius+=multiplier*10;
                                                }
-                                               /*
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
-                                               mapcenter.x+=multiplier*20;
-                                               }
-
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
-                                               mapcenter.x-=multiplier*20;
-                                               }
-
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
-                                               mapcenter.z+=multiplier*20;
-                                               }
-
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
-                                               mapcenter.z-=multiplier*20;
-                                               }
-                                               */
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_UP)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){
                                                        editorrotation2+=multiplier*100;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){
+                                               if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){
                                                        editorrotation2-=multiplier*100;
                                                        if(editorrotation2<-.01)editorrotation2=-.01;
                                                }
-                                               if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){
+                                               if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)){
                                                        int closest=-1;
                                                        float closestdist=-1;
                                                        float distance;
@@ -6578,11 +5483,11 @@ void    Game::Tick()
                                                }
 
 
-                                               if(!IsKeyDown(theKeyMap, MAC_M_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&!IsKeyDown(theKeyMap, MAC_P_KEY)){
+                                               if(!Input::isKeyDown(SDLK_m)&&!Input::isKeyDown(SDLK_LEFT)&&!Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_PERIOD)&&!Input::isKeyDown(SDLK_RIGHT)&&!Input::isKeyDown(SDLK_DELETE)&&!Input::isKeyDown(SDLK_p)){
                                                        drawmodetogglekeydown=0;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_n)&&!Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){
                                                        //if(!player[0].skeleton.free)player[0].damage+=500;
                                                        player[0].RagDoll(0);
                                                        //player[0].spurt=1;
@@ -6605,7 +5510,7 @@ void      Game::Tick()
                                                        texturesizetogglekeydown=1;
                                                }
 
-                                               if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){
+                                               if(Input::isKeyDown(SDLK_n)&&Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){
 
                                                        int closest=-1;
                                                        float closestdist=-1;
@@ -6623,13 +5528,13 @@ void    Game::Tick()
                                                //Attack
                                                static bool playerrealattackkeydown=0;
 
-                                               if(!buttons[0])oldbutton=0;
-                                               if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0;
+                                               if(!Input::isKeyDown(MOUSEBUTTON1)&&!Input::isKeyDown(MOUSEBUTTON2))oldbutton=0;
+                                               if(!Input::isKeyDown(attackkey))oldattackkey=0;
                                                if(oldattackkey)player[0].attackkeydown=0;
                                                if(oldattackkey)playerrealattackkeydown=0;
-                                               if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey);
-                                               if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=IsKeyDown(theKeyMap, attackkey);
-                                               if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){
+                                               if(!oldattackkey)playerrealattackkeydown=Input::isKeyDown(attackkey);
+                                               if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=Input::isKeyDown(attackkey);
+                                               if(Input::isKeyDown(attackkey)&&!oldattackkey&&!player[0].backkeydown){
                                                        for(k=0;k<numplayers;k++){
                                                                if((player[k].targetanimation==swordslashanim||player[k].targetanimation==staffhitanim||player[k].targetanimation==staffspinhitanim)&&player[0].currentanimation!=dodgebackanim&&!player[k].skeleton.free)
                                                                        player[k].Reverse();
@@ -7215,78 +6120,7 @@ void     Game::Tick()
 
 
                                                        //pile
-                                                       /*
-                                                       XYZ tempdiff;
-                                                       XYZ tempoldpos;
-                                                       XYZ temp1,temp2;
-                                                       bool isgood;
-                                                       static float checkdelay;
-                                                       checkdelay-=multiplier;
-                                                       int m;
-                                                       static bool checkedcoll[maxplayers][maxplayers];
-                                                       static bool above[maxplayers];
-
-                                                       for(i=0;i<maxplayers;i++){
-                                                       for(j=0;j<maxplayers;j++){
-                                                       checkedcoll[i][j]=0;
-                                                       }
-                                                       }
-
-                                                       if(numplayers>1&&checkdelay<=0){
-                                                       checkdelay=.015;
-                                                       for(k=0;k<numplayers;k++){
-                                                       if(player[k].skeleton.free!=2)above[k]=-1;
-
-                                                       for(i=k;i<numplayers;i++){
-                                                       if(i==k)i++;
-                                                       if(i<numplayers)
-                                                       if(!checkedcoll[i][k]){
-                                                       checkedcoll[i][k]=1;
-                                                       checkedcoll[k][i]=1;
-                                                       if(player[i].skeleton.free&&player[k].skeleton.free)
-                                                       if(player[i].skeleton.free!=2||player[k].skeleton.free!=2)
-                                                       if(i!=k&&player[i].whichpatchx==player[k].whichpatchx&&player[i].whichpatchz==player[k].whichpatchz)
-                                                       if(player[i].coords.y>player[k].coords.y-3)
-                                                       if(player[i].coords.y<player[k].coords.y+3)
-                                                       if(player[i].coords.x>player[k].coords.x-3)
-                                                       if(player[i].coords.x<player[k].coords.x+3)
-                                                       if(player[i].coords.z>player[k].coords.z-3)
-                                                       if(player[i].coords.z<player[k].coords.z+3)
-                                                       if(findDistancefast(&player[i].coords,&player[k].coords)<3*((player[i].scale+player[k].scale)*2.5)*((player[i].scale+player[k].scale)*2.5)){
-                                                       int stuck,moving;
-                                                       if((player[i].skeleton.longdead>player[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){
-                                                       stuck=i;
-                                                       moving=k;
-                                                       }
-                                                       else
-                                                       {
-                                                       moving=i;
-                                                       stuck=k;
-                                                       }
-                                                       isgood=1;
-
-                                                       if(isgood){
-                                                       above[moving]=stuck;
-                                                       for(l=0;l<player[moving].skeleton.num_joints;l++){
-                                                       for(m=0;m<player[stuck].skeleton.num_joints;m++){
-                                                       while(findDistancefast(player[moving].skeleton.joints[l].position+player[moving].coords,player[stuck].skeleton.joints[m].position+player[stuck].coords)<.25)
-                                                       {
-                                                       player[moving].skeleton.joints[l].position.y+=.003;
-                                                       if(player[moving].skeleton.joints[l].velocity.y<-.05)player[moving].skeleton.joints[l].velocity.y+=.003/.015/2;
-
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-                                                       }
-
-                                                       */
-
-                                                       if(!IsKeyDown(theKeyMap, MAC_N_KEY)){
+                                                       if(!Input::isKeyDown(SDLK_n)){
                                                                texturesizetogglekeydown=0;
                                                        }
 
@@ -7299,52 +6133,27 @@ void    Game::Tick()
                                                        }
 
                                                        static bool respawnkeydown;
-                                                       if(!editorenabled&&(whichlevel!=-2&&(IsKeyDown(theKeyMap, MAC_Z_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)&&debugmode&&!editorenabled)||(IsKeyDown(theKeyMap, jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
+                                                       if(!editorenabled&&(whichlevel!=-2&&(Input::isKeyDown(SDLK_z)&&Input::isKeyDown(SDLK_LMETA)&&debugmode&&!editorenabled)||(Input::isKeyDown(jumpkey)&&!respawnkeydown&&!oldattackkey&&player[0].dead))){
                                                                targetlevel=whichlevel;
                                                                loading=1;
                                                                leveltime=5;
                                                        }
-                                                       if(!IsKeyDown(theKeyMap, jumpkey))respawnkeydown=0;
-                                                       if(IsKeyDown(theKeyMap, jumpkey))respawnkeydown=1;
+                                                       if(!Input::isKeyDown(jumpkey))respawnkeydown=0;
+                                                       if(Input::isKeyDown(jumpkey))respawnkeydown=1;
 
 
 
 
-                                                       if(whichlevel!=-2&&IsKeyDown(theKeyMap, MAC_K_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!slomotogglekeydown&&debugmode&&!editorenabled){
+                                                       if(whichlevel!=-2&&Input::isKeyDown(SDLK_k)&&Input::isKeyDown(SDLK_LSHIFT)&&!slomotogglekeydown&&debugmode&&!editorenabled){
                                                                targetlevel++;
                                                                if(targetlevel>numchallengelevels-1)targetlevel=0;
                                                                loading=1;
                                                                leveltime=5;
                                                                slomotogglekeydown=1;
                                                        }
-
-                                                       /*
-                                                       if(IsKeyDown(theKeyMap, MAC_Z_KEY)){
-                                                       //Respawn
-                                                       OPENAL_SetPaused(channels[whooshsound], true);
-                                                       changedelay=0;
-                                                       for(k=0;k<numplayers;k++){
-                                                       player[k].dead=0;
-                                                       player[k].damage=0;
-                                                       player[k].permanentdamage=0;
-                                                       if(player[k].skeleton.free==2)player[k].skeleton.free=1;
-                                                       player[k].aitype=passivetype;
-                                                       }
-                                                       player[0].aitype=playercontrolled;
-                                                       }
-                                                       */
-
                                                        static bool movekey;
                                                        static bool connected;
-                                                       /*player[0].forwardkeydown=IsKeyDown(theKeyMap, MAC_W_KEY);
-                                                       player[0].leftkeydown=IsKeyDown(theKeyMap, MAC_A_KEY);
-                                                       player[0].backkeydown=IsKeyDown(theKeyMap, MAC_S_KEY);
-                                                       player[0].rightkeydown=IsKeyDown(theKeyMap, MAC_D_KEY);
-                                                       player[0].jumpkeydown=IsKeyDown(theKeyMap, MAC_SPACE_KEY);
-                                                       player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_SHIFT_KEY);*/
-
-                                                       //if(!player[0].crouchkeydown)player[0].crouchkeydown=IsKeyDown(theKeyMap, MAC_CONTROL_KEY);
-
+                                                       
                for(int i=0;i<numplayers;i++){
                                                                if(!player[i].skeleton.free){
                                                                        oldtargetrotation=player[i].targetrotation;
@@ -8191,21 +7000,9 @@ void     Game::Tick()
                                                                                                                                player[i].throwkeydown=0;
 
                                                                                                                                if(player[i].avoidcollided>.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1);
-                                                                                                                               /*for(j=0;j<numplayers;j++){
-                                                                                                                               if(player[j].victim->id==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){
-                                                                                                                               player[i].crouchkeydown=1;
-                                                                                                                               }
-                                                                                                                               }*/
                                                                                                                                if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1;
                                                                                                                                else player[i].attackkeydown=0;
                                                                                                                                if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0;
-                                                                                                                               //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1;
-                                                                                                                               /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){
-                                                                                                                               player[i].attackkeydown=0;
-                                                                                                                               if(player[i].isIdle())player[i].crouchkeydown=1;
-                                                                                                                               player[i].forwardkeydown=0;
-                                                                                                                               player[i].aiupdatedelay=.02;
-                                                                                                                               }*/
 
                                                                                                                                if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){
                                                                                                                                        target=-2;
@@ -9043,42 +7840,7 @@ void     Game::Tick()
                                                        }
 
                                                        objects.DoStuff();
-                                                       /*
-                                                       player[0].righthandmorphstart=0;
-                                                       player[0].righthandmorphend=1;
-                                                       player[0].lefthandmorphstart=0;
-                                                       player[0].lefthandmorphend=1;
-                                                       player[0].headmorphstart=0;
-                                                       player[0].headmorphend=2;*/
-
-                                                       /*
-                                                       if(IsKeyDown( theKeyMap, MAC_P_KEY )){
-                                                       if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0;
-                                                       player[0].righthandmorphend=1;
-                                                       player[0].targetrighthandmorphness=1;
-
-                                                       if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0;
-                                                       player[0].lefthandmorphend=0;
-                                                       player[0].targetlefthandmorphness=1;
-
-                                                       if(player[0].headmorphend!=2)player[0].headmorphness=0;
-                                                       player[0].headmorphend=2;
-                                                       player[0].targetheadmorphness=1;
-                                                       }
-                                                       if(IsKeyDown( theKeyMap, MAC_L_KEY )){
-                                                       if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0;
-                                                       player[0].righthandmorphend=0;
-                                                       player[0].targetrighthandmorphness=1;
-
-                                                       if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0;
-                                                       player[0].lefthandmorphend=1;
-                                                       player[0].targetlefthandmorphness=1;
-
-                                                       if(player[0].headmorphend!=0)player[0].headmorphness=0;
-                                                       player[0].headmorphend=0;
-                                                       player[0].targetheadmorphness=1;
-                                                       }
-                                                       */
+                                                       
                                                        if(numenvsounds!=0)
                                                                for(j=numenvsounds-1;j>=0;j--){
                                                                        envsoundlife[j]-=multiplier;
@@ -9129,11 +7891,7 @@ void     Game::Tick()
                                                                                        OPENAL_SetPaused(channels[fireendsound], false);
                                                                                        OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
 
-                                                                                       flashr=1;
-                                                                                       flashg=0;
-                                                                                       flashb=0;
-                                                                                       flashamount=1;
-                                                                                       flashdelay=1;
+                                                                                       flash();
                                                                                }
                                                                                if(tutorialstage<51)
                                                                                        if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){
@@ -9152,11 +7910,7 @@ void     Game::Tick()
 
                                                                                                player[0].coords=(oldtemp+oldtemp2)/2;
 
-                                                                                               flashr=1;
-                                                                                               flashg=1;
-                                                                                               flashb=1;
-                                                                                               flashamount=1;
-                                                                                               flashdelay=1;
+                                                                                               flash();
                                                                                        }
                                                                                        if(tutorialstage>=14&&tutorialstage<50)
                                                                                                if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){
@@ -9238,14 +7992,13 @@ void    Game::Tick()
                }
        }
 
-       if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){
+       if(Input::isKeyDown(SDLK_F1)&&!freezetogglekeydown){
                Screenshot();
                freezetogglekeydown=1;
        }
 }
 
 void   Game::TickOnce(){
-       //if(!console){
        if(!mainmenu)
                if(directing||indialogue==-1){
                        rotation+=deltah*.7;
@@ -9255,8 +8008,6 @@ void      Game::TickOnce(){
                        if(rotation2<-70)rotation2=-70;
                }
                if(mainmenu)rotation+=multiplier*5;
-      
-               //}
 }
 
 void   Game::TickOnceAfter(){
@@ -9334,14 +8085,6 @@ void     Game::TickOnceAfter(){
                else musicvolume[1]-=multiplier*450;
                if(musicselected==stream_music3)musicvolume[2]+=multiplier*450;
                else musicvolume[2]-=multiplier*450;
-               /*
-               if(musicselected==music1)musicvolume[0]+=multiplier*100;
-               else musicvolume[0]-=multiplier*450;
-               if(musicselected==music2)musicvolume[1]+=multiplier*150;
-               else if(player[0].dead)musicvolume[1]-=multiplier*450;
-               else musicvolume[1]-=multiplier*100;
-               if(musicselected==music3)musicvolume[2]+=multiplier*450;
-               else musicvolume[2]-=multiplier*450;*/
 
                for(i=0;i<3;i++){
                        if(musicvolume[i]<0)musicvolume[i]=0;
@@ -9466,24 +8209,19 @@ void    Game::TickOnceAfter(){
                                                                //high scores, awards, win
                                                                if(campaign){
                                                                        won=1;
-                                                                       accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
-                                                                       accountcampaignchoicesmade[accountactive]++;
+                                                                       accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime);
+                                                                       /*accountcampaignchoices[accountactive][accountactive->getCampaignChoicesMade()]=whichchoice;
+                                                                       accountactive->getCampaignChoicesMade()++;
                                                                        accountcampaignscore[accountactive]+=bonustotal;
-                                                                       scoreadded=1;
                                                                        accountcampaigntime[accountactive]+=leveltime;
-                                                                       if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];
-
-                                                                       //if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
+                                                                       if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])
+                                                                               accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];*/
+                                                                       scoreadded=1;
                                                                }
                                                                else
                                                                {
                                                                        won=1;
-                                                                       if(!debugmode){
-                                                                               if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal;
-                                                                               if(accountfasttime[accountactive][whichlevel]==0||leveltime<accountfasttime[accountactive][whichlevel])accountfasttime[accountactive][whichlevel]=leveltime;
-                                                                       }
-                                                                       if(accountprogress[accountactive]<whichlevel+1)accountprogress[accountactive]=whichlevel+1;
-
+                                                                       accountactive->winLevel(whichlevel,bonustotal-startbonustotal,leveltime);
                                                                }
                                                        }
                                        }
@@ -9502,21 +8240,9 @@ void     Game::TickOnceAfter(){
                                                        if(changedelay!=-999)changedelay-=multiplier/7;
                                                        if(player[0].dead)targetlevel=whichlevel;
                                                        if(loading==2&&!campaign){
-                                                               flashr=1;
-                                                               flashg=0;
-                                                               flashb=0;
-                                                               flashamount=1;
-                                                               flashdelay=1;
-                                                               loadtime=0;
+                                                               flash();
 
-                                                               float gLoc[3]={0,0,0};
-                                                               float vel[3]={0,0,0};
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
+                                                               fireSound(firestartsound);
 
                                                                if(!player[0].dead&&targetlevel!=whichlevel){
                                                                        startbonustotal=bonustotal;
@@ -9524,31 +8250,17 @@ void    Game::TickOnceAfter(){
                                                                if(!player[0].dead)Loadlevel(targetlevel);
                                                                if(player[0].dead)Loadlevel(whichlevel);
 
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[fireendsound], 256);
-                                                               OPENAL_SetPaused(channels[fireendsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
+                                                               fireSound();
 
                                                                loading=3;
                                                        }
                                                        if(loading==2&&targetlevel==whichlevel){
-                                                               flashr=1;
-                                                               flashg=0;
-                                                               flashb=0;
-                                                               flashamount=1;
-                                                               flashdelay=1;
+                                                               flash();
                                                                loadtime=0;
 
                                                                float gLoc[3]={0,0,0};
                                                                float vel[3]={0,0,0};
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
+                                                               fireSound(firestartsound);
 
                                                                for(i=0;i<255;i++){
                                                                        mapname[i]='\0';
@@ -9564,15 +8276,10 @@ void    Game::TickOnceAfter(){
                                                                mapname[8]='p';
                                                                mapname[9]='s';
                                                                mapname[10]=':';
-                                                               strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]);
+                                                               strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]);
                                                                Loadlevel(mapname);
 
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
-                                                               PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[fireendsound], 256);
-                                                               OPENAL_SetPaused(channels[fireendsound], false);
-                                                               OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
+                                                               fireSound();
 
                                                                loading=3;
                                                        }
@@ -9602,25 +8309,14 @@ void    Game::TickOnceAfter(){
                                                                if(!stealthloading){
                                                                        float gLoc[3]={0,0,0};
                                                                        float vel[3]={0,0,0};
-                                                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
-                                                                       PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                                       OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                                       OPENAL_SetVolume(channels[firestartsound], 256);
-                                                                       OPENAL_SetPaused(channels[firestartsound], false);
-                                                                       OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
-                                                                       flashr=1;
-                                                                       flashg=0;
-                                                                       flashb=0;
-                                                                       flashamount=1;
-                                                                       flashdelay=1;
+                                                                       fireSound(firestartsound);
+
+                                                                       flash();
                                                                }
 
                                                                startbonustotal=0;
 
                                                                ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt"));
-                                                               //campaignnumlevels=0;
-                                                               //accountcampaignchoicesmade[accountactive]=0;
                                                                ipstream.ignore(256,':');
                                                                ipstream >> campaignnumlevels;
                                                                for(i=0;i<campaignnumlevels;i++){
@@ -9663,13 +8359,13 @@ void    Game::TickOnceAfter(){
 
                                                                levelorder[0]=0;
                                                                levelvisible[0]=1;
-                                                               if(accountcampaignchoicesmade[accountactive])
-                                                                       for(i=0;i<accountcampaignchoicesmade[accountactive];i++){
-                                                                               levelorder[i+1]=campaignnextlevel[levelorder[i]][accountcampaignchoices[accountactive][i]];
+                                                               if(accountactive->getCampaignChoicesMade())
+                                                                       for(i=0;i<accountactive->getCampaignChoicesMade();i++){
+                                                                               levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)];
                                                                                levelvisible[levelorder[i+1]]=1;
                                                                        }
                                                                        int whichlevelstart;
-                                                                       whichlevelstart=accountcampaignchoicesmade[accountactive]-1;
+                                                                       whichlevelstart=accountactive->getCampaignChoicesMade()-1;
                                                                        if(whichlevelstart<0){
                                                                                campaignchoicenum=1;
                                                                                campaignchoicewhich[0]=0;
@@ -9706,10 +8402,6 @@ void     Game::TickOnceAfter(){
                                                                        mapname[9]='s';
                                                                        mapname[10]=':';
 
-                                                                       //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice;
-                                                                       //accountcampaignchoicesmade[accountactive]++;
-
-
                                                                        strcat(mapname,campaignmapname[campaignchoicewhich[0]]);
                                                                        whichchoice=0;
                                                                        visibleloading=1;
index eae0bd07f0590fbda565f78b41bd0c97c2a3068e..d55167b01f9513013310a4cfb43ec456deec6e41 100644 (file)
@@ -42,8 +42,7 @@ OPENAL_SAMPLE *samp[100] = {0};
 OPENAL_STREAM * strm[20] = {0};
 int channels[100] = {0};
 
-float volume = 0;bool buttons[3] = {0};
-bool oldbuttons[3] = {0};
+float volume = 0;
 bool ismotionblur = 0;
 float usermousesensitivity = 0;
 bool floatjump = 0;
@@ -229,20 +228,6 @@ float bonustotal = 0;
 float startbonustotal = 0;
 float bonustime = 0;
 
-int numaccounts = 0;
-int accountactive = 0;
-int accountdifficulty[10] = {0};
-int accountprogress[10] = {0};
-float accountpoints[10] = {0};
-float accounthighscore[10][50] = {0};
-float accountfasttime[10][50] = {0};
-bool accountunlocked[10][60] = {0};
-char accountname[10][256] = {0};
-float accountcampaignhighscore[10] = {0};
-float accountcampaignfasttime[10] = {0};
-float accountcampaignscore[10] = {0};
-float accountcampaigntime[10] = {0};
-int accountcampaignchoicesmade[10] = {0};int accountcampaignchoices[10][5000] = {0};
 bool won = 0;
 
 
@@ -272,4 +257,4 @@ bool gamestarted = 0;
 StereoMode stereomode =  stereoNone;
 StereoMode newstereomode = stereoNone;
 float stereoseparation = 0.05;
-bool  stereoreverse = false;
\ No newline at end of file
+bool  stereoreverse = false;
index b68c60bcfd37bc3d4e03960d401d03430aa5ddea..8cfe83618deecc6249254410a40a5c01367d4f4b 100644 (file)
@@ -61,7 +61,6 @@ static bool save_png(const char * fname);
 #pragma comment(lib, "glaux.lib")
 #endif
 
-extern bool buttons[3];
 extern float multiplier;
 extern float sps;
 extern float realmultiplier;
@@ -119,20 +118,15 @@ static SDL_Rect *hardcoded_resolutions[] = {
 
 unsigned int resolutionDepths[8][2] = {0};
 
-bool selectDetail(int & width, int & height, int & bpp, int & detail);
 int closestResolution(int width, int height);
 int resolutionID(int width, int height);
 
 void ReportError (char * strError);
 
-void SetupDSpFullScreen();
-void ShutdownDSp();
-
 void DrawGL(Game & game);
 
 void CreateGLWindow (void);
 Boolean SetUp (Game & game);
-void DoKey (SInt8 theKey, SInt8 theCode);
 void DoUpdate (Game & game);
 
 void DoEvent (void);
@@ -196,10 +190,7 @@ static void GLAPIENTRY glDeleteTextures_doNothing(GLsizei n, const GLuint *textu
 
 void sdlGetCursorPos(POINT *pt)
 {
-    int x, y;
-    SDL_GetMouseState(&x, &y);
-    pt->x = x;
-    pt->y = y;
+    SDL_GetMouseState(&(pt->x), &(pt->y));
 }
 #define GetCursorPos(x) sdlGetCursorPos(x)
 #define SetCursorPos(x, y) SDL_WarpMouse(x, y)
@@ -281,16 +272,6 @@ void ReportError (char * strError)
        */
 }
 
-void SetupDSpFullScreen ()
-{
-}
-
-
-void ShutdownDSp ()
-{
-}
-
-
 //-----------------------------------------------------------------------------------------------------------------------
 
 // OpenGL Drawing
@@ -306,7 +287,7 @@ void DrawGL (Game & game)
 }
 
 
-static KeyMap g_theKeys;
+/*static KeyMap g_theKeys;
 
 void SetKey( int key)
 {
@@ -321,110 +302,11 @@ void ClearKey( int key)
 void GetKeys(  unsigned char theKeys[16])
 {
     memcpy( theKeys, &g_theKeys, 16);
-}
+}*/
 
 Boolean Button()
 {
-    return g_button;
-}
-
-
-#define MAX_SDLKEYS SDLK_LAST
-static unsigned short KeyTable[MAX_SDLKEYS];
-
-static void initSDLKeyTable(void)
-{
-    memset(KeyTable, 0xFF, sizeof (KeyTable));
-    KeyTable[SDLK_BACKSPACE] = MAC_DELETE_KEY;
-    KeyTable[SDLK_TAB] = MAC_TAB_KEY;
-    KeyTable[SDLK_RETURN] = MAC_RETURN_KEY;
-    KeyTable[SDLK_ESCAPE] = MAC_ESCAPE_KEY;
-    KeyTable[SDLK_SPACE] = MAC_SPACE_KEY;
-    KeyTable[SDLK_PAGEUP] = MAC_PAGE_UP_KEY;
-    KeyTable[SDLK_PAGEDOWN] = MAC_PAGE_DOWN_KEY;
-    KeyTable[SDLK_END] = MAC_END_KEY;
-    KeyTable[SDLK_HOME] = MAC_HOME_KEY;
-    KeyTable[SDLK_LEFT] = MAC_ARROW_LEFT_KEY;
-    KeyTable[SDLK_UP] = MAC_ARROW_UP_KEY;
-    KeyTable[SDLK_RIGHT] = MAC_ARROW_RIGHT_KEY;
-    KeyTable[SDLK_DOWN] = MAC_ARROW_DOWN_KEY;
-    KeyTable[SDLK_INSERT] = MAC_INSERT_KEY;
-    KeyTable[SDLK_DELETE] = MAC_DEL_KEY;
-    KeyTable[SDLK_0] = MAC_0_KEY;
-    KeyTable[SDLK_1] = MAC_1_KEY;
-    KeyTable[SDLK_2] = MAC_2_KEY;
-    KeyTable[SDLK_3] = MAC_3_KEY;
-    KeyTable[SDLK_4] = MAC_4_KEY;
-    KeyTable[SDLK_5] = MAC_5_KEY;
-    KeyTable[SDLK_6] = MAC_6_KEY;
-    KeyTable[SDLK_7] = MAC_7_KEY;
-    KeyTable[SDLK_8] = MAC_8_KEY;
-    KeyTable[SDLK_9] = MAC_9_KEY;
-    KeyTable[SDLK_a] = MAC_A_KEY;
-    KeyTable[SDLK_b] = MAC_B_KEY;
-    KeyTable[SDLK_c] = MAC_C_KEY;
-    KeyTable[SDLK_d] = MAC_D_KEY;
-    KeyTable[SDLK_e] = MAC_E_KEY;
-    KeyTable[SDLK_f] = MAC_F_KEY;
-    KeyTable[SDLK_g] = MAC_G_KEY;
-    KeyTable[SDLK_h] = MAC_H_KEY;
-    KeyTable[SDLK_i] = MAC_I_KEY;
-    KeyTable[SDLK_j] = MAC_J_KEY;
-    KeyTable[SDLK_k] = MAC_K_KEY;
-    KeyTable[SDLK_l] = MAC_L_KEY;
-    KeyTable[SDLK_m] = MAC_M_KEY;
-    KeyTable[SDLK_n] = MAC_N_KEY;
-    KeyTable[SDLK_o] = MAC_O_KEY;
-    KeyTable[SDLK_p] = MAC_P_KEY;
-    KeyTable[SDLK_q] = MAC_Q_KEY;
-    KeyTable[SDLK_r] = MAC_R_KEY;
-    KeyTable[SDLK_s] = MAC_S_KEY;
-    KeyTable[SDLK_t] = MAC_T_KEY;
-    KeyTable[SDLK_u] = MAC_U_KEY;
-    KeyTable[SDLK_v] = MAC_V_KEY;
-    KeyTable[SDLK_w] = MAC_W_KEY;
-    KeyTable[SDLK_x] = MAC_X_KEY;
-    KeyTable[SDLK_y] = MAC_Y_KEY;
-    KeyTable[SDLK_z] = MAC_Z_KEY;
-    KeyTable[SDLK_KP0] = MAC_NUMPAD_0_KEY;
-    KeyTable[SDLK_KP1] = MAC_NUMPAD_1_KEY;
-    KeyTable[SDLK_KP2] = MAC_NUMPAD_2_KEY;
-    KeyTable[SDLK_KP3] = MAC_NUMPAD_3_KEY;
-    KeyTable[SDLK_KP4] = MAC_NUMPAD_4_KEY;
-    KeyTable[SDLK_KP5] = MAC_NUMPAD_5_KEY;
-    KeyTable[SDLK_KP6] = MAC_NUMPAD_6_KEY;
-    KeyTable[SDLK_KP7] = MAC_NUMPAD_7_KEY;
-    KeyTable[SDLK_KP8] = MAC_NUMPAD_8_KEY;
-    KeyTable[SDLK_KP9] = MAC_NUMPAD_9_KEY;
-    KeyTable[SDLK_KP_MULTIPLY] = MAC_NUMPAD_ASTERISK_KEY;
-    KeyTable[SDLK_KP_PLUS] = MAC_NUMPAD_PLUS_KEY;
-    KeyTable[SDLK_KP_ENTER] = MAC_NUMPAD_ENTER_KEY;
-    KeyTable[SDLK_KP_MINUS] = MAC_NUMPAD_MINUS_KEY;
-    KeyTable[SDLK_KP_PERIOD] = MAC_NUMPAD_PERIOD_KEY;
-    KeyTable[SDLK_KP_DIVIDE] = MAC_NUMPAD_SLASH_KEY;
-    KeyTable[SDLK_F1] = MAC_F1_KEY;
-    KeyTable[SDLK_F2] = MAC_F2_KEY;
-    KeyTable[SDLK_F3] = MAC_F3_KEY;
-    KeyTable[SDLK_F4] = MAC_F4_KEY;
-    KeyTable[SDLK_F5] = MAC_F5_KEY;
-    KeyTable[SDLK_F6] = MAC_F6_KEY;
-    KeyTable[SDLK_F7] = MAC_F7_KEY;
-    KeyTable[SDLK_F8] = MAC_F8_KEY;
-    KeyTable[SDLK_F9] = MAC_F9_KEY;
-    KeyTable[SDLK_F10] = MAC_F10_KEY;
-    KeyTable[SDLK_F11] = MAC_F11_KEY;
-    KeyTable[SDLK_F12] = MAC_F12_KEY;
-    KeyTable[SDLK_SEMICOLON] = MAC_SEMICOLON_KEY;
-    KeyTable[SDLK_PLUS] = MAC_PLUS_KEY;
-    KeyTable[SDLK_COMMA] = MAC_COMMA_KEY;
-    KeyTable[SDLK_MINUS] = MAC_MINUS_KEY;
-    KeyTable[SDLK_PERIOD] = MAC_PERIOD_KEY;
-    KeyTable[SDLK_SLASH] = MAC_SLASH_KEY;
-    KeyTable[SDLK_BACKQUOTE] = MAC_TILDE_KEY;
-    KeyTable[SDLK_LEFTBRACKET] = MAC_LEFTBRACKET_KEY;
-    KeyTable[SDLK_BACKSLASH] = MAC_BACKSLASH_KEY;
-    KeyTable[SDLK_RIGHTBRACKET] = MAC_RIGHTBRACKET_KEY;
-    KeyTable[SDLK_QUOTE] = MAC_APOSTROPHE_KEY;
+    return SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_LEFT);
 }
 
 static inline int clamp_sdl_mouse_button(Uint8 button)
@@ -442,7 +324,6 @@ static inline int clamp_sdl_mouse_button(Uint8 button)
 static void sdlEventProc(const SDL_Event &e, Game &game)
 {
     int val;
-    bool skipkey = false;
     SDLMod mod;
 
     switch(e.type)
@@ -452,93 +333,17 @@ static void sdlEventProc(const SDL_Event &e, Game &game)
             game.deltav += e.motion.yrel;
             return;
 
-               case SDL_MOUSEBUTTONDOWN:
-                       {
-                val = clamp_sdl_mouse_button(e.button.button);
-                if ((val >= 0) && (val <= 2))
-                {
-                    if (val == 0)
-                                   g_button = true;
-                               buttons[val] = true;
-                }
-                       }
-                       return;
-
-               case SDL_MOUSEBUTTONUP:
-                       {
-                val = clamp_sdl_mouse_button(e.button.button);
-                if ((val >= 0) && (val <= 2))
-                {
-                    if (val == 0)
-                                   g_button = false;
-                               buttons[val] = false;
-                }
-                       }
-            return;
-
         case SDL_KEYDOWN:
-            if (e.key.keysym.sym == SDLK_g)
-            {
-                if (e.key.keysym.mod & KMOD_CTRL)
-                {
-                    skipkey = true;
-                    SDL_GrabMode mode = SDL_GRAB_ON;
-                    if ((SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) == 0)
-                    {
-                        mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
-                        mode = (mode==SDL_GRAB_ON) ? SDL_GRAB_OFF:SDL_GRAB_ON;
-                    }
-                    SDL_WM_GrabInput(mode);
-                }
-            }
-
-            else if (e.key.keysym.sym == SDLK_RETURN)
-            {
-                if (e.key.keysym.mod & KMOD_ALT)
-                {
-                    skipkey = true;
-                    SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
-                }
-            }
-
-            if ((!skipkey) && (e.key.keysym.sym < SDLK_LAST))
-            {
-                if (KeyTable[e.key.keysym.sym] != 0xffff)
-                    SetKey(KeyTable[e.key.keysym.sym]);
+            if ((e.key.keysym.sym == SDLK_g) &&
+                               (e.key.keysym.mod & KMOD_CTRL) &&
+                               !(SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) ) {
+                               SDL_WM_GrabInput( ((SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON) ? SDL_GRAB_OFF:SDL_GRAB_ON) );
+                       } else if ( (e.key.keysym.sym == SDLK_RETURN) && (e.key.keysym.mod & KMOD_ALT) ) {
+                               SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
             }
-
-            mod = SDL_GetModState();
-            if (mod & KMOD_CTRL)
-                SetKey(MAC_CONTROL_KEY);
-            if (mod & KMOD_ALT)
-                SetKey(MAC_OPTION_KEY);
-            if (mod & KMOD_META)
-                SetKey(MAC_COMMAND_KEY);
-            if (mod & KMOD_SHIFT)
-                SetKey(MAC_SHIFT_KEY);
-            if (mod & KMOD_CAPS)
-                SetKey(MAC_CAPS_LOCK_KEY);
-
             return;
 
         case SDL_KEYUP:
-            if (e.key.keysym.sym < SDLK_LAST)
-            {
-                if (KeyTable[e.key.keysym.sym] != 0xffff)
-                    ClearKey(KeyTable[e.key.keysym.sym]);
-            }
-
-            mod = SDL_GetModState();
-            if ((mod & KMOD_CTRL) == 0)
-                ClearKey(MAC_CONTROL_KEY);
-            if ((mod & KMOD_ALT) == 0)
-                ClearKey(MAC_OPTION_KEY);
-            if ((mod & KMOD_META) == 0)
-                ClearKey(MAC_COMMAND_KEY);
-            if ((mod & KMOD_SHIFT) == 0)
-                ClearKey(MAC_SHIFT_KEY);
-            if ((mod & KMOD_CAPS) == 0)
-                ClearKey(MAC_CAPS_LOCK_KEY);
             return;
     }
 }
@@ -566,8 +371,12 @@ Boolean SetUp (Game & game)
        
        DefaultSettings(game);
 
-       selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail);
-
+    if (!SDL_WasInit(SDL_INIT_VIDEO))
+        if (SDL_Init(SDL_INIT_VIDEO) == -1)
+        {
+            fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+            return false;
+        }
        if(!LoadSettings(game)) {
                fprintf(stderr, "Failed to load config, creating default\n");
                SaveSettings(game);
@@ -576,63 +385,48 @@ Boolean SetUp (Game & game)
                kBitsPerPixel=16;
        }
 
+       if (SDL_GL_LoadLibrary(NULL) == -1)
+       {
+               fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError());
+               SDL_Quit();
+               return false;
+       }
 
-       selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail);
-
-       SetupDSpFullScreen();
-
-
-    if (!SDL_WasInit(SDL_INIT_VIDEO))
-    {
-        if (SDL_Init(SDL_INIT_VIDEO) == -1)
-        {
-            fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
-            return false;
-        }
-
-        if (SDL_GL_LoadLibrary(NULL) == -1)
-        {
-            fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError());
-            SDL_Quit();
-            return false;
-        }
-
-        SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
-        if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) )
-            res = hardcoded_resolutions;
+       SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
+       if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) )
+               res = hardcoded_resolutions;
 
-        // reverse list (it was sorted biggest to smallest by SDL)...
-        int count;
-        for (count = 0; res[count]; count++)
-        {
-            if ((res[count]->w < 640) || (res[count]->h < 480))
-                break;   // sane lower limit.
-        }
+       // reverse list (it was sorted biggest to smallest by SDL)...
+       int count;
+       for (count = 0; res[count]; count++)
+       {
+               if ((res[count]->w < 640) || (res[count]->h < 480))
+                       break;   // sane lower limit.
+       }
 
-        static SDL_Rect *resolutions_block = NULL;
-        resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count);
-        resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1));
-        if ((resolutions_block == NULL) || (resolutions == NULL))
-        {
-            SDL_Quit();
-            fprintf(stderr, "Out of memory!\n");
-            return false;
-        }
+       static SDL_Rect *resolutions_block = NULL;
+       resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count);
+       resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1));
+       if ((resolutions_block == NULL) || (resolutions == NULL))
+       {
+               SDL_Quit();
+               fprintf(stderr, "Out of memory!\n");
+               return false;
+       }
 
-        resolutions[count--] = NULL;
-        for (int i = 0; count >= 0; i++, count--)
-        {
-            memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect));
-            resolutions[count] = &resolutions_block[count];
-        }
+       resolutions[count--] = NULL;
+       for (int i = 0; count >= 0; i++, count--)
+       {
+               memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect));
+               resolutions[count] = &resolutions_block[count];
+       }
 
-        if (cmdline("showresolutions"))
-        {
-            printf("Resolutions we think are okay:\n");
-            for (int i = 0; resolutions[i]; i++)
-                printf("  %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h);
-        }
-    }
+       if (cmdline("showresolutions"))
+       {
+               printf("Resolutions we think are okay:\n");
+               for (int i = 0; resolutions[i]; i++)
+                       printf("  %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h);
+       }
 
     Uint32 sdlflags = SDL_OPENGL;
     if (!cmdline("windowed"))
@@ -768,19 +562,6 @@ static void DoMouse(Game & game)
 
 }
 
-
-
-// --------------------------------------------------------------------------
-
-void DoKey (SInt8 theKey, SInt8 theCode)
-{
-       // do nothing
-}
-
-// --------------------------------------------------------------------------
-
-
-
 void DoFrameRate (int update)
 {      
        static long frames = 0;
@@ -796,9 +577,9 @@ void DoFrameRate (int update)
                deltaTime /= 1000.0;
 
        multiplier=deltaTime;
-       if(multiplier<.001)multiplier=.001;
-       if(multiplier>10)multiplier=10;
-       if(update)frametime = currTime; // reset for next time interval
+       if(multiplier<.001) multiplier=.001;
+       if(multiplier>10) multiplier=10;
+       if(update) frametime = currTime;        // reset for next time interval
 
        deltaTime = (float) AbsoluteDeltaToDuration (currTime, time);
 
@@ -1062,9 +843,9 @@ int main(int argc, char **argv)
 
        LOGFUNC;
 
-       memset( &g_theKeys, 0, sizeof( KeyMap));
+       //memset( &g_theKeys, 0, sizeof( KeyMap));
 
-    initSDLKeyTable();
+    //initSDLKeyTable();
 
        try
        {
@@ -1092,17 +873,18 @@ int main(int argc, char **argv)
                                        game.deltah = 0;
                                        game.deltav = 0;
                                        SDL_Event e;
-                                       // message pump
-                                       while( SDL_PollEvent( &e ) )
-                                       {
-                                               if( e.type == SDL_QUIT )
+                                       if(!game.isWaiting()) {
+                                               // message pump
+                                               while( SDL_PollEvent( &e ) )
                                                {
-                                                       gDone=true;
-                                                       break;
+                                                       if( e.type == SDL_QUIT )
+                                                       {
+                                                               gDone=true;
+                                                               break;
+                                                       }
+                                                       sdlEventProc(e, game);
                                                }
-                                               sdlEventProc(e, game);
                                        }
-                               
 
                                        // game
                                        DoUpdate(game);
@@ -1126,21 +908,7 @@ int main(int argc, char **argv)
                pgame = 0;
 
                CleanUp ();
-//             if(game.registernow){
-               if(regnow)
-               {
-            #if (defined(__APPLE__) && defined(__MACH__))
-            launch_web_browser("http://www.wolfire.com/purchase/lugaru/mac");
-            #elif PLATFORM_LINUX
-            launch_web_browser("http://www.wolfire.com/purchase/lugaru/linux");
-            #else
-            launch_web_browser("http://www.wolfire.com/purchase/lugaru/pc");
-            #endif
-               }
-
-        #if PLATFORM_LINUX  // (this may not be necessary any more.)
-        _exit(0);  // !!! FIXME: hack...crashes on exit!
-        #endif
+               
                return 0;
        }
        catch (const std::exception& error)
@@ -1164,19 +932,6 @@ int main(int argc, char **argv)
 
        // --------------------------------------------------------------------------
 
-
-
-       bool selectDetail(int & width, int & height, int & bpp, int & detail)
-       {
-               bool res = true;
-
-               // currently with SDL, we just use whatever is requested
-               //  and don't care.  --ryan.
-               
-
-               return res;
-       }
-
        extern int channels[100];
        extern OPENAL_SAMPLE * samp[100];
        extern OPENAL_STREAM * strm[20];
@@ -1236,25 +991,15 @@ int main(int argc, char **argv)
 
        bool LoadImage(const char * fname, TGAImageRec & tex)
        {
-               bool res = true;
-
                if ( tex.data == NULL )
-               {
                        return false;
-               }
-
-       
-        res = load_image(fname, tex);
-    
-
-               return res;
+               else
+                       return load_image(fname, tex);
        }
 
        void ScreenShot(const char * fname)
        {
-  
         save_image(fname);
-  
        }
 
 
index 6a1def9bf91bff686c2d975bb43dd22f7e63a386..d1ac29f591e27a9b884e11945facdcfa0b4cd8c9 100644 (file)
@@ -6166,23 +6166,6 @@ void     Person::DoStuff(){
                                                                tempcoord+=objects.position[i];
                                                        }
                                                        if(findDistancefastflat(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*8&&findDistancefast(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*300&&tempcoord.y>objects.position[i].y+3*objects.scale[i]){
-                                                               /*if(onfire){
-                                                               if(!objects.onfire[i]){
-                                                               float gLoc[3];
-                                                               float vel[3];
-                                                               gLoc[0]=objects.position[i].x;
-                                                               gLoc[1]=objects.position[i].y;
-                                                               gLoc[2]=objects.position[i].z;
-                                                               vel[0]=0;
-                                                               vel[1]=0;
-                                                               vel[2]=0;
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               objects.onfire[i]=1;
-                                                               }
-                                                               }*/
                                                                if(objects.messedwith[i]<=0){
                                                                        XYZ tempvel;
                                                                        XYZ pos;
@@ -6276,8 +6259,6 @@ void      Person::DoStuff(){
                                                }
                                        }
                                        speechdelay=.3;
-                                       //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
-                                       //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
 
                                        if(whichsound!=-1){
                                                PlaySoundEx( whichsound, samp[whichsound], NULL, true);
index b2c761ddbe312dbe1fabc825ab2d19b100ac8aa4..2ee6ad19f00d4ae74764f74ceabe15ad95663082 100644 (file)
@@ -1,6 +1,6 @@
 #include "Settings.h"
 #include "Game.h"
-
+#include "Input.h"
 
 void DefaultSettings(Game &game) {
        detail=1;
@@ -31,16 +31,16 @@ void DefaultSettings(Game &game) {
        vblsync=0;
        debugmode=0;
        
-       game.crouchkey=MAC_SHIFT_KEY;
-       game.jumpkey=MAC_SPACE_KEY;
-       game.leftkey=MAC_A_KEY;
-       game.forwardkey=MAC_W_KEY;
-       game.backkey=MAC_S_KEY;
-       game.rightkey=MAC_D_KEY;
-       game.drawkey=MAC_E_KEY;
-       game.throwkey=MAC_Q_KEY;
-       game.attackkey=MAC_MOUSEBUTTON1;
-       game.chatkey=MAC_T_KEY;
+       game.crouchkey=SDLK_LSHIFT;
+       game.jumpkey=SDLK_SPACE;
+       game.leftkey=SDLK_a;
+       game.forwardkey=SDLK_w;
+       game.backkey=SDLK_s;
+       game.rightkey=SDLK_d;
+       game.drawkey=SDLK_e;
+       game.throwkey=SDLK_q;
+       game.attackkey=MOUSEBUTTON1;
+       game.chatkey=SDLK_t;
 }
 
 void SaveSettings(Game &game) {
@@ -99,25 +99,25 @@ void SaveSettings(Game &game) {
        opstream << "\nVolume:\n";
        opstream << volume;
        opstream << "\nForward key:\n";
-       opstream << KeyToChar(game.forwardkey);
+       opstream << Input::keyToChar(game.forwardkey);
        opstream << "\nBack key:\n";
-       opstream << KeyToChar(game.backkey);
+       opstream << Input::keyToChar(game.backkey);
        opstream << "\nLeft key:\n";
-       opstream << KeyToChar(game.leftkey);
+       opstream << Input::keyToChar(game.leftkey);
        opstream << "\nRight key:\n";
-       opstream << KeyToChar(game.rightkey);
+       opstream << Input::keyToChar(game.rightkey);
        opstream << "\nJump key:\n";
-       opstream << KeyToChar(game.jumpkey);
+       opstream << Input::keyToChar(game.jumpkey);
        opstream << "\nCrouch key:\n";
-       opstream << KeyToChar(game.crouchkey);
+       opstream << Input::keyToChar(game.crouchkey);
        opstream << "\nDraw key:\n";
-       opstream << KeyToChar(game.drawkey);
+       opstream << Input::keyToChar(game.drawkey);
        opstream << "\nThrow key:\n";
-       opstream << KeyToChar(game.throwkey);
+       opstream << Input::keyToChar(game.throwkey);
        opstream << "\nAttack key:\n";
-       opstream << KeyToChar(game.attackkey);
+       opstream << Input::keyToChar(game.attackkey);
        opstream << "\nChat key:\n";
-       opstream << KeyToChar(game.chatkey);
+       opstream << Input::keyToChar(game.chatkey);
        opstream << "\nDamage bar:\n";
        opstream << showdamagebar;
        opstream << "\nStereoMode:\n";
@@ -141,6 +141,7 @@ bool LoadSettings(Game &game) {
        printf("Loading config\n");
        while(!ipstream.eof()) {
                ipstream.getline( setting, sizeof(setting) );
+               printf("setting : %s\n",setting);
                
                // skip blank lines
                // assume lines starting with spaces are all blank
@@ -213,34 +214,34 @@ bool LoadSettings(Game &game) {
                } else if ( !strncmp(setting, "Volume", 6) ) {
                        ipstream >> volume;
                } else if ( !strncmp(setting, "Forward key", 11) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.forwardkey = CharToKey(string);
                } else if ( !strncmp(setting, "Back key", 8) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.backkey = CharToKey(string);
                } else if ( !strncmp(setting, "Left key", 8) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.leftkey = CharToKey(string);
                } else if ( !strncmp(setting, "Right key", 9) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.rightkey = CharToKey(string);
                } else if ( !strncmp(setting, "Jump key", 8) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.jumpkey = CharToKey(string);
                } else if ( !strncmp(setting, "Crouch key", 10) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.crouchkey = CharToKey(string);
                } else if ( !strncmp(setting, "Draw key", 8) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.drawkey = CharToKey(string);
                } else if ( !strncmp(setting, "Throw key", 9) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.throwkey = CharToKey(string);
                } else if ( !strncmp(setting, "Attack key", 10) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.attackkey = CharToKey(string);
                } else if ( !strncmp(setting, "Chat key", 8) ) {
-                       ipstream >> string;
+                       ipstream.getline( string, sizeof(string) );
                        game.chatkey = CharToKey(string);
                } else if ( !strncmp(setting, "Damage bar", 10) ) {
                        ipstream >> showdamagebar;
index 2caa4c6e9eb1697034d4ddd7adb32722966c982d..496e0fee431acf410cf0770bfc8e4d10386cd1b7 100644 (file)
@@ -106,13 +106,6 @@ void       Weapons::DoStuff(){
                        XYZ speed;
                        //speed=(tippoint[i]-oldtippoint[i])/multiplier/6;
                        speed=0;
-                       /*for(j=0;j<10;j++){
-                       tempvel.x=float(abs(Random()%100)-50)/20;
-                       tempvel.y=float(abs(Random()%100)-50)/20;
-                       tempvel.z=float(abs(Random()%100)-50)/20;
-                       tempvel+=speed;
-                       sprites.MakeSprite(cloudimpactsprite, position[i]+(tippoint[i]-position[i])*((float)j-2)/8,tempvel*.5, 115/255,73/255,12/255, .15+float(abs(Random()%100)-50)/1000, .7);
-                       }*/
                        for(j=0;j<40;j++){
                                tempvel.x=float(abs(Random()%100)-50)/20;
                                tempvel.y=float(abs(Random()%100)-50)/20;
index d38708c70e8b8620dbe776b49166745e4a957fe1..8129225b4d3bf6969faab37c7ffd5c407e55c5dd 100644 (file)
@@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /**> HEADER FILES <**/
 #include "WinInput.h"
+#include "SDL.h"
 
 #ifdef WIN32
 #include "String.h"
@@ -31,822 +32,153 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #endif
 
 extern bool keyboardfrozen;
-extern bool buttons[3];
 /********************> IsKeyDown() <*****/
-Boolean        IsKeyDown( unsigned char *keyMap, unsigned short theKey )
-{
-       if(keyboardfrozen)return 0;
-       if(theKey< 0x80 /*1000*/){
-               static long     keyMapIndex;
-               static Boolean  isKeyDown;
-               static short    bitToCheck;
-
-               // Calculate the key map index
-               keyMapIndex = keyMap[theKey/8];
-
-               // Calculate the individual bit to check
-               bitToCheck = theKey%8;
-
-               // Check the status of the key
-               isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01;
-
-               // Return the status of the key
-               return isKeyDown;
-       }
-       else if(theKey==MAC_MOUSEBUTTON1)
-               return buttons[0];
-       else if(theKey==MAC_MOUSEBUTTON2)
-               return buttons[1];
-
-       return 0;
-}
 
 unsigned short         CharToKey(const char* which)
 {
-       // alphabetic keys
-       if(!strcasecmp(which,"a")){
-               return MAC_A_KEY;
-       }
-       if(!strcasecmp(which,"b")){
-               return MAC_B_KEY;
-       }
-       if(!strcasecmp(which,"c")){
-               return MAC_C_KEY;
-       }
-       if(!strcasecmp(which,"d")){
-               return MAC_D_KEY;
-       }
-       if(!strcasecmp(which,"e")){
-               return MAC_E_KEY;
-       }
-       if(!strcasecmp(which,"f")){
-               return MAC_F_KEY;
-       }
-       if(!strcasecmp(which,"g")){
-               return MAC_G_KEY;
-       }
-       if(!strcasecmp(which,"h")){
-               return MAC_H_KEY;
-       }
-       if(!strcasecmp(which,"i")){
-               return MAC_I_KEY;
-       }
-       if(!strcasecmp(which,"j")){
-               return MAC_J_KEY;
-       }
-       if(!strcasecmp(which,"k")){
-               return MAC_K_KEY;
-       }
-       if(!strcasecmp(which,"l")){
-               return MAC_L_KEY;
-       }
-       if(!strcasecmp(which,"m")){
-               return MAC_M_KEY;
-       }
-       if(!strcasecmp(which,"n")){
-               return MAC_N_KEY;
-       }
-       if(!strcasecmp(which,"o")){
-               return MAC_O_KEY;
-       }
-       if(!strcasecmp(which,"p")){
-               return MAC_P_KEY;
-       }
-       if(!strcasecmp(which,"q")){
-               return MAC_Q_KEY;
-       }
-       if(!strcasecmp(which,"r")){
-               return MAC_R_KEY;
-       }
-       if(!strcasecmp(which,"s")){
-               return MAC_S_KEY;
-       }
-       if(!strcasecmp(which,"t")){
-               return MAC_T_KEY;
-       }
-       if(!strcasecmp(which,"u")){
-               return MAC_U_KEY;
-       }
-       if(!strcasecmp(which,"v")){
-               return MAC_V_KEY;
-       }
-       if(!strcasecmp(which,"w")){
-               return MAC_W_KEY;
-       }
-       if(!strcasecmp(which,"x")){
-               return MAC_X_KEY;
-       }
-       if(!strcasecmp(which,"y")){
-               return MAC_Y_KEY;
-       }
-       if(!strcasecmp(which,"z")){
-               return MAC_Z_KEY;
-       }
-
-       // keypad keys
-       if(!strcasecmp(which,"KP0")){
-               return MAC_NUMPAD_0_KEY;
-       }
-       if(!strcasecmp(which,"KP1")){
-               return MAC_NUMPAD_1_KEY;
-       }
-       if(!strcasecmp(which,"KP2")){
-               return MAC_NUMPAD_2_KEY;
-       }
-       if(!strcasecmp(which,"KP3")){
-               return MAC_NUMPAD_3_KEY;
-       }
-       if(!strcasecmp(which,"KP4")){
-               return MAC_NUMPAD_4_KEY;
-       }
-       if(!strcasecmp(which,"KP5")){
-               return MAC_NUMPAD_5_KEY;
-       }
-       if(!strcasecmp(which,"KP6")){
-               return MAC_NUMPAD_6_KEY;
-       }
-       if(!strcasecmp(which,"KP7")){
-               return MAC_NUMPAD_7_KEY;
-       }
-       if(!strcasecmp(which,"KP8")){
-               return MAC_NUMPAD_8_KEY;
-       }
-       if(!strcasecmp(which,"KP9")){
-               return MAC_NUMPAD_9_KEY;
-       }
-
-       // enter
-       if(!strcasecmp(which,"enter")){
-               return MAC_ENTER_KEY;
-       }
-
-       // number keys
-       if(!strcasecmp(which,"0")){
-               return MAC_0_KEY;
-       }
-       if(!strcasecmp(which,"1")){
-               return MAC_1_KEY;
-       }
-       if(!strcasecmp(which,"2")){
-               return MAC_2_KEY;
-       }
-       if(!strcasecmp(which,"3")){
-               return MAC_3_KEY;
-       }
-       if(!strcasecmp(which,"4")){
-               return MAC_4_KEY;
-       }
-       if(!strcasecmp(which,"5")){
-               return MAC_5_KEY;
-       }
-       if(!strcasecmp(which,"6")){
-               return MAC_6_KEY;
-       }
-       if(!strcasecmp(which,"7")){
-               return MAC_7_KEY;
-       }
-       if(!strcasecmp(which,"8")){
-               return MAC_8_KEY;
-       }
-       if(!strcasecmp(which,"9")){
-               return MAC_9_KEY;
-       }
-
-       // function keys
-       if(!strcasecmp(which,"F1")){
-               return MAC_F1_KEY;
-       }
-       if(!strcasecmp(which,"F2")){
-               return MAC_F2_KEY;
-       }
-       if(!strcasecmp(which,"F3")){
-               return MAC_F3_KEY;
-       }
-       if(!strcasecmp(which,"F4")){
-               return MAC_F4_KEY;
-       }
-       if(!strcasecmp(which,"F5")){
-               return MAC_F5_KEY;
-       }
-       if(!strcasecmp(which,"F6")){
-               return MAC_F6_KEY;
-       }
-       if(!strcasecmp(which,"F7")){
-               return MAC_F7_KEY;
-       }
-       if(!strcasecmp(which,"F8")){
-               return MAC_F8_KEY;
-       }
-       if(!strcasecmp(which,"F9")){
-               return MAC_F9_KEY;
-       }
-       if(!strcasecmp(which,"F10")){
-               return MAC_F10_KEY;
-       }
-       if(!strcasecmp(which,"F11")){
-               return MAC_F11_KEY;
-       }
-       if(!strcasecmp(which,"F12")){
-               return MAC_F12_KEY;
-       }
-
-       // escape
-       if(!strcasecmp(which,"escape")){
-               return MAC_ESCAPE_KEY;
-       }
-       if(!strcasecmp(which,"backspace")){
-               return MAC_DELETE_KEY;
-       }
-       if(!strcasecmp(which,"tab")){
-               return MAC_TAB_KEY;
-       }
-       if(!strcasecmp(which,"`")){
-               return MAC_TILDE_KEY;
-       }
-       if(!strcasecmp(which,"caps_lock")){
-               return MAC_CAPS_LOCK_KEY;
-       }
-//     if(which==){
-//             return "";
-//     }
-       if(!strcasecmp(which,"command")){
-               return MAC_COMMAND_KEY;
-       }
-       if(!strcasecmp(which,"option")){
-               return MAC_OPTION_KEY;
-       }
-       if(!strcasecmp(which,"delete")){
-               return MAC_DEL_KEY;
-       }
-       if(!strcasecmp(which,"insert")){
-               return MAC_INSERT_KEY;
-       }
-       if(!strcasecmp(which,"home")){
-               return MAC_HOME_KEY;
-       }
-       if(!strcasecmp(which,"end")){
-               return MAC_END_KEY;
-       }
-       if(!strcasecmp(which,"page_up")){
-               return MAC_PAGE_UP_KEY;
-       }
-       if(!strcasecmp(which,"page_down")){
-               return MAC_PAGE_DOWN_KEY;
-       }
-       if(!strcasecmp(which,"clear")){
-               return MAC_NUMPAD_CLEAR_KEY;
-       }
-
-       if(!strcasecmp(which,"control")){
-               return MAC_CONTROL_KEY;
-       }
-       if(!strcasecmp(which,"return")){
-               return MAC_RETURN_KEY;
-       }
-       if(!strcasecmp(which,"space")){
-               return MAC_SPACE_KEY;
-       }
-       if(!strcasecmp(which,"shift")){
-               return MAC_SHIFT_KEY;
-       }
-       if(!strcasecmp(which,"uparrow")){
-               return MAC_ARROW_UP_KEY;
-       }
-       if(!strcasecmp(which,"downarrow")){
-               return MAC_ARROW_DOWN_KEY;
-       }
-       if(!strcasecmp(which,"leftarrow")){
-               return MAC_ARROW_LEFT_KEY;
-       }
-       if(!strcasecmp(which,"rightarrow")){
-               return MAC_ARROW_RIGHT_KEY;
+       for(unsigned short i=0;i<SDLK_LAST;i++) {
+               if(!strcasecmp(which,SDL_GetKeyName(SDLKey(i))))
+                       return i;
        }
        if(!strcasecmp(which,"mouse1")){
-               return MAC_MOUSEBUTTON1;
+               return MOUSEBUTTON1;
        }
        if(!strcasecmp(which,"mouse2")){
-               return MAC_MOUSEBUTTON2;
-       }
-       if(!strcasecmp(which,"+")){
-               return MAC_NUMPAD_PLUS_KEY;
-       }
-       if(!strcasecmp(which,"*")){
-               return MAC_NUMPAD_ASTERISK_KEY;
-       }
-       if(!strcasecmp(which,"/")){
-               return MAC_SLASH_KEY;
-       }
-       if(!strcasecmp(which,"\\")){
-               return MAC_BACKSLASH_KEY;
-       }
-       if(!strcasecmp(which,"[")){
-               return MAC_LEFTBRACKET_KEY;
-       }
-       if(!strcasecmp(which,"]")){
-               return MAC_RIGHTBRACKET_KEY;
-       }
-       if(!strcasecmp(which,".")){
-               return MAC_PERIOD_KEY;
+               return MOUSEBUTTON2;
        }
-       if(!strcasecmp(which,",")){
-               return MAC_COMMA_KEY;
-       }
-       if(!strcasecmp(which,"\"")){
-               return MAC_APOSTROPHE_KEY;
-       }
-       if(!strcasecmp(which,";")){
-               return MAC_SEMICOLON_KEY;
-       }
-       return UNKNOWN_KEY;
-}
-
-const char*    KeyToChar(unsigned short which)
-{
-       static int i;
-
-       // alphabetic keys
-       if(which==MAC_A_KEY){
-               return "a";
-       }
-       if(which==MAC_B_KEY){
-               return "b";
-       }
-       if(which==MAC_C_KEY){
-               return "c";
-       }
-       if(which==MAC_D_KEY){
-               return "d";
-       }
-       if(which==MAC_E_KEY){
-               return "e";
-       }
-       if(which==MAC_F_KEY){
-               return "f";
-       }
-       if(which==MAC_G_KEY){
-               return "g";
-       }
-       if(which==MAC_H_KEY){
-               return "h";
-       }
-       if(which==MAC_I_KEY){
-               return "i";
-       }
-       if(which==MAC_J_KEY){
-               return "j";
-       }
-       if(which==MAC_K_KEY){
-               return "k";
-       }
-       if(which==MAC_L_KEY){
-               return "l";
-       }
-       if(which==MAC_M_KEY){
-               return "m";
-       }
-       if(which==MAC_N_KEY){
-               return "n";
-       }
-       if(which==MAC_O_KEY){
-               return "o";
-       }
-       if(which==MAC_P_KEY){
-               return "p";
-       }
-       if(which==MAC_Q_KEY){
-               return "q";
-       }
-       if(which==MAC_R_KEY){
-               return "r";
-       }
-       if(which==MAC_S_KEY){
-               return "s";
-       }
-       if(which==MAC_T_KEY){
-               return "t";
-       }
-       if(which==MAC_U_KEY){
-               return "u";
-       }
-       if(which==MAC_V_KEY){
-               return "v";
-       }
-       if(which==MAC_W_KEY){
-               return "w";
-       }
-       if(which==MAC_X_KEY){
-               return "x";
-       }
-       if(which==MAC_Y_KEY){
-               return "y";
-       }
-       if(which==MAC_Z_KEY){
-               return "z";
-       }
-
-       // keypad keys
-       if(which==MAC_NUMPAD_1_KEY){
-               return "KP1";
-       }
-       if(which==MAC_NUMPAD_2_KEY){
-               return "KP2";
-       }
-       if(which==MAC_NUMPAD_3_KEY){
-               return "KP3";
-       }
-       if(which==MAC_NUMPAD_4_KEY){
-               return "KP4";
-       }
-       if(which==MAC_NUMPAD_5_KEY){
-               return "KP5";
-       }
-       if(which==MAC_NUMPAD_6_KEY){
-               return "KP6";
-       }
-       if(which==MAC_NUMPAD_7_KEY){
-               return "KP7";
-       }
-       if(which==MAC_NUMPAD_8_KEY){
-               return "KP8";
-       }
-       if(which==MAC_NUMPAD_9_KEY){
-               return "KP9";
-       }
-       if(which==MAC_NUMPAD_0_KEY){
-               return "KP0";
-       }
-
-       // enter
-       if(which==MAC_ENTER_KEY){
-               return "enter";
-       }
-
-       // number keys
-       if(which==MAC_1_KEY){
-               return "1";
-       }
-       if(which==MAC_2_KEY){
-               return "2";
-       }
-       if(which==MAC_3_KEY){
-               return "3";
-       }
-       if(which==MAC_4_KEY){
-               return "4";
-       }
-       if(which==MAC_5_KEY){
-               return "5";
-       }
-       if(which==MAC_6_KEY){
-               return "6";
-       }
-       if(which==MAC_7_KEY){
-               return "7";
-       }
-       if(which==MAC_8_KEY){
-               return "8";
-       }
-       if(which==MAC_9_KEY){
-               return "9";
-       }
-       if(which==MAC_0_KEY){
-               return "0";
-       }
-
-       // function keys
-       if(which==MAC_F1_KEY){
-               return "F1";
-       }
-       if(which==MAC_F2_KEY){
-               return "F2";
-       }
-       if(which==MAC_F3_KEY){
-               return "F3";
-       }
-       if(which==MAC_F4_KEY){
-               return "F4";
-       }
-       if(which==MAC_F5_KEY){
-               return "F5";
-       }
-       if(which==MAC_F6_KEY){
-               return "F6";
-       }
-       if(which==MAC_F7_KEY){
-               return "F7";
-       }
-       if(which==MAC_F8_KEY){
-               return "F8";
-       }
-       if(which==MAC_F9_KEY){
-               return "F9";
-       }
-       if(which==MAC_F10_KEY){
-               return "F10";
-       }
-       if(which==MAC_F11_KEY){
-               return "F11";
-       }
-       if(which==MAC_F12_KEY){
-               return "F12";
-       }
-
-       // escape
-       if(which==MAC_ESCAPE_KEY){
-               return "escape";
-       }
-       if(which==MAC_DELETE_KEY){
-               return "backspace";
-       }
-       if(which==MAC_TAB_KEY){
-               return "tab";
-       }
-       if(which==MAC_TILDE_KEY){
-               return "`";
-       }
-       if(which==MAC_CAPS_LOCK_KEY){
-               return "caps_lock";
-       }
-       if(which==MAC_COMMAND_KEY){
-               return "command";
-       }
-       if(which==MAC_OPTION_KEY){
-               return "option";
-       }
-       if(which==MAC_DEL_KEY){
-               return "delete";
-       }
-       if(which==MAC_INSERT_KEY){
-               return "insert";
-       }
-       if(which==MAC_HOME_KEY){
-               return "home";
-       }
-       if(which==MAC_END_KEY){
-               return "end";
-       }
-       if(which==MAC_PAGE_UP_KEY){
-               return "page_up";
-       }
-       if(which==MAC_PAGE_DOWN_KEY){
-               return "page_down";
-       }
-       if(which==MAC_NUMPAD_CLEAR_KEY){
-               return "clear";
-       }
-       if(which==MAC_CONTROL_KEY){
-               return "control";
-       }
-       if(which==MAC_SPACE_KEY){
-               return "space";
-       }
-       if(which==MAC_RETURN_KEY){
-               return "return";
-       }
-       if(which==MAC_SHIFT_KEY){
-               return "shift";
-       }
-       if(which==MAC_ARROW_UP_KEY){
-               return "uparrow";
-       }
-       if(which==MAC_ARROW_DOWN_KEY){
-               return "downarrow";
-       }
-       if(which==MAC_ARROW_LEFT_KEY){
-               return "leftarrow";
-       }
-       if(which==MAC_ARROW_RIGHT_KEY){
-               return "rightarrow";
-       }
-       if(which==MAC_MOUSEBUTTON1){
-               return "mouse1";
-       }
-       if(which==MAC_MOUSEBUTTON2){
-               return "mouse2";
-       }
-       if(which==MAC_ARROW_RIGHT_KEY){
-               return "rightarrow";
-       }
-       if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
-               return "-";
-       }
-       if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
-               return "=";
-       }
-       if(which==MAC_NUMPAD_PLUS_KEY){
-               return "+";
-       }
-       if(which==MAC_NUMPAD_ASTERISK_KEY){
-               return "*";
-       }
-       if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
-               return "/";
-       }
-       if(which==MAC_BACKSLASH_KEY){
-               return "\\";
-       }
-       if(which==MAC_LEFTBRACKET_KEY){
-               return "[";
-       }
-       if(which==MAC_RIGHTBRACKET_KEY){
-               return "]";
-       }
-       if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
-               return ".";
-       }
-       if(which==MAC_COMMA_KEY){
-               return ",";
-       }
-       if(which==MAC_APOSTROPHE_KEY){
-               return "\"";
-       }
-       if(which==MAC_SEMICOLON_KEY){
-               return ";";
-       }
-       return "unknown";
+       return SDLK_LAST;
 }
 
 char   KeyToSingleChar(unsigned short which)
 {
        static int i;
 
-       if(which==MAC_A_KEY){
+       if(which==SDLK_a){
                return 'a';
        }
-       if(which==MAC_B_KEY){
+       if(which==SDLK_b){
                return 'b';
        }
-       if(which==MAC_C_KEY){
+       if(which==SDLK_c){
                return 'c';
        }
-       if(which==MAC_D_KEY){
+       if(which==SDLK_d){
                return 'd';
        }
-       if(which==MAC_E_KEY){
+       if(which==SDLK_e){
                return 'e';
        }
-       if(which==MAC_F_KEY){
+       if(which==SDLK_f){
                return 'f';
        }
-       if(which==MAC_G_KEY){
+       if(which==SDLK_g){
                return 'g';
        }
-       if(which==MAC_H_KEY){
+       if(which==SDLK_h){
                return 'h';
        }
-       if(which==MAC_I_KEY){
+       if(which==SDLK_i){
                return 'i';
        }
-       if(which==MAC_J_KEY){
+       if(which==SDLK_j){
                return 'j';
        }
-       if(which==MAC_K_KEY){
+       if(which==SDLK_k){
                return 'k';
        }
-       if(which==MAC_L_KEY){
-               return 'l';
-       }
-       if(which==MAC_M_KEY){
+       if(which==SDLK_m){
                return 'm';
        }
-       if(which==MAC_N_KEY){
+       if(which==SDLK_n){
                return 'n';
        }
-       if(which==MAC_O_KEY){
+       if(which==SDLK_o){
                return 'o';
        }
-       if(which==MAC_P_KEY){
+       if(which==SDLK_p){
                return 'p';
        }
-       if(which==MAC_Q_KEY){
+       if(which==SDLK_q){
                return 'q';
        }
-       if(which==MAC_R_KEY){
-               return 'r';
-       }
-       if(which==MAC_S_KEY){
+       if(which==SDLK_s){
                return 's';
        }
-       if(which==MAC_T_KEY){
-               return 't';
-       }
-       if(which==MAC_U_KEY){
+       if(which==SDLK_u){
                return 'u';
        }
-       if(which==MAC_V_KEY){
+       if(which==SDLK_v){
                return 'v';
        }
-       if(which==MAC_W_KEY){
-               return 'w';
-       }
-       if(which==MAC_X_KEY){
+       if(which==SDLK_x){
                return 'x';
        }
-       if(which==MAC_Y_KEY){
-               return 'y';
-       }
-       if(which==MAC_Z_KEY){
+       if(which==SDLK_z){
                return 'z';
        }
-       if(which==MAC_NUMPAD_1_KEY){
+       if(which==SDLK_KP1){
                return '1';
        }
-       if(which==MAC_NUMPAD_2_KEY){
+       if(which==SDLK_KP2){
                return '2';
        }
-       if(which==MAC_NUMPAD_3_KEY){
+       if(which==SDLK_KP3){
                return '3';
        }
-       if(which==MAC_NUMPAD_4_KEY){
+       if(which==SDLK_KP4){
                return '4';
        }
-       if(which==MAC_NUMPAD_5_KEY){
+       if(which==SDLK_KP5){
                return '5';
        }
-       if(which==MAC_NUMPAD_6_KEY){
+       if(which==SDLK_KP6){
                return '6';
        }
-       if(which==MAC_NUMPAD_7_KEY){
+       if(which==SDLK_KP7){
                return '7';
        }
-       if(which==MAC_NUMPAD_8_KEY){
+       if(which==SDLK_KP8){
                return '8';
        }
-       if(which==MAC_NUMPAD_9_KEY){
+       if(which==SDLK_KP9){
                return '9';
        }
-       if(which==MAC_NUMPAD_0_KEY){
+       if(which==SDLK_KP0){
                return '0';
        }
-       if(which==MAC_1_KEY){
+       if(which==SDLK_1){
                return '1';
        }
-       if(which==MAC_2_KEY){
+       if(which==SDLK_2){
                return '2';
        }
-       if(which==MAC_3_KEY){
+       if(which==SDLK_3){
                return '3';
        }
-       if(which==MAC_4_KEY){
+       if(which==SDLK_4){
                return '4';
        }
-       if(which==MAC_5_KEY){
+       if(which==SDLK_5){
                return '5';
        }
-       if(which==MAC_6_KEY){
+       if(which==SDLK_6){
                return '6';
        }
-       if(which==MAC_7_KEY){
+       if(which==SDLK_7){
                return '7';
        }
-       if(which==MAC_8_KEY){
+       if(which==SDLK_8){
                return '8';
        }
-       if(which==MAC_9_KEY){
+       if(which==SDLK_9){
                return '9';
        }
-       if(which==MAC_0_KEY){
+       if(which==SDLK_0){
                return '0';
        }
-       if(which==MAC_SPACE_KEY){
+       if(which==SDLK_SPACE){
                return ' ';
        }
-       if(which==MAC_MINUS_KEY||which==MAC_NUMPAD_MINUS_KEY){
-               return '-';
-       }
-       if(which==MAC_PLUS_KEY||which==MAC_NUMPAD_EQUALS_KEY){
-               return '=';
-       }
-       if(which==MAC_NUMPAD_PLUS_KEY){
-               return '+';
-       }
-       if(which==MAC_NUMPAD_ASTERISK_KEY){
-               return '*';
-       }
-       if(which==MAC_SLASH_KEY||which==MAC_NUMPAD_SLASH_KEY){
-               return '/';
-       }
-       if(which==MAC_BACKSLASH_KEY){
-               return '\\';
-       }
-       if(which==MAC_LEFTBRACKET_KEY){
-               return '[';
-       }
-       if(which==MAC_RIGHTBRACKET_KEY){
-               return ']';
-       }
-       if(which==MAC_PERIOD_KEY||which==MAC_NUMPAD_PERIOD_KEY){
-               return '.';
-       }
-       if(which==MAC_COMMA_KEY){
-               return ',';
-       }
-       if(which==MAC_APOSTROPHE_KEY){
-               return '\'';
-       }
-       if(which==MAC_SEMICOLON_KEY){
-               return ';';
-       }
        return '\0';
 }
 
index bbdf59736f77049909b0db0853e91ba6f1294d35..561d593709276604f7d4d91a43b0f25b5d0c41c8 100644 (file)
@@ -26,131 +26,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <stdlib.h>
 #include <stdio.h>
 #include "MacCompatibility.h"
+#include "SDL.h"
 
 /**> CONSTANT DECLARATIONS <**/
-// Mac Keyboard Codes
-#define        MAC_1_KEY                               0x12
-#define        MAC_2_KEY                               0x13
-#define        MAC_3_KEY                               0x14
-#define        MAC_4_KEY                               0x15
-#define        MAC_5_KEY                               0x17
-#define        MAC_6_KEY                               0x16
-#define        MAC_7_KEY                               0x1A
-#define        MAC_8_KEY                               0x1C
-#define        MAC_9_KEY                               0x19
-#define        MAC_0_KEY                               0x1D
-#define        MAC_NUMPAD_1_KEY                0x53
-#define        MAC_NUMPAD_2_KEY                0x54
-#define        MAC_NUMPAD_3_KEY                0x55
-#define        MAC_NUMPAD_4_KEY                0x56
-#define        MAC_NUMPAD_5_KEY                0x57
-#define        MAC_NUMPAD_6_KEY                0x58
-#define        MAC_NUMPAD_7_KEY                0x59
-#define        MAC_NUMPAD_8_KEY                0x5B
-#define        MAC_NUMPAD_9_KEY                0x5C
-#define        MAC_NUMPAD_0_KEY                0x52
-#define        MAC_A_KEY                               0x00
-#define        MAC_B_KEY                               0x0B
-#define        MAC_C_KEY                               0x08
-#define        MAC_D_KEY                               0x02
-#define        MAC_E_KEY                               0x0E
-#define        MAC_F_KEY                               0x03
-#define        MAC_G_KEY                               0x05
-#define        MAC_H_KEY                               0x04
-#define        MAC_I_KEY                               0x22
-#define        MAC_J_KEY                               0x26
-#define        MAC_K_KEY                               0x28
-#define        MAC_L_KEY                               0x25
-#define        MAC_M_KEY                               0x2E
-#define        MAC_N_KEY                               0x2D
-#define        MAC_O_KEY                               0x1F
-#define        MAC_P_KEY                               0x23
-#define        MAC_Q_KEY                               0x0C
-#define        MAC_R_KEY                               0x0F
-#define        MAC_S_KEY                               0x01
-#define        MAC_T_KEY                               0x11
-#define        MAC_U_KEY                               0x20
-#define        MAC_V_KEY                               0x09
-#define        MAC_W_KEY                               0x0D
-#define        MAC_X_KEY                               0x07
-#define        MAC_Y_KEY                               0x10
-#define        MAC_Z_KEY                               0x06
-#define        MAC_F1_KEY                              0x7A
-#define        MAC_F2_KEY                              0x78
-#define        MAC_F3_KEY                              0x63
-#define        MAC_F4_KEY                              0x76
-#define        MAC_F5_KEY                              0x60
-#define        MAC_F6_KEY                              0x61
-#define        MAC_F7_KEY                              0x62
-#define        MAC_F8_KEY                              0x64
-#define        MAC_F9_KEY                              0x65
-#define        MAC_F10_KEY                             0x6D
-#define        MAC_F11_KEY                             0x67
-#define        MAC_F12_KEY                             0x6F
-#define        MAC_RETURN_KEY                  0x24
-#define        MAC_ENTER_KEY                   0x4C
-#define        MAC_TAB_KEY                             0x30
-#define        MAC_SPACE_KEY                   0x31
-#define        MAC_DELETE_KEY                  0x33
-#define        MAC_ESCAPE_KEY                  0x35
-#define        MAC_COMMAND_KEY                 0x37
-#define        MAC_SHIFT_KEY                   0x38
-#define        MAC_CAPS_LOCK_KEY               0x39
-#define        MAC_OPTION_KEY                  0x3A
-#define        MAC_CONTROL_KEY                 0x3B
-#define        MAC_PAGE_UP_KEY                 0x74
-#define        MAC_PAGE_DOWN_KEY               0x79
-#define        MAC_INSERT_KEY                  0x72
-#define        MAC_DEL_KEY                             0x75
-#define        MAC_HOME_KEY                    0x73
-#define        MAC_END_KEY                             0x77
-#define        MAC_LEFT_BRACKET_KEY    0x21
-#define        MAC_RIGHT_BRACKET_KEY   0x1E
-#define        MAC_ARROW_UP_KEY                0x7E
-#define        MAC_ARROW_DOWN_KEY              0x7D
-#define        MAC_ARROW_LEFT_KEY              0x7B
-#define        MAC_ARROW_RIGHT_KEY             0x7C
-#define        MAC_TILDE_KEY                   0x32
-#define MAC_MINUS_KEY                  0x1B
-#define MAC_PLUS_KEY                   0x18
-#define MAC_SLASH_KEY                  0x2C
-#define MAC_PERIOD_KEY                 0x2F
-#define MAC_COMMA_KEY                  0x2B
-#define MAC_BACKSLASH_KEY              0x2A
-#define MAC_LEFTBRACKET_KEY            0x21
-#define MAC_RIGHTBRACKET_KEY   0x1E
-#define MAC_NUMPAD_CLEAR_KEY   0x47
-#define MAC_NUMPAD_MINUS_KEY   0x4E
-#define MAC_NUMPAD_EQUALS_KEY  0x51
-#define MAC_NUMPAD_PLUS_KEY            0x45
-#define MAC_NUMPAD_SLASH_KEY   0x4B
-#define MAC_NUMPAD_ASTERISK_KEY        0x43
-#define MAC_NUMPAD_ENTER_KEY   0x4C
-#define MAC_NUMPAD_PERIOD_KEY  0x41
-#define MAC_SEMICOLON_KEY              0x29
-#define MAC_APOSTROPHE_KEY             0x27
-#define MAC_MOUSEBUTTON1               10000
-#define MAC_MOUSEBUTTON2               10001
-
-#define UNKNOWN_KEY 0xFF
-
+#define MOUSEBUTTON1           SDLK_LAST+SDL_BUTTON_LEFT
+#define MOUSEBUTTON2           SDLK_LAST+SDL_BUTTON_RIGHT
 
 /**> FUNCTION PROTOTYPES <**/
-Boolean        IsKeyDown( unsigned char *keyMap, unsigned short theKey );
 void   InitMouse();
 void   MoveMouse(int xcoord, int ycoord, Point *mouseloc);
 void   RefreshMouse(Point *mouseloc);
 void   DisposeMouse();
 unsigned short         CharToKey(const char* which);
-const char*    KeyToChar(unsigned short which);
 char   KeyToSingleChar(unsigned short which);
 char   Shift(char which);
 
-
-typedef unsigned char KeyMap[16];
-void GetKeys( unsigned char theKeys[16]);
-
 Boolean Button();
 
-
 #endif