1 #ifndef __GAME_ERRORS_H
2 #define __GAME_ERRORS_H
3 
4 /*
5 	game_errors.h
6 
7 	Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8 	and the "Aleph One" developers.
9 
10 	This program is free software; you can redistribute it and/or modify
11 	it under the terms of the GNU General Public License as published by
12 	the Free Software Foundation; either version 3 of the License, or
13 	(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 	This license is contained in the file "COPYING",
21 	which is included with this source code; it is available online at
22 	http://www.gnu.org/licenses/gpl.html
23 
24 	Monday, June 12, 1995 9:24:29 AM- rdm created.
25 
26 */
27 
28 enum { /* types */
29 	systemError,
30 	gameError,
31 	NUMBER_OF_TYPES
32 };
33 
34 enum { /* Game Errors */
35 	errNone= 0,
36 	errMapFileNotSet,
37 	errIndexOutOfRange,
38 	errTooManyOpenFiles,
39 	errUnknownWadVersion,
40 	errWadIndexOutOfRange,
41 	errServerDied,
42 	errUnsyncOnLevelChange,
43 	NUMBER_OF_GAME_ERRORS
44 };
45 
46 void set_game_error(short type, short error_code);
47 short get_game_error(short *type);
48 bool error_pending(void);
49 void clear_game_error(void);
50 
51 // game_error system badly needs fixing (suggestion: use exceptions)
52 // for now, you can use this RAII class before calls where you don't care about
53 // the error, and it will restore the previous error when it is destroyed
54 class ScopedGameError
55 {
56 public:
ScopedGameError()57 	ScopedGameError() {
58 		_error = get_game_error(&_type);
59 	}
60 
~ScopedGameError()61 	~ScopedGameError() {
62 		set_game_error(_type, _error);
63 	}
64 
65 private:
66 	short _error, _type;
67 };
68 
69 #endif
70