View | Details | Raw Unified | Return to bug 225722 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 37-43 Link Here
37
37
38
USE_GITHUB=	yes
38
USE_GITHUB=	yes
39
GH_ACCOUNT=	pioneerspacesim
39
GH_ACCOUNT=	pioneerspacesim
40
GH_TAGNAME=	20171001
40
GH_TAGNAME=	20180203
41
41
42
USE_GL=		gl
42
USE_GL=		gl
43
USE_SDL=	image2 sdl2
43
USE_SDL=	image2 sdl2
(-)distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1506816107
1
TIMESTAMP = 1517474724
2
SHA256 (pioneerspacesim-pioneer-0.0.20171001-20171001_GH0.tar.gz) = 154118bd3dac2f9b8ea43a837bcb967abcc8c3a8ee5ab61d35183bae85e8b0db
2
SHA256 (pioneerspacesim-pioneer-0.0.20180203-20180203_GH0.tar.gz) = 19aa89e8ec0221b937b9279e0d4897b3016e0ce80858d03600d3e80cd7daa907
3
SIZE (pioneerspacesim-pioneer-0.0.20171001-20171001_GH0.tar.gz) = 210900753
3
SIZE (pioneerspacesim-pioneer-0.0.20180203-20180203_GH0.tar.gz) = 212872392
(-)files/patch-data_modules_SearchRescue_SearchRescue.lua (-83 lines)
Lines 1-83 Link Here
1
Fix SAR selection of ship sizes for missions
2
https://github.com/pioneerspacesim/pioneer/commit/008e30a857036a8cc40c42bf89ef68e65b47a41e
3
4
--- data/modules/SearchRescue/SearchRescue.lua.orig	2017-10-01 00:01:47 UTC
5
+++ data/modules/SearchRescue/SearchRescue.lua
6
@@ -613,7 +613,20 @@ local createTargetShipParameters = funct
7
 	---- loading drive, weapons etc.
8
 	if flavour.id == 1 or flavour.id == 6 then
9
 		for i,shipdef in pairs(shipdefs) do
10
-			if shipdef.capacity / 10 < 1 then shipdefs[i] = nil end
11
+
12
+			-- get mass of hyperdrive if this ship has a default drive
13
+			-- if no default drive assume lowest mass drive
14
+			-- higher mass drives will only be fitted later at ship creation if capacity is huge
15
+			local drive = Equipment.hyperspace['hyperdrive_'..tostring(shipdef.hyperdriveClass)]
16
+			if not drive then
17
+				local drives = {}
18
+				for i = 9, 1, -1 do
19
+					table.insert(drives, Equipment.hyperspace['hyperdrive_'..tostring(i)])
20
+				end
21
+				table.sort(drives, function (a,b) return a.capabilities.mass < b.capabilities.mass end)
22
+				drive = drives[1]
23
+			end
24
+			if (shipdef.capacity-drive.capabilities.mass) / 10 < 1 then shipdefs[i] = nil end
25
 		end
26
 	elseif flavour.pickup_pass > 0 then
27
 		for i,shipdef in pairs(shipdefs) do
28
@@ -661,7 +674,16 @@ local createTargetShipParameters = funct
29
 	if flavour.id == 1 or flavour.id == 6 then
30
 		local any_pass = rand:Integer(0,1)
31
 		if any_pass > 0 then
32
-			pickup_pass = rand:Integer(1, math.min((shipdef.capacity / 10)+1, max_pass))
33
+			local drive = Equipment.hyperspace['hyperdrive_'..tostring(shipdef.hyperdriveClass)]
34
+			if not drive then
35
+				local drives = {}
36
+				for i = 9, 1, -1 do
37
+					table.insert(drives, Equipment.hyperspace['hyperdrive_'..tostring(i)])
38
+				end
39
+				table.sort(drives, function (a,b) return a.capabilities.mass < b.capabilities.mass end)
40
+				drive = drives[1]
41
+			end
42
+			pickup_pass = rand:Integer(1, math.min(((shipdef.capacity-drive.capabilities.mass) / 10)+1, max_pass))
43
 		else
44
 			pickup_pass = 0
45
 		end
46
@@ -709,22 +731,25 @@ local createTargetShip = function (missi
47
 	ship:SetPattern(pattern)
48
 
49
 	-- load a hyperdrive
50
-	local default_drive = Equipment.hyperspace['hyperdrive_'..tostring(shipdef.hyperdriveClass)]
51
-	if default_drive then
52
-		ship:AddEquip(default_drive)
53
-	else
54
-		local drive
55
+	-- 1st try: default drive for this ship class
56
+	-- 2nd try: largest drive possible that doesn't take more than a 10th of available room
57
+	-- fallback: smallest drive
58
+	local drives = {}
59
+	local drive = Equipment.hyperspace['hyperdrive_'..tostring(shipdef.hyperdriveClass)]
60
+	if not drive then
61
 		for i = 9, 1, -1 do
62
-			drive = Equipment.hyperspace['hyperdrive_'..tostring(i)]
63
-			if shipdef.capacity / 10 > drive.capabilities.mass then
64
-				ship:AddEquip(drive)
65
-				break
66
-			end
67
+			table.insert(drives, Equipment.hyperspace['hyperdrive_'..tostring(i)])
68
 		end
69
-		if not drive then
70
-			ship:AddEquip(Equipment.hyperspace['hyperdrive_1'])
71
+		table.sort(drives, function (a,b) return a.capabilities.mass < b.capabilities.mass end)
72
+		for i = #drives, 1, -1 do
73
+			local test_drive = drives[i]
74
+			if shipdef.capacity / 10 > test_drive.capabilities.mass then
75
+				drive = test_drive
76
+			end
77
 		end
78
 	end
79
+	if not drive then drive = drives[1] end
80
+	ship:AddEquip(drive)
81
 
82
 	-- add thruster fuel
83
 	if mission.flavour.id == 2 or mission.flavour.id == 4 or mission.flavour.id == 5 then

Return to bug 225722