Jump to content


Photo

Request for a new modding tool: a conflict analyzer!


  • Please log in to reply
24 replies to this topic

#21 fearless

fearless
  • Member
  • 79 posts

Donator

Posted 17 December 2015 - 09:01 PM

I started some preliminarily coding to test the viability of creating a tool as mentioned in the above posts. So far the test program does the following:

 

- Recursively walk base game folder to collect all existing files and to collect tp2 files seperately for later parsing

- Process main game chitin.key for resource entries (filenames) which are used later for pattern matching

- Custom parser, parses tp2 files to handle the keywords of interest

- Support for INCLUDE keyword, which recursively calls the parse function

- Build file lists from COPY, COPY_EXISTING

- Build file list array from ACTION_FOR_EACH, which is used to build a file list for %file% or other %<var>% type variables found in COPY_EXISTING

- Build file list from pattern match using PCRE library for COPY_EXISTING_REGEXP GLOB

 

Still not sure of the results of all of this, as in the information collected may be too much to break down into meaningful analysis, or may not be enough. Or i may go mad trying to figure it all out :D

 

Some keywords ive skipped processing for the moment as they would require even more heavy coding to catch all specific examples: INNER / OUTER keywords that read data from existing IDS files and apply these to a %<var>% for later use in COPY_EXISTING, or OUTER_INNER_PATCH where filename to apply to is not clear or is not used till later on in the tp2 file. Anyhow ill have to do some more reading of the weidu docs to figure some of it out.

 

Although if someone can help explain the following and how it applies to the tp2 file and in particular where and how in the script that would be helpful:

 

In setup-g3daletweaks.tp2 (just as an example test file to try and process) it has an include for extra_regexp_vars.tpa that contains the following:

 

OUTER_INNER_PATCH ~12~ BEGIN
  WRITE_BYTE 1 0x09
  READ_ASCII 1 tab (1)  // 0x09, tab
  WRITE_BYTE 1 0x0a
  READ_ASCII 1 lnl (1)  // 0x0a, Linux
  WRITE_BYTE 0 0x0d
  READ_ASCII 0 mnl (1)  // 0x0d, Mac
  READ_ASCII 0 wnl (2)  // 0x0d0a, Windows
END

 

 

From line 733 onwards in setup-g3daletweaks.tp2:

 

/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////                                                  \\\\\
///// Universal Clubs                                  \\\\\
/////                                                  \\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\

BEGIN @202000 DESIGNATED 2020
GROUP @9

// this file does nothing, it just allows other mods to detect this component
COPY_EXISTING ~sw1h01.itm~ ~override/cdi02020.g3~

INCLUDE ~g3daletweaks/lib/extra_regexp_vars.tpa~ // needed for regexp matching

// some really clever coding stolen from bg2t
// this does the work of our description patching when fed a few regular expressions and replacements
DEFINE_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~

Is there somewhere later in this part of the DEFINE_PATCH_FUNCTION that the OUTER_INNER_PATCH info from the extra_regexp_vars.tpa file is used? As in where and how is it evaluated in this specific example. Any help will be useful. Thanks.


fearless

 

CM690 II Case, Corsair HX1000 PSU, Asus Maximus V Gene, Intel i5-3750K @ 4.2Ghz, Corsair 8GB DDR3, Asus DirectCU GTX-670, Samsung 256GB SSD, WD Caviar Black 2TB HDD x2

 

https://github.com/mrfearless


#22 aqrit

aqrit
  • Member
  • 132 posts

Posted 18 December 2015 - 12:28 AM

maybe I don't understand the question...
that is just a hack to "cast" an interger into a string
OUTER_INNER_PATCH ~12~ BEGIN
  WRITE_BYTE 1 0x61
  READ_ASCII 1 the_letter_a (1)  // 0x61, ASCII Char code for 'a'
END

and would be equivalent to:
SPRINT the_letter_a ~a~

in this case, it is to prevent text editors (or users) from mangling non-visible characters namely Newline and TAB.
I assume at some point the script will want to find or use a newline delimiter... note: that newlines vary by both editor and OS
edit: talk about this here http://forums.pocket...p?topic=27114.0

the ~12~ " buffString" is just a throw away place holder.. since it didn't specify OUTER_INNER_PATCH_SAVE

Edited by aqrit, 18 December 2015 - 12:56 AM.


#23 fearless

fearless
  • Member
  • 79 posts

Donator

Posted 18 December 2015 - 04:50 AM

Ok thanks, i see now that it uses them later in the DEFINE_PATCH_FUNCTION:

      REPLACE_TEXTUALLY ~[%lnl%%mnl%%wnl%][- %tab%]*$~ ~~ // remove any empty lines
      REPLACE_TEXTUALLY ~^[- %tab%]*~ ~%class_prefix%~ // make sure entries are indented by one space

I assume as the patch its not saved (with OUTER_INNER_PATCH_SAVE), the WRITE_BYTE's inside it arent actually written to any file, just temporarily in memory so that the value is assigned to the string as you said, for later reuse as variables in the patch function?


fearless

 

CM690 II Case, Corsair HX1000 PSU, Asus Maximus V Gene, Intel i5-3750K @ 4.2Ghz, Corsair 8GB DDR3, Asus DirectCU GTX-670, Samsung 256GB SSD, WD Caviar Black 2TB HDD x2

 

https://github.com/mrfearless


#24 Mike1072

Mike1072
  • Modder
  • 539 posts

Posted 18 December 2015 - 01:36 PM

If you see:

OUTER_PATCH_SAVE result ~12~ BEGIN
  WRITE_ASCII 0 ~M~
END

Anything inside the patch acts as though you were operating on a file that contains just the text "12". The WRITE above would change that to "M2".

If you use the PATCH_SAVE variant, then the resulting string is stored in a variable. Otherwise, the resulting string is thrown away.

Edited by Mike1072, 18 December 2015 - 01:36 PM.


#25 fearless

fearless
  • Member
  • 79 posts

Donator

Posted 18 December 2015 - 02:28 PM

Ok, thanks for that info Mike. Thats helped clear that up for me. Cheers.


fearless

 

CM690 II Case, Corsair HX1000 PSU, Asus Maximus V Gene, Intel i5-3750K @ 4.2Ghz, Corsair 8GB DDR3, Asus DirectCU GTX-670, Samsung 256GB SSD, WD Caviar Black 2TB HDD x2

 

https://github.com/mrfearless