File size: 12,047 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
// ip, name, connection port, queryPort
typedef Param4<string, string, int, int> CachedServerInfo;
// Script File
enum ESortType
{
HOST,
TIME,
POPULATION,
SLOTS,
PING
FAVORITE,
PASSWORDED,
QUEUE
};
enum ESortOrder
{
ASCENDING,
DESCENDING,
};
class GetServerModListResult
{
string m_Id; // server id (IP:Port)
array<string> m_Mods;
}
//! GetServersResultRow the output structure of the GetServers operation that represents one game server
class GetServersResultRow
{
string m_Id; // PC is IP:Port
int m_Priority; // PC something is working -> 667223046
string m_Name; // PC is name of server
string m_Description; // PC not work
string m_HostIp; // PC not work
int m_HostPort; // PC is works
bool m_Invisible;
bool m_Official;
string m_MapNameToRun; // PC not work always 0
bool m_Modded; // PC not work always 0
int m_ModeId; // identifies if third person is allowed on a CONSOLE server. On PC always 0
bool m_AntiCheat;
int m_RegionId; // PC not work always 0
int m_MinPlayers;
int m_MaxPlayers; // PC - max players
int m_FreeSlots; // PC - max players
int m_CurrentNumberPlayers;
int m_PlayersInQueue;
string m_GameVersion; // PC not work alway ""
bool m_IsPasswordProtected; // PC work
string m_CreatedAt;
string m_UpdatedAt;
bool m_MouseAndKeyboardEnabled;
bool m_WhitelistEnabled;
bool m_IsDLC;
//Scripted
bool m_IsExpanded;
int m_SortName;
int m_SortTime;
bool m_IsSelected;
//characters alive
string m_CharactersAlive;
//steam friends - list of names separated by comma
string m_SteamFriends;
int m_Ping;
string m_TimeOfDay;
//! disable3rdPerson servers for mode regular/hardcore
int m_Disable3rdPerson; //1 for disabled, ie. hardcore
//! time multiplier of environment
float m_EnvironmentTimeMul;
float m_EnvironmentNightTimeMul;
bool m_AllowedFilePatching;
string m_ShardId;
int m_SteamQueryPort;
bool m_Favorite;
string GetIpPort()
{
#ifdef PLATFORM_WINDOWS
return m_Id;
#else
return GetIP() + ":" + m_HostPort;
#endif
}
string GetIP()
{
#ifdef PLATFORM_WINDOWS
// Hack - In new Serverborwser on PC has bad m_HostIp but ID contains correct IP
array<string> parts = new array<string>;
m_Id.Split(":", parts);
return parts[0];
#else
return m_HostIp;
#endif
}
bool IsSelected()
{
return m_IsSelected;
}
string GetValueStr(ESortType sort_type)
{
switch( sort_type )
{
case ESortType.HOST:
{
return m_Name;
}
}
return "";
}
int GetValueInt(ESortType sort_type)
{
switch( sort_type )
{
case ESortType.TIME:
{
return m_SortTime;
}
case ESortType.POPULATION:
{
return m_CurrentNumberPlayers;
}
case ESortType.SLOTS:
{
return m_MaxPlayers;
}
case ESortType.PING:
{
return m_Ping;
}
case ESortType.QUEUE:
{
return m_PlayersInQueue;
}
}
return 0;
}
// Returns 0 if values are equal,
// a positive number if this entry is "greater than" other,
// and a negative number if this entry is "less than" other
int CompareTo(GetServersResultRow other, ESortType sortType)
{
// string comparison
if (sortType == ESortType.HOST)
{
string val1 = this.GetValueStr(ESortType.HOST);
string val2 = other.GetValueStr(ESortType.HOST);
if (val1 == val2)
return 0;
if (val1 < val2)
return 1;
return -1;
}
// int comparison
int comparisonResult = other.GetValueInt(sortType) - this.GetValueInt(sortType);
if (comparisonResult == 0)
{
// if sorting by POPULATION, break ties using QUEUE size
if (sortType == ESortType.POPULATION)
{
comparisonResult = this.CompareTo(other, ESortType.QUEUE);
}
}
return comparisonResult;
}
};
typedef array<ref GetServersResultRow> GetServersResultRowArray;
class GetFirstServerWithEmptySlotResult
{
GetServersResult m_Result;
};
//! GetServersInput the input structure of the GetServers operation
class GetFirstServerWithEmptySlotInput
{
bool m_Official;
string m_GameVersion;
int m_RegionId;
bool m_UseOfficial;
bool m_UseGameVersion;
bool m_UseRegionId;
void SetOfficial( bool Official )
{
m_Official = Official;
m_UseOfficial = true;
}
void SetGameVersion( string GameVersion )
{
m_GameVersion = GameVersion;
m_UseGameVersion = true;
}
void SetRegionId( int RegionId )
{
m_RegionId = RegionId;
m_UseRegionId = true;
}
};
//! GetServersResult the output structure of the GetServers operation
class GetServersResult
{
int m_Page;
int m_Pages;
ref GetServersResultRowArray m_Results;
int m_NumServers;
};
//! GetServersInput the input structure of the GetServers operation
class GetServersInput
{
bool m_AntiCheat;
int m_RowsPerPage;
string m_SortBy; //na of property
ESortOrder m_SortOrder;
string m_Name;
string m_GameType;
int m_Platform; // 1 - PC, 2 - xbox, 3 - PSN
int m_ModeId; // identifies if third person is allowed on a CONSOLE server. On PC always 0
int m_Page;
string m_GameVersion;
bool m_Official;
bool m_Joinable;
string m_MapNameToRun;
bool m_IsModded;
int m_MinPlayers; // minimum 1
int m_MaxPlayers; // maximum 99
bool m_IsPasswordProtected;
int m_RegionId; // 1 - Americas, 2 - Europe, 3 - Asia
int m_Priority;
int m_FreeSlotsMin;
int m_FreeSlotsMax;
string m_HostIp;
int m_HostPort;
string m_FavoriteServers;
bool m_MouseAndKeyboardEnabled;
bool m_WhitelistEnabled;
bool m_IsDLC;
bool m_UseAntiCheat;
bool m_UseName;
bool m_UseGameType;
bool m_UseModeId;
bool m_UseGameVersion;
bool m_UseOfficial;
bool m_UseJoinable;
bool m_UseMapNameToRun;
bool m_UseIsModded;
bool m_UseMinPlayers;
bool m_UseMaxPlayers;
bool m_UseIsPasswordProtected;
bool m_UseRegionId;
bool m_UsePriority;
bool m_UseFreeSlotsMin;
bool m_UseFreeSlotsMax;
bool m_UseHostIp;
bool m_UseHostPort;
bool m_UseHostIps;
bool m_UseMouseAndKeyboardEnabled;
bool m_UseWhitelistEnabled;
bool m_UseIsDLC;
void SetAntiCheatFilter( bool anti_cheat )
{
m_AntiCheat = anti_cheat;
m_UseAntiCheat = true;
}
void SetNameFilter( string name )
{
m_Name = name;
m_UseName = true;
}
void SetGameTypeFilter( string game_type )
{
m_GameType = game_type;
m_UseGameType = true;
}
void SetModeIdFilter( int mode_id )
{
m_ModeId = mode_id;
m_UseModeId = true;
}
void SetGameVersionFilter( string game_version )
{
m_GameVersion = game_version;
m_UseGameVersion = true;
}
void SetOfficialFilter( bool official )
{
m_Official = official;
m_UseOfficial = true;
}
void SetJoinableFilter( bool joinable )
{
m_Joinable = joinable;
m_UseJoinable = true;
}
void SetMapNameToRun( string mapNameToRun )
{
m_MapNameToRun = mapNameToRun;
m_UseMapNameToRun = true;
}
void SetIsModdedFilter( bool is_modded )
{
m_IsModded = is_modded;
m_UseIsModded = true;
}
void SetMinPlayersFilter( int min_players )
{
m_MinPlayers = min_players;
m_UseMinPlayers = true;
}
void SetMaxPlayersFilter( int max_players )
{
m_MaxPlayers = max_players;
m_UseMaxPlayers = true;
}
void SetIsPasswordProtectedFilter( bool password_protected )
{
m_IsPasswordProtected = password_protected;
m_UseIsPasswordProtected = true;
}
void SetRegionIdFilter( int region )
{
m_RegionId = region;
m_UseRegionId = true;
}
void SetPriorityFilter( int priority )
{
m_Priority = priority;
m_UsePriority = true;
}
void SetFreeSlotsMin( int freeSlotsMin )
{
m_FreeSlotsMin = freeSlotsMin;
m_UseFreeSlotsMin = true;
}
void SetFreeSlotsMax( int freeSlotsMax )
{
m_FreeSlotsMax = freeSlotsMax;
m_UseFreeSlotsMax = true;
}
void SetHostIp( string hostIp )
{
m_HostIp = hostIp;
m_UseHostIp = true;
}
void SetHostPort( int hostPort )
{
m_HostPort = hostPort;
m_UseHostPort = true;
}
void SetMouseAndKeyboardEnabled(bool enabledMouseAndKeyboard)
{
m_MouseAndKeyboardEnabled = enabledMouseAndKeyboard;
m_UseMouseAndKeyboardEnabled = true;
}
void SetFavorited( bool show )
{
m_SortBy += "F";
AddShow( show );
}
void SetFriendsPlaying( bool show )
{
m_SortBy += "P";
AddShow( show );
}
void SetPreviouslyPlayed( bool show )
{
m_SortBy += "R";
AddShow( show );
}
void SetProperVersionMatch( bool show )
{
m_SortBy += "V";
AddShow( show );
}
void SetFullServer( bool show )
{
m_SortBy += "S";
AddShow( show );
}
void SetThirdPerson( bool show )
{
m_SortBy += "3";
AddShow( show );
}
void SetPublic( bool show )
{
m_SortBy += "L";
AddShow( show );
}
void SetAcceleratedTime( bool show )
{
m_SortBy += "A";
AddShow( show );
}
void SetAllowedFilePatching( bool show )
{
m_SortBy += "7";
AddShow( show );
}
void SetLAN()
{
m_SortBy += "N";
}
void SetPingFilter( int pingMaxValue )
{
m_SortBy += "M" + pingMaxValue + ";";
}
void SetBattleyeProtection(bool show)
{
m_SortBy += "B";
AddShow(show);
}
void SetPassworded(bool show)
{
m_SortBy += "C";
AddShow(show);
}
void AddShow( bool show )
{
if( show )
m_SortBy += "+";
else
m_SortBy += "-";
}
void AddFavourite(string ip, int port)
{
m_FavoriteServers += ip + ";" + port + ";";
}
void SetWhitelistEnabled(bool whitelistEnabled)
{
m_WhitelistEnabled = whitelistEnabled;
m_UseWhitelistEnabled = true;
m_SortBy += "W";
AddShow(whitelistEnabled);
}
void SetIsDLC(bool isDLC)
{
m_IsDLC = isDLC;
m_UseIsDLC = true;
m_SortBy += "D";
AddShow(isDLC);
}
};
class BiosLobbyService
{
//! Query game servers
/*!
The async result is returned in the OnDoneAsync callback.
Expected errors:
BAD_PARAMETER - if atleast one of the permissions is not supported on the current platform,
or atleast one of the input arrays is NULL.
@param inputValues input structure
*/
proto native EBiosError GetServers(GetServersInput inputValues);
//! First 1st free server
/*!
The async result is returned in the OnGetFirstServerWithEmptySlot callback.
*/
proto native EBiosError GetFirstServerWithEmptySlot(GetFirstServerWithEmptySlotInput inputValues);
proto native void AddServerFavorite(string ipAddress, int port, int steamQueryPort);
proto native void RemoveServerFavorite(string ipAddress, int port, int steamQueryPort);
proto native void GetFavoriteServers(TStringArray favServers);
//! Get cached info about favorited servers (ONLY ON WINDOWS)
/*!
@param favServersInfoCache gets populated with data with format: key = Query End Point, value.param1 = Server Name, value.param2 = Connection Port
*/
proto native void GetCachedFavoriteServerInfo(array<ref CachedServerInfo> favServersInfoCache);
//! Async function to retrieve info about mods for specific server (only for PC)
//! @param serverId have to be an id returned by callbacks issued by last call to GetServers
//! if GetServers is used another time the id's must be upated
proto native EBiosError GetServerModList(string serverId);
//! Async callback for GetServers
/*!
@param result_list result object
@param error error indicating success or fail of the async operation.
@param response for debugging - this is the data returned by the server; or an empty string ;)
*/
void OnDoneAsync(GetServersResult result_list, EBiosError error, string response)
{
/*
if (result_list.m_Results != null && result_list.m_Results.Count() > 0)
Print(result_list.m_Results[0].m_TimeOfDay);
*/
OnlineServices.OnLoadServersAsync( result_list, error, response );
}
void OnGetFirstServerWithEmptySlot(GetFirstServerWithEmptySlotResult result_list, EBiosError error)
{
OnlineServices.OnAutoConnectToEmptyServer( result_list, error );
}
//! Async callback for GetServerModList
void OnServerModList(GetServerModListResult result_list, EBiosError error)
{
OnlineServices.OnGetServerModList( result_list, error );
}
};
|