mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-28 11:51:08 -04:00
Fix typo and remove 'Q' as quitting command
This commit is contained in:
16
mcrcon.c
16
mcrcon.c
@ -57,6 +57,8 @@
|
|||||||
#define MAX_PACKET_SIZE 4106 // id (4) + cmd (4) + DATA_BUFFSIZE
|
#define MAX_PACKET_SIZE 4106 // id (4) + cmd (4) + DATA_BUFFSIZE
|
||||||
#define MIN_PACKET_SIZE 10 // id (4) + cmd (4) + two empty strings (2)
|
#define MIN_PACKET_SIZE 10 // id (4) + cmd (4) + two empty strings (2)
|
||||||
|
|
||||||
|
#define MAX_WAIT_TIME 600
|
||||||
|
|
||||||
#define log_error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__);
|
#define log_error(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__);
|
||||||
|
|
||||||
// rcon packet structure
|
// rcon packet structure
|
||||||
@ -143,8 +145,6 @@ void sighandler(int sig)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_WAIT_TIME 600
|
|
||||||
|
|
||||||
unsigned int mcrcon_parse_seconds(char *str)
|
unsigned int mcrcon_parse_seconds(char *str)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
@ -549,7 +549,7 @@ void packet_print(rc_packet *packet)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add missing slashes
|
// Add missing newlines
|
||||||
if (colors_detected == false && global_minecraft_newline_fix && data[i] == '/') {
|
if (colors_detected == false && global_minecraft_newline_fix && data[i] == '/') {
|
||||||
slash ? putchar('\n') : (slash = true);
|
slash ? putchar('\n') : (slash = true);
|
||||||
}
|
}
|
||||||
@ -720,7 +720,7 @@ int run_terminal_mode(int sock)
|
|||||||
{
|
{
|
||||||
char command[MAX_COMMAND_LENGTH] = {0};
|
char command[MAX_COMMAND_LENGTH] = {0};
|
||||||
|
|
||||||
puts("Logged in.\nType 'Q' or press Ctrl-D / Ctrl-C to disconnect.");
|
puts("Logged in. Press Ctrl-D or Ctrl-C to disconnect.\n");
|
||||||
|
|
||||||
while (global_connection_alive) {
|
while (global_connection_alive) {
|
||||||
putchar('>');
|
putchar('>');
|
||||||
@ -729,8 +729,6 @@ int run_terminal_mode(int sock)
|
|||||||
int len = get_line(command, MAX_COMMAND_LENGTH);
|
int len = get_line(command, MAX_COMMAND_LENGTH);
|
||||||
if (len < 1) continue;
|
if (len < 1) continue;
|
||||||
|
|
||||||
if (strcasecmp(command, "Q") == 0) break;
|
|
||||||
|
|
||||||
if (len > 0 && global_connection_alive) {
|
if (len > 0 && global_connection_alive) {
|
||||||
if (!rcon_command(sock, command)) {
|
if (!rcon_command(sock, command)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -740,9 +738,7 @@ int run_terminal_mode(int sock)
|
|||||||
/* Special case for "stop" command to prevent server-side bug.
|
/* Special case for "stop" command to prevent server-side bug.
|
||||||
* https://bugs.mojang.com/browse/MC-154617
|
* https://bugs.mojang.com/browse/MC-154617
|
||||||
*
|
*
|
||||||
* NOTE: This is hacky workaround which should be handled better to
|
* NOTE: Not sure if this still a problem?!
|
||||||
* ensure compatibility with other servers using source RCON.
|
|
||||||
* NOTE: strcasecmp() is POSIX function.
|
|
||||||
*/
|
*/
|
||||||
if (global_valve_protocol == false && strcasecmp(command, "stop") == 0) {
|
if (global_valve_protocol == false && strcasecmp(command, "stop") == 0) {
|
||||||
// Timeout to before checking if connection was closed
|
// Timeout to before checking if connection was closed
|
||||||
@ -780,6 +776,8 @@ char *utf8_getline(char *buf, int size, FILE *stream)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Test if this is even required.
|
||||||
|
|
||||||
wint_t ch;
|
wint_t ch;
|
||||||
while ((ch = getwchar()) != L'\n' && ch != WEOF);
|
while ((ch = getwchar()) != L'\n' && ch != WEOF);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user