Skip to content

Commit 3187c6c

Browse files
update
1 parent 46ee0c9 commit 3187c6c

File tree

8 files changed

+146
-1
lines changed

8 files changed

+146
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<Platforms>AnyCPU</Platforms>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<None Include="license\license.txt" Pack="true" PackagePath="" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\AltV.Net\AltV.Net.csproj" />
15+
</ItemGroup>
16+
17+
</Project>

api/AltV.Net.ColShape/Class1.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace AltV.Net.ColShape
4+
{
5+
public class Class1
6+
{
7+
}
8+
}

api/AltV.Net.ColShape/ColShape.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace AltV.Net.ColShape
2+
{
3+
public struct ColShape
4+
{
5+
public ulong Id;
6+
}
7+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading;
4+
using AltV.Net.Data;
5+
using AltV.Net.Elements.Entities;
6+
7+
namespace AltV.Net.ColShape
8+
{
9+
/// <summary>
10+
/// Requires a lock in entity pool, so probably always requires async
11+
/// </summary>
12+
public class ColShapeModule
13+
{
14+
//TODO: just round up always when inserting col shapes then it can't happen,
15+
//TODO: btw for large colshapes we need to put same colshape in multiple areas because it can be bigger then the area
16+
17+
//TODO: col shape with size <= 100 size will always be in at least all border areas
18+
19+
//TODO: colshape with n = size / 100 will be in all n border areas around the calculated area
20+
21+
//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
22+
23+
//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)}
24+
25+
// To reduce gc work
26+
private List<IPlayer> players;
27+
private IPlayer curr;
28+
private Position pos;
29+
30+
// z doesn't matter, we put all z values in same
31+
32+
// x-index, y-index, col shapes
33+
private ColShape[][][] colShapeAreas;
34+
35+
public ColShapeModule()
36+
{
37+
var thread = new Thread(Loop)
38+
{
39+
IsBackground = true
40+
};
41+
thread.Start();
42+
}
43+
44+
private void Loop()
45+
{
46+
players = new List<IPlayer>(Alt.GetAllPlayers());
47+
for (int i = 0, length = players.Count; i < length; i++)
48+
{
49+
curr = players[i];
50+
lock (curr)
51+
{
52+
if (!curr.Exists) continue;
53+
pos = curr.Position;
54+
}
55+
56+
var xIndex = (int) Math.Ceiling(pos.X) / 100;
57+
58+
var currXIndexArr = colShapeAreas[xIndex];
59+
60+
if (currXIndexArr == null) continue;
61+
62+
var yIndex = (int) Math.Ceiling(pos.Y) / 100;
63+
64+
var curryYIndexArr = currXIndexArr[yIndex];
65+
66+
if (curryYIndexArr == null) continue;
67+
68+
for (int j = 0, innerLength = curryYIndexArr.Length; j < innerLength; j++)
69+
{
70+
71+
}
72+
73+
//TODO: now hash pos in fragments of map areas and create matrix of col shape lists for map areas
74+
//100x100 is one area we create them when creating a col shape
75+
}
76+
}
77+
}
78+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 alt:mp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

api/AltV.Net.NetworkingEntity/AltNetworking.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
namespace AltV.Net.NetworkingEntity
77
{
88
// TODO: We don't trigger stream out in entity remove because client can calculate that himself
9+
10+
//TODO: make streaming handler depending on entity if streamed to all players or only the players that are in range
11+
//TODO: so that server calculates stream in, out for entities that shouldn't be send to all players that aren't in range
12+
//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
13+
14+
//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
915
public static class AltNetworking
1016
{
1117
internal static NetworkingModule Module;

api/AltV.Net.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.NetworkingEntity",
1818
EndProject
1919
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.Networking.Example", "AltV.Net.Networking.Example\AltV.Net.Networking.Example.csproj", "{D3729770-8807-41D6-8D8D-8E984FA74B1B}"
2020
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net.ColShape", "AltV.Net.ColShape\AltV.Net.ColShape.csproj", "{E4376702-6BBF-4275-AE38-0C762C28BE05}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|Any CPU = Debug|Any CPU
@@ -79,5 +81,11 @@ Global
7981
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Release|Any CPU.Build.0 = Release|Any CPU
8082
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Testing|Any CPU.ActiveCfg = Debug|Any CPU
8183
{D3729770-8807-41D6-8D8D-8E984FA74B1B}.Testing|Any CPU.Build.0 = Debug|Any CPU
84+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Release|Any CPU.ActiveCfg = Release|Any CPU
87+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Release|Any CPU.Build.0 = Release|Any CPU
88+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Testing|Any CPU.ActiveCfg = Debug|Any CPU
89+
{E4376702-6BBF-4275-AE38-0C762C28BE05}.Testing|Any CPU.Build.0 = Debug|Any CPU
8290
EndGlobalSection
8391
EndGlobal

runtime/linux-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
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"
1+
cmake -B"cmake-build-linux"
22
cd cmake-build-linux
33
make

0 commit comments

Comments
 (0)