1 //------------------------------------------------------------------------
2 //  OBJECT IDENTIFICATION
3 //------------------------------------------------------------------------
4 //
5 //  Eureka DOOM Editor
6 //
7 //  Copyright (C) 2001-2019 Andrew Apted
8 //  Copyright (C) 1997-2003 André Majorel et al
9 //
10 //  This program is free software; you can redistribute it and/or
11 //  modify it under the terms of the GNU General Public License
12 //  as published by the Free Software Foundation; either version 2
13 //  of the License, or (at your option) any later version.
14 //
15 //  This program is distributed in the hope that it will be useful,
16 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 //  GNU General Public License for more details.
19 //
20 //------------------------------------------------------------------------
21 //
22 //  Based on Yadex which incorporated code from DEU 5.21 that was put
23 //  in the public domain in 1994 by Raphaël Quinet and Brendon Wyber.
24 //
25 //------------------------------------------------------------------------
26 
27 #ifndef __EUREKA_OBJ_ID_H__
28 #define __EUREKA_OBJ_ID_H__
29 
30 
31 // main kinds of objects
32 typedef enum
33 {
34 	OBJ_THINGS,
35 	OBJ_LINEDEFS,
36 	OBJ_SIDEDEFS,
37 	OBJ_VERTICES,
38 	OBJ_SECTORS,
39 }
40 obj_type_e;
41 
42 
43 // special object number for "NONE"
44 #define NIL_OBJ		-1
45 
46 
47 // bit flags for object parts (bit zero is reserved)
48 #define PART_FLOOR		0x02
49 #define PART_CEIL		0x04
50 #define PART_SEC_ALL	(PART_FLOOR + PART_CEIL)
51 
52 #define PART_RT_LOWER		0x02
53 #define PART_RT_UPPER		0x04
54 #define PART_RT_RAIL		0x08
55 #define PART_RT_ALL			(PART_RT_LOWER | PART_RT_UPPER | PART_RT_RAIL)
56 
57 #define PART_LF_LOWER		0x20
58 #define PART_LF_UPPER		0x40
59 #define PART_LF_RAIL		0x80
60 #define PART_LF_ALL			(PART_LF_LOWER | PART_LF_UPPER | PART_LF_RAIL)
61 
62 
63 class Objid
64 {
65 public:
66 	obj_type_e type;
67 
68 	int num;
69 
70 	// this is some combination of PART_XXX flags, or 0 which
71 	// represents the object as a whole.
72 	int parts;
73 
74 public:
Objid()75 	Objid() : type(OBJ_THINGS), num(NIL_OBJ), parts(0) { }
Objid(obj_type_e t,int n)76 	Objid(obj_type_e t, int n) : type(t), num(n), parts(0) { }
Objid(obj_type_e t,int n,int p)77 	Objid(obj_type_e t, int n, int p) : type(t), num(n), parts(p) { }
Objid(const Objid & other)78 	Objid(const Objid& other) : type(other.type), num(other.num), parts(other.parts) { }
79 
clear()80 	void clear()
81 	{
82 		num = NIL_OBJ;
83 		parts = 0;
84 	}
85 
valid()86 	bool valid()  const { return num >= 0; }
is_nil()87 	bool is_nil() const { return num <  0; }
88 
89 	bool operator== (const Objid& other) const
90 	{
91 		return  (other.type  == type) &&
92 				(other.num   == num) &&
93 				(other.parts == parts);
94 	}
95 
96 private:
97 	// not generally available
98 	bool operator!= (const Objid& other) const { return false; }
99 };
100 
101 
102 #endif  /* __EUREKA_OBJ_ID_H__ */
103 
104 //--- editor settings ---
105 // vi:ts=4:sw=4:noexpandtab
106