Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions plugins/OWSPluginUE5/OWSPlugin.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"DocsURL": "https://www.openworldserver.com",
"MarketplaceURL": "",
"SupportURL": "",
"EngineVersion": "5.5.0",
"EngineVersion": "5.7.0",
"CanContainContent": true,
"IsBetaVersion": false,
"Installed": true,
Expand All @@ -25,10 +25,6 @@
{
"Name": "GameplayAbilities",
"Enabled": true
},
{
"Name": "ReplicationGraph",
"Enabled": true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void AOWSAdvancedProjectile::OnRep_Instigator()
//InstigatorTeamNum = GetTeamNum(); // this checks Instigator first

InstigatorController = GetInstigator()->Controller;
if (Cast<AOWSCharacterWithAbilities>(GetInstigator()))
if (Cast<AOWSAdvancedProjectile>(GetInstigator()))
{
((AOWSCharacterWithAbilities*)(GetInstigator()))->LastFiredProjectile = this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void UOWSCharacterMovementComponent::OnMovementUpdated(float DeltaTime, const FV
APlayerController* OurPlayerController = Cast<APlayerController>(CharacterOwner->GetController());
if (OurPlayerController)
{
OurPlayerController->SetDeprecatedInputYawScale(0.f);
//OurPlayerController->SetDeprecatedInputYawScale(0.f);
}
}

Expand All @@ -169,7 +169,7 @@ void UOWSCharacterMovementComponent::OnMovementUpdated(float DeltaTime, const FV
APlayerController* OurPlayerController = Cast<APlayerController>(CharacterOwner->GetController());
if (OurPlayerController)
{
OurPlayerController->SetDeprecatedInputYawScale(1.f);
//OurPlayerController->SetDeprecatedInputYawScale(1.f);
}

bUseControllerDesiredRotation = true;
Expand Down Expand Up @@ -586,7 +586,7 @@ void UOWSCharacterMovementComponent::ProcessLanded(const FHitResult& Hit, float

if (OurPlayerController)
{
OurPlayerController->SetDeprecatedInputYawScale(1.f);
//OurPlayerController->SetDeprecatedInputYawScale(1.f);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,24 @@ FString UOWSGameInstance::SerializeStructToJSONString(const UStruct* StructToSer

UClass* UOWSGameInstance::FindClass(FString ClassName) const
{
UObject* ClassPackage = ANY_PACKAGE;
UClass* Result = FindObject<UClass>(ClassPackage, *ClassName);
if (ClassName.IsEmpty())
{
return nullptr;
}

return Result;
UClass* FoundClass = FindFirstObject<UClass>(*ClassName);
return IsValid(FoundClass) ? FoundClass : nullptr;
}

//This only works if the ability is already in memory. Use LoadGameplayAbilityClass instead
TSubclassOf<UGameplayAbility> UOWSGameInstance::FindGameplayAbilityClass(FString ClassName) const
{
UObject* ClassPackage = ANY_PACKAGE;
UClass* Result = FindObject<UClass>(ClassPackage, *ClassName);
UClass* FoundClass = FindFirstObject<UClass>(*ClassName);

TSubclassOf<UGameplayAbility> GameplayAbilityClass = Result;
TSubclassOf<UGameplayAbility> GameplayAbilityClass = FoundClass;

if (GameplayAbilityClass)
return Result;
return FoundClass;
else
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,6 @@ AOWSPlayerState* AOWSPlayerController::GetOWSPlayerState() const
return GetPlayerState<AOWSPlayerState>();
}

bool AOWSPlayerController::InputAxis(FKey Key, float Delta, float DeltaTime, int32 NumSamples, bool bGamepad)
{
bool bResult = false;

if (PlayerInput)
{
bResult = PlayerInput->InputKey(FInputKeyParams(Key, Delta, DeltaTime, NumSamples, bGamepad));
}

return bResult;
}

void AOWSPlayerController::SavePlayerLocation()
{
OWSPlayerControllerComponent->SavePlayerLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ class OWSPLUGIN_API AOWSPlayerController : public APlayerController

void PawnLeavingGame();

//bool InputKey(FKey Key, EInputEvent EventType, float AmountDepressed, bool bGamepad) override;
bool InputAxis(FKey Key, float Delta, float DeltaTime, int32 NumSamples, bool bGamepad) override;

UFUNCTION(BlueprintImplementableEvent, Category = "Save")
void NotifyPawnLeavingGame(const AOWSCharacter* RPGCharacter);

Expand Down
2 changes: 1 addition & 1 deletion src/.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ DATABASE_PASSWORD='yourStrong(!)Password'
# MSSQL
# DATABASE_CONNECTION_STRING="Server=host.docker.internal;Database=OpenWorldServer;User Id=SA;Password=${DATABASE_PASSWORD};ConnectRetryCount=0"
# Postgres
DATABASE_CONNECTION_STRING="Host=host.docker.internal;Port=15432;Database=openworldserver;Username=postgres;Password=${DATABASE_PASSWORD};"
DATABASE_CONNECTION_STRING="Host=host.docker.internal;Port=15432;Database=openworldserver;Username=postgres;Password=${DATABASE_PASSWORD};Maximum Pool Size=6;"
# Mysql
# DATABASE_CONNECTION_STRING="server=host.docker.internal;user=root;database=openworldserver;port=3306;password=${DATABASE_PASSWORD};Allow User Variables=True;SslMode=None"

Expand Down
15 changes: 9 additions & 6 deletions src/OWSCharacterPersistence/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,23 @@ private void InitializeContainer(IServiceCollection services)
if (OWSStorageConfig.Exists())
{
string dbBackend = OWSStorageConfig.GetValue<string>("OWSDBBackend");
string connectionString = OWSStorageConfig.GetValue<string>("OWSDBConnectionString");
string connectionStringWithApplicationName = $"{connectionString}Application Name=OWS Character Persistence;";
OWSStorageConfig["OWSDBConnectionString"] = connectionStringWithApplicationName;

switch (dbBackend)
{
case "postgres":
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.Postgres.CharactersRepository>(Lifestyle.Singleton);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.Postgres.UsersRepository>(Lifestyle.Singleton);
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.Postgres.CharactersRepository>(Lifestyle.Scoped);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.Postgres.UsersRepository>(Lifestyle.Scoped);
break;
case "mysql":
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.MySQL.CharactersRepository>(Lifestyle.Singleton);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.MySQL.UsersRepository>(Lifestyle.Singleton);
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.MySQL.CharactersRepository>(Lifestyle.Scoped);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.MySQL.UsersRepository>(Lifestyle.Scoped);
break;
default: // Default to MSSQL
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.MSSQL.CharactersRepository>(Lifestyle.Singleton);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.MSSQL.UsersRepository>(Lifestyle.Singleton);
container.Register<ICharactersRepository, OWSData.Repositories.Implementations.MSSQL.CharactersRepository>(Lifestyle.Scoped);
container.Register<IUsersRepository, OWSData.Repositories.Implementations.MSSQL.UsersRepository>(Lifestyle.Scoped);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public async Task<MapInstances> CheckMapInstanceStatus(Guid customerGUID, int ma
}
}

public async Task CleanUpInstances(Guid customerGUID)
public async Task CleanUpInstances(Guid customerGuid)
{
using (var connection = (NpgsqlConnection)Connection)
{
Expand All @@ -151,7 +151,7 @@ public async Task CleanUpInstances(Guid customerGUID)
try
{
var parameters = new DynamicParameters();
parameters.Add("@CustomerGUID", customerGUID);
parameters.Add("@CustomerGUID", customerGuid);
parameters.Add("@CharacterMinutes", 1); // TODO Add Configuration Parameter
parameters.Add("@MapMinutes", 2); // TODO Add Configuration Parameter

Expand Down Expand Up @@ -180,6 +180,10 @@ await transaction.ExecuteAsync(PostgresQueries.RemoveMapInstances,

transaction.Commit();
}
catch (NpgsqlException ex)
{
Console.WriteLine($"Error opening PostgreSQL connection: {ex.Message}");
}
catch
{
transaction.Rollback();
Expand Down Expand Up @@ -358,12 +362,24 @@ public async Task<JoinMapByCharName> JoinMapByCharName(Guid customerGUID, string
{
MapInstances outputMapInstance = await SpinUpInstance(customerGUID, zoneName, outputPlayerGroup.PlayerGroupId);

if (outputMapInstance.WorldServerId < 1)
{
Console.WriteLine("Failed to spin up Server Instance!");
return outputObject;
}

parameters.Add("@WorldServerId", outputMapInstance.WorldServerId);

WorldServers outputWorldServers = await connection.QuerySingleOrDefaultAsync<WorldServers>(GenericQueries.GetWorldByID,
parameters,
commandType: CommandType.Text);

if (outputWorldServers == null)
{
Console.WriteLine($"Failed to find Server Instance for World ServerId: {outputMapInstance.WorldServerId}");
return outputObject;
}

outputObject.NeedToStartupMap = true;
outputObject.WorldServerID = outputMapInstance.WorldServerId;
outputObject.ServerIP = outputWorldServers.ServerIp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,28 @@ public async Task AddOrUpdateGlobalData(GlobalData globalData)
{
using (var connection = (NpgsqlConnection)Connection)
{
var outputGlobalData = await connection.QuerySingleOrDefaultAsync<GlobalData>(GenericQueries.GetGlobalDataByGlobalDataKey,
globalData,
commandType: CommandType.Text);

if (outputGlobalData != null)
try
{
await connection.ExecuteAsync(GenericQueries.UpdateGlobalData,
var outputGlobalData = await connection.QuerySingleOrDefaultAsync<GlobalData>(GenericQueries.GetGlobalDataByGlobalDataKey,
globalData,
commandType: CommandType.Text);

if (outputGlobalData != null)
{
await connection.ExecuteAsync(GenericQueries.UpdateGlobalData,
globalData,
commandType: CommandType.Text);
}
else
{
await connection.ExecuteAsync(GenericQueries.AddGlobalData,
globalData,
commandType: CommandType.Text);
}
}
else
catch (Exception ex)
{
await connection.ExecuteAsync(GenericQueries.AddGlobalData,
globalData,
commandType: CommandType.Text);
Console.WriteLine($"AddOrUpdateGlobalData Error: {ex.Message}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,53 +171,61 @@ public async Task<int> StartWorldServer(Guid customerGUID, string launcherGuid)

using (var connection = (NpgsqlConnection)Connection)
{
var parameters = new {
CustomerGUID = customerGUID,
ZoneServerGUID = launcherGuid
};

GetWorldServerID getWorldServerID = await connection.QueryFirstOrDefaultAsync<GetWorldServerID>(PostgresQueries.GetWorldServerSQL, parameters);

if (getWorldServerID != null)
{
worldServerId = getWorldServerID.WorldServerID;
}

if (worldServerId > 0)
try
{
var parameters2 = new {
var parameters = new
{
CustomerGUID = customerGUID,
WorldServerID = worldServerId
ZoneServerGUID = launcherGuid
};

await connection.ExecuteAsync(PostgresQueries.UpdateWorldServerSQL, parameters2);
GetWorldServerID getWorldServerID = await connection.QueryFirstOrDefaultAsync<GetWorldServerID>(PostgresQueries.GetWorldServerSQL, parameters);

if (getWorldServerID != null)
{
worldServerId = getWorldServerID.WorldServerID;
}

if (worldServerId > 0)
{
var parameters2 = new
{
CustomerGUID = customerGUID,
WorldServerID = worldServerId
};

await connection.ExecuteAsync(PostgresQueries.UpdateWorldServerSQL, parameters2);
}
}
catch (Exception ex)
{
Console.WriteLine($"StartWorldServer error: {ex.Message}");
return -1;
}
}

return worldServerId;
}

public async Task<SuccessAndErrorMessage> UpdateNumberOfPlayers(Guid customerGUID, int zoneInstanceId, int numberOfPlayers)
public async Task<SuccessAndErrorMessage> UpdateNumberOfPlayers(Guid customerGuid, int zoneInstanceId, int numberOfPlayers)
{
using (var connection = (NpgsqlConnection)Connection)
{
var paremeters = new
{
CustomerGUID = customerGUID,
CustomerGUID = customerGuid,
ZoneInstanceID = zoneInstanceId,
NumberOfReportedPlayers = numberOfPlayers
};

_ = await connection.ExecuteAsync(PostgresQueries.UpdateNumberOfPlayersSQL, paremeters);
}

SuccessAndErrorMessage output = new SuccessAndErrorMessage()
return new SuccessAndErrorMessage()
{
Success = true,
ErrorMessage = ""
};

return output;
}

public async Task<IEnumerable<GetZoneInstancesForZone>> GetZoneInstancesOfZone(Guid customerGUID, string ZoneName)
Expand Down
Loading
Loading