]> git.jsancho.org Git - lugaru.git/commitdiff
Some clean up.
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Fri, 4 Jun 2010 19:45:46 +0000 (21:45 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Fri, 4 Jun 2010 19:45:46 +0000 (21:45 +0200)
No more WinInput.{h,cpp}.

CMakeLists.txt
Source/Account.cpp
Source/Game.h
Source/GameTick.cpp
Source/Input.cpp
Source/Input.h
Source/OpenGL_Windows.cpp
Source/Settings.cpp
Source/WinInput.cpp [deleted file]
Source/WinInput.h [deleted file]

index aa0374f1320259b9806505d38998def466ca60d6..e09a14908b9dd0ac429f56d4ceefe8bbf6b0c528 100644 (file)
@@ -78,7 +78,6 @@ set(LUGARU_SRCS
        ${SRCDIR}/Weapons.cpp
        ${SRCDIR}/OpenGL_Windows.cpp
        ${SRCDIR}/openal_wrapper.cpp
-       ${SRCDIR}/WinInput.cpp
        ${SRCDIR}/Input.cpp
        ${SRCDIR}/Settings.cpp
        ${SRCDIR}/Stereo.cpp
@@ -105,7 +104,6 @@ set(LUGARU_H
        ${SRCDIR}/Terrain.h
        ${SRCDIR}/Text.h
        ${SRCDIR}/Weapons.h
-       ${SRCDIR}/WinInput.h
        ${SRCDIR}/Input.h
        ${SRCDIR}/alstubs.h
        ${SRCDIR}/binio.h
index 31e99af8c54efcaecdcbdf601e2476dfac870321..90b585a38b4f20f4a99a911a5c865fcc58a9a6fc 100644 (file)
@@ -37,15 +37,15 @@ Account::Account(string n) {
        difficulty = 0;
        progress = 0;
        points = 0;
-       for(int i=0;i<50;highscore[i++] = 0);
-       for(int i=0;i<50;fasttime[i++] = 0);
-       for(int i=0;i<60;unlocked[i++] = 0);
+       memset(highscore, 0, sizeof(highscore));
+       memset(fasttime, 0, sizeof(fasttime));
+       memset(unlocked, 0, sizeof(unlocked));
        campaignhighscore = 0;
        campaignfasttime = 0;
        campaignscore = 0;
        campaigntime = 0;
        campaignchoicesmade = 0;
-       for(int i=0;i<5000;campaignchoices[i++] = 0);
+       memset(campaignchoices, 0, sizeof(campaignchoices));
 }
 
 Account* Account::add(string name) {
index fab60c8a0c7f7850ad744a1ecc234987bb5fa490..389db5aea69f8d8f8871d71b6549eb8e22569c12 100644 (file)
@@ -40,9 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "TGALoader.h"
 
-#if !PLATFORM_MACOSX
-#include "WinInput.h"
-#else
+#if PLATFORM_MACOSX
 #include "Macinput.h"
 #endif
 
index e1ea0433fa973fb4d3bb962e31458ee5d770a2a8..b3114ede00ef316177d82a46fc01e3b8a03aea50 100644 (file)
@@ -213,14 +213,6 @@ extern bool campaign;
 
 extern float oldgamespeed;
 
-extern float accountcampaignhighscore[10];
-extern float accountcampaignfasttime[10];
-extern float accountcampaignscore[10];
-extern float accountcampaigntime[10];
-
-extern int accountcampaignchoicesmade[10];
-extern int accountcampaignchoices[10][5000];
-
 static const char *rabbitskin[] = {
 ":Data:Textures:Fur3.jpg",
 ":Data:Textures:Fur.jpg",
@@ -322,142 +314,131 @@ static void ch_save(Game *game, const char *args)
   fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
 
   fpackf(tfile, "Bi", numdialogues);
-  if(numdialogues)
-    for(k=0;k<numdialogues;k++){
-      fpackf(tfile, "Bi", numdialogueboxes[k]);
-      fpackf(tfile, "Bi", dialoguetype[k]);
-      for(l=0;l<10;l++){
-       fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
-       fpackf(tfile, "Bf", participantrotation[k][l]);
-      }
-      if(numdialogueboxes)
-       for(l=0;l<numdialogueboxes[k];l++){
-         fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
-         fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
-         fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
-         fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
-         fpackf(tfile, "Bi", dialogueboxsound[k][l]);
-
-         templength=strlen(dialoguetext[k][l]);
-         fpackf(tfile, "Bi",(templength));
-         for(m=0;m<templength;m++){
-           fpackf(tfile, "Bb", dialoguetext[k][l][m]);
-           if(dialoguetext[k][l][m]=='\0')break;
-         }
-
-         templength=strlen(dialoguename[k][l]);
-         fpackf(tfile, "Bi",templength);
-         for(m=0;m<templength;m++){
-           fpackf(tfile, "Bb", dialoguename[k][l][m]);
-           if(dialoguename[k][l][m]=='\0')break;
-         }
-
-         fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
-         fpackf(tfile, "Bi", participantfocus[k][l]);
-         fpackf(tfile, "Bi", participantaction[k][l]);
-
-         for(m=0;m<10;m++)
-           fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
-
-         fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
+       for(k=0;k<numdialogues;k++){
+               fpackf(tfile, "Bi", numdialogueboxes[k]);
+               fpackf(tfile, "Bi", dialoguetype[k]);
+               for(l=0;l<10;l++){
+                       fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
+                       fpackf(tfile, "Bf", participantrotation[k][l]);
+               }
+               for(l=0;l<numdialogueboxes[k];l++){
+                       fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
+                       fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
+                       fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
+                       fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
+                       fpackf(tfile, "Bi", dialogueboxsound[k][l]);
+
+                       templength=strlen(dialoguetext[k][l]);
+                       fpackf(tfile, "Bi",(templength));
+                       for(m=0;m<templength;m++){
+                               fpackf(tfile, "Bb", dialoguetext[k][l][m]);
+                               if(dialoguetext[k][l][m]=='\0')break;
+                       }
+
+                       templength=strlen(dialoguename[k][l]);
+                       fpackf(tfile, "Bi",templength);
+                       for(m=0;m<templength;m++){
+                               fpackf(tfile, "Bb", dialoguename[k][l][m]);
+                               if(dialoguename[k][l][m]=='\0')break;
+                       }
+
+                       fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
+                       fpackf(tfile, "Bi", participantfocus[k][l]);
+                       fpackf(tfile, "Bi", participantaction[k][l]);
+
+                       for(m=0;m<10;m++)
+                               fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
+
+                       fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
+               }
        }
-    }
 
-  if(player[0].numclothes)
-    for(k=0;k<player[0].numclothes;k++){
-      templength=strlen(player[0].clothes[k]);
-      fpackf(tfile, "Bi", templength);
-      for(l=0;l<templength;l++)
-       fpackf(tfile, "Bb", player[0].clothes[k][l]);
-      fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
-    }
+       for(k=0;k<player[0].numclothes;k++){
+               templength=strlen(player[0].clothes[k]);
+               fpackf(tfile, "Bi", templength);
+               for(l=0;l<templength;l++)
+                       fpackf(tfile, "Bb", player[0].clothes[k][l]);
+               fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
+       }
 
   fpackf(tfile, "Bi", environment);
 
   fpackf(tfile, "Bi", objects.numobjects);
 
-  if(objects.numobjects)
     for(k=0;k<objects.numobjects;k++){
       fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.rotation[k], objects.rotation2[k], objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
     }
 
   fpackf(tfile, "Bi", numhotspots);
-  if(numhotspots)
-    for(i=0;i<numhotspots;i++){
-      fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
-      templength=strlen(hotspottext[i]);
-      fpackf(tfile, "Bi",templength);
-      for(l=0;l<templength;l++)
-       fpackf(tfile, "Bb", hotspottext[i][l]);
-    }
+       for(i=0;i<numhotspots;i++){
+               fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
+               templength=strlen(hotspottext[i]);
+               fpackf(tfile, "Bi",templength);
+               for(l=0;l<templength;l++)
+                       fpackf(tfile, "Bb", hotspottext[i][l]);
+       }
 
   fpackf(tfile, "Bi", numplayers);
-  if(numplayers>1&&numplayers<maxplayers)
+  if(numplayers<maxplayers)
     for(j=1;j<numplayers;j++){
-      fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature, player[j].coords.x, player[j].coords.y, player[j].coords.z, player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
-      if(player[j].num_weapons>0&&player[j].num_weapons<5)
-       for(k=0;k<player[j].num_weapons;k++){
-         fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
-       }
-      if(player[j].numwaypoints<30){
-       fpackf(tfile, "Bi", player[j].numwaypoints);
-       for(k=0;k<player[j].numwaypoints;k++){
-         fpackf(tfile, "Bf", player[j].waypoints[k].x);
-         fpackf(tfile, "Bf", player[j].waypoints[k].y);
-         fpackf(tfile, "Bf", player[j].waypoints[k].z);
-         fpackf(tfile, "Bi", player[j].waypointtype[k]);
-       }
-       fpackf(tfile, "Bi", player[j].waypoint);
-      }
-      else{
-       player[j].numwaypoints=0;
-       player[j].waypoint=0;
-       fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
-      }
-
-      fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
-      fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
-      fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
-      fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
-
-      if(player[j].creature==wolftype){
-       headprop=player[j].proportionhead.x/1.1;
-       bodyprop=player[j].proportionbody.x/1.1;
-       armprop=player[j].proportionarms.x/1.1;
-       legprop=player[j].proportionlegs.x/1.1;
-      }
-
-      if(player[j].creature==rabbittype){
-       headprop=player[j].proportionhead.x/1.2;
-       bodyprop=player[j].proportionbody.x/1.05;
-       armprop=player[j].proportionarms.x/1.00;
-       legprop=player[j].proportionlegs.x/1.1;
-      }
-
-      fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
+               fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature, player[j].coords.x, player[j].coords.y, player[j].coords.z, player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
+               if(player[j].num_weapons<5)
+                       for(k=0;k<player[j].num_weapons;k++){
+                               fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
+                       }
+               if(player[j].numwaypoints<30){
+                       fpackf(tfile, "Bi", player[j].numwaypoints);
+                       for(k=0;k<player[j].numwaypoints;k++){
+                               fpackf(tfile, "Bf", player[j].waypoints[k].x);
+                               fpackf(tfile, "Bf", player[j].waypoints[k].y);
+                               fpackf(tfile, "Bf", player[j].waypoints[k].z);
+                               fpackf(tfile, "Bi", player[j].waypointtype[k]);
+                       }
+                       fpackf(tfile, "Bi", player[j].waypoint);
+               } else {
+                       player[j].numwaypoints=0;
+                       player[j].waypoint=0;
+                       fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
+               }
 
+               fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
+               fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
+               fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
+               fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
+
+               if(player[j].creature==wolftype) {
+                       headprop=player[j].proportionhead.x/1.1;
+                       bodyprop=player[j].proportionbody.x/1.1;
+                       armprop=player[j].proportionarms.x/1.1;
+                       legprop=player[j].proportionlegs.x/1.1;
+               } else if(player[j].creature==rabbittype){
+                       headprop=player[j].proportionhead.x/1.2;
+                       bodyprop=player[j].proportionbody.x/1.05;
+                       armprop=player[j].proportionarms.x/1.00;
+                       legprop=player[j].proportionlegs.x/1.1;
+               }
 
+               fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
 
-      fpackf(tfile, "Bi", player[j].numclothes);
-      if(player[j].numclothes)
-       for(k=0;k<player[j].numclothes;k++){
-         int templength;
-         templength=strlen(player[j].clothes[k]);
-         fpackf(tfile, "Bi", templength);
-         for(l=0;l<templength;l++)
-           fpackf(tfile, "Bb", player[j].clothes[k][l]);
-         fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
-       }
+               fpackf(tfile, "Bi", player[j].numclothes);
+               if(player[j].numclothes)
+                       for(k=0;k<player[j].numclothes;k++){
+                               int templength;
+                               templength=strlen(player[j].clothes[k]);
+                               fpackf(tfile, "Bi", templength);
+                               for(l=0;l<templength;l++)
+                                       fpackf(tfile, "Bb", player[j].clothes[k][l]);
+                               fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
+                       }
     }
 
   fpackf(tfile, "Bi", game->numpathpoints);
-  if(game->numpathpoints)
-    for(j=0;j<game->numpathpoints;j++){
-      fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]);
-      for(k=0;k<game->numpathpointconnect[j];k++){
-       fpackf(tfile, "Bi", game->pathpointconnect[j][k]);
-      }
-    }
+       for(j=0;j<game->numpathpoints;j++){
+               fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]);
+               for(k=0;k<game->numpathpointconnect[j];k++){
+                       fpackf(tfile, "Bi", game->pathpointconnect[j][k]);
+               }
+       }
 
   fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius);
 
@@ -544,9 +525,7 @@ static void set_proportion(int pnum, const char *args)
     player[pnum].proportionbody=1.1*bodyprop;
     player[pnum].proportionarms=1.1*armprop;
     player[pnum].proportionlegs=1.1*legprop;
-  }
-
-  if(player[pnum].creature==rabbittype){
+  } else if(player[pnum].creature==rabbittype){
     player[pnum].proportionhead=1.2*headprop;
     player[pnum].proportionbody=1.05*bodyprop;
     player[pnum].proportionarms=1.00*armprop;
@@ -818,23 +797,21 @@ static void ch_notindemo(Game *game, const char *args)
 static void ch_type(Game *game, const char *args)
 {
   int i, n = sizeof(editortypenames) / sizeof(editortypenames[0]);
-  for (i = 0; i < n; i++)
-    if (stripfx(args, editortypenames[i]))
-      {
-       editoractive = i;
-       break;
-      }
+       for (i = 0; i < n; i++)
+               if (stripfx(args, editortypenames[i])) {
+                       editoractive = i;
+                       break;
+               }
 }
 
 static void ch_path(Game *game, const char *args)
 {
   int i, n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
   for (i = 0; i < n; i++)
-    if (stripfx(args, pathtypenames[i]))
-      {
-       editorpathtype = i;
-       break;
-      }
+    if (stripfx(args, pathtypenames[i])) {
+               editorpathtype = i;
+               break;
+    }
 }
 
 static void ch_hs(Game *game, const char *args)
@@ -1003,9 +980,7 @@ static void ch_default(Game *game, const char *args)
     player[0].proportionbody=1.1;
     player[0].proportionarms=1.1;
     player[0].proportionlegs=1.1;
-  }
-
-  if(player[0].creature==rabbittype){
+  } else if(player[0].creature==rabbittype){
     player[0].proportionhead=1.2;
     player[0].proportionbody=1.05;
     player[0].proportionarms=1.00;
@@ -2539,7 +2514,7 @@ void      Game::Tick()
        if(mainmenu){
                //menu buttons
                if(mainmenu==1||mainmenu==2){
-                       if(Button()&&!oldbutton&&selected==1){
+                       if(Input::Button()&&!oldbutton&&selected==1){
                                if(!gameon){
                                        fireSound(firestartsound);
 
@@ -2562,7 +2537,7 @@ void      Game::Tick()
                                }
                        }
 
-                       if(Button()&&!oldbutton&&selected==2){
+                       if(Input::Button()&&!oldbutton&&selected==2){
                                fireSound();
 
                                flash();
@@ -2579,7 +2554,7 @@ void      Game::Tick()
                                if(newscreenheight<0)newscreenheight=screenheight;
                        }
 
-                       if(Button()&&!oldbutton&&selected==3){
+                       if(Input::Button()&&!oldbutton&&selected==3){
                                fireSound();
 
                                flash();
@@ -2597,10 +2572,10 @@ void    Game::Tick()
                        }
                }
                if(mainmenu==3){
-                       if(Button()&&!oldbutton&&selected!=-1){
+                       if(Input::Button()&&!oldbutton&&selected!=-1){
                                fireSound();
                        }
-                       if(Button()&&!oldbutton&&selected==0){
+                       if(Input::Button()&&!oldbutton&&selected==0){
                        
                                extern SDL_Rect **resolutions;
                                bool isCustomResolution = true;
@@ -2648,25 +2623,25 @@ void    Game::Tick()
 
                                
                        }
-                       if(Button()&&!oldbutton&&selected==1){
+                       if(Input::Button()&&!oldbutton&&selected==1){
                                newdetail++;
                                if(newdetail>2)newdetail=0;
                        }
-                       if(Button()&&!oldbutton&&selected==2){
+                       if(Input::Button()&&!oldbutton&&selected==2){
                                bloodtoggle++;
                                if(bloodtoggle>2)bloodtoggle=0;
                        }
-                       if(Button()&&!oldbutton&&selected==3){
+                       if(Input::Button()&&!oldbutton&&selected==3){
                                difficulty++;
                                if(difficulty>2)difficulty=0;
                        }
-                       if(Button()&&!oldbutton&&selected==4){
+                       if(Input::Button()&&!oldbutton&&selected==4){
                                ismotionblur=1-ismotionblur;
                        }
-                       if(Button()&&!oldbutton&&selected==5){
+                       if(Input::Button()&&!oldbutton&&selected==5){
                                decals=1-decals;
                        }
-                       if(Button()&&!oldbutton&&selected==6){
+                       if(Input::Button()&&!oldbutton&&selected==6){
                                musictoggle=1-musictoggle;
 
                                if(!musictoggle){
@@ -2686,19 +2661,19 @@ void    Game::Tick()
                                        OPENAL_SetVolume(channels[stream_music3], 256);
                                }
                        }
-                       if(Button()&&!oldbutton&&selected==9){
+                       if(Input::Button()&&!oldbutton&&selected==9){
                                invertmouse=1-invertmouse;
                        }
-                       if(Button()&&!oldbutton&&selected==10){
+                       if(Input::Button()&&!oldbutton&&selected==10){
                                usermousesensitivity+=.2;
                                if(usermousesensitivity>2)usermousesensitivity=.2;
                        }
-                       if(Button()&&!oldbutton&&selected==11){
+                       if(Input::Button()&&!oldbutton&&selected==11){
                                volume+=.1f;
                                if(volume>1.0001f)volume=0;
                                OPENAL_SetSFXMasterVolume((int)(volume*255));
                        }
-                       if(Button()&&!oldbutton&&selected==7){
+                       if(Input::Button()&&!oldbutton&&selected==7){
                                /*fireSound();
                                */
                                flash();
@@ -2709,17 +2684,17 @@ void    Game::Tick()
                                selected=-1;
                                keyselect=-1;
                        }
-                       if(Button() && !oldbutton && selected == 12) {
+                       if(Input::Button() && !oldbutton && selected == 12) {
                                flash();
                                
                                newstereomode = stereomode;
                                mainmenu=18;
                                keyselect=-1;
                        }
-                       if(Button() && !oldbutton && selected == 13) {
+                       if(Input::Button() && !oldbutton && selected == 13) {
                                showdamagebar=!showdamagebar;
                        }
-                       if(Button()&&!oldbutton&&selected==8){
+                       if(Input::Button()&&!oldbutton&&selected==8){
                                fireSound();
 
                                flash();
@@ -2736,7 +2711,7 @@ void      Game::Tick()
                        }
                }
                if(mainmenu==4){
-                       if(Button()&&!oldbutton&&selected!=-1&&!waiting){
+                       if(Input::Button()&&!oldbutton&&selected!=-1&&!waiting){
                                fireSound();
                                if(selected<9&&keyselect==-1)
                                        keyselect=selected;
@@ -2764,7 +2739,7 @@ void      Game::Tick()
                                endgame=0;
                        }
 
-                       if(Button()&&!oldbutton&&selected==1){
+                       if(Input::Button()&&!oldbutton&&selected==1){
                                fireSound();
 
                                flash();
@@ -2784,7 +2759,7 @@ void      Game::Tick()
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){
+                       if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){
                                fireSound();
 
                                flash();
@@ -2821,7 +2796,7 @@ void      Game::Tick()
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&selected==4){
+                       if(Input::Button()&&!oldbutton&&selected==4){
                                fireSound();
 
                                flash();
@@ -2829,21 +2804,21 @@ void    Game::Tick()
                                if(mainmenu==5&&gameon)mainmenu=2;
                                if(mainmenu==5&&!gameon)mainmenu=1;
                        }
-                       if(Button()&&!oldbutton&&selected==5){
+                       if(Input::Button()&&!oldbutton&&selected==5){
                                fireSound();
 
                                flash();
 
                                mainmenu=7;
                        }
-                       if(Button()&&!oldbutton&&selected==3){
+                       if(Input::Button()&&!oldbutton&&selected==3){
                                fireSound();
 
                                flash();
 
                                mainmenu=6;
                        }
-                       if(Button()&&!oldbutton&&selected==2){
+                       if(Input::Button()&&!oldbutton&&selected==2){
                                fireSound();
 
                                flash();
@@ -2852,7 +2827,7 @@ void      Game::Tick()
                        }
                }
                if(mainmenu==9){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
+                       if(Input::Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
                                fireSound();
 
                                flash();
@@ -2873,7 +2848,7 @@ void      Game::Tick()
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&selected==numchallengelevels){
+                       if(Input::Button()&&!oldbutton&&selected==numchallengelevels){
                                fireSound();
 
                                flash();
@@ -2882,7 +2857,7 @@ void      Game::Tick()
                        }
                }
                if(mainmenu==11){
-                       if(Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
+                       if(Input::Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
                                fireSound();
 
                                flash();
@@ -2903,7 +2878,7 @@ void      Game::Tick()
                                gameon=1;
                                OPENAL_SetPaused(channels[stream_music3], true);
                        }
-                       if(Button()&&!oldbutton&&selected==numchallengelevels){
+                       if(Input::Button()&&!oldbutton&&selected==numchallengelevels){
                                fireSound();
 
                                flash();
@@ -2913,7 +2888,7 @@ void      Game::Tick()
                }
                if(mainmenu==10){
                        endgame=2;
-                       if(Button()&&!oldbutton&&selected==3){
+                       if(Input::Button()&&!oldbutton&&selected==3){
                                fireSound();
 
                                flash();
@@ -2923,7 +2898,7 @@ void      Game::Tick()
                }
 
                if(mainmenu==6){
-                       if(Button()&&!oldbutton) {
+                       if(Input::Button()&&!oldbutton) {
                                if(selected>-1){
                                        fireSound();
                                        if(selected==1) {
@@ -2938,7 +2913,7 @@ void      Game::Tick()
                        }
                }
                if(mainmenu==7){
-                       if(Button()&&!oldbutton) {
+                       if(Input::Button()&&!oldbutton) {
                                if(selected!=-1){
                                        fireSound();
                                        if(selected==0&&Account::getNbAccounts()<8){
@@ -2963,7 +2938,7 @@ void      Game::Tick()
                        }
                }
                if(mainmenu==8){
-                       if(Button()&&!oldbutton&&selected>-1){
+                       if(Input::Button()&&!oldbutton&&selected>-1){
                                fireSound();
 
                                if(selected<=2)
@@ -2976,7 +2951,7 @@ void      Game::Tick()
                        }
                }
                if (mainmenu==18) {                     
-                       if(Button()&&!oldbutton&&selected==0) {
+                       if(Input::Button()&&!oldbutton&&selected==0) {
                                newstereomode = (StereoMode)(newstereomode + 1);
                                while(!CanInitStereo(newstereomode)) {
                                        printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode), newstereomode);
@@ -2994,11 +2969,11 @@ void    Game::Tick()
                                stereoseparation-=0.001;
                        }
 
-                       if(Button()&&!oldbutton&&selected==2) {
+                       if(Input::Button()&&!oldbutton&&selected==2) {
                                stereoreverse =! stereoreverse;
                        }
                        
-                       if(Button()&&!oldbutton&&selected==3) {
+                       if(Input::Button()&&!oldbutton&&selected==3) {
                                flash();
 
                                stereomode = newstereomode;
@@ -3009,7 +2984,7 @@ void      Game::Tick()
                }
 
 
-               if(Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1;
+               if(Input::Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1;
                else oldbutton=0;
 
                if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
index 41229e345fada9be48e246850545c9ac12aa27c8..3cf1b1ce99657b9d466589834047025056e680e0 100644 (file)
@@ -47,3 +47,22 @@ const char* Input::keyToChar(unsigned short i) {
                return "unknown";
 }
 
+unsigned short         Input::CharToKey(const char* which)
+{
+       for(unsigned short i=0;i<SDLK_LAST;i++) {
+               if(!strcasecmp(which,SDL_GetKeyName(SDLKey(i))))
+                       return i;
+       }
+       if(!strcasecmp(which,"mouse1")){
+               return MOUSEBUTTON1;
+       }
+       if(!strcasecmp(which,"mouse2")){
+               return MOUSEBUTTON2;
+       }
+       return SDLK_LAST;
+}
+
+Boolean Input::Button()
+{
+    return SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_LEFT);
+}
index 571f33ef0229cef0af498e9a9ff22434c18a1136..f78437c39bbdc10d9e3784f40ea3047c87759bb2 100644 (file)
@@ -27,11 +27,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "SDL.h"
 #include "Game.h"
 
+/**> CONSTANT DECLARATIONS <**/
+#define MOUSEBUTTON1           SDLK_LAST+SDL_BUTTON_LEFT
+#define MOUSEBUTTON2           SDLK_LAST+SDL_BUTTON_RIGHT
+
+/**> FUNCTION PROTOTYPES <**/
 class Input {
        public:
                static bool isKeyDown(int k);
                static const char* keyToChar(unsigned short which);
                static void setKeyFor(Game* g);
+               static unsigned short   CharToKey(const char* which);
+               static Boolean Button();
 };
 
 #endif
index 16b8c82357047a24df357e809ada131ea82f87fc..7e32f0bbee6ceaede81f2dd56295954275211abc 100644 (file)
@@ -286,29 +286,6 @@ void DrawGL (Game & game)
        }
 }
 
-
-/*static KeyMap g_theKeys;
-
-void SetKey( int key)
-{
-    g_theKeys[ key >> 3] |= (1 << (key & 7));
-}
-
-void ClearKey( int key)
-{
-    g_theKeys[ key >> 3] &= (0xff ^ (1 << (key & 7)));
-}
-
-void GetKeys(  unsigned char theKeys[16])
-{
-    memcpy( theKeys, &g_theKeys, 16);
-}*/
-
-Boolean Button()
-{
-    return SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_LEFT);
-}
-
 static inline int clamp_sdl_mouse_button(Uint8 button)
 {
     if (button == 2)   // right mouse button is button 3 in SDL.
index 9642cb941d04195695d466060758539295249af9..7e62341d4b70bd1b5b6d4289b20eb19e66fa4455 100644 (file)
@@ -214,34 +214,34 @@ bool LoadSettings(Game &game) {
                        ipstream >> volume;
                } else if ( !strncmp(setting, "Forward key", 11) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.forwardkey = CharToKey(string);
+                       game.forwardkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Back key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.backkey = CharToKey(string);
+                       game.backkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Left key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.leftkey = CharToKey(string);
+                       game.leftkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Right key", 9) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.rightkey = CharToKey(string);
+                       game.rightkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Jump key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.jumpkey = CharToKey(string);
+                       game.jumpkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Crouch key", 10) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.crouchkey = CharToKey(string);
+                       game.crouchkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Draw key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.drawkey = CharToKey(string);
+                       game.drawkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Throw key", 9) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.throwkey = CharToKey(string);
+                       game.throwkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Attack key", 10) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.attackkey = CharToKey(string);
+                       game.attackkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Chat key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
-                       game.chatkey = CharToKey(string);
+                       game.chatkey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Damage bar", 10) ) {
                        ipstream >> showdamagebar;
                } else if ( !strncmp(setting, "StereoMode", 10) ) {
diff --git a/Source/WinInput.cpp b/Source/WinInput.cpp
deleted file mode 100644 (file)
index 8726854..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*/
-
-/**> HEADER FILES <**/
-#include "WinInput.h"
-#include "SDL.h"
-
-#ifdef WIN32
-#include <string.h>
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#endif
-
-extern bool keyboardfrozen;
-/********************> IsKeyDown() <*****/
-
-unsigned short         CharToKey(const char* which)
-{
-       for(unsigned short i=0;i<SDLK_LAST;i++) {
-               if(!strcasecmp(which,SDL_GetKeyName(SDLKey(i))))
-                       return i;
-       }
-       if(!strcasecmp(which,"mouse1")){
-               return MOUSEBUTTON1;
-       }
-       if(!strcasecmp(which,"mouse2")){
-               return MOUSEBUTTON2;
-       }
-       return SDLK_LAST;
-}
diff --git a/Source/WinInput.h b/Source/WinInput.h
deleted file mode 100644 (file)
index 1145eb3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-Copyright (C) 2003, 2010 - Wolfire Games
-
-This file is part of Lugaru.
-
-Lugaru is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*/
-
-#ifndef _WININPUT_H_
-#define _WININPUT_H_
-
-/**> HEADER FILES <**/
-#include <stdlib.h>
-#include <stdio.h>
-#include "MacCompatibility.h"
-#include "SDL.h"
-
-/**> CONSTANT DECLARATIONS <**/
-#define MOUSEBUTTON1           SDLK_LAST+SDL_BUTTON_LEFT
-#define MOUSEBUTTON2           SDLK_LAST+SDL_BUTTON_RIGHT
-
-/**> FUNCTION PROTOTYPES <**/
-void   InitMouse();
-void   MoveMouse(int xcoord, int ycoord, Point *mouseloc);
-void   RefreshMouse(Point *mouseloc);
-void   DisposeMouse();
-unsigned short         CharToKey(const char* which);
-
-Boolean Button();
-
-#endif