From dccf58be3feecce963f763fad86c64bbaa32a4b5 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Thu, 16 Mar 2017 17:29:49 +0100
Subject: [PATCH] Use https links in ingame tooltips and server requests

Conflicts:
	game/modules/tome/init.lua
---
 game/engines/default/engine/PlayerProfile.lua |  2 +-
 game/engines/default/engine/ui/WebView.lua    |  8 +++----
 .../default/modules/boot/class/Game.lua       | 14 ++++++------
 .../default/modules/boot/dialogs/Addons.lua   |  4 ++--
 .../default/modules/boot/dialogs/LoadGame.lua | 22 +++++++++----------
 .../default/modules/boot/dialogs/MainMenu.lua |  2 +-
 .../default/modules/boot/dialogs/NewGame.lua  |  2 +-
 .../boot/dialogs/ProfileSteamRegister.lua     |  2 +-
 .../modules/boot/dialogs/UpdateAll.lua        |  4 ++--
 game/modules/tome/dialogs/CharacterSheet.lua  |  2 +-
 game/modules/tome/dialogs/Donation.lua        |  2 +-
 game/modules/tome/init.lua                    |  2 +-
 12 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/game/engines/default/engine/PlayerProfile.lua b/game/engines/default/engine/PlayerProfile.lua
index 6278f98e54..3a5ca60d17 100644
--- a/game/engines/default/engine/PlayerProfile.lua
+++ b/game/engines/default/engine/PlayerProfile.lua
@@ -756,7 +756,7 @@ end
 
 function _M:registerNewCharacter(module)
 	if not self.auth or not self.hash_valid then return end
-	local dialog = Dialog:simpleWaiter("Registering character", "Character is being registered on http://te4.org/")
+	local dialog = Dialog:simpleWaiter("Registering character", "Character is being registered on https://te4.org/")
 	core.display.forceRedraw()
 
 	core.profile.pushOrder(table.serialize{o="RegisterNewCharacter", module=module})
diff --git a/game/engines/default/engine/ui/WebView.lua b/game/engines/default/engine/ui/WebView.lua
index d4fe559d6b..9f970cbf4d 100644
--- a/game/engines/default/engine/ui/WebView.lua
+++ b/game/engines/default/engine/ui/WebView.lua
@@ -38,7 +38,7 @@ function _M:init(t)
 	self.custom_calls = t.custom_calls or {}
 	if self.allow_login == nil then self.allow_login = true end
 
-	if self.allow_login and self.url:find("^http://te4%.org/") and profile.auth then
+	if self.allow_login and (self.url:find("^http://te4%.org/") or self.url:find("^https://te4%.org/")) and profile.auth then
 		local param = "_te4ah="..profile.auth.hash.."&_te4ad="..profile.auth.drupid
 
 		local first = self.url:find("?", 1, 1)
@@ -46,7 +46,7 @@ function _M:init(t)
 		else self.url = self.url.."?"..param end
 	end
 
-	if self.url:find("^http://te4%.org/")  then
+	if self.url:find("^http://te4%.org/") or self.url:find("^https://te4%.org/") then
 		local param = "_te4"
 
 		local first = self.url:find("?", 1, 1)
@@ -187,7 +187,7 @@ function _M:onDownload(handlers)
 	local Dialog = require "engine.ui.Dialog"
 
 	handlers.on_download_request = function(downid, url, file, mime)
-		if mime == "application/t-engine-addon" and self.allow_downloads.addons and url:find("^http://te4%.org/") then
+		if mime == "application/t-engine-addon" and self.allow_downloads.addons and (url:find("^http://te4%.org/") or url:find("^https://te4%.org/")) then
 			local path = fs.getRealPath("/addons/")
 			if path then
 				local name = file
@@ -205,7 +205,7 @@ function _M:onDownload(handlers)
 				end)
 				return
 			end
-		elseif mime == "application/t-engine-module" and self.allow_downloads.modules and url:find("^http://te4%.org/") then
+		elseif mime == "application/t-engine-module" and self.allow_downloads.modules and (url:find("^http://te4%.org/") or url:find("^https://te4%.org/")) then
 			local path = fs.getRealPath("/modules/")
 			if path then
 				local name = file
