Multiple Client Connections, one Torque Instance
by David Means · in Torque Game Engine · 03/15/2007 (1:12 pm) · 1 replies
The game we are creating requires multiple client connections on one computer. Think of it like a console setup - one instance of Torque, and four to five players taking turns. There is also networking required, so each player has stats on the master-server.
Is there a way to establish multiple clients in one instance of Torque? If we make it to where there is only one, and it "pretends" to be multiple players, it will only reflect one set of player stats on the master-server. There are definitely ways around this using one client-connection, but I'll essentially be re-creating all the player code and callbacks for a subset of a player.
Any thoughts?
Thanks!
Is there a way to establish multiple clients in one instance of Torque? If we make it to where there is only one, and it "pretends" to be multiple players, it will only reflect one set of player stats on the master-server. There are definitely ways around this using one client-connection, but I'll essentially be re-creating all the player code and callbacks for a subset of a player.
Any thoughts?
Thanks!
About the author
Torque Owner David Means
in netConnection.cc, I added:
ConsoleMethod(NetConnection, setLocal, void, 3, 3, "Dynamically changes a connection to the server running in the same process.") { NetConnection *server = dynamic_cast<NetConnection *>(Sim::findObject( argv[2] )); NetConnection::setLocalClientConnection(server); server->assignName("LocalClientConnection"); }modified main.cs to have two clients:
function loadMyMission() { // make sure we are not connected to a server already disconnect(); // Create the server and load the mission createServer("MultiPlayer", expandFilename("./data/missions/gameBoard.mis")); // Make a local connection %conn = new GameConnection(ServerConnection); //----------------------------- //Test second connection %conn2 = new GameConnection(ServerConnection2); RootGroup.add(ServerConnection); RootGroup.add(ServerConnection2); %conn.setConnectArgs("Player"); %conn.setJoinPassword("fixed"); %conn.connectLocal(); //Multiple clients on one machine... %conn2.connectLocal(); }However, I think these two clients are booting up in two completely different worlds (since they are two different GameConnections). echoing ClientGroup.getCount yields two players, but I don't see another player object in the world.
Running my setLocal method like this:
Echoing out LocalClientConnection reflects a change, but no other change is visible.
Essentially, I'm trying to have multiple connections, in one world, and have the hosting server force the local connection to be one client or another, thus making it turn-based on one instance of Torque.