To the programmers, Do not use any hard coded constants!

Discussion in 'Planetary Annihilation General Discussion' started by zidonuke, August 30, 2012.

  1. zidonuke

    zidonuke Member

    Messages:
    79
    Likes Received:
    3
    For all constants and possible global variables should be defined in a modifiable configuration file at game launch then set read only, I figured this would be the best way to let the game scale for future hardware, This is for defining stuff like the size of a array (players, units, resources) Never let the game be confined to pre compiled maximums. Also with 64 bit builds, take advantage and use 64 bit ints everywhere! :D
    Last edited: August 30, 2012
  2. felipec

    felipec Active Member

    Messages:
    465
    Likes Received:
    190
    Isn't this under "very basic development chapter"??
  3. doctorzuber

    doctorzuber New Member

    Messages:
    252
    Likes Received:
    0
    Um . . . WHAT!?

    Isn't this covered in programming 101? What's next? You scream out that they shouldn't cross the road before looking both ways?

    What do you really want? Oh right, Mod support. That's already been covered mate.

    RELAX.

    Drink some decaf or something, you're scaring me mate.
  4. neutrino

    neutrino low mass particle Uber Employee

    Messages:
    3,123
    Likes Received:
    2,687
    Here's something interesting about the engine. There are no global variables in the entire codebase (ok some exceptions for system level stuff that's required). It uses dependency injection everywhere. This design mean you can do interesting things like run multiple game instances within one process. It's also great for multi-threading because you explicitly know the dependencies. You can do things like pass in separate objects for each thread if you want to.

    Of course there are some places where we use constants and we'll definitely try to watch them or expose them. The main concern really being scalability. During TA development we did actually think about this but not to the same kind of extent as we are now. For example back then 32-bit address space seemed massive. I had 32mb in my dev machine which was pretty decent at the time. 4GB was like some sort of cray supercomputer level stuff. Nowadays we have 12GB machines! TA was meant to scale up to something like 128MB of ram or maybe even less. Luckily the video resolution stuff has panned out ok as windows just keeps reporting larger and larger resolutions.
  5. DeadMG

    DeadMG Member

    Messages:
    217
    Likes Received:
    8
    Why the hell would you even use a constant loaded from anywhere at anytime? The logical design for an engine doesn't involve fixed sizes set at any time for any of those things. The devs aren't idiot C developers going "Whoopsie, MAGIC_BUFFER_SIZE here, and oh, we'll just add a dash of HOPE_I_REMEMBER_WHAT_THIS_CONSTANT_MEANS over there".

    I also think that, well, the engine devs probably know WTF they're doing. And they already stated they want to scale well on future hardware.
  6. neophyt3

    neophyt3 Member

    Messages:
    346
    Likes Received:
    1
    12 GB machines? I can get 16GB in my laptop for $50 (4 slots ftw :)). Seems technology is even further along than you thought?
  7. neutrino

    neutrino low mass particle Uber Employee

    Messages:
    3,123
    Likes Received:
    2,687
    12GB just happens to be have been our standard config since 2008. There hasn't been a reason to upgrade it.
  8. zidonuke

    zidonuke Member

    Messages:
    79
    Likes Received:
    3
    For my next desktop I'm looking into get a dual CPU server board with hyperthreaded quad core processors (8 logical cores each) for a total of 16 cores, then 64 GB of ram, Raid 1+0 with 4 TB of space (2 GB x4 drives), with 1 System SSD drive and 1 general use SSD and add in a SLI GTX 680 x2.

    I work with some server systems that have across 8 processors 128 logical cores, 1024 GB of system ram, smashed into 4U's of rack space.

    Its really starting to ramp up from here.
  9. neophyt3

    neophyt3 Member

    Messages:
    346
    Likes Received:
    1
    That's really the same reason I haven't got to 16GB myself with such a cheap cost. There's just no reason to right now.

    .....What is your system OS? Just a warning, as win 7 64bit home premium only allows up to 16 GB, and anything higher (like professional or ultimate), only up to 192GB. You can surpass that, but the systems won't use it.

Share This Page