-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46ee0c9
commit 3187c6c
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace AltV.Net.ColShape | ||
{ | ||
public class Class1 | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace AltV.Net.ColShape | ||
{ | ||
public struct ColShape | ||
{ | ||
public ulong Id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |