X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnotifications.qc;h=def7484efa99e5ba869caf7f3ce3a60784e8acf8;hb=b915cf293a273e0365792891d739f96c364b57f2;hp=600ddaa1b3237301833480c7ef92cb901333b1a0;hpb=3ae1efa7401791e42e3171f4db2cc2d38adde088;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 600ddaa1b..def7484ef 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -1,4 +1,5 @@ #if defined(CSQC) + #include "../client/announcer.qh" #elif defined(MENUQC) #elif defined(SVQC) #include "constants.qh" @@ -7,7 +8,7 @@ #include "../server/constants.qh" #include "../server/defs.qh" #include "notifications.qh" - #include "../server/mutators/mutators_include.qh" + #include #endif // ================================================ @@ -233,19 +234,19 @@ void Destroy_Notification_Entity(entity notif) remove(notif); } -void Destroy_All_Notifications(void) +void Destroy_All_Notifications() { entity notif; int i; - #define DESTROY_LOOP(type,count) do { \ + #define DESTROY_LOOP(type,count) MACRO_BEGIN { \ for(i = 1; i <= count; ++i) \ { \ notif = Get_Notif_Ent(type, i); \ if (!notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \ Destroy_Notification_Entity(notif); \ } \ - } while(0) + } MACRO_END // kill all networked notifications and centerprints #ifdef SVQC @@ -522,7 +523,7 @@ void Create_Notification_Entity( // ===================== // Global Entity Setup // ===================== - entity notif = spawn(); + entity notif = new_pure(notification); switch(typeId) { case MSG_ANNCE: @@ -595,7 +596,7 @@ void Create_Notification_Entity( { if(notif.nent_enabled) { - precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd)); + precache_sound(sprintf("announcer/%s/%s.wav", AnnouncerOption(), snd)); notif.nent_channel = channel; notif.nent_snd = strzone(snd); notif.nent_vol = vol; @@ -735,7 +736,7 @@ void Create_Notification_Entity( // ====================== // Process Notif String // ====================== - #define SET_NOTIF_STRING(string,stringname) do { \ + #define SET_NOTIF_STRING(string,stringname) MACRO_BEGIN { \ notif.nent_string = strzone(CCR( \ Process_Notif_Line( \ typeId, \ @@ -746,7 +747,7 @@ void Create_Notification_Entity( stringname \ )) \ ); \ - } while(0) + } MACRO_END if(GENTLE) { @@ -941,7 +942,7 @@ void Create_Notification_Entity( // used by MSG_CHOICE to build list of choices #ifdef SVQC -void Notification_GetCvars(void) +void Notification_GetCvars() { for(int i = 0; i <= NOTIF_CHOICE_COUNT; ++i) { @@ -1276,7 +1277,7 @@ void Local_Notification_sound( soundchannel, sprintf( "announcer/%s/%s.wav", - autocvar_cl_announcer, + AnnouncerOption(), soundfile ), soundvolume, @@ -1289,7 +1290,7 @@ void Local_Notification_sound( soundchannel, sprintf( "announcer/%s/%s.wav", - autocvar_cl_announcer, + AnnouncerOption(), soundfile ), soundvolume, @@ -1311,7 +1312,7 @@ void Local_Notification_sound( soundchannel, sprintf( "announcer/%s/%s.wav", - autocvar_cl_announcer, + AnnouncerOption(), soundfile ), soundvolume, @@ -1677,11 +1678,14 @@ void Local_Notification_WOVA( // Notification Networking // ========================= +REGISTER_NET_LINKED(ENT_CLIENT_NOTIFICATION) + #ifdef CSQC -void Read_Notification(float is_new) +NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new) { int net_type = ReadByte(); int net_name = ReadShort(); + return = true; entity notif; @@ -1775,7 +1779,7 @@ bool Net_Write_Notification(entity this, entity client, int sf) { if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client)) { - WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION); + WriteHeader(MSG_ENTITY, ENT_CLIENT_NOTIFICATION); WriteByte(MSG_ENTITY, self.nent_net_type); WriteShort(MSG_ENTITY, self.nent_net_name); for(int i = 0; i < self.nent_stringcount; ++i) { WriteString(MSG_ENTITY, self.nent_strings[i]); } @@ -1802,7 +1806,7 @@ void Kill_Notification( string checkargs = Notification_CheckArgs(broadcast, client, 1, 1); if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; } - entity notif, net_notif; + entity net_notif; float killed_cpid = NO_CPID; switch(net_type) @@ -1841,8 +1845,8 @@ void Kill_Notification( if(killed_cpid != NO_CPID) { - net_notif = spawn(); - net_notif.classname = "net_kill_notification"; + net_notif = new(net_kill_notification); + make_pure(net_notif); net_notif.nent_broadcast = broadcast; net_notif.nent_client = client; net_notif.nent_net_type = MSG_CENTER_CPID; @@ -1850,32 +1854,32 @@ void Kill_Notification( Net_LinkEntity(net_notif, false, autocvar_notification_lifetime_runtime, Net_Write_Notification); } - for(notif = world; (notif = find(notif, classname, "net_notification"));) + FOREACH_ENTITY_CLASS("net_notification", true, { if(net_type) { - if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER)) + if((killed_cpid != NO_CPID) && (it.nent_net_type == MSG_CENTER)) { - if(notif.owner.nent_cpid == killed_cpid) + if(it.owner.nent_cpid == killed_cpid) { - notif.nent_net_name = -1; - notif.nextthink = time; + it.nent_net_name = -1; + it.nextthink = time; } else { continue; } // we ARE looking for a specific CPID, don't kill everything else too } - else if(notif.nent_net_type == net_type) + else if(it.nent_net_type == net_type) { if(net_name) { - if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; } + if(it.nent_net_name == net_name) { it.nent_net_name = -1; it.nextthink = time; } else { continue; } // we ARE looking for a certain net_name, don't kill everything else too } - else { notif.nent_net_name = -1; notif.nextthink = time; } + else { it.nent_net_name = -1; it.nextthink = time; } } else { continue; } // we ARE looking for a certain net_type, don't kill everything else too } - else { notif.nent_net_name = -1; notif.nextthink = time; } - } + else { it.nent_net_name = -1; it.nextthink = time; } + }); } void Send_Notification( @@ -2044,7 +2048,7 @@ void Send_Notification( // 2. Manually handling each separate call on per-usage basis (See old CTF usage of verbose) entity found_choice; - #define RECURSE_FROM_CHOICE(ent,action) do { \ + #define RECURSE_FROM_CHOICE(ent,action) MACRO_BEGIN { \ if(notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) \ { \ switch(ent.msg_choice_choices[net_name - 1]) \ @@ -2064,7 +2068,7 @@ void Send_Notification( found_choice.nent_floatcount, \ s1, s2, s3, s4, \ f1, f2, f3, f4); \ - } while(0) + } MACRO_END switch(broadcast) { @@ -2078,23 +2082,21 @@ void Send_Notification( } default: { - entity to; - FOR_EACH_REALCLIENT(to) - { - if(Notification_ShouldSend(broadcast, to, client)) + FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( + if(Notification_ShouldSend(broadcast, it, client)) { - RECURSE_FROM_CHOICE(to, continue); + RECURSE_FROM_CHOICE(it, continue); } - } + )); break; } } } else { - entity net_notif = spawn(); + entity net_notif = new(net_notification); + make_pure(net_notif); net_notif.owner = notif; - net_notif.classname = "net_notification"; net_notif.nent_broadcast = broadcast; net_notif.nent_client = client; net_notif.nent_net_type = net_type;