File tree 1 file changed +9
-22
lines changed
1 file changed +9
-22
lines changed Original file line number Diff line number Diff line change @@ -594,31 +594,18 @@ int ModApiMainMenu::l_create_world(lua_State *L)
594
594
/* *****************************************************************************/
595
595
int ModApiMainMenu::l_delete_world (lua_State *L)
596
596
{
597
- int worldidx = luaL_checkinteger (L,1 ) -1 ;
598
-
597
+ int world_id = luaL_checkinteger (L, 1 ) - 1 ;
599
598
std::vector<WorldSpec> worlds = getAvailableWorlds ();
600
-
601
- if ((worldidx >= 0 ) &&
602
- (worldidx < (int ) worlds.size ())) {
603
-
604
- WorldSpec spec = worlds[worldidx];
605
-
606
- std::vector<std::string> paths;
607
- paths.push_back (spec.path );
608
- fs::GetRecursiveSubPaths (spec.path , paths, true );
609
-
610
- // Delete files
611
- if (!fs::DeletePaths (paths)) {
612
- lua_pushstring (L, " Failed to delete world" );
613
- }
614
- else {
615
- lua_pushnil (L);
616
- }
617
- }
618
- else {
599
+ if (world_id < 0 || world_id >= (int ) worlds.size ()) {
619
600
lua_pushstring (L, " Invalid world index" );
601
+ return 1 ;
620
602
}
621
- return 1 ;
603
+ const WorldSpec &spec = worlds[world_id];
604
+ if (!fs::RecursiveDelete (spec.path )) {
605
+ lua_pushstring (L, " Failed to delete world" );
606
+ return 1 ;
607
+ }
608
+ return 0 ;
622
609
}
623
610
624
611
/* *****************************************************************************/
You can’t perform that action at this time.
0 commit comments