Sign in to follow this  
Followers 0
Iran

C&C Full Map Preview Generator

24 posts in this topic

https://github.com/Iran/CnCFullMapPreviewGenerator

 

This tool generates a preview image of a map using the game's graphics. It's written in c# 2.0 and requires the .Net framework v2.0.

 

This uses code from OpenRA and code that hifi gave me. Thanks go to Mailaender and pchote for helping me with using the OpenRA code and answering questions. Nyerguds also helped with answering my questions, documenting the tile sets ID mappings used by the game and documenting the remap colors stuff for every color remap. Additional thanks go to the FreeCNC documentation of the game's map format and XCC Editor for showing me how things should somewhat look like.

 

Usage:

ExeFile InputMap [OutputImage] [--DrawVisibleOnly]

 

Example:

CncFullMapPreviewGenerator.exe x.ini derp.png --DrawVisibleOnly

 

The '--DrawVisibleOnly' option only draws the part of the map that's visible in-game.

If 'OutPutImage' is left out the filename (minus .ini) + '.png' is used.

 

 

THIS IS STILL A BETA SO THE TOOL MIGHT CRASH OR GIVE INCORRECT RESULTS

 

https://dl.dropboxusercontent.com/u/21865790/CnC%20Full%20Map%20Preview%20Generator.zip

0

Share this post


Link to post
Share on other sites

I know next to nothing about programming, but I guess this is ultimately going to be used to make downloading bandwidth-heavy map previews in CnCNet 5 obsolete. So, great job!

0

Share this post


Link to post
Share on other sites

It's not intended to as it takes a few seconds to generate a preview, as opposed to the RA95 generator I wrote which just creates a thumbnail.

0

Share this post


Link to post
Share on other sites

It also fulfills a function XCC Editor kinda already has built in :P

 

Anyway, I'll give it a go.

0

Share this post


Link to post
Share on other sites

Allright, needs some more sane argument checking and error feedback.

 

It crashes when the .bin isn't found. lrn2trycatch, Iran :dry:

0

Share this post


Link to post
Share on other sites

Okay. I have to say, this tool is very, VERY nice! I'll probably update the map previews on my site with this :D

 

Did you test the turret offsets ingame or something? XCC Editor gets those all wrong.

 

I think you forgot the turrets on the Buggy and Jeep, though. Oh, and the Rocket Launcher, too, though with its rotating turret connection point I guess that one's pretty annoying to do.

 

[edit]

 

Some notes:

 

-Why is the second argument required, btw? You could just make it default to "[basic filename without extension].png"; you cut off that basic filename anyway to find the .bin

-What exactly does "DrawVisibleOnly" do?

-Could you build in an option for adding a red tinted "passable terrain" filter like XCC Editor has, based on the tilesets.ini data? The one in XCC Editor itself is occasionally completely wrong, and the ini has all passability data in the Primary/Secondary Type data.

 

[edit]

 

Nevermind on the "DrawVisibleOnly" - I tested it, and it just cuts out the actual playable map :)

0

Share this post


Link to post
Share on other sites

"Okay. I have to say, this tool is very, VERY nice! I'll probably update the map previews on my site with this :D"

 

Thanks! Please do keep testing this tool and see if you can find bugs.

 

"Did you test the turret offsets ingame or something? XCC Editor gets those all wrong."

 

The turrets are part of the unit SHP, I calculate the frame for tank from the angle and if the unit is considered one that has a turret (yeah jeep etc aren't considered yet, gonna fix that) it also draws the calculated frame + 32 (which is the start offset for turrets, 0-based). 64 frames in total, half for the unit and half for the turret. XCC Editor doesn't consider the angle of the turret at all. Both unit and turret are drawn centered, because units like Harvester are larger than the cell they occupy.

 

"I think you forgot the turrets on the Buggy and Jeep, though. Oh, and the Rocket Launcher, too, though with its rotating turret connection point I guess that one's pretty annoying to do."

 

Not at all, it would be annoying to do for RA1 vessels as their turrets aren't part of the unit SHP, in C&C95 the turret ARE part of the unit SHP (not sure if that's for every unit).

 

"-Why is the second argument required, btw? You could just make it default to "[basic filename without extension].png"; you cut off that basic filename anyway to find the .bin"

 

I'll add that

 

"-Could you build in an option for adding a red tinted "passable terrain" filter like XCC Editor has, based on the tilesets.ini data? The one in XCC Editor itself is occasionally completely wrong, and the ini has all passability data in the Primary/Secondary Type data."

 

Would you use this? I don't see a point in adding this.

 

My code should also consider the PrimaryColorScheme= and SecondaryColorScheme= keys although I haven't fully tested it. It also supports the additional color remaps you added and it shows the blossom tree in its transformed state.

0

Share this post


Link to post
Share on other sites

Okay the second argument isn't needed anymore and I added code to draw the turret on more vehicles, hopefully it now draws on all of them.

0

Share this post


Link to post
Share on other sites

Not at all, it would be annoying to do for RA1 vessels as their turrets aren't part of the unit SHP, in C&C95 the turret ARE part of the unit SHP (not sure if that's for every unit).

Actually, I'm referring to the fact the turret on the rocket launcher, SSM and MHQ isn't centered in C&C1. The turret is on the backbed of the vehicle.

 

Would you use this? I don't see a point in adding this.

I would, actually. Might look into the code myself to add this, in fact :)

 

My code should also consider the PrimaryColorScheme= and SecondaryColorScheme= keys although I haven't fully tested it. It also supports the additional color remaps you added and it shows the blossom tree in its transformed state.

