From 048469148a6d787b8a65cd77095245943f90feb7 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 9 Feb 2022 01:08:20 +0100 Subject: [PATCH] Better error messages when no materials are set into the VoxelLibrary. --- library/voxel_library.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/voxel_library.cpp b/library/voxel_library.cpp index b3449f3..79d5e54 100644 --- a/library/voxel_library.cpp +++ b/library/voxel_library.cpp @@ -50,13 +50,13 @@ bool VoxelLibrary::_supports_caching() { //Materials Ref VoxelLibrary::material_get(const int index) { - ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _materials.size(), Ref()); return _materials[index]; } Ref VoxelLibrary::material_lod_get(const int index) { - ERR_FAIL_COND_V(_materials.size() == 0, Ref(NULL)); + ERR_FAIL_COND_V_MSG(_materials.size() == 0, Ref(), "Error! You should to add at least one material to VoxelLibrary! (By default it will use up to 5. See VoxelWorldDefault::_create_chunk().)"); if (index < 0) { return _materials[0]; @@ -134,13 +134,13 @@ void VoxelLibrary::materials_set(const Vector &materials) { //Liquid Materials Ref VoxelLibrary::liquid_material_get(const int index) { - ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref()); return _liquid_materials[index]; } Ref VoxelLibrary::liquid_material_lod_get(const int index) { - ERR_FAIL_COND_V(_materials.size() == 0, Ref(NULL)); + ERR_FAIL_COND_V_MSG(_materials.size() == 0, Ref(), "Error! You should to add at least one liquid to VoxelLibrary! (By default it will use up to 5. See VoxelWorldDefault::_create_chunk().)"); if (index < 0) { return _liquid_materials[0]; @@ -219,13 +219,13 @@ void VoxelLibrary::liquid_materials_set(const Vector &materials) { //Prop Materials Ref VoxelLibrary::prop_material_get(const int index) { - ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref(NULL)); + ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref()); return _prop_materials[index]; } Ref VoxelLibrary::prop_material_lod_get(const int index) { - ERR_FAIL_COND_V(_prop_materials.size() == 0, Ref(NULL)); + ERR_FAIL_COND_V_MSG(_prop_materials.size() == 0, Ref(), "Error! You should to add at least one material to VoxelLibrary!"); if (index < 0) { return _prop_materials[0];