2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 ----------------------------------------------------------------------------------
23 This code has been altered significantly from its original form, to support
24 several games based on the Quake III Arena engine, in the form of "Q3Map2."
26 ------------------------------------------------------------------------------- */
41 ==============================================================================
45 Save out name.line for qe3 to read
46 ==============================================================================
54 Finds the shortest possible chain of portals
55 that leads from the outside leaf to a specifically
58 TTimo: builds a polyline xml node
61 xmlNodePtr LeakFile (tree_t *tree)
68 xmlNodePtr xml_node, point;
70 if (!tree->outside_node.occupied)
73 Sys_FPrintf (SYS_VRB,"--- LeakFile ---\n");
76 // write the points to the file
78 sprintf (filename, "%s.lin", source);
79 linefile = fopen (filename, "w");
81 Error ("Couldn't open %s\n", filename);
83 xml_node = xmlNewNode (NULL, "polyline");
86 node = &tree->outside_node;
87 while (node->occupied > 1)
90 portal_t *p, *nextportal;
94 // find the best portal exit
95 next = node->occupied;
96 for (p=node->portals ; p ; p = p->next[!s])
98 s = (p->nodes[0] == node);
99 if (p->nodes[s]->occupied
100 && p->nodes[s]->occupied < next)
103 nextnode = p->nodes[s];
104 next = nextnode->occupied;
108 WindingCenter (nextportal->winding, mid);
109 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
110 point = xml_NodeForVec(mid);
111 xmlAddChild(xml_node, point);
114 // add the occupant center
115 GetVectorForKey (node->occupant, "origin", mid);
117 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
118 point = xml_NodeForVec(mid);
119 xmlAddChild(xml_node, point);
120 Sys_FPrintf( SYS_VRB, "%9d point linefile\n", count+1);