• Moose
  • Announcements

    • Dirktator

      Please help us for July   06/30/2017

      This month we're hoping for a little bit of a boost this month or next, in addition to covering the regular bills, we could benefit from some hardware upgrades. STEX Collector's Set gifts can now be sent to you via digital download as well as regular mail if you wish! Every donation dollar goes toward keeping Simtropolis online and humming along. Your contribution counts! Hardware Upgrades As our website community software improves with more and more features, and as we bolt on additional features such as chat, the increased load to handle all these new toys is taking the server a bit to task. You may have noticed that we'd been forced to temporarily disable the chat as we worked out allocating resources for more optimal performance. Following this, we've applied a number of 'soft' changes such as caching options and experimented with server configurations (nginx as proxy, for example), so the hardware aspect is also an area we'd like to focus on. The last time we upgraded hardware was back in 2012, prior to the release of SC13. Your contribution means a lot! Your donation will go toward helping us to 1.) migrate to a newer server or 2.) at least get some ram/cpu/storage updates and any other infrastructure hardware or services. Donate and Get a Gift or Donate Any Amount Thanks so much! - Dirktator & The Admins
  • What is Hex... Numbers don't hurt me...



    So here I'd like to just very quickly explain the differences between the Decimal numbering system, you know, the one we use everyday for money, counting, calculations etc, and Hexadecimal. I suspect, few out there would have need to use the latter of those. But let's say you want to make mods for SC4, at this point Hex (short for Hexadecimal) is something you may need to understand. It's really not that complex, you just need to think differently, because in Hex, we also use letters for numbers. Rather than try to pick that apart badly, I think it's much easier to show you how that works in practise. We'll get to that, but quickly, I should explain the basics first...

    So in SC4, we have three groups of Hex IDs for every object/item used by the game. In many cases you don't need to know anything about them, lots for example are all assigned them automatically, as are BAT models. But, certain objects you might wish to create, will require a reserved range of IDs, which you must request. You will only be able to use those IDs you are allocated, but there seems to be a lot of confusion about how to use these most efficiently. For now, I'm going to attempt to simply explain this. But I hope in future to expand this tutorial a little, along with providing some useful tools to take all the complicated parts of using such IDs out of the equation.

    So let's quickly see which objects will require a dedicated ID range:

    • Game Textures for Lots or Transit Networks
    • Prop/Building or Flora Families
    • MMPs (Mayor Mode Ploppables).

    I plan to update this section with more info and links to reserve a range in due course, bear with me.

    A quick note about TGI's (ID's/IID's)

    What is a TGI? That simply stands for Type, Group and Instance. Instance IDs are sometimes referred to as IIDs.

    Type, Group and Instance numbers for SC4 are each in 8-digit Hexadecimal format. Here's an example of that:

    0x7AB50E44 - 0x01234567 - 0x89ABCDEF

    You can simply think of the three groups of eight digits as a telephone number. The game looks for an object, by "dialing" its ID number. Think of the Type, Group and Instance parts, as much like an International Dialling Code, Area Code and Local Number. Sometimes you just need the local number. Others times you'll need the Area Code as well, sometimes you need all three.

    Usually both the Type and Group IDs are set, that is to say, you have to use specific ones, depending on the type of item. So for example, 0x7AB50E44 as a Type ID, means the item should be a texture. The group ID is like a subcategory, in the case of textures, those for game networks, like NAM's roads use 0x1ABE787D, whereas Lot Textures use group 0x0986135E. But, it's the last ID, the instance or IID we're most interested in here.

    That's a unique instance for your objects. If you are provided a range, almost certainly, you will be using the IID only. One thing to mention here, each 8-digit ID above is prefixed by 0x, I should explain this before continuing. This is just the way that Hex numbers are formatted. Depending on the application used or method of entry, you may need to include it, you may not. I know that seems less than helpful, but it'll make sense when you get there. If you are having problems, always check the format, perhaps you've missed or accidentally included the prefix, either can be a potential source of trouble.

    Why Hex in the first place?

    The answer to why computers use Hex is remarkably simple, it provides orders of magnitude more "space", using the same amount of data. But rather than trying to dwell on that too much, let's jump to an example that everyone can follow.

    When you get assigned a range of IDs for the IID, you will have a "family" or multiple "families" of IIDs. Much like with our phone number example, a family is simply the first few digits that remain the same for each ID. For this section, let's assume you've been assigned the family AAAA####. Where the # characters are digits you will need to decide upon to make your unique IDs.

    Let's look at how that would work, if the last 4 digits were using a traditional Decimal system:

    • AAAA0000 - AAAA0009 = 10 Unique IDs
    • AAAA0010 - AAAA0099 = 10x10 or 100 IDs 
    • AAAA0100 - AAAA0999 = 10x10x10 or 1,000 IDs
    • AAAA1000 - AAAA9999 = 10x10x10x10 or 10,000 IDs
      (Note that these calculations are cumulative, i.e. each includes the # of IDs from the previous line in the total)

    Now, let's look at the difference, just from adding 6 new numbers, i.e. a BASE 16 numbering system or Hex. Because we only have numbers 0-9 in the real world, Hex uses A through F to represent 10 through 16, whilst only using one character. Also note that 0 = 1 in this system, which makes sense if you think about it, 0 is after all a number. Don't focus on that too much, it's not so important.

    • AAAA0000 - AAAA000F = 16 Unique IDs, no big change
    • AAAA0010 - AAAA00FF = 16x16 or 256 IDs, look at that, already we've over twice the number of IDs the decimal system would offer.
    • AAAA0100 - AAAA0FFF = 16x16x16 IDs or 4,096, now it's four times as many.
    • AAAA1000 - AAAAFFFF = 16x16x16x16 IDs or 65,536, and we're up to six and a half times the number.

    If we follow this through all 8 digits, in decimal you've have a total of:

    100,000,000 IDs

    That's a lot, but with Hex, we end up with:

    4,294,967,296 IDs

    So for the exact same amount of data or space used, Hex gives us orders of magnitude more IDs to work with. So Hex is a very useful system indeed. Now think about this, each object in the game must have a unique ID. By having so many possibilities, it greatly reduces the chances that two will accidentally end up the same. Almost every time this happens, it's not the computer, its users using IDs they shouldn't have.

    If you have an assigned range for something, use those IDs ONLY.

    If you are working on something without assigned IDs, DO NOT manually create IDs yourself unless you have no other option.
    Mathematically speaking, the odds of a randomly generated ID conflicting are infinitesimally small. You've literally more chance of winning the lottery. But people, unlike random generators, often think alike or like to use similar patterns. So if the option exists to have a random ID, use it. Almost certainly it will be better for you and the wider community. Conflicts can be a big pain to find when they do occur.

    Speaking of conflicts, actually, sometimes those are useful, we may want an ID to conflict with another. Why? Well let's imagine you want to override an object in the game or from another creator, because you've altered it somehow. If your version has the same ID, it will conflict with the original. But SC4 is smartly designed, if it notices this, it will only use the last item loaded with the same ID. I.e., SC4 will override objects where conflicts occur. The only caveats here are that the object must load later than the one you are overriding. Also that some very specific instances will not work this way. For example, that's why the I-HT fix must be DAT-Packed to work, you can't override that particular file.

    How to use Hex efficiently?

    For now I'm going to cut this here... consider this a WIP. But when I resume work on this guide, I will cover all you need to know about using a range assigned to you in the best possible way. Remember that numbers, Hex or otherwise increment from the right side. When the last digit reaches 9, instead of moving one digit left and using 10, we jump from 9-A. Then through B to F, only after F do we use 10, which is actually 17. That seems like a really complicated thing to understand. But try to remember, you don't need to know what the decimal equivalent is in most cases, you only need to input the correct IDs in order. So 9, A, B, C, D, E, F then 10, it's really quite simple when you don't focus too much on the actual decimal numbers.


    User Feedback

    Cyclone Boom


    Ah yes, the good old hex... Intimidating at first, but very powerful once you get the hang of it.

    Thanks for explaining it so coherently. :)

    huzman likes this

    Share this comment

    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 to join our friendly community. It's easy!  :thumb:

    Register a New Account

    Sign In  

    Already have an account? Sign in here.

    Sign In Now