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