Initialize func_breakable sound on connect.
authorRudolf Polzer <divverent@xonotic.org>
Sat, 21 Feb 2015 15:03:44 +0000 (16:03 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 21 Feb 2015 15:03:44 +0000 (16:03 +0100)
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/func_breakable.qc

index 405d558..3bc5cc7 100644 (file)
@@ -1249,6 +1249,13 @@ void ClientConnect (void)
        if(IS_REAL_CLIENT(self))
                sv_notice_join();
 
+       for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
+               entity oldself = self;
+               self = e;
+               e.init_for_player(oldself);
+               self = oldself;
+       }
+
        MUTATOR_CALLHOOK(ClientConnect);
 }
 /*
index 175179b..822c516 100644 (file)
@@ -623,4 +623,8 @@ const int MIF_GUIDED_TAG = 128;
 .string playernick;
 .float elos;
 .float ranks;
+
+.float init_for_player_needed;
+.void(entity) init_for_player;
+
 #endif
index a8cca1e..127f622 100644 (file)
@@ -142,6 +142,15 @@ void func_breakable_behave_restore()
                sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
 }
 
+void func_breakable_init_for_player(entity player)
+{
+       if (self.state == 0)
+       {
+               msg_entity = player;
+               soundto (MSG_ONE, self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
+       }
+}
+
 void func_breakable_destroyed()
 {
        func_breakable_look_destroyed();
@@ -283,6 +292,9 @@ void spawnfunc_func_breakable() {
        self.reset = func_breakable_reset;
        func_breakable_reset();
 
+       self.init_for_player_needed = 1;
+       self.init_for_player = func_breakable_init_for_player;
+
        CSQCMODEL_AUTOINIT();
 }