@@ -351,24 +351,21 @@ void Terrain3DData::save_region(const Vector2i &p_region_loc, const String &p_di
351351
352352void Terrain3DData::load_directory (const String &p_dir) {
353353 if (p_dir.is_empty ()) {
354- LOG (ERROR, " Specified data directory is blank" );
354+ LOG (ERROR, " Specified directory name is blank" );
355355 return ;
356356 }
357- Ref<DirAccess> da = DirAccess::open (p_dir);
358- if (da.is_null ()) {
359- LOG (ERROR, " Cannot read Terrain3D data directory: " , p_dir);
357+
358+ LOG (INFO, " Loading region files from " , p_dir);
359+ PackedStringArray files = Util::get_files (p_dir, " terrain3d*.res" );
360+ if (files.size () == 0 ) {
361+ LOG (INFO, " No Terrain3D region files found in: " , p_dir);
360362 return ;
361363 }
362- _clear ();
363364
364- LOG (INFO, " Loading region files from " , p_dir);
365- PackedStringArray files = da->get_files ();
365+ _clear ();
366366 for (int i = 0 ; i < files.size (); i++) {
367- String fname = files[i]. trim_suffix ( " .remap " ) ;
367+ String fname = files[i];
368368 String path = p_dir + String (" /" ) + fname;
369- if (!fname.begins_with (" terrain3d" ) || !fname.ends_with (" .res" )) {
370- continue ;
371- }
372369 LOG (DEBUG, " Loading region from " , path);
373370 Vector2i loc = Util::filename_to_location (fname);
374371 if (loc.x == INT32_MAX) {
0 commit comments