Compare commits
	
		
			1 Commits
		
	
	
		
			a1e36ccbc7
			...
			8d88f01c9d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						8d88f01c9d
	
				 | 
					
					
						
@ -1,44 +0,0 @@
 | 
				
			|||||||
package school_project;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.io.*;
 | 
					 | 
				
			||||||
import java.lang.reflect.Array;
 | 
					 | 
				
			||||||
import java.util.Arrays;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class MapParser {
 | 
					 | 
				
			||||||
    public static Map ParseMapFile(File file) throws IllegalArgumentException, IllegalAccessException, IOException {
 | 
					 | 
				
			||||||
        System.out.println(file.getAbsolutePath());
 | 
					 | 
				
			||||||
        FileInputStream fileStream = new FileInputStream(file);
 | 
					 | 
				
			||||||
        if(!file.isFile()) throw new IllegalArgumentException("The argument should be a file");
 | 
					 | 
				
			||||||
        if(!file.canRead()) throw new IllegalAccessException("This file can't be read");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        byte[] bytes = fileStream.readAllBytes();
 | 
					 | 
				
			||||||
        int start_position = 0, end_position = 0;
 | 
					 | 
				
			||||||
        for (int i = 0; i < bytes.length; i++) {
 | 
					 | 
				
			||||||
            if(bytes[i] == 83 && bytes[i+1] == 77 && bytes[i+2] == 83){ // SMS
 | 
					 | 
				
			||||||
                start_position = i+3;
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (int i = start_position; i < bytes.length; i++) {
 | 
					 | 
				
			||||||
            if(bytes[i] == 83 && bytes[i+1] == 77 && bytes[i+2] == 69){ // SME
 | 
					 | 
				
			||||||
                end_position = i;
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        byte[] map_data = Arrays.copyOfRange(bytes, start_position, end_position); //TODO tonitch cursor
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        fileStream.close();
 | 
					 | 
				
			||||||
        return new Map(); //TODO: Send the parsed map
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//    public static void SaveMapFile(File file){
 | 
					 | 
				
			||||||
//    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public static void main(String[] args) throws IOException, IllegalAccessException {
 | 
					 | 
				
			||||||
        ParseMapFile(new File("test.smap"));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user