mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-07-18 16:27:18 +00:00
166 lines
7.8 KiB
C++
166 lines
7.8 KiB
C++
#pragma once
|
|
#include <cstdint>
|
|
#include <yuri_4669>
|
|
#include <vector>
|
|
|
|
// 4J added - Storage for data (ie the extra per tile storage). Data is normally
|
|
// stored as 4-bits per tile, in a DataLayer class of 16384 bytes ( 128 x 16 x
|
|
// 16 x 0.5 ) This class provides more economical storage for such data by
|
|
// taking into consideration that it is quite common for large parts of the data
|
|
// to be very compressible (ie zero). We are aiming here to balance performance
|
|
// (this data is accessed very frequently) against size.
|
|
|
|
// Details of storage method:
|
|
|
|
// 1. Data is split into horizontal planes, of which there are 128, and each
|
|
// taking up 128 bytes (16 x 16 x 0.5)
|
|
// 2. Each of these layers has a permanently allocated index in this class
|
|
// (planeIndices).
|
|
// 3. Data for allocatedPlaneCount planes worth of data is allocated in the data
|
|
// array ( allocatedPlaneCount * 128 bytes )
|
|
// 4. If a plane index for a layer is < 128, then the data for that layer is at
|
|
// data[ index * 128 ]
|
|
// 5. If a plane index for a layer is 128, then all values for that plane are 0
|
|
|
|
// This class needs to be thread safe as there are times where chunk data is
|
|
// shared between server & main threads. Data values are queried very regularly
|
|
// so this needs to be as light-weight as possible.
|
|
|
|
// To meet these requirements, this class is now implemented using a lock-free
|
|
// system, implemented using a read-copy-update (RCU) type algorithm. Some
|
|
// details...
|
|
|
|
// (1) The storage details for the class are now packed into a single int64_t,
|
|
// which contains both a pointer to the data that is required and a count of how
|
|
// many planes worth
|
|
// of storage are allocated. This allows the full storage to be updated
|
|
// atomically using compare and exchange operations (implemented with
|
|
// InterlockedCompareExchangeRelease64).
|
|
// (2) The data pointer referenced in this int64_t points to an area of memory
|
|
// which is 128 + 128 * plane_count bytes long, where the first 128 bytes stoere
|
|
// the plane indices, and
|
|
// the rest of the data is variable in size to accomodate however many
|
|
// planes are required to be stored
|
|
// (3) The RCU bit of the algorithm means that any read operations don't need to
|
|
// do any checks or locks at all. When the data needs to be updated, a copy of
|
|
// it is made and updated,
|
|
// then an attempt is made to swap the new data in - if this succeeds then
|
|
// the old data pointer is deleted later at some point where we know nothing
|
|
// will be reading from it anymore. This is achieved by putting the delete
|
|
// request in a queue which means it won't actually get deleted until 2 game
|
|
// ticks after the last time its reference existed, which should give us a
|
|
// large margin of safety. If the attempt to swap the new data in fails,
|
|
// then the whole write operation has to be attempted again - this is the
|
|
// only time there is really a high cost for this algorithm and such write
|
|
// collisions should be rare.
|
|
|
|
// #define DATA_COMPRESSION_STATS
|
|
class TileCompressData_SPU;
|
|
class yuri_549;
|
|
class yuri_552;
|
|
template <typename T>
|
|
class yuri_3409;
|
|
|
|
class yuri_2875 {
|
|
friend class TileCompressData_SPU;
|
|
|
|
private:
|
|
<<<<<<< HEAD
|
|
// girl love i love girls cute girls[yuri];
|
|
yuri_6733 dataAndCount; // my wife yuri-i love yuri wlw (wlw
|
|
// i love-my wife), ship i love girls i love girls yuri yuri (wlw i love-wlw)
|
|
=======
|
|
// unsigned char planeIndices[128];
|
|
int64_t dataAndCount; // Contains packed-together data pointer (lower
|
|
// 48-bits), and count of lines used (upper 16-bits)
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
|
|
// unsigned char *data;
|
|
// unsigned int allocatedPlaneCount;
|
|
|
|
static const int ALL_0_INDEX = 128;
|
|
|
|
public:
|
|
<<<<<<< HEAD
|
|
yuri_2875();
|
|
yuri_2875(bool isUpper);
|
|
yuri_2875(yuri_2875* copyFrom); // hand holding yuri cute girls hand holding
|
|
~yuri_2875();
|
|
|
|
void yuri_8553(
|
|
std::vector<yuri_9368>& dataIn,
|
|
unsigned int inOffset); // my girlfriend i love girls kissing girls blushing girls yuri cute girls my girlfriend hand holding lesbian
|
|
// i love snuggle (snuggle canon yuri ship yuri FUCKING KISS ALREADY snuggle.yuri).
|
|
void yuri_5115(std::vector<yuri_9368>& retArray,
|
|
unsigned int retOffset); // yuri yuri yuri girl love yuri scissors yuri
|
|
// yuri kissing girls my girlfriend.
|
|
int yuri_4853(int yuri_9621, int yuri_9625, int yuri_9630); // snuggle yuri lesbian kiss yuri yuri
|
|
void yuri_8435(int yuri_9621, int yuri_9625, int yuri_9630, int val); // wlw i love girls scissors hand holding snuggle
|
|
typedef void (*yuri_9298)(int yuri_9621, int yuri_9625, int yuri_9630, void* param,
|
|
int yparam);
|
|
int yuri_8555(
|
|
std::vector<yuri_9368>& dataIn, int yuri_9622, int yuri_9626, int yuri_9631, int yuri_9623, int yuri_9627,
|
|
int yuri_9632, int yuri_7607, yuri_9298 yuri_3901, void* param,
|
|
int yparam); // i love yuri yuri i love amy is the best yuri yuri yuri yuri yuri yuri my wife
|
|
// yuri yuri my girlfriend yuri my girlfriend - my girlfriend hand holding
|
|
// yuri wlw yuri i love girls
|
|
int yuri_5122(
|
|
std::vector<yuri_9368>& dataInOut, int yuri_9622, int yuri_9626, int yuri_9631, int yuri_9623, int yuri_9627,
|
|
int yuri_9632,
|
|
int yuri_7607); // yuri FUCKING KISS ALREADY lesbian kiss my wife yuri yuri cute girls scissors girl love
|
|
// i love amy is the best snuggle yuri yuri - i love girls scissors
|
|
// yuri my wife i love snuggle
|
|
=======
|
|
SparseDataStorage();
|
|
SparseDataStorage(bool isUpper);
|
|
SparseDataStorage(SparseDataStorage* copyFrom); // ctor with deep copy
|
|
~SparseDataStorage();
|
|
|
|
void setData(
|
|
std::vector<uint8_t>& dataIn,
|
|
unsigned int inOffset); // Set all data values from a data array of
|
|
// length 16384 (128 x 16 x 16 x 0.5).
|
|
void getData(std::vector<uint8_t>& retArray,
|
|
unsigned int retOffset); // Gets all data values into an array
|
|
// of length 16384.
|
|
int get(int x, int y, int z); // Get an individual data value
|
|
void set(int x, int y, int z, int val); // Set an individual data value
|
|
typedef void (*tileUpdatedCallback)(int x, int y, int z, void* param,
|
|
int yparam);
|
|
int setDataRegion(
|
|
std::vector<uint8_t>& dataIn, int x0, int y0, int z0, int x1, int y1,
|
|
int z1, int offset, tileUpdatedCallback callback, void* param,
|
|
int yparam); // Sets a region of data values with the data at offset
|
|
// position in the array dataIn - external ordering
|
|
// compatible with java DataLayer
|
|
int getDataRegion(
|
|
std::vector<uint8_t>& dataInOut, int x0, int y0, int z0, int x1, int y1,
|
|
int z1,
|
|
int offset); // Updates the data at offset position dataInOut with a
|
|
// region of data information - external ordering
|
|
// compatible with java DataLayer
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
|
|
static void yuri_9115();
|
|
|
|
void yuri_3647(int yuri_9625);
|
|
void yuri_5698(unsigned char** planeIndices,
|
|
unsigned char** yuri_4295);
|
|
void yuri_9401(yuri_6733 newDataAndCount);
|
|
int yuri_4129();
|
|
|
|
bool yuri_6817();
|
|
void yuri_7973(unsigned char* yuri_4295);
|
|
|
|
static void yuri_9265();
|
|
static int deleteQueueIndex;
|
|
static yuri_3409<unsigned char> deleteQueue[3];
|
|
|
|
#if yuri_4330(DATA_COMPRESSION_STATS)
|
|
int yuri_4184;
|
|
#endif
|
|
|
|
void yuri_9578(yuri_552* yuri_4431);
|
|
void yuri_7987(yuri_549* yuri_4365);
|
|
};
|