diff --git a/game/engines/default/modules/boot/class/Game.lua b/game/engines/default/modules/boot/class/Game.lua
index 83327aae7c..3d50cdda16 100644
--- a/game/engines/default/modules/boot/class/Game.lua
+++ b/game/engines/default/modules/boot/class/Game.lua
@@ -101,7 +101,7 @@ end
 
 function _M:makeWebtooltip()
 	self.webtooltip = require("engine.ui.WebView").new{width=380, height=500, has_frame=true, never_clean=true, allow_popup=true,
-		url = ("http://te4.org/tooltip-ingame?steam=%d&vM=%d&vm=%d&vp=%d"):format(core.steam and 1 or 0, engine.version[1], engine.version[2], engine.version[3])
+		url = ("https://te4.org/tooltip-ingame?steam=%d&vM=%d&vm=%d&vp=%d"):format(core.steam and 1 or 0, engine.version[1], engine.version[2], engine.version[3])
 	}
 	if self.webtooltip.unusable then
 		self.webtooltip = nil
@@ -153,7 +153,7 @@ function _M:run()
 	if not self.news then
 		self.news = {
 			title = "Welcome to T-Engine and the Tales of Maj'Eyal",
-			text = [[#GOLD#"Tales of Maj'Eyal"#WHITE# is the main game, you can also install more addons or modules by by going to http://te4.org/
+			text = [[#GOLD#"Tales of Maj'Eyal"#WHITE# is the main game, you can also install more addons or modules by by going to https://te4.org/
 
 When inside a module remember you can press Escape to bring up a menu to change keybindings, resolution and other module specific options.
 
@@ -539,7 +539,7 @@ function _M:onQuit()
 	end, "Quit", "Continue")
 end
 
-profile_help_text = [[#LIGHT_GREEN#T-Engine4#LAST# allows you to sync your player profile with the website #LIGHT_BLUE#http://te4.org/#LAST#
+profile_help_text = [[#LIGHT_GREEN#T-Engine4#LAST# allows you to sync your player profile with the website #LIGHT_BLUE#https://te4.org/#LAST#
 
 This allows you to:
 * Play from several computers without having to copy unlocks and achievements.
@@ -548,7 +548,7 @@ This allows you to:
 * Cool statistics for each module to help sharpen your gameplay style
 * Help the game developers balance and refine the game
 
-You will also have a user page on http://te4.org/ where you can show off your achievements to your friends.
+You will also have a user page on https://te4.org/ where you can show off your achievements to your friends.
 This is all optional, you are not forced to use this feature at all, but the developers would thank you if you did as it will make balancing easier.
 Online profile requires an internet connection, if not available it will wait and sync when it finds one.]]
 
@@ -593,7 +593,7 @@ function _M:createProfile(loginItem)
 		end
 	else
 		self.auth_tried = nil
-		local d = Dialog:simpleWaiter("Registering...", "Registering on http://te4.org/, please wait...") core.display.forceRedraw()
+		local d = Dialog:simpleWaiter("Registering...", "Registering on https://te4.org/, please wait...") core.display.forceRedraw()
 		local ok, err = profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email, loginItem.news)
 		profile:waitFirstAuth()
 		d:done()
@@ -601,9 +601,9 @@ function _M:createProfile(loginItem)
 			Dialog:simplePopup(self.justlogin and "Logged in!" or "Profile created!", "Your online profile is now active. Have fun!", function() end )
 		else
 			if err ~= "unknown" and err then
-				Dialog:simplePopup("Profile creation failed!", "Creation failed: "..err.." (you may also register on http://te4.org/)", function() end )
+				Dialog:simplePopup("Profile creation failed!", "Creation failed: "..err.." (you may also register on https://te4.org/)", function() end )
 			else
-				Dialog:simplePopup("Profile creation failed!", "Try again in in a few moments, or try online at http://te4.org/", function() end )
+				Dialog:simplePopup("Profile creation failed!", "Try again in in a few moments, or try online at https://te4.org/", function() end )
 			end
 		end
 	end
diff --git a/game/engines/default/modules/boot/dialogs/Addons.lua b/game/engines/default/modules/boot/dialogs/Addons.lua
index d505295e34..198f6f893e 100644
--- a/game/engines/default/modules/boot/dialogs/Addons.lua
+++ b/game/engines/default/modules/boot/dialogs/Addons.lua
@@ -32,11 +32,11 @@ function _M:init()
 	Dialog.init(self, "Configure Addons", game.w * 0.8, game.h * 0.8)
 
 	local webaddonload = function()
-		local method, d = util.browserOpenUrl("http://te4.org/addons/tome", {steam=true})
+		local method, d = util.browserOpenUrl("https://te4.org/addons/tome", {steam=true})
 		if method == "webview" and d then d.unload = function() self:regen() end end
 	end
 	local webdlcload = function()
-		local method, d = util.browserOpenUrl("http://te4.org/tome/dlc", {steam=true})
+		local method, d = util.browserOpenUrl("https://te4.org/tome/dlc", {steam=true})
 		if method == "webview" and d then d.unload = function() self:regen() end end
 	end
 
diff --git a/game/engines/default/modules/boot/dialogs/LoadGame.lua b/game/engines/default/modules/boot/dialogs/LoadGame.lua
index 870eebe137..d6dbb02c85 100644
--- a/game/engines/default/modules/boot/dialogs/LoadGame.lua
+++ b/game/engines/default/modules/boot/dialogs/LoadGame.lua
@@ -182,11 +182,11 @@ function _M:playSave(ignore_mod_compat)
 		Dialog:yesnoLongPopup("Incompatible savefile", [[Due to huge changes in 1.2.0 all previous savefiles will not work with it.
 This savefile requires a game version lower than 1.2.0 and thus can not be loaded.
 
-But despair not, if you wish to finish it you can simply download the old version corresponding to the savefile on #{italic}##LIGHT_BLUE#http://te4.org/download#WHITE##{normal}#.
+But despair not, if you wish to finish it you can simply download the old version corresponding to the savefile on #{italic}##LIGHT_BLUE#https://te4.org/download#WHITE##{normal}#.
 
 We apologize for the annoyance, most of the time we try to keep compatibility but this once it was simply not possible.]],
 			700, function(ret) if ret then
-				util.browserOpenUrl("http://te4.org/download", {webview=true, steam=true})
+				util.browserOpenUrl("https://te4.org/download", {webview=true, steam=true})
 			end end, "Go to download in your browser", "Cancel"
 		)
 		return
@@ -244,17 +244,17 @@ function _M:installOldGame(version_string)
 	local dls = {}
 	-- Later on we can request the server for a list, but heh
 	if version_string == "tome-1.2.5" then
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.2.5-gfx.team", name="tome-1.2.5-gfx.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.2.5-music.team", name="tome-1.2.5-music.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.2.5.team", name="tome-1.2.5.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.2.5-gfx.team", name="tome-1.2.5-gfx.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.2.5-music.team", name="tome-1.2.5-music.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.2.5.team", name="tome-1.2.5.team"}
 	elseif version_string == "tome-1.3.3" then
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.3.3-gfx.team", name="tome-1.3.3-gfx.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.3.3-music.team", name="tome-1.3.3-music.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.3.3.team", name="tome-1.3.3.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.3.3-gfx.team", name="tome-1.3.3-gfx.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.3.3-music.team", name="tome-1.3.3-music.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.3.3.team", name="tome-1.3.3.team"}
 	elseif version_string == "tome-1.4.9" then
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.4.9-gfx.team", name="tome-1.4.9-gfx.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.4.9-music.team", name="tome-1.4.9-music.team"}
-		dls[#dls+1] = {url="http://te4.org/dl/modules/tome/tome-1.4.9.team", name="tome-1.4.9.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.4.9-gfx.team", name="tome-1.4.9-gfx.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.4.9-music.team", name="tome-1.4.9-music.team"}
+		dls[#dls+1] = {url="https://te4.org/dl/modules/tome/tome-1.4.9.team", name="tome-1.4.9.team"}
 	end
 
 	if #dls == 0 then
diff --git a/game/engines/default/modules/boot/dialogs/MainMenu.lua b/game/engines/default/modules/boot/dialogs/MainMenu.lua
index d58145ac79..e0bda42397 100644
--- a/game/engines/default/modules/boot/dialogs/MainMenu.lua
+++ b/game/engines/default/modules/boot/dialogs/MainMenu.lua
@@ -169,7 +169,7 @@ function _M:uiLoginSteam(uis)
 end
 
 function _M:uiStats(uis)
-	self.logged_url = "http://te4.org/users/"..profile.auth.page
+	self.logged_url = "https://te4.org/users/"..profile.auth.page
 	local str1 = Textzone.new{auto_width=true, auto_height=true, text="#GOLD#Online Profile#WHITE#"}
 	local str2 = Textzone.new{auto_width=true, auto_height=true, text="#LIGHT_BLUE##{underline}#"..self.logged_url.."#LAST##{normal}#", fct=function() util.browserOpenUrl(self.logged_url, {is_external=true}) end}
 
diff --git a/game/engines/default/modules/boot/dialogs/NewGame.lua b/game/engines/default/modules/boot/dialogs/NewGame.lua
index 1471101f01..331e5ec245 100644
--- a/game/engines/default/modules/boot/dialogs/NewGame.lua
+++ b/game/engines/default/modules/boot/dialogs/NewGame.lua
@@ -36,7 +36,7 @@ function _M:init()
 	self.c_switch = Checkbox.new{default=false, width=math.floor(self.iw / 3 - 40), title="Show all versions", on_change=function() self:switch() end}
 	self.c_compat = Checkbox.new{default=false, width=math.floor(self.iw / 3 - 40), title="Show incompatible", on_change=function() self:switch() end}
 
-	local url = Textzone.new{text="You can get new games at\n#LIGHT_BLUE##{underline}#http://te4.org/games#{normal}#", auto_height=true, auto_width=true, fct=function() util.browserOpenUrl("http://te4.org/games") end}
+	local url = Textzone.new{text="You can get new games at\n#LIGHT_BLUE##{underline}#https://te4.org/games#{normal}#", auto_height=true, auto_width=true, fct=function() util.browserOpenUrl("https://te4.org/games") end}
 
 	self:generateList()
 
diff --git a/game/engines/default/modules/boot/dialogs/ProfileSteamRegister.lua b/game/engines/default/modules/boot/dialogs/ProfileSteamRegister.lua
index 6694017dce..b899008b9f 100644
--- a/game/engines/default/modules/boot/dialogs/ProfileSteamRegister.lua
+++ b/game/engines/default/modules/boot/dialogs/ProfileSteamRegister.lua
@@ -75,7 +75,7 @@ function _M:okclick()
 		return
 	end
 
-	local d = self:simpleWaiter("Registering...", "Registering on http://te4.org/, please wait...") core.display.forceRedraw()
+	local d = self:simpleWaiter("Registering...", "Registering on https://te4.org/, please wait...") core.display.forceRedraw()
 	d:timeout(30, function() Dialog:simplePopup("Steam", "Steam client not found.")	end)
 	core.steam.sessionTicket(function(ticket)
 		if not ticket then
diff --git a/game/engines/default/modules/boot/dialogs/UpdateAll.lua b/game/engines/default/modules/boot/dialogs/UpdateAll.lua
index cb55f658a0..abbbebbfa8 100644
--- a/game/engines/default/modules/boot/dialogs/UpdateAll.lua
+++ b/game/engines/default/modules/boot/dialogs/UpdateAll.lua
@@ -128,7 +128,7 @@ function _M:updateAll()
 			local fname = ("/tmp-dl/engines/%s-%d.%d.%d.teae"):format(eversion[4], eversion[1], eversion[2], eversion[3])
 			local f = fs.open(fname, "w")
 
-			local url = ("http://te4.org/dl/engines/%s-%d.%d.%d.teae"):format(eversion[4], eversion[1], eversion[2], eversion[3])
+			local url = ("https://te4.org/dl/engines/%s-%d.%d.%d.teae"):format(eversion[4], eversion[1], eversion[2], eversion[3])
 			local d = DownloadDialog.new(("Downloading engine: %s"):format(next.name), url, function(chunk)
 				f:write(chunk)
 			end, function(di, data)
@@ -141,7 +141,7 @@ function _M:updateAll()
 				local fname = ("/tmp-dl/modules/boot-%s-%d.%d.%d.team"):format(eversion[4], eversion[1], eversion[2], eversion[3])
 				local f = fs.open(fname, "w")
 
-				local url = ("http://te4.org/dl/engines/boot-%s-%d.%d.%d.team"):format(eversion[4], eversion[1], eversion[2], eversion[3])
+				local url = ("https://te4.org/dl/engines/boot-%s-%d.%d.%d.team"):format(eversion[4], eversion[1], eversion[2], eversion[3])
 				local d = DownloadDialog.new(("Downloading engine boot menu: %s"):format(next.name), url, function(chunk)
 					f:write(chunk)
 				end, function(di, data)
diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua
index b9d5622a49..45c61c5df9 100644
--- a/game/modules/tome/dialogs/CharacterSheet.lua
+++ b/game/modules/tome/dialogs/CharacterSheet.lua
@@ -446,7 +446,7 @@ function _M:drawDialog(kind, actor_to_compare)
 	local dur_text = ""
 
 	if player.__te4_uuid and profile.auth and profile.auth.drupid then
-		local path = "http://te4.org/characters/"..profile.auth.drupid.."/tome/"..player.__te4_uuid
+		local path = "https://te4.org/characters/"..profile.auth.drupid.."/tome/"..player.__te4_uuid
 		local LinkTxt = "Online URL: #LIGHT_BLUE##{underline}#"..path.."#{normal}#"
 		local Link_w, Link_h = self.font:size(LinkTxt)
 		h = self.c_desc.h - Link_h
diff --git a/game/modules/tome/dialogs/Donation.lua b/game/modules/tome/dialogs/Donation.lua
index 7c2ab7a40c..37077b07ac 100644
--- a/game/modules/tome/dialogs/Donation.lua
+++ b/game/modules/tome/dialogs/Donation.lua
@@ -88,7 +88,7 @@ function _M:ok()
 
 	if not inside then self:simplePopup("Thank you", "Thank you, a paypal page should now open in your browser.") end
 
-	local url = ("http://te4.org/ingame-donate/%s/%s/%s/EUR/%s"):format(self.c_donate.number, self.c_recur.checked and "monthly" or "onetime", (profile.auth and profile.auth.drupid) and profile.auth.drupid or "0", self.donation_source)
+	local url = ("https://te4.org/ingame-donate/%s/%s/%s/EUR/%s"):format(self.c_donate.number, self.c_recur.checked and "monthly" or "onetime", (profile.auth and profile.auth.drupid) and profile.auth.drupid or "0", self.donation_source)
 
 	if inside then util.browserOpenUrl(url, {is_external=true})
 	else util.browserOpenUrl(url, {webview=true, is_external=true}) end
diff --git a/game/modules/tome/init.lua b/game/modules/tome/init.lua
index 932d00ae26..317b2b473e 100644
--- a/game/modules/tome/init.lua
+++ b/game/modules/tome/init.lua
@@ -21,7 +21,7 @@ name = "T.o.M.E"
 long_name = "Tales of Maj'Eyal: Age of Ascendancy"
 short_name = "tome"
 author = { "DarkGod", "darkgod@te4.org" }
-homepage = "http://te4.org/"
+homepage = "https://te4.org/"
 version = {1,5,1}
 engine = {1,5,1,"te4"}
 description = [[
-- 
GitLab