X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Ft_plats.qc;h=8c2766295e7ca3cad676c15247e82c9581404a11;hb=f192c14ff0d6d3205d90f83f254ecaa637e59bbb;hp=8d81ca263d60f04ff8df54a6535876d64e0e6e33;hpb=666aa5a431dc80985574fdddbc7c322cc7fd0811;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index 8d81ca263..8c2766295 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -1225,24 +1225,32 @@ entity spawn_field(vector fmins, vector fmaxs) } -float EntitiesTouching(entity e1, entity e2) +entity LinkDoors_nextent(entity cur, entity near, entity pass) { - if (e1.absmin_x > e2.absmax_x) + while((cur = find(cur, classname, self.classname)) && ((cur.spawnflags & 4) || cur.enemy)) + { + } + return cur; +} + +float LinkDoors_isconnected(entity e1, entity e2, entity pass) +{ + float DELTA = 4; + if (e1.absmin_x > e2.absmax_x + DELTA) return FALSE; - if (e1.absmin_y > e2.absmax_y) + if (e1.absmin_y > e2.absmax_y + DELTA) return FALSE; - if (e1.absmin_z > e2.absmax_z) + if (e1.absmin_z > e2.absmax_z + DELTA) return FALSE; - if (e1.absmax_x < e2.absmin_x) + if (e2.absmin_x > e1.absmax_x + DELTA) return FALSE; - if (e1.absmax_y < e2.absmin_y) + if (e2.absmin_y > e1.absmax_y + DELTA) return FALSE; - if (e1.absmax_z < e2.absmin_z) + if (e2.absmin_z > e1.absmax_z + DELTA) return FALSE; return TRUE; } - /* ============= LinkDoors @@ -1252,7 +1260,7 @@ LinkDoors */ void LinkDoors() { - entity t, starte; + entity t; vector cmins, cmaxs; if (self.enemy) @@ -1272,68 +1280,70 @@ void LinkDoors() return; // don't want to link this door } - cmins = self.absmin; - cmaxs = self.absmax; - - starte = self; - t = self; + FindConnectedComponent(self, enemy, LinkDoors_nextent, LinkDoors_isconnected, world); - do + // set owner, and make a loop of the chain + dprint("LinkDoors: linking doors:"); + for(t = self; ; t = t.enemy) { - self.owner = starte; // master door - - if (self.health) - starte.health = self.health; - IFTARGETED - starte.targetname = self.targetname; - if (self.message != "") - starte.message = self.message; - - t = find(t, classname, self.classname); - if (!t) + dprint(" ", etos(t)); + t.owner = self; + if(t.enemy == world) { - self.enemy = starte; // make the chain a loop - - // shootable, or triggered doors just needed the owner/enemy links, - // they don't spawn a field - - self = self.owner; + t.enemy = self; + break; + } + } + dprint("\n"); - if (self.health) - return; - IFTARGETED - return; - if (self.items) - return; + // collect health, targetname, message, size + cmins = self.absmin; + cmaxs = self.absmax; + for(t = self; ; t = t.enemy) + { + if(t.health && !self.health) + self.health = t.health; + if(t.targetname && !self.targetname) + self.targetname = t.targetname; + if(t.message != "" && self.message == "") + self.message = t.message; + if (t.absmin_x < cmins_x) + cmins_x = t.absmin_x; + if (t.absmin_y < cmins_y) + cmins_y = t.absmin_y; + if (t.absmin_z < cmins_z) + cmins_z = t.absmin_z; + if (t.absmax_x > cmaxs_x) + cmaxs_x = t.absmax_x; + if (t.absmax_y > cmaxs_y) + cmaxs_y = t.absmax_y; + if (t.absmax_z > cmaxs_z) + cmaxs_z = t.absmax_z; + if(t.enemy == self) + break; + } - self.owner.trigger_field = spawn_field(cmins, cmaxs); + // distribute health, targetname, message + for(t = self; t; t = t.enemy) + { + t.health = self.health; + t.targetname = self.targetname; + t.message = self.message; + if(t.enemy == self) + break; + } - return; - } + // shootable, or triggered doors just needed the owner/enemy links, + // they don't spawn a field - if (EntitiesTouching(self,t)) - { - if (t.enemy) - objerror ("cross connected doors"); - - self.enemy = t; - self = t; - - if (t.absmin_x < cmins_x) - cmins_x = t.absmin_x; - if (t.absmin_y < cmins_y) - cmins_y = t.absmin_y; - if (t.absmin_z < cmins_z) - cmins_z = t.absmin_z; - if (t.absmax_x > cmaxs_x) - cmaxs_x = t.absmax_x; - if (t.absmax_y > cmaxs_y) - cmaxs_y = t.absmax_y; - if (t.absmax_z > cmaxs_z) - cmaxs_z = t.absmax_z; - } - } while (1 ); + if (self.health) + return; + IFTARGETED + return; + if (self.items) + return; + self.trigger_field = spawn_field(cmins, cmaxs); } @@ -1996,7 +2006,7 @@ void func_vectormamamam_findtarget() if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03) objerror("No reference entity found, so there is nothing to move. Aborting."); - self.destvec = self.origin - func_vectormamamam_origin(self.owner, 0); + self.destvec = self.origin - func_vectormamamam_origin(self, 0); entity controller; controller = spawn();