X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnotifications%2Fall.qh;h=60b3874de233d369109b16c50a53e1fb3426fe48;hp=4bd827a6e8fe8f80f8ff6d2ef8142af8ba1964e4;hb=e05fde461f84978a7a9477ddc5767f8755bc8175;hpb=238d04f302418c0b644c68d45e64eb05b3583f09 diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 4bd827a6e..60b3874de 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -5,6 +5,12 @@ #include #include #include +#include +#include + +#ifdef CSQC +#include +#endif /** main types/groups of notifications */ ENUMCLASS(MSG) @@ -177,25 +183,25 @@ GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt" if (fh >= 0) { Dump_Notifications(fh, alsoprint); - LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.\n", filename); + LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.", filename); fclose(fh); } else { - LOG_INFOF("^1Error: ^7Could not open file '%s'!\n", filename); + LOG_INFOF("^1Error: ^7Could not open file '%s'!", filename); } #else - LOG_INFO(_("Notification dump command only works with cl_cmd and sv_cmd.\n")); + LOG_INFO(_("Notification dump command only works with cl_cmd and sv_cmd.")); #endif return; } default: case CMD_REQUEST_USAGE: { - LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]")); - LOG_INFO(" Where 'filename' is the file to write (default is notifications_dump.cfg),\n"); - LOG_INFO(" if supplied with '-' output to console as well as default,\n"); - LOG_INFO(" if left blank, it will only write to default.\n"); + LOG_INFO("Usage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]"); + LOG_INFO(" Where 'filename' is the file to write (default is notifications_dump.cfg),"); + LOG_INFO(" if supplied with '-' output to console as well as default,"); + LOG_INFO(" if left blank, it will only write to default."); return; } } @@ -304,7 +310,6 @@ float autocvar_notification_lifetime_mapload = 10; #endif #ifdef SVQC -.float FRAG_VERBOSE; void Notification_GetCvars(entity this); float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes #else @@ -365,7 +370,7 @@ float autocvar_notification_show_sprees_center_specialonly = true; spree_end: placed at the end of murder messages to show ending of sprees spree_lost: placed at the end of suicide messages to show losing of sprees item_wepname: return full name of a weapon from weaponid - item_wepammo: ammo display for weapon from string + item_wepammo: ammo display for weapon from f1 and f2 item_centime: amount of time to display weapon message in centerprint item_buffname: return full name of a buff from buffid death_team: show the full name of the team a player is switching from @@ -402,8 +407,8 @@ string BUFF_NAME(int i); ARG_CASE(ARG_CS_SV_DC, "f2", ftos(f2)) \ ARG_CASE(ARG_CS_SV, "f3", ftos(f3)) \ ARG_CASE(ARG_CS_SV, "f4", ftos(f4)) \ - ARG_CASE(ARG_CS_SV, "f1p2dec", ftos_decimals(f1/100, 2)) \ - ARG_CASE(ARG_CS_SV, "f2p2dec", ftos_decimals(f2/100, 2)) \ + ARG_CASE(ARG_CS_SV, "f1dtime", ftos_decimals(TIME_DECODE(f1), 2)) \ + ARG_CASE(ARG_CS_SV, "f2dtime", ftos_decimals(TIME_DECODE(f2), 2)) \ ARG_CASE(ARG_CS, "f2primsec", (f2 ? _("secondary") : _("primary"))) \ ARG_CASE(ARG_CS, "f3primsec", (f3 ? _("secondary") : _("primary"))) \ ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \ @@ -428,16 +433,17 @@ string BUFF_NAME(int i); ARG_CASE(ARG_CS_SV, "item_wepname", Weapons_from(f1).m_name) \ ARG_CASE(ARG_CS_SV, "item_buffname", BUFF_NAME(f1)) \ ARG_CASE(ARG_CS_SV, "f3buffname", BUFF_NAME(f3)) \ - ARG_CASE(ARG_CS_SV, "item_wepammo", (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \ + ARG_CASE(ARG_CS_SV, "item_wepammo", (f2 > 0 ? notif_arg_item_wepammo(f1, f2) : "")) \ ARG_CASE(ARG_DC, "item_centime", ftos(autocvar_notification_item_centerprinttime)) \ ARG_CASE(ARG_SV, "death_team", Team_ColoredFullName(f1)) \ ARG_CASE(ARG_CS, "death_team", Team_ColoredFullName(f1 - 1)) \ ARG_CASE(ARG_CS_SV_HA, "minigame1_name",find(NULL,netname,s1).descriptor.message) \ ARG_CASE(ARG_CS_SV_HA, "minigame1_d", find(NULL,netname,s1).descriptor.netname) -#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN { \ +#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN \ if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \ -} MACRO_END +MACRO_END + #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; } #define KILL_SPREE_LIST \ @@ -619,6 +625,23 @@ string notif_arg_spree_inf(float type, string input, string player, float spree) return ""; } +string notif_arg_item_wepammo(float f1, float f2) +{ + string ammoitems = ""; + Weapon wep = Weapons_from(f1); + switch (wep.ammo_type) + { + case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break; + case RES_BULLETS: ammoitems = ITEM_Bullets.m_name; break; + case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name; break; + case RES_CELLS: ammoitems = ITEM_Cells.m_name; break; + case RES_PLASMA: ammoitems = ITEM_Plasma.m_name; break; + case RES_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break; + default: return ""; // doesn't use ammo + } + return sprintf(_(" with %d %s"), f2, ammoitems); +} + // ==================================== // Initialization/Create Declarations @@ -672,10 +695,13 @@ string notif_arg_spree_inf(float type, string input, string player, float spree) REGISTRY(Notifications, BITS(11)) REGISTER_REGISTRY(Notifications) -REGISTRY_SORT(Notifications); STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); } +REGISTRY_SORT(Notifications); +STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); } REGISTRY_CHECK(Notifications) -const int NOTIF_CHOICE_MAX = 50; +const int NOTIF_CHOICE_MAX = 20; +// NOTE: a team choice is actually made of 4 choices (one per team) with the same nent_choice_idx +// thus they are counted as 1 in nent_choice_count int nent_choice_count = 0; .int nent_choice_idx; .int msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices @@ -683,12 +709,11 @@ int nent_choice_count = 0; bool notif_error; bool notif_global_error; -STATIC_INIT_LATE(Notif_Choices) { - int c = 0; - FOREACH(Notifications, it.nent_type == MSG_CHOICE, { c++; }); - if (c > NOTIF_CHOICE_MAX) { - LOG_FATALF("Too many MSG_CHOICE notifications (%d)", c); - } +STATIC_INIT_LATE(Notif_Choices) +{ + if (nent_choice_count > NOTIF_CHOICE_MAX) + LOG_FATALF("Too many MSG_CHOICE notifications (%d), hit NOTIF_CHOICE_MAX (%d) limit", + nent_choice_count, NOTIF_CHOICE_MAX); } string Get_Notif_CvarName(Notification notif) @@ -807,7 +832,9 @@ Notification Get_Notif_Ent(MSG net_type, int net_name) #define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \ REGISTER(Notifications, name, m_id, new_pure(msg_choice_notification)) { \ - this.nent_choice_idx = nent_choice_count++; \ + this.nent_choice_idx = nent_choice_count; \ + if (!teamnum || teamnum == NUM_TEAM_4) \ + nent_choice_count++; \ Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), teamnum); \ Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \ challow, /* challow_def */ \