From 60db149cddefb0c0fea8389eb5c9bbb7fb6787f1 Mon Sep 17 00:00:00 2001 From: TurtleP Date: Wed, 29 May 2024 10:09:20 -0400 Subject: [PATCH] backport game stuff and fix bundled stuff (woops) --- source/main.cpp | 9 ++++++--- source/modules/love/scripts/arg.lua | 14 ++++++-------- source/modules/love/scripts/boot.lua | 23 +++-------------------- source/modules/love/scripts/callbacks.lua | 2 +- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 3ff7c918..92cf6c7f 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -28,13 +28,16 @@ DoneAction RunLOVE(int argc, char** argv, int& retval, Variant& restartValue) lua_rawseti(L, -2, -2); } + std::vector args(argv, argv + argc); + args.push_back("game"); + lua_pushstring(L, "embedded boot.lua"); lua_rawseti(L, -2, -1); - for (int i = 1; i < argc; i++) + for (int index = 1; index < (int)args.size(); index++) { - lua_pushstring(L, argv[i]); - lua_rawseti(L, -2, i); + lua_pushstring(L, args[index]); + lua_rawseti(L, -2, index); } lua_setglobal(L, "arg"); diff --git a/source/modules/love/scripts/arg.lua b/source/modules/love/scripts/arg.lua index 342f28ca..29e71164 100644 --- a/source/modules/love/scripts/arg.lua +++ b/source/modules/love/scripts/arg.lua @@ -3,7 +3,7 @@ R"luastring"--( -- There is a matching delimiter at the bottom of the file. --[[ -Copyright (c) 2006-2021 LOVE Development Team +Copyright (c) 2006-2024 LOVE Development Team This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -45,7 +45,6 @@ end -- Checks whether a path is absolute or not. function love.path.abs(p) - local tmp = love.path.normalslashes(p) -- Path is absolute if it starts with a "/". @@ -61,7 +60,6 @@ function love.path.abs(p) -- Relative. return false - end -- Converts any path into a full path. @@ -71,7 +69,6 @@ function love.path.getFull(p) end local cwd = love.filesystem.getWorkingDirectory() - cwd = love.path.normalslashes(cwd) cwd = love.path.endslash(cwd) @@ -115,7 +112,9 @@ end love.arg.options = { console = { a = 0 }, fused = { a = 0 }, - game = { a = 1 } + game = { a = 1 }, + renderers = { a = 1 }, + excluderenderers = { a = 1 }, } love.arg.optionIndices = {} @@ -131,11 +130,10 @@ function love.arg.parseOption(m, i) end end - table.insert(m.arg, "game") return m.a end -function love.arg.parseOptions() +function love.arg.parseOptions(arg) local game local argc = #arg @@ -147,7 +145,7 @@ function love.arg.parseOptions() if m and m ~= "" and love.arg.options[m] and not love.arg.options[m].set then love.arg.optionIndices[i] = true i = i + love.arg.parseOption(love.arg.options[m], i + 1) - elseif m == "" then -- handle '--' as an option + elseif m == "" then -- handle '--' as an option love.arg.optionIndices[i] = true if not game then -- handle '--' followed by game name game = i + 1 diff --git a/source/modules/love/scripts/boot.lua b/source/modules/love/scripts/boot.lua index eebfc955..9073de41 100644 --- a/source/modules/love/scripts/boot.lua +++ b/source/modules/love/scripts/boot.lua @@ -35,15 +35,6 @@ local function uridecode(s) end) end -local function https_setup_certs() - local https = require("https") - - if love._os == "Cafe" then - return https.setCertificateFile("/sdcard/config/ssl/cacert.pem") - end - https.setCertificateFile("sdmc/config/ssl/cacert.pem") -end - local no_game_code = false local invalid_game_path = nil local main_file = "main.lua" @@ -56,7 +47,6 @@ function love.boot() love.rawGameArguments = arg local arg0 = love.arg.getLow(love.rawGameArguments) - love.filesystem.init(arg0) local exepath = love.filesystem.getExecutablePath() @@ -108,11 +98,10 @@ function love.boot() main_file = source_leaf custom_main_file = true full_source = love.path.getFull(full_source:sub(1, -(#source_leaf + 1))) - elseif nouri:match("%.love$") then - full_source = nouri end can_has_game = pcall(love.filesystem.setSource, full_source) + if not can_has_game then invalid_game_path = full_source end @@ -134,23 +123,17 @@ function love.boot() identity = identity:gsub("^([%.]+)", "") -- strip leading "."'s identity = identity:gsub("%.([^%.]+)$", "") -- strip extension identity = identity:gsub("%.", "_") -- replace remaining "."'s with "_" - identity = #identity > 0 and identity or "game" + identity = #identity > 0 and identity or "lovegame" -- When conf.lua is initially loaded, the main source should be checked -- before the save directory (the identity should be appended.) pcall(love.filesystem.setIdentity, identity, true) - local has_main_file = love.filesystem.getInfo(main_file) - local has_conf_file = love.filesystem.getInfo("conf.lua") - - if can_has_game and not (has_main_file or (not custom_main_file and has_conf_file)) then + if can_has_game and not (love.filesystem.getInfo(main_file) or (not custom_main_file and love.filesystem.getInfo("conf.lua"))) then no_game_code = true end - -- https_setup_certs() - if not can_has_game then - invalid_game_path = false local nogame = require("love.nogame") nogame() end diff --git a/source/modules/love/scripts/callbacks.lua b/source/modules/love/scripts/callbacks.lua index 747159e4..8357b940 100644 --- a/source/modules/love/scripts/callbacks.lua +++ b/source/modules/love/scripts/callbacks.lua @@ -224,7 +224,7 @@ end function love.run() if love.load then - love.load(arg) + love.load(love.parsedGameArguments, love.rawGameArguments) end if love.timer then