Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/basin/accept.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef BASIN_ACCEPT_H_
#define BASIN_ACCEPT_H_

#include <basin/server.h>

void run_accept(struct server* param);

struct timeval {
int32_t tv_sec;
int32_t tv_usec;
};

#endif /* BASIN_ACCEPT_H_ */
2 changes: 1 addition & 1 deletion include/basin/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ void broadcastf(char* color, char* fmt, ...);
#define BEGIN_BROADCAST_EXCEPT(players, except) if(players->mc) pthread_rwlock_rdlock(&players->data_mutex); for (size_t i = 0; i < players->size; i++) {struct player* bc_player = (struct player*) players->data[i];if (bc_player != NULL && bc_player != except) {
#define END_BROADCAST_MT(players) }} if(players->mc) pthread_rwlock_unlock(&players->data_mutex);
#define END_BROADCAST }}
*/
*/

#endif /* BASIN_GAME_H_ */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions src/accept.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "accept.h"
#include "work.h"
#include <basin/accept.h>
#include <basin/work.h>
#include <basin/connection.h>
#include <avuna/queue.h>
#include <avuna/string.h>
Expand Down Expand Up @@ -46,7 +46,6 @@ void run_accept(struct server* server) {
if ((spfd.revents ^ POLLIN) != 0) {
printf("Error after polling server: %i (poll revents)!\n", spfd.revents);
pfree(pool);
break;
}
spfd.revents = 0;
int fd = accept(server->fd, (struct sockaddr*) &conn->addr, &conn->addrlen);
Expand Down
8 changes: 0 additions & 8 deletions src/accept.h

This file was deleted.

8 changes: 6 additions & 2 deletions src/ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,15 @@ int ai_shouldnearestattackabletarget(struct world* world, struct entity* entity,
struct entity* ce = NULL;
BEGIN_HASHMAP_ITERATION(world->entities);
struct entity* ie = value;
if (!entity_has_flag(entity_get_info(ie->type), "livingbase") || ie == entity) continue;
if (!entity_has_flag(entity_get_info(ie->type), "livingbase") || ie == entity) {

}
double dsq = entity_distsq(entity, value);
if (ie->type == ENT_PLAYER) {
struct player* pl = ie->data.player.player;
if (pl->gamemode == 1 || pl->gamemode == 3 || pl->invulnerable) continue;
if (pl->gamemode == 1 || pl->gamemode == 3 || pl->invulnerable) {

}
int sk = entity_has_flag(entity_get_info(entity->type), "skeleton");
int zo = entity_has_flag(entity_get_info(entity->type), "zombie");
int cr = entity_has_flag(entity_get_info(entity->type), "creeper");
Expand Down
4 changes: 3 additions & 1 deletion src/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,12 @@ void onBlockInteract_workbench(struct world* world, block blk, int32_t x, int32_
block onBlockPlaced_chest(struct world* world, block blk, int32_t x, int32_t y, int32_t z, block replaced) {
int16_t meta = blk & 0x0f;
if (meta < 2 || meta > 5) meta = 2;
struct mempool* pool = mempool_new();
struct tile_entity* te = tile_new("minecraft:chest", x, y, z);
te->data.chest.lock = NULL;
te->data.chest.inv = xmalloc(sizeof(struct inventory));
inventory_new(te->data.chest.inv, INVTYPE_CHEST, 2, 27);
struct mempool* pool = mempool_new();
inventory_new(pool, te->data.chest.inv, INVTYPE_CHEST, 2, 27);
te->data.chest.inv->tile = te;
te->data.chest.inv->title = xstrdup("{\"text\": \"Chest\"}", 0);
world_set_tile(world, x, y, z, te);
Expand Down
4 changes: 3 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ void callCommand(struct player* player, struct mempool* pool, char* command) {
}
for (size_t i3 = 0; i3 < registered_commands->size; i3++) {
struct command* com = (struct command*) registered_commands->data[i3];
if (com == NULL) continue;
if (com == NULL) {

}
if (streq_nocase(com->command, rc)) {
(*com->callback)(player, args, arg_count);
return;
Expand Down
27 changes: 19 additions & 8 deletions src/crafting.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ void crafting_init() {
ITER_LLIST_END();
}
list_append(crafting_recipies, recipe);
continue;
crafting_format_error:;
crafting_format_error: ;
printf("[WARNING] Error Loading Crafting Recipe \"%s\"! Skipped.\n", child_json->name);
ITER_LLIST_END();
}
Expand All @@ -94,7 +93,9 @@ void crafting_once(struct player* player, struct inventory* inv) {
int cap = inv->type == INVTYPE_PLAYERINVENTORY ? 4 : 9;
for (int i = 1; i <= cap; i++) {
struct slot* slot = inventory_get(player, inv, i);
if (slot == NULL) continue;
if (slot == NULL) {

}
if (--slot->count <= 0) {
if (slot->nbt != NULL) {
pfree(slot->nbt->pool);
Expand All @@ -111,12 +112,16 @@ int crafting_all(struct player* player, struct inventory* inv) {
uint8_t count = 64;
for (int i = 1; i <= cap; i++) {
struct slot* slot = inventory_get(player, inv, i);
if (slot == NULL) continue;
if (slot == NULL) {

}
if (slot->count < count) count = slot->count;
}
for (int i = 1; i <= cap; i++) {
struct slot* slot = inventory_get(player, inv, i);
if (slot == NULL) continue;
if (slot == NULL) {

}
slot->count -= count;
if (slot->count <= 0) {
if (slot->nbt != NULL) {
Expand Down Expand Up @@ -177,12 +182,16 @@ struct slot* crafting_result(struct mempool* pool, struct slot** slots, size_t s

for (size_t i = 0; i < crafting_recipies->size; i++) {
struct crafting_recipe* recipe = (struct crafting_recipe*) crafting_recipies->data[i];
if (recipe == NULL || (recipe->width > 2 && slot_count <= 4) || (slot_count == 4 && (recipe->slot[6] != NULL || recipe->slot[7] != NULL || recipe->slot[8] != NULL))) continue;
if (recipe == NULL || (recipe->width > 2 && slot_count <= 4) || (slot_count == 4 && (recipe->slot[6] != NULL || recipe->slot[7] != NULL || recipe->slot[8] != NULL))) {

}
if (recipe->shapeless) { // TODO: optimize
int matching = 1;
for (int slot_index = 0; slot_index <= slot_count; slot_index++) {
struct slot* slot = slots[slot_index];
if (slot == NULL) continue;
if (slot == NULL) {

}
int local_matched = 0;
for (int ri = 0; ri < 9; ri++) {
struct slot* local_slot = recipe->slot[ri];
Expand All @@ -199,7 +208,9 @@ struct slot* crafting_result(struct mempool* pool, struct slot** slots, size_t s
if (matching) {
for (int slot_index_2 = 0; slot_index_2 < 9; slot_index_2++) {
struct slot* slot = recipe->slot[slot_index_2];
if (slot == NULL) continue;
if (slot == NULL) {

}
int local_matched = 0;
for (int ls = 1; ls <= 4; ls++) {
struct slot* local_slot = slots[ls];
Expand Down
45 changes: 33 additions & 12 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ void init_entities() {
info->dataname = str_dup(tmp->data.string, 0, entities_pool);
list_set(entity_infos, id, info);
hashmap_put(entity_infos_by_name, str_tolower(str_dup(info->dataname, 0, entities_pool)), info);
continue;
entity_error: ;
printf("[WARNING] Error Loading Entity \"%s\"! Skipped.\n", child_json->name);
ITER_LLIST_END();
Expand Down Expand Up @@ -539,10 +538,14 @@ int entity_move(struct entity* entity, double* motionX, double* motionY, double*
for (int32_t z = (int32_t) floor(obb.minZ); z < floor(obb.maxZ + 1.); z++) {
for (int32_t y = (int32_t) floor(obb.minY); y < floor(obb.maxY + 1.); y++) {
block b = world_get_block_guess(entity->world, ch, x, y, z);
if (b == 0) continue;
if (b == 0) {

}
b = entity_adjustCollision(entity->world, entity, ch, b, x, y, z);
struct block_info* bi = getBlockInfo(b);
if (bi == NULL) continue;
if (bi == NULL) {

}
for (size_t i = 0; i < bi->boundingBox_count; i++) {
struct boundingbox* bbx = &bi->boundingBoxes[i];
struct boundingbox bbd;
Expand Down Expand Up @@ -578,10 +581,14 @@ int entity_move(struct entity* entity, double* motionX, double* motionY, double*
for (int32_t z = (int32_t) floor(obb.minZ); z < floor(obb.maxZ + 1.); z++) {
for (int32_t y = (int32_t) floor(obb.minY); y < floor(obb.maxY + 1.); y++) {
block b = world_get_block_guess(entity->world, ch, x, y, z);
if (b == 0) continue;
if (b == 0) {

}
b = entity_adjustCollision(entity->world, entity, ch, b, x, y, z);
struct block_info* bi = getBlockInfo(b);
if (bi == NULL) continue;
if (bi == NULL) {

}
for (size_t i = 0; i < bi->boundingBox_count; i++) {
struct boundingbox* bbx = &bi->boundingBoxes[i];
struct boundingbox bbd;
Expand Down Expand Up @@ -617,10 +624,14 @@ int entity_move(struct entity* entity, double* motionX, double* motionY, double*
for (int32_t z = (int32_t) floor(obb.minZ); z < floor(obb.maxZ + 1.); z++) {
for (int32_t y = (int32_t) floor(obb.minY); y < floor(obb.maxY + 1.); y++) {
block b = world_get_block_guess(entity->world, ch, x, y, z);
if (b == 0) continue;
if (b == 0) {

}
b = entity_adjustCollision(entity->world, entity, ch, b, x, y, z);
struct block_info* bi = getBlockInfo(b);
if (bi == NULL) continue;
if (bi == NULL) {

}
for (size_t i = 0; i < bi->boundingBox_count; i++) {
struct boundingbox* bbx = &bi->boundingBoxes[i];
struct boundingbox bbd;
Expand Down Expand Up @@ -835,7 +846,9 @@ int damageEntity(struct entity* attacked, float damage, int armorable) {
for (size_t i = 0; i < info->loot_count; i++) {
struct entity_loot* el = &info->loots[i];
int amt = el->amountMax == el->amountMin ? el->amountMax : (rand() % (el->amountMax - el->amountMin) + el->amountMin);
if (amt <= 0) continue;
if (amt <= 0) {

}
struct slot it;
it.item = el->id;
it.count = (unsigned char) amt;
Expand Down Expand Up @@ -888,9 +901,13 @@ int entity_inFluid(struct entity* entity, uint16_t blk, float ydown, int meta_ch
for (int32_t z = (int32_t) floor(pbb.minZ); z < floor(pbb.maxZ + 1.); z++) {
for (int32_t y = (int32_t) floor(pbb.minY); y < floor(pbb.maxY + 1.); y++) {
block b = world_get_block(entity->world, x, y, z);
if (meta_check ? (b != blk) : ((b >> 4) != (blk >> 4))) continue;
if (meta_check ? (b != blk) : ((b >> 4) != (blk >> 4))) {

}
struct block_info* bi = getBlockInfo(b);
if (bi == NULL) continue;
if (bi == NULL) {

}
struct boundingbox bb2;
bb2.minX = 0. + (double) x;
bb2.maxX = 1. + (double) x;
Expand Down Expand Up @@ -921,9 +938,13 @@ int entity_inBlock(struct entity* ent, block blk) { // blk = 0 for any block
for (int32_t z = floor(obb.minZ); z < floor(obb.maxZ + 1.); z++) {
for (int32_t y = floor(obb.minY); y < floor(obb.maxY + 1.); y++) {
block b = world_get_block(ent->world, x, y, z);
if (b == 0 || (blk != 0 && blk != b)) continue;
if (b == 0 || (blk != 0 && blk != b)) {

}
struct block_info* bi = getBlockInfo(b);
if (bi == NULL) continue;
if (bi == NULL) {

}
for (size_t i = 0; i < bi->boundingBox_count; i++) {
struct boundingbox* bb = &bi->boundingBoxes[i];
struct boundingbox nbb;
Expand Down
Loading