]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/less_fields 659/head
authorMario <mario@smbclan.net>
Thu, 29 Aug 2019 05:44:29 +0000 (15:44 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Aug 2019 05:44:29 +0000 (15:44 +1000)
# Conflicts:
# qcsrc/common/notifications/all.qh

1  2 
qcsrc/common/notifications/all.qh
qcsrc/server/client.qh

index 60b3874de233d369109b16c50a53e1fb3426fe48,6eabc983488d720ef43f7f40b2b3c0a7bb3c1f12..ee39b1881ab100937221ae3604d1cac68bb817ae
@@@ -295,7 -295,7 +295,7 @@@ void Send_Notification_WOCOVA
  // MAKE SURE THIS IS ALWAYS SYNCHRONIZED WITH THE DUMP
  // NOTIFICATIONS FUNCTION IN THE .QC FILE!
  
- #define NOTIF_ADD_AUTOCVAR(name,default) float autocvar_notification_##name = default;
+ #define NOTIF_ADD_AUTOCVAR(name,defaultvalue) float autocvar_notification_##name = defaultvalue;
  
  float autocvar_notification_show_location = false;
  string autocvar_notification_show_location_string = ""; //_(" at the %s");
@@@ -699,9 -699,7 +699,9 @@@ 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
  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)
@@@ -737,16 -736,16 +737,16 @@@ Notification Get_Notif_Ent(MSG net_type
        return it;
  }
  
- #define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, default, sound, channel, volume, position) \
-       MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, default, sound, channel, volume, position)
+ #define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position) \
+       MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, defaultvalue, sound, channel, volume, position)
  
- #define MSG_ANNCE_NOTIF(name, default, sound, channel, volume, position) \
-       NOTIF_ADD_AUTOCVAR(ANNCE_##name, default) \
-       MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, default, sound, channel, volume, position)
+ #define MSG_ANNCE_NOTIF(name, defaultvalue, sound, channel, volume, position) \
+       NOTIF_ADD_AUTOCVAR(ANNCE_##name, defaultvalue) \
+       MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, defaultvalue, sound, channel, volume, position)
  
- #define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, default, sound, channel, volume, position) \
+ #define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, defaultvalue, sound, channel, volume, position) \
        REGISTER(Notifications, name, m_id, new_pure(msg_annce_notification)) { \
-               Create_Notification_Entity      (this, default, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), teamnum); \
+               Create_Notification_Entity      (this, defaultvalue, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), teamnum); \
                Create_Notification_Entity_Annce(this, ACVNN(cvarname), strtoupper(#name), \
                        channel,   /* channel  */ \
                        sound,     /* snd      */ \
                        position); /* position */ \
        }
  
