X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fcommon.qc;h=80b1d23a442f00c4dc1fb418f653bf128401ee7e;hb=0ded465b923f9e51db5bf62c271488e64e2a3f2c;hp=eae71b045c82845688d653b999d705f07854ac68;hpb=2f2fd66d1b78236228005a04f5bc193e7ff37251;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index eae71b045..80b1d23a4 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -24,11 +24,11 @@ string GetCallerName(entity caller) // verify that the client provided is acceptable for use float VerifyClientEntity(entity client, float must_be_real, float must_be_bots) { - if not(client.flags & FL_CLIENT) + if not(IS_CLIENT(client)) return CLIENT_DOESNT_EXIST; - else if(must_be_real && (clienttype(client) != CLIENTTYPE_REAL)) + else if(must_be_real && !IS_REAL_CLIENT(client)) return CLIENT_NOT_REAL; - else if(must_be_bots && (clienttype(client) != CLIENTTYPE_BOT)) + else if(must_be_bots && !IS_BOT_CLIENT(client)) return CLIENT_NOT_BOT; return CLIENT_ACCEPTABLE; @@ -162,14 +162,9 @@ void print_to(entity to, string input) // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such. void timeout_handler_reset() { - entity tmp_player; - timeout_caller = world; timeout_time = 0; timeout_leadtime = 0; - - FOR_EACH_REALPLAYER(tmp_player) - Send_CSQC_Centerprint_Generic_Expire(tmp_player, CPID_TIMEOUT_COUNTDOWN); remove(self); } @@ -184,11 +179,10 @@ void timeout_handler_think() { if(timeout_time > 0) // countdown is still going { - FOR_EACH_REALPLAYER(tmp_player) - Send_CSQC_Centerprint_Generic(tmp_player, CPID_TIMEOUT_COUNTDOWN, "Timeout ends in %d seconds!", 1, timeout_time); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_ENDING, timeout_time); if(timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only seconds are left - Announce("prepareforbattle"); + Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_PREPARE); self.nextthink = time + TIMEOUT_SLOWMO_VALUE; // think again in one second timeout_time -= 1; // decrease the time counter @@ -214,9 +208,7 @@ void timeout_handler_think() { if(timeout_leadtime > 0) // countdown is still going { - // centerprint the information to every player - FOR_EACH_REALPLAYER(tmp_player) - Send_CSQC_Centerprint_Generic(tmp_player, CPID_TIMEOUT_COUNTDOWN, "Timeout begins in %d seconds!", 1, timeout_leadtime); + Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_TIMEOUT_BEGINNING, timeout_leadtime); self.nextthink = time + 1; // think again in one second timeout_leadtime -= 1; // decrease the time counter @@ -368,26 +360,6 @@ void CommonCommand_lsmaps(float request, entity caller) } } -void CommonCommand_lsnewmaps(float request, entity caller) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - print_to(caller, lsnewmaps_reply); - return; // never fall through to usage - } - - default: - case CMD_REQUEST_USAGE: - { - print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " lsnewmaps")); - print_to(caller, " No arguments required."); - return; - } - } -} - void CommonCommand_printmaplist(float request, entity caller) { switch(request) @@ -565,14 +537,14 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN else if(inWarmupStage && !g_warmup_allow_timeout) { print_to(caller, "^7Error: You can not call a timeout in warmup-stage."); } else if(time < game_starttime) { print_to(caller, "^7Error: You can not call a timeout while the map is being restarted."); } else if(caller && (caller.allowed_timeouts < 1)) { print_to(caller, "^7Error: You already used all your timeout calls for this map."); } - else if(caller && (caller.classname != "player")) { print_to(caller, "^7Error: You must be a player to call a timeout."); } + else if(caller && !IS_PLAYER(caller)) { print_to(caller, "^7Error: You must be a player to call a timeout."); } else if((autocvar_timelimit) && (last_possible_timeout < time - game_starttime)) { print_to(caller, "^7Error: It is too late to call a timeout now!"); } else // everything should be okay, proceed with starting the timeout { if(caller) { caller.allowed_timeouts -= 1; } - bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : string_null), "!\n"); // write a bprint who started the timeout (and how many they have left) + bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n"); // write a bprint who started the timeout (and how many they have left) timeout_status = TIMEOUT_LEADTIME; timeout_caller = caller; @@ -583,7 +555,7 @@ void CommonCommand_timeout(float request, entity caller) // DEAR GOD THIS COMMAN timeout_handler.think = timeout_handler_think; timeout_handler.nextthink = time; // always let the entity think asap - Announce("timeoutcalled"); + Send_Notification(NOTIF_ALL, world, MSG_ANNCE, ANNCE_TIMEOUT); } } else { print_to(caller, "^1Timeouts are not allowed to be called, enable them with sv_timeout 1.\n"); } @@ -607,21 +579,21 @@ void CommonCommand_who(float request, entity caller, float argc) { case CMD_REQUEST_COMMAND: { - float total_listed_players, tmp_hours, tmp_minutes, tmp_seconds, is_bot; + float total_listed_players, is_bot; entity tmp_player; float privacy = (caller && autocvar_sv_status_privacy); string separator = strreplace("%", " ", strcat((argv(1) ? argv(1) : " "), "^7")); string tmp_netaddress, tmp_crypto_idfp; - print_to(caller, strcat("List of client information", (privacy ? " (some data is hidden for privacy)" : string_null), ":")); + print_to(caller, strcat("List of client information", (privacy ? " (some data is hidden for privacy)" : ""), ":")); print_to(caller, sprintf(strreplace(" ", separator, " %-4s %-20s %-5s %-3s %-9s %-16s %s "), "ent", "nickname", "ping", "pl", "time", "ip", "crypto_id")); total_listed_players = 0; FOR_EACH_CLIENT(tmp_player) { - is_bot = (clienttype(tmp_player) == CLIENTTYPE_BOT); + is_bot = (IS_BOT_CLIENT(tmp_player)); if(is_bot) { @@ -638,22 +610,13 @@ void CommonCommand_who(float request, entity caller, float argc) tmp_netaddress = tmp_player.netaddress; tmp_crypto_idfp = tmp_player.crypto_idfp; } - - tmp_hours = tmp_minutes = tmp_seconds = 0; - - tmp_seconds = floor(time - tmp_player.jointime); - tmp_minutes = floor(tmp_seconds / 60); - tmp_hours = floor(tmp_minutes / 60); - - if(tmp_minutes) { tmp_seconds -= (tmp_minutes * 60); } - if(tmp_hours) { tmp_minutes -= (tmp_hours * 60); } print_to(caller, sprintf(strreplace(" ", separator, " #%-3d %-20.20s %-5d %-3d %-9s %-16s %s "), num_for_edict(tmp_player), tmp_player.netname, tmp_player.ping, tmp_player.ping_packetloss, - sprintf("%02d:%02d:%02d", tmp_hours, tmp_minutes, tmp_seconds), + process_time(1, time - tmp_player.jointime), tmp_netaddress, tmp_crypto_idfp)); @@ -710,7 +673,6 @@ void CommonCommand_(float request, entity caller) COMMON_COMMAND("info", CommonCommand_info(request, caller, arguments), "Request for unique server information set up by admin") \ COMMON_COMMAND("ladder", CommonCommand_ladder(request, caller), "Get information about top players if supported") \ COMMON_COMMAND("lsmaps", CommonCommand_lsmaps(request, caller), "List maps which can be used with the current game mode") \ - COMMON_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request, caller), "List maps which have no records or are seemingly unplayed yet") \ COMMON_COMMAND("printmaplist", CommonCommand_printmaplist(request, caller), "Display full server maplist reply") \ COMMON_COMMAND("rankings", CommonCommand_rankings(request, caller), "Print information about rankings") \ COMMON_COMMAND("records", CommonCommand_records(request, caller), "List top 10 records for the current map") \