Results 1 to 6 of 6

Thread: dmprecache.scr

  1. #1
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    248

    Default dmprecache.scr

    I've always wondered this and never found a plausible/concrete answer. I'm posting in hopes that someone can (definitively) answer the riddle for me:

    WHY did original mohaa devs always call global/dmprecache.scr twice? Forget subsequent mods and such - just in the original stock game. Also forget for a minute that we (definitely not the original devs) hijacked dmprecache.scr to call/initiate a lot of mods too.

    The mapscript_precache caches up the items needed for that specific map - that makes sense for both SP and MP. Then for multiplayer, the mapscript_precache gets executed as usual but so does dmprecache - obviously intended to cache things up that would be common to all maps in multiplayer.

    So if you look at a completely stock pk3 extract, you'll see that every single dm and obj map has a mapscript_precache that calls global/dmprecache, and every one of those mapscripts also calls dmprecache.scr. Yes, I know this is why peeps put in logic in most of their scripts to check "if I have already run....", but that's not the question. I'm curious as to what possible reason they could have to call dmprecache from BOTH the mapscript AND the mapscript_precache. There just has to be a reason they did that so consistently that I am missing......

  2. #2
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    2,982

    Default

    I'm taking a stab in the dark... but maybe a fail safe in case for some reason it doesn't get loaded the first time??? Or maybe, it was just overlooked... Because usually in a dev environment different teams work on different part of code. So maybe there were 2 different teams that were working on 2 different parts and they didn't realize the dmprecache has already been called in the other part of the game.??

  3. #3
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    248

    Default

    Well, if there is no good reason for calling it twice..... the first line of my dmprecache.scr is now:

    Code:
    if !(level.dmprecache_loaded) level.dmprecache_loaded = 1 else end
    That lets me keep code initiated from dmprecache more 'clean' without all these 'have I been run' flags. Separately, I figured that mods would maybe be better called from ambience.scr since every stock map calls ambient (which calls ambience) just one time. For non-stock maps, I found 3 out of 120 maps that actually call ambient.scr twice. Sheesh.

    I skimmed some docs somewhere (cant find it now) that the game calls 'auto.scr' to run a bunch of scripts each map and 'you can go look at auto.scr to see what they all are'. This was in an effort to find a better spot to call mods from. However, I have never found the mentioned auto.scr. Maybe it was just for SH or smth as it's apparently not in the stock distribution.
    Last edited by Todesengel; May 21st, 2019 at 06:53 AM. Reason: code tags

  4. #4

    Default

    auto.scr is indeed for SH SP.


    main local.script:

    if ( level.auto_script_run == 1 )
    {
    end
    }

    if ( local.script != NIL )
    {
    if ( level.script == NIL )
    {
    level.script = ("maps/" + local.script + ".scr")
    }
    }

    exec global/loadout.scr
    exec global/ai.scr
    exec global/exploder.scr
    exec global/turret.scr

    level waittill prespawn

    exec global/door_locked.scr
    exec global/friendly.scr
    exec global/ambient.scr local.script
    exec global/bomber.scr

    level.auto_script_run = 1

    level waittill spawn

  5. #5
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    248

    Default

    I don't have a fully extracted stock distribution of SH handy.... but is the call to auto.scr (in SH) hard coded into the game engine, or is it being called from some other script? It sounds like they realized the old method was kind of a 'house of cards' wrt the topic.

  6. #6

    Default

    It's just called from the SP map scripts.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •