LUA versions for SWBF1/2?

Talk and share anything related to Star Wars Battlefront 2. No maps or mod announcements here. Use Work in Progress forum.

Moderator: Moderators

Post Reply
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

LUA versions for SWBF1/2?

Post by Teancum »

Does anyone (particularly Zerted) know the exact version of LUA that SWBF1 or SWBF2 (particularly SWBF2) uses? I know that the LUA system has decompilers, and I think it's just a matter of extracting raw files and then reinserting a proper header, then decompiling, but I'm not sure on the versions. I think I read somewhere that SWBF2 uses 5.0, but I'm fuzzy on that.

*EDIT*

Why oh why did we have forum pruning on in this section? That PSP/PS2/Xbox mod thread is gone, and I really needed some files someone posted to test out LUA decompiling (the PSP scripts for Rebel Raider). There's a luadec.exe (LUA decompiler) demonstration video below. It's not for the faint of heart, but it seems to work.

http://www.youtube.com/watch?v=Qz4LDs18-nY
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: LUA versions for SWBF1/2?

Post by Frisbeetarian »

Teancum wrote:There's a luadec.exe (LUA decompiler) demonstration video below. It's not for the faint of heart, but it seems to work.
But what is it decompiling from, compiled source from luac.exe? It would be of great use if it could decompile from .lvl files, but I don't think that compiled Lua code is just sitting around in .lvl files.

http://www.gametoast.com/forums/viewtop ... =27&t=2572
This talks about which version each game uses, but the first post is gone, so I'm not sure why it's still in the FAQ.

EDIT:
I tried to work a simple file (LinkedTurrets) through THIS which is basically just LuaDec51 with some batch scripts to help end users (it's more than that, but that's not important). I extracted the compiled scripts from mission.lvl with the LVL Extractor, but the output .lub file didn't work through luadec.exe. To make sure, I took the original LinkedTurrets.lua, compiled it, then decompiled it and it worked out fine, so it's not the process I used that was wrong. I also tested the compiled LinkedTurrets.lua to the .lub file that was output from the extractor and while there were similarities, it was not a match.

I'm not saying that LuaDec51 does not work, I'm suggesting that it might not, but that instead this decompiling kitchen doesn't work. There is another luadec.exe for 5.0, but this was the easiest to use, so I tried it first hoping for some back compatibility.

EDIT2:
Looking more into that video, I think I found the source: HERE. The .lub file from that thread has a striking resemblance to the .lub files from the extractor, so it looks like money... if we can get it to work.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA versions for SWBF1/2?

Post by [RDH]Zerted »

Teancum wrote:I think I read somewhere that SWBF2 uses 5.0, but I'm fuzzy on that.
The topic you linked to says that in its title. If you run luac.exe from the mod tools, it says its v5.0.2. You need to use the v5.0.2 decompiler (LuaDec)

The problem noted so long ago (it might have been said on extract's site instead of GT, I don't remember), was that the number size for swbf2's lua is 4 while the decompiler expected 8 (the decompiler's error message clearly says this). I tried to make the changes a few years ago, but I didn't have the build tools to recompile the decompiler. Now I'm on linux and I do.

I messed with decompiler's config file for a few minutes, then found a different tool that works better. The other tool reconstructs the code, but keeps it coupled with the Lua VM instructions. In theory decompiling with the tool, recompiling with number size 8, and decompiling the result with LuaDec will give us most of the source code back and without the VM instructions. I'm saying most because both tools say they have a few bugs in them. Hopefully, none of the scripts have the complex, unsupported operations. v1.3's code might :(

I'll mess around with it a little more. If I get it working, I'll post a short tutorial. I've got bunches of stuff to do and don't have time to make any more video tutorials.

Edit:
We can use extract to pull the compiled Lua out of lvl files
We can use ChunkSpy to generate a more readable version of the lub files.
We can use ChunkSpy to recompile the lubs into slightly different profiles (such as to fix the 4->8 number issue).
LuaDec fails with the 4->8 number issue on lub files from extract.
LuaDec fails with unknown number format on 4->8 rewritten/fixed ChunkSpy recompiled files.
For ChunkSpy to fix the 4->8 issue, one has use the command line option: --rewrite "swbf2" after adding the following code at line 135 in ChunkSpy.lua:
Hidden/Spoiler:
[code] ["swbf2"] = {
description = "Zerted's attempt at getting extract's lub files working with LuaDec",
endianness = 0,
size_int = 4,
size_size_t = 4,
size_Instruction = 4,
size_lua_Number = 8,
SIZE_OP = 6, SIZE_A = 8, SIZE_B = 9, SIZE_C = 9,
number_type = "int",
MAX_STACK = 250,
},[/code]
SetupTeams.lua extracted from mission.lvl using extract and processed with ChunkSpy:
Hidden/Spoiler:
[code]Pos Hex Data Description or Code
------------------------------------------------------------------------
0000 ** source chunk: ../../extract/scr_setup_teams.lub
** global header start **
0000 1B4C7561 header signature: "\27Lua"
0004 50 version (major:minor hex digits)
0005 01 endianness (1=little endian)
0006 04 size of int (bytes)
0007 04 size of size_t (bytes)
0008 04 size of Instruction (bytes)
0009 06 size of OP (bits)
000A 08 size of A (bits)
000B 09 size of B (bits)
000C 09 size of C (bits)
000D 04 size of number (bytes)
000E 3BAFEF4B sample number (single)
* chunk platform unrecognized
** global header end **

0012 ** function [0] definition (level 1)
** start of function **
0012 08000000 string size (8)
0016 3D286E6F6E652900 "=(none)"
source name: =(none)
001E 00000000 line defined (0)
0022 00 nups (0)
0023 00 numparams (0)
0024 00 is_vararg (0)
0025 02 maxstacksize (2)
* lines:
0026 00000000 sizelineinfo (0)
[pc] (line)
* locals:
002A 00000000 sizelocvars (0)
* upvalues:
002E 00000000 sizeupvalues (0)
* constants:
0032 01000000 sizek (1)
0036 04 const type 4
0037 0B000000 string size (11)
003B 5365747570546561+ "SetupTea"
0043 6D7300 "ms\0"
const [0]: "SetupTeams"
* functions:
0046 01000000 sizep (1)

004A ** function [0] definition (level 2)
** start of function **
004A 00000000 string size (0)
source name: (none)
004E 01000000 line defined (1)
0052 00 nups (0)
0053 01 numparams (1)
0054 00 is_vararg (0)
0055 12 maxstacksize (18)
* lines:
0056 00000000 sizelineinfo (0)
[pc] (line)
* locals:
005A 00000000 sizelocvars (0)
* upvalues:
005E 00000000 sizeupvalues (0)
* constants:
0062 1E000000 sizek (30)
0066 04 const type 4
0067 08000000 string size (8)
006B 736F6C6469657200 "soldier"
const [0]: "soldier"
0073 04 const type 4
0074 06000000 string size (6)
0078 70696C6F7400 "pilot"
const [1]: "pilot"
007E 04 const type 4
007F 08000000 string size (8)
0083 61737361756C7400 "assault"
const [2]: "assault"
008B 04 const type 4
008C 07000000 string size (7)
0090 736E6970657200 "sniper"
const [3]: "sniper"
0097 04 const type 4
0098 07000000 string size (7)
009C 6D6172696E6500 "marine"
const [4]: "marine"
00A3 04 const type 4
00A4 09000000 string size (9)
00A8 656E67696E656572+ "engineer"
00B0 00 "\0"
const [5]: "engineer"
00B1 04 const type 4
00B2 08000000 string size (8)
00B6 6F66666963657200 "officer"
const [6]: "officer"
00BE 04 const type 4
00BF 08000000 string size (8)
00C3 7370656369616C00 "special"
const [7]: "special"
00CB 04 const type 4
00CC 1D000000 string size (29)
00D0 5363726970744342+ "ScriptCB"
00D8 5F49734D69737369+ "_IsMissi"
00E0 6F6E536574757053+ "onSetupS"
00E8 6176656400 "aved\0"
const [8]: "ScriptCB_IsMissionSetupSaved"
00ED 04 const type 4
00EE 1A000000 string size (26)
00F2 5363726970744342+ "ScriptCB"
00FA 5F4C6F61644D6973+ "_LoadMis"
0102 73696F6E53657475+ "sionSetu"
010A 7000 "p\0"
const [9]: "ScriptCB_LoadMissionSetup"
010C 04 const type 4
010D 06000000 string size (6)
0111 756E69747300 "units"
const [10]: "units"
0117 04 const type 4
0118 06000000 string size (6)
011C 706169727300 "pairs"
const [11]: "pairs"
0122 04 const type 4
0123 05000000 string size (5)
0127 7465616D00 "team"
const [12]: "team"
012C 04 const type 4
012D 07000000 string size (7)
0131 737472696E6700 "string"
const [13]: "string"
0138 04 const type 4
0139 06000000 string size (6)
013D 6C6F77657200 "lower"
const [14]: "lower"
0143 04 const type 4
0144 0C000000 string size (12)
0148 5365745465616D4E+ "SetTeamN"
0150 616D6500 "ame\0"
const [15]: "SetTeamName"
0154 04 const type 4
0155 0C000000 string size (12)
0159 5365745465616D49+ "SetTeamI"
0161 636F6E00 "con\0"
const [16]: "SetTeamIcon"
0165 04 const type 4
0166 06000000 string size (6)
016A 5F69636F6E00 "_icon"
const [17]: "_icon"
0170 04 const type 4
0171 17000000 string size (23)
0175 6875645F7265696E+ "hud_rein"
017D 666F7263656D656E+ "forcemen"
0185 745F69636F6E00 "t_icon\0"
const [18]: "hud_reinforcement_icon"
018C 04 const type 4
018D 0A000000 string size (10)
0191 666C61675F69636F+ "flag_ico"
0199 6E00 "n\0"
const [19]: "flag_icon"
019B 04 const type 4
019C 0D000000 string size (13)
01A0 536574556E697443+ "SetUnitC"
01A8 6F756E7400 "ount\0"
const [20]: "SetUnitCount"
01AD 04 const type 4
01AE 16000000 string size (22)
01B2 5365745265696E66+ "SetReinf"
01BA 6F7263656D656E74+ "orcement"
01C2 436F756E7400 "Count\0"
const [21]: "SetReinforcementCount"
01C8 04 const type 4
01C9 0F000000 string size (15)
01CD 7265696E666F7263+ "reinforc"
01D5 656D656E747300 "ements\0"
const [22]: "reinforcements"
01DC 04 const type 4
01DD 07000000 string size (7)
01E1 69706169727300 "ipairs"
const [23]: "ipairs"
01E8 04 const type 4
01E9 0D000000 string size (13)
01ED 416464556E697443+ "AddUnitC"
01F5 6C61737300 "lass\0"
const [24]: "AddUnitClass"
01FA 03 const type 3
01FB 0000803F const [25]: (1)
01FF 03 const type 3
0200 00000040 const [26]: (2)
0204 03 const type 3
0205 00004040 const [27]: (3)
0209 04 const type 4
020A 05000000 string size (5)
020E 6865726F00 "hero"
const [28]: "hero"
0213 04 const type 4
0214 0D000000 string size (13)
0218 4164644865726F43+ "AddHeroC"
0220 6C61737300 "lass\0"
const [29]: "AddHeroClass"
* functions:
0225 00000000 sizep (0)
* code:
0229 55000000 sizecode (85)
022D 0A000601 [01] newtable 1 12 0 ; array=8, hash=0
0231 01000002 [02] loadk 2 0 ; "soldier"
0235 41000003 [03] loadk 3 1 ; "pilot"
0239 81000004 [04] loadk 4 2 ; "assault"
023D C1000005 [05] loadk 5 3 ; "sniper"
0241 01010006 [06] loadk 6 4 ; "marine"
0245 41010007 [07] loadk 7 5 ; "engineer"
0249 81010008 [08] loadk 8 6 ; "officer"
024D C1010009 [09] loadk 9 7 ; "special"
0251 DF010001 [10] setlist 1 7 ; index 1 to 8
0255 03000102 [11] loadnil 2 2
0259 05020003 [12] getglobal 3 8 ; ScriptCB_IsMissionSetupSaved
025D 99800003 [13] call 3 1 2
0261 18800103 [14] test 3 3 0 ; to [16] if true
0265 94008000 [15] jmp 3 ; to [19]
0269 45020003 [16] getglobal 3 9 ; ScriptCB_LoadMissionSetup
026D 99800003 [17] call 3 1 2
0271 86A20102 [18] gettable 2 3 138
0275 C5020003 [19] getglobal 3 11 ; pairs
0279 00000004 [20] move 4 0
027D 59010103 [21] call 3 2 5
0281 DE0E8003 [22] tforprep 3 60 ; to [83]
0285 06230307 [23] gettable 7 6 140
0289 45030008 [24] getglobal 8 13 ; string
028D 86230408 [25] gettable 8 8 142
0291 00800209 [26] move 9 5
0295 99000108 [27] call 8 2 2
0299 C5030009 [28] getglobal 9 15 ; SetTeamName
029D 0080030A [29] move 10 7
02A1 0000040B [30] move 11 8
02A5 59800109 [31] call 9 3 1
02A9 05040009 [32] getglobal 9 16 ; SetTeamIcon
02AD 0080030A [33] move 10 7
02B1 0000040B [34] move 11 8
02B5 4104000C [35] loadk 12 17 ; "_icon"
02B9 1383050B [36] concat 11 11 12
02BD 8104000C [37] loadk 12 18 ; "hud_reinforcement_icon"
02C1 C104000D [38] loadk 13 19 ; "flag_icon"
02C5 59800209 [39] call 9 5 1
02C9 05050009 [40] getglobal 9 20 ; SetUnitCount
02CD 0080030A [41] move 10 7
02D1 8622030B [42] gettable 11 6 138
02D5 59800109 [43] call 9 3 1
02D9 45050009 [44] getglobal 9 21 ; SetReinforcementCount
02DD 0080030A [45] move 10 7
02E1 8625030B [46] gettable 11 6 150
02E5 59800109 [47] call 9 3 1
02E9 C5050009 [48] getglobal 9 23 ; ipairs
02ED 0080000A [49] move 10 1
02F1 59010109 [50] call 9 2 5
02F5 1E058009 [51] tforprep 9 21 ; to [73]
02F9 0603030D [52] gettable 13 6 12
02FD 1880060D [53] test 13 13 0 ; to [55] if true
0301 54048000 [54] jmp 18 ; to [73]
0305 18000102 [55] test 2 2 0 ; to [57] if true
0309 94018000 [56] jmp 7 ; to [64]
030D 0602010D [57] gettable 13 2 8
0311 1880060D [58] test 13 13 0 ; to [60] if true
0315 D4008000 [59] jmp 4 ; to [64]
0319 0602010D [60] gettable 13 2 8
031D 0683060D [61] gettable 13 13 12
0321 1880060D [62] test 13 13 0 ; to [64] if true
0325 14028000 [63] jmp 9 ; to [73]
0329 0506000D [64] getglobal 13 24 ; AddUnitClass
032D 0080030E [65] move 14 7
0331 0603030F [66] gettable 15 6 12
0335 46A6070F [67] gettable 15 15 153
0339 06030310 [68] gettable 16 6 12
033D 86260810 [69] gettable 16 16 154
0341 06030311 [70] gettable 17 6 12
0345 C6A60811 [71] gettable 17 17 155
0349 5980020D [72] call 13 5 1
034D 5D000009 [73] tforloop 9 1 ; to [75] if exit
0351 14FA7F00 [74] jmp -23 ; to [52]
0355 05070009 [75] getglobal 9 28 ; hero
0359 46020309 [76] gettable 9 6 9
035D 18800409 [77] test 9 9 0 ; to [79] if true
0361 D4008000 [78] jmp 4 ; to [83]
0365 45070009 [79] getglobal 9 29 ; AddHeroClass
0369 0507000A [80] getglobal 10 28 ; hero
036D 8602030A [81] gettable 10 6 10
0371 59000109 [82] call 9 2 1
0375 5D000003 [83] tforloop 3 1 ; to [85] if exit
0379 54F07F00 [84] jmp -62 ; to [23]
037D 1B800000 [85] return 0 1
** end of function **

* code:
0381 03000000 sizecode (3)
0385 22000000 [1] closure 0 0 ; 0 upvalues
0389 07000000 [2] setglobal 0 0 ; SetupTeams
038D 1B800000 [3] return 0 1
** end of function **

0391 ** end of chunk **[/code]
I can slowly read that, but I'm not sure whats worth trying to recreate the lua for. Other then the v1.3 code, what do we need to extract? Err, I guess the PSP stuff Teancum wants. Anything on the PC side?
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: LUA versions for SWBF1/2?

Post by Frisbeetarian »

Mav's "The Big L" Lua script was also lost.
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: LUA versions for SWBF1/2?

Post by Teancum »

It's almost not worth it for that effort. Too bad the video doesn't shed more light on the situation.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: LUA versions for SWBF1/2?

Post by Maveritchell »

There are a few scripts of mine that I'd like to get my hands on that I could not otherwise. If there's not a way to easily parse the output from this into SWBF2 script luacode, I won't press too hard to see it done, though.
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: LUA versions for SWBF1/2?

Post by Frisbeetarian »

Teancum wrote:Too bad the video doesn't shed more light on the situation.
The video sheds plenty of light. It more or less tells us exactly what this guy did to decompile his Worms3D files.

I'm not saying that it's easy (the guy who did this even says that it's "very very very hard"), but I am saying that it seems like they have the same type of problems we have, thus their solution may work. I just need to figure out from where to get that Lua50to51.exe (he says that it's used "for replace Single value to Double value").
AlexBond
Posts: 1
Joined: Sat Jul 11, 2009 9:16 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Belarus
Contact:

Re: LUA versions for SWBF1/2?

Post by AlexBond »

:lol: It my Video, I making this for show how hard decompile Lub to Lua...
Full video http://rapidshare.com/files/139045930/L ... w.rar.html

About program Lua50to51.exe it my program I writed it long time ago when i have not source of Scripts lua...

You want Lua50to51.exe? Ok I put it here 8)
Download Lua50to51.rar
But you should replace only Float values... Now I not need this program, I get original lua scripts from PS2 version.

P.S. Sorry for bad English :mrgreen:

AlexBond.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA versions for SWBF1/2?

Post by [RDH]Zerted »

That didn't really help me, but thanks for posting the file. Frisbeetarian's going at this from a slightly different approach than me. He might have more success with it.

I did discover using the --brief argument with ChunkSpy provides a much more readable output. Heres a sample below:
Hidden/Spoiler:
[code]; source chunk: ../scr_setup_teams.lub
; chunk platform unrecognized

; function [0] definition (level 1)
; 0 upvalues, 0 params, 2 stacks
.function 0 0 0 2
.const "SetupTeams" ; 0

; function [0] definition (level 2)
; 0 upvalues, 1 params, 18 stacks
.function 0 1 0 18
.const "soldier" ; 0
.const "pilot" ; 1
.const "assault" ; 2
.const "sniper" ; 3
.const "marine" ; 4
.const "engineer" ; 5
.const "officer" ; 6
.const "special" ; 7
.const "ScriptCB_IsMissionSetupSaved" ; 8
.const "ScriptCB_LoadMissionSetup" ; 9
.const "units" ; 10
.const "pairs" ; 11
.const "team" ; 12
.const "string" ; 13
.const "lower" ; 14
.const "SetTeamName" ; 15
.const "SetTeamIcon" ; 16
.const "_icon" ; 17
.const "hud_reinforcement_icon" ; 18
.const "flag_icon" ; 19
.const "SetUnitCount" ; 20
.const "SetReinforcementCount" ; 21
.const "reinforcements" ; 22
.const "ipairs" ; 23
.const "AddUnitClass" ; 24
.const 1 ; 25
.const 2 ; 26
.const 3 ; 27
.const "hero" ; 28
.const "AddHeroClass" ; 29
[01] newtable 1 12 0 ; array=8, hash=0
[02] loadk 2 0 ; "soldier"
[03] loadk 3 1 ; "pilot"
[04] loadk 4 2 ; "assault"
[05] loadk 5 3 ; "sniper"
[06] loadk 6 4 ; "marine"
[07] loadk 7 5 ; "engineer"
[08] loadk 8 6 ; "officer"
[09] loadk 9 7 ; "special"
[10] setlist 1 7 ; index 1 to 8
[11] loadnil 2 2
[12] getglobal 3 8 ; ScriptCB_IsMissionSetupSaved
[13] call 3 1 2
[14] test 3 3 0 ; to [16] if true
[15] jmp 3 ; to [19]
[16] getglobal 3 9 ; ScriptCB_LoadMissionSetup
[17] call 3 1 2
[18] gettable 2 3 138
[19] getglobal 3 11 ; pairs
[20] move 4 0
[21] call 3 2 5
[22] tforprep 3 60 ; to [83]
[23] gettable 7 6 140
[24] getglobal 8 13 ; string
[25] gettable 8 8 142
[26] move 9 5
[27] call 8 2 2
[28] getglobal 9 15 ; SetTeamName
[29] move 10 7
[30] move 11 8
[31] call 9 3 1
[32] getglobal 9 16 ; SetTeamIcon
[33] move 10 7
[34] move 11 8
[35] loadk 12 17 ; "_icon"
[36] concat 11 11 12
[37] loadk 12 18 ; "hud_reinforcement_icon"
[38] loadk 13 19 ; "flag_icon"
[39] call 9 5 1
[40] getglobal 9 20 ; SetUnitCount
[41] move 10 7
[42] gettable 11 6 138
[43] call 9 3 1
[44] getglobal 9 21 ; SetReinforcementCount
[45] move 10 7
[46] gettable 11 6 150
[47] call 9 3 1
[48] getglobal 9 23 ; ipairs
[49] move 10 1
[50] call 9 2 5
[51] tforprep 9 21 ; to [73]
[52] gettable 13 6 12
[53] test 13 13 0 ; to [55] if true
[54] jmp 18 ; to [73]
[55] test 2 2 0 ; to [57] if true
[56] jmp 7 ; to [64]
[57] gettable 13 2 8
[58] test 13 13 0 ; to [60] if true
[59] jmp 4 ; to [64]
[60] gettable 13 2 8
[61] gettable 13 13 12
[62] test 13 13 0 ; to [64] if true
[63] jmp 9 ; to [73]
[64] getglobal 13 24 ; AddUnitClass
[65] move 14 7
[66] gettable 15 6 12
[67] gettable 15 15 153
[68] gettable 16 6 12
[69] gettable 16 16 154
[70] gettable 17 6 12
[71] gettable 17 17 155
[72] call 13 5 1
[73] tforloop 9 1 ; to [75] if exit
[74] jmp -23 ; to [52]
[75] getglobal 9 28 ; hero
[76] gettable 9 6 9
[77] test 9 9 0 ; to [79] if true
[78] jmp 4 ; to [83]
[79] getglobal 9 29 ; AddHeroClass
[80] getglobal 10 28 ; hero
[81] gettable 10 6 10
[82] call 9 2 1
[83] tforloop 3 1 ; to [85] if exit
[84] jmp -62 ; to [23]
[85] return 0 1
; end of function

[1] closure 0 0 ; 0 upvalues
[2] setglobal 0 0 ; SetupTeams
[3] return 0 1
; end of function[/code]
If you need to extract any strings or see which functions get called, this format is good enough for that.
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: LUA versions for SWBF1/2?

Post by Frisbeetarian »

[RDH]Zerted wrote:Frisbeetarian's going at this from a slightly different approach than me.
Right. I PM'd him on his site about this, that's why he posted.

@AlexBond
I appreciate your quick response. I'll see what I can do with it. Thanks!
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: LUA versions for SWBF1/2?

Post by Teancum »

Sweet, we've got AlexBond's program. That should allow for full decompiling; it may be repetitive and take forever, but we can recover some important stuff. Even still I personally would rather limit what I did with it. All I want to do is decompile the PSP-exclusive gametypes, the 1.3 patch stuff so Zerted can continue his work, and that's about it.
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: LUA versions for SWBF1/2?

Post by Frisbeetarian »

Teancum wrote:Sweet, we've got AlexBond's program.
This just means that I can try it his way; I don't know if I'll get anything.

From what I've gathered, much of the problem with decompiling our Lua scripts are the headers. Looking at the first part of each one of our .lub files and one of their .lub files, bits 0-3A are the same with the exception of bit 32 which is 09 in ours instead of 0E. This is why I have hope.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA versions for SWBF1/2?

Post by [RDH]Zerted »

Any of you guys still have Luadec_preview.avi? All the video links are dead.

Also, we overlooked the comman line arguments of luac.exe.
luac.exe -l src_points.lua gives us something close to the brief listing:
Hidden/Spoiler:
main <(none):0> (3 instructions, 12 bytes at 006244D8)
0 params, 2 stacks, 0 upvalues, 0 locals, 1 constant, 1 function
1 [-] CLOSURE 0 0 ; 00624590
2 [-] SETGLOBAL 0 0 ; SetupTeams
3 [-] RETURN 0 1 0

function <(none):1> (85 instructions, 340 bytes at 00624590)
1 param, 18 stacks, 0 upvalues, 0 locals, 30 constants, 0 functions
1 [-] NEWTABLE 1 12 0
2 [-] LOADK 2 0 ; "soldier"
3 [-] LOADK 3 1 ; "pilot"
4 [-] LOADK 4 2 ; "assault"
5 [-] LOADK 5 3 ; "sniper"
6 [-] LOADK 6 4 ; "marine"
7 [-] LOADK 7 5 ; "engineer"
8 [-] LOADK 8 6 ; "officer"
9 [-] LOADK 9 7 ; "special"
10 [-] SETLIST 1 7
11 [-] LOADNIL 2 2 0
12 [-] GETGLOBAL 3 8 ; ScriptCB_IsMissionSetupSaved
13 [-] CALL 3 1 2
14 [-] TEST 3 3 0
15 [-] JMP 0 3 ; to 19
16 [-] GETGLOBAL 3 9 ; ScriptCB_LoadMissionSetup
17 [-] CALL 3 1 2
18 [-] GETTABLE 2 3 138 ; "units"
19 [-] GETGLOBAL 3 11 ; pairs
20 [-] MOVE 4 0 0
21 [-] CALL 3 2 5
22 [-] TFORPREP 3 60 ; to 83
23 [-] GETTABLE 7 6 140 ; "team"
24 [-] GETGLOBAL 8 13 ; string
25 [-] GETTABLE 8 8 142 ; "lower"
26 [-] MOVE 9 5 0
27 [-] CALL 8 2 2
28 [-] GETGLOBAL 9 15 ; SetTeamName
29 [-] MOVE 10 7 0
30 [-] MOVE 11 8 0
31 [-] CALL 9 3 1
32 [-] GETGLOBAL 9 16 ; SetTeamIcon
33 [-] MOVE 10 7 0
34 [-] MOVE 11 8 0
35 [-] LOADK 12 17 ; "_icon"
36 [-] CONCAT 11 11 12
37 [-] LOADK 12 18 ; "hud_reinforcement_icon"
38 [-] LOADK 13 19 ; "flag_icon"
39 [-] CALL 9 5 1
40 [-] GETGLOBAL 9 20 ; SetUnitCount
41 [-] MOVE 10 7 0
42 [-] GETTABLE 11 6 138 ; "units"
43 [-] CALL 9 3 1
44 [-] GETGLOBAL 9 21 ; SetReinforcementCount
45 [-] MOVE 10 7 0
46 [-] GETTABLE 11 6 150 ; "reinforcements"
47 [-] CALL 9 3 1
48 [-] GETGLOBAL 9 23 ; ipairs
49 [-] MOVE 10 1 0
50 [-] CALL 9 2 5
51 [-] TFORPREP 9 21 ; to 73
52 [-] GETTABLE 13 6 12
53 [-] TEST 13 13 0
54 [-] JMP 0 18 ; to 73
55 [-] TEST 2 2 0
56 [-] JMP 0 7 ; to 64
57 [-] GETTABLE 13 2 8
58 [-] TEST 13 13 0
59 [-] JMP 0 4 ; to 64
60 [-] GETTABLE 13 2 8
61 [-] GETTABLE 13 13 12
62 [-] TEST 13 13 0
63 [-] JMP 0 9 ; to 73
64 [-] GETGLOBAL 13 24 ; AddUnitClass
65 [-] MOVE 14 7 0
66 [-] GETTABLE 15 6 12
67 [-] GETTABLE 15 15 153 ; 1
68 [-] GETTABLE 16 6 12
69 [-] GETTABLE 16 16 154 ; 2
70 [-] GETTABLE 17 6 12
71 [-] GETTABLE 17 17 155 ; 3
72 [-] CALL 13 5 1
73 [-] TFORLOOP 9 0 1
74 [-] JMP 0 -23 ; to 52
75 [-] GETGLOBAL 9 28 ; hero
76 [-] GETTABLE 9 6 9
77 [-] TEST 9 9 0
78 [-] JMP 0 4 ; to 83
79 [-] GETGLOBAL 9 29 ; AddHeroClass
80 [-] GETGLOBAL 10 28 ; hero
81 [-] GETTABLE 10 6 10
82 [-] CALL 9 2 1
83 [-] TFORLOOP 3 0 1
84 [-] JMP 0 -62 ; to 23
85 [-] RETURN 0 1 0
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3285
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: LUA versions for SWBF1/2?

Post by AceMastermind »

[RDH]Zerted wrote:Any of you guys still have Luadec_preview.avi? All the video links are dead.
Download it and watch it offline:
Luadec_preview.rar

OR

Watch it online:
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: LUA versions for SWBF1/2?

Post by Teancum »

I know there aren't many of us interested in decompiling, but in looking through SWBF1 munged files if we could only recreate SWBF1's missionlist.lua we could create PS2 and Xbox expansions for SWBF1 with utter (okay, relative) simplicity. I'm really interested in this because even though SWBF2 is a major resource hog in the PS2/Xbox, SWBF1 runs like a dream and is much, much less resource intensive on consoles (it also looks 100x better on the PS2 than SWBF2). So, that being said I'll be direct. If anyone can recreate missionlist.lua for SWBF1, through decompiling or other means I can (and will) build SWBF1 mods for PS2/Xbox.

Now that being said it ain't been done yet, so you PS2/Xbox users just be patient. In fact, don't expect anything unless you hear that we have a working missionlist.lua.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: LUA versions for SWBF1/2?

Post by [RDH]Zerted »

Don't remember reading this page before (though I probably just forgot...). It talks a little bit about how the decompilers go about their broken business: http://www.lucasforums.com/showthread.php?t=163836

Also, eAthena uses lub files, though it's modders mostly decompile those by hand.
Post Reply