mirror of
https://github.com/basinserver/basin/
synced 2025-03-11 07:17:49 +00:00
Chat check
This commit is contained in:
parent
dcbf276468
commit
9ee9dd8971
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.idea
|
||||
cmake-build-debug
|
||||
|
@ -3,21 +3,36 @@
|
||||
#include "profile.h"
|
||||
#include "anticheat.h"
|
||||
|
||||
int ac_lock = 0;
|
||||
#define AC_BEGIN
|
||||
#define AC_END(ret) return ret;
|
||||
#define AC_BEGIN beginProfilerSection("player_anticheat");
|
||||
#define AC_END(ret) { endProfilerSection("player_anticheat"); return ret; }
|
||||
|
||||
int ac_chat(struct player* player, char* msg) {
|
||||
AC_BEGIN
|
||||
for (char* p = msg; *p; p++) {
|
||||
if (*p < 32 || *p == 127 || *p == '\u00A7') {
|
||||
kickPlayer(player, "Invalid chat message");
|
||||
AC_END(1);
|
||||
}
|
||||
}
|
||||
AC_END(0)
|
||||
}
|
||||
|
||||
int ac_tick(struct player* player, int onground) {
|
||||
AC_BEGIN
|
||||
|
||||
AC_END(0)
|
||||
}
|
||||
|
||||
int ac_ticklook(struct player* player, float yaw, float pitch) {
|
||||
AC_BEGIN
|
||||
if (!isfinite(yaw) || !isfinite(pitch))
|
||||
AC_END(1)
|
||||
AC_END(0)
|
||||
}
|
||||
|
||||
int ac_tickpos(struct player* player, double x, double y, double z) {
|
||||
AC_BEGIN
|
||||
if (!isfinite(x) || !isfinite(y) || !isfinite(z))
|
||||
AC_END(1)
|
||||
AC_END(0);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#ifndef BASIN_ANTICHEAT_H_
|
||||
#define BASIN_ANTICHEAT_H_
|
||||
|
||||
int ac_chat(struct player* player, char* msg);
|
||||
int ac_tick(struct player* player, int onground);
|
||||
int ac_ticklook(struct player* player, float yaw, float pitch);
|
||||
int ac_tickpos(struct player* player, double x, double y, double z);
|
||||
|
@ -71,11 +71,6 @@ struct player* newPlayer(struct entity* entity, char* name, struct uuid uuid, st
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
player->reachDistance = 6.f;
|
||||
player->acstate.real_onGround = 1;
|
||||
player->acstate.flightInfraction = 0;
|
||||
player->acstate.ldy = 0.;
|
||||
player->acstate.lastJump = 0;
|
||||
player->acstate.offGroundTime = 0;
|
||||
player->spawnedIn = 0;
|
||||
player->llTick = 0;
|
||||
player->triggerRechunk = 0;
|
||||
@ -157,6 +152,8 @@ void player_receive_packet(struct player* player, struct packet* inp) {
|
||||
}
|
||||
} else if (inp->id == PKT_PLAY_SERVER_CHATMESSAGE) {
|
||||
char* msg = inp->data.play_server.chatmessage.message;
|
||||
if (ac_chat(player, msg))
|
||||
goto cont;
|
||||
if (startsWith(msg, "/")) {
|
||||
callCommand(player, msg + 1);
|
||||
} else {
|
||||
|
@ -11,11 +11,6 @@
|
||||
#include "network.h"
|
||||
|
||||
typedef struct _acstate {
|
||||
uint8_t real_onGround;
|
||||
uint8_t flightInfraction;
|
||||
double ldy;
|
||||
size_t lastJump;
|
||||
uint32_t offGroundTime;
|
||||
} acstate_t;
|
||||
|
||||
struct player {
|
||||
|
Loading…
Reference in New Issue
Block a user