]> git.jsancho.org Git - lugaru.git/commitdiff
Minor Loadlevel cleanup
authorAlexander Monakov <amonakov@gmail.com>
Fri, 7 Jan 2011 19:41:38 +0000 (22:41 +0300)
committerAlexander Monakov <amonakov@gmail.com>
Fri, 7 Jan 2011 19:41:38 +0000 (22:41 +0300)
Source/Game.h
Source/GameTick.cpp

index d09474a96b2f640f1f4f0779a83abb2bc1488afe..63bb0a6468bfcbf60863b6055005c8ab0a90edd4 100644 (file)
@@ -246,7 +246,7 @@ class Game
                void TickOnceAfter();
                void SetUpLighting();
                void Loadlevel(int which);
-               void Loadlevel(char *name);
+               void Loadlevel(const char *name);
                void Setenvironment(int which);
                GLvoid ReSizeGLScene(float fov, float near);
                int findPathDist(int start,int end);
index 3281f6bf167f6984a920c8769575eb13b32d77c2..e6a810a651969e8f4fb032abf0f04d2af5f3f8f3 100644 (file)
@@ -1425,30 +1425,24 @@ void    Game::Setenvironment(int which)
 
 void   Game::Loadlevel(int which){
        stealthloading=0;
-
-       if(which==0)Loadlevel((char *)":Data:Maps:map1");
-       else if(which==1)Loadlevel((char *)":Data:Maps:map2");
-       else if(which==2)Loadlevel((char *)":Data:Maps:map3");
-       else if(which==3)Loadlevel((char *)":Data:Maps:map4");
-       else if(which==4)Loadlevel((char *)":Data:Maps:map5");
-       else if(which==5)Loadlevel((char *)":Data:Maps:map6");
-       else if(which==6)Loadlevel((char *)":Data:Maps:map7");
-       else if(which==7)Loadlevel((char *)":Data:Maps:map8");
-       else if(which==8)Loadlevel((char *)":Data:Maps:map9");
-       else if(which==9)Loadlevel((char *)":Data:Maps:map10");
-       else if(which==10)Loadlevel((char *)":Data:Maps:map11");
-       else if(which==11)Loadlevel((char *)":Data:Maps:map12");
-       else if(which==12)Loadlevel((char *)":Data:Maps:map13");
-       else if(which==13)Loadlevel((char *)":Data:Maps:map14");
-       else if(which==14)Loadlevel((char *)":Data:Maps:map15");
-       else if(which==15)Loadlevel((char *)":Data:Maps:map16");
-       else if(which==-1){tutoriallevel=-1;Loadlevel((char *)":Data:Maps:tutorial");}
-       else Loadlevel((char *)":Data:Maps:mapsave");
-
        whichlevel=which;
+
+       if (which == -1)
+         {
+           tutoriallevel = -1;
+           Loadlevel(":Data:Maps:tutorial");
+         }
+       else if (which >= 0 && which <= 15)
+         {
+           char buf[32];
+           snprintf(buf, 32, ":Data:Maps:map%d", which + 1);
+           Loadlevel(buf);
+         }
+       else
+         Loadlevel(":Data:Maps:mapsave");
 }
 
-void   Game::Loadlevel(char *name){
+void   Game::Loadlevel(const char *name){
        int i,j,k,l,m;
        static int oldlevel;
        int templength;