All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.daxie.xops.bd1.BD1Parser Maven / Gradle / Ivy

package com.daxie.xops.bd1;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.daxie.tool.ByteFunctions;
import com.daxie.tool.FileFunctions;
import com.daxie.tool.FilenameFunctions;

/**
 * Reads data from a BD1 file.
 * @author Daba
 *
 */
class BD1Parser {
	private Map texture_filenames_map;//(texture_id,texture_filename)
	private List blocks;
	
	public BD1Parser(String bd1_filename) throws IOException{
		texture_filenames_map=new HashMap<>();
		blocks=new ArrayList<>();
		
		List bin=FileFunctions.GetFileAllBin(bd1_filename);
		
		int pos=0;
		
		//Texture filenames
		byte[] texture_filename_buffer=new byte[31];
		String texture_filename_temp;
		int first_null_pos;
		for(int i=0;i<10;i++) {
			for(int j=0;j<31;j++) {
				texture_filename_buffer[j]=bin.get(pos);
				pos++;
			}
			texture_filename_temp=new String(texture_filename_buffer);
			
			first_null_pos=30;
			for(int j=0;j<30;j++) {
				if(texture_filename_temp.charAt(j)=='\0') {
					first_null_pos=j;
					break;
				}
			}
			
			texture_filename_temp=texture_filename_temp.substring(0, first_null_pos);
			texture_filename_temp=FilenameFunctions.ReplaceWindowsDelimiterWithLinuxDelimiter(texture_filename_temp);
			
			texture_filenames_map.put(i, texture_filename_temp);
		}
		
		//Number of blocks
		int block_num=ByteFunctions.GetUShortValueFromBin_LE(bin, pos);
		pos+=2;
		
		//Blocks
		for(int i=0;i GetBlocks(){
		return new ArrayList(blocks);
	}
	public Map GetTextureFilenamesMap(){
		return new HashMap(texture_filenames_map);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy