Skip to content

Commit b85ee6a

Browse files
committed
+Fixed bug in globals.lua where DoFile was called with full path.
+made the patch compatible with vanilla base BF2 game for debugging purposes.
1 parent 19161ea commit b85ee6a

File tree

7 files changed

+101
-52
lines changed

7 files changed

+101
-52
lines changed

0/Apply_patch.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
:: At some point we could possibly do an automatic copy from the user's _lvl_common\common.lvl
33
:: but for now, let's keep it simple. (if doing teh copy we'd want to check if it had already been patched, maybe)
4+
@echo off
45

56
if not exist "base_common.lvl_goes_in_here\common.lvl" (
67
echo Error: file does not exist, place your common.lvl file into the 'base_common.lvl_goes_in_here' folder
8+
pause
79
exit /b
810
)
911

src/scripts/addme.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function uop_AddEra(entry)
197197
end
198198
---------------------------------------------------
199199
table.insert( gMapEras, entry )
200-
print("uop_AddEra(): added Era: ")
200+
print("uop_AddEra(): added Era: " .. tostring(entry.key))
201201
else
202202
print("uop_AddEra: Error adding Era. Must specify properties [key, showstr, subst, Team1Name, Team2Name ]\n" ..
203203
"See 'gMapEras' (missionlist.lua) to see format of existing eras.")
@@ -217,7 +217,7 @@ function uop_AddGameMode(entry)
217217
end
218218
---------------------------------------------------
219219
table.insert( gMapModes, entry )
220-
print("uop_AddGameMode(): added Era: ")
220+
print("uop_AddGameMode(): added Era: " .. tostring(entry.key))
221221
else
222222
print("uop_AddGameMode: Error adding Game mode. Must specify [key, showstr, descstr, subst]\n" ..
223223
"See 'gMapModes' to see format of existing Game mode entries.")

src/scripts/globals.lua

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,19 @@ RumbleLarge = {
322322
FXName = "Doesn'tWorkYet", --the particle effect that gets triggered, is read in, but not used yet.
323323

324324
}
325-
print("Apply_Classic_Collection_Patch_To_Common.lvl")
325+
326+
local addon_path = "..\\..\\addon\\"
327+
if(ScriptCB_IsFileExist("side\\all2.lvl") == 1) then
328+
print("globals: This Collection is truly the classic one")
329+
addon_path = "..\\..\\addon2\\"
330+
else
331+
print("globals: This is not classic ")
332+
end
333+
334+
326335
-- Enter patch stuff!
327-
local target = "..\\..\\addon2\\0\\patch_scripts\\patch_paths.script"
328-
if ScriptCB_IsFileExist(target) == 1 then
336+
local target = addon_path .. "0\\patch_scripts\\patch_paths.script"
337+
if (ScriptCB_IsFileExist(target) == 1 and addon_path == "..\\..\\addon2\\" ) then
329338
ReadDataFile(target)
330339
ScriptCB_DoFile("patch_paths")
331340
-- are we ingame? if so do some more stuff
@@ -335,16 +344,16 @@ end
335344
-- for the respective lua env
336345
if ( SetupTeams ~= nil ) then -- this will exist at mission script execution/ingame time
337346
-- this should run during game_interface execution
338-
local target = "..\\..\\addon2\\0\\patch_scripts\\patch_ingame.script"
347+
local target = addon_path .. "0\\patch_scripts\\patch_ingame.script"
339348
if(ScriptCB_IsFileExist(target) == 1 ) then
340349
ReadDataFile(target)
341-
ScriptCB_DoFile(target)
350+
ScriptCB_DoFile("patch_ingame")
342351
end
343352
else
344353
-- running at shell time
345-
local target = "..\\..\\addon2\\0\\patch_scripts\\patch_shell.script"
354+
local target = addon_path .. "0\\patch_scripts\\patch_shell.script"
346355
if(ScriptCB_IsFileExist(target) == 1 ) then
347356
ReadDataFile(target)
348-
ScriptCB_DoFile(target)
357+
ScriptCB_DoFile("patch_shell")
349358
end
350359
end

