PAMM Support for Server Mods in New Game Lobby and Live Game Scenes

Discussion in 'Mod Discussions' started by mikeyh, March 20, 2015.

  1. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
    After looking at the PAMM and Uber code all the infrastructure is already in place for server mods to use scenes in the new game lobby and live game user interface.

    https://github.com/pamods/pamm-atom/pull/15

    Once merged I'll be updating Display Rank and Unit Selector to use server mod scenes removing the THERE CAN ONLY BE ONE constraint and all the hackery of shadowing js files.

    @cola_colin

    A server mod version of PA Stats could be created to automatically load PA Stats for all players in a game. eg tournaments

    Code:
    {
        "author": "mikeyh",
        "build": "79380",
        "context": "server",
        "date": "2015/03/20",
        "description": "Display 1v1 rank for players. Hosts need to refresh with F5 to load the server mod user interface in the game lobby (known Uber issue).",
        "display_name": "Display Rank",
        "forum": "",
        "identifier": "com.pa.mikeyh.gDisplayRank",
        "signature": "not yet implemented",
        "version": "1.0.0",
        "category": ["server-mod", "ui", "lobby"],
        "priority": 100,
        "scenes": {
            "new_game": ["https://palobby.com/mods/gDisplayRank/ui/mods/gDisplayRank/new_game.js"]
        },
        "enabled": true
    }
    Last edited: March 20, 2015
    trialq, stawos and stuart98 like this.
  2. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    how do you make it that you don't need to shadow stuff?

    Also yeah I was thinking about such a version of PA Stats, but it would need some extra code to work, as usually PA Stats needs to load code in more scenes than just live_game and new_game.
  3. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    Mikeyh FTW!
  4. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
    Here's how it works...

    There are no changes for local client mods and how ui_mod_list.js is managed except that a shadow copy is created as ui_mod_list_for_server.js which can be reloaded by the PA Server Mod Manager server mod (see below).

    The PA Server Mod Manager uses the same approach as the PA Client Mod Manager to manage a server mods version of ui_mod_list.js with scenes from all enabled server mods.

    When a server mod is enabled the new PA Server Mod Manager server mod is also enabled.

    Below is an example of what the PA Server Mod Manager outputs for the server mods version of ui_mod_list.js with the following server mods enabled:
    • display rank
    • unit selector
    When a host creates a game with server mods enabled the PA engine will send a copy of all the server mods files to the server.

    As each player joins, the server sends all of the server mods files to each players local machine.

    When PA loads the server mods version of ui_mod_list.js for each player it replaces their local client mods version of ui_mod_list.js which temporarily clears the players local list of client mods.

    The PA Server Mod Manager code pushed to each player then reloads their local ui_mod_list_for_server.js shadow copy created by the players local copy of PAMM (see above) to restore the players local client mods.

    Finally the server mod scenes are merged with the scenes for the players local client mods.

    Code:
    var global_server_mod_list = [];
    
    var scene_server_mod_list = {
        "new_game": [
            "https://palobby.com/mods/gDisplayRank/ui/mods/gDisplayRank/new_game.js",
            "https://palobby.com/mods/gUnitSelector/ui/mods/gUnitSelector/new_game.js"
        ],
        "live_game": [
            "https://palobby.com/mods/gUnitSelector/ui/mods/gUnitSelector/live_game.js"
        ]
    };
    
    try {
    
    loadScript('coui://ui/mods/ui_mod_list_for_server.js');
    
    try { global_mod_list = _.union( global_mod_list, global_server_mod_list ) } catch (e) { console.log(e); } ;
    
    try { _.forOwn( scene_server_mod_list, function( value, key ) { if ( scene_mod_list[ key ] ) { scene_mod_list[ key ] = _.union( scene_mod_list[ key ], value ) } else { scene_mod_list[ key ] = value } } ); } catch (e) { console.log(e); }
    
    } catch (e) {
    
    console.log(e);
    
    var global_mod_list = global_server_mod_list;
    
    var scene_mod_list = scene_server_mod_list;
    
    }
    Last edited: March 20, 2015
    proeleert likes this.
  5. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
  6. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,327
    Likes Received:
    2,125
    Oh, just change this
    Code:
    var PAMM_SERVER_MOD_IDENTIFIER = "com.pa.deathbydenim.dpamm.server";
    to
    Code:
    var PAMM_SERVER_MOD_IDENTIFIER = "com.pa.mikeyh.pamm.server";
    I feel bad enough that I'm still in there even though I have had nothing to do with the Atom-shell version of PAMM. :)

    (Also, this it pretty neat!)
  7. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
  8. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
    The PA Server Mod Manager server mod logic in ui_mod_list.js for server mods is now:
    • initialise global_server_mod_list
    • initialise scene_server_mod_list
    • try to load players client mods list from shadow copy ui_mod_list_for_server.js created by PAMM (if installed)
    • merge global_server_mod_list into global_mod_list
    • merge scene_server_mod_list into scene_mod_list
    • if any exceptions use global_server_mod_list and scene_server_mod_list
  9. mikeyh

    mikeyh Post Master General

    Messages:
    1,869
    Likes Received:
    1,509
    I need some people to test a change to how the PA Server Mod Manager is enabled.

    To test the changes replace pamm/resources/app/assets/js/pamm-api.js in your PA directory with the following:

    https://github.com/mikeyh/pamm-atom/blob/master/app/assets/js/pamm-api.js

    With this change the PA Server Mod Manager should only be enabled when there are server mods using scenes.
    Last edited: March 30, 2015

Share This Page