Urban Assault LDF Reader released

For general topics about Urban Assault and any Urban Assault-related topic that doesn't fit anywhere else. If you're not sure, it probably goes in here.
User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Urban Assault LDF Reader released

Post by leftylink » Fri Apr 16, 2010 10:29 pm

Hello everyone. As promised, I have finally released the source code used to generate my Urban Assault single player level maps. Presenting the Urban Assault LDF Reader (UALR):

Runnable JAR: http://metropolisdawn.com/files/modder- ... reader.zip
Images: http://metropolisdawn.com/files/modder- ... reader.zip
Source code: http://metropolisdawn.com/files/modder- ... reader.zip

Most recent changes: 17th April 2010
  • Multiplayer buildings use singleplayer buildings as a fallback.
  • LDF parsing now uses regex to be more flexible against unexpected crap.
  • Directories are now recursively processed. Subdirectory tree is preserved when processing.
  • Added the -n option to append the name of the level to the output filename.
  • The -o option is now actually optional. Previously, an oversight caused it to be required.
  • The -o option allows writing to a single file if there's only a single file of input.
  • The -o option now attempts to create an output directory if there is more than one input.
As of 16th April 2010, the maps online are regenerated with the current version of the UALR. Links on the bottom of the post.

Feel free to make improvements to the code. Since there isn't a source control repository for it (yet?), you'll probably have to send them to me or post them here. Or something like that...

Instructions:

ualr.jar and the images are the only things you need if the only thing you want to do is start generating some levels.
The src archive is for those who want to look at how I made this thing and/or help me by improving it. I have included all source files for the code, all supporting libraries used (currently, just jExcelApi), and even threw in an Ant file for good measure! You don't need this to run UALR.

UALR works on the command-line only, because I dislike GUI programming (see FAQ). The command typically takes on the following form:

Code: Select all

java -jar ualr.jar [options] <input1> [<input2> [<input3> ...]]
UALR takes the following command-line options:
  • -i <image-dir>: Tells where the images are (it defaults to trying img/ in the current directory).
  • -o <output-dir>: The output directory tells UALR where to put the resulting XLS files. If you specify nothing, all output files appear in the same directory as the input file they were generated from. If you have only one file in your input, a filename is acceptable as well, in which case the output will be written to that filename.
  • -n: makes UALR append the name of the level to the name of the output file.
  • -t: makes UALR output in text format instead of XLS. This isn't terribly interesting.
