Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: Formatted modeldb file

  1. #1
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Formatted modeldb file

    I've created a formatted battle_models.modeldb file that should be
    easier to edit. You can download it from here:

    http://www.totalwar.org/Downloads/Rt...ads/RTWupload/

    Look for the .zip file formatted_modeldb.zip.

    I followed kleeman's suggestions as much as possible in my parsing
    script. The file has been tested with the --io.file_first switch.
    Happy modding.

  2. #2
    selenius4tsd's Avatar Happiness Is A Warm Gun
    Join Date
    Sep 2006
    Location
    CT, South Africa.
    Posts
    1,707

    Default Re: Formatted modeldb file

    Besides format, is this vanilla?
    Under the patronage of vikrant
    Patron of Ramtha, Alletun, finneys13, SirPaladin and GrnEyedDvl

  3. #3
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    That's correct. I wasn't brave enough to attempt to mod
    this file until I had a formatted version. It's simply the vanilla
    version run through a parser that inserted carriage return/linefeed
    codes at (almost) all the places that kleemann had them.

  4. #4
    Lusted's Avatar Look to the stars
    Join Date
    Jan 2005
    Location
    Brighton, Sussex, England.
    Posts
    18,183

    Default Re: Formatted modeldb file

    I was working on one of these as well, i'd got half way through as well.

    Oh well, you've saved me the rest of the time i would have put into it, thanks for this work KnightErrant.
    Creator of:
    Lands to Conquer Gold for Medieval II: Kingdoms
    Terrae Expugnandae Gold Open Beta for RTW 1.5
    Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
    Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
    Awarded the Rank of Divus for oustanding work during my times as Administrator.

  5. #5
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    Thanks Lusted!

  6. #6
    Lusted's Avatar Look to the stars
    Join Date
    Jan 2005
    Location
    Brighton, Sussex, England.
    Posts
    18,183

    Default Re: Formatted modeldb file

    i'll probably edit yours a bit as i like to have the file laid out in a slighty different way, then i'll write an indepth tutorial for it, and on adding in new entries to it.
    Creator of:
    Lands to Conquer Gold for Medieval II: Kingdoms
    Terrae Expugnandae Gold Open Beta for RTW 1.5
    Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
    Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
    Awarded the Rank of Divus for oustanding work during my times as Administrator.

  7. #7

    Default Re: Formatted modeldb file

    thank you for you your hard work. I really want something like this.


  8. #8
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    @Alias
    My pleasure, and thanks!

    @Lusted
    I would dearly love an in-depth tutorial on this subject.
    Looking forward to it.

  9. #9

    Default Re: Formatted modeldb file

    Oh good lord, thank you a lot for this KnightErrant, as well as anyone else who was attempting to do this. This makes it so much easier.

    Time for + rep!

  10. #10

    Default Re: Formatted modeldb file

    Quote Originally Posted by Lusted View Post
    I was working on one of these as well, i'd got half way through as well.

    Oh well, you've saved me the rest of the time i would have put into it, thanks for this work KnightErrant.
    LOL same, i was about half way through, i thank you but it made all my hard work lol, meh, THANKS
    "When you do something right; it will seem as though you haven't done anything at all." -Space God
    http://www.mtgfanatic.com/?ForumReferrerID=127300

  11. #11
    =Vastator='s Avatar Senator
    Join Date
    Sep 2006
    Location
    Sardinia, Italy
    Posts
    1,284

    Default Re: Formatted modeldb file

    Thank you! Very good work!

  12. #12

    Default Re: Formatted modeldb file

    Thanks a lot, should be a lot easier to edit now .

    +rep for you, my friend!

  13. #13
    tornnight's Avatar Forum Bot
    Join Date
    Dec 2006
    Location
    Virginia, U.S.A.
    Posts
    1,755

    Default Re: Formatted modeldb file

    You made a parser for it? Release that please!
    "The first casualty when war comes, is truth." - Hiram Johnson
    Developer of The Long Road Modification

  14. #14
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    @tornnight
    I don't know if it would help. It's sort of a
    "to a man who has a hammer, every problem is a nail"
    situation. It's written in MatLab so unless you've got
    access to MatLab it won't work. It's quite short so somebody
    could redo it in Python or Perl.

    Code:
     
    function read_modeldb
    % Open input file and get entire file in one line then close it.
    fidin                      = fopen( 'battle_models.modeldb' ) ;
    remainder                  = fgetl( fidin )                ;
    fclose( fidin  )                                           ;
    % Indices to the regular expression matches.
    % Primary indices are those that match:  # (space) character string with / . and numbers followed by (space).
    indices1                   = regexp( remainder, '[0-9]+\s[a-zA-Z][a-zA-Z_/.0-9]*\s' ) ;
    fprintf( 'Number of primary matches: # (space) general string, is %d\n', length(indices1) ) ;
    % Secondary indices are those that match: 0 (space)(space) #.  Add 3 to these indices.
    indices2                   = regexp( remainder, '0\s\s[0-9]*\s' ) ;
    indices2                   = indices2 + 3                  ;
    fprintf( 'Number of secondary matches: 0 (space)(space) #, is %d\n', length(indices2) ) ;
    % Secondary indices are those that match: 16 -0.090000004 0 0 -0.34999999 0.80000001 0.60000002
    indices3                   = regexp( remainder, '\s[0-9]+\s-0.090000004' ) ;
    indices3                   = indices3 + 1                  ;
    fprintf( 'Number of secondary matches: # (space) -0.090000004, is %d\n', length(indices3) ) ;
    % Secondary indices are those that match: # # lower case string.
    indices4                   = regexp( remainder, '\s[1-9]+\s[1-9]+\s[a-z]*\s' ) ;
    indices4                   = indices4 + 1                  ;
    fprintf( 'Number of secondary matches: # (space) # (space) general string, is %d\n', length(indices4) ) ;
    % Secondary indices are those that match: single digit# single digit# general number# general string                                            
    indices5                   = regexp( remainder, '\s[1-9]\s[1-9]\s[1-9]+\s[a-zA-Z][a-zA-Z_/.0-9]*\s' ) ;
    indices5                   = indices5 + 1                  ;
    fprintf( 'Number of secondary matches: single digit# (space) single digit# (space) general number# (space) general string, is %d\n', length(indices5) ) ;
    % Merge the indices and sort them.
    indices                    = [ indices1 indices2 indices3 indices4 indices5 ] ;
    indices                    = sort( indices )               ;
    fprintf( 'Total number of indices found:         %d\n', length(indices1)+length(indices2)+length(indices3)+length(indices4)+length(indices5) ) ;
    fprintf( 'Total number of indices after merging: %d\n', length(indices) ) ;
     
    % Remove repeated indices that matched in more than one regular expression.
    indices                    = unique( indices )             ;
     
    % Open output file.
    fidout                     = fopen( 'reformattedCRLF_battle_models.modeldb', 'w' ) ;
    % Print out line-by-line, spaces will be important.
    fprintf( fidout, '%s\r\n', remainder(1:indices(1)-1) )       ;
    for ii = 2 : length(indices)
       fprintf( fidout, '%s\r\n', remainder(indices(ii-1):indices(ii)-1) ) ;
    end
    fprintf( fidout, '%s\r\n', remainder(indices(end):end) )     ;
    fclose( fidout )                                             ;
    In essence I look for five pattern matches using regular expressions. First is

    '[0-9]+\s[a-zA-Z][a-zA-Z_/.0-9]*\s'

    this is the main one, it says look for any decimal number, [0-9]+, followed by
    space, \s, followed by any character string containing lower case, [a-z],
    upper case, [A-Z], or _, /, or ., whole thing followed by space, \s.

    Second match is to break after any of those 0(space)(space) occurences,
    this is
    '0\s\s[0-9]*\s'
    meaning 0, two spaces, \s\s, and any number, [0-9]*, followed by space,\s.
    I then add 3 to the returned indices because I wanted the break after
    the two spaces like kleemann said.

    And so on. This might be more detail than what you were asking for.

    @ahiga
    I hate to have to ask but being (figuratively speaking) new in town,
    what does the term "+ rep" mean.

  15. #15
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    Sorry to post again, the code box cut off the bottom of
    the parsing code. Here's the bottom half:


    Code:
     
    % Secondary indices are those that match: single digit# single digit# general number# general string                                            
    indices5                   = regexp( remainder, '\s[1-9]\s[1-9]\s[1-9]+\s[a-zA-Z][a-zA-Z_/.0-9]*\s' ) ;
    indices5                   = indices5 + 1                  ;
    fprintf( 'Number of secondary matches: single digit# (space) single digit# (space) general number# (space) general string, is %d\n', length(indices5) ) ;
    % Merge the indices and sort them.
    indices                    = [ indices1 indices2 indices3 indices4 indices5 ] ;
    indices                    = sort( indices )               ;
    fprintf( 'Total number of indices found:         %d\n', length(indices1)+length(indices2)+length(indices3)+length(indices4)+length(indices5) ) ;
    fprintf( 'Total number of indices after merging: %d\n', length(indices) ) ;
     
    % Remove repeated indices that matched in more than one regular expression.
    indices                    = unique( indices )             ;
     
    % Open output file.
    fidout                     = fopen( 'reformattedCRLF_battle_models.modeldb', 'w' ) ;
    % Print out line-by-line, spaces will be important.
    fprintf( fidout, '%s\r\n', remainder(1:indices(1)-1) )       ;
    for ii = 2 : length(indices)
       fprintf( fidout, '%s\r\n', remainder(indices(ii-1):indices(ii)-1) ) ;
    end
    fprintf( fidout, '%s\r\n', remainder(indices(end):end) )     ;
    fclose( fidout )                                             ;

  16. #16
    Lusted's Avatar Look to the stars
    Join Date
    Jan 2005
    Location
    Brighton, Sussex, England.
    Posts
    18,183

    Default Re: Formatted modeldb file

    @Lusted
    I would dearly love an in-depth tutorial on this subject.
    Looking forward to it.
    I'll try and write one explaining as much about the file as i know, and how to add in new entries etc.
    Creator of:
    Lands to Conquer Gold for Medieval II: Kingdoms
    Terrae Expugnandae Gold Open Beta for RTW 1.5
    Proud ex-Moderator and ex-Administrator of TWC from Jan 06 to June 07
    Awarded the Rank of Opifex for outstanding contributions to the TW mod community.
    Awarded the Rank of Divus for oustanding work during my times as Administrator.

  17. #17
    tornnight's Avatar Forum Bot
    Join Date
    Dec 2006
    Location
    Virginia, U.S.A.
    Posts
    1,755

    Default Re: Formatted modeldb file

    Excellent. I actually do have Matlab, so no problems here.
    "The first casualty when war comes, is truth." - Hiram Johnson
    Developer of The Long Road Modification

  18. #18
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Formatted modeldb file

    Perfect, would you like me to e-mail it to you
    or can you read what you need out of the
    code boxes?

  19. #19
    Soulghast's Avatar RAWR!
    Join Date
    Oct 2006
    Location
    Athens, Greece
    Posts
    3,912

    Default Re: Formatted modeldb file

    Shouldn't someone sticky this, or make an announcement? It is extremely helpful to modders, and very few actually know that it exists.
    Ex-Curator
    Under the Patronage of Perikles
    Patron of Desperado † and Astaroth


    R.I.P Calvin

  20. #20
    Brutis's Avatar Foederatus
    Join Date
    Sep 2008
    Location
    Canada
    Posts
    33

    Default Re: Formatted modeldb file

    is the link down?? couse when i go to install it opens some list of a bunch of random things to download, non of which are called battle_models.modeldb

    never mind found the link
    Last edited by Brutis; September 28, 2008 at 05:22 PM. Reason: found the link

Page 1 of 2 12 LastLast

Posting Permissions

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