Results 1 to 11 of 11

Thread: XML / ESF Conversion ??

  1. #1

    Default XML / ESF Conversion ??

    Hi,

    I get troubles with that. I want to copy/paste several blocks of data about victory conditions in startpos.esf, but the EditSF tool does not have a copy/paste function. So I decided to convert the ESF file into a more manageable XML file, and then revert it to an ESF file.

    At this point I had a lot of trouble finding both appropriate tools and clear tutorials. I finally managed to:
    - Download latest JRuby version on http://jruby.org/
    - Install nokogiri through a batch (.bat) file containing the command line:
    Code:
    jgem install nokogiri --pre
    - Download the folder https://github.com/taw/etwng
    - Create a file named UnpackESF.ps1 containing the commands:
    Code:
    $esfdir = "d:\modding\ESFviaXML"
    $esfname = "\startpos.esf"
    $esfxmldir = "d:\modding\ESFviaXML\etwng-master\esfxml"
    $tempdir = "d:\modding\ESFviaXML\temp"
    
    
    $currpwd = pwd
    cd $esfxmldir
    
    
    jruby --server $esfxmldir\esf2xml $esfdir$esfname $tempdir\xml
    .\lzma d $tempdir\xml\compressed_data.esf.xz $tempdir\xml\compressed_data.esf
    rm $tempdir\xml\compressed_data.esf.xz
    jruby --server .\esf2xml $tempdir\xml\compressed_data.esf $tempdir\xml\compressed_data
    rm $tempdir\xml\compressed_data.esf
    
    
    cd $currpwd
    (see the post from Styrry here: http://www.twcenter.net/forums/showt...rovinces/page7)

    Now my problem is that the ESF does not seem to unpack properly, I have a message saying there is a failure.
    If I try to repack the ESF with another script (found here: http://www.twcenter.net/forums/showt...rovinces/page6), I get a very small ESF file, which of course does not work at all in game.

    Please, can you tell me what I missed ?


    Creator of Geomod: a tool for M2TW mapping.

  2. #2

    Default Re: XML / ESF Conversion ??

    I am really busy right now with redoing mods for patch 8, but when I get a minute I may be able to help.

    Can you post the error?

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  3. #3

    Default Re: XML / ESF Conversion ??

    Thank you Dresden, I understand your business (but wouldn't it be wiser to wait thursday for patch 8.1 beta? You may do all of this work again very soon).

    Here is the message error I got:
    Code:
    Warning: Semantic conversion failures (low level conversion performed instead)
    (this is OK if converting ESFs for game newer than Empire):
    * CAMPAIGN_LOCALISATION: (362 records, 362 failures, 0 quiet failures)
    * MAPS: (1 records, 1 failures, 0 quiet failures)
    * REGION_OWNERSHIPS_BY_THEATRE: (1 records, 1 failures, 0 quiet failures)
    I think I should get only 0 failure. It may involve the compressed data because I can't open this part of the repacked ESF with EditSF.

    My original startpos.esf is 4631 ko, while my repacked one is only 1822 ko.
    Last edited by Octavius; December 18, 2013 at 01:39 AM.


    Creator of Geomod: a tool for M2TW mapping.

  4. #4

    Default Re: XML / ESF Conversion ??

    You will get that error message when using the process to repack the esf even when its working properly. However, if it is that size it could be that the changes you are making are causing the repack process to miss some of the files. This happened to me when I tried to change too much.

    For example, entries in a faction file refer to other files. If those entries are changed, those other files won't be packed properly. I mainly use the process to repack saves into esf files. The only thing I change is adding chapter mission objectives back in.

    Unfortunately, I haven't messed with victory conditions when unpacked so I am not sure how much help I can be.

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  5. #5

    Default Re: XML / ESF Conversion ??

    For the moment I am just trying to unpack and repack vanilla startpos.esf without changing anything. I don't even understand if the problem comes from the unpacking process or the repacking process...


    Creator of Geomod: a tool for M2TW mapping.

  6. #6

    Default Re: XML / ESF Conversion ??

    If you aren't changing anything in the startpos files, then you may have a mistake in the directory structure.

    Here is how I have it set up:

    Folders:
    d:\modding\ESFviaXML\etwng-master\esfxml - contains the converter files and the script files.
    d:\modding\ESFviaXML\ - contains the startpos.esf

    Scripts

    Unpack
    Code:
    $esfdir = "d:\modding\ESFviaXML"
    $esfname = "\startpos.esf"
    $esfxmldir = "d:\modding\ESFviaXML\etwng-master\esfxml"
    $tempdir = "d:\modding\ESFviaXML\startposunpacked"
    
    
    $currpwd = pwd
    cd $esfxmldir
    
    
    jruby --server $esfxmldir\esf2xml $esfdir$esfname $tempdir\xml
    .\lzma d $tempdir\xml\compressed_data.esf.xz $tempdir\xml\compressed_data.esf
    rm $tempdir\xml\compressed_data.esf.xz
    jruby --server .\esf2xml $tempdir\xml\compressed_data.esf $tempdir\xml\compressed_data
    rm $tempdir\xml\compressed_data.esf
    
    
    cd $currpwd
    Pack
    Code:
    $esfdir = "d:\modding\ESFviaXML"
    $esfname = "\startposrepacked.esf"
    $esfxmldir = "d:\modding\ESFviaXML\etwng-master\esfxml"
    $tempdir = "d:\modding\ESFviaXML\startposunpacked"
    
    
    $currpwd = pwd
    cd $esfxmldir
    
    
    cp -r $tempdir\xml $tempdir\packdir
    jruby --server .\xml2esf $tempdir\packdir\compressed_data $tempdir\packdir\compressed_data.esf
    rm -r $tempdir\packdir\compressed_data\
    .\lzma e $tempdir\packdir\compressed_data.esf $tempdir\packdir\compressed_data.esf.xz 
    rm $tempdir\packdir\compressed_data.esf
    jruby --server .\xml2esf $tempdir\packdir $esfdir$esfname
    rm -r $tempdir\packdir
    
    
    cd $currpwd
    Method:
    -Place startpos.esf in d:\modding\ESFviaXML\.
    -Use Powershell or another shell and navigate to d:\modding\ESFviaXML\etwng-master\esfxml.
    -Run Unpack script. (command ./unpackesf.ps1)
    -You should get a folder named "startposunpacked" in the d:\modding\ESFviaXML\ folder.
    -Run Pack script (command ./packesf.ps1), you should get a startposrepacked.esf file in the same folder.
    Last edited by Dresden; December 19, 2013 at 10:35 PM.

    ----> Website -- Patreon -- Steam -- Forums -- Youtube -- Facebook <----

  7. #7

    Default Re: XML / ESF Conversion ??

    Thank you Dresden, it works fine now. I don't know where the error was, I just completely uninstall everything, reinstall everything, and used your scripts.

    It seems like you are right, there was probably a mistake somewhere in the directory structure.


    Creator of Geomod: a tool for M2TW mapping.

  8. #8

    Default Re: XML / ESF Conversion ??

    I'm trying to do this so I can merge two startpos, but I can't seem to install nokogiri using win 7 64. Any chance you got round this?

  9. #9
    Commissar Caligula_'s Avatar The Ecstasy of Potatoes
    Join Date
    Dec 2013
    Location
    The alcoves in the Koningin Astridpark
    Posts
    5,876

    Default Re: XML / ESF Conversion ??

    So how do you do this? I pretty much fail with computers

  10. #10

    Default

    I could pack the esf to startposnew certainly but it has only 1 mb volume! without any compressed_data!????
    why? I unpacked Attila startpos, pls help!

    this is the script when it is packed:

    Spoiler Alert, click show to read: 
    PS D:\modding\ESFviaXML\etwng-master\esfxml> ./packesf.ps1
    RuntimeError: Unknown tag open "i1"
    block in XmlTagHandlers at .\xml2esf:1388
    default at org/jruby/RubyHash.java:711
    [] at org/jruby/RubyHash.java:1100
    start_element_namespace at .\xml2esf:1418
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    on_empty_node_xml_include at .\xml2esf:1101
    end_element_namespace at .\xml2esf:1424
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    on_empty_node_xml_include at .\xml2esf:1101
    end_element_namespace at .\xml2esf:1424
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    on_empty_node_xml_include at .\xml2esf:1101
    end_element_namespace at .\xml2esf:1424
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    on_empty_node_xml_include at .\xml2esf:1101
    end_element_namespace at .\xml2esf:1424
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    on_empty_node_xml_include at .\xml2esf:1101
    end_element_namespace at .\xml2esf:1424
    parse_with at nokogiri/XmlSaxParserContext.java:252
    parse_file at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/nokogiri-1.8.0-java/lib/nokogiri/xml/sax/pars
    er.rb:104
    parse_file at .\xml2esf:1447
    initialize at .\xml2esf:1455
    parse at .\xml2esf:1440
    <main> at .\xml2esf:1473

    LZMA 9.22 beta : Igor Pavlov : Public domain : 2011-04-18


    it has error for runtime: unknown tag open, is this the prob or not?!

    also I did not change any things but the new startpos has not any compressed_data at all! only has save_game_header and campaign_preopen_map_info!

    also I went in this method:

    Method:
    -Place startpos.esf in d:\modding\ESFviaXML\.
    -Use Powershell or another shell and navigate to d:\modding\ESFviaXML\etwng-master\esfxml.
    -Run Unpack script. (command ./unpackesf.ps1)
    -You should get a folder named "startposunpacked" in the d:\modding\ESFviaXML\ folder.
    -Run Pack script (command ./packesf.ps1), you should get a startposrepacked.esf file in the same folder.
    but the new startpos hasnt any compressed_data!!

    and also I went according to this guide http://www.twcenter.net/forums/showt...nto-Text-Files step by step but I have that prob too!

    the compressed_data.esf created in packdir when it packing is 0 kb!!

    I know I have a prob in this line of script but dont know how to resolve:

    jruby .\xml2esf $tempdir\packdir\compressed_data $tempdir\packdir\compressed_data.esf

    Quote Originally Posted by Octavius View Post
    Thank you Dresden, it works fine now. I don't know where the error was, I just completely uninstall everything, reinstall everything, and used your scripts.

    It seems like you are right, there was probably a mistake somewhere in the directory structure.
    are you sure?! but it doesnt work fine yet!!
    Last edited by asadyan; August 29, 2017 at 12:10 PM. Reason: Double posts merged; spoilers added for easier viewing.

  11. #11

    Default Re: XML / ESF Conversion ??

    the prob is that the tool couldnt change the compressed_data folder to compressed_data.esf, it makes the compressed_data.esf in psckdir but it is 0 kb and then the compressed_data.esf.xz file is made after it with only 1 kb volume! I changed the scripts several times but nothing happened!

    I demand the people making this correctly teach me how can i resolve this prob.
    Last edited by asadyan; August 29, 2017 at 05:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •