From ee1df4fd40e5e70a3995b5ebec1f380730c36ca9 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 19 Oct 2014 19:42:12 +0300 Subject: [PATCH] impl/voxel: add_voxel(): Make sure that a voxel of the same name doesn't alrady exist --- src/impl/voxel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/impl/voxel.cpp b/src/impl/voxel.cpp index d109ab9..4881aad 100644 --- a/src/impl/voxel.cpp +++ b/src/impl/voxel.cpp @@ -80,6 +80,9 @@ struct CVoxelRegistry: public VoxelRegistry if(def.id != VOXELTYPEID_UNDEFINED && id != def.id) throw Exception(ss_()+"add_voxel(): def.id="+itos(def.id)+ "; should be "+itos(id)); + if(m_name_to_id.count(def.name) != 0) + throw Exception(ss_()+"add_voxel(): Already exists: "+ + cs(def.name.dump())); // NOTE: This invalidates all previous pointers to cache entries that // were given out m_defs.resize(id + 1);