mirror of
https://github.com/p2r3/bareiron.git
synced 2025-10-01 23:25:09 +02:00
move headers to separate directory
This commit is contained in:
11
include/crafting.h
Normal file
11
include/crafting.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef CRAFTING_H
|
||||
#define CRAFTING_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item);
|
||||
void getSmeltingOutput (PlayerData *player);
|
||||
|
||||
#endif
|
86
include/globals.h
Normal file
86
include/globals.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef H_GLOBALS
|
||||
#define H_GLOBALS
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#define WIFI_SSID "your-ssid"
|
||||
#define WIFI_PASS "your-password"
|
||||
#include "esp_task_wdt.h"
|
||||
#define wdt_reset(); \
|
||||
esp_task_wdt_reset(); \
|
||||
vTaskDelay(1); \
|
||||
esp_task_wdt_reset();
|
||||
#else
|
||||
#define wdt_reset();
|
||||
#endif
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#define PORT 25565
|
||||
#define MAX_PLAYERS 16
|
||||
#define GAMEMODE 0
|
||||
#define VIEW_DISTANCE 2
|
||||
// How many visited chunks to "remember"
|
||||
// The server will not re-send chunks that the player has recently been in
|
||||
#define VISITED_HISTORY 4
|
||||
// If defined, scales the frequency at which player movement updates are
|
||||
// broadcast based on the amount of players, reducing overhead for higher
|
||||
// player counts. For very many players, makes movement look jittery.
|
||||
#define SCALE_MOVEMENT_UPDATES_TO_PLAYER_COUNT
|
||||
|
||||
#define STATE_NONE 0
|
||||
#define STATE_STATUS 1
|
||||
#define STATE_LOGIN 2
|
||||
#define STATE_TRANSFER 3
|
||||
#define STATE_CONFIGURATION 4
|
||||
#define STATE_PLAY 5
|
||||
|
||||
extern ssize_t recv_count;
|
||||
extern uint8_t recv_buffer[256];
|
||||
|
||||
extern uint32_t world_seed;
|
||||
extern uint32_t rng_seed;
|
||||
|
||||
extern uint16_t client_count;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
short x;
|
||||
uint8_t y;
|
||||
short z;
|
||||
uint8_t block;
|
||||
} BlockChange;
|
||||
|
||||
typedef struct {
|
||||
uint8_t uuid[16];
|
||||
char name[16];
|
||||
int client_fd;
|
||||
short x;
|
||||
short y;
|
||||
short z;
|
||||
short visited_x[VISITED_HISTORY];
|
||||
short visited_z[VISITED_HISTORY];
|
||||
#ifdef SCALE_MOVEMENT_UPDATES_TO_PLAYER_COUNT
|
||||
uint16_t packets_since_update;
|
||||
#endif
|
||||
int8_t yaw;
|
||||
int8_t pitch;
|
||||
uint8_t hotbar;
|
||||
uint16_t inventory_items[41];
|
||||
uint16_t craft_items[9];
|
||||
uint8_t inventory_count[41];
|
||||
uint8_t craft_count[9];
|
||||
} PlayerData;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
extern BlockChange block_changes[20000];
|
||||
extern int block_changes_count;
|
||||
|
||||
extern PlayerData player_data[MAX_PLAYERS];
|
||||
|
||||
#endif
|
42
include/packets.h
Normal file
42
include/packets.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef H_PACKETS
|
||||
#define H_PACKETS
|
||||
|
||||
int cs_handshake (int client_fd);
|
||||
int cs_loginStart (int client_fd, uint8_t *uuid, char *name);
|
||||
int cs_clientInformation (int client_fd);
|
||||
int cs_pluginMessage (int client_fd);
|
||||
int cs_playerAction (int client_fd);
|
||||
int cs_useItemOn (int client_fd);
|
||||
int cs_setPlayerPositionAndRotation (int client_fd, double *x, double *y, double *z, float *yaw, float *pitch);
|
||||
int cs_setPlayerPosition (int client_fd, double *x, double *y, double *z);
|
||||
int cs_setPlayerRotation(int client_fd, float *yaw, float *pitch);
|
||||
int cs_setHeldItem (int client_fd);
|
||||
int cs_clickContainer (int client_fd);
|
||||
int cs_closeContainer (int client_fd);
|
||||
|
||||
int sc_loginSuccess (int client_fd, uint8_t *uuid, char *name);
|
||||
int sc_knownPacks (int client_fd);
|
||||
int sc_finishConfiguration (int client_fd);
|
||||
int sc_loginPlay (int client_fd);
|
||||
int sc_synchronizePlayerPosition (int client_fd, double x, double y, double z, float yaw, float pitch);
|
||||
int sc_setDefaultSpawnPosition (int client_fd, int64_t x, int64_t y, int64_t z);
|
||||
int sc_startWaitingForChunks (int client_fd);
|
||||
int sc_playerAbilities (int client_fd, uint8_t flags);
|
||||
int sc_updateTime (int client_fd, uint64_t ticks);
|
||||
int sc_setCenterChunk (int client_fd, int x, int y);
|
||||
int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z);
|
||||
int sc_keepAlive (int client_fd);
|
||||
int sc_setContainerSlot (int client_fd, int window_id, uint16_t slot, uint8_t count, uint16_t item);
|
||||
int sc_setHeldItem (int client_fd, uint8_t slot);
|
||||
int sc_blockUpdate (int client_fd, int64_t x, int64_t y, int64_t z, uint8_t block);
|
||||
int sc_openScreen (int client_fd, uint8_t window, const char *title, uint16_t length);
|
||||
int sc_acknowledgeBlockChange (int client_fd, int sequence);
|
||||
int sc_playerInfoUpdateAddPlayer (int client_fd, PlayerData player);
|
||||
int sc_spawnEntity (int client_fd, int id, uint8_t *uuid, int type, double x, double y, double z, double yaw, double pitch);
|
||||
int sc_spawnEntityPlayer (int client_fd, PlayerData player);
|
||||
int sc_teleportEntity (int client_fd, int id, double x, double y, double z, float yaw, float pitch);
|
||||
int sc_setHeadRotation (int client_fd, int id, uint8_t yaw);
|
||||
int sc_updateEntityRotation (int client_fd, int id, uint8_t yaw, uint8_t pitch);
|
||||
int sc_registries(int client_fd);
|
||||
|
||||
#endif
|
51
include/tools.h
Normal file
51
include/tools.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef H_TOOLS
|
||||
#define H_TOOLS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
ssize_t recv_all (int client_fd, void *buf, size_t n, uint8_t require_first);
|
||||
ssize_t send_all (int fd, const void *buf, size_t len);
|
||||
|
||||
ssize_t writeByte (int client_fd, uint8_t byte);
|
||||
ssize_t writeUint16 (int client_fd, uint16_t num);
|
||||
ssize_t writeUint32 (int client_fd, uint32_t num);
|
||||
ssize_t writeUint64 (int client_fd, uint64_t num);
|
||||
ssize_t writeFloat (int client_fd, float num);
|
||||
ssize_t writeDouble (int client_fd, double num);
|
||||
|
||||
uint8_t readByte (int client_fd);
|
||||
uint16_t readUint16 (int client_fd);
|
||||
uint32_t readUint32 (int client_fd);
|
||||
uint64_t readUint64 (int client_fd);
|
||||
int64_t readInt64 (int client_fd);
|
||||
float readFloat (int client_fd);
|
||||
double readDouble (int client_fd);
|
||||
|
||||
void readString (int client_fd);
|
||||
|
||||
uint32_t fast_rand ();
|
||||
uint64_t splitmix64 (uint64_t state);
|
||||
|
||||
extern int client_states[MAX_PLAYERS * 2];
|
||||
|
||||
void setClientState (int client_fd, int new_state);
|
||||
int getClientState (int client_fd);
|
||||
int getClientIndex (int client_fd);
|
||||
|
||||
int reservePlayerData (int client_fd, uint8_t *uuid, char* name);
|
||||
int getPlayerData (int client_fd, PlayerData **output);
|
||||
void clearPlayerFD (int client_fd);
|
||||
int givePlayerItem (PlayerData *player, uint16_t item, uint8_t count);
|
||||
|
||||
uint8_t serverSlotToClientSlot (int window_id, uint8_t slot);
|
||||
uint8_t clientSlotToServerSlot (int window_id, uint8_t slot);
|
||||
|
||||
uint8_t getBlockChange (short x, uint8_t y, short z);
|
||||
void makeBlockChange (short x, uint8_t y, short z, uint8_t block);
|
||||
|
||||
uint16_t getMiningResult (int client_fd, uint8_t block);
|
||||
|
||||
#endif
|
14
include/varnum.h
Normal file
14
include/varnum.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef H_VARNUM
|
||||
#define H_VARNUM
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SEGMENT_BITS 0x7F
|
||||
#define CONTINUE_BIT 0x80
|
||||
#define VARNUM_ERROR 0xFFFFFFFF
|
||||
|
||||
int32_t readVarInt (int client_fd);
|
||||
int sizeVarInt (uint32_t value);
|
||||
void writeVarInt (int client_fd, uint32_t value);
|
||||
|
||||
#endif
|
27
include/worldgen.h
Normal file
27
include/worldgen.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef H_WORLDGEN
|
||||
#define H_WORLDGEN
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// For best performance, CHUNK_SIZE should be a power of 2
|
||||
#define CHUNK_SIZE 8
|
||||
// Terrain low point - should start a bit below sea level for rivers/lakes
|
||||
#define TERRAIN_BASE_HEIGHT 60
|
||||
// Center point of cave generation
|
||||
#define CAVE_BASE_DEPTH 24
|
||||
|
||||
typedef struct {
|
||||
short x;
|
||||
short z;
|
||||
uint32_t hash;
|
||||
} ChunkAnchor;
|
||||
|
||||
uint32_t getChunkHash (short x, short z);
|
||||
int getHeightAt (int rx, int rz, int _x, int _z, uint32_t chunk_hash);
|
||||
uint8_t getTerrainAt (int x, int y, int z, ChunkAnchor anchor);
|
||||
uint8_t getBlockAt (int x, int y, int z);
|
||||
|
||||
extern uint8_t chunk_section[4096];
|
||||
void buildChunkSection (int x, int y, int z);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user