@@ -704,11 +704,16 @@ static int l_register_ore(lua_State *L)
704
704
enum OreType oretype = (OreType)getenumfield (L, index ,
705
705
" ore_type" , es_OreType, ORE_SCATTER);
706
706
Ore *ore = createOre (oretype);
707
+ if (!ore) {
708
+ errorstream << " register_ore: ore_type "
709
+ << oretype << " not implemented" ;
710
+ return 0 ;
711
+ }
707
712
708
713
ore->ore_name = getstringfield_default (L, index , " ore" , " " );
709
714
ore->wherein_name = getstringfield_default (L, index , " wherein" , " " );
710
- ore->clust_scarcity = getintfield_default (L, index , " clust_scarcity" , 0 );
711
- ore->clust_num_ores = getintfield_default (L, index , " clust_num_ores" , 0 );
715
+ ore->clust_scarcity = getintfield_default (L, index , " clust_scarcity" , 1 );
716
+ ore->clust_num_ores = getintfield_default (L, index , " clust_num_ores" , 1 );
712
717
ore->clust_size = getintfield_default (L, index , " clust_size" , 0 );
713
718
ore->height_min = getintfield_default (L, index , " height_min" , 0 );
714
719
ore->height_max = getintfield_default (L, index , " height_max" , 0 );
@@ -720,6 +725,13 @@ static int l_register_ore(lua_State *L)
720
725
721
726
ore->noise = NULL ;
722
727
728
+ if (ore->clust_scarcity <= 0 || ore->clust_num_ores <= 0 ) {
729
+ errorstream << " register_ore: clust_scarcity and clust_num_ores"
730
+ " must be greater than 0" ;
731
+ delete ore;
732
+ return 0 ;
733
+ }
734
+
723
735
emerge->ores .push_back (ore);
724
736
725
737
verbosestream << " register_ore: ore '" << ore->ore_name
0 commit comments