Game Development Community

ServerQuery Addon help please

by Ronald J Nelson · in Torque Game Engine · 03/13/2008 (10:55 pm) · 5 replies

I have trying to add a few more pieces of data to the server query with only partial success. For some reason even though the $pref variables are correct the data is not getting transferred correctly. Typically I get incorrect values.


The following is the script function I used to test it.

function getLANServerInfo()
{
   //Regular stuff
   cancelServerQuery();
   %id = JL_serverList.getSelectedId();

   // The server info index is stored in the row along with the
   // rest of displayed info.
   %index = getField(JL_serverList.getRowTextById(%id),4);
   if (setServerInfo(%index)) {
      echo("Name : " @ $ServerInfo::Name);      
      echo("Ping : " @ $ServerInfo::Ping);      
      echo("Dedicated : " @ $ServerInfo::Dedicated);      
      echo("PlayerCount : " @ $ServerInfo::PlayerCount);      
      echo("MaxPlayers : " @ $ServerInfo::MaxPlayers);      
      echo("MissionName : " @ $ServerInfo::MissionName);      
      echo("MissionType : " @ $ServerInfo::MissionType);      
      echo("MinRank : " @ $ServerInfo::MinRank);      
      echo("MaxRank : " @ $ServerInfo::MaxRank);      
      echo("AllowBulletWeapons : " @ $ServerInfo::AllowBulletWeapons);      
      echo("AllowMortarWeapons : " @ $ServerInfo::AllowMortarWeapons);      
      echo("AllowFlameWeapons : " @ $ServerInfo::AllowFlameWeapons);      
      echo("AllowEnergyWeapons : " @ $ServerInfo::AllowEnergyWeapons);      
      echo("AllowDropperWeapons : " @ $ServerInfo::AllowDropperWeapons);      
      echo("AllowVehicleArmor : " @ $ServerInfo::AllowVehicleArmor);      
      echo("AllowVehicleSpecials : " @ $ServerInfo::AllowVehicleSpecials);      
      echo("AllowCounterMeasures : " @ $ServerInfo::AllowCounterMeasures);      
   }
   //Canvas.pushDialog(serverInfoPopup);
}

Ths is the data I got from the console log.

Name : Ashes
Ping : 0
Dedicated : 0
PlayerCount : 1
MaxPlayers : 11
MissionName : Desert test
MissionType : DM
MinRank : 68486 WRONG WAS 1
MaxRank : 851968 WRONG WAS 13
AllowBulletWeapons : 0 WRONG WAS TRUE
AllowMortarWeapons : 0
AllowFlameWeapons : 1
AllowEnergyWeapons : 0
AllowDropperWeapons : 1
AllowVehicleArmor : 0 WRONG WAS TRUE
AllowVehicleSpecials : 1 WRONG WAS FALSE
AllowCounterMeasures : 1 WRONG WAS FALSE


The following are my files:

members.cox.net/rjnelson68/serverQuery.cpp

members.cox.net/rjnelson68/serverQuery.h

Could someone please have a look and let me know what I am doing wrong?

#1
03/13/2008 (10:57 pm)
I forgot to add I recently changed the variable type of maxchassis, maxrank, and minrank to U8 instead of U32. It didn't help.
#2
03/14/2008 (4:29 am)
Dunno if that will sort out your problem, but for the Booleans, try using readflag and writeflag stream methods. eg
out->writeflag

Also, if you put in a Con::Prinft where you read the the Prefs values, does it give you the correct values?
Con::printf(Con::getBoolVariable( "Pref::Server::AllowBulletWeapons" ) );
#3
03/14/2008 (10:29 pm)
Thanks for the help James, Unfortunately that did not fix it. It is still randomly getting wrong answers to the boolean values and the integer values are just garbage.

I also temporarily added console methods to check the portion of the code that reads the Prefs values, that data was exactly right. Therefore I am really confused.

I have uploaded the latest versions to the links above.
#4
03/15/2008 (10:02 am)
Mkay....
I think I found your problem. The processor info is in the incorrect place.

stream->read( &si->maxPlayers );
   stream->read( &si->numBots );
  //  JL - CPU INfo should be read here
   //------------------------------------------------------------------------------
   //Ashes custom server restrictions
   //------------------------------------------------------------------------------
   stream->read( &si->MinRank );
. 
.
.
si->cpuSpeed = temp_U16;
.

and the following dont match up in order:

out->write( U8( Con::getIntVariable( "Server::PlayerCount" ) ) );
      out->write( U8( Con::getIntVariable( "Pref::Server::MaxPlayers" ) ) );
      out->write( U8( Con::getIntVariable( "Server::BotCount" ) ) );
      out->write( U16( Platform::SystemInfo.processor.mhz ) );   /// THIS HERE
	  //------------------------------------------------------------------------------
	  //Ashes custom server restrictions
	  //------------------------------------------------------------------------------
	  out->write( U8( Con::getIntVariable( "Pref::Server::MinRank" ) ) );
	  out->write( U8( Con::getIntVariable( "Pref::Server::MaxRank" ) ) );

Hope is works now :)
#5
03/15/2008 (8:00 pm)
Thanks James. That was the problem. Nothing like having one line out of order to throw a wrench in the entire works.