id collision validation
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
46d526a26d
commit
595dac8e4b
@ -1742,6 +1742,7 @@ Fix character bug with loading into level
|
||||
Multiple loot pool support
|
||||
Crops replace loot pool on completion of growth
|
||||
Display name for all common entity data
|
||||
Enitity id collision validation
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package electrosphere.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import electrosphere.data.common.CommonEntityType;
|
||||
@ -33,6 +35,45 @@ public class ConfigValidator {
|
||||
for(CommonEntityType type : allData){
|
||||
CommonEntityValidator.validate(type);
|
||||
}
|
||||
|
||||
ConfigValidator.checkIdCollisions(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are any id collisions
|
||||
* @param config The config
|
||||
*/
|
||||
private static void checkIdCollisions(Config config){
|
||||
//check for id collisions
|
||||
Map<String,Boolean> occupancyMap = new HashMap<String,Boolean>();
|
||||
for(CommonEntityType type : config.getObjectTypeMap().getTypes()){
|
||||
if(occupancyMap.containsKey(type.getId())){
|
||||
throw new Error("Entity id collision: " + type.getId());
|
||||
} else {
|
||||
occupancyMap.put(type.getId(),true);
|
||||
}
|
||||
}
|
||||
for(CommonEntityType type : config.getCreatureTypeLoader().getTypes()){
|
||||
if(occupancyMap.containsKey(type.getId())){
|
||||
throw new Error("Entity id collision: " + type.getId());
|
||||
} else {
|
||||
occupancyMap.put(type.getId(),true);
|
||||
}
|
||||
}
|
||||
for(CommonEntityType type : config.getFoliageMap().getTypes()){
|
||||
if(occupancyMap.containsKey(type.getId())){
|
||||
throw new Error("Entity id collision: " + type.getId());
|
||||
} else {
|
||||
occupancyMap.put(type.getId(),true);
|
||||
}
|
||||
}
|
||||
for(CommonEntityType type : config.getItemMap().getTypes()){
|
||||
if(occupancyMap.containsKey(type.getId())){
|
||||
throw new Error("Entity id collision: " + type.getId());
|
||||
} else {
|
||||
occupancyMap.put(type.getId(),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user