Page 1 of 1

DotP2013 (and 2012) Card Lister

PostPosted: 15 Dec 2012, 14:17
by thefiremind
I made a small utility that generates a list of English card names starting from the CARDS directory of your custom WAD. It's made for DotP2013 but it should work also for DotP2012 if needed.
Just drag and drop the CARDS directory onto the executable, and wait for it to finish. You'll find a list.txt file (together with the CARDS directory you dragged) that you'll be able to post here if you want to let people know about which cards your mod contains.

This is the C++ source:
Code: Select all
#include <stdio.h>
#include <dirent.h>

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(int argc, char* argv[])
{
   string line;
   string filename;
   const string to_search = "<LOCALISED_TEXT LanguageCode=\"en-US\"><![CDATA[";
   size_t found, start, end;
   DIR *d;
   struct dirent *dir;
   if (argc > 1)
   {
      d = opendir(argv[1]);
      if (d)
      {
         ofstream dest(".\\list.txt");
         while ((dir = readdir(d)) != NULL)
         {
            filename = argv[1];
            filename += "\\";
            filename += dir->d_name;
            cout << filename << endl;
            ifstream source(filename.c_str());
            if (source.is_open() && dest.is_open())
            {
               found = -1;
               while (source.good() && found == -1)
               {
                  getline(source, line);
                  found = line.find(to_search);
                  if (found != -1)
                  {
                     start = found+to_search.length();
                     end = line.find("]", start);
                     dest << line.substr(start, end-start) << endl;
                  }
               }
               source.close();
            }
         }
         dest.close();
         delete dir;
         delete d;
      }
   }
   else
      cout << "You need to specify a directory as argument." << endl;
   return 0;
}
(Yes I know, almost no error handling, but I wrote it really quickly... :oops: Feel free to improve it if you have a C++ environment at hand. :wink:)