<commit_before>package resources.objects.buildouts;

import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import resources.Location;
import resources.Terrain;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.WorldSnapshotData;
import resources.client_info.visitors.WorldSnapshotData.Chunk;
import resources.containers.ContainerPermissions;
import resources.objects.SWGObject;
import resources.objects.cell.CellObject;
import resources.server_info.Log;
import services.objects.ObjectCreator;

public class TerrainSnapshotLoader {
	
	private static final String BASE_PATH = "snapshot/";
	
	private final Terrain terrain;
	private final Map <Long, SWGObject> objectTable;
	private final List <SWGObject> objects;
	
	public TerrainSnapshotLoader(Terrain terrain) {
		this.terrain = terrain;
		this.objectTable = new Hashtable<Long, SWGObject>(12*1024);
		this.objects = new LinkedList<>();
	}
	
	public List <SWGObject> getObjects() {
		return objects;
	}
	
	public void load() {
		objects.clear();
		String path = BASE_PATH + terrain.getName() + ".ws";
		WorldSnapshotData data = (WorldSnapshotData) ClientFactory.getInfoFromFile(path);
		Map <Integer, String> templates = data.getObjectTemplateNames();
		for (Chunk chunk : data.getChunks()) {
			SWGObject object = createObject(templates, chunk);
			object.setLoadRange(chunk.getRadius());
			addObject(object, chunk.getContainerId());
			setCellInformation(object, chunk.getCellIndex());
			updatePermissions(object);
		}
	}
	
	private SWGObject createObject(Map <Integer, String> templateMap, Chunk row) {
		SWGObject object = ObjectCreator.createObjectFromTemplate(row.getId(), templateMap.get(row.getObjectTemplateNameIndex()));
		Location l = row.getLocation();
		l.setTerrain(terrain);
		object.setLocation(l);
		return object;
	}
	
	private void addObject(SWGObject object, long containerId) {<commit_msg>Fixed snapshots to load like buildouts<commit_after>package resources.objects.buildouts;

import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import resources.Location;
import resources.Terrain;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.WorldSnapshotData;
import resources.client_info.visitors.WorldSnapshotData.Chunk;
import resources.containers.ContainerPermissions;
import resources.objects.SWGObject;
import resources.objects.cell.CellObject;
import resources.server_info.Log;
import services.objects.ObjectCreator;

public class TerrainSnapshotLoader {
	
	private static final String BASE_PATH = "snapshot/";
	
	private final Terrain terrain;
	private final Map <Long, SWGObject> objectTable;
	private final List <SWGObject> objects;
	
	public TerrainSnapshotLoader(Terrain terrain) {
		this.terrain = terrain;
		this.objectTable = new Hashtable<Long, SWGObject>(12*1024);
		this.objects = new LinkedList<>();
	}
	
	public List <SWGObject> getObjects() {
		return objects;
	}
	
	public void load() {
		objects.clear();
		String path = BASE_PATH + terrain.getName() + ".ws";
		WorldSnapshotData data = (WorldSnapshotData) ClientFactory.getInfoFromFile(path);
		Map <Integer, String> templates = data.getObjectTemplateNames();
		for (Chunk chunk : data.getChunks()) {
			SWGObject object = createObject(templates, chunk);
			object.setBuildout(true);
			object.setLoadRange(chunk.getRadius());
			addObject(object, chunk.getContainerId());
			setCellInformation(object, chunk.getCellIndex());
			updatePermissions(object);
		}
	}
	
	private SWGObject createObject(Map <Integer, String> templateMap, Chunk row) {
		SWGObject object = ObjectCreator.createObjectFromTemplate(row.getId(), templateMap.get(row.getObjectTemplateNameIndex()));
		Location l = row.getLocation();
		l.setTerrain(terrain);
		object.setLocation(l);
		return object;
	}
	
	private void addObject(SWGObject object, long containerId) {
{'fraction_non_alphanumeric': 0.1050228310502283, 'fraction_numerical': 0.0030441400304414, 'mean_word_length': 5.881326352530541, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1561716', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1143, 'n_words': 264}