Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianTerhorst committed Jun 12, 2019
1 parent 46ee0c9 commit 3187c6c
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 1 deletion.
17 changes: 17 additions & 0 deletions api/AltV.Net.ColShape/AltV.Net.ColShape.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
<None Include="license\license.txt" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AltV.Net\AltV.Net.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions api/AltV.Net.ColShape/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace AltV.Net.ColShape
{
public class Class1
{
}
}
7 changes: 7 additions & 0 deletions api/AltV.Net.ColShape/ColShape.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace AltV.Net.ColShape
{
public struct ColShape
{
public ulong Id;
}
}
78 changes: 78 additions & 0 deletions api/AltV.Net.ColShape/ColShapeModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Threading;
using AltV.Net.Data;
using AltV.Net.Elements.Entities;

namespace AltV.Net.ColShape
{
/// <summary>
/// Requires a lock in entity pool, so probably always requires async
/// </summary>
public class ColShapeModule
{
//TODO: just round up always when inserting col shapes then it can't happen,
//TODO: btw for large colshapes we need to put same colshape in multiple areas because it can be bigger then the area

//TODO: col shape with size <= 100 size will always be in at least all border areas

//TODO: colshape with n = size / 100 will be in all n border areas around the calculated area

//TODO: when x = size / 100 and n > 1 then 1 is x instead of e.g. +1 x times in a increasing 4-edge circle with the radius of size / 100

//TODO: border areas are when index is (m, n) {(m, n), (m+1, n), (m-1, n), (m, n+1), (m, n-1), (m+1, n+1), (m+1, n-1), (m-1, n+1), (m-1, n-1)}

// To reduce gc work
private List<IPlayer> players;
private IPlayer curr;
private Position pos;

// z doesn't matter, we put all z values in same

// x-index, y-index, col shapes
private ColShape[][][] colShapeAreas;

public ColShapeModule()
{
var thread = new Thread(Loop)
{
IsBackground = true
};
thread.Start();
}

private void Loop()
{
players = new List<IPlayer>(Alt.GetAllPlayers());
for (int i = 0, length = players.Count; i < length; i++)
{
curr = players[i];
lock (curr)
{
if (!curr.Exists) continue;
pos = curr.Position;
}

var xIndex = (int) Math.Ceiling(pos.X) / 100;

var currXIndexArr = colShapeAreas[xIndex];

if (currXIndexArr == null) continue;

var yIndex = (int) Math.Ceiling(pos.Y) / 100;

var curryYIndexArr = currXIndexArr[yIndex];

if (curryYIndexArr == null) continue;

for (int j = 0, innerLength = curryYIndexArr.Length; j < innerLength; j++)
{

}

//TODO: now hash pos in fragments of map areas and create matrix of col shape lists for map areas
//100x100 is one area we create them when creating a col shape
}
}
}
}
21 changes: 21 additions & 0 deletions api/AltV.Net.ColShape/license/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 alt:mp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions api/AltV.Net.NetworkingEntity/AltNetworking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
namespace AltV.Net.NetworkingEntity
{
// TODO: We don't trigger stream out in entity remove because client can calculate that himself

//TODO: make streaming handler depending on entity if streamed to all players or only the players that are in range
//TODO: so that server calculates stream in, out for entities that shouldn't be send to all players that aren't in range
//TODO: that information does only the server need because it will send the entity to the client when in range with all data or snapshot cache

//TODO: make it possible to set if server should even be notified when enter stream in ,out like we know no data will ever change so no need to spam server with that entity
public static class AltNetworking
{
internal static NetworkingModule Module;
Expand Down
8 changes: 8 additions & 0 deletions api/AltV.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.NetworkingEntity",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.Networking.Example", "AltV.Net.Networking.Example\AltV.Net.Networking.Example.csproj", "{D3729770-8807-41D6-8D8D-8E984FA74B1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.ColShape", "AltV.Net.ColShape\AltV.Net.ColShape.csproj", "{E4376702-6BBF-4275-AE38-0C762C28BE05}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -79,5 +81,11 @@ Global
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Release|Any CPU.Build.0 = Release|Any CPU
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Testing|Any CPU.ActiveCfg = Debug|Any CPU
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Testing|Any CPU.Build.0 = Debug|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Release|Any CPU.Build.0 = Release|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Testing|Any CPU.ActiveCfg = Debug|Any CPU
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Testing|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion runtime/linux-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cmake -B"cmake-build-linux" -DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=leak -g" -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -g" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" -DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak"
cmake -B"cmake-build-linux"
cd cmake-build-linux
make

0 comments on commit 3187c6c

Please sign in to comment.