mirror of https://github.com/basinserver/basin/
Overall improvements.
This commit is contained in:
parent
5386cffe7a
commit
0d2647ef15
|
@ -1,3 +1,6 @@
|
|||
.idea
|
||||
.vscode
|
||||
|
||||
cmake-build-debug
|
||||
.nfs*
|
||||
build
|
||||
.nfs*
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef AI_H_
|
||||
#define AI_H_
|
||||
#ifndef BASIN_AI_H_
|
||||
#define BASIN_AI_H_
|
||||
|
||||
#include <avuna/hash.h>
|
||||
#include <basin/world.h>
|
||||
|
@ -313,4 +313,4 @@ int ai_shouldwatchclosest(struct world* world, struct entity* entity, struct ait
|
|||
|
||||
int ai_shouldzombieattack(struct world* world, struct entity* entity, struct aitask* ai);
|
||||
|
||||
#endif /* AI_H_ */
|
||||
#endif /* BASIN_AI_H_ */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <basin/network.h>
|
||||
#include <basin/perlin.h>
|
||||
#include <basin/player.h>
|
||||
#include <basin/plugin.h>
|
||||
// #include <basin/plugin.h>
|
||||
#include <basin/profile.h>
|
||||
#include <basin/server.h>
|
||||
#include <basin/smelting.h>
|
||||
|
@ -26,4 +26,4 @@
|
|||
#include <basin/world.h>
|
||||
#include <basin/worldmanager.h>
|
||||
|
||||
#endif //BASIN_BASIN_H_
|
||||
#endif /* BASIN_BASIN_H_ */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef BIOME_H_
|
||||
#define BIOME_H_
|
||||
#ifndef BASIN_BIOME_H_
|
||||
#define BASIN_BIOME_H_
|
||||
|
||||
#define BIOME_OCEAN 0
|
||||
#define BIOME_PLAINS 1
|
||||
|
@ -57,11 +57,11 @@
|
|||
#define BIOME_COLD_TAIGA_M 158
|
||||
#define BIOME_MEGA_SPRUCE_TAIGA 160
|
||||
#define BIOME_REDWOOD_TAIGA_HILLS_M 161
|
||||
#define BIOME_EXTREME_HILLS_PLUS M 162
|
||||
#define BIOME_EXTREME_HILLS_PLUS_M 162
|
||||
#define BIOME_SAVANNA_M 163
|
||||
#define BIOME_SAVANNA_PLATEAU_M 164
|
||||
#define BIOME_MESA_BRYCE 165
|
||||
#define BIOME_MESA_PLATEAU_F M 166
|
||||
#define BIOME_MESA_PLATEAU_F_M 166
|
||||
#define BIOME_MESA_PLATEAU_M 167
|
||||
|
||||
#endif /* BIOME_H_ */
|
||||
#endif /* BASIN_BIOME_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef BLOCK_H_
|
||||
#define BLOCK_H_
|
||||
#ifndef BASIN_BLOCK_H_
|
||||
#define BASIN_BLOCK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_H_
|
||||
#define COMMAND_H_
|
||||
#ifndef BASIN_COMMAND_H_
|
||||
#define BASIN_COMMAND_H_
|
||||
|
||||
#include <basin/player.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -17,4 +17,4 @@ void registerCommand(char* command, void (*callback)(struct player* player, char
|
|||
|
||||
void callCommand(struct player* player, struct mempool* pool, char* command);
|
||||
|
||||
#endif /* COMMAND_H_ */
|
||||
#endif /* BASIN_COMMAND_H_ */
|
||||
|
|
|
@ -34,4 +34,4 @@ struct connection {
|
|||
struct server* server;
|
||||
};
|
||||
|
||||
#endif //BASIN_CONNECTION_H
|
||||
#endif /* BASIN_CONNECTION_H */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef CRAFTING_H_
|
||||
#define CRAFTING_H_
|
||||
#ifndef BASIN_CRAFTING_H_
|
||||
#define BASIN_CRAFTING_H_
|
||||
|
||||
#include <basin/network.h>
|
||||
#include <basin/inventory.h>
|
||||
|
@ -29,4 +29,4 @@ int crafting_all(struct player* player, struct inventory* inv);
|
|||
|
||||
struct slot* crafting_result(struct mempool* pool, struct slot** slots, size_t slot_count); // 012/345/678 or 01/23
|
||||
|
||||
#endif /* CRAFTING_H_ */
|
||||
#endif /* BASIN_CRAFTING_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef ENTITY_H_
|
||||
#define ENTITY_H_
|
||||
#ifndef BASIN_ENTITY_H_
|
||||
#define BASIN_ENTITY_H_
|
||||
|
||||
#include <basin/world.h>
|
||||
#include <basin/item.h>
|
||||
|
@ -481,4 +481,4 @@ void tick_entity(struct world* world, struct entity* entity);
|
|||
|
||||
void freeEntity(struct entity* entity);
|
||||
|
||||
#endif /* ENTITY_H_ */
|
||||
#endif /* BASIN_ENTITY_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef GAME_H_
|
||||
#define GAME_H_
|
||||
#ifndef BASIN_GAME_H_
|
||||
#define BASIN_GAME_H_
|
||||
|
||||
#include <basin/world.h>
|
||||
#include <basin/entity.h>
|
||||
|
@ -62,4 +62,4 @@ void broadcastf(char* color, char* fmt, ...);
|
|||
#define END_BROADCAST }}
|
||||
*/
|
||||
|
||||
#endif /* GAME_H_ */
|
||||
#endif /* BASIN_GAME_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef GLOBALS_H_
|
||||
#define GLOBALS_H_
|
||||
#ifndef BASIN_GLOBALS_H_
|
||||
#define BASIN_GLOBALS_H_
|
||||
|
||||
#define MC_PROTOCOL_VERSION_MIN 210
|
||||
#define MC_PROTOCOL_VERSION_MAX 316
|
||||
|
@ -24,4 +24,4 @@ struct mempool* global_pool;
|
|||
struct logsess* delog;
|
||||
struct hashmap* server_map;
|
||||
|
||||
#endif /* GLOBALS_H_ */
|
||||
#endif /* BASIN_GLOBALS_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef INVENTORY_H_
|
||||
#define INVENTORY_H_
|
||||
#ifndef BASIN_INVENTORY_H_
|
||||
#define BASIN_INVENTORY_H_
|
||||
|
||||
#include <basin/player.h>
|
||||
#include <basin/nbt.h>
|
||||
|
@ -82,4 +82,4 @@ int inventory_add_player(struct player* player, struct inventory* inv, struct sl
|
|||
|
||||
int inventory_add(struct player* player, struct inventory* inv, struct slot* slot, int start, int end, int broadcast);
|
||||
|
||||
#endif /* INVENTORY_H_ */
|
||||
#endif /* BASIN_INVENTORY_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef ITEM_H_
|
||||
#define ITEM_H_
|
||||
#ifndef BASIN_ITEM_H_
|
||||
#define BASIN_ITEM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -277,4 +277,4 @@ void init_items();
|
|||
|
||||
void add_item(item id, struct item_info* info);
|
||||
|
||||
#endif /* ITEM_H_ */
|
||||
#endif /* BASIN_ITEM_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef NBT_H_
|
||||
#define NBT_H_
|
||||
#ifndef BASIN_NBT_H_
|
||||
#define BASIN_NBT_H_
|
||||
|
||||
#include <avuna/hash.h>
|
||||
#include <avuna/pmem.h>
|
||||
|
@ -76,4 +76,4 @@ struct nbt_tag* nbt_new(struct mempool* pool, uint8_t type);
|
|||
|
||||
void nbt_put(struct nbt_tag* parent, struct nbt_tag* child);
|
||||
|
||||
#endif /* NBT_H_ */
|
||||
#endif /* BASIN_NBT_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef NETWORK_H_
|
||||
#define NETWORK_H_
|
||||
#ifndef BASIN_NETWORK_H_
|
||||
#define BASIN_NETWORK_H_
|
||||
|
||||
#include <basin/inventory.h>
|
||||
#include <avuna/pmem.h>
|
||||
|
@ -15,19 +15,19 @@
|
|||
struct packet;
|
||||
|
||||
struct __attribute__((__packed__)) encpos {
|
||||
int32_t z :26;
|
||||
int32_t y :12;
|
||||
int32_t x :26;
|
||||
int32_t z :26;
|
||||
int32_t y :12;
|
||||
int32_t x :26;
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) uuid {
|
||||
uint64_t uuid1;
|
||||
uint64_t uuid2;
|
||||
uint64_t uuid1;
|
||||
uint64_t uuid2;
|
||||
};
|
||||
|
||||
struct entity_metadata {
|
||||
uint8_t* metadata;
|
||||
size_t metadata_size;
|
||||
uint8_t* metadata;
|
||||
size_t metadata_size;
|
||||
};
|
||||
|
||||
RSA* public_rsa;
|
||||
|
@ -60,17 +60,17 @@ int writeSlot(struct slot* slot, unsigned char* buffer, size_t buflen);
|
|||
|
||||
int writeVarInt_stream(int32_t input,
|
||||
#ifdef __MINGW32__
|
||||
SOCKET
|
||||
SOCKET
|
||||
#else
|
||||
int
|
||||
int
|
||||
#endif
|
||||
fd);
|
||||
fd);
|
||||
|
||||
int readVarInt_stream(int32_t* output,
|
||||
#ifdef __MINGW32__
|
||||
SOCKET
|
||||
SOCKET
|
||||
#else
|
||||
int
|
||||
int
|
||||
#endif
|
||||
fd);
|
||||
#endif /* NETWORK_H_ */
|
||||
fd);
|
||||
#endif /* BASIN_NETWORK_H_ */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PACKET_H_
|
||||
#define PACKET_H_
|
||||
#ifndef BASIN_PACKET_H_
|
||||
#define BASIN_PACKET_H_
|
||||
|
||||
#include <basin/connection.h>
|
||||
#include <basin/network.h>
|
||||
|
@ -1280,4 +1280,4 @@ ssize_t packet_read(struct connection* conn, unsigned char* buf, size_t buflen,
|
|||
|
||||
ssize_t packet_write(struct connection* conn, struct packet* packet);
|
||||
|
||||
#endif
|
||||
#endif /* BASIN_PACKET */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PERLIN_H_
|
||||
#define PERLIN_H_
|
||||
#ifndef BASIN_PERLIN_H_
|
||||
#define BASIN_PERLIN_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -18,4 +18,4 @@ double perlin(struct perlin* perlin, double x, double y, double z);
|
|||
|
||||
void perlin_init(struct perlin* perlin, uint64_t seed);
|
||||
|
||||
#endif /* PERLIN_H_ */
|
||||
#endif /* BASIN_PERLIN_H_ */
|
||||
|
|
|
@ -5,17 +5,19 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef PLAYER_H_
|
||||
#define PLAYER_H_
|
||||
#ifndef BASIN_PLAYER_H_
|
||||
#define BASIN_PLAYER_H_
|
||||
|
||||
#include <basin/network.h>
|
||||
#include <basin/block.h>
|
||||
#include <avuna/pmem.h>
|
||||
|
||||
struct player {
|
||||
|
||||
struct mempool* pool;
|
||||
struct server* server;
|
||||
struct conn* conn;
|
||||
struct protocol_version* protocol_version;
|
||||
struct world* world;
|
||||
struct entity* entity;
|
||||
|
||||
|
@ -72,7 +74,6 @@ void player_hungerUpdate(struct player* player);
|
|||
|
||||
void player_send_entity_move(struct player* player, struct entity* ent);
|
||||
|
||||
|
||||
void player_receive_packet(struct player* player, struct packet* inp);
|
||||
|
||||
void player_tick(struct world* world, struct player* player);
|
||||
|
@ -93,4 +94,4 @@ void player_set_gamemode(struct player* player, int gamemode);
|
|||
|
||||
block player_can_place_block(struct player* player, uint16_t blk, int32_t x, int32_t y, int32_t z, uint8_t face);
|
||||
|
||||
#endif /* PLAYER_H_ */
|
||||
#endif /* BASIN_PLAYER_H_ */
|
||||
|
|
|
@ -74,4 +74,4 @@ packet_handler player_packet_handlers[256] = {
|
|||
(packet_handler) player_packet_handle_useitem,
|
||||
};
|
||||
|
||||
#endif //BASIN_PLAYER_PACKET_H
|
||||
#endif /* BASIN_PLAYER_PACKET_H */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef PLUGIN_H_
|
||||
#define PLUGIN_H_
|
||||
#ifndef BASIN_PLUGIN_H_
|
||||
#define BASIN_PLUGIN_H_
|
||||
|
||||
#include <basin/world.h>
|
||||
#include <basin/block.h>
|
||||
|
@ -61,4 +61,4 @@ struct plugin {
|
|||
|
||||
void init_plugins();
|
||||
|
||||
#endif /* PLUGIN_H_ */
|
||||
#endif /* BASIN_PLUGIN_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef PROFILE_H_
|
||||
#define PROFILE_H_
|
||||
#ifndef BASIN_PROFILE_H_
|
||||
#define BASIN_PROFILE_H_
|
||||
|
||||
void beginProfilerSection(char* name);
|
||||
|
||||
|
@ -16,4 +16,4 @@ void printProfiler();
|
|||
|
||||
void clearProfiler();
|
||||
|
||||
#endif /* PROFILE_H_ */
|
||||
#endif /* BASIN_PROFILE_H_ */
|
||||
|
|
|
@ -13,4 +13,4 @@ int raytrace_block(struct boundingbox* bb, int32_t x, int32_t y, int32_t z, doub
|
|||
|
||||
int raytrace(struct world* world, double x, double y, double z, double ex, double ey, double ez, int stopOnLiquid, int ignoreNonCollidable, int returnLast, double* rx, double* ry, double* rz);
|
||||
|
||||
#endif //BASIN_RAYTRACE_H
|
||||
#endif /* BASIN_RAYTRACE_H */
|
||||
|
|
|
@ -26,4 +26,4 @@ struct region* region_new(struct mempool* parent, char* path, int16_t x, int16_t
|
|||
|
||||
struct chunk* region_load_chunk(struct region* region, int8_t local_chunk_x, int8_t local_chunk_z);
|
||||
|
||||
#endif //BASIN_REGION_H
|
||||
#endif /* BASIN_REGION_H */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef SERVER_H_
|
||||
#define SERVER_H_
|
||||
#ifndef BASIN_SERVER_H_
|
||||
#define BASIN_SERVER_H_
|
||||
|
||||
#include <avuna/pmem.h>
|
||||
#include <avuna/log.h>
|
||||
|
@ -36,4 +36,4 @@ struct server {
|
|||
//TODO: make this an option
|
||||
#define RANDOM_TICK_SPEED 3
|
||||
|
||||
#endif /* SERVER_H_ */
|
||||
#endif /* BASIN_SERVER_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef SMELTING_H_
|
||||
#define SMELTING_H_
|
||||
#ifndef BASIN_SMELTING_H_
|
||||
#define BASIN_SMELTING_H_
|
||||
|
||||
#include <basin/world.h>
|
||||
#include <basin/entity.h>
|
||||
|
@ -34,4 +34,4 @@ void add_smelting_fuel(struct smelting_fuel* fuel);
|
|||
|
||||
void add_smelting_recipe(struct smelting_recipe* recipe);
|
||||
|
||||
#endif /* SMELTING_H_ */
|
||||
#endif /* BASIN_SMELTING_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef TILEENTITY_H_
|
||||
#define TILEENTITY_H_
|
||||
#ifndef BASIN_TILEENTITY_H_
|
||||
#define BASIN_TILEENTITY_H_
|
||||
|
||||
#include <basin/nbt.h>
|
||||
#include <basin/inventory.h>
|
||||
|
@ -163,4 +163,4 @@ struct nbt_tag* tile_serialize(struct mempool* parent, struct tile_entity* tile,
|
|||
|
||||
void freeTileEntity(struct tile_entity* te);
|
||||
|
||||
#endif /* TILEENTITY_H_ */
|
||||
#endif /* BASIN_TILEENTITY_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef TOOLS_H_
|
||||
#define TOOLS_H_
|
||||
#ifndef BASIN_TOOLS_H_
|
||||
#define BASIN_TOOLS_H_
|
||||
|
||||
#include <basin/item.h>
|
||||
#include <basin/world.h>
|
||||
|
@ -30,4 +30,4 @@ int tools_proficient(struct tool_info* info, uint8_t harvest_level, uint16_t b);
|
|||
|
||||
void tools_add(struct tool_info* tool);
|
||||
|
||||
#endif /* TOOLS_H_ */
|
||||
#endif /* BASIN_TOOLS_H_ */
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef VERSION_H_
|
||||
#define VERSION_H_
|
||||
#ifndef BASIN_VERSION_H_
|
||||
#define BASIN_VERSION_H_
|
||||
|
||||
#define VERSION "1.0.0"
|
||||
#define DAEMON_NAME "basin"
|
||||
#define DEBUG
|
||||
|
||||
#endif /* VERSION_H_ */
|
||||
#endif /* BASIN_VERSION_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef WORLD_H_
|
||||
#define WORLD_H_
|
||||
#ifndef BASIN_WORLD_H_
|
||||
#define BASIN_WORLD_H_
|
||||
|
||||
#include <basin/network.h>
|
||||
#include <basin/biome.h>
|
||||
|
@ -153,4 +153,4 @@ uint8_t world_get_raw_light_guess(struct world* world, struct chunk* ch, int32_t
|
|||
|
||||
uint8_t world_get_raw_light(struct world* world, int32_t x, int32_t y, int32_t z, uint8_t blocklight);
|
||||
|
||||
#endif /* WORLD_H_ */
|
||||
#endif /* BASIN_WORLD_H_ */
|
||||
|
|
|
@ -12,4 +12,4 @@ struct chunk* worldgen_gen_chunk_standard(struct world* world, struct chunk* chu
|
|||
|
||||
struct chunk* worldgen_gen_chunk(struct world* world, struct chunk* chunk);
|
||||
|
||||
#endif //BASIN_WORLDGEN_H
|
||||
#endif /* BASIN_WORLDGEN_H */
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
* Author: root
|
||||
*/
|
||||
|
||||
#ifndef WORLDMANAGER_H_
|
||||
#define WORLDMANAGER_H_
|
||||
#ifndef BASIN_WORLDMANAGER_H_
|
||||
#define BASIN_WORLDMANAGER_H_
|
||||
|
||||
#include <basin/world.h>
|
||||
|
||||
struct world* getWorldByID(int32_t id);
|
||||
|
||||
#endif /* WORLDMANAGER_H_ */
|
||||
#endif /* BASIN_WORLDMANAGER_H_ */
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "basin/network.h"
|
||||
#include <basin/world.h>
|
||||
#include <basin/game.h>
|
||||
#include <basin/queue.h>
|
||||
// #include <basin/queue.h>
|
||||
#include <basin/smelting.h>
|
||||
#include <basin/tileentity.h>
|
||||
#include <basin/smelting.h>
|
||||
|
|
|
@ -390,13 +390,13 @@ int handle_login_start(struct connection* conn, struct packet* packet) {
|
|||
size_t trimmed_length = strlen(name_trimmed);
|
||||
if (trimmed_length > 16 || trimmed_length < 2) bad_name = 2;
|
||||
if (!bad_name) {
|
||||
BEGIN_HASHMAP_ITERATION (players)
|
||||
BEGIN_HASHMAP_ITERATION (players);
|
||||
struct player* player = (struct player*) value;
|
||||
if (streq_nocase(name_trimmed, player->name)) {
|
||||
bad_name = 1;
|
||||
goto pbn;
|
||||
}
|
||||
END_HASHMAP_ITERATION (players)
|
||||
END_HASHMAP_ITERATION (players);
|
||||
pbn: ;
|
||||
}
|
||||
if (bad_name) {
|
||||
|
@ -422,4 +422,3 @@ int handle_packet_login(struct connection* conn, struct packet* packet) {
|
|||
} else return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -326,15 +326,15 @@ int main(int argc, char* argv[]) {
|
|||
return 1;
|
||||
}
|
||||
if (freopen("/dev/null", "r", stdin) < 0) {
|
||||
printf("reopening of STDIN to /dev/null failed: %s\n", strerror(errno));
|
||||
printf("Reopening of STDIN to /dev/null failed: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (freopen("/dev/null", "w", stderr) < 0) {
|
||||
printf("reopening of STDERR to /dev/null failed: %s\n", strerror(errno));
|
||||
printf("Reopening of STDERR to /dev/null failed: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (freopen("/dev/null", "w", stdout) < 0) {
|
||||
printf("reopening of STDOUT to /dev/null failed: %s\n", strerror(errno));
|
||||
printf("Reopening of STDOUT to /dev/null failed: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue