Typedef bs

This commit is contained in:
ecx86 2016-12-30 15:16:13 -05:00
parent caf30fe11c
commit 0368b40215
1 changed files with 5 additions and 3 deletions

View File

@ -73,14 +73,16 @@ void init_base_commands() {
registerCommand("spawn", &command_spawn); registerCommand("spawn", &command_spawn);
} }
typedef void (*command_callback)(struct player* player, char** args, size_t args_count);
struct command { struct command {
char* command; char* command;
void (*callback)(struct player* player, char** args, size_t args_count); command_callback callback;
}; };
struct collection* registered_commands; struct collection* registered_commands;
void registerCommand(char* command, void (*callback)(struct player* player, char** args, size_t args_count)) { void registerCommand(char* command, command_callback callback) {
if (registered_commands == NULL) registered_commands = new_collection(16, 0); if (registered_commands == NULL) registered_commands = new_collection(16, 0);
struct command* com = xmalloc(sizeof(struct command)); struct command* com = xmalloc(sizeof(struct command));
com->command = xstrdup(command, 0); com->command = xstrdup(command, 0);