- #define MSG_INFO_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
-       MSG_INFO_NOTIF_(teamnum, INFO_##name, INFO_##cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle)
+ #define MSG_INFO_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle) \
+       MSG_INFO_NOTIF_(teamnum, INFO_##name, INFO_##cvarname, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle)
  
- #define MSG_INFO_NOTIF(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
-       NOTIF_ADD_AUTOCVAR(INFO_##name, default) \
-       MSG_INFO_NOTIF_(0, INFO_##name, INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle)
+ #define MSG_INFO_NOTIF(name, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle) \
+       NOTIF_ADD_AUTOCVAR(INFO_##name, defaultvalue) \
+       MSG_INFO_NOTIF_(0, INFO_##name, INFO_##name, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle)
  
- #define MSG_INFO_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \
+ #define MSG_INFO_NOTIF_(teamnum, name, cvarname, defaultvalue, strnum, flnum, args, hudargs, icon, normal, gentle) \
        REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \
-               Create_Notification_Entity           (this, default, ACVNN(cvarname), MSG_INFO, strtoupper(#name), teamnum); \
+               Create_Notification_Entity           (this, defaultvalue, ACVNN(cvarname), MSG_INFO, strtoupper(#name), teamnum); \
                Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
                        args,     /* args    */ \
                        hudargs,  /* hudargs */ \
        }
  
  .string nent_iconargs;
- #define MULTIICON_INFO(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
-       MULTIICON_INFO_(INFO_##name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle)
- #define MULTIICON_INFO_(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
-       NOTIF_ADD_AUTOCVAR(name, default) \
+ #define MULTIICON_INFO(name, defaultvalue, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
+       MULTIICON_INFO_(INFO_##name, defaultvalue, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle)
+ #define MULTIICON_INFO_(name, defaultvalue, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \
+       NOTIF_ADD_AUTOCVAR(name, defaultvalue) \
        REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \
-               Create_Notification_Entity           (this, default, ACVNN(name), MSG_INFO, strtoupper(#name), 0); \
+               Create_Notification_Entity           (this, defaultvalue, ACVNN(name), MSG_INFO, strtoupper(#name), 0); \
                Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \
                        args,     /* args    */ \
                        hudargs,  /* hudargs */ \
                this.nent_iconargs = iconargs; \
        }
  
- #define MSG_CENTER_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
-       MSG_CENTER_NOTIF_(teamnum, CENTER_##name, CENTER_##cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
+ #define MSG_CENTER_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, strnum, flnum, args, cpid, durcnt, normal, gentle) \
+       MSG_CENTER_NOTIF_(teamnum, CENTER_##name, CENTER_##cvarname, defaultvalue, strnum, flnum, args, cpid, durcnt, normal, gentle)
  
- #define MSG_CENTER_NOTIF(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
-       NOTIF_ADD_AUTOCVAR(CENTER_##name, default) \
-       MSG_CENTER_NOTIF_(0, CENTER_##name, CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle)
+ #define MSG_CENTER_NOTIF(name, defaultvalue, strnum, flnum, args, cpid, durcnt, normal, gentle) \
+       NOTIF_ADD_AUTOCVAR(CENTER_##name, defaultvalue) \
+       MSG_CENTER_NOTIF_(0, CENTER_##name, CENTER_##name, defaultvalue, strnum, flnum, args, cpid, durcnt, normal, gentle)
  
- #define MSG_CENTER_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \
+ #define MSG_CENTER_NOTIF_(teamnum, name, cvarname, defaultvalue, strnum, flnum, args, cpid, durcnt, normal, gentle) \
        REGISTER(Notifications, name, m_id, new_pure(msg_center_notification)) { \
-               Create_Notification_Entity           (this, default, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), teamnum); \
+               Create_Notification_Entity           (this, defaultvalue, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), teamnum); \
                Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \
                        args,    /* args    */ \
                        "",      /* hudargs */ \
                        gentle); /* gentle  */ \
        }
  
- #define MSG_MULTI_NOTIF(name, default, anncename, infoname, centername) \
-       NOTIF_ADD_AUTOCVAR(name, default) \
+ #define MSG_MULTI_NOTIF(name, defaultvalue, anncename, infoname, centername) \
+       NOTIF_ADD_AUTOCVAR(name, defaultvalue) \
        REGISTER(Notifications, name, m_id, new_pure(msg_multi_notification)) { \
-               Create_Notification_Entity      (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name), 0); \
+               Create_Notification_Entity      (this, defaultvalue, ACVNN(name), MSG_MULTI, strtoupper(#name), 0); \
                Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \
                        anncename,   /* anncename  */ \
                        infoname,    /* infoname   */ \
                        centername); /* centername */ \
        }
  
- #define MSG_CHOICE_NOTIF_TEAM(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \
-       MSG_CHOICE_NOTIF_(teamnum, CHOICE_##name, CHOICE_##cvarname, default, challow, chtype, optiona, optionb)
+ #define MSG_CHOICE_NOTIF_TEAM(teamnum, name, cvarname, defaultvalue, challow, chtype, optiona, optionb) \
+       MSG_CHOICE_NOTIF_(teamnum, CHOICE_##name, CHOICE_##cvarname, defaultvalue, challow, chtype, optiona, optionb)
  
- #define MSG_CHOICE_NOTIF(name, default, challow, chtype, optiona, optionb) \
-       NOTIF_ADD_AUTOCVAR(CHOICE_##name, default) \
+ #define MSG_CHOICE_NOTIF(name, defaultvalue, challow, chtype, optiona, optionb) \
+       NOTIF_ADD_AUTOCVAR(CHOICE_##name, defaultvalue) \
        NOTIF_ADD_AUTOCVAR(CHOICE_##name##_ALLOWED, challow) \
-       MSG_CHOICE_NOTIF_(0, CHOICE_##name, CHOICE_##name, default, challow, chtype, optiona, optionb)
+       MSG_CHOICE_NOTIF_(0, CHOICE_##name, CHOICE_##name, defaultvalue, challow, chtype, optiona, optionb)
  
- #define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \
+ #define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, defaultvalue, 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       (this, defaultvalue, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), teamnum); \
                Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \
                        challow,                                 /* challow_def */ \
                        autocvar_notification_##cvarname##_ALLOWED,  /* challow_var */ \
@@@ -859,4 -856,17 +859,17 @@@ REGISTRY_END(Notifications
                LOG_SEVERE("Notification initialization failed! Read above and fix the errors!");
  }
  
+ #ifdef CSQC
+ .int cvar_value;
+ void ReplicateVars(bool would_destroy)
+ {
+       if (!would_destroy)
+               FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
+                       string cvarname = sprintf("notification_%s", Get_Notif_CvarName(it));
+                       // NOTE: REPLICATE_SIMPLE can return;
+                       REPLICATE_SIMPLE(it.cvar_value, cvarname);
+               });
+ }
+ #endif
  #include "all.inc"
diff --combined qcsrc/server/client.qh
index e70510d9b2d3c67f00f018ff144f825b9cfc07eb,bc4a60e1a88d5f55d7688e0b5756d2f06329d885..b20a8af93cdd5a72539e334adaefabf7b47ae3ac
@@@ -98,7 -98,7 +98,7 @@@ CLASS(Client, Object
      ATTRIB(Client, zoomstate, bool, this.zoomstate);
      ATTRIB(Client, just_joined, bool, this.just_joined);
      ATTRIB(Client, race_completed, bool, this.race_completed);
 -    ATTRIBARRAY(Client, msg_choice_choices, int, 50); // TODO: actually NOTIF_CHOICE_MAX
 +    ATTRIBARRAY(Client, msg_choice_choices, int, 20); // TODO: actually NOTIF_CHOICE_MAX
      ATTRIB(Client, latency_sum, float, this.latency_sum);
      ATTRIB(Client, latency_cnt, int, this.latency_cnt);
      ATTRIB(Client, latency_time, float, this.latency_time);
      ATTRIB(Client, cvar_cl_weaponimpulsemode, int, this.cvar_cl_weaponimpulsemode);
      ATTRIB(Client, cvar_g_xonoticversion, string, this.cvar_g_xonoticversion);
      ATTRIB(Client, autoswitch, bool, this.autoswitch);
+     ATTRIB(Client, cvar_cl_casings, bool, this.cvar_cl_casings);
      ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout);
      ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
      ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);