2019-04-14 20:45:32 +00:00
|
|
|
#include <basin/basin.h>
|
|
|
|
#include <basin/profile.h>
|
|
|
|
#include <basin/anticheat.h>
|
2017-01-03 19:51:34 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2017-01-04 00:48:45 +00:00
|
|
|
#define AC_BEGIN beginProfilerSection("player_anticheat");
|
2017-01-04 07:21:26 +00:00
|
|
|
#define AC_END(ret) { endProfilerSection("player_anticheat"); if (ret) printf("[AC] Player %s infraction at %s (%d)\n", player->name, __func__, ret); return ret; }
|
2017-01-04 00:48:45 +00:00
|
|
|
|
|
|
|
int ac_chat(struct player* player, char* msg) {
|
2019-05-01 10:26:21 +00:00
|
|
|
AC_BEGIN
|
2017-01-04 05:20:00 +00:00
|
|
|
|
2019-05-01 10:26:21 +00:00
|
|
|
for (char* p = msg; *p; p++) {
|
|
|
|
if (*p < 32 || *p == 127 || *p == 0xA7) {
|
2019-04-17 13:38:46 +00:00
|
|
|
player_kick(player, "Invalid chat message");
|
2019-05-01 10:26:21 +00:00
|
|
|
AC_END(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AC_END(0)
|
2017-01-04 00:48:45 +00:00
|
|
|
}
|
2017-01-03 19:51:34 +00:00
|
|
|
|
|
|
|
int ac_tick(struct player* player, int onground) {
|
2019-05-01 10:26:21 +00:00
|
|
|
AC_BEGIN
|
|
|
|
AC_END(0)
|
2017-01-03 19:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ac_ticklook(struct player* player, float yaw, float pitch) {
|
2019-05-01 10:26:21 +00:00
|
|
|
AC_BEGIN
|
|
|
|
if (!isfinite(yaw) || !isfinite(pitch))
|
|
|
|
AC_END(1)
|
|
|
|
AC_END(0)
|
2017-01-03 19:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ac_tickpos(struct player* player, double x, double y, double z) {
|
2019-05-01 10:26:21 +00:00
|
|
|
AC_BEGIN
|
|
|
|
if (!isfinite(x) || !isfinite(y) || !isfinite(z))
|
|
|
|
AC_END(1)
|
|
|
|
AC_END(0);
|
2017-01-04 05:20:00 +00:00
|
|
|
}
|