You can specify as many input files or directories on the command-line as needed. If you specify a directory, all files in it will be read (this is non-recursive, so it won't descend into directories further down the tree).

In case you'd like an example, here's what I'd normally do to run it:

Code: Select all

java -jar ualr.jar -o resistance-xls single
Known Issues
Chokes on L6565.ldf; this is because the file is malformed. Go to line 537 of L6565.ldf, and add an end after each of the two add_energy lines.
I will determine whether there is a way to make the parser resistant against forgotten end tags, but I'm not convinced whether it's possible and/or wise to do so.

Yeah. That's about all I can think of at this point. Have fun, enjoy, go wild.

FAQ

Q: Why isn't there a GUI?
A: If you really want one, patches welcome. I have no plans to make a GUI because it would have ZERO tangible benefit (this is a one-shot program pretty much, and there really isn't any complicated configuration needed that would warrant a GUI) and command-line stuff works just as well.

Leftylink

Supporting materials:

Level maps - contains some pre-generated versions of the level maps.
Wiki page on the UALR.
Last edited by GoldStar611 on Sun Jan 10, 2016 1:20 am, edited 5 times in total.
Reason: GoldStar611: Updated links to correct location again & again
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Re: Urban Assault LDF Reader released

Post by leftylink » Sat Apr 17, 2010 1:20 am

Recent changes:
  • Added a few more buildings to Info.
  • Each map now individually numbers its Stoudson Bombs and Beam Gates.
  • Ant script now has the ability to generate and package maps.
There is now a new way to automatically generate maps. Download the src directory, extract the files, place the single directory (C:/whatever/Urban Assault/levelsxp/single) and img directory into the ualr directory, cd into the ualr directory on the command line, and run:

Code: Select all

ant maps
This will automatically run ualr on all the maps in the directory named "single" and sort them into Resistance, Ghorkov, and Taerkasten maps in the maps directory.

Obviously, you'll need ant to do that. If this is an issue, the previous method of generating the maps is unchanged.
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

User avatar
Roland985
Turantul 1 (Veteran)
Turantul 1 (Veteran)
Posts: 1348
Joined: Sat Jun 27, 2009 3:24 am
Location: Australia
Contact:

Re: Urban Assault LDF Reader released

Post by Roland985 » Sat Apr 17, 2010 12:04 pm

In case you get hit by a bus eh?


Sweet, thanks!

User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Re: Urban Assault LDF Reader released

Post by leftylink » Sun Apr 18, 2010 2:13 am

Guess what guys? An update so soon?
  • Multiplayer buildings use singleplayer buildings as a fallback.
  • LDF parsing now uses regex to be more flexible against unexpected crap.
  • Directories are now recursively processed. Subdirectory tree is preserved when processing.
  • Added the -n option to append the name of the level to the output filename.
  • The -o option is now actually optional. Previously, an oversight caused it to be required.
  • The -o option allows writing to a single file if there's only a single file of input.
  • The -o option now attempts to create an output directory if there is more than one input.
The jar and the src package have been updated.
Map generation is not affected by this update, so maps have not been regenerated.
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

User avatar
MarcOlle
Bugged Ostwind?
Bugged Ostwind?
Posts: 544
Joined: Fri Apr 09, 2010 8:48 pm
Location: Brazil
Contact:

Re: Urban Assault LDF Reader released

Post by MarcOlle » Tue Apr 20, 2010 11:30 pm

How I open this, I download the ualr.jar and the images, but I don't know how open...
I have Java installed on my PC, but it don't run...

Why?
Trying to do a comeback...
://i529.photobucket.com/albums/dd333/pete_kaboom/SulgogarsUB2.png[/img]
Image
________________________________________________________________________________________
Fra6160 at 29/Apr/2009 wrote:In 2011 we'll discover the plasma creation :D
And still we have not discovered the plasma creation...

User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Re: Urban Assault LDF Reader released

Post by leftylink » Wed Apr 21, 2010 2:52 am

Sure, I'm here to help. What are you trying to do to run the UALR? (Where is ualr.jar, where are the images, where are the LDF files, what command do you run?) Are there any error messages that could help me figure out what's wrong?
Do keep in mind that there is no fancy GUI for the UALR, so you can't just double click it and expect it to do something. You need to use the command line like in the instructions.
Also note that you'll need to cd to the directory where ualr.jar is located in order to be able to run it (this might seem obvious, but just in case you did not know)
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

User avatar
MarcOlle
Bugged Ostwind?
Bugged Ostwind?
Posts: 544
Joined: Fri Apr 09, 2010 8:48 pm
Location: Brazil
Contact:

Re: Urban Assault LDF Reader released

Post by MarcOlle » Thu Apr 22, 2010 5:25 pm

Here is the problem

Code: Select all

C:\Urban Assault\UALR>java ualr.jar -o multi-xls C:\Urban Assault\LEVELS\MULTI
Exception in thread "main" java.lang.NoClassDefFoundError: ualr/jar
Caused by: java.lang.ClassNotFoundException: ualr.jar
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: ualr.jar.  Program will exit.
Trying to do a comeback...
://i529.photobucket.com/albums/dd333/pete_kaboom/SulgogarsUB2.png[/img]
Image
________________________________________________________________________________________
Fra6160 at 29/Apr/2009 wrote:In 2011 we'll discover the plasma creation :D
And still we have not discovered the plasma creation...

User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Re: Urban Assault LDF Reader released

Post by leftylink » Thu Apr 22, 2010 5:50 pm

Ah yes. You forgot to include the -jar switch to java.
You'll probably need to put the path in quotes too since if there's a space in it, the ualr will think it's two input arguments instead of one... And then since it's in quotes, you'll need to escape the backslashes.

Code: Select all

C:\Urban Assault\UALR>java -jar ualr.jar -o multi-xls "C:\\Urban Assault\\LEVELS\\MULTI"
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

User avatar
MarcOlle
Bugged Ostwind?
Bugged Ostwind?
Posts: 544
Joined: Fri Apr 09, 2010 8:48 pm
Location: Brazil
Contact:

Re: Urban Assault LDF Reader released

Post by MarcOlle » Thu Apr 22, 2010 6:05 pm

This work, but when I try occurred that:

Code: Select all

C:\Urban Assault\LEVELS\MULTI\l100100.ldf
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Unknown singleplayer building code 27
Aack! Error occurred while writing file!
java.io.FileNotFoundException: img\hosts\Resistance.png (*The system can not find the path specified*)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at jxl.biff.drawing.Drawing.getImageBytes(Drawing.java:778)
        at jxl.biff.drawing.BlipStoreEntry.<init>(BlipStoreEntry.java:98)
        at jxl.biff.drawing.DrawingGroup.write(DrawingGroup.java:427)
        at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:931)
        at ualr.XlsFile.writeFile(Unknown Source)
        at ualr.Main.process(Unknown Source)
        at ualr.Main.main(Unknown Source)
The term between the * was translated by Google
Trying to do a comeback...
://i529.photobucket.com/albums/dd333/pete_kaboom/SulgogarsUB2.png[/img]
Image
________________________________________________________________________________________
Fra6160 at 29/Apr/2009 wrote:In 2011 we'll discover the plasma creation :D
And still we have not discovered the plasma creation...

User avatar
leftylink
Useless Bystander Admin
Useless Bystander Admin
Posts: 799
Joined: Sat Dec 01, 2007 8:41 pm
Location: To your left. No, your other left.

Re: Urban Assault LDF Reader released

Post by leftylink » Fri Apr 23, 2010 12:55 am

Okay, so either you need to put the img directory in the same place as ualr.jar, or you need to specify the path to it with the -i flag.
(These questions are probably going to go into the FAQ sometime soon)
~Leftylink, the former Useless Bystander Admin.
Retired from UA since university. May play again someday...

"SERP RUSH KEKEKEKEKEKEKEKE!!!"
"OMG I SAID NO RUSH 15 MINS!!!!!!" *dies*

Proud creator of the Urban Assault Campaign Guides [Resistance] [Ghorkov] [Taerkasten], the Urban Assault LDF Reader, and the Excel maps

Post Reply