src/scripts/ifs_mod_menu_launcher.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ if(gPlatformStr == "PC" and ScriptCB_CheckProfanity == nil ) then -- only Aspyr
276276
end
277277
--- use 'ifs_sp_campaign' instead of 'ifs_sp' if targeting the non-BFCC PC versions
278278
----- Redefine the accept handler for 'ifs_sp'----
279-
print("Plumb in the Console instant action screen (hijack 'spacetraining' button )")
279+
print("Plumb in the mod menu launcher (hijack 'spacetraining' button )")
280280
-- take over the 'spacetraining' button
281281
IFText_fnSetString(target_screen.buttons.spacetraining.label, "Mod Menu Launcher") -- set new text on spacetraining button
282282

src/scripts/patch_ingame.lua

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1+
2+
-- first things game_interface does:
3+
-- gPlatformStr = ScriptCB_GetPlatform()
4+
-- gOnlineServiceStr = ScriptCB_GetConnectType()
5+
-- gLangStr,gLangEnum = ScriptCB_GetLanguage()
6+
-- ScriptCB_DoFile("globals") -- our 'patch' is called from here
7+
8+
-- last thing game_interface does: ScriptCB_DoFile("ifs_mpgs_friends")
9+
10+
print("Patch ingame start")
11+
12+
-- this will get the Fake console & Free Cam buttons to show
13+
gFinalBuild = false
14+
15+
print("gFinalBuild: " .. tostring(gFinalBuild))
16+
117
function RunUserScripts()
218
local maxScripts = 100
319
local i = nil
4-
20+
local patchDir = "..\\..\\addon\\0\\"
21+
print("RunUserScripts() Start")
522
for i = 0, maxScripts, 1 do
623

7-
if ScriptCB_IsFileExist(patchDir .. "user_script_" .. i .. ".lvl") == 0 then
8-
print("game_interface: No user_script_" .. i .. ".lvl")
9-
else
24+
if ScriptCB_IsFileExist(patchDir .. "user_script_" .. i .. ".lvl") ~= 0 then
1025
print("game_interface: Found user_script_" .. i .. ".lvl")
1126

1227
ReadDataFile(patchDir .. "user_script_" .. i .. ".lvl")
1328
ScriptCB_DoFile("user_script_" .. i)
1429
end
1530

1631
end
32+
print("RunUserScripts() End")
1733
end
1834
RunUserScripts()
1935

36+
ingame_messages = {}
37+
function AddIngameMessage(str)
38+
table.insert( ingame_messages, str)
39+
end
40+
41+
local old_print = print
42+
print = function(...)
43+
AddIngameMessage(arg[1])
44+
return old_print(unpack(arg))
45+
end
46+
47+
2048
--[[
2149
for patching ifs_ menu screens, we'll want to 'Catch' when they are passed to 'AddIfScreen'.
2250
We can manipulate/adjust the screen structure at that time. Adding buttons, adjusting location...
@@ -25,4 +53,11 @@ RunUserScripts()
2553
2654
For replacing a screen we can override 'ScriptCB_PushScreen' and/or 'ScriptCB_SetIFScreen'.
2755
'ScriptCB_SetIFScreen' is used infrequently though.
28-
]]
56+
]]
57+
--local old_AddIFScreen = AddIFScreen
58+
--AddIFScreen = function(...)
59+
-- print("AddIFScreen: " .. arg[2])
60+
-- if( arg[1] == "target+screen") then
61+
-- end
62+
-- return old_AddIFScreen(unpack(arg))
63+
--end

src/scripts/patch_paths.lua

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,52 +46,54 @@ end
4646

4747
----------------------------------------------------------------------------------------
4848

49-
-- patch paths
50-
if ReadDataFile then
51-
ReadDataFile = replaceAddonPath(ReadDataFile)
52-
ReadDataFile = replaceAllLVL(ReadDataFile)
53-
end
54-
55-
if ReadDataFileInGame then
56-
ReadDataFileInGame = replaceAddonPath(ReadDataFileInGame)
57-
ReadDataFileInGame = replaceAllLVL(ReadDataFileInGame)
58-
end
49+
if(ScriptCB_IsFileExist("side\\all2.lvl") == 1) then
50+
print("This is BF Classic Collection; patching file paths")
51+
-- patch paths
52+
if ReadDataFile then
53+
ReadDataFile = replaceAddonPath(ReadDataFile)
54+
ReadDataFile = replaceAllLVL(ReadDataFile)
55+
end
5956

60-
if ScriptCB_IsFileExist then
61-
ScriptCB_IsFileExist = replaceAddonPath(ScriptCB_IsFileExist)
62-
end
57+
if ReadDataFileInGame then
58+
ReadDataFileInGame = replaceAddonPath(ReadDataFileInGame)
59+
ReadDataFileInGame = replaceAllLVL(ReadDataFileInGame)
60+
end
6361

64-
-- not needed, ScriptCB_DoFile 'does' a file that has already been read into memory.
65-
--if ScriptCB_DoFile then
66-
-- ScriptCB_DoFile = replaceAddonPath(ScriptCB_DoFile)
67-
--end
62+
if ScriptCB_IsFileExist then
63+
ScriptCB_IsFileExist = replaceAddonPath(ScriptCB_IsFileExist)
64+
end
6865

69-
if PlayAudioStream then
70-
PlayAudioStream = replaceAddonPath(PlayAudioStream)
71-
end
66+
-- not needed, ScriptCB_DoFile 'does' a file that has already been read into memory.
67+
--if ScriptCB_DoFile then
68+
-- ScriptCB_DoFile = replaceAddonPath(ScriptCB_DoFile)
69+
--end
7270

73-
-- I do not know who came up with the idea to make this a whole other function, but screw you
74-
if PlayAudioStreamUsingProperties then
75-
PlayAudioStreamUsingProperties = replaceAddonPath(PlayAudioStreamUsingProperties)
76-
end
71+
if PlayAudioStream then
72+
PlayAudioStream = replaceAddonPath(PlayAudioStream)
73+
end
7774

78-
if OpenAudioStream then
79-
OpenAudioStream = replaceAddonPath(OpenAudioStream)
80-
end
75+
-- I do not know who came up with the idea to make this a whole other function, but screw you
76+
if PlayAudioStreamUsingProperties then
77+
PlayAudioStreamUsingProperties = replaceAddonPath(PlayAudioStreamUsingProperties)
78+
end
8179

82-
if AudioStreamAppendSegments then
83-
AudioStreamAppendSegments = replaceAddonPath(AudioStreamAppendSegments)
84-
end
80+
if OpenAudioStream then
81+
OpenAudioStream = replaceAddonPath(OpenAudioStream)
82+
end
8583

86-
if SetMissionEndMovie then
87-
SetMissionEndMovie = replaceAddonPath(SetMissionEndMovie)
88-
end
84+
if AudioStreamAppendSegments then
85+
AudioStreamAppendSegments = replaceAddonPath(AudioStreamAppendSegments)
86+
end
8987

90-
if CreateEffect then
91-
CreateEffect = replaceAddonPath(CreateEffect)
92-
end
88+
if SetMissionEndMovie then
89+
SetMissionEndMovie = replaceAddonPath(SetMissionEndMovie)
90+
end
9391

92+
if CreateEffect then
93+
CreateEffect = replaceAddonPath(CreateEffect)
94+
end
9495

96+
end
9597

9698
-- This does not work. Find a better solution asap.
9799
--[[ load core again for custom localization

src/scripts/patch_shell.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
print("nothing yet")
1+
print("patch_shell start")
22

33

44
--[[
@@ -12,3 +12,4 @@ print("nothing yet")
1212
'ScriptCB_SetIFScreen' is used infrequently though.
1313
(Prefer to do this in the '0' addme though)
1414
]]
15+
print("patch_shell end")

0 commit comments

Comments
 (0)