Debian Codegraph @

tools/quake3/q3map2/bsp_info.c

raw symbols SCIP
1 /* -------------------------------------------------------------------------------
2
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
5
6 This file is part of GtkRadiant.
7
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.
12
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.
17
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
21
22 -------------------------------------------------------------------------------
23
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."
26
27 ------------------------------------------------------------------------------- */
28
29
30
31 /* dependencies */
32 #include "q3map2.h"
33
34
35
36 /*
37 BSPInfoMain()
38 emits statistics about the bsp file
39 */
40
41 int BSPInfoMain( int count, char **fileNames ){
42 int i;
43 char source[ 1024 ], ext[ 64 ];
44 int size;
45 FILE *f;
46
47
48 /* dummy check */
49 if ( count < 1 ) {
50 Sys_Printf( "No files to dump info for.\n" );
51 return -1;
52 }
53
54 /* enable info mode */
55 infoMode = qtrue;
56
57 /* walk file list */
58 for ( i = 0; i < count; i++ )
59 {
60 Sys_Printf( "---------------------------------\n" );
61
62 /* mangle filename and get size */
63 strcpy( source, fileNames[ i ] );
64 ExtractFileExtension( source, ext );
65 if ( !Q_stricmp( ext, "map" ) ) {
66 StripExtension( source );
67 }
68 DefaultExtension( source, ".bsp" );
69 f = fopen( source, "rb" );
70 if ( f ) {
71 size = Q_filelength( f );
72 fclose( f );
73 }
74 else{
75 size = 0;
76 }
77
78 /* load the bsp file and print lump sizes */
79 Sys_Printf( "%s\n", source );
80 LoadBSPFile( source );
81 PrintBSPFileSizes();
82
83 /* print sizes */
84 Sys_Printf( "\n" );
85 Sys_Printf( " total %9d\n", size );
86 Sys_Printf( " %9d KB\n", size / 1024 );
87 Sys_Printf( " %9d MB\n", size / ( 1024 * 1024 ) );
88
89 Sys_Printf( "---------------------------------\n" );
90 }
91
92 /* return count */
93 return i;
94 }