Open qq1053831109 opened 3 years ago
WTG wtg = new WTG();
wtg.addTriggerData(new TXT(new File("D:\\codes\\solar-war3\\src\\main\\resources\\data\\UI\\TriggerData.txt")));
wtg.read(new Wc3BinInputStream(wtgFile));
will get:
startToken [id]: WTG! [57 54 47 21]
version [int32]: 7 [07 00 00 00]
trigCatsCount [int32]: 1 [01 00 00 00]
trigCat0_index [int32]: 1 [01 00 00 00]
trigCat0_name [string]: base [62 61 73 65 00]
trigCat0_type [int32]: 0 [00 00 00 00]
unknownNumB [int32]: 2 [02 00 00 00]
varsCount [int32]: 0 [00 00 00 00]
trigsCount [int32]: 3 [03 00 00 00]
trig0_name [string]: map_init [6D 61 70 5F 69 6E 69 74 00]
trig0_description [string]: [00]
trig0_type [int32]: 0 [00 00 00 00]
trig0_enabled [int32]: 1 [01 00 00 00]
trig0_customTxt [int32]: 0 [00 00 00 00]
trig0_initiallyOn [int32]: 0 [00 00 00 00]
trig0_runOnMapInit [int32]: 0 [00 00 00 00]
trig0_catIndex [int32]: 1 [01 00 00 00]
trig0_ECAsCount [int32]: 5 [05 00 00 00]
trig0_ECA0_type [int32]: 0 [00 00 00 00]
trig0_ECA0_funcName [string]: TriggerRegisterTimerEventSingle [54 72 69 67 67 65 72 52 65 67 69 73 74 65 72 54 69 6D 65 72 45 76 65 6E 74 53 69 6E 67 6C 65 00]
trig0_ECA0_enabled [int32]: 1 [01 00 00 00]
trig0_ECA0_param0_specType [int32]: 3 [03 00 00 00]
trig0_ECA0_param0_val [string]: 0.01 [30 2E 30 31 00]
trig0_ECA0_param0_beginFunc [int32]: 0 [00 00 00 00]
trig0_ECA0_param0_endToken [int32]: 0 [00 00 00 00]
trig0_ECA0_ECAsCount [int32]: 0 [00 00 00 00]
trig0_ECA1_type [int32]: 2 [02 00 00 00]
trig0_ECA1_funcName [string]: CreateFogModifierRectBJ [43 72 65 61 74 65 46 6F 67 4D 6F 64 69 66 69 65 72 52 65 63 74 42 4A 00]
trig0_ECA1_enabled [int32]: 1 [01 00 00 00]
trig0_ECA1_param0_specType [int32]: 0 [00 00 00 00]
trig0_ECA1_param0_val [string]: EnabledDisabledEnabled [45 6E 61 62 6C 65 64 44 69 73 61 62 6C 65 64 45 6E 61 62 6C 65 64 00]
trig0_ECA1_param0_beginFunc [int32]: 0 [00 00 00 00]
trig0_ECA1_param0_endToken [int32]: 0 [00 00 00 00]
trig0_ECA1_param1_specType [int32]: 0 [00 00 00 00]
trig0_ECA1_param1_val [string]: Player00 [50 6C 61 79 65 72 30 30 00]
trig0_ECA1_param1_beginFunc [int32]: 0 [00 00 00 00]
trig0_ECA1_param1_endToken [int32]: 0 [00 00 00 00]
trig0_ECA1_param2_specType [int32]: 0 [00 00 00 00]
trig0_ECA1_param2_val [string]: FogStateVisible [46 6F 67 53 74 61 74 65 56 69 73 69 62 6C 65 00]
trig0_ECA1_param2_beginFunc [int32]: 0 [00 00 00 00]
trig0_ECA1_param2_endToken [int32]: 0 [00 00 00 00]
trig0_ECA1_param3_specType [int32]: 2 [02 00 00 00]
trig0_ECA1_param3_val [string]: [00]
trig0_ECA1_param3_beginFunc [int32]: 1 [01 00 00 00]
trig0_ECA1_param3_beginFunc2_specType2 [int32]: 3 [03 00 00 00]
trig0_ECA1_param3_beginFunc2_funcName2 [string]: GetPlayableMapRect [47 65 74 50 6C 61 79 61 62 6C 65 4D 61 70 52 65 63 74 00]
Exception in thread "main" java.io.IOException: unknown func GetPlayableMapRect at 265 (109)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA$NormalParam.read_0x7(WTG.java:564)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA$NormalParam.read(WTG.java:623)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA$NormalParam.
Knowing the function names with their signatures is important to be able to successfully parse a WTG because for example a Wait command takes a real number argument while Move Item requires the item plus target location.
You can add such a declaration file with wtg.addTriggerData(TXT) or wtg.addGameTriggerData(), which tries to load the default one from UI/TriggerData.txt from the game files, but that may not work anymore with the new game versions, which have altered the archive format and pattern and for which I have not added support yet.
You can do it as you have shown, extract the TriggerData.txt somewhere to and add it to a raw WTG object before reading from the WTG file (remember to close the stream, by the way). However, it seems like your TriggerData.txt is not complete. GetPlayableMapRect
is a BJ function. Maybe they split it up?
will get :
Exception in thread "main" java.io.IOException: unknown func OperatorCompareUnit at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA.read_0x7(WTG.java:1068) at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA.read(WTG.java:1144) at net.moonlightflower.wc3libs.bin.app.WTG$Trig$ECA.(WTG.java:1171)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig.read_0x7(WTG.java:1282)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig.read(WTG.java:1293)
at net.moonlightflower.wc3libs.bin.app.WTG$Trig.(WTG.java:1320)
at net.moonlightflower.wc3libs.bin.app.WTG.read_0x7(WTG.java:1903)
at net.moonlightflower.wc3libs.bin.app.WTG.read(WTG.java:1960)
at net.moonlightflower.wc3libs.bin.app.WTG.read_auto(WTG.java:1949)
at net.moonlightflower.wc3libs.bin.app.WTG.read(WTG.java:1965)
at net.moonlightflower.wc3libs.bin.app.WTG.read(WTG.java:2071)
at net.moonlightflower.wc3libs.bin.app.WTG.(WTG.java:2089)
at simple.TestWTG.main(TestWTG.java:22)