From 5d48529da4d86c0db66c4cab4902f3884af387ca Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 20 May 2020 01:19:33 +1000 Subject: [PATCH] Apply a workaround to avoid empty sprintf calls in the notification system, also fix another bug in the Matrix found by FTEQCC --- qcsrc/common/notifications/all.inc | 11 +++++++---- qcsrc/lib/matrix/matrix.qc | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index d4bab9dd2..a9a2ee655 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -216,12 +216,15 @@ #define N_CONSOLE 1 #define N_CHATCON 2 +// hack to work around the limitations of sprintf +string multiteam_info_sprintf(string input, string teamname) { return ((input != "") ? sprintf(input, teamname) : ""); } + #define MULTITEAM_INFO(prefix, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle, type) \ NOTIF_ADD_AUTOCVAR(INFO_##prefix, defaultvalue) \ - MSG_INFO_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, defaultvalue, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_1)), TCR(normal, type, 1), TCR(gentle, type, 1)) \ - MSG_INFO_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, defaultvalue, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_2)), TCR(normal, type, 2), TCR(gentle, type, 2)) \ - MSG_INFO_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, defaultvalue, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_3)), TCR(normal, type, 3), TCR(gentle, type, 3)) \ - MSG_INFO_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, defaultvalue, strnum, flnum, args, hudargs, sprintf(icon, strtolower(STATIC_NAME_TEAM_4)), TCR(normal, type, 4), TCR(gentle, type, 4)) + MSG_INFO_NOTIF_TEAM(NUM_TEAM_1, prefix##_RED, prefix, defaultvalue, strnum, flnum, args, hudargs, multiteam_info_sprintf(icon, strtolower(STATIC_NAME_TEAM_1)), TCR(normal, type, 1), TCR(gentle, type, 1)) \ + MSG_INFO_NOTIF_TEAM(NUM_TEAM_2, prefix##_BLUE, prefix, defaultvalue, strnum, flnum, args, hudargs, multiteam_info_sprintf(icon, strtolower(STATIC_NAME_TEAM_2)), TCR(normal, type, 2), TCR(gentle, type, 2)) \ + MSG_INFO_NOTIF_TEAM(NUM_TEAM_3, prefix##_YELLOW, prefix, defaultvalue, strnum, flnum, args, hudargs, multiteam_info_sprintf(icon, strtolower(STATIC_NAME_TEAM_3)), TCR(normal, type, 3), TCR(gentle, type, 3)) \ + MSG_INFO_NOTIF_TEAM(NUM_TEAM_4, prefix##_PINK, prefix, defaultvalue, strnum, flnum, args, hudargs, multiteam_info_sprintf(icon, strtolower(STATIC_NAME_TEAM_4)), TCR(normal, type, 4), TCR(gentle, type, 4)) // MSG_INFO_NOTIFICATIONS MSG_INFO_NOTIF(CHAT_NOSPECTATORS, N_CHATCON, 0, 0, "", "", "", _("^F4NOTE: ^BGSpectator chat is not sent to players during the match"), "") diff --git a/qcsrc/lib/matrix/matrix.qc b/qcsrc/lib/matrix/matrix.qc index 57754d04e..3ce4fcfc8 100644 --- a/qcsrc/lib/matrix/matrix.qc +++ b/qcsrc/lib/matrix/matrix.qc @@ -147,7 +147,7 @@ void MX_JLF_(entity fh, entity pass, int status) switch (status) { case URL_READY_CANWRITE: { fh.url_content_type = "application/json"; - url_fputs(fh, sprintf("{}", pass.message)); + url_fputs(fh, sprintf("{%s}", pass.message)); url_fclose(fh); break; } -- 2.39.2