initial code dump

This commit is contained in:
p2r3
2025-08-12 03:51:57 +03:00
parent 94b568d2ac
commit 269e8346eb
17 changed files with 5134 additions and 0 deletions

47
src/tools.h Normal file
View File

@@ -0,0 +1,47 @@
#ifndef H_TOOLS
#define H_TOOLS
#include <stdlib.h>
#include <unistd.h>
#include "globals.h"
static ssize_t recv_all (int client_fd, void *buffer, size_t length);
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);
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, char *uuid);
void clearPlayerFD (int client_fd);
int savePlayerPositionAndRotation (int client_fd, short x, short y, short z, int8_t yaw, int8_t pitch);
int savePlayerPosition (int client_fd, short x, short y, short z);
int restorePlayerPosition (int client_fd, short *x, short *y, short *z, int8_t *yaw, int8_t *pitch);
uint8_t *getPlayerInventory (int client_fd);
uint8_t serverSlotToClientSlot (uint8_t slot);
uint8_t clientSlotToServerSlot (uint8_t slot);
uint8_t getBlockChange (short x, short y, short z);
void makeBlockChange (short x, short y, short z, uint8_t block);
#endif