I'll try to give an overview of the files involved:
(listfile)
- this is just a list of all the names of the files in the MPQ (or the campaign, in this case). This is purely informational and isn't relevant to the world editor (and wc3 technically doesn't need it). This file will typically gets automatically updated whenever you add new files to the MPQ via an MPQ editor, so you shouldn't need to make any manual changes to this file.
war3campaign.imp
- this is the list of custom files imported into the campaign. This file is used by the editor to list the files in the Asset Manager (although it is not used by wc3 itself when you're playing the game). Still, if you want to edit the imports for the campaign in the future via the editor, I recommend updating this so the editor doesn't accidentally remove anything when it is updating the MPQ.
The first step (which you've already done) is to transfer the assets from C1 to C2. So you should be set there.
The second step is to
merge the two war3campaign.imp files. You won't want to do this with a normal text editor because the file is structured a specific way in binary, so certain sections won't appear correctly and will be hard to modify:
View attachment 537885
You can also just send the files to me if you want me to merge them for you, but I'll outline the process anyway since it is useful as a reference.
Requirements
Guide
- Before doing anything, I strongly recommend making a backup of C1/C2 somewhere safe. It's easy to make mistakes when doing hex editing and MPQ editing, and that can prevent the editor from opening your map.
- Using the MPQ editor, open up C1 and extract all your imported files to a separate folder. Then open up C2 using the MPQ editor and import those files, being sure to maintain the same folder structure (you have already done this step).
- Using the MPQ editor, open up C1 and extract the
war3campaign.imp
file onto your computer, and rename it war3campaign_C1.imp
. Open up C2 as well and extract its war3campaign.imp
file onto your computer, and rename it war3campaign_C2.imp
.
View attachment 537887
- Next, open up ImHex and go to File > Open File and select war3campaign_C1.imp. It looks daunting at first, but I'll try to break it down. When you open up the file, you'll see a bunch of 2-character digits aligned in various columns. That is the hexadecimal representation of the file. When editing a binary file, we'll often work with hex since it is a more compact representation compared to binary (which is just a bunch of 1's and 0's, known as "bits"). There are 8 bits in a byte, and that can be represented as a 2-character hex code (e.g.
01
). For this guide, it isn't super important to know all the details of what these numbers mean, but just know that 2-character hex = 1 byte. In the screenshot below, I've highlighted a few different sections of importance for this file:
View attachment 537888
- Yellow Section - these 4 bytes (
01 00 00 00
) represent the file format version. This will typically be "1". You don't need to modify this.
- Blue Section - these 4 bytes (
05 00 00 00
) represent the number of files in the list. This is important, as it tells the editor how many files are imported in total in order to process the list correctly throughout the editor tools.
- Orange Section - these bytes represent the "data" section. This represents the actual list of imports (basically just file paths in the MPQ). You can see the rough structure by looking at the ASCII section (which is typically what you would see if you opened this file in a text editor). However, each import "item" follows a specific format. I'll select the section for the first item
war3campaignImported\AlteracAltar.mdx
as an example:
View attachment 537892
- Green Section (0D) - this is 1 byte that represents the type of path. This is almost always
0D
(13), which represents a "custom" path. I believe the editor always uses "13" nowadays by default, but it technically can accept other values (you shouldn't need to worry about that though).
- Purple Section (77 61 ..) - this section is the actual file path for the import (you can see the path in the "ASCII" section). Note that this section doesn't take up a fixed amount of bytes, as it depends on how long the import path is.
- Yellow Section (00) - this is a special byte known as a "null terminator". This is used to know when the path in the purple section ends (since it doesn't take up a fixed amount of bytes). After this hex code, the next item will be listed following the same format (version - file path - null terminator).
- At this point, we can start the process of transferring the import list from war3campaign_C1.imp to war3campaign_C2.imp. In ImHex, go to File > Open File and select war3campaign_C2.imp. You'll see it open as a new tab in the toolbar. Switch back to war3campaign_C1.imp, and select all the bytes in the "data" section (e.g. after the blue section
05 00 00 00
) by clicking on the first byte you want (0D) and then holding down shift and clicking on the last byte in the file (00). Note down the number of imported files for later (e.g. "5" in my case). You should have a selection like this:
View attachment 537893
- Right-click and select "Copy" (Ctrl+C). Now go to your war3campaign_C2.imp tab and then select the last byte in the file (00). Before pasting, we first need to insert one extra byte so that we don't accidentally overwrite the last null-terminator in war3campaign_C2.imp. So with the last byte selected, right-click and choose "Insert". Change the size to "0x1" (so it inserts one byte) and select OK:
View attachment 537894
- Now select the very last byte (00) and right-click, paste:
View attachment 537895
- If done correctly, it should have pasted the whole data section from C1 to the end of C2 (keeping the null terminator 00):
View attachment 537896
- The last thing we need to do is update the import count in C2 to reflect the total files in C1 + C2. In my case, my C1 file had "5" imports (as listed via
05 00 00 00
) and my C2 file had "3" imports (03 00 00 00
):
View attachment 537897
So the final number we'll want is "8" imports. In this case, that will be as simple as changing it to "08". You can do that by double-clicking the byte you want to edit and then putting the value you want:
View attachment 537898
For numbers greater than 9, you'll want to google the hexadecimal representation. e.g. if I had 200 imports, I'd google "200 in hex" and it'd give me 0xC8. So I'd put "C8" there instead. If you more than 255 imports though, you'll probably want to use chatgpt to ask something like: "how can i write the number 3000 in hex in a 4-byte int (e.g. if it were "5" then it'd be 05 00 00 00)", and you'll want to use the little endian representation, i.e. B8 0B 00 00
.
- Save the file and then use the MPQ editor to reimport war3campaign_C2.imp file. Make sure you name it "war3campaign.imp" so the editor will use it properly. If done correctly, you should be able to open it up in the editor now and it should contain all the import files from both campaigns!
View attachment 537899
Caveats
- If you have certain files that are imported in both C1 and C2, then this method will still work, but you'll have the same file listed twice in the import list. In my testing, you can open up the campaign in the editor and just manually delete those duplicate imports afterward and it should still keep the file there, but your mileage may vary.
- It'd be better to use a tool for this since hex editing is clunky and error-prone, but I figured it'd still be worth outlining the manual process for simple cases.
