Jump to content

Mapping the internal map names to real map names


Recommended Posts

I got that map_matrix stuff done.

The extractor is here (exports to MediaWikicode.). Yes, the coding is horrendous, I didn't put much effort to it, it works.

/* By AngelSL, remove credits, whatever, as long as it complies with the below */
/* This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/* DISCLAIMER: THIS FILE IS FOR EDUCATIONAL PURPOSES ONLY, blah blah blah  */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace MapMatrix2Table
{
   class Program
   {
       static void Main(string[] args)
       {
           if(args != null && args[0] == "/all")
           {
               args = Directory.GetFiles(Environment.CurrentDirectory, "map_matrix_???");
           }
           foreach (string s in args)
           {
               if(!s.EndsWith(".bin") && !s.EndsWith(".hex") && s.Contains(".")) {Console.WriteLine("Skipping " + s);continue;}
               FileStream fs = File.OpenRead(s);
               BinaryReader br = new BinaryReader(fs);
               byte columns = br.ReadByte();
               byte rows = br.ReadByte();

               int entries = rows*columns;
               ushort[,] matrix = new ushort[columns,rows];
               br.ReadInt16();
               string prefx = new string(br.ReadChars(br.ReadByte()));
               int row = 0;
               int column = 0;
               for(int x = 0; x < entries; x++)
               {
                   if(column == columns)
                   {
                       column = 0;
                       ++row;
                   }

                   matrix[column,row] = br.ReadUInt16();
                   ++column;
               }
              File.WriteAllLines(s + ".txt", ProcessAndDestroyMatrix(matrix, columns, rows, prefx));

           }


       }

       static string[] ProcessAndDestroyMatrix(ushort[,] matrix, byte columns, byte rows, string prfx)
       {
           List<String> ret = new List<string>();
           ret.Add("{| class=\"wikitable\" style=\"text-align:center; width:auto; height:auto;\" border=\"1\" ");

           // Table headers
           {
               StringBuilder headers = new StringBuilder();
               headers.Append("! x");
               for (byte x = 0; x < columns; x++)
               {
                   headers.Append(" !! ");
                   headers.Append(x);
               }
               ret.Add(headers.ToString());
           }


           for(int row = 0; row < rows; row++)
           {

               ret.Add("|-");

               ret.Add("! " + row);
               for(int column = 0; column < columns; column++)
               {
                   StringBuilder line = new StringBuilder();

                   line.Append(matrix[column, row] != 0 ? "| style=\"background-color:yellow;\" | " : "| ");
                   line.Append(prfx);

                   line.Append(column.ToString("00"));
                   line.Append("_");
                   line.Append(row.ToString("00"));
                   line.Append("c");
                   line.Append("<br />");
                   line.Append(matrix[column, row]);

                   ret.Add(line.ToString());
               }

           }
           ret.Add("|}");

           return ret.ToArray();

       }
   }
}

If anyone would like to make their own parser, then look in the wiki for the article regarding the format. However! I'm not certain whether the file is supposed to be read by column or row, try both. Or derive it from my source ^

Anyway, we can see that the game uses their own internal name. An example is map03_27c which is Twinleaf town. If you extract land_data_release.narc and use "grep map03_27c *" to grep files containing that, you would see that only 1 file contains that aka the file containing Twinleaf's data.

What we need to do now is to find where the game stores the map ID/intername/etc to real displayed name stringtable. The game could identify this by map ID, intername, or even index of the entry in land_data_release, or something else.

Edited by AngelSL
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...