forked from EXTERNAL/bareiron
"deferred block updates": falling sand and flowing water
This commit is contained in:
@@ -34,8 +34,8 @@
|
||||
// Max render distance, determines how many chunks to send
|
||||
#define VIEW_DISTANCE 2
|
||||
|
||||
// Time between server ticks in microseconds (default = 1s)
|
||||
#define TIME_BETWEEN_TICKS 1000000
|
||||
// Time between server ticks in microseconds (default = 0.05s)
|
||||
#define TIME_BETWEEN_TICKS 50000
|
||||
|
||||
// Calculated from TIME_BETWEEN_TICKS
|
||||
#define TICKS_PER_SECOND ((float)1000000 / TIME_BETWEEN_TICKS)
|
||||
@@ -74,6 +74,10 @@
|
||||
// Determines the fixed amount of memory allocated to blocks
|
||||
#define MAX_BLOCK_CHANGES 20000
|
||||
|
||||
// How many "deferred" (happen at a later time than triggered) block updates to store.
|
||||
// Determines the fixed amount of memory allocated to that list
|
||||
#define MAX_DEFERRED_BLOCK_UPDATES 64
|
||||
|
||||
// If defined, writes and reads world data to/from disk (or flash).
|
||||
// This is a synchronous operation, and can cause performance issues if
|
||||
// frequent random disk access is slow. Data is still stored in and
|
||||
@@ -195,6 +199,24 @@ typedef struct {
|
||||
uint8_t block;
|
||||
} BlockChange;
|
||||
|
||||
#define UPDATE_BASIC (1 << 0)
|
||||
// the sand at this position will be moved down immediately when this is processed
|
||||
#define UPDATE_FALL_SAND (1 << 1)
|
||||
#define UPDATE_FLOW_WATER (1 << 2)
|
||||
// the sand below this block will fall soon
|
||||
#define UPDATE_CHECK_SAND_FALL (1 << 3)
|
||||
#define UPDATE_CHECK_WATER (1 << 4)
|
||||
|
||||
#define UPDATE_NOW (UPDATE_BASIC | UPDATE_CHECK_SAND_FALL | UPDATE_CHECK_WATER)
|
||||
|
||||
typedef struct {
|
||||
short update_kind;
|
||||
short x;
|
||||
short z;
|
||||
uint8_t y;
|
||||
uint8_t await_ticks;
|
||||
} DeferredBlockUpdate;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
@@ -267,6 +289,10 @@ typedef struct {
|
||||
extern BlockChange block_changes[MAX_BLOCK_CHANGES];
|
||||
extern int block_changes_count;
|
||||
|
||||
extern DeferredBlockUpdate deferred_block_updates[MAX_DEFERRED_BLOCK_UPDATES];
|
||||
extern int deferred_block_updates_count;
|
||||
extern uint8_t is_processing_deferred_block_updates;
|
||||
|
||||
extern PlayerData player_data[MAX_PLAYERS];
|
||||
extern int player_data_count;
|
||||
|
||||
|
@@ -32,9 +32,11 @@ uint8_t makeBlockChange (short x, uint8_t y, short z, uint8_t block);
|
||||
|
||||
uint8_t isInstantlyMined (PlayerData *player, uint8_t block);
|
||||
uint8_t isColumnBlock (uint8_t block);
|
||||
uint8_t isFallingBlock (uint8_t block);
|
||||
uint8_t isPassableBlock (uint8_t block);
|
||||
uint8_t isPassableSpawnBlock (uint8_t block);
|
||||
uint8_t isReplaceableBlock (uint8_t block);
|
||||
uint8_t getFluid (uint8_t block);
|
||||
uint32_t isCompostItem (uint16_t item);
|
||||
uint8_t getItemStackSize (uint16_t item);
|
||||
|
||||
@@ -43,7 +45,10 @@ void bumpToolDurability (PlayerData *player);
|
||||
void handlePlayerAction (PlayerData *player, int action, short x, short y, short z);
|
||||
void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t face);
|
||||
|
||||
void checkFluidUpdate (short x, uint8_t y, short z, uint8_t block);
|
||||
void processBlockUpdate (short x, uint8_t y, short z, uint8_t block, short update_kind);
|
||||
void updateXZNeighbors (short x, uint8_t y, short z, short update_kind);
|
||||
void updateXYZNeighbors (short x, uint8_t y, short z, short update_kind);
|
||||
void deferBlockUpdate (short x, uint8_t y, short z, uint8_t await_ticks, short update_kind);
|
||||
|
||||
void spawnMob (uint8_t type, short x, uint8_t y, short z, uint8_t health);
|
||||
void interactEntity (int entity_id, int interactor_id);
|
||||
|
Reference in New Issue
Block a user