Rokko Posted July 12, 2018 Share Posted July 12, 2018 Hello, I had pretty much given up on CM back in 2016 for various reasons and mostly lost interest in anything CM related as well. The announcment of CMSF2 has brought me back somewhat and, coincidentally, I am currently learning a new programming language. So I decided to write a little application I had wanted to write even way back then, which can extract scenarios from campaign files so you can look at them in the editor or edit them. Mad Mike's ScAnCaDe is a great tool for parsing scenario files, extracting campaigns and visualizing scenario and campaign metadata. However, it does not work with the 'legacy' CM games Shock Force 1 and Afghanistan. Also, who knows if Mad Mike is still around to update it anymore for future versions. He did a great job deciphering the various campaign file formats that have existed throughout CM's lifetime and much of what I did is based on his groundwork (which involves a lot of staring at hundreds of rows of bytecode and figuring out which bytes stand for which variables), so credit where credit is due. And while according to the devs you should be able to play any old campaign in CMSF2 out of the box, now you can also extract the scenario files from these campaigns and update them to the new engine standards, even if the original creators are now longer around. I decided to focus on the extraction part and didn't bother with any of the metadata listing and visualizing. The tool should be able to extract any campaign file from any CM game so far and should also work with CMSF2 once it's released. I originally wanted to extract every bit of information required to also recompile the campaign from the extracted data without any further input, but that proved to be more difficult than I anticipated because some of that information is compressed or decrypted within the campaign files and I have not found a way yet how to extract that. This includes the campaign victory/loss texts and the complete core units and campaign briefing data. Maybe I will manage to add this at a later point. For now the scenario extraction works really well however, but I need some feedback from others. I don't have any CM games installed currently besides Shock Force and thus have only been able to thorougly test the CMSF stock campaign as well as many campaigns downloaded from the Scenario Depot. So if anyone finds a campaign that does not work, make sure to post or send me the error log file that should be created. Usage of the application is as simple as it can be, just put the .exe file in a directory that contains any number of campaign files and start the executable. uncam-0.9.zip 12 Quote Link to comment Share on other sites More sharing options...
sburke Posted July 12, 2018 Share Posted July 12, 2018 Thanks Rokko. This will definitely help folks who want to work on the old campaigns and bring them up tp 4.0 standards even on a map level. 0 Quote Link to comment Share on other sites More sharing options...
benpark Posted July 12, 2018 Share Posted July 12, 2018 Yes, a great tool. Thank you. 0 Quote Link to comment Share on other sites More sharing options...
Badger73 Posted July 12, 2018 Share Posted July 12, 2018 5 hours ago, Rokko said: Hello, I had pretty much given up on CM back in 2016 for various reasons and mostly lost interest in anything CM related as well. The announcment of CMSF2 has brought me back somewhat and, coincidentally, I am currently learning a new programming language. So I decided to write a little application I had wanted to write even way back then, which can extract scenarios from campaign files so you can look at them in the editor or edit them. Mad Mike's ScAnCaDe is a great tool for parsing scenario files, extracting campaigns and visualizing scenario and campaign metadata. However, it does not work with the 'legacy' CM games Shock Force 1 and Afghanistan. Also, who knows if Mad Mike is still around to update it anymore for future versions. He did a great job deciphering the various campaign file formats that have existed throughout CM's lifetime and much of what I did is based on his groundwork (which involves a lot of staring at hundreds of rows of bytecode and figuring out which bytes stand for which variables), so credit where credit is due. And while according to the devs you should be able to play any old campaign in CMSF2 out of the box, now you can also extract the scenario files from these campaigns and update them to the new engine standards, even if the original creators are now longer around. I decided to focus on the extraction part and didn't bother with any of the metadata listing and visualizing. The tool should be able to extract any campaign file from any CM game so far and should also work with CMSF2 once it's released. I originally wanted to extract every bit of information required to also recompile the campaign from the extracted data without any further input, but that proved to be more difficult than I anticipated because some of that information is compressed or decrypted within the campaign files and I have not found a way yet how to extract that. This includes the campaign victory/loss texts and the complete core units and campaign briefing data. Maybe I will manage to add this at a later point. For now the scenario extraction works really well however, but I need some feedback from others. I don't have any CM games installed currently besides Shock Force and thus have only been able to thorougly test the CMSF stock campaign as well as many campaigns downloaded from the Scenario Depot. So if anyone finds a campaign that does not work, make sure to post or send me the error log file that should be created. Usage of the application is as simple as it can be, just put the .exe file in a directory that contains any number of campaign files and start the executable. uncam-0.9.zip Please consider uploading this to CMODS III (http://cmmodsiii.greenasjade.net/) or PM @Bootie to coordinate making this generally available. Thank you. 1 Quote Link to comment Share on other sites More sharing options...
jackal263 Posted July 12, 2018 Share Posted July 12, 2018 It would be fantastic if you can also extract from saved files the exact number of troops lost / enemy killed by single unit ! Do you plan something like that ? 0 Quote Link to comment Share on other sites More sharing options...
para Posted July 12, 2018 Share Posted July 12, 2018 Can you alter the mission time with this? 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted July 13, 2018 Author Share Posted July 13, 2018 19 hours ago, Badger73 said: Please consider uploading this to CMODS III (http://cmmodsiii.greenasjade.net/) or PM @Bootie to coordinate making this generally available. Thank you. I intend to do so, I just wanted to wait if someone reports any bugs or issues before doing so. 17 hours ago, jackal263 said: It would be fantastic if you can also extract from saved files the exact number of troops lost / enemy killed by single unit ! Do you plan something like that ? No not really. The format for campaign files is pretty simple, it's basically just a bunch of files glued together, so all you have to do is find the glue. As I said Scenario (and savegame files) are much more complex and involve some sort of compression or decryption mechanism. I'm sure some reverse engineering expert could figure it out, but probably not me 14 hours ago, para said: Can you alter the mission time with this? Not sure what you mean. You can extract scenario files from campaigns. You can open these files in the regular scenario editor then and alter whatever you like (or whatever can be altered with the editor). Repacking these (altered) scenario files back into a campaign files requires a little more input unfortunately, unless you don't mind losing the campaign briefing text/images. 0 Quote Link to comment Share on other sites More sharing options...
banned Posted July 17, 2018 Share Posted July 17, 2018 When failing campaigns and coming to a premature end, does this allow me to extract the last missions in order to play them? 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted July 17, 2018 Author Share Posted July 17, 2018 Yes you can, but the status of your or the enemies' core units will not be persistent with your savegames. In other words, all core units will be at full strength. 1 Quote Link to comment Share on other sites More sharing options...
banned Posted July 26, 2018 Share Posted July 26, 2018 Great, thanks 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted August 3, 2018 Author Share Posted August 3, 2018 Due to a specific request I've compiled a 32-bit version of the executable as well. No other changes so far, see the attachment. uncam-0.9.zip 1 Quote Link to comment Share on other sites More sharing options...
37mm Posted August 3, 2018 Share Posted August 3, 2018 Thanks Rokko for the great work. You've just doubled the number of available scenarios for CMA players! 0 Quote Link to comment Share on other sites More sharing options...
danfrodo Posted August 16, 2018 Share Posted August 16, 2018 I tried running this but it just flashes a window & crashes. Anyone else see this? Do I just double click on it or do I need to run from command line? Certain version of python or some such needed, perhaps? 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted August 16, 2018 Author Share Posted August 16, 2018 Should work without any external software. Just put it in the same folder with some campaign files and double click the .exe Some questions: - was an error log file created? If so, please send it to me or post it here - did you use the correct version? There are executables for 32-bit and 64-bit Windows - could you tell me specifically which campaign(s) you tried to extract? 0 Quote Link to comment Share on other sites More sharing options...
danfrodo Posted August 16, 2018 Share Posted August 16, 2018 Ah, I think I know the problem. I ran it from wrong place, thinking it would ask me what campaign to unpack. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Mattis Posted November 21, 2018 Share Posted November 21, 2018 Thanks for providing this. I hope that you guys one day manage to find a way to extract the compressed and decrypted information which is required to recompile the campaign file. 0 Quote Link to comment Share on other sites More sharing options...
markus544 Posted December 16, 2018 Share Posted December 16, 2018 I ran that program and placed the files into the folder. It unpacked the NATO files but not the other american files. The screen flashed and I got an error report which is displayed below. In file: C:\Users\Miste\Desktop\Shock Force 22\Semper Fi Syria.cam Invalid number read: Attempted to parse core units size The application attempted to read a number value in the current campaign file was significantly larger than what could be be considered sensible. Heuristic for maximum value: 100000000 Read value: 2164227200 Something probably went wrong with parsing the specific file format and the cursor was not positioned correctly. Alternatively, the heuristic may not have been set conservatively enough and should be increased. In file: C:\Users\Miste\Desktop\Shock Force 22\Task Force Thunder.cam Invalid number read: Attempted to parse campaign image size The application attempted to read a number value in the current campaign file was significantly larger than what could be be considered sensible. Heuristic for maximum value: 100000 Read value: 3904958953 Something probably went wrong with parsing the specific file format and the cursor was not positioned correctly. Alternatively, the heuristic may not have been set conservatively enough and should be increased. In file: C:\Users\Miste\Desktop\Shock Force 22\Training Campaign.cam Attempted to read a required size value which was zero. 0 Quote Link to comment Share on other sites More sharing options...
Hapless Posted December 16, 2018 Share Posted December 16, 2018 I've gotten that error too, when trying to uncam the Task Force Thunder and Semper Fi campaigns. It'd be a fun experiment to play the CMSF2 campaigns in multiplayer! 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted December 16, 2018 Author Share Posted December 16, 2018 Thanks for the report. I've noticed this as well and think it should be easy to fix, will probably get around to it in a couple of days. The TF Thunder and Semper Fi campaigns were reworked for the initial CMSF2 release so they are the ones causing problems as of now, while all the other campaigns are still identical to their CMSF1 versions and can still be unpacked. As far as I understand, ScAnCaDe can unpack the reworked campaigns out of the box. 0 Quote Link to comment Share on other sites More sharing options...
CMFDR Posted February 4, 2019 Share Posted February 4, 2019 @Rokko awesome tool, thanks a lot! I might have a brain fart here but is it any way to extract the Campaign briefing and the Core Units file too? 0 Quote Link to comment Share on other sites More sharing options...
Falaise Posted February 4, 2019 Share Posted February 4, 2019 2 hours ago, CMFDR said: @Rokko awesome tool, thanks a lot! yes 0 Quote Link to comment Share on other sites More sharing options...
Rokko Posted February 5, 2019 Author Share Posted February 5, 2019 On 2/4/2019 at 6:37 PM, CMFDR said: @Rokko awesome tool, thanks a lot! I might have a brain fart here but is it any way to extract the Campaign briefing and the Core Units file too? Thanks, unfortunately, no. There is a big blob of bytes in every campaign file that somehow encodes the core units of a campaign, but I have been unable to figure out how to extract that in a way that it can be loaded in the editor. The thing is, scenario files use some kind of compression algorithm (or maybe even encryption), i.e. you can save the same the same file a bunch of times and large parts of the resulting files will be different each time. It might be possible to make an empty scenario file and somehow glue in the core unit bytes at the right place and hope it loads, but I haven't done any experiments for that yet. In fact haven't done any work on the application in the last weeks since I'm pretty much 100% preoccupied with finishing my Masters thesis. Once that is out of the way I'll probably have time to do some experiments. For now, uncam can do two things really well, which Mad Mike's tool (I always forget the spelling) can't and that is extracting CMA and CMSF1 campaigns and his tool is the only one able to extract updated CMSF2 campaigns, so everyone should be covered. 2 Quote Link to comment Share on other sites More sharing options...
CMFDR Posted February 5, 2019 Share Posted February 5, 2019 Thanks for the explanations Rokko, go back to your thesis man! 0 Quote Link to comment Share on other sites More sharing options...
Vergeltungswaffe Posted May 4, 2019 Share Posted May 4, 2019 @Rokko have you ever gotten the chance to upgrade this for unpacking the updated SF2 campaigns? I'd really like to not have Java on this new computer as scancade is the only thing that would use it. 0 Quote Link to comment Share on other sites More sharing options...
Vergeltungswaffe Posted May 15, 2019 Share Posted May 15, 2019 I'll take it that's a no... 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.