Advertisement
Guest User

TLIGameinstance.cpp

a guest
Apr 7th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. // Copyright (c) 2016 FinalSpark Gamestudios UG (haftungsbeschränkt)
  2.  
  3.  
  4. #define __NETWORKSESSIONTEST_H__
  5.  
  6. #include "TheLostIslandAlpha.h"
  7. #include "TLIGameinstance.h"
  8. #include "Online.h"
  9. #include "OnlineSubsystem.h"
  10. #include "OnlineSubsystemUtils.h"
  11. #include "Engine.h"
  12.  
  13.  
  14. //////////////////////////////////////////////////////////////////
  15. //////////////////////Game Instance Init//////////////////////////
  16. //////////////////////////////////////////////////////////////////
  17.  
  18. void UTLIGameinstance::Init(){
  19.  
  20. if (IsRunningDedicatedServer()){
  21. UE_LOG(LogTemp, Warning, TEXT("Starting The Lost Island Dedicated Server....."));
  22. RegisterServerOnSteam();
  23. }
  24.  
  25. }
  26.  
  27. //////////////////////////////////////////////////////////////////
  28. /////////////////Register Server On Steam/////////////////////////
  29. //////////////////////////////////////////////////////////////////
  30.  
  31. void UTLIGameinstance::RegisterServerOnSteam(){
  32. IOnlineSubsystem* const online_sub = IOnlineSubsystem::Get();
  33. if (online_sub){
  34.  
  35.  
  36. UE_LOG(LogTemp, Log, TEXT("Creating Steam Session ......."));
  37.  
  38. UWorld* World = GetWorld();
  39. IOnlineSessionPtr SessionInt = Online::GetSessionInterface();
  40. if (SessionInt.IsValid()){
  41.  
  42.  
  43. FOnlineSessionSettings Settings;
  44. Settings.NumPublicConnections = 12;
  45. Settings.bShouldAdvertise = true;
  46. Settings.bIsDedicated = true;
  47. Settings.bAllowInvites = true;
  48. Settings.bAllowJoinInProgress = true;
  49. Settings.bIsLANMatch = false;
  50. Settings.bUsesPresence = false;
  51. Settings.bAllowJoinViaPresence = true;
  52. Settings.bAntiCheatProtected = true;
  53. Settings.Set(SETTING_MAPNAME, FString("MP_Game"), EOnlineDataAdvertisementType::ViaOnlineService);
  54. SessionInt->CreateSession(0, TLIHostName, Settings);
  55. return;
  56. }
  57. else{
  58. UE_LOG(LogTemp, Error, TEXT("SessionInterface invalid."));
  59. }
  60.  
  61. }
  62.  
  63. else{
  64. UE_LOG(LogTemp, Error, TEXT("OnlineSubSystem error."));
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement