Browse Source

Now returns return value 1 on error

Bart van Strien 13 years ago
parent
commit
db7fba1d3a
3 changed files with 16 additions and 8 deletions
  1. 7 2
      src/love.cpp
  2. 5 3
      src/scripts/boot.lua
  3. 4 3
      src/scripts/boot.lua.h

+ 7 - 2
src/love.cpp

@@ -289,7 +289,7 @@ namespace love
 	void boot(lua_State *L)
 	{
 		if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0)
-		lua_call(L, 0, 0);
+		lua_call(L, 0, LUA_MULTRET);
 	}
 } // love
 
@@ -353,6 +353,11 @@ extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv)
 
 	// Boot
 	love::boot(L);
+	
+	int retval = 0;
+	if (lua_isnumber(L, -1))
+		retval = lua_tonumber(L, -1);
+
 	lua_close(L);
 
 #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK
@@ -363,6 +368,6 @@ extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv)
 		delete [] hack_argv;
 	}
 #endif // LOVE_LEGENDARY_UTF8_ARGV_HACK
-	return 0;
+	return retval;
 }
 

+ 5 - 3
src/scripts/boot.lua

@@ -802,8 +802,10 @@ end
 -----------------------------------------------------------
 
 local result = xpcall(love.boot, error_printer)
-if not result then return end
+if not result then return 1 end
 local result = xpcall(love.init, love._release and love.releaseerrhand or love.errhand)
-if not result then return end
+if not result then return 1 end
 local result = xpcall(love.run, love._release and love.releaseerrhand or love.errhand)
-if not result then return end
+if not result then return 1 end
+
+return 0

+ 4 - 3
src/scripts/boot.lua.h

@@ -1850,20 +1850,21 @@ const unsigned char boot_lua[] =
 	0x61, 0x6c, 0x6c, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x74, 0x2c, 0x20, 0x65, 0x72, 0x72, 
 	0x6f, 0x72, 0x5f, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x29, 0x0a,
 	0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 
-	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x20, 0x65, 0x6e, 0x64, 0x0a,
 	0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x78, 0x70, 0x63, 
 	0x61, 0x6c, 0x6c, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x69, 0x6e, 0x69, 0x74, 0x2c, 0x20, 0x6c, 0x6f, 0x76, 
 	0x65, 0x2e, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6c, 0x6f, 0x76, 
 	0x65, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x65, 0x72, 0x72, 0x68, 0x61, 0x6e, 0x64, 0x20, 0x6f, 
 	0x72, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x72, 0x72, 0x68, 0x61, 0x6e, 0x64, 0x29, 0x0a,
 	0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 
-	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x20, 0x65, 0x6e, 0x64, 0x0a,
 	0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x78, 0x70, 0x63, 
 	0x61, 0x6c, 0x6c, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x72, 0x75, 0x6e, 0x2c, 0x20, 0x6c, 0x6f, 0x76, 0x65, 
 	0x2e, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6c, 0x6f, 0x76, 0x65, 
 	0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x65, 0x72, 0x72, 0x68, 0x61, 0x6e, 0x64, 0x20, 0x6f, 0x72, 
 	0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x72, 0x72, 0x68, 0x61, 0x6e, 0x64, 0x29, 0x0a,
 	0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 
-	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+	0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x20, 0x65, 0x6e, 0x64, 0x0a,0x0a,
+	0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x30, 0x0a,
 }; // [boot.lua]
 } // love