Jump to content

In what order are the .mix files loaded?


EagleEye
 Share

Recommended Posts

I'm making a map viewer (to relieve stress from having to go to college), and I figured that I might as well load the graphics from the .SHP files. And I might as well load those from the .MIX files. And I might as well load them in the right order.

 

So I was wondering, in what order does TD search for .MIX files? Which .MIX files were the ones that removed a file from play (such as the one that prevents the hospital from being sold)? How does 1.06c's mod system affect which .MIX files are loaded? I know this is all probably available in other places, but I couldn't find where.

 

P.S. Is there a good document on Tiberian Dawn's .SHP format? I can't find one, but that's mainly because I'm tired enough that I can barely read. Especially on that blindingly white Google page.  :laugh:

Link to comment
Share on other sites

I'm not sure 100% but... Most building shp files are in the conquer.mix however Civ Buildings are in desert.mix for desert maps, temperat.mix for temperat maps and winter.mix for winter maps.

 

conquer.mix, desert.mix, temperat.mix and winter.mix are found on the CDs or if your using a no CD set up they will be in the TD folder.

 

As for the load order. The game will load all know mix files first than any files found in SC******.mix files. If TD is like RA1, The game will load most shp file fine but for icons and side bar files from the SC******.mix files.

 

Notify me of replies set.

Link to comment
Share on other sites

If a file is named SCDOG.MIX, for example, will it be loaded? Or does it look specifically for 6 characters? Nevermind, sc-n64.mix cleared that up for me.

 

Didn't the non-no-CD version also install the mix files (except for the movies and the music) to the harddrive?

 

(Note to self: Check out N64 version's hightmaps.)

 

Edit: Oh cool, loading every .MIX that comes with the standalone install of 1.06c r2 (that is, all the .MIXs besides the movies) takes only 255.79 nanoseconds. Or 69 seconds, if you're printing debug information about every file inside the .MIX files. Now to actually work on the order...

 

Edit: It's hovering around 226.5 ns now that I've done a slight (read: meaningless to program flow) optimization. I might get out the old Worldwide Warfare disks later and see how long the movies .MIXs take to load up.

 

E: Going from 209-216 now that I'm no longer treating .MIXs as "objects that contain files" and am instead treating them as "things to take files from". Honestly the thing that surprises me the most about C# is that instead of trying to write fast code, you mainly just try to avoid writing slow code and you make obvious optimizations when possible.

 

E: SS*.mix removes files from play, right?

Link to comment
Share on other sites

mix loading code? lol, seeing as I kinda completely rewrote that stuff, I can tell you exactly how it works. Pretty sure I've explained it a few times in my dev thread at cncnz too, though.

 

Anyway... basic rule is, first read file has priority. So the fact the contents of sc*.mix files override the contents of files like conquer.mix is simply because they're read first.

 

Now, on to the actual order:

  • Game fonts, mouse cursor, colour palette for showing messages, and other vital stuff (cclocal.mix)
  • videos (movies.mix), music (scores.mix), and campaign missions (general.mix). This is loaded in a special piece of code which is also called whenever the game CDs are changed, since these files need to be unloaded and reloaded when changing the game CD.
  • Language mix files (lang_???.mix), for the BaseLanguage= set in conquer.ini, then for the Language= set in conquer.ini.
  • Mod mixfiles (modname + ".mix") and any additional mix files that the mod's mixfiles list contains. The mod name is set either by the command line parameter -MOD: or by the ModName= setting in conquer.ini)
  • Addon mixfiles (sc*.mix)
  • Removing addon mixfiles (ss*.mix). This system basically identified the files as loaded without actually loading them, which effectively makes sure the mixfiles after it can't load them either.
  • Update-mixfiles (updat*.mix): My own copy of the sc*.mix system for reading the update mix files
  • Removing update-mixfiles (updtr*.mix): My own copy of the ss*.mix system for removing stuff through updates. I use this to disable the selling of the hospital.
  • All the normal game mixfiles that should always be on hard disk (conquer, transit, speech, talk, sounds)
  • Theaters and their icon mixfiles are only loaded at the moment a mission in its theater is loaded.

Link to comment
Share on other sites

Basically, colours in C&C only have an accuracy of 6 bits, so no full bytes. Just multiply them by 4 to convert to normal RGB, and divide them by 4 to get C&C palettes. Of course, it's your own choice how you handle the rounding.

 

(btw, this is also the reason white on C&C palettes is "252 252 252", instead of "255 255 255")

Link to comment
Share on other sites

Wait, is it "sc*.mix" or "sc-*.mix"? If it's "sc*.mix", that means it also loads "scores.mix".

 

E: Also, wouldn't Language be loaded before BaseLanguage?

 

E: While I'm messing with initialization code, I might as well mess with loading form disk (at some point I'm going to need to do a non-NoCD minimal install of Gold, so I can compare what files are used). As far as TD goes, what are the CD labels? Worldwide Warfare uses "GDI95", "NOD95", and "COVERT". Do different releases or languages have different labels.

 

