浏览代码

Update spriteeditor.c

Rudy Boudewijn van Etten 5 年之前
父节点
当前提交
e85e3b6ff3
共有 1 个文件被更改,包括 13 次插入8 次删除
  1. 13 8
      SpriteEditor/spriteeditor.c

+ 13 - 8
SpriteEditor/spriteeditor.c

@@ -158,7 +158,7 @@ static	float palettewidth;
 static  float paletteheight;// ' our palette screen w and h
 static	float palettecellwidth;
 static  float palettecellheight; //'cell width and height of color
-static	int numpalette;// 'number of colors
+static	int numpalette;// 'number of colors (holds the amount of the selected palette.)
 	
 	//'
 	//' Top Bar
@@ -2383,15 +2383,18 @@ void readtempsprite(int w,int h,char *in){
         
             int z=0;
             int num=0;
-            char charnum[14];
-            while(in[i+z]!=','){                
-                charnum[z]=in[i+z];
+            char charnum[14]="";
+            
+            //while(in[i]!=','){                
+            do{    
+                charnum[z]=in[i];
+                i++;
                 z++;
-                if(z>=3)break;//no longer numbers than 3
-            }
-            i+=z;
-            num = atoi(charnum);
+                if(i+1>=strlen(in))break;//no longer numbers than 3
+            }while(in[i]!=',');
             
+            num = atoi(charnum);
+             
             cnt++;
             if(cnt>1){
                 y++;
@@ -2401,8 +2404,10 @@ void readtempsprite(int w,int h,char *in){
                 }                
             }
             
+            if(num>=numpalette)num=0;
             //tempsprite[x][y] = num;//in[i]-'0';
             map[x][y] = num;//in[i]-'0';
+            //if(num>15)map[x][y]=0;
         }
     }
 }