From: TimePath Date: Wed, 26 Aug 2015 01:38:05 +0000 (+1000) Subject: Ping pong X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e5c8f528fcf30b97daef34ff923d4a566e13a411;p=xonotic%2Fxonotic-data.pk3dir.git Ping pong --- diff --git a/qcsrc/common/mutators/mutator/social.qc b/qcsrc/common/mutators/mutator/social.qc index 7ee332d26..905dfcf9b 100644 --- a/qcsrc/common/mutators/mutator/social.qc +++ b/qcsrc/common/mutators/mutator/social.qc @@ -1,6 +1,8 @@ #ifdef MENUQC REGISTER_MUTATOR(social, true); +void Social_send(int to, string msg); + void Social_parse(entity fh, entity pass, int status) { switch (status) { @@ -16,19 +18,30 @@ void Social_parse(entity fh, entity pass, int status) if (first == "") return; int id = stoi(first); printf("from player %d:\n", id); - for (string input; (input = url_fgets(fh)); ) { - print(input, "\n"); - } + string cmd = url_fgets(fh); + switch (cmd) { + case "ping": + Social_send(id, "pong"); + case "pong": + printf("Player %d is online\n", id); + break; + case "msg": + for (string input; (input = url_fgets(fh)); ) { + print(input, "\n"); + } + break; + default: + printf("Social_parse(): '%s'\n", cmd); + break; + } url_fclose(fh); break; } case URL_READY_CLOSED: break; case URL_READY_ERROR: default: - { printf("Social_parse(): %s\n", ftos(status)); break; - } } }