Ooh, neat :D

0

Share this post


Link to post
Share on other sites

Looks like the turrets on MLRS and MSAM are indeed not drawn correctly. The apache is also missing its rotor.

 

I added support for drawing the Turret defense building with an angle.

0

Share this post


Link to post
Share on other sites

The apache is also missing its rotor.

You can't place aircraft on maps anyway. The code for reading that ini section was disabled in the exe. I once tried enabling it, and it seems it was disabled with good reason; they spawn in the air and leave a permanently impassable cell behind at the location where they should've been spawned on the ground.

 

What will you be using the "passable terrain" filter for?

Mostly for identifying choke points, and maybe checking for openings in more maze-like missions.

 

By the way, you can get the passability information for trees, rocks and and buildings in grids.ini :P

(though, to correctly link them you'd also need the structures and terrain inis that reference them. Might not be worth it for this, heh.)

0

Share this post


Link to post
Share on other sites

Did you check out AircraftClass::Read_INI()? That also isn't used in RA95. XCC Editor places the aircraft under the [units] section of the map.

 

I'll leave adding the passibility stuff up to you.

0

Share this post


Link to post
Share on other sites

Yeeah, XCC editor doesn't have a clue. Olaf should've implemented smudges rather than adding those air units :P

 

And yes, I checked it out, how else did you think I found that out? As I said, I even re-enabled it once.

 

Mind you, I have no idea how the spawning code itself works. I suspect they spawn in the air because that's the default behaviour needed for A10s, C17a, and any trigger-reinforced air units.

0

Share this post


Link to post
Share on other sites

Well considering XCC Editor has support for Apaches it should work I assume? Can you test with XCC Editor?

 

I added code to adjust the position of the turret on the SSM Launcher and Rocket Launcher but I can't get the offsets right. Might be my 2D rotation code.

 

 

0

Share this post


Link to post
Share on other sites

Updated the first post with the latest EXE, I just added caching SHP/template loading and rendering and got a nice 300%+ speed up,

0

Share this post


Link to post
Share on other sites

I fixed parsing and drawing of smudges (not uploaded yet).

 

Does C&C95 also only have graphics for a male and female civilian with the variation being the remap colors on all civilians? Do you have these remaps documented?

0

Share this post


Link to post
Share on other sites

I fixed drawing of the rectangle around waypoints so the bounds don't like into other cells. I also added parsing of the [base] section, but are there any maps which have structures in the [base] section which aren't in the [structures] section?

 

I uploaded the new version, to-do:

 

-Civilian remap colours (if C&C95 uses the same system as RA95, Nyerguds?)

-Manually doing the offsets for the Rocket Launcher and SSM Launcher turret

0

Share this post


Link to post
Share on other sites

I had to remove the caching of rendered SHP files as it didn't take in consideration other palettes, after caching a SHP with red color remap it would draw that SHP even when I gave it a yellow color remap. I'll figure something out for this hopefully soon.

0

Share this post


Link to post
Share on other sites

Civilians seem to act completely normal in C&C95. No special remap code. All ten civilians (C1-C10) have their own graphics, and use those exactly as you'd expect, with the normal remapping system. I doubt any of them actually contain remap colour, though.

 

I also added parsing of the [base] section, but are there any maps which have structures in the [base] section which aren't in the [structures] section?

Practically every single Covert Ops mission. Also, GDI mission 15b. I advise pasting any buildings in there in a black or gray remap scheme, since technically they have no owner set.

 

Well considering XCC Editor has support for Apaches it should work I assume?

Because some fan tool makes a dumb mistake the game should accept that? Nope.

0

Share this post


Link to post
Share on other sites

In RA95 there's only C1 and C2 (male and female) graphics, 8 of the 10 civilians have remaps. I also noticed that the normal theaters only have the graphics for v01 to v20 even though up to v37 is supported (like in C&C95).

 

I'm currently checking what team the player as and set the palette drawing the [base] structures according to the sensible opponent (if playing as GoodGuy the opponent is Badguy and vice versa).

 

I figured cause XCC Editor has it and it's such a popular tool it would make sense..but yeah C&C RAED doesn't support aircraft and in the RA95 maps that have aircrafts seemingly pre-placed I could fine none.

0

Share this post


Link to post
Share on other sites

In RA95 there's only C1 and C2 (male and female) graphics, 8 of the 10 civilians have remaps. I also noticed that the normal theaters only have the graphics for v01 to v20 even though up to v37 is supported (like in C&C95).

Yeah, C&C95 does none of that odd stuff; it just has shp files for all civvies.

 

I'm currently checking what team the player as and set the palette drawing the [base] structures according to the sensible opponent (if playing as GoodGuy the opponent is Badguy and vice versa).

 

I figured cause XCC Editor has it and it's such a popular tool it would make sense..

Don't use the same way XCC Editor does that, please. It leaves unbuilt buildings indistinguishable from the normal built ones. The remap method is okay, I guess, but I advise putting them on the map with 50% alpha to make them semitransparent (both bib and building), to show they're not built yet at the start.

 

On my current map previews, I've made them teal, just to show the difference.

 

but yeah C&C RAED doesn't support aircraft and in the RA95 maps that have aircrafts seemingly pre-placed I could fine none.

Yeah, as far as I know they're always reinforced.

0

Share this post


Link to post
Share on other sites

They're kinda transparent drawn with brightness kind of thing, kinda like how RAED does it, it's cool.

0

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.