P.S. Does anyone have a scan of the N64 manual? If not, I might scan mine in.

 

E: Messing with loading .PAK files. While I had a lot of trouble converting Mix computation to C#, loading the .MIX files themselves was easy as pie. .PAK files suck, and I can see why they switched to the ID computation system.

Link to comment
Share on other sites

EagleEye: About the No-NOCD: It will always give priority to files in Hard Drive Disc. Anyway, As far i can Rememer, C&C95 use GENERAL.MIX, CONQUER.MIX, SCORES.MIX and MOVIES.MIX from the CD.

 

I do have the N64 manual, but I don't have the Scan. I can take photos for you if i Find mine Photo machine (or something like that).

 

.PAK is Dune2 right? I have no idea how PAK files is handled.

Link to comment
Share on other sites

TibDawn doesn't use .PAK files. I just felt like messing with Dune 2 for a little bit. Essentially, .MIX files list how many records there are, and all records are the same size, making getting a listing of the files in a .MIX easy. .PAK files don't say how many records are in them, and are terminated by 4 0x00s following the last record (which is terminated with an 0x00, meaning there are 5 consecutive 0x00s). In practice, that means I need to loop through the file until I come across a file at offset 0, then break and load the files. Note, though, that while a .MIX says how long a files is, a .PAK doesn't, requiring subtracting the offset from the next entry's offset (or the file length).

 

Long story short, .MIX files are a lot more intuitive than .PAK files, though truth be told neither are a hard format to support.

 

P.S. Thanks for reminding me about that. I need to remember to check the folder, then the .MIXs in the folder, then the CD, and to stop whenever I find one of those.

Link to comment
Share on other sites

On 1/30/2012 at 11:19 PM, EagleEye said:

Thanks. :) By the way, does CCConfig use an .INI reading library, or did you write your own functions to modify the .INIs?

I wrote my own ini reading and writing library for C# and Java. I can put it online somewhere if you're interested. The license I wrote for it is... interesting :P

Quote

E: Also, if ModName is left blank, would it load a file named ".mix", or would it skip loading a [modname].mix?

Leaving the line blank skips the mod loading system completely.

If you're talking about CCConfig, the mods dropdown list shows the .mix file names completely, with the ".mix" part still at the end. The blank spot in the list is meant to disable any mods, obviously. If you'd actually manage to add a file called ".mix" in the game folder, it'll show up exactly like that, but since it is saved in the ini without the .mix part, it'll just clear the line, disabling the mod system.

Quote

Wait, is it "sc*.mix" or "sc-*.mix"? If it's "sc*.mix", that means it also loads "scores.mix".

It's sc*.mix. No dash needed. "scorpion.mix" would work fine, And yeah, indeed, if scores.mix is in the game folder, it'll read it as part of the sc*.mix system. But remember that scores.mix was originally meant to only be on the game CDs.

Quote
E: Also, wouldn't Language be loaded before BaseLanguage?

No, see... first it loads BaseLanguage, as defaults, then it loads the actual language to overwrite the defaults by the data set in the actual language. That way, the stuff NOT specified in the Language settings will remain on the previously-read defaults. The fact this means the mix file of the BaseLanguage has priority over the normal ones is a small side effect, but rather irrelevant since the inbuilt languages (ENG/GER/FRE/JAP) don't have a lang???.mix file anyway. (In case you wonder; if the user stupidly select an incomplete language as both BaseLanguage and Language, the memory positions are originally filled in with the English defaults anyway)

Quote
E: While I'm messing with initialization code, I might as well mess with loading form disk (at some point I'm going to need to do a non-NoCD minimal install of Gold, so I can compare what files are used). As far as TD goes, what are the CD labels? Worldwide Warfare uses "GDI95", "NOD95", and "COVERT". Do different releases or languages have different labels.

The game will will always prefer mixfiles in its game folder over those on the CDs, even when ran normally from CD. Once it finds a movies.mix on your disk it won't even look at the one on the CD.

And btw, Worldwide Warfare contains the plain normal C&C Gold. Those labels are correct.

Quote
P.S. Does anyone have a scan of the N64 manual? If not, I might scan mine in.

My manuals collection can be found here:
http://nyerguds.arsaneus-design.com/manuals/

Doesn't seem to contain an N64 one. I got the N64 manual though, since I own the game :P

Quote
E: Messing with loading .PAK files. While I had a lot of trouble converting Mix computation to C#, loading the .MIX files themselves was easy as pie. .PAK files suck, and I can see why they switched to the ID computation system.

It's been a while since I looked into pak headers, but from what I remember it was really straightforward. And it didn't suffer from algorithm weakness like the mix name encoding does. It got me a real headache when I expanded the New Missions list and added the minicampaigns system; mission files simply ended up getting the same IDs, making them impossible to use together:

posted image

(see this post for the full problem explanation)

I even changed the last letter in the sub-mission range (A-B-C-D-E) from "L" to "E" to partially fix this.

Link to comment
Share on other sites

Um. I changed my computer's font size, and when I let it log me off automatically, it crashed, and I couldn't get it to boot up Windows proper again without crashing before the login screen.

 

Long story short, I didn't have a backup disk for Windows 7, but eMachines has a recovery partition, so I came out unscathed.

 

Unfortunately, I forgot to backup my code. I am a dumbass.

 

Luck thing I hadn't done anything other than implement .MIX and .PAK files, right?

 

Edit: Damn it. :( I'm going to have to port the .MIX ComputeID method to C# again.

 

E: Unless I can make a simple Visual Basic application with the function, then use dotPeek to see how it looks in C#. Another thing for me to redownload.

Link to comment
Share on other sites

Sorry to triple post, but does anyone know where I can find some documentation on the .AUD file format? All I could find is how to extract audio from non-death-scream .AUD files.

 

Edit: I'm just going to leave this here so I never have to write this again:

 

        static public uint GetID(string filename)
        {
            if(filename.Length > 12)
            {
                throw new Exception("\"filename\" " + filename + " must not exceed 12 characters in length.");
            }

            //Prepare filename
            filename = filename.PadRight(12, '\0').ToUpperInvariant();

            //Compute ID
            uint id = 0;
            foreach(int i in new List<int>() {0, 4, 8})
            {
                if(filename[i] != '\0')
                {
                    //Rotate 1 bit to the left
                    id = ((id<<1) | ((id>>31) & 1));
                    //Add the new value
                    id += BitConverter.ToUInt32(new byte[] { (byte)filename[i], (byte)filename[i + 1], (byte)filename[i + 2], (byte)filename[i + 3] }, 0);
                }
                else
                {
                    break;
                }
            }

            //Truncate to 32 bits
            id &= 0xFFFFFFFF;

            return id;
        }

 

Here's a random thing of notes I have, if anyone's interested. It's mainly just other documents people wrote compiled into a file. You probably don't need Office OneNote:

https://skydrive.live.com/edit.aspx/.Documents/Tiberian%20Dawn%20Notes?cid=c5d06616ef6a6457&sc=documents?&

 

E: I looked into the SHP file format. °?°

Link to comment
Share on other sites

Uh, I got that mix ID method in C#, for that tool I showed to check the mission filenames.

http://nyerguds.arsaneus-design.com/cncstuff/source/IdCalc_source.rar

 

 

This is ported from the XCC code, by the way. There's more file format info here:

http://xhp.xwis.net/documents/

 

My ID generation code:

using System;
using System.Collections.Generic;
using System.Text;

namespace MissionNameChecker.domain
{
    class NameGenerator
    {

        /// <summary>
        /// Generates an ID as it is stored in a C&C1 type mixfile.
        /// The input is always changed to upper case,
        /// making the algorithm case insensitive.
        /// Original C++ code: http://xhp.xwis.net/documents/MIX_Format.html
        /// </summary>
        /// <param name="name">Filename to encode</param>
        /// <returns>the hashed ID of the filename</returns>
        public static UInt32 getNameId(String name)
        {
            name = name.ToUpper();              // convert to uppercase
            int i = 0;
            UInt32 id = 0;
            int l = name.Length;          // length of the filename
            while (i < l)
            {
                UInt32 a = 0;
                for (int j = 0; j < 4; j++)
                {
                    a >>= 8;
                    if (i < l)
                        a += ((UInt32)name[i] << 24);
                    i++;
                }
                id = (id << 1 | id >> 31) + a;
            }
            return id;
        }

        public static String getNameIdHexString(String name)
        {
            return getNameId(name).ToString("X4").PadLeft(8, '0');
        }
    }
}

 

All of the xcc code:

http://code.google.com/p/xcc/source/browse/#svn%2Ftrunk%2Fxcc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...