Browse Source

Attempt to make identity autodetection even more robust using getRealDirectory

Bart van Strien 10 years ago
parent
commit
29da6b3c26
2 changed files with 19 additions and 0 deletions
  1. 7 0
      src/scripts/boot.lua
  2. 12 0
      src/scripts/boot.lua.h

+ 7 - 0
src/scripts/boot.lua

@@ -289,9 +289,16 @@ function love.boot()
 	local identity = ""
 	local identity = ""
 	if not can_has_game and o.game.set and o.game.arg[1] then
 	if not can_has_game and o.game.set and o.game.arg[1] then
 		local nouri = o.game.arg[1]
 		local nouri = o.game.arg[1]
+
+		-- Use the realdir to determine the identity, if we can
+		if love.filesystem.isFile("main.lua") then
+			nouri = love.filesystem.getRealDirectory("main.lua")
+		end
+
 		if nouri:sub(1, 7) == "file://" then
 		if nouri:sub(1, 7) == "file://" then
 			nouri = uridecode(nouri:sub(8))
 			nouri = uridecode(nouri:sub(8))
 		end
 		end
+
 		local full_source =  love.path.getfull(nouri)
 		local full_source =  love.path.getfull(nouri)
 		can_has_game = pcall(love.filesystem.setSource, full_source)
 		can_has_game = pcall(love.filesystem.setSource, full_source)
 		
 		

+ 12 - 0
src/scripts/boot.lua.h

@@ -533,6 +533,18 @@ const unsigned char boot_lua[] =
 	0x74, 0x68, 0x65, 0x6e, 0x0a,
 	0x74, 0x68, 0x65, 0x6e, 0x0a,
 	0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6e, 0x6f, 0x75, 0x72, 0x69, 0x20, 0x3d, 0x20, 0x6f, 0x2e, 
 	0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6e, 0x6f, 0x75, 0x72, 0x69, 0x20, 0x3d, 0x20, 0x6f, 0x2e, 
 	0x67, 0x61, 0x6d, 0x65, 0x2e, 0x61, 0x72, 0x67, 0x5b, 0x31, 0x5d, 0x0a,
 	0x67, 0x61, 0x6d, 0x65, 0x2e, 0x61, 0x72, 0x67, 0x5b, 0x31, 0x5d, 0x0a,
+	0x09, 0x09, 0x2d, 0x2d, 0x20, 0x55, 0x73, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x61, 0x6c, 0x64, 
+	0x69, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x64, 0x65, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x65, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2c, 0x20, 0x69, 0x66, 0x20, 0x77, 0x65, 0x20, 
+	0x63, 0x61, 0x6e, 0x0a,
+	0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 
+	0x65, 0x6d, 0x2e, 0x69, 0x73, 0x46, 0x69, 0x6c, 0x65, 0x28, 0x22, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x6c, 0x75, 
+	0x61, 0x22, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
+	0x09, 0x09, 0x09, 0x6e, 0x6f, 0x75, 0x72, 0x69, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 
+	0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x67, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x44, 0x69, 
+	0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x28, 0x22, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x6c, 0x75, 0x61, 0x22, 
+	0x29, 0x0a,
+	0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x75, 0x72, 0x69, 0x3a, 0x73, 0x75, 0x62, 0x28, 0x31, 0x2c, 0x20, 
 	0x09, 0x09, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x75, 0x72, 0x69, 0x3a, 0x73, 0x75, 0x62, 0x28, 0x31, 0x2c, 0x20, 
 	0x37, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0x2f, 0x2f, 0x22, 0x20, 0x74, 0x68, 
 	0x37, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0x2f, 0x2f, 0x22, 0x20, 0x74, 0x68, 
 	0x65, 0x6e, 0x0a,
 	0x65, 0x6e, 0x0a,