diff options
Diffstat (limited to 'minecctl')
-rw-r--r-- | minecctl/minecctl-rcon.c | 20 | ||||
-rw-r--r-- | minecctl/minecctl.c | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/minecctl/minecctl-rcon.c b/minecctl/minecctl-rcon.c index b97e03e..6ef6cc1 100644 --- a/minecctl/minecctl-rcon.c +++ b/minecctl/minecctl-rcon.c @@ -239,10 +239,10 @@ do_status(struct cfg *cfg) { int fd; struct server *server; - if (list_empty(&cfg->servers)) + server = list_first_entry_or_null(&cfg->servers, struct server, list); + if (!server) die("No servers defined"); - server = list_first_entry(&cfg->servers, struct server, list); read_server_config(server); fd = rcon_login(cfg, server); @@ -321,10 +321,10 @@ do_stop(struct cfg *cfg) { int fd; struct server *server; - if (list_empty(&cfg->servers)) + server = list_first_entry_or_null(&cfg->servers, struct server, list); + if (!server) die("No servers defined"); - server = list_first_entry(&cfg->servers, struct server, list); read_server_config(server); fd = rcon_login(cfg, server); @@ -364,10 +364,10 @@ do_pcount(struct cfg *cfg) { unsigned current, max; struct server *server; - if (list_empty(&cfg->servers)) + server = list_first_entry_or_null(&cfg->servers, struct server, list); + if (!server) die("No servers defined"); - server = list_first_entry(&cfg->servers, struct server, list); read_server_config(server); fd = rcon_login(cfg, server); @@ -385,10 +385,10 @@ do_console(struct cfg *cfg) int fd; struct server *server; - if (list_empty(&cfg->servers)) + server = list_first_entry_or_null(&cfg->servers, struct server, list); + if (!server) die("No servers defined"); - server = list_first_entry(&cfg->servers, struct server, list); read_server_config(server); fd = rcon_login(cfg, server); @@ -431,10 +431,10 @@ do_command(struct cfg *cfg) { int fd; struct server *server; - if (list_empty(&cfg->servers)) + server = list_first_entry_or_null(&cfg->servers, struct server, list); + if (!server) die("No servers defined"); - server = list_first_entry(&cfg->servers, struct server, list); read_server_config(server); fd = rcon_login(cfg, server); send_cmd(fd, cfg->cmdstr); diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c index 6ccf413..bbe605b 100644 --- a/minecctl/minecctl.c +++ b/minecctl/minecctl.c @@ -303,9 +303,7 @@ set_server(const char *name) list_for_each_entry(server, &cfg->servers, list) { if (streq(name, server->shortname)) { - /* This puts the chosen server first in the list */ - list_del(&server->list); - list_add(&server->list, &cfg->servers); + list_rotate_to_front(&server->list, &cfg->servers); return; } } |