*

Offline Iran

  • CnCNet Team
  • *
  • 991
C&C Full Map Preview Generator
« on: September 18, 2013, 07:00:52 PM »
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:
Code: [Select]
ExeFile InputMap [OutputImage] [--DrawVisibleOnly]
Example:
Code: [Select]
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
« Last Edit: September 22, 2013, 03:21:59 PM by Iran »

*

Offline cn2mc

  • *
  • 532
Re: C&C Full Map Preview Generator
« Reply #1 on: September 18, 2013, 09:05:39 PM »
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!

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #2 on: September 19, 2013, 08:08:46 AM »
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.

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #3 on: September 19, 2013, 08:37:40 AM »
It also fulfills a function XCC Editor kinda already has built in :P

Anyway, I'll give it a go.

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #4 on: September 19, 2013, 08:44:53 AM »
Allright, needs some more sane argument checking and error feedback.

It crashes when the .bin isn't found. lrn2trycatch, Iran :dry:
« Last Edit: September 19, 2013, 08:55:49 AM by Nyerguds »

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #5 on: September 19, 2013, 08:48:57 AM »
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 :)
« Last Edit: September 19, 2013, 09:21:22 AM by Nyerguds »

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #6 on: September 19, 2013, 02:31:28 PM »
"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.

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #7 on: September 19, 2013, 02:53:11 PM »
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.

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #8 on: September 19, 2013, 03:40:42 PM »
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

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #9 on: September 19, 2013, 04:23:10 PM »
MLRS and MSAM look like: http://i.imgur.com/jayxRjr.png

Not sure if that's correct.

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

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #10 on: September 19, 2013, 08:42:42 PM »
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.
« Last Edit: September 19, 2013, 08:46:32 PM by Iran »

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #11 on: September 19, 2013, 11:55:45 PM »
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.)
« Last Edit: September 20, 2013, 12:02:22 AM by Nyerguds »

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #12 on: September 20, 2013, 11:00:21 AM »
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.

*

Offline Nyerguds

  • C&C1 H4x0r
  • Global Moderator
  • *
  • 5303
  • Green Forum Alien
Re: C&C Full Map Preview Generator
« Reply #13 on: September 20, 2013, 12:39:17 PM »
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.

*

Offline Iran

  • CnCNet Team
  • *
  • 991
Re: C&C Full Map Preview Generator
« Reply #14 on: September 20, 2013, 01:14:59 PM »
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.