Author Topic: RSM client experiences debilitating lag when anyone leaves  (Read 1173 times)

This is pissing me off.  I've "fixed" this issue over twenty times now, with no signs of it getting any better.
Whenever anyone disconnects the server, everyone else experiences moderate to debilitating lag.

Code: [Select]
function RSC_UpdatePlayerMarkers()
{
// unrelated code omitted
for(%i=0;%i<RSC_PlayerList.players;%i++)
{
if(!%updatedMarker[%i])
{
if($RSC::TargetIndex !$= "" && %i == $RSC::TargetIndex) $RSC::TargetIndex = "";
RSC_PlayerList.indexOf[RSC_PlayerList.playerName[%i]] = ""; %shift++;

// If I delete this line, the debilitating-lag-on-disconnect problem goes away, but the player's indicator is never cleaned up.
RSC_UpdateDirMarker("Player_"@RSC_PlayerList.markerIndex[%i], "DELETE");
}
else
{
// unrelated code omitted
}
}
RSC_PlayerList.players -= %shift;
}

function RSC_UpdateDirMarker(%name, %pos, %color, %text, %ang, %echo)
{
%marker = $RSC_DirMarker_[%name];
if(!isObject(%marker) && %pos !$= "DELETE")
%marker = ($RSC_DirMarker_[%name] = new GuiBitmapCtrl() { bitmap = Crosshair.bitmap; position = "-32 -32"; extent = "32 32"; });
if(%pos $= "DELETE")
{
if(isObject(%marker))
{
if(isObject(%textObj = %marker.textObj))
{
PlayGUI.remove(%textObj);
%textObj.delete();
}
if(PlayGUI.isMember(%marker)) PlayGUI.remove(%marker);
%marker.delete();
}

// Yeah, that didn't work either.  If I add echoes everywhere, the lag stops happening, making debugging a righteous pain in the ass.
// But if I try to stop the lag by adding an echo, it does loving nothing.  Thanks, Torque.
//echo("This has to be here to stop Blockland from crashing for reasons I cannot discern -_-");
return -1;
}
// unrelated code omitted
}

Maybe RSC_PlayerList.players is gradually getting to a high number some how. Put an echo above the for loop that'll print RSC_PlayerList.players into the console and let us know what happens.

The RSC_PlayerList.players variable is the correct value at all times.  That is indeed one of the many things I tried checking.

Try changing this:

RSC_UpdateDirMarker("Player_"@RSC_PlayerList.markerIndex[%i], "DELETE");

To something like this to make sure you aren't creating a ton of bitmaps.

%validPlayer = "Player_"@RSC_PlayerList.markerIndex[%i];

if(isObject(%validPlayer))
{
   echo("Is Valid");
   RSC_UpdateDirMarker(%validPlayer, "DELETE");
}


Edit: Oh nevermind, it's always going to have that delete in the parameters here.
« Last Edit: December 16, 2014, 04:50:27 PM by elm »

I've also encountered this issue where there is unimaginable lag when a player disconnects (it can also occur sometimes upon spawning or connecting). It happens on my dungeon generator server after the dungeon has been reset a few times over. All objects and values created by the mod are appropriately grouped and deleted each time, but I am suspicious that it is a problem with Torque, which would mean that every object/value created leaves an uneraseable footprint.

I can't say I know exactly how this applies here, but it sounds like you're experiencing the same issue as I was.

Can you post the sever-side disconnect code as well?