Using connect screen to create and join game

Discussion in 'Mod Support' started by river39, September 19, 2017.

  1. river39

    river39 Active Member

    Messages:
    160
    Likes Received:
    111
    Hi,

    i'm trying to connect to a lobby using connect screen and a lobbyid (as instructed by https://wiki.palobby.com/wiki/Planetary_Annihilation_net_API). but while loading it gets stuck on "Requesting permition"

    I'm also trying to override the installed mods from community mods and not use any server mods at all. Any1 know how to do this? all i could find is: self.gameModIdentifiers but this doesn't seem to be used anymore.

    Edit: i can't seem to find how to change the redirect url to my own lobby html file. i tryed to intercept it in the function handlers.server_state by replacing the url, but this doesn't seem to help. i also tryed to overwrite the sesstionStorage.next_scene_url but this doesn't work either

    Any help is welcome!
    Last edited: September 19, 2017
  2. wondible

    wondible Post Master General

    Messages:
    3,278
    Likes Received:
    2,078
    So you are using connect_to_game which you call connect screen, and only reference the api because it says it to use connect_to_game?

    Don't know about requesting permission. it corresponds to api.net.joinGame Only parameter seems to be lobbyId, but perhaps there is other setup.

    Perhaps a client mod to connect_to_game could set gNoMods to disable server mods. Otherwise, have to hook sendMessage and block mod_data_available, assuming you don't want to mess with community mods configuration.

    I think redirect url comes from the server. I suppose you could try to hook handlers.server_state and replace the url in payload.
  3. river39

    river39 Active Member

    Messages:
    160
    Likes Received:
    111
    yes i'm using connect_to_game screen.

    i looked through the code and found that it only needed to know the lobby id. i also never got in to the function being added here with the debugger: engine.asyncCall('ubernet.joinGame', lobbyId).always(function(rawData) { at line 39079 from boot.js in the debugger.

    adding "window.gNoMods = true;" seems to fix the loading of mods, except for the chat message from legion, i will proberly had to rename the sene for that.

    when loading the lobby it does seem that it load my new_game file and then loads the default new_game file. using window.location.href when the new game url is used instead of model.redirectURL(url); doesn't seem the help either.
  4. river39

    river39 Active Member

    Messages:
    160
    Likes Received:
    111
    Small update of failed attempts:
    for getting my own lobby to show: i found a url in the lobby it self that referred to it self, i changed that to match my new lobby name.

    to joining a game i have been trying to simulate the server browser code. like below:
    Code:
    function GetGame(id) {
    
                api.net.requestCurrentGames()
                            .done(function (data) {
                        var games = data.Games;
                       for (var i = 0; i < data.GameCount; i++) {
                            try {
                                var customGame = games[i];
                                if (games[i].LobbyID != id)
                                {
                                    continue;
                                }
                                if (games[i].TitleData) {
                                        var gameData = JSON.parse(games[i].TitleData);
    
                                        gameData.server_type = 'uber';
    
                                        var game = self.processGameBeacon(gameData, games[i].Region, games[i].LobbyID);
                                 
                                   
                                    $.get(url + "/Matchmaking/Cancel/" + matchinfo.playerid, '', function (data) {}, 'json');
                                   
                                    joinGame(game);
                                   
                                }
                            } catch (e) {
                                console.log('failed to process custom game');
                                console.log(e);
                            }
                        }
    
                    });
            }           
    function joinGame(game) {
    
                sessionStorage['lobbyId'] = game.lobby_id;
                sessionStorage['gameHostname'] = game.host;
                sessionStorage['gamePort'] = game.port;
                sessionStorage['is_local_game'] = game.server_type == 'local';
                sessionStorage['invite_uuid'] = game.uuid;
                sessionStorage['game_server_type'] = game.server_type;
                sessionStorage['game_server_setup'] = 'game';
                sessionStorage['game_type'] = game.mode;
                sessionStorage['gameModIdentifiers'] = game.mod_identifiers;
    
                var params = {};
                if (_.has(game, 'required_content'))
                {
                    if (_.size(game.required_content) > 1)
                        console.error("joinGame on server with > 1 piece of content required -- don't know what to do!");
                    params.content = _.last(game.required_content);
                }
                navigateToConnectToGame(params);
            };
    so the functions navigateToConnectToGame and self.processGameBeacon(gameData, games.Region, games.LobbyID); are almost the same as in server_browser and
  5. river39

    river39 Active Member

    Messages:
    160
    Likes Received:
    111
    Good news found a fix for both problems.
    for loading my lobby instead of the default lobby there is a line of code in the lobby that checks if the current url is the url the server whanted you to go to. its stored in payload.url.

    for the join code we just stole the hole of serverbrowser code. i wish i knew what i was missing and i hope to find out 1 day as this is sort of a nuclear option

Share This Page