Skip to content
Open
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
24 changes: 12 additions & 12 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
*.sln merge=binary
*.csproj merge=binary
*.vbproj merge=binary
*.vcxproj merge=binary
*.vcproj merge=binary
*.dbproj merge=binary
*.fsproj merge=binary
*.lsproj merge=binary
*.wixproj merge=binary
*.modelproj merge=binary
*.sqlproj merge=binary
*.wwaproj merge=binary

###############################################################################
# behavior for image files
Expand Down
13 changes: 8 additions & 5 deletions Feature/RaceSystem/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -30,15 +30,18 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Client, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\RS\RaceSystem\packages\CitizenFX.Core.Client.1.0.1188\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<HintPath>..\..\..\packages\CitizenFX.Core.Client.1.0.1188\lib\net45\CitizenFX.Core.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MenuAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\MenuAPI.dll</HintPath>
<Reference Include="MenuAPI">
<HintPath>..\..\..\lib\client\MenuAPI.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\lib\shared\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
26 changes: 25 additions & 1 deletion Feature/RaceSystem/Client/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

using Newtonsoft.Json;

using CitizenFX.Core;
using CitizenFX.Core.Native;
using CitizenFX.Core.NaturalMotion;
Expand All @@ -24,6 +27,16 @@ public class Main : BaseScript

private int creatorIndex = -1;
private List<Vector3> creatorCheckpointPos;
/// <summary>
/// creatorCheckpointPos:JsonFormat
/// </summary>
private string creatorCheckpointPosJson
{
get
{
return JsonConvert.SerializeObject(creatorCheckpointPos);
}
}
private List<int> creatorBlips;
private List<int> creatorCheckpoints;

Expand All @@ -49,13 +62,23 @@ public Main()
API.RegisterCommand("race", new Action<int, List<object>, string>(RaceCommand), false);
EventHandlers["rs:Received"] += new Action<string>(Received);
EventHandlers["rs:SetRaces"] += new Action<List<Dictionary<string, string>>>(SetRaces);
EventHandlers["rs:SetRacesJson"] += new Action<string>(SetRacesJson);
}

private void SetRaces(List<Dictionary<string, string>> races)
{
mainMenu.SetRaces(races);
}

/// <summary>
/// Set races as json format
/// </summary>
/// <param name="racesAsJson"></param>
private void SetRacesJson(string racesAsJson)
{
mainMenu.SetRacesJson(racesAsJson);
}

private void Received(string resp)
{
response = resp;
Expand Down Expand Up @@ -209,7 +232,8 @@ private async Task CheckSave()
if (mainMenu.requestSave)
{
mainMenu.requestSave = false;
TriggerServerEvent("rs:SaveRace", mainMenu.raceName, creatorCheckpointPos);
TriggerServerEvent("rs:SaveRaceJson", mainMenu.raceName, creatorCheckpointPosJson);
//TriggerServerEvent("rs:SaveRace", mainMenu.raceName, creatorCheckpointPos);
while (!isReceived)
{
await Delay(100);
Expand Down
16 changes: 15 additions & 1 deletion Feature/RaceSystem/Client/Menus/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Newtonsoft.Json;

using CitizenFX.Core;
using MenuAPI;

Expand Down Expand Up @@ -38,6 +41,16 @@ public void SetRaces(List<Dictionary<string, string>> races)
raceSelectionMenu.GetMenu().RefreshIndex();
}

/// <summary>
/// Set races from json format
/// </summary>
/// <param name="racesAsJson"></param>
public void SetRacesJson(string racesAsJson)
{
var races = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(racesAsJson);
SetRaces(races);
}

private void CreateMenu()
{
// Menu align with left side
Expand Down Expand Up @@ -73,7 +86,8 @@ private void CreateMenu()
menu.CloseMenu();

if(_item.Text == "Start Race")
BaseScript.TriggerServerEvent("rs:GetRaces");
//BaseScript.TriggerServerEvent("rs:GetRaces");
BaseScript.TriggerServerEvent("rs:GetRacesJson");
};
}
}
Expand Down
24 changes: 24 additions & 0 deletions Feature/RaceSystem/Server/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using ServiceStack.OrmLite;
using ServiceStack.Text.Common;

using Newtonsoft.Json;

namespace Server
{
public class Database
Expand Down Expand Up @@ -134,5 +136,27 @@ public List<Dictionary<string, string>> GetRaces()

return results;
}

/// <summary>
/// Insert race from json format
/// </summary>
/// <param name="_name"></param>
/// <param name="_author"></param>
/// <param name="posAsJson"></param>
/// <returns></returns>
public bool InsertRaceJson(string _name, string _author, string posAsJson)
{
var pos = JsonConvert.DeserializeObject<List<Vector3>>(posAsJson);
return InsertRace(_name, _author, pos);
}

/// <summary>
/// ����Json��ʽ��Races��Ϣ
/// </summary>
/// <returns></returns>
public string GetRacesJson()
{
return JsonConvert.SerializeObject(GetRaces());
}
}
}
27 changes: 27 additions & 0 deletions Feature/RaceSystem/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Text;
using System.Threading.Tasks;

using Newtonsoft.Json;

using CitizenFX.Core;

namespace Server
Expand All @@ -19,7 +21,9 @@ public Main()
{
db = new Database();
EventHandlers["rs:SaveRace"] += new Action<Player, string, List<Vector3>>(SaveRace);
EventHandlers["rs:SaveRaceJson"] += new Action<Player, string, string>(SaveRaceJson);
EventHandlers["rs:GetRaces"] += new Action<Player>(GetRaces);
EventHandlers["rs:GetRacesJson"] += new Action<Player>(GetRacesJson);
}

private void SaveRace([FromSource] Player source, string name, List<Vector3> pos)
Expand All @@ -29,10 +33,33 @@ private void SaveRace([FromSource] Player source, string name, List<Vector3> pos
TriggerClientEvent(source, "rs:Received", response);
}

/// <summary>
/// Save race from json format
/// </summary>
/// <param name="source"></param>
/// <param name="name"></param>
/// <param name="posAsJson"></param>
private void SaveRaceJson([FromSource] Player source, string name, string posAsJson)
{
bool result = db.InsertRaceJson(name, source.Name, posAsJson);
string response = result ? "OK" : "Bad";
TriggerClientEvent(source, "rs:Received", response);
}

private void GetRaces([FromSource] Player source)
{
TriggerClientEvent(source, "rs:SetRaces", db.GetRaces());
}

/// <summary>
/// Get races as json format
/// </summary>
/// <param name="source"></param>
private void GetRacesJson([FromSource]Player source)
{
TriggerClientEvent(source, "rs:SetRacesJson", db.GetRacesJson());
}

}

}
34 changes: 18 additions & 16 deletions Feature/RaceSystem/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -30,53 +30,56 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="CitizenFX.Core.Server, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\RS\RaceSystem\packages\CitizenFX.Core.Server.1.0.1188\lib\net45\CitizenFX.Core.Server.dll</HintPath>
<HintPath>..\..\..\packages\CitizenFX.Core.Server.1.0.1188\lib\net45\CitizenFX.Core.Server.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\wl-playground-imckl\src\Lib\Shared\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587">
<HintPath>..\..\..\RS\RaceSystem\packages\ServiceStack.Common.5.5.0\lib\net45\ServiceStack.Common.dll</HintPath>
<HintPath>..\..\..\packages\ServiceStack.Common.5.5.0\lib\net45\ServiceStack.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587">
<HintPath>..\..\..\RS\RaceSystem\packages\ServiceStack.Interfaces.5.5.0\lib\net45\ServiceStack.Interfaces.dll</HintPath>
<HintPath>..\..\..\packages\ServiceStack.Interfaces.5.5.0\lib\net45\ServiceStack.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.OrmLite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587">
<HintPath>..\..\..\RS\RaceSystem\packages\ServiceStack.OrmLite.5.5.0\lib\net45\ServiceStack.OrmLite.dll</HintPath>
<HintPath>..\..\..\packages\ServiceStack.OrmLite.5.5.0\lib\net45\ServiceStack.OrmLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.OrmLite.Sqlite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587">
<HintPath>..\..\..\RS\RaceSystem\packages\ServiceStack.OrmLite.Sqlite.5.5.0\lib\net45\ServiceStack.OrmLite.Sqlite.dll</HintPath>
<Reference Include="ServiceStack.OrmLite.Sqlite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\ServiceStack.OrmLite.Sqlite.5.5.0\lib\net45\ServiceStack.OrmLite.Sqlite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ServiceStack.Text, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587">
<HintPath>..\..\..\RS\RaceSystem\packages\ServiceStack.Text.5.5.0\lib\net45\ServiceStack.Text.dll</HintPath>
<HintPath>..\..\..\packages\ServiceStack.Text.5.5.0\lib\net45\ServiceStack.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\..\..\RS\RaceSystem\packages\System.Buffers.4.5.0\lib\netstandard1.1\System.Buffers.dll</HintPath>
<HintPath>..\..\..\packages\System.Buffers.4.5.0\lib\netstandard1.1\System.Buffers.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139">
<HintPath>..\..\..\RS\RaceSystem\packages\System.Data.SQLite.Core.1.0.110.0\lib\net451\System.Data.SQLite.dll</HintPath>
<HintPath>..\..\..\packages\System.Data.SQLite.Core.1.0.110.0\lib\net451\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\..\..\RS\RaceSystem\packages\System.Memory.4.5.2\lib\netstandard1.1\System.Memory.dll</HintPath>
<HintPath>..\..\..\packages\System.Memory.4.5.2\lib\netstandard1.1\System.Memory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\..\..\RS\RaceSystem\packages\System.Runtime.CompilerServices.Unsafe.4.6.0-preview3.19128.7\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.6.0-preview3.19128.7\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading" />
Expand All @@ -94,15 +97,14 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\RS\RaceSystem\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\..\RS\RaceSystem\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets')" />
<Import Project="..\..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\RS\RaceSystem\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\RS\RaceSystem\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets'))" />
<Error Condition="!Exists('..\..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net451\System.Data.SQLite.Core.targets'))" />
</Target>
</Project>
Binary file added lib/shared/Newtonsoft.Json.dll
Binary file not shown.
Binary file added lib/shared/System.Numerics.dll
Binary file not shown.
8 changes: 6 additions & 2 deletions src.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio 15
VisualStudioVersion = 15.0.28307.539
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mission", "Mission", "{5D5A822B-AF58-42A1-8E81-D50C819AD7AA}"
EndProject
Expand Down Expand Up @@ -29,6 +29,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client", "client", "{97C687
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{71569242-6268-4E47-A8C8-D5DFA97814A5}"
ProjectSection(SolutionItems) = preProject
lib\shared\Newtonsoft.Json.dll = lib\shared\Newtonsoft.Json.dll
lib\shared\System.Numerics.dll = lib\shared\System.Numerics.dll
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "server", "server", "{FE3580A3-1109-4145-8537-3E2856826EE7}"
ProjectSection(SolutionItems) = preProject
Expand Down