aboutsummaryrefslogtreecommitdiff
path: root/tool_src/BspLib/BspFormat.cpp
blob: a358339947b711d128e9994a6b57f264f6df52fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//-----------------------------------------------------------------------------
//	BSPLIB MODULE: BspFormat.cpp
//
//  Copyright (c) 1997 by Markus Hadwiger
//  All Rights Reserved.
//-----------------------------------------------------------------------------

// bsplib header files
#include "BspFormat.h"


BSPLIB_NAMESPACE_BEGIN


// get index to section id specified as string (this function is static!) -----
//
int BspFormat::GetSectionId( char *section_name ) 
{ 
	int sectionid = SingleFormat::GetSectionId( section_name );
	if ( sectionid == _nil ) {
		for ( int i = 0; i < _num_bsp_sections - _num_single_sections; i++ )
			if ( stricmp( section_name, section_strings[ i ] ) == 0 )
				return section_ids[ i ];
	}
	return sectionid;
}


// get name of section specified via id (this function is static!) ------------
//
const char *BspFormat::GetSectionName( int section_id )
{
	const char *sectionname = SingleFormat::GetSectionName( section_id );
	if ( sectionname == NULL ) {
		return ( section_id < _num_bsp_sections ) ?
				section_strings[ section_id - _num_single_sections ] : NULL;
	}
	return sectionname;
}


// BspFormat specific static variables ----------------------------------------
//
const char BspFormat::_bspsig_str[]					= "#BSP";
const char BspFormat::BSP_FILE_EXTENSION[]			= ".bsp";

const char BspFormat::_bspspec_polygon_str[]		= "polygon";
const char BspFormat::_bspspec_frontlist_str[]		= "frontlist";
const char BspFormat::_bspspec_backlist_str[]		= "backlist";
const char BspFormat::_bspspec_fronttree_str[]		= "fronttree";
const char BspFormat::_bspspec_backtree_str[]		= "backtree";
const char BspFormat::_bspspec_plane_str[]			= "plane";
const char BspFormat::_bspspec_boundingbox_str[]	= "boundingbox";

const char BspFormat::_bsptree_str[]				= "#bsptree";
const char BspFormat::_polygons_str[] 				= "#polygons";

// additional section names table
const char *BspFormat::section_strings[] = {
	_bsptree_str,
	_polygons_str
};
const int BspFormat::section_ids[] = {
	_bsptree,
	_polygons
};


BSPLIB_NAMESPACE_END

//-----------------------------------------------------------------------------