]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Get the new material system working. The material slider in the menu will not work...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 19:54:41 +0000 (22:54 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 19:54:41 +0000 (22:54 +0300)
qcsrc/server/mutators/sandbox.qc

index 5af69e20a0fa493ac51b8e69ef600231a05e773f..c82c815e7b10f07ccedea85aa8cfbbeeee34899e 100644 (file)
@@ -8,6 +8,8 @@ void sandbox_Object_Touch()
 {
        // apply material impact effects
 
+       if(!self.material)
+               return;
        if(self.touch_timer > time)
                return; // don't execute each frame
        self.touch_timer = time + 0.1;
@@ -102,7 +104,7 @@ entity sandbox_SpawnObject()
        e.movetype = MOVETYPE_TOSS;
        e.frame = 0;
        e.skin = 0;
-       e.material = "";
+       e.material = string_null;
 
        e.touch = sandbox_Object_Touch;
 
@@ -121,6 +123,11 @@ void sandbox_RemoveObject(entity e)
 {
        e.realowner.object_count -= 1;
 
+       if(e.material)
+       {
+               strunzone(e.material);
+               e.material = string_null;
+       }
        remove(e);
        e = world;
 }
@@ -414,9 +421,16 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                                        e.damageforcescale = stof(argv(3));
                                                        break;
                                                case "material":
-                                                       for (i = 1; i <= 5; i++) // precache material sounds, 5 in total
-                                                               precache_sound(strcat("object/impact_", argv(3), "_", ftos(i), ".ogg"));
-                                                       e.material = argv(3);
+                                                       if(e.material)
+                                                               strunzone(e.material);
+                                                       if(argv(3))
+                                                       {
+                                                               for (i = 1; i <= 5; i++) // precache material sounds, 5 in total
+                                                                       precache_sound(strcat("object/impact_", argv(3), "_", ftos(i), ".ogg"));
+                                                               e.material = strzone(argv(3));
+                                                       }
+                                                       else
+                                                               e.material = string_null; // no material
                                                        break;
                                                default:
                                                        print_to(self, "WARNING: Invalid object property. For usage information, type 'sandbox help'");