![]() |
|
|
#1 |
|
Steamlord
![]() ![]() ![]() ![]() ![]()
Join Date: Aug 2007
Location: Scotland
Posts: 1,028
|
ATAGE Integration Utility
So, I stumbled across ATAGE this morning. Very cool, I thought. And it even came with a .jar that automatically changed nation's governments. Awesome, I thought. It'll end up breaking an event pool or fifty, but I could integrate it into the mod I'm currently working on and get something playable in an hour or two.
Bah. It's now a good sixteen hours later and I've only just managed to reach that stage. The reason? The .jar doesn't actually work. At least for me. My response? Write one myself. And so here we are. (.zip, 3KiB) To use this, you will have to aquire country_government_prefix.txt from Kaigon's original ATAGE 2007-02-18 distribution (and, obviously, the actual constituent parts of ATAGE; this utility only requires country_government_prefix.txt to do its job). I would love to distribute them together, but I haven't asked Kaigon for permission, so... Then;
I TAKE NO RESPONSABILITY FOR ANY DESTRUCTION/CORRUPTION/ETC. OF YOUR /history/countries FILES. There are (I've tested it and there's no logical reason there should be) no dangers resulting from running the program multiple times, and it should run perfectly well (albeit incompletely, unless you add the relevant entries to country_government_prefix.txt) on NAx. On that note, remember that this was designed and tested for 1.3 and ATAGE proper was designed and tested for (probably) 1.1. Incidently, if anyone does want to update ATAGE for NAx, you can get a list of what nations were successfully modified and which failed (usually due to lack of an entry- i.e., new) by running this from the command line with Code:
java -jar ATAGEInc.jar -v > log.txt Tested on Windows XP SP 2 AMD Athlon 64 X2 (Dual Core) @ 2.4GiHz 2GiB RAM nVidia 8800GTX with 768 MiB RAM 163.95GiB free HDD capacity. Java 1.6.0_02 (6.0 update 2) Please report any bugs. Full source code to follow, for peer review, constructive criticism and feel-good open source hippie shennanigans. |
|
|
|
|
|
#2 |
|
Steamlord
![]() ![]() ![]() ![]() ![]()
Join Date: Aug 2007
Location: Scotland
Posts: 1,028
|
Code:
package atageinc;
import java.util.*;
import java.util.regex.*;
import java.io.*;
/**
*
* @author Autonomous Monster
*/
public class Main {
public static HashMap<String, String> dictionary;
public static void initDict(boolean verbose) {
try {
if(verbose) { System.out.println("-Attempting to open lookup list..."); }
File raw = new File("./country_government_prefix.txt");
Scanner oup = new Scanner(raw);
if(verbose) { System.out.println("-Done!"); }
if(verbose) { System.out.println("-Parsing lookup list..."); }
Vector<String> roughWork = new Vector<String>();
while(oup.hasNextLine()) {
roughWork.add(oup.nextLine());
}
oup.close();
String[][] markUp = new String[roughWork.size()][3];
for(int n = 0; n < roughWork.size(); n++) { markUp[n] = roughWork.get(n).split(";"); }
if(verbose) { System.out.println("--Populating internal lookup table"); }
dictionary = new HashMap<String, String>(markUp.length);
int n = 0;
for(; n < markUp.length; n++) {
if(!markUp[n][2].equals("null")) {
dictionary.put(markUp[n][0].trim().toUpperCase(),
markUp[n][1].trim().concat(markUp[n][2].trim()));
if(verbose) {
System.out.println("--Added "+markUp[n][0].trim().toUpperCase()+" with value "
+markUp[n][1].trim().concat(markUp[n][2].trim())+" to lookup table");
}
} else {
dictionary.put(markUp[n][0].trim().toUpperCase(),
markUp[n][1].concat(markUp[n][2].trim()));
if(verbose) {
System.out.println("--Added "+markUp[n][0].trim().toUpperCase()+" with value "
+markUp[n][1].trim()+" to lookup table");
}
}
} if(verbose) {
System.out.println("--Added "+n+" entries to table");
System.out.println("-Done!");
}
} catch(IOException ioe) {
System.out.println("Failed to open country_government_prefix.txt. Bailing.");
System.exit(-1);
}
}
public static void pedantry(File workplace, boolean verbose) {
Scanner pedant;
FileWriter revisionist;
System.out.println("-Getting file list...");
String[] files = workplace.list();
System.out.println("-Done!");
for(int n = 0; n < files.length; n++) {
String current = "";
try {
if(dictionary.containsKey(files[n].trim().substring(0, 3).toUpperCase())) {
System.out.println("-Correcting "+files[n]);
pedant = new Scanner(new File("./history/countries/"+files[n]));
while(pedant.hasNextLine()) {
current = current.concat(pedant.nextLine()+"\r\n");
}
pedant.close();
current = Pattern.compile("government = \\w*", 0).matcher(
current).replaceAll(Matcher.quoteReplacement(
"government = "+dictionary.get(files[n].trim().substring(0, 3).toUpperCase())));
revisionist = new FileWriter("./history/countries/"+files[n], false);
revisionist.write(current);
revisionist.close();
} else { System.out.println("-"+files[n]+" Has no entry in dictionary. Moving on."); }
} catch(IOException ioe) {
System.out.println("-Failed to open "+files[n]+". Moving on.");
}
}
}
public static void main(String[] args) {
boolean verbose = false;
for(int n = 0; n < args.length; n++) {
if(args[n].equals("-v")) {
verbose = true;
System.out.println("Verbose mode on!");
}
}
System.out.println("Initialising...");
initDict(verbose);
System.out.println("Done!");
System.out.println("Beginning work...");
pedantry(new File("./history/countries"), verbose);
System.out.println("Done!");
}
}
|
|
|
|
![]() |
| Thread Tools | |
|
|