1 /*=============================================================================
2 Blobby Volley 2
3 Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de)
4 Copyright (C) 2006 Daniel Knobe (daniel-knobe@web.de)
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 =============================================================================*/
20 
21 #pragma once
22 
23 #include <string>
24 #include <exception>
25 #include <SDL2/SDL_stdinc.h>
26 #include <cstring>
27 
28 // I hope the GP2X is the only combination of these systems
29 #if defined(__linux__) && defined(__arm__)
30 #define GP2X GP2X
31 #endif
32 
33 #if defined __ANDROID__ || (defined __APPLE__ && !MAC_OS_X)
34 #define __MOBILE__ true
35 #define __DESKTOP__ false
36 #else
37 #define __MOBILE__ false
38 #define __DESKTOP__ true
39 #endif // defined
40 
41 /*!	\def DEBUG
42 	\brief Enable debugging support
43 	\details when this marko is present, Blobby generates some additional debugging code
44 			usefull for tracking down bugs.
45 */
46 
47 const int BLOBBY_PORT = 1234;
48 
49 const int BLOBBY_VERSION_MAJOR = 0;
50 const int BLOBBY_VERSION_MINOR = 103;
51 
52 const char AppTitle[] = "Blobby Volley 2 Version 1.0";
53 const int BASE_RESOLUTION_X = 800;
54 const int BASE_RESOLUTION_Y = 600;
55 
56 const float ROUND_START_SOUND_VOLUME = 0.2;
57 const float BALL_HIT_PLAYER_SOUND_VOLUME = 0.4;
58 
59 // max. 1 ms additional latency, but much improved performance
60 const int RAKNET_THREAD_SLEEP_TIME = 1;
61 
62 const std::string DEFAULT_RULES_FILE = "default.lua";
63 
64 enum PlayerSide
65 {
66 	NO_PLAYER = -1,
67 	LEFT_PLAYER = 0,
68 	RIGHT_PLAYER = 1,
69 	//LEFT_PLAYER_2 = 2,
70 	//RIGHT_PLAYER_2 = 3,
71 	MAX_PLAYERS // This is always one more than the highest player enum
72 	            // and can be used to declare arrays
73 };
74 
75 enum InputDeviceName
76 {
77 	KEYBOARD = 1,
78 	MOUSE = 2,
79 	JOYSTICK = 3
80 };
81 
82 /*! \class Color
83 	\brief represents RGB Colours
84 	\details This class represents colors as RGB with one byte for each channel.
85 */
86 struct Color
87 {
ColorColor88 	Color(int red, int green, int blue)
89 	: r(red)
90 	, g(green)
91 	, b(blue)
92 	{}
93 
94 	/// \sa toInt()
ColorColor95 	Color(unsigned int col)
96 	: r(col&0xff)
97 	, g((col>>8)&0xff)
98 	, b((col>>16)&0xff)
99 	{
100 
101 	}
102 
ColorColor103 	Color() {}
104 
105 	union
106 	{
107 		struct
108 		{
109 			Uint8 r;
110 			Uint8 g;
111 			Uint8 b;
112 		};
113 		Uint8 val[3];
114 	};
115 
116 	bool operator == (Color rval) const
117 	{
118 		return !std::memcmp(val, rval.val, 3);
119 	}
120 
121 	bool operator != (Color rval) const
122 	{
123 		return !(*this == rval);
124 	}
125 
toIntColor126 	unsigned int toInt() const
127 	{
128 		int i = 0;
129 		i |= r;
130 		i |= g << 8;
131 		i |= b << 16;
132 		return i;
133 	}
134 
135 };
136 
137 
138 struct ExtensionUnsupportedException : public std::exception
139 {
140 	std::string extension;
ExtensionUnsupportedExceptionExtensionUnsupportedException141 	ExtensionUnsupportedException(std::string name) : extension(name) {}
throwExtensionUnsupportedException142 	~ExtensionUnsupportedException() throw() {}
143 };
144 
145 struct ScriptException : public std::exception
146 {
147 	std::string luaerror;
throwScriptException148 	~ScriptException() throw() {}
149 };
150 
151 /// we need to define this constant to make it compile with strict c++98 mode
152 #undef M_PI
153 const double M_PI = 3.141592653589793238462643383279;
154