Upload
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#ifndef ADMIN_CLI_H
|
||||
#define ADMIN_CLI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool admin_cli_stdin_is_tty(void);
|
||||
int admin_cli_run(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <jni.h>
|
||||
#ifndef _Included_com_teamexeempire_disaster2d_Disaster
|
||||
#define _Included_com_teamexeempire_disaster2d_Disaster
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef com_teamexeempire_disaster2d_Disaster_MIN_PRIORITY
|
||||
#define com_teamexeempire_disaster2d_Disaster_MIN_PRIORITY 1L
|
||||
#undef com_teamexeempire_disaster2d_Disaster_NORM_PRIORITY
|
||||
#define com_teamexeempire_disaster2d_Disaster_NORM_PRIORITY 5L
|
||||
#undef com_teamexeempire_disaster2d_Disaster_MAX_PRIORITY
|
||||
#define com_teamexeempire_disaster2d_Disaster_MAX_PRIORITY 10L
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_teamexeempire_disaster2d_Disaster_disaster_1start
|
||||
(JNIEnv*, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef API_H
|
||||
#define API_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SERVER_API __declspec(dllexport)
|
||||
#else
|
||||
#define SERVER_API
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef AUTH_H
|
||||
#define AUTH_H
|
||||
#include <Packet.h>
|
||||
#include <Player.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t type;
|
||||
uint8_t one;
|
||||
uint8_t two;
|
||||
} auth_peer_data;
|
||||
|
||||
typedef struct PeerData PeerData;
|
||||
|
||||
bool auth_create_ticket(PeerData* peer, Packet* packet);
|
||||
bool auth_verify_ticket(PeerData* peer, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef CMATH_H
|
||||
#define CMATH_H
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} Vector2;
|
||||
|
||||
float lerp(float a, float b, float f);
|
||||
float sign(float x);
|
||||
|
||||
float vector2_dist(Vector2* a, Vector2* b);
|
||||
float vector2_dist_squared(Vector2* a, Vector2* b);
|
||||
Vector2 vector2_dir(Vector2* a, Vector2* b);
|
||||
uint16_t game_float_to_half(float f);
|
||||
float game_half_to_float(uint16_t h);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef COLORS_H
|
||||
#define COLORS_H
|
||||
|
||||
#define CLRCODE_RED "\\"
|
||||
#define CLRCODE_GRN "@"
|
||||
#define CLRCODE_PUR "&"
|
||||
#define CLRCODE_BLU "/"
|
||||
#define CLRCODE_GRA "|"
|
||||
#define CLRCODE_YLW "`"
|
||||
#define CLRCODE_ORG "\xE2\x84\x96"
|
||||
#define CLRCODE_RST "~"
|
||||
|
||||
#define CLRLIST { CLRCODE_RED, CLRCODE_GRN, CLRCODE_PUR, CLRCODE_BLU, CLRCODE_GRA, CLRCODE_YLW, CLRCODE_ORG, CLRCODE_RST }
|
||||
#define CLRLIST_LEN 8
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,107 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include <cJSON.h>
|
||||
#include <Api.h>
|
||||
#include <io/Threads.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef SYS_ANDROID
|
||||
#define CONFIG_FILE "Config.json"
|
||||
#define BANS_FILE "Bans.json"
|
||||
#define OPERATORS_FILE "Operators.json"
|
||||
#define TIMEOUTS_FILE "Timeouts.json"
|
||||
#define REPORTS_FILE "Reports.json"
|
||||
#define LOBBY_TIMEOUTS_FILE "LobbyTimeouts.json"
|
||||
#else
|
||||
#define ANDROID_DIR "/data/data/com.teamexeempire.disaster2d/files/"
|
||||
#define CONFIG_FILE ANDROID_DIR "Config.json"
|
||||
#define BANS_FILE ANDROID_DIR "Bans.json"
|
||||
#define OPERATORS_FILE ANDROID_DIR "Operators.json"
|
||||
#define TIMEOUTS_FILE ANDROID_DIR "Timeouts.json"
|
||||
#define REPORTS_FILE ANDROID_DIR "Reports.json"
|
||||
#define LOBBY_TIMEOUTS_FILE ANDROID_DIR "LobbyTimeouts.json"
|
||||
#endif
|
||||
|
||||
/* Message of the day is a list of chat lines; a single string still works. */
|
||||
#define MOTD_MAX_LINES 12
|
||||
#define MOTD_LINE_SIZE 256
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t port;
|
||||
int32_t max_simultaneous_players;
|
||||
int32_t server_count;
|
||||
int32_t ping_limit;
|
||||
bool log_debug;
|
||||
bool log_file;
|
||||
bool anticheat;
|
||||
bool pride;
|
||||
bool vanilla_balancing;
|
||||
bool gamemodes[10];
|
||||
float retained_velocity_decay;
|
||||
int retained_velocity_decay_start_ticks;
|
||||
int retained_extrapolation_limit_ticks_x;
|
||||
int retained_extrapolation_limit_ticks_y;
|
||||
int relay_fill_interval_ticks;
|
||||
int relay_heartbeat_interval_ticks;
|
||||
int relay_correction_interval_ticks;
|
||||
int relay_priority_interval_ticks;
|
||||
bool map_list[20];
|
||||
Mutex map_list_lock;
|
||||
|
||||
char motd[MOTD_MAX_LINES][MOTD_LINE_SIZE];
|
||||
int32_t motd_lines;
|
||||
|
||||
/* moderation */
|
||||
int32_t votekick_vote_seconds;
|
||||
int32_t votekick_start_cooldown_seconds;
|
||||
int32_t votekick_lobby_block_seconds;
|
||||
int32_t report_cooldown_seconds;
|
||||
} Config;
|
||||
|
||||
SERVER_API extern Config g_config;
|
||||
SERVER_API extern cJSON* g_bans;
|
||||
SERVER_API extern cJSON* g_timeouts;
|
||||
SERVER_API extern cJSON* g_ops;
|
||||
SERVER_API extern cJSON* g_reports;
|
||||
SERVER_API extern cJSON* g_lobbyTimeouts;
|
||||
SERVER_API extern Mutex g_banMut;
|
||||
SERVER_API extern Mutex g_timeoutMut;
|
||||
SERVER_API extern Mutex g_opMut;
|
||||
SERVER_API extern Mutex g_reportMut;
|
||||
SERVER_API extern Mutex g_lobbyTimeoutMut;
|
||||
|
||||
SERVER_API bool config_init(void);
|
||||
SERVER_API bool config_save(void);
|
||||
|
||||
SERVER_API bool ban_add(const char* nickname, const char* udid, const char* ip);
|
||||
SERVER_API bool ban_revoke(const char* udid, const char* ip);
|
||||
SERVER_API bool ban_check(const char* udid, const char* ip, bool* result);
|
||||
|
||||
SERVER_API bool timeout_set(const char* nickname, const char* udid, const char* ip, uint64_t timestamp);
|
||||
SERVER_API bool timeout_revoke(const char* udid, const char* ip);
|
||||
SERVER_API bool timeout_check(const char* udid, const char* ip, uint64_t* result);
|
||||
|
||||
SERVER_API bool op_add(const char* nickname, const char* ip);
|
||||
SERVER_API bool op_revoke(const char* ip);
|
||||
SERVER_API bool op_check(const char* ip, bool* result);
|
||||
|
||||
SERVER_API bool report_add(const char* reporter, const char* target_nickname, const char* target_udid,
|
||||
const char* target_ip, const char* reason, int32_t server_id);
|
||||
SERVER_API bool report_clear(const char* key);
|
||||
SERVER_API bool report_clear_all(void);
|
||||
|
||||
/* Per-lobby timeouts: a player kicked out of one server instance is kept out of
|
||||
that instance only, and the block survives a restart until it expires. */
|
||||
SERVER_API bool lobby_timeout_set(const char* nickname, const char* udid, const char* ip,
|
||||
int32_t server_id, uint64_t until);
|
||||
SERVER_API bool lobby_timeout_check(const char* udid, const char* ip, int32_t server_id, uint64_t* until);
|
||||
SERVER_API bool lobby_timeout_revoke(const char* udid, const char* ip, int32_t server_id);
|
||||
SERVER_API bool lobby_timeout_clear_all(void);
|
||||
|
||||
bool collection_save(const char* file, cJSON* value);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef LINKEDLIST_H
|
||||
#define LINKEDLIST_H
|
||||
#include <Log.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void** ptr;
|
||||
size_t noitems;
|
||||
size_t capacity;
|
||||
} DyList;
|
||||
|
||||
bool dylist_create(DyList* list, size_t max_capacity);
|
||||
bool dylist_push(DyList* list, void* item);
|
||||
bool dylist_remove(DyList* list, void* item);
|
||||
void dylist_free(DyList* list);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef LIB_H
|
||||
#define LIB_H
|
||||
#include <Api.h>
|
||||
#include <enet/enet.h>
|
||||
#include <io/Threads.h>
|
||||
#include <DyList.h>
|
||||
#include <Packet.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DR_FAILEDTOCONNECT,
|
||||
DR_KICKEDBYHOST,
|
||||
DR_BANNEDBYHOST,
|
||||
DR_VERMISMATCH,
|
||||
DR_SERVERTIMEOUT,
|
||||
DR_PACKETSNOTRECV,
|
||||
DR_GAMESTARTED,
|
||||
DR_AFKTIMEOUT,
|
||||
DR_LOBBYFULL,
|
||||
DR_RATELIMITED,
|
||||
DR_SHUTDOWN,
|
||||
DR_IPINUSE,
|
||||
|
||||
DR_DONTREPORT = 254,
|
||||
DR_OTHER = 255
|
||||
} DisconnectReason;
|
||||
|
||||
struct Server;
|
||||
struct PeerData;
|
||||
typedef struct
|
||||
{
|
||||
struct PeerData* peer;
|
||||
String ip_addr;
|
||||
bool is_exe;
|
||||
int8_t character;
|
||||
} PeerInfo;
|
||||
|
||||
SERVER_API bool disaster_init (void);
|
||||
SERVER_API int disaster_run (void);
|
||||
SERVER_API bool disaster_start (void);
|
||||
SERVER_API int disaster_wait (void);
|
||||
SERVER_API void disaster_shutdown(void);
|
||||
|
||||
SERVER_API struct Server* disaster_get (int);
|
||||
SERVER_API int disaster_count (void);
|
||||
SERVER_API bool disaster_server_lock (struct Server* server);
|
||||
SERVER_API bool disaster_server_unlock (struct Server* server);
|
||||
SERVER_API uint8_t disaster_server_state (struct Server* server);
|
||||
SERVER_API bool disaster_server_ban (struct Server* server, uint16_t);
|
||||
SERVER_API bool disaster_server_op (struct Server* server, uint16_t);
|
||||
SERVER_API bool disaster_server_timeout (struct Server* server, uint16_t, double);
|
||||
SERVER_API bool disaster_server_peer (struct Server*, int, PeerInfo*);
|
||||
SERVER_API bool disaster_server_peer_disconnect (struct Server*, uint16_t, DisconnectReason, const char*);
|
||||
SERVER_API int disaster_server_peer_count (struct Server*);
|
||||
SERVER_API int disaster_server_peer_ingame (struct Server*);
|
||||
SERVER_API int8_t disaster_game_map (struct Server*);
|
||||
SERVER_API double disaster_game_time (struct Server*);
|
||||
SERVER_API uint16_t disaster_game_time_sec (struct Server*);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <Colors.h>
|
||||
#include <Api.h>
|
||||
#include <Config.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__unix) || defined(__unix__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
#else
|
||||
#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#endif
|
||||
|
||||
#ifdef SYS_USE_SDL2
|
||||
#define DEBUG_TYPE "DBG "
|
||||
#define INFO_TYPE "INF "
|
||||
#define WARN_TYPE "WRN "
|
||||
#define ERROR_TYPE "ERR "
|
||||
|
||||
#define LOG_GRN CLRCODE_GRN
|
||||
#define LOG_GRA CLRCODE_GRA
|
||||
#define LOG_RED CLRCODE_RED
|
||||
#define LOG_BLU CLRCODE_BLU
|
||||
#define LOG_YLW CLRCODE_YLW
|
||||
#define LOG_PUR CLRCODE_PUR
|
||||
#define LOG_RST CLRCODE_RST
|
||||
#else
|
||||
#define DEBUG_TYPE "\x1B[36mDBG \x1B[0m"
|
||||
#define INFO_TYPE "\x1B[32mINF \x1B[0m"
|
||||
#define WARN_TYPE "\x1B[33mWRN \x1B[0m"
|
||||
#define ERROR_TYPE "\x1B[31mERR \x1B[0m"
|
||||
|
||||
#define LOG_GRN
|
||||
#define LOG_GRA
|
||||
#define LOG_RED
|
||||
#define LOG_BLU
|
||||
#define LOG_YLW
|
||||
#define LOG_PUR
|
||||
#define LOG_RST
|
||||
#endif
|
||||
|
||||
#define Log(type, fmt, ...) log_fmt(fmt, type, __FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
#define Debug(fmt, ...) if(g_config.log_debug) log_fmt(fmt, DEBUG_TYPE, __FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
#define Info(fmt, ...) log_fmt(fmt, INFO_TYPE, __FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
#define Warn(fmt, ...) log_fmt(fmt, WARN_TYPE, __FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
#define Err(fmt, ...) log_fmt(fmt, ERROR_TYPE, __FILENAME__, __LINE__, ##__VA_ARGS__)
|
||||
#define RAssert(x) if (!(x)) { Err("RAssert(" #x ") failed!"); return false; }
|
||||
#define BoolStringify(bool) (bool ? "true" : "false")
|
||||
|
||||
typedef void (*loghook_t)(const char* type, const char* message);
|
||||
|
||||
bool log_init (void);
|
||||
SERVER_API void log_hook (loghook_t func);
|
||||
SERVER_API void log_fmt (const char* fmt, const char* type, const char* file, int line, ...);
|
||||
|
||||
#ifdef SYS_ANDROID
|
||||
void log_android(const char* type, const char* message);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef MAPS_H
|
||||
#define MAPS_H
|
||||
#include <Server.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
|
||||
struct
|
||||
{
|
||||
bool (*init)(Server*);
|
||||
bool (*tick)(Server*);
|
||||
bool (*tcp_msg)(PeerData*, Packet*);
|
||||
bool (*left)(PeerData*);
|
||||
} cb;
|
||||
|
||||
uint8_t spawn_red_rings;
|
||||
uint8_t ring_count;
|
||||
} Map;
|
||||
|
||||
#define MAP_COUNT 20
|
||||
#define MAP_FART_ZONE MAP_COUNT
|
||||
extern Map g_mapList[MAP_COUNT + 1];
|
||||
|
||||
bool map_init (Server* server);
|
||||
bool map_tick (Server* server);
|
||||
bool map_tcpmsg (PeerData* v, Packet* packet);
|
||||
bool map_left (PeerData* v);
|
||||
|
||||
bool map_time (Server* server, double seconds, float mul);
|
||||
bool map_ring (Server* server, int ringcoff);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,219 @@
|
||||
#ifndef PACKET_H
|
||||
#define PACKET_H
|
||||
#include <Log.h>
|
||||
#include <enet/enet.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IDENTITY,
|
||||
SERVER_IDENTITY_RESPONSE,
|
||||
|
||||
SERVER_PLAYER_JOINED,
|
||||
SERVER_PLAYER_LEFT,
|
||||
SERVER_PLAYER_FORCE_DISCONNECT,
|
||||
|
||||
SERVER_WAITING_PLAYER_INFO,
|
||||
|
||||
SERVER_LOBBY_READY_STATE,
|
||||
SERVER_LOBBY_EXE,
|
||||
SERVER_LOBBY_COUNTDOWN,
|
||||
SERVER_LOBBY_EXE_CHANGE,
|
||||
SERVER_LOBBY_CHARACTER_CHANGE,
|
||||
SERVER_LOBBY_CHARACTER_RESPONSE,
|
||||
SERVER_LOBBY_EXECHARACTER_RESPONSE,
|
||||
SERVER_LOBBY_GAME_START,
|
||||
SERVER_LOBBY_PLAYER,
|
||||
SERVER_LOBBY_EXE_CHANCE,
|
||||
SERVER_LOBBY_CORRECT,
|
||||
SERVER_LOBBY_CHOOSEVOTEKICK,
|
||||
SERVER_LOBBY_CHOOSEBAN,
|
||||
SERVER_LOBBY_CHOOSEKICK,
|
||||
SERVER_LOBBY_CHOOSEOP,
|
||||
SERVER_LOBBY_CHANGELOBBY,
|
||||
SERVER_CHAR_TIME_SYNC,
|
||||
|
||||
SERVER_VOTE_MAPS,
|
||||
SERVER_VOTE_SET,
|
||||
SERVER_VOTE_TIME_SYNC,
|
||||
|
||||
SERVER_GAME_PLAYERS_READY,
|
||||
SERVER_GAME_EXE_WINS,
|
||||
SERVER_GAME_SURVIVOR_WIN,
|
||||
SERVER_GAME_SPAWN_RING,
|
||||
SERVER_GAME_PLAYER_ESCAPED,
|
||||
SERVER_GAME_BACK_TO_LOBBY,
|
||||
SERVER_GAME_TIME_SYNC,
|
||||
SERVER_GAME_TIME_OVER,
|
||||
SERVER_GAME_PING,
|
||||
SERVER_PLAYER_DEATH_STATE,
|
||||
SERVER_GAME_DEATHTIMER_TICK,
|
||||
SERVER_GAME_DEATHTIMER_END,
|
||||
|
||||
SERVER_REQUEST_INFO,
|
||||
SERVER_HEARTBEAT,
|
||||
SERVER_PONG,
|
||||
|
||||
SERVER_FORCE_DAMAGE,
|
||||
SERVER_GAME_RING_READY,
|
||||
SERVER_PLAYER_BACKTRACK,
|
||||
|
||||
|
||||
SERVER_TPROJECTILE_STATE,
|
||||
SERVER_ETRACKER_STATE,
|
||||
SERVER_ERECTOR_BRING_SPAWN,
|
||||
SERVER_RMZSLIME_STATE,
|
||||
SERVER_RMZSLIME_RINGBONUS,
|
||||
SERVER_RMZSHARD_STATE,
|
||||
SERVER_LCEYE_STATE,
|
||||
SERVER_LCCHAIN_STATE,
|
||||
SERVER_NPCONTROLLER_STATE,
|
||||
SERVER_KAFMONITOR_STATE,
|
||||
SERVER_YCRSMOKE_STATE,
|
||||
SERVER_YCRSMOKE_READY,
|
||||
SERVER_MOVINGSPIKE_STATE,
|
||||
SERVER_RING_STATE,
|
||||
SERVER_RING_COLLECTED,
|
||||
SERVER_ACT9WALL_STATE,
|
||||
SERVER_NAPBALL_STATE,
|
||||
SERVER_NAPICE_STATE,
|
||||
SERVER_PFLIFT_STATE,
|
||||
SERVER_BRING_STATE,
|
||||
SERVER_BRING_COLLECTED,
|
||||
SERVER_VVLCOLUMN_STATE,
|
||||
SERVER_VVVASE_STATE,
|
||||
SERVER_GHZTHUNDER_STATE,
|
||||
SERVER_TCGOM_STATE,
|
||||
SERVER_EXELLERCLONE_STATE,
|
||||
SERVER_DTTAILSDOLL_STATE,
|
||||
SERVER_DTBALL_STATE,
|
||||
SERVER_DTASS_STATE,
|
||||
SERVER_HDDOOR_STATE,
|
||||
SERVER_WDLATERN_ACTIVATE,
|
||||
SERVER_FART_STATE,
|
||||
SERVER_MJLAVA_STATE,
|
||||
SERVER_MJJUDGER_STATE,
|
||||
SERVER_MJCRYSTAL_STATE,
|
||||
|
||||
|
||||
CLIENT_ETRACKER,
|
||||
CLIENT_ETRACKER_ACTIVATED,
|
||||
CLIENT_TPROJECTILE,
|
||||
CLIENT_TPROJECTILE_HIT,
|
||||
CLIENT_TPROJECTILE_STARTCHARGE,
|
||||
CLIENT_ERECTOR_BALLS,
|
||||
CLIENT_ERECTOR_BRING_SPAWN,
|
||||
CLIENT_EXELLER_SPAWN_CLONE,
|
||||
CLIENT_EXELLER_TELEPORT_CLONE,
|
||||
CLIENT_MERCOIN_BONUS,
|
||||
|
||||
CLIENT_RMZSLIME_HIT,
|
||||
CLIENT_LCEYE_REQUEST_ACTIVATE,
|
||||
CLIENT_KAFMONITOR_ACTIVATE,
|
||||
CLIENT_RING_COLLECTED,
|
||||
CLIENT_RING_BROKE,
|
||||
CLIENT_BRING_COLLECTED,
|
||||
CLIENT_NAPICE_ACTIVATE,
|
||||
CLIENT_SPRING_USE,
|
||||
CLIENT_PFLIT_ACTIVATE,
|
||||
CLIENT_VVVASE_BREAK,
|
||||
CLIENT_RMZSHARD_COLLECT,
|
||||
CLIENT_RMZSHARD_LAND,
|
||||
CLIENT_DTASS_ACTIVATE,
|
||||
CLIENT_HDDOOR_TOGGLE,
|
||||
CLIENT_FART_PUSH,
|
||||
|
||||
CLIENT_LOBBY_READY_STATE,
|
||||
CLIENT_REQUESTED_INFO,
|
||||
CLIENT_PLAYER_DATA,
|
||||
CLIENT_PLAYER_HURT,
|
||||
CLIENT_SOUND_EMIT,
|
||||
CLIENT_PING,
|
||||
|
||||
CLIENT_REVIVAL_PROGRESS,
|
||||
CLIENT_PLAYER_HEAL,
|
||||
CLIENT_PLAYER_HEAL_PART,
|
||||
SERVER_REVIVAL_PROGRESS,
|
||||
SERVER_REVIVAL_STATUS,
|
||||
SERVER_REVIVAL_RINGSUB,
|
||||
SERVER_REVIVAL_REVIVED,
|
||||
|
||||
CLIENT_REQUEST_CHARACTER,
|
||||
CLIENT_REQUEST_EXECHARACTER,
|
||||
CLIENT_VOTE_REQUEST,
|
||||
|
||||
CLIENT_PLAYER_DEATH_STATE,
|
||||
CLIENT_PLAYER_ESCAPED,
|
||||
SERVER_PLAYER_ESCAPED,
|
||||
CLIENT_LOBBY_PLAYERS_REQUEST,
|
||||
CLIENT_CREAM_SPAWN_RINGS,
|
||||
CLIENT_SPAWN_EFFECT,
|
||||
CLIENT_CHAT_MESSAGE,
|
||||
CLIENT_LOBBY_CHOOSEVOTEKICK,
|
||||
CLIENT_LOBBY_CHOOSEBAN,
|
||||
CLIENT_LOBBY_CHOOSEKICK,
|
||||
CLIENT_LOBBY_CHOOSEOP,
|
||||
CLIENT_PLAYER_PALETTE,
|
||||
CLIENT_PET_PALETTE,
|
||||
|
||||
SERVER_RESULTS,
|
||||
SERVER_RESULTS_DATA,
|
||||
CLIENT_RESULTS_REQUEST,
|
||||
CLIENT_STATS_REPORT,
|
||||
SERVER_PREIDENTITY,
|
||||
SERVER_FELLA,
|
||||
|
||||
CLIENT_PLAYER_POTATER
|
||||
} PacketType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#define PACKET_MAXSIZE 256
|
||||
|
||||
uint8_t buff[PACKET_MAXSIZE];
|
||||
uint8_t pos;
|
||||
uint8_t len;
|
||||
} Packet;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char value[250];
|
||||
uint16_t len;
|
||||
} String;
|
||||
|
||||
String string_new(const char* value);
|
||||
size_t string_length(String* str);
|
||||
String string_lower(String str);
|
||||
#define __Str(x) string_new(x)
|
||||
|
||||
bool packet_new(Packet* packet, PacketType type);
|
||||
Packet packet_from(ENetPacket* packet);
|
||||
|
||||
struct Server;
|
||||
bool packet_send(ENetPeer* peer, Packet* packet, bool reliable);
|
||||
bool packet_send_id(struct Server* server, uint16_t id, Packet* packet, bool reliable);
|
||||
bool packet_seek(Packet* packet, int wh);
|
||||
|
||||
bool packet_read8(Packet* packet, uint8_t* out);
|
||||
bool packet_read16(Packet* packet, uint16_t* out);
|
||||
bool packet_read32(Packet* packet, uint32_t* out);
|
||||
bool packet_read64(Packet* packet, uint64_t* out);
|
||||
bool packet_readfloat(Packet* packet, float* out);
|
||||
bool packet_readdouble(Packet* packet, double* out);
|
||||
bool packet_readstr(Packet* packet, String* out);
|
||||
|
||||
bool packet_write8(Packet* packet, uint8_t value);
|
||||
bool packet_write16(Packet* packet, uint16_t value);
|
||||
bool packet_write32(Packet* packet, uint32_t value);
|
||||
bool packet_write64(Packet* packet, uint64_t value);
|
||||
bool packet_writefloat(Packet* packet, float value);
|
||||
bool packet_writedouble(Packet* packet, double value);
|
||||
bool packet_writestr(Packet* packet, String value);
|
||||
|
||||
#define PacketCreate(packet, type) RAssert(packet_new(packet, type))
|
||||
#define PacketRead(outname, packet, func, type)\
|
||||
type outname;\
|
||||
RAssert(func(packet, (void*)&outname))
|
||||
#define PacketWrite(packet, func, val) RAssert(func(packet, val))
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef PALETTE_H
|
||||
#define PALETTE_H
|
||||
#include <Packet.h>
|
||||
#include <Server.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool palette_player_validate(PeerData* v, Packet* packet);
|
||||
bool palette_player_reset(PeerData* v);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
#include <io/Time.h>
|
||||
#include <Packet.h>
|
||||
#include <CMath.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PLAYER_HISTORY_TICKS (4 * 60)
|
||||
typedef enum
|
||||
{
|
||||
PLAYER_NONE = 0,
|
||||
PLAYER_ESCAPED = 0x1 << 0,
|
||||
PLAYER_DEAD = 0x1 << 1,
|
||||
PLAYER_DEMONIZED = 0x1 << 2,
|
||||
PLAYER_REVIVED = 0x1 << 3,
|
||||
PLAYER_CANTREVIVE = 0x1 << 4,
|
||||
PLAYER_LEFT = 0x1 << 5,
|
||||
PLAYER_KILLER = 0x1 << 6,
|
||||
PLAYER_FIRST_HALF_DEAD = 0x1 << 7,
|
||||
PLAYER_FROZEN_DEMON = 0x1 << 8
|
||||
} PlayerFlags;
|
||||
typedef struct
|
||||
{
|
||||
double elapsed;
|
||||
Vector2 pos;
|
||||
uint8_t state;
|
||||
bool attacking;
|
||||
} PlayerHistorySample;
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ready;
|
||||
uint16_t seq;
|
||||
uint16_t errors;
|
||||
uint8_t ex_teleport;
|
||||
double timeout;
|
||||
uint8_t mod_tool;
|
||||
uint32_t mod_tool_timer;
|
||||
uint32_t chunk;
|
||||
|
||||
bool is_attacking;
|
||||
double attack_timer;
|
||||
TimeStamp last_attack;
|
||||
uint16_t ping_last;
|
||||
double ping_total;
|
||||
double ping_timer;
|
||||
uint16_t rings;
|
||||
TimeStamp last_rings;
|
||||
TimeStamp tails_last_proj;
|
||||
uint16_t heal_rings;
|
||||
uint8_t state;
|
||||
PlayerFlags flags;
|
||||
bool kill_reported;
|
||||
bool onehit_checked;
|
||||
uint8_t death_timer_sec;
|
||||
double death_timer;
|
||||
double revival;
|
||||
int32_t revival_init[5];
|
||||
uintptr_t data[4];
|
||||
Vector2 start_pos;
|
||||
Vector2 pos;
|
||||
double last_recv_elapsed;
|
||||
uint32_t dead_fully_tick;
|
||||
float recv_vx;
|
||||
float recv_vy;
|
||||
Vector2 prev_recv_pos;
|
||||
bool prev_recv_valid;
|
||||
uint32_t prev_recv_tick;
|
||||
PlayerHistorySample history[PLAYER_HISTORY_TICKS];
|
||||
uint16_t history_head;
|
||||
uint16_t history_count;
|
||||
struct
|
||||
{
|
||||
double survive_time;
|
||||
double danger_time;
|
||||
double camp_time;
|
||||
double braindead_time;
|
||||
bool brain_damage;
|
||||
uint32_t stun_time;
|
||||
uint32_t stuns;
|
||||
uint32_t hp_restored;
|
||||
uint32_t rings;
|
||||
uint32_t damage_raw;
|
||||
uint32_t damage_taken_raw;
|
||||
uint32_t damage;
|
||||
uint32_t damage_taken;
|
||||
uint32_t kills;
|
||||
} stats;
|
||||
} Player;
|
||||
#define SET_FLAG(x, flag) x |= (flag)
|
||||
#define DEL_FLAG(x, flag) x = x & ~(flag)
|
||||
struct Server;
|
||||
struct PeerData;
|
||||
bool player_add_error(struct Server* server, struct PeerData* v, uint16_t by);
|
||||
void player_check_zone(struct Server* server, struct PeerData* v);
|
||||
void player_history_reset(Player *player);
|
||||
void player_history_append(Player *player, double elapsed, Vector2 pos, uint8_t state, bool attacking);
|
||||
bool player_history_at_or_before(const Player *player, double target_elapsed, PlayerHistorySample *out);
|
||||
#endif
|
||||
@@ -0,0 +1,319 @@
|
||||
#ifndef SERVER_H
|
||||
#define SERVER_H
|
||||
|
||||
#include <Auth.h>
|
||||
#include <DyList.h>
|
||||
#include <Lib.h>
|
||||
#include <Log.h>
|
||||
#include <Vote.h>
|
||||
#include <Player.h>
|
||||
#include <Packet.h>
|
||||
#include <io/Threads.h>
|
||||
#include <io/Time.h>
|
||||
#include <enet/enet.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#define TICKSPERSEC 60
|
||||
#define MAX_SUPPORTED_PLAYERS 100
|
||||
#define DEFAULT_MAX_SIMULTANEOUS_PLAYERS 100
|
||||
#define MAP_FART_ZONE MAP_COUNT
|
||||
|
||||
#define PING_INITIAL_DELAY_TICKS (5 * TICKSPERSEC)
|
||||
#define PING_REPORT_INTERVAL_TICKS (10 * TICKSPERSEC)
|
||||
#define PING_REPORT_DELTA_MS 10
|
||||
#define PING_REPORTS_PER_TICK 1
|
||||
#define MAX_SERVICE_EVENTS_PER_LOOP 256
|
||||
|
||||
/* How long a worker may sleep when its lobby is completely empty. An empty
|
||||
ST_LOBBY has no per-tick work, and a connecting peer wakes the select()
|
||||
inside enet_host_service immediately, so this only costs idle wake-ups. */
|
||||
#define SERVER_IDLE_SLEEP_MS 100
|
||||
|
||||
#define RELAY_HEARTBEAT_INTERVAL_TICKS (2 * TICKSPERSEC)
|
||||
#define MAX_CATCHUP_TICKS 3
|
||||
#define RELAY_PRIORITY_DURATION_TICKS ((uint32_t)(3.5 * TICKSPERSEC))
|
||||
#define RELAY_COMBAT_RADIUS 800.0f
|
||||
#define RELAY_TIER_STABILIZATION_TICKS (2 * TICKSPERSEC)
|
||||
#define RELAY_TIER_DOWNGRADE_MARGIN 2
|
||||
#define RELAY_AOI_RADIUS_PX 500.0f
|
||||
#define RELAY_AOI_OFF_ZONE_INTERVAL_TICKS (TICKSPERSEC / 3)
|
||||
#define RELAY_SEND_BUDGET 1024
|
||||
#define GAME_ENTITY_CAPACITY 16384
|
||||
#define GAME_MAX_DESPAWNS_PER_TICK 2048
|
||||
#define MAX_CREAM_RINGS_QUERY 512
|
||||
|
||||
#ifndef PLAYER_HISTORY_TICKS
|
||||
#define PLAYER_HISTORY_TICKS (4 * TICKSPERSEC)
|
||||
#endif
|
||||
#define HIGH_PING_DEFENDER_MS 150
|
||||
#define MAX_DEFENDER_REWIND_MS 250
|
||||
|
||||
#define BUILD_VERSION 1101
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STRINGIFY(x) STR_HELPER(x)
|
||||
|
||||
struct Server;
|
||||
struct auth_peer_data;
|
||||
typedef struct
|
||||
{
|
||||
Vector2 offset;
|
||||
float last_vx;
|
||||
float last_vy;
|
||||
uint32_t last_tick;
|
||||
uint32_t aoi_last_send_tick;
|
||||
uint16_t recipient_id;
|
||||
bool valid;
|
||||
} RelayCorrectionState;
|
||||
|
||||
typedef struct PeerData
|
||||
{
|
||||
uint16_t id;
|
||||
String ip;
|
||||
ENetPeer *peer;
|
||||
|
||||
Player plr;
|
||||
String nickname;
|
||||
String udid;
|
||||
uint8_t lobby_icon;
|
||||
int8_t pet;
|
||||
|
||||
bool verified;
|
||||
bool in_game;
|
||||
bool op;
|
||||
bool ready;
|
||||
bool mod_tool;
|
||||
bool is_mobile;
|
||||
bool can_vote;
|
||||
bool voted;
|
||||
bool disconnecting;
|
||||
|
||||
auth_peer_data auth;
|
||||
|
||||
enum
|
||||
{
|
||||
CH_NONE = -1,
|
||||
|
||||
CH_TAILS,
|
||||
CH_KNUX,
|
||||
CH_EGGMAN,
|
||||
CH_AMY,
|
||||
CH_CREAM,
|
||||
CH_SALLY
|
||||
} surv_char;
|
||||
|
||||
enum
|
||||
{
|
||||
EX_NONE = -1,
|
||||
|
||||
EX_ORIGINAL,
|
||||
EX_CHAOS,
|
||||
EX_EXETIOR,
|
||||
EX_EXELLER
|
||||
} exe_char;
|
||||
|
||||
bool should_timeout;
|
||||
|
||||
uint64_t last_report_time;
|
||||
|
||||
uint8_t exe_chance;
|
||||
double timeout;
|
||||
double vote_cooldown;
|
||||
|
||||
uint8_t player_data[PACKET_MAXSIZE - 2];
|
||||
uint8_t player_data_len;
|
||||
bool player_data_valid;
|
||||
uint8_t last_relay_state;
|
||||
Vector2 relay_latest_pos;
|
||||
Vector2 relay_previous_pos;
|
||||
uint16_t relay_latest_xspd;
|
||||
uint16_t relay_latest_yspd;
|
||||
uint32_t relay_latest_tick;
|
||||
uint32_t relay_previous_tick;
|
||||
uint32_t relay_update_interval;
|
||||
uint32_t priority_until_tick;
|
||||
double relay_next_elapsed;
|
||||
uint32_t relay_last_fill_tick;
|
||||
uint32_t relay_last_send_tick;
|
||||
Vector2 relay_last_sent_pos;
|
||||
float relay_last_sent_vx;
|
||||
float relay_last_sent_vy;
|
||||
bool relay_last_sent_valid;
|
||||
bool relay_stop_pending;
|
||||
bool relay_force_pending;
|
||||
RelayCorrectionState relay_corrections[MAX_SUPPORTED_PLAYERS + 1];
|
||||
|
||||
uint16_t ping_reported_value;
|
||||
uint32_t ping_last_report_tick;
|
||||
bool ping_has_report;
|
||||
bool ping_initial_pending;
|
||||
|
||||
struct Server *server;
|
||||
} PeerData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
double countdown;
|
||||
uint8_t countdown_sec;
|
||||
Vote vote;
|
||||
PeerData kick_target;
|
||||
|
||||
uint8_t maps[3];
|
||||
uint8_t votes[3];
|
||||
uint8_t pool[20];
|
||||
uint8_t pool_size;
|
||||
uint8_t wait_queue[20];
|
||||
uint8_t wait_size;
|
||||
|
||||
int8_t map;
|
||||
uint16_t exe;
|
||||
bool avail[CH_SALLY + 1];
|
||||
uint8_t surv_reservations[CH_SALLY + 1];
|
||||
|
||||
int8_t pending_map;
|
||||
bool pending_map_set;
|
||||
} Lobby;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BS_NONE,
|
||||
BS_DEACTIVATED,
|
||||
BS_ACTIVATED,
|
||||
} BigRingState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ED_EXEWIN,
|
||||
ED_SURVWIN,
|
||||
ED_TIMEOVER
|
||||
} Ending;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int exe;
|
||||
int8_t map;
|
||||
bool started;
|
||||
bool sudden_death;
|
||||
int match_initial_survivors;
|
||||
int death_order_count;
|
||||
bool last_minute_sweep_done;
|
||||
bool sixty_second_sweep_done;
|
||||
bool duel_triggered;
|
||||
double duel_ring_clear_at;
|
||||
double duel_boost_until;
|
||||
double ring_spawn_disabled_until;
|
||||
uint16_t *pending_demonize;
|
||||
size_t pending_demonize_capacity;
|
||||
size_t pending_demonize_count;
|
||||
|
||||
double start_timeout;
|
||||
double time;
|
||||
double elapsed;
|
||||
uint16_t time_sec;
|
||||
double end;
|
||||
Ending ending;
|
||||
|
||||
BigRingState bring_state;
|
||||
uint8_t bring_loc;
|
||||
|
||||
uint16_t entid;
|
||||
DyList entities;
|
||||
|
||||
bool rings[256];
|
||||
uint8_t ring_coff;
|
||||
double ring_accum;
|
||||
int base_red_ring_chance;
|
||||
int active_red_ring_count;
|
||||
int base_ring_coff;
|
||||
int total_red_rings_spawned;
|
||||
int total_red_rings_picked_up;
|
||||
uint16_t cream_guard_id;
|
||||
int onehit_checked_count;
|
||||
bool last_survivor_disabled;
|
||||
|
||||
DyList left;
|
||||
|
||||
uint32_t tick;
|
||||
uint32_t relay_accumulator;
|
||||
uint8_t relay_tier;
|
||||
uint8_t relay_pending_tier;
|
||||
uint16_t relay_stable_ticks;
|
||||
uint32_t ping_initial_tick;
|
||||
uint16_t ping_cursor;
|
||||
uint16_t relay_source_cursor;
|
||||
uint16_t relay_recipient_cursor;
|
||||
} Game;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double countdown;
|
||||
} Results;
|
||||
|
||||
typedef struct Server
|
||||
{
|
||||
uint16_t id;
|
||||
atomic_bool running;
|
||||
|
||||
enum
|
||||
{
|
||||
ST_LOBBY,
|
||||
ST_MAPVOTE,
|
||||
ST_CHARSELECT,
|
||||
ST_GAME,
|
||||
ST_RESULTS
|
||||
} state;
|
||||
Mutex state_lock;
|
||||
|
||||
Lobby lobby;
|
||||
Game game;
|
||||
Results results;
|
||||
|
||||
int8_t last_map;
|
||||
|
||||
double delta;
|
||||
DyList peers;
|
||||
ENetHost *host;
|
||||
|
||||
uint32_t tick;
|
||||
} Server;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int8_t index;
|
||||
bool regular_rotation;
|
||||
} NormalizedMap;
|
||||
|
||||
bool server_normalize_map_argument(const char *text, NormalizedMap *out);
|
||||
|
||||
bool server_state_joined(PeerData *v);
|
||||
bool server_state_left(PeerData *v);
|
||||
bool server_state_handle(PeerData *v, Packet *packet);
|
||||
bool server_msg_handle(Server *server, PacketType type, PeerData *v, Packet *packet);
|
||||
bool server_cmd_handle(Server *server, unsigned long hash, PeerData *v, String *msg);
|
||||
unsigned long server_cmd_parse(String *string);
|
||||
|
||||
bool server_global_init(void);
|
||||
bool server_worker(Server *server);
|
||||
bool server_broadcast(Server *server, Packet *packet, bool reliable);
|
||||
bool server_broadcast_ex(Server *server, Packet *packet, bool reliable, uint16_t ignore);
|
||||
bool server_send_msg(Server *server, ENetPeer *peer, const char *message);
|
||||
bool server_send_motd(Server *server, ENetPeer *peer);
|
||||
bool server_broadcast_msg(Server *server, const char *message);
|
||||
bool relay_cache_player_data(PeerData *source, const Packet *incoming);
|
||||
void relay_invalidate_player_data(PeerData *source);
|
||||
void relay_mark_priority_near(Server *server, const Vector2 *center);
|
||||
void server_relay_fill(Server *server);
|
||||
void server_relay_tick(Server *server);
|
||||
|
||||
int server_total(Server *server);
|
||||
int server_ingame(Server *server);
|
||||
PeerData *server_find_peer(Server *server, uint16_t id);
|
||||
void report_normalize_name(const char *src, char *dst, size_t dst_size);
|
||||
PeerData *server_resolve_peer(Server *server, const char *query, const char **problem);
|
||||
bool server_disconnect(Server *server, ENetPeer *peer, DisconnectReason reason, const char *text);
|
||||
bool server_disconnect_id(Server *server, uint16_t id, DisconnectReason reason, const char *text);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
#ifndef LOBBY_H
|
||||
#define LOBBY_H
|
||||
#include <Server.h>
|
||||
#include <Log.h>
|
||||
#include <Maps.h>
|
||||
#include <Player.h>
|
||||
|
||||
#define AssertOrDisconnect(server, x) if(!(x)) { server_disconnect(server, v->peer, DR_OTHER, "AssertOrDisconnect(" #x ") failed!"); return false; }
|
||||
#define ENTITY_BODY \
|
||||
char tag[16];\
|
||||
uint16_t id;\
|
||||
Vector2 pos;\
|
||||
bool (*init)(Server*, struct Entity*);\
|
||||
bool (*tick)(Server*, struct Entity*);\
|
||||
bool (*uninit)(Server*, struct Entity*);
|
||||
|
||||
struct Entity;
|
||||
typedef struct Entity
|
||||
{
|
||||
ENTITY_BODY
|
||||
} Entity;
|
||||
#define MakeEntity(tag, x, y) tag, 0, (Vector2){ x, y },
|
||||
|
||||
#define CMD_HELP 45680751
|
||||
#define CMD_MAP 1478254
|
||||
#define CMD_STINK 1426706039
|
||||
#define CMD_VK 47971
|
||||
#define CMD_VP 47976
|
||||
#define CMD_BAN 1467681
|
||||
#define CMD_KICK 45773684
|
||||
#define CMD_OP 47759
|
||||
#define CMD_YES 1489913
|
||||
#define CMD_Y 1547
|
||||
#define CMD_NO 47727
|
||||
#define CMD_N 1536
|
||||
#define CMD_INFO 45719004
|
||||
#define CMD_LOBBY 1420085352
|
||||
#define CMD_TM 47911
|
||||
#define CMD_CM 47384
|
||||
#define CMD_REPORT 1235942114
|
||||
#define CMD_PLAYERS 2366296516
|
||||
#define CMD_WHO 1488080
|
||||
#define CMD_PING 45922976
|
||||
#define CMD_COMMANDS 2153905334
|
||||
#define CMD_CMDS 45539239
|
||||
|
||||
bool lobby_init(Server* server);
|
||||
bool lobby_state_join(PeerData* v);
|
||||
bool lobby_state_left(PeerData* v);
|
||||
bool lobby_state_handle(PeerData* v, Packet* packet);
|
||||
bool lobby_state_tick(Server* server);
|
||||
void lobby_check_vote(Server* server);
|
||||
|
||||
bool mapvote_init(Server* server);
|
||||
bool mapvote_pool_init(Server* server);
|
||||
bool mapvote_state_join(PeerData * v);
|
||||
bool mapvote_state_left(PeerData * v);
|
||||
bool mapvote_state_handle(PeerData* v, Packet* packet);
|
||||
bool mapvote_state_tick(Server* server);
|
||||
|
||||
bool charselect_init(int8_t map, Server* server);
|
||||
bool charselect_state_join(PeerData* v);
|
||||
bool charselect_state_left(PeerData* v);
|
||||
bool charselect_state_handle(PeerData* v, Packet * packet);
|
||||
bool charselect_state_tick(Server* server);
|
||||
|
||||
bool game_end(Server* server, Ending ending, bool achiv);
|
||||
bool game_init(int exe, int8_t map, Server* server);
|
||||
bool game_uninit(Server* server, bool show_results);
|
||||
bool game_spawn(Server* server, Entity* entity, size_t size, Entity** out);
|
||||
bool game_despawn(Server* server, Entity** out, uint16_t id);
|
||||
int game_find(Server* server, Entity** out, char* tag, size_t count);
|
||||
|
||||
bool game_bigring(Server* server, BigRingState state);
|
||||
bool game_state_join(PeerData* v);
|
||||
bool game_state_left(PeerData* v);
|
||||
bool game_state_handletcp(PeerData* v, Packet* packet);
|
||||
bool game_state_tick(Server* server);
|
||||
|
||||
bool results_init(Server* server);
|
||||
bool results_state_tick(Server* server);
|
||||
bool results_state_handle(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef UTF8_H
|
||||
#define UTF8_H
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
typedef int utf8_char;
|
||||
|
||||
utf8_char utf8_tolower(utf8_char c);
|
||||
utf8_char utf8_get(const char* str, int index);
|
||||
size_t utf8_strlen(const char* str);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef VOTE_H
|
||||
#define VOTE_H
|
||||
#include <Log.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VOTE_KICK,
|
||||
VOTE_PRACTICE
|
||||
} VoteType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VOTE_SUCCESS = 1,
|
||||
VOTE_ALREADYVOTED = 0,
|
||||
VOTE_FULL = -1
|
||||
} VoteState;
|
||||
|
||||
/* One slot per player that could possibly be connected. The old array held 7
|
||||
entries while every connected player is allowed to vote, so a busy lobby
|
||||
wrote past the end of the struct. */
|
||||
#ifndef VOTE_MAX_VOTERS
|
||||
#define VOTE_MAX_VOTERS 128
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
VoteType type;
|
||||
bool ongoing;
|
||||
uint16_t votes[VOTE_MAX_VOTERS];
|
||||
uint8_t votecnt;
|
||||
uint16_t novotes[VOTE_MAX_VOTERS];
|
||||
uint8_t novotecnt;
|
||||
uint8_t votetotal;
|
||||
double countdown;
|
||||
} Vote;
|
||||
|
||||
struct Server;
|
||||
bool vote_init(struct Server* server, Vote* vote, VoteType type, uint16_t id);
|
||||
VoteState vote_add(Vote* vote, uint16_t id);
|
||||
VoteState vote_add_no(Vote* vote, uint16_t id);
|
||||
bool vote_tick(struct Server* server, Vote* vote);
|
||||
bool vote_check(Vote* vote);
|
||||
bool vote_rejected(Vote* vote);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef ZONE_H
|
||||
#define ZONE_H
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x, y, w, h;
|
||||
} Zone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double min_x, min_y, max_x, max_y;
|
||||
bool valid;
|
||||
} ZoneBounds;
|
||||
|
||||
extern Zone* g_mapZone[21];
|
||||
extern size_t g_mapZoneSize[21];
|
||||
extern ZoneBounds g_mapZoneBounds[21];
|
||||
|
||||
#endif
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 16
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7)
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
typedef struct cJSON
|
||||
{
|
||||
|
||||
struct cJSON* next;
|
||||
struct cJSON* prev;
|
||||
|
||||
struct cJSON* child;
|
||||
|
||||
|
||||
int type;
|
||||
|
||||
|
||||
char* valuestring;
|
||||
|
||||
int valueint;
|
||||
|
||||
double valuedouble;
|
||||
|
||||
|
||||
char* string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
|
||||
void* (CJSON_CDECL* malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL* free_fn)(void* ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
|
||||
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_Parse(const char* value);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_ParseWithLength(const char* value, size_t buffer_length);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_ParseWithOpts(const char* value, const char** return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_ParseWithLengthOpts(const char* value, size_t buffer_length, const char** return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
|
||||
CJSON_PUBLIC(char*) cJSON_Print(const cJSON* item);
|
||||
|
||||
CJSON_PUBLIC(char*) cJSON_PrintUnformatted(const cJSON* item);
|
||||
|
||||
CJSON_PUBLIC(char*) cJSON_PrintBuffered(const cJSON* item, int prebuffer, cJSON_bool fmt);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON* item, char* buffer, const int length, const cJSON_bool format);
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON* item);
|
||||
|
||||
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON* array);
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_GetArrayItem(const cJSON* array, int index);
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_GetObjectItem(const cJSON* const object, const char* const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_GetObjectItemCaseSensitive(const cJSON* const object, const char* const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON* object, const char* string);
|
||||
|
||||
CJSON_PUBLIC(const char*) cJSON_GetErrorPtr(void);
|
||||
|
||||
|
||||
CJSON_PUBLIC(char*) cJSON_GetStringValue(const cJSON* const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON* const item);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON* const item);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateString(const char* string);
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateRaw(const char* raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateObject(void);
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateStringReference(const char* string);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateObjectReference(const cJSON* child);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateArrayReference(const cJSON* child);
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateIntArray(const int* numbers, int count);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateFloatArray(const float* numbers, int count);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateDoubleArray(const double* numbers, int count);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_CreateStringArray(const char* const* strings, int count);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON* array, cJSON* item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON* object, const char* string, cJSON* item);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON* object, const char* string, cJSON* item);
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON* array, cJSON* item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON* object, const char* string, cJSON* item);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_DetachItemViaPointer(cJSON* parent, cJSON* const item);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_DetachItemFromArray(cJSON* array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON* array, int which);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_DetachItemFromObject(cJSON* object, const char* string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_DetachItemFromObjectCaseSensitive(cJSON* object, const char* string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON* object, const char* string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON* object, const char* string);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON* array, int which, cJSON* newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON* const parent, cJSON* const item, cJSON* replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON* array, int which, cJSON* newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON* object, const char* string, cJSON* newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON* object, const char* string, cJSON* newitem);
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_Duplicate(const cJSON* item, cJSON_bool recurse);
|
||||
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON* const a, const cJSON* const b, const cJSON_bool case_sensitive);
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char* json);
|
||||
|
||||
|
||||
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON* const object, const char* const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON* const object, const char* const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON* const object, const char* const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON* const object, const char* const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON* const object, const char* const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON* const object, const char* const name, const char* const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON* const object, const char* const name, const char* const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON* const object, const char* const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON* const object, const char* const name);
|
||||
|
||||
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON* object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON* object, const char* valuestring);
|
||||
|
||||
|
||||
#define cJSON_SetBoolValue(object, boolValue) ( \
|
||||
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
|
||||
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
|
||||
cJSON_Invalid\
|
||||
)
|
||||
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
CJSON_PUBLIC(void*) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void* object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef ACT9WALL_H
|
||||
#define ACT9WALL_H
|
||||
#include "../States.h"
|
||||
|
||||
bool act9wall_init(Server* server, Entity* entity);
|
||||
bool act9wall_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t wid;
|
||||
double start_time;
|
||||
double init_elapsed;
|
||||
bool shrink_started;
|
||||
} Act9Wall;
|
||||
#define MakeAct9Wall(wid, x, y) ((Act9Wall) { MakeEntity("act9wall", x, y) act9wall_init, act9wall_tick, NULL, wid, 0, 0, false })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef BRING_H
|
||||
#define BRING_H
|
||||
#include "../States.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bool bring_init(Server* server, Entity* entity);
|
||||
bool bring_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
} BRing;
|
||||
#define MakeBlackRing(x, y) ((BRing) { MakeEntity("bring", x, y) bring_init, NULL, bring_uninit})
|
||||
#define MAP_BRING INT16_MAX
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef CREAM_RING
|
||||
#define CREAM_RING
|
||||
#include "../States.h"
|
||||
|
||||
bool cring_init(Server* server, Entity* entity);
|
||||
bool cring_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t rid;
|
||||
uint8_t red;
|
||||
} CreamRing;
|
||||
#define MakeCreamRing(x, y, red) ((CreamRing) { MakeEntity("cring", x, y) cring_init, NULL, cring_uninit, 255, red })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef DTBALL_H
|
||||
#define DTBALL_H
|
||||
#include "../States.h"
|
||||
|
||||
bool dtball_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double state;
|
||||
uint8_t side;
|
||||
} DTBall;
|
||||
#define MakeDTBall() ((DTBall) { MakeEntity("dtball", 0, 0) NULL, dtball_tick, NULL, 0, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef DTSTALACTITS_H
|
||||
#define DTSTALACTITS_H
|
||||
#include "../States.h"
|
||||
|
||||
bool dtst_init(Server* server, Entity* entity);
|
||||
bool dtst_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t sid;
|
||||
bool state;
|
||||
bool show;
|
||||
uint16_t sx, sy;
|
||||
double timer;
|
||||
float vel;
|
||||
} DTStalactits;
|
||||
#define MakeDTStalactiti(id, x, y) ((DTStalactits) { MakeEntity("dttits", x, y) dtst_init, dtst_tick, NULL, id, 0, 1, x, y, 0, 0 })
|
||||
|
||||
bool dtst_activate(Server* server, DTStalactits* tits);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef DUMMY_H
|
||||
#define DUMMY_H
|
||||
#include "../States.h"
|
||||
|
||||
bool dummy_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double vel;
|
||||
} Dummy;
|
||||
#define MakeDummy() ((Dummy) { MakeEntity("dummy", 1616, 2608) NULL, dummy_tick, NULL, 0 })
|
||||
|
||||
void dummy_activate(Dummy* dummy, int8_t dir);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef EGGTRACK
|
||||
#define EGGTRACK
|
||||
#include "../States.h"
|
||||
|
||||
bool eggtrack_init(Server* server, Entity* entity);
|
||||
bool eggtrack_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint16_t activ_id;
|
||||
} EggTracker;
|
||||
#define MakeEggTrack(x, y) ((EggTracker) { MakeEntity("eggtrack", x, y) eggtrack_init, NULL, eggtrack_uninit, 0, })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef EXELCLONE_H
|
||||
#define EXELCLONE_H
|
||||
#include "../States.h"
|
||||
|
||||
bool exclone_init(Server* server, Entity* entity);
|
||||
bool exclone_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
int8_t dir;
|
||||
uint16_t owner;
|
||||
} ExellerClone;
|
||||
#define MakeExellerClone(x, y, dir, owner) ((ExellerClone) { MakeEntity("exclone", x, y) exclone_init, NULL, exclone_uninit, dir, owner })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef HDDOOR_H
|
||||
#define HDDOOR_H
|
||||
#include "../States.h"
|
||||
|
||||
bool hddoor_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t state;
|
||||
double timer;
|
||||
} HDDoor;
|
||||
|
||||
#define MakeHDDoor() ((HDDoor) { MakeEntity("hddoor", 0, 0) NULL, hddoor_tick, NULL, 0, 0 })
|
||||
bool hddoor_toggle(Server* server, HDDoor* door);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef GHZTHUNDER_H
|
||||
#define GHZTHUNDER_H
|
||||
#include "../States.h"
|
||||
|
||||
bool thunder_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double timer;
|
||||
bool flag;
|
||||
} Thunder;
|
||||
#define MakeThunder() ((Thunder) { MakeEntity("thunder", 0, 0) NULL, thunder_tick, NULL, (15 + (rand() % 5)) * TICKSPERSEC, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef KAFSPEEDBOX_H
|
||||
#define KAFSPEEDBOX_H
|
||||
#include "../States.h"
|
||||
|
||||
bool kafbox_init(Server* server, Entity* entity);
|
||||
bool kafbox_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t nid;
|
||||
double timer;
|
||||
bool activated;
|
||||
} KafBox;
|
||||
#define MakeKafBox(nid) ((KafBox) { MakeEntity("kafbox", 0, 0) kafbox_init, kafbox_tick, NULL, nid, 0, 0, })
|
||||
|
||||
bool kafbox_activate(Server* server, KafBox* box, uint16_t pid, uint8_t is_proj);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef LCCHAIN_H
|
||||
#define LCCHAIN_H
|
||||
#include "../States.h"
|
||||
|
||||
bool lcchain_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double timer;
|
||||
enum
|
||||
{
|
||||
LCC_NONE,
|
||||
LCC_PREPARE,
|
||||
LCC_ACTIVATE
|
||||
} state;
|
||||
} LCChain;
|
||||
|
||||
#define MakeLCChain() ((LCChain) { MakeEntity("lcchain", 0, 0) NULL, lcchain_tick, NULL, 0, LCC_NONE })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef LCEYE_H
|
||||
#define LCEYE_H
|
||||
#include "../States.h"
|
||||
|
||||
bool lceye_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t eye_id;
|
||||
uint16_t use_id;
|
||||
bool used;
|
||||
uint8_t charge;
|
||||
uint16_t target;
|
||||
|
||||
double cooldown;
|
||||
double timer;
|
||||
|
||||
} LCEye;
|
||||
|
||||
#define MakeLCEye(id) ((LCEye) { MakeEntity("lceye", 0, 0) NULL, lceye_tick, NULL, id, 0, 0, 100, 0, 0, 0 })
|
||||
bool lceye_update(Server* server, LCEye* eye);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef MJASS_H
|
||||
#define MJASS_H
|
||||
#include "../States.h"
|
||||
|
||||
bool mass_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double next_time;
|
||||
double timer;
|
||||
bool state;
|
||||
} MAss;
|
||||
#define MakeMAss() ((MAss) { MakeEntity("mass", 0, 0) NULL, mass_tick, NULL, 10 * TICKSPERSEC, 0.0, false })
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MJJUDGER_H
|
||||
#define MJJUDGER_H
|
||||
#include "../States.h"
|
||||
|
||||
bool mjew_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double next_time;
|
||||
double timer;
|
||||
enum
|
||||
{
|
||||
MJJ_WAIT,
|
||||
MJJ_PREPARE,
|
||||
MJJ_FIRE
|
||||
} state;
|
||||
} MJew;
|
||||
#define MakeMJew() ((MJew) { MakeEntity("mjud", 0, 0) NULL, mjew_tick, NULL, (10 + rand() % 5) * TICKSPERSEC, 0.0, MJJ_WAIT })
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MJLAVA_H
|
||||
#define MJLAVA_H
|
||||
#include "../States.h"
|
||||
|
||||
bool mlava_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
enum
|
||||
{
|
||||
MLV_IDLE,
|
||||
MLV_MOVEDOWN,
|
||||
MLV_RAISE,
|
||||
MLV_MOVE,
|
||||
MLV_LOWER
|
||||
} state;
|
||||
double timer;
|
||||
float start;
|
||||
float dist;
|
||||
float vel;
|
||||
|
||||
} MLava;
|
||||
#define MakeMLava(start, dist) ((MLava) { MakeEntity("mlava", 0, start) NULL, mlava_tick, NULL, MLV_IDLE, 5 * TICKSPERSEC, start, dist, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef NAPICE_H
|
||||
#define NAPICE_H
|
||||
#include "../States.h"
|
||||
|
||||
bool ice_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t iid;
|
||||
bool activated;
|
||||
double timer;
|
||||
|
||||
} Ice;
|
||||
#define MakeIce(id) ((Ice) { MakeEntity("ice", 0, 0) NULL, ice_tick, NULL, id, 0, 0 })
|
||||
|
||||
bool ice_activate(Server* server, Ice* ice);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef NAPSNOWBALL_H
|
||||
#define NAPSNOWBALL_H
|
||||
#include "../States.h"
|
||||
|
||||
bool snowball_init(Server* server, Entity* entity);
|
||||
bool snowball_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t sid;
|
||||
bool active;
|
||||
uint8_t state;
|
||||
double stage_prog;
|
||||
int8_t dir;
|
||||
double frame;
|
||||
double start;
|
||||
double vel;
|
||||
uint8_t p_count;
|
||||
double timer;
|
||||
|
||||
float p_move[20];
|
||||
float p_anim[20];
|
||||
|
||||
} Snowball;
|
||||
#define MakeSnowball(id, p_count, dir) ((Snowball) { MakeEntity("snowball", 0, 0) snowball_init, snowball_tick, NULL, id, 0, 0, 0, dir, 0, 0, 0, p_count, 0 })
|
||||
|
||||
bool snowball_activate(Server* server, Snowball* sb);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef NPCONTROLLER_H
|
||||
#define NPCONTROLLER_H
|
||||
#include "../States.h"
|
||||
|
||||
bool npctrl_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
enum
|
||||
{
|
||||
NPC_NONE,
|
||||
NPC_PREPARE
|
||||
} state;
|
||||
uint8_t stage;
|
||||
double timer;
|
||||
bool balls;
|
||||
} NPController;
|
||||
#define MakeNPCtrl() ((NPController) { MakeEntity("npctrl", 0, 0) NULL, npctrl_tick, NULL, NPC_NONE, 0, 0, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef PFLIFT_H
|
||||
#define PFLIFT_H
|
||||
#include "../States.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t lid;
|
||||
double timer;
|
||||
float start;
|
||||
float end;
|
||||
float speed;
|
||||
uint16_t activator;
|
||||
bool activated;
|
||||
|
||||
} PFLift;
|
||||
#define MakePFLift(id, start, end) ((PFLift) { MakeEntity("pflift", 0, 0) pflift_init, pflift_tick, NULL, id, 0, start, end, 0, 0, 0 })
|
||||
|
||||
bool pflift_init(Server* server, Entity* entity);
|
||||
bool pflift_tick(Server* server, Entity* entity);
|
||||
bool pflift_activate(Server* server, PFLift* lift, uint16_t id);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef RMZSHARD_H
|
||||
#define RMZSHARD_H
|
||||
#include "../States.h"
|
||||
|
||||
bool shard_init(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t spawned;
|
||||
} Shard;
|
||||
#define MakeShard(x, y, spawned) ((Shard) { MakeEntity("shard", x, y) shard_init, NULL, NULL, spawned })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef RMZSLIME_H
|
||||
#define RMZSLIME_H
|
||||
#include "../States.h"
|
||||
|
||||
bool slug_init(Server* server, Entity* entity);
|
||||
bool slug_tick(Server* server, Entity* entity);
|
||||
bool slug_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
float sX, sY;
|
||||
enum
|
||||
{
|
||||
SLUG_NONERIGHT,
|
||||
SLUG_NONELEFT,
|
||||
SLUG_RINGRIGHT,
|
||||
SLUG_RINGLEFT,
|
||||
SLUG_REDRINGRIGHT,
|
||||
SLUG_REDRINGLEFT
|
||||
} state;
|
||||
|
||||
enum
|
||||
{
|
||||
SLUG_NORING,
|
||||
SLUG_RING,
|
||||
SLUG_REDRING
|
||||
} ring;
|
||||
} Slug;
|
||||
#define MakeSlug(x, y) ((Slug) { MakeEntity("slug", x, y) slug_init, slug_tick, slug_uninit, 0.f, 0.f, 0, 0 })
|
||||
|
||||
bool slugspawn_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
double offset;
|
||||
double timer;
|
||||
uint16_t slug;
|
||||
} SlugSpawner;
|
||||
#define MakeSlugSpawn(x, y) ((SlugSpawner) { MakeEntity("slugspawn", x, y) NULL, slugspawn_tick, NULL, (rand() % 10) * TICKSPERSEC, 0, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef RING_H
|
||||
#define RING_H
|
||||
#include "../States.h"
|
||||
|
||||
bool ring_init(Server* server, Entity* entity);
|
||||
bool ring_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t rid;
|
||||
uint8_t red;
|
||||
} Ring;
|
||||
#define MakeRing() ((Ring) { MakeEntity("ring", 0, 0) ring_init, NULL, ring_uninit, 0, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef SPIKES_H
|
||||
#define SPIKES_H
|
||||
#include "../States.h"
|
||||
|
||||
bool spike_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t frame;
|
||||
double timer;
|
||||
} SpikeController;
|
||||
#define MakeSpike() ((SpikeController) { MakeEntity("spikectrl", 0, 0) NULL, spike_tick, NULL, 0, 2 * TICKSPERSEC })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef TCACID_H
|
||||
#define TCACID_H
|
||||
#include "../States.h"
|
||||
|
||||
bool acid_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t acid_id;
|
||||
uint8_t activated;
|
||||
double timer;
|
||||
} Acid;
|
||||
#define MakeAcid() ((Acid) { MakeEntity("acid", 0, 0) NULL, acid_tick, NULL, 0, 0, 0.0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef TPROJECTILE_H
|
||||
#define TPROJECTILE_H
|
||||
#include "../States.h"
|
||||
|
||||
bool tdoll_init(Server* server, Entity* entity);
|
||||
bool tdoll_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
enum
|
||||
{
|
||||
TDST_NONE,
|
||||
TDST_READY,
|
||||
TDST_FOLLOW,
|
||||
TDST_RELOC
|
||||
} state;
|
||||
uint32_t target;
|
||||
double timer;
|
||||
double velx, vely;
|
||||
} TailsDoll;
|
||||
#define MakeTailsDoll() ((TailsDoll) { MakeEntity("tdoll", 0, 0) tdoll_init, tdoll_tick, NULL, TDST_NONE, -1, 0, 0.0, 0.0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef TPROJECTILE_H
|
||||
#define TPROJECTILE_H
|
||||
#include "../States.h"
|
||||
|
||||
bool tproj_init(Server* server, Entity* entity);
|
||||
bool tproj_tick(Server* server, Entity* entity);
|
||||
bool tproj_uninit(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint16_t owner;
|
||||
int8_t dir;
|
||||
uint8_t exe;
|
||||
uint8_t charge;
|
||||
uint8_t damage;
|
||||
|
||||
double timer;
|
||||
} TProjectile;
|
||||
#define MakeTailsProj(x, y, owner, dir, exe, charge, damage) ((TProjectile) { MakeEntity("tproj", x, y) tproj_init, tproj_tick, tproj_uninit, owner, dir, exe, charge, damage, 20 * TICKSPERSEC })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef VVLAVA_H
|
||||
#define VVLAVA_H
|
||||
#include "../States.h"
|
||||
|
||||
bool lava_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t lid;
|
||||
enum
|
||||
{
|
||||
LV_IDLE,
|
||||
LV_MOVEDOWN,
|
||||
LV_RAISE,
|
||||
LV_MOVE,
|
||||
LV_LOWER
|
||||
} state;
|
||||
double timer;
|
||||
float start;
|
||||
float dist;
|
||||
float vel;
|
||||
|
||||
} Lava;
|
||||
#define MakeLava(id, start, dist) ((Lava) { MakeEntity("lava", 0, start) NULL, lava_tick, NULL, id, LV_IDLE, (20 + rand() % 5) * TICKSPERSEC, start, dist, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef VVVASE_H
|
||||
#define VVVASE_H
|
||||
#include "../States.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
uint8_t vid;
|
||||
uint8_t type;
|
||||
} Vase;
|
||||
#define MakeVase(id) ((Vase) { MakeEntity("vase", 0, 0) NULL, NULL, NULL, id, (rand() % 4) })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef WDLATERN_H
|
||||
#define WDLATERN_H
|
||||
#include <stdlib.h>
|
||||
#include "../States.h"
|
||||
|
||||
bool latern_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
bool side;
|
||||
double timer;
|
||||
uint8_t lid;
|
||||
uint16_t time;
|
||||
} Latern;
|
||||
#define MakeLatern() ((Latern) { MakeEntity("latrn", 0, 0) NULL, latern_tick, NULL, false, 0.0, 0, (7 + rand() % 2) })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef YCRCONTROLLER_H
|
||||
#define YCRCONTROLLER_H
|
||||
#include "../States.h"
|
||||
|
||||
bool ycrctrl_tick(Server* server, Entity* entity);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ENTITY_BODY
|
||||
|
||||
enum
|
||||
{
|
||||
YCC_NONE,
|
||||
YCC_SOME
|
||||
} state;
|
||||
double timer;
|
||||
uint8_t smoke_id;
|
||||
uint8_t activated;
|
||||
} YCRController;
|
||||
#define MakeYCRCtrl() ((YCRController) { MakeEntity("ycrctrl", 0, 0) NULL, ycrctrl_tick, NULL, YCC_NONE, 0, 0, 0 })
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef DIR_H
|
||||
#define DIR_H
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEARN_AND_MEAN
|
||||
#include <direct.h>
|
||||
#define mkdir(dir, mode) _mkdir(dir)
|
||||
#elif defined(__unix) || defined(__unix__)
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef SOCKET_H
|
||||
#define SOCKET_H
|
||||
|
||||
#if defined(__unix) || defined(__unix__)
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define SockError(signature) strncpy(signature, strerror(errno), 256)
|
||||
#define Poll poll
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <mstcpip.h>
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define close closesocket
|
||||
#define SockError(signature) FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK , 0, WSAGetLastError(), 0, signature, 256, 0);
|
||||
#define Poll WSAPoll
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef THREADS_H
|
||||
#define THREADS_H
|
||||
|
||||
#if defined(__unix) || defined(__unix__)
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sched.h>
|
||||
|
||||
typedef pthread_t Thread;
|
||||
typedef pthread_key_t ThreadVar;
|
||||
typedef void* (*pthread_cbfunc_t) (void*);
|
||||
|
||||
#define ThreadVarCreate(var) pthread_key_create(&var, NULL)
|
||||
#define ThreadVarSet(var, value) pthread_setspecific(var, value)
|
||||
#define ThreadVarGet(var) pthread_getspecific(var)
|
||||
#define ThreadVarFree(var) pthread_key_delete(var)
|
||||
|
||||
#define ThreadSpawn(thr, cb, arg) \
|
||||
RAssert(pthread_create(&thr, NULL, (pthread_cbfunc_t)(cb), (arg)) == 0)
|
||||
#define ThreadJoin(thr) pthread_join(thr, NULL)
|
||||
#define ThreadSleep(ms) { struct timespec ts;\
|
||||
ts.tv_sec = ms / 1000;\
|
||||
ts.tv_nsec = (ms % 1000) * 1000000;\
|
||||
nanosleep(&ts, NULL); }
|
||||
|
||||
typedef pthread_mutex_t Mutex;
|
||||
#define MutexCreate(mut) RAssert(pthread_mutex_init(&mut, NULL) == 0)
|
||||
#define MutexLock(mut) RAssert(pthread_mutex_lock(&mut) == 0)
|
||||
#define MutexUnlock(mut) RAssert(pthread_mutex_unlock(&mut) == 0)
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
typedef HANDLE Thread;
|
||||
typedef DWORD ThreadVar;
|
||||
|
||||
#define ThreadVarCreate(var) RAssert((var = TlsAlloc()) != TLS_OUT_OF_INDEXES)
|
||||
#define ThreadVarGet(var) TlsGetValue(var)
|
||||
#define ThreadVarSet(var, value) TlsSetValue(var, value)
|
||||
#define ThreadVarFree(var) TlsFree(var)
|
||||
|
||||
#define ThreadSpawn(thr, cb, arg) (thr = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(cb), (arg), 0, NULL))
|
||||
#define ThreadJoin(thr) WaitForSingleObject(thr, INFINITE)
|
||||
#define ThreadSleep(ms) Sleep(ms)
|
||||
|
||||
typedef HANDLE Mutex;
|
||||
#define MutexCreate(mut) (mut = CreateMutex(NULL, FALSE, NULL))
|
||||
#define MutexLock(mut) RAssert(WaitForSingleObject(mut, INFINITE) == WAIT_OBJECT_0)
|
||||
#define MutexUnlock(mut) RAssert(ReleaseMutex(mut))
|
||||
#endif
|
||||
|
||||
extern ThreadVar g_threadName;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef double TimeStamp;
|
||||
void time_init(void);
|
||||
void time_start (TimeStamp* timer);
|
||||
double time_end (TimeStamp* timer);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef ACT9_H
|
||||
#define ACT9_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool act9_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef DARKTOWER_H
|
||||
#define DARKTOWER_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool dt_init(Server* server);
|
||||
bool dt_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef THREEDOTS_H
|
||||
#define THREEDOTS_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool dot_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef FARTZONE_H
|
||||
#define FARTZONE_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool ft_init(Server* server);
|
||||
bool ft_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef HAUNTDREAM_H
|
||||
#define HAUNTDREAM_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool hd_init(Server* server);
|
||||
bool hd_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef HIDEANDSEEK2_H
|
||||
#define HIDEANDSEEK2_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool hs2_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef HILL_H
|
||||
#define HILL_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool hill_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef KINDANDFAIR_H
|
||||
#define KINDANDFAIR_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool kaf_init (Server* server);
|
||||
bool kaf_tcpmsg (PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef LIMPCITY_H
|
||||
#define LIMPCITY_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool lc_init(Server* server);
|
||||
bool lc_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef MAJINFOREST_H
|
||||
#define MAJINFOREST_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool maj_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef MARIJUNA_H
|
||||
#define MARIJUNA_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool mj_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef NASTYPUSSY_H
|
||||
#define NASTYPUSSY_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool nap_init(Server* server);
|
||||
bool nap_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef NOTPERFECT_H
|
||||
#define NOTPERFECT_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool np_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef PRICELESSFREEDOM_H
|
||||
#define PRICELESSFREEDOM_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool pf_init(Server* server);
|
||||
bool pf_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef RAVINEMIST_H
|
||||
#define RAVINEMIST_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool rmz_init(Server* server);
|
||||
bool rmz_tick(Server* server);
|
||||
bool rmz_tcpmsg(PeerData* v, Packet* packet);
|
||||
bool rmz_left(PeerData* v);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef TORTURECAVE_H
|
||||
#define TORTURECAVE_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool tc_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef VOLCANOVALLEY_H
|
||||
#define VOLCANOVALLEY_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool vv_init(Server* server);
|
||||
bool vv_tcpmsg(PeerData* v, Packet* packet);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef WOODDREAM_H
|
||||
#define WOODDREAM_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool wd_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef YOUCANTRUN_H
|
||||
#define YOUCANTRUN_H
|
||||
#include "../Maps.h"
|
||||
|
||||
bool ycr_init(Server* server);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,138 @@
|
||||
#ifndef COMPONENTS_H
|
||||
#define COMPONENTS_H
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdbool.h>
|
||||
#include <Maps.h>
|
||||
#include <ui/Resources.h>
|
||||
|
||||
#define COMPONENT_BODY int x, y, w, h; UpdateCallback update
|
||||
#define COLOR_WHITE (SDL_Color) { 255, 255, 255, 255 }
|
||||
#define COLOR_RED (SDL_Color) { 194, 0, 55, 255 }
|
||||
#define COLOR_GRN (SDL_Color) { 15, 255, 57, 255 }
|
||||
#define COLOR_PUR (SDL_Color) { 184, 36, 255, 255 }
|
||||
#define COLOR_BLU (SDL_Color) { 93, 103, 255, 255 }
|
||||
#define COLOR_GRA (SDL_Color) { 100, 100, 100, 255 }
|
||||
#define COLOR_YLW (SDL_Color) { 255, 219, 0, 255 }
|
||||
#define COLOR_ORG (SDL_Color) { 234, 96, 20, 255 }
|
||||
#define INTERFACE_SCALE 2
|
||||
|
||||
extern int g_mouseWheel;
|
||||
|
||||
struct _Component;
|
||||
typedef bool (*UpdateCallback)(SDL_Renderer*, struct _Component*);
|
||||
typedef struct _Component
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
} Component;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
const char* text;
|
||||
int scale;
|
||||
} Label;
|
||||
#define LabelCreate(x, y, text, scale) (Label) { x, y, 0, 0, label_update, text, scale }
|
||||
bool label_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
int d_x, d_y, d_w, d_h;
|
||||
} Image;
|
||||
#define ImageCreate(x, y, w, h, s_x, s_y, s_w, s_h) (Image) { s_x, s_y, s_w, s_h, image_update, x, y, w, h }
|
||||
bool image_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef bool (*ButtonCallback)(struct _Component* component);
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
int d_x, d_y, d_w, d_h;
|
||||
ButtonCallback cb;
|
||||
bool clicked;
|
||||
} Button;
|
||||
#define ButtonCreate(x, y, w, h, cb, s_x, s_y, s_w, s_h) (Button) { s_x, s_y, s_w, s_h, button_update, x, y, w, h, cb, false }
|
||||
bool button_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
int d_x, d_y, d_w, d_h;
|
||||
ButtonCallback cb;
|
||||
bool clicked, reverse;
|
||||
bool* value;
|
||||
} ToggleButton;
|
||||
#define TButtonCreate(x, y, w, h, cb, pointer, reverse, s_x, s_y, s_w, s_h) (ToggleButton) { s_x, s_y, s_w, s_h, tbutton_update, x, y, w, h, cb, false, reverse, pointer }
|
||||
bool tbutton_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
int d_x, d_y, d_w, d_h;
|
||||
ButtonCallback cb;
|
||||
bool clicked;
|
||||
PeerData peer;
|
||||
} PlayerButton;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
bool clicked;
|
||||
ButtonCallback cb;
|
||||
float scroll, target_scroll;
|
||||
} MapList;
|
||||
#define MapListCreate(x, y, w, h, cb) (MapList) { x, y, w, h, maplist_update, false, cb, 0, 0 }
|
||||
bool maplist_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
bool clicked;
|
||||
int preset;
|
||||
Label label;
|
||||
} MapListPreset;
|
||||
#define MapListPresetCreate(x, y, w, h) (MapListPreset) { x, y, w, h, mappreset_update, false, 0 }
|
||||
bool mappreset_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
bool clicked;
|
||||
int preset;
|
||||
Label label;
|
||||
} PingLimit;
|
||||
#define PingLimitCreate(x, y, w, h) (PingLimit) { x, y, w, h, ping_update, false, 0 }
|
||||
bool ping_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
bool clicked;
|
||||
PeerData peers[MAX_SUPPORTED_PLAYERS];
|
||||
} PlayerList;
|
||||
|
||||
#define PlayerListCreate(x, y) (PlayerList) { x, y, 144, 176, playerlist_update, false, {0} }
|
||||
bool playerlist_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
int d_x, d_y, d_w, d_h;
|
||||
ButtonCallback cb;
|
||||
bool clicked;
|
||||
|
||||
const char* collection;
|
||||
cJSON* root;
|
||||
const char* key;
|
||||
} DeleteButton;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
COMPONENT_BODY;
|
||||
bool clicked;
|
||||
int page;
|
||||
} PlayerListConfig;
|
||||
#define PlayerListConfigCreate(x, y, update) (PlayerListConfig) { x, y, 144, 176, update, false, 0 }
|
||||
bool playerlist_bans_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
bool playerlist_op_update(SDL_Renderer* renderer, struct _Component* component);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
#include <cJSON.h>
|
||||
#include <ui/Components.h>
|
||||
#include <Server.h>
|
||||
|
||||
void ui_update_playerlist(Server* server);
|
||||
|
||||
bool ui_update_delete(struct _Component* component);
|
||||
|
||||
bool ui_button_op(struct _Component* component);
|
||||
bool ui_button_kick(struct _Component* component);
|
||||
bool ui_button_ban(struct _Component* component);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef PRESETS_H
|
||||
#define PRESETS_H
|
||||
#include <Maps.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const bool values[MAP_COUNT];
|
||||
} Preset;
|
||||
|
||||
extern Preset g_defaultPresets[];
|
||||
#define PRESET_COUNT 9
|
||||
#define PRESET_CUSTOM 8
|
||||
|
||||
extern int g_defaultPingPresets[];
|
||||
#define PING_PRESET_COUNT 5
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef RESOURCES_H
|
||||
#define RESOURCES_H
|
||||
#include <Server.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define INFO_TEXT CLRCODE_PUR "disasterserverui " CLRCODE_BLU __DATE__ " " CLRCODE_GRN __TIME__ CLRCODE_RST "\n"\
|
||||
CLRCODE_RST "(c) 2024 team exe empire\n\n\n"\
|
||||
"game version: v" CLRCODE_PUR STRINGIFY(BUILD_VERSION) "\n"\
|
||||
CLRCODE_RST "compiler: " CLRCODE_PUR "%s\n"\
|
||||
CLRCODE_RST "sdl2 version: " CLRCODE_PUR "%d.%d.%d\n"\
|
||||
CLRCODE_RST "sdl2_image version: " CLRCODE_PUR "%d.%d.%d\n"\
|
||||
|
||||
extern SDL_Texture* g_textureSheet;
|
||||
bool resources_load(SDL_Renderer* renderer);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
Reference in New Issue
Block a user