Skip to content

uhh, basic netdriver listening!! #24

@wiktorwiktor11

Description

@wiktorwiktor11
static bool bPlaylist = false;
static bool bListening = false;

bool (*ReadyToStartMatch)(AFortGameModeAthena*);
bool ReadyToStartMatch(AFortGameModeAthena* GameMode) {
       auto GameState = (AFortGameStateAthena*)UWorld::GetWorld()->GameState;
       if (!GameState || !GameState->MapInfo) return false;
       
       if (!bPlaylist) {
              auto Playlist = UObject::FindObject<UFortPlaylistAthena>("FortPlaylistAthena Playlist_DefaultSolo.Playlist_DefaultSolo");
              if (Playlist) {
              GameState->CurrentPlaylistInfo.BasePlaylist = Playlist;
              GameState->CurrentPlaylistInfo.OverridePlaylist = Playlist;
	      GameState->CurrentPlaylistInfo.MarkArrayDirty();
	      GameState->OnRep_CurrentPlaylistInfo();

	      GameState->CurrentPlaylistId = Playlist->PlaylistId;
	      GameState->OnRep_CurrentPlaylistId();

	      GameMode->CurrentPlaylistName = Playlist->PlaylistName;
	      GameMode->CurrentPlaylistId = Playlist->PlaylistId;
	      GameMode->WarmupRequiredPlayerCount = 1;
              
              bPlaylist = true;
              }
              else {
                   std::cout << "Failed to parse playlist! \n";
                   return false;
              }
       }
       
       if (!bListening) {
       FName DriverName = UKismetStringLibrary::Conv_StringToName(L"GameNetDriver");
       auto Driver = CreateNetDriver(UEngine::GetEngine(), UWorld::GetWorld(), DriverName);
       if (Driver) {
       UWorld::GetWorld()->NetDriver = Driver;
       UWorld::GetWorld()->NetDriver->NetDriverName = DriverName;
       UWorld::GetWorld()->NetDrive->World = UWorld::GetWorld();
       
       FString Error;
       FURL URL;
       URL.Port = 7777;
       
       InitListen(UWorld::GetWorld()->NetDriver, nullptr,  URL, false,  Error);
       SetWorld(UWorld::GetWorld(), UWorld::GetWorld()->NetDriver);
       
       auto LevelCollections = UWorld::GetWorld()->LevelCollections;
       for (auto Collection : LevelCollections) {
             Collection.NetDriver = UWorld::GetWorld()->NetDriver;
       }
       
           GameMode->bWorldIsReady = true;
       }
       
       return ReadyToStartMatchOG(GameMode);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions