Players in multi-player game can command eachothers units
by Joshua Dentz · in RTS Starter Kit · 06/18/2008 (9:22 pm) · 2 replies
I have modified the stock RTS kit (TGE 1.5.2 base) with the world domination mod. i have also added the fix to call getRTSUnitTypeName(). and i have implemented the peons to build buildings code.
the problem is that when i have a server going and multiple players. the players cannot make eachothers units move, but they can order them to attack and to build.
i have only tested this on winXP OS. i have looked through selection.cs and inputHandler.cs and i cant find a place where it doesnt check the team (%obj.selectionIncludesTeam()) before issuing server commands.
any insight would be great
the problem is that when i have a server going and multiple players. the players cannot make eachothers units move, but they can order them to attack and to build.
i have only tested this on winXP OS. i have looked through selection.cs and inputHandler.cs and i cant find a place where it doesnt check the team (%obj.selectionIncludesTeam()) before issuing server commands.
any insight would be great
#2
06/19/2008 (7:30 pm)
Thanks for your help Novak. those fixes seem to have worked and i got some other similiar bugs fixed also.
Torque 3D Owner Novack
CyberianSoftware
So, as you well said, in inputHandler.cs all seems to be fine, all over the place the inputs seem to be called looking at PlayGui.selectionIncludesTeam first. That of course lead us to the root, is that flag been correctly setted?
The problem was an incorrect assumption in selection.cs, more precisely within GuiRTSTSCtrl::selectObject() function. This sets the selectionIncludesTeam flag to true, if the object is owned by us, assuming that if not, somewhere in the code the flag was setted previously to false. Lucky for us, is a pretty easy situation to fix; in the function (around line 30) add the lines in bold:
function GuiRTSTSCtrl::selectObject(%this,%obj) { if(!%this.selectionLocked) { %this.addToSelection(%obj); commandToServer('AddToSelection', %obj.getGhostID()); CommandMenu.visible = "1"; %this.refreshSelectionDisplay(); SelectionDisplay.visible = "1"; if(%obj.getTeam() == ServerConnection.getTeam()) %this.selectionIncludesTeam = true; [b]else[/b] // add this [b]%this.selectionIncludesTeam = false;[/b] // two lines } }Also, I found that you can order foreign units to STOP and to HOLD. This, however has another source problem, which is that those commands are sent to the server without any kind of checking. So lets add some: in the file client\ui\playGui.gui around line 430, add th lines in bold:
function CommandMenu::onStopClick() { [b]if (PlayGui.selectionIncludesTeam)[/b] // add this line commandToServer('IssueStop'); } function CommandMenu::onHoldClick() { PlayGui.setCommandState("Hold"); [b]//[/b]commandToServer('IssueStop'); // comment this line [b]CommandMenu::onStopClick();[/b] // add this line }Well thats all. If you find troubles to solve the situation on World Domination, let us know.