mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Added all raknet headers for full raknet support Added Testclass "TestCB.cpp" which is a test implementation for raknet plugin "File List Transfer". We will use this plugin for file transfer in multiplayer git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2638 3b4a5df2-a311-0410-b5c6-a8a6f20db521
69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
#ifndef _GRID_SECTORIZER_H
|
|
#define _GRID_SECTORIZER_H
|
|
|
|
//#define _USE_ORDERED_LIST
|
|
|
|
#include "RakMemoryOverride.h"
|
|
|
|
#ifdef _USE_ORDERED_LIST
|
|
#include "DS_OrderedList.h"
|
|
#else
|
|
#include "DS_List.h"
|
|
#endif
|
|
|
|
class GridSectorizer
|
|
{
|
|
public:
|
|
GridSectorizer();
|
|
~GridSectorizer();
|
|
|
|
// _cellWidth, _cellHeight is the width and height of each cell in world units
|
|
// minX, minY, maxX, maxY are the world dimensions (can be changed to dynamically allocate later if needed)
|
|
void Init(const float _maxCellWidth, const float _maxCellHeight, const float minX, const float minY, const float maxX, const float maxY);
|
|
|
|
// Adds a pointer to the grid with bounding rectangle dimensions
|
|
void AddEntry(void *entry, const float minX, const float minY, const float maxX, const float maxY);
|
|
|
|
#ifdef _USE_ORDERED_LIST
|
|
|
|
// Removes a pointer, as above
|
|
void RemoveEntry(void *entry, const float minX, const float minY, const float maxX, const float maxY);
|
|
|
|
// Adds and removes in one pass, more efficient than calling both functions consecutively
|
|
void MoveEntry(void *entry, const float sourceMinX, const float sourceMinY, const float sourceMaxX, const float sourceMaxY,
|
|
const float destMinX, const float destMinY, const float destMaxX, const float destMaxY);
|
|
|
|
#endif
|
|
|
|
// Adds to intersectionList all entries in a certain radius
|
|
void GetEntries(DataStructures::List<void*>& intersectionList, const float minX, const float minY, const float maxX, const float maxY);
|
|
|
|
void Clear(void);
|
|
|
|
protected:
|
|
int WorldToCellX(const float input) const;
|
|
int WorldToCellY(const float input) const;
|
|
int WorldToCellXOffsetAndClamped(const float input) const;
|
|
int WorldToCellYOffsetAndClamped(const float input) const;
|
|
|
|
// Returns true or false if a position crosses cells in the grid. If false, you don't need to move entries
|
|
bool PositionCrossesCells(const float originX, const float originY, const float destinationX, const float destinationY) const;
|
|
|
|
float cellOriginX, cellOriginY;
|
|
float cellWidth, cellHeight;
|
|
float invCellWidth, invCellHeight;
|
|
float gridWidth, gridHeight;
|
|
int gridCellWidthCount, gridCellHeightCount;
|
|
|
|
|
|
// int gridWidth, gridHeight;
|
|
|
|
#ifdef _USE_ORDERED_LIST
|
|
DataStructures::OrderedList<void*, void*>* grid;
|
|
#else
|
|
DataStructures::List<void*>* grid;
|
|
#endif
|
|
};
|
|
|
|
#endif
|