astyle
parent
00a944ce24
commit
ef6a1262c5
|
@ -19,7 +19,8 @@
|
|||
*/
|
||||
|
||||
// 0
|
||||
{ 1.23, 1.30, 1.47, 1.35, 1.56, 1.71, 1.37, 1.38,
|
||||
{
|
||||
1.23, 1.30, 1.47, 1.35, 1.56, 1.71, 1.37, 1.38,
|
||||
1.59, 1.60, 1.79, 1.97, 1.88, 1.92, 1.79, 1.02,
|
||||
0.93, 1.07, 0.82, 0.87, 0.88, 0.94, 0.96, 1.14,
|
||||
1.11, 0.82, 0.83, 0.89, 0.89, 0.86, 0.94, 0.91,
|
||||
|
@ -51,10 +52,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 1
|
||||
{ 1.26, 1.26, 1.48, 1.23, 1.50, 1.71, 1.14, 1.19,
|
||||
{
|
||||
1.26, 1.26, 1.48, 1.23, 1.50, 1.71, 1.14, 1.19,
|
||||
1.38, 1.46, 1.64, 1.94, 1.87, 1.84, 1.71, 1.02,
|
||||
0.92, 1.00, 0.79, 0.85, 0.84, 0.91, 0.90, 0.98,
|
||||
0.99, 0.77, 0.77, 0.83, 0.82, 0.79, 0.86, 0.84,
|
||||
|
@ -86,10 +88,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 2
|
||||
{ 1.34, 1.27, 1.53, 1.17, 1.46, 1.71, 0.98, 1.05,
|
||||
{
|
||||
1.34, 1.27, 1.53, 1.17, 1.46, 1.71, 0.98, 1.05,
|
||||
1.20, 1.34, 1.48, 1.86, 1.82, 1.71, 1.62, 1.09,
|
||||
0.94, 0.99, 0.79, 0.85, 0.82, 0.90, 0.87, 0.93,
|
||||
0.96, 0.76, 0.74, 0.79, 0.76, 0.74, 0.79, 0.78,
|
||||
|
@ -121,10 +124,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 3
|
||||
{ 1.46, 1.34, 1.60, 1.16, 1.46, 1.71, 0.94, 0.99,
|
||||
{
|
||||
1.46, 1.34, 1.60, 1.16, 1.46, 1.71, 0.94, 0.99,
|
||||
1.05, 1.26, 1.33, 1.74, 1.76, 1.57, 1.54, 1.23,
|
||||
0.98, 1.05, 0.83, 0.89, 0.84, 0.92, 0.87, 0.91,
|
||||
0.96, 0.78, 0.74, 0.79, 0.72, 0.72, 0.75, 0.76,
|
||||
|
@ -156,10 +160,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 4
|
||||
{ 1.60, 1.44, 1.68, 1.22, 1.49, 1.71, 0.93, 0.99,
|
||||
{
|
||||
1.60, 1.44, 1.68, 1.22, 1.49, 1.71, 0.93, 0.99,
|
||||
0.99, 1.23, 1.22, 1.60, 1.68, 1.44, 1.49, 1.40,
|
||||
1.14, 1.19, 0.89, 0.96, 0.89, 0.97, 0.89, 0.91,
|
||||
0.98, 0.82, 0.76, 0.82, 0.71, 0.72, 0.73, 0.76,
|
||||
|
@ -191,10 +196,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 5
|
||||
{ 1.74, 1.57, 1.76, 1.33, 1.54, 1.71, 0.94, 1.05,
|
||||
{
|
||||
1.74, 1.57, 1.76, 1.33, 1.54, 1.71, 0.94, 1.05,
|
||||
0.99, 1.26, 1.16, 1.46, 1.60, 1.34, 1.46, 1.59,
|
||||
1.37, 1.37, 0.97, 1.11, 0.96, 1.10, 0.95, 0.94,
|
||||
1.08, 0.89, 0.82, 0.88, 0.72, 0.76, 0.75, 0.80,
|
||||
|
@ -226,10 +232,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 6
|
||||
{ 1.86, 1.71, 1.82, 1.48, 1.62, 1.71, 0.98, 1.20,
|
||||
{
|
||||
1.86, 1.71, 1.82, 1.48, 1.62, 1.71, 0.98, 1.20,
|
||||
1.05, 1.34, 1.17, 1.34, 1.53, 1.27, 1.46, 1.77,
|
||||
1.60, 1.57, 1.16, 1.38, 1.12, 1.35, 1.06, 1.00,
|
||||
1.28, 0.97, 0.89, 0.95, 0.76, 0.81, 0.79, 0.86,
|
||||
|
@ -261,10 +268,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 7
|
||||
{ 1.94, 1.84, 1.87, 1.64, 1.71, 1.71, 1.14, 1.38,
|
||||
{
|
||||
1.94, 1.84, 1.87, 1.64, 1.71, 1.71, 1.14, 1.38,
|
||||
1.19, 1.46, 1.23, 1.26, 1.48, 1.26, 1.50, 1.91,
|
||||
1.80, 1.76, 1.41, 1.61, 1.39, 1.59, 1.33, 1.24,
|
||||
1.51, 1.18, 0.97, 1.11, 0.82, 0.88, 0.86, 0.94,
|
||||
|
@ -296,10 +304,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 8
|
||||
{ 1.97, 1.92, 1.88, 1.79, 1.79, 1.71, 1.37, 1.59,
|
||||
{
|
||||
1.97, 1.92, 1.88, 1.79, 1.79, 1.71, 1.37, 1.59,
|
||||
1.38, 1.60, 1.35, 1.23, 1.47, 1.30, 1.56, 1.99,
|
||||
1.93, 1.90, 1.60, 1.78, 1.61, 1.79, 1.57, 1.48,
|
||||
1.72, 1.40, 1.14, 1.37, 0.89, 0.96, 0.94, 1.07,
|
||||
|
@ -331,10 +340,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 9
|
||||
{ 1.94, 1.97, 1.87, 1.91, 1.85, 1.71, 1.60, 1.77,
|
||||
{
|
||||
1.94, 1.97, 1.87, 1.91, 1.85, 1.71, 1.60, 1.77,
|
||||
1.58, 1.74, 1.51, 1.26, 1.48, 1.39, 1.64, 1.99,
|
||||
1.97, 1.99, 1.70, 1.85, 1.76, 1.91, 1.76, 1.70,
|
||||
1.88, 1.55, 1.33, 1.57, 0.96, 1.08, 1.05, 1.31,
|
||||
|
@ -366,10 +376,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 10
|
||||
{ 1.86, 1.95, 1.82, 1.98, 1.89, 1.71, 1.80, 1.91,
|
||||
{
|
||||
1.86, 1.95, 1.82, 1.98, 1.89, 1.71, 1.80, 1.91,
|
||||
1.77, 1.86, 1.67, 1.34, 1.53, 1.51, 1.72, 1.92,
|
||||
1.91, 1.99, 1.69, 1.82, 1.80, 1.94, 1.87, 1.86,
|
||||
1.97, 1.59, 1.44, 1.69, 1.05, 1.24, 1.27, 1.49,
|
||||
|
@ -401,10 +412,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 11
|
||||
{ 1.74, 1.89, 1.76, 1.98, 1.89, 1.71, 1.93, 1.99,
|
||||
{
|
||||
1.74, 1.89, 1.76, 1.98, 1.89, 1.71, 1.93, 1.99,
|
||||
1.91, 1.94, 1.82, 1.46, 1.60, 1.65, 1.80, 1.79,
|
||||
1.77, 1.92, 1.57, 1.69, 1.74, 1.87, 1.88, 1.94,
|
||||
1.98, 1.53, 1.45, 1.70, 1.18, 1.32, 1.42, 1.58,
|
||||
|
@ -436,10 +448,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 12
|
||||
{ 1.60, 1.78, 1.68, 1.93, 1.86, 1.71, 1.97, 1.99,
|
||||
{
|
||||
1.60, 1.78, 1.68, 1.93, 1.86, 1.71, 1.97, 1.99,
|
||||
1.99, 1.97, 1.93, 1.60, 1.68, 1.78, 1.86, 1.61,
|
||||
1.57, 1.79, 1.37, 1.48, 1.59, 1.72, 1.79, 1.92,
|
||||
1.90, 1.38, 1.35, 1.60, 1.23, 1.30, 1.47, 1.56,
|
||||
|
@ -471,10 +484,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 13
|
||||
{ 1.46, 1.65, 1.60, 1.82, 1.80, 1.71, 1.93, 1.91,
|
||||
{
|
||||
1.46, 1.65, 1.60, 1.82, 1.80, 1.71, 1.93, 1.91,
|
||||
1.99, 1.94, 1.98, 1.74, 1.76, 1.89, 1.89, 1.42,
|
||||
1.34, 1.61, 1.11, 1.22, 1.36, 1.50, 1.61, 1.81,
|
||||
1.75, 1.15, 1.17, 1.41, 1.18, 1.19, 1.42, 1.44,
|
||||
|
@ -506,10 +520,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 14
|
||||
{ 1.34, 1.51, 1.53, 1.67, 1.72, 1.71, 1.80, 1.77,
|
||||
{
|
||||
1.34, 1.51, 1.53, 1.67, 1.72, 1.71, 1.80, 1.77,
|
||||
1.91, 1.86, 1.98, 1.86, 1.82, 1.95, 1.89, 1.24,
|
||||
1.10, 1.41, 0.95, 0.99, 1.09, 1.25, 1.37, 1.63,
|
||||
1.55, 0.96, 0.98, 1.16, 1.05, 1.00, 1.27, 1.23,
|
||||
|
@ -541,10 +556,11 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
},
|
||||
},
|
||||
|
||||
// 15
|
||||
{ 1.26, 1.39, 1.48, 1.51, 1.64, 1.71, 1.60, 1.58,
|
||||
{
|
||||
1.26, 1.39, 1.48, 1.51, 1.64, 1.71, 1.60, 1.58,
|
||||
1.77, 1.74, 1.91, 1.94, 1.87, 1.97, 1.85, 1.10,
|
||||
0.97, 1.22, 0.88, 0.92, 0.95, 1.01, 1.11, 1.39,
|
||||
1.32, 0.88, 0.90, 0.97, 0.96, 0.93, 1.05, 0.99,
|
||||
|
@ -576,5 +592,5 @@
|
|||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00,
|
||||
1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00
|
||||
}
|
||||
}
|
||||
|
||||
|
|
324
source/anorms.h
324
source/anorms.h
|
@ -18,165 +18,165 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
{ -0.525731, 0.000000, 0.850651 },
|
||||
{ -0.442863, 0.238856, 0.864188 },
|
||||
{ -0.295242, 0.000000, 0.955423 },
|
||||
{ -0.309017, 0.500000, 0.809017 },
|
||||
{ -0.162460, 0.262866, 0.951056 },
|
||||
{ 0.000000, 0.000000, 1.000000 },
|
||||
{ 0.000000, 0.850651, 0.525731 },
|
||||
{ -0.147621, 0.716567, 0.681718 },
|
||||
{ 0.147621, 0.716567, 0.681718 },
|
||||
{ 0.000000, 0.525731, 0.850651 },
|
||||
{ 0.309017, 0.500000, 0.809017 },
|
||||
{ 0.525731, 0.000000, 0.850651 },
|
||||
{ 0.295242, 0.000000, 0.955423 },
|
||||
{ 0.442863, 0.238856, 0.864188 },
|
||||
{ 0.162460, 0.262866, 0.951056 },
|
||||
{ -0.681718, 0.147621, 0.716567 },
|
||||
{ -0.809017, 0.309017, 0.500000 },
|
||||
{ -0.587785, 0.425325, 0.688191 },
|
||||
{ -0.850651, 0.525731, 0.000000 },
|
||||
{ -0.864188, 0.442863, 0.238856 },
|
||||
{ -0.716567, 0.681718, 0.147621 },
|
||||
{ -0.688191, 0.587785, 0.425325 },
|
||||
{ -0.500000, 0.809017, 0.309017 },
|
||||
{ -0.238856, 0.864188, 0.442863 },
|
||||
{ -0.425325, 0.688191, 0.587785 },
|
||||
{ -0.716567, 0.681718, -0.147621 },
|
||||
{ -0.500000, 0.809017, -0.309017 },
|
||||
{ -0.525731, 0.850651, 0.000000 },
|
||||
{ 0.000000, 0.850651, -0.525731 },
|
||||
{ -0.238856, 0.864188, -0.442863 },
|
||||
{ 0.000000, 0.955423, -0.295242 },
|
||||
{ -0.262866, 0.951056, -0.162460 },
|
||||
{ 0.000000, 1.000000, 0.000000 },
|
||||
{ 0.000000, 0.955423, 0.295242 },
|
||||
{ -0.262866, 0.951056, 0.162460 },
|
||||
{ 0.238856, 0.864188, 0.442863 },
|
||||
{ 0.262866, 0.951056, 0.162460 },
|
||||
{ 0.500000, 0.809017, 0.309017 },
|
||||
{ 0.238856, 0.864188, -0.442863 },
|
||||
{ 0.262866, 0.951056, -0.162460 },
|
||||
{ 0.500000, 0.809017, -0.309017 },
|
||||
{ 0.850651, 0.525731, 0.000000 },
|
||||
{ 0.716567, 0.681718, 0.147621 },
|
||||
{ 0.716567, 0.681718, -0.147621 },
|
||||
{ 0.525731, 0.850651, 0.000000 },
|
||||
{ 0.425325, 0.688191, 0.587785 },
|
||||
{ 0.864188, 0.442863, 0.238856 },
|
||||
{ 0.688191, 0.587785, 0.425325 },
|
||||
{ 0.809017, 0.309017, 0.500000 },
|
||||
{ 0.681718, 0.147621, 0.716567 },
|
||||
{ 0.587785, 0.425325, 0.688191 },
|
||||
{ 0.955423, 0.295242, 0.000000 },
|
||||
{ 1.000000, 0.000000, 0.000000 },
|
||||
{ 0.951056, 0.162460, 0.262866 },
|
||||
{ 0.850651, -0.525731, 0.000000 },
|
||||
{ 0.955423, -0.295242, 0.000000 },
|
||||
{ 0.864188, -0.442863, 0.238856 },
|
||||
{ 0.951056, -0.162460, 0.262866 },
|
||||
{ 0.809017, -0.309017, 0.500000 },
|
||||
{ 0.681718, -0.147621, 0.716567 },
|
||||
{ 0.850651, 0.000000, 0.525731 },
|
||||
{ 0.864188, 0.442863, -0.238856 },
|
||||
{ 0.809017, 0.309017, -0.500000 },
|
||||
{ 0.951056, 0.162460, -0.262866 },
|
||||
{ 0.525731, 0.000000, -0.850651 },
|
||||
{ 0.681718, 0.147621, -0.716567 },
|
||||
{ 0.681718, -0.147621, -0.716567 },
|
||||
{ 0.850651, 0.000000, -0.525731 },
|
||||
{ 0.809017, -0.309017, -0.500000 },
|
||||
{ 0.864188, -0.442863, -0.238856 },
|
||||
{ 0.951056, -0.162460, -0.262866 },
|
||||
{ 0.147621, 0.716567, -0.681718 },
|
||||
{ 0.309017, 0.500000, -0.809017 },
|
||||
{ 0.425325, 0.688191, -0.587785 },
|
||||
{ 0.442863, 0.238856, -0.864188 },
|
||||
{ 0.587785, 0.425325, -0.688191 },
|
||||
{ 0.688191, 0.587785, -0.425325 },
|
||||
{ -0.147621, 0.716567, -0.681718 },
|
||||
{ -0.309017, 0.500000, -0.809017 },
|
||||
{ 0.000000, 0.525731, -0.850651 },
|
||||
{ -0.525731, 0.000000, -0.850651 },
|
||||
{ -0.442863, 0.238856, -0.864188 },
|
||||
{ -0.295242, 0.000000, -0.955423 },
|
||||
{ -0.162460, 0.262866, -0.951056 },
|
||||
{ 0.000000, 0.000000, -1.000000 },
|
||||
{ 0.295242, 0.000000, -0.955423 },
|
||||
{ 0.162460, 0.262866, -0.951056 },
|
||||
{ -0.442863, -0.238856, -0.864188 },
|
||||
{ -0.309017, -0.500000, -0.809017 },
|
||||
{ -0.162460, -0.262866, -0.951056 },
|
||||
{ 0.000000, -0.850651, -0.525731 },
|
||||
{ -0.147621, -0.716567, -0.681718 },
|
||||
{ 0.147621, -0.716567, -0.681718 },
|
||||
{ 0.000000, -0.525731, -0.850651 },
|
||||
{ 0.309017, -0.500000, -0.809017 },
|
||||
{ 0.442863, -0.238856, -0.864188 },
|
||||
{ 0.162460, -0.262866, -0.951056 },
|
||||
{ 0.238856, -0.864188, -0.442863 },
|
||||
{ 0.500000, -0.809017, -0.309017 },
|
||||
{ 0.425325, -0.688191, -0.587785 },
|
||||
{ 0.716567, -0.681718, -0.147621 },
|
||||
{ 0.688191, -0.587785, -0.425325 },
|
||||
{ 0.587785, -0.425325, -0.688191 },
|
||||
{ 0.000000, -0.955423, -0.295242 },
|
||||
{ 0.000000, -1.000000, 0.000000 },
|
||||
{ 0.262866, -0.951056, -0.162460 },
|
||||
{ 0.000000, -0.850651, 0.525731 },
|
||||
{ 0.000000, -0.955423, 0.295242 },
|
||||
{ 0.238856, -0.864188, 0.442863 },
|
||||
{ 0.262866, -0.951056, 0.162460 },
|
||||
{ 0.500000, -0.809017, 0.309017 },
|
||||
{ 0.716567, -0.681718, 0.147621 },
|
||||
{ 0.525731, -0.850651, 0.000000 },
|
||||
{ -0.238856, -0.864188, -0.442863 },
|
||||
{ -0.500000, -0.809017, -0.309017 },
|
||||
{ -0.262866, -0.951056, -0.162460 },
|
||||
{ -0.850651, -0.525731, 0.000000 },
|
||||
{ -0.716567, -0.681718, -0.147621 },
|
||||
{ -0.716567, -0.681718, 0.147621 },
|
||||
{ -0.525731, -0.850651, 0.000000 },
|
||||
{ -0.500000, -0.809017, 0.309017 },
|
||||
{ -0.238856, -0.864188, 0.442863 },
|
||||
{ -0.262866, -0.951056, 0.162460 },
|
||||
{ -0.864188, -0.442863, 0.238856 },
|
||||
{ -0.809017, -0.309017, 0.500000 },
|
||||
{ -0.688191, -0.587785, 0.425325 },
|
||||
{ -0.681718, -0.147621, 0.716567 },
|
||||
{ -0.442863, -0.238856, 0.864188 },
|
||||
{ -0.587785, -0.425325, 0.688191 },
|
||||
{ -0.309017, -0.500000, 0.809017 },
|
||||
{ -0.147621, -0.716567, 0.681718 },
|
||||
{ -0.425325, -0.688191, 0.587785 },
|
||||
{ -0.162460, -0.262866, 0.951056 },
|
||||
{ 0.442863, -0.238856, 0.864188 },
|
||||
{ 0.162460, -0.262866, 0.951056 },
|
||||
{ 0.309017, -0.500000, 0.809017 },
|
||||
{ 0.147621, -0.716567, 0.681718 },
|
||||
{ 0.000000, -0.525731, 0.850651 },
|
||||
{ 0.425325, -0.688191, 0.587785 },
|
||||
{ 0.587785, -0.425325, 0.688191 },
|
||||
{ 0.688191, -0.587785, 0.425325 },
|
||||
{ -0.955423, 0.295242, 0.000000 },
|
||||
{ -0.951056, 0.162460, 0.262866 },
|
||||
{ -1.000000, 0.000000, 0.000000 },
|
||||
{ -0.850651, 0.000000, 0.525731 },
|
||||
{ -0.955423, -0.295242, 0.000000 },
|
||||
{ -0.951056, -0.162460, 0.262866 },
|
||||
{ -0.864188, 0.442863, -0.238856 },
|
||||
{ -0.951056, 0.162460, -0.262866 },
|
||||
{ -0.809017, 0.309017, -0.500000 },
|
||||
{ -0.864188, -0.442863, -0.238856 },
|
||||
{ -0.951056, -0.162460, -0.262866 },
|
||||
{ -0.809017, -0.309017, -0.500000 },
|
||||
{ -0.681718, 0.147621, -0.716567 },
|
||||
{ -0.681718, -0.147621, -0.716567 },
|
||||
{ -0.850651, 0.000000, -0.525731 },
|
||||
{ -0.688191, 0.587785, -0.425325 },
|
||||
{ -0.587785, 0.425325, -0.688191 },
|
||||
{ -0.425325, 0.688191, -0.587785 },
|
||||
{ -0.425325, -0.688191, -0.587785 },
|
||||
{ -0.587785, -0.425325, -0.688191 },
|
||||
{ -0.688191, -0.587785, -0.425325 },
|
||||
{ -0.525731, 0.000000, 0.850651 },
|
||||
{ -0.442863, 0.238856, 0.864188 },
|
||||
{ -0.295242, 0.000000, 0.955423 },
|
||||
{ -0.309017, 0.500000, 0.809017 },
|
||||
{ -0.162460, 0.262866, 0.951056 },
|
||||
{ 0.000000, 0.000000, 1.000000 },
|
||||
{ 0.000000, 0.850651, 0.525731 },
|
||||
{ -0.147621, 0.716567, 0.681718 },
|
||||
{ 0.147621, 0.716567, 0.681718 },
|
||||
{ 0.000000, 0.525731, 0.850651 },
|
||||
{ 0.309017, 0.500000, 0.809017 },
|
||||
{ 0.525731, 0.000000, 0.850651 },
|
||||
{ 0.295242, 0.000000, 0.955423 },
|
||||
{ 0.442863, 0.238856, 0.864188 },
|
||||
{ 0.162460, 0.262866, 0.951056 },
|
||||
{ -0.681718, 0.147621, 0.716567 },
|
||||
{ -0.809017, 0.309017, 0.500000 },
|
||||
{ -0.587785, 0.425325, 0.688191 },
|
||||
{ -0.850651, 0.525731, 0.000000 },
|
||||
{ -0.864188, 0.442863, 0.238856 },
|
||||
{ -0.716567, 0.681718, 0.147621 },
|
||||
{ -0.688191, 0.587785, 0.425325 },
|
||||
{ -0.500000, 0.809017, 0.309017 },
|
||||
{ -0.238856, 0.864188, 0.442863 },
|
||||
{ -0.425325, 0.688191, 0.587785 },
|
||||
{ -0.716567, 0.681718, -0.147621 },
|
||||
{ -0.500000, 0.809017, -0.309017 },
|
||||
{ -0.525731, 0.850651, 0.000000 },
|
||||
{ 0.000000, 0.850651, -0.525731 },
|
||||
{ -0.238856, 0.864188, -0.442863 },
|
||||
{ 0.000000, 0.955423, -0.295242 },
|
||||
{ -0.262866, 0.951056, -0.162460 },
|
||||
{ 0.000000, 1.000000, 0.000000 },
|
||||
{ 0.000000, 0.955423, 0.295242 },
|
||||
{ -0.262866, 0.951056, 0.162460 },
|
||||
{ 0.238856, 0.864188, 0.442863 },
|
||||
{ 0.262866, 0.951056, 0.162460 },
|
||||
{ 0.500000, 0.809017, 0.309017 },
|
||||
{ 0.238856, 0.864188, -0.442863 },
|
||||
{ 0.262866, 0.951056, -0.162460 },
|
||||
{ 0.500000, 0.809017, -0.309017 },
|
||||
{ 0.850651, 0.525731, 0.000000 },
|
||||
{ 0.716567, 0.681718, 0.147621 },
|
||||
{ 0.716567, 0.681718, -0.147621 },
|
||||
{ 0.525731, 0.850651, 0.000000 },
|
||||
{ 0.425325, 0.688191, 0.587785 },
|
||||
{ 0.864188, 0.442863, 0.238856 },
|
||||
{ 0.688191, 0.587785, 0.425325 },
|
||||
{ 0.809017, 0.309017, 0.500000 },
|
||||
{ 0.681718, 0.147621, 0.716567 },
|
||||
{ 0.587785, 0.425325, 0.688191 },
|
||||
{ 0.955423, 0.295242, 0.000000 },
|
||||
{ 1.000000, 0.000000, 0.000000 },
|
||||
{ 0.951056, 0.162460, 0.262866 },
|
||||
{ 0.850651, -0.525731, 0.000000 },
|
||||
{ 0.955423, -0.295242, 0.000000 },
|
||||
{ 0.864188, -0.442863, 0.238856 },
|
||||
{ 0.951056, -0.162460, 0.262866 },
|
||||
{ 0.809017, -0.309017, 0.500000 },
|
||||
{ 0.681718, -0.147621, 0.716567 },
|
||||
{ 0.850651, 0.000000, 0.525731 },
|
||||
{ 0.864188, 0.442863, -0.238856 },
|
||||
{ 0.809017, 0.309017, -0.500000 },
|
||||
{ 0.951056, 0.162460, -0.262866 },
|
||||
{ 0.525731, 0.000000, -0.850651 },
|
||||
{ 0.681718, 0.147621, -0.716567 },
|
||||
{ 0.681718, -0.147621, -0.716567 },
|
||||
{ 0.850651, 0.000000, -0.525731 },
|
||||
{ 0.809017, -0.309017, -0.500000 },
|
||||
{ 0.864188, -0.442863, -0.238856 },
|
||||
{ 0.951056, -0.162460, -0.262866 },
|
||||
{ 0.147621, 0.716567, -0.681718 },
|
||||
{ 0.309017, 0.500000, -0.809017 },
|
||||
{ 0.425325, 0.688191, -0.587785 },
|
||||
{ 0.442863, 0.238856, -0.864188 },
|
||||
{ 0.587785, 0.425325, -0.688191 },
|
||||
{ 0.688191, 0.587785, -0.425325 },
|
||||
{ -0.147621, 0.716567, -0.681718 },
|
||||
{ -0.309017, 0.500000, -0.809017 },
|
||||
{ 0.000000, 0.525731, -0.850651 },
|
||||
{ -0.525731, 0.000000, -0.850651 },
|
||||
{ -0.442863, 0.238856, -0.864188 },
|
||||
{ -0.295242, 0.000000, -0.955423 },
|
||||
{ -0.162460, 0.262866, -0.951056 },
|
||||
{ 0.000000, 0.000000, -1.000000 },
|
||||
{ 0.295242, 0.000000, -0.955423 },
|
||||
{ 0.162460, 0.262866, -0.951056 },
|
||||
{ -0.442863, -0.238856, -0.864188 },
|
||||
{ -0.309017, -0.500000, -0.809017 },
|
||||
{ -0.162460, -0.262866, -0.951056 },
|
||||
{ 0.000000, -0.850651, -0.525731 },
|
||||
{ -0.147621, -0.716567, -0.681718 },
|
||||
{ 0.147621, -0.716567, -0.681718 },
|
||||
{ 0.000000, -0.525731, -0.850651 },
|
||||
{ 0.309017, -0.500000, -0.809017 },
|
||||
{ 0.442863, -0.238856, -0.864188 },
|
||||
{ 0.162460, -0.262866, -0.951056 },
|
||||
{ 0.238856, -0.864188, -0.442863 },
|
||||
{ 0.500000, -0.809017, -0.309017 },
|
||||
{ 0.425325, -0.688191, -0.587785 },
|
||||
{ 0.716567, -0.681718, -0.147621 },
|
||||
{ 0.688191, -0.587785, -0.425325 },
|
||||
{ 0.587785, -0.425325, -0.688191 },
|
||||
{ 0.000000, -0.955423, -0.295242 },
|
||||
{ 0.000000, -1.000000, 0.000000 },
|
||||
{ 0.262866, -0.951056, -0.162460 },
|
||||
{ 0.000000, -0.850651, 0.525731 },
|
||||
{ 0.000000, -0.955423, 0.295242 },
|
||||
{ 0.238856, -0.864188, 0.442863 },
|
||||
{ 0.262866, -0.951056, 0.162460 },
|
||||
{ 0.500000, -0.809017, 0.309017 },
|
||||
{ 0.716567, -0.681718, 0.147621 },
|
||||
{ 0.525731, -0.850651, 0.000000 },
|
||||
{ -0.238856, -0.864188, -0.442863 },
|
||||
{ -0.500000, -0.809017, -0.309017 },
|
||||
{ -0.262866, -0.951056, -0.162460 },
|
||||
{ -0.850651, -0.525731, 0.000000 },
|
||||
{ -0.716567, -0.681718, -0.147621 },
|
||||
{ -0.716567, -0.681718, 0.147621 },
|
||||
{ -0.525731, -0.850651, 0.000000 },
|
||||
{ -0.500000, -0.809017, 0.309017 },
|
||||
{ -0.238856, -0.864188, 0.442863 },
|
||||
{ -0.262866, -0.951056, 0.162460 },
|
||||
{ -0.864188, -0.442863, 0.238856 },
|
||||
{ -0.809017, -0.309017, 0.500000 },
|
||||
{ -0.688191, -0.587785, 0.425325 },
|
||||
{ -0.681718, -0.147621, 0.716567 },
|
||||
{ -0.442863, -0.238856, 0.864188 },
|
||||
{ -0.587785, -0.425325, 0.688191 },
|
||||
{ -0.309017, -0.500000, 0.809017 },
|
||||
{ -0.147621, -0.716567, 0.681718 },
|
||||
{ -0.425325, -0.688191, 0.587785 },
|
||||
{ -0.162460, -0.262866, 0.951056 },
|
||||
{ 0.442863, -0.238856, 0.864188 },
|
||||
{ 0.162460, -0.262866, 0.951056 },
|
||||
{ 0.309017, -0.500000, 0.809017 },
|
||||
{ 0.147621, -0.716567, 0.681718 },
|
||||
{ 0.000000, -0.525731, 0.850651 },
|
||||
{ 0.425325, -0.688191, 0.587785 },
|
||||
{ 0.587785, -0.425325, 0.688191 },
|
||||
{ 0.688191, -0.587785, 0.425325 },
|
||||
{ -0.955423, 0.295242, 0.000000 },
|
||||
{ -0.951056, 0.162460, 0.262866 },
|
||||
{ -1.000000, 0.000000, 0.000000 },
|
||||
{ -0.850651, 0.000000, 0.525731 },
|
||||
{ -0.955423, -0.295242, 0.000000 },
|
||||
{ -0.951056, -0.162460, 0.262866 },
|
||||
{ -0.864188, 0.442863, -0.238856 },
|
||||
{ -0.951056, 0.162460, -0.262866 },
|
||||
{ -0.809017, 0.309017, -0.500000 },
|
||||
{ -0.864188, -0.442863, -0.238856 },
|
||||
{ -0.951056, -0.162460, -0.262866 },
|
||||
{ -0.809017, -0.309017, -0.500000 },
|
||||
{ -0.681718, 0.147621, -0.716567 },
|
||||
{ -0.681718, -0.147621, -0.716567 },
|
||||
{ -0.850651, 0.000000, -0.525731 },
|
||||
{ -0.688191, 0.587785, -0.425325 },
|
||||
{ -0.587785, 0.425325, -0.688191 },
|
||||
{ -0.425325, 0.688191, -0.587785 },
|
||||
{ -0.425325, -0.688191, -0.587785 },
|
||||
{ -0.587785, -0.425325, -0.688191 },
|
||||
{ -0.688191, -0.587785, -0.425325 },
|
||||
|
|
176
source/bgmusic.c
176
source/bgmusic.c
|
@ -32,7 +32,7 @@
|
|||
bool bgmloop;
|
||||
cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE};
|
||||
|
||||
static bool no_extmusic= false;
|
||||
static bool no_extmusic = false;
|
||||
static float old_volume = -1.0f;
|
||||
|
||||
typedef enum _bgm_player
|
||||
|
@ -54,7 +54,7 @@ typedef struct music_handler_s
|
|||
|
||||
static music_handler_t wanted_handlers[] =
|
||||
{
|
||||
{ CODECTYPE_VORBIS,BGM_STREAMER,-1, "ogg", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_VORBIS, BGM_STREAMER, -1, "ogg", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_OPUS, BGM_STREAMER, -1, "opus", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_MP3, BGM_STREAMER, -1, "mp3", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_FLAC, BGM_STREAMER, -1, "flac", MUSIC_DIRNAME, NULL },
|
||||
|
@ -75,55 +75,55 @@ static music_handler_t *music_handlers = NULL;
|
|||
|
||||
static snd_stream_t *bgmstream = NULL;
|
||||
|
||||
static void BGM_Play_f (void)
|
||||
static void BGM_Play_f(void)
|
||||
{
|
||||
if (Cmd_Argc() == 2)
|
||||
if(Cmd_Argc() == 2)
|
||||
{
|
||||
BGM_Play (Cmd_Argv(1));
|
||||
BGM_Play(Cmd_Argv(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf ("music <musicfile>\n");
|
||||
Con_Printf("music <musicfile>\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void BGM_Pause_f (void)
|
||||
static void BGM_Pause_f(void)
|
||||
{
|
||||
BGM_Pause ();
|
||||
BGM_Pause();
|
||||
}
|
||||
|
||||
static void BGM_Resume_f (void)
|
||||
static void BGM_Resume_f(void)
|
||||
{
|
||||
BGM_Resume ();
|
||||
BGM_Resume();
|
||||
}
|
||||
|
||||
static void BGM_Loop_f (void)
|
||||
static void BGM_Loop_f(void)
|
||||
{
|
||||
if (Cmd_Argc() == 2)
|
||||
if(Cmd_Argc() == 2)
|
||||
{
|
||||
if (q_strcasecmp(Cmd_Argv(1), "0") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1),"off") == 0)
|
||||
if(q_strcasecmp(Cmd_Argv(1), "0") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1), "off") == 0)
|
||||
bgmloop = false;
|
||||
else if (q_strcasecmp(Cmd_Argv(1), "1") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1),"on") == 0)
|
||||
else if(q_strcasecmp(Cmd_Argv(1), "1") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1), "on") == 0)
|
||||
bgmloop = true;
|
||||
else if (q_strcasecmp(Cmd_Argv(1),"toggle") == 0)
|
||||
else if(q_strcasecmp(Cmd_Argv(1), "toggle") == 0)
|
||||
bgmloop = !bgmloop;
|
||||
}
|
||||
|
||||
if (bgmloop)
|
||||
if(bgmloop)
|
||||
Con_Printf("Music will be looped\n");
|
||||
else
|
||||
Con_Printf("Music will not be looped\n");
|
||||
}
|
||||
|
||||
static void BGM_Stop_f (void)
|
||||
static void BGM_Stop_f(void)
|
||||
{
|
||||
BGM_Stop();
|
||||
}
|
||||
|
||||
bool BGM_Init (void)
|
||||
bool BGM_Init(void)
|
||||
{
|
||||
music_handler_t *handlers = NULL;
|
||||
int32_t i;
|
||||
|
@ -135,14 +135,14 @@ bool BGM_Init (void)
|
|||
Cmd_AddCommand("music_loop", BGM_Loop_f);
|
||||
Cmd_AddCommand("music_stop", BGM_Stop_f);
|
||||
|
||||
if (COM_CheckParm("-noextmusic") != 0)
|
||||
if(COM_CheckParm("-noextmusic") != 0)
|
||||
no_extmusic = true;
|
||||
|
||||
bgmloop = true;
|
||||
|
||||
for (i = 0; wanted_handlers[i].type != CODECTYPE_NONE; i++)
|
||||
for(i = 0; wanted_handlers[i].type != CODECTYPE_NONE; i++)
|
||||
{
|
||||
switch (wanted_handlers[i].player)
|
||||
switch(wanted_handlers[i].player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
|
@ -155,9 +155,9 @@ bool BGM_Init (void)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (wanted_handlers[i].is_available != -1)
|
||||
if(wanted_handlers[i].is_available != -1)
|
||||
{
|
||||
if (handlers)
|
||||
if(handlers)
|
||||
{
|
||||
handlers->next = &wanted_handlers[i];
|
||||
handlers = handlers->next;
|
||||
|
@ -170,46 +170,46 @@ bool BGM_Init (void)
|
|||
}
|
||||
}
|
||||
|
||||
return CDAudio_Init ();
|
||||
return CDAudio_Init();
|
||||
}
|
||||
|
||||
void BGM_Shutdown (void)
|
||||
void BGM_Shutdown(void)
|
||||
{
|
||||
BGM_Stop();
|
||||
/* sever our connections to
|
||||
/* sever our connections to
|
||||
* midi_drv and snd_codec */
|
||||
music_handlers = NULL;
|
||||
CDAudio_Shutdown ();
|
||||
CDAudio_Shutdown();
|
||||
}
|
||||
|
||||
static void BGM_Play_noext (const char *filename, uint32_t allowed_types)
|
||||
static void BGM_Play_noext(const char *filename, uint32_t allowed_types)
|
||||
{
|
||||
char tmp[MAX_QPATH];
|
||||
music_handler_t *handler;
|
||||
|
||||
handler = music_handlers;
|
||||
while (handler)
|
||||
while(handler)
|
||||
{
|
||||
if (! (handler->type & allowed_types))
|
||||
if(!(handler->type & allowed_types))
|
||||
{
|
||||
handler = handler->next;
|
||||
continue;
|
||||
}
|
||||
if (!handler->is_available)
|
||||
if(!handler->is_available)
|
||||
{
|
||||
handler = handler->next;
|
||||
continue;
|
||||
}
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/%s.%s",
|
||||
handler->dir, filename, handler->ext);
|
||||
switch (handler->player)
|
||||
switch(handler->player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
if (bgmstream)
|
||||
if(bgmstream)
|
||||
return; /* success */
|
||||
break;
|
||||
case BGM_NONE:
|
||||
|
@ -222,7 +222,7 @@ static void BGM_Play_noext (const char *filename, uint32_t allowed_types)
|
|||
Con_Printf("Couldn't handle music file %s\n", filename);
|
||||
}
|
||||
|
||||
void BGM_Play (const char *filename)
|
||||
void BGM_Play(const char *filename)
|
||||
{
|
||||
char tmp[MAX_QPATH];
|
||||
const char *ext;
|
||||
|
@ -230,44 +230,44 @@ void BGM_Play (const char *filename)
|
|||
|
||||
BGM_Stop();
|
||||
|
||||
if (music_handlers == NULL)
|
||||
if(music_handlers == NULL)
|
||||
return;
|
||||
|
||||
if (!filename || !*filename)
|
||||
if(!filename || !*filename)
|
||||
{
|
||||
Con_DPrintf("null music file name\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext) /* try all things */
|
||||
if(! *ext) /* try all things */
|
||||
{
|
||||
BGM_Play_noext(filename, ANY_CODECTYPE);
|
||||
return;
|
||||
}
|
||||
|
||||
handler = music_handlers;
|
||||
while (handler)
|
||||
while(handler)
|
||||
{
|
||||
if (handler->is_available &&
|
||||
if(handler->is_available &&
|
||||
!q_strcasecmp(ext, handler->ext))
|
||||
break;
|
||||
handler = handler->next;
|
||||
}
|
||||
if (!handler)
|
||||
if(!handler)
|
||||
{
|
||||
Con_Printf("Unhandled extension for %s\n", filename);
|
||||
return;
|
||||
}
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/%s", handler->dir, filename);
|
||||
switch (handler->player)
|
||||
switch(handler->player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
if (bgmstream)
|
||||
if(bgmstream)
|
||||
return; /* success */
|
||||
break;
|
||||
case BGM_NONE:
|
||||
|
@ -278,9 +278,9 @@ void BGM_Play (const char *filename)
|
|||
Con_Printf("Couldn't handle music file %s\n", filename);
|
||||
}
|
||||
|
||||
void BGM_PlayCDtrack (byte track, bool looping)
|
||||
void BGM_PlayCDtrack(byte track, bool looping)
|
||||
{
|
||||
/* instead of searching by the order of music_handlers, do so by
|
||||
/* instead of searching by the order of music_handlers, do so by
|
||||
* the order of searchpath priority: the file from the searchpath
|
||||
* with the highest path_id is most likely from our own gamedir
|
||||
* itself. This way, if a mod has track02 as a *.mp3 file, which
|
||||
|
@ -293,53 +293,53 @@ void BGM_PlayCDtrack (byte track, bool looping)
|
|||
music_handler_t *handler;
|
||||
|
||||
BGM_Stop();
|
||||
if (CDAudio_Play(track, looping) == 0)
|
||||
if(CDAudio_Play(track, looping) == 0)
|
||||
return; /* success */
|
||||
|
||||
if (music_handlers == NULL)
|
||||
if(music_handlers == NULL)
|
||||
return;
|
||||
|
||||
if (no_extmusic || !bgm_extmusic.value)
|
||||
if(no_extmusic || !bgm_extmusic.value)
|
||||
return;
|
||||
|
||||
prev_id = 0;
|
||||
type = 0;
|
||||
ext = NULL;
|
||||
handler = music_handlers;
|
||||
while (handler)
|
||||
while(handler)
|
||||
{
|
||||
if (! handler->is_available)
|
||||
if(! handler->is_available)
|
||||
goto _next;
|
||||
if (! CDRIPTYPE(handler->type))
|
||||
if(! CDRIPTYPE(handler->type))
|
||||
goto _next;
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02" PRIi32 ".%s",
|
||||
MUSIC_DIRNAME, (int32_t)track, handler->ext);
|
||||
if (! COM_FileExists(tmp, &path_id))
|
||||
if(! COM_FileExists(tmp, &path_id))
|
||||
goto _next;
|
||||
if (path_id > prev_id)
|
||||
if(path_id > prev_id)
|
||||
{
|
||||
prev_id = path_id;
|
||||
type = handler->type;
|
||||
ext = handler->ext;
|
||||
}
|
||||
_next:
|
||||
_next:
|
||||
handler = handler->next;
|
||||
}
|
||||
if (ext == NULL)
|
||||
if(ext == NULL)
|
||||
Con_Printf("Couldn't find a cdrip for track %" PRIi32 "\n", (int32_t)track);
|
||||
else
|
||||
{
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02" PRIi32 ".%s",
|
||||
MUSIC_DIRNAME, (int32_t)track, ext);
|
||||
bgmstream = S_CodecOpenStreamType(tmp, type);
|
||||
if (! bgmstream)
|
||||
if(! bgmstream)
|
||||
Con_Printf("Couldn't handle music file %s\n", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void BGM_Stop (void)
|
||||
void BGM_Stop(void)
|
||||
{
|
||||
if (bgmstream)
|
||||
if(bgmstream)
|
||||
{
|
||||
bgmstream->status = STREAM_NONE;
|
||||
S_CodecCloseStream(bgmstream);
|
||||
|
@ -349,27 +349,27 @@ void BGM_Stop (void)
|
|||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
void BGM_Pause (void)
|
||||
void BGM_Pause(void)
|
||||
{
|
||||
if (bgmstream)
|
||||
if(bgmstream)
|
||||
{
|
||||
if (bgmstream->status == STREAM_PLAY)
|
||||
if(bgmstream->status == STREAM_PLAY)
|
||||
bgmstream->status = STREAM_PAUSE;
|
||||
}
|
||||
CDAudio_Pause ();
|
||||
CDAudio_Pause();
|
||||
}
|
||||
|
||||
void BGM_Resume (void)
|
||||
void BGM_Resume(void)
|
||||
{
|
||||
if (bgmstream)
|
||||
if(bgmstream)
|
||||
{
|
||||
if (bgmstream->status == STREAM_PAUSE)
|
||||
if(bgmstream->status == STREAM_PAUSE)
|
||||
bgmstream->status = STREAM_PLAY;
|
||||
}
|
||||
CDAudio_Resume ();
|
||||
CDAudio_Resume();
|
||||
}
|
||||
|
||||
static void BGM_UpdateStream (void)
|
||||
static void BGM_UpdateStream(void)
|
||||
{
|
||||
bool did_rewind = false;
|
||||
int32_t res; /* Number of bytes read. */
|
||||
|
@ -378,29 +378,29 @@ static void BGM_UpdateStream (void)
|
|||
int32_t fileBytes;
|
||||
byte raw[16384];
|
||||
|
||||
if (bgmstream->status != STREAM_PLAY)
|
||||
if(bgmstream->status != STREAM_PLAY)
|
||||
return;
|
||||
|
||||
/* don't bother playing anything if musicvolume is 0 */
|
||||
if (bgmvolume.value <= 0)
|
||||
if(bgmvolume.value <= 0)
|
||||
return;
|
||||
|
||||
/* see how many samples should be copied into the raw buffer */
|
||||
if (s_rawend < paintedtime)
|
||||
if(s_rawend < paintedtime)
|
||||
s_rawend = paintedtime;
|
||||
|
||||
while (s_rawend < paintedtime + MAX_RAW_SAMPLES)
|
||||
while(s_rawend < paintedtime + MAX_RAW_SAMPLES)
|
||||
{
|
||||
bufferSamples = MAX_RAW_SAMPLES - (s_rawend - paintedtime);
|
||||
|
||||
/* decide how much data needs to be read from the file */
|
||||
fileSamples = bufferSamples * bgmstream->info.rate / shm->speed;
|
||||
if (!fileSamples)
|
||||
if(!fileSamples)
|
||||
return;
|
||||
|
||||
/* our max buffer size */
|
||||
fileBytes = fileSamples * (bgmstream->info.width * bgmstream->info.channels);
|
||||
if (fileBytes > (int32_t) sizeof(raw))
|
||||
if(fileBytes > (int32_t) sizeof(raw))
|
||||
{
|
||||
fileBytes = (int32_t) sizeof(raw);
|
||||
fileSamples = fileBytes /
|
||||
|
@ -409,13 +409,13 @@ static void BGM_UpdateStream (void)
|
|||
|
||||
/* Read */
|
||||
res = S_CodecReadStream(bgmstream, fileBytes, raw);
|
||||
if (res < fileBytes)
|
||||
if(res < fileBytes)
|
||||
{
|
||||
fileBytes = res;
|
||||
fileSamples = res / (bgmstream->info.width * bgmstream->info.channels);
|
||||
}
|
||||
|
||||
if (res > 0) /* data: add to raw buffer */
|
||||
if(res > 0) /* data: add to raw buffer */
|
||||
{
|
||||
S_RawSamples(fileSamples, bgmstream->info.rate,
|
||||
bgmstream->info.width,
|
||||
|
@ -423,11 +423,11 @@ static void BGM_UpdateStream (void)
|
|||
raw, bgmvolume.value);
|
||||
did_rewind = false;
|
||||
}
|
||||
else if (res == 0) /* EOF */
|
||||
else if(res == 0) /* EOF */
|
||||
{
|
||||
if (bgmloop)
|
||||
if(bgmloop)
|
||||
{
|
||||
if (did_rewind)
|
||||
if(did_rewind)
|
||||
{
|
||||
Con_Printf("Stream keeps returning EOF.\n");
|
||||
BGM_Stop();
|
||||
|
@ -435,7 +435,7 @@ static void BGM_UpdateStream (void)
|
|||
}
|
||||
|
||||
res = S_CodecRewindStream(bgmstream);
|
||||
if (res != 0)
|
||||
if(res != 0)
|
||||
{
|
||||
Con_Printf("Stream seek error (%" PRIi32 "), stopping.\n", res);
|
||||
BGM_Stop();
|
||||
|
@ -458,18 +458,18 @@ static void BGM_UpdateStream (void)
|
|||
}
|
||||
}
|
||||
|
||||
void BGM_Update (void)
|
||||
void BGM_Update(void)
|
||||
{
|
||||
if (old_volume != bgmvolume.value)
|
||||
if(old_volume != bgmvolume.value)
|
||||
{
|
||||
if (bgmvolume.value < 0)
|
||||
Cvar_SetQuick (&bgmvolume, "0");
|
||||
else if (bgmvolume.value > 1)
|
||||
Cvar_SetQuick (&bgmvolume, "1");
|
||||
if(bgmvolume.value < 0)
|
||||
Cvar_SetQuick(&bgmvolume, "0");
|
||||
else if(bgmvolume.value > 1)
|
||||
Cvar_SetQuick(&bgmvolume, "1");
|
||||
old_volume = bgmvolume.value;
|
||||
}
|
||||
if (bgmstream)
|
||||
BGM_UpdateStream ();
|
||||
if(bgmstream)
|
||||
BGM_UpdateStream();
|
||||
|
||||
CDAudio_Update();
|
||||
}
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
extern bool bgmloop;
|
||||
extern cvar_t bgm_extmusic;
|
||||
|
||||
bool BGM_Init (void);
|
||||
void BGM_Shutdown (void);
|
||||
bool BGM_Init(void);
|
||||
void BGM_Shutdown(void);
|
||||
|
||||
void BGM_Play (const char *filename);
|
||||
void BGM_Stop (void);
|
||||
void BGM_Update (void);
|
||||
void BGM_Pause (void);
|
||||
void BGM_Resume (void);
|
||||
void BGM_Play(const char *filename);
|
||||
void BGM_Stop(void);
|
||||
void BGM_Update(void);
|
||||
void BGM_Pause(void);
|
||||
void BGM_Resume(void);
|
||||
|
||||
void BGM_PlayCDtrack (byte track, bool looping);
|
||||
void BGM_PlayCDtrack(byte track, bool looping);
|
||||
|
||||
#endif /* _BGMUSIC_H_ */
|
||||
|
||||
|
|
266
source/cd_sdl.c
266
source/cd_sdl.c
|
@ -50,24 +50,24 @@ static bool hw_vol_works = true;
|
|||
|
||||
static void CDAudio_Eject(void)
|
||||
{
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
#ifdef __linux__
|
||||
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
|
||||
#endif
|
||||
if (SDL_CDEject(cd_handle) < 0)
|
||||
Con_Printf ("Unable to eject CD-ROM: %s\n", SDL_GetError ());
|
||||
if(SDL_CDEject(cd_handle) < 0)
|
||||
Con_Printf("Unable to eject CD-ROM: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
static int32_t CDAudio_GetAudioDiskInfo(void)
|
||||
{
|
||||
cdValid = false;
|
||||
|
||||
if (!cd_handle)
|
||||
if(!cd_handle)
|
||||
return -1;
|
||||
|
||||
if ( ! CD_INDRIVE(SDL_CDStatus(cd_handle)) )
|
||||
if(! CD_INDRIVE(SDL_CDStatus(cd_handle)))
|
||||
return -1;
|
||||
|
||||
cdValid = true;
|
||||
|
@ -79,40 +79,40 @@ int32_t CDAudio_Play(byte track, bool looping)
|
|||
{
|
||||
int32_t len_m, len_s, len_f;
|
||||
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return -1;
|
||||
|
||||
if (!cdValid)
|
||||
if(!cdValid)
|
||||
{
|
||||
CDAudio_GetAudioDiskInfo();
|
||||
if (!cdValid)
|
||||
if(!cdValid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
track = remap[track];
|
||||
|
||||
if (track < 1 || track > cd_handle->numtracks)
|
||||
if(track < 1 || track > cd_handle->numtracks)
|
||||
{
|
||||
Con_Printf ("CDAudio_Play: Bad track number %" PRIi32 ".\n", track);
|
||||
Con_Printf("CDAudio_Play: Bad track number %" PRIi32 ".\n", track);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cd_handle->track[track-1].type == SDL_DATA_TRACK)
|
||||
if(cd_handle->track[track - 1].type == SDL_DATA_TRACK)
|
||||
{
|
||||
Con_Printf ("CDAudio_Play: track %" PRIi32 " is not audio\n", track);
|
||||
Con_Printf("CDAudio_Play: track %" PRIi32 " is not audio\n", track);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (playing)
|
||||
if(playing)
|
||||
{
|
||||
if (playTrack == track)
|
||||
if(playTrack == track)
|
||||
return 0;
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
if (SDL_CDPlay(cd_handle, cd_handle->track[track-1].offset, cd_handle->track[track-1].length) < 0)
|
||||
if(SDL_CDPlay(cd_handle, cd_handle->track[track - 1].offset, cd_handle->track[track - 1].length) < 0)
|
||||
{
|
||||
Con_Printf ("CDAudio_Play: Unable to play track %" PRIi32 ": %s\n", track, SDL_GetError ());
|
||||
Con_Printf("CDAudio_Play: Unable to play track %" PRIi32 ": %s\n", track, SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ int32_t CDAudio_Play(byte track, bool looping)
|
|||
playTrack = track;
|
||||
playing = true;
|
||||
|
||||
FRAMES_TO_MSF(cd_handle->track[track-1].length, &len_m, &len_s, &len_f);
|
||||
FRAMES_TO_MSF(cd_handle->track[track - 1].length, &len_m, &len_s, &len_f);
|
||||
endOfTrack = realtime + ((double)len_m * 60.0) + (double)len_s + (double)len_f / (double)CD_FPS;
|
||||
|
||||
/* Add the pregap for the next track. This means that disc-at-once CDs
|
||||
|
@ -130,18 +130,18 @@ int32_t CDAudio_Play(byte track, bool looping)
|
|||
endOfTrack += 2.0;
|
||||
pausetime = -1.0;
|
||||
|
||||
if (bgmvolume.value == 0) /* don't bother advancing */
|
||||
CDAudio_Pause ();
|
||||
if(bgmvolume.value == 0) /* don't bother advancing */
|
||||
CDAudio_Pause();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDAudio_Stop(void)
|
||||
{
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
if (!playing)
|
||||
if(!playing)
|
||||
return;
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -151,11 +151,11 @@ void CDAudio_Stop(void)
|
|||
* firmware versions running under a 2.6.27.25 kernel, and with a
|
||||
* Samsung DVD r/w drive running under 2.6.35.6 kernel.
|
||||
* Therefore, avoid dead stops if playback may be resumed shortly. */
|
||||
if (SDL_CDPause(cd_handle) < 0)
|
||||
Con_Printf ("CDAudio_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
if(SDL_CDPause(cd_handle) < 0)
|
||||
Con_Printf("CDAudio_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
#else
|
||||
if (SDL_CDStop(cd_handle) < 0)
|
||||
Con_Printf ("CDAudio_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
if(SDL_CDStop(cd_handle) < 0)
|
||||
Con_Printf("CDAudio_Stop: Unable to stop CD-ROM (%s)\n", SDL_GetError());
|
||||
#endif
|
||||
|
||||
wasPlaying = false;
|
||||
|
@ -166,14 +166,14 @@ void CDAudio_Stop(void)
|
|||
|
||||
void CDAudio_Pause(void)
|
||||
{
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
if (!playing)
|
||||
if(!playing)
|
||||
return;
|
||||
|
||||
if (SDL_CDPause(cd_handle) < 0)
|
||||
Con_Printf ("Unable to pause CD-ROM: %s\n", SDL_GetError());
|
||||
if(SDL_CDPause(cd_handle) < 0)
|
||||
Con_Printf("Unable to pause CD-ROM: %s\n", SDL_GetError());
|
||||
|
||||
wasPlaying = playing;
|
||||
playing = false;
|
||||
|
@ -182,37 +182,37 @@ void CDAudio_Pause(void)
|
|||
|
||||
void CDAudio_Resume(void)
|
||||
{
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
if (!cdValid)
|
||||
if(!cdValid)
|
||||
return;
|
||||
|
||||
if (!wasPlaying)
|
||||
if(!wasPlaying)
|
||||
return;
|
||||
|
||||
if (SDL_CDResume(cd_handle) < 0)
|
||||
Con_Printf ("Unable to resume CD-ROM: %s\n", SDL_GetError());
|
||||
if(SDL_CDResume(cd_handle) < 0)
|
||||
Con_Printf("Unable to resume CD-ROM: %s\n", SDL_GetError());
|
||||
playing = true;
|
||||
endOfTrack += realtime - pausetime;
|
||||
pausetime = -1.0;
|
||||
}
|
||||
|
||||
static int32_t get_first_audiotrk (void)
|
||||
static int32_t get_first_audiotrk(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i = 0; i < cd_handle->numtracks; ++i)
|
||||
if (cd_handle->track[i].type != SDL_DATA_TRACK)
|
||||
for(i = 0; i < cd_handle->numtracks; ++i)
|
||||
if(cd_handle->track[i].type != SDL_DATA_TRACK)
|
||||
return ++i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void CD_f (void)
|
||||
static void CD_f(void)
|
||||
{
|
||||
const char *command;
|
||||
int32_t ret, n;
|
||||
|
||||
if (Cmd_Argc() < 2)
|
||||
if(Cmd_Argc() < 2)
|
||||
{
|
||||
Con_Printf("commands:");
|
||||
Con_Printf("on, off, reset, remap, \n");
|
||||
|
@ -221,119 +221,119 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
command = Cmd_Argv (1);
|
||||
command = Cmd_Argv(1);
|
||||
|
||||
if (q_strcasecmp(command, "on") == 0)
|
||||
if(q_strcasecmp(command, "on") == 0)
|
||||
{
|
||||
enabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "off") == 0)
|
||||
if(q_strcasecmp(command, "off") == 0)
|
||||
{
|
||||
if (playing)
|
||||
if(playing)
|
||||
CDAudio_Stop();
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "reset") == 0)
|
||||
if(q_strcasecmp(command, "reset") == 0)
|
||||
{
|
||||
enabled = true;
|
||||
if (playing)
|
||||
if(playing)
|
||||
CDAudio_Stop();
|
||||
for (n = 0; n < 100; n++)
|
||||
for(n = 0; n < 100; n++)
|
||||
remap[n] = n;
|
||||
CDAudio_GetAudioDiskInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "remap") == 0)
|
||||
if(q_strcasecmp(command, "remap") == 0)
|
||||
{
|
||||
ret = Cmd_Argc() - 2;
|
||||
if (ret <= 0)
|
||||
if(ret <= 0)
|
||||
{
|
||||
for (n = 1; n < 100; n++)
|
||||
if (remap[n] != n)
|
||||
for(n = 1; n < 100; n++)
|
||||
if(remap[n] != n)
|
||||
Con_Printf(" %" PRIu32 " -> %" PRIu32 "\n", n, remap[n]);
|
||||
return;
|
||||
}
|
||||
for (n = 1; n <= ret; n++)
|
||||
remap[n] = atoi(Cmd_Argv (n + 1));
|
||||
for(n = 1; n <= ret; n++)
|
||||
remap[n] = atoi(Cmd_Argv(n + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cdValid)
|
||||
if(!cdValid)
|
||||
{
|
||||
CDAudio_GetAudioDiskInfo();
|
||||
if (!cdValid)
|
||||
if(!cdValid)
|
||||
{
|
||||
Con_Printf("No CD in player.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "play") == 0)
|
||||
if(q_strcasecmp(command, "play") == 0)
|
||||
{
|
||||
n = atoi(Cmd_Argv (2));
|
||||
if (n == 0)
|
||||
n = atoi(Cmd_Argv(2));
|
||||
if(n == 0)
|
||||
n = 1;
|
||||
CDAudio_Play((byte)n, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "loop") == 0)
|
||||
if(q_strcasecmp(command, "loop") == 0)
|
||||
{
|
||||
CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
|
||||
CDAudio_Play((byte)atoi(Cmd_Argv(2)), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "stop") == 0)
|
||||
if(q_strcasecmp(command, "stop") == 0)
|
||||
{
|
||||
CDAudio_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "pause") == 0)
|
||||
if(q_strcasecmp(command, "pause") == 0)
|
||||
{
|
||||
CDAudio_Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "resume") == 0)
|
||||
if(q_strcasecmp(command, "resume") == 0)
|
||||
{
|
||||
CDAudio_Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "eject") == 0)
|
||||
if(q_strcasecmp(command, "eject") == 0)
|
||||
{
|
||||
if (playing)
|
||||
if(playing)
|
||||
CDAudio_Stop();
|
||||
CDAudio_Eject();
|
||||
cdValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "info") == 0)
|
||||
if(q_strcasecmp(command, "info") == 0)
|
||||
{
|
||||
int32_t current_min, current_sec, current_frame;
|
||||
int32_t length_min, length_sec, length_frame;
|
||||
|
||||
Con_Printf ("%" PRIu32 " tracks\n", cd_handle->numtracks);
|
||||
Con_Printf("%" PRIu32 " tracks\n", cd_handle->numtracks);
|
||||
|
||||
if (playing)
|
||||
if(playing)
|
||||
Con_Printf("Currently %s track %" PRIu32 "\n", playLooping ? "looping" : "playing", playTrack);
|
||||
else if (wasPlaying)
|
||||
else if(wasPlaying)
|
||||
Con_Printf("Paused %s track %" PRIu32 "\n", playLooping ? "looping" : "playing", playTrack);
|
||||
|
||||
if (playing || wasPlaying)
|
||||
if(playing || wasPlaying)
|
||||
{
|
||||
SDL_CDStatus(cd_handle);
|
||||
FRAMES_TO_MSF(cd_handle->cur_frame, ¤t_min, ¤t_sec, ¤t_frame);
|
||||
FRAMES_TO_MSF(cd_handle->track[playTrack-1].length, &length_min, &length_sec, &length_frame);
|
||||
FRAMES_TO_MSF(cd_handle->track[playTrack - 1].length, &length_min, &length_sec, &length_frame);
|
||||
|
||||
Con_Printf ("Current position: %" PRIi32 ":%02" PRIi32 ".%02" PRIi32 " (of %" PRIi32 ":%02" PRIi32 ".%02" PRIi32 ")\n",
|
||||
Con_Printf("Current position: %" PRIi32 ":%02" PRIi32 ".%02" PRIi32 " (of %" PRIi32 ":%02" PRIi32 ".%02" PRIi32 ")\n",
|
||||
current_min, current_sec, current_frame * 60 / CD_FPS,
|
||||
length_min, length_sec, length_frame * 60 / CD_FPS);
|
||||
}
|
||||
|
@ -342,111 +342,111 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "next") == 0)
|
||||
if(q_strcasecmp(command, "next") == 0)
|
||||
{
|
||||
if (playTrack == cd_handle->numtracks)
|
||||
if(playTrack == cd_handle->numtracks)
|
||||
playTrack = get_first_audiotrk() - 1;
|
||||
CDAudio_Play(playTrack + 1, playLooping);
|
||||
return;
|
||||
}
|
||||
|
||||
if (q_strcasecmp(command, "prev") == 0)
|
||||
if(q_strcasecmp(command, "prev") == 0)
|
||||
{
|
||||
if (playTrack == get_first_audiotrk())
|
||||
if(playTrack == get_first_audiotrk())
|
||||
playTrack = cd_handle->numtracks + 1;
|
||||
CDAudio_Play(playTrack - 1, playLooping);
|
||||
return;
|
||||
}
|
||||
|
||||
Con_Printf ("cd: unknown command \"%s\"\n", command);
|
||||
Con_Printf("cd: unknown command \"%s\"\n", command);
|
||||
}
|
||||
|
||||
static bool CD_GetVolume (void *unused)
|
||||
static bool CD_GetVolume(void *unused)
|
||||
{
|
||||
/* FIXME: write proper code in here when SDL
|
||||
/* FIXME: write proper code in here when SDL
|
||||
supports cdrom volume control some day. */
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool CD_SetVolume (void *unused)
|
||||
static bool CD_SetVolume(void *unused)
|
||||
{
|
||||
/* FIXME: write proper code in here when SDL
|
||||
/* FIXME: write proper code in here when SDL
|
||||
supports cdrom volume control some day. */
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool CDAudio_SetVolume (float value)
|
||||
static bool CDAudio_SetVolume(float value)
|
||||
{
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return false;
|
||||
|
||||
old_cdvolume = value;
|
||||
|
||||
if (value == 0.0f)
|
||||
CDAudio_Pause ();
|
||||
if(value == 0.0f)
|
||||
CDAudio_Pause();
|
||||
else
|
||||
CDAudio_Resume();
|
||||
|
||||
if (!hw_vol_works)
|
||||
if(!hw_vol_works)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: write proper code in here when SDL
|
||||
/* FIXME: write proper code in here when SDL
|
||||
supports cdrom volume control some day. */
|
||||
return CD_SetVolume (NULL);
|
||||
return CD_SetVolume(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CDAudio_Update(void)
|
||||
{
|
||||
CDstatus curstat;
|
||||
/* static double lastchk;*/
|
||||
/* static double lastchk;*/
|
||||
|
||||
if (!cd_handle || !enabled)
|
||||
if(!cd_handle || !enabled)
|
||||
return;
|
||||
|
||||
if (old_cdvolume != bgmvolume.value)
|
||||
CDAudio_SetVolume (bgmvolume.value);
|
||||
if(old_cdvolume != bgmvolume.value)
|
||||
CDAudio_SetVolume(bgmvolume.value);
|
||||
|
||||
/* if (playing && realtime > lastchk)*/
|
||||
if (playing && realtime > endOfTrack)
|
||||
/* if (playing && realtime > lastchk)*/
|
||||
if(playing && realtime > endOfTrack)
|
||||
{
|
||||
/* lastchk = realtime + 2;*/ /* two seconds between chks */
|
||||
curstat = SDL_CDStatus(cd_handle);
|
||||
if (curstat != CD_PLAYING && curstat != CD_PAUSED)
|
||||
if(curstat != CD_PLAYING && curstat != CD_PAUSED)
|
||||
{
|
||||
playing = false;
|
||||
endOfTrack = -1.0;
|
||||
if (playLooping)
|
||||
if(playLooping)
|
||||
CDAudio_Play(playTrack, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const char *get_cddev_arg (const char *arg)
|
||||
static const char *get_cddev_arg(const char *arg)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
/* arg should be like "D:\", make sure it is so,
|
||||
/* arg should be like "D:\", make sure it is so,
|
||||
* but tolerate args like "D" or "D:", as well. */
|
||||
static char drive[4];
|
||||
if (!arg || ! *arg)
|
||||
if(!arg || ! *arg)
|
||||
return NULL;
|
||||
if (arg[1] != '\0')
|
||||
if(arg[1] != '\0')
|
||||
{
|
||||
if (arg[1] != ':')
|
||||
if(arg[1] != ':')
|
||||
return NULL;
|
||||
if (arg[2] != '\0')
|
||||
if(arg[2] != '\0')
|
||||
{
|
||||
if (arg[2] != '\\' &&
|
||||
if(arg[2] != '\\' &&
|
||||
arg[2] != '/')
|
||||
return NULL;
|
||||
if (arg[3] != '\0')
|
||||
if(arg[3] != '\0')
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (*arg >= 'A' && *arg <= 'Z')
|
||||
if(*arg >= 'A' && *arg <= 'Z')
|
||||
{
|
||||
drive[0] = *arg;
|
||||
drive[1] = ':';
|
||||
|
@ -454,7 +454,7 @@ static const char *get_cddev_arg (const char *arg)
|
|||
drive[3] = '\0';
|
||||
return drive;
|
||||
}
|
||||
else if (*arg >= 'a' && *arg <= 'z')
|
||||
else if(*arg >= 'a' && *arg <= 'z')
|
||||
{
|
||||
/* make it uppercase for SDL */
|
||||
drive[0] = *arg - ('a' - 'A');
|
||||
|
@ -465,22 +465,22 @@ static const char *get_cddev_arg (const char *arg)
|
|||
}
|
||||
return NULL;
|
||||
#else
|
||||
if (!arg || ! *arg)
|
||||
if(!arg || ! *arg)
|
||||
return NULL;
|
||||
return arg;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void export_cddev_arg (void)
|
||||
static void export_cddev_arg(void)
|
||||
{
|
||||
/* Bad ugly hack to workaround SDL's cdrom device detection.
|
||||
/* Bad ugly hack to workaround SDL's cdrom device detection.
|
||||
* not needed for windows due to the way SDL_cdrom works. */
|
||||
#if !defined(_WIN32)
|
||||
int32_t i = COM_CheckParm("-cddev");
|
||||
if (i != 0 && i < com_argc - 1 && com_argv[i+1][0] != '\0')
|
||||
if(i != 0 && i < com_argc - 1 && com_argv[i + 1][0] != '\0')
|
||||
{
|
||||
static char arg[64];
|
||||
q_snprintf(arg, sizeof(arg), "SDL_CDROM=%s", com_argv[i+1]);
|
||||
q_snprintf(arg, sizeof(arg), "SDL_CDROM=%s", com_argv[i + 1]);
|
||||
putenv(arg);
|
||||
}
|
||||
#endif
|
||||
|
@ -490,87 +490,87 @@ int32_t CDAudio_Init(void)
|
|||
{
|
||||
int32_t i, sdl_num_drives;
|
||||
|
||||
if (safemode || COM_CheckParm("-nocdaudio"))
|
||||
if(safemode || COM_CheckParm("-nocdaudio"))
|
||||
return -1;
|
||||
|
||||
export_cddev_arg();
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0)
|
||||
if(SDL_InitSubSystem(SDL_INIT_CDROM) < 0)
|
||||
{
|
||||
Con_Printf("Couldn't init SDL cdrom: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
sdl_num_drives = SDL_CDNumDrives ();
|
||||
Con_Printf ("SDL detected %" PRIi32 " CD-ROM drive%c\n", sdl_num_drives,
|
||||
sdl_num_drives = SDL_CDNumDrives();
|
||||
Con_Printf("SDL detected %" PRIi32 " CD-ROM drive%c\n", sdl_num_drives,
|
||||
sdl_num_drives == 1 ? ' ' : 's');
|
||||
|
||||
if (sdl_num_drives < 1)
|
||||
if(sdl_num_drives < 1)
|
||||
return -1;
|
||||
|
||||
if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1)
|
||||
if((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1)
|
||||
{
|
||||
const char *userdev = get_cddev_arg(com_argv[i+1]);
|
||||
if (!userdev)
|
||||
const char *userdev = get_cddev_arg(com_argv[i + 1]);
|
||||
if(!userdev)
|
||||
{
|
||||
Con_Printf("Invalid argument to -cddev\n");
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < sdl_num_drives; i++)
|
||||
for(i = 0; i < sdl_num_drives; i++)
|
||||
{
|
||||
if (!q_strcasecmp(SDL_CDName(i), userdev))
|
||||
if(!q_strcasecmp(SDL_CDName(i), userdev))
|
||||
{
|
||||
cd_dev = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cd_dev == -1)
|
||||
if(cd_dev == -1)
|
||||
{
|
||||
Con_Printf("SDL couldn't find cdrom device %s\n", userdev);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (cd_dev == -1)
|
||||
if(cd_dev == -1)
|
||||
cd_dev = 0; /* default drive */
|
||||
|
||||
cd_handle = SDL_CDOpen(cd_dev);
|
||||
if (!cd_handle)
|
||||
if(!cd_handle)
|
||||
{
|
||||
Con_Printf ("CDAudio_Init: Unable to open CD-ROM drive %s (%s)\n",
|
||||
Con_Printf("CDAudio_Init: Unable to open CD-ROM drive %s (%s)\n",
|
||||
SDL_CDName(cd_dev), SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
for(i = 0; i < 100; i++)
|
||||
remap[i] = i;
|
||||
enabled = true;
|
||||
old_cdvolume = bgmvolume.value;
|
||||
|
||||
Con_Printf("CDAudio initialized (SDL, using %s)\n", SDL_CDName(cd_dev));
|
||||
|
||||
if (CDAudio_GetAudioDiskInfo())
|
||||
if(CDAudio_GetAudioDiskInfo())
|
||||
{
|
||||
Con_Printf("CDAudio_Init: No CD in drive\n");
|
||||
cdValid = false;
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("cd", CD_f);
|
||||
Cmd_AddCommand("cd", CD_f);
|
||||
|
||||
hw_vol_works = CD_GetVolume (NULL); /* no SDL support at present. */
|
||||
if (hw_vol_works)
|
||||
hw_vol_works = CDAudio_SetVolume (bgmvolume.value);
|
||||
hw_vol_works = CD_GetVolume(NULL); /* no SDL support at present. */
|
||||
if(hw_vol_works)
|
||||
hw_vol_works = CDAudio_SetVolume(bgmvolume.value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CDAudio_Shutdown(void)
|
||||
{
|
||||
if (!cd_handle)
|
||||
if(!cd_handle)
|
||||
return;
|
||||
CDAudio_Stop();
|
||||
if (hw_vol_works)
|
||||
CD_SetVolume (NULL); /* no SDL support at present. */
|
||||
if(hw_vol_works)
|
||||
CD_SetVolume(NULL); /* no SDL support at present. */
|
||||
#ifdef __linux__
|
||||
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
|
||||
#endif
|
||||
|
|
|
@ -22,14 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef __CDAUDIO_H
|
||||
#define __CDAUDIO_H
|
||||
|
||||
int32_t CDAudio_Init (void);
|
||||
int32_t CDAudio_Play (byte track, bool looping);
|
||||
/* returns 0 for success, -1 for failure. */
|
||||
void CDAudio_Stop (void);
|
||||
void CDAudio_Pause (void);
|
||||
void CDAudio_Resume (void);
|
||||
void CDAudio_Shutdown (void);
|
||||
void CDAudio_Update (void);
|
||||
int32_t CDAudio_Init(void);
|
||||
int32_t CDAudio_Play(byte track, bool looping);
|
||||
/* returns 0 for success, -1 for failure. */
|
||||
void CDAudio_Stop(void);
|
||||
void CDAudio_Pause(void);
|
||||
void CDAudio_Resume(void);
|
||||
void CDAudio_Shutdown(void);
|
||||
void CDAudio_Update(void);
|
||||
|
||||
#endif /* __CDAUDIO_H */
|
||||
|
||||
|
|
|
@ -35,42 +35,43 @@ the num_vars argument must be the exact number of strings in the
|
|||
array, otherwise I have nothing against going out of bounds.
|
||||
===================
|
||||
*/
|
||||
void CFG_ReadCvars (const char **vars, int32_t num_vars)
|
||||
void CFG_ReadCvars(const char **vars, int32_t num_vars)
|
||||
{
|
||||
char buff[1024], *tmp;
|
||||
int32_t i, j;
|
||||
|
||||
if (!cfg_file || num_vars < 1)
|
||||
if(!cfg_file || num_vars < 1)
|
||||
return;
|
||||
|
||||
j = 0;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
i = 0;
|
||||
memset (buff, 0, sizeof(buff));
|
||||
memset(buff, 0, sizeof(buff));
|
||||
// we expect a line in the format that Cvar_WriteVariables
|
||||
// writes to the config file. although I'm trying to be as
|
||||
// much cautious as possible, if the user screws it up by
|
||||
// editing it, it's his fault.
|
||||
if (FS_fgets(buff, sizeof(buff), cfg_file))
|
||||
if(FS_fgets(buff, sizeof(buff), cfg_file))
|
||||
{
|
||||
// remove end-of-line characters
|
||||
while (buff[i])
|
||||
while(buff[i])
|
||||
{
|
||||
if (buff[i] == '\r' || buff[i] == '\n')
|
||||
if(buff[i] == '\r' || buff[i] == '\n')
|
||||
buff[i] = '\0';
|
||||
// while we're here, replace tabs with spaces
|
||||
if (buff[i] == '\t')
|
||||
if(buff[i] == '\t')
|
||||
buff[i] = ' ';
|
||||
i++;
|
||||
}
|
||||
// go to the last character
|
||||
while (buff[i] == 0 && i > 0)
|
||||
while(buff[i] == 0 && i > 0)
|
||||
i--;
|
||||
// remove trailing spaces
|
||||
while (i > 0)
|
||||
while(i > 0)
|
||||
{
|
||||
if (buff[i] == ' ')
|
||||
if(buff[i] == ' ')
|
||||
{
|
||||
buff[i] = '\0';
|
||||
i--;
|
||||
|
@ -80,33 +81,34 @@ void CFG_ReadCvars (const char **vars, int32_t num_vars)
|
|||
}
|
||||
|
||||
// the line must end with a quotation mark
|
||||
if (buff[i] != '\"')
|
||||
if(buff[i] != '\"')
|
||||
continue;
|
||||
buff[i] = '\0';
|
||||
|
||||
for (i = 0; i < num_vars && vars[i]; i++)
|
||||
for(i = 0; i < num_vars && vars[i]; i++)
|
||||
{
|
||||
// look for the cvar name + one space
|
||||
tmp = strstr(buff, va("%s ",vars[i]));
|
||||
if (tmp != buff)
|
||||
tmp = strstr(buff, va("%s ", vars[i]));
|
||||
if(tmp != buff)
|
||||
continue;
|
||||
// locate the first quotation mark
|
||||
tmp = strchr(buff, '\"');
|
||||
if (tmp)
|
||||
if(tmp)
|
||||
{
|
||||
Cvar_Set (vars[i], tmp + 1);
|
||||
Cvar_Set(vars[i], tmp + 1);
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (j == num_vars)
|
||||
if(j == num_vars)
|
||||
break;
|
||||
|
||||
} while (!FS_feof(cfg_file) && !FS_ferror(cfg_file));
|
||||
}
|
||||
while(!FS_feof(cfg_file) && !FS_ferror(cfg_file));
|
||||
|
||||
FS_rewind (cfg_file);
|
||||
FS_rewind(cfg_file);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -118,31 +120,31 @@ values of cvars in the given list. doesn't do anything with
|
|||
the config file.
|
||||
===================
|
||||
*/
|
||||
void CFG_ReadCvarOverrides (const char **vars, int32_t num_vars)
|
||||
void CFG_ReadCvarOverrides(const char **vars, int32_t num_vars)
|
||||
{
|
||||
char buff[64];
|
||||
int32_t i, j;
|
||||
|
||||
if (num_vars < 1)
|
||||
if(num_vars < 1)
|
||||
return;
|
||||
|
||||
buff[0] = '+';
|
||||
|
||||
for (i = 0; i < num_vars; i++)
|
||||
for(i = 0; i < num_vars; i++)
|
||||
{
|
||||
q_strlcpy (&buff[1], vars[i], sizeof(buff) - 1);
|
||||
q_strlcpy(&buff[1], vars[i], sizeof(buff) - 1);
|
||||
j = COM_CheckParm(buff);
|
||||
if (j != 0 && j < com_argc - 1)
|
||||
if(j != 0 && j < com_argc - 1)
|
||||
{
|
||||
if (com_argv[j + 1][0] != '-' && com_argv[j + 1][0] != '+')
|
||||
if(com_argv[j + 1][0] != '-' && com_argv[j + 1][0] != '+')
|
||||
Cvar_Set(vars[i], com_argv[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CFG_CloseConfig (void)
|
||||
void CFG_CloseConfig(void)
|
||||
{
|
||||
if (cfg_file)
|
||||
if(cfg_file)
|
||||
{
|
||||
FS_fclose(cfg_file);
|
||||
Z_Free(cfg_file);
|
||||
|
@ -150,17 +152,17 @@ void CFG_CloseConfig (void)
|
|||
}
|
||||
}
|
||||
|
||||
int32_t CFG_OpenConfig (const char *cfg_name)
|
||||
int32_t CFG_OpenConfig(const char *cfg_name)
|
||||
{
|
||||
FILE *f;
|
||||
long length;
|
||||
bool pak;
|
||||
|
||||
CFG_CloseConfig ();
|
||||
CFG_CloseConfig();
|
||||
|
||||
length = (long) COM_FOpenFile (cfg_name, &f, NULL);
|
||||
length = (long) COM_FOpenFile(cfg_name, &f, NULL);
|
||||
pak = file_from_pak;
|
||||
if (length == -1)
|
||||
if(length == -1)
|
||||
return -1;
|
||||
|
||||
cfg_file = (fshandle_t *) Z_Malloc(sizeof(fshandle_t));
|
||||
|
|
|
@ -22,18 +22,18 @@
|
|||
#ifndef __CFGFILE_H
|
||||
#define __CFGFILE_H
|
||||
|
||||
int32_t CFG_OpenConfig (const char *cfg_name);
|
||||
int32_t CFG_OpenConfig(const char *cfg_name);
|
||||
// opens the given config file. only one open config file is
|
||||
// kept: previosly opened one, if any, will be closed.
|
||||
|
||||
void CFG_CloseConfig (void);
|
||||
void CFG_CloseConfig(void);
|
||||
// closes the currently open config file.
|
||||
|
||||
void CFG_ReadCvars (const char **vars, int32_t num_vars);
|
||||
void CFG_ReadCvars(const char **vars, int32_t num_vars);
|
||||
// reads the values of cvars in the given list from the opened
|
||||
// config file.
|
||||
|
||||
void CFG_ReadCvarOverrides (const char **vars, int32_t num_vars);
|
||||
void CFG_ReadCvarOverrides(const char **vars, int32_t num_vars);
|
||||
// convenience function, reading the "+" command line override
|
||||
// values of cvars in the given list. doesn't do anything with
|
||||
// the config file. call this after CFG_ReadCvars() and before
|
||||
|
|
|
@ -33,12 +33,12 @@ cvar_t chase_active = {"chase_active", "0", CVAR_NONE};
|
|||
Chase_Init
|
||||
==============
|
||||
*/
|
||||
void Chase_Init (void)
|
||||
void Chase_Init(void)
|
||||
{
|
||||
Cvar_RegisterVariable (&chase_back);
|
||||
Cvar_RegisterVariable (&chase_up);
|
||||
Cvar_RegisterVariable (&chase_right);
|
||||
Cvar_RegisterVariable (&chase_active);
|
||||
Cvar_RegisterVariable(&chase_back);
|
||||
Cvar_RegisterVariable(&chase_up);
|
||||
Cvar_RegisterVariable(&chase_right);
|
||||
Cvar_RegisterVariable(&chase_active);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -48,14 +48,14 @@ TraceLine
|
|||
TODO: impact on bmodels, monsters
|
||||
==============
|
||||
*/
|
||||
void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
||||
void TraceLine(vec3_t start, vec3_t end, vec3_t impact)
|
||||
{
|
||||
trace_t trace;
|
||||
|
||||
memset (&trace, 0, sizeof(trace));
|
||||
SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
||||
memset(&trace, 0, sizeof(trace));
|
||||
SV_RecursiveHullCheck(cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
|
||||
|
||||
VectorCopy (trace.endpos, impact);
|
||||
VectorCopy(trace.endpos, impact);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -63,7 +63,7 @@ void TraceLine (vec3_t start, vec3_t end, vec3_t impact)
|
|||
Chase_UpdateForClient -- johnfitz -- orient client based on camera. called after input
|
||||
==============
|
||||
*/
|
||||
void Chase_UpdateForClient (void)
|
||||
void Chase_UpdateForClient(void)
|
||||
{
|
||||
//place camera
|
||||
|
||||
|
@ -81,38 +81,38 @@ Chase_UpdateForDrawing -- johnfitz -- orient camera based on client. called befo
|
|||
TODO: stay at least 8 units away from all walls in this leaf
|
||||
==============
|
||||
*/
|
||||
void Chase_UpdateForDrawing (void)
|
||||
void Chase_UpdateForDrawing(void)
|
||||
{
|
||||
int32_t i;
|
||||
vec3_t forward, up, right;
|
||||
vec3_t ideal, crosshair, temp;
|
||||
|
||||
AngleVectors (cl.viewangles, forward, right, up);
|
||||
AngleVectors(cl.viewangles, forward, right, up);
|
||||
|
||||
// calc ideal camera location before checking for walls
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
ideal[i] = cl.viewent.origin[i]
|
||||
- forward[i]*chase_back.value
|
||||
+ right[i]*chase_right.value;
|
||||
- forward[i] * chase_back.value
|
||||
+ right[i] * chase_right.value;
|
||||
//+ up[i]*chase_up.value;
|
||||
ideal[2] = cl.viewent.origin[2] + chase_up.value;
|
||||
|
||||
// make sure camera is not in or behind a wall
|
||||
TraceLine(r_refdef.vieworg, ideal, temp);
|
||||
if (VectorLength(temp) != 0)
|
||||
if(VectorLength(temp) != 0)
|
||||
VectorCopy(temp, ideal);
|
||||
|
||||
// place camera
|
||||
VectorCopy (ideal, r_refdef.vieworg);
|
||||
VectorCopy(ideal, r_refdef.vieworg);
|
||||
|
||||
// find the spot the player is looking at
|
||||
VectorMA (cl.viewent.origin, 4096, forward, temp);
|
||||
TraceLine (cl.viewent.origin, temp, crosshair);
|
||||
VectorMA(cl.viewent.origin, 4096, forward, temp);
|
||||
TraceLine(cl.viewent.origin, temp, crosshair);
|
||||
|
||||
// calculate camera angles to look at the same spot
|
||||
VectorSubtract (crosshair, r_refdef.vieworg, temp);
|
||||
VectorAngles (temp, r_refdef.viewangles);
|
||||
if (r_refdef.viewangles[PITCH] == 90 || r_refdef.viewangles[PITCH] == -90)
|
||||
VectorSubtract(crosshair, r_refdef.vieworg, temp);
|
||||
VectorAngles(temp, r_refdef.viewangles);
|
||||
if(r_refdef.viewangles[PITCH] == 90 || r_refdef.viewangles[PITCH] == -90)
|
||||
r_refdef.viewangles[YAW] = cl.viewangles[YAW];
|
||||
}
|
||||
|
||||
|
|
273
source/cl_demo.c
273
source/cl_demo.c
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
static void CL_FinishTimeDemo (void);
|
||||
static void CL_FinishTimeDemo(void);
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
@ -47,19 +47,19 @@ CL_StopPlayback
|
|||
Called when a demo file runs out, or the user starts a game
|
||||
==============
|
||||
*/
|
||||
void CL_StopPlayback (void)
|
||||
void CL_StopPlayback(void)
|
||||
{
|
||||
if (!cls.demoplayback)
|
||||
if(!cls.demoplayback)
|
||||
return;
|
||||
|
||||
fclose (cls.demofile);
|
||||
fclose(cls.demofile);
|
||||
cls.demoplayback = false;
|
||||
cls.demopaused = false;
|
||||
cls.demofile = NULL;
|
||||
cls.state = ca_disconnected;
|
||||
|
||||
if (cls.timedemo)
|
||||
CL_FinishTimeDemo ();
|
||||
if(cls.timedemo)
|
||||
CL_FinishTimeDemo();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -69,66 +69,66 @@ CL_WriteDemoMessage
|
|||
Dumps the current net message, prefixed by the length and view angles
|
||||
====================
|
||||
*/
|
||||
static void CL_WriteDemoMessage (void)
|
||||
static void CL_WriteDemoMessage(void)
|
||||
{
|
||||
int32_t len;
|
||||
int32_t i;
|
||||
float f;
|
||||
|
||||
len = LittleLong (net_message.cursize);
|
||||
fwrite (&len, 4, 1, cls.demofile);
|
||||
for (i = 0; i < 3; i++)
|
||||
len = LittleLong(net_message.cursize);
|
||||
fwrite(&len, 4, 1, cls.demofile);
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
f = LittleFloat (cl.viewangles[i]);
|
||||
fwrite (&f, 4, 1, cls.demofile);
|
||||
f = LittleFloat(cl.viewangles[i]);
|
||||
fwrite(&f, 4, 1, cls.demofile);
|
||||
}
|
||||
fwrite (net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
fflush (cls.demofile);
|
||||
fwrite(net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
fflush(cls.demofile);
|
||||
}
|
||||
|
||||
static int32_t CL_GetDemoMessage (void)
|
||||
static int32_t CL_GetDemoMessage(void)
|
||||
{
|
||||
int32_t r, i;
|
||||
float f;
|
||||
|
||||
if (cls.demopaused)
|
||||
if(cls.demopaused)
|
||||
return 0;
|
||||
|
||||
// decide if it is time to grab the next message
|
||||
if (cls.signon == SIGNONS) // always grab until fully connected
|
||||
if(cls.signon == SIGNONS) // always grab until fully connected
|
||||
{
|
||||
if (cls.timedemo)
|
||||
if(cls.timedemo)
|
||||
{
|
||||
if (host_framecount == cls.td_lastframe)
|
||||
if(host_framecount == cls.td_lastframe)
|
||||
return 0; // already read this frame's message
|
||||
cls.td_lastframe = host_framecount;
|
||||
// if this is the second frame, grab the real td_starttime
|
||||
// so the bogus time on the first frame doesn't count
|
||||
if (host_framecount == cls.td_startframe + 1)
|
||||
if(host_framecount == cls.td_startframe + 1)
|
||||
cls.td_starttime = realtime;
|
||||
}
|
||||
else if (/* cl.time > 0 && */ cl.time <= cl.mtime[0])
|
||||
else if(/* cl.time > 0 && */ cl.time <= cl.mtime[0])
|
||||
{
|
||||
return 0; // don't need another message yet
|
||||
}
|
||||
}
|
||||
|
||||
// get the next message
|
||||
fread (&net_message.cursize, 4, 1, cls.demofile);
|
||||
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
||||
for (i = 0 ; i < 3 ; i++)
|
||||
fread(&net_message.cursize, 4, 1, cls.demofile);
|
||||
VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
r = fread (&f, 4, 1, cls.demofile);
|
||||
cl.mviewangles[0][i] = LittleFloat (f);
|
||||
r = fread(&f, 4, 1, cls.demofile);
|
||||
cl.mviewangles[0][i] = LittleFloat(f);
|
||||
}
|
||||
|
||||
net_message.cursize = LittleLong (net_message.cursize);
|
||||
if (net_message.cursize > MAX_MSGLEN)
|
||||
Sys_Error ("Demo message > MAX_MSGLEN");
|
||||
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
if (r != 1)
|
||||
net_message.cursize = LittleLong(net_message.cursize);
|
||||
if(net_message.cursize > MAX_MSGLEN)
|
||||
Sys_Error("Demo message > MAX_MSGLEN");
|
||||
r = fread(net_message.data, net_message.cursize, 1, cls.demofile);
|
||||
if(r != 1)
|
||||
{
|
||||
CL_StopPlayback ();
|
||||
CL_StopPlayback();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,31 +142,31 @@ CL_GetMessage
|
|||
Handles recording and playback of demos, on top of NET_ code
|
||||
====================
|
||||
*/
|
||||
int32_t CL_GetMessage (void)
|
||||
int32_t CL_GetMessage(void)
|
||||
{
|
||||
int32_t r;
|
||||
|
||||
if (cls.demoplayback)
|
||||
return CL_GetDemoMessage ();
|
||||
if(cls.demoplayback)
|
||||
return CL_GetDemoMessage();
|
||||
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
r = NET_GetMessage (cls.netcon);
|
||||
r = NET_GetMessage(cls.netcon);
|
||||
|
||||
if (r != 1 && r != 2)
|
||||
if(r != 1 && r != 2)
|
||||
return r;
|
||||
|
||||
// discard nop keepalive message
|
||||
if (net_message.cursize == 1 && net_message.data[0] == svc_nop)
|
||||
Con_Printf ("<-- server to client keepalive\n");
|
||||
if(net_message.cursize == 1 && net_message.data[0] == svc_nop)
|
||||
Con_Printf("<-- server to client keepalive\n");
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (cls.demorecording)
|
||||
CL_WriteDemoMessage ();
|
||||
if(cls.demorecording)
|
||||
CL_WriteDemoMessage();
|
||||
|
||||
if (cls.signon < 2)
|
||||
if(cls.signon < 2)
|
||||
{
|
||||
// record messages before full connection, so that a
|
||||
// demo record can happen after connection is done
|
||||
|
@ -185,30 +185,30 @@ CL_Stop_f
|
|||
stop recording a demo
|
||||
====================
|
||||
*/
|
||||
void CL_Stop_f (void)
|
||||
void CL_Stop_f(void)
|
||||
{
|
||||
if (cmd_source != src_command)
|
||||
if(cmd_source != src_command)
|
||||
return;
|
||||
|
||||
if (!cls.demorecording)
|
||||
if(!cls.demorecording)
|
||||
{
|
||||
Con_Printf ("Not recording a demo.\n");
|
||||
Con_Printf("Not recording a demo.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// write a disconnect message to the demo file
|
||||
SZ_Clear (&net_message);
|
||||
MSG_WriteByte (&net_message, svc_disconnect);
|
||||
CL_WriteDemoMessage ();
|
||||
SZ_Clear(&net_message);
|
||||
MSG_WriteByte(&net_message, svc_disconnect);
|
||||
CL_WriteDemoMessage();
|
||||
|
||||
// finish up
|
||||
fclose (cls.demofile);
|
||||
fclose(cls.demofile);
|
||||
cls.demofile = NULL;
|
||||
cls.demorecording = false;
|
||||
Con_Printf ("Completed demo\n");
|
||||
Con_Printf("Completed demo\n");
|
||||
|
||||
// ericw -- update demo tab-completion list
|
||||
DemoList_Rebuild ();
|
||||
DemoList_Rebuild();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -218,44 +218,44 @@ CL_Record_f
|
|||
record <demoname> <map> [cd track]
|
||||
====================
|
||||
*/
|
||||
void CL_Record_f (void)
|
||||
void CL_Record_f(void)
|
||||
{
|
||||
int32_t c;
|
||||
char name[MAX_OSPATH];
|
||||
int32_t track;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if(cmd_source != src_command)
|
||||
return;
|
||||
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
{
|
||||
Con_Printf ("Can't record during demo playback\n");
|
||||
Con_Printf("Can't record during demo playback\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cls.demorecording)
|
||||
if(cls.demorecording)
|
||||
CL_Stop_f();
|
||||
|
||||
c = Cmd_Argc();
|
||||
if (c != 2 && c != 3 && c != 4)
|
||||
if(c != 2 && c != 3 && c != 4)
|
||||
{
|
||||
Con_Printf ("record <demoname> [<map> [cd track]]\n");
|
||||
Con_Printf("record <demoname> [<map> [cd track]]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if(strstr(Cmd_Argv(1), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
Con_Printf("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == 2 && cls.state == ca_connected)
|
||||
if(c == 2 && cls.state == ca_connected)
|
||||
{
|
||||
#if 0
|
||||
Con_Printf("Can not record - already connected to server\nClient demo recording must be started before connecting\n");
|
||||
return;
|
||||
#endif
|
||||
if (cls.signon < 2)
|
||||
if(cls.signon < 2)
|
||||
{
|
||||
Con_Printf("Can't record - try again when connected\n");
|
||||
return;
|
||||
|
@ -263,50 +263,50 @@ void CL_Record_f (void)
|
|||
}
|
||||
|
||||
// write the forced cd track number, or -1
|
||||
if (c == 4)
|
||||
if(c == 4)
|
||||
{
|
||||
track = atoi(Cmd_Argv(3));
|
||||
Con_Printf ("Forcing CD track to %" PRIi32 "\n", cls.forcetrack);
|
||||
Con_Printf("Forcing CD track to %" PRIi32 "\n", cls.forcetrack);
|
||||
}
|
||||
else
|
||||
{
|
||||
track = -1;
|
||||
}
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf(name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
|
||||
// start the map up
|
||||
if (c > 2)
|
||||
if(c > 2)
|
||||
{
|
||||
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);
|
||||
if (cls.state != ca_connected)
|
||||
Cmd_ExecuteString(va("map %s", Cmd_Argv(2)), src_command);
|
||||
if(cls.state != ca_connected)
|
||||
return;
|
||||
}
|
||||
|
||||
// open the demo file
|
||||
COM_AddExtension (name, ".dem", sizeof(name));
|
||||
COM_AddExtension(name, ".dem", sizeof(name));
|
||||
|
||||
Con_Printf ("recording to %s.\n", name);
|
||||
cls.demofile = fopen (name, "wb");
|
||||
if (!cls.demofile)
|
||||
Con_Printf("recording to %s.\n", name);
|
||||
cls.demofile = fopen(name, "wb");
|
||||
if(!cls.demofile)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't create %s\n", name);
|
||||
Con_Printf("ERROR: couldn't create %s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
cls.forcetrack = track;
|
||||
fprintf (cls.demofile, "%" PRIi32 "\n", cls.forcetrack);
|
||||
fprintf(cls.demofile, "%" PRIi32 "\n", cls.forcetrack);
|
||||
|
||||
cls.demorecording = true;
|
||||
|
||||
// from ProQuake: initialize the demo file if we're already connected
|
||||
if (c == 2 && cls.state == ca_connected)
|
||||
if(c == 2 && cls.state == ca_connected)
|
||||
{
|
||||
byte *data = net_message.data;
|
||||
int32_t cursize = net_message.cursize;
|
||||
int32_t i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
for(i = 0; i < 2; i++)
|
||||
{
|
||||
net_message.data = demo_head[i];
|
||||
net_message.cursize = demo_head_size[i];
|
||||
|
@ -314,54 +314,54 @@ void CL_Record_f (void)
|
|||
}
|
||||
|
||||
net_message.data = demo_head[2];
|
||||
SZ_Clear (&net_message);
|
||||
SZ_Clear(&net_message);
|
||||
|
||||
// current names, colors, and frag counts
|
||||
for (i = 0; i < cl.maxclients; i++)
|
||||
for(i = 0; i < cl.maxclients; i++)
|
||||
{
|
||||
MSG_WriteByte (&net_message, svc_updatename);
|
||||
MSG_WriteByte (&net_message, i);
|
||||
MSG_WriteString (&net_message, cl.scores[i].name);
|
||||
MSG_WriteByte (&net_message, svc_updatefrags);
|
||||
MSG_WriteByte (&net_message, i);
|
||||
MSG_WriteShort (&net_message, cl.scores[i].frags);
|
||||
MSG_WriteByte (&net_message, svc_updatecolors);
|
||||
MSG_WriteByte (&net_message, i);
|
||||
MSG_WriteByte (&net_message, cl.scores[i].colors);
|
||||
MSG_WriteByte(&net_message, svc_updatename);
|
||||
MSG_WriteByte(&net_message, i);
|
||||
MSG_WriteString(&net_message, cl.scores[i].name);
|
||||
MSG_WriteByte(&net_message, svc_updatefrags);
|
||||
MSG_WriteByte(&net_message, i);
|
||||
MSG_WriteShort(&net_message, cl.scores[i].frags);
|
||||
MSG_WriteByte(&net_message, svc_updatecolors);
|
||||
MSG_WriteByte(&net_message, i);
|
||||
MSG_WriteByte(&net_message, cl.scores[i].colors);
|
||||
}
|
||||
|
||||
// send all current light styles
|
||||
for (i = 0; i < MAX_LIGHTSTYLES; i++)
|
||||
for(i = 0; i < MAX_LIGHTSTYLES; i++)
|
||||
{
|
||||
MSG_WriteByte (&net_message, svc_lightstyle);
|
||||
MSG_WriteByte (&net_message, i);
|
||||
MSG_WriteString (&net_message, cl_lightstyle[i].map);
|
||||
MSG_WriteByte(&net_message, svc_lightstyle);
|
||||
MSG_WriteByte(&net_message, i);
|
||||
MSG_WriteString(&net_message, cl_lightstyle[i].map);
|
||||
}
|
||||
|
||||
// what about the CD track or SVC fog... future consideration.
|
||||
MSG_WriteByte (&net_message, svc_updatestat);
|
||||
MSG_WriteByte (&net_message, STAT_TOTALSECRETS);
|
||||
MSG_WriteLong (&net_message, cl.stats[STAT_TOTALSECRETS]);
|
||||
MSG_WriteByte(&net_message, svc_updatestat);
|
||||
MSG_WriteByte(&net_message, STAT_TOTALSECRETS);
|
||||
MSG_WriteLong(&net_message, cl.stats[STAT_TOTALSECRETS]);
|
||||
|
||||
MSG_WriteByte (&net_message, svc_updatestat);
|
||||
MSG_WriteByte (&net_message, STAT_TOTALMONSTERS);
|
||||
MSG_WriteLong (&net_message, cl.stats[STAT_TOTALMONSTERS]);
|
||||
MSG_WriteByte(&net_message, svc_updatestat);
|
||||
MSG_WriteByte(&net_message, STAT_TOTALMONSTERS);
|
||||
MSG_WriteLong(&net_message, cl.stats[STAT_TOTALMONSTERS]);
|
||||
|
||||
MSG_WriteByte (&net_message, svc_updatestat);
|
||||
MSG_WriteByte (&net_message, STAT_SECRETS);
|
||||
MSG_WriteLong (&net_message, cl.stats[STAT_SECRETS]);
|
||||
MSG_WriteByte(&net_message, svc_updatestat);
|
||||
MSG_WriteByte(&net_message, STAT_SECRETS);
|
||||
MSG_WriteLong(&net_message, cl.stats[STAT_SECRETS]);
|
||||
|
||||
MSG_WriteByte (&net_message, svc_updatestat);
|
||||
MSG_WriteByte (&net_message, STAT_MONSTERS);
|
||||
MSG_WriteLong (&net_message, cl.stats[STAT_MONSTERS]);
|
||||
MSG_WriteByte(&net_message, svc_updatestat);
|
||||
MSG_WriteByte(&net_message, STAT_MONSTERS);
|
||||
MSG_WriteLong(&net_message, cl.stats[STAT_MONSTERS]);
|
||||
|
||||
// view entity
|
||||
MSG_WriteByte (&net_message, svc_setview);
|
||||
MSG_WriteShort (&net_message, cl.viewentity);
|
||||
MSG_WriteByte(&net_message, svc_setview);
|
||||
MSG_WriteShort(&net_message, cl.viewentity);
|
||||
|
||||
// signon
|
||||
MSG_WriteByte (&net_message, svc_signonnum);
|
||||
MSG_WriteByte (&net_message, 3);
|
||||
MSG_WriteByte(&net_message, svc_signonnum);
|
||||
MSG_WriteByte(&net_message, 3);
|
||||
|
||||
CL_WriteDemoMessage();
|
||||
|
||||
|
@ -379,34 +379,34 @@ CL_PlayDemo_f
|
|||
play [demoname]
|
||||
====================
|
||||
*/
|
||||
void CL_PlayDemo_f (void)
|
||||
void CL_PlayDemo_f(void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
int32_t i, c;
|
||||
bool neg;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if(cmd_source != src_command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("playdemo <demoname> : plays a demo\n");
|
||||
Con_Printf("playdemo <demoname> : plays a demo\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// disconnect from server
|
||||
CL_Disconnect ();
|
||||
CL_Disconnect();
|
||||
|
||||
// open the demo file
|
||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||
COM_AddExtension (name, ".dem", sizeof(name));
|
||||
q_strlcpy(name, Cmd_Argv(1), sizeof(name));
|
||||
COM_AddExtension(name, ".dem", sizeof(name));
|
||||
|
||||
Con_Printf ("Playing demo from %s.\n", name);
|
||||
Con_Printf("Playing demo from %s.\n", name);
|
||||
|
||||
COM_FOpenFile (name, &cls.demofile, NULL);
|
||||
if (!cls.demofile)
|
||||
COM_FOpenFile(name, &cls.demofile, NULL);
|
||||
if(!cls.demofile)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open %s\n", name);
|
||||
Con_Printf("ERROR: couldn't open %s\n", name);
|
||||
cls.demonum = -1; // stop demo loop
|
||||
return;
|
||||
}
|
||||
|
@ -420,27 +420,28 @@ void CL_PlayDemo_f (void)
|
|||
neg = false;
|
||||
// read a decimal integer possibly with a leading '-',
|
||||
// followed by a '\n':
|
||||
for (i = 0; i < 13; i++)
|
||||
for(i = 0; i < 13; i++)
|
||||
{
|
||||
c = getc(cls.demofile);
|
||||
if (c == '\n')
|
||||
if(c == '\n')
|
||||
break;
|
||||
if (c == '-') {
|
||||
if(c == '-')
|
||||
{
|
||||
neg = true;
|
||||
continue;
|
||||
}
|
||||
// check for multiple '-' or legal digits? meh...
|
||||
cls.forcetrack = cls.forcetrack * 10 + (c - '0');
|
||||
}
|
||||
if (c != '\n')
|
||||
if(c != '\n')
|
||||
{
|
||||
fclose (cls.demofile);
|
||||
fclose(cls.demofile);
|
||||
cls.demofile = NULL;
|
||||
cls.demonum = -1; // stop demo loop
|
||||
Con_Printf ("ERROR: demo \"%s\" is invalid\n", name);
|
||||
Con_Printf("ERROR: demo \"%s\" is invalid\n", name);
|
||||
return;
|
||||
}
|
||||
if (neg)
|
||||
if(neg)
|
||||
cls.forcetrack = -cls.forcetrack;
|
||||
|
||||
cls.demoplayback = true;
|
||||
|
@ -457,7 +458,7 @@ CL_FinishTimeDemo
|
|||
|
||||
====================
|
||||
*/
|
||||
static void CL_FinishTimeDemo (void)
|
||||
static void CL_FinishTimeDemo(void)
|
||||
{
|
||||
int32_t frames;
|
||||
float time;
|
||||
|
@ -467,9 +468,9 @@ static void CL_FinishTimeDemo (void)
|
|||
// the first frame didn't count
|
||||
frames = (host_framecount - cls.td_startframe) - 1;
|
||||
time = realtime - cls.td_starttime;
|
||||
if (!time)
|
||||
if(!time)
|
||||
time = 1;
|
||||
Con_Printf ("%" PRIi32 " frames %5.1f seconds %5.1f fps\n", frames, time, frames/time);
|
||||
Con_Printf("%" PRIi32 " frames %5.1f seconds %5.1f fps\n", frames, time, frames / time);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -479,19 +480,19 @@ CL_TimeDemo_f
|
|||
timedemo [demoname]
|
||||
====================
|
||||
*/
|
||||
void CL_TimeDemo_f (void)
|
||||
void CL_TimeDemo_f(void)
|
||||
{
|
||||
if (cmd_source != src_command)
|
||||
if(cmd_source != src_command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("timedemo <demoname> : gets demo speeds\n");
|
||||
Con_Printf("timedemo <demoname> : gets demo speeds\n");
|
||||
return;
|
||||
}
|
||||
|
||||
CL_PlayDemo_f ();
|
||||
if (!cls.demofile)
|
||||
CL_PlayDemo_f();
|
||||
if(!cls.demofile)
|
||||
return;
|
||||
|
||||
// cls.td_starttime will be grabbed at the second frame of the demo, so
|
||||
|
|
|
@ -60,108 +60,212 @@ kbutton_t in_up, in_down;
|
|||
int32_t in_impulse;
|
||||
|
||||
|
||||
void KeyDown (kbutton_t *b)
|
||||
void KeyDown(kbutton_t *b)
|
||||
{
|
||||
int32_t k;
|
||||
const char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if (c[0])
|
||||
if(c[0])
|
||||
k = atoi(c);
|
||||
else
|
||||
k = -1; // typed manually at the console for continuous down
|
||||
|
||||
if (k == b->down[0] || k == b->down[1])
|
||||
if(k == b->down[0] || k == b->down[1])
|
||||
return; // repeating key
|
||||
|
||||
if (!b->down[0])
|
||||
if(!b->down[0])
|
||||
b->down[0] = k;
|
||||
else if (!b->down[1])
|
||||
else if(!b->down[1])
|
||||
b->down[1] = k;
|
||||
else
|
||||
{
|
||||
Con_Printf ("Three keys down for a button!\n");
|
||||
Con_Printf("Three keys down for a button!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (b->state & 1)
|
||||
if(b->state & 1)
|
||||
return; // still down
|
||||
b->state |= 1 + 2; // down + impulse down
|
||||
}
|
||||
|
||||
void KeyUp (kbutton_t *b)
|
||||
void KeyUp(kbutton_t *b)
|
||||
{
|
||||
int32_t k;
|
||||
const char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if (c[0])
|
||||
if(c[0])
|
||||
k = atoi(c);
|
||||
else
|
||||
{ // typed manually at the console, assume for unsticking, so clear all
|
||||
{
|
||||
// typed manually at the console, assume for unsticking, so clear all
|
||||
b->down[0] = b->down[1] = 0;
|
||||
b->state = 4; // impulse up
|
||||
return;
|
||||
}
|
||||
|
||||
if (b->down[0] == k)
|
||||
if(b->down[0] == k)
|
||||
b->down[0] = 0;
|
||||
else if (b->down[1] == k)
|
||||
else if(b->down[1] == k)
|
||||
b->down[1] = 0;
|
||||
else
|
||||
return; // key up without coresponding down (menu pass through)
|
||||
if (b->down[0] || b->down[1])
|
||||
if(b->down[0] || b->down[1])
|
||||
return; // some other key is still holding it down
|
||||
|
||||
if (!(b->state & 1))
|
||||
if(!(b->state & 1))
|
||||
return; // still up (this should not happen)
|
||||
b->state &= ~1; // now up
|
||||
b->state |= 4; // impulse up
|
||||
}
|
||||
|
||||
void IN_KLookDown (void) {KeyDown(&in_klook);}
|
||||
void IN_KLookUp (void) {KeyUp(&in_klook);}
|
||||
void IN_MLookDown (void) {KeyDown(&in_mlook);}
|
||||
void IN_MLookUp (void) {
|
||||
void IN_KLookDown(void)
|
||||
{
|
||||
KeyDown(&in_klook);
|
||||
}
|
||||
void IN_KLookUp(void)
|
||||
{
|
||||
KeyUp(&in_klook);
|
||||
}
|
||||
void IN_MLookDown(void)
|
||||
{
|
||||
KeyDown(&in_mlook);
|
||||
}
|
||||
void IN_MLookUp(void)
|
||||
{
|
||||
KeyUp(&in_mlook);
|
||||
if ( !(in_mlook.state&1) && lookspring.value)
|
||||
if(!(in_mlook.state & 1) && lookspring.value)
|
||||
V_StartPitchDrift();
|
||||
}
|
||||
void IN_UpDown(void) {KeyDown(&in_up);}
|
||||
void IN_UpUp(void) {KeyUp(&in_up);}
|
||||
void IN_DownDown(void) {KeyDown(&in_down);}
|
||||
void IN_DownUp(void) {KeyUp(&in_down);}
|
||||
void IN_LeftDown(void) {KeyDown(&in_left);}
|
||||
void IN_LeftUp(void) {KeyUp(&in_left);}
|
||||
void IN_RightDown(void) {KeyDown(&in_right);}
|
||||
void IN_RightUp(void) {KeyUp(&in_right);}
|
||||
void IN_ForwardDown(void) {KeyDown(&in_forward);}
|
||||
void IN_ForwardUp(void) {KeyUp(&in_forward);}
|
||||
void IN_BackDown(void) {KeyDown(&in_back);}
|
||||
void IN_BackUp(void) {KeyUp(&in_back);}
|
||||
void IN_LookupDown(void) {KeyDown(&in_lookup);}
|
||||
void IN_LookupUp(void) {KeyUp(&in_lookup);}
|
||||
void IN_LookdownDown(void) {KeyDown(&in_lookdown);}
|
||||
void IN_LookdownUp(void) {KeyUp(&in_lookdown);}
|
||||
void IN_MoveleftDown(void) {KeyDown(&in_moveleft);}
|
||||
void IN_MoveleftUp(void) {KeyUp(&in_moveleft);}
|
||||
void IN_MoverightDown(void) {KeyDown(&in_moveright);}
|
||||
void IN_MoverightUp(void) {KeyUp(&in_moveright);}
|
||||
void IN_UpDown(void)
|
||||
{
|
||||
KeyDown(&in_up);
|
||||
}
|
||||
void IN_UpUp(void)
|
||||
{
|
||||
KeyUp(&in_up);
|
||||
}
|
||||
void IN_DownDown(void)
|
||||
{
|
||||
KeyDown(&in_down);
|
||||
}
|
||||
void IN_DownUp(void)
|
||||
{
|
||||
KeyUp(&in_down);
|
||||
}
|
||||
void IN_LeftDown(void)
|
||||
{
|
||||
KeyDown(&in_left);
|
||||
}
|
||||
void IN_LeftUp(void)
|
||||
{
|
||||
KeyUp(&in_left);
|
||||
}
|
||||
void IN_RightDown(void)
|
||||
{
|
||||
KeyDown(&in_right);
|
||||
}
|
||||
void IN_RightUp(void)
|
||||
{
|
||||
KeyUp(&in_right);
|
||||
}
|
||||
void IN_ForwardDown(void)
|
||||
{
|
||||
KeyDown(&in_forward);
|
||||
}
|
||||
void IN_ForwardUp(void)
|
||||
{
|
||||
KeyUp(&in_forward);
|
||||
}
|
||||
void IN_BackDown(void)
|
||||
{
|
||||
KeyDown(&in_back);
|
||||
}
|
||||
void IN_BackUp(void)
|
||||
{
|
||||
KeyUp(&in_back);
|
||||
}
|
||||
void IN_LookupDown(void)
|
||||
{
|
||||
KeyDown(&in_lookup);
|
||||
}
|
||||
void IN_LookupUp(void)
|
||||
{
|
||||
KeyUp(&in_lookup);
|
||||
}
|
||||
void IN_LookdownDown(void)
|
||||
{
|
||||
KeyDown(&in_lookdown);
|
||||
}
|
||||
void IN_LookdownUp(void)
|
||||
{
|
||||
KeyUp(&in_lookdown);
|
||||
}
|
||||
void IN_MoveleftDown(void)
|
||||
{
|
||||
KeyDown(&in_moveleft);
|
||||
}
|
||||
void IN_MoveleftUp(void)
|
||||
{
|
||||
KeyUp(&in_moveleft);
|
||||
}
|
||||
void IN_MoverightDown(void)
|
||||
{
|
||||
KeyDown(&in_moveright);
|
||||
}
|
||||
void IN_MoverightUp(void)
|
||||
{
|
||||
KeyUp(&in_moveright);
|
||||
}
|
||||
|
||||
void IN_SpeedDown(void) {KeyDown(&in_speed);}
|
||||
void IN_SpeedUp(void) {KeyUp(&in_speed);}
|
||||
void IN_StrafeDown(void) {KeyDown(&in_strafe);}
|
||||
void IN_StrafeUp(void) {KeyUp(&in_strafe);}
|
||||
void IN_SpeedDown(void)
|
||||
{
|
||||
KeyDown(&in_speed);
|
||||
}
|
||||
void IN_SpeedUp(void)
|
||||
{
|
||||
KeyUp(&in_speed);
|
||||
}
|
||||
void IN_StrafeDown(void)
|
||||
{
|
||||
KeyDown(&in_strafe);
|
||||
}
|
||||
void IN_StrafeUp(void)
|
||||
{
|
||||
KeyUp(&in_strafe);
|
||||
}
|
||||
|
||||
void IN_AttackDown(void) {KeyDown(&in_attack);}
|
||||
void IN_AttackUp(void) {KeyUp(&in_attack);}
|
||||
void IN_AttackDown(void)
|
||||
{
|
||||
KeyDown(&in_attack);
|
||||
}
|
||||
void IN_AttackUp(void)
|
||||
{
|
||||
KeyUp(&in_attack);
|
||||
}
|
||||
|
||||
void IN_UseDown (void) {KeyDown(&in_use);}
|
||||
void IN_UseUp (void) {KeyUp(&in_use);}
|
||||
void IN_JumpDown (void) {KeyDown(&in_jump);}
|
||||
void IN_JumpUp (void) {KeyUp(&in_jump);}
|
||||
void IN_UseDown(void)
|
||||
{
|
||||
KeyDown(&in_use);
|
||||
}
|
||||
void IN_UseUp(void)
|
||||
{
|
||||
KeyUp(&in_use);
|
||||
}
|
||||
void IN_JumpDown(void)
|
||||
{
|
||||
KeyDown(&in_jump);
|
||||
}
|
||||
void IN_JumpUp(void)
|
||||
{
|
||||
KeyUp(&in_jump);
|
||||
}
|
||||
|
||||
void IN_Impulse (void) {in_impulse=Q_atoi(Cmd_Argv(1));}
|
||||
void IN_Impulse(void)
|
||||
{
|
||||
in_impulse = Q_atoi(Cmd_Argv(1));
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -173,7 +277,7 @@ Returns 0.25 if a key was pressed and released during the frame,
|
|||
1.0 if held for the entire time
|
||||
===============
|
||||
*/
|
||||
float CL_KeyState (kbutton_t *key)
|
||||
float CL_KeyState(kbutton_t *key)
|
||||
{
|
||||
float val;
|
||||
bool impulsedown, impulseup, down;
|
||||
|
@ -183,30 +287,30 @@ float CL_KeyState (kbutton_t *key)
|
|||
down = key->state & 1;
|
||||
val = 0;
|
||||
|
||||
if (impulsedown && !impulseup)
|
||||
if(impulsedown && !impulseup)
|
||||
{
|
||||
if (down)
|
||||
if(down)
|
||||
val = 0.5; // pressed and held this frame
|
||||
else
|
||||
val = 0; // I_Error ();
|
||||
}
|
||||
if (impulseup && !impulsedown)
|
||||
if(impulseup && !impulsedown)
|
||||
{
|
||||
if (down)
|
||||
if(down)
|
||||
val = 0; // I_Error ();
|
||||
else
|
||||
val = 0; // released this frame
|
||||
}
|
||||
if (!impulsedown && !impulseup)
|
||||
if(!impulsedown && !impulseup)
|
||||
{
|
||||
if (down)
|
||||
if(down)
|
||||
val = 1.0; // held the entire frame
|
||||
else
|
||||
val = 0; // up the entire frame
|
||||
}
|
||||
if (impulsedown && impulseup)
|
||||
if(impulsedown && impulseup)
|
||||
{
|
||||
if (down)
|
||||
if(down)
|
||||
val = 0.75; // released and re-pressed this frame
|
||||
else
|
||||
val = 0.25; // pressed and released this frame
|
||||
|
@ -220,19 +324,19 @@ float CL_KeyState (kbutton_t *key)
|
|||
|
||||
//==========================================================================
|
||||
|
||||
cvar_t cl_upspeed = {"cl_upspeed","200",CVAR_NONE};
|
||||
cvar_t cl_forwardspeed = {"cl_forwardspeed","200", CVAR_ARCHIVE};
|
||||
cvar_t cl_backspeed = {"cl_backspeed","200", CVAR_ARCHIVE};
|
||||
cvar_t cl_sidespeed = {"cl_sidespeed","350",CVAR_NONE};
|
||||
cvar_t cl_upspeed = {"cl_upspeed", "200", CVAR_NONE};
|
||||
cvar_t cl_forwardspeed = {"cl_forwardspeed", "200", CVAR_ARCHIVE};
|
||||
cvar_t cl_backspeed = {"cl_backspeed", "200", CVAR_ARCHIVE};
|
||||
cvar_t cl_sidespeed = {"cl_sidespeed", "350", CVAR_NONE};
|
||||
|
||||
cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0",CVAR_NONE};
|
||||
cvar_t cl_movespeedkey = {"cl_movespeedkey", "2.0", CVAR_NONE};
|
||||
|
||||
cvar_t cl_yawspeed = {"cl_yawspeed","140",CVAR_NONE};
|
||||
cvar_t cl_pitchspeed = {"cl_pitchspeed","150",CVAR_NONE};
|
||||
cvar_t cl_yawspeed = {"cl_yawspeed", "140", CVAR_NONE};
|
||||
cvar_t cl_pitchspeed = {"cl_pitchspeed", "150", CVAR_NONE};
|
||||
|
||||
cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5",CVAR_NONE};
|
||||
cvar_t cl_anglespeedkey = {"cl_anglespeedkey", "1.5", CVAR_NONE};
|
||||
|
||||
cvar_t cl_alwaysrun = {"cl_alwaysrun","0",CVAR_ARCHIVE}; // QuakeSpasm -- new always run
|
||||
cvar_t cl_alwaysrun = {"cl_alwaysrun", "0", CVAR_ARCHIVE}; // QuakeSpasm -- new always run
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -241,48 +345,48 @@ CL_AdjustAngles
|
|||
Moves the local angle positions
|
||||
================
|
||||
*/
|
||||
void CL_AdjustAngles (void)
|
||||
void CL_AdjustAngles(void)
|
||||
{
|
||||
float speed;
|
||||
float up, down;
|
||||
|
||||
if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
if((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
speed = host_frametime * cl_anglespeedkey.value;
|
||||
else
|
||||
speed = host_frametime;
|
||||
|
||||
if (!(in_strafe.state & 1))
|
||||
if(!(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[YAW] -= speed*cl_yawspeed.value*CL_KeyState (&in_right);
|
||||
cl.viewangles[YAW] += speed*cl_yawspeed.value*CL_KeyState (&in_left);
|
||||
cl.viewangles[YAW] -= speed * cl_yawspeed.value * CL_KeyState(&in_right);
|
||||
cl.viewangles[YAW] += speed * cl_yawspeed.value * CL_KeyState(&in_left);
|
||||
cl.viewangles[YAW] = anglemod(cl.viewangles[YAW]);
|
||||
}
|
||||
if (in_klook.state & 1)
|
||||
if(in_klook.state & 1)
|
||||
{
|
||||
V_StopPitchDrift ();
|
||||
cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * CL_KeyState (&in_forward);
|
||||
cl.viewangles[PITCH] += speed*cl_pitchspeed.value * CL_KeyState (&in_back);
|
||||
V_StopPitchDrift();
|
||||
cl.viewangles[PITCH] -= speed * cl_pitchspeed.value * CL_KeyState(&in_forward);
|
||||
cl.viewangles[PITCH] += speed * cl_pitchspeed.value * CL_KeyState(&in_back);
|
||||
}
|
||||
|
||||
up = CL_KeyState (&in_lookup);
|
||||
up = CL_KeyState(&in_lookup);
|
||||
down = CL_KeyState(&in_lookdown);
|
||||
|
||||
cl.viewangles[PITCH] -= speed*cl_pitchspeed.value * up;
|
||||
cl.viewangles[PITCH] += speed*cl_pitchspeed.value * down;
|
||||
cl.viewangles[PITCH] -= speed * cl_pitchspeed.value * up;
|
||||
cl.viewangles[PITCH] += speed * cl_pitchspeed.value * down;
|
||||
|
||||
if (up || down)
|
||||
V_StopPitchDrift ();
|
||||
if(up || down)
|
||||
V_StopPitchDrift();
|
||||
|
||||
//johnfitz -- variable pitch clamping
|
||||
if (cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
if(cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
cl.viewangles[PITCH] = cl_maxpitch.value;
|
||||
if (cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
if(cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
cl.viewangles[PITCH] = cl_minpitch.value;
|
||||
//johnfitz
|
||||
|
||||
if (cl.viewangles[ROLL] > 50)
|
||||
if(cl.viewangles[ROLL] > 50)
|
||||
cl.viewangles[ROLL] = 50;
|
||||
if (cl.viewangles[ROLL] < -50)
|
||||
if(cl.viewangles[ROLL] < -50)
|
||||
cl.viewangles[ROLL] = -50;
|
||||
}
|
||||
|
||||
|
@ -293,37 +397,37 @@ CL_BaseMove
|
|||
Send the intended movement message to the server
|
||||
================
|
||||
*/
|
||||
void CL_BaseMove (usercmd_t *cmd)
|
||||
void CL_BaseMove(usercmd_t *cmd)
|
||||
{
|
||||
if (cls.signon != SIGNONS)
|
||||
if(cls.signon != SIGNONS)
|
||||
return;
|
||||
|
||||
CL_AdjustAngles ();
|
||||
CL_AdjustAngles();
|
||||
|
||||
Q_memset (cmd, 0, sizeof(*cmd));
|
||||
Q_memset(cmd, 0, sizeof(*cmd));
|
||||
|
||||
if (in_strafe.state & 1)
|
||||
if(in_strafe.state & 1)
|
||||
{
|
||||
cmd->sidemove += cl_sidespeed.value * CL_KeyState (&in_right);
|
||||
cmd->sidemove -= cl_sidespeed.value * CL_KeyState (&in_left);
|
||||
cmd->sidemove += cl_sidespeed.value * CL_KeyState(&in_right);
|
||||
cmd->sidemove -= cl_sidespeed.value * CL_KeyState(&in_left);
|
||||
}
|
||||
|
||||
cmd->sidemove += cl_sidespeed.value * CL_KeyState (&in_moveright);
|
||||
cmd->sidemove -= cl_sidespeed.value * CL_KeyState (&in_moveleft);
|
||||
cmd->sidemove += cl_sidespeed.value * CL_KeyState(&in_moveright);
|
||||
cmd->sidemove -= cl_sidespeed.value * CL_KeyState(&in_moveleft);
|
||||
|
||||
cmd->upmove += cl_upspeed.value * CL_KeyState (&in_up);
|
||||
cmd->upmove -= cl_upspeed.value * CL_KeyState (&in_down);
|
||||
cmd->upmove += cl_upspeed.value * CL_KeyState(&in_up);
|
||||
cmd->upmove -= cl_upspeed.value * CL_KeyState(&in_down);
|
||||
|
||||
if (! (in_klook.state & 1) )
|
||||
if(!(in_klook.state & 1))
|
||||
{
|
||||
cmd->forwardmove += cl_forwardspeed.value * CL_KeyState (&in_forward);
|
||||
cmd->forwardmove -= cl_backspeed.value * CL_KeyState (&in_back);
|
||||
cmd->forwardmove += cl_forwardspeed.value * CL_KeyState(&in_forward);
|
||||
cmd->forwardmove -= cl_backspeed.value * CL_KeyState(&in_back);
|
||||
}
|
||||
|
||||
//
|
||||
// adjust for speed key
|
||||
//
|
||||
if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
if((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
{
|
||||
cmd->forwardmove *= cl_movespeedkey.value;
|
||||
cmd->sidemove *= cl_movespeedkey.value;
|
||||
|
@ -337,7 +441,7 @@ void CL_BaseMove (usercmd_t *cmd)
|
|||
CL_SendMove
|
||||
==============
|
||||
*/
|
||||
void CL_SendMove (const usercmd_t *cmd)
|
||||
void CL_SendMove(const usercmd_t *cmd)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t bits;
|
||||
|
@ -353,57 +457,57 @@ void CL_SendMove (const usercmd_t *cmd)
|
|||
//
|
||||
// send the movement message
|
||||
//
|
||||
MSG_WriteByte (&buf, clc_move);
|
||||
MSG_WriteByte(&buf, clc_move);
|
||||
|
||||
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
|
||||
MSG_WriteFloat(&buf, cl.mtime[0]); // so server can get ping times
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
//johnfitz -- 16-bit angles for PROTOCOL_FITZQUAKE
|
||||
if (cl.protocol == PROTOCOL_NETQUAKE)
|
||||
MSG_WriteAngle (&buf, cl.viewangles[i], cl.protocolflags);
|
||||
if(cl.protocol == PROTOCOL_NETQUAKE)
|
||||
MSG_WriteAngle(&buf, cl.viewangles[i], cl.protocolflags);
|
||||
else
|
||||
MSG_WriteAngle16 (&buf, cl.viewangles[i], cl.protocolflags);
|
||||
MSG_WriteAngle16(&buf, cl.viewangles[i], cl.protocolflags);
|
||||
//johnfitz
|
||||
|
||||
MSG_WriteShort (&buf, cmd->forwardmove);
|
||||
MSG_WriteShort (&buf, cmd->sidemove);
|
||||
MSG_WriteShort (&buf, cmd->upmove);
|
||||
MSG_WriteShort(&buf, cmd->forwardmove);
|
||||
MSG_WriteShort(&buf, cmd->sidemove);
|
||||
MSG_WriteShort(&buf, cmd->upmove);
|
||||
|
||||
//
|
||||
// send button bits
|
||||
//
|
||||
bits = 0;
|
||||
|
||||
if ( in_attack.state & 3 )
|
||||
if(in_attack.state & 3)
|
||||
bits |= 1;
|
||||
in_attack.state &= ~2;
|
||||
|
||||
if (in_jump.state & 3)
|
||||
if(in_jump.state & 3)
|
||||
bits |= 2;
|
||||
in_jump.state &= ~2;
|
||||
|
||||
MSG_WriteByte (&buf, bits);
|
||||
MSG_WriteByte(&buf, bits);
|
||||
|
||||
MSG_WriteByte (&buf, in_impulse);
|
||||
MSG_WriteByte(&buf, in_impulse);
|
||||
in_impulse = 0;
|
||||
|
||||
//
|
||||
// deliver the message
|
||||
//
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
return;
|
||||
|
||||
//
|
||||
// allways dump the first two message, because it may contain leftover inputs
|
||||
// from the last level
|
||||
//
|
||||
if (++cl.movemessages <= 2)
|
||||
if(++cl.movemessages <= 2)
|
||||
return;
|
||||
|
||||
if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1)
|
||||
if(NET_SendUnreliableMessage(cls.netcon, &buf) == -1)
|
||||
{
|
||||
Con_Printf ("CL_SendMove: lost server connection\n");
|
||||
CL_Disconnect ();
|
||||
Con_Printf("CL_SendMove: lost server connection\n");
|
||||
CL_Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,43 +516,43 @@ void CL_SendMove (const usercmd_t *cmd)
|
|||
CL_InitInput
|
||||
============
|
||||
*/
|
||||
void CL_InitInput (void)
|
||||
void CL_InitInput(void)
|
||||
{
|
||||
Cmd_AddCommand ("+moveup",IN_UpDown);
|
||||
Cmd_AddCommand ("-moveup",IN_UpUp);
|
||||
Cmd_AddCommand ("+movedown",IN_DownDown);
|
||||
Cmd_AddCommand ("-movedown",IN_DownUp);
|
||||
Cmd_AddCommand ("+left",IN_LeftDown);
|
||||
Cmd_AddCommand ("-left",IN_LeftUp);
|
||||
Cmd_AddCommand ("+right",IN_RightDown);
|
||||
Cmd_AddCommand ("-right",IN_RightUp);
|
||||
Cmd_AddCommand ("+forward",IN_ForwardDown);
|
||||
Cmd_AddCommand ("-forward",IN_ForwardUp);
|
||||
Cmd_AddCommand ("+back",IN_BackDown);
|
||||
Cmd_AddCommand ("-back",IN_BackUp);
|
||||
Cmd_AddCommand ("+lookup", IN_LookupDown);
|
||||
Cmd_AddCommand ("-lookup", IN_LookupUp);
|
||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown);
|
||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp);
|
||||
Cmd_AddCommand ("+strafe", IN_StrafeDown);
|
||||
Cmd_AddCommand ("-strafe", IN_StrafeUp);
|
||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
|
||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
|
||||
Cmd_AddCommand ("+moveright", IN_MoverightDown);
|
||||
Cmd_AddCommand ("-moveright", IN_MoverightUp);
|
||||
Cmd_AddCommand ("+speed", IN_SpeedDown);
|
||||
Cmd_AddCommand ("-speed", IN_SpeedUp);
|
||||
Cmd_AddCommand ("+attack", IN_AttackDown);
|
||||
Cmd_AddCommand ("-attack", IN_AttackUp);
|
||||
Cmd_AddCommand ("+use", IN_UseDown);
|
||||
Cmd_AddCommand ("-use", IN_UseUp);
|
||||
Cmd_AddCommand ("+jump", IN_JumpDown);
|
||||
Cmd_AddCommand ("-jump", IN_JumpUp);
|
||||
Cmd_AddCommand ("impulse", IN_Impulse);
|
||||
Cmd_AddCommand ("+klook", IN_KLookDown);
|
||||
Cmd_AddCommand ("-klook", IN_KLookUp);
|
||||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||
Cmd_AddCommand("+moveup", IN_UpDown);
|
||||
Cmd_AddCommand("-moveup", IN_UpUp);
|
||||
Cmd_AddCommand("+movedown", IN_DownDown);
|
||||
Cmd_AddCommand("-movedown", IN_DownUp);
|
||||
Cmd_AddCommand("+left", IN_LeftDown);
|
||||
Cmd_AddCommand("-left", IN_LeftUp);
|
||||
Cmd_AddCommand("+right", IN_RightDown);
|
||||
Cmd_AddCommand("-right", IN_RightUp);
|
||||
Cmd_AddCommand("+forward", IN_ForwardDown);
|
||||
Cmd_AddCommand("-forward", IN_ForwardUp);
|
||||
Cmd_AddCommand("+back", IN_BackDown);
|
||||
Cmd_AddCommand("-back", IN_BackUp);
|
||||
Cmd_AddCommand("+lookup", IN_LookupDown);
|
||||
Cmd_AddCommand("-lookup", IN_LookupUp);
|
||||
Cmd_AddCommand("+lookdown", IN_LookdownDown);
|
||||
Cmd_AddCommand("-lookdown", IN_LookdownUp);
|
||||
Cmd_AddCommand("+strafe", IN_StrafeDown);
|
||||
Cmd_AddCommand("-strafe", IN_StrafeUp);
|
||||
Cmd_AddCommand("+moveleft", IN_MoveleftDown);
|
||||
Cmd_AddCommand("-moveleft", IN_MoveleftUp);
|
||||
Cmd_AddCommand("+moveright", IN_MoverightDown);
|
||||
Cmd_AddCommand("-moveright", IN_MoverightUp);
|
||||
Cmd_AddCommand("+speed", IN_SpeedDown);
|
||||
Cmd_AddCommand("-speed", IN_SpeedUp);
|
||||
Cmd_AddCommand("+attack", IN_AttackDown);
|
||||
Cmd_AddCommand("-attack", IN_AttackUp);
|
||||
Cmd_AddCommand("+use", IN_UseDown);
|
||||
Cmd_AddCommand("-use", IN_UseUp);
|
||||
Cmd_AddCommand("+jump", IN_JumpDown);
|
||||
Cmd_AddCommand("-jump", IN_JumpUp);
|
||||
Cmd_AddCommand("impulse", IN_Impulse);
|
||||
Cmd_AddCommand("+klook", IN_KLookDown);
|
||||
Cmd_AddCommand("-klook", IN_KLookUp);
|
||||
Cmd_AddCommand("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand("-mlook", IN_MLookUp);
|
||||
|
||||
}
|
||||
|
||||
|
|
506
source/cl_main.c
506
source/cl_main.c
|
@ -31,19 +31,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
cvar_t cl_name = {"_cl_name", "player", CVAR_ARCHIVE};
|
||||
cvar_t cl_color = {"_cl_color", "0", CVAR_ARCHIVE};
|
||||
|
||||
cvar_t cl_shownet = {"cl_shownet","0",CVAR_NONE}; // can be 0, 1, or 2
|
||||
cvar_t cl_nolerp = {"cl_nolerp","0",CVAR_NONE};
|
||||
cvar_t cl_shownet = {"cl_shownet", "0", CVAR_NONE}; // can be 0, 1, or 2
|
||||
cvar_t cl_nolerp = {"cl_nolerp", "0", CVAR_NONE};
|
||||
|
||||
cvar_t cfg_unbindall = {"cfg_unbindall", "1", CVAR_ARCHIVE};
|
||||
|
||||
cvar_t lookspring = {"lookspring","0", CVAR_ARCHIVE};
|
||||
cvar_t lookstrafe = {"lookstrafe","0", CVAR_ARCHIVE};
|
||||
cvar_t sensitivity = {"sensitivity","3", CVAR_ARCHIVE};
|
||||
cvar_t lookspring = {"lookspring", "0", CVAR_ARCHIVE};
|
||||
cvar_t lookstrafe = {"lookstrafe", "0", CVAR_ARCHIVE};
|
||||
cvar_t sensitivity = {"sensitivity", "3", CVAR_ARCHIVE};
|
||||
|
||||
cvar_t m_pitch = {"m_pitch","0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_yaw = {"m_yaw","0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_forward = {"m_forward","1", CVAR_ARCHIVE};
|
||||
cvar_t m_side = {"m_side","0.8", CVAR_ARCHIVE};
|
||||
cvar_t m_pitch = {"m_pitch", "0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_yaw = {"m_yaw", "0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_forward = {"m_forward", "1", CVAR_ARCHIVE};
|
||||
cvar_t m_side = {"m_side", "0.8", CVAR_ARCHIVE};
|
||||
|
||||
cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
|
||||
cvar_t cl_minpitch = {"cl_minpitch", "-90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
|
||||
|
@ -69,25 +69,25 @@ CL_ClearState
|
|||
|
||||
=====================
|
||||
*/
|
||||
void CL_ClearState (void)
|
||||
void CL_ClearState(void)
|
||||
{
|
||||
if (!sv.active)
|
||||
Host_ClearMemory ();
|
||||
if(!sv.active)
|
||||
Host_ClearMemory();
|
||||
|
||||
// wipe the entire cl structure
|
||||
memset (&cl, 0, sizeof(cl));
|
||||
memset(&cl, 0, sizeof(cl));
|
||||
|
||||
SZ_Clear (&cls.message);
|
||||
SZ_Clear(&cls.message);
|
||||
|
||||
// clear other arrays
|
||||
memset (cl_dlights, 0, sizeof(cl_dlights));
|
||||
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
memset (cl_temp_entities, 0, sizeof(cl_temp_entities));
|
||||
memset (cl_beams, 0, sizeof(cl_beams));
|
||||
memset(cl_dlights, 0, sizeof(cl_dlights));
|
||||
memset(cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
memset(cl_temp_entities, 0, sizeof(cl_temp_entities));
|
||||
memset(cl_beams, 0, sizeof(cl_beams));
|
||||
|
||||
//johnfitz -- cl_entities is now dynamically allocated
|
||||
cl_max_edicts = CLAMP (MIN_EDICTS,(int32_t)max_edicts.value,MAX_EDICTS);
|
||||
cl_entities = (entity_t *) Hunk_AllocName (cl_max_edicts*sizeof(entity_t), "cl_entities");
|
||||
cl_max_edicts = CLAMP(MIN_EDICTS, (int32_t)max_edicts.value, MAX_EDICTS);
|
||||
cl_entities = (entity_t *) Hunk_AllocName(cl_max_edicts * sizeof(entity_t), "cl_entities");
|
||||
//johnfitz
|
||||
}
|
||||
|
||||
|
@ -99,32 +99,32 @@ Sends a disconnect message to the server
|
|||
This is also called on Host_Error, so it shouldn't cause any errors
|
||||
=====================
|
||||
*/
|
||||
void CL_Disconnect (void)
|
||||
void CL_Disconnect(void)
|
||||
{
|
||||
if (key_dest == key_message)
|
||||
Key_EndChat (); // don't get stuck in chat mode
|
||||
if(key_dest == key_message)
|
||||
Key_EndChat(); // don't get stuck in chat mode
|
||||
|
||||
// stop sounds (especially looping!)
|
||||
S_StopAllSounds (true);
|
||||
S_StopAllSounds(true);
|
||||
BGM_Stop();
|
||||
|
||||
// if running a local server, shut it down
|
||||
if (cls.demoplayback)
|
||||
CL_StopPlayback ();
|
||||
else if (cls.state == ca_connected)
|
||||
if(cls.demoplayback)
|
||||
CL_StopPlayback();
|
||||
else if(cls.state == ca_connected)
|
||||
{
|
||||
if (cls.demorecording)
|
||||
CL_Stop_f ();
|
||||
if(cls.demorecording)
|
||||
CL_Stop_f();
|
||||
|
||||
Con_DPrintf ("Sending clc_disconnect\n");
|
||||
SZ_Clear (&cls.message);
|
||||
MSG_WriteByte (&cls.message, clc_disconnect);
|
||||
NET_SendUnreliableMessage (cls.netcon, &cls.message);
|
||||
SZ_Clear (&cls.message);
|
||||
NET_Close (cls.netcon);
|
||||
Con_DPrintf("Sending clc_disconnect\n");
|
||||
SZ_Clear(&cls.message);
|
||||
MSG_WriteByte(&cls.message, clc_disconnect);
|
||||
NET_SendUnreliableMessage(cls.netcon, &cls.message);
|
||||
SZ_Clear(&cls.message);
|
||||
NET_Close(cls.netcon);
|
||||
|
||||
cls.state = ca_disconnected;
|
||||
if (sv.active)
|
||||
if(sv.active)
|
||||
Host_ShutdownServer(false);
|
||||
}
|
||||
|
||||
|
@ -134,11 +134,11 @@ void CL_Disconnect (void)
|
|||
cl.intermission = 0;
|
||||
}
|
||||
|
||||
void CL_Disconnect_f (void)
|
||||
void CL_Disconnect_f(void)
|
||||
{
|
||||
CL_Disconnect ();
|
||||
if (sv.active)
|
||||
Host_ShutdownServer (false);
|
||||
CL_Disconnect();
|
||||
if(sv.active)
|
||||
Host_ShutdownServer(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,25 +149,25 @@ CL_EstablishConnection
|
|||
Host should be either "local" or a net address to be passed on
|
||||
=====================
|
||||
*/
|
||||
void CL_EstablishConnection (const char *host)
|
||||
void CL_EstablishConnection(const char *host)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if(cls.state == ca_dedicated)
|
||||
return;
|
||||
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
return;
|
||||
|
||||
CL_Disconnect ();
|
||||
CL_Disconnect();
|
||||
|
||||
cls.netcon = NET_Connect (host);
|
||||
if (!cls.netcon)
|
||||
Host_Error ("CL_Connect: connect failed\n");
|
||||
Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
|
||||
cls.netcon = NET_Connect(host);
|
||||
if(!cls.netcon)
|
||||
Host_Error("CL_Connect: connect failed\n");
|
||||
Con_DPrintf("CL_EstablishConnection: connected to %s\n", host);
|
||||
|
||||
cls.demonum = -1; // not in the demo loop now
|
||||
cls.state = ca_connected;
|
||||
cls.signon = 0; // need all the signon messages before playing
|
||||
MSG_WriteByte (&cls.message, clc_nop); // NAT Fix from ProQuake
|
||||
MSG_WriteByte(&cls.message, clc_nop); // NAT Fix from ProQuake
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -177,39 +177,39 @@ CL_SignonReply
|
|||
An svc_signonnum has been received, perform a client side setup
|
||||
=====================
|
||||
*/
|
||||
void CL_SignonReply (void)
|
||||
void CL_SignonReply(void)
|
||||
{
|
||||
char str[8192];
|
||||
|
||||
Con_DPrintf ("CL_SignonReply: %" PRIi32 "\n", cls.signon);
|
||||
Con_DPrintf("CL_SignonReply: %" PRIi32 "\n", cls.signon);
|
||||
|
||||
switch (cls.signon)
|
||||
switch(cls.signon)
|
||||
{
|
||||
case 1:
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.message, "prespawn");
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
MSG_WriteString(&cls.message, "prespawn");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
MSG_WriteString(&cls.message, va("name \"%s\"\n", cl_name.string));
|
||||
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.message, va("color %" PRIi32 " %" PRIi32 "\n", ((int32_t)cl_color.value)>>4, ((int32_t)cl_color.value)&15));
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
MSG_WriteString(&cls.message, va("color %" PRIi32 " %" PRIi32 "\n", ((int32_t)cl_color.value) >> 4, ((int32_t)cl_color.value) & 15));
|
||||
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
sprintf (str, "spawn %s", cls.spawnparms);
|
||||
MSG_WriteString (&cls.message, str);
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
sprintf(str, "spawn %s", cls.spawnparms);
|
||||
MSG_WriteString(&cls.message, str);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.message, "begin");
|
||||
Cache_Report (); // print remaining memory
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
MSG_WriteString(&cls.message, "begin");
|
||||
Cache_Report(); // print remaining memory
|
||||
break;
|
||||
|
||||
case 4:
|
||||
SCR_EndLoadingPlaque (); // allow normal screen updates
|
||||
SCR_EndLoadingPlaque(); // allow normal screen updates
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -221,29 +221,29 @@ CL_NextDemo
|
|||
Called to play the next demo in the demo loop
|
||||
=====================
|
||||
*/
|
||||
void CL_NextDemo (void)
|
||||
void CL_NextDemo(void)
|
||||
{
|
||||
char str[1024];
|
||||
|
||||
if (cls.demonum == -1)
|
||||
if(cls.demonum == -1)
|
||||
return; // don't play demos
|
||||
|
||||
if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
|
||||
if(!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
|
||||
{
|
||||
cls.demonum = 0;
|
||||
if (!cls.demos[cls.demonum][0])
|
||||
if(!cls.demos[cls.demonum][0])
|
||||
{
|
||||
Con_Printf ("No demos listed with startdemos\n");
|
||||
Con_Printf("No demos listed with startdemos\n");
|
||||
cls.demonum = -1;
|
||||
CL_Disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SCR_BeginLoadingPlaque ();
|
||||
SCR_BeginLoadingPlaque();
|
||||
|
||||
sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
|
||||
Cbuf_InsertText (str);
|
||||
sprintf(str, "playdemo %s\n", cls.demos[cls.demonum]);
|
||||
Cbuf_InsertText(str);
|
||||
cls.demonum++;
|
||||
}
|
||||
|
||||
|
@ -252,24 +252,24 @@ void CL_NextDemo (void)
|
|||
CL_PrintEntities_f
|
||||
==============
|
||||
*/
|
||||
void CL_PrintEntities_f (void)
|
||||
void CL_PrintEntities_f(void)
|
||||
{
|
||||
entity_t *ent;
|
||||
int32_t i;
|
||||
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
return;
|
||||
|
||||
for (i=0,ent=cl_entities ; i<cl.num_entities ; i++,ent++)
|
||||
for(i = 0, ent = cl_entities ; i < cl.num_entities ; i++, ent++)
|
||||
{
|
||||
Con_Printf ("%3" PRIi32 ":",i);
|
||||
if (!ent->model)
|
||||
Con_Printf("%3" PRIi32 ":", i);
|
||||
if(!ent->model)
|
||||
{
|
||||
Con_Printf ("EMPTY\n");
|
||||
Con_Printf("EMPTY\n");
|
||||
continue;
|
||||
}
|
||||
Con_Printf ("%s:%2" PRIi32 " (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
|
||||
,ent->model->name,ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
|
||||
Con_Printf("%s:%2" PRIi32 " (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
|
||||
, ent->model->name, ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,20 +279,20 @@ CL_AllocDlight
|
|||
|
||||
===============
|
||||
*/
|
||||
dlight_t *CL_AllocDlight (int32_t key)
|
||||
dlight_t *CL_AllocDlight(int32_t key)
|
||||
{
|
||||
int32_t i;
|
||||
dlight_t *dl;
|
||||
|
||||
// first look for an exact key match
|
||||
if (key)
|
||||
if(key)
|
||||
{
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
for(i = 0 ; i < MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->key == key)
|
||||
if(dl->key == key)
|
||||
{
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
memset(dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
dl->color[0] = dl->color[1] = dl->color[2] = 1; //johnfitz -- lit support via lordhavoc
|
||||
return dl;
|
||||
|
@ -302,11 +302,11 @@ dlight_t *CL_AllocDlight (int32_t key)
|
|||
|
||||
// then look for anything else
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
for(i = 0 ; i < MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->die < cl.time)
|
||||
if(dl->die < cl.time)
|
||||
{
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
memset(dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
dl->color[0] = dl->color[1] = dl->color[2] = 1; //johnfitz -- lit support via lordhavoc
|
||||
return dl;
|
||||
|
@ -314,7 +314,7 @@ dlight_t *CL_AllocDlight (int32_t key)
|
|||
}
|
||||
|
||||
dl = &cl_dlights[0];
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
memset(dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
dl->color[0] = dl->color[1] = dl->color[2] = 1; //johnfitz -- lit support via lordhavoc
|
||||
return dl;
|
||||
|
@ -327,7 +327,7 @@ CL_DecayLights
|
|||
|
||||
===============
|
||||
*/
|
||||
void CL_DecayLights (void)
|
||||
void CL_DecayLights(void)
|
||||
{
|
||||
int32_t i;
|
||||
dlight_t *dl;
|
||||
|
@ -336,13 +336,13 @@ void CL_DecayLights (void)
|
|||
time = cl.time - cl.oldtime;
|
||||
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
for(i = 0 ; i < MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->die < cl.time || !dl->radius)
|
||||
if(dl->die < cl.time || !dl->radius)
|
||||
continue;
|
||||
|
||||
dl->radius -= time*dl->decay;
|
||||
if (dl->radius < 0)
|
||||
dl->radius -= time * dl->decay;
|
||||
if(dl->radius < 0)
|
||||
dl->radius = 0;
|
||||
}
|
||||
}
|
||||
|
@ -356,19 +356,19 @@ Determines the fraction between the last two messages that the objects
|
|||
should be put at.
|
||||
===============
|
||||
*/
|
||||
float CL_LerpPoint (void)
|
||||
float CL_LerpPoint(void)
|
||||
{
|
||||
float f, frac;
|
||||
|
||||
f = cl.mtime[0] - cl.mtime[1];
|
||||
|
||||
if (!f || cls.timedemo || sv.active)
|
||||
if(!f || cls.timedemo || sv.active)
|
||||
{
|
||||
cl.time = cl.mtime[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (f > 0.1) // dropped packet, or start of demo
|
||||
if(f > 0.1) // dropped packet, or start of demo
|
||||
{
|
||||
cl.mtime[1] = cl.mtime[0] - 0.1;
|
||||
f = 0.1;
|
||||
|
@ -376,21 +376,21 @@ float CL_LerpPoint (void)
|
|||
|
||||
frac = (cl.time - cl.mtime[1]) / f;
|
||||
|
||||
if (frac < 0)
|
||||
if(frac < 0)
|
||||
{
|
||||
if (frac < -0.01)
|
||||
if(frac < -0.01)
|
||||
cl.time = cl.mtime[1];
|
||||
frac = 0;
|
||||
}
|
||||
else if (frac > 1)
|
||||
else if(frac > 1)
|
||||
{
|
||||
if (frac > 1.01)
|
||||
if(frac > 1.01)
|
||||
cl.time = cl.mtime[0];
|
||||
frac = 1;
|
||||
}
|
||||
|
||||
//johnfitz -- better nolerp behavior
|
||||
if (cl_nolerp.value)
|
||||
if(cl_nolerp.value)
|
||||
return 1;
|
||||
//johnfitz
|
||||
|
||||
|
@ -402,7 +402,7 @@ float CL_LerpPoint (void)
|
|||
CL_RelinkEntities
|
||||
===============
|
||||
*/
|
||||
void CL_RelinkEntities (void)
|
||||
void CL_RelinkEntities(void)
|
||||
{
|
||||
entity_t *ent;
|
||||
int32_t i, j;
|
||||
|
@ -413,38 +413,39 @@ void CL_RelinkEntities (void)
|
|||
dlight_t *dl;
|
||||
|
||||
// determine partial update time
|
||||
frac = CL_LerpPoint ();
|
||||
frac = CL_LerpPoint();
|
||||
|
||||
cl_numvisedicts = 0;
|
||||
|
||||
//
|
||||
// interpolate player info
|
||||
//
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
cl.velocity[i] = cl.mvelocity[1][i] +
|
||||
frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
|
||||
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
{
|
||||
// interpolate the angles
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
{
|
||||
d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
|
||||
if (d > 180)
|
||||
if(d > 180)
|
||||
d -= 360;
|
||||
else if (d < -180)
|
||||
else if(d < -180)
|
||||
d += 360;
|
||||
cl.viewangles[j] = cl.mviewangles[1][j] + frac*d;
|
||||
cl.viewangles[j] = cl.mviewangles[1][j] + frac * d;
|
||||
}
|
||||
}
|
||||
|
||||
bobjrotate = anglemod(100*cl.time);
|
||||
bobjrotate = anglemod(100 * cl.time);
|
||||
|
||||
// start on the entity after the world
|
||||
for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
|
||||
for(i = 1, ent = cl_entities + 1 ; i < cl.num_entities ; i++, ent++)
|
||||
{
|
||||
if (!ent->model)
|
||||
{ // empty slot
|
||||
if(!ent->model)
|
||||
{
|
||||
// empty slot
|
||||
|
||||
// ericw -- efrags are only used for static entities in GLQuake
|
||||
// ent can't be static, so this is a no-op.
|
||||
|
@ -454,28 +455,30 @@ void CL_RelinkEntities (void)
|
|||
}
|
||||
|
||||
// if the object wasn't included in the last packet, remove it
|
||||
if (ent->msgtime != cl.mtime[0])
|
||||
if(ent->msgtime != cl.mtime[0])
|
||||
{
|
||||
ent->model = NULL;
|
||||
ent->lerpflags |= LERP_RESETMOVE|LERP_RESETANIM; //johnfitz -- next time this entity slot is reused, the lerp will need to be reset
|
||||
ent->lerpflags |= LERP_RESETMOVE | LERP_RESETANIM; //johnfitz -- next time this entity slot is reused, the lerp will need to be reset
|
||||
continue;
|
||||
}
|
||||
|
||||
VectorCopy (ent->origin, oldorg);
|
||||
VectorCopy(ent->origin, oldorg);
|
||||
|
||||
if (ent->forcelink)
|
||||
{ // the entity was not updated in the last message
|
||||
if(ent->forcelink)
|
||||
{
|
||||
// the entity was not updated in the last message
|
||||
// so move to the final spot
|
||||
VectorCopy (ent->msg_origins[0], ent->origin);
|
||||
VectorCopy (ent->msg_angles[0], ent->angles);
|
||||
VectorCopy(ent->msg_origins[0], ent->origin);
|
||||
VectorCopy(ent->msg_angles[0], ent->angles);
|
||||
}
|
||||
else
|
||||
{ // if the delta is large, assume a teleport and don't lerp
|
||||
{
|
||||
// if the delta is large, assume a teleport and don't lerp
|
||||
f = frac;
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
{
|
||||
delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
|
||||
if (delta[j] > 100 || delta[j] < -100)
|
||||
if(delta[j] > 100 || delta[j] < -100)
|
||||
{
|
||||
f = 1; // assume a teleportation, not a motion
|
||||
ent->lerpflags |= LERP_RESETMOVE; //johnfitz -- don't lerp teleports
|
||||
|
@ -483,98 +486,98 @@ void CL_RelinkEntities (void)
|
|||
}
|
||||
|
||||
//johnfitz -- don't cl_lerp entities that will be r_lerped
|
||||
if (r_lerpmove.value && (ent->lerpflags & LERP_MOVESTEP))
|
||||
if(r_lerpmove.value && (ent->lerpflags & LERP_MOVESTEP))
|
||||
f = 1;
|
||||
//johnfitz
|
||||
|
||||
// interpolate the origin and angles
|
||||
for (j=0 ; j<3 ; j++)
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
{
|
||||
ent->origin[j] = ent->msg_origins[1][j] + f*delta[j];
|
||||
ent->origin[j] = ent->msg_origins[1][j] + f * delta[j];
|
||||
|
||||
d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
|
||||
if (d > 180)
|
||||
if(d > 180)
|
||||
d -= 360;
|
||||
else if (d < -180)
|
||||
else if(d < -180)
|
||||
d += 360;
|
||||
ent->angles[j] = ent->msg_angles[1][j] + f*d;
|
||||
ent->angles[j] = ent->msg_angles[1][j] + f * d;
|
||||
}
|
||||
}
|
||||
|
||||
// rotate binary objects locally
|
||||
if (ent->model->flags & EF_ROTATE)
|
||||
if(ent->model->flags & EF_ROTATE)
|
||||
ent->angles[1] = bobjrotate;
|
||||
|
||||
if (ent->effects & EF_BRIGHTFIELD)
|
||||
R_EntityParticles (ent);
|
||||
if(ent->effects & EF_BRIGHTFIELD)
|
||||
R_EntityParticles(ent);
|
||||
|
||||
if (ent->effects & EF_MUZZLEFLASH)
|
||||
if(ent->effects & EF_MUZZLEFLASH)
|
||||
{
|
||||
vec3_t fv, rv, uv;
|
||||
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl = CL_AllocDlight(i);
|
||||
VectorCopy(ent->origin, dl->origin);
|
||||
dl->origin[2] += 16;
|
||||
AngleVectors (ent->angles, fv, rv, uv);
|
||||
AngleVectors(ent->angles, fv, rv, uv);
|
||||
|
||||
VectorMA (dl->origin, 18, fv, dl->origin);
|
||||
dl->radius = 200 + (rand()&31);
|
||||
VectorMA(dl->origin, 18, fv, dl->origin);
|
||||
dl->radius = 200 + (rand() & 31);
|
||||
dl->minlight = 32;
|
||||
dl->die = cl.time + 0.1;
|
||||
|
||||
//johnfitz -- assume muzzle flash accompanied by muzzle flare, which looks bad when lerped
|
||||
if (r_lerpmodels.value != 2)
|
||||
if(r_lerpmodels.value != 2)
|
||||
{
|
||||
if (ent == &cl_entities[cl.viewentity])
|
||||
cl.viewent.lerpflags |= LERP_RESETANIM|LERP_RESETANIM2; //no lerping for two frames
|
||||
if(ent == &cl_entities[cl.viewentity])
|
||||
cl.viewent.lerpflags |= LERP_RESETANIM | LERP_RESETANIM2; //no lerping for two frames
|
||||
else
|
||||
ent->lerpflags |= LERP_RESETANIM|LERP_RESETANIM2; //no lerping for two frames
|
||||
ent->lerpflags |= LERP_RESETANIM | LERP_RESETANIM2; //no lerping for two frames
|
||||
}
|
||||
//johnfitz
|
||||
}
|
||||
if (ent->effects & EF_BRIGHTLIGHT)
|
||||
if(ent->effects & EF_BRIGHTLIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl = CL_AllocDlight(i);
|
||||
VectorCopy(ent->origin, dl->origin);
|
||||
dl->origin[2] += 16;
|
||||
dl->radius = 400 + (rand()&31);
|
||||
dl->radius = 400 + (rand() & 31);
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
if (ent->effects & EF_DIMLIGHT)
|
||||
if(ent->effects & EF_DIMLIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->radius = 200 + (rand()&31);
|
||||
dl = CL_AllocDlight(i);
|
||||
VectorCopy(ent->origin, dl->origin);
|
||||
dl->radius = 200 + (rand() & 31);
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
|
||||
if (ent->model->flags & EF_GIB)
|
||||
R_RocketTrail (oldorg, ent->origin, 2);
|
||||
else if (ent->model->flags & EF_ZOMGIB)
|
||||
R_RocketTrail (oldorg, ent->origin, 4);
|
||||
else if (ent->model->flags & EF_TRACER)
|
||||
R_RocketTrail (oldorg, ent->origin, 3);
|
||||
else if (ent->model->flags & EF_TRACER2)
|
||||
R_RocketTrail (oldorg, ent->origin, 5);
|
||||
else if (ent->model->flags & EF_ROCKET)
|
||||
if(ent->model->flags & EF_GIB)
|
||||
R_RocketTrail(oldorg, ent->origin, 2);
|
||||
else if(ent->model->flags & EF_ZOMGIB)
|
||||
R_RocketTrail(oldorg, ent->origin, 4);
|
||||
else if(ent->model->flags & EF_TRACER)
|
||||
R_RocketTrail(oldorg, ent->origin, 3);
|
||||
else if(ent->model->flags & EF_TRACER2)
|
||||
R_RocketTrail(oldorg, ent->origin, 5);
|
||||
else if(ent->model->flags & EF_ROCKET)
|
||||
{
|
||||
R_RocketTrail (oldorg, ent->origin, 0);
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
R_RocketTrail(oldorg, ent->origin, 0);
|
||||
dl = CL_AllocDlight(i);
|
||||
VectorCopy(ent->origin, dl->origin);
|
||||
dl->radius = 200;
|
||||
dl->die = cl.time + 0.01;
|
||||
}
|
||||
else if (ent->model->flags & EF_GRENADE)
|
||||
R_RocketTrail (oldorg, ent->origin, 1);
|
||||
else if (ent->model->flags & EF_TRACER3)
|
||||
R_RocketTrail (oldorg, ent->origin, 6);
|
||||
else if(ent->model->flags & EF_GRENADE)
|
||||
R_RocketTrail(oldorg, ent->origin, 1);
|
||||
else if(ent->model->flags & EF_TRACER3)
|
||||
R_RocketTrail(oldorg, ent->origin, 6);
|
||||
|
||||
ent->forcelink = false;
|
||||
|
||||
if (i == cl.viewentity && !chase_active.value)
|
||||
if(i == cl.viewentity && !chase_active.value)
|
||||
continue;
|
||||
|
||||
if (cl_numvisedicts < MAX_VISEDICTS)
|
||||
if(cl_numvisedicts < MAX_VISEDICTS)
|
||||
{
|
||||
cl_visedicts[cl_numvisedicts] = ent;
|
||||
cl_numvisedicts++;
|
||||
|
@ -590,7 +593,7 @@ CL_ReadFromServer
|
|||
Read all incoming data from the server
|
||||
===============
|
||||
*/
|
||||
int32_t CL_ReadFromServer (void)
|
||||
int32_t CL_ReadFromServer(void)
|
||||
{
|
||||
int32_t ret;
|
||||
extern int32_t num_temp_entities; //johnfitz
|
||||
|
@ -606,51 +609,52 @@ int32_t CL_ReadFromServer (void)
|
|||
|
||||
do
|
||||
{
|
||||
ret = CL_GetMessage ();
|
||||
if (ret == -1)
|
||||
Host_Error ("CL_ReadFromServer: lost server connection");
|
||||
if (!ret)
|
||||
ret = CL_GetMessage();
|
||||
if(ret == -1)
|
||||
Host_Error("CL_ReadFromServer: lost server connection");
|
||||
if(!ret)
|
||||
break;
|
||||
|
||||
cl.last_received_message = realtime;
|
||||
CL_ParseServerMessage ();
|
||||
} while (ret && cls.state == ca_connected);
|
||||
CL_ParseServerMessage();
|
||||
}
|
||||
while(ret && cls.state == ca_connected);
|
||||
|
||||
if (cl_shownet.value)
|
||||
Con_Printf ("\n");
|
||||
if(cl_shownet.value)
|
||||
Con_Printf("\n");
|
||||
|
||||
CL_RelinkEntities ();
|
||||
CL_UpdateTEnts ();
|
||||
CL_RelinkEntities();
|
||||
CL_UpdateTEnts();
|
||||
|
||||
//johnfitz -- devstats
|
||||
|
||||
//visedicts
|
||||
if (cl_numvisedicts > 256 && dev_peakstats.visedicts <= 256)
|
||||
Con_DWarning ("%" PRIi32 " visedicts exceeds standard limit of 256 (max = %" PRIi32 ").\n", cl_numvisedicts, MAX_VISEDICTS);
|
||||
if(cl_numvisedicts > 256 && dev_peakstats.visedicts <= 256)
|
||||
Con_DWarning("%" PRIi32 " visedicts exceeds standard limit of 256 (max = %" PRIi32 ").\n", cl_numvisedicts, MAX_VISEDICTS);
|
||||
dev_stats.visedicts = cl_numvisedicts;
|
||||
dev_peakstats.visedicts = q_max(cl_numvisedicts, dev_peakstats.visedicts);
|
||||
|
||||
//temp entities
|
||||
if (num_temp_entities > 64 && dev_peakstats.tempents <= 64)
|
||||
Con_DWarning ("%" PRIi32 " tempentities exceeds standard limit of 64 (max = %" PRIi32 ").\n", num_temp_entities, MAX_TEMP_ENTITIES);
|
||||
if(num_temp_entities > 64 && dev_peakstats.tempents <= 64)
|
||||
Con_DWarning("%" PRIi32 " tempentities exceeds standard limit of 64 (max = %" PRIi32 ").\n", num_temp_entities, MAX_TEMP_ENTITIES);
|
||||
dev_stats.tempents = num_temp_entities;
|
||||
dev_peakstats.tempents = q_max(num_temp_entities, dev_peakstats.tempents);
|
||||
|
||||
//beams
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
if (b->model && b->endtime >= cl.time)
|
||||
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
|
||||
if(b->model && b->endtime >= cl.time)
|
||||
num_beams++;
|
||||
if (num_beams > 24 && dev_peakstats.beams <= 24)
|
||||
Con_DWarning ("%" PRIi32 " beams exceeded standard limit of 24 (max = %" PRIi32 ").\n", num_beams, MAX_BEAMS);
|
||||
if(num_beams > 24 && dev_peakstats.beams <= 24)
|
||||
Con_DWarning("%" PRIi32 " beams exceeded standard limit of 24 (max = %" PRIi32 ").\n", num_beams, MAX_BEAMS);
|
||||
dev_stats.beams = num_beams;
|
||||
dev_peakstats.beams = q_max(num_beams, dev_peakstats.beams);
|
||||
|
||||
//dlights
|
||||
for (i=0, l=cl_dlights ; i<MAX_DLIGHTS ; i++, l++)
|
||||
if (l->die >= cl.time && l->radius)
|
||||
for(i = 0, l = cl_dlights ; i < MAX_DLIGHTS ; i++, l++)
|
||||
if(l->die >= cl.time && l->radius)
|
||||
num_dlights++;
|
||||
if (num_dlights > 32 && dev_peakstats.dlights <= 32)
|
||||
Con_DWarning ("%" PRIi32 " dlights exceeded standard limit of 32 (max = %" PRIi32 ").\n", num_dlights, MAX_DLIGHTS);
|
||||
if(num_dlights > 32 && dev_peakstats.dlights <= 32)
|
||||
Con_DWarning("%" PRIi32 " dlights exceeded standard limit of 32 (max = %" PRIi32 ").\n", num_dlights, MAX_DLIGHTS);
|
||||
dev_stats.dlights = num_dlights;
|
||||
dev_peakstats.dlights = q_max(num_dlights, dev_peakstats.dlights);
|
||||
|
||||
|
@ -667,45 +671,45 @@ int32_t CL_ReadFromServer (void)
|
|||
CL_SendCmd
|
||||
=================
|
||||
*/
|
||||
void CL_SendCmd (void)
|
||||
void CL_SendCmd(void)
|
||||
{
|
||||
usercmd_t cmd;
|
||||
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
return;
|
||||
|
||||
if (cls.signon == SIGNONS)
|
||||
if(cls.signon == SIGNONS)
|
||||
{
|
||||
// get basic movement from keyboard
|
||||
CL_BaseMove (&cmd);
|
||||
CL_BaseMove(&cmd);
|
||||
|
||||
// allow mice or other external controllers to add to the move
|
||||
IN_Move (&cmd);
|
||||
IN_Move(&cmd);
|
||||
|
||||
// send the unreliable message
|
||||
CL_SendMove (&cmd);
|
||||
CL_SendMove(&cmd);
|
||||
}
|
||||
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
{
|
||||
SZ_Clear (&cls.message);
|
||||
SZ_Clear(&cls.message);
|
||||
return;
|
||||
}
|
||||
|
||||
// send the reliable message
|
||||
if (!cls.message.cursize)
|
||||
if(!cls.message.cursize)
|
||||
return; // no message at all
|
||||
|
||||
if (!NET_CanSendMessage (cls.netcon))
|
||||
if(!NET_CanSendMessage(cls.netcon))
|
||||
{
|
||||
Con_DPrintf ("CL_SendCmd: can't send\n");
|
||||
Con_DPrintf("CL_SendCmd: can't send\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NET_SendMessage (cls.netcon, &cls.message) == -1)
|
||||
Host_Error ("CL_SendCmd: lost server connection");
|
||||
if(NET_SendMessage(cls.netcon, &cls.message) == -1)
|
||||
Host_Error("CL_SendCmd: lost server connection");
|
||||
|
||||
SZ_Clear (&cls.message);
|
||||
SZ_Clear(&cls.message);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -715,20 +719,20 @@ CL_Tracepos_f -- johnfitz
|
|||
display impact point of trace along VPN
|
||||
=============
|
||||
*/
|
||||
void CL_Tracepos_f (void)
|
||||
void CL_Tracepos_f(void)
|
||||
{
|
||||
vec3_t v, w;
|
||||
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
return;
|
||||
|
||||
VectorMA(r_refdef.vieworg, 8192.0, vpn, v);
|
||||
TraceLine(r_refdef.vieworg, v, w);
|
||||
|
||||
if (VectorLength(w) == 0)
|
||||
Con_Printf ("Tracepos: trace didn't hit anything\n");
|
||||
if(VectorLength(w) == 0)
|
||||
Con_Printf("Tracepos: trace didn't hit anything\n");
|
||||
else
|
||||
Con_Printf ("Tracepos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ")\n", (int32_t)w[0], (int32_t)w[1], (int32_t)w[2]);
|
||||
Con_Printf("Tracepos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ")\n", (int32_t)w[0], (int32_t)w[1], (int32_t)w[2]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -738,13 +742,13 @@ CL_Viewpos_f -- johnfitz
|
|||
display client's position and angles
|
||||
=============
|
||||
*/
|
||||
void CL_Viewpos_f (void)
|
||||
void CL_Viewpos_f(void)
|
||||
{
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
return;
|
||||
#if 0
|
||||
//camera position
|
||||
Con_Printf ("Viewpos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ") %" PRIi32 " %" PRIi32 " %" PRIi32 "\n",
|
||||
Con_Printf("Viewpos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ") %" PRIi32 " %" PRIi32 " %" PRIi32 "\n",
|
||||
(int32_t)r_refdef.vieworg[0],
|
||||
(int32_t)r_refdef.vieworg[1],
|
||||
(int32_t)r_refdef.vieworg[2],
|
||||
|
@ -753,7 +757,7 @@ void CL_Viewpos_f (void)
|
|||
(int32_t)r_refdef.viewangles[ROLL]);
|
||||
#else
|
||||
//player position
|
||||
Con_Printf ("Viewpos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ") %" PRIi32 " %" PRIi32 " %" PRIi32 "\n",
|
||||
Con_Printf("Viewpos: (%" PRIi32 " %" PRIi32 " %" PRIi32 ") %" PRIi32 " %" PRIi32 " %" PRIi32 "\n",
|
||||
(int32_t)cl_entities[cl.viewentity].origin[0],
|
||||
(int32_t)cl_entities[cl.viewentity].origin[1],
|
||||
(int32_t)cl_entities[cl.viewentity].origin[2],
|
||||
|
@ -768,49 +772,49 @@ void CL_Viewpos_f (void)
|
|||
CL_Init
|
||||
=================
|
||||
*/
|
||||
void CL_Init (void)
|
||||
void CL_Init(void)
|
||||
{
|
||||
SZ_Alloc (&cls.message, 1024);
|
||||
SZ_Alloc(&cls.message, 1024);
|
||||
|
||||
CL_InitInput ();
|
||||
CL_InitTEnts ();
|
||||
CL_InitInput();
|
||||
CL_InitTEnts();
|
||||
|
||||
Cvar_RegisterVariable (&cl_name);
|
||||
Cvar_RegisterVariable (&cl_color);
|
||||
Cvar_RegisterVariable (&cl_upspeed);
|
||||
Cvar_RegisterVariable (&cl_forwardspeed);
|
||||
Cvar_RegisterVariable (&cl_backspeed);
|
||||
Cvar_RegisterVariable (&cl_sidespeed);
|
||||
Cvar_RegisterVariable (&cl_movespeedkey);
|
||||
Cvar_RegisterVariable (&cl_yawspeed);
|
||||
Cvar_RegisterVariable (&cl_pitchspeed);
|
||||
Cvar_RegisterVariable (&cl_anglespeedkey);
|
||||
Cvar_RegisterVariable (&cl_shownet);
|
||||
Cvar_RegisterVariable (&cl_nolerp);
|
||||
Cvar_RegisterVariable (&lookspring);
|
||||
Cvar_RegisterVariable (&lookstrafe);
|
||||
Cvar_RegisterVariable (&sensitivity);
|
||||
Cvar_RegisterVariable(&cl_name);
|
||||
Cvar_RegisterVariable(&cl_color);
|
||||
Cvar_RegisterVariable(&cl_upspeed);
|
||||
Cvar_RegisterVariable(&cl_forwardspeed);
|
||||
Cvar_RegisterVariable(&cl_backspeed);
|
||||
Cvar_RegisterVariable(&cl_sidespeed);
|
||||
Cvar_RegisterVariable(&cl_movespeedkey);
|
||||
Cvar_RegisterVariable(&cl_yawspeed);
|
||||
Cvar_RegisterVariable(&cl_pitchspeed);
|
||||
Cvar_RegisterVariable(&cl_anglespeedkey);
|
||||
Cvar_RegisterVariable(&cl_shownet);
|
||||
Cvar_RegisterVariable(&cl_nolerp);
|
||||
Cvar_RegisterVariable(&lookspring);
|
||||
Cvar_RegisterVariable(&lookstrafe);
|
||||
Cvar_RegisterVariable(&sensitivity);
|
||||
|
||||
Cvar_RegisterVariable (&cl_alwaysrun);
|
||||
Cvar_RegisterVariable(&cl_alwaysrun);
|
||||
|
||||
Cvar_RegisterVariable (&m_pitch);
|
||||
Cvar_RegisterVariable (&m_yaw);
|
||||
Cvar_RegisterVariable (&m_forward);
|
||||
Cvar_RegisterVariable (&m_side);
|
||||
Cvar_RegisterVariable(&m_pitch);
|
||||
Cvar_RegisterVariable(&m_yaw);
|
||||
Cvar_RegisterVariable(&m_forward);
|
||||
Cvar_RegisterVariable(&m_side);
|
||||
|
||||
Cvar_RegisterVariable (&cfg_unbindall);
|
||||
Cvar_RegisterVariable(&cfg_unbindall);
|
||||
|
||||
Cvar_RegisterVariable (&cl_maxpitch); //johnfitz -- variable pitch clamping
|
||||
Cvar_RegisterVariable (&cl_minpitch); //johnfitz -- variable pitch clamping
|
||||
Cvar_RegisterVariable(&cl_maxpitch); //johnfitz -- variable pitch clamping
|
||||
Cvar_RegisterVariable(&cl_minpitch); //johnfitz -- variable pitch clamping
|
||||
|
||||
Cmd_AddCommand ("entities", CL_PrintEntities_f);
|
||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
||||
Cmd_AddCommand ("record", CL_Record_f);
|
||||
Cmd_AddCommand ("stop", CL_Stop_f);
|
||||
Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
|
||||
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
|
||||
Cmd_AddCommand("entities", CL_PrintEntities_f);
|
||||
Cmd_AddCommand("disconnect", CL_Disconnect_f);
|
||||
Cmd_AddCommand("record", CL_Record_f);
|
||||
Cmd_AddCommand("stop", CL_Stop_f);
|
||||
Cmd_AddCommand("playdemo", CL_PlayDemo_f);
|
||||
Cmd_AddCommand("timedemo", CL_TimeDemo_f);
|
||||
|
||||
Cmd_AddCommand ("tracepos", CL_Tracepos_f); //johnfitz
|
||||
Cmd_AddCommand ("viewpos", CL_Viewpos_f); //johnfitz
|
||||
Cmd_AddCommand("tracepos", CL_Tracepos_f); //johnfitz
|
||||
Cmd_AddCommand("viewpos", CL_Viewpos_f); //johnfitz
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
250
source/cl_tent.c
250
source/cl_tent.c
|
@ -40,15 +40,15 @@ sfx_t *cl_sfx_r_exp3;
|
|||
CL_ParseTEnt
|
||||
=================
|
||||
*/
|
||||
void CL_InitTEnts (void)
|
||||
void CL_InitTEnts(void)
|
||||
{
|
||||
cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav");
|
||||
cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav");
|
||||
cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav");
|
||||
cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav");
|
||||
cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav");
|
||||
cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav");
|
||||
cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav");
|
||||
cl_sfx_wizhit = S_PrecacheSound("wizard/hit.wav");
|
||||
cl_sfx_knighthit = S_PrecacheSound("hknight/hit.wav");
|
||||
cl_sfx_tink1 = S_PrecacheSound("weapons/tink1.wav");
|
||||
cl_sfx_ric1 = S_PrecacheSound("weapons/ric1.wav");
|
||||
cl_sfx_ric2 = S_PrecacheSound("weapons/ric2.wav");
|
||||
cl_sfx_ric3 = S_PrecacheSound("weapons/ric3.wav");
|
||||
cl_sfx_r_exp3 = S_PrecacheSound("weapons/r_exp3.wav");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,53 +56,53 @@ void CL_InitTEnts (void)
|
|||
CL_ParseBeam
|
||||
=================
|
||||
*/
|
||||
void CL_ParseBeam (qmodel_t *m)
|
||||
void CL_ParseBeam(qmodel_t *m)
|
||||
{
|
||||
int32_t ent;
|
||||
vec3_t start, end;
|
||||
beam_t *b;
|
||||
int32_t i;
|
||||
|
||||
ent = MSG_ReadShort ();
|
||||
ent = MSG_ReadShort();
|
||||
|
||||
start[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
start[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
start[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
start[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
start[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
start[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
|
||||
end[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
end[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
end[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
end[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
end[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
end[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
|
||||
// override any beam with the same entity
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
if (b->entity == ent)
|
||||
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
|
||||
if(b->entity == ent)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = m;
|
||||
b->endtime = cl.time + 0.2;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy(start, b->start);
|
||||
VectorCopy(end, b->end);
|
||||
return;
|
||||
}
|
||||
|
||||
// find a free beam
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
if(!b->model || b->endtime < cl.time)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = m;
|
||||
b->endtime = cl.time + 0.2;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy(start, b->start);
|
||||
VectorCopy(end, b->end);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//johnfitz -- less spammy overflow message
|
||||
if (!dev_overflows.beams || dev_overflows.beams + CONSOLE_RESPAM_TIME < realtime )
|
||||
if(!dev_overflows.beams || dev_overflows.beams + CONSOLE_RESPAM_TIME < realtime)
|
||||
{
|
||||
Con_Printf ("Beam list overflow!\n");
|
||||
Con_Printf("Beam list overflow!\n");
|
||||
dev_overflows.beams = realtime;
|
||||
}
|
||||
//johnfitz
|
||||
|
@ -113,7 +113,7 @@ void CL_ParseBeam (qmodel_t *m)
|
|||
CL_ParseTEnt
|
||||
=================
|
||||
*/
|
||||
void CL_ParseTEnt (void)
|
||||
void CL_ParseTEnt(void)
|
||||
{
|
||||
int32_t type;
|
||||
vec3_t pos;
|
||||
|
@ -121,141 +121,141 @@ void CL_ParseTEnt (void)
|
|||
int32_t rnd;
|
||||
int32_t colorStart, colorLength;
|
||||
|
||||
type = MSG_ReadByte ();
|
||||
switch (type)
|
||||
type = MSG_ReadByte();
|
||||
switch(type)
|
||||
{
|
||||
case TE_WIZSPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_RunParticleEffect (pos, vec3_origin, 20, 30);
|
||||
S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_RunParticleEffect(pos, vec3_origin, 20, 30);
|
||||
S_StartSound(-1, 0, cl_sfx_wizhit, pos, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_KNIGHTSPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_RunParticleEffect (pos, vec3_origin, 226, 20);
|
||||
S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_RunParticleEffect(pos, vec3_origin, 226, 20);
|
||||
S_StartSound(-1, 0, cl_sfx_knighthit, pos, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_SPIKE: // spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_RunParticleEffect (pos, vec3_origin, 0, 10);
|
||||
if ( rand() % 5 )
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_RunParticleEffect(pos, vec3_origin, 0, 10);
|
||||
if(rand() % 5)
|
||||
S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
else
|
||||
{
|
||||
rnd = rand() & 3;
|
||||
if (rnd == 1)
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
else if (rnd == 2)
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
if(rnd == 1)
|
||||
S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
else if(rnd == 2)
|
||||
S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
else
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
}
|
||||
break;
|
||||
case TE_SUPERSPIKE: // super spike hitting wall
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_RunParticleEffect (pos, vec3_origin, 0, 20);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_RunParticleEffect(pos, vec3_origin, 0, 20);
|
||||
|
||||
if ( rand() % 5 )
|
||||
S_StartSound (-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
if(rand() % 5)
|
||||
S_StartSound(-1, 0, cl_sfx_tink1, pos, 1, 1);
|
||||
else
|
||||
{
|
||||
rnd = rand() & 3;
|
||||
if (rnd == 1)
|
||||
S_StartSound (-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
else if (rnd == 2)
|
||||
S_StartSound (-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
if(rnd == 1)
|
||||
S_StartSound(-1, 0, cl_sfx_ric1, pos, 1, 1);
|
||||
else if(rnd == 2)
|
||||
S_StartSound(-1, 0, cl_sfx_ric2, pos, 1, 1);
|
||||
else
|
||||
S_StartSound (-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
S_StartSound(-1, 0, cl_sfx_ric3, pos, 1, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case TE_GUNSHOT: // bullet hitting wall
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_RunParticleEffect (pos, vec3_origin, 0, 20);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_RunParticleEffect(pos, vec3_origin, 0, 20);
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION: // rocket explosion
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_ParticleExplosion (pos);
|
||||
dl = CL_AllocDlight (0);
|
||||
VectorCopy (pos, dl->origin);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_ParticleExplosion(pos);
|
||||
dl = CL_AllocDlight(0);
|
||||
VectorCopy(pos, dl->origin);
|
||||
dl->radius = 350;
|
||||
dl->die = cl.time + 0.5;
|
||||
dl->decay = 300;
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_TAREXPLOSION: // tarbaby explosion
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_BlobExplosion (pos);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_BlobExplosion(pos);
|
||||
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING1: // lightning bolts
|
||||
CL_ParseBeam (Mod_ForName("progs/bolt.mdl", true));
|
||||
CL_ParseBeam(Mod_ForName("progs/bolt.mdl", true));
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING2: // lightning bolts
|
||||
CL_ParseBeam (Mod_ForName("progs/bolt2.mdl", true));
|
||||
CL_ParseBeam(Mod_ForName("progs/bolt2.mdl", true));
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING3: // lightning bolts
|
||||
CL_ParseBeam (Mod_ForName("progs/bolt3.mdl", true));
|
||||
CL_ParseBeam(Mod_ForName("progs/bolt3.mdl", true));
|
||||
break;
|
||||
|
||||
// PGM 01/21/97
|
||||
case TE_BEAM: // grappling hook beam
|
||||
CL_ParseBeam (Mod_ForName("progs/beam.mdl", true));
|
||||
CL_ParseBeam(Mod_ForName("progs/beam.mdl", true));
|
||||
break;
|
||||
// PGM 01/21/97
|
||||
|
||||
case TE_LAVASPLASH:
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_LavaSplash (pos);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_LavaSplash(pos);
|
||||
break;
|
||||
|
||||
case TE_TELEPORT:
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
R_TeleportSplash (pos);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
R_TeleportSplash(pos);
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION2: // color mapped explosion
|
||||
pos[0] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord (cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord (cl.protocolflags);
|
||||
colorStart = MSG_ReadByte ();
|
||||
colorLength = MSG_ReadByte ();
|
||||
R_ParticleExplosion2 (pos, colorStart, colorLength);
|
||||
dl = CL_AllocDlight (0);
|
||||
VectorCopy (pos, dl->origin);
|
||||
pos[0] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[1] = MSG_ReadCoord(cl.protocolflags);
|
||||
pos[2] = MSG_ReadCoord(cl.protocolflags);
|
||||
colorStart = MSG_ReadByte();
|
||||
colorLength = MSG_ReadByte();
|
||||
R_ParticleExplosion2(pos, colorStart, colorLength);
|
||||
dl = CL_AllocDlight(0);
|
||||
VectorCopy(pos, dl->origin);
|
||||
dl->radius = 350;
|
||||
dl->die = cl.time + 0.5;
|
||||
dl->decay = 300;
|
||||
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
S_StartSound(-1, 0, cl_sfx_r_exp3, pos, 1, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
Sys_Error ("CL_ParseTEnt: bad type");
|
||||
Sys_Error("CL_ParseTEnt: bad type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,16 +265,16 @@ void CL_ParseTEnt (void)
|
|||
CL_NewTempEntity
|
||||
=================
|
||||
*/
|
||||
entity_t *CL_NewTempEntity (void)
|
||||
entity_t *CL_NewTempEntity(void)
|
||||
{
|
||||
entity_t *ent;
|
||||
|
||||
if (cl_numvisedicts == MAX_VISEDICTS)
|
||||
if(cl_numvisedicts == MAX_VISEDICTS)
|
||||
return NULL;
|
||||
if (num_temp_entities == MAX_TEMP_ENTITIES)
|
||||
if(num_temp_entities == MAX_TEMP_ENTITIES)
|
||||
return NULL;
|
||||
ent = &cl_temp_entities[num_temp_entities];
|
||||
memset (ent, 0, sizeof(*ent));
|
||||
memset(ent, 0, sizeof(*ent));
|
||||
num_temp_entities++;
|
||||
cl_visedicts[cl_numvisedicts] = ent;
|
||||
cl_numvisedicts++;
|
||||
|
@ -289,7 +289,7 @@ entity_t *CL_NewTempEntity (void)
|
|||
CL_UpdateTEnts
|
||||
=================
|
||||
*/
|
||||
void CL_UpdateTEnts (void)
|
||||
void CL_UpdateTEnts(void)
|
||||
{
|
||||
int32_t i, j; //johnfitz -- use j instead of using i twice, so we don't corrupt memory
|
||||
beam_t *b;
|
||||
|
@ -301,60 +301,60 @@ void CL_UpdateTEnts (void)
|
|||
|
||||
num_temp_entities = 0;
|
||||
|
||||
srand ((int32_t) (cl.time * 1000)); //johnfitz -- freeze beams when paused
|
||||
srand((int32_t)(cl.time * 1000)); //johnfitz -- freeze beams when paused
|
||||
|
||||
// update lightning
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
for(i = 0, b = cl_beams ; i < MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
if(!b->model || b->endtime < cl.time)
|
||||
continue;
|
||||
|
||||
// if coming from the player, update the start position
|
||||
if (b->entity == cl.viewentity)
|
||||
if(b->entity == cl.viewentity)
|
||||
{
|
||||
VectorCopy (cl_entities[cl.viewentity].origin, b->start);
|
||||
VectorCopy(cl_entities[cl.viewentity].origin, b->start);
|
||||
}
|
||||
|
||||
// calculate pitch and yaw
|
||||
VectorSubtract (b->end, b->start, dist);
|
||||
VectorSubtract(b->end, b->start, dist);
|
||||
|
||||
if (dist[1] == 0 && dist[0] == 0)
|
||||
if(dist[1] == 0 && dist[0] == 0)
|
||||
{
|
||||
yaw = 0;
|
||||
if (dist[2] > 0)
|
||||
if(dist[2] > 0)
|
||||
pitch = 90;
|
||||
else
|
||||
pitch = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = (int32_t) (atan2(dist[1], dist[0]) * 180 / M_PI);
|
||||
if (yaw < 0)
|
||||
yaw = (int32_t)(atan2(dist[1], dist[0]) * 180 / M_PI);
|
||||
if(yaw < 0)
|
||||
yaw += 360;
|
||||
|
||||
forward = sqrt (dist[0]*dist[0] + dist[1]*dist[1]);
|
||||
pitch = (int32_t) (atan2(dist[2], forward) * 180 / M_PI);
|
||||
if (pitch < 0)
|
||||
forward = sqrt(dist[0] * dist[0] + dist[1] * dist[1]);
|
||||
pitch = (int32_t)(atan2(dist[2], forward) * 180 / M_PI);
|
||||
if(pitch < 0)
|
||||
pitch += 360;
|
||||
}
|
||||
|
||||
// add new entities for the lightning
|
||||
VectorCopy (b->start, org);
|
||||
VectorCopy(b->start, org);
|
||||
d = VectorNormalize(dist);
|
||||
while (d > 0)
|
||||
while(d > 0)
|
||||
{
|
||||
ent = CL_NewTempEntity ();
|
||||
if (!ent)
|
||||
ent = CL_NewTempEntity();
|
||||
if(!ent)
|
||||
return;
|
||||
VectorCopy (org, ent->origin);
|
||||
VectorCopy(org, ent->origin);
|
||||
ent->model = b->model;
|
||||
ent->angles[0] = pitch;
|
||||
ent->angles[1] = yaw;
|
||||
ent->angles[2] = rand()%360;
|
||||
ent->angles[2] = rand() % 360;
|
||||
|
||||
//johnfitz -- use j instead of using i twice, so we don't corrupt memory
|
||||
for (j=0 ; j<3 ; j++)
|
||||
org[j] += dist[j]*30;
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
org[j] += dist[j] * 30;
|
||||
d -= 30;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct
|
|||
float entertime;
|
||||
int32_t frags;
|
||||
int32_t colors; // two 4 bit fields
|
||||
byte translations[VID_GRADES*256];
|
||||
byte translations[VID_GRADES * 256];
|
||||
} scoreboard_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -89,10 +89,11 @@ typedef struct
|
|||
#define MAX_DEMOS 8
|
||||
#define MAX_DEMONAME 16
|
||||
|
||||
typedef enum {
|
||||
ca_dedicated, // a dedicated server with no ability to start a client
|
||||
ca_disconnected, // full screen console with no connection
|
||||
ca_connected // valid netcon, talking to a server
|
||||
typedef enum
|
||||
{
|
||||
ca_dedicated, // a dedicated server with no ability to start a client
|
||||
ca_disconnected, // full screen console with no connection
|
||||
ca_connected // valid netcon, talking to a server
|
||||
} cactive_t;
|
||||
|
||||
//
|
||||
|
@ -288,20 +289,20 @@ extern int32_t cl_max_edicts; //johnfitz -- only changes when new map loads
|
|||
//
|
||||
// cl_main
|
||||
//
|
||||
dlight_t *CL_AllocDlight (int32_t key);
|
||||
void CL_DecayLights (void);
|
||||
dlight_t *CL_AllocDlight(int32_t key);
|
||||
void CL_DecayLights(void);
|
||||
|
||||
void CL_Init (void);
|
||||
void CL_Init(void);
|
||||
|
||||
void CL_EstablishConnection (const char *host);
|
||||
void CL_Signon1 (void);
|
||||
void CL_Signon2 (void);
|
||||
void CL_Signon3 (void);
|
||||
void CL_Signon4 (void);
|
||||
void CL_EstablishConnection(const char *host);
|
||||
void CL_Signon1(void);
|
||||
void CL_Signon2(void);
|
||||
void CL_Signon3(void);
|
||||
void CL_Signon4(void);
|
||||
|
||||
void CL_Disconnect (void);
|
||||
void CL_Disconnect_f (void);
|
||||
void CL_NextDemo (void);
|
||||
void CL_Disconnect(void);
|
||||
void CL_Disconnect_f(void);
|
||||
void CL_NextDemo(void);
|
||||
|
||||
//
|
||||
// cl_input
|
||||
|
@ -316,61 +317,61 @@ extern kbutton_t in_mlook, in_klook;
|
|||
extern kbutton_t in_strafe;
|
||||
extern kbutton_t in_speed;
|
||||
|
||||
void CL_InitInput (void);
|
||||
void CL_SendCmd (void);
|
||||
void CL_SendMove (const usercmd_t *cmd);
|
||||
int32_t CL_ReadFromServer (void);
|
||||
void CL_BaseMove (usercmd_t *cmd);
|
||||
void CL_InitInput(void);
|
||||
void CL_SendCmd(void);
|
||||
void CL_SendMove(const usercmd_t *cmd);
|
||||
int32_t CL_ReadFromServer(void);
|
||||
void CL_BaseMove(usercmd_t *cmd);
|
||||
|
||||
void CL_ParseTEnt (void);
|
||||
void CL_UpdateTEnts (void);
|
||||
void CL_ParseTEnt(void);
|
||||
void CL_UpdateTEnts(void);
|
||||
|
||||
void CL_ClearState (void);
|
||||
void CL_ClearState(void);
|
||||
|
||||
//
|
||||
// cl_demo.c
|
||||
//
|
||||
void CL_StopPlayback (void);
|
||||
int32_t CL_GetMessage (void);
|
||||
void CL_StopPlayback(void);
|
||||
int32_t CL_GetMessage(void);
|
||||
|
||||
void CL_Stop_f (void);
|
||||
void CL_Record_f (void);
|
||||
void CL_PlayDemo_f (void);
|
||||
void CL_TimeDemo_f (void);
|
||||
void CL_Stop_f(void);
|
||||
void CL_Record_f(void);
|
||||
void CL_PlayDemo_f(void);
|
||||
void CL_TimeDemo_f(void);
|
||||
|
||||
//
|
||||
// cl_parse.c
|
||||
//
|
||||
void CL_ParseServerMessage (void);
|
||||
void CL_NewTranslation (int32_t slot);
|
||||
void CL_ParseServerMessage(void);
|
||||
void CL_NewTranslation(int32_t slot);
|
||||
|
||||
//
|
||||
// view
|
||||
//
|
||||
void V_StartPitchDrift (void);
|
||||
void V_StopPitchDrift (void);
|
||||
void V_StartPitchDrift(void);
|
||||
void V_StopPitchDrift(void);
|
||||
|
||||
void V_RenderView (void);
|
||||
void V_RenderView(void);
|
||||
//void V_UpdatePalette (void); //johnfitz
|
||||
void V_Register (void);
|
||||
void V_ParseDamage (void);
|
||||
void V_SetContentsColor (int32_t contents);
|
||||
void V_Register(void);
|
||||
void V_ParseDamage(void);
|
||||
void V_SetContentsColor(int32_t contents);
|
||||
|
||||
//
|
||||
// cl_tent
|
||||
//
|
||||
void CL_InitTEnts (void);
|
||||
void CL_SignonReply (void);
|
||||
void CL_InitTEnts(void);
|
||||
void CL_SignonReply(void);
|
||||
|
||||
//
|
||||
// chase
|
||||
//
|
||||
extern cvar_t chase_active;
|
||||
|
||||
void Chase_Init (void);
|
||||
void TraceLine (vec3_t start, vec3_t end, vec3_t impact);
|
||||
void Chase_UpdateForClient (void); //johnfitz
|
||||
void Chase_UpdateForDrawing (void); //johnfitz
|
||||
void Chase_Init(void);
|
||||
void TraceLine(vec3_t start, vec3_t end, vec3_t impact);
|
||||
void Chase_UpdateForClient(void); //johnfitz
|
||||
void Chase_UpdateForDrawing(void); //johnfitz
|
||||
|
||||
#endif /* _CLIENT_H_ */
|
||||
|
||||
|
|
382
source/cmd.c
382
source/cmd.c
|
@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
void Cmd_ForwardToServer(void);
|
||||
|
||||
#define MAX_ALIAS_NAME 32
|
||||
|
||||
|
@ -52,7 +52,7 @@ next frame. This allows commands like:
|
|||
bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
|
||||
============
|
||||
*/
|
||||
void Cmd_Wait_f (void)
|
||||
void Cmd_Wait_f(void)
|
||||
{
|
||||
cmd_wait = true;
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ sizebuf_t cmd_text;
|
|||
Cbuf_Init
|
||||
============
|
||||
*/
|
||||
void Cbuf_Init (void)
|
||||
void Cbuf_Init(void)
|
||||
{
|
||||
SZ_Alloc (&cmd_text, 1<<18); // space for commands and script files. spike -- was 8192, but modern configs can be _HUGE_, at least if they contain lots of comments/docs for things.
|
||||
SZ_Alloc(&cmd_text, 1 << 18); // space for commands and script files. spike -- was 8192, but modern configs can be _HUGE_, at least if they contain lots of comments/docs for things.
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,19 +85,19 @@ Cbuf_AddText
|
|||
Adds command text at the end of the buffer
|
||||
============
|
||||
*/
|
||||
void Cbuf_AddText (const char *text)
|
||||
void Cbuf_AddText(const char *text)
|
||||
{
|
||||
int32_t l;
|
||||
|
||||
l = Q_strlen (text);
|
||||
l = Q_strlen(text);
|
||||
|
||||
if (cmd_text.cursize + l >= cmd_text.maxsize)
|
||||
if(cmd_text.cursize + l >= cmd_text.maxsize)
|
||||
{
|
||||
Con_Printf ("Cbuf_AddText: overflow\n");
|
||||
Con_Printf("Cbuf_AddText: overflow\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SZ_Write (&cmd_text, text, Q_strlen (text));
|
||||
SZ_Write(&cmd_text, text, Q_strlen(text));
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,30 +110,30 @@ Adds a \n to the text
|
|||
FIXME: actually change the command buffer to do less copying
|
||||
============
|
||||
*/
|
||||
void Cbuf_InsertText (const char *text)
|
||||
void Cbuf_InsertText(const char *text)
|
||||
{
|
||||
char *temp;
|
||||
int32_t templen;
|
||||
|
||||
// copy off any commands still remaining in the exec buffer
|
||||
templen = cmd_text.cursize;
|
||||
if (templen)
|
||||
if(templen)
|
||||
{
|
||||
temp = (char *) Z_Malloc (templen);
|
||||
Q_memcpy (temp, cmd_text.data, templen);
|
||||
SZ_Clear (&cmd_text);
|
||||
temp = (char *) Z_Malloc(templen);
|
||||
Q_memcpy(temp, cmd_text.data, templen);
|
||||
SZ_Clear(&cmd_text);
|
||||
}
|
||||
else
|
||||
temp = NULL; // shut up compiler
|
||||
|
||||
// add the entire text of the file
|
||||
Cbuf_AddText (text);
|
||||
SZ_Write (&cmd_text, "\n", 1);
|
||||
Cbuf_AddText(text);
|
||||
SZ_Write(&cmd_text, "\n", 1);
|
||||
// add the copied off data
|
||||
if (templen)
|
||||
if(templen)
|
||||
{
|
||||
SZ_Write (&cmd_text, temp, templen);
|
||||
Z_Free (temp);
|
||||
SZ_Write(&cmd_text, temp, templen);
|
||||
Z_Free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,37 +142,37 @@ void Cbuf_InsertText (const char *text)
|
|||
Cbuf_Execute
|
||||
============
|
||||
*/
|
||||
void Cbuf_Execute (void)
|
||||
void Cbuf_Execute(void)
|
||||
{
|
||||
int32_t i;
|
||||
char *text;
|
||||
char line[1024];
|
||||
int32_t quotes;
|
||||
|
||||
while (cmd_text.cursize)
|
||||
while(cmd_text.cursize)
|
||||
{
|
||||
// find a \n or ; line break
|
||||
text = (char *)cmd_text.data;
|
||||
|
||||
quotes = 0;
|
||||
for (i=0 ; i< cmd_text.cursize ; i++)
|
||||
for(i = 0 ; i < cmd_text.cursize ; i++)
|
||||
{
|
||||
if (text[i] == '"')
|
||||
if(text[i] == '"')
|
||||
quotes++;
|
||||
if ( !(quotes&1) && text[i] == ';')
|
||||
if(!(quotes & 1) && text[i] == ';')
|
||||
break; // don't break if inside a quoted string
|
||||
if (text[i] == '\n')
|
||||
if(text[i] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
if (i > (int32_t)sizeof(line) - 1)
|
||||
if(i > (int32_t)sizeof(line) - 1)
|
||||
{
|
||||
memcpy (line, text, sizeof(line) - 1);
|
||||
memcpy(line, text, sizeof(line) - 1);
|
||||
line[sizeof(line) - 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (line, text, i);
|
||||
memcpy(line, text, i);
|
||||
line[i] = 0;
|
||||
}
|
||||
|
||||
|
@ -180,20 +180,21 @@ void Cbuf_Execute (void)
|
|||
// this is necessary because commands (exec, alias) can insert data at the
|
||||
// beginning of the text buffer
|
||||
|
||||
if (i == cmd_text.cursize)
|
||||
if(i == cmd_text.cursize)
|
||||
cmd_text.cursize = 0;
|
||||
else
|
||||
{
|
||||
i++;
|
||||
cmd_text.cursize -= i;
|
||||
memmove (text, text + i, cmd_text.cursize);
|
||||
memmove(text, text + i, cmd_text.cursize);
|
||||
}
|
||||
|
||||
// execute the command line
|
||||
Cmd_ExecuteString (line, src_command);
|
||||
Cmd_ExecuteString(line, src_command);
|
||||
|
||||
if (cmd_wait)
|
||||
{ // skip out while text still remains in buffer, leaving it
|
||||
if(cmd_wait)
|
||||
{
|
||||
// skip out while text still remains in buffer, leaving it
|
||||
// for next frame
|
||||
cmd_wait = false;
|
||||
break;
|
||||
|
@ -219,7 +220,7 @@ quake +prog jctest.qp +cmd amlev1
|
|||
quake -nosound +cmd amlev1
|
||||
===============
|
||||
*/
|
||||
void Cmd_StuffCmds_f (void)
|
||||
void Cmd_StuffCmds_f(void)
|
||||
{
|
||||
extern cvar_t cmdline;
|
||||
char cmds[CMDLINE_LENGTH];
|
||||
|
@ -227,26 +228,26 @@ void Cmd_StuffCmds_f (void)
|
|||
|
||||
plus = false; // On Unix, argv[0] is command name
|
||||
|
||||
for (i = 0, j = 0; cmdline.string[i]; i++)
|
||||
for(i = 0, j = 0; cmdline.string[i]; i++)
|
||||
{
|
||||
if (cmdline.string[i] == '+')
|
||||
if(cmdline.string[i] == '+')
|
||||
{
|
||||
plus = true;
|
||||
if (j > 0)
|
||||
if(j > 0)
|
||||
{
|
||||
cmds[j-1] = ';';
|
||||
cmds[j - 1] = ';';
|
||||
cmds[j++] = ' ';
|
||||
}
|
||||
}
|
||||
else if (cmdline.string[i] == '-' &&
|
||||
(i==0 || cmdline.string[i-1] == ' ')) //johnfitz -- allow hypenated map names with +map
|
||||
else if(cmdline.string[i] == '-' &&
|
||||
(i == 0 || cmdline.string[i - 1] == ' ')) //johnfitz -- allow hypenated map names with +map
|
||||
plus = false;
|
||||
else if (plus)
|
||||
else if(plus)
|
||||
cmds[j++] = cmdline.string[i];
|
||||
}
|
||||
cmds[j] = 0;
|
||||
|
||||
Cbuf_InsertText (cmds);
|
||||
Cbuf_InsertText(cmds);
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,28 +256,28 @@ void Cmd_StuffCmds_f (void)
|
|||
Cmd_Exec_f
|
||||
===============
|
||||
*/
|
||||
void Cmd_Exec_f (void)
|
||||
void Cmd_Exec_f(void)
|
||||
{
|
||||
char *f;
|
||||
int32_t mark;
|
||||
|
||||
if (Cmd_Argc () != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("exec <filename> : execute a script file\n");
|
||||
Con_Printf("exec <filename> : execute a script file\n");
|
||||
return;
|
||||
}
|
||||
|
||||
mark = Hunk_LowMark ();
|
||||
f = (char *)COM_LoadHunkFile (Cmd_Argv(1), NULL);
|
||||
if (!f)
|
||||
mark = Hunk_LowMark();
|
||||
f = (char *)COM_LoadHunkFile(Cmd_Argv(1), NULL);
|
||||
if(!f)
|
||||
{
|
||||
Con_Printf ("couldn't exec %s\n",Cmd_Argv(1));
|
||||
Con_Printf("couldn't exec %s\n", Cmd_Argv(1));
|
||||
return;
|
||||
}
|
||||
Con_Printf ("execing %s\n",Cmd_Argv(1));
|
||||
Con_Printf("execing %s\n", Cmd_Argv(1));
|
||||
|
||||
Cbuf_InsertText (f);
|
||||
Hunk_FreeToLowMark (mark);
|
||||
Cbuf_InsertText(f);
|
||||
Hunk_FreeToLowMark(mark);
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,13 +288,13 @@ Cmd_Echo_f
|
|||
Just prints the rest of the line to the console
|
||||
===============
|
||||
*/
|
||||
void Cmd_Echo_f (void)
|
||||
void Cmd_Echo_f(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
for (i=1 ; i<Cmd_Argc() ; i++)
|
||||
Con_Printf ("%s ",Cmd_Argv(i));
|
||||
Con_Printf ("\n");
|
||||
for(i = 1 ; i < Cmd_Argc() ; i++)
|
||||
Con_Printf("%s ", Cmd_Argv(i));
|
||||
Con_Printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -303,7 +304,7 @@ Cmd_Alias_f -- johnfitz -- rewritten
|
|||
Creates a new command that executes a command string (possibly ; seperated)
|
||||
===============
|
||||
*/
|
||||
void Cmd_Alias_f (void)
|
||||
void Cmd_Alias_f(void)
|
||||
{
|
||||
cmdalias_t *a;
|
||||
char cmd[1024];
|
||||
|
@ -311,64 +312,64 @@ void Cmd_Alias_f (void)
|
|||
const char *s;
|
||||
|
||||
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
case 1: //list all aliases
|
||||
for (a = cmd_alias, i = 0; a; a=a->next, i++)
|
||||
Con_SafePrintf (" %s: %s", a->name, a->value);
|
||||
if (i)
|
||||
Con_SafePrintf ("%" PRIi32 " alias command(s)\n", i);
|
||||
for(a = cmd_alias, i = 0; a; a = a->next, i++)
|
||||
Con_SafePrintf(" %s: %s", a->name, a->value);
|
||||
if(i)
|
||||
Con_SafePrintf("%" PRIi32 " alias command(s)\n", i);
|
||||
else
|
||||
Con_SafePrintf ("no alias commands found\n");
|
||||
Con_SafePrintf("no alias commands found\n");
|
||||
break;
|
||||
case 2: //output current alias string
|
||||
for (a = cmd_alias ; a ; a=a->next)
|
||||
if (!strcmp(Cmd_Argv(1), a->name))
|
||||
Con_Printf (" %s: %s", a->name, a->value);
|
||||
for(a = cmd_alias ; a ; a = a->next)
|
||||
if(!strcmp(Cmd_Argv(1), a->name))
|
||||
Con_Printf(" %s: %s", a->name, a->value);
|
||||
break;
|
||||
default: //set alias string
|
||||
s = Cmd_Argv(1);
|
||||
if (strlen(s) >= MAX_ALIAS_NAME)
|
||||
if(strlen(s) >= MAX_ALIAS_NAME)
|
||||
{
|
||||
Con_Printf ("Alias name is too long\n");
|
||||
Con_Printf("Alias name is too long\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// if the alias allready exists, reuse it
|
||||
for (a = cmd_alias ; a ; a=a->next)
|
||||
for(a = cmd_alias ; a ; a = a->next)
|
||||
{
|
||||
if (!strcmp(s, a->name))
|
||||
if(!strcmp(s, a->name))
|
||||
{
|
||||
Z_Free (a->value);
|
||||
Z_Free(a->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!a)
|
||||
if(!a)
|
||||
{
|
||||
a = (cmdalias_t *) Z_Malloc (sizeof(cmdalias_t));
|
||||
a = (cmdalias_t *) Z_Malloc(sizeof(cmdalias_t));
|
||||
a->next = cmd_alias;
|
||||
cmd_alias = a;
|
||||
}
|
||||
strcpy (a->name, s);
|
||||
strcpy(a->name, s);
|
||||
|
||||
// copy the rest of the command line
|
||||
cmd[0] = 0; // start out with a null string
|
||||
c = Cmd_Argc();
|
||||
for (i = 2; i < c; i++)
|
||||
for(i = 2; i < c; i++)
|
||||
{
|
||||
q_strlcat (cmd, Cmd_Argv(i), sizeof(cmd));
|
||||
if (i != c - 1)
|
||||
q_strlcat (cmd, " ", sizeof(cmd));
|
||||
q_strlcat(cmd, Cmd_Argv(i), sizeof(cmd));
|
||||
if(i != c - 1)
|
||||
q_strlcat(cmd, " ", sizeof(cmd));
|
||||
}
|
||||
if (q_strlcat(cmd, "\n", sizeof(cmd)) >= sizeof(cmd))
|
||||
if(q_strlcat(cmd, "\n", sizeof(cmd)) >= sizeof(cmd))
|
||||
{
|
||||
Con_Printf("alias value too long!\n");
|
||||
cmd[0] = '\n'; // nullify the string
|
||||
cmd[1] = 0;
|
||||
}
|
||||
|
||||
a->value = Z_Strdup (cmd);
|
||||
a->value = Z_Strdup(cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -378,11 +379,11 @@ void Cmd_Alias_f (void)
|
|||
Cmd_Unalias_f -- johnfitz
|
||||
===============
|
||||
*/
|
||||
void Cmd_Unalias_f (void)
|
||||
void Cmd_Unalias_f(void)
|
||||
{
|
||||
cmdalias_t *a, *prev;
|
||||
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
|
@ -390,22 +391,22 @@ void Cmd_Unalias_f (void)
|
|||
break;
|
||||
case 2:
|
||||
prev = NULL;
|
||||
for (a = cmd_alias; a; a = a->next)
|
||||
for(a = cmd_alias; a; a = a->next)
|
||||
{
|
||||
if (!strcmp(Cmd_Argv(1), a->name))
|
||||
if(!strcmp(Cmd_Argv(1), a->name))
|
||||
{
|
||||
if (prev)
|
||||
if(prev)
|
||||
prev->next = a->next;
|
||||
else
|
||||
cmd_alias = a->next;
|
||||
|
||||
Z_Free (a->value);
|
||||
Z_Free (a);
|
||||
Z_Free(a->value);
|
||||
Z_Free(a);
|
||||
return;
|
||||
}
|
||||
prev = a;
|
||||
}
|
||||
Con_Printf ("No alias named %s\n", Cmd_Argv(1));
|
||||
Con_Printf("No alias named %s\n", Cmd_Argv(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -415,11 +416,11 @@ void Cmd_Unalias_f (void)
|
|||
Cmd_Unaliasall_f -- johnfitz
|
||||
===============
|
||||
*/
|
||||
void Cmd_Unaliasall_f (void)
|
||||
void Cmd_Unaliasall_f(void)
|
||||
{
|
||||
cmdalias_t *blah;
|
||||
|
||||
while (cmd_alias)
|
||||
while(cmd_alias)
|
||||
{
|
||||
blah = cmd_alias->next;
|
||||
Z_Free(cmd_alias->value);
|
||||
|
@ -463,15 +464,15 @@ cmd_function_t *cmd_functions; // possible commands to execute
|
|||
Cmd_List_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cmd_List_f (void)
|
||||
void Cmd_List_f(void)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
const char *partial;
|
||||
int32_t len, count;
|
||||
|
||||
if (Cmd_Argc() > 1)
|
||||
if(Cmd_Argc() > 1)
|
||||
{
|
||||
partial = Cmd_Argv (1);
|
||||
partial = Cmd_Argv(1);
|
||||
len = Q_strlen(partial);
|
||||
}
|
||||
else
|
||||
|
@ -480,23 +481,23 @@ void Cmd_List_f (void)
|
|||
len = 0;
|
||||
}
|
||||
|
||||
count=0;
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
count = 0;
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
{
|
||||
if (partial && Q_strncmp (partial,cmd->name, len))
|
||||
if(partial && Q_strncmp(partial, cmd->name, len))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Con_SafePrintf (" %s\n", cmd->name);
|
||||
Con_SafePrintf(" %s\n", cmd->name);
|
||||
count++;
|
||||
}
|
||||
|
||||
Con_SafePrintf ("%" PRIi32 " commands", count);
|
||||
if (partial)
|
||||
Con_SafePrintf("%" PRIi32 " commands", count);
|
||||
if(partial)
|
||||
{
|
||||
Con_SafePrintf (" beginning with \"%s\"", partial);
|
||||
Con_SafePrintf(" beginning with \"%s\"", partial);
|
||||
}
|
||||
Con_SafePrintf ("\n");
|
||||
Con_SafePrintf("\n");
|
||||
}
|
||||
|
||||
static char *Cmd_TintSubstring(const char *in, const char *substr, char *out, size_t outsize)
|
||||
|
@ -504,11 +505,11 @@ static char *Cmd_TintSubstring(const char *in, const char *substr, char *out, si
|
|||
int32_t l;
|
||||
char *m;
|
||||
q_strlcpy(out, in, outsize);
|
||||
while ((m = q_strcasestr(out, substr)))
|
||||
while((m = q_strcasestr(out, substr)))
|
||||
{
|
||||
l = strlen(substr);
|
||||
while (l-->0)
|
||||
if (*m >= ' ' && *m < 127)
|
||||
while(l-- > 0)
|
||||
if(*m >= ' ' && *m < 127)
|
||||
*m++ |= 0x80;
|
||||
}
|
||||
return out;
|
||||
|
@ -528,31 +529,31 @@ void Cmd_Apropos_f(void)
|
|||
int32_t hits = 0;
|
||||
cmd_function_t *cmd;
|
||||
cvar_t *var;
|
||||
const char *substr = Cmd_Argv (1);
|
||||
if (!*substr)
|
||||
const char *substr = Cmd_Argv(1);
|
||||
if(!*substr)
|
||||
{
|
||||
Con_SafePrintf ("%s <substring> : search through commands and cvars for the given substring\n", Cmd_Argv(0));
|
||||
Con_SafePrintf("%s <substring> : search through commands and cvars for the given substring\n", Cmd_Argv(0));
|
||||
return;
|
||||
}
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
{
|
||||
if (q_strcasestr(cmd->name, substr))
|
||||
if(q_strcasestr(cmd->name, substr))
|
||||
{
|
||||
hits++;
|
||||
Con_SafePrintf ("%s\n", Cmd_TintSubstring(cmd->name, substr, tmpbuf, sizeof(tmpbuf)));
|
||||
Con_SafePrintf("%s\n", Cmd_TintSubstring(cmd->name, substr, tmpbuf, sizeof(tmpbuf)));
|
||||
}
|
||||
}
|
||||
|
||||
for (var=Cvar_FindVarAfter("", 0) ; var ; var=var->next)
|
||||
for(var = Cvar_FindVarAfter("", 0) ; var ; var = var->next)
|
||||
{
|
||||
if (q_strcasestr(var->name, substr))
|
||||
if(q_strcasestr(var->name, substr))
|
||||
{
|
||||
hits++;
|
||||
Con_SafePrintf ("%s (current value: \"%s\")\n", Cmd_TintSubstring(var->name, substr, tmpbuf, sizeof(tmpbuf)), var->string);
|
||||
Con_SafePrintf("%s (current value: \"%s\")\n", Cmd_TintSubstring(var->name, substr, tmpbuf, sizeof(tmpbuf)), var->string);
|
||||
}
|
||||
}
|
||||
if (!hits)
|
||||
Con_SafePrintf ("no cvars nor commands contain that substring\n");
|
||||
if(!hits)
|
||||
Con_SafePrintf("no cvars nor commands contain that substring\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -560,21 +561,21 @@ void Cmd_Apropos_f(void)
|
|||
Cmd_Init
|
||||
============
|
||||
*/
|
||||
void Cmd_Init (void)
|
||||
void Cmd_Init(void)
|
||||
{
|
||||
Cmd_AddCommand ("cmdlist", Cmd_List_f); //johnfitz
|
||||
Cmd_AddCommand ("unalias", Cmd_Unalias_f); //johnfitz
|
||||
Cmd_AddCommand ("unaliasall", Cmd_Unaliasall_f); //johnfitz
|
||||
Cmd_AddCommand("cmdlist", Cmd_List_f); //johnfitz
|
||||
Cmd_AddCommand("unalias", Cmd_Unalias_f); //johnfitz
|
||||
Cmd_AddCommand("unaliasall", Cmd_Unaliasall_f); //johnfitz
|
||||
|
||||
Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f);
|
||||
Cmd_AddCommand ("exec",Cmd_Exec_f);
|
||||
Cmd_AddCommand ("echo",Cmd_Echo_f);
|
||||
Cmd_AddCommand ("alias",Cmd_Alias_f);
|
||||
Cmd_AddCommand ("cmd", Cmd_ForwardToServer);
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f);
|
||||
Cmd_AddCommand("stuffcmds", Cmd_StuffCmds_f);
|
||||
Cmd_AddCommand("exec", Cmd_Exec_f);
|
||||
Cmd_AddCommand("echo", Cmd_Echo_f);
|
||||
Cmd_AddCommand("alias", Cmd_Alias_f);
|
||||
Cmd_AddCommand("cmd", Cmd_ForwardToServer);
|
||||
Cmd_AddCommand("wait", Cmd_Wait_f);
|
||||
|
||||
Cmd_AddCommand ("apropos", Cmd_Apropos_f);
|
||||
Cmd_AddCommand ("find", Cmd_Apropos_f);
|
||||
Cmd_AddCommand("apropos", Cmd_Apropos_f);
|
||||
Cmd_AddCommand("find", Cmd_Apropos_f);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -582,7 +583,7 @@ void Cmd_Init (void)
|
|||
Cmd_Argc
|
||||
============
|
||||
*/
|
||||
int32_t Cmd_Argc (void)
|
||||
int32_t Cmd_Argc(void)
|
||||
{
|
||||
return cmd_argc;
|
||||
}
|
||||
|
@ -592,9 +593,9 @@ int32_t Cmd_Argc (void)
|
|||
Cmd_Argv
|
||||
============
|
||||
*/
|
||||
const char *Cmd_Argv (int32_t arg)
|
||||
const char *Cmd_Argv(int32_t arg)
|
||||
{
|
||||
if (arg < 0 || arg >= cmd_argc)
|
||||
if(arg < 0 || arg >= cmd_argc)
|
||||
return cmd_null_string;
|
||||
return cmd_argv[arg];
|
||||
}
|
||||
|
@ -604,7 +605,7 @@ const char *Cmd_Argv (int32_t arg)
|
|||
Cmd_Args
|
||||
============
|
||||
*/
|
||||
const char *Cmd_Args (void)
|
||||
const char *Cmd_Args(void)
|
||||
{
|
||||
return cmd_args;
|
||||
}
|
||||
|
@ -617,44 +618,45 @@ Cmd_TokenizeString
|
|||
Parses the given string into command line tokens.
|
||||
============
|
||||
*/
|
||||
void Cmd_TokenizeString (const char *text)
|
||||
void Cmd_TokenizeString(const char *text)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
// clear the args from the last string
|
||||
for (i=0 ; i<cmd_argc ; i++)
|
||||
Z_Free (cmd_argv[i]);
|
||||
for(i = 0 ; i < cmd_argc ; i++)
|
||||
Z_Free(cmd_argv[i]);
|
||||
|
||||
cmd_argc = 0;
|
||||
cmd_args = NULL;
|
||||
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
// skip whitespace up to a /n
|
||||
while (*text && *text <= ' ' && *text != '\n')
|
||||
while(*text && *text <= ' ' && *text != '\n')
|
||||
{
|
||||
text++;
|
||||
}
|
||||
|
||||
if (*text == '\n')
|
||||
{ // a newline seperates commands in the buffer
|
||||
if(*text == '\n')
|
||||
{
|
||||
// a newline seperates commands in the buffer
|
||||
text++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!*text)
|
||||
if(!*text)
|
||||
return;
|
||||
|
||||
if (cmd_argc == 1)
|
||||
if(cmd_argc == 1)
|
||||
cmd_args = text;
|
||||
|
||||
text = COM_Parse (text);
|
||||
if (!text)
|
||||
text = COM_Parse(text);
|
||||
if(!text)
|
||||
return;
|
||||
|
||||
if (cmd_argc < MAX_ARGS)
|
||||
if(cmd_argc < MAX_ARGS)
|
||||
{
|
||||
cmd_argv[cmd_argc] = Z_Strdup (com_token);
|
||||
cmd_argv[cmd_argc] = Z_Strdup(com_token);
|
||||
cmd_argc++;
|
||||
}
|
||||
}
|
||||
|
@ -666,37 +668,37 @@ void Cmd_TokenizeString (const char *text)
|
|||
Cmd_AddCommand
|
||||
============
|
||||
*/
|
||||
void Cmd_AddCommand (const char *cmd_name, xcommand_t function)
|
||||
void Cmd_AddCommand(const char *cmd_name, xcommand_t function)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
cmd_function_t *cursor,*prev; //johnfitz -- sorted list insert
|
||||
cmd_function_t *cursor, *prev; //johnfitz -- sorted list insert
|
||||
|
||||
if (host_initialized) // because hunk allocation would get stomped
|
||||
Sys_Error ("Cmd_AddCommand after host_initialized");
|
||||
if(host_initialized) // because hunk allocation would get stomped
|
||||
Sys_Error("Cmd_AddCommand after host_initialized");
|
||||
|
||||
// fail if the command is a variable name
|
||||
if (Cvar_VariableString(cmd_name)[0])
|
||||
if(Cvar_VariableString(cmd_name)[0])
|
||||
{
|
||||
Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name);
|
||||
Con_Printf("Cmd_AddCommand: %s already defined as a var\n", cmd_name);
|
||||
return;
|
||||
}
|
||||
|
||||
// fail if the command already exists
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
{
|
||||
if (!Q_strcmp (cmd_name, cmd->name))
|
||||
if(!Q_strcmp(cmd_name, cmd->name))
|
||||
{
|
||||
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
||||
Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cmd = (cmd_function_t *) Hunk_Alloc (sizeof(cmd_function_t));
|
||||
cmd = (cmd_function_t *) Hunk_Alloc(sizeof(cmd_function_t));
|
||||
cmd->name = cmd_name;
|
||||
cmd->function = function;
|
||||
|
||||
//johnfitz -- insert each entry in alphabetical order
|
||||
if (cmd_functions == NULL || strcmp(cmd->name, cmd_functions->name) < 0) //insert at front
|
||||
if(cmd_functions == NULL || strcmp(cmd->name, cmd_functions->name) < 0) //insert at front
|
||||
{
|
||||
cmd->next = cmd_functions;
|
||||
cmd_functions = cmd;
|
||||
|
@ -705,7 +707,7 @@ void Cmd_AddCommand (const char *cmd_name, xcommand_t function)
|
|||
{
|
||||
prev = cmd_functions;
|
||||
cursor = cmd_functions->next;
|
||||
while ((cursor != NULL) && (strcmp(cmd->name, cursor->name) > 0))
|
||||
while((cursor != NULL) && (strcmp(cmd->name, cursor->name) > 0))
|
||||
{
|
||||
prev = cursor;
|
||||
cursor = cursor->next;
|
||||
|
@ -721,13 +723,13 @@ void Cmd_AddCommand (const char *cmd_name, xcommand_t function)
|
|||
Cmd_Exists
|
||||
============
|
||||
*/
|
||||
bool Cmd_Exists (const char *cmd_name)
|
||||
bool Cmd_Exists(const char *cmd_name)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
{
|
||||
if (!Q_strcmp (cmd_name,cmd->name))
|
||||
if(!Q_strcmp(cmd_name, cmd->name))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -741,19 +743,19 @@ bool Cmd_Exists (const char *cmd_name)
|
|||
Cmd_CompleteCommand
|
||||
============
|
||||
*/
|
||||
const char *Cmd_CompleteCommand (const char *partial)
|
||||
const char *Cmd_CompleteCommand(const char *partial)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
int32_t len;
|
||||
|
||||
len = Q_strlen(partial);
|
||||
|
||||
if (!len)
|
||||
if(!len)
|
||||
return NULL;
|
||||
|
||||
// check functions
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
if (!Q_strncmp (partial,cmd->name, len))
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
if(!Q_strncmp(partial, cmd->name, len))
|
||||
return cmd->name;
|
||||
|
||||
return NULL;
|
||||
|
@ -767,41 +769,41 @@ A complete command line has been parsed, so try to execute it
|
|||
FIXME: lookupnoadd the token to speed search?
|
||||
============
|
||||
*/
|
||||
void Cmd_ExecuteString (const char *text, cmd_source_t src)
|
||||
void Cmd_ExecuteString(const char *text, cmd_source_t src)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
cmdalias_t *a;
|
||||
|
||||
cmd_source = src;
|
||||
Cmd_TokenizeString (text);
|
||||
Cmd_TokenizeString(text);
|
||||
|
||||
// execute the command line
|
||||
if (!Cmd_Argc())
|
||||
if(!Cmd_Argc())
|
||||
return; // no tokens
|
||||
|
||||
// check functions
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
for(cmd = cmd_functions ; cmd ; cmd = cmd->next)
|
||||
{
|
||||
if (!q_strcasecmp (cmd_argv[0],cmd->name))
|
||||
if(!q_strcasecmp(cmd_argv[0], cmd->name))
|
||||
{
|
||||
cmd->function ();
|
||||
cmd->function();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check alias
|
||||
for (a=cmd_alias ; a ; a=a->next)
|
||||
for(a = cmd_alias ; a ; a = a->next)
|
||||
{
|
||||
if (!q_strcasecmp (cmd_argv[0], a->name))
|
||||
if(!q_strcasecmp(cmd_argv[0], a->name))
|
||||
{
|
||||
Cbuf_InsertText (a->value);
|
||||
Cbuf_InsertText(a->value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check cvars
|
||||
if (!Cvar_Command ())
|
||||
Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0));
|
||||
if(!Cvar_Command())
|
||||
Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0));
|
||||
|
||||
}
|
||||
|
||||
|
@ -813,27 +815,27 @@ Cmd_ForwardToServer
|
|||
Sends the entire command line over to the server
|
||||
===================
|
||||
*/
|
||||
void Cmd_ForwardToServer (void)
|
||||
void Cmd_ForwardToServer(void)
|
||||
{
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
{
|
||||
Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
||||
Con_Printf("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cls.demoplayback)
|
||||
if(cls.demoplayback)
|
||||
return; // not really connected
|
||||
|
||||
MSG_WriteByte (&cls.message, clc_stringcmd);
|
||||
if (q_strcasecmp(Cmd_Argv(0), "cmd") != 0)
|
||||
MSG_WriteByte(&cls.message, clc_stringcmd);
|
||||
if(q_strcasecmp(Cmd_Argv(0), "cmd") != 0)
|
||||
{
|
||||
SZ_Print (&cls.message, Cmd_Argv(0));
|
||||
SZ_Print (&cls.message, " ");
|
||||
SZ_Print(&cls.message, Cmd_Argv(0));
|
||||
SZ_Print(&cls.message, " ");
|
||||
}
|
||||
if (Cmd_Argc() > 1)
|
||||
SZ_Print (&cls.message, Cmd_Args());
|
||||
if(Cmd_Argc() > 1)
|
||||
SZ_Print(&cls.message, Cmd_Args());
|
||||
else
|
||||
SZ_Print (&cls.message, "\n");
|
||||
SZ_Print(&cls.message, "\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -846,15 +848,15 @@ where the given parameter apears, or 0 if not present
|
|||
================
|
||||
*/
|
||||
|
||||
int32_t Cmd_CheckParm (const char *parm)
|
||||
int32_t Cmd_CheckParm(const char *parm)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (!parm)
|
||||
Sys_Error ("Cmd_CheckParm: NULL");
|
||||
if(!parm)
|
||||
Sys_Error("Cmd_CheckParm: NULL");
|
||||
|
||||
for (i = 1; i < Cmd_Argc (); i++)
|
||||
if (! q_strcasecmp (parm, Cmd_Argv (i)))
|
||||
for(i = 1; i < Cmd_Argc(); i++)
|
||||
if(! q_strcasecmp(parm, Cmd_Argv(i)))
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
|
|
34
source/cmd.h
34
source/cmd.h
|
@ -39,19 +39,19 @@ The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
|
|||
|
||||
*/
|
||||
|
||||
void Cbuf_Init (void);
|
||||
void Cbuf_Init(void);
|
||||
// allocates an initial text buffer that will grow as needed
|
||||
|
||||
void Cbuf_AddText (const char *text);
|
||||
void Cbuf_AddText(const char *text);
|
||||
// as new commands are generated from the console or keybindings,
|
||||
// the text is added to the end of the command buffer.
|
||||
|
||||
void Cbuf_InsertText (const char *text);
|
||||
void Cbuf_InsertText(const char *text);
|
||||
// when a command wants to issue other commands immediately, the text is
|
||||
// inserted at the beginning of the buffer, before any remaining unexecuted
|
||||
// commands.
|
||||
|
||||
void Cbuf_Execute (void);
|
||||
void Cbuf_Execute(void);
|
||||
// Pulls off \n terminated lines of text from the command buffer and sends
|
||||
// them through Cmd_ExecuteString. Stops when the buffer is empty.
|
||||
// Normally called once per frame, but may be explicitly invoked.
|
||||
|
@ -70,7 +70,7 @@ not apropriate.
|
|||
|
||||
*/
|
||||
|
||||
typedef void (*xcommand_t) (void);
|
||||
typedef void (*xcommand_t)(void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -81,45 +81,45 @@ typedef enum
|
|||
|
||||
extern cmd_source_t cmd_source;
|
||||
|
||||
void Cmd_Init (void);
|
||||
void Cmd_Init(void);
|
||||
|
||||
void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
|
||||
void Cmd_AddCommand(const char *cmd_name, xcommand_t function);
|
||||
// called by the init functions of other parts of the program to
|
||||
// register commands and functions to call for them.
|
||||
// The cmd_name is referenced later, so it should not be in temp memory
|
||||
|
||||
bool Cmd_Exists (const char *cmd_name);
|
||||
bool Cmd_Exists(const char *cmd_name);
|
||||
// used by the cvar code to check for cvar / command name overlap
|
||||
|
||||
const char *Cmd_CompleteCommand (const char *partial);
|
||||
const char *Cmd_CompleteCommand(const char *partial);
|
||||
// attempts to match a partial command for automatic command line completion
|
||||
// returns NULL if nothing fits
|
||||
|
||||
int32_t Cmd_Argc (void);
|
||||
const char *Cmd_Argv (int32_t arg);
|
||||
const char *Cmd_Args (void);
|
||||
int32_t Cmd_Argc(void);
|
||||
const char *Cmd_Argv(int32_t arg);
|
||||
const char *Cmd_Args(void);
|
||||
// The functions that execute commands get their parameters with these
|
||||
// functions. Cmd_Argv () will return an empty string, not a NULL
|
||||
// if arg > argc, so string operations are allways safe.
|
||||
|
||||
int32_t Cmd_CheckParm (const char *parm);
|
||||
int32_t Cmd_CheckParm(const char *parm);
|
||||
// Returns the position (1 to argc-1) in the command's argument list
|
||||
// where the given parameter apears, or 0 if not present
|
||||
|
||||
void Cmd_TokenizeString (const char *text);
|
||||
void Cmd_TokenizeString(const char *text);
|
||||
// Takes a null terminated string. Does not need to be /n terminated.
|
||||
// breaks the string up into arg tokens.
|
||||
|
||||
void Cmd_ExecuteString (const char *text, cmd_source_t src);
|
||||
void Cmd_ExecuteString(const char *text, cmd_source_t src);
|
||||
// Parses a single line of text into arguments and tries to execute it.
|
||||
// The text can come from the command buffer, a remote client, or stdin.
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
void Cmd_ForwardToServer(void);
|
||||
// adds the current command line as a clc_stringcmd to the client message.
|
||||
// things like godmode, noclip, etc, are commands directed to the server,
|
||||
// so when they are typed in at the console, they will need to be forwarded.
|
||||
|
||||
void Cmd_Print (const char *text);
|
||||
void Cmd_Print(const char *text);
|
||||
// used by command functions to send output to either the graphics console or
|
||||
// passed as a print message to the client
|
||||
|
||||
|
|
1252
source/common.c
1252
source/common.c
File diff suppressed because it is too large
Load Diff
186
source/common.h
186
source/common.h
|
@ -28,13 +28,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#if defined(_WIN32)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable:4244)
|
||||
/* 'argument' : conversion from 'type1' to 'type2',
|
||||
/* 'argument' : conversion from 'type1' to 'type2',
|
||||
possible loss of data */
|
||||
# pragma warning(disable:4305)
|
||||
/* 'identifier' : truncation from 'type1' to 'type2' */
|
||||
/* in our case, truncation from 'double' to 'float' */
|
||||
/* 'identifier' : truncation from 'type1' to 'type2' */
|
||||
/* in our case, truncation from 'double' to 'float' */
|
||||
# pragma warning(disable:4267)
|
||||
/* 'var' : conversion from 'size_t' to 'type',
|
||||
/* 'var' : conversion from 'size_t' to 'type',
|
||||
possible loss of data (/Wp64 warning) */
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* _WIN32 */
|
||||
|
@ -56,12 +56,12 @@ typedef struct sizebuf_s
|
|||
int32_t cursize;
|
||||
} sizebuf_t;
|
||||
|
||||
void SZ_Alloc (sizebuf_t *buf, int32_t startsize);
|
||||
void SZ_Free (sizebuf_t *buf);
|
||||
void SZ_Clear (sizebuf_t *buf);
|
||||
void *SZ_GetSpace (sizebuf_t *buf, int32_t length);
|
||||
void SZ_Write (sizebuf_t *buf, const void *data, int32_t length);
|
||||
void SZ_Print (sizebuf_t *buf, const char *data); // strcats onto the sizebuf
|
||||
void SZ_Alloc(sizebuf_t *buf, int32_t startsize);
|
||||
void SZ_Free(sizebuf_t *buf);
|
||||
void SZ_Clear(sizebuf_t *buf);
|
||||
void *SZ_GetSpace(sizebuf_t *buf, int32_t length);
|
||||
void SZ_Write(sizebuf_t *buf, const void *data, int32_t length);
|
||||
void SZ_Print(sizebuf_t *buf, const char *data); // strcats onto the sizebuf
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
@ -71,10 +71,10 @@ typedef struct link_s
|
|||
} link_t;
|
||||
|
||||
|
||||
void ClearLink (link_t *l);
|
||||
void RemoveLink (link_t *l);
|
||||
void InsertLinkBefore (link_t *l, link_t *before);
|
||||
void InsertLinkAfter (link_t *l, link_t *after);
|
||||
void ClearLink(link_t *l);
|
||||
void RemoveLink(link_t *l);
|
||||
void InsertLinkBefore(link_t *l, link_t *before);
|
||||
void InsertLinkAfter(link_t *l, link_t *after);
|
||||
|
||||
// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
|
||||
// ent = STRUCT_FROM_LINK(link,entity_t,order)
|
||||
|
@ -85,79 +85,79 @@ void InsertLinkAfter (link_t *l, link_t *after);
|
|||
|
||||
extern bool host_bigendian;
|
||||
|
||||
extern int16_t (*BigShort) (int16_t l);
|
||||
extern int16_t (*LittleShort) (int16_t l);
|
||||
extern int32_t (*BigLong) (int32_t l);
|
||||
extern int32_t (*LittleLong) (int32_t l);
|
||||
extern float (*BigFloat) (float l);
|
||||
extern float (*LittleFloat) (float l);
|
||||
extern int16_t (*BigShort)(int16_t l);
|
||||
extern int16_t (*LittleShort)(int16_t l);
|
||||
extern int32_t (*BigLong)(int32_t l);
|
||||
extern int32_t (*LittleLong)(int32_t l);
|
||||
extern float (*BigFloat)(float l);
|
||||
extern float (*LittleFloat)(float l);
|
||||
|
||||
//============================================================================
|
||||
|
||||
void MSG_WriteChar (sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteByte (sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteShort (sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteLong (sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteFloat (sizebuf_t *sb, float f);
|
||||
void MSG_WriteString (sizebuf_t *sb, const char *s);
|
||||
void MSG_WriteCoord (sizebuf_t *sb, float f, uint32_t flags);
|
||||
void MSG_WriteAngle (sizebuf_t *sb, float f, uint32_t flags);
|
||||
void MSG_WriteAngle16 (sizebuf_t *sb, float f, uint32_t flags); //johnfitz
|
||||
void MSG_WriteChar(sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteByte(sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteShort(sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteLong(sizebuf_t *sb, int32_t c);
|
||||
void MSG_WriteFloat(sizebuf_t *sb, float f);
|
||||
void MSG_WriteString(sizebuf_t *sb, const char *s);
|
||||
void MSG_WriteCoord(sizebuf_t *sb, float f, uint32_t flags);
|
||||
void MSG_WriteAngle(sizebuf_t *sb, float f, uint32_t flags);
|
||||
void MSG_WriteAngle16(sizebuf_t *sb, float f, uint32_t flags); //johnfitz
|
||||
|
||||
extern int32_t msg_readcount;
|
||||
extern bool msg_badread; // set if a read goes beyond end of message
|
||||
|
||||
void MSG_BeginReading (void);
|
||||
int32_t MSG_ReadChar (void);
|
||||
int32_t MSG_ReadByte (void);
|
||||
int32_t MSG_ReadShort (void);
|
||||
int32_t MSG_ReadLong (void);
|
||||
float MSG_ReadFloat (void);
|
||||
const char *MSG_ReadString (void);
|
||||
void MSG_BeginReading(void);
|
||||
int32_t MSG_ReadChar(void);
|
||||
int32_t MSG_ReadByte(void);
|
||||
int32_t MSG_ReadShort(void);
|
||||
int32_t MSG_ReadLong(void);
|
||||
float MSG_ReadFloat(void);
|
||||
const char *MSG_ReadString(void);
|
||||
|
||||
float MSG_ReadCoord (uint32_t flags);
|
||||
float MSG_ReadAngle (uint32_t flags);
|
||||
float MSG_ReadAngle16 (uint32_t flags); //johnfitz
|
||||
float MSG_ReadCoord(uint32_t flags);
|
||||
float MSG_ReadAngle(uint32_t flags);
|
||||
float MSG_ReadAngle16(uint32_t flags); //johnfitz
|
||||
|
||||
//============================================================================
|
||||
|
||||
void Q_memset (void *dest, int32_t fill, size_t count);
|
||||
void Q_memcpy (void *dest, const void *src, size_t count);
|
||||
int32_t Q_memcmp (const void *m1, const void *m2, size_t count);
|
||||
void Q_strcpy (char *dest, const char *src);
|
||||
void Q_strncpy (char *dest, const char *src, int32_t count);
|
||||
int32_t Q_strlen (const char *str);
|
||||
char *Q_strrchr (const char *s, char c);
|
||||
void Q_strcat (char *dest, const char *src);
|
||||
int32_t Q_strcmp (const char *s1, const char *s2);
|
||||
int32_t Q_strncmp (const char *s1, const char *s2, int32_t count);
|
||||
int32_t Q_atoi (const char *str);
|
||||
float Q_atof (const char *str);
|
||||
void Q_memset(void *dest, int32_t fill, size_t count);
|
||||
void Q_memcpy(void *dest, const void *src, size_t count);
|
||||
int32_t Q_memcmp(const void *m1, const void *m2, size_t count);
|
||||
void Q_strcpy(char *dest, const char *src);
|
||||
void Q_strncpy(char *dest, const char *src, int32_t count);
|
||||
int32_t Q_strlen(const char *str);
|
||||
char *Q_strrchr(const char *s, char c);
|
||||
void Q_strcat(char *dest, const char *src);
|
||||
int32_t Q_strcmp(const char *s1, const char *s2);
|
||||
int32_t Q_strncmp(const char *s1, const char *s2, int32_t count);
|
||||
int32_t Q_atoi(const char *str);
|
||||
float Q_atof(const char *str);
|
||||
|
||||
|
||||
#include "strl_fn.h"
|
||||
|
||||
/* locale-insensitive strcasecmp replacement functions: */
|
||||
extern int32_t q_strcasecmp (const char * s1, const char * s2);
|
||||
extern int32_t q_strncasecmp (const char *s1, const char *s2, size_t n);
|
||||
extern int32_t q_strcasecmp(const char * s1, const char * s2);
|
||||
extern int32_t q_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/* locale-insensitive case-insensitive alternative to strstr */
|
||||
extern char *q_strcasestr(const char *haystack, const char *needle);
|
||||
|
||||
/* locale-insensitive strlwr/upr replacement functions: */
|
||||
extern char *q_strlwr (char *str);
|
||||
extern char *q_strupr (char *str);
|
||||
extern char *q_strlwr(char *str);
|
||||
extern char *q_strupr(char *str);
|
||||
|
||||
/* snprintf, vsnprintf : always use our versions. */
|
||||
extern int32_t q_snprintf (char *str, size_t size, const char *format, ...) FUNC_PRINTF(3,4);
|
||||
extern int32_t q_vsnprintf(char *str, size_t size, const char *format, va_list args) FUNC_PRINTF(3,0);
|
||||
extern int32_t q_snprintf(char *str, size_t size, const char *format, ...) FUNC_PRINTF(3, 4);
|
||||
extern int32_t q_vsnprintf(char *str, size_t size, const char *format, va_list args) FUNC_PRINTF(3, 0);
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern char com_token[1024];
|
||||
extern bool com_eof;
|
||||
|
||||
const char *COM_Parse (const char *data);
|
||||
const char *COM_Parse(const char *data);
|
||||
|
||||
|
||||
extern int32_t com_argc;
|
||||
|
@ -170,24 +170,24 @@ extern int32_t safemode;
|
|||
-nomouse, -nojoy, -nolan
|
||||
*/
|
||||
|
||||
int32_t COM_CheckParm (const char *parm);
|
||||
int32_t COM_CheckParm(const char *parm);
|
||||
|
||||
void COM_Init (void);
|
||||
void COM_InitArgv (int32_t argc, char **argv);
|
||||
void COM_InitFilesystem (void);
|
||||
void COM_Init(void);
|
||||
void COM_InitArgv(int32_t argc, char **argv);
|
||||
void COM_InitFilesystem(void);
|
||||
|
||||
const char *COM_SkipPath (const char *pathname);
|
||||
void COM_StripExtension (const char *in, char *out, size_t outsize);
|
||||
void COM_FileBase (const char *in, char *out, size_t outsize);
|
||||
void COM_AddExtension (char *path, const char *extension, size_t len);
|
||||
const char *COM_SkipPath(const char *pathname);
|
||||
void COM_StripExtension(const char *in, char *out, size_t outsize);
|
||||
void COM_FileBase(const char *in, char *out, size_t outsize);
|
||||
void COM_AddExtension(char *path, const char *extension, size_t len);
|
||||
#if 0 /* COM_DefaultExtension can be dangerous */
|
||||
void COM_DefaultExtension (char *path, const char *extension, size_t len);
|
||||
void COM_DefaultExtension(char *path, const char *extension, size_t len);
|
||||
#endif
|
||||
const char *COM_FileGetExtension (const char *in); /* doesn't return NULL */
|
||||
void COM_ExtractExtension (const char *in, char *out, size_t outsize);
|
||||
void COM_CreatePath (char *path);
|
||||
const char *COM_FileGetExtension(const char *in); /* doesn't return NULL */
|
||||
void COM_ExtractExtension(const char *in, char *out, size_t outsize);
|
||||
void COM_CreatePath(char *path);
|
||||
|
||||
char *va (const char *format, ...) FUNC_PRINTF(1,2);
|
||||
char *va(const char *format, ...) FUNC_PRINTF(1, 2);
|
||||
// does a varargs printf into a temp buffer
|
||||
|
||||
|
||||
|
@ -228,36 +228,36 @@ extern char com_basedir[MAX_OSPATH];
|
|||
extern char com_gamedir[MAX_OSPATH];
|
||||
extern int32_t file_from_pak; // global indicating that file came from a pak
|
||||
|
||||
void COM_WriteFile (const char *filename, const void *data, int32_t len);
|
||||
int32_t COM_OpenFile (const char *filename, int32_t *handle, uint32_t *path_id);
|
||||
int32_t COM_FOpenFile (const char *filename, FILE **file, uint32_t *path_id);
|
||||
bool COM_FileExists (const char *filename, uint32_t *path_id);
|
||||
void COM_CloseFile (int32_t h);
|
||||
void COM_WriteFile(const char *filename, const void *data, int32_t len);
|
||||
int32_t COM_OpenFile(const char *filename, int32_t *handle, uint32_t *path_id);
|
||||
int32_t COM_FOpenFile(const char *filename, FILE **file, uint32_t *path_id);
|
||||
bool COM_FileExists(const char *filename, uint32_t *path_id);
|
||||
void COM_CloseFile(int32_t h);
|
||||
|
||||
// these procedures open a file using COM_FindFile and loads it into a proper
|
||||
// buffer. the buffer is allocated with a total size of com_filesize + 1. the
|
||||
// procedures differ by their buffer allocation method.
|
||||
byte *COM_LoadStackFile (const char *path, void *buffer, int32_t bufsize,
|
||||
byte *COM_LoadStackFile(const char *path, void *buffer, int32_t bufsize,
|
||||
uint32_t *path_id);
|
||||
// uses the specified stack stack buffer with the specified size
|
||||
// of bufsize. if bufsize is too short, uses temp hunk. the bufsize
|
||||
// must include the +1
|
||||
byte *COM_LoadTempFile (const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the temp hunk.
|
||||
byte *COM_LoadHunkFile (const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the hunk.
|
||||
byte *COM_LoadZoneFile (const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the zone.
|
||||
void COM_LoadCacheFile (const char *path, struct cache_user_s *cu,
|
||||
// uses the specified stack stack buffer with the specified size
|
||||
// of bufsize. if bufsize is too short, uses temp hunk. the bufsize
|
||||
// must include the +1
|
||||
byte *COM_LoadTempFile(const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the temp hunk.
|
||||
byte *COM_LoadHunkFile(const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the hunk.
|
||||
byte *COM_LoadZoneFile(const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the zone.
|
||||
void COM_LoadCacheFile(const char *path, struct cache_user_s *cu,
|
||||
uint32_t *path_id);
|
||||
// uses cache mem for allocating the buffer.
|
||||
byte *COM_LoadMallocFile (const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the system mem (malloc).
|
||||
// uses cache mem for allocating the buffer.
|
||||
byte *COM_LoadMallocFile(const char *path, uint32_t *path_id);
|
||||
// allocates the buffer on the system mem (malloc).
|
||||
|
||||
// Opens the given path directly, ignoring search paths.
|
||||
// Returns NULL on failure, or else a '\0'-terminated malloc'ed buffer.
|
||||
// Loads in "t" mode so CRLF to LF translation is performed on Windows.
|
||||
byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out);
|
||||
byte *COM_LoadMallocFile_TextMode_OSPath(const char *path, long *len_out);
|
||||
|
||||
// Attempts to parse an int32_t, followed by a newline.
|
||||
// Returns advanced buffer position.
|
||||
|
@ -296,13 +296,13 @@ int32_t FS_ferror(fshandle_t *fh);
|
|||
int32_t FS_fclose(fshandle_t *fh);
|
||||
int32_t FS_fgetc(fshandle_t *fh);
|
||||
char *FS_fgets(char *s, int32_t size, fshandle_t *fh);
|
||||
long FS_filelength (fshandle_t *fh);
|
||||
long FS_filelength(fshandle_t *fh);
|
||||
|
||||
|
||||
extern struct cvar_s registered;
|
||||
extern bool standard_quake, rogue, hipnotic;
|
||||
extern bool fitzmode;
|
||||
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
|
||||
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
|
||||
|
||||
#endif /* _Q_COMMON_H */
|
||||
|
||||
|
|
581
source/console.c
581
source/console.c
File diff suppressed because it is too large
Load Diff
|
@ -34,36 +34,36 @@ extern byte *con_chars;
|
|||
|
||||
extern char con_lastcenterstring[]; //johnfitz
|
||||
|
||||
void Con_DrawCharacter (int32_t cx, int32_t line, int32_t num);
|
||||
void Con_DrawCharacter(int32_t cx, int32_t line, int32_t num);
|
||||
|
||||
void Con_CheckResize (void);
|
||||
void Con_Init (void);
|
||||
void Con_DrawConsole (int32_t lines, bool drawinput);
|
||||
void Con_Printf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DWarning (const char *fmt, ...) FUNC_PRINTF(1,2); //ericw
|
||||
void Con_Warning (const char *fmt, ...) FUNC_PRINTF(1,2); //johnfitz
|
||||
void Con_DPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DPrintf2 (const char *fmt, ...) FUNC_PRINTF(1,2); //johnfitz
|
||||
void Con_SafePrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Con_DrawNotify (void);
|
||||
void Con_ClearNotify (void);
|
||||
void Con_ToggleConsole_f (void);
|
||||
void Con_CheckResize(void);
|
||||
void Con_Init(void);
|
||||
void Con_DrawConsole(int32_t lines, bool drawinput);
|
||||
void Con_Printf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
void Con_DWarning(const char *fmt, ...) FUNC_PRINTF(1, 2); //ericw
|
||||
void Con_Warning(const char *fmt, ...) FUNC_PRINTF(1, 2); //johnfitz
|
||||
void Con_DPrintf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
void Con_DPrintf2(const char *fmt, ...) FUNC_PRINTF(1, 2); //johnfitz
|
||||
void Con_SafePrintf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
void Con_DrawNotify(void);
|
||||
void Con_ClearNotify(void);
|
||||
void Con_ToggleConsole_f(void);
|
||||
|
||||
void Con_NotifyBox (const char *text); // during startup for sound / cd warnings
|
||||
void Con_NotifyBox(const char *text); // during startup for sound / cd warnings
|
||||
|
||||
void Con_Show (void);
|
||||
void Con_Hide (void);
|
||||
void Con_Show(void);
|
||||
void Con_Hide(void);
|
||||
|
||||
const char *Con_Quakebar (int32_t len);
|
||||
void Con_TabComplete (void);
|
||||
void Con_LogCenterPrint (const char *str);
|
||||
const char *Con_Quakebar(int32_t len);
|
||||
void Con_TabComplete(void);
|
||||
void Con_LogCenterPrint(const char *str);
|
||||
|
||||
//
|
||||
// debuglog
|
||||
//
|
||||
void LOG_Init (quakeparms_t *parms);
|
||||
void LOG_Close (void);
|
||||
void Con_DebugLog (const char *msg);
|
||||
void LOG_Init(quakeparms_t *parms);
|
||||
void LOG_Close(void);
|
||||
void Con_DebugLog(const char *msg);
|
||||
|
||||
#endif /* __CONSOLE_H */
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@ uint16_t CRC_Value(uint16_t crcvalue)
|
|||
}
|
||||
|
||||
//johnfitz -- texture crc
|
||||
uint16_t CRC_Block (const byte *start, int32_t count)
|
||||
uint16_t CRC_Block(const byte *start, int32_t count)
|
||||
{
|
||||
uint16_t crc;
|
||||
|
||||
CRC_Init (&crc);
|
||||
while (count--)
|
||||
CRC_Init(&crc);
|
||||
while(count--)
|
||||
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
|
||||
|
||||
return crc;
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
void CRC_Init(uint16_t *crcvalue);
|
||||
void CRC_ProcessByte(uint16_t *crcvalue, byte data);
|
||||
uint16_t CRC_Value(uint16_t crcvalue);
|
||||
uint16_t CRC_Block (const byte *start, int32_t count); //johnfitz -- texture crc
|
||||
uint16_t CRC_Block(const byte *start, int32_t count); //johnfitz -- texture crc
|
||||
|
||||
#endif /* _QUAKE_CRC_H */
|
||||
|
||||
|
|
307
source/cvar.c
307
source/cvar.c
|
@ -32,22 +32,22 @@ static char cvar_null_string[] = "";
|
|||
//
|
||||
//==============================================================================
|
||||
|
||||
void Cvar_Reset (const char *name); //johnfitz
|
||||
void Cvar_Reset(const char *name); //johnfitz
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_List_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_List_f (void)
|
||||
void Cvar_List_f(void)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
const char *partial;
|
||||
int32_t len, count;
|
||||
|
||||
if (Cmd_Argc() > 1)
|
||||
if(Cmd_Argc() > 1)
|
||||
{
|
||||
partial = Cmd_Argv (1);
|
||||
partial = Cmd_Argv(1);
|
||||
len = Q_strlen(partial);
|
||||
}
|
||||
else
|
||||
|
@ -57,13 +57,13 @@ void Cvar_List_f (void)
|
|||
}
|
||||
|
||||
count = 0;
|
||||
for (cvar = cvar_vars ; cvar ; cvar = cvar->next)
|
||||
for(cvar = cvar_vars ; cvar ; cvar = cvar->next)
|
||||
{
|
||||
if (partial && Q_strncmp(partial, cvar->name, len))
|
||||
if(partial && Q_strncmp(partial, cvar->name, len))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Con_SafePrintf ("%s%s %s \"%s\"\n",
|
||||
Con_SafePrintf("%s%s %s \"%s\"\n",
|
||||
(cvar->flags & CVAR_ARCHIVE) ? "*" : " ",
|
||||
(cvar->flags & CVAR_NOTIFY) ? "s" : " ",
|
||||
cvar->name,
|
||||
|
@ -71,12 +71,12 @@ void Cvar_List_f (void)
|
|||
count++;
|
||||
}
|
||||
|
||||
Con_SafePrintf ("%" PRIi32 " cvars", count);
|
||||
if (partial)
|
||||
Con_SafePrintf("%" PRIi32 " cvars", count);
|
||||
if(partial)
|
||||
{
|
||||
Con_SafePrintf (" beginning with \"%s\"", partial);
|
||||
Con_SafePrintf(" beginning with \"%s\"", partial);
|
||||
}
|
||||
Con_SafePrintf ("\n");
|
||||
Con_SafePrintf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -84,19 +84,19 @@ void Cvar_List_f (void)
|
|||
Cvar_Inc_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Inc_f (void)
|
||||
void Cvar_Inc_f(void)
|
||||
{
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("inc <cvar> [amount] : increment cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
Cvar_SetValue (Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + 1);
|
||||
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + 1);
|
||||
break;
|
||||
case 3:
|
||||
Cvar_SetValue (Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + Q_atof(Cmd_Argv(2)));
|
||||
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + Q_atof(Cmd_Argv(2)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -106,19 +106,19 @@ void Cvar_Inc_f (void)
|
|||
Cvar_Toggle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Toggle_f (void)
|
||||
void Cvar_Toggle_f(void)
|
||||
{
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("toggle <cvar> : toggle cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Cvar_VariableValue(Cmd_Argv(1)))
|
||||
Cvar_Set (Cmd_Argv(1), "0");
|
||||
if(Cvar_VariableValue(Cmd_Argv(1)))
|
||||
Cvar_Set(Cmd_Argv(1), "0");
|
||||
else
|
||||
Cvar_Set (Cmd_Argv(1), "1");
|
||||
Cvar_Set(Cmd_Argv(1), "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ void Cvar_Toggle_f (void)
|
|||
Cvar_Cycle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Cycle_f (void)
|
||||
void Cvar_Cycle_f(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (Cmd_Argc() < 3)
|
||||
if(Cmd_Argc() < 3)
|
||||
{
|
||||
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
|
||||
return;
|
||||
|
@ -141,29 +141,29 @@ void Cvar_Cycle_f (void)
|
|||
//loop through the args until you find one that matches the current cvar value.
|
||||
//yes, this will get stuck on a list that contains the same value twice.
|
||||
//it's not worth dealing with, and i'm not even sure it can be dealt with.
|
||||
for (i = 2; i < Cmd_Argc(); i++)
|
||||
for(i = 2; i < Cmd_Argc(); i++)
|
||||
{
|
||||
//zero is assumed to be a string, even though it could actually be zero. The worst case
|
||||
//is that the first time you call this command, it won't match on zero when it should, but after that,
|
||||
//it will be comparing strings that all had the same source (the user) so it will work.
|
||||
if (Q_atof(Cmd_Argv(i)) == 0)
|
||||
if(Q_atof(Cmd_Argv(i)) == 0)
|
||||
{
|
||||
if (!strcmp(Cmd_Argv(i), Cvar_VariableString(Cmd_Argv(1))))
|
||||
if(!strcmp(Cmd_Argv(i), Cvar_VariableString(Cmd_Argv(1))))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Q_atof(Cmd_Argv(i)) == Cvar_VariableValue(Cmd_Argv(1)))
|
||||
if(Q_atof(Cmd_Argv(i)) == Cvar_VariableValue(Cmd_Argv(1)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == Cmd_Argc())
|
||||
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2)); // no match
|
||||
else if (i + 1 == Cmd_Argc())
|
||||
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2)); // matched last value in list
|
||||
if(i == Cmd_Argc())
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // no match
|
||||
else if(i + 1 == Cmd_Argc())
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // matched last value in list
|
||||
else
|
||||
Cvar_Set (Cmd_Argv(1), Cmd_Argv(i+1)); // matched earlier in list
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(i + 1)); // matched earlier in list
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -171,16 +171,16 @@ void Cvar_Cycle_f (void)
|
|||
Cvar_Reset_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Reset_f (void)
|
||||
void Cvar_Reset_f(void)
|
||||
{
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf ("reset <cvar> : reset cvar to default\n");
|
||||
Con_Printf("reset <cvar> : reset cvar to default\n");
|
||||
break;
|
||||
case 2:
|
||||
Cvar_Reset (Cmd_Argv(1));
|
||||
Cvar_Reset(Cmd_Argv(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -190,12 +190,12 @@ void Cvar_Reset_f (void)
|
|||
Cvar_ResetAll_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetAll_f (void)
|
||||
void Cvar_ResetAll_f(void)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
Cvar_Reset (var->name);
|
||||
for(var = cvar_vars ; var ; var = var->next)
|
||||
Cvar_Reset(var->name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -203,12 +203,12 @@ void Cvar_ResetAll_f (void)
|
|||
Cvar_ResetCfg_f -- QuakeSpasm
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetCfg_f (void)
|
||||
void Cvar_ResetCfg_f(void)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
if (var->flags & CVAR_ARCHIVE) Cvar_Reset (var->name);
|
||||
for(var = cvar_vars ; var ; var = var->next)
|
||||
if(var->flags & CVAR_ARCHIVE) Cvar_Reset(var->name);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
@ -223,15 +223,15 @@ Cvar_Init -- johnfitz
|
|||
============
|
||||
*/
|
||||
|
||||
void Cvar_Init (void)
|
||||
void Cvar_Init(void)
|
||||
{
|
||||
Cmd_AddCommand ("cvarlist", Cvar_List_f);
|
||||
Cmd_AddCommand ("toggle", Cvar_Toggle_f);
|
||||
Cmd_AddCommand ("cycle", Cvar_Cycle_f);
|
||||
Cmd_AddCommand ("inc", Cvar_Inc_f);
|
||||
Cmd_AddCommand ("reset", Cvar_Reset_f);
|
||||
Cmd_AddCommand ("resetall", Cvar_ResetAll_f);
|
||||
Cmd_AddCommand ("resetcfg", Cvar_ResetCfg_f);
|
||||
Cmd_AddCommand("cvarlist", Cvar_List_f);
|
||||
Cmd_AddCommand("toggle", Cvar_Toggle_f);
|
||||
Cmd_AddCommand("cycle", Cvar_Cycle_f);
|
||||
Cmd_AddCommand("inc", Cvar_Inc_f);
|
||||
Cmd_AddCommand("reset", Cvar_Reset_f);
|
||||
Cmd_AddCommand("resetall", Cvar_ResetAll_f);
|
||||
Cmd_AddCommand("resetcfg", Cvar_ResetCfg_f);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
@ -245,27 +245,27 @@ void Cvar_Init (void)
|
|||
Cvar_FindVar
|
||||
============
|
||||
*/
|
||||
cvar_t *Cvar_FindVar (const char *var_name)
|
||||
cvar_t *Cvar_FindVar(const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
for(var = cvar_vars ; var ; var = var->next)
|
||||
{
|
||||
if (!Q_strcmp(var_name, var->name))
|
||||
if(!Q_strcmp(var_name, var->name))
|
||||
return var;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cvar_t *Cvar_FindVarAfter (const char *prev_name, uint32_t with_flags)
|
||||
cvar_t *Cvar_FindVarAfter(const char *prev_name, uint32_t with_flags)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
if (*prev_name)
|
||||
if(*prev_name)
|
||||
{
|
||||
var = Cvar_FindVar (prev_name);
|
||||
if (!var)
|
||||
var = Cvar_FindVar(prev_name);
|
||||
if(!var)
|
||||
return NULL;
|
||||
var = var->next;
|
||||
}
|
||||
|
@ -273,9 +273,9 @@ cvar_t *Cvar_FindVarAfter (const char *prev_name, uint32_t with_flags)
|
|||
var = cvar_vars;
|
||||
|
||||
// search for the next cvar matching the needed flags
|
||||
while (var)
|
||||
while(var)
|
||||
{
|
||||
if ((var->flags & with_flags) || !with_flags)
|
||||
if((var->flags & with_flags) || !with_flags)
|
||||
break;
|
||||
var = var->next;
|
||||
}
|
||||
|
@ -287,25 +287,25 @@ cvar_t *Cvar_FindVarAfter (const char *prev_name, uint32_t with_flags)
|
|||
Cvar_LockVar
|
||||
============
|
||||
*/
|
||||
void Cvar_LockVar (const char *var_name)
|
||||
void Cvar_LockVar(const char *var_name)
|
||||
{
|
||||
cvar_t *var = Cvar_FindVar (var_name);
|
||||
if (var)
|
||||
cvar_t *var = Cvar_FindVar(var_name);
|
||||
if(var)
|
||||
var->flags |= CVAR_LOCKED;
|
||||
}
|
||||
|
||||
void Cvar_UnlockVar (const char *var_name)
|
||||
void Cvar_UnlockVar(const char *var_name)
|
||||
{
|
||||
cvar_t *var = Cvar_FindVar (var_name);
|
||||
if (var)
|
||||
cvar_t *var = Cvar_FindVar(var_name);
|
||||
if(var)
|
||||
var->flags &= ~CVAR_LOCKED;
|
||||
}
|
||||
|
||||
void Cvar_UnlockAll (void)
|
||||
void Cvar_UnlockAll(void)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
for(var = cvar_vars ; var ; var = var->next)
|
||||
{
|
||||
var->flags &= ~CVAR_LOCKED;
|
||||
}
|
||||
|
@ -316,14 +316,14 @@ void Cvar_UnlockAll (void)
|
|||
Cvar_VariableValue
|
||||
============
|
||||
*/
|
||||
float Cvar_VariableValue (const char *var_name)
|
||||
float Cvar_VariableValue(const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
if (!var)
|
||||
var = Cvar_FindVar(var_name);
|
||||
if(!var)
|
||||
return 0;
|
||||
return Q_atof (var->string);
|
||||
return Q_atof(var->string);
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,12 +332,12 @@ float Cvar_VariableValue (const char *var_name)
|
|||
Cvar_VariableString
|
||||
============
|
||||
*/
|
||||
const char *Cvar_VariableString (const char *var_name)
|
||||
const char *Cvar_VariableString(const char *var_name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
if (!var)
|
||||
var = Cvar_FindVar(var_name);
|
||||
if(!var)
|
||||
return cvar_null_string;
|
||||
return var->string;
|
||||
}
|
||||
|
@ -348,19 +348,19 @@ const char *Cvar_VariableString (const char *var_name)
|
|||
Cvar_CompleteVariable
|
||||
============
|
||||
*/
|
||||
const char *Cvar_CompleteVariable (const char *partial)
|
||||
const char *Cvar_CompleteVariable(const char *partial)
|
||||
{
|
||||
cvar_t *cvar;
|
||||
int32_t len;
|
||||
|
||||
len = Q_strlen(partial);
|
||||
if (!len)
|
||||
if(!len)
|
||||
return NULL;
|
||||
|
||||
// check functions
|
||||
for (cvar = cvar_vars ; cvar ; cvar = cvar->next)
|
||||
for(cvar = cvar_vars ; cvar ; cvar = cvar->next)
|
||||
{
|
||||
if (!Q_strncmp(partial, cvar->name, len))
|
||||
if(!Q_strncmp(partial, cvar->name, len))
|
||||
return cvar->name;
|
||||
}
|
||||
|
||||
|
@ -372,79 +372,79 @@ const char *Cvar_CompleteVariable (const char *partial)
|
|||
Cvar_Reset -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Reset (const char *name)
|
||||
void Cvar_Reset(const char *name)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (name);
|
||||
if (!var)
|
||||
Con_Printf ("variable \"%s\" not found\n", name);
|
||||
var = Cvar_FindVar(name);
|
||||
if(!var)
|
||||
Con_Printf("variable \"%s\" not found\n", name);
|
||||
else
|
||||
Cvar_SetQuick (var, var->default_string);
|
||||
Cvar_SetQuick(var, var->default_string);
|
||||
}
|
||||
|
||||
void Cvar_SetQuick (cvar_t *var, const char *value)
|
||||
void Cvar_SetQuick(cvar_t *var, const char *value)
|
||||
{
|
||||
if (var->flags & (CVAR_ROM|CVAR_LOCKED))
|
||||
if(var->flags & (CVAR_ROM | CVAR_LOCKED))
|
||||
return;
|
||||
if (!(var->flags & CVAR_REGISTERED))
|
||||
if(!(var->flags & CVAR_REGISTERED))
|
||||
return;
|
||||
|
||||
if (!var->string)
|
||||
var->string = Z_Strdup (value);
|
||||
if(!var->string)
|
||||
var->string = Z_Strdup(value);
|
||||
else
|
||||
{
|
||||
int32_t len;
|
||||
|
||||
if (!strcmp(var->string, value))
|
||||
if(!strcmp(var->string, value))
|
||||
return; // no change
|
||||
|
||||
var->flags |= CVAR_CHANGED;
|
||||
len = Q_strlen (value);
|
||||
if (len != Q_strlen(var->string))
|
||||
len = Q_strlen(value);
|
||||
if(len != Q_strlen(var->string))
|
||||
{
|
||||
Z_Free ((void *)var->string);
|
||||
var->string = (char *) Z_Malloc (len + 1);
|
||||
Z_Free((void *)var->string);
|
||||
var->string = (char *) Z_Malloc(len + 1);
|
||||
}
|
||||
memcpy ((char *)var->string, value, len + 1);
|
||||
memcpy((char *)var->string, value, len + 1);
|
||||
}
|
||||
|
||||
var->value = Q_atof (var->string);
|
||||
var->value = Q_atof(var->string);
|
||||
|
||||
//johnfitz -- save initial value for "reset" command
|
||||
if (!var->default_string)
|
||||
var->default_string = Z_Strdup (var->string);
|
||||
if(!var->default_string)
|
||||
var->default_string = Z_Strdup(var->string);
|
||||
//johnfitz -- during initialization, update default too
|
||||
else if (!host_initialized)
|
||||
else if(!host_initialized)
|
||||
{
|
||||
// Sys_Printf("changing default of %s: %s -> %s\n",
|
||||
// var->name, var->default_string, var->string);
|
||||
Z_Free ((void *)var->default_string);
|
||||
var->default_string = Z_Strdup (var->string);
|
||||
Z_Free((void *)var->default_string);
|
||||
var->default_string = Z_Strdup(var->string);
|
||||
}
|
||||
//johnfitz
|
||||
|
||||
if (var->callback)
|
||||
var->callback (var);
|
||||
if(var->callback)
|
||||
var->callback(var);
|
||||
}
|
||||
|
||||
void Cvar_SetValueQuick (cvar_t *var, const float value)
|
||||
void Cvar_SetValueQuick(cvar_t *var, const float value)
|
||||
{
|
||||
char val[32], *ptr = val;
|
||||
|
||||
if (value == (float)((int32_t)value))
|
||||
q_snprintf (val, sizeof(val), "%" PRIi32 "", (int32_t)value);
|
||||
if(value == (float)((int32_t)value))
|
||||
q_snprintf(val, sizeof(val), "%" PRIi32 "", (int32_t)value);
|
||||
else
|
||||
{
|
||||
q_snprintf (val, sizeof(val), "%f", value);
|
||||
q_snprintf(val, sizeof(val), "%f", value);
|
||||
// kill trailing zeroes
|
||||
while (*ptr)
|
||||
while(*ptr)
|
||||
ptr++;
|
||||
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
while(--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
Cvar_SetQuick (var, val);
|
||||
Cvar_SetQuick(var, val);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -452,18 +452,19 @@ void Cvar_SetValueQuick (cvar_t *var, const float value)
|
|||
Cvar_Set
|
||||
============
|
||||
*/
|
||||
void Cvar_Set (const char *var_name, const char *value)
|
||||
void Cvar_Set(const char *var_name, const char *value)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
var = Cvar_FindVar (var_name);
|
||||
if (!var)
|
||||
{ // there is an error in C code if this happens
|
||||
Con_Printf ("Cvar_Set: variable %s not found\n", var_name);
|
||||
var = Cvar_FindVar(var_name);
|
||||
if(!var)
|
||||
{
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf("Cvar_Set: variable %s not found\n", var_name);
|
||||
return;
|
||||
}
|
||||
|
||||
Cvar_SetQuick (var, value);
|
||||
Cvar_SetQuick(var, value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -471,23 +472,23 @@ void Cvar_Set (const char *var_name, const char *value)
|
|||
Cvar_SetValue
|
||||
============
|
||||
*/
|
||||
void Cvar_SetValue (const char *var_name, const float value)
|
||||
void Cvar_SetValue(const char *var_name, const float value)
|
||||
{
|
||||
char val[32], *ptr = val;
|
||||
|
||||
if (value == (float)((int32_t)value))
|
||||
q_snprintf (val, sizeof(val), "%" PRIi32 "", (int32_t)value);
|
||||
if(value == (float)((int32_t)value))
|
||||
q_snprintf(val, sizeof(val), "%" PRIi32 "", (int32_t)value);
|
||||
else
|
||||
{
|
||||
q_snprintf (val, sizeof(val), "%f", value);
|
||||
q_snprintf(val, sizeof(val), "%f", value);
|
||||
// kill trailing zeroes
|
||||
while (*ptr)
|
||||
while(*ptr)
|
||||
ptr++;
|
||||
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
while(--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
Cvar_Set (var_name, val);
|
||||
Cvar_Set(var_name, val);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -495,13 +496,13 @@ void Cvar_SetValue (const char *var_name, const float value)
|
|||
Cvar_SetROM
|
||||
============
|
||||
*/
|
||||
void Cvar_SetROM (const char *var_name, const char *value)
|
||||
void Cvar_SetROM(const char *var_name, const char *value)
|
||||
{
|
||||
cvar_t *var = Cvar_FindVar (var_name);
|
||||
if (var)
|
||||
cvar_t *var = Cvar_FindVar(var_name);
|
||||
if(var)
|
||||
{
|
||||
var->flags &= ~CVAR_ROM;
|
||||
Cvar_SetQuick (var, value);
|
||||
Cvar_SetQuick(var, value);
|
||||
var->flags |= CVAR_ROM;
|
||||
}
|
||||
}
|
||||
|
@ -511,13 +512,13 @@ void Cvar_SetROM (const char *var_name, const char *value)
|
|||
Cvar_SetValueROM
|
||||
============
|
||||
*/
|
||||
void Cvar_SetValueROM (const char *var_name, const float value)
|
||||
void Cvar_SetValueROM(const char *var_name, const float value)
|
||||
{
|
||||
cvar_t *var = Cvar_FindVar (var_name);
|
||||
if (var)
|
||||
cvar_t *var = Cvar_FindVar(var_name);
|
||||
if(var)
|
||||
{
|
||||
var->flags &= ~CVAR_ROM;
|
||||
Cvar_SetValueQuick (var, value);
|
||||
Cvar_SetValueQuick(var, value);
|
||||
var->flags |= CVAR_ROM;
|
||||
}
|
||||
}
|
||||
|
@ -529,29 +530,29 @@ Cvar_RegisterVariable
|
|||
Adds a freestanding variable to the variable list.
|
||||
============
|
||||
*/
|
||||
void Cvar_RegisterVariable (cvar_t *variable)
|
||||
void Cvar_RegisterVariable(cvar_t *variable)
|
||||
{
|
||||
char value[512];
|
||||
bool set_rom;
|
||||
cvar_t *cursor,*prev; //johnfitz -- sorted list insert
|
||||
cvar_t *cursor, *prev; //johnfitz -- sorted list insert
|
||||
|
||||
// first check to see if it has already been defined
|
||||
if (Cvar_FindVar (variable->name))
|
||||
if(Cvar_FindVar(variable->name))
|
||||
{
|
||||
Con_Printf ("Can't register variable %s, already defined\n", variable->name);
|
||||
Con_Printf("Can't register variable %s, already defined\n", variable->name);
|
||||
return;
|
||||
}
|
||||
|
||||
// check for overlap with a command
|
||||
if (Cmd_Exists (variable->name))
|
||||
if(Cmd_Exists(variable->name))
|
||||
{
|
||||
Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name);
|
||||
Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
|
||||
return;
|
||||
}
|
||||
|
||||
// link the variable in
|
||||
//johnfitz -- insert each entry in alphabetical order
|
||||
if (cvar_vars == NULL ||
|
||||
if(cvar_vars == NULL ||
|
||||
strcmp(variable->name, cvar_vars->name) < 0) // insert at front
|
||||
{
|
||||
variable->next = cvar_vars;
|
||||
|
@ -561,7 +562,7 @@ void Cvar_RegisterVariable (cvar_t *variable)
|
|||
{
|
||||
prev = cvar_vars;
|
||||
cursor = cvar_vars->next;
|
||||
while (cursor && (strcmp(variable->name, cursor->name) > 0))
|
||||
while(cursor && (strcmp(variable->name, cursor->name) > 0))
|
||||
{
|
||||
prev = cursor;
|
||||
cursor = cursor->next;
|
||||
|
@ -573,18 +574,18 @@ void Cvar_RegisterVariable (cvar_t *variable)
|
|||
variable->flags |= CVAR_REGISTERED;
|
||||
|
||||
// copy the value off, because future sets will Z_Free it
|
||||
q_strlcpy (value, variable->string, sizeof(value));
|
||||
q_strlcpy(value, variable->string, sizeof(value));
|
||||
variable->string = NULL;
|
||||
variable->default_string = NULL;
|
||||
|
||||
if (!(variable->flags & CVAR_CALLBACK))
|
||||
if(!(variable->flags & CVAR_CALLBACK))
|
||||
variable->callback = NULL;
|
||||
|
||||
// set it through the function to be consistent
|
||||
set_rom = (variable->flags & CVAR_ROM);
|
||||
variable->flags &= ~CVAR_ROM;
|
||||
Cvar_SetQuick (variable, value);
|
||||
if (set_rom)
|
||||
Cvar_SetQuick(variable, value);
|
||||
if(set_rom)
|
||||
variable->flags |= CVAR_ROM;
|
||||
}
|
||||
|
||||
|
@ -595,10 +596,10 @@ Cvar_SetCallback
|
|||
Set a callback function to the var
|
||||
============
|
||||
*/
|
||||
void Cvar_SetCallback (cvar_t *var, cvarcallback_t func)
|
||||
void Cvar_SetCallback(cvar_t *var, cvarcallback_t func)
|
||||
{
|
||||
var->callback = func;
|
||||
if (func)
|
||||
if(func)
|
||||
var->flags |= CVAR_CALLBACK;
|
||||
else var->flags &= ~CVAR_CALLBACK;
|
||||
}
|
||||
|
@ -610,23 +611,23 @@ Cvar_Command
|
|||
Handles variable inspection and changing from the console
|
||||
============
|
||||
*/
|
||||
bool Cvar_Command (void)
|
||||
bool Cvar_Command(void)
|
||||
{
|
||||
cvar_t *v;
|
||||
|
||||
// check variables
|
||||
v = Cvar_FindVar (Cmd_Argv(0));
|
||||
if (!v)
|
||||
v = Cvar_FindVar(Cmd_Argv(0));
|
||||
if(!v)
|
||||
return false;
|
||||
|
||||
// perform a variable print or set
|
||||
if (Cmd_Argc() == 1)
|
||||
if(Cmd_Argc() == 1)
|
||||
{
|
||||
Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
|
||||
Con_Printf("\"%s\" is \"%s\"\n", v->name, v->string);
|
||||
return true;
|
||||
}
|
||||
|
||||
Cvar_Set (v->name, Cmd_Argv(1));
|
||||
Cvar_Set(v->name, Cmd_Argv(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -639,14 +640,14 @@ Writes lines containing "set variable value" for all variables
|
|||
with the archive flag set to true.
|
||||
============
|
||||
*/
|
||||
void Cvar_WriteVariables (FILE *f)
|
||||
void Cvar_WriteVariables(FILE *f)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
for(var = cvar_vars ; var ; var = var->next)
|
||||
{
|
||||
if (var->flags & CVAR_ARCHIVE)
|
||||
fprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||
if(var->flags & CVAR_ARCHIVE)
|
||||
fprintf(f, "%s \"%s\"\n", var->name, var->string);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ interface from being ambiguous.
|
|||
#define CVAR_CALLBACK (1U << 16) // var has a callback
|
||||
|
||||
|
||||
typedef void (*cvarcallback_t) (struct cvar_s *);
|
||||
typedef void (*cvarcallback_t)(struct cvar_s *);
|
||||
|
||||
typedef struct cvar_s
|
||||
{
|
||||
|
@ -88,54 +88,54 @@ typedef struct cvar_s
|
|||
struct cvar_s *next;
|
||||
} cvar_t;
|
||||
|
||||
void Cvar_RegisterVariable (cvar_t *variable);
|
||||
void Cvar_RegisterVariable(cvar_t *variable);
|
||||
// registers a cvar that already has the name, string, and optionally
|
||||
// the archive elements set.
|
||||
|
||||
void Cvar_SetCallback (cvar_t *var, cvarcallback_t func);
|
||||
void Cvar_SetCallback(cvar_t *var, cvarcallback_t func);
|
||||
// set a callback function to the var
|
||||
|
||||
void Cvar_Set (const char *var_name, const char *value);
|
||||
void Cvar_Set(const char *var_name, const char *value);
|
||||
// equivelant to "<name> <variable>" typed at the console
|
||||
|
||||
void Cvar_SetValue (const char *var_name, const float value);
|
||||
void Cvar_SetValue(const char *var_name, const float value);
|
||||
// expands value to a string and calls Cvar_Set
|
||||
|
||||
void Cvar_SetROM (const char *var_name, const char *value);
|
||||
void Cvar_SetValueROM (const char *var_name, const float value);
|
||||
void Cvar_SetROM(const char *var_name, const char *value);
|
||||
void Cvar_SetValueROM(const char *var_name, const float value);
|
||||
// sets a CVAR_ROM variable from within the engine
|
||||
|
||||
void Cvar_SetQuick (cvar_t *var, const char *value);
|
||||
void Cvar_SetValueQuick (cvar_t *var, const float value);
|
||||
void Cvar_SetQuick(cvar_t *var, const char *value);
|
||||
void Cvar_SetValueQuick(cvar_t *var, const float value);
|
||||
// these two accept a cvar pointer instead of a var name,
|
||||
// but are otherwise identical to the "non-Quick" versions.
|
||||
// the cvar MUST be registered.
|
||||
|
||||
float Cvar_VariableValue (const char *var_name);
|
||||
float Cvar_VariableValue(const char *var_name);
|
||||
// returns 0 if not defined or non numeric
|
||||
|
||||
const char *Cvar_VariableString (const char *var_name);
|
||||
const char *Cvar_VariableString(const char *var_name);
|
||||
// returns an empty string if not defined
|
||||
|
||||
bool Cvar_Command (void);
|
||||
bool Cvar_Command(void);
|
||||
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
|
||||
// command. Returns true if the command was a variable reference that
|
||||
// was handled. (print or change)
|
||||
|
||||
void Cvar_WriteVariables (FILE *f);
|
||||
void Cvar_WriteVariables(FILE *f);
|
||||
// Writes lines containing "set variable value" for all variables
|
||||
// with the CVAR_ARCHIVE flag set
|
||||
|
||||
cvar_t *Cvar_FindVar (const char *var_name);
|
||||
cvar_t *Cvar_FindVarAfter (const char *prev_name, uint32_t with_flags);
|
||||
cvar_t *Cvar_FindVar(const char *var_name);
|
||||
cvar_t *Cvar_FindVarAfter(const char *prev_name, uint32_t with_flags);
|
||||
|
||||
void Cvar_LockVar (const char *var_name);
|
||||
void Cvar_UnlockVar (const char *var_name);
|
||||
void Cvar_UnlockAll (void);
|
||||
void Cvar_LockVar(const char *var_name);
|
||||
void Cvar_UnlockVar(const char *var_name);
|
||||
void Cvar_UnlockAll(void);
|
||||
|
||||
void Cvar_Init (void);
|
||||
void Cvar_Init(void);
|
||||
|
||||
const char *Cvar_CompleteVariable (const char *partial);
|
||||
const char *Cvar_CompleteVariable(const char *partial);
|
||||
// attempts to match a partial variable name for command line completion
|
||||
// returns NULL if nothing fits
|
||||
|
||||
|
|
|
@ -28,21 +28,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern qpic_t *draw_disc; // also used on sbar
|
||||
|
||||
void Draw_Init (void);
|
||||
void Draw_Character (int32_t x, int32_t y, int32_t num);
|
||||
void Draw_DebugChar (char num);
|
||||
void Draw_Pic (int32_t x, int32_t y, qpic_t *pic);
|
||||
void Draw_TransPicTranslate (int32_t x, int32_t y, qpic_t *pic, int32_t top, int32_t bottom); //johnfitz -- more parameters
|
||||
void Draw_ConsoleBackground (void); //johnfitz -- removed parameter int32_t lines
|
||||
void Draw_TileClear (int32_t x, int32_t y, int32_t w, int32_t h);
|
||||
void Draw_Fill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t c, float alpha); //johnfitz -- added alpha
|
||||
void Draw_FadeScreen (void);
|
||||
void Draw_String (int32_t x, int32_t y, const char *str);
|
||||
qpic_t *Draw_PicFromWad (const char *name);
|
||||
qpic_t *Draw_CachePic (const char *path);
|
||||
void Draw_NewGame (void);
|
||||
void Draw_Init(void);
|
||||
void Draw_Character(int32_t x, int32_t y, int32_t num);
|
||||
void Draw_DebugChar(char num);
|
||||
void Draw_Pic(int32_t x, int32_t y, qpic_t *pic);
|
||||
void Draw_TransPicTranslate(int32_t x, int32_t y, qpic_t *pic, int32_t top, int32_t bottom); //johnfitz -- more parameters
|
||||
void Draw_ConsoleBackground(void); //johnfitz -- removed parameter int32_t lines
|
||||
void Draw_TileClear(int32_t x, int32_t y, int32_t w, int32_t h);
|
||||
void Draw_Fill(int32_t x, int32_t y, int32_t w, int32_t h, int32_t c, float alpha); //johnfitz -- added alpha
|
||||
void Draw_FadeScreen(void);
|
||||
void Draw_String(int32_t x, int32_t y, const char *str);
|
||||
qpic_t *Draw_PicFromWad(const char *name);
|
||||
qpic_t *Draw_CachePic(const char *path);
|
||||
void Draw_NewGame(void);
|
||||
|
||||
void GL_SetCanvas (canvastype newcanvas); //johnfitz
|
||||
void GL_SetCanvas(canvastype newcanvas); //johnfitz
|
||||
|
||||
#endif /* _QUAKE_DRAW_H */
|
||||
|
||||
|
|
|
@ -58,54 +58,60 @@
|
|||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC((f)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
char *p1 = strchr(_the_path, '/');
|
||||
char *p2 = strchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 < p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 < p2) ? p1 : p2;
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline char *FIND_LAST_DIRSEP(char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
char *p1 = strrchr(_the_path, '/');
|
||||
char *p2 = strrchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 > p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 > p2) ? p1 : p2;
|
||||
}
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
const char *p1 = strchr(_the_path, '/');
|
||||
const char *p2 = strchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 < p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 < p2) ? p1 : p2;
|
||||
}
|
||||
static inline const char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
const char *p1 = strrchr(_the_path, '/');
|
||||
const char *p2 = strrchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 > p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 > p2) ? p1 : p2;
|
||||
}
|
||||
#else
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
char *p1 = strchr(_the_path, '/');
|
||||
char *p2 = strchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 < p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 < p2) ? p1 : p2;
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
/* FIXME: What about C:FOO ? */
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
/* FIXME: What about C:FOO ? */
|
||||
char *p1 = strrchr(_the_path, '/');
|
||||
char *p2 = strrchr(_the_path, '\\');
|
||||
if (p1 == NULL) return p2;
|
||||
if (p2 == NULL) return p1;
|
||||
return (p1 > p2)? p1 : p2;
|
||||
if(p1 == NULL) return p2;
|
||||
if(p2 == NULL) return p1;
|
||||
return (p1 > p2) ? p1 : p2;
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
|
@ -123,35 +129,41 @@ static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
|||
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path) {
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
|
||||
{
|
||||
char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (char *_the_path) {
|
||||
static inline char *FIND_LAST_DIRSEP(char *_the_path)
|
||||
{
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
const char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline const char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
const char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
#else
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
@ -167,23 +179,29 @@ static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
|||
#define STRIP_DRIVE_SPEC(f) (f)
|
||||
|
||||
#ifdef __cplusplus
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path) {
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
|
||||
{
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (char *_the_path) {
|
||||
static inline char *FIND_LAST_DIRSEP(char *_the_path)
|
||||
{
|
||||
return strrchr(_the_path, '/');
|
||||
}
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline const char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strrchr(_the_path, '/');
|
||||
}
|
||||
#else
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strrchr(_the_path, '/');
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
|
511
source/gl_draw.c
511
source/gl_draw.c
|
@ -39,63 +39,63 @@ qpic_t *pic_nul; //johnfitz -- for missing gfx, don't crash
|
|||
//johnfitz -- new pics
|
||||
byte pic_ovr_data[8][8] =
|
||||
{
|
||||
{255,255,255,255,255,255,255,255},
|
||||
{255, 15, 15, 15, 15, 15, 15,255},
|
||||
{255, 255, 255, 255, 255, 255, 255, 255},
|
||||
{255, 15, 15, 15, 15, 15, 15, 255},
|
||||
{255, 15, 15, 15, 15, 15, 15, 2},
|
||||
{255, 15, 15, 15, 15, 15, 15, 2},
|
||||
{255, 15, 15, 15, 15, 15, 15, 2},
|
||||
{255, 15, 15, 15, 15, 15, 15, 2},
|
||||
{255, 15, 15, 15, 15, 15, 15, 2},
|
||||
{255,255, 2, 2, 2, 2, 2, 2},
|
||||
{255, 255, 2, 2, 2, 2, 2, 2},
|
||||
};
|
||||
|
||||
byte pic_ins_data[9][8] =
|
||||
{
|
||||
{ 15, 15,255,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{ 15, 15, 2,255,255,255,255,255},
|
||||
{255, 2, 2,255,255,255,255,255},
|
||||
{ 15, 15, 255, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{ 15, 15, 2, 255, 255, 255, 255, 255},
|
||||
{255, 2, 2, 255, 255, 255, 255, 255},
|
||||
};
|
||||
|
||||
byte pic_nul_data[8][8] =
|
||||
{
|
||||
{252,252,252,252, 0, 0, 0, 0},
|
||||
{252,252,252,252, 0, 0, 0, 0},
|
||||
{252,252,252,252, 0, 0, 0, 0},
|
||||
{252,252,252,252, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0,252,252,252,252},
|
||||
{ 0, 0, 0, 0,252,252,252,252},
|
||||
{ 0, 0, 0, 0,252,252,252,252},
|
||||
{ 0, 0, 0, 0,252,252,252,252},
|
||||
{252, 252, 252, 252, 0, 0, 0, 0},
|
||||
{252, 252, 252, 252, 0, 0, 0, 0},
|
||||
{252, 252, 252, 252, 0, 0, 0, 0},
|
||||
{252, 252, 252, 252, 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 0, 252, 252, 252, 252},
|
||||
{ 0, 0, 0, 0, 252, 252, 252, 252},
|
||||
{ 0, 0, 0, 0, 252, 252, 252, 252},
|
||||
{ 0, 0, 0, 0, 252, 252, 252, 252},
|
||||
};
|
||||
|
||||
byte pic_stipple_data[8][8] =
|
||||
{
|
||||
{255, 0, 0, 0,255, 0, 0, 0},
|
||||
{ 0, 0,255, 0, 0, 0,255, 0},
|
||||
{255, 0, 0, 0,255, 0, 0, 0},
|
||||
{ 0, 0,255, 0, 0, 0,255, 0},
|
||||
{255, 0, 0, 0,255, 0, 0, 0},
|
||||
{ 0, 0,255, 0, 0, 0,255, 0},
|
||||
{255, 0, 0, 0,255, 0, 0, 0},
|
||||
{ 0, 0,255, 0, 0, 0,255, 0},
|
||||
{255, 0, 0, 0, 255, 0, 0, 0},
|
||||
{ 0, 0, 255, 0, 0, 0, 255, 0},
|
||||
{255, 0, 0, 0, 255, 0, 0, 0},
|
||||
{ 0, 0, 255, 0, 0, 0, 255, 0},
|
||||
{255, 0, 0, 0, 255, 0, 0, 0},
|
||||
{ 0, 0, 255, 0, 0, 0, 255, 0},
|
||||
{255, 0, 0, 0, 255, 0, 0, 0},
|
||||
{ 0, 0, 255, 0, 0, 0, 255, 0},
|
||||
};
|
||||
|
||||
byte pic_crosshair_data[8][8] =
|
||||
{
|
||||
{255,255,255,255,255,255,255,255},
|
||||
{255,255,255, 8, 9,255,255,255},
|
||||
{255,255,255, 6, 8, 2,255,255},
|
||||
{255, 6, 8, 8, 6, 8, 8,255},
|
||||
{255,255, 2, 8, 8, 2, 2, 2},
|
||||
{255,255,255, 7, 8, 2,255,255},
|
||||
{255,255,255,255, 2, 2,255,255},
|
||||
{255,255,255,255,255,255,255,255},
|
||||
{255, 255, 255, 255, 255, 255, 255, 255},
|
||||
{255, 255, 255, 8, 9, 255, 255, 255},
|
||||
{255, 255, 255, 6, 8, 2, 255, 255},
|
||||
{255, 6, 8, 8, 6, 8, 8, 255},
|
||||
{255, 255, 2, 8, 8, 2, 2, 2},
|
||||
{255, 255, 255, 7, 8, 2, 255, 255},
|
||||
{255, 255, 255, 255, 2, 2, 255, 255},
|
||||
{255, 255, 255, 255, 255, 255, 255, 255},
|
||||
};
|
||||
//johnfitz
|
||||
|
||||
|
@ -135,7 +135,7 @@ byte menuplyr_pixels[4096];
|
|||
#define BLOCK_HEIGHT 256
|
||||
|
||||
int32_t scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT]; //johnfitz -- removed *4 after BLOCK_HEIGHT
|
||||
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT]; //johnfitz -- removed *4 after BLOCK_HEIGHT
|
||||
bool scrap_dirty;
|
||||
gltexture_t *scrap_textures[MAX_SCRAPS]; //johnfitz
|
||||
|
||||
|
@ -147,44 +147,45 @@ Scrap_AllocBlock
|
|||
returns an index into scrap_texnums[] and the position inside it
|
||||
================
|
||||
*/
|
||||
int32_t Scrap_AllocBlock (int32_t w, int32_t h, int32_t *x, int32_t *y)
|
||||
int32_t Scrap_AllocBlock(int32_t w, int32_t h, int32_t *x, int32_t *y)
|
||||
{
|
||||
int32_t i, j;
|
||||
int32_t best, best2;
|
||||
int32_t texnum;
|
||||
|
||||
for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++)
|
||||
for(texnum = 0 ; texnum < MAX_SCRAPS ; texnum++)
|
||||
{
|
||||
best = BLOCK_HEIGHT;
|
||||
|
||||
for (i=0 ; i<BLOCK_WIDTH-w ; i++)
|
||||
for(i = 0 ; i < BLOCK_WIDTH - w ; i++)
|
||||
{
|
||||
best2 = 0;
|
||||
|
||||
for (j=0 ; j<w ; j++)
|
||||
for(j = 0 ; j < w ; j++)
|
||||
{
|
||||
if (scrap_allocated[texnum][i+j] >= best)
|
||||
if(scrap_allocated[texnum][i + j] >= best)
|
||||
break;
|
||||
if (scrap_allocated[texnum][i+j] > best2)
|
||||
best2 = scrap_allocated[texnum][i+j];
|
||||
if(scrap_allocated[texnum][i + j] > best2)
|
||||
best2 = scrap_allocated[texnum][i + j];
|
||||
}
|
||||
if (j == w)
|
||||
{ // this is a valid spot
|
||||
if(j == w)
|
||||
{
|
||||
// this is a valid spot
|
||||
*x = i;
|
||||
*y = best = best2;
|
||||
}
|
||||
}
|
||||
|
||||
if (best + h > BLOCK_HEIGHT)
|
||||
if(best + h > BLOCK_HEIGHT)
|
||||
continue;
|
||||
|
||||
for (i=0 ; i<w ; i++)
|
||||
for(i = 0 ; i < w ; i++)
|
||||
scrap_allocated[texnum][*x + i] = best + h;
|
||||
|
||||
return texnum;
|
||||
}
|
||||
|
||||
Sys_Error ("Scrap_AllocBlock: full"); //johnfitz -- correct function name
|
||||
Sys_Error("Scrap_AllocBlock: full"); //johnfitz -- correct function name
|
||||
return 0; //johnfitz -- shut up compiler
|
||||
}
|
||||
|
||||
|
@ -193,15 +194,15 @@ int32_t Scrap_AllocBlock (int32_t w, int32_t h, int32_t *x, int32_t *y)
|
|||
Scrap_Upload -- johnfitz -- now uses TexMgr
|
||||
================
|
||||
*/
|
||||
void Scrap_Upload (void)
|
||||
void Scrap_Upload(void)
|
||||
{
|
||||
char name[8];
|
||||
int32_t i;
|
||||
|
||||
for (i=0; i<MAX_SCRAPS; i++)
|
||||
for(i = 0; i < MAX_SCRAPS; i++)
|
||||
{
|
||||
sprintf (name, "scrap%" PRIi32 "", i);
|
||||
scrap_textures[i] = TexMgr_LoadImage (NULL, name, BLOCK_WIDTH, BLOCK_HEIGHT, SRC_INDEXED, scrap_texels[i],
|
||||
sprintf(name, "scrap%" PRIi32 "", i);
|
||||
scrap_textures[i] = TexMgr_LoadImage(NULL, name, BLOCK_WIDTH, BLOCK_HEIGHT, SRC_INDEXED, scrap_texels[i],
|
||||
"", (src_offset_t)scrap_texels[i], TEXPREF_ALPHA | TEXPREF_OVERWRITE | TEXPREF_NOPICMIP);
|
||||
}
|
||||
|
||||
|
@ -213,53 +214,53 @@ void Scrap_Upload (void)
|
|||
Draw_PicFromWad
|
||||
================
|
||||
*/
|
||||
qpic_t *Draw_PicFromWad (const char *name)
|
||||
qpic_t *Draw_PicFromWad(const char *name)
|
||||
{
|
||||
qpic_t *p;
|
||||
glpic_t gl;
|
||||
src_offset_t offset; //johnfitz
|
||||
|
||||
p = (qpic_t *) W_GetLumpName (name);
|
||||
if (!p) return pic_nul; //johnfitz
|
||||
p = (qpic_t *) W_GetLumpName(name);
|
||||
if(!p) return pic_nul; //johnfitz
|
||||
|
||||
// load little ones into the scrap
|
||||
if (p->width < 64 && p->height < 64)
|
||||
if(p->width < 64 && p->height < 64)
|
||||
{
|
||||
int32_t x, y;
|
||||
int32_t i, j, k;
|
||||
int32_t texnum;
|
||||
|
||||
texnum = Scrap_AllocBlock (p->width, p->height, &x, &y);
|
||||
texnum = Scrap_AllocBlock(p->width, p->height, &x, &y);
|
||||
scrap_dirty = true;
|
||||
k = 0;
|
||||
for (i=0 ; i<p->height ; i++)
|
||||
for(i = 0 ; i < p->height ; i++)
|
||||
{
|
||||
for (j=0 ; j<p->width ; j++, k++)
|
||||
scrap_texels[texnum][(y+i)*BLOCK_WIDTH + x + j] = p->data[k];
|
||||
for(j = 0 ; j < p->width ; j++, k++)
|
||||
scrap_texels[texnum][(y + i)*BLOCK_WIDTH + x + j] = p->data[k];
|
||||
}
|
||||
gl.gltexture = scrap_textures[texnum]; //johnfitz -- changed to an array
|
||||
//johnfitz -- no longer go from 0.01 to 0.99
|
||||
gl.sl = x/(float)BLOCK_WIDTH;
|
||||
gl.sh = (x+p->width)/(float)BLOCK_WIDTH;
|
||||
gl.tl = y/(float)BLOCK_WIDTH;
|
||||
gl.th = (y+p->height)/(float)BLOCK_WIDTH;
|
||||
gl.sl = x / (float)BLOCK_WIDTH;
|
||||
gl.sh = (x + p->width) / (float)BLOCK_WIDTH;
|
||||
gl.tl = y / (float)BLOCK_WIDTH;
|
||||
gl.th = (y + p->height) / (float)BLOCK_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
char texturename[64]; //johnfitz
|
||||
q_snprintf (texturename, sizeof(texturename), "%s:%s", WADFILENAME, name); //johnfitz
|
||||
q_snprintf(texturename, sizeof(texturename), "%s:%s", WADFILENAME, name); //johnfitz
|
||||
|
||||
offset = (src_offset_t)p - (src_offset_t)wad_base + sizeof(int32_t)*2; //johnfitz
|
||||
offset = (src_offset_t)p - (src_offset_t)wad_base + sizeof(int32_t) * 2; //johnfitz
|
||||
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME,
|
||||
gl.gltexture = TexMgr_LoadImage(NULL, texturename, p->width, p->height, SRC_INDEXED, p->data, WADFILENAME,
|
||||
offset, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)p->width/(float)TexMgr_PadConditional(p->width); //johnfitz
|
||||
gl.sh = (float)p->width / (float)TexMgr_PadConditional(p->width); //johnfitz
|
||||
gl.tl = 0;
|
||||
gl.th = (float)p->height/(float)TexMgr_PadConditional(p->height); //johnfitz
|
||||
gl.th = (float)p->height / (float)TexMgr_PadConditional(p->height); //johnfitz
|
||||
}
|
||||
|
||||
memcpy (p->data, &gl, sizeof(glpic_t));
|
||||
memcpy(p->data, &gl, sizeof(glpic_t));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -269,47 +270,47 @@ qpic_t *Draw_PicFromWad (const char *name)
|
|||
Draw_CachePic
|
||||
================
|
||||
*/
|
||||
qpic_t *Draw_CachePic (const char *path)
|
||||
qpic_t *Draw_CachePic(const char *path)
|
||||
{
|
||||
cachepic_t *pic;
|
||||
int32_t i;
|
||||
qpic_t *dat;
|
||||
glpic_t gl;
|
||||
|
||||
for (pic=menu_cachepics, i=0 ; i<menu_numcachepics ; pic++, i++)
|
||||
for(pic = menu_cachepics, i = 0 ; i < menu_numcachepics ; pic++, i++)
|
||||
{
|
||||
if (!strcmp (path, pic->name))
|
||||
if(!strcmp(path, pic->name))
|
||||
return &pic->pic;
|
||||
}
|
||||
if (menu_numcachepics == MAX_CACHED_PICS)
|
||||
Sys_Error ("menu_numcachepics == MAX_CACHED_PICS");
|
||||
if(menu_numcachepics == MAX_CACHED_PICS)
|
||||
Sys_Error("menu_numcachepics == MAX_CACHED_PICS");
|
||||
menu_numcachepics++;
|
||||
strcpy (pic->name, path);
|
||||
strcpy(pic->name, path);
|
||||
|
||||
//
|
||||
// load the pic from disk
|
||||
//
|
||||
dat = (qpic_t *)COM_LoadTempFile (path, NULL);
|
||||
if (!dat)
|
||||
Sys_Error ("Draw_CachePic: failed to load %s", path);
|
||||
SwapPic (dat);
|
||||
dat = (qpic_t *)COM_LoadTempFile(path, NULL);
|
||||
if(!dat)
|
||||
Sys_Error("Draw_CachePic: failed to load %s", path);
|
||||
SwapPic(dat);
|
||||
|
||||
// HACK HACK HACK --- we need to keep the bytes for
|
||||
// the translatable player picture just for the menu
|
||||
// configuration dialog
|
||||
if (!strcmp (path, "gfx/menuplyr.lmp"))
|
||||
memcpy (menuplyr_pixels, dat->data, dat->width*dat->height);
|
||||
if(!strcmp(path, "gfx/menuplyr.lmp"))
|
||||
memcpy(menuplyr_pixels, dat->data, dat->width * dat->height);
|
||||
|
||||
pic->pic.width = dat->width;
|
||||
pic->pic.height = dat->height;
|
||||
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, path, dat->width, dat->height, SRC_INDEXED, dat->data, path,
|
||||
sizeof(int32_t)*2, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl.gltexture = TexMgr_LoadImage(NULL, path, dat->width, dat->height, SRC_INDEXED, dat->data, path,
|
||||
sizeof(int32_t) * 2, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)dat->width/(float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl.sh = (float)dat->width / (float)TexMgr_PadConditional(dat->width); //johnfitz
|
||||
gl.tl = 0;
|
||||
gl.th = (float)dat->height/(float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
memcpy (pic->pic.data, &gl, sizeof(glpic_t));
|
||||
gl.th = (float)dat->height / (float)TexMgr_PadConditional(dat->height); //johnfitz
|
||||
memcpy(pic->pic.data, &gl, sizeof(glpic_t));
|
||||
|
||||
return &pic->pic;
|
||||
}
|
||||
|
@ -319,22 +320,22 @@ qpic_t *Draw_CachePic (const char *path)
|
|||
Draw_MakePic -- johnfitz -- generate pics from internal data
|
||||
================
|
||||
*/
|
||||
qpic_t *Draw_MakePic (const char *name, int32_t width, int32_t height, byte *data)
|
||||
qpic_t *Draw_MakePic(const char *name, int32_t width, int32_t height, byte *data)
|
||||
{
|
||||
int32_t flags = TEXPREF_NEAREST | TEXPREF_ALPHA | TEXPREF_PERSIST | TEXPREF_NOPICMIP | TEXPREF_PAD;
|
||||
qpic_t *pic;
|
||||
glpic_t gl;
|
||||
|
||||
pic = (qpic_t *) Hunk_Alloc (sizeof(qpic_t) - 4 + sizeof (glpic_t));
|
||||
pic = (qpic_t *) Hunk_Alloc(sizeof(qpic_t) - 4 + sizeof(glpic_t));
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
|
||||
gl.gltexture = TexMgr_LoadImage (NULL, name, width, height, SRC_INDEXED, data, "", (src_offset_t)data, flags);
|
||||
gl.gltexture = TexMgr_LoadImage(NULL, name, width, height, SRC_INDEXED, data, "", (src_offset_t)data, flags);
|
||||
gl.sl = 0;
|
||||
gl.sh = (float)width/(float)TexMgr_PadConditional(width);
|
||||
gl.sh = (float)width / (float)TexMgr_PadConditional(width);
|
||||
gl.tl = 0;
|
||||
gl.th = (float)height/(float)TexMgr_PadConditional(height);
|
||||
memcpy (pic->data, &gl, sizeof(glpic_t));
|
||||
gl.th = (float)height / (float)TexMgr_PadConditional(height);
|
||||
memcpy(pic->data, &gl, sizeof(glpic_t));
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
@ -350,19 +351,19 @@ qpic_t *Draw_MakePic (const char *name, int32_t width, int32_t height, byte *dat
|
|||
Draw_LoadPics -- johnfitz
|
||||
===============
|
||||
*/
|
||||
void Draw_LoadPics (void)
|
||||
void Draw_LoadPics(void)
|
||||
{
|
||||
byte *data;
|
||||
src_offset_t offset;
|
||||
|
||||
data = (byte *) W_GetLumpName ("conchars");
|
||||
if (!data) Sys_Error ("Draw_LoadPics: couldn't load conchars");
|
||||
data = (byte *) W_GetLumpName("conchars");
|
||||
if(!data) Sys_Error("Draw_LoadPics: couldn't load conchars");
|
||||
offset = (src_offset_t)data - (src_offset_t)wad_base;
|
||||
char_texture = TexMgr_LoadImage (NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data,
|
||||
char_texture = TexMgr_LoadImage(NULL, WADFILENAME":conchars", 128, 128, SRC_INDEXED, data,
|
||||
WADFILENAME, offset, TEXPREF_ALPHA | TEXPREF_NEAREST | TEXPREF_NOPICMIP | TEXPREF_CONCHARS);
|
||||
|
||||
draw_disc = Draw_PicFromWad ("disc");
|
||||
draw_backtile = Draw_PicFromWad ("backtile");
|
||||
draw_disc = Draw_PicFromWad("disc");
|
||||
draw_backtile = Draw_PicFromWad("backtile");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -370,7 +371,7 @@ void Draw_LoadPics (void)
|
|||
Draw_NewGame -- johnfitz
|
||||
===============
|
||||
*/
|
||||
void Draw_NewGame (void)
|
||||
void Draw_NewGame(void)
|
||||
{
|
||||
cachepic_t *pic;
|
||||
int32_t i;
|
||||
|
@ -379,16 +380,16 @@ void Draw_NewGame (void)
|
|||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||
|
||||
Scrap_Upload (); //creates 2 empty gltextures
|
||||
Scrap_Upload(); //creates 2 empty gltextures
|
||||
|
||||
// reload wad pics
|
||||
W_LoadWadFile (); //johnfitz -- filename is now hard-coded for honesty
|
||||
Draw_LoadPics ();
|
||||
SCR_LoadPics ();
|
||||
Sbar_LoadPics ();
|
||||
W_LoadWadFile(); //johnfitz -- filename is now hard-coded for honesty
|
||||
Draw_LoadPics();
|
||||
SCR_LoadPics();
|
||||
Sbar_LoadPics();
|
||||
|
||||
// empty lmp cache
|
||||
for (pic = menu_cachepics, i = 0; i < menu_numcachepics; pic++, i++)
|
||||
for(pic = menu_cachepics, i = 0; i < menu_numcachepics; pic++, i++)
|
||||
pic->name[0] = 0;
|
||||
menu_numcachepics = 0;
|
||||
}
|
||||
|
@ -398,23 +399,23 @@ void Draw_NewGame (void)
|
|||
Draw_Init -- johnfitz -- rewritten
|
||||
===============
|
||||
*/
|
||||
void Draw_Init (void)
|
||||
void Draw_Init(void)
|
||||
{
|
||||
Cvar_RegisterVariable (&scr_conalpha);
|
||||
Cvar_RegisterVariable(&scr_conalpha);
|
||||
|
||||
// clear scrap and allocate gltextures
|
||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||
memset(scrap_texels, 255, sizeof(scrap_texels));
|
||||
|
||||
Scrap_Upload (); //creates 2 empty textures
|
||||
Scrap_Upload(); //creates 2 empty textures
|
||||
|
||||
// create internal pics
|
||||
pic_ins = Draw_MakePic ("ins", 8, 9, &pic_ins_data[0][0]);
|
||||
pic_ovr = Draw_MakePic ("ovr", 8, 8, &pic_ovr_data[0][0]);
|
||||
pic_nul = Draw_MakePic ("nul", 8, 8, &pic_nul_data[0][0]);
|
||||
pic_ins = Draw_MakePic("ins", 8, 9, &pic_ins_data[0][0]);
|
||||
pic_ovr = Draw_MakePic("ovr", 8, 8, &pic_ovr_data[0][0]);
|
||||
pic_nul = Draw_MakePic("nul", 8, 8, &pic_nul_data[0][0]);
|
||||
|
||||
// load game pics
|
||||
Draw_LoadPics ();
|
||||
Draw_LoadPics();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
@ -428,26 +429,26 @@ void Draw_Init (void)
|
|||
Draw_CharacterQuad -- johnfitz -- seperate function to spit out verts
|
||||
================
|
||||
*/
|
||||
void Draw_CharacterQuad (int32_t x, int32_t y, char num)
|
||||
void Draw_CharacterQuad(int32_t x, int32_t y, char num)
|
||||
{
|
||||
int32_t row, col;
|
||||
float frow, fcol, size;
|
||||
|
||||
row = num>>4;
|
||||
col = num&15;
|
||||
row = num >> 4;
|
||||
col = num & 15;
|
||||
|
||||
frow = row*0.0625;
|
||||
fcol = col*0.0625;
|
||||
frow = row * 0.0625;
|
||||
fcol = col * 0.0625;
|
||||
size = 0.0625;
|
||||
|
||||
glTexCoord2f (fcol, frow);
|
||||
glVertex2f (x, y);
|
||||
glTexCoord2f (fcol + size, frow);
|
||||
glVertex2f (x+8, y);
|
||||
glTexCoord2f (fcol + size, frow + size);
|
||||
glVertex2f (x+8, y+8);
|
||||
glTexCoord2f (fcol, frow + size);
|
||||
glVertex2f (x, y+8);
|
||||
glTexCoord2f(fcol, frow);
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f(fcol + size, frow);
|
||||
glVertex2f(x + 8, y);
|
||||
glTexCoord2f(fcol + size, frow + size);
|
||||
glVertex2f(x + 8, y + 8);
|
||||
glTexCoord2f(fcol, frow + size);
|
||||
glVertex2f(x, y + 8);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -455,22 +456,22 @@ void Draw_CharacterQuad (int32_t x, int32_t y, char num)
|
|||
Draw_Character -- johnfitz -- modified to call Draw_CharacterQuad
|
||||
================
|
||||
*/
|
||||
void Draw_Character (int32_t x, int32_t y, int32_t num)
|
||||
void Draw_Character(int32_t x, int32_t y, int32_t num)
|
||||
{
|
||||
if (y <= -8)
|
||||
if(y <= -8)
|
||||
return; // totally off screen
|
||||
|
||||
num &= 255;
|
||||
|
||||
if (num == 32)
|
||||
if(num == 32)
|
||||
return; //don't waste verts on spaces
|
||||
|
||||
GL_Bind (char_texture);
|
||||
glBegin (GL_QUADS);
|
||||
GL_Bind(char_texture);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
Draw_CharacterQuad (x, y, (char) num);
|
||||
Draw_CharacterQuad(x, y, (char) num);
|
||||
|
||||
glEnd ();
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -478,23 +479,23 @@ void Draw_Character (int32_t x, int32_t y, int32_t num)
|
|||
Draw_String -- johnfitz -- modified to call Draw_CharacterQuad
|
||||
================
|
||||
*/
|
||||
void Draw_String (int32_t x, int32_t y, const char *str)
|
||||
void Draw_String(int32_t x, int32_t y, const char *str)
|
||||
{
|
||||
if (y <= -8)
|
||||
if(y <= -8)
|
||||
return; // totally off screen
|
||||
|
||||
GL_Bind (char_texture);
|
||||
glBegin (GL_QUADS);
|
||||
GL_Bind(char_texture);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
while (*str)
|
||||
while(*str)
|
||||
{
|
||||
if (*str != 32) //don't waste verts on spaces
|
||||
Draw_CharacterQuad (x, y, *str);
|
||||
if(*str != 32) //don't waste verts on spaces
|
||||
Draw_CharacterQuad(x, y, *str);
|
||||
str++;
|
||||
x += 8;
|
||||
}
|
||||
|
||||
glEnd ();
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -502,24 +503,24 @@ void Draw_String (int32_t x, int32_t y, const char *str)
|
|||
Draw_Pic -- johnfitz -- modified
|
||||
=============
|
||||
*/
|
||||
void Draw_Pic (int32_t x, int32_t y, qpic_t *pic)
|
||||
void Draw_Pic(int32_t x, int32_t y, qpic_t *pic)
|
||||
{
|
||||
glpic_t *gl;
|
||||
|
||||
if (scrap_dirty)
|
||||
Scrap_Upload ();
|
||||
if(scrap_dirty)
|
||||
Scrap_Upload();
|
||||
gl = (glpic_t *)pic->data;
|
||||
GL_Bind (gl->gltexture);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (gl->sl, gl->tl);
|
||||
glVertex2f (x, y);
|
||||
glTexCoord2f (gl->sh, gl->tl);
|
||||
glVertex2f (x+pic->width, y);
|
||||
glTexCoord2f (gl->sh, gl->th);
|
||||
glVertex2f (x+pic->width, y+pic->height);
|
||||
glTexCoord2f (gl->sl, gl->th);
|
||||
glVertex2f (x, y+pic->height);
|
||||
glEnd ();
|
||||
GL_Bind(gl->gltexture);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(gl->sl, gl->tl);
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f(gl->sh, gl->tl);
|
||||
glVertex2f(x + pic->width, y);
|
||||
glTexCoord2f(gl->sh, gl->th);
|
||||
glVertex2f(x + pic->width, y + pic->height);
|
||||
glTexCoord2f(gl->sl, gl->th);
|
||||
glVertex2f(x, y + pic->height);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -529,20 +530,20 @@ Draw_TransPicTranslate -- johnfitz -- rewritten to use texmgr to do translation
|
|||
Only used for the player color selection menu
|
||||
=============
|
||||
*/
|
||||
void Draw_TransPicTranslate (int32_t x, int32_t y, qpic_t *pic, int32_t top, int32_t bottom)
|
||||
void Draw_TransPicTranslate(int32_t x, int32_t y, qpic_t *pic, int32_t top, int32_t bottom)
|
||||
{
|
||||
static int32_t oldtop = -2;
|
||||
static int32_t oldbottom = -2;
|
||||
|
||||
if (top != oldtop || bottom != oldbottom)
|
||||
if(top != oldtop || bottom != oldbottom)
|
||||
{
|
||||
glpic_t *p = (glpic_t *)pic->data;
|
||||
gltexture_t *glt = p->gltexture;
|
||||
oldtop = top;
|
||||
oldbottom = bottom;
|
||||
TexMgr_ReloadImage (glt, top, bottom);
|
||||
TexMgr_ReloadImage(glt, top, bottom);
|
||||
}
|
||||
Draw_Pic (x, y, pic);
|
||||
Draw_Pic(x, y, pic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -550,37 +551,37 @@ void Draw_TransPicTranslate (int32_t x, int32_t y, qpic_t *pic, int32_t top, int
|
|||
Draw_ConsoleBackground -- johnfitz -- rewritten
|
||||
================
|
||||
*/
|
||||
void Draw_ConsoleBackground (void)
|
||||
void Draw_ConsoleBackground(void)
|
||||
{
|
||||
qpic_t *pic;
|
||||
float alpha;
|
||||
|
||||
pic = Draw_CachePic ("gfx/conback.lmp");
|
||||
pic = Draw_CachePic("gfx/conback.lmp");
|
||||
pic->width = vid.conwidth;
|
||||
pic->height = vid.conheight;
|
||||
|
||||
alpha = (con_forcedup) ? 1.0 : scr_conalpha.value;
|
||||
|
||||
GL_SetCanvas (CANVAS_CONSOLE); //in case this is called from weird places
|
||||
GL_SetCanvas(CANVAS_CONSOLE); //in case this is called from weird places
|
||||
|
||||
if (alpha > 0.0)
|
||||
if(alpha > 0.0)
|
||||
{
|
||||
if (alpha < 1.0)
|
||||
if(alpha < 1.0)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glColor4f (1,1,1,alpha);
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, alpha);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
||||
Draw_Pic (0, 0, pic);
|
||||
Draw_Pic(0, 0, pic);
|
||||
|
||||
if (alpha < 1.0)
|
||||
if(alpha < 1.0)
|
||||
{
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glDisable (GL_BLEND);
|
||||
glColor4f (1,1,1,1);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -594,24 +595,24 @@ This repeats a 64*64 tile graphic to fill the screen around a sized down
|
|||
refresh window.
|
||||
=============
|
||||
*/
|
||||
void Draw_TileClear (int32_t x, int32_t y, int32_t w, int32_t h)
|
||||
void Draw_TileClear(int32_t x, int32_t y, int32_t w, int32_t h)
|
||||
{
|
||||
glpic_t *gl;
|
||||
|
||||
gl = (glpic_t *)draw_backtile->data;
|
||||
|
||||
glColor3f (1,1,1);
|
||||
GL_Bind (gl->gltexture);
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2f (x/64.0, y/64.0);
|
||||
glVertex2f (x, y);
|
||||
glTexCoord2f ( (x+w)/64.0, y/64.0);
|
||||
glVertex2f (x+w, y);
|
||||
glTexCoord2f ( (x+w)/64.0, (y+h)/64.0);
|
||||
glVertex2f (x+w, y+h);
|
||||
glTexCoord2f ( x/64.0, (y+h)/64.0 );
|
||||
glVertex2f (x, y+h);
|
||||
glEnd ();
|
||||
glColor3f(1, 1, 1);
|
||||
GL_Bind(gl->gltexture);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(x / 64.0, y / 64.0);
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f((x + w) / 64.0, y / 64.0);
|
||||
glVertex2f(x + w, y);
|
||||
glTexCoord2f((x + w) / 64.0, (y + h) / 64.0);
|
||||
glVertex2f(x + w, y + h);
|
||||
glTexCoord2f(x / 64.0, (y + h) / 64.0);
|
||||
glVertex2f(x, y + h);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -621,26 +622,26 @@ Draw_Fill
|
|||
Fills a box of pixels with a single color
|
||||
=============
|
||||
*/
|
||||
void Draw_Fill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t c, float alpha) //johnfitz -- added alpha
|
||||
void Draw_Fill(int32_t x, int32_t y, int32_t w, int32_t h, int32_t c, float alpha) //johnfitz -- added alpha
|
||||
{
|
||||
byte *pal = (byte *)d_8to24table; //johnfitz -- use d_8to24table instead of host_basepal
|
||||
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glEnable (GL_BLEND); //johnfitz -- for alpha
|
||||
glDisable (GL_ALPHA_TEST); //johnfitz -- for alpha
|
||||
glColor4f (pal[c*4]/255.0, pal[c*4+1]/255.0, pal[c*4+2]/255.0, alpha); //johnfitz -- added alpha
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND); //johnfitz -- for alpha
|
||||
glDisable(GL_ALPHA_TEST); //johnfitz -- for alpha
|
||||
glColor4f(pal[c * 4] / 255.0, pal[c * 4 + 1] / 255.0, pal[c * 4 + 2] / 255.0, alpha); //johnfitz -- added alpha
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
glVertex2f (x,y);
|
||||
glVertex2f (x+w, y);
|
||||
glVertex2f (x+w, y+h);
|
||||
glVertex2f (x, y+h);
|
||||
glEnd ();
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x + w, y);
|
||||
glVertex2f(x + w, y + h);
|
||||
glVertex2f(x, y + h);
|
||||
glEnd();
|
||||
|
||||
glColor3f (1,1,1);
|
||||
glDisable (GL_BLEND); //johnfitz -- for alpha
|
||||
glEnable (GL_ALPHA_TEST); //johnfitz -- for alpha
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glColor3f(1, 1, 1);
|
||||
glDisable(GL_BLEND); //johnfitz -- for alpha
|
||||
glEnable(GL_ALPHA_TEST); //johnfitz -- for alpha
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -648,26 +649,26 @@ void Draw_Fill (int32_t x, int32_t y, int32_t w, int32_t h, int32_t c, float alp
|
|||
Draw_FadeScreen -- johnfitz -- revised
|
||||
================
|
||||
*/
|
||||
void Draw_FadeScreen (void)
|
||||
void Draw_FadeScreen(void)
|
||||
{
|
||||
GL_SetCanvas (CANVAS_DEFAULT);
|
||||
GL_SetCanvas(CANVAS_DEFAULT);
|
||||
|
||||
glEnable (GL_BLEND);
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glColor4f (0, 0, 0, 0.5);
|
||||
glBegin (GL_QUADS);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4f(0, 0, 0, 0.5);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex2f (0,0);
|
||||
glVertex2f (glwidth, 0);
|
||||
glVertex2f (glwidth, glheight);
|
||||
glVertex2f (0, glheight);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(glwidth, 0);
|
||||
glVertex2f(glwidth, glheight);
|
||||
glVertex2f(0, glheight);
|
||||
|
||||
glEnd ();
|
||||
glColor4f (1,1,1,1);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glDisable (GL_BLEND);
|
||||
glEnd();
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
Sbar_Changed();
|
||||
}
|
||||
|
@ -677,81 +678,81 @@ void Draw_FadeScreen (void)
|
|||
GL_SetCanvas -- johnfitz -- support various canvas types
|
||||
================
|
||||
*/
|
||||
void GL_SetCanvas (canvastype newcanvas)
|
||||
void GL_SetCanvas(canvastype newcanvas)
|
||||
{
|
||||
extern vrect_t scr_vrect;
|
||||
float s;
|
||||
int32_t lines;
|
||||
|
||||
if (newcanvas == currentcanvas)
|
||||
if(newcanvas == currentcanvas)
|
||||
return;
|
||||
|
||||
currentcanvas = newcanvas;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
glLoadIdentity();
|
||||
|
||||
switch(newcanvas)
|
||||
{
|
||||
case CANVAS_DEFAULT:
|
||||
glOrtho (0, glwidth, glheight, 0, -99999, 99999);
|
||||
glViewport (glx, gly, glwidth, glheight);
|
||||
glOrtho(0, glwidth, glheight, 0, -99999, 99999);
|
||||
glViewport(glx, gly, glwidth, glheight);
|
||||
break;
|
||||
case CANVAS_CONSOLE:
|
||||
lines = vid.conheight - (scr_con_current * vid.conheight / glheight);
|
||||
glOrtho (0, vid.conwidth, vid.conheight + lines, lines, -99999, 99999);
|
||||
glViewport (glx, gly, glwidth, glheight);
|
||||
glOrtho(0, vid.conwidth, vid.conheight + lines, lines, -99999, 99999);
|
||||
glViewport(glx, gly, glwidth, glheight);
|
||||
break;
|
||||
case CANVAS_MENU:
|
||||
s = q_min((float)glwidth / 320.0, (float)glheight / 200.0);
|
||||
s = CLAMP (1.0, scr_menuscale.value, s);
|
||||
s = CLAMP(1.0, scr_menuscale.value, s);
|
||||
// ericw -- doubled width to 640 to accommodate long keybindings
|
||||
glOrtho (0, 640, 200, 0, -99999, 99999);
|
||||
glViewport (glx + (glwidth - 320*s) / 2, gly + (glheight - 200*s) / 2, 640*s, 200*s);
|
||||
glOrtho(0, 640, 200, 0, -99999, 99999);
|
||||
glViewport(glx + (glwidth - 320 * s) / 2, gly + (glheight - 200 * s) / 2, 640 * s, 200 * s);
|
||||
break;
|
||||
case CANVAS_SBAR:
|
||||
s = CLAMP (1.0, scr_sbarscale.value, (float)glwidth / 320.0);
|
||||
if (cl.gametype == GAME_DEATHMATCH)
|
||||
s = CLAMP(1.0, scr_sbarscale.value, (float)glwidth / 320.0);
|
||||
if(cl.gametype == GAME_DEATHMATCH)
|
||||
{
|
||||
glOrtho (0, glwidth / s, 48, 0, -99999, 99999);
|
||||
glViewport (glx, gly, glwidth, 48*s);
|
||||
glOrtho(0, glwidth / s, 48, 0, -99999, 99999);
|
||||
glViewport(glx, gly, glwidth, 48 * s);
|
||||
}
|
||||
else
|
||||
{
|
||||
glOrtho (0, 320, 48, 0, -99999, 99999);
|
||||
glViewport (glx + (glwidth - 320*s) / 2, gly, 320*s, 48*s);
|
||||
glOrtho(0, 320, 48, 0, -99999, 99999);
|
||||
glViewport(glx + (glwidth - 320 * s) / 2, gly, 320 * s, 48 * s);
|
||||
}
|
||||
break;
|
||||
case CANVAS_WARPIMAGE:
|
||||
glOrtho (0, 128, 0, 128, -99999, 99999);
|
||||
glViewport (glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize);
|
||||
glOrtho(0, 128, 0, 128, -99999, 99999);
|
||||
glViewport(glx, gly + glheight - gl_warpimagesize, gl_warpimagesize, gl_warpimagesize);
|
||||
break;
|
||||
case CANVAS_CROSSHAIR: //0,0 is center of viewport
|
||||
s = CLAMP (1.0, scr_crosshairscale.value, 10.0);
|
||||
glOrtho (scr_vrect.width/-2/s, scr_vrect.width/2/s, scr_vrect.height/2/s, scr_vrect.height/-2/s, -99999, 99999);
|
||||
glViewport (scr_vrect.x, glheight - scr_vrect.y - scr_vrect.height, scr_vrect.width & ~1, scr_vrect.height & ~1);
|
||||
s = CLAMP(1.0, scr_crosshairscale.value, 10.0);
|
||||
glOrtho(scr_vrect.width / -2 / s, scr_vrect.width / 2 / s, scr_vrect.height / 2 / s, scr_vrect.height / -2 / s, -99999, 99999);
|
||||
glViewport(scr_vrect.x, glheight - scr_vrect.y - scr_vrect.height, scr_vrect.width & ~1, scr_vrect.height & ~1);
|
||||
break;
|
||||
case CANVAS_BOTTOMLEFT: //used by devstats
|
||||
s = (float)glwidth/vid.conwidth; //use console scale
|
||||
glOrtho (0, 320, 200, 0, -99999, 99999);
|
||||
glViewport (glx, gly, 320*s, 200*s);
|
||||
s = (float)glwidth / vid.conwidth; //use console scale
|
||||
glOrtho(0, 320, 200, 0, -99999, 99999);
|
||||
glViewport(glx, gly, 320 * s, 200 * s);
|
||||
break;
|
||||
case CANVAS_BOTTOMRIGHT: //used by fps/clock
|
||||
s = (float)glwidth/vid.conwidth; //use console scale
|
||||
glOrtho (0, 320, 200, 0, -99999, 99999);
|
||||
glViewport (glx+glwidth-320*s, gly, 320*s, 200*s);
|
||||
s = (float)glwidth / vid.conwidth; //use console scale
|
||||
glOrtho(0, 320, 200, 0, -99999, 99999);
|
||||
glViewport(glx + glwidth - 320 * s, gly, 320 * s, 200 * s);
|
||||
break;
|
||||
case CANVAS_TOPRIGHT: //used by disc
|
||||
s = 1;
|
||||
glOrtho (0, 320, 200, 0, -99999, 99999);
|
||||
glViewport (glx+glwidth-320*s, gly+glheight-200*s, 320*s, 200*s);
|
||||
glOrtho(0, 320, 200, 0, -99999, 99999);
|
||||
glViewport(glx + glwidth - 320 * s, gly + glheight - 200 * s, 320 * s, 200 * s);
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("GL_SetCanvas: bad canvas type");
|
||||
Sys_Error("GL_SetCanvas: bad canvas type");
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -759,14 +760,14 @@ void GL_SetCanvas (canvastype newcanvas)
|
|||
GL_Set2D -- johnfitz -- rewritten
|
||||
================
|
||||
*/
|
||||
void GL_Set2D (void)
|
||||
void GL_Set2D(void)
|
||||
{
|
||||
currentcanvas = CANVAS_INVALID;
|
||||
GL_SetCanvas (CANVAS_DEFAULT);
|
||||
GL_SetCanvas(CANVAS_DEFAULT);
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_CULL_FACE);
|
||||
glDisable (GL_BLEND);
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glColor4f (1,1,1,1);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@ Fog_Update
|
|||
update internal variables
|
||||
=============
|
||||
*/
|
||||
void Fog_Update (float density, float red, float green, float blue, float time)
|
||||
void Fog_Update(float density, float red, float green, float blue, float time)
|
||||
{
|
||||
//save previous settings for fade
|
||||
if (time > 0)
|
||||
if(time > 0)
|
||||
{
|
||||
//check for a fade in progress
|
||||
if (fade_done > cl.time)
|
||||
if(fade_done > cl.time)
|
||||
{
|
||||
float f;
|
||||
|
||||
|
@ -92,7 +92,7 @@ Fog_ParseServerMessage
|
|||
handle an SVC_FOG message from server
|
||||
=============
|
||||
*/
|
||||
void Fog_ParseServerMessage (void)
|
||||
void Fog_ParseServerMessage(void)
|
||||
{
|
||||
float density, red, green, blue, time;
|
||||
|
||||
|
@ -102,7 +102,7 @@ void Fog_ParseServerMessage (void)
|
|||
blue = MSG_ReadByte() / 255.0;
|
||||
time = q_max(0.0, MSG_ReadShort() / 100.0);
|
||||
|
||||
Fog_Update (density, red, green, blue, time);
|
||||
Fog_Update(density, red, green, blue, time);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -112,9 +112,9 @@ Fog_FogCommand_f
|
|||
handle the 'fog' console command
|
||||
=============
|
||||
*/
|
||||
void Fog_FogCommand_f (void)
|
||||
void Fog_FogCommand_f(void)
|
||||
{
|
||||
switch (Cmd_Argc())
|
||||
switch(Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
|
@ -173,7 +173,7 @@ Fog_ParseWorldspawn
|
|||
called at map load
|
||||
=============
|
||||
*/
|
||||
void Fog_ParseWorldspawn (void)
|
||||
void Fog_ParseWorldspawn(void)
|
||||
{
|
||||
char key[128], value[4096];
|
||||
const char *data;
|
||||
|
@ -193,29 +193,29 @@ void Fog_ParseWorldspawn (void)
|
|||
fade_done = 0.0;
|
||||
|
||||
data = COM_Parse(cl.worldmodel->entities);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
if (com_token[0] != '{')
|
||||
if(com_token[0] != '{')
|
||||
return; // error
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
if (com_token[0] == '}')
|
||||
if(com_token[0] == '}')
|
||||
break; // end of worldspawn
|
||||
if (com_token[0] == '_')
|
||||
if(com_token[0] == '_')
|
||||
strcpy(key, com_token + 1);
|
||||
else
|
||||
strcpy(key, com_token);
|
||||
while (key[strlen(key)-1] == ' ') // remove trailing spaces
|
||||
key[strlen(key)-1] = 0;
|
||||
while(key[strlen(key) - 1] == ' ') // remove trailing spaces
|
||||
key[strlen(key) - 1] = 0;
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
strcpy(value, com_token);
|
||||
|
||||
if (!strcmp("fog", key))
|
||||
if(!strcmp("fog", key))
|
||||
{
|
||||
sscanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
|
||||
}
|
||||
|
@ -229,13 +229,13 @@ Fog_GetColor
|
|||
calculates fog color for this frame, taking into account fade times
|
||||
=============
|
||||
*/
|
||||
float *Fog_GetColor (void)
|
||||
float *Fog_GetColor(void)
|
||||
{
|
||||
static float c[4];
|
||||
float f;
|
||||
int32_t i;
|
||||
|
||||
if (fade_done > cl.time)
|
||||
if(fade_done > cl.time)
|
||||
{
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
c[0] = f * old_red + (1.0 - f) * fog_red;
|
||||
|
@ -252,7 +252,7 @@ float *Fog_GetColor (void)
|
|||
}
|
||||
|
||||
//find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly
|
||||
for (i=0;i<3;i++)
|
||||
for(i = 0; i < 3; i++)
|
||||
c[i] = (float)(Q_rint(c[i] * 255)) / 255.0f;
|
||||
|
||||
return c;
|
||||
|
@ -265,11 +265,11 @@ Fog_GetDensity
|
|||
returns current density of fog
|
||||
=============
|
||||
*/
|
||||
float Fog_GetDensity (void)
|
||||
float Fog_GetDensity(void)
|
||||
{
|
||||
float f;
|
||||
|
||||
if (fade_done > cl.time)
|
||||
if(fade_done > cl.time)
|
||||
{
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
return f * old_density + (1.0 - f) * fog_density;
|
||||
|
@ -285,7 +285,7 @@ Fog_SetupFrame
|
|||
called at the beginning of each frame
|
||||
=============
|
||||
*/
|
||||
void Fog_SetupFrame (void)
|
||||
void Fog_SetupFrame(void)
|
||||
{
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
glFogf(GL_FOG_DENSITY, Fog_GetDensity() / 64.0);
|
||||
|
@ -298,9 +298,9 @@ Fog_EnableGFog
|
|||
called before drawing stuff that should be fogged
|
||||
=============
|
||||
*/
|
||||
void Fog_EnableGFog (void)
|
||||
void Fog_EnableGFog(void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
if(Fog_GetDensity() > 0)
|
||||
glEnable(GL_FOG);
|
||||
}
|
||||
|
||||
|
@ -311,9 +311,9 @@ Fog_DisableGFog
|
|||
called after drawing stuff that should be fogged
|
||||
=============
|
||||
*/
|
||||
void Fog_DisableGFog (void)
|
||||
void Fog_DisableGFog(void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
if(Fog_GetDensity() > 0)
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
|
@ -324,11 +324,11 @@ Fog_StartAdditive
|
|||
called before drawing stuff that is additive blended -- sets fog color to black
|
||||
=============
|
||||
*/
|
||||
void Fog_StartAdditive (void)
|
||||
void Fog_StartAdditive(void)
|
||||
{
|
||||
vec3_t color = {0,0,0};
|
||||
vec3_t color = {0, 0, 0};
|
||||
|
||||
if (Fog_GetDensity() > 0)
|
||||
if(Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
}
|
||||
|
||||
|
@ -339,9 +339,9 @@ Fog_StopAdditive
|
|||
called after drawing stuff that is additive blended -- restores fog color
|
||||
=============
|
||||
*/
|
||||
void Fog_StopAdditive (void)
|
||||
void Fog_StopAdditive(void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
if(Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
}
|
||||
|
||||
|
@ -353,8 +353,8 @@ void Fog_StopAdditive (void)
|
|||
|
||||
cvar_t r_vfog = {"r_vfog", "1", CVAR_NONE};
|
||||
|
||||
void Fog_DrawVFog (void){}
|
||||
void Fog_MarkModels (void){}
|
||||
void Fog_DrawVFog(void) {}
|
||||
void Fog_MarkModels(void) {}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
|
@ -369,10 +369,10 @@ Fog_NewMap
|
|||
called whenever a map is loaded
|
||||
=============
|
||||
*/
|
||||
void Fog_NewMap (void)
|
||||
void Fog_NewMap(void)
|
||||
{
|
||||
Fog_ParseWorldspawn (); //for global fog
|
||||
Fog_MarkModels (); //for volumetric fog
|
||||
Fog_ParseWorldspawn(); //for global fog
|
||||
Fog_MarkModels(); //for volumetric fog
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -382,9 +382,9 @@ Fog_Init
|
|||
called when quake initializes
|
||||
=============
|
||||
*/
|
||||
void Fog_Init (void)
|
||||
void Fog_Init(void)
|
||||
{
|
||||
Cmd_AddCommand ("fog",Fog_FogCommand_f);
|
||||
Cmd_AddCommand("fog", Fog_FogCommand_f);
|
||||
|
||||
//Cvar_RegisterVariable (&r_vfog);
|
||||
|
||||
|
@ -394,7 +394,7 @@ void Fog_Init (void)
|
|||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
|
||||
Fog_SetupState ();
|
||||
Fog_SetupState();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -404,7 +404,7 @@ Fog_SetupState
|
|||
ericw -- moved from Fog_Init, state that needs to be setup when a new context is created
|
||||
=============
|
||||
*/
|
||||
void Fog_SetupState (void)
|
||||
void Fog_SetupState(void)
|
||||
{
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
}
|
||||
|
|
253
source/gl_mesh.c
253
source/gl_mesh.c
|
@ -58,7 +58,7 @@ int32_t stripcount;
|
|||
StripLength
|
||||
================
|
||||
*/
|
||||
int32_t StripLength (int32_t starttri, int32_t startv)
|
||||
int32_t StripLength(int32_t starttri, int32_t startv)
|
||||
{
|
||||
int32_t m1, m2;
|
||||
int32_t j;
|
||||
|
@ -69,42 +69,42 @@ int32_t StripLength (int32_t starttri, int32_t startv)
|
|||
|
||||
last = &triangles[starttri];
|
||||
|
||||
stripverts[0] = last->vertindex[(startv)%3];
|
||||
stripverts[1] = last->vertindex[(startv+1)%3];
|
||||
stripverts[2] = last->vertindex[(startv+2)%3];
|
||||
stripverts[0] = last->vertindex[(startv) % 3];
|
||||
stripverts[1] = last->vertindex[(startv + 1) % 3];
|
||||
stripverts[2] = last->vertindex[(startv + 2) % 3];
|
||||
|
||||
striptris[0] = starttri;
|
||||
stripcount = 1;
|
||||
|
||||
m1 = last->vertindex[(startv+2)%3];
|
||||
m2 = last->vertindex[(startv+1)%3];
|
||||
m1 = last->vertindex[(startv + 2) % 3];
|
||||
m2 = last->vertindex[(startv + 1) % 3];
|
||||
|
||||
// look for a matching triangle
|
||||
nexttri:
|
||||
for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
|
||||
for(j = starttri + 1, check = &triangles[starttri + 1] ; j < pheader->numtris ; j++, check++)
|
||||
{
|
||||
if (check->facesfront != last->facesfront)
|
||||
if(check->facesfront != last->facesfront)
|
||||
continue;
|
||||
for (k=0 ; k<3 ; k++)
|
||||
for(k = 0 ; k < 3 ; k++)
|
||||
{
|
||||
if (check->vertindex[k] != m1)
|
||||
if(check->vertindex[k] != m1)
|
||||
continue;
|
||||
if (check->vertindex[ (k+1)%3 ] != m2)
|
||||
if(check->vertindex[(k + 1) % 3 ] != m2)
|
||||
continue;
|
||||
|
||||
// this is the next part of the fan
|
||||
|
||||
// if we can't use this triangle, this tristrip is done
|
||||
if (used[j])
|
||||
if(used[j])
|
||||
goto done;
|
||||
|
||||
// the new edge
|
||||
if (stripcount & 1)
|
||||
m2 = check->vertindex[ (k+2)%3 ];
|
||||
if(stripcount & 1)
|
||||
m2 = check->vertindex[(k + 2) % 3 ];
|
||||
else
|
||||
m1 = check->vertindex[ (k+2)%3 ];
|
||||
m1 = check->vertindex[(k + 2) % 3 ];
|
||||
|
||||
stripverts[stripcount+2] = check->vertindex[ (k+2)%3 ];
|
||||
stripverts[stripcount + 2] = check->vertindex[(k + 2) % 3 ];
|
||||
striptris[stripcount] = j;
|
||||
stripcount++;
|
||||
|
||||
|
@ -115,8 +115,8 @@ nexttri:
|
|||
done:
|
||||
|
||||
// clear the temp used flags
|
||||
for (j=starttri+1 ; j<pheader->numtris ; j++)
|
||||
if (used[j] == 2)
|
||||
for(j = starttri + 1 ; j < pheader->numtris ; j++)
|
||||
if(used[j] == 2)
|
||||
used[j] = 0;
|
||||
|
||||
return stripcount;
|
||||
|
@ -127,7 +127,7 @@ done:
|
|||
FanLength
|
||||
===========
|
||||
*/
|
||||
int32_t FanLength (int32_t starttri, int32_t startv)
|
||||
int32_t FanLength(int32_t starttri, int32_t startv)
|
||||
{
|
||||
int32_t m1, m2;
|
||||
int32_t j;
|
||||
|
@ -138,40 +138,40 @@ int32_t FanLength (int32_t starttri, int32_t startv)
|
|||
|
||||
last = &triangles[starttri];
|
||||
|
||||
stripverts[0] = last->vertindex[(startv)%3];
|
||||
stripverts[1] = last->vertindex[(startv+1)%3];
|
||||
stripverts[2] = last->vertindex[(startv+2)%3];
|
||||
stripverts[0] = last->vertindex[(startv) % 3];
|
||||
stripverts[1] = last->vertindex[(startv + 1) % 3];
|
||||
stripverts[2] = last->vertindex[(startv + 2) % 3];
|
||||
|
||||
striptris[0] = starttri;
|
||||
stripcount = 1;
|
||||
|
||||
m1 = last->vertindex[(startv+0)%3];
|
||||
m2 = last->vertindex[(startv+2)%3];
|
||||
m1 = last->vertindex[(startv + 0) % 3];
|
||||
m2 = last->vertindex[(startv + 2) % 3];
|
||||
|
||||
|
||||
// look for a matching triangle
|
||||
nexttri:
|
||||
for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
|
||||
for(j = starttri + 1, check = &triangles[starttri + 1] ; j < pheader->numtris ; j++, check++)
|
||||
{
|
||||
if (check->facesfront != last->facesfront)
|
||||
if(check->facesfront != last->facesfront)
|
||||
continue;
|
||||
for (k=0 ; k<3 ; k++)
|
||||
for(k = 0 ; k < 3 ; k++)
|
||||
{
|
||||
if (check->vertindex[k] != m1)
|
||||
if(check->vertindex[k] != m1)
|
||||
continue;
|
||||
if (check->vertindex[ (k+1)%3 ] != m2)
|
||||
if(check->vertindex[(k + 1) % 3 ] != m2)
|
||||
continue;
|
||||
|
||||
// this is the next part of the fan
|
||||
|
||||
// if we can't use this triangle, this tristrip is done
|
||||
if (used[j])
|
||||
if(used[j])
|
||||
goto done;
|
||||
|
||||
// the new edge
|
||||
m2 = check->vertindex[ (k+2)%3 ];
|
||||
m2 = check->vertindex[(k + 2) % 3 ];
|
||||
|
||||
stripverts[stripcount+2] = m2;
|
||||
stripverts[stripcount + 2] = m2;
|
||||
striptris[stripcount] = j;
|
||||
stripcount++;
|
||||
|
||||
|
@ -182,8 +182,8 @@ nexttri:
|
|||
done:
|
||||
|
||||
// clear the temp used flags
|
||||
for (j=starttri+1 ; j<pheader->numtris ; j++)
|
||||
if (used[j] == 2)
|
||||
for(j = starttri + 1 ; j < pheader->numtris ; j++)
|
||||
if(used[j] == 2)
|
||||
used[j] = 0;
|
||||
|
||||
return stripcount;
|
||||
|
@ -198,7 +198,7 @@ Generate a list of trifans or strips
|
|||
for the model, which holds for all frames
|
||||
================
|
||||
*/
|
||||
void BuildTris (void)
|
||||
void BuildTris(void)
|
||||
{
|
||||
int32_t i, j, k;
|
||||
int32_t startv;
|
||||
|
@ -213,46 +213,46 @@ void BuildTris (void)
|
|||
//
|
||||
numorder = 0;
|
||||
numcommands = 0;
|
||||
memset (used, 0, sizeof(used));
|
||||
for (i = 0; i < pheader->numtris; i++)
|
||||
memset(used, 0, sizeof(used));
|
||||
for(i = 0; i < pheader->numtris; i++)
|
||||
{
|
||||
// pick an unused triangle and start the trifan
|
||||
if (used[i])
|
||||
if(used[i])
|
||||
continue;
|
||||
|
||||
bestlen = 0;
|
||||
besttype = 0;
|
||||
for (type = 0 ; type < 2 ; type++)
|
||||
for(type = 0 ; type < 2 ; type++)
|
||||
// type = 1;
|
||||
{
|
||||
for (startv = 0; startv < 3; startv++)
|
||||
for(startv = 0; startv < 3; startv++)
|
||||
{
|
||||
if (type == 1)
|
||||
len = StripLength (i, startv);
|
||||
if(type == 1)
|
||||
len = StripLength(i, startv);
|
||||
else
|
||||
len = FanLength (i, startv);
|
||||
if (len > bestlen)
|
||||
len = FanLength(i, startv);
|
||||
if(len > bestlen)
|
||||
{
|
||||
besttype = type;
|
||||
bestlen = len;
|
||||
for (j = 0; j < bestlen+2; j++)
|
||||
for(j = 0; j < bestlen + 2; j++)
|
||||
bestverts[j] = stripverts[j];
|
||||
for (j = 0; j < bestlen; j++)
|
||||
for(j = 0; j < bestlen; j++)
|
||||
besttris[j] = striptris[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mark the tris on the best strip as used
|
||||
for (j = 0; j < bestlen; j++)
|
||||
for(j = 0; j < bestlen; j++)
|
||||
used[besttris[j]] = 1;
|
||||
|
||||
if (besttype == 1)
|
||||
commands[numcommands++] = (bestlen+2);
|
||||
if(besttype == 1)
|
||||
commands[numcommands++] = (bestlen + 2);
|
||||
else
|
||||
commands[numcommands++] = -(bestlen+2);
|
||||
commands[numcommands++] = -(bestlen + 2);
|
||||
|
||||
for (j = 0; j < bestlen+2; j++)
|
||||
for(j = 0; j < bestlen + 2; j++)
|
||||
{
|
||||
int32_t tmp;
|
||||
|
||||
|
@ -263,7 +263,7 @@ void BuildTris (void)
|
|||
// emit s/t coords into the commands stream
|
||||
s = stverts[k].s;
|
||||
t = stverts[k].t;
|
||||
if (!triangles[besttris[0]].facesfront && stverts[k].onseam)
|
||||
if(!triangles[besttris[0]].facesfront && stverts[k].onseam)
|
||||
s += pheader->skinwidth / 2; // on back side
|
||||
s = (s + 0.5) / pheader->skinwidth;
|
||||
t = (t + 0.5) / pheader->skinheight;
|
||||
|
@ -272,30 +272,30 @@ void BuildTris (void)
|
|||
// *(float *)&commands[numcommands++] = t;
|
||||
// NOTE: 4 == sizeof(int32_t)
|
||||
// == sizeof(float)
|
||||
memcpy (&tmp, &s, 4);
|
||||
memcpy(&tmp, &s, 4);
|
||||
commands[numcommands++] = tmp;
|
||||
memcpy (&tmp, &t, 4);
|
||||
memcpy(&tmp, &t, 4);
|
||||
commands[numcommands++] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
commands[numcommands++] = 0; // end of list marker
|
||||
|
||||
Con_DPrintf2 ("%3" PRIi32 " tri %3" PRIi32 " vert %3" PRIi32 " cmd\n", pheader->numtris, numorder, numcommands);
|
||||
Con_DPrintf2("%3" PRIi32 " tri %3" PRIi32 " vert %3" PRIi32 " cmd\n", pheader->numtris, numorder, numcommands);
|
||||
|
||||
allverts += numorder;
|
||||
alltris += pheader->numtris;
|
||||
}
|
||||
|
||||
static void GL_MakeAliasModelDisplayLists_VBO (void);
|
||||
static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr);
|
||||
static void GL_MakeAliasModelDisplayLists_VBO(void);
|
||||
static void GLMesh_LoadVertexBuffer(qmodel_t *m, const aliashdr_t *hdr);
|
||||
|
||||
/*
|
||||
================
|
||||
GL_MakeAliasModelDisplayLists
|
||||
================
|
||||
*/
|
||||
void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr)
|
||||
void GL_MakeAliasModelDisplayLists(qmodel_t *m, aliashdr_t *hdr)
|
||||
{
|
||||
int32_t i, j;
|
||||
int32_t *cmds;
|
||||
|
@ -305,22 +305,22 @@ void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr)
|
|||
int32_t *loadcmds; //johnfitz
|
||||
|
||||
//johnfitz -- padded skins
|
||||
hscale = (float)hdr->skinwidth/(float)TexMgr_PadConditional(hdr->skinwidth);
|
||||
vscale = (float)hdr->skinheight/(float)TexMgr_PadConditional(hdr->skinheight);
|
||||
hscale = (float)hdr->skinwidth / (float)TexMgr_PadConditional(hdr->skinwidth);
|
||||
vscale = (float)hdr->skinheight / (float)TexMgr_PadConditional(hdr->skinheight);
|
||||
//johnfitz
|
||||
|
||||
aliasmodel = m;
|
||||
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
||||
|
||||
//johnfitz -- generate meshes
|
||||
Con_DPrintf2 ("meshing %s...\n",m->name);
|
||||
BuildTris ();
|
||||
Con_DPrintf2("meshing %s...\n", m->name);
|
||||
BuildTris();
|
||||
|
||||
// save the data out
|
||||
|
||||
paliashdr->poseverts = numorder;
|
||||
|
||||
cmds = (int32_t *) Hunk_Alloc (numcommands * 4);
|
||||
cmds = (int32_t *) Hunk_Alloc(numcommands * 4);
|
||||
paliashdr->commands = (byte *)cmds - (byte *)paliashdr;
|
||||
|
||||
//johnfitz -- precompute texcoords for padded skins
|
||||
|
@ -329,28 +329,29 @@ void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr)
|
|||
{
|
||||
*cmds++ = count = *loadcmds++;
|
||||
|
||||
if (!count)
|
||||
if(!count)
|
||||
break;
|
||||
|
||||
if (count < 0)
|
||||
if(count < 0)
|
||||
count = -count;
|
||||
|
||||
do
|
||||
{
|
||||
*(float *)cmds++ = hscale * (*(float *)loadcmds++);
|
||||
*(float *)cmds++ = vscale * (*(float *)loadcmds++);
|
||||
} while (--count);
|
||||
}
|
||||
while(--count);
|
||||
}
|
||||
//johnfitz
|
||||
|
||||
verts = (trivertx_t *) Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t));
|
||||
verts = (trivertx_t *) Hunk_Alloc(paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t));
|
||||
paliashdr->posedata = (byte *)verts - (byte *)paliashdr;
|
||||
for (i=0 ; i<paliashdr->numposes ; i++)
|
||||
for (j=0 ; j<numorder ; j++)
|
||||
for(i = 0 ; i < paliashdr->numposes ; i++)
|
||||
for(j = 0 ; j < numorder ; j++)
|
||||
*verts++ = poseverts[i][vertexorder[j]];
|
||||
|
||||
// ericw
|
||||
GL_MakeAliasModelDisplayLists_VBO ();
|
||||
GL_MakeAliasModelDisplayLists_VBO();
|
||||
}
|
||||
|
||||
uint32_t r_meshindexbuffer = 0;
|
||||
|
@ -366,7 +367,7 @@ is copied to Mod_Extradata.
|
|||
Original code by MH from RMQEngine
|
||||
================
|
||||
*/
|
||||
void GL_MakeAliasModelDisplayLists_VBO (void)
|
||||
void GL_MakeAliasModelDisplayLists_VBO(void)
|
||||
{
|
||||
int32_t i, j;
|
||||
int32_t maxverts_vbo;
|
||||
|
@ -374,31 +375,31 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
|
|||
uint16_t *indexes;
|
||||
aliasmesh_t *desc;
|
||||
|
||||
if (!gl_glsl_alias_able)
|
||||
if(!gl_glsl_alias_able)
|
||||
return;
|
||||
|
||||
// first, copy the verts onto the hunk
|
||||
verts = (trivertx_t *) Hunk_Alloc (paliashdr->numposes * paliashdr->numverts * sizeof(trivertx_t));
|
||||
verts = (trivertx_t *) Hunk_Alloc(paliashdr->numposes * paliashdr->numverts * sizeof(trivertx_t));
|
||||
paliashdr->vertexes = (byte *)verts - (byte *)paliashdr;
|
||||
for (i=0 ; i<paliashdr->numposes ; i++)
|
||||
for (j=0 ; j<paliashdr->numverts ; j++)
|
||||
verts[i*paliashdr->numverts + j] = poseverts[i][j];
|
||||
for(i = 0 ; i < paliashdr->numposes ; i++)
|
||||
for(j = 0 ; j < paliashdr->numverts ; j++)
|
||||
verts[i * paliashdr->numverts + j] = poseverts[i][j];
|
||||
|
||||
// there can never be more than this number of verts and we just put them all on the hunk
|
||||
maxverts_vbo = pheader->numtris * 3;
|
||||
desc = (aliasmesh_t *) Hunk_Alloc (sizeof (aliasmesh_t) * maxverts_vbo);
|
||||
desc = (aliasmesh_t *) Hunk_Alloc(sizeof(aliasmesh_t) * maxverts_vbo);
|
||||
|
||||
// there will always be this number of indexes
|
||||
indexes = (uint16_t *) Hunk_Alloc (sizeof (uint16_t) * maxverts_vbo);
|
||||
indexes = (uint16_t *) Hunk_Alloc(sizeof(uint16_t) * maxverts_vbo);
|
||||
|
||||
pheader->indexes = (intptr_t) indexes - (intptr_t) pheader;
|
||||
pheader->meshdesc = (intptr_t) desc - (intptr_t) pheader;
|
||||
pheader->numindexes = 0;
|
||||
pheader->numverts_vbo = 0;
|
||||
|
||||
for (i = 0; i < pheader->numtris; i++)
|
||||
for(i = 0; i < pheader->numtris; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
for(j = 0; j < 3; j++)
|
||||
{
|
||||
int32_t v;
|
||||
|
||||
|
@ -410,13 +411,13 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
|
|||
int32_t t = stverts[vertindex].t;
|
||||
|
||||
// check for back side and adjust texcoord s
|
||||
if (!triangles[i].facesfront && stverts[vertindex].onseam) s += pheader->skinwidth / 2;
|
||||
if(!triangles[i].facesfront && stverts[vertindex].onseam) s += pheader->skinwidth / 2;
|
||||
|
||||
// see does this vert already exist
|
||||
for (v = 0; v < pheader->numverts_vbo; v++)
|
||||
for(v = 0; v < pheader->numverts_vbo; v++)
|
||||
{
|
||||
// it could use the same xyz but have different s and t
|
||||
if (desc[v].vertindex == vertindex && (int32_t) desc[v].st[0] == s && (int32_t) desc[v].st[1] == t)
|
||||
if(desc[v].vertindex == vertindex && (int32_t) desc[v].st[0] == s && (int32_t) desc[v].st[1] == t)
|
||||
{
|
||||
// exists; emit an index for it
|
||||
indexes[pheader->numindexes++] = v;
|
||||
|
@ -426,7 +427,7 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (v == pheader->numverts_vbo)
|
||||
if(v == pheader->numverts_vbo)
|
||||
{
|
||||
// doesn't exist; emit a new vert and index
|
||||
indexes[pheader->numindexes++] = pheader->numverts_vbo;
|
||||
|
@ -439,7 +440,7 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
|
|||
}
|
||||
|
||||
// upload immediately
|
||||
GLMesh_LoadVertexBuffer (aliasmodel, pheader);
|
||||
GLMesh_LoadVertexBuffer(aliasmodel, pheader);
|
||||
}
|
||||
|
||||
#define NUMVERTEXNORMALS 162
|
||||
|
@ -454,7 +455,7 @@ Upload the given alias model's mesh to a VBO
|
|||
Original code by MH from RMQEngine
|
||||
================
|
||||
*/
|
||||
static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
||||
static void GLMesh_LoadVertexBuffer(qmodel_t *m, const aliashdr_t *hdr)
|
||||
{
|
||||
int32_t totalvbosize = 0;
|
||||
const aliasmesh_t *desc;
|
||||
|
@ -463,7 +464,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
byte *vbodata;
|
||||
int32_t f;
|
||||
|
||||
if (!gl_glsl_alias_able)
|
||||
if(!gl_glsl_alias_able)
|
||||
return;
|
||||
|
||||
// count the sizes we need
|
||||
|
@ -474,26 +475,26 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
m->vboindexofs = 0;
|
||||
|
||||
m->vboxyzofs = 0;
|
||||
totalvbosize += (hdr->numposes * hdr->numverts_vbo * sizeof (meshxyz_t)); // ericw -- what RMQEngine called nummeshframes is called numposes in QuakeSpasm
|
||||
totalvbosize += (hdr->numposes * hdr->numverts_vbo * sizeof(meshxyz_t)); // ericw -- what RMQEngine called nummeshframes is called numposes in QuakeSpasm
|
||||
|
||||
m->vbostofs = totalvbosize;
|
||||
totalvbosize += (hdr->numverts_vbo * sizeof (meshst_t));
|
||||
totalvbosize += (hdr->numverts_vbo * sizeof(meshst_t));
|
||||
|
||||
if (!hdr->numindexes) return;
|
||||
if (!totalvbosize) return;
|
||||
if(!hdr->numindexes) return;
|
||||
if(!totalvbosize) return;
|
||||
|
||||
// grab the pointers to data in the extradata
|
||||
|
||||
desc = (aliasmesh_t *) ((byte *) hdr + hdr->meshdesc);
|
||||
indexes = (int16_t *) ((byte *) hdr + hdr->indexes);
|
||||
trivertexes = (trivertx_t *) ((byte *)hdr + hdr->vertexes);
|
||||
desc = (aliasmesh_t *)((byte *) hdr + hdr->meshdesc);
|
||||
indexes = (int16_t *)((byte *) hdr + hdr->indexes);
|
||||
trivertexes = (trivertx_t *)((byte *)hdr + hdr->vertexes);
|
||||
|
||||
// upload indices buffer
|
||||
|
||||
GL_DeleteBuffersFunc (1, &m->meshindexesvbo);
|
||||
GL_GenBuffersFunc (1, &m->meshindexesvbo);
|
||||
GL_BindBufferFunc (GL_ELEMENT_ARRAY_BUFFER, m->meshindexesvbo);
|
||||
GL_BufferDataFunc (GL_ELEMENT_ARRAY_BUFFER, hdr->numindexes * sizeof (uint16_t), indexes, GL_STATIC_DRAW);
|
||||
GL_DeleteBuffersFunc(1, &m->meshindexesvbo);
|
||||
GL_GenBuffersFunc(1, &m->meshindexesvbo);
|
||||
GL_BindBufferFunc(GL_ELEMENT_ARRAY_BUFFER, m->meshindexesvbo);
|
||||
GL_BufferDataFunc(GL_ELEMENT_ARRAY_BUFFER, hdr->numindexes * sizeof(uint16_t), indexes, GL_STATIC_DRAW);
|
||||
|
||||
// create the vertex buffer (empty)
|
||||
|
||||
|
@ -501,13 +502,13 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
memset(vbodata, 0, totalvbosize);
|
||||
|
||||
// fill in the vertices at the start of the buffer
|
||||
for (f = 0; f < hdr->numposes; f++) // ericw -- what RMQEngine called nummeshframes is called numposes in QuakeSpasm
|
||||
for(f = 0; f < hdr->numposes; f++) // ericw -- what RMQEngine called nummeshframes is called numposes in QuakeSpasm
|
||||
{
|
||||
int32_t v;
|
||||
meshxyz_t *xyz = (meshxyz_t *) (vbodata + (f * hdr->numverts_vbo * sizeof (meshxyz_t)));
|
||||
meshxyz_t *xyz = (meshxyz_t *)(vbodata + (f * hdr->numverts_vbo * sizeof(meshxyz_t)));
|
||||
const trivertx_t *tv = trivertexes + (hdr->numverts * f);
|
||||
|
||||
for (v = 0; v < hdr->numverts_vbo; v++)
|
||||
for(v = 0; v < hdr->numverts_vbo; v++)
|
||||
{
|
||||
trivertx_t trivert = tv[desc[v].vertindex];
|
||||
|
||||
|
@ -532,12 +533,12 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
float hscale, vscale;
|
||||
|
||||
//johnfitz -- padded skins
|
||||
hscale = (float)hdr->skinwidth/(float)TexMgr_PadConditional(hdr->skinwidth);
|
||||
vscale = (float)hdr->skinheight/(float)TexMgr_PadConditional(hdr->skinheight);
|
||||
hscale = (float)hdr->skinwidth / (float)TexMgr_PadConditional(hdr->skinwidth);
|
||||
vscale = (float)hdr->skinheight / (float)TexMgr_PadConditional(hdr->skinheight);
|
||||
//johnfitz
|
||||
|
||||
st = (meshst_t *) (vbodata + m->vbostofs);
|
||||
for (f = 0; f < hdr->numverts_vbo; f++)
|
||||
st = (meshst_t *)(vbodata + m->vbostofs);
|
||||
for(f = 0; f < hdr->numverts_vbo; f++)
|
||||
{
|
||||
st[f].st[0] = hscale * ((float) desc[f].st[0] + 0.5f) / (float) hdr->skinwidth;
|
||||
st[f].st[1] = vscale * ((float) desc[f].st[1] + 0.5f) / (float) hdr->skinheight;
|
||||
|
@ -545,15 +546,15 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
}
|
||||
|
||||
// upload vertexes buffer
|
||||
GL_DeleteBuffersFunc (1, &m->meshvbo);
|
||||
GL_GenBuffersFunc (1, &m->meshvbo);
|
||||
GL_BindBufferFunc (GL_ARRAY_BUFFER, m->meshvbo);
|
||||
GL_BufferDataFunc (GL_ARRAY_BUFFER, totalvbosize, vbodata, GL_STATIC_DRAW);
|
||||
GL_DeleteBuffersFunc(1, &m->meshvbo);
|
||||
GL_GenBuffersFunc(1, &m->meshvbo);
|
||||
GL_BindBufferFunc(GL_ARRAY_BUFFER, m->meshvbo);
|
||||
GL_BufferDataFunc(GL_ARRAY_BUFFER, totalvbosize, vbodata, GL_STATIC_DRAW);
|
||||
|
||||
free (vbodata);
|
||||
free(vbodata);
|
||||
|
||||
// invalidate the cached bindings
|
||||
GL_ClearBufferBindings ();
|
||||
GL_ClearBufferBindings();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -563,23 +564,23 @@ GLMesh_LoadVertexBuffers
|
|||
Loop over all precached alias models, and upload each one to a VBO.
|
||||
================
|
||||
*/
|
||||
void GLMesh_LoadVertexBuffers (void)
|
||||
void GLMesh_LoadVertexBuffers(void)
|
||||
{
|
||||
int32_t j;
|
||||
qmodel_t *m;
|
||||
const aliashdr_t *hdr;
|
||||
|
||||
if (!gl_glsl_alias_able)
|
||||
if(!gl_glsl_alias_able)
|
||||
return;
|
||||
|
||||
for (j = 1; j < MAX_MODELS; j++)
|
||||
for(j = 1; j < MAX_MODELS; j++)
|
||||
{
|
||||
if (!(m = cl.model_precache[j])) break;
|
||||
if (m->type != mod_alias) continue;
|
||||
if(!(m = cl.model_precache[j])) break;
|
||||
if(m->type != mod_alias) continue;
|
||||
|
||||
hdr = (const aliashdr_t *) Mod_Extradata (m);
|
||||
hdr = (const aliashdr_t *) Mod_Extradata(m);
|
||||
|
||||
GLMesh_LoadVertexBuffer (m, hdr);
|
||||
GLMesh_LoadVertexBuffer(m, hdr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -590,25 +591,25 @@ GLMesh_DeleteVertexBuffers
|
|||
Delete VBOs for all loaded alias models
|
||||
================
|
||||
*/
|
||||
void GLMesh_DeleteVertexBuffers (void)
|
||||
void GLMesh_DeleteVertexBuffers(void)
|
||||
{
|
||||
int32_t j;
|
||||
qmodel_t *m;
|
||||
|
||||
if (!gl_glsl_alias_able)
|
||||
if(!gl_glsl_alias_able)
|
||||
return;
|
||||
|
||||
for (j = 1; j < MAX_MODELS; j++)
|
||||
for(j = 1; j < MAX_MODELS; j++)
|
||||
{
|
||||
if (!(m = cl.model_precache[j])) break;
|
||||
if (m->type != mod_alias) continue;
|
||||
if(!(m = cl.model_precache[j])) break;
|
||||
if(m->type != mod_alias) continue;
|
||||
|
||||
GL_DeleteBuffersFunc (1, &m->meshvbo);
|
||||
GL_DeleteBuffersFunc(1, &m->meshvbo);
|
||||
m->meshvbo = 0;
|
||||
|
||||
GL_DeleteBuffersFunc (1, &m->meshindexesvbo);
|
||||
GL_DeleteBuffersFunc(1, &m->meshindexesvbo);
|
||||
m->meshindexesvbo = 0;
|
||||
}
|
||||
|
||||
GL_ClearBufferBindings ();
|
||||
GL_ClearBufferBindings();
|
||||
}
|
||||
|
|
1427
source/gl_model.c
1427
source/gl_model.c
File diff suppressed because it is too large
Load Diff
|
@ -77,7 +77,8 @@ typedef struct mplane_s
|
|||
|
||||
// ericw -- each texture has two chains, so we can clear the model chains
|
||||
// without affecting the world
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
chain_world = 0,
|
||||
chain_model = 1
|
||||
} texchain_t;
|
||||
|
@ -332,14 +333,16 @@ typedef struct
|
|||
} maliasgroup_t;
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct mtriangle_s {
|
||||
typedef struct mtriangle_s
|
||||
{
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
} mtriangle_t;
|
||||
|
||||
|
||||
#define MAX_SKINS 32
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
|
@ -503,17 +506,17 @@ typedef struct qmodel_s
|
|||
|
||||
//============================================================================
|
||||
|
||||
void Mod_Init (void);
|
||||
void Mod_ClearAll (void);
|
||||
void Mod_ResetAll (void); // for gamedir changes (Host_Game_f)
|
||||
qmodel_t *Mod_ForName (const char *name, bool crash);
|
||||
void *Mod_Extradata (qmodel_t *mod); // handles caching
|
||||
void Mod_TouchModel (const char *name);
|
||||
void Mod_Init(void);
|
||||
void Mod_ClearAll(void);
|
||||
void Mod_ResetAll(void); // for gamedir changes (Host_Game_f)
|
||||
qmodel_t *Mod_ForName(const char *name, bool crash);
|
||||
void *Mod_Extradata(qmodel_t *mod); // handles caching
|
||||
void Mod_TouchModel(const char *name);
|
||||
|
||||
mleaf_t *Mod_PointInLeaf (float *p, qmodel_t *model);
|
||||
byte *Mod_LeafPVS (mleaf_t *leaf, qmodel_t *model);
|
||||
byte *Mod_NoVisPVS (qmodel_t *model);
|
||||
mleaf_t *Mod_PointInLeaf(float *p, qmodel_t *model);
|
||||
byte *Mod_LeafPVS(mleaf_t *leaf, qmodel_t *model);
|
||||
byte *Mod_NoVisPVS(qmodel_t *model);
|
||||
|
||||
void Mod_SetExtraFlags (qmodel_t *mod);
|
||||
void Mod_SetExtraFlags(qmodel_t *mod);
|
||||
|
||||
#endif // __MODEL__
|
||||
|
|
|
@ -54,13 +54,13 @@ entity_t *r_addent;
|
|||
#define EXTRA_EFRAGS 128
|
||||
|
||||
// based on RMQEngine
|
||||
static efrag_t *R_GetEfrag (void)
|
||||
static efrag_t *R_GetEfrag(void)
|
||||
{
|
||||
// we could just Hunk_Alloc a single efrag_t and return it, but since
|
||||
// the struct is so small (2 pointers) allocate groups of them
|
||||
// to avoid wasting too much space on the hunk allocation headers.
|
||||
|
||||
if (cl.free_efrags)
|
||||
if(cl.free_efrags)
|
||||
{
|
||||
efrag_t *ef = cl.free_efrags;
|
||||
cl.free_efrags = ef->leafnext;
|
||||
|
@ -74,15 +74,15 @@ static efrag_t *R_GetEfrag (void)
|
|||
{
|
||||
int32_t i;
|
||||
|
||||
cl.free_efrags = (efrag_t *) Hunk_AllocName (EXTRA_EFRAGS * sizeof (efrag_t), "efrags");
|
||||
cl.free_efrags = (efrag_t *) Hunk_AllocName(EXTRA_EFRAGS * sizeof(efrag_t), "efrags");
|
||||
|
||||
for (i = 0; i < EXTRA_EFRAGS - 1; i++)
|
||||
for(i = 0; i < EXTRA_EFRAGS - 1; i++)
|
||||
cl.free_efrags[i].leafnext = &cl.free_efrags[i + 1];
|
||||
|
||||
cl.free_efrags[i].leafnext = NULL;
|
||||
|
||||
// call recursively to get a newly allocated free efrag
|
||||
return R_GetEfrag ();
|
||||
return R_GetEfrag();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,23 +91,23 @@ static efrag_t *R_GetEfrag (void)
|
|||
R_SplitEntityOnNode
|
||||
===================
|
||||
*/
|
||||
void R_SplitEntityOnNode (mnode_t *node)
|
||||
void R_SplitEntityOnNode(mnode_t *node)
|
||||
{
|
||||
efrag_t *ef;
|
||||
mplane_t *splitplane;
|
||||
mleaf_t *leaf;
|
||||
int32_t sides;
|
||||
|
||||
if (node->contents == CONTENTS_SOLID)
|
||||
if(node->contents == CONTENTS_SOLID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// add an efrag if the node is a leaf
|
||||
|
||||
if ( node->contents < 0)
|
||||
if(node->contents < 0)
|
||||
{
|
||||
if (!r_pefragtopnode)
|
||||
if(!r_pefragtopnode)
|
||||
r_pefragtopnode = node;
|
||||
|
||||
leaf = (mleaf_t *)node;
|
||||
|
@ -128,20 +128,20 @@ void R_SplitEntityOnNode (mnode_t *node)
|
|||
splitplane = node->plane;
|
||||
sides = BOX_ON_PLANE_SIDE(r_emins, r_emaxs, splitplane);
|
||||
|
||||
if (sides == 3)
|
||||
if(sides == 3)
|
||||
{
|
||||
// split on this plane
|
||||
// if this is the first splitter of this bmodel, remember it
|
||||
if (!r_pefragtopnode)
|
||||
if(!r_pefragtopnode)
|
||||
r_pefragtopnode = node;
|
||||
}
|
||||
|
||||
// recurse down the contacted sides
|
||||
if (sides & 1)
|
||||
R_SplitEntityOnNode (node->children[0]);
|
||||
if(sides & 1)
|
||||
R_SplitEntityOnNode(node->children[0]);
|
||||
|
||||
if (sides & 2)
|
||||
R_SplitEntityOnNode (node->children[1]);
|
||||
if(sides & 2)
|
||||
R_SplitEntityOnNode(node->children[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -149,13 +149,13 @@ void R_SplitEntityOnNode (mnode_t *node)
|
|||
R_CheckEfrags -- johnfitz -- check for excessive efrag count
|
||||
===========
|
||||
*/
|
||||
void R_CheckEfrags (void)
|
||||
void R_CheckEfrags(void)
|
||||
{
|
||||
if (cls.signon < 2)
|
||||
if(cls.signon < 2)
|
||||
return; //don't spam when still parsing signon packet full of static ents
|
||||
|
||||
if (cl.num_efrags > 640 && dev_peakstats.efrags <= 640)
|
||||
Con_DWarning ("%" PRIi32 " efrags exceeds standard limit of 640.\n", cl.num_efrags);
|
||||
if(cl.num_efrags > 640 && dev_peakstats.efrags <= 640)
|
||||
Con_DWarning("%" PRIi32 " efrags exceeds standard limit of 640.\n", cl.num_efrags);
|
||||
|
||||
dev_stats.efrags = cl.num_efrags;
|
||||
dev_peakstats.efrags = q_max(cl.num_efrags, dev_peakstats.efrags);
|
||||
|
@ -166,12 +166,12 @@ void R_CheckEfrags (void)
|
|||
R_AddEfrags
|
||||
===========
|
||||
*/
|
||||
void R_AddEfrags (entity_t *ent)
|
||||
void R_AddEfrags(entity_t *ent)
|
||||
{
|
||||
qmodel_t *entmodel;
|
||||
int32_t i;
|
||||
|
||||
if (!ent->model)
|
||||
if(!ent->model)
|
||||
return;
|
||||
|
||||
r_addent = ent;
|
||||
|
@ -180,17 +180,17 @@ void R_AddEfrags (entity_t *ent)
|
|||
|
||||
entmodel = ent->model;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
r_emins[i] = ent->origin[i] + entmodel->mins[i];
|
||||
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
|
||||
}
|
||||
|
||||
R_SplitEntityOnNode (cl.worldmodel->nodes);
|
||||
R_SplitEntityOnNode(cl.worldmodel->nodes);
|
||||
|
||||
ent->topnode = r_pefragtopnode;
|
||||
|
||||
R_CheckEfrags (); //johnfitz
|
||||
R_CheckEfrags(); //johnfitz
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,16 +199,16 @@ void R_AddEfrags (entity_t *ent)
|
|||
R_StoreEfrags -- johnfitz -- pointless switch statement removed.
|
||||
================
|
||||
*/
|
||||
void R_StoreEfrags (efrag_t **ppefrag)
|
||||
void R_StoreEfrags(efrag_t **ppefrag)
|
||||
{
|
||||
entity_t *pent;
|
||||
efrag_t *pefrag;
|
||||
|
||||
while ((pefrag = *ppefrag) != NULL)
|
||||
while((pefrag = *ppefrag) != NULL)
|
||||
{
|
||||
pent = pefrag->entity;
|
||||
|
||||
if ((pent->visframe != r_framecount) && (cl_numvisedicts < MAX_VISEDICTS))
|
||||
if((pent->visframe != r_framecount) && (cl_numvisedicts < MAX_VISEDICTS))
|
||||
{
|
||||
cl_visedicts[cl_numvisedicts++] = pent;
|
||||
pent->visframe = r_framecount;
|
||||
|
|
|
@ -32,32 +32,32 @@ extern cvar_t r_flatlightstyles; //johnfitz
|
|||
R_AnimateLight
|
||||
==================
|
||||
*/
|
||||
void R_AnimateLight (void)
|
||||
void R_AnimateLight(void)
|
||||
{
|
||||
int32_t i,j,k;
|
||||
int32_t i, j, k;
|
||||
|
||||
//
|
||||
// light animations
|
||||
// 'm' is normal light, 'a' is no light, 'z' is double bright
|
||||
i = (int32_t)(cl.time*10);
|
||||
for (j=0 ; j<MAX_LIGHTSTYLES ; j++)
|
||||
i = (int32_t)(cl.time * 10);
|
||||
for(j = 0 ; j < MAX_LIGHTSTYLES ; j++)
|
||||
{
|
||||
if (!cl_lightstyle[j].length)
|
||||
if(!cl_lightstyle[j].length)
|
||||
{
|
||||
d_lightstylevalue[j] = 256;
|
||||
continue;
|
||||
}
|
||||
//johnfitz -- r_flatlightstyles
|
||||
if (r_flatlightstyles.value == 2)
|
||||
if(r_flatlightstyles.value == 2)
|
||||
k = cl_lightstyle[j].peak - 'a';
|
||||
else if (r_flatlightstyles.value == 1)
|
||||
else if(r_flatlightstyles.value == 1)
|
||||
k = cl_lightstyle[j].average - 'a';
|
||||
else
|
||||
{
|
||||
k = i % cl_lightstyle[j].length;
|
||||
k = cl_lightstyle[j].map[k] - 'a';
|
||||
}
|
||||
d_lightstylevalue[j] = k*22;
|
||||
d_lightstylevalue[j] = k * 22;
|
||||
//johnfitz
|
||||
}
|
||||
}
|
||||
|
@ -70,20 +70,20 @@ DYNAMIC LIGHTS BLEND RENDERING (gl_flashblend 1)
|
|||
=============================================================================
|
||||
*/
|
||||
|
||||
void AddLightBlend (float r, float g, float b, float a2)
|
||||
void AddLightBlend(float r, float g, float b, float a2)
|
||||
{
|
||||
float a;
|
||||
|
||||
v_blend[3] = a = v_blend[3] + a2*(1-v_blend[3]);
|
||||
v_blend[3] = a = v_blend[3] + a2 * (1 - v_blend[3]);
|
||||
|
||||
a2 = a2/a;
|
||||
a2 = a2 / a;
|
||||
|
||||
v_blend[0] = v_blend[1]*(1-a2) + r*a2;
|
||||
v_blend[1] = v_blend[1]*(1-a2) + g*a2;
|
||||
v_blend[2] = v_blend[2]*(1-a2) + b*a2;
|
||||
v_blend[0] = v_blend[1] * (1 - a2) + r * a2;
|
||||
v_blend[1] = v_blend[1] * (1 - a2) + g * a2;
|
||||
v_blend[2] = v_blend[2] * (1 - a2) + b * a2;
|
||||
}
|
||||
|
||||
void R_RenderDlight (dlight_t *light)
|
||||
void R_RenderDlight(dlight_t *light)
|
||||
{
|
||||
int32_t i, j;
|
||||
float a;
|
||||
|
@ -92,28 +92,29 @@ void R_RenderDlight (dlight_t *light)
|
|||
|
||||
rad = light->radius * 0.35;
|
||||
|
||||
VectorSubtract (light->origin, r_origin, v);
|
||||
if (VectorLength (v) < rad)
|
||||
{ // view is inside the dlight
|
||||
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
|
||||
VectorSubtract(light->origin, r_origin, v);
|
||||
if(VectorLength(v) < rad)
|
||||
{
|
||||
// view is inside the dlight
|
||||
AddLightBlend(1, 0.5, 0, light->radius * 0.0003);
|
||||
return;
|
||||
}
|
||||
|
||||
glBegin (GL_TRIANGLE_FAN);
|
||||
glColor3f (0.2,0.1,0.0);
|
||||
for (i=0 ; i<3 ; i++)
|
||||
v[i] = light->origin[i] - vpn[i]*rad;
|
||||
glVertex3fv (v);
|
||||
glColor3f (0,0,0);
|
||||
for (i=16 ; i>=0 ; i--)
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glColor3f(0.2, 0.1, 0.0);
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
v[i] = light->origin[i] - vpn[i] * rad;
|
||||
glVertex3fv(v);
|
||||
glColor3f(0, 0, 0);
|
||||
for(i = 16 ; i >= 0 ; i--)
|
||||
{
|
||||
a = i/16.0 * M_PI*2;
|
||||
for (j=0 ; j<3 ; j++)
|
||||
v[j] = light->origin[j] + vright[j]*cos(a)*rad
|
||||
+ vup[j]*sin(a)*rad;
|
||||
glVertex3fv (v);
|
||||
a = i / 16.0 * M_PI * 2;
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
v[j] = light->origin[j] + vright[j] * cos(a) * rad
|
||||
+ vup[j] * sin(a) * rad;
|
||||
glVertex3fv(v);
|
||||
}
|
||||
glEnd ();
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,35 +122,35 @@ void R_RenderDlight (dlight_t *light)
|
|||
R_RenderDlights
|
||||
=============
|
||||
*/
|
||||
void R_RenderDlights (void)
|
||||
void R_RenderDlights(void)
|
||||
{
|
||||
int32_t i;
|
||||
dlight_t *l;
|
||||
|
||||
if (!gl_flashblend.value)
|
||||
if(!gl_flashblend.value)
|
||||
return;
|
||||
|
||||
r_dlightframecount = r_framecount + 1; // because the count hasn't
|
||||
// advanced yet for this frame
|
||||
glDepthMask (0);
|
||||
glDisable (GL_TEXTURE_2D);
|
||||
glShadeModel (GL_SMOOTH);
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_ONE, GL_ONE);
|
||||
glDepthMask(0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
l = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, l++)
|
||||
for(i = 0 ; i < MAX_DLIGHTS ; i++, l++)
|
||||
{
|
||||
if (l->die < cl.time || !l->radius)
|
||||
if(l->die < cl.time || !l->radius)
|
||||
continue;
|
||||
R_RenderDlight (l);
|
||||
R_RenderDlight(l);
|
||||
}
|
||||
|
||||
glColor3f (1,1,1);
|
||||
glDisable (GL_BLEND);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask (1);
|
||||
glColor3f(1, 1, 1);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,7 +167,7 @@ DYNAMIC LIGHTS
|
|||
R_MarkLights -- johnfitz -- rewritten to use LordHavoc's lighting speedup
|
||||
=============
|
||||
*/
|
||||
void R_MarkLights (dlight_t *light, int32_t num, mnode_t *node)
|
||||
void R_MarkLights(dlight_t *light, int32_t num, mnode_t *node)
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
msurface_t *surf;
|
||||
|
@ -176,44 +177,48 @@ void R_MarkLights (dlight_t *light, int32_t num, mnode_t *node)
|
|||
|
||||
start:
|
||||
|
||||
if (node->contents < 0)
|
||||
if(node->contents < 0)
|
||||
return;
|
||||
|
||||
splitplane = node->plane;
|
||||
if (splitplane->type < 3)
|
||||
if(splitplane->type < 3)
|
||||
dist = light->origin[splitplane->type] - splitplane->dist;
|
||||
else
|
||||
dist = DotProduct (light->origin, splitplane->normal) - splitplane->dist;
|
||||
dist = DotProduct(light->origin, splitplane->normal) - splitplane->dist;
|
||||
|
||||
if (dist > light->radius)
|
||||
if(dist > light->radius)
|
||||
{
|
||||
node = node->children[0];
|
||||
goto start;
|
||||
}
|
||||
if (dist < -light->radius)
|
||||
if(dist < -light->radius)
|
||||
{
|
||||
node = node->children[1];
|
||||
goto start;
|
||||
}
|
||||
|
||||
maxdist = light->radius*light->radius;
|
||||
maxdist = light->radius * light->radius;
|
||||
// mark the polygons
|
||||
surf = cl.worldmodel->surfaces + node->firstsurface;
|
||||
for (i=0 ; i<node->numsurfaces ; i++, surf++)
|
||||
for(i = 0 ; i < node->numsurfaces ; i++, surf++)
|
||||
{
|
||||
for (j=0 ; j<3 ; j++)
|
||||
impact[j] = light->origin[j] - surf->plane->normal[j]*dist;
|
||||
for(j = 0 ; j < 3 ; j++)
|
||||
impact[j] = light->origin[j] - surf->plane->normal[j] * dist;
|
||||
// clamp center of light to corner and check brightness
|
||||
l = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
||||
s = l+0.5;if (s < 0) s = 0;else if (s > surf->extents[0]) s = surf->extents[0];
|
||||
l = DotProduct(impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0];
|
||||
s = l + 0.5;
|
||||
if(s < 0) s = 0;
|
||||
else if(s > surf->extents[0]) s = surf->extents[0];
|
||||
s = l - s;
|
||||
l = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
||||
t = l+0.5;if (t < 0) t = 0;else if (t > surf->extents[1]) t = surf->extents[1];
|
||||
l = DotProduct(impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1];
|
||||
t = l + 0.5;
|
||||
if(t < 0) t = 0;
|
||||
else if(t > surf->extents[1]) t = surf->extents[1];
|
||||
t = l - t;
|
||||
// compare to minimum light
|
||||
if ((s*s+t*t+dist*dist) < maxdist)
|
||||
if((s * s + t * t + dist * dist) < maxdist)
|
||||
{
|
||||
if (surf->dlightframe != r_dlightframecount) // not dynamic until now
|
||||
if(surf->dlightframe != r_dlightframecount) // not dynamic until now
|
||||
{
|
||||
surf->dlightbits[num >> 5] = 1U << (num & 31);
|
||||
surf->dlightframe = r_dlightframecount;
|
||||
|
@ -223,10 +228,10 @@ start:
|
|||
}
|
||||
}
|
||||
|
||||
if (node->children[0]->contents >= 0)
|
||||
R_MarkLights (light, num, node->children[0]);
|
||||
if (node->children[1]->contents >= 0)
|
||||
R_MarkLights (light, num, node->children[1]);
|
||||
if(node->children[0]->contents >= 0)
|
||||
R_MarkLights(light, num, node->children[0]);
|
||||
if(node->children[1]->contents >= 0)
|
||||
R_MarkLights(light, num, node->children[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -234,23 +239,23 @@ start:
|
|||
R_PushDlights
|
||||
=============
|
||||
*/
|
||||
void R_PushDlights (void)
|
||||
void R_PushDlights(void)
|
||||
{
|
||||
int32_t i;
|
||||
dlight_t *l;
|
||||
|
||||
if (gl_flashblend.value)
|
||||
if(gl_flashblend.value)
|
||||
return;
|
||||
|
||||
r_dlightframecount = r_framecount + 1; // because the count hasn't
|
||||
// advanced yet for this frame
|
||||
l = cl_dlights;
|
||||
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, l++)
|
||||
for(i = 0 ; i < MAX_DLIGHTS ; i++, l++)
|
||||
{
|
||||
if (l->die < cl.time || !l->radius)
|
||||
if(l->die < cl.time || !l->radius)
|
||||
continue;
|
||||
R_MarkLights (l, i, cl.worldmodel->nodes);
|
||||
R_MarkLights(l, i, cl.worldmodel->nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,17 +277,17 @@ vec3_t lightcolor; //johnfitz -- lit support via lordhavoc
|
|||
RecursiveLightPoint -- johnfitz -- replaced entire function for lit support via lordhavoc
|
||||
=============
|
||||
*/
|
||||
int32_t RecursiveLightPoint (vec3_t color, mnode_t *node, vec3_t start, vec3_t end)
|
||||
int32_t RecursiveLightPoint(vec3_t color, mnode_t *node, vec3_t start, vec3_t end)
|
||||
{
|
||||
float front, back, frac;
|
||||
vec3_t mid;
|
||||
|
||||
loc0:
|
||||
if (node->contents < 0)
|
||||
if(node->contents < 0)
|
||||
return false; // didn't hit anything
|
||||
|
||||
// calculate mid point
|
||||
if (node->plane->type < 3)
|
||||
if(node->plane->type < 3)
|
||||
{
|
||||
front = start[node->plane->type] - node->plane->dist;
|
||||
back = end[node->plane->type] - node->plane->dist;
|
||||
|
@ -294,79 +299,87 @@ loc0:
|
|||
}
|
||||
|
||||
// LordHavoc: optimized recursion
|
||||
if ((back < 0) == (front < 0))
|
||||
if((back < 0) == (front < 0))
|
||||
// return RecursiveLightPoint (color, node->children[front < 0], start, end);
|
||||
{
|
||||
node = node->children[front < 0];
|
||||
goto loc0;
|
||||
}
|
||||
|
||||
frac = front / (front-back);
|
||||
mid[0] = start[0] + (end[0] - start[0])*frac;
|
||||
mid[1] = start[1] + (end[1] - start[1])*frac;
|
||||
mid[2] = start[2] + (end[2] - start[2])*frac;
|
||||
frac = front / (front - back);
|
||||
mid[0] = start[0] + (end[0] - start[0]) * frac;
|
||||
mid[1] = start[1] + (end[1] - start[1]) * frac;
|
||||
mid[2] = start[2] + (end[2] - start[2]) * frac;
|
||||
|
||||
// go down front side
|
||||
if (RecursiveLightPoint (color, node->children[front < 0], start, mid))
|
||||
if(RecursiveLightPoint(color, node->children[front < 0], start, mid))
|
||||
return true; // hit something
|
||||
else
|
||||
{
|
||||
int32_t i, ds, dt;
|
||||
msurface_t *surf;
|
||||
// check for impact on this node
|
||||
VectorCopy (mid, lightspot);
|
||||
VectorCopy(mid, lightspot);
|
||||
lightplane = node->plane;
|
||||
|
||||
surf = cl.worldmodel->surfaces + node->firstsurface;
|
||||
for (i = 0;i < node->numsurfaces;i++, surf++)
|
||||
for(i = 0; i < node->numsurfaces; i++, surf++)
|
||||
{
|
||||
if (surf->flags & SURF_DRAWTILED)
|
||||
if(surf->flags & SURF_DRAWTILED)
|
||||
continue; // no lightmaps
|
||||
|
||||
// ericw -- added double casts to force 64-bit precision.
|
||||
// Without them the zombie at the start of jam3_ericw.bsp was
|
||||
// incorrectly being lit up in SSE builds.
|
||||
ds = (int32_t) ((double) DoublePrecisionDotProduct (mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);
|
||||
dt = (int32_t) ((double) DoublePrecisionDotProduct (mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);
|
||||
ds = (int32_t)((double) DoublePrecisionDotProduct(mid, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]);
|
||||
dt = (int32_t)((double) DoublePrecisionDotProduct(mid, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]);
|
||||
|
||||
if (ds < surf->texturemins[0] || dt < surf->texturemins[1])
|
||||
if(ds < surf->texturemins[0] || dt < surf->texturemins[1])
|
||||
continue;
|
||||
|
||||
ds -= surf->texturemins[0];
|
||||
dt -= surf->texturemins[1];
|
||||
|
||||
if (ds > surf->extents[0] || dt > surf->extents[1])
|
||||
if(ds > surf->extents[0] || dt > surf->extents[1])
|
||||
continue;
|
||||
|
||||
if (surf->samples)
|
||||
if(surf->samples)
|
||||
{
|
||||
// LordHavoc: enhanced to interpolate lighting
|
||||
byte *lightmap;
|
||||
int32_t maps, line3, dsfrac = ds & 15, dtfrac = dt & 15, r00 = 0, g00 = 0, b00 = 0, r01 = 0, g01 = 0, b01 = 0, r10 = 0, g10 = 0, b10 = 0, r11 = 0, g11 = 0, b11 = 0;
|
||||
float scale;
|
||||
line3 = ((surf->extents[0]>>4)+1)*3;
|
||||
line3 = ((surf->extents[0] >> 4) + 1) * 3;
|
||||
|
||||
lightmap = surf->samples + ((dt>>4) * ((surf->extents[0]>>4)+1) + (ds>>4))*3; // LordHavoc: *3 for color
|
||||
lightmap = surf->samples + ((dt >> 4) * ((surf->extents[0] >> 4) + 1) + (ds >> 4)) * 3; // LordHavoc: *3 for color
|
||||
|
||||
for (maps = 0;maps < MAXLIGHTMAPS && surf->styles[maps] != 255;maps++)
|
||||
for(maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
||||
{
|
||||
scale = (float) d_lightstylevalue[surf->styles[maps]] * 1.0 / 256.0;
|
||||
r00 += (float) lightmap[ 0] * scale;g00 += (float) lightmap[ 1] * scale;b00 += (float) lightmap[2] * scale;
|
||||
r01 += (float) lightmap[ 3] * scale;g01 += (float) lightmap[ 4] * scale;b01 += (float) lightmap[5] * scale;
|
||||
r10 += (float) lightmap[line3+0] * scale;g10 += (float) lightmap[line3+1] * scale;b10 += (float) lightmap[line3+2] * scale;
|
||||
r11 += (float) lightmap[line3+3] * scale;g11 += (float) lightmap[line3+4] * scale;b11 += (float) lightmap[line3+5] * scale;
|
||||
lightmap += ((surf->extents[0]>>4)+1) * ((surf->extents[1]>>4)+1)*3; // LordHavoc: *3 for colored lighting
|
||||
r00 += (float) lightmap[ 0] * scale;
|
||||
g00 += (float) lightmap[ 1] * scale;
|
||||
b00 += (float) lightmap[2] * scale;
|
||||
r01 += (float) lightmap[ 3] * scale;
|
||||
g01 += (float) lightmap[ 4] * scale;
|
||||
b01 += (float) lightmap[5] * scale;
|
||||
r10 += (float) lightmap[line3 + 0] * scale;
|
||||
g10 += (float) lightmap[line3 + 1] * scale;
|
||||
b10 += (float) lightmap[line3 + 2] * scale;
|
||||
r11 += (float) lightmap[line3 + 3] * scale;
|
||||
g11 += (float) lightmap[line3 + 4] * scale;
|
||||
b11 += (float) lightmap[line3 + 5] * scale;
|
||||
lightmap += ((surf->extents[0] >> 4) + 1) * ((surf->extents[1] >> 4) + 1) * 3; // LordHavoc: *3 for colored lighting
|
||||
}
|
||||
|
||||
color[0] += (float) ((int32_t) ((((((((r11-r10) * dsfrac) >> 4) + r10)-((((r01-r00) * dsfrac) >> 4) + r00)) * dtfrac) >> 4) + ((((r01-r00) * dsfrac) >> 4) + r00)));
|
||||
color[1] += (float) ((int32_t) ((((((((g11-g10) * dsfrac) >> 4) + g10)-((((g01-g00) * dsfrac) >> 4) + g00)) * dtfrac) >> 4) + ((((g01-g00) * dsfrac) >> 4) + g00)));
|
||||
color[2] += (float) ((int32_t) ((((((((b11-b10) * dsfrac) >> 4) + b10)-((((b01-b00) * dsfrac) >> 4) + b00)) * dtfrac) >> 4) + ((((b01-b00) * dsfrac) >> 4) + b00)));
|
||||
color[0] += (float)((int32_t)((((((((r11 - r10) * dsfrac) >> 4) + r10) - ((((r01 - r00) * dsfrac) >> 4) + r00)) * dtfrac) >> 4) + ((((r01 - r00) * dsfrac) >> 4) + r00)));
|
||||
color[1] += (float)((int32_t)((((((((g11 - g10) * dsfrac) >> 4) + g10) - ((((g01 - g00) * dsfrac) >> 4) + g00)) * dtfrac) >> 4) + ((((g01 - g00) * dsfrac) >> 4) + g00)));
|
||||
color[2] += (float)((int32_t)((((((((b11 - b10) * dsfrac) >> 4) + b10) - ((((b01 - b00) * dsfrac) >> 4) + b00)) * dtfrac) >> 4) + ((((b01 - b00) * dsfrac) >> 4) + b00)));
|
||||
}
|
||||
return true; // success
|
||||
}
|
||||
|
||||
// go down back side
|
||||
return RecursiveLightPoint (color, node->children[front >= 0], mid, end);
|
||||
return RecursiveLightPoint(color, node->children[front >= 0], mid, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,11 +388,11 @@ loc0:
|
|||
R_LightPoint -- johnfitz -- replaced entire function for lit support via lordhavoc
|
||||
=============
|
||||
*/
|
||||
int32_t R_LightPoint (vec3_t p)
|
||||
int32_t R_LightPoint(vec3_t p)
|
||||
{
|
||||
vec3_t end;
|
||||
|
||||
if (!cl.worldmodel->lightdata)
|
||||
if(!cl.worldmodel->lightdata)
|
||||
{
|
||||
lightcolor[0] = lightcolor[1] = lightcolor[2] = 255;
|
||||
return 255;
|
||||
|
@ -390,6 +403,6 @@ int32_t R_LightPoint (vec3_t p)
|
|||
end[2] = p[2] - 8192; //johnfitz -- was 2048
|
||||
|
||||
lightcolor[0] = lightcolor[1] = lightcolor[2] = 0;
|
||||
RecursiveLightPoint (lightcolor, cl.worldmodel->nodes, p, end);
|
||||
RecursiveLightPoint(lightcolor, cl.worldmodel->nodes, p, end);
|
||||
return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -56,10 +56,10 @@ extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz
|
|||
GL_Overbright_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void GL_Overbright_f (cvar_t *var)
|
||||
static void GL_Overbright_f(cvar_t *var)
|
||||
{
|
||||
(void)var;
|
||||
R_RebuildAllLightmaps ();
|
||||
R_RebuildAllLightmaps();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -67,10 +67,10 @@ static void GL_Overbright_f (cvar_t *var)
|
|||
GL_Fullbrights_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void GL_Fullbrights_f (cvar_t *var)
|
||||
static void GL_Fullbrights_f(cvar_t *var)
|
||||
{
|
||||
(void)var;
|
||||
TexMgr_ReloadNobrightImages ();
|
||||
TexMgr_ReloadNobrightImages();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -78,7 +78,7 @@ static void GL_Fullbrights_f (cvar_t *var)
|
|||
R_SetClearColor_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void R_SetClearColor_f (cvar_t *var)
|
||||
static void R_SetClearColor_f(cvar_t *var)
|
||||
{
|
||||
byte *rgb;
|
||||
int32_t s;
|
||||
|
@ -86,7 +86,7 @@ static void R_SetClearColor_f (cvar_t *var)
|
|||
(void)var;
|
||||
s = (int32_t)r_clearcolor.value & 0xFF;
|
||||
rgb = (byte*)(d_8to24table + s);
|
||||
glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0);
|
||||
glClearColor(rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -94,7 +94,7 @@ static void R_SetClearColor_f (cvar_t *var)
|
|||
R_Novis_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void R_VisChanged (cvar_t *var)
|
||||
static void R_VisChanged(cvar_t *var)
|
||||
{
|
||||
extern int32_t vis_changed;
|
||||
(void)var;
|
||||
|
@ -106,12 +106,12 @@ static void R_VisChanged (cvar_t *var)
|
|||
R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow_list cvar changes
|
||||
===============
|
||||
*/
|
||||
static void R_Model_ExtraFlags_List_f (cvar_t *var)
|
||||
static void R_Model_ExtraFlags_List_f(cvar_t *var)
|
||||
{
|
||||
(void)var;
|
||||
int32_t i;
|
||||
for (i=0; i < MAX_MODELS; i++)
|
||||
Mod_SetExtraFlags (cl.model_precache[i]);
|
||||
for(i = 0; i < MAX_MODELS; i++)
|
||||
Mod_SetExtraFlags(cl.model_precache[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -119,7 +119,7 @@ static void R_Model_ExtraFlags_List_f (cvar_t *var)
|
|||
R_SetWateralpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetWateralpha_f (cvar_t *var)
|
||||
static void R_SetWateralpha_f(cvar_t *var)
|
||||
{
|
||||
map_wateralpha = var->value;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ static void R_SetWateralpha_f (cvar_t *var)
|
|||
R_SetLavaalpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetLavaalpha_f (cvar_t *var)
|
||||
static void R_SetLavaalpha_f(cvar_t *var)
|
||||
{
|
||||
map_lavaalpha = var->value;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ static void R_SetLavaalpha_f (cvar_t *var)
|
|||
R_SetTelealpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetTelealpha_f (cvar_t *var)
|
||||
static void R_SetTelealpha_f(cvar_t *var)
|
||||
{
|
||||
map_telealpha = var->value;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ static void R_SetTelealpha_f (cvar_t *var)
|
|||
R_SetSlimealpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetSlimealpha_f (cvar_t *var)
|
||||
static void R_SetSlimealpha_f(cvar_t *var)
|
||||
{
|
||||
map_slimealpha = var->value;
|
||||
}
|
||||
|
@ -159,13 +159,13 @@ static void R_SetSlimealpha_f (cvar_t *var)
|
|||
GL_WaterAlphaForSurfface -- ericw
|
||||
====================
|
||||
*/
|
||||
float GL_WaterAlphaForSurface (msurface_t *fa)
|
||||
float GL_WaterAlphaForSurface(msurface_t *fa)
|
||||
{
|
||||
if (fa->flags & SURF_DRAWLAVA)
|
||||
if(fa->flags & SURF_DRAWLAVA)
|
||||
return map_lavaalpha > 0 ? map_lavaalpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWTELE)
|
||||
else if(fa->flags & SURF_DRAWTELE)
|
||||
return map_telealpha > 0 ? map_telealpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWSLIME)
|
||||
else if(fa->flags & SURF_DRAWSLIME)
|
||||
return map_slimealpha > 0 ? map_slimealpha : map_wateralpha;
|
||||
else
|
||||
return map_wateralpha;
|
||||
|
@ -177,80 +177,80 @@ float GL_WaterAlphaForSurface (msurface_t *fa)
|
|||
R_Init
|
||||
===============
|
||||
*/
|
||||
void R_Init (void)
|
||||
void R_Init(void)
|
||||
{
|
||||
extern cvar_t gl_finish;
|
||||
|
||||
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
|
||||
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
|
||||
Cmd_AddCommand("timerefresh", R_TimeRefresh_f);
|
||||
Cmd_AddCommand("pointfile", R_ReadPointFile_f);
|
||||
|
||||
Cvar_RegisterVariable (&r_norefresh);
|
||||
Cvar_RegisterVariable (&r_lightmap);
|
||||
Cvar_RegisterVariable (&r_fullbright);
|
||||
Cvar_RegisterVariable (&r_drawentities);
|
||||
Cvar_RegisterVariable (&r_drawviewmodel);
|
||||
Cvar_RegisterVariable (&r_shadows);
|
||||
Cvar_RegisterVariable (&r_wateralpha);
|
||||
Cvar_SetCallback (&r_wateralpha, R_SetWateralpha_f);
|
||||
Cvar_RegisterVariable (&r_dynamic);
|
||||
Cvar_RegisterVariable (&r_novis);
|
||||
Cvar_SetCallback (&r_novis, R_VisChanged);
|
||||
Cvar_RegisterVariable (&r_speeds);
|
||||
Cvar_RegisterVariable (&r_pos);
|
||||
Cvar_RegisterVariable(&r_norefresh);
|
||||
Cvar_RegisterVariable(&r_lightmap);
|
||||
Cvar_RegisterVariable(&r_fullbright);
|
||||
Cvar_RegisterVariable(&r_drawentities);
|
||||
Cvar_RegisterVariable(&r_drawviewmodel);
|
||||
Cvar_RegisterVariable(&r_shadows);
|
||||
Cvar_RegisterVariable(&r_wateralpha);
|
||||
Cvar_SetCallback(&r_wateralpha, R_SetWateralpha_f);
|
||||
Cvar_RegisterVariable(&r_dynamic);
|
||||
Cvar_RegisterVariable(&r_novis);
|
||||
Cvar_SetCallback(&r_novis, R_VisChanged);
|
||||
Cvar_RegisterVariable(&r_speeds);
|
||||
Cvar_RegisterVariable(&r_pos);
|
||||
|
||||
Cvar_RegisterVariable (&gl_finish);
|
||||
Cvar_RegisterVariable (&gl_clear);
|
||||
Cvar_RegisterVariable (&gl_cull);
|
||||
Cvar_RegisterVariable (&gl_smoothmodels);
|
||||
Cvar_RegisterVariable (&gl_affinemodels);
|
||||
Cvar_RegisterVariable (&gl_polyblend);
|
||||
Cvar_RegisterVariable (&gl_flashblend);
|
||||
Cvar_RegisterVariable (&gl_playermip);
|
||||
Cvar_RegisterVariable (&gl_nocolors);
|
||||
Cvar_RegisterVariable(&gl_finish);
|
||||
Cvar_RegisterVariable(&gl_clear);
|
||||
Cvar_RegisterVariable(&gl_cull);
|
||||
Cvar_RegisterVariable(&gl_smoothmodels);
|
||||
Cvar_RegisterVariable(&gl_affinemodels);
|
||||
Cvar_RegisterVariable(&gl_polyblend);
|
||||
Cvar_RegisterVariable(&gl_flashblend);
|
||||
Cvar_RegisterVariable(&gl_playermip);
|
||||
Cvar_RegisterVariable(&gl_nocolors);
|
||||
|
||||
//johnfitz -- new cvars
|
||||
Cvar_RegisterVariable (&r_stereo);
|
||||
Cvar_RegisterVariable (&r_stereodepth);
|
||||
Cvar_RegisterVariable (&r_clearcolor);
|
||||
Cvar_SetCallback (&r_clearcolor, R_SetClearColor_f);
|
||||
Cvar_RegisterVariable (&r_waterquality);
|
||||
Cvar_RegisterVariable (&r_oldwater);
|
||||
Cvar_RegisterVariable (&r_waterwarp);
|
||||
Cvar_RegisterVariable (&r_drawflat);
|
||||
Cvar_RegisterVariable (&r_flatlightstyles);
|
||||
Cvar_RegisterVariable (&r_oldskyleaf);
|
||||
Cvar_SetCallback (&r_oldskyleaf, R_VisChanged);
|
||||
Cvar_RegisterVariable (&r_drawworld);
|
||||
Cvar_RegisterVariable (&r_showtris);
|
||||
Cvar_RegisterVariable (&r_showbboxes);
|
||||
Cvar_RegisterVariable (&gl_farclip);
|
||||
Cvar_RegisterVariable (&gl_fullbrights);
|
||||
Cvar_RegisterVariable (&gl_overbright);
|
||||
Cvar_SetCallback (&gl_fullbrights, GL_Fullbrights_f);
|
||||
Cvar_SetCallback (&gl_overbright, GL_Overbright_f);
|
||||
Cvar_RegisterVariable (&gl_overbright_models);
|
||||
Cvar_RegisterVariable (&r_lerpmodels);
|
||||
Cvar_RegisterVariable (&r_lerpmove);
|
||||
Cvar_RegisterVariable (&r_nolerp_list);
|
||||
Cvar_SetCallback (&r_nolerp_list, R_Model_ExtraFlags_List_f);
|
||||
Cvar_RegisterVariable (&r_noshadow_list);
|
||||
Cvar_SetCallback (&r_noshadow_list, R_Model_ExtraFlags_List_f);
|
||||
Cvar_RegisterVariable(&r_stereo);
|
||||
Cvar_RegisterVariable(&r_stereodepth);
|
||||
Cvar_RegisterVariable(&r_clearcolor);
|
||||
Cvar_SetCallback(&r_clearcolor, R_SetClearColor_f);
|
||||
Cvar_RegisterVariable(&r_waterquality);
|
||||
Cvar_RegisterVariable(&r_oldwater);
|
||||
Cvar_RegisterVariable(&r_waterwarp);
|
||||
Cvar_RegisterVariable(&r_drawflat);
|
||||
Cvar_RegisterVariable(&r_flatlightstyles);
|
||||
Cvar_RegisterVariable(&r_oldskyleaf);
|
||||
Cvar_SetCallback(&r_oldskyleaf, R_VisChanged);
|
||||
Cvar_RegisterVariable(&r_drawworld);
|
||||
Cvar_RegisterVariable(&r_showtris);
|
||||
Cvar_RegisterVariable(&r_showbboxes);
|
||||
Cvar_RegisterVariable(&gl_farclip);
|
||||
Cvar_RegisterVariable(&gl_fullbrights);
|
||||
Cvar_RegisterVariable(&gl_overbright);
|
||||
Cvar_SetCallback(&gl_fullbrights, GL_Fullbrights_f);
|
||||
Cvar_SetCallback(&gl_overbright, GL_Overbright_f);
|
||||
Cvar_RegisterVariable(&gl_overbright_models);
|
||||
Cvar_RegisterVariable(&r_lerpmodels);
|
||||
Cvar_RegisterVariable(&r_lerpmove);
|
||||
Cvar_RegisterVariable(&r_nolerp_list);
|
||||
Cvar_SetCallback(&r_nolerp_list, R_Model_ExtraFlags_List_f);
|
||||
Cvar_RegisterVariable(&r_noshadow_list);
|
||||
Cvar_SetCallback(&r_noshadow_list, R_Model_ExtraFlags_List_f);
|
||||
//johnfitz
|
||||
|
||||
Cvar_RegisterVariable (&gl_zfix); // QuakeSpasm z-fighting fix
|
||||
Cvar_RegisterVariable (&r_lavaalpha);
|
||||
Cvar_RegisterVariable (&r_telealpha);
|
||||
Cvar_RegisterVariable (&r_slimealpha);
|
||||
Cvar_RegisterVariable (&r_scale);
|
||||
Cvar_SetCallback (&r_lavaalpha, R_SetLavaalpha_f);
|
||||
Cvar_SetCallback (&r_telealpha, R_SetTelealpha_f);
|
||||
Cvar_SetCallback (&r_slimealpha, R_SetSlimealpha_f);
|
||||
Cvar_RegisterVariable(&gl_zfix); // QuakeSpasm z-fighting fix
|
||||
Cvar_RegisterVariable(&r_lavaalpha);
|
||||
Cvar_RegisterVariable(&r_telealpha);
|
||||
Cvar_RegisterVariable(&r_slimealpha);
|
||||
Cvar_RegisterVariable(&r_scale);
|
||||
Cvar_SetCallback(&r_lavaalpha, R_SetLavaalpha_f);
|
||||
Cvar_SetCallback(&r_telealpha, R_SetTelealpha_f);
|
||||
Cvar_SetCallback(&r_slimealpha, R_SetSlimealpha_f);
|
||||
|
||||
R_InitParticles ();
|
||||
R_SetClearColor_f (&r_clearcolor); //johnfitz
|
||||
R_InitParticles();
|
||||
R_SetClearColor_f(&r_clearcolor); //johnfitz
|
||||
|
||||
Sky_Init (); //johnfitz
|
||||
Fog_Init (); //johnfitz
|
||||
Sky_Init(); //johnfitz
|
||||
Fog_Init(); //johnfitz
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -258,17 +258,17 @@ void R_Init (void)
|
|||
R_TranslatePlayerSkin -- johnfitz -- rewritten. also, only handles new colors, not new skins
|
||||
===============
|
||||
*/
|
||||
void R_TranslatePlayerSkin (int32_t playernum)
|
||||
void R_TranslatePlayerSkin(int32_t playernum)
|
||||
{
|
||||
int32_t top, bottom;
|
||||
|
||||
top = (cl.scores[playernum].colors & 0xf0)>>4;
|
||||
bottom = cl.scores[playernum].colors &15;
|
||||
top = (cl.scores[playernum].colors & 0xf0) >> 4;
|
||||
bottom = cl.scores[playernum].colors & 15;
|
||||
|
||||
//FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors.
|
||||
if (!gl_nocolors.value)
|
||||
if (playertextures[playernum])
|
||||
TexMgr_ReloadImage (playertextures[playernum], top, bottom);
|
||||
if(!gl_nocolors.value)
|
||||
if(playertextures[playernum])
|
||||
TexMgr_ReloadImage(playertextures[playernum], top, bottom);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -278,7 +278,7 @@ the skin or model actually changes, instead of just new colors
|
|||
added bug fix from bengt jardup
|
||||
===============
|
||||
*/
|
||||
void R_TranslateNewPlayerSkin (int32_t playernum)
|
||||
void R_TranslateNewPlayerSkin(int32_t playernum)
|
||||
{
|
||||
char name[64];
|
||||
byte *pixels;
|
||||
|
@ -286,17 +286,17 @@ void R_TranslateNewPlayerSkin (int32_t playernum)
|
|||
int32_t skinnum;
|
||||
|
||||
//get correct texture pixels
|
||||
currententity = &cl_entities[1+playernum];
|
||||
currententity = &cl_entities[1 + playernum];
|
||||
|
||||
if (!currententity->model || currententity->model->type != mod_alias)
|
||||
if(!currententity->model || currententity->model->type != mod_alias)
|
||||
return;
|
||||
|
||||
paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
|
||||
paliashdr = (aliashdr_t *)Mod_Extradata(currententity->model);
|
||||
|
||||
skinnum = currententity->skinnum;
|
||||
|
||||
//TODO: move these tests to the place where skinnum gets received from the server
|
||||
if (skinnum < 0 || skinnum >= paliashdr->numskins)
|
||||
if(skinnum < 0 || skinnum >= paliashdr->numskins)
|
||||
{
|
||||
Con_DPrintf("(%" PRIi32 "): Invalid player skin #%" PRIi32 "\n", playernum, skinnum);
|
||||
skinnum = 0;
|
||||
|
@ -306,11 +306,11 @@ void R_TranslateNewPlayerSkin (int32_t playernum)
|
|||
|
||||
//upload new image
|
||||
q_snprintf(name, sizeof(name), "player_%" PRIi32 "", playernum);
|
||||
playertextures[playernum] = TexMgr_LoadImage (currententity->model, name, paliashdr->skinwidth, paliashdr->skinheight,
|
||||
playertextures[playernum] = TexMgr_LoadImage(currententity->model, name, paliashdr->skinwidth, paliashdr->skinheight,
|
||||
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file, paliashdr->gltextures[skinnum][0]->source_offset, TEXPREF_PAD | TEXPREF_OVERWRITE);
|
||||
|
||||
//now recolor it
|
||||
R_TranslatePlayerSkin (playernum);
|
||||
R_TranslatePlayerSkin(playernum);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -318,12 +318,12 @@ void R_TranslateNewPlayerSkin (int32_t playernum)
|
|||
R_NewGame -- johnfitz -- handle a game switch
|
||||
===============
|
||||
*/
|
||||
void R_NewGame (void)
|
||||
void R_NewGame(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
//clear playertexture pointers (the textures themselves were freed by texmgr_newgame)
|
||||
for (i=0; i<MAX_SCOREBOARD; i++)
|
||||
for(i = 0; i < MAX_SCOREBOARD; i++)
|
||||
playertextures[i] = NULL;
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ R_ParseWorldspawn
|
|||
called at map load
|
||||
=============
|
||||
*/
|
||||
static void R_ParseWorldspawn (void)
|
||||
static void R_ParseWorldspawn(void)
|
||||
{
|
||||
char key[128], value[4096];
|
||||
const char *data;
|
||||
|
@ -345,38 +345,38 @@ static void R_ParseWorldspawn (void)
|
|||
map_slimealpha = r_slimealpha.value;
|
||||
|
||||
data = COM_Parse(cl.worldmodel->entities);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
if (com_token[0] != '{')
|
||||
if(com_token[0] != '{')
|
||||
return; // error
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
if (com_token[0] == '}')
|
||||
if(com_token[0] == '}')
|
||||
break; // end of worldspawn
|
||||
if (com_token[0] == '_')
|
||||
if(com_token[0] == '_')
|
||||
strcpy(key, com_token + 1);
|
||||
else
|
||||
strcpy(key, com_token);
|
||||
while (key[strlen(key)-1] == ' ') // remove trailing spaces
|
||||
key[strlen(key)-1] = 0;
|
||||
while(key[strlen(key) - 1] == ' ') // remove trailing spaces
|
||||
key[strlen(key) - 1] = 0;
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
if(!data)
|
||||
return; // error
|
||||
strcpy(value, com_token);
|
||||
|
||||
if (!strcmp("wateralpha", key))
|
||||
if(!strcmp("wateralpha", key))
|
||||
map_wateralpha = atof(value);
|
||||
|
||||
if (!strcmp("lavaalpha", key))
|
||||
if(!strcmp("lavaalpha", key))
|
||||
map_lavaalpha = atof(value);
|
||||
|
||||
if (!strcmp("telealpha", key))
|
||||
if(!strcmp("telealpha", key))
|
||||
map_telealpha = atof(value);
|
||||
|
||||
if (!strcmp("slimealpha", key))
|
||||
if(!strcmp("slimealpha", key))
|
||||
map_slimealpha = atof(value);
|
||||
}
|
||||
}
|
||||
|
@ -387,31 +387,31 @@ static void R_ParseWorldspawn (void)
|
|||
R_NewMap
|
||||
===============
|
||||
*/
|
||||
void R_NewMap (void)
|
||||
void R_NewMap(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
for(i = 0 ; i < 256 ; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
// FIXME: is this one short?
|
||||
for (i=0 ; i<cl.worldmodel->numleafs ; i++)
|
||||
for(i = 0 ; i < cl.worldmodel->numleafs ; i++)
|
||||
cl.worldmodel->leafs[i].efrags = NULL;
|
||||
|
||||
r_viewleaf = NULL;
|
||||
R_ClearParticles ();
|
||||
R_ClearParticles();
|
||||
|
||||
GL_BuildLightmaps ();
|
||||
GL_BuildBModelVertexBuffer ();
|
||||
GL_BuildLightmaps();
|
||||
GL_BuildBModelVertexBuffer();
|
||||
//ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel
|
||||
|
||||
r_framecount = 0; //johnfitz -- paranoid?
|
||||
r_visframecount = 0; //johnfitz -- paranoid?
|
||||
|
||||
Sky_NewMap (); //johnfitz -- skybox in worldspawn
|
||||
Fog_NewMap (); //johnfitz -- global fog in worldspawn
|
||||
R_ParseWorldspawn (); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn
|
||||
Sky_NewMap(); //johnfitz -- skybox in worldspawn
|
||||
Fog_NewMap(); //johnfitz -- global fog in worldspawn
|
||||
R_ParseWorldspawn(); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn
|
||||
|
||||
load_subdivide_size = gl_subdivide_size.value; //johnfitz -- is this the right place to set this?
|
||||
}
|
||||
|
@ -423,71 +423,71 @@ R_TimeRefresh_f
|
|||
For program optimization
|
||||
====================
|
||||
*/
|
||||
void R_TimeRefresh_f (void)
|
||||
void R_TimeRefresh_f(void)
|
||||
{
|
||||
int32_t i;
|
||||
float start, stop, time;
|
||||
|
||||
if (cls.state != ca_connected)
|
||||
if(cls.state != ca_connected)
|
||||
{
|
||||
Con_Printf("Not connected to a server\n");
|
||||
return;
|
||||
}
|
||||
|
||||
start = Sys_DoubleTime ();
|
||||
for (i = 0; i < 128; i++)
|
||||
start = Sys_DoubleTime();
|
||||
for(i = 0; i < 128; i++)
|
||||
{
|
||||
GL_BeginRendering(&glx, &gly, &glwidth, &glheight);
|
||||
r_refdef.viewangles[1] = i/128.0*360.0;
|
||||
R_RenderView ();
|
||||
GL_EndRendering ();
|
||||
r_refdef.viewangles[1] = i / 128.0 * 360.0;
|
||||
R_RenderView();
|
||||
GL_EndRendering();
|
||||
}
|
||||
|
||||
glFinish ();
|
||||
stop = Sys_DoubleTime ();
|
||||
time = stop-start;
|
||||
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
||||
glFinish();
|
||||
stop = Sys_DoubleTime();
|
||||
time = stop - start;
|
||||
Con_Printf("%f seconds (%f fps)\n", time, 128 / time);
|
||||
}
|
||||
|
||||
void D_FlushCaches (void)
|
||||
void D_FlushCaches(void)
|
||||
{
|
||||
}
|
||||
|
||||
static GLuint gl_programs[16];
|
||||
static int32_t gl_num_programs;
|
||||
|
||||
static bool GL_CheckShader (GLuint shader)
|
||||
static bool GL_CheckShader(GLuint shader)
|
||||
{
|
||||
GLint status;
|
||||
GL_GetShaderivFunc (shader, GL_COMPILE_STATUS, &status);
|
||||
GL_GetShaderivFunc(shader, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (status != GL_TRUE)
|
||||
if(status != GL_TRUE)
|
||||
{
|
||||
char infolog[1024];
|
||||
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog);
|
||||
GL_GetShaderInfoLogFunc(shader, sizeof(infolog), NULL, infolog);
|
||||
|
||||
Con_Warning ("GLSL program failed to compile: %s", infolog);
|
||||
Con_Warning("GLSL program failed to compile: %s", infolog);
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool GL_CheckProgram (GLuint program)
|
||||
static bool GL_CheckProgram(GLuint program)
|
||||
{
|
||||
GLint status;
|
||||
GL_GetProgramivFunc (program, GL_LINK_STATUS, &status);
|
||||
GL_GetProgramivFunc(program, GL_LINK_STATUS, &status);
|
||||
|
||||
if (status != GL_TRUE)
|
||||
if(status != GL_TRUE)
|
||||
{
|
||||
char infolog[1024];
|
||||
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetProgramInfoLogFunc (program, sizeof(infolog), NULL, infolog);
|
||||
GL_GetProgramInfoLogFunc(program, sizeof(infolog), NULL, infolog);
|
||||
|
||||
Con_Warning ("GLSL program failed to link: %s", infolog);
|
||||
Con_Warning("GLSL program failed to link: %s", infolog);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -499,15 +499,15 @@ static bool GL_CheckProgram (GLuint program)
|
|||
GL_GetUniformLocation
|
||||
=============
|
||||
*/
|
||||
GLint GL_GetUniformLocation (GLuint *programPtr, const char *name)
|
||||
GLint GL_GetUniformLocation(GLuint *programPtr, const char *name)
|
||||
{
|
||||
GLint location;
|
||||
|
||||
if (!programPtr)
|
||||
if(!programPtr)
|
||||
return -1;
|
||||
|
||||
location = GL_GetUniformLocationFunc(*programPtr, name);
|
||||
if (location == -1)
|
||||
if(location == -1)
|
||||
{
|
||||
Con_Warning("GL_GetUniformLocationFunc %s failed\n", name);
|
||||
*programPtr = 0;
|
||||
|
@ -522,55 +522,55 @@ GL_CreateProgram
|
|||
Compiles and returns GLSL program.
|
||||
====================
|
||||
*/
|
||||
GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int32_t numbindings, const glsl_attrib_binding_t *bindings)
|
||||
GLuint GL_CreateProgram(const GLchar *vertSource, const GLchar *fragSource, int32_t numbindings, const glsl_attrib_binding_t *bindings)
|
||||
{
|
||||
int32_t i;
|
||||
GLuint program, vertShader, fragShader;
|
||||
|
||||
if (!gl_glsl_able)
|
||||
if(!gl_glsl_able)
|
||||
return 0;
|
||||
|
||||
vertShader = GL_CreateShaderFunc (GL_VERTEX_SHADER);
|
||||
GL_ShaderSourceFunc (vertShader, 1, &vertSource, NULL);
|
||||
GL_CompileShaderFunc (vertShader);
|
||||
if (!GL_CheckShader (vertShader))
|
||||
vertShader = GL_CreateShaderFunc(GL_VERTEX_SHADER);
|
||||
GL_ShaderSourceFunc(vertShader, 1, &vertSource, NULL);
|
||||
GL_CompileShaderFunc(vertShader);
|
||||
if(!GL_CheckShader(vertShader))
|
||||
{
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fragShader = GL_CreateShaderFunc (GL_FRAGMENT_SHADER);
|
||||
GL_ShaderSourceFunc (fragShader, 1, &fragSource, NULL);
|
||||
GL_CompileShaderFunc (fragShader);
|
||||
if (!GL_CheckShader (fragShader))
|
||||
fragShader = GL_CreateShaderFunc(GL_FRAGMENT_SHADER);
|
||||
GL_ShaderSourceFunc(fragShader, 1, &fragSource, NULL);
|
||||
GL_CompileShaderFunc(fragShader);
|
||||
if(!GL_CheckShader(fragShader))
|
||||
{
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
GL_DeleteShaderFunc (fragShader);
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
GL_DeleteShaderFunc(fragShader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
program = GL_CreateProgramFunc ();
|
||||
GL_AttachShaderFunc (program, vertShader);
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
GL_AttachShaderFunc (program, fragShader);
|
||||
GL_DeleteShaderFunc (fragShader);
|
||||
program = GL_CreateProgramFunc();
|
||||
GL_AttachShaderFunc(program, vertShader);
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
GL_AttachShaderFunc(program, fragShader);
|
||||
GL_DeleteShaderFunc(fragShader);
|
||||
|
||||
for (i = 0; i < numbindings; i++)
|
||||
for(i = 0; i < numbindings; i++)
|
||||
{
|
||||
GL_BindAttribLocationFunc (program, bindings[i].attrib, bindings[i].name);
|
||||
GL_BindAttribLocationFunc(program, bindings[i].attrib, bindings[i].name);
|
||||
}
|
||||
|
||||
GL_LinkProgramFunc (program);
|
||||
GL_LinkProgramFunc(program);
|
||||
|
||||
if (!GL_CheckProgram (program))
|
||||
if(!GL_CheckProgram(program))
|
||||
{
|
||||
GL_DeleteProgramFunc (program);
|
||||
GL_DeleteProgramFunc(program);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gl_num_programs == (sizeof(gl_programs)/sizeof(GLuint)))
|
||||
Host_Error ("gl_programs overflow");
|
||||
if(gl_num_programs == (sizeof(gl_programs) / sizeof(GLuint)))
|
||||
Host_Error("gl_programs overflow");
|
||||
|
||||
gl_programs[gl_num_programs] = program;
|
||||
gl_num_programs++;
|
||||
|
@ -586,16 +586,16 @@ R_DeleteShaders
|
|||
Deletes any GLSL programs that have been created.
|
||||
====================
|
||||
*/
|
||||
void R_DeleteShaders (void)
|
||||
void R_DeleteShaders(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (!gl_glsl_able)
|
||||
if(!gl_glsl_able)
|
||||
return;
|
||||
|
||||
for (i = 0; i < gl_num_programs; i++)
|
||||
for(i = 0; i < gl_num_programs; i++)
|
||||
{
|
||||
GL_DeleteProgramFunc (gl_programs[i]);
|
||||
GL_DeleteProgramFunc(gl_programs[i]);
|
||||
gl_programs[i] = 0;
|
||||
}
|
||||
gl_num_programs = 0;
|
||||
|
@ -609,14 +609,14 @@ GL_BindBuffer
|
|||
glBindBuffer wrapper
|
||||
====================
|
||||
*/
|
||||
void GL_BindBuffer (GLenum target, GLuint buffer)
|
||||
void GL_BindBuffer(GLenum target, GLuint buffer)
|
||||
{
|
||||
GLuint *cache;
|
||||
|
||||
if (!gl_vbo_able)
|
||||
if(!gl_vbo_able)
|
||||
return;
|
||||
|
||||
switch (target)
|
||||
switch(target)
|
||||
{
|
||||
case GL_ARRAY_BUFFER:
|
||||
cache = ¤t_array_buffer;
|
||||
|
@ -629,10 +629,10 @@ void GL_BindBuffer (GLenum target, GLuint buffer)
|
|||
return;
|
||||
}
|
||||
|
||||
if (*cache != buffer)
|
||||
if(*cache != buffer)
|
||||
{
|
||||
*cache = buffer;
|
||||
GL_BindBufferFunc (target, *cache);
|
||||
GL_BindBufferFunc(target, *cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,13 +644,13 @@ This must be called if you do anything that could make the cached bindings
|
|||
invalid (e.g. manually binding, destroying the context).
|
||||
====================
|
||||
*/
|
||||
void GL_ClearBufferBindings ()
|
||||
void GL_ClearBufferBindings()
|
||||
{
|
||||
if (!gl_vbo_able)
|
||||
if(!gl_vbo_able)
|
||||
return;
|
||||
|
||||
current_array_buffer = 0;
|
||||
current_element_array_buffer = 0;
|
||||
GL_BindBufferFunc (GL_ARRAY_BUFFER, 0);
|
||||
GL_BindBufferFunc (GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL_BindBufferFunc(GL_ARRAY_BUFFER, 0);
|
||||
GL_BindBufferFunc(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
596
source/gl_sky.c
596
source/gl_sky.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,8 @@ enum srcformat {SRC_INDEXED, SRC_LIGHTMAP, SRC_RGBA};
|
|||
|
||||
typedef uintptr_t src_offset_t;
|
||||
|
||||
typedef struct gltexture_s {
|
||||
typedef struct gltexture_s
|
||||
{
|
||||
//managed by texture manager
|
||||
GLuint texnum;
|
||||
struct gltexture_s *next;
|
||||
|
@ -77,34 +78,34 @@ extern uint32_t d_8to24table_pants[256];
|
|||
|
||||
// TEXTURE MANAGER
|
||||
|
||||
float TexMgr_FrameUsage (void);
|
||||
gltexture_t *TexMgr_FindTexture (qmodel_t *owner, const char *name);
|
||||
gltexture_t *TexMgr_NewTexture (void);
|
||||
void TexMgr_FreeTexture (gltexture_t *kill);
|
||||
void TexMgr_FreeTextures (uint32_t flags, uint32_t mask);
|
||||
void TexMgr_FreeTexturesForOwner (qmodel_t *owner);
|
||||
void TexMgr_NewGame (void);
|
||||
void TexMgr_Init (void);
|
||||
void TexMgr_DeleteTextureObjects (void);
|
||||
float TexMgr_FrameUsage(void);
|
||||
gltexture_t *TexMgr_FindTexture(qmodel_t *owner, const char *name);
|
||||
gltexture_t *TexMgr_NewTexture(void);
|
||||
void TexMgr_FreeTexture(gltexture_t *kill);
|
||||
void TexMgr_FreeTextures(uint32_t flags, uint32_t mask);
|
||||
void TexMgr_FreeTexturesForOwner(qmodel_t *owner);
|
||||
void TexMgr_NewGame(void);
|
||||
void TexMgr_Init(void);
|
||||
void TexMgr_DeleteTextureObjects(void);
|
||||
|
||||
// IMAGE LOADING
|
||||
gltexture_t *TexMgr_LoadImage (qmodel_t *owner, const char *name, int32_t width, int32_t height, enum srcformat format,
|
||||
gltexture_t *TexMgr_LoadImage(qmodel_t *owner, const char *name, int32_t width, int32_t height, enum srcformat format,
|
||||
byte *data, const char *source_file, src_offset_t source_offset, unsigned flags);
|
||||
void TexMgr_ReloadImage (gltexture_t *glt, int32_t shirt, int32_t pants);
|
||||
void TexMgr_ReloadImages (void);
|
||||
void TexMgr_ReloadNobrightImages (void);
|
||||
void TexMgr_ReloadImage(gltexture_t *glt, int32_t shirt, int32_t pants);
|
||||
void TexMgr_ReloadImages(void);
|
||||
void TexMgr_ReloadNobrightImages(void);
|
||||
|
||||
int32_t TexMgr_Pad(int32_t s);
|
||||
int32_t TexMgr_SafeTextureSize (int32_t s);
|
||||
int32_t TexMgr_PadConditional (int32_t s);
|
||||
int32_t TexMgr_SafeTextureSize(int32_t s);
|
||||
int32_t TexMgr_PadConditional(int32_t s);
|
||||
|
||||
// TEXTURE BINDING & TEXTURE UNIT SWITCHING
|
||||
|
||||
void GL_SelectTexture (GLenum target);
|
||||
void GL_DisableMultitexture (void); //selects texture unit 0
|
||||
void GL_EnableMultitexture (void); //selects texture unit 1
|
||||
void GL_Bind (gltexture_t *texture);
|
||||
void GL_ClearBindings (void);
|
||||
void GL_SelectTexture(GLenum target);
|
||||
void GL_DisableMultitexture(void); //selects texture unit 0
|
||||
void GL_EnableMultitexture(void); //selects texture unit 1
|
||||
void GL_Bind(gltexture_t *texture);
|
||||
void GL_ClearBindings(void);
|
||||
|
||||
#endif /* _GL_TEXMAN_H */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
136
source/gl_warp.c
136
source/gl_warp.c
|
@ -51,7 +51,7 @@ msurface_t *warpface;
|
|||
|
||||
cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", CVAR_ARCHIVE};
|
||||
|
||||
void BoundPoly (int32_t numverts, float *verts, vec3_t mins, vec3_t maxs)
|
||||
void BoundPoly(int32_t numverts, float *verts, vec3_t mins, vec3_t maxs)
|
||||
{
|
||||
int32_t i, j;
|
||||
float *v;
|
||||
|
@ -59,17 +59,17 @@ void BoundPoly (int32_t numverts, float *verts, vec3_t mins, vec3_t maxs)
|
|||
mins[0] = mins[1] = mins[2] = 999999999;
|
||||
maxs[0] = maxs[1] = maxs[2] = -999999999;
|
||||
v = verts;
|
||||
for (i=0 ; i<numverts ; i++)
|
||||
for (j=0 ; j<3 ; j++, v++)
|
||||
for(i = 0 ; i < numverts ; i++)
|
||||
for(j = 0 ; j < 3 ; j++, v++)
|
||||
{
|
||||
if (*v < mins[j])
|
||||
if(*v < mins[j])
|
||||
mins[j] = *v;
|
||||
if (*v > maxs[j])
|
||||
if(*v > maxs[j])
|
||||
maxs[j] = *v;
|
||||
}
|
||||
}
|
||||
|
||||
void SubdividePolygon (int32_t numverts, float *verts)
|
||||
void SubdividePolygon(int32_t numverts, float *verts)
|
||||
{
|
||||
int32_t i, j, k;
|
||||
vec3_t mins, maxs;
|
||||
|
@ -82,71 +82,71 @@ void SubdividePolygon (int32_t numverts, float *verts)
|
|||
glpoly_t *poly;
|
||||
float s, t;
|
||||
|
||||
if (numverts > 60)
|
||||
Sys_Error ("numverts = %" PRIi32 "", numverts);
|
||||
if(numverts > 60)
|
||||
Sys_Error("numverts = %" PRIi32 "", numverts);
|
||||
|
||||
BoundPoly (numverts, verts, mins, maxs);
|
||||
BoundPoly(numverts, verts, mins, maxs);
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
m = (mins[i] + maxs[i]) * 0.5;
|
||||
m = gl_subdivide_size.value * floor (m/gl_subdivide_size.value + 0.5);
|
||||
if (maxs[i] - m < 8)
|
||||
m = gl_subdivide_size.value * floor(m / gl_subdivide_size.value + 0.5);
|
||||
if(maxs[i] - m < 8)
|
||||
continue;
|
||||
if (m - mins[i] < 8)
|
||||
if(m - mins[i] < 8)
|
||||
continue;
|
||||
|
||||
// cut it
|
||||
v = verts + i;
|
||||
for (j=0 ; j<numverts ; j++, v+= 3)
|
||||
for(j = 0 ; j < numverts ; j++, v += 3)
|
||||
dist[j] = *v - m;
|
||||
|
||||
// wrap cases
|
||||
dist[j] = dist[0];
|
||||
v-=i;
|
||||
VectorCopy (verts, v);
|
||||
v -= i;
|
||||
VectorCopy(verts, v);
|
||||
|
||||
f = b = 0;
|
||||
v = verts;
|
||||
for (j=0 ; j<numverts ; j++, v+= 3)
|
||||
for(j = 0 ; j < numverts ; j++, v += 3)
|
||||
{
|
||||
if (dist[j] >= 0)
|
||||
if(dist[j] >= 0)
|
||||
{
|
||||
VectorCopy (v, front[f]);
|
||||
VectorCopy(v, front[f]);
|
||||
f++;
|
||||
}
|
||||
if (dist[j] <= 0)
|
||||
if(dist[j] <= 0)
|
||||
{
|
||||
VectorCopy (v, back[b]);
|
||||
VectorCopy(v, back[b]);
|
||||
b++;
|
||||
}
|
||||
if (dist[j] == 0 || dist[j+1] == 0)
|
||||
if(dist[j] == 0 || dist[j + 1] == 0)
|
||||
continue;
|
||||
if ( (dist[j] > 0) != (dist[j+1] > 0) )
|
||||
if((dist[j] > 0) != (dist[j + 1] > 0))
|
||||
{
|
||||
// clip point
|
||||
frac = dist[j] / (dist[j] - dist[j+1]);
|
||||
for (k=0 ; k<3 ; k++)
|
||||
front[f][k] = back[b][k] = v[k] + frac*(v[3+k] - v[k]);
|
||||
frac = dist[j] / (dist[j] - dist[j + 1]);
|
||||
for(k = 0 ; k < 3 ; k++)
|
||||
front[f][k] = back[b][k] = v[k] + frac * (v[3 + k] - v[k]);
|
||||
f++;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
SubdividePolygon (f, front[0]);
|
||||
SubdividePolygon (b, back[0]);
|
||||
SubdividePolygon(f, front[0]);
|
||||
SubdividePolygon(b, back[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
poly = (glpoly_t *) Hunk_Alloc (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float));
|
||||
poly = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float));
|
||||
poly->next = warpface->polys->next;
|
||||
warpface->polys->next = poly;
|
||||
poly->numverts = numverts;
|
||||
for (i=0 ; i<numverts ; i++, verts+= 3)
|
||||
for(i = 0 ; i < numverts ; i++, verts += 3)
|
||||
{
|
||||
VectorCopy (verts, poly->verts[i]);
|
||||
s = DotProduct (verts, warpface->texinfo->vecs[0]);
|
||||
t = DotProduct (verts, warpface->texinfo->vecs[1]);
|
||||
VectorCopy(verts, poly->verts[i]);
|
||||
s = DotProduct(verts, warpface->texinfo->vecs[0]);
|
||||
t = DotProduct(verts, warpface->texinfo->vecs[1]);
|
||||
poly->verts[i][3] = s;
|
||||
poly->verts[i][4] = t;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ void SubdividePolygon (int32_t numverts, float *verts)
|
|||
GL_SubdivideSurface
|
||||
================
|
||||
*/
|
||||
void GL_SubdivideSurface (msurface_t *fa)
|
||||
void GL_SubdivideSurface(msurface_t *fa)
|
||||
{
|
||||
vec3_t verts[64];
|
||||
int32_t i;
|
||||
|
@ -166,10 +166,10 @@ void GL_SubdivideSurface (msurface_t *fa)
|
|||
|
||||
//the first poly in the chain is the undivided poly for newwater rendering.
|
||||
//grab the verts from that.
|
||||
for (i=0; i<fa->polys->numverts; i++)
|
||||
VectorCopy (fa->polys->verts[i], verts[i]);
|
||||
for(i = 0; i < fa->polys->numverts; i++)
|
||||
VectorCopy(fa->polys->verts[i], verts[i]);
|
||||
|
||||
SubdividePolygon (fa->polys->numverts, verts[0]);
|
||||
SubdividePolygon(fa->polys->numverts, verts[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -177,32 +177,32 @@ void GL_SubdivideSurface (msurface_t *fa)
|
|||
DrawWaterPoly -- johnfitz
|
||||
================
|
||||
*/
|
||||
void DrawWaterPoly (glpoly_t *p)
|
||||
void DrawWaterPoly(glpoly_t *p)
|
||||
{
|
||||
float *v;
|
||||
int32_t i;
|
||||
|
||||
if (load_subdivide_size > 48)
|
||||
if(load_subdivide_size > 48)
|
||||
{
|
||||
glBegin (GL_POLYGON);
|
||||
glBegin(GL_POLYGON);
|
||||
v = p->verts[0];
|
||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||
for(i = 0 ; i < p->numverts ; i++, v += VERTEXSIZE)
|
||||
{
|
||||
glTexCoord2f (WARPCALC2(v[3],v[4]), WARPCALC2(v[4],v[3]));
|
||||
glVertex3fv (v);
|
||||
glTexCoord2f(WARPCALC2(v[3], v[4]), WARPCALC2(v[4], v[3]));
|
||||
glVertex3fv(v);
|
||||
}
|
||||
glEnd ();
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBegin (GL_POLYGON);
|
||||
glBegin(GL_POLYGON);
|
||||
v = p->verts[0];
|
||||
for (i=0 ; i<p->numverts ; i++, v+= VERTEXSIZE)
|
||||
for(i = 0 ; i < p->numverts ; i++, v += VERTEXSIZE)
|
||||
{
|
||||
glTexCoord2f (WARPCALC(v[3],v[4]), WARPCALC(v[4],v[3]));
|
||||
glVertex3fv (v);
|
||||
glTexCoord2f(WARPCALC(v[3], v[4]), WARPCALC(v[4], v[3]));
|
||||
glVertex3fv(v);
|
||||
}
|
||||
glEnd ();
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,45 +217,45 @@ void DrawWaterPoly (glpoly_t *p)
|
|||
R_UpdateWarpTextures -- johnfitz -- each frame, update warping textures
|
||||
=============
|
||||
*/
|
||||
void R_UpdateWarpTextures (void)
|
||||
void R_UpdateWarpTextures(void)
|
||||
{
|
||||
texture_t *tx;
|
||||
int32_t i;
|
||||
float x, y, x2, warptess;
|
||||
|
||||
if (r_oldwater.value || cl.paused || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
|
||||
if(r_oldwater.value || cl.paused || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
|
||||
return;
|
||||
|
||||
warptess = 128.0/CLAMP (3.0, floor(r_waterquality.value), 64.0);
|
||||
warptess = 128.0 / CLAMP(3.0, floor(r_waterquality.value), 64.0);
|
||||
|
||||
for (i=0; i<cl.worldmodel->numtextures; i++)
|
||||
for(i = 0; i < cl.worldmodel->numtextures; i++)
|
||||
{
|
||||
if (!(tx = cl.worldmodel->textures[i]))
|
||||
if(!(tx = cl.worldmodel->textures[i]))
|
||||
continue;
|
||||
|
||||
if (!tx->update_warp)
|
||||
if(!tx->update_warp)
|
||||
continue;
|
||||
|
||||
//render warp
|
||||
GL_SetCanvas (CANVAS_WARPIMAGE);
|
||||
GL_Bind (tx->gltexture);
|
||||
for (x=0.0; x<128.0; x=x2)
|
||||
GL_SetCanvas(CANVAS_WARPIMAGE);
|
||||
GL_Bind(tx->gltexture);
|
||||
for(x = 0.0; x < 128.0; x = x2)
|
||||
{
|
||||
x2 = x + warptess;
|
||||
glBegin (GL_TRIANGLE_STRIP);
|
||||
for (y=0.0; y<128.01; y+=warptess) // .01 for rounding errors
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for(y = 0.0; y < 128.01; y += warptess) // .01 for rounding errors
|
||||
{
|
||||
glTexCoord2f (WARPCALC(x,y), WARPCALC(y,x));
|
||||
glVertex2f (x,y);
|
||||
glTexCoord2f (WARPCALC(x2,y), WARPCALC(y,x2));
|
||||
glVertex2f (x2,y);
|
||||
glTexCoord2f(WARPCALC(x, y), WARPCALC(y, x));
|
||||
glVertex2f(x, y);
|
||||
glTexCoord2f(WARPCALC(x2, y), WARPCALC(y, x2));
|
||||
glVertex2f(x2, y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
//copy to texture
|
||||
GL_Bind (tx->warpimage);
|
||||
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, glx, gly+glheight-gl_warpimagesize, gl_warpimagesize, gl_warpimagesize);
|
||||
GL_Bind(tx->warpimage);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, glx, gly + glheight - gl_warpimagesize, gl_warpimagesize, gl_warpimagesize);
|
||||
|
||||
tx->update_warp = false;
|
||||
}
|
||||
|
@ -264,8 +264,8 @@ void R_UpdateWarpTextures (void)
|
|||
GL_SetCanvas(CANVAS_DEFAULT);
|
||||
|
||||
//if warp render went down into sbar territory, we need to be sure to refresh it next frame
|
||||
if (gl_warpimagesize + sb_lines > glheight)
|
||||
Sbar_Changed ();
|
||||
if(gl_warpimagesize + sb_lines > glheight)
|
||||
Sbar_Changed();
|
||||
|
||||
//if viewsize is less than 100, we need to redraw the frame around the viewport
|
||||
scr_tileclear_updates = 0;
|
||||
|
|
|
@ -17,40 +17,40 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
0, 0.19633, 0.392541, 0.588517,
|
||||
0.784137, 0.979285, 1.17384, 1.3677,
|
||||
1.56072, 1.75281, 1.94384, 2.1337,
|
||||
2.32228, 2.50945, 2.69512, 2.87916,
|
||||
3.06147, 3.24193, 3.42044, 3.59689,
|
||||
3.77117, 3.94319, 4.11282, 4.27998,
|
||||
4.44456, 4.60647, 4.76559, 4.92185,
|
||||
5.07515, 5.22538, 5.37247, 5.51632,
|
||||
5.65685, 5.79398, 5.92761, 6.05767,
|
||||
6.18408, 6.30677, 6.42566, 6.54068,
|
||||
6.65176, 6.75883, 6.86183, 6.9607,
|
||||
7.05537, 7.14579, 7.23191, 7.31368,
|
||||
7.39104, 7.46394, 7.53235, 7.59623,
|
||||
7.65552, 7.71021, 7.76025, 7.80562,
|
||||
7.84628, 7.88222, 7.91341, 7.93984,
|
||||
7.96148, 7.97832, 7.99036, 7.99759,
|
||||
8, 7.99759, 7.99036, 7.97832,
|
||||
7.96148, 7.93984, 7.91341, 7.88222,
|
||||
7.84628, 7.80562, 7.76025, 7.71021,
|
||||
7.65552, 7.59623, 7.53235, 7.46394,
|
||||
7.39104, 7.31368, 7.23191, 7.14579,
|
||||
7.05537, 6.9607, 6.86183, 6.75883,
|
||||
6.65176, 6.54068, 6.42566, 6.30677,
|
||||
6.18408, 6.05767, 5.92761, 5.79398,
|
||||
5.65685, 5.51632, 5.37247, 5.22538,
|
||||
5.07515, 4.92185, 4.76559, 4.60647,
|
||||
4.44456, 4.27998, 4.11282, 3.94319,
|
||||
3.77117, 3.59689, 3.42044, 3.24193,
|
||||
3.06147, 2.87916, 2.69512, 2.50945,
|
||||
2.32228, 2.1337, 1.94384, 1.75281,
|
||||
1.56072, 1.3677, 1.17384, 0.979285,
|
||||
0.784137, 0.588517, 0.392541, 0.19633,
|
||||
9.79717e-16, -0.19633, -0.392541, -0.588517,
|
||||
-0.784137, -0.979285, -1.17384, -1.3677,
|
||||
0, 0.19633, 0.392541, 0.588517,
|
||||
0.784137, 0.979285, 1.17384, 1.3677,
|
||||
1.56072, 1.75281, 1.94384, 2.1337,
|
||||
2.32228, 2.50945, 2.69512, 2.87916,
|
||||
3.06147, 3.24193, 3.42044, 3.59689,
|
||||
3.77117, 3.94319, 4.11282, 4.27998,
|
||||
4.44456, 4.60647, 4.76559, 4.92185,
|
||||
5.07515, 5.22538, 5.37247, 5.51632,
|
||||
5.65685, 5.79398, 5.92761, 6.05767,
|
||||
6.18408, 6.30677, 6.42566, 6.54068,
|
||||
6.65176, 6.75883, 6.86183, 6.9607,
|
||||
7.05537, 7.14579, 7.23191, 7.31368,
|
||||
7.39104, 7.46394, 7.53235, 7.59623,
|
||||
7.65552, 7.71021, 7.76025, 7.80562,
|
||||
7.84628, 7.88222, 7.91341, 7.93984,
|
||||
7.96148, 7.97832, 7.99036, 7.99759,
|
||||
8, 7.99759, 7.99036, 7.97832,
|
||||
7.96148, 7.93984, 7.91341, 7.88222,
|
||||
7.84628, 7.80562, 7.76025, 7.71021,
|
||||
7.65552, 7.59623, 7.53235, 7.46394,
|
||||
7.39104, 7.31368, 7.23191, 7.14579,
|
||||
7.05537, 6.9607, 6.86183, 6.75883,
|
||||
6.65176, 6.54068, 6.42566, 6.30677,
|
||||
6.18408, 6.05767, 5.92761, 5.79398,
|
||||
5.65685, 5.51632, 5.37247, 5.22538,
|
||||
5.07515, 4.92185, 4.76559, 4.60647,
|
||||
4.44456, 4.27998, 4.11282, 3.94319,
|
||||
3.77117, 3.59689, 3.42044, 3.24193,
|
||||
3.06147, 2.87916, 2.69512, 2.50945,
|
||||
2.32228, 2.1337, 1.94384, 1.75281,
|
||||
1.56072, 1.3677, 1.17384, 0.979285,
|
||||
0.784137, 0.588517, 0.392541, 0.19633,
|
||||
9.79717e-16, -0.19633, -0.392541, -0.588517,
|
||||
-0.784137, -0.979285, -1.17384, -1.3677,
|
||||
-1.56072, -1.75281, -1.94384, -2.1337,
|
||||
-2.32228, -2.50945, -2.69512, -2.87916,
|
||||
-3.06147, -3.24193, -3.42044, -3.59689,
|
||||
|
|
224
source/glquake.h
224
source/glquake.h
|
@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef __GLQUAKE_H
|
||||
#define __GLQUAKE_H
|
||||
|
||||
void GL_BeginRendering (int32_t *x, int32_t *y, int32_t *width, int32_t *height);
|
||||
void GL_EndRendering (void);
|
||||
void GL_Set2D (void);
|
||||
void GL_BeginRendering(int32_t *x, int32_t *y, int32_t *width, int32_t *height);
|
||||
void GL_EndRendering(void);
|
||||
void GL_Set2D(void);
|
||||
|
||||
extern int32_t glx, gly, glwidth, glheight;
|
||||
|
||||
|
@ -35,8 +35,8 @@ extern int32_t glx, gly, glwidth, glheight;
|
|||
// r_local.h -- private refresh defs
|
||||
|
||||
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
|
||||
// normalizing factor so player model works out to about
|
||||
// 1 pixel per triangle
|
||||
// normalizing factor so player model works out to about
|
||||
// 1 pixel per triangle
|
||||
#define MAX_LBM_HEIGHT 480
|
||||
|
||||
#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
|
||||
|
@ -48,11 +48,12 @@ extern int32_t glx, gly, glwidth, glheight;
|
|||
#define BACKFACE_EPSILON 0.01
|
||||
|
||||
|
||||
void R_TimeRefresh_f (void);
|
||||
void R_ReadPointFile_f (void);
|
||||
texture_t *R_TextureAnimation (texture_t *base, int32_t frame);
|
||||
void R_TimeRefresh_f(void);
|
||||
void R_ReadPointFile_f(void);
|
||||
texture_t *R_TextureAnimation(texture_t *base, int32_t frame);
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
|
||||
} ptype_t;
|
||||
|
||||
|
@ -154,29 +155,29 @@ extern bool gl_vbo_able;
|
|||
//ericw -- GLSL
|
||||
|
||||
// SDL 1.2 has a bug where it doesn't provide these typedefs on OS X!
|
||||
typedef GLuint (APIENTRYP QS_PFNGLCREATESHADERPROC) (GLenum type);
|
||||
typedef void (APIENTRYP QS_PFNGLDELETESHADERPROC) (GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLDELETEPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP QS_PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
typedef void (APIENTRYP QS_PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP QS_PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef void (APIENTRYP QS_PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP QS_PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef GLuint (APIENTRYP QS_PFNGLCREATEPROGRAMPROC) (void);
|
||||
typedef void (APIENTRYP QS_PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLLINKPROGRAMPROC) (GLuint program);
|
||||
typedef void (APIENTRYP QS_PFNGLBINDATTRIBLOCATIONFUNC) (GLuint program, GLuint index, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLUSEPROGRAMPROC) (GLuint program);
|
||||
typedef GLint (APIENTRYP QS_PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
||||
typedef void (APIENTRYP QS_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||
typedef void (APIENTRYP QS_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
||||
typedef GLint (APIENTRYP QS_PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
typedef GLuint(APIENTRYP QS_PFNGLCREATESHADERPROC)(GLenum type);
|
||||
typedef void (APIENTRYP QS_PFNGLDELETESHADERPROC)(GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLDELETEPROGRAMPROC)(GLuint program);
|
||||
typedef void (APIENTRYP QS_PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
|
||||
typedef void (APIENTRYP QS_PFNGLCOMPILESHADERPROC)(GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP QS_PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef void (APIENTRYP QS_PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP QS_PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
typedef GLuint(APIENTRYP QS_PFNGLCREATEPROGRAMPROC)(void);
|
||||
typedef void (APIENTRYP QS_PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
|
||||
typedef void (APIENTRYP QS_PFNGLLINKPROGRAMPROC)(GLuint program);
|
||||
typedef void (APIENTRYP QS_PFNGLBINDATTRIBLOCATIONFUNC)(GLuint program, GLuint index, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLUSEPROGRAMPROC)(GLuint program);
|
||||
typedef GLint(APIENTRYP QS_PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
||||
typedef void (APIENTRYP QS_PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
|
||||
typedef void (APIENTRYP QS_PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
|
||||
typedef GLint(APIENTRYP QS_PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
||||
typedef void (APIENTRYP QS_PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
|
||||
extern QS_PFNGLCREATESHADERPROC GL_CreateShaderFunc;
|
||||
extern QS_PFNGLDELETESHADERPROC GL_DeleteShaderFunc;
|
||||
|
@ -215,7 +216,7 @@ extern bool gl_texture_NPOT;
|
|||
#define OFFSET_DECAL -1
|
||||
#define OFFSET_FOG -2
|
||||
#define OFFSET_SHOWTRIS -3
|
||||
void GL_PolygonOffset (int32_t);
|
||||
void GL_PolygonOffset(int32_t);
|
||||
|
||||
//johnfitz -- GL_EXT_texture_env_combine
|
||||
//the values for GL_ARB_ are identical
|
||||
|
@ -240,7 +241,8 @@ extern float rs_megatexels;
|
|||
|
||||
//johnfitz -- track developer statistics that vary every frame
|
||||
extern cvar_t devstats;
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t packetsize;
|
||||
int32_t edicts;
|
||||
int32_t visedicts;
|
||||
|
@ -252,7 +254,8 @@ typedef struct {
|
|||
extern devstats_t dev_stats, dev_peakstats;
|
||||
|
||||
//ohnfitz -- reduce overflow warning spam
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
double packetsize;
|
||||
double efrags;
|
||||
double beams;
|
||||
|
@ -270,7 +273,8 @@ extern int32_t gl_warpimagesize; //johnfitz -- for water warp
|
|||
|
||||
extern bool r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz
|
||||
|
||||
typedef struct glsl_attrib_binding_s {
|
||||
typedef struct glsl_attrib_binding_s
|
||||
{
|
||||
const char *name;
|
||||
GLuint attrib;
|
||||
} glsl_attrib_binding_t;
|
||||
|
@ -278,99 +282,99 @@ typedef struct glsl_attrib_binding_s {
|
|||
extern float map_wateralpha, map_lavaalpha, map_telealpha, map_slimealpha; //ericw
|
||||
|
||||
//johnfitz -- fog functions called from outside gl_fog.c
|
||||
void Fog_ParseServerMessage (void);
|
||||
float *Fog_GetColor (void);
|
||||
float Fog_GetDensity (void);
|
||||
void Fog_EnableGFog (void);
|
||||
void Fog_DisableGFog (void);
|
||||
void Fog_StartAdditive (void);
|
||||
void Fog_StopAdditive (void);
|
||||
void Fog_SetupFrame (void);
|
||||
void Fog_NewMap (void);
|
||||
void Fog_Init (void);
|
||||
void Fog_SetupState (void);
|
||||
void Fog_ParseServerMessage(void);
|
||||
float *Fog_GetColor(void);
|
||||
float Fog_GetDensity(void);
|
||||
void Fog_EnableGFog(void);
|
||||
void Fog_DisableGFog(void);
|
||||
void Fog_StartAdditive(void);
|
||||
void Fog_StopAdditive(void);
|
||||
void Fog_SetupFrame(void);
|
||||
void Fog_NewMap(void);
|
||||
void Fog_Init(void);
|
||||
void Fog_SetupState(void);
|
||||
|
||||
void R_NewGame (void);
|
||||
void R_NewGame(void);
|
||||
|
||||
void R_AnimateLight (void);
|
||||
void R_MarkSurfaces (void);
|
||||
void R_CullSurfaces (void);
|
||||
bool R_CullBox (vec3_t emins, vec3_t emaxs);
|
||||
void R_StoreEfrags (efrag_t **ppefrag);
|
||||
bool R_CullModelForEntity (entity_t *e);
|
||||
void R_RotateForEntity (vec3_t origin, vec3_t angles);
|
||||
void R_MarkLights (dlight_t *light, int32_t num, mnode_t *node);
|
||||
void R_AnimateLight(void);
|
||||
void R_MarkSurfaces(void);
|
||||
void R_CullSurfaces(void);
|
||||
bool R_CullBox(vec3_t emins, vec3_t emaxs);
|
||||
void R_StoreEfrags(efrag_t **ppefrag);
|
||||
bool R_CullModelForEntity(entity_t *e);
|
||||
void R_RotateForEntity(vec3_t origin, vec3_t angles);
|
||||
void R_MarkLights(dlight_t *light, int32_t num, mnode_t *node);
|
||||
|
||||
void R_InitParticles (void);
|
||||
void R_DrawParticles (void);
|
||||
void CL_RunParticles (void);
|
||||
void R_ClearParticles (void);
|
||||
void R_InitParticles(void);
|
||||
void R_DrawParticles(void);
|
||||
void CL_RunParticles(void);
|
||||
void R_ClearParticles(void);
|
||||
|
||||
void R_TranslatePlayerSkin (int32_t playernum);
|
||||
void R_TranslateNewPlayerSkin (int32_t playernum); //johnfitz -- this handles cases when the actual texture changes
|
||||
void R_UpdateWarpTextures (void);
|
||||
void R_TranslatePlayerSkin(int32_t playernum);
|
||||
void R_TranslateNewPlayerSkin(int32_t playernum); //johnfitz -- this handles cases when the actual texture changes
|
||||
void R_UpdateWarpTextures(void);
|
||||
|
||||
void R_DrawWorld (void);
|
||||
void R_DrawAliasModel (entity_t *e);
|
||||
void R_DrawBrushModel (entity_t *e);
|
||||
void R_DrawSpriteModel (entity_t *e);
|
||||
void R_DrawWorld(void);
|
||||
void R_DrawAliasModel(entity_t *e);
|
||||
void R_DrawBrushModel(entity_t *e);
|
||||
void R_DrawSpriteModel(entity_t *e);
|
||||
|
||||
void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain);
|
||||
void R_DrawTextureChains_Water(qmodel_t *model, entity_t *ent, texchain_t chain);
|
||||
|
||||
void R_RenderDlights (void);
|
||||
void GL_BuildLightmaps (void);
|
||||
void GL_DeleteBModelVertexBuffer (void);
|
||||
void GL_BuildBModelVertexBuffer (void);
|
||||
void GLMesh_LoadVertexBuffers (void);
|
||||
void GLMesh_DeleteVertexBuffers (void);
|
||||
void R_RebuildAllLightmaps (void);
|
||||
void R_RenderDlights(void);
|
||||
void GL_BuildLightmaps(void);
|
||||
void GL_DeleteBModelVertexBuffer(void);
|
||||
void GL_BuildBModelVertexBuffer(void);
|
||||
void GLMesh_LoadVertexBuffers(void);
|
||||
void GLMesh_DeleteVertexBuffers(void);
|
||||
void R_RebuildAllLightmaps(void);
|
||||
|
||||
int32_t R_LightPoint (vec3_t p);
|
||||
int32_t R_LightPoint(vec3_t p);
|
||||
|
||||
void GL_SubdivideSurface (msurface_t *fa);
|
||||
void R_BuildLightMap (msurface_t *surf, byte *dest, int32_t stride);
|
||||
void R_RenderDynamicLightmaps (msurface_t *fa);
|
||||
void R_UploadLightmaps (void);
|
||||
void GL_SubdivideSurface(msurface_t *fa);
|
||||
void R_BuildLightMap(msurface_t *surf, byte *dest, int32_t stride);
|
||||
void R_RenderDynamicLightmaps(msurface_t *fa);
|
||||
void R_UploadLightmaps(void);
|
||||
|
||||
void R_DrawWorld_ShowTris (void);
|
||||
void R_DrawBrushModel_ShowTris (entity_t *e);
|
||||
void R_DrawAliasModel_ShowTris (entity_t *e);
|
||||
void R_DrawParticles_ShowTris (void);
|
||||
void R_DrawWorld_ShowTris(void);
|
||||
void R_DrawBrushModel_ShowTris(entity_t *e);
|
||||
void R_DrawAliasModel_ShowTris(entity_t *e);
|
||||
void R_DrawParticles_ShowTris(void);
|
||||
|
||||
GLint GL_GetUniformLocation (GLuint *programPtr, const char *name);
|
||||
GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int32_t numbindings, const glsl_attrib_binding_t *bindings);
|
||||
void R_DeleteShaders (void);
|
||||
GLint GL_GetUniformLocation(GLuint *programPtr, const char *name);
|
||||
GLuint GL_CreateProgram(const GLchar *vertSource, const GLchar *fragSource, int32_t numbindings, const glsl_attrib_binding_t *bindings);
|
||||
void R_DeleteShaders(void);
|
||||
|
||||
void GLWorld_CreateShaders (void);
|
||||
void GLAlias_CreateShaders (void);
|
||||
void GL_DrawAliasShadow (entity_t *e);
|
||||
void DrawGLTriangleFan (glpoly_t *p);
|
||||
void DrawGLPoly (glpoly_t *p);
|
||||
void DrawWaterPoly (glpoly_t *p);
|
||||
void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr);
|
||||
void GLWorld_CreateShaders(void);
|
||||
void GLAlias_CreateShaders(void);
|
||||
void GL_DrawAliasShadow(entity_t *e);
|
||||
void DrawGLTriangleFan(glpoly_t *p);
|
||||
void DrawGLPoly(glpoly_t *p);
|
||||
void DrawWaterPoly(glpoly_t *p);
|
||||
void GL_MakeAliasModelDisplayLists(qmodel_t *m, aliashdr_t *hdr);
|
||||
|
||||
void Sky_Init (void);
|
||||
void Sky_DrawSky (void);
|
||||
void Sky_NewMap (void);
|
||||
void Sky_LoadTexture (texture_t *mt);
|
||||
void Sky_LoadSkyBox (const char *name);
|
||||
void Sky_Init(void);
|
||||
void Sky_DrawSky(void);
|
||||
void Sky_NewMap(void);
|
||||
void Sky_LoadTexture(texture_t *mt);
|
||||
void Sky_LoadSkyBox(const char *name);
|
||||
|
||||
void TexMgr_RecalcWarpImageSize (void);
|
||||
void TexMgr_RecalcWarpImageSize(void);
|
||||
|
||||
void R_ClearTextureChains (qmodel_t *mod, texchain_t chain);
|
||||
void R_ChainSurface (msurface_t *surf, texchain_t chain);
|
||||
void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain);
|
||||
void R_DrawWorld_Water (void);
|
||||
void R_ClearTextureChains(qmodel_t *mod, texchain_t chain);
|
||||
void R_ChainSurface(msurface_t *surf, texchain_t chain);
|
||||
void R_DrawTextureChains(qmodel_t *model, entity_t *ent, texchain_t chain);
|
||||
void R_DrawWorld_Water(void);
|
||||
|
||||
void GL_BindBuffer (GLenum target, GLuint buffer);
|
||||
void GL_ClearBufferBindings ();
|
||||
void GL_BindBuffer(GLenum target, GLuint buffer);
|
||||
void GL_ClearBufferBindings();
|
||||
|
||||
void GLSLGamma_DeleteTexture (void);
|
||||
void GLSLGamma_GammaCorrect (void);
|
||||
void GLSLGamma_DeleteTexture(void);
|
||||
void GLSLGamma_GammaCorrect(void);
|
||||
|
||||
void R_ScaleView_DeleteTexture (void);
|
||||
void R_ScaleView_DeleteTexture(void);
|
||||
|
||||
float GL_WaterAlphaForSurface (msurface_t *fa);
|
||||
float GL_WaterAlphaForSurface(msurface_t *fa);
|
||||
|
||||
#endif /* __GLQUAKE_H */
|
||||
|
||||
|
|
618
source/host.c
618
source/host.c
File diff suppressed because it is too large
Load Diff
1273
source/host_cmd.c
1273
source/host_cmd.c
File diff suppressed because it is too large
Load Diff
259
source/image.c
259
source/image.c
|
@ -36,7 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static char loadfilename[MAX_OSPATH]; //file scope so that error messages can use it
|
||||
|
||||
typedef struct stdio_buffer_s {
|
||||
typedef struct stdio_buffer_s
|
||||
{
|
||||
FILE *f;
|
||||
uint8_t buffer[1024];
|
||||
int32_t size;
|
||||
|
@ -57,12 +58,12 @@ static void Buf_Free(stdio_buffer_t *buf)
|
|||
|
||||
static inline int32_t Buf_GetC(stdio_buffer_t *buf)
|
||||
{
|
||||
if (buf->pos >= buf->size)
|
||||
if(buf->pos >= buf->size)
|
||||
{
|
||||
buf->size = fread(buf->buffer, 1, sizeof(buf->buffer), buf->f);
|
||||
buf->pos = 0;
|
||||
|
||||
if (buf->size == 0)
|
||||
if(buf->size == 0)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
@ -78,19 +79,19 @@ returns a pointer to hunk allocated RGBA data
|
|||
TODO: search order: tga png jpg pcx lmp
|
||||
============
|
||||
*/
|
||||
byte *Image_LoadImage (const char *name, int32_t *width, int32_t *height)
|
||||
byte *Image_LoadImage(const char *name, int32_t *width, int32_t *height)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
q_snprintf (loadfilename, sizeof(loadfilename), "%s.tga", name);
|
||||
COM_FOpenFile (loadfilename, &f, NULL);
|
||||
if (f)
|
||||
return Image_LoadTGA (f, width, height);
|
||||
q_snprintf(loadfilename, sizeof(loadfilename), "%s.tga", name);
|
||||
COM_FOpenFile(loadfilename, &f, NULL);
|
||||
if(f)
|
||||
return Image_LoadTGA(f, width, height);
|
||||
|
||||
q_snprintf (loadfilename, sizeof(loadfilename), "%s.pcx", name);
|
||||
COM_FOpenFile (loadfilename, &f, NULL);
|
||||
if (f)
|
||||
return Image_LoadPCX (f, width, height);
|
||||
q_snprintf(loadfilename, sizeof(loadfilename), "%s.pcx", name);
|
||||
COM_FOpenFile(loadfilename, &f, NULL);
|
||||
if(f)
|
||||
return Image_LoadPCX(f, width, height);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -101,7 +102,8 @@ byte *Image_LoadImage (const char *name, int32_t *width, int32_t *height)
|
|||
//
|
||||
//==============================================================================
|
||||
|
||||
typedef struct targaheader_s {
|
||||
typedef struct targaheader_s
|
||||
{
|
||||
uint8_t id_length, colormap_type, image_type;
|
||||
uint16_t colormap_index, colormap_length;
|
||||
uint8_t colormap_size;
|
||||
|
@ -113,17 +115,17 @@ typedef struct targaheader_s {
|
|||
|
||||
targaheader_t targa_header;
|
||||
|
||||
int32_t fgetLittleShort (FILE *f)
|
||||
int32_t fgetLittleShort(FILE *f)
|
||||
{
|
||||
byte b1, b2;
|
||||
|
||||
b1 = fgetc(f);
|
||||
b2 = fgetc(f);
|
||||
|
||||
return (int16_t)(b1 + b2*256);
|
||||
return (int16_t)(b1 + b2 * 256);
|
||||
}
|
||||
|
||||
int32_t fgetLittleLong (FILE *f)
|
||||
int32_t fgetLittleLong(FILE *f)
|
||||
{
|
||||
byte b1, b2, b3, b4;
|
||||
|
||||
|
@ -132,7 +134,7 @@ int32_t fgetLittleLong (FILE *f)
|
|||
b3 = fgetc(f);
|
||||
b4 = fgetc(f);
|
||||
|
||||
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
||||
return b1 + (b2 << 8) + (b3 << 16) + (b4 << 24);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -144,41 +146,41 @@ returns true if successful
|
|||
TODO: support BGRA and BGR formats (since opengl can return them, and we don't have to swap)
|
||||
============
|
||||
*/
|
||||
bool Image_WriteTGA (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown)
|
||||
bool Image_WriteTGA(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown)
|
||||
{
|
||||
int32_t handle, i, size, temp, bytes;
|
||||
char pathname[MAX_OSPATH];
|
||||
byte header[TARGAHEADERSIZE];
|
||||
|
||||
Sys_mkdir (com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf (pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
handle = Sys_FileOpenWrite (pathname);
|
||||
if (handle == -1)
|
||||
Sys_mkdir(com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf(pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
handle = Sys_FileOpenWrite(pathname);
|
||||
if(handle == -1)
|
||||
return false;
|
||||
|
||||
Q_memset (header, 0, TARGAHEADERSIZE);
|
||||
Q_memset(header, 0, TARGAHEADERSIZE);
|
||||
header[2] = 2; // uncompressed type
|
||||
header[12] = width&255;
|
||||
header[13] = width>>8;
|
||||
header[14] = height&255;
|
||||
header[15] = height>>8;
|
||||
header[12] = width & 255;
|
||||
header[13] = width >> 8;
|
||||
header[14] = height & 255;
|
||||
header[15] = height >> 8;
|
||||
header[16] = bpp; // pixel size
|
||||
if (upsidedown)
|
||||
if(upsidedown)
|
||||
header[17] = 0x20; //upside-down attribute
|
||||
|
||||
// swap red and blue bytes
|
||||
bytes = bpp/8;
|
||||
size = width*height*bytes;
|
||||
for (i=0; i<size; i+=bytes)
|
||||
bytes = bpp / 8;
|
||||
size = width * height * bytes;
|
||||
for(i = 0; i < size; i += bytes)
|
||||
{
|
||||
temp = data[i];
|
||||
data[i] = data[i+2];
|
||||
data[i+2] = temp;
|
||||
data[i] = data[i + 2];
|
||||
data[i + 2] = temp;
|
||||
}
|
||||
|
||||
Sys_FileWrite (handle, header, TARGAHEADERSIZE);
|
||||
Sys_FileWrite (handle, data, size);
|
||||
Sys_FileClose (handle);
|
||||
Sys_FileWrite(handle, header, TARGAHEADERSIZE);
|
||||
Sys_FileWrite(handle, data, size);
|
||||
Sys_FileClose(handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ bool Image_WriteTGA (const char *name, byte *data, int32_t width, int32_t height
|
|||
Image_LoadTGA
|
||||
=============
|
||||
*/
|
||||
byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
||||
byte *Image_LoadTGA(FILE *fin, int32_t *width, int32_t *height)
|
||||
{
|
||||
int32_t columns, rows, numPixels;
|
||||
byte *pixbuf;
|
||||
|
@ -212,36 +214,36 @@ byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
|||
targa_header.pixel_size = fgetc(fin);
|
||||
targa_header.attributes = fgetc(fin);
|
||||
|
||||
if (targa_header.image_type!=2 && targa_header.image_type!=10)
|
||||
Sys_Error ("Image_LoadTGA: %s is not a type 2 or type 10 targa\n", loadfilename);
|
||||
if(targa_header.image_type != 2 && targa_header.image_type != 10)
|
||||
Sys_Error("Image_LoadTGA: %s is not a type 2 or type 10 targa\n", loadfilename);
|
||||
|
||||
if (targa_header.colormap_type !=0 || (targa_header.pixel_size!=32 && targa_header.pixel_size!=24))
|
||||
Sys_Error ("Image_LoadTGA: %s is not a 24bit or 32bit targa\n", loadfilename);
|
||||
if(targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
|
||||
Sys_Error("Image_LoadTGA: %s is not a 24bit or 32bit targa\n", loadfilename);
|
||||
|
||||
columns = targa_header.width;
|
||||
rows = targa_header.height;
|
||||
numPixels = columns * rows;
|
||||
upside_down = !(targa_header.attributes & 0x20); //johnfitz -- fix for upside-down targas
|
||||
|
||||
targa_rgba = (byte *) Hunk_Alloc (numPixels*4);
|
||||
targa_rgba = (byte *) Hunk_Alloc(numPixels * 4);
|
||||
|
||||
if (targa_header.id_length != 0)
|
||||
if(targa_header.id_length != 0)
|
||||
fseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
||||
|
||||
buf = Buf_Alloc(fin);
|
||||
|
||||
if (targa_header.image_type==2) // Uncompressed, RGB images
|
||||
if(targa_header.image_type == 2) // Uncompressed, RGB images
|
||||
{
|
||||
for(row=rows-1; row>=0; row--)
|
||||
for(row = rows - 1; row >= 0; row--)
|
||||
{
|
||||
//johnfitz -- fix for upside-down targas
|
||||
realrow = upside_down ? row : rows - 1 - row;
|
||||
pixbuf = targa_rgba + realrow*columns*4;
|
||||
pixbuf = targa_rgba + realrow * columns * 4;
|
||||
//johnfitz
|
||||
for(column=0; column<columns; column++)
|
||||
for(column = 0; column < columns; column++)
|
||||
{
|
||||
uint8_t red,green,blue,alphabyte;
|
||||
switch (targa_header.pixel_size)
|
||||
uint8_t red, green, blue, alphabyte;
|
||||
switch(targa_header.pixel_size)
|
||||
{
|
||||
case 24:
|
||||
blue = Buf_GetC(buf);
|
||||
|
@ -266,22 +268,22 @@ byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (targa_header.image_type==10) // Runlength encoded RGB images
|
||||
else if(targa_header.image_type == 10) // Runlength encoded RGB images
|
||||
{
|
||||
uint8_t red,green,blue,alphabyte,packetHeader,packetSize,j;
|
||||
for(row=rows-1; row>=0; row--)
|
||||
uint8_t red, green, blue, alphabyte, packetHeader, packetSize, j;
|
||||
for(row = rows - 1; row >= 0; row--)
|
||||
{
|
||||
//johnfitz -- fix for upside-down targas
|
||||
realrow = upside_down ? row : rows - 1 - row;
|
||||
pixbuf = targa_rgba + realrow*columns*4;
|
||||
pixbuf = targa_rgba + realrow * columns * 4;
|
||||
//johnfitz
|
||||
for(column=0; column<columns; )
|
||||
for(column = 0; column < columns;)
|
||||
{
|
||||
packetHeader=Buf_GetC(buf);
|
||||
packetHeader = Buf_GetC(buf);
|
||||
packetSize = 1 + (packetHeader & 0x7f);
|
||||
if (packetHeader & 0x80) // run-length packet
|
||||
if(packetHeader & 0x80) // run-length packet
|
||||
{
|
||||
switch (targa_header.pixel_size)
|
||||
switch(targa_header.pixel_size)
|
||||
{
|
||||
case 24:
|
||||
blue = Buf_GetC(buf);
|
||||
|
@ -299,32 +301,32 @@ byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
|||
blue = red = green = alphabyte = 0;
|
||||
}
|
||||
|
||||
for(j=0;j<packetSize;j++)
|
||||
for(j = 0; j < packetSize; j++)
|
||||
{
|
||||
*pixbuf++=red;
|
||||
*pixbuf++=green;
|
||||
*pixbuf++=blue;
|
||||
*pixbuf++=alphabyte;
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
*pixbuf++ = alphabyte;
|
||||
column++;
|
||||
if (column==columns) // run spans across rows
|
||||
if(column == columns) // run spans across rows
|
||||
{
|
||||
column=0;
|
||||
if (row>0)
|
||||
column = 0;
|
||||
if(row > 0)
|
||||
row--;
|
||||
else
|
||||
goto breakOut;
|
||||
//johnfitz -- fix for upside-down targas
|
||||
realrow = upside_down ? row : rows - 1 - row;
|
||||
pixbuf = targa_rgba + realrow*columns*4;
|
||||
pixbuf = targa_rgba + realrow * columns * 4;
|
||||
//johnfitz
|
||||
}
|
||||
}
|
||||
}
|
||||
else // non run-length packet
|
||||
{
|
||||
for(j=0;j<packetSize;j++)
|
||||
for(j = 0; j < packetSize; j++)
|
||||
{
|
||||
switch (targa_header.pixel_size)
|
||||
switch(targa_header.pixel_size)
|
||||
{
|
||||
case 24:
|
||||
blue = Buf_GetC(buf);
|
||||
|
@ -349,22 +351,23 @@ byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
|||
blue = red = green = alphabyte = 0;
|
||||
}
|
||||
column++;
|
||||
if (column==columns) // pixel packet run spans across rows
|
||||
if(column == columns) // pixel packet run spans across rows
|
||||
{
|
||||
column=0;
|
||||
if (row>0)
|
||||
column = 0;
|
||||
if(row > 0)
|
||||
row--;
|
||||
else
|
||||
goto breakOut;
|
||||
//johnfitz -- fix for upside-down targas
|
||||
realrow = upside_down ? row : rows - 1 - row;
|
||||
pixbuf = targa_rgba + realrow*columns*4;
|
||||
pixbuf = targa_rgba + realrow * columns * 4;
|
||||
//johnfitz
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
breakOut:;
|
||||
breakOut:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,8 +391,8 @@ typedef struct
|
|||
int8_t version;
|
||||
int8_t encoding;
|
||||
int8_t bits_per_pixel;
|
||||
uint16_t xmin,ymin,xmax,ymax;
|
||||
uint16_t hdpi,vdpi;
|
||||
uint16_t xmin, ymin, xmax, ymax;
|
||||
uint16_t hdpi, vdpi;
|
||||
uint8_t colortable[48];
|
||||
int8_t reserved;
|
||||
int8_t color_planes;
|
||||
|
@ -403,7 +406,7 @@ typedef struct
|
|||
Image_LoadPCX
|
||||
============
|
||||
*/
|
||||
byte *Image_LoadPCX (FILE *f, int32_t *width, int32_t *height)
|
||||
byte *Image_LoadPCX(FILE *f, int32_t *width, int32_t *height)
|
||||
{
|
||||
pcxheader_t pcx;
|
||||
int32_t x, y, w, h, readbyte, runlength, start;
|
||||
|
@ -411,43 +414,43 @@ byte *Image_LoadPCX (FILE *f, int32_t *width, int32_t *height)
|
|||
byte palette[768];
|
||||
stdio_buffer_t *buf;
|
||||
|
||||
start = ftell (f); //save start of file (since we might be inside a pak file, SEEK_SET might not be the start of the pcx)
|
||||
start = ftell(f); //save start of file (since we might be inside a pak file, SEEK_SET might not be the start of the pcx)
|
||||
|
||||
fread(&pcx, sizeof(pcx), 1, f);
|
||||
pcx.xmin = (uint16_t)LittleShort (pcx.xmin);
|
||||
pcx.ymin = (uint16_t)LittleShort (pcx.ymin);
|
||||
pcx.xmax = (uint16_t)LittleShort (pcx.xmax);
|
||||
pcx.ymax = (uint16_t)LittleShort (pcx.ymax);
|
||||
pcx.bytes_per_line = (uint16_t)LittleShort (pcx.bytes_per_line);
|
||||
pcx.xmin = (uint16_t)LittleShort(pcx.xmin);
|
||||
pcx.ymin = (uint16_t)LittleShort(pcx.ymin);
|
||||
pcx.xmax = (uint16_t)LittleShort(pcx.xmax);
|
||||
pcx.ymax = (uint16_t)LittleShort(pcx.ymax);
|
||||
pcx.bytes_per_line = (uint16_t)LittleShort(pcx.bytes_per_line);
|
||||
|
||||
if (pcx.signature != 0x0A)
|
||||
Sys_Error ("'%s' is not a valid PCX file", loadfilename);
|
||||
if(pcx.signature != 0x0A)
|
||||
Sys_Error("'%s' is not a valid PCX file", loadfilename);
|
||||
|
||||
if (pcx.version != 5)
|
||||
Sys_Error ("'%s' is version %" PRIi32 ", should be 5", loadfilename, pcx.version);
|
||||
if(pcx.version != 5)
|
||||
Sys_Error("'%s' is version %" PRIi32 ", should be 5", loadfilename, pcx.version);
|
||||
|
||||
if (pcx.encoding != 1 || pcx.bits_per_pixel != 8 || pcx.color_planes != 1)
|
||||
Sys_Error ("'%s' has wrong encoding or bit depth", loadfilename);
|
||||
if(pcx.encoding != 1 || pcx.bits_per_pixel != 8 || pcx.color_planes != 1)
|
||||
Sys_Error("'%s' has wrong encoding or bit depth", loadfilename);
|
||||
|
||||
w = pcx.xmax - pcx.xmin + 1;
|
||||
h = pcx.ymax - pcx.ymin + 1;
|
||||
|
||||
data = (byte *) Hunk_Alloc((w*h+1)*4); //+1 to allow reading padding byte on last line
|
||||
data = (byte *) Hunk_Alloc((w * h + 1) * 4); //+1 to allow reading padding byte on last line
|
||||
|
||||
//load palette
|
||||
fseek (f, start + com_filesize - 768, SEEK_SET);
|
||||
fread (palette, 1, 768, f);
|
||||
fseek(f, start + com_filesize - 768, SEEK_SET);
|
||||
fread(palette, 1, 768, f);
|
||||
|
||||
//back to start of image data
|
||||
fseek (f, start + sizeof(pcx), SEEK_SET);
|
||||
fseek(f, start + sizeof(pcx), SEEK_SET);
|
||||
|
||||
buf = Buf_Alloc(f);
|
||||
|
||||
for (y=0; y<h; y++)
|
||||
for(y = 0; y < h; y++)
|
||||
{
|
||||
p = data + y * w * 4;
|
||||
|
||||
for (x=0; x<(pcx.bytes_per_line); ) //read the extra padding byte if necessary
|
||||
for(x = 0; x < (pcx.bytes_per_line);) //read the extra padding byte if necessary
|
||||
{
|
||||
readbyte = Buf_GetC(buf);
|
||||
|
||||
|
@ -461,9 +464,9 @@ byte *Image_LoadPCX (FILE *f, int32_t *width, int32_t *height)
|
|||
|
||||
while(runlength--)
|
||||
{
|
||||
p[0] = palette[readbyte*3];
|
||||
p[1] = palette[readbyte*3+1];
|
||||
p[2] = palette[readbyte*3+2];
|
||||
p[0] = palette[readbyte * 3];
|
||||
p[1] = palette[readbyte * 3 + 1];
|
||||
p[2] = palette[readbyte * 3 + 2];
|
||||
p[3] = 255;
|
||||
p += 4;
|
||||
x++;
|
||||
|
@ -492,10 +495,10 @@ static byte *CopyFlipped(const byte *data, int32_t width, int32_t height, int32_
|
|||
|
||||
rowsize = width * (bpp / 8);
|
||||
flipped = (byte *) malloc(height * rowsize);
|
||||
if (!flipped)
|
||||
if(!flipped)
|
||||
return NULL;
|
||||
|
||||
for (y=0; y<height; y++)
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
memcpy(&flipped[y * rowsize], &data[(height - 1 - y) * rowsize], rowsize);
|
||||
}
|
||||
|
@ -509,38 +512,38 @@ Image_WriteJPG -- writes using stb_image_write
|
|||
returns true if successful
|
||||
============
|
||||
*/
|
||||
bool Image_WriteJPG (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown)
|
||||
bool Image_WriteJPG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown)
|
||||
{
|
||||
unsigned error;
|
||||
char pathname[MAX_OSPATH];
|
||||
byte *flipped;
|
||||
int32_t bytes_per_pixel;
|
||||
|
||||
if (!(bpp == 32 || bpp == 24))
|
||||
Sys_Error ("bpp not 24 or 32");
|
||||
if(!(bpp == 32 || bpp == 24))
|
||||
Sys_Error("bpp not 24 or 32");
|
||||
|
||||
bytes_per_pixel = bpp / 8;
|
||||
|
||||
Sys_mkdir (com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf (pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
Sys_mkdir(com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf(pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
|
||||
if (!upsidedown)
|
||||
if(!upsidedown)
|
||||
{
|
||||
flipped = CopyFlipped (data, width, height, bpp);
|
||||
if (!flipped)
|
||||
flipped = CopyFlipped(data, width, height, bpp);
|
||||
if(!flipped)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
flipped = data;
|
||||
|
||||
error = stbi_write_jpg (pathname, width, height, bytes_per_pixel, flipped, quality);
|
||||
if (!upsidedown)
|
||||
free (flipped);
|
||||
error = stbi_write_jpg(pathname, width, height, bytes_per_pixel, flipped, quality);
|
||||
if(!upsidedown)
|
||||
free(flipped);
|
||||
|
||||
return (error != 0);
|
||||
}
|
||||
|
||||
bool Image_WritePNG (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown)
|
||||
bool Image_WritePNG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown)
|
||||
{
|
||||
unsigned error;
|
||||
char pathname[MAX_OSPATH];
|
||||
|
@ -550,19 +553,19 @@ bool Image_WritePNG (const char *name, byte *data, int32_t width, int32_t height
|
|||
size_t pngsize;
|
||||
LodePNGState state;
|
||||
|
||||
if (!(bpp == 32 || bpp == 24))
|
||||
if(!(bpp == 32 || bpp == 24))
|
||||
Sys_Error("bpp not 24 or 32");
|
||||
|
||||
Sys_mkdir (com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf (pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
Sys_mkdir(com_gamedir); //if we've switched to a nonexistant gamedir, create it now so we don't crash
|
||||
q_snprintf(pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
|
||||
|
||||
flipped = (!upsidedown)? CopyFlipped (data, width, height, bpp) : data;
|
||||
filters = (uint8_t *) malloc (height);
|
||||
if (!filters || !flipped)
|
||||
flipped = (!upsidedown) ? CopyFlipped(data, width, height, bpp) : data;
|
||||
filters = (uint8_t *) malloc(height);
|
||||
if(!filters || !flipped)
|
||||
{
|
||||
if (!upsidedown)
|
||||
free (flipped);
|
||||
free (filters);
|
||||
if(!upsidedown)
|
||||
free(flipped);
|
||||
free(filters);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -574,7 +577,7 @@ bool Image_WritePNG (const char *name, byte *data, int32_t width, int32_t height
|
|||
memset(filters, 1, height); //use filter 1; see https://www.w3.org/TR/PNG-Filters.html
|
||||
state.encoder.predefined_filters = filters;
|
||||
|
||||
if (bpp == 24)
|
||||
if(bpp == 24)
|
||||
{
|
||||
state.info_raw.colortype = LCT_RGB;
|
||||
state.info_png.color.colortype = LCT_RGB;
|
||||
|
@ -585,17 +588,17 @@ bool Image_WritePNG (const char *name, byte *data, int32_t width, int32_t height
|
|||
state.info_png.color.colortype = LCT_RGBA;
|
||||
}
|
||||
|
||||
error = lodepng_encode (&png, &pngsize, flipped, width, height, &state);
|
||||
if (error == 0) lodepng_save_file (png, pngsize, pathname);
|
||||
error = lodepng_encode(&png, &pngsize, flipped, width, height, &state);
|
||||
if(error == 0) lodepng_save_file(png, pngsize, pathname);
|
||||
#ifdef LODEPNG_COMPILE_ERROR_TEXT
|
||||
else Con_Printf("WritePNG: %s\n", lodepng_error_text());
|
||||
#endif
|
||||
|
||||
lodepng_state_cleanup (&state);
|
||||
free (png);
|
||||
free (filters);
|
||||
if (!upsidedown)
|
||||
free (flipped);
|
||||
lodepng_state_cleanup(&state);
|
||||
free(png);
|
||||
free(filters);
|
||||
if(!upsidedown)
|
||||
free(flipped);
|
||||
|
||||
return (error == 0);
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//image.h -- image reading / writing
|
||||
|
||||
//be sure to free the hunk after using these loading functions
|
||||
byte *Image_LoadTGA (FILE *f, int32_t *width, int32_t *height);
|
||||
byte *Image_LoadPCX (FILE *f, int32_t *width, int32_t *height);
|
||||
byte *Image_LoadImage (const char *name, int32_t *width, int32_t *height);
|
||||
byte *Image_LoadTGA(FILE *f, int32_t *width, int32_t *height);
|
||||
byte *Image_LoadPCX(FILE *f, int32_t *width, int32_t *height);
|
||||
byte *Image_LoadImage(const char *name, int32_t *width, int32_t *height);
|
||||
|
||||
bool Image_WriteTGA (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown);
|
||||
bool Image_WritePNG (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown);
|
||||
bool Image_WriteJPG (const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown);
|
||||
bool Image_WriteTGA(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown);
|
||||
bool Image_WritePNG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, bool upsidedown);
|
||||
bool Image_WriteJPG(const char *name, byte *data, int32_t width, int32_t height, int32_t bpp, int32_t quality, bool upsidedown);
|
||||
|
||||
#endif /* GL_IMAGE_H */
|
||||
|
||||
|
|
558
source/in_sdl.c
558
source/in_sdl.c
|
@ -68,9 +68,9 @@ static int32_t buttonremap[] =
|
|||
/* total accumulated mouse movement since last frame */
|
||||
static int32_t total_dx, total_dy = 0;
|
||||
|
||||
static int32_t SDLCALL IN_FilterMouseEvents (const SDL_Event *event)
|
||||
static int32_t SDLCALL IN_FilterMouseEvents(const SDL_Event *event)
|
||||
{
|
||||
switch (event->type)
|
||||
switch(event->type)
|
||||
{
|
||||
case SDL_MOUSEMOTION:
|
||||
// case SDL_MOUSEBUTTONDOWN:
|
||||
|
@ -81,10 +81,10 @@ static int32_t SDLCALL IN_FilterMouseEvents (const SDL_Event *event)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int32_t SDLCALL IN_SDL2_FilterMouseEvents (void *userdata, SDL_Event *event)
|
||||
static int32_t SDLCALL IN_SDL2_FilterMouseEvents(void *userdata, SDL_Event *event)
|
||||
{
|
||||
(void)userdata;
|
||||
return IN_FilterMouseEvents (event);
|
||||
return IN_FilterMouseEvents(event);
|
||||
}
|
||||
|
||||
static void IN_BeginIgnoringMouseEvents(void)
|
||||
|
@ -93,7 +93,7 @@ static void IN_BeginIgnoringMouseEvents(void)
|
|||
void *currentUserdata = NULL;
|
||||
SDL_GetEventFilter(¤tFilter, ¤tUserdata);
|
||||
|
||||
if (currentFilter != IN_SDL2_FilterMouseEvents)
|
||||
if(currentFilter != IN_SDL2_FilterMouseEvents)
|
||||
SDL_SetEventFilter(IN_SDL2_FilterMouseEvents, NULL);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ static void IN_EndIgnoringMouseEvents(void)
|
|||
{
|
||||
SDL_EventFilter currentFilter;
|
||||
void *currentUserdata;
|
||||
if (SDL_GetEventFilter(¤tFilter, ¤tUserdata) == SDL_TRUE)
|
||||
if(SDL_GetEventFilter(¤tFilter, ¤tUserdata) == SDL_TRUE)
|
||||
SDL_SetEventFilter(NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -117,11 +117,11 @@ static io_connect_t IN_GetIOHandle(void)
|
|||
kern_return_t status;
|
||||
|
||||
status = IOMasterPort(MACH_PORT_NULL, &masterport);
|
||||
if (status != KERN_SUCCESS)
|
||||
if(status != KERN_SUCCESS)
|
||||
return 0;
|
||||
|
||||
iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem");
|
||||
if (!iohidsystem)
|
||||
if(!iohidsystem)
|
||||
return 0;
|
||||
|
||||
status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle);
|
||||
|
@ -130,14 +130,14 @@ static io_connect_t IN_GetIOHandle(void)
|
|||
return iohandle;
|
||||
}
|
||||
|
||||
static void IN_DisableOSXMouseAccel (void)
|
||||
static void IN_DisableOSXMouseAccel(void)
|
||||
{
|
||||
io_connect_t mouseDev = IN_GetIOHandle();
|
||||
if (mouseDev != 0)
|
||||
if(mouseDev != 0)
|
||||
{
|
||||
if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
|
||||
if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
|
||||
{
|
||||
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
|
||||
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
|
||||
{
|
||||
Cvar_Set("in_disablemacosxmouseaccel", "0");
|
||||
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||
|
@ -157,12 +157,12 @@ static void IN_DisableOSXMouseAccel (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void IN_ReenableOSXMouseAccel (void)
|
||||
static void IN_ReenableOSXMouseAccel(void)
|
||||
{
|
||||
io_connect_t mouseDev = IN_GetIOHandle();
|
||||
if (mouseDev != 0)
|
||||
if(mouseDev != 0)
|
||||
{
|
||||
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
|
||||
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
|
||||
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||
IOServiceClose(mouseDev);
|
||||
}
|
||||
|
@ -175,18 +175,18 @@ static void IN_ReenableOSXMouseAccel (void)
|
|||
#endif /* MACOS_X_ACCELERATION_HACK */
|
||||
|
||||
|
||||
void IN_Activate (void)
|
||||
void IN_Activate(void)
|
||||
{
|
||||
if (no_mouse)
|
||||
if(no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
/* Save the status of mouse acceleration */
|
||||
if (originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
||||
if(originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
||||
IN_DisableOSXMouseAccel();
|
||||
#endif
|
||||
|
||||
if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0)
|
||||
if(SDL_SetRelativeMouseMode(SDL_TRUE) != 0)
|
||||
{
|
||||
Con_Printf("WARNING: SDL_SetRelativeMouseMode(SDL_TRUE) failed.\n");
|
||||
}
|
||||
|
@ -197,17 +197,17 @@ void IN_Activate (void)
|
|||
total_dy = 0;
|
||||
}
|
||||
|
||||
void IN_Deactivate (bool free_cursor)
|
||||
void IN_Deactivate(bool free_cursor)
|
||||
{
|
||||
if (no_mouse)
|
||||
if(no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
if (originalMouseSpeed != -1)
|
||||
if(originalMouseSpeed != -1)
|
||||
IN_ReenableOSXMouseAccel();
|
||||
#endif
|
||||
|
||||
if (free_cursor)
|
||||
if(free_cursor)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
}
|
||||
|
@ -216,45 +216,45 @@ void IN_Deactivate (bool free_cursor)
|
|||
IN_BeginIgnoringMouseEvents();
|
||||
}
|
||||
|
||||
void IN_StartupJoystick (void)
|
||||
void IN_StartupJoystick(void)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t nummappings;
|
||||
char controllerdb[MAX_OSPATH];
|
||||
SDL_GameController *gamecontroller;
|
||||
|
||||
if (COM_CheckParm("-nojoy"))
|
||||
if(COM_CheckParm("-nojoy"))
|
||||
return;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1 )
|
||||
if(SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1)
|
||||
{
|
||||
Con_Warning("could not initialize SDL Game Controller\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Load additional SDL2 controller definitions from gamecontrollerdb.txt
|
||||
q_snprintf (controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", com_basedir);
|
||||
q_snprintf(controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", com_basedir);
|
||||
nummappings = SDL_GameControllerAddMappingsFromFile(controllerdb);
|
||||
if (nummappings > 0)
|
||||
if(nummappings > 0)
|
||||
Con_Printf("%" PRIi32 " mappings loaded from gamecontrollerdb.txt\n", nummappings);
|
||||
|
||||
// Also try host_parms->userdir
|
||||
if (host_parms->userdir != host_parms->basedir)
|
||||
if(host_parms->userdir != host_parms->basedir)
|
||||
{
|
||||
q_snprintf (controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", host_parms->userdir);
|
||||
q_snprintf(controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", host_parms->userdir);
|
||||
nummappings = SDL_GameControllerAddMappingsFromFile(controllerdb);
|
||||
if (nummappings > 0)
|
||||
if(nummappings > 0)
|
||||
Con_Printf("%" PRIi32 " mappings loaded from gamecontrollerdb.txt\n", nummappings);
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_NumJoysticks(); i++)
|
||||
for(i = 0; i < SDL_NumJoysticks(); i++)
|
||||
{
|
||||
const char *joyname = SDL_JoystickNameForIndex(i);
|
||||
if ( SDL_IsGameController(i) )
|
||||
if(SDL_IsGameController(i))
|
||||
{
|
||||
const char *controllername = SDL_GameControllerNameForIndex(i);
|
||||
gamecontroller = SDL_GameControllerOpen(i);
|
||||
if (gamecontroller)
|
||||
if(gamecontroller)
|
||||
{
|
||||
Con_Printf("detected controller: %s\n", controllername != NULL ? controllername : "NULL");
|
||||
|
||||
|
@ -269,25 +269,25 @@ void IN_StartupJoystick (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
Con_Warning("joystick missing controller mappings: %s\n", joyname != NULL ? joyname : "NULL" );
|
||||
Con_Warning("joystick missing controller mappings: %s\n", joyname != NULL ? joyname : "NULL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IN_ShutdownJoystick (void)
|
||||
void IN_ShutdownJoystick(void)
|
||||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
}
|
||||
|
||||
void IN_Init (void)
|
||||
void IN_Init(void)
|
||||
{
|
||||
textmode = Key_TextEntry();
|
||||
|
||||
if (textmode)
|
||||
if(textmode)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
SDL_StopTextInput();
|
||||
if (safemode || COM_CheckParm("-nomouse"))
|
||||
if(safemode || COM_CheckParm("-nomouse"))
|
||||
{
|
||||
no_mouse = true;
|
||||
/* discard all mouse events when input is deactivated */
|
||||
|
@ -312,7 +312,7 @@ void IN_Init (void)
|
|||
IN_StartupJoystick();
|
||||
}
|
||||
|
||||
void IN_Shutdown (void)
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
IN_Deactivate(true);
|
||||
IN_ShutdownJoystick();
|
||||
|
@ -382,7 +382,7 @@ static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent)
|
|||
vec_t eased_magnitude;
|
||||
vec_t magnitude = IN_AxisMagnitude(axis);
|
||||
|
||||
if (magnitude == 0)
|
||||
if(magnitude == 0)
|
||||
return result;
|
||||
|
||||
eased_magnitude = powf(magnitude, exponent);
|
||||
|
@ -434,7 +434,8 @@ static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone)
|
|||
joyaxis_t result = {0};
|
||||
vec_t magnitude = IN_AxisMagnitude(axis);
|
||||
|
||||
if ( magnitude > deadzone ) {
|
||||
if(magnitude > deadzone)
|
||||
{
|
||||
const vec_t new_magnitude = q_min(1.0, (magnitude - deadzone) / (1.0 - deadzone));
|
||||
const vec_t scale = new_magnitude / magnitude;
|
||||
result.x = axis.x * scale;
|
||||
|
@ -451,23 +452,38 @@ IN_KeyForControllerButton
|
|||
*/
|
||||
static int32_t IN_KeyForControllerButton(SDL_GameControllerButton button)
|
||||
{
|
||||
switch (button)
|
||||
switch(button)
|
||||
{
|
||||
case SDL_CONTROLLER_BUTTON_A: return K_ABUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_B: return K_BBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_X: return K_XBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_Y: return K_YBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_BACK: return K_TAB;
|
||||
case SDL_CONTROLLER_BUTTON_START: return K_ESCAPE;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSTICK: return K_LTHUMB;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSTICK: return K_RTHUMB;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: return K_LSHOULDER;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: return K_RSHOULDER;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP: return K_UPARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return K_DOWNARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return K_LEFTARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return K_RIGHTARROW;
|
||||
default: return 0;
|
||||
case SDL_CONTROLLER_BUTTON_A:
|
||||
return K_ABUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_B:
|
||||
return K_BBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_X:
|
||||
return K_XBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_Y:
|
||||
return K_YBUTTON;
|
||||
case SDL_CONTROLLER_BUTTON_BACK:
|
||||
return K_TAB;
|
||||
case SDL_CONTROLLER_BUTTON_START:
|
||||
return K_ESCAPE;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
||||
return K_LTHUMB;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
|
||||
return K_RTHUMB;
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
||||
return K_LSHOULDER;
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
||||
return K_RSHOULDER;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
||||
return K_UPARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
||||
return K_DOWNARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
|
||||
return K_LEFTARROW;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||
return K_RIGHTARROW;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,11 +502,11 @@ static void IN_JoyKeyEvent(bool wasdown, bool isdown, int32_t key, double *timer
|
|||
// we can't use `realtime` for key repeats because it is not monotomic
|
||||
const double currenttime = Sys_DoubleTime();
|
||||
|
||||
if (wasdown)
|
||||
if(wasdown)
|
||||
{
|
||||
if (isdown)
|
||||
if(isdown)
|
||||
{
|
||||
if (currenttime >= *timer)
|
||||
if(currenttime >= *timer)
|
||||
{
|
||||
*timer = currenttime + 0.1;
|
||||
Key_Event(key, true);
|
||||
|
@ -504,7 +520,7 @@ static void IN_JoyKeyEvent(bool wasdown, bool isdown, int32_t key, double *timer
|
|||
}
|
||||
else
|
||||
{
|
||||
if (isdown)
|
||||
if(isdown)
|
||||
{
|
||||
*timer = currenttime + 0.5;
|
||||
Key_Event(key, true);
|
||||
|
@ -519,21 +535,21 @@ IN_Commands
|
|||
Emit key events for game controller buttons, including emulated buttons for analog sticks/triggers
|
||||
================
|
||||
*/
|
||||
void IN_Commands (void)
|
||||
void IN_Commands(void)
|
||||
{
|
||||
joyaxisstate_t newaxisstate;
|
||||
int32_t i;
|
||||
const float stickthreshold = 0.9;
|
||||
const float triggerthreshold = joy_deadzone_trigger.value;
|
||||
|
||||
if (!joy_enable.value)
|
||||
if(!joy_enable.value)
|
||||
return;
|
||||
|
||||
if (!joy_active_controller)
|
||||
if(!joy_active_controller)
|
||||
return;
|
||||
|
||||
// emit key events for controller buttons
|
||||
for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++)
|
||||
for(i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++)
|
||||
{
|
||||
bool newstate = SDL_GameControllerGetButton(joy_active_controller, (SDL_GameControllerButton)i);
|
||||
bool oldstate = joy_buttonstate.buttondown[i];
|
||||
|
@ -544,21 +560,21 @@ void IN_Commands (void)
|
|||
IN_JoyKeyEvent(oldstate, newstate, IN_KeyForControllerButton((SDL_GameControllerButton)i), &joy_buttontimer[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++)
|
||||
for(i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++)
|
||||
{
|
||||
newaxisstate.axisvalue[i] = SDL_GameControllerGetAxis(joy_active_controller, (SDL_GameControllerAxis)i) / 32768.0f;
|
||||
}
|
||||
|
||||
// emit emulated arrow keys so the analog sticks can be used in the menu
|
||||
if (key_dest != key_game)
|
||||
if(key_dest != key_game)
|
||||
{
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold, K_LEFTARROW, &joy_emulatedkeytimer[0]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold, K_RIGHTARROW, &joy_emulatedkeytimer[1]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold, K_UPARROW, &joy_emulatedkeytimer[2]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold, K_DOWNARROW, &joy_emulatedkeytimer[3]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] < -stickthreshold,newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] < -stickthreshold, K_LEFTARROW, &joy_emulatedkeytimer[4]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] < -stickthreshold, K_LEFTARROW, &joy_emulatedkeytimer[4]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX] > stickthreshold, K_RIGHTARROW, &joy_emulatedkeytimer[5]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] < -stickthreshold,newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] < -stickthreshold, K_UPARROW, &joy_emulatedkeytimer[6]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] < -stickthreshold, K_UPARROW, &joy_emulatedkeytimer[6]);
|
||||
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY] > stickthreshold, K_DOWNARROW, &joy_emulatedkeytimer[7]);
|
||||
}
|
||||
|
||||
|
@ -574,16 +590,16 @@ void IN_Commands (void)
|
|||
IN_JoyMove
|
||||
================
|
||||
*/
|
||||
void IN_JoyMove (usercmd_t *cmd)
|
||||
void IN_JoyMove(usercmd_t *cmd)
|
||||
{
|
||||
float speed;
|
||||
joyaxis_t moveRaw, moveDeadzone, moveEased;
|
||||
joyaxis_t lookRaw, lookDeadzone, lookEased;
|
||||
|
||||
if (!joy_enable.value)
|
||||
if(!joy_enable.value)
|
||||
return;
|
||||
|
||||
if (!joy_active_controller)
|
||||
if(!joy_active_controller)
|
||||
return;
|
||||
|
||||
moveRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX];
|
||||
|
@ -591,7 +607,7 @@ void IN_JoyMove (usercmd_t *cmd)
|
|||
lookRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX];
|
||||
lookRaw.y = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY];
|
||||
|
||||
if (joy_swapmovelook.value)
|
||||
if(joy_swapmovelook.value)
|
||||
{
|
||||
joyaxis_t temp = moveRaw;
|
||||
moveRaw = lookRaw;
|
||||
|
@ -604,7 +620,7 @@ void IN_JoyMove (usercmd_t *cmd)
|
|||
moveEased = IN_ApplyMoveEasing(moveDeadzone, joy_exponent_move.value);
|
||||
lookEased = IN_ApplyEasing(lookDeadzone, joy_exponent.value);
|
||||
|
||||
if ((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
if((in_speed.state & 1) ^ (cl_alwaysrun.value != 0.0))
|
||||
speed = cl_movespeedkey.value;
|
||||
else
|
||||
speed = 1;
|
||||
|
@ -615,13 +631,13 @@ void IN_JoyMove (usercmd_t *cmd)
|
|||
cl.viewangles[YAW] -= lookEased.x * joy_sensitivity_yaw.value * host_frametime;
|
||||
cl.viewangles[PITCH] += lookEased.y * joy_sensitivity_pitch.value * (joy_invert.value ? -1.0 : 1.0) * host_frametime;
|
||||
|
||||
if (lookEased.x != 0 || lookEased.y != 0)
|
||||
if(lookEased.x != 0 || lookEased.y != 0)
|
||||
V_StopPitchDrift();
|
||||
|
||||
/* johnfitz -- variable pitch clamping */
|
||||
if (cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
if(cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
cl.viewangles[PITCH] = cl_maxpitch.value;
|
||||
if (cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
if(cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
cl.viewangles[PITCH] = cl_minpitch.value;
|
||||
}
|
||||
|
||||
|
@ -635,29 +651,29 @@ void IN_MouseMove(usercmd_t *cmd)
|
|||
total_dx = 0;
|
||||
total_dy = 0;
|
||||
|
||||
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
|
||||
if((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
|
||||
cmd->sidemove += m_side.value * dmx;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw.value * dmx;
|
||||
|
||||
if (in_mlook.state & 1)
|
||||
if(in_mlook.state & 1)
|
||||
{
|
||||
if (dmx || dmy)
|
||||
V_StopPitchDrift ();
|
||||
if(dmx || dmy)
|
||||
V_StopPitchDrift();
|
||||
}
|
||||
|
||||
if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
if((in_mlook.state & 1) && !(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[PITCH] += m_pitch.value * dmy;
|
||||
/* johnfitz -- variable pitch clamping */
|
||||
if (cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
if(cl.viewangles[PITCH] > cl_maxpitch.value)
|
||||
cl.viewangles[PITCH] = cl_maxpitch.value;
|
||||
if (cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
if(cl.viewangles[PITCH] < cl_minpitch.value)
|
||||
cl.viewangles[PITCH] = cl_minpitch.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((in_strafe.state & 1) && noclip_anglehack)
|
||||
if((in_strafe.state & 1) && noclip_anglehack)
|
||||
cmd->upmove -= m_forward.value * dmy;
|
||||
else
|
||||
cmd->forwardmove -= m_forward.value * dmy;
|
||||
|
@ -670,26 +686,26 @@ void IN_Move(usercmd_t *cmd)
|
|||
IN_MouseMove(cmd);
|
||||
}
|
||||
|
||||
void IN_ClearStates (void)
|
||||
void IN_ClearStates(void)
|
||||
{
|
||||
}
|
||||
|
||||
void IN_UpdateInputMode (void)
|
||||
void IN_UpdateInputMode(void)
|
||||
{
|
||||
bool want_textmode = Key_TextEntry();
|
||||
if (textmode != want_textmode)
|
||||
if(textmode != want_textmode)
|
||||
{
|
||||
textmode = want_textmode;
|
||||
if (textmode)
|
||||
if(textmode)
|
||||
{
|
||||
SDL_StartTextInput();
|
||||
if (in_debugkeys.value)
|
||||
if(in_debugkeys.value)
|
||||
Con_Printf("SDL_StartTextInput time: %g\n", Sys_DoubleTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_StopTextInput();
|
||||
if (in_debugkeys.value)
|
||||
if(in_debugkeys.value)
|
||||
Con_Printf("SDL_StopTextInput time: %g\n", Sys_DoubleTime());
|
||||
}
|
||||
}
|
||||
|
@ -697,158 +713,262 @@ void IN_UpdateInputMode (void)
|
|||
|
||||
static inline int32_t IN_SDL2_ScancodeToQuakeKey(SDL_Scancode scancode)
|
||||
{
|
||||
switch (scancode)
|
||||
switch(scancode)
|
||||
{
|
||||
case SDL_SCANCODE_TAB: return K_TAB;
|
||||
case SDL_SCANCODE_RETURN: return K_ENTER;
|
||||
case SDL_SCANCODE_RETURN2: return K_ENTER;
|
||||
case SDL_SCANCODE_ESCAPE: return K_ESCAPE;
|
||||
case SDL_SCANCODE_SPACE: return K_SPACE;
|
||||
case SDL_SCANCODE_TAB:
|
||||
return K_TAB;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
return K_ENTER;
|
||||
case SDL_SCANCODE_RETURN2:
|
||||
return K_ENTER;
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
return K_ESCAPE;
|
||||
case SDL_SCANCODE_SPACE:
|
||||
return K_SPACE;
|
||||
|
||||
case SDL_SCANCODE_A: return 'a';
|
||||
case SDL_SCANCODE_B: return 'b';
|
||||
case SDL_SCANCODE_C: return 'c';
|
||||
case SDL_SCANCODE_D: return 'd';
|
||||
case SDL_SCANCODE_E: return 'e';
|
||||
case SDL_SCANCODE_F: return 'f';
|
||||
case SDL_SCANCODE_G: return 'g';
|
||||
case SDL_SCANCODE_H: return 'h';
|
||||
case SDL_SCANCODE_I: return 'i';
|
||||
case SDL_SCANCODE_J: return 'j';
|
||||
case SDL_SCANCODE_K: return 'k';
|
||||
case SDL_SCANCODE_L: return 'l';
|
||||
case SDL_SCANCODE_M: return 'm';
|
||||
case SDL_SCANCODE_N: return 'n';
|
||||
case SDL_SCANCODE_O: return 'o';
|
||||
case SDL_SCANCODE_P: return 'p';
|
||||
case SDL_SCANCODE_Q: return 'q';
|
||||
case SDL_SCANCODE_R: return 'r';
|
||||
case SDL_SCANCODE_S: return 's';
|
||||
case SDL_SCANCODE_T: return 't';
|
||||
case SDL_SCANCODE_U: return 'u';
|
||||
case SDL_SCANCODE_V: return 'v';
|
||||
case SDL_SCANCODE_W: return 'w';
|
||||
case SDL_SCANCODE_X: return 'x';
|
||||
case SDL_SCANCODE_Y: return 'y';
|
||||
case SDL_SCANCODE_Z: return 'z';
|
||||
case SDL_SCANCODE_A:
|
||||
return 'a';
|
||||
case SDL_SCANCODE_B:
|
||||
return 'b';
|
||||
case SDL_SCANCODE_C:
|
||||
return 'c';
|
||||
case SDL_SCANCODE_D:
|
||||
return 'd';
|
||||
case SDL_SCANCODE_E:
|
||||
return 'e';
|
||||
case SDL_SCANCODE_F:
|
||||
return 'f';
|
||||
case SDL_SCANCODE_G:
|
||||
return 'g';
|
||||
case SDL_SCANCODE_H:
|
||||
return 'h';
|
||||
case SDL_SCANCODE_I:
|
||||
return 'i';
|
||||
case SDL_SCANCODE_J:
|
||||
return 'j';
|
||||
case SDL_SCANCODE_K:
|
||||
return 'k';
|
||||
case SDL_SCANCODE_L:
|
||||
return 'l';
|
||||
case SDL_SCANCODE_M:
|
||||
return 'm';
|
||||
case SDL_SCANCODE_N:
|
||||
return 'n';
|
||||
case SDL_SCANCODE_O:
|
||||
return 'o';
|
||||
case SDL_SCANCODE_P:
|
||||
return 'p';
|
||||
case SDL_SCANCODE_Q:
|
||||
return 'q';
|
||||
case SDL_SCANCODE_R:
|
||||
return 'r';
|
||||
case SDL_SCANCODE_S:
|
||||
return 's';
|
||||
case SDL_SCANCODE_T:
|
||||
return 't';
|
||||
case SDL_SCANCODE_U:
|
||||
return 'u';
|
||||
case SDL_SCANCODE_V:
|
||||
return 'v';
|
||||
case SDL_SCANCODE_W:
|
||||
return 'w';
|
||||
case SDL_SCANCODE_X:
|
||||
return 'x';
|
||||
case SDL_SCANCODE_Y:
|
||||
return 'y';
|
||||
case SDL_SCANCODE_Z:
|
||||
return 'z';
|
||||
|
||||
case SDL_SCANCODE_1: return '1';
|
||||
case SDL_SCANCODE_2: return '2';
|
||||
case SDL_SCANCODE_3: return '3';
|
||||
case SDL_SCANCODE_4: return '4';
|
||||
case SDL_SCANCODE_5: return '5';
|
||||
case SDL_SCANCODE_6: return '6';
|
||||
case SDL_SCANCODE_7: return '7';
|
||||
case SDL_SCANCODE_8: return '8';
|
||||
case SDL_SCANCODE_9: return '9';
|
||||
case SDL_SCANCODE_0: return '0';
|
||||
case SDL_SCANCODE_1:
|
||||
return '1';
|
||||
case SDL_SCANCODE_2:
|
||||
return '2';
|
||||
case SDL_SCANCODE_3:
|
||||
return '3';
|
||||
case SDL_SCANCODE_4:
|
||||
return '4';
|
||||
case SDL_SCANCODE_5:
|
||||
return '5';
|
||||
case SDL_SCANCODE_6:
|
||||
return '6';
|
||||
case SDL_SCANCODE_7:
|
||||
return '7';
|
||||
case SDL_SCANCODE_8:
|
||||
return '8';
|
||||
case SDL_SCANCODE_9:
|
||||
return '9';
|
||||
case SDL_SCANCODE_0:
|
||||
return '0';
|
||||
|
||||
case SDL_SCANCODE_MINUS: return '-';
|
||||
case SDL_SCANCODE_EQUALS: return '=';
|
||||
case SDL_SCANCODE_LEFTBRACKET: return '[';
|
||||
case SDL_SCANCODE_RIGHTBRACKET: return ']';
|
||||
case SDL_SCANCODE_BACKSLASH: return '\\';
|
||||
case SDL_SCANCODE_NONUSHASH: return '#';
|
||||
case SDL_SCANCODE_SEMICOLON: return ';';
|
||||
case SDL_SCANCODE_APOSTROPHE: return '\'';
|
||||
case SDL_SCANCODE_GRAVE: return '`';
|
||||
case SDL_SCANCODE_COMMA: return ',';
|
||||
case SDL_SCANCODE_PERIOD: return '.';
|
||||
case SDL_SCANCODE_SLASH: return '/';
|
||||
case SDL_SCANCODE_NONUSBACKSLASH: return '\\';
|
||||
case SDL_SCANCODE_MINUS:
|
||||
return '-';
|
||||
case SDL_SCANCODE_EQUALS:
|
||||
return '=';
|
||||
case SDL_SCANCODE_LEFTBRACKET:
|
||||
return '[';
|
||||
case SDL_SCANCODE_RIGHTBRACKET:
|
||||
return ']';
|
||||
case SDL_SCANCODE_BACKSLASH:
|
||||
return '\\';
|
||||
case SDL_SCANCODE_NONUSHASH:
|
||||
return '#';
|
||||
case SDL_SCANCODE_SEMICOLON:
|
||||
return ';';
|
||||
case SDL_SCANCODE_APOSTROPHE:
|
||||
return '\'';
|
||||
case SDL_SCANCODE_GRAVE:
|
||||
return '`';
|
||||
case SDL_SCANCODE_COMMA:
|
||||
return ',';
|
||||
case SDL_SCANCODE_PERIOD:
|
||||
return '.';
|
||||
case SDL_SCANCODE_SLASH:
|
||||
return '/';
|
||||
case SDL_SCANCODE_NONUSBACKSLASH:
|
||||
return '\\';
|
||||
|
||||
case SDL_SCANCODE_BACKSPACE: return K_BACKSPACE;
|
||||
case SDL_SCANCODE_UP: return K_UPARROW;
|
||||
case SDL_SCANCODE_DOWN: return K_DOWNARROW;
|
||||
case SDL_SCANCODE_LEFT: return K_LEFTARROW;
|
||||
case SDL_SCANCODE_RIGHT: return K_RIGHTARROW;
|
||||
case SDL_SCANCODE_BACKSPACE:
|
||||
return K_BACKSPACE;
|
||||
case SDL_SCANCODE_UP:
|
||||
return K_UPARROW;
|
||||
case SDL_SCANCODE_DOWN:
|
||||
return K_DOWNARROW;
|
||||
case SDL_SCANCODE_LEFT:
|
||||
return K_LEFTARROW;
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
return K_RIGHTARROW;
|
||||
|
||||
case SDL_SCANCODE_LALT: return K_ALT;
|
||||
case SDL_SCANCODE_RALT: return K_ALT;
|
||||
case SDL_SCANCODE_LCTRL: return K_CTRL;
|
||||
case SDL_SCANCODE_RCTRL: return K_CTRL;
|
||||
case SDL_SCANCODE_LSHIFT: return K_SHIFT;
|
||||
case SDL_SCANCODE_RSHIFT: return K_SHIFT;
|
||||
case SDL_SCANCODE_LALT:
|
||||
return K_ALT;
|
||||
case SDL_SCANCODE_RALT:
|
||||
return K_ALT;
|
||||
case SDL_SCANCODE_LCTRL:
|
||||
return K_CTRL;
|
||||
case SDL_SCANCODE_RCTRL:
|
||||
return K_CTRL;
|
||||
case SDL_SCANCODE_LSHIFT:
|
||||
return K_SHIFT;
|
||||
case SDL_SCANCODE_RSHIFT:
|
||||
return K_SHIFT;
|
||||
|
||||
case SDL_SCANCODE_F1: return K_F1;
|
||||
case SDL_SCANCODE_F2: return K_F2;
|
||||
case SDL_SCANCODE_F3: return K_F3;
|
||||
case SDL_SCANCODE_F4: return K_F4;
|
||||
case SDL_SCANCODE_F5: return K_F5;
|
||||
case SDL_SCANCODE_F6: return K_F6;
|
||||
case SDL_SCANCODE_F7: return K_F7;
|
||||
case SDL_SCANCODE_F8: return K_F8;
|
||||
case SDL_SCANCODE_F9: return K_F9;
|
||||
case SDL_SCANCODE_F10: return K_F10;
|
||||
case SDL_SCANCODE_F11: return K_F11;
|
||||
case SDL_SCANCODE_F12: return K_F12;
|
||||
case SDL_SCANCODE_INSERT: return K_INS;
|
||||
case SDL_SCANCODE_DELETE: return K_DEL;
|
||||
case SDL_SCANCODE_PAGEDOWN: return K_PGDN;
|
||||
case SDL_SCANCODE_PAGEUP: return K_PGUP;
|
||||
case SDL_SCANCODE_HOME: return K_HOME;
|
||||
case SDL_SCANCODE_END: return K_END;
|
||||
case SDL_SCANCODE_F1:
|
||||
return K_F1;
|
||||
case SDL_SCANCODE_F2:
|
||||
return K_F2;
|
||||
case SDL_SCANCODE_F3:
|
||||
return K_F3;
|
||||
case SDL_SCANCODE_F4:
|
||||
return K_F4;
|
||||
case SDL_SCANCODE_F5:
|
||||
return K_F5;
|
||||
case SDL_SCANCODE_F6:
|
||||
return K_F6;
|
||||
case SDL_SCANCODE_F7:
|
||||
return K_F7;
|
||||
case SDL_SCANCODE_F8:
|
||||
return K_F8;
|
||||
case SDL_SCANCODE_F9:
|
||||
return K_F9;
|
||||
case SDL_SCANCODE_F10:
|
||||
return K_F10;
|
||||
case SDL_SCANCODE_F11:
|
||||
return K_F11;
|
||||
case SDL_SCANCODE_F12:
|
||||
return K_F12;
|
||||
case SDL_SCANCODE_INSERT:
|
||||
return K_INS;
|
||||
case SDL_SCANCODE_DELETE:
|
||||
return K_DEL;
|
||||
case SDL_SCANCODE_PAGEDOWN:
|
||||
return K_PGDN;
|
||||
case SDL_SCANCODE_PAGEUP:
|
||||
return K_PGUP;
|
||||
case SDL_SCANCODE_HOME:
|
||||
return K_HOME;
|
||||
case SDL_SCANCODE_END:
|
||||
return K_END;
|
||||
|
||||
case SDL_SCANCODE_NUMLOCKCLEAR: return K_KP_NUMLOCK;
|
||||
case SDL_SCANCODE_KP_DIVIDE: return K_KP_SLASH;
|
||||
case SDL_SCANCODE_KP_MULTIPLY: return K_KP_STAR;
|
||||
case SDL_SCANCODE_KP_MINUS: return K_KP_MINUS;
|
||||
case SDL_SCANCODE_KP_7: return K_KP_HOME;
|
||||
case SDL_SCANCODE_KP_8: return K_KP_UPARROW;
|
||||
case SDL_SCANCODE_KP_9: return K_KP_PGUP;
|
||||
case SDL_SCANCODE_KP_PLUS: return K_KP_PLUS;
|
||||
case SDL_SCANCODE_KP_4: return K_KP_LEFTARROW;
|
||||
case SDL_SCANCODE_KP_5: return K_KP_5;
|
||||
case SDL_SCANCODE_KP_6: return K_KP_RIGHTARROW;
|
||||
case SDL_SCANCODE_KP_1: return K_KP_END;
|
||||
case SDL_SCANCODE_KP_2: return K_KP_DOWNARROW;
|
||||
case SDL_SCANCODE_KP_3: return K_KP_PGDN;
|
||||
case SDL_SCANCODE_KP_ENTER: return K_KP_ENTER;
|
||||
case SDL_SCANCODE_KP_0: return K_KP_INS;
|
||||
case SDL_SCANCODE_KP_PERIOD: return K_KP_DEL;
|
||||
case SDL_SCANCODE_NUMLOCKCLEAR:
|
||||
return K_KP_NUMLOCK;
|
||||
case SDL_SCANCODE_KP_DIVIDE:
|
||||
return K_KP_SLASH;
|
||||
case SDL_SCANCODE_KP_MULTIPLY:
|
||||
return K_KP_STAR;
|
||||
case SDL_SCANCODE_KP_MINUS:
|
||||
return K_KP_MINUS;
|
||||
case SDL_SCANCODE_KP_7:
|
||||
return K_KP_HOME;
|
||||
case SDL_SCANCODE_KP_8:
|
||||
return K_KP_UPARROW;
|
||||
case SDL_SCANCODE_KP_9:
|
||||
return K_KP_PGUP;
|
||||
case SDL_SCANCODE_KP_PLUS:
|
||||
return K_KP_PLUS;
|
||||
case SDL_SCANCODE_KP_4:
|
||||
return K_KP_LEFTARROW;
|
||||
case SDL_SCANCODE_KP_5:
|
||||
return K_KP_5;
|
||||
case SDL_SCANCODE_KP_6:
|
||||
return K_KP_RIGHTARROW;
|
||||
case SDL_SCANCODE_KP_1:
|
||||
return K_KP_END;
|
||||
case SDL_SCANCODE_KP_2:
|
||||
return K_KP_DOWNARROW;
|
||||
case SDL_SCANCODE_KP_3:
|
||||
return K_KP_PGDN;
|
||||
case SDL_SCANCODE_KP_ENTER:
|
||||
return K_KP_ENTER;
|
||||
case SDL_SCANCODE_KP_0:
|
||||
return K_KP_INS;
|
||||
case SDL_SCANCODE_KP_PERIOD:
|
||||
return K_KP_DEL;
|
||||
|
||||
case SDL_SCANCODE_LGUI: return K_COMMAND;
|
||||
case SDL_SCANCODE_RGUI: return K_COMMAND;
|
||||
case SDL_SCANCODE_LGUI:
|
||||
return K_COMMAND;
|
||||
case SDL_SCANCODE_RGUI:
|
||||
return K_COMMAND;
|
||||
|
||||
case SDL_SCANCODE_PAUSE: return K_PAUSE;
|
||||
case SDL_SCANCODE_PAUSE:
|
||||
return K_PAUSE;
|
||||
|
||||
default: return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void IN_DebugTextEvent(SDL_Event *event)
|
||||
{
|
||||
Con_Printf ("SDL_TEXTINPUT '%s' time: %g\n", event->text.text, Sys_DoubleTime());
|
||||
Con_Printf("SDL_TEXTINPUT '%s' time: %g\n", event->text.text, Sys_DoubleTime());
|
||||
}
|
||||
|
||||
static void IN_DebugKeyEvent(SDL_Event *event)
|
||||
{
|
||||
const char *eventtype = (event->key.state == SDL_PRESSED) ? "SDL_KEYDOWN" : "SDL_KEYUP";
|
||||
Con_Printf ("%s scancode: '%s' keycode: '%s' time: %g\n",
|
||||
Con_Printf("%s scancode: '%s' keycode: '%s' time: %g\n",
|
||||
eventtype,
|
||||
SDL_GetScancodeName(event->key.keysym.scancode),
|
||||
SDL_GetKeyName(event->key.keysym.sym),
|
||||
Sys_DoubleTime());
|
||||
}
|
||||
|
||||
void IN_SendKeyEvents (void)
|
||||
void IN_SendKeyEvents(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int32_t key;
|
||||
bool down;
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_WINDOWEVENT:
|
||||
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
if(event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||
S_UnblockSound();
|
||||
else if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
else if(event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
S_BlockSound();
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if (in_debugkeys.value)
|
||||
if(in_debugkeys.value)
|
||||
IN_DebugTextEvent(&event);
|
||||
|
||||
// SDL2: We use SDL_TEXTINPUT for typing in the console / chat.
|
||||
|
@ -856,32 +976,32 @@ void IN_SendKeyEvents (void)
|
|||
// (shift for uppercase, etc.) for us.
|
||||
{
|
||||
uint8_t *ch;
|
||||
for (ch = (uint8_t *)event.text.text; *ch; ch++)
|
||||
if ((*ch & ~0x7F) == 0)
|
||||
Char_Event (*ch);
|
||||
for(ch = (uint8_t *)event.text.text; *ch; ch++)
|
||||
if((*ch & ~0x7F) == 0)
|
||||
Char_Event(*ch);
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
down = (event.key.state == SDL_PRESSED);
|
||||
|
||||
if (in_debugkeys.value)
|
||||
if(in_debugkeys.value)
|
||||
IN_DebugKeyEvent(&event);
|
||||
|
||||
// SDL2: we interpret the keyboard as the US layout, so keybindings
|
||||
// are based on key position, not the label on the key cap.
|
||||
key = IN_SDL2_ScancodeToQuakeKey(event.key.keysym.scancode);
|
||||
|
||||
Key_Event (key, down);
|
||||
Key_Event(key, down);
|
||||
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (event.button.button < 1 ||
|
||||
if(event.button.button < 1 ||
|
||||
event.button.button > sizeof(buttonremap) / sizeof(buttonremap[0]))
|
||||
{
|
||||
Con_Printf ("Ignored event for mouse button %" PRIi32 "\n",
|
||||
Con_Printf("Ignored event for mouse button %" PRIi32 "\n",
|
||||
event.button.button);
|
||||
break;
|
||||
}
|
||||
|
@ -889,12 +1009,12 @@ void IN_SendKeyEvents (void)
|
|||
break;
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
if (event.wheel.y > 0)
|
||||
if(event.wheel.y > 0)
|
||||
{
|
||||
Key_Event(K_MWHEELUP, true);
|
||||
Key_Event(K_MWHEELUP, false);
|
||||
}
|
||||
else if (event.wheel.y < 0)
|
||||
else if(event.wheel.y < 0)
|
||||
{
|
||||
Key_Event(K_MWHEELDOWN, true);
|
||||
Key_Event(K_MWHEELDOWN, false);
|
||||
|
@ -906,10 +1026,10 @@ void IN_SendKeyEvents (void)
|
|||
break;
|
||||
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
if (joy_active_instaceid == -1)
|
||||
if(joy_active_instaceid == -1)
|
||||
{
|
||||
joy_active_controller = SDL_GameControllerOpen(event.cdevice.which);
|
||||
if (joy_active_controller == NULL)
|
||||
if(joy_active_controller == NULL)
|
||||
Con_DPrintf("Couldn't open game controller\n");
|
||||
else
|
||||
{
|
||||
|
@ -922,7 +1042,7 @@ void IN_SendKeyEvents (void)
|
|||
Con_DPrintf("Ignoring SDL_CONTROLLERDEVICEADDED\n");
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
if (joy_active_instaceid != -1 && event.cdevice.which == joy_active_instaceid)
|
||||
if(joy_active_instaceid != -1 && event.cdevice.which == joy_active_instaceid)
|
||||
{
|
||||
SDL_GameControllerClose(joy_active_controller);
|
||||
joy_active_controller = NULL;
|
||||
|
@ -936,8 +1056,8 @@ void IN_SendKeyEvents (void)
|
|||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
CL_Disconnect ();
|
||||
Sys_Quit ();
|
||||
CL_Disconnect();
|
||||
Sys_Quit();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -24,34 +24,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// input.h -- external (non-keyboard) input devices
|
||||
|
||||
void IN_Init (void);
|
||||
void IN_Init(void);
|
||||
|
||||
void IN_Shutdown (void);
|
||||
void IN_Shutdown(void);
|
||||
|
||||
void IN_Commands (void);
|
||||
void IN_Commands(void);
|
||||
// oportunity for devices to stick commands on the script buffer
|
||||
|
||||
// mouse moved by dx and dy pixels
|
||||
void IN_MouseMotion(int32_t dx, int32_t dy);
|
||||
|
||||
|
||||
void IN_SendKeyEvents (void);
|
||||
void IN_SendKeyEvents(void);
|
||||
// used as a callback for Sys_SendKeyEvents() by some drivers
|
||||
|
||||
void IN_UpdateInputMode (void);
|
||||
void IN_UpdateInputMode(void);
|
||||
// do stuff if input mode (text/non-text) changes matter to the keyboard driver
|
||||
|
||||
void IN_Move (usercmd_t *cmd);
|
||||
void IN_Move(usercmd_t *cmd);
|
||||
// add additional movement on top of the keyboard move cmd
|
||||
|
||||
void IN_ClearStates (void);
|
||||
void IN_ClearStates(void);
|
||||
// restores all button and position states to defaults
|
||||
|
||||
// called when the app becomes active
|
||||
void IN_Activate ();
|
||||
void IN_Activate();
|
||||
|
||||
// called when the app becomes inactive
|
||||
void IN_Deactivate (bool free_cursor);
|
||||
void IN_Deactivate(bool free_cursor);
|
||||
|
||||
#endif /* _QUAKE_INPUT_H */
|
||||
|
||||
|
|
451
source/keys.c
451
source/keys.c
File diff suppressed because it is too large
Load Diff
|
@ -173,28 +173,28 @@ extern double key_blinktime;
|
|||
|
||||
extern bool chat_team;
|
||||
|
||||
void Key_Init (void);
|
||||
void Key_ClearStates (void);
|
||||
void Key_UpdateForDest (void);
|
||||
void Key_Init(void);
|
||||
void Key_ClearStates(void);
|
||||
void Key_UpdateForDest(void);
|
||||
|
||||
void Key_BeginInputGrab (void);
|
||||
void Key_EndInputGrab (void);
|
||||
void Key_GetGrabbedInput (int32_t *lastkey, int32_t *lastchar);
|
||||
void Key_BeginInputGrab(void);
|
||||
void Key_EndInputGrab(void);
|
||||
void Key_GetGrabbedInput(int32_t *lastkey, int32_t *lastchar);
|
||||
|
||||
void Key_Event (int32_t key, bool down);
|
||||
void Char_Event (int32_t key);
|
||||
bool Key_TextEntry (void);
|
||||
void Key_Event(int32_t key, bool down);
|
||||
void Char_Event(int32_t key);
|
||||
bool Key_TextEntry(void);
|
||||
|
||||
void Key_SetBinding (int32_t keynum, const char *binding);
|
||||
const char *Key_KeynumToString (int32_t keynum);
|
||||
void Key_WriteBindings (FILE *f);
|
||||
void Key_SetBinding(int32_t keynum, const char *binding);
|
||||
const char *Key_KeynumToString(int32_t keynum);
|
||||
void Key_WriteBindings(FILE *f);
|
||||
|
||||
void Key_EndChat (void);
|
||||
const char *Key_GetChatBuffer (void);
|
||||
int32_t Key_GetChatMsgLen (void);
|
||||
void Key_EndChat(void);
|
||||
const char *Key_GetChatBuffer(void);
|
||||
int32_t Key_GetChatMsgLen(void);
|
||||
|
||||
void History_Init (void);
|
||||
void History_Shutdown (void);
|
||||
void History_Init(void);
|
||||
void History_Shutdown(void);
|
||||
|
||||
#endif /* _QUAKE_KEYS_H */
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static const Uint8 bmp_bytes[] =
|
|||
#include "qs_bmp.h"
|
||||
};
|
||||
|
||||
void PL_SetWindowIcon (void)
|
||||
void PL_SetWindowIcon(void)
|
||||
{
|
||||
SDL_RWops *rwop;
|
||||
SDL_Surface *icon;
|
||||
|
@ -37,10 +37,10 @@ void PL_SetWindowIcon (void)
|
|||
|
||||
/* SDL_RWFromConstMem() requires SDL >= 1.2.7 */
|
||||
rwop = SDL_RWFromConstMem(bmp_bytes, sizeof(bmp_bytes));
|
||||
if (rwop == NULL)
|
||||
if(rwop == NULL)
|
||||
return;
|
||||
icon = SDL_LoadBMP_RW(rwop, 1);
|
||||
if (icon == NULL)
|
||||
if(icon == NULL)
|
||||
return;
|
||||
/* make pure magenta (#ff00ff) tranparent */
|
||||
colorkey = SDL_MapRGB(icon->format, 255, 0, 255);
|
||||
|
@ -49,17 +49,17 @@ void PL_SetWindowIcon (void)
|
|||
SDL_FreeSurface(icon);
|
||||
}
|
||||
|
||||
void PL_VID_Shutdown (void)
|
||||
void PL_VID_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
#define MAX_CLIPBOARDTXT MAXCMDLINE /* 256 */
|
||||
char *PL_GetClipboardData (void)
|
||||
char *PL_GetClipboardData(void)
|
||||
{
|
||||
char *data = NULL;
|
||||
char *cliptext = SDL_GetClipboardText();
|
||||
|
||||
if (cliptext != NULL)
|
||||
if(cliptext != NULL)
|
||||
{
|
||||
size_t size = strlen(cliptext) + 1;
|
||||
/* this is intended for simple small text copies
|
||||
|
@ -68,13 +68,13 @@ char *PL_GetClipboardData (void)
|
|||
* failures and all other not-oh-so-fun stuff. */
|
||||
size = q_min(MAX_CLIPBOARDTXT, size);
|
||||
data = (char *) Z_Malloc(size);
|
||||
q_strlcpy (data, cliptext, size);
|
||||
q_strlcpy(data, cliptext, size);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void PL_ErrorDialog (const char *errorMsg)
|
||||
void PL_ErrorDialog(const char *errorMsg)
|
||||
{
|
||||
(void)errorMsg;
|
||||
}
|
||||
|
|
381
source/lodepng.c
381
source/lodepng.c
|
@ -329,7 +329,7 @@ static void lodepng_set32bitInt(uint8_t* buffer, unsigned value)
|
|||
buffer[0] = (uint8_t)((value >> 24) & 0xff);
|
||||
buffer[1] = (uint8_t)((value >> 16) & 0xff);
|
||||
buffer[2] = (uint8_t)((value >> 8) & 0xff);
|
||||
buffer[3] = (uint8_t)((value ) & 0xff);
|
||||
buffer[3] = (uint8_t)((value) & 0xff);
|
||||
}
|
||||
#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/
|
||||
|
||||
|
@ -380,14 +380,14 @@ static unsigned lodepng_buffer_file(uint8_t* out, size_t size, const char* filen
|
|||
readsize = fread(out, 1, size, file);
|
||||
fclose(file);
|
||||
|
||||
if (readsize != size) return 78;
|
||||
if(readsize != size) return 78;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned lodepng_load_file(uint8_t** out, size_t* outsize, const char* filename)
|
||||
{
|
||||
long size = lodepng_filesize(filename);
|
||||
if (size < 0) return 78;
|
||||
if(size < 0) return 78;
|
||||
*outsize = (size_t)size;
|
||||
|
||||
*out = (uint8_t*)lodepng_malloc((size_t)size);
|
||||
|
@ -400,9 +400,9 @@ unsigned lodepng_load_file(uint8_t** out, size_t* outsize, const char* filename)
|
|||
unsigned lodepng_save_file(const uint8_t* buffer, size_t buffersize, const char* filename)
|
||||
{
|
||||
FILE* file;
|
||||
file = fopen(filename, "wb" );
|
||||
file = fopen(filename, "wb");
|
||||
if(!file) return 79;
|
||||
fwrite(buffer , 1 , buffersize, file);
|
||||
fwrite(buffer, 1, buffersize, file);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
@ -479,22 +479,26 @@ static unsigned readBitsFromStream(size_t* bitpointer, const uint8_t* bitstream,
|
|||
/*the base lengths represented by codes 257-285*/
|
||||
static const unsigned LENGTHBASE[29]
|
||||
= {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
|
||||
67, 83, 99, 115, 131, 163, 195, 227, 258};
|
||||
67, 83, 99, 115, 131, 163, 195, 227, 258
|
||||
};
|
||||
|
||||
/*the extra bits used by codes 257-285 (added to base length)*/
|
||||
static const unsigned LENGTHEXTRA[29]
|
||||
= {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 5, 5, 5, 5, 0};
|
||||
4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
/*the base backwards distances (the bits of distance codes appear after length codes and use their own huffman tree)*/
|
||||
static const unsigned DISTANCEBASE[30]
|
||||
= {1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
|
||||
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
|
||||
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
/*the extra bits of backwards distances (added to base)*/
|
||||
static const unsigned DISTANCEEXTRA[30]
|
||||
= {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
|
||||
8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
|
||||
8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
||||
};
|
||||
|
||||
/*the order in which "code length alphabet code lengths" are stored, out of this
|
||||
the huffman tree of the dynamic huffman tree lengths is generated*/
|
||||
|
@ -1193,12 +1197,15 @@ static unsigned inflateHuffmanBlock(ucvector* out, const uint8_t* in, size_t* bp
|
|||
backward = start - distance;
|
||||
|
||||
if(!ucvector_resize(out, (*pos) + length)) ERROR_BREAK(83 /*alloc fail*/);
|
||||
if (distance < length) {
|
||||
if(distance < length)
|
||||
{
|
||||
for(forward = 0; forward < length; ++forward)
|
||||
{
|
||||
out->data[(*pos)++] = out->data[backward++];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(out->data + *pos, out->data + backward, length);
|
||||
*pos += length;
|
||||
}
|
||||
|
@ -1233,8 +1240,10 @@ static unsigned inflateNoCompression(ucvector* out, const uint8_t* in, size_t* b
|
|||
|
||||
/*read LEN (2 bytes) and NLEN (2 bytes)*/
|
||||
if(p + 4 >= inlength) return 52; /*error, bit pointer will jump past memory*/
|
||||
LEN = in[p] + 256u * in[p + 1]; p += 2;
|
||||
NLEN = in[p] + 256u * in[p + 1]; p += 2;
|
||||
LEN = in[p] + 256u * in[p + 1];
|
||||
p += 2;
|
||||
NLEN = in[p] + 256u * in[p + 1];
|
||||
p += 2;
|
||||
|
||||
/*check if 16-bit NLEN is really the one's complement of LEN*/
|
||||
if(LEN + NLEN != 65535) return 21; /*error: NLEN is not one's complement of LEN*/
|
||||
|
@ -1331,9 +1340,10 @@ static size_t searchCodeIndex(const unsigned* array, size_t array_size, size_t v
|
|||
size_t left = 1;
|
||||
size_t right = array_size - 1;
|
||||
|
||||
while(left <= right) {
|
||||
while(left <= right)
|
||||
{
|
||||
size_t mid = (left + right) >> 1;
|
||||
if (array[mid] >= value) right = mid - 1;
|
||||
if(array[mid] >= value) right = mid - 1;
|
||||
else left = mid + 1;
|
||||
}
|
||||
if(left >= array_size || array[left] > value) left--;
|
||||
|
@ -1389,7 +1399,7 @@ static unsigned hash_init(Hash* hash, unsigned windowsize)
|
|||
hash->headz = (int32_t*)lodepng_malloc(sizeof(int32_t) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
|
||||
hash->chainz = (uint16_t*)lodepng_malloc(sizeof(uint16_t) * windowsize);
|
||||
|
||||
if(!hash->head || !hash->chain || !hash->val || !hash->headz|| !hash->chainz || !hash->zeros)
|
||||
if(!hash->head || !hash->chain || !hash->val || !hash->headz || !hash->chainz || !hash->zeros)
|
||||
{
|
||||
return 83; /*alloc fail*/
|
||||
}
|
||||
|
@ -1430,7 +1440,9 @@ static unsigned getHash(const uint8_t* data, size_t size, size_t pos)
|
|||
result ^= (unsigned)(data[pos + 0] << 0u);
|
||||
result ^= (unsigned)(data[pos + 1] << 4u);
|
||||
result ^= (unsigned)(data[pos + 2] << 8u);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t amount, i;
|
||||
if(pos >= size) return 0;
|
||||
amount = size - pos;
|
||||
|
@ -1816,8 +1828,10 @@ static unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash,
|
|||
error = HuffmanTree_makeFromFrequencies(&tree_d, frequencies_d.data, 2, frequencies_d.size, 15);
|
||||
if(error) break;
|
||||
|
||||
numcodes_ll = tree_ll.numcodes; if(numcodes_ll > 286) numcodes_ll = 286;
|
||||
numcodes_d = tree_d.numcodes; if(numcodes_d > 30) numcodes_d = 30;
|
||||
numcodes_ll = tree_ll.numcodes;
|
||||
if(numcodes_ll > 286) numcodes_ll = 286;
|
||||
numcodes_d = tree_d.numcodes;
|
||||
if(numcodes_d > 30) numcodes_d = 30;
|
||||
/*store the code lengths of both generated trees in bitlen_lld*/
|
||||
for(i = 0; i != numcodes_ll; ++i) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_ll, (unsigned)i));
|
||||
for(i = 0; i != numcodes_d; ++i) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_d, (unsigned)i));
|
||||
|
@ -2320,7 +2334,8 @@ const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0,
|
|||
|
||||
#ifndef LODEPNG_NO_COMPILE_CRC
|
||||
/* CRC polynomial: 0xedb88320 */
|
||||
static unsigned lodepng_crc32_table[256] = {
|
||||
static unsigned lodepng_crc32_table[256] =
|
||||
{
|
||||
0u, 1996959894u, 3993919788u, 2567524794u, 124634137u, 1886057615u, 3915621685u, 2657392035u,
|
||||
249268274u, 2044508324u, 3772115230u, 2547177864u, 162941995u, 2125561021u, 3887607047u, 2428444049u,
|
||||
498536548u, 1789927666u, 4089016648u, 2227061214u, 450548861u, 1843258603u, 4107580753u, 2211677639u,
|
||||
|
@ -2549,12 +2564,23 @@ static unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) /*bd
|
|||
{
|
||||
switch(colortype)
|
||||
{
|
||||
case 0: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break; /*grey*/
|
||||
case 2: if(!( bd == 8 || bd == 16)) return 37; break; /*RGB*/
|
||||
case 3: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 )) return 37; break; /*palette*/
|
||||
case 4: if(!( bd == 8 || bd == 16)) return 37; break; /*grey + alpha*/
|
||||
case 6: if(!( bd == 8 || bd == 16)) return 37; break; /*RGBA*/
|
||||
default: return 31;
|
||||
case 0:
|
||||
if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37;
|
||||
break; /*grey*/
|
||||
case 2:
|
||||
if(!(bd == 8 || bd == 16)) return 37;
|
||||
break; /*RGB*/
|
||||
case 3:
|
||||
if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8)) return 37;
|
||||
break; /*palette*/
|
||||
case 4:
|
||||
if(!(bd == 8 || bd == 16)) return 37;
|
||||
break; /*grey + alpha*/
|
||||
case 6:
|
||||
if(!(bd == 8 || bd == 16)) return 37;
|
||||
break; /*RGBA*/
|
||||
default:
|
||||
return 31;
|
||||
}
|
||||
return 0; /*allowed color type / bits combination*/
|
||||
}
|
||||
|
@ -2563,11 +2589,16 @@ static unsigned getNumColorChannels(LodePNGColorType colortype)
|
|||
{
|
||||
switch(colortype)
|
||||
{
|
||||
case 0: return 1; /*grey*/
|
||||
case 2: return 3; /*RGB*/
|
||||
case 3: return 1; /*palette*/
|
||||
case 4: return 2; /*grey + alpha*/
|
||||
case 6: return 4; /*RGBA*/
|
||||
case 0:
|
||||
return 1; /*grey*/
|
||||
case 2:
|
||||
return 3; /*RGB*/
|
||||
case 3:
|
||||
return 1; /*palette*/
|
||||
case 4:
|
||||
return 2; /*grey + alpha*/
|
||||
case 6:
|
||||
return 4; /*RGBA*/
|
||||
}
|
||||
return 0; /*unexisting color type*/
|
||||
}
|
||||
|
@ -3191,7 +3222,9 @@ static void getPixelColorRGBA8(uint8_t* r, uint8_t* g,
|
|||
{
|
||||
if(mode->bitdepth == 8)
|
||||
{
|
||||
*r = in[i * 3 + 0]; *g = in[i * 3 + 1]; *b = in[i * 3 + 2];
|
||||
*r = in[i * 3 + 0];
|
||||
*g = in[i * 3 + 1];
|
||||
*b = in[i * 3 + 2];
|
||||
if(mode->key_defined && *r == mode->key_r && *g == mode->key_g && *b == mode->key_b) *a = 0;
|
||||
else *a = 255;
|
||||
}
|
||||
|
@ -3314,7 +3347,7 @@ static void getPixelColorsRGBA8(uint8_t* buffer, size_t numpixels,
|
|||
buffer[1] = in[i * 3 + 1];
|
||||
buffer[2] = in[i * 3 + 2];
|
||||
if(has_alpha) buffer[3] = mode->key_defined && buffer[0] == mode->key_r
|
||||
&& buffer[1]== mode->key_g && buffer[2] == mode->key_b ? 0 : 255;
|
||||
&& buffer[1] == mode->key_g && buffer[2] == mode->key_b ? 0 : 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3467,7 +3500,7 @@ unsigned lodepng_convert(uint8_t* out, const uint8_t* in,
|
|||
/*if the input was also palette with same bitdepth, then the color types are also
|
||||
equal, so copy literally. This to preserve the exact indices that were in the PNG
|
||||
even in case there are duplicate colors in the palette.*/
|
||||
if (mode_in->colortype == LCT_PALETTE && mode_in->bitdepth == mode_out->bitdepth)
|
||||
if(mode_in->colortype == LCT_PALETTE && mode_in->bitdepth == mode_out->bitdepth)
|
||||
{
|
||||
size_t numbytes = lodepng_get_raw_size(w, h, mode_in);
|
||||
for(i = 0; i != numbytes; ++i) out[i] = in[i];
|
||||
|
@ -3507,7 +3540,7 @@ unsigned lodepng_convert(uint8_t* out, const uint8_t* in,
|
|||
{
|
||||
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
|
||||
error = rgba8ToPixel(out, i, mode_out, &tree, r, g, b, a);
|
||||
if (error) break;
|
||||
if(error) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4026,7 +4059,8 @@ static unsigned unfilterScanline(uint8_t* recon, const uint8_t* scanline, const
|
|||
}
|
||||
}
|
||||
break;
|
||||
default: return 36; /*error: unexisting filter type given*/
|
||||
default:
|
||||
return 36; /*error: unexisting filter type given*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -4178,7 +4212,8 @@ static unsigned postProcessScanlines(uint8_t* out, uint8_t* in,
|
|||
}
|
||||
else /*interlace_method is 1 (Adam7)*/
|
||||
{
|
||||
unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];
|
||||
unsigned passw[7], passh[7];
|
||||
size_t filter_passstart[8], padded_passstart[8], passstart[8];
|
||||
unsigned i;
|
||||
|
||||
Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
|
||||
|
@ -4716,7 +4751,7 @@ static void decodeGeneric(uint8_t** out, unsigned* w, unsigned* h,
|
|||
}
|
||||
if(!state->error)
|
||||
{
|
||||
for(i = 0; i < outsize; i++) (*out)[i] = 0;
|
||||
for(i = 0; i < outsize; i++)(*out)[i] = 0;
|
||||
state->error = postProcessScanlines(*out, scanlines.data, *w, *h, &state->info_png);
|
||||
}
|
||||
ucvector_cleanup(&scanlines);
|
||||
|
@ -4856,8 +4891,10 @@ void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source)
|
|||
*dest = *source;
|
||||
lodepng_color_mode_init(&dest->info_raw);
|
||||
lodepng_info_init(&dest->info_png);
|
||||
dest->error = lodepng_color_mode_copy(&dest->info_raw, &source->info_raw); if(dest->error) return;
|
||||
dest->error = lodepng_info_copy(&dest->info_png, &source->info_png); if(dest->error) return;
|
||||
dest->error = lodepng_color_mode_copy(&dest->info_raw, &source->info_raw);
|
||||
if(dest->error) return;
|
||||
dest->error = lodepng_info_copy(&dest->info_png, &source->info_png);
|
||||
if(dest->error) return;
|
||||
}
|
||||
|
||||
#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */
|
||||
|
@ -5197,7 +5234,8 @@ static void filterScanline(uint8_t* out, const uint8_t* scanline, const uint8_t*
|
|||
for(i = bytewidth; i < length; ++i) out[i] = (scanline[i] - scanline[i - bytewidth]);
|
||||
}
|
||||
break;
|
||||
default: return; /*unexisting filter type given*/
|
||||
default:
|
||||
return; /*unexisting filter type given*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5205,8 +5243,16 @@ static void filterScanline(uint8_t* out, const uint8_t* scanline, const uint8_t*
|
|||
static float flog2(float f)
|
||||
{
|
||||
float result = 0;
|
||||
while(f > 32) { result += 4; f /= 16; }
|
||||
while(f > 2) { ++result; f /= 2; }
|
||||
while(f > 32)
|
||||
{
|
||||
result += 4;
|
||||
f /= 16;
|
||||
}
|
||||
while(f > 2)
|
||||
{
|
||||
++result;
|
||||
f /= 2;
|
||||
}
|
||||
return result + 1.442695f * (f * f * f / 3 - 3 * f * f / 2 + 3 * f - 1.83333f);
|
||||
}
|
||||
|
||||
|
@ -5616,7 +5662,9 @@ static unsigned getPaletteTranslucency(const uint8_t* palette, size_t palettesiz
|
|||
{
|
||||
if(!key && palette[4 * i + 3] == 0)
|
||||
{
|
||||
r = palette[4 * i + 0]; g = palette[4 * i + 1]; b = palette[4 * i + 2];
|
||||
r = palette[4 * i + 0];
|
||||
g = palette[4 * i + 1];
|
||||
b = palette[4 * i + 2];
|
||||
key = 1;
|
||||
i = (size_t)(-1); /*restart from beginning, to detect earlier opaque colors with key's value*/
|
||||
}
|
||||
|
@ -5681,7 +5729,7 @@ unsigned lodepng_encode(uint8_t** out, size_t* outsize,
|
|||
{
|
||||
state->error = lodepng_auto_choose_color(&info.color, image, w, h, &state->info_raw);
|
||||
}
|
||||
if (!state->error)
|
||||
if(!state->error)
|
||||
{
|
||||
if(!lodepng_color_mode_equal(&state->info_raw, &info.color))
|
||||
{
|
||||
|
@ -5915,99 +5963,180 @@ const char* lodepng_error_text(unsigned code)
|
|||
{
|
||||
switch(code)
|
||||
{
|
||||
case 0: return "no error, everything went ok";
|
||||
case 1: return "nothing done yet"; /*the Encoder/Decoder has done nothing yet, error checking makes no sense yet*/
|
||||
case 10: return "end of input memory reached without huffman end code"; /*while huffman decoding*/
|
||||
case 11: return "error in code tree made it jump outside of huffman tree"; /*while huffman decoding*/
|
||||
case 13: return "problem while processing dynamic deflate block";
|
||||
case 14: return "problem while processing dynamic deflate block";
|
||||
case 15: return "problem while processing dynamic deflate block";
|
||||
case 16: return "unexisting code while processing dynamic deflate block";
|
||||
case 17: return "end of out buffer memory reached while inflating";
|
||||
case 18: return "invalid distance code while inflating";
|
||||
case 19: return "end of out buffer memory reached while inflating";
|
||||
case 20: return "invalid deflate block BTYPE encountered while decoding";
|
||||
case 21: return "NLEN is not ones complement of LEN in a deflate block";
|
||||
case 0:
|
||||
return "no error, everything went ok";
|
||||
case 1:
|
||||
return "nothing done yet"; /*the Encoder/Decoder has done nothing yet, error checking makes no sense yet*/
|
||||
case 10:
|
||||
return "end of input memory reached without huffman end code"; /*while huffman decoding*/
|
||||
case 11:
|
||||
return "error in code tree made it jump outside of huffman tree"; /*while huffman decoding*/
|
||||
case 13:
|
||||
return "problem while processing dynamic deflate block";
|
||||
case 14:
|
||||
return "problem while processing dynamic deflate block";
|
||||
case 15:
|
||||
return "problem while processing dynamic deflate block";
|
||||
case 16:
|
||||
return "unexisting code while processing dynamic deflate block";
|
||||
case 17:
|
||||
return "end of out buffer memory reached while inflating";
|
||||
case 18:
|
||||
return "invalid distance code while inflating";
|
||||
case 19:
|
||||
return "end of out buffer memory reached while inflating";
|
||||
case 20:
|
||||
return "invalid deflate block BTYPE encountered while decoding";
|
||||
case 21:
|
||||
return "NLEN is not ones complement of LEN in a deflate block";
|
||||
/*end of out buffer memory reached while inflating:
|
||||
This can happen if the inflated deflate data is longer than the amount of bytes required to fill up
|
||||
all the pixels of the image, given the color depth and image dimensions. Something that doesn't
|
||||
happen in a normal, well encoded, PNG image.*/
|
||||
case 22: return "end of out buffer memory reached while inflating";
|
||||
case 23: return "end of in buffer memory reached while inflating";
|
||||
case 24: return "invalid FCHECK in zlib header";
|
||||
case 25: return "invalid compression method in zlib header";
|
||||
case 26: return "FDICT encountered in zlib header while it's not used for PNG";
|
||||
case 27: return "PNG file is smaller than a PNG header";
|
||||
case 22:
|
||||
return "end of out buffer memory reached while inflating";
|
||||
case 23:
|
||||
return "end of in buffer memory reached while inflating";
|
||||
case 24:
|
||||
return "invalid FCHECK in zlib header";
|
||||
case 25:
|
||||
return "invalid compression method in zlib header";
|
||||
case 26:
|
||||
return "FDICT encountered in zlib header while it's not used for PNG";
|
||||
case 27:
|
||||
return "PNG file is smaller than a PNG header";
|
||||
/*Checks the magic file header, the first 8 bytes of the PNG file*/
|
||||
case 28: return "incorrect PNG signature, it's no PNG or corrupted";
|
||||
case 29: return "first chunk is not the header chunk";
|
||||
case 30: return "chunk length too large, chunk broken off at end of file";
|
||||
case 31: return "illegal PNG color type or bpp";
|
||||
case 32: return "illegal PNG compression method";
|
||||
case 33: return "illegal PNG filter method";
|
||||
case 34: return "illegal PNG interlace method";
|
||||
case 35: return "chunk length of a chunk is too large or the chunk too small";
|
||||
case 36: return "illegal PNG filter type encountered";
|
||||
case 37: return "illegal bit depth for this color type given";
|
||||
case 38: return "the palette is too big"; /*more than 256 colors*/
|
||||
case 39: return "more palette alpha values given in tRNS chunk than there are colors in the palette";
|
||||
case 40: return "tRNS chunk has wrong size for greyscale image";
|
||||
case 41: return "tRNS chunk has wrong size for RGB image";
|
||||
case 42: return "tRNS chunk appeared while it was not allowed for this color type";
|
||||
case 43: return "bKGD chunk has wrong size for palette image";
|
||||
case 44: return "bKGD chunk has wrong size for greyscale image";
|
||||
case 45: return "bKGD chunk has wrong size for RGB image";
|
||||
case 48: return "empty input buffer given to decoder. Maybe caused by non-existing file?";
|
||||
case 49: return "jumped past memory while generating dynamic huffman tree";
|
||||
case 50: return "jumped past memory while generating dynamic huffman tree";
|
||||
case 51: return "jumped past memory while inflating huffman block";
|
||||
case 52: return "jumped past memory while inflating";
|
||||
case 53: return "size of zlib data too small";
|
||||
case 54: return "repeat symbol in tree while there was no value symbol yet";
|
||||
case 28:
|
||||
return "incorrect PNG signature, it's no PNG or corrupted";
|
||||
case 29:
|
||||
return "first chunk is not the header chunk";
|
||||
case 30:
|
||||
return "chunk length too large, chunk broken off at end of file";
|
||||
case 31:
|
||||
return "illegal PNG color type or bpp";
|
||||
case 32:
|
||||
return "illegal PNG compression method";
|
||||
case 33:
|
||||
return "illegal PNG filter method";
|
||||
case 34:
|
||||
return "illegal PNG interlace method";
|
||||
case 35:
|
||||
return "chunk length of a chunk is too large or the chunk too small";
|
||||
case 36:
|
||||
return "illegal PNG filter type encountered";
|
||||
case 37:
|
||||
return "illegal bit depth for this color type given";
|
||||
case 38:
|
||||
return "the palette is too big"; /*more than 256 colors*/
|
||||
case 39:
|
||||
return "more palette alpha values given in tRNS chunk than there are colors in the palette";
|
||||
case 40:
|
||||
return "tRNS chunk has wrong size for greyscale image";
|
||||
case 41:
|
||||
return "tRNS chunk has wrong size for RGB image";
|
||||
case 42:
|
||||
return "tRNS chunk appeared while it was not allowed for this color type";
|
||||
case 43:
|
||||
return "bKGD chunk has wrong size for palette image";
|
||||
case 44:
|
||||
return "bKGD chunk has wrong size for greyscale image";
|
||||
case 45:
|
||||
return "bKGD chunk has wrong size for RGB image";
|
||||
case 48:
|
||||
return "empty input buffer given to decoder. Maybe caused by non-existing file?";
|
||||
case 49:
|
||||
return "jumped past memory while generating dynamic huffman tree";
|
||||
case 50:
|
||||
return "jumped past memory while generating dynamic huffman tree";
|
||||
case 51:
|
||||
return "jumped past memory while inflating huffman block";
|
||||
case 52:
|
||||
return "jumped past memory while inflating";
|
||||
case 53:
|
||||
return "size of zlib data too small";
|
||||
case 54:
|
||||
return "repeat symbol in tree while there was no value symbol yet";
|
||||
/*jumped past tree while generating huffman tree, this could be when the
|
||||
tree will have more leaves than symbols after generating it out of the
|
||||
given lenghts. They call this an oversubscribed dynamic bit lengths tree in zlib.*/
|
||||
case 55: return "jumped past tree while generating huffman tree";
|
||||
case 56: return "given output image colortype or bitdepth not supported for color conversion";
|
||||
case 57: return "invalid CRC encountered (checking CRC can be disabled)";
|
||||
case 58: return "invalid ADLER32 encountered (checking ADLER32 can be disabled)";
|
||||
case 59: return "requested color conversion not supported";
|
||||
case 60: return "invalid window size given in the settings of the encoder (must be 0-32768)";
|
||||
case 61: return "invalid BTYPE given in the settings of the encoder (only 0, 1 and 2 are allowed)";
|
||||
case 55:
|
||||
return "jumped past tree while generating huffman tree";
|
||||
case 56:
|
||||
return "given output image colortype or bitdepth not supported for color conversion";
|
||||
case 57:
|
||||
return "invalid CRC encountered (checking CRC can be disabled)";
|
||||
case 58:
|
||||
return "invalid ADLER32 encountered (checking ADLER32 can be disabled)";
|
||||
case 59:
|
||||
return "requested color conversion not supported";
|
||||
case 60:
|
||||
return "invalid window size given in the settings of the encoder (must be 0-32768)";
|
||||
case 61:
|
||||
return "invalid BTYPE given in the settings of the encoder (only 0, 1 and 2 are allowed)";
|
||||
/*LodePNG leaves the choice of RGB to greyscale conversion formula to the user.*/
|
||||
case 62: return "conversion from color to greyscale not supported";
|
||||
case 63: return "length of a chunk too long, max allowed for PNG is 2147483647 bytes per chunk"; /*(2^31-1)*/
|
||||
case 62:
|
||||
return "conversion from color to greyscale not supported";
|
||||
case 63:
|
||||
return "length of a chunk too long, max allowed for PNG is 2147483647 bytes per chunk"; /*(2^31-1)*/
|
||||
/*this would result in the inability of a deflated block to ever contain an end code. It must be at least 1.*/
|
||||
case 64: return "the length of the END symbol 256 in the Huffman tree is 0";
|
||||
case 66: return "the length of a text chunk keyword given to the encoder is longer than the maximum of 79 bytes";
|
||||
case 67: return "the length of a text chunk keyword given to the encoder is smaller than the minimum of 1 byte";
|
||||
case 68: return "tried to encode a PLTE chunk with a palette that has less than 1 or more than 256 colors";
|
||||
case 69: return "unknown chunk type with 'critical' flag encountered by the decoder";
|
||||
case 71: return "unexisting interlace mode given to encoder (must be 0 or 1)";
|
||||
case 72: return "while decoding, unexisting compression method encountering in zTXt or iTXt chunk (it must be 0)";
|
||||
case 73: return "invalid tIME chunk size";
|
||||
case 74: return "invalid pHYs chunk size";
|
||||
case 64:
|
||||
return "the length of the END symbol 256 in the Huffman tree is 0";
|
||||
case 66:
|
||||
return "the length of a text chunk keyword given to the encoder is longer than the maximum of 79 bytes";
|
||||
case 67:
|
||||
return "the length of a text chunk keyword given to the encoder is smaller than the minimum of 1 byte";
|
||||
case 68:
|
||||
return "tried to encode a PLTE chunk with a palette that has less than 1 or more than 256 colors";
|
||||
case 69:
|
||||
return "unknown chunk type with 'critical' flag encountered by the decoder";
|
||||
case 71:
|
||||
return "unexisting interlace mode given to encoder (must be 0 or 1)";
|
||||
case 72:
|
||||
return "while decoding, unexisting compression method encountering in zTXt or iTXt chunk (it must be 0)";
|
||||
case 73:
|
||||
return "invalid tIME chunk size";
|
||||
case 74:
|
||||
return "invalid pHYs chunk size";
|
||||
/*length could be wrong, or data chopped off*/
|
||||
case 75: return "no null termination char found while decoding text chunk";
|
||||
case 76: return "iTXt chunk too short to contain required bytes";
|
||||
case 77: return "integer overflow in buffer size";
|
||||
case 78: return "failed to open file for reading"; /*file doesn't exist or couldn't be opened for reading*/
|
||||
case 79: return "failed to open file for writing";
|
||||
case 80: return "tried creating a tree of 0 symbols";
|
||||
case 81: return "lazy matching at pos 0 is impossible";
|
||||
case 82: return "color conversion to palette requested while a color isn't in palette";
|
||||
case 83: return "memory allocation failed";
|
||||
case 84: return "given image too small to contain all pixels to be encoded";
|
||||
case 86: return "impossible offset in lz77 encoding (internal bug)";
|
||||
case 87: return "must provide custom zlib function pointer if LODEPNG_COMPILE_ZLIB is not defined";
|
||||
case 88: return "invalid filter strategy given for LodePNGEncoderSettings.filter_strategy";
|
||||
case 89: return "text chunk keyword too short or long: must have size 1-79";
|
||||
case 75:
|
||||
return "no null termination char found while decoding text chunk";
|
||||
case 76:
|
||||
return "iTXt chunk too short to contain required bytes";
|
||||
case 77:
|
||||
return "integer overflow in buffer size";
|
||||
case 78:
|
||||
return "failed to open file for reading"; /*file doesn't exist or couldn't be opened for reading*/
|
||||
case 79:
|
||||
return "failed to open file for writing";
|
||||
case 80:
|
||||
return "tried creating a tree of 0 symbols";
|
||||
case 81:
|
||||
return "lazy matching at pos 0 is impossible";
|
||||
case 82:
|
||||
return "color conversion to palette requested while a color isn't in palette";
|
||||
case 83:
|
||||
return "memory allocation failed";
|
||||
case 84:
|
||||
return "given image too small to contain all pixels to be encoded";
|
||||
case 86:
|
||||
return "impossible offset in lz77 encoding (internal bug)";
|
||||
case 87:
|
||||
return "must provide custom zlib function pointer if LODEPNG_COMPILE_ZLIB is not defined";
|
||||
case 88:
|
||||
return "invalid filter strategy given for LodePNGEncoderSettings.filter_strategy";
|
||||
case 89:
|
||||
return "text chunk keyword too short or long: must have size 1-79";
|
||||
/*the windowsize in the LodePNGCompressSettings. Requiring POT(==> & instead of %) makes encoding 12% faster.*/
|
||||
case 90: return "windowsize must be a power of two";
|
||||
case 91: return "invalid decompressed idat size";
|
||||
case 92: return "too many pixels, not supported";
|
||||
case 93: return "zero width or height is invalid";
|
||||
case 94: return "header chunk must have a size of 13 bytes";
|
||||
case 90:
|
||||
return "windowsize must be a power of two";
|
||||
case 91:
|
||||
return "invalid decompressed idat size";
|
||||
case 92:
|
||||
return "too many pixels, not supported";
|
||||
case 93:
|
||||
return "zero width or height is invalid";
|
||||
case 94:
|
||||
return "header chunk must have a size of 13 bytes";
|
||||
}
|
||||
return "unknown error code";
|
||||
}
|
||||
|
|
|
@ -259,13 +259,13 @@ struct LodePNGDecompressSettings
|
|||
unsigned ignore_adler32; /*if 1, continue and don't give an error message if the Adler32 checksum is corrupted*/
|
||||
|
||||
/*use custom zlib decoder instead of built in one (default: null)*/
|
||||
unsigned (*custom_zlib)(uint8_t**, size_t*,
|
||||
unsigned(*custom_zlib)(uint8_t**, size_t*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
/*use custom deflate decoder instead of built in one (default: null)
|
||||
if custom_zlib is used, custom_deflate is ignored since only the built in
|
||||
zlib function will call custom_deflate*/
|
||||
unsigned (*custom_inflate)(uint8_t**, size_t*,
|
||||
unsigned(*custom_inflate)(uint8_t**, size_t*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
|
||||
|
@ -293,13 +293,13 @@ struct LodePNGCompressSettings /*deflate = compress*/
|
|||
unsigned lazymatching; /*use lazy matching: better compression but a bit slower. Default: true*/
|
||||
|
||||
/*use custom zlib encoder instead of built in one (default: null)*/
|
||||
unsigned (*custom_zlib)(uint8_t**, size_t*,
|
||||
unsigned(*custom_zlib)(uint8_t**, size_t*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGCompressSettings*);
|
||||
/*use custom deflate encoder instead of built in one (default: null)
|
||||
if custom_zlib is used, custom_deflate is ignored since only the built in
|
||||
zlib function will call custom_deflate*/
|
||||
unsigned (*custom_deflate)(uint8_t**, size_t*,
|
||||
unsigned(*custom_deflate)(uint8_t**, size_t*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGCompressSettings*);
|
||||
|
||||
|
@ -636,7 +636,7 @@ typedef struct LodePNGState
|
|||
unsigned error;
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* For the lodepng::State subclass. */
|
||||
virtual ~LodePNGState(){}
|
||||
virtual ~LodePNGState() {}
|
||||
#endif
|
||||
} LodePNGState;
|
||||
|
||||
|
@ -823,7 +823,7 @@ namespace lodepng
|
|||
#ifdef LODEPNG_COMPILE_PNG
|
||||
class State : public LodePNGState
|
||||
{
|
||||
public:
|
||||
public:
|
||||
State();
|
||||
State(const State& other);
|
||||
virtual ~State();
|
||||
|
|
|
@ -32,29 +32,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define SDL_REQUIREDVERSION (SDL_VERSIONNUM(SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z))
|
||||
#define SDL_NEW_VERSION_REJECT (SDL_VERSIONNUM(3,0,0))
|
||||
|
||||
static void Sys_AtExit (void)
|
||||
static void Sys_AtExit(void)
|
||||
{
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
static void Sys_InitSDL (void)
|
||||
static void Sys_InitSDL(void)
|
||||
{
|
||||
SDL_version v;
|
||||
SDL_version *sdl_version = &v;
|
||||
SDL_GetVersion(&v);
|
||||
|
||||
Sys_Printf("Found SDL version %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n",sdl_version->major,sdl_version->minor,sdl_version->patch);
|
||||
if (SDL_VERSIONNUM(sdl_version->major,sdl_version->minor,sdl_version->patch) < SDL_REQUIREDVERSION)
|
||||
{ /*reject running under older SDL versions */
|
||||
Sys_Error("You need at least v%" PRIi32 ".%" PRIi32 ".%" PRIi32 " of SDL to run this game.", SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z);
|
||||
Sys_Printf("Found SDL version %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", sdl_version->major, sdl_version->minor, sdl_version->patch);
|
||||
if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) < SDL_REQUIREDVERSION)
|
||||
{
|
||||
/*reject running under older SDL versions */
|
||||
Sys_Error("You need at least v%" PRIi32 ".%" PRIi32 ".%" PRIi32 " of SDL to run this game.", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
|
||||
}
|
||||
if (SDL_VERSIONNUM(sdl_version->major,sdl_version->minor,sdl_version->patch) >= SDL_NEW_VERSION_REJECT)
|
||||
{ /*reject running under newer (1.3.x) SDL */
|
||||
if(SDL_VERSIONNUM(sdl_version->major, sdl_version->minor, sdl_version->patch) >= SDL_NEW_VERSION_REJECT)
|
||||
{
|
||||
/*reject running under newer (1.3.x) SDL */
|
||||
Sys_Error("Your version of SDL library is incompatible with me.\n"
|
||||
"You need a library version in the line of %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z);
|
||||
"You need a library version in the line of %" PRIi32 ".%" PRIi32 ".%" PRIi32 "\n", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
|
||||
}
|
||||
|
||||
if (SDL_Init(0) < 0)
|
||||
if(SDL_Init(0) < 0)
|
||||
{
|
||||
Sys_Error("Couldn't init SDL: %s", SDL_GetError());
|
||||
}
|
||||
|
@ -88,22 +90,22 @@ int32_t main(int32_t argc, char *argv[])
|
|||
|
||||
isDedicated = (COM_CheckParm("-dedicated") != 0);
|
||||
|
||||
Sys_InitSDL ();
|
||||
Sys_InitSDL();
|
||||
|
||||
Sys_Init();
|
||||
|
||||
parms.memsize = DEFAULT_MEMORY;
|
||||
if (COM_CheckParm("-heapsize"))
|
||||
if(COM_CheckParm("-heapsize"))
|
||||
{
|
||||
t = COM_CheckParm("-heapsize") + 1;
|
||||
if (t < com_argc)
|
||||
if(t < com_argc)
|
||||
parms.memsize = Q_atoi(com_argv[t]) * 1024;
|
||||
}
|
||||
|
||||
parms.membase = malloc (parms.memsize);
|
||||
parms.membase = malloc(parms.memsize);
|
||||
|
||||
if (!parms.membase)
|
||||
Sys_Error ("Not enough memory free; check disk space\n");
|
||||
if(!parms.membase)
|
||||
Sys_Error("Not enough memory free; check disk space\n");
|
||||
|
||||
Sys_Printf("Quake " VERSION " (c) id Software\n");
|
||||
Sys_Printf("FitzQuake " FITZQUAKE_VERSION " (c) John Fitzgibbons\n");
|
||||
|
@ -114,34 +116,34 @@ int32_t main(int32_t argc, char *argv[])
|
|||
Host_Init();
|
||||
|
||||
oldtime = Sys_DoubleTime();
|
||||
if (isDedicated)
|
||||
if(isDedicated)
|
||||
{
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
newtime = Sys_DoubleTime ();
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
|
||||
while (time < sys_ticrate.value )
|
||||
while(time < sys_ticrate.value)
|
||||
{
|
||||
SDL_Delay(1);
|
||||
newtime = Sys_DoubleTime ();
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
}
|
||||
|
||||
Host_Frame (time);
|
||||
Host_Frame(time);
|
||||
oldtime = newtime;
|
||||
}
|
||||
}
|
||||
else
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
/* If we have no input focus at all, sleep a bit */
|
||||
if (!VID_HasMouseOrInputFocus() || cl.paused)
|
||||
if(!VID_HasMouseOrInputFocus() || cl.paused)
|
||||
{
|
||||
SDL_Delay(16);
|
||||
}
|
||||
/* If we're minimised, sleep a bit more */
|
||||
if (VID_IsMinimized())
|
||||
if(VID_IsMinimized())
|
||||
{
|
||||
scr_skipupdate = 1;
|
||||
SDL_Delay(32);
|
||||
|
@ -150,12 +152,12 @@ int32_t main(int32_t argc, char *argv[])
|
|||
{
|
||||
scr_skipupdate = 0;
|
||||
}
|
||||
newtime = Sys_DoubleTime ();
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
|
||||
Host_Frame (time);
|
||||
Host_Frame(time);
|
||||
|
||||
if (time < sys_throttle.value && !cls.timedemo)
|
||||
if(time < sys_throttle.value && !cls.timedemo)
|
||||
SDL_Delay(1);
|
||||
|
||||
oldtime = newtime;
|
||||
|
|
212
source/mathlib.c
212
source/mathlib.c
|
@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
vec3_t vec3_origin = {0,0,0};
|
||||
vec3_t vec3_origin = {0, 0, 0};
|
||||
|
||||
/*-----------------------------------------------------------------*/
|
||||
|
||||
|
@ -32,15 +32,15 @@ vec3_t vec3_origin = {0,0,0};
|
|||
//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F
|
||||
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz
|
||||
|
||||
void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )
|
||||
void ProjectPointOnPlane(vec3_t dst, const vec3_t p, const vec3_t normal)
|
||||
{
|
||||
float d;
|
||||
vec3_t n;
|
||||
float inv_denom;
|
||||
|
||||
inv_denom = 1.0F / DotProduct( normal, normal );
|
||||
inv_denom = 1.0F / DotProduct(normal, normal);
|
||||
|
||||
d = DotProduct( normal, p ) * inv_denom;
|
||||
d = DotProduct(normal, p) * inv_denom;
|
||||
|
||||
n[0] = normal[0] * inv_denom;
|
||||
n[1] = normal[1] * inv_denom;
|
||||
|
@ -54,7 +54,7 @@ void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )
|
|||
/*
|
||||
** assumes "src" is normalized
|
||||
*/
|
||||
void PerpendicularVector( vec3_t dst, const vec3_t src )
|
||||
void PerpendicularVector(vec3_t dst, const vec3_t src)
|
||||
{
|
||||
int32_t pos;
|
||||
int32_t i;
|
||||
|
@ -64,12 +64,12 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
|
|||
/*
|
||||
** find the smallest magnitude axially aligned vector
|
||||
*/
|
||||
for ( pos = 0, i = 0; i < 3; i++ )
|
||||
for(pos = 0, i = 0; i < 3; i++)
|
||||
{
|
||||
if ( fabs( src[i] ) < minelem )
|
||||
if(fabs(src[i]) < minelem)
|
||||
{
|
||||
pos = i;
|
||||
minelem = fabs( src[i] );
|
||||
minelem = fabs(src[i]);
|
||||
}
|
||||
}
|
||||
tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
|
||||
|
@ -78,12 +78,12 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
|
|||
/*
|
||||
** project the point onto the plane defined by src
|
||||
*/
|
||||
ProjectPointOnPlane( dst, tempvec, src );
|
||||
ProjectPointOnPlane(dst, tempvec, src);
|
||||
|
||||
/*
|
||||
** normalize the result
|
||||
*/
|
||||
VectorNormalize( dst );
|
||||
VectorNormalize(dst);
|
||||
}
|
||||
|
||||
//johnfitz -- removed RotatePointAroundVector() becuase it's no longer used and my compiler fucked it up anyway
|
||||
|
@ -94,12 +94,12 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
|
|||
float anglemod(float a)
|
||||
{
|
||||
#if 0
|
||||
if (a >= 0)
|
||||
a -= 360*(int32_t)(a/360);
|
||||
if(a >= 0)
|
||||
a -= 360 * (int32_t)(a / 360);
|
||||
else
|
||||
a += 360*( 1 + (int32_t)(-a/360) );
|
||||
a += 360 * (1 + (int32_t)(-a / 360));
|
||||
#endif
|
||||
a = (360.0/65536) * ((int32_t)(a*(65536/360.0)) & 65535);
|
||||
a = (360.0 / 65536) * ((int32_t)(a * (65536 / 360.0)) & 65535);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ BoxOnPlaneSide
|
|||
Returns 1, 2, or 1 + 2
|
||||
==================
|
||||
*/
|
||||
int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
||||
int32_t BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, mplane_t *p)
|
||||
{
|
||||
float dist1, dist2;
|
||||
int32_t sides;
|
||||
|
@ -119,54 +119,54 @@ int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
#if 0 // this is done by the BOX_ON_PLANE_SIDE macro before calling this
|
||||
// function
|
||||
// fast axial cases
|
||||
if (p->type < 3)
|
||||
if(p->type < 3)
|
||||
{
|
||||
if (p->dist <= emins[p->type])
|
||||
if(p->dist <= emins[p->type])
|
||||
return 1;
|
||||
if (p->dist >= emaxs[p->type])
|
||||
if(p->dist >= emaxs[p->type])
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
#endif
|
||||
|
||||
// general case
|
||||
switch (p->signbits)
|
||||
switch(p->signbits)
|
||||
{
|
||||
case 0:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] + p->normal[2] * emaxs[2];
|
||||
dist2 = p->normal[0] * emins[0] + p->normal[1] * emins[1] + p->normal[2] * emins[2];
|
||||
break;
|
||||
case 1:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist1 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] + p->normal[2] * emaxs[2];
|
||||
dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] + p->normal[2] * emins[2];
|
||||
break;
|
||||
case 2:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] + p->normal[2] * emaxs[2];
|
||||
dist2 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] + p->normal[2] * emins[2];
|
||||
break;
|
||||
case 3:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist1 = p->normal[0] * emins[0] + p->normal[1] * emins[1] + p->normal[2] * emaxs[2];
|
||||
dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] + p->normal[2] * emins[2];
|
||||
break;
|
||||
case 4:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] + p->normal[2] * emins[2];
|
||||
dist2 = p->normal[0] * emins[0] + p->normal[1] * emins[1] + p->normal[2] * emaxs[2];
|
||||
break;
|
||||
case 5:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2];
|
||||
dist1 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] + p->normal[2] * emins[2];
|
||||
dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] + p->normal[2] * emaxs[2];
|
||||
break;
|
||||
case 6:
|
||||
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist1 = p->normal[0] * emaxs[0] + p->normal[1] * emins[1] + p->normal[2] * emins[2];
|
||||
dist2 = p->normal[0] * emins[0] + p->normal[1] * emaxs[1] + p->normal[2] * emaxs[2];
|
||||
break;
|
||||
case 7:
|
||||
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
|
||||
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
|
||||
dist1 = p->normal[0] * emins[0] + p->normal[1] * emins[1] + p->normal[2] * emins[2];
|
||||
dist2 = p->normal[0] * emaxs[0] + p->normal[1] * emaxs[1] + p->normal[2] * emaxs[2];
|
||||
break;
|
||||
default:
|
||||
dist1 = dist2 = 0; // shut up compiler
|
||||
Sys_Error ("BoxOnPlaneSide: Bad signbits");
|
||||
Sys_Error("BoxOnPlaneSide: Bad signbits");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,9 @@ int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
int32_t i;
|
||||
vec3_t corners[2];
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
if (plane->normal[i] < 0)
|
||||
if(plane->normal[i] < 0)
|
||||
{
|
||||
corners[0][i] = emins[i];
|
||||
corners[1][i] = emaxs[i];
|
||||
|
@ -187,24 +187,24 @@ int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
corners[0][i] = emaxs[i];
|
||||
}
|
||||
}
|
||||
dist = DotProduct (plane->normal, corners[0]) - plane->dist;
|
||||
dist2 = DotProduct (plane->normal, corners[1]) - plane->dist;
|
||||
dist = DotProduct(plane->normal, corners[0]) - plane->dist;
|
||||
dist2 = DotProduct(plane->normal, corners[1]) - plane->dist;
|
||||
sides = 0;
|
||||
if (dist1 >= 0)
|
||||
if(dist1 >= 0)
|
||||
sides = 1;
|
||||
if (dist2 < 0)
|
||||
if(dist2 < 0)
|
||||
sides |= 2;
|
||||
#endif
|
||||
|
||||
sides = 0;
|
||||
if (dist1 >= p->dist)
|
||||
if(dist1 >= p->dist)
|
||||
sides = 1;
|
||||
if (dist2 < p->dist)
|
||||
if(dist2 < p->dist)
|
||||
sides |= 2;
|
||||
|
||||
#ifdef PARANOID
|
||||
if (sides == 0)
|
||||
Sys_Error ("BoxOnPlaneSide: sides==0");
|
||||
if(sides == 0)
|
||||
Sys_Error("BoxOnPlaneSide: sides==0");
|
||||
#endif
|
||||
|
||||
return sides;
|
||||
|
@ -212,7 +212,7 @@ int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
|
|||
|
||||
//johnfitz -- the opposite of AngleVectors. this takes forward and generates pitch yaw roll
|
||||
//TODO: take right and up vectors to properly set yaw and roll
|
||||
void VectorAngles (const vec3_t forward, vec3_t angles)
|
||||
void VectorAngles(const vec3_t forward, vec3_t angles)
|
||||
{
|
||||
vec3_t temp;
|
||||
|
||||
|
@ -224,98 +224,98 @@ void VectorAngles (const vec3_t forward, vec3_t angles)
|
|||
angles[ROLL] = 0;
|
||||
}
|
||||
|
||||
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
|
||||
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
|
||||
{
|
||||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
angle = angles[YAW] * (M_PI*2 / 360);
|
||||
angle = angles[YAW] * (M_PI * 2 / 360);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = angles[PITCH] * (M_PI*2 / 360);
|
||||
angle = angles[PITCH] * (M_PI * 2 / 360);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = angles[ROLL] * (M_PI*2 / 360);
|
||||
angle = angles[ROLL] * (M_PI * 2 / 360);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
forward[0] = cp*cy;
|
||||
forward[1] = cp*sy;
|
||||
forward[0] = cp * cy;
|
||||
forward[1] = cp * sy;
|
||||
forward[2] = -sp;
|
||||
right[0] = (-1*sr*sp*cy+-1*cr*-sy);
|
||||
right[1] = (-1*sr*sp*sy+-1*cr*cy);
|
||||
right[2] = -1*sr*cp;
|
||||
up[0] = (cr*sp*cy+-sr*-sy);
|
||||
up[1] = (cr*sp*sy+-sr*cy);
|
||||
up[2] = cr*cp;
|
||||
right[0] = (-1 * sr * sp * cy + -1 * cr * -sy);
|
||||
right[1] = (-1 * sr * sp * sy + -1 * cr * cy);
|
||||
right[2] = -1 * sr * cp;
|
||||
up[0] = (cr * sp * cy + -sr * -sy);
|
||||
up[1] = (cr * sp * sy + -sr * cy);
|
||||
up[2] = cr * cp;
|
||||
}
|
||||
|
||||
int32_t VectorCompare (vec3_t v1, vec3_t v2)
|
||||
int32_t VectorCompare(vec3_t v1, vec3_t v2)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
if (v1[i] != v2[i])
|
||||
for(i = 0 ; i < 3 ; i++)
|
||||
if(v1[i] != v2[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
|
||||
void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
|
||||
{
|
||||
vecc[0] = veca[0] + scale*vecb[0];
|
||||
vecc[1] = veca[1] + scale*vecb[1];
|
||||
vecc[2] = veca[2] + scale*vecb[2];
|
||||
vecc[0] = veca[0] + scale * vecb[0];
|
||||
vecc[1] = veca[1] + scale * vecb[1];
|
||||
vecc[2] = veca[2] + scale * vecb[2];
|
||||
}
|
||||
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2)
|
||||
vec_t _DotProduct(vec3_t v1, vec3_t v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
|
||||
}
|
||||
|
||||
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out)
|
||||
void _VectorSubtract(vec3_t veca, vec3_t vecb, vec3_t out)
|
||||
{
|
||||
out[0] = veca[0]-vecb[0];
|
||||
out[1] = veca[1]-vecb[1];
|
||||
out[2] = veca[2]-vecb[2];
|
||||
out[0] = veca[0] - vecb[0];
|
||||
out[1] = veca[1] - vecb[1];
|
||||
out[2] = veca[2] - vecb[2];
|
||||
}
|
||||
|
||||
void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out)
|
||||
void _VectorAdd(vec3_t veca, vec3_t vecb, vec3_t out)
|
||||
{
|
||||
out[0] = veca[0]+vecb[0];
|
||||
out[1] = veca[1]+vecb[1];
|
||||
out[2] = veca[2]+vecb[2];
|
||||
out[0] = veca[0] + vecb[0];
|
||||
out[1] = veca[1] + vecb[1];
|
||||
out[2] = veca[2] + vecb[2];
|
||||
}
|
||||
|
||||
void _VectorCopy (vec3_t in, vec3_t out)
|
||||
void _VectorCopy(vec3_t in, vec3_t out)
|
||||
{
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = in[2];
|
||||
}
|
||||
|
||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
|
||||
void CrossProduct(vec3_t v1, vec3_t v2, vec3_t cross)
|
||||
{
|
||||
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
||||
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
||||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
cross[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
||||
cross[1] = v1[2] * v2[0] - v1[0] * v2[2];
|
||||
cross[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
||||
}
|
||||
|
||||
vec_t VectorLength(vec3_t v)
|
||||
{
|
||||
return sqrt(DotProduct(v,v));
|
||||
return sqrt(DotProduct(v, v));
|
||||
}
|
||||
|
||||
float VectorNormalize (vec3_t v)
|
||||
float VectorNormalize(vec3_t v)
|
||||
{
|
||||
float length, ilength;
|
||||
|
||||
length = sqrt(DotProduct(v,v));
|
||||
length = sqrt(DotProduct(v, v));
|
||||
|
||||
if (length)
|
||||
if(length)
|
||||
{
|
||||
ilength = 1/length;
|
||||
ilength = 1 / length;
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
|
@ -325,25 +325,25 @@ float VectorNormalize (vec3_t v)
|
|||
|
||||
}
|
||||
|
||||
void VectorInverse (vec3_t v)
|
||||
void VectorInverse(vec3_t v)
|
||||
{
|
||||
v[0] = -v[0];
|
||||
v[1] = -v[1];
|
||||
v[2] = -v[2];
|
||||
}
|
||||
|
||||
void VectorScale (vec3_t in, vec_t scale, vec3_t out)
|
||||
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
|
||||
{
|
||||
out[0] = in[0]*scale;
|
||||
out[1] = in[1]*scale;
|
||||
out[2] = in[2]*scale;
|
||||
out[0] = in[0] * scale;
|
||||
out[1] = in[1] * scale;
|
||||
out[2] = in[2] * scale;
|
||||
}
|
||||
|
||||
|
||||
int32_t Q_log2(int32_t val)
|
||||
{
|
||||
int32_t answer=0;
|
||||
while (val>>=1)
|
||||
int32_t answer = 0;
|
||||
while(val >>= 1)
|
||||
answer++;
|
||||
return answer;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ int32_t Q_log2(int32_t val)
|
|||
R_ConcatRotations
|
||||
================
|
||||
*/
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
|
||||
void R_ConcatRotations(float in1[3][3], float in2[3][3], float out[3][3])
|
||||
{
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
||||
in1[0][2] * in2[2][0];
|
||||
|
@ -382,7 +382,7 @@ void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3])
|
|||
R_ConcatTransforms
|
||||
================
|
||||
*/
|
||||
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4])
|
||||
void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4])
|
||||
{
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
||||
in1[0][2] * in2[2][0];
|
||||
|
@ -421,22 +421,22 @@ quotient must fit in 32 bits.
|
|||
====================
|
||||
*/
|
||||
|
||||
void FloorDivMod (double numer, double denom, int32_t *quotient,
|
||||
void FloorDivMod(double numer, double denom, int32_t *quotient,
|
||||
int32_t *rem)
|
||||
{
|
||||
int32_t q, r;
|
||||
double x;
|
||||
|
||||
#ifndef PARANOID
|
||||
if (denom <= 0.0)
|
||||
Sys_Error ("FloorDivMod: bad denominator %f\n", denom);
|
||||
if(denom <= 0.0)
|
||||
Sys_Error("FloorDivMod: bad denominator %f\n", denom);
|
||||
|
||||
// if ((floor(numer) != numer) || (floor(denom) != denom))
|
||||
// Sys_Error ("FloorDivMod: non-integer numer or denom %f %f\n",
|
||||
// numer, denom);
|
||||
#endif
|
||||
|
||||
if (numer >= 0.0)
|
||||
if(numer >= 0.0)
|
||||
{
|
||||
|
||||
x = floor(numer / denom);
|
||||
|
@ -451,7 +451,7 @@ void FloorDivMod (double numer, double denom, int32_t *quotient,
|
|||
x = floor(-numer / denom);
|
||||
q = -(int32_t)x;
|
||||
r = (int32_t)floor(-numer - (x * denom));
|
||||
if (r != 0)
|
||||
if(r != 0)
|
||||
{
|
||||
q--;
|
||||
r = (int32_t)denom - r;
|
||||
|
@ -468,18 +468,18 @@ void FloorDivMod (double numer, double denom, int32_t *quotient,
|
|||
GreatestCommonDivisor
|
||||
====================
|
||||
*/
|
||||
int32_t GreatestCommonDivisor (int32_t i1, int32_t i2)
|
||||
int32_t GreatestCommonDivisor(int32_t i1, int32_t i2)
|
||||
{
|
||||
if (i1 > i2)
|
||||
if(i1 > i2)
|
||||
{
|
||||
if (i2 == 0)
|
||||
if(i2 == 0)
|
||||
return (i1);
|
||||
return GreatestCommonDivisor (i2, i1 % i2);
|
||||
return GreatestCommonDivisor(i2, i1 % i2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i1 == 0)
|
||||
if(i1 == 0)
|
||||
return (i2);
|
||||
return GreatestCommonDivisor (i1, i2 % i1);
|
||||
return GreatestCommonDivisor(i1, i2 % i1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,13 @@ extern vec3_t vec3_origin;
|
|||
#if 0 /* macro is violating strict aliasing rules */
|
||||
#define IS_NAN(x) (((*(int32_t *) (char *) &x) & nanmask) == nanmask)
|
||||
#else
|
||||
static inline int32_t IS_NAN (float x) {
|
||||
union { float f; int32_t i; } num;
|
||||
static inline int32_t IS_NAN(float x)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
int32_t i;
|
||||
} num;
|
||||
num.f = x;
|
||||
return ((num.i & nanmask) == nanmask);
|
||||
}
|
||||
|
@ -71,33 +76,33 @@ static inline int32_t IS_NAN (float x) {
|
|||
}\
|
||||
}
|
||||
|
||||
void TurnVector (vec3_t out, const vec3_t forward, const vec3_t side, float angle); //johnfitz
|
||||
void VectorAngles (const vec3_t forward, vec3_t angles); //johnfitz
|
||||
void TurnVector(vec3_t out, const vec3_t forward, const vec3_t side, float angle); //johnfitz
|
||||
void VectorAngles(const vec3_t forward, vec3_t angles); //johnfitz
|
||||
|
||||
void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
|
||||
void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorCopy (vec3_t in, vec3_t out);
|
||||
vec_t _DotProduct(vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract(vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorAdd(vec3_t veca, vec3_t vecb, vec3_t out);
|
||||
void _VectorCopy(vec3_t in, vec3_t out);
|
||||
|
||||
int32_t VectorCompare (vec3_t v1, vec3_t v2);
|
||||
vec_t VectorLength (vec3_t v);
|
||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
|
||||
float VectorNormalize (vec3_t v); // returns vector length
|
||||
void VectorInverse (vec3_t v);
|
||||
void VectorScale (vec3_t in, vec_t scale, vec3_t out);
|
||||
int32_t VectorCompare(vec3_t v1, vec3_t v2);
|
||||
vec_t VectorLength(vec3_t v);
|
||||
void CrossProduct(vec3_t v1, vec3_t v2, vec3_t cross);
|
||||
float VectorNormalize(vec3_t v); // returns vector length
|
||||
void VectorInverse(vec3_t v);
|
||||
void VectorScale(vec3_t in, vec_t scale, vec3_t out);
|
||||
int32_t Q_log2(int32_t val);
|
||||
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
|
||||
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
void R_ConcatRotations(float in1[3][3], float in2[3][3], float out[3][3]);
|
||||
void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
|
||||
void FloorDivMod (double numer, double denom, int32_t *quotient,
|
||||
void FloorDivMod(double numer, double denom, int32_t *quotient,
|
||||
int32_t *rem);
|
||||
int32_t GreatestCommonDivisor (int32_t i1, int32_t i2);
|
||||
int32_t GreatestCommonDivisor(int32_t i1, int32_t i2);
|
||||
|
||||
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
int32_t BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
|
||||
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
|
||||
int32_t BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
|
||||
float anglemod(float a);
|
||||
|
||||
|
||||
|
|
1682
source/menu.c
1682
source/menu.c
File diff suppressed because it is too large
Load Diff
|
@ -23,7 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef _QUAKE_MENU_H
|
||||
#define _QUAKE_MENU_H
|
||||
|
||||
enum m_state_e {
|
||||
enum m_state_e
|
||||
{
|
||||
m_none,
|
||||
m_main,
|
||||
m_singleplayer,
|
||||
|
@ -51,25 +52,25 @@ extern bool m_entersound;
|
|||
//
|
||||
// menus
|
||||
//
|
||||
void M_Init (void);
|
||||
void M_Keydown (int32_t key);
|
||||
void M_Charinput (int32_t key);
|
||||
bool M_TextEntry (void);
|
||||
void M_ToggleMenu_f (void);
|
||||
void M_Init(void);
|
||||
void M_Keydown(int32_t key);
|
||||
void M_Charinput(int32_t key);
|
||||
bool M_TextEntry(void);
|
||||
void M_ToggleMenu_f(void);
|
||||
|
||||
void M_Menu_Main_f (void);
|
||||
void M_Menu_Options_f (void);
|
||||
void M_Menu_Quit_f (void);
|
||||
void M_Menu_Main_f(void);
|
||||
void M_Menu_Options_f(void);
|
||||
void M_Menu_Quit_f(void);
|
||||
|
||||
void M_Print (int32_t cx, int32_t cy, const char *str);
|
||||
void M_PrintWhite (int32_t cx, int32_t cy, const char *str);
|
||||
void M_Print(int32_t cx, int32_t cy, const char *str);
|
||||
void M_PrintWhite(int32_t cx, int32_t cy, const char *str);
|
||||
|
||||
void M_Draw (void);
|
||||
void M_DrawCharacter (int32_t cx, int32_t line, int32_t num);
|
||||
void M_Draw(void);
|
||||
void M_DrawCharacter(int32_t cx, int32_t line, int32_t num);
|
||||
|
||||
void M_DrawPic (int32_t x, int32_t y, qpic_t *pic);
|
||||
void M_DrawTransPic (int32_t x, int32_t y, qpic_t *pic);
|
||||
void M_DrawCheckbox (int32_t x, int32_t y, int32_t on);
|
||||
void M_DrawPic(int32_t x, int32_t y, qpic_t *pic);
|
||||
void M_DrawTransPic(int32_t x, int32_t y, qpic_t *pic);
|
||||
void M_DrawCheckbox(int32_t x, int32_t y, int32_t on);
|
||||
|
||||
#endif /* _QUAKE_MENU_H */
|
||||
|
||||
|
|
|
@ -54,14 +54,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// must match definition in spritegn.h
|
||||
#ifndef SYNCTYPE_T
|
||||
#define SYNCTYPE_T
|
||||
typedef enum {ST_SYNC=0, ST_RAND } synctype_t;
|
||||
typedef enum {ST_SYNC = 0, ST_RAND } synctype_t;
|
||||
#endif
|
||||
|
||||
typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t;
|
||||
typedef enum { ALIAS_SINGLE = 0, ALIAS_GROUP } aliasframetype_t;
|
||||
|
||||
typedef enum { ALIAS_SKIN_SINGLE=0, ALIAS_SKIN_GROUP } aliasskintype_t;
|
||||
typedef enum { ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_GROUP } aliasskintype_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
|
@ -81,13 +82,15 @@ typedef struct {
|
|||
|
||||
// TODO: could be shorts
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t onseam;
|
||||
int32_t s;
|
||||
int32_t t;
|
||||
} stvert_t;
|
||||
|
||||
typedef struct dtriangle_s {
|
||||
typedef struct dtriangle_s
|
||||
{
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
} dtriangle_t;
|
||||
|
@ -97,45 +100,53 @@ typedef struct dtriangle_s {
|
|||
// This mirrors trivert_t in trilib.h, is present so Quake knows how to
|
||||
// load this data
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
byte v[3];
|
||||
byte lightnormalindex;
|
||||
} trivertx_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
trivertx_t bboxmin; // lightnormal isn't used
|
||||
trivertx_t bboxmax; // lightnormal isn't used
|
||||
char name[16]; // frame name from grabbing
|
||||
} daliasframe_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t numframes;
|
||||
trivertx_t bboxmin; // lightnormal isn't used
|
||||
trivertx_t bboxmax; // lightnormal isn't used
|
||||
} daliasgroup_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t numskins;
|
||||
} daliasskingroup_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float interval;
|
||||
} daliasinterval_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float interval;
|
||||
} daliasskininterval_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
aliasframetype_t type;
|
||||
} daliasframetype_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
aliasskintype_t type;
|
||||
} daliasskintype_t;
|
||||
|
||||
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
|
||||
// little-endian "IDPO"
|
||||
// little-endian "IDPO"
|
||||
|
||||
#endif /* _MODELGEN_H */
|
||||
|
||||
|
|
32
source/net.h
32
source/net.h
|
@ -46,31 +46,31 @@ extern sizebuf_t net_message;
|
|||
extern int32_t net_activeconnections;
|
||||
|
||||
|
||||
void NET_Init (void);
|
||||
void NET_Shutdown (void);
|
||||
void NET_Init(void);
|
||||
void NET_Shutdown(void);
|
||||
|
||||
struct qsocket_s *NET_CheckNewConnections (void);
|
||||
struct qsocket_s *NET_CheckNewConnections(void);
|
||||
// returns a new connection number if there is one pending, else -1
|
||||
|
||||
struct qsocket_s *NET_Connect (const char *host);
|
||||
struct qsocket_s *NET_Connect(const char *host);
|
||||
// called by client to connect to a host. Returns -1 if not able to
|
||||
|
||||
double NET_QSocketGetTime (const struct qsocket_s *sock);
|
||||
const char *NET_QSocketGetAddressString (const struct qsocket_s *sock);
|
||||
double NET_QSocketGetTime(const struct qsocket_s *sock);
|
||||
const char *NET_QSocketGetAddressString(const struct qsocket_s *sock);
|
||||
|
||||
bool NET_CanSendMessage (struct qsocket_s *sock);
|
||||
bool NET_CanSendMessage(struct qsocket_s *sock);
|
||||
// Returns true or false if the given qsocket can currently accept a
|
||||
// message to be transmitted.
|
||||
|
||||
int32_t NET_GetMessage (struct qsocket_s *sock);
|
||||
int32_t NET_GetMessage(struct qsocket_s *sock);
|
||||
// returns data in net_message sizebuf
|
||||
// returns 0 if no data is waiting
|
||||
// returns 1 if a message was received
|
||||
// returns 2 if an unreliable message was received
|
||||
// returns -1 if the connection died
|
||||
|
||||
int32_t NET_SendMessage (struct qsocket_s *sock, sizebuf_t *data);
|
||||
int32_t NET_SendUnreliableMessage (struct qsocket_s *sock, sizebuf_t *data);
|
||||
int32_t NET_SendMessage(struct qsocket_s *sock, sizebuf_t *data);
|
||||
int32_t NET_SendUnreliableMessage(struct qsocket_s *sock, sizebuf_t *data);
|
||||
// returns 0 if the message connot be delivered reliably, but the connection
|
||||
// is still considered valid
|
||||
// returns 1 if the message was sent properly
|
||||
|
@ -79,7 +79,7 @@ int32_t NET_SendUnreliableMessage (struct qsocket_s *sock, sizebuf_t *data);
|
|||
int32_t NET_SendToAll(sizebuf_t *data, double blocktime);
|
||||
// This is a reliable *blocking* send to all attached clients.
|
||||
|
||||
void NET_Close (struct qsocket_s *sock);
|
||||
void NET_Close(struct qsocket_s *sock);
|
||||
// if a dead connection is returned by a get or send function, this function
|
||||
// should be called when it is convenient
|
||||
|
||||
|
@ -88,7 +88,7 @@ void NET_Close (struct qsocket_s *sock);
|
|||
// from a server.
|
||||
// A netcon_t number will not be reused until this function is called for it
|
||||
|
||||
void NET_Poll (void);
|
||||
void NET_Poll(void);
|
||||
|
||||
|
||||
// Server list related globals:
|
||||
|
@ -98,10 +98,10 @@ extern bool slistLocal;
|
|||
|
||||
extern int32_t hostCacheCount;
|
||||
|
||||
void NET_Slist_f (void);
|
||||
void NET_SlistSort (void);
|
||||
const char *NET_SlistPrintServer (int32_t n);
|
||||
const char *NET_SlistPrintServerName (int32_t n);
|
||||
void NET_Slist_f(void);
|
||||
void NET_SlistSort(void);
|
||||
const char *NET_SlistPrintServer(int32_t n);
|
||||
const char *NET_SlistPrintServerName(int32_t n);
|
||||
|
||||
|
||||
/* FIXME: driver related, but public:
|
||||
|
|
|
@ -168,24 +168,24 @@ typedef struct
|
|||
const char *name;
|
||||
bool initialized;
|
||||
sys_socket_t controlSock;
|
||||
sys_socket_t (*Init) (void);
|
||||
void (*Shutdown) (void);
|
||||
void (*Listen) (bool state);
|
||||
sys_socket_t (*Open_Socket) (int32_t port);
|
||||
int32_t (*Close_Socket) (sys_socket_t socketid);
|
||||
int32_t (*Connect) (sys_socket_t socketid, struct qsockaddr *addr);
|
||||
sys_socket_t (*CheckNewConnections) (void);
|
||||
int32_t (*Read) (sys_socket_t socketid, byte *buf, int32_t len, struct qsockaddr *addr);
|
||||
int32_t (*Write) (sys_socket_t socketid, byte *buf, int32_t len, struct qsockaddr *addr);
|
||||
int32_t (*Broadcast) (sys_socket_t socketid, byte *buf, int32_t len);
|
||||
const char * (*AddrToString) (struct qsockaddr *addr);
|
||||
int32_t (*StringToAddr) (const char *string, struct qsockaddr *addr);
|
||||
int32_t (*GetSocketAddr) (sys_socket_t socketid, struct qsockaddr *addr);
|
||||
int32_t (*GetNameFromAddr) (struct qsockaddr *addr, char *name);
|
||||
int32_t (*GetAddrFromName) (const char *name, struct qsockaddr *addr);
|
||||
int32_t (*AddrCompare) (struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
int32_t (*GetSocketPort) (struct qsockaddr *addr);
|
||||
int32_t (*SetSocketPort) (struct qsockaddr *addr, int32_t port);
|
||||
sys_socket_t (*Init)(void);
|
||||
void (*Shutdown)(void);
|
||||
void (*Listen)(bool state);
|
||||
sys_socket_t (*Open_Socket)(int32_t port);
|
||||
int32_t (*Close_Socket)(sys_socket_t socketid);
|
||||
int32_t (*Connect)(sys_socket_t socketid, struct qsockaddr *addr);
|
||||
sys_socket_t (*CheckNewConnections)(void);
|
||||
int32_t (*Read)(sys_socket_t socketid, byte *buf, int32_t len, struct qsockaddr *addr);
|
||||
int32_t (*Write)(sys_socket_t socketid, byte *buf, int32_t len, struct qsockaddr *addr);
|
||||
int32_t (*Broadcast)(sys_socket_t socketid, byte *buf, int32_t len);
|
||||
const char * (*AddrToString)(struct qsockaddr *addr);
|
||||
int32_t (*StringToAddr)(const char *string, struct qsockaddr *addr);
|
||||
int32_t (*GetSocketAddr)(sys_socket_t socketid, struct qsockaddr *addr);
|
||||
int32_t (*GetNameFromAddr)(struct qsockaddr *addr, char *name);
|
||||
int32_t (*GetAddrFromName)(const char *name, struct qsockaddr *addr);
|
||||
int32_t (*AddrCompare)(struct qsockaddr *addr1, struct qsockaddr *addr2);
|
||||
int32_t (*GetSocketPort)(struct qsockaddr *addr);
|
||||
int32_t (*SetSocketPort)(struct qsockaddr *addr, int32_t port);
|
||||
} net_landriver_t;
|
||||
|
||||
#define MAX_NET_DRIVERS 8
|
||||
|
@ -196,18 +196,18 @@ typedef struct
|
|||
{
|
||||
const char *name;
|
||||
bool initialized;
|
||||
int32_t (*Init) (void);
|
||||
void (*Listen) (bool state);
|
||||
void (*SearchForHosts) (bool xmit);
|
||||
qsocket_t *(*Connect) (const char *host);
|
||||
qsocket_t *(*CheckNewConnections) (void);
|
||||
int32_t (*QGetMessage) (qsocket_t *sock);
|
||||
int32_t (*QSendMessage) (qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t (*SendUnreliableMessage) (qsocket_t *sock, sizebuf_t *data);
|
||||
bool (*CanSendMessage) (qsocket_t *sock);
|
||||
bool (*CanSendUnreliableMessage) (qsocket_t *sock);
|
||||
void (*Close) (qsocket_t *sock);
|
||||
void (*Shutdown) (void);
|
||||
int32_t (*Init)(void);
|
||||
void (*Listen)(bool state);
|
||||
void (*SearchForHosts)(bool xmit);
|
||||
qsocket_t *(*Connect)(const char *host);
|
||||
qsocket_t *(*CheckNewConnections)(void);
|
||||
int32_t (*QGetMessage)(qsocket_t *sock);
|
||||
int32_t (*QSendMessage)(qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t (*SendUnreliableMessage)(qsocket_t *sock, sizebuf_t *data);
|
||||
bool (*CanSendMessage)(qsocket_t *sock);
|
||||
bool (*CanSendUnreliableMessage)(qsocket_t *sock);
|
||||
void (*Close)(qsocket_t *sock);
|
||||
void (*Shutdown)(void);
|
||||
} net_driver_t;
|
||||
|
||||
extern net_driver_t net_drivers[];
|
||||
|
@ -223,7 +223,7 @@ extern int32_t messagesReceived;
|
|||
extern int32_t unreliableMessagesSent;
|
||||
extern int32_t unreliableMessagesReceived;
|
||||
|
||||
qsocket_t *NET_NewQSocket (void);
|
||||
qsocket_t *NET_NewQSocket(void);
|
||||
void NET_FreeQSocket(qsocket_t *);
|
||||
double SetNetTime(void);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,18 +22,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef __NET_DATAGRAM_H
|
||||
#define __NET_DATAGRAM_H
|
||||
|
||||
int32_t Datagram_Init (void);
|
||||
void Datagram_Listen (bool state);
|
||||
void Datagram_SearchForHosts (bool xmit);
|
||||
qsocket_t *Datagram_Connect (const char *host);
|
||||
qsocket_t *Datagram_CheckNewConnections (void);
|
||||
int32_t Datagram_GetMessage (qsocket_t *sock);
|
||||
int32_t Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
|
||||
bool Datagram_CanSendMessage (qsocket_t *sock);
|
||||
bool Datagram_CanSendUnreliableMessage (qsocket_t *sock);
|
||||
void Datagram_Close (qsocket_t *sock);
|
||||
void Datagram_Shutdown (void);
|
||||
int32_t Datagram_Init(void);
|
||||
void Datagram_Listen(bool state);
|
||||
void Datagram_SearchForHosts(bool xmit);
|
||||
qsocket_t *Datagram_Connect(const char *host);
|
||||
qsocket_t *Datagram_CheckNewConnections(void);
|
||||
int32_t Datagram_GetMessage(qsocket_t *sock);
|
||||
int32_t Datagram_SendMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t Datagram_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
bool Datagram_CanSendMessage(qsocket_t *sock);
|
||||
bool Datagram_CanSendUnreliableMessage(qsocket_t *sock);
|
||||
void Datagram_Close(qsocket_t *sock);
|
||||
void Datagram_Shutdown(void);
|
||||
|
||||
#endif /* __NET_DATAGRAM_H */
|
||||
|
||||
|
|
|
@ -30,34 +30,34 @@ static bool localconnectpending = false;
|
|||
static qsocket_t *loop_client = NULL;
|
||||
static qsocket_t *loop_server = NULL;
|
||||
|
||||
int32_t Loop_Init (void)
|
||||
int32_t Loop_Init(void)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
if(cls.state == ca_dedicated)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Loop_Shutdown (void)
|
||||
void Loop_Shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Loop_Listen (bool state)
|
||||
void Loop_Listen(bool state)
|
||||
{
|
||||
(void)state;
|
||||
}
|
||||
|
||||
|
||||
void Loop_SearchForHosts (bool xmit)
|
||||
void Loop_SearchForHosts(bool xmit)
|
||||
{
|
||||
(void)xmit;
|
||||
|
||||
if (!sv.active)
|
||||
if(!sv.active)
|
||||
return;
|
||||
|
||||
hostCacheCount = 1;
|
||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
||||
if(Q_strcmp(hostname.string, "UNNAMED") == 0)
|
||||
Q_strcpy(hostcache[0].name, "local");
|
||||
else
|
||||
Q_strcpy(hostcache[0].name, hostname.string);
|
||||
|
@ -69,34 +69,34 @@ void Loop_SearchForHosts (bool xmit)
|
|||
}
|
||||
|
||||
|
||||
qsocket_t *Loop_Connect (const char *host)
|
||||
qsocket_t *Loop_Connect(const char *host)
|
||||
{
|
||||
if (Q_strcmp(host,"local") != 0)
|
||||
if(Q_strcmp(host, "local") != 0)
|
||||
return NULL;
|
||||
|
||||
localconnectpending = true;
|
||||
|
||||
if (!loop_client)
|
||||
if(!loop_client)
|
||||
{
|
||||
if ((loop_client = NET_NewQSocket ()) == NULL)
|
||||
if((loop_client = NET_NewQSocket()) == NULL)
|
||||
{
|
||||
Con_Printf("Loop_Connect: no qsocket available\n");
|
||||
return NULL;
|
||||
}
|
||||
Q_strcpy (loop_client->address, "localhost");
|
||||
Q_strcpy(loop_client->address, "localhost");
|
||||
}
|
||||
loop_client->receiveMessageLength = 0;
|
||||
loop_client->sendMessageLength = 0;
|
||||
loop_client->canSend = true;
|
||||
|
||||
if (!loop_server)
|
||||
if(!loop_server)
|
||||
{
|
||||
if ((loop_server = NET_NewQSocket ()) == NULL)
|
||||
if((loop_server = NET_NewQSocket()) == NULL)
|
||||
{
|
||||
Con_Printf("Loop_Connect: no qsocket available\n");
|
||||
return NULL;
|
||||
}
|
||||
Q_strcpy (loop_server->address, "LOCAL");
|
||||
Q_strcpy(loop_server->address, "LOCAL");
|
||||
}
|
||||
loop_server->receiveMessageLength = 0;
|
||||
loop_server->sendMessageLength = 0;
|
||||
|
@ -109,9 +109,9 @@ qsocket_t *Loop_Connect (const char *host)
|
|||
}
|
||||
|
||||
|
||||
qsocket_t *Loop_CheckNewConnections (void)
|
||||
qsocket_t *Loop_CheckNewConnections(void)
|
||||
{
|
||||
if (!localconnectpending)
|
||||
if(!localconnectpending)
|
||||
return NULL;
|
||||
|
||||
localconnectpending = false;
|
||||
|
@ -131,44 +131,44 @@ static int32_t IntAlign(int32_t value)
|
|||
}
|
||||
|
||||
|
||||
int32_t Loop_GetMessage (qsocket_t *sock)
|
||||
int32_t Loop_GetMessage(qsocket_t *sock)
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t length;
|
||||
|
||||
if (sock->receiveMessageLength == 0)
|
||||
if(sock->receiveMessageLength == 0)
|
||||
return 0;
|
||||
|
||||
ret = sock->receiveMessage[0];
|
||||
length = sock->receiveMessage[1] + (sock->receiveMessage[2] << 8);
|
||||
// alignment byte skipped here
|
||||
SZ_Clear (&net_message);
|
||||
SZ_Write (&net_message, &sock->receiveMessage[4], length);
|
||||
SZ_Clear(&net_message);
|
||||
SZ_Write(&net_message, &sock->receiveMessage[4], length);
|
||||
|
||||
length = IntAlign(length + 4);
|
||||
sock->receiveMessageLength -= length;
|
||||
|
||||
if (sock->receiveMessageLength)
|
||||
memmove (sock->receiveMessage, &sock->receiveMessage[length], sock->receiveMessageLength);
|
||||
if(sock->receiveMessageLength)
|
||||
memmove(sock->receiveMessage, &sock->receiveMessage[length], sock->receiveMessageLength);
|
||||
|
||||
if (sock->driverdata && ret == 1)
|
||||
if(sock->driverdata && ret == 1)
|
||||
((qsocket_t *)sock->driverdata)->canSend = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int32_t Loop_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
int32_t Loop_SendMessage(qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
byte *buffer;
|
||||
int32_t *bufferLength;
|
||||
|
||||
if (!sock->driverdata)
|
||||
if(!sock->driverdata)
|
||||
return -1;
|
||||
|
||||
bufferLength = &((qsocket_t *)sock->driverdata)->receiveMessageLength;
|
||||
|
||||
if ((*bufferLength + data->cursize + 4) > NET_MAXMESSAGE)
|
||||
if((*bufferLength + data->cursize + 4) > NET_MAXMESSAGE)
|
||||
Sys_Error("Loop_SendMessage: overflow");
|
||||
|
||||
buffer = ((qsocket_t *)sock->driverdata)->receiveMessage + *bufferLength;
|
||||
|
@ -192,17 +192,17 @@ int32_t Loop_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
}
|
||||
|
||||
|
||||
int32_t Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
int32_t Loop_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
byte *buffer;
|
||||
int32_t *bufferLength;
|
||||
|
||||
if (!sock->driverdata)
|
||||
if(!sock->driverdata)
|
||||
return -1;
|
||||
|
||||
bufferLength = &((qsocket_t *)sock->driverdata)->receiveMessageLength;
|
||||
|
||||
if ((*bufferLength + data->cursize + sizeof(byte) + sizeof(int16_t)) > NET_MAXMESSAGE)
|
||||
if((*bufferLength + data->cursize + sizeof(byte) + sizeof(int16_t)) > NET_MAXMESSAGE)
|
||||
return 0;
|
||||
|
||||
buffer = ((qsocket_t *)sock->driverdata)->receiveMessage + *bufferLength;
|
||||
|
@ -224,29 +224,29 @@ int32_t Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
}
|
||||
|
||||
|
||||
bool Loop_CanSendMessage (qsocket_t *sock)
|
||||
bool Loop_CanSendMessage(qsocket_t *sock)
|
||||
{
|
||||
if (!sock->driverdata)
|
||||
if(!sock->driverdata)
|
||||
return false;
|
||||
return sock->canSend;
|
||||
}
|
||||
|
||||
|
||||
bool Loop_CanSendUnreliableMessage (qsocket_t *sock)
|
||||
bool Loop_CanSendUnreliableMessage(qsocket_t *sock)
|
||||
{
|
||||
(void)sock;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Loop_Close (qsocket_t *sock)
|
||||
void Loop_Close(qsocket_t *sock)
|
||||
{
|
||||
if (sock->driverdata)
|
||||
if(sock->driverdata)
|
||||
((qsocket_t *)sock->driverdata)->driverdata = NULL;
|
||||
sock->receiveMessageLength = 0;
|
||||
sock->sendMessageLength = 0;
|
||||
sock->canSend = true;
|
||||
if (sock == loop_client)
|
||||
if(sock == loop_client)
|
||||
loop_client = NULL;
|
||||
else
|
||||
loop_server = NULL;
|
||||
|
|
|
@ -23,18 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define __NET_LOOP_H
|
||||
|
||||
// net_loop.h
|
||||
int32_t Loop_Init (void);
|
||||
void Loop_Listen (bool state);
|
||||
void Loop_SearchForHosts (bool xmit);
|
||||
qsocket_t *Loop_Connect (const char *host);
|
||||
qsocket_t *Loop_CheckNewConnections (void);
|
||||
int32_t Loop_GetMessage (qsocket_t *sock);
|
||||
int32_t Loop_SendMessage (qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
|
||||
bool Loop_CanSendMessage (qsocket_t *sock);
|
||||
bool Loop_CanSendUnreliableMessage (qsocket_t *sock);
|
||||
void Loop_Close (qsocket_t *sock);
|
||||
void Loop_Shutdown (void);
|
||||
int32_t Loop_Init(void);
|
||||
void Loop_Listen(bool state);
|
||||
void Loop_SearchForHosts(bool xmit);
|
||||
qsocket_t *Loop_Connect(const char *host);
|
||||
qsocket_t *Loop_CheckNewConnections(void);
|
||||
int32_t Loop_GetMessage(qsocket_t *sock);
|
||||
int32_t Loop_SendMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
int32_t Loop_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data);
|
||||
bool Loop_CanSendMessage(qsocket_t *sock);
|
||||
bool Loop_CanSendUnreliableMessage(qsocket_t *sock);
|
||||
void Loop_Close(qsocket_t *sock);
|
||||
void Loop_Shutdown(void);
|
||||
|
||||
#endif /* __NET_LOOP_H */
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ bool slistLocal = true;
|
|||
static double slistStartTime;
|
||||
static int32_t slistLastShown;
|
||||
|
||||
static void Slist_Send (void *);
|
||||
static void Slist_Poll (void *);
|
||||
static void Slist_Send(void *);
|
||||
static void Slist_Poll(void *);
|
||||
static PollProcedure slistSendProcedure = {NULL, 0.0, Slist_Send};
|
||||
static PollProcedure slistPollProcedure = {NULL, 0.0, Slist_Poll};
|
||||
|
||||
|
@ -59,7 +59,7 @@ int32_t messagesReceived = 0;
|
|||
int32_t unreliableMessagesSent = 0;
|
||||
int32_t unreliableMessagesReceived = 0;
|
||||
|
||||
static cvar_t net_messagetimeout = {"net_messagetimeout","300",CVAR_NONE};
|
||||
static cvar_t net_messagetimeout = {"net_messagetimeout", "300", CVAR_NONE};
|
||||
cvar_t hostname = {"hostname", "UNNAMED", CVAR_NONE};
|
||||
|
||||
// these two macros are to make the code more readable
|
||||
|
@ -71,7 +71,7 @@ int32_t net_driverlevel;
|
|||
double net_time;
|
||||
|
||||
|
||||
double SetNetTime (void)
|
||||
double SetNetTime(void)
|
||||
{
|
||||
net_time = Sys_DoubleTime();
|
||||
return net_time;
|
||||
|
@ -86,14 +86,14 @@ Called by drivers when a new communications endpoint is required
|
|||
The sequence and buffer fields will be filled in properly
|
||||
===================
|
||||
*/
|
||||
qsocket_t *NET_NewQSocket (void)
|
||||
qsocket_t *NET_NewQSocket(void)
|
||||
{
|
||||
qsocket_t *sock;
|
||||
|
||||
if (net_freeSockets == NULL)
|
||||
if(net_freeSockets == NULL)
|
||||
return NULL;
|
||||
|
||||
if (net_activeconnections >= svs.maxclients)
|
||||
if(net_activeconnections >= svs.maxclients)
|
||||
return NULL;
|
||||
|
||||
// get one from free list
|
||||
|
@ -106,7 +106,7 @@ qsocket_t *NET_NewQSocket (void)
|
|||
|
||||
sock->disconnected = false;
|
||||
sock->connecttime = net_time;
|
||||
Q_strcpy (sock->address,"UNSET ADDRESS");
|
||||
Q_strcpy(sock->address, "UNSET ADDRESS");
|
||||
sock->driver = net_driverlevel;
|
||||
sock->socket = 0;
|
||||
sock->driverdata = NULL;
|
||||
|
@ -130,21 +130,21 @@ void NET_FreeQSocket(qsocket_t *sock)
|
|||
qsocket_t *s;
|
||||
|
||||
// remove it from active list
|
||||
if (sock == net_activeSockets)
|
||||
if(sock == net_activeSockets)
|
||||
net_activeSockets = net_activeSockets->next;
|
||||
else
|
||||
{
|
||||
for (s = net_activeSockets; s; s = s->next)
|
||||
for(s = net_activeSockets; s; s = s->next)
|
||||
{
|
||||
if (s->next == sock)
|
||||
if(s->next == sock)
|
||||
{
|
||||
s->next = sock->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s)
|
||||
Sys_Error ("NET_FreeQSocket: not active");
|
||||
if(!s)
|
||||
Sys_Error("NET_FreeQSocket: not active");
|
||||
}
|
||||
|
||||
// add it to free list
|
||||
|
@ -154,101 +154,101 @@ void NET_FreeQSocket(qsocket_t *sock)
|
|||
}
|
||||
|
||||
|
||||
double NET_QSocketGetTime (const qsocket_t *s)
|
||||
double NET_QSocketGetTime(const qsocket_t *s)
|
||||
{
|
||||
return s->connecttime;
|
||||
}
|
||||
|
||||
|
||||
const char *NET_QSocketGetAddressString (const qsocket_t *s)
|
||||
const char *NET_QSocketGetAddressString(const qsocket_t *s)
|
||||
{
|
||||
return s->address;
|
||||
}
|
||||
|
||||
|
||||
static void NET_Listen_f (void)
|
||||
static void NET_Listen_f(void)
|
||||
{
|
||||
if (Cmd_Argc () != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("\"listen\" is \"%" PRIi32 "\"\n", listening ? 1 : 0);
|
||||
Con_Printf("\"listen\" is \"%" PRIi32 "\"\n", listening ? 1 : 0);
|
||||
return;
|
||||
}
|
||||
|
||||
listening = Q_atoi(Cmd_Argv(1)) ? true : false;
|
||||
|
||||
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (net_drivers[net_driverlevel].initialized == false)
|
||||
if(net_drivers[net_driverlevel].initialized == false)
|
||||
continue;
|
||||
dfunc.Listen (listening);
|
||||
dfunc.Listen(listening);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void MaxPlayers_f (void)
|
||||
static void MaxPlayers_f(void)
|
||||
{
|
||||
int32_t n;
|
||||
|
||||
if (Cmd_Argc () != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("\"maxplayers\" is \"%" PRIi32 "\"\n", svs.maxclients);
|
||||
Con_Printf("\"maxplayers\" is \"%" PRIi32 "\"\n", svs.maxclients);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sv.active)
|
||||
if(sv.active)
|
||||
{
|
||||
Con_Printf ("maxplayers can not be changed while a server is running.\n");
|
||||
Con_Printf("maxplayers can not be changed while a server is running.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
n = Q_atoi(Cmd_Argv(1));
|
||||
if (n < 1)
|
||||
if(n < 1)
|
||||
n = 1;
|
||||
if (n > svs.maxclientslimit)
|
||||
if(n > svs.maxclientslimit)
|
||||
{
|
||||
n = svs.maxclientslimit;
|
||||
Con_Printf ("\"maxplayers\" set to \"%" PRIi32 "\"\n", n);
|
||||
Con_Printf("\"maxplayers\" set to \"%" PRIi32 "\"\n", n);
|
||||
}
|
||||
|
||||
if ((n == 1) && listening)
|
||||
Cbuf_AddText ("listen 0\n");
|
||||
if((n == 1) && listening)
|
||||
Cbuf_AddText("listen 0\n");
|
||||
|
||||
if ((n > 1) && (!listening))
|
||||
Cbuf_AddText ("listen 1\n");
|
||||
if((n > 1) && (!listening))
|
||||
Cbuf_AddText("listen 1\n");
|
||||
|
||||
svs.maxclients = n;
|
||||
if (n == 1)
|
||||
Cvar_Set ("deathmatch", "0");
|
||||
if(n == 1)
|
||||
Cvar_Set("deathmatch", "0");
|
||||
else
|
||||
Cvar_Set ("deathmatch", "1");
|
||||
Cvar_Set("deathmatch", "1");
|
||||
}
|
||||
|
||||
|
||||
static void NET_Port_f (void)
|
||||
static void NET_Port_f(void)
|
||||
{
|
||||
int32_t n;
|
||||
|
||||
if (Cmd_Argc () != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Con_Printf ("\"port\" is \"%" PRIi32 "\"\n", net_hostport);
|
||||
Con_Printf("\"port\" is \"%" PRIi32 "\"\n", net_hostport);
|
||||
return;
|
||||
}
|
||||
|
||||
n = Q_atoi(Cmd_Argv(1));
|
||||
if (n < 1 || n > 65534)
|
||||
if(n < 1 || n > 65534)
|
||||
{
|
||||
Con_Printf ("Bad value, must be between 1 and 65534\n");
|
||||
Con_Printf("Bad value, must be between 1 and 65534\n");
|
||||
return;
|
||||
}
|
||||
|
||||
DEFAULTnet_hostport = n;
|
||||
net_hostport = n;
|
||||
|
||||
if (listening)
|
||||
if(listening)
|
||||
{
|
||||
// force a change to the new port
|
||||
Cbuf_AddText ("listen 0\n");
|
||||
Cbuf_AddText ("listen 1\n");
|
||||
Cbuf_AddText("listen 0\n");
|
||||
Cbuf_AddText("listen 1\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,9 +265,9 @@ static void PrintSlist(void)
|
|||
{
|
||||
int32_t n;
|
||||
|
||||
for (n = slistLastShown; n < hostCacheCount; n++)
|
||||
for(n = slistLastShown; n < hostCacheCount; n++)
|
||||
{
|
||||
if (hostcache[n].maxusers)
|
||||
if(hostcache[n].maxusers)
|
||||
Con_Printf("%-15.15s %-15.15s %2" PRIu32 "/%2" PRIu32 "\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers);
|
||||
else
|
||||
Con_Printf("%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
|
||||
|
@ -278,19 +278,19 @@ static void PrintSlist(void)
|
|||
|
||||
static void PrintSlistTrailer(void)
|
||||
{
|
||||
if (hostCacheCount)
|
||||
if(hostCacheCount)
|
||||
Con_Printf("== end list ==\n\n");
|
||||
else
|
||||
Con_Printf("No Quake servers found.\n\n");
|
||||
}
|
||||
|
||||
|
||||
void NET_Slist_f (void)
|
||||
void NET_Slist_f(void)
|
||||
{
|
||||
if (slistInProgress)
|
||||
if(slistInProgress)
|
||||
return;
|
||||
|
||||
if (! slistSilent)
|
||||
if(! slistSilent)
|
||||
{
|
||||
Con_Printf("Looking for Quake servers...\n");
|
||||
PrintSlistHeader();
|
||||
|
@ -306,17 +306,17 @@ void NET_Slist_f (void)
|
|||
}
|
||||
|
||||
|
||||
void NET_SlistSort (void)
|
||||
void NET_SlistSort(void)
|
||||
{
|
||||
if (hostCacheCount > 1)
|
||||
if(hostCacheCount > 1)
|
||||
{
|
||||
int32_t i, j;
|
||||
hostcache_t temp;
|
||||
for (i = 0; i < hostCacheCount; i++)
|
||||
for(i = 0; i < hostCacheCount; i++)
|
||||
{
|
||||
for (j = i + 1; j < hostCacheCount; j++)
|
||||
for(j = i + 1; j < hostCacheCount; j++)
|
||||
{
|
||||
if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
|
||||
if(strcmp(hostcache[j].name, hostcache[i].name) < 0)
|
||||
{
|
||||
memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
|
||||
memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
|
||||
|
@ -328,14 +328,14 @@ void NET_SlistSort (void)
|
|||
}
|
||||
|
||||
|
||||
const char *NET_SlistPrintServer (int32_t idx)
|
||||
const char *NET_SlistPrintServer(int32_t idx)
|
||||
{
|
||||
static char string[64];
|
||||
|
||||
if (idx < 0 || idx >= hostCacheCount)
|
||||
if(idx < 0 || idx >= hostCacheCount)
|
||||
return "";
|
||||
|
||||
if (hostcache[idx].maxusers)
|
||||
if(hostcache[idx].maxusers)
|
||||
{
|
||||
q_snprintf(string, sizeof(string), "%-15.15s %-15.15s %2" PRIu32 "/%2" PRIu32 "\n",
|
||||
hostcache[idx].name, hostcache[idx].map,
|
||||
|
@ -351,53 +351,53 @@ const char *NET_SlistPrintServer (int32_t idx)
|
|||
}
|
||||
|
||||
|
||||
const char *NET_SlistPrintServerName (int32_t idx)
|
||||
const char *NET_SlistPrintServerName(int32_t idx)
|
||||
{
|
||||
if (idx < 0 || idx >= hostCacheCount)
|
||||
if(idx < 0 || idx >= hostCacheCount)
|
||||
return "";
|
||||
return hostcache[idx].cname;
|
||||
}
|
||||
|
||||
|
||||
static void Slist_Send (void *unused)
|
||||
static void Slist_Send(void *unused)
|
||||
{
|
||||
(void)unused;
|
||||
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
|
||||
if(!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
|
||||
continue;
|
||||
if (net_drivers[net_driverlevel].initialized == false)
|
||||
if(net_drivers[net_driverlevel].initialized == false)
|
||||
continue;
|
||||
dfunc.SearchForHosts (true);
|
||||
dfunc.SearchForHosts(true);
|
||||
}
|
||||
|
||||
if ((Sys_DoubleTime() - slistStartTime) < 0.5)
|
||||
if((Sys_DoubleTime() - slistStartTime) < 0.5)
|
||||
SchedulePollProcedure(&slistSendProcedure, 0.75);
|
||||
}
|
||||
|
||||
|
||||
static void Slist_Poll (void *unused)
|
||||
static void Slist_Poll(void *unused)
|
||||
{
|
||||
(void)unused;
|
||||
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
|
||||
if(!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
|
||||
continue;
|
||||
if (net_drivers[net_driverlevel].initialized == false)
|
||||
if(net_drivers[net_driverlevel].initialized == false)
|
||||
continue;
|
||||
dfunc.SearchForHosts (false);
|
||||
dfunc.SearchForHosts(false);
|
||||
}
|
||||
|
||||
if (! slistSilent)
|
||||
if(! slistSilent)
|
||||
PrintSlist();
|
||||
|
||||
if ((Sys_DoubleTime() - slistStartTime) < 1.5)
|
||||
if((Sys_DoubleTime() - slistStartTime) < 1.5)
|
||||
{
|
||||
SchedulePollProcedure(&slistPollProcedure, 0.1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! slistSilent)
|
||||
if(! slistSilent)
|
||||
PrintSlistTrailer();
|
||||
slistInProgress = false;
|
||||
slistSilent = false;
|
||||
|
@ -414,7 +414,7 @@ NET_Connect
|
|||
int32_t hostCacheCount = 0;
|
||||
hostcache_t hostcache[HOSTCACHESIZE];
|
||||
|
||||
qsocket_t *NET_Connect (const char *host)
|
||||
qsocket_t *NET_Connect(const char *host)
|
||||
{
|
||||
qsocket_t *ret;
|
||||
int32_t n;
|
||||
|
@ -422,49 +422,49 @@ qsocket_t *NET_Connect (const char *host)
|
|||
|
||||
SetNetTime();
|
||||
|
||||
if (host && *host == 0)
|
||||
if(host && *host == 0)
|
||||
host = NULL;
|
||||
|
||||
if (host)
|
||||
if(host)
|
||||
{
|
||||
if (q_strcasecmp (host, "local") == 0)
|
||||
if(q_strcasecmp(host, "local") == 0)
|
||||
{
|
||||
numdrivers = 1;
|
||||
goto JustDoIt;
|
||||
}
|
||||
|
||||
if (hostCacheCount)
|
||||
if(hostCacheCount)
|
||||
{
|
||||
for (n = 0; n < hostCacheCount; n++)
|
||||
if (q_strcasecmp (host, hostcache[n].name) == 0)
|
||||
for(n = 0; n < hostCacheCount; n++)
|
||||
if(q_strcasecmp(host, hostcache[n].name) == 0)
|
||||
{
|
||||
host = hostcache[n].cname;
|
||||
break;
|
||||
}
|
||||
if (n < hostCacheCount)
|
||||
if(n < hostCacheCount)
|
||||
goto JustDoIt;
|
||||
}
|
||||
}
|
||||
|
||||
slistSilent = host ? true : false;
|
||||
NET_Slist_f ();
|
||||
NET_Slist_f();
|
||||
|
||||
while (slistInProgress)
|
||||
while(slistInProgress)
|
||||
NET_Poll();
|
||||
|
||||
if (host == NULL)
|
||||
if(host == NULL)
|
||||
{
|
||||
if (hostCacheCount != 1)
|
||||
if(hostCacheCount != 1)
|
||||
return NULL;
|
||||
host = hostcache[0].cname;
|
||||
Con_Printf("Connecting to...\n%s @ %s\n\n", hostcache[0].name, host);
|
||||
}
|
||||
|
||||
if (hostCacheCount)
|
||||
if(hostCacheCount)
|
||||
{
|
||||
for (n = 0; n < hostCacheCount; n++)
|
||||
for(n = 0; n < hostCacheCount; n++)
|
||||
{
|
||||
if (q_strcasecmp (host, hostcache[n].name) == 0)
|
||||
if(q_strcasecmp(host, hostcache[n].name) == 0)
|
||||
{
|
||||
host = hostcache[n].cname;
|
||||
break;
|
||||
|
@ -473,16 +473,16 @@ qsocket_t *NET_Connect (const char *host)
|
|||
}
|
||||
|
||||
JustDoIt:
|
||||
for (net_driverlevel = 0; net_driverlevel < numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (net_drivers[net_driverlevel].initialized == false)
|
||||
if(net_drivers[net_driverlevel].initialized == false)
|
||||
continue;
|
||||
ret = dfunc.Connect (host);
|
||||
if (ret)
|
||||
ret = dfunc.Connect(host);
|
||||
if(ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (host)
|
||||
if(host)
|
||||
{
|
||||
Con_Printf("\n");
|
||||
PrintSlistHeader();
|
||||
|
@ -499,20 +499,20 @@ JustDoIt:
|
|||
NET_CheckNewConnections
|
||||
===================
|
||||
*/
|
||||
qsocket_t *NET_CheckNewConnections (void)
|
||||
qsocket_t *NET_CheckNewConnections(void)
|
||||
{
|
||||
qsocket_t *ret;
|
||||
|
||||
SetNetTime();
|
||||
|
||||
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (net_drivers[net_driverlevel].initialized == false)
|
||||
if(net_drivers[net_driverlevel].initialized == false)
|
||||
continue;
|
||||
if (!IS_LOOP_DRIVER(net_driverlevel) && listening == false)
|
||||
if(!IS_LOOP_DRIVER(net_driverlevel) && listening == false)
|
||||
continue;
|
||||
ret = dfunc.CheckNewConnections ();
|
||||
if (ret)
|
||||
ret = dfunc.CheckNewConnections();
|
||||
if(ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
@ -526,18 +526,18 @@ qsocket_t *NET_CheckNewConnections (void)
|
|||
NET_Close
|
||||
===================
|
||||
*/
|
||||
void NET_Close (qsocket_t *sock)
|
||||
void NET_Close(qsocket_t *sock)
|
||||
{
|
||||
if (!sock)
|
||||
if(!sock)
|
||||
return;
|
||||
|
||||
if (sock->disconnected)
|
||||
if(sock->disconnected)
|
||||
return;
|
||||
|
||||
SetNetTime();
|
||||
|
||||
// call the driver_Close function
|
||||
sfunc.Close (sock);
|
||||
sfunc.Close(sock);
|
||||
|
||||
NET_FreeQSocket(sock);
|
||||
}
|
||||
|
@ -554,14 +554,14 @@ returns 1 if a message was received
|
|||
returns -1 if connection is invalid
|
||||
=================
|
||||
*/
|
||||
int32_t NET_GetMessage (qsocket_t *sock)
|
||||
int32_t NET_GetMessage(qsocket_t *sock)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (!sock)
|
||||
if(!sock)
|
||||
return -1;
|
||||
|
||||
if (sock->disconnected)
|
||||
if(sock->disconnected)
|
||||
{
|
||||
Con_Printf("NET_GetMessage: disconnected socket\n");
|
||||
return -1;
|
||||
|
@ -572,23 +572,23 @@ int32_t NET_GetMessage (qsocket_t *sock)
|
|||
ret = sfunc.QGetMessage(sock);
|
||||
|
||||
// see if this connection has timed out
|
||||
if (ret == 0 && !IS_LOOP_DRIVER(sock->driver))
|
||||
if(ret == 0 && !IS_LOOP_DRIVER(sock->driver))
|
||||
{
|
||||
if (net_time - sock->lastMessageTime > net_messagetimeout.value)
|
||||
if(net_time - sock->lastMessageTime > net_messagetimeout.value)
|
||||
{
|
||||
NET_Close(sock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret > 0)
|
||||
if(ret > 0)
|
||||
{
|
||||
if (!IS_LOOP_DRIVER(sock->driver))
|
||||
if(!IS_LOOP_DRIVER(sock->driver))
|
||||
{
|
||||
sock->lastMessageTime = net_time;
|
||||
if (ret == 1)
|
||||
if(ret == 1)
|
||||
messagesReceived++;
|
||||
else if (ret == 2)
|
||||
else if(ret == 2)
|
||||
unreliableMessagesReceived++;
|
||||
}
|
||||
}
|
||||
|
@ -608,14 +608,14 @@ returns 1 if the message was sent properly
|
|||
returns -1 if the connection died
|
||||
==================
|
||||
*/
|
||||
int32_t NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
int32_t NET_SendMessage(qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
int32_t r;
|
||||
|
||||
if (!sock)
|
||||
if(!sock)
|
||||
return -1;
|
||||
|
||||
if (sock->disconnected)
|
||||
if(sock->disconnected)
|
||||
{
|
||||
Con_Printf("NET_SendMessage: disconnected socket\n");
|
||||
return -1;
|
||||
|
@ -623,21 +623,21 @@ int32_t NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
|
||||
SetNetTime();
|
||||
r = sfunc.QSendMessage(sock, data);
|
||||
if (r == 1 && !IS_LOOP_DRIVER(sock->driver))
|
||||
if(r == 1 && !IS_LOOP_DRIVER(sock->driver))
|
||||
messagesSent++;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int32_t NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
int32_t NET_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
int32_t r;
|
||||
|
||||
if (!sock)
|
||||
if(!sock)
|
||||
return -1;
|
||||
|
||||
if (sock->disconnected)
|
||||
if(sock->disconnected)
|
||||
{
|
||||
Con_Printf("NET_SendMessage: disconnected socket\n");
|
||||
return -1;
|
||||
|
@ -645,7 +645,7 @@ int32_t NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
|
||||
SetNetTime();
|
||||
r = sfunc.SendUnreliableMessage(sock, data);
|
||||
if (r == 1 && !IS_LOOP_DRIVER(sock->driver))
|
||||
if(r == 1 && !IS_LOOP_DRIVER(sock->driver))
|
||||
unreliableMessagesSent++;
|
||||
|
||||
return r;
|
||||
|
@ -660,12 +660,12 @@ Returns true or false if the given qsocket can currently accept a
|
|||
message to be transmitted.
|
||||
==================
|
||||
*/
|
||||
bool NET_CanSendMessage (qsocket_t *sock)
|
||||
bool NET_CanSendMessage(qsocket_t *sock)
|
||||
{
|
||||
if (!sock)
|
||||
if(!sock)
|
||||
return false;
|
||||
|
||||
if (sock->disconnected)
|
||||
if(sock->disconnected)
|
||||
return false;
|
||||
|
||||
SetNetTime();
|
||||
|
@ -674,7 +674,7 @@ bool NET_CanSendMessage (qsocket_t *sock)
|
|||
}
|
||||
|
||||
|
||||
int32_t NET_SendToAll (sizebuf_t *data, double blocktime)
|
||||
int32_t NET_SendToAll(sizebuf_t *data, double blocktime)
|
||||
{
|
||||
double start;
|
||||
int32_t i;
|
||||
|
@ -682,16 +682,16 @@ int32_t NET_SendToAll (sizebuf_t *data, double blocktime)
|
|||
bool msg_init[MAX_SCOREBOARD]; /* did we write the message to the client's connection */
|
||||
bool msg_sent[MAX_SCOREBOARD]; /* did the msg arrive its destination (canSend state). */
|
||||
|
||||
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
|
||||
for(i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
|
||||
{
|
||||
/*
|
||||
if (!host_client->netconnection)
|
||||
continue;
|
||||
if (host_client->active)
|
||||
*/
|
||||
if (host_client->netconnection && host_client->active)
|
||||
if(host_client->netconnection && host_client->active)
|
||||
{
|
||||
if (IS_LOOP_DRIVER(host_client->netconnection->driver))
|
||||
if(IS_LOOP_DRIVER(host_client->netconnection->driver))
|
||||
{
|
||||
NET_SendMessage(host_client->netconnection, data);
|
||||
msg_init[i] = true;
|
||||
|
@ -710,41 +710,41 @@ int32_t NET_SendToAll (sizebuf_t *data, double blocktime)
|
|||
}
|
||||
|
||||
start = Sys_DoubleTime();
|
||||
while (count)
|
||||
while(count)
|
||||
{
|
||||
count = 0;
|
||||
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
|
||||
for(i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++)
|
||||
{
|
||||
if (! msg_init[i])
|
||||
if(! msg_init[i])
|
||||
{
|
||||
if (NET_CanSendMessage (host_client->netconnection))
|
||||
if(NET_CanSendMessage(host_client->netconnection))
|
||||
{
|
||||
msg_init[i] = true;
|
||||
NET_SendMessage(host_client->netconnection, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
NET_GetMessage (host_client->netconnection);
|
||||
NET_GetMessage(host_client->netconnection);
|
||||
}
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! msg_sent[i])
|
||||
if(! msg_sent[i])
|
||||
{
|
||||
if (NET_CanSendMessage (host_client->netconnection))
|
||||
if(NET_CanSendMessage(host_client->netconnection))
|
||||
{
|
||||
msg_sent[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NET_GetMessage (host_client->netconnection);
|
||||
NET_GetMessage(host_client->netconnection);
|
||||
}
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((Sys_DoubleTime() - start) > blocktime)
|
||||
if((Sys_DoubleTime() - start) > blocktime)
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
|
@ -759,35 +759,35 @@ NET_Init
|
|||
====================
|
||||
*/
|
||||
|
||||
void NET_Init (void)
|
||||
void NET_Init(void)
|
||||
{
|
||||
int32_t i;
|
||||
qsocket_t *s;
|
||||
|
||||
i = COM_CheckParm ("-port");
|
||||
if (!i)
|
||||
i = COM_CheckParm ("-udpport");
|
||||
if (!i)
|
||||
i = COM_CheckParm ("-ipxport");
|
||||
i = COM_CheckParm("-port");
|
||||
if(!i)
|
||||
i = COM_CheckParm("-udpport");
|
||||
if(!i)
|
||||
i = COM_CheckParm("-ipxport");
|
||||
|
||||
if (i)
|
||||
if(i)
|
||||
{
|
||||
if (i < com_argc-1)
|
||||
DEFAULTnet_hostport = Q_atoi (com_argv[i+1]);
|
||||
if(i < com_argc - 1)
|
||||
DEFAULTnet_hostport = Q_atoi(com_argv[i + 1]);
|
||||
else
|
||||
Sys_Error ("NET_Init: you must specify a number after -port");
|
||||
Sys_Error("NET_Init: you must specify a number after -port");
|
||||
}
|
||||
net_hostport = DEFAULTnet_hostport;
|
||||
|
||||
net_numsockets = svs.maxclientslimit;
|
||||
if (cls.state != ca_dedicated)
|
||||
if(cls.state != ca_dedicated)
|
||||
net_numsockets++;
|
||||
if (COM_CheckParm("-listen") || cls.state == ca_dedicated)
|
||||
if(COM_CheckParm("-listen") || cls.state == ca_dedicated)
|
||||
listening = true;
|
||||
|
||||
SetNetTime();
|
||||
|
||||
for (i = 0; i < net_numsockets; i++)
|
||||
for(i = 0; i < net_numsockets; i++)
|
||||
{
|
||||
s = (qsocket_t *)Hunk_AllocName(sizeof(qsocket_t), "qsocket");
|
||||
s->next = net_freeSockets;
|
||||
|
@ -796,41 +796,41 @@ void NET_Init (void)
|
|||
}
|
||||
|
||||
// allocate space for network message buffer
|
||||
SZ_Alloc (&net_message, NET_MAXMESSAGE);
|
||||
SZ_Alloc(&net_message, NET_MAXMESSAGE);
|
||||
|
||||
Cvar_RegisterVariable (&net_messagetimeout);
|
||||
Cvar_RegisterVariable (&hostname);
|
||||
Cvar_RegisterVariable(&net_messagetimeout);
|
||||
Cvar_RegisterVariable(&hostname);
|
||||
|
||||
Cmd_AddCommand ("slist", NET_Slist_f);
|
||||
Cmd_AddCommand ("listen", NET_Listen_f);
|
||||
Cmd_AddCommand ("maxplayers", MaxPlayers_f);
|
||||
Cmd_AddCommand ("port", NET_Port_f);
|
||||
Cmd_AddCommand("slist", NET_Slist_f);
|
||||
Cmd_AddCommand("listen", NET_Listen_f);
|
||||
Cmd_AddCommand("maxplayers", MaxPlayers_f);
|
||||
Cmd_AddCommand("port", NET_Port_f);
|
||||
|
||||
// initialize all the drivers
|
||||
for (i = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(i = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (net_drivers[net_driverlevel].Init() == -1)
|
||||
if(net_drivers[net_driverlevel].Init() == -1)
|
||||
continue;
|
||||
i++;
|
||||
net_drivers[net_driverlevel].initialized = true;
|
||||
if (listening)
|
||||
net_drivers[net_driverlevel].Listen (true);
|
||||
if(listening)
|
||||
net_drivers[net_driverlevel].Listen(true);
|
||||
}
|
||||
|
||||
/* Loop_Init() returns -1 for dedicated server case,
|
||||
* therefore the i == 0 check is correct */
|
||||
if (i == 0
|
||||
if(i == 0
|
||||
&& cls.state == ca_dedicated
|
||||
)
|
||||
{
|
||||
Sys_Error("Network not available!");
|
||||
}
|
||||
|
||||
if (*my_ipx_address)
|
||||
if(*my_ipx_address)
|
||||
{
|
||||
Con_DPrintf("IPX address %s\n", my_ipx_address);
|
||||
}
|
||||
if (*my_tcpip_address)
|
||||
if(*my_tcpip_address)
|
||||
{
|
||||
Con_DPrintf("TCP/IP address %s\n", my_tcpip_address);
|
||||
}
|
||||
|
@ -842,23 +842,23 @@ NET_Shutdown
|
|||
====================
|
||||
*/
|
||||
|
||||
void NET_Shutdown (void)
|
||||
void NET_Shutdown(void)
|
||||
{
|
||||
qsocket_t *sock;
|
||||
|
||||
SetNetTime();
|
||||
|
||||
for (sock = net_activeSockets; sock; sock = sock->next)
|
||||
for(sock = net_activeSockets; sock; sock = sock->next)
|
||||
NET_Close(sock);
|
||||
|
||||
//
|
||||
// shutdown the drivers
|
||||
//
|
||||
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
for(net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
|
||||
{
|
||||
if (net_drivers[net_driverlevel].initialized == true)
|
||||
if(net_drivers[net_driverlevel].initialized == true)
|
||||
{
|
||||
net_drivers[net_driverlevel].Shutdown ();
|
||||
net_drivers[net_driverlevel].Shutdown();
|
||||
net_drivers[net_driverlevel].initialized = false;
|
||||
}
|
||||
}
|
||||
|
@ -873,9 +873,9 @@ void NET_Poll(void)
|
|||
|
||||
SetNetTime();
|
||||
|
||||
for (pp = pollProcedureList; pp; pp = pp->next)
|
||||
for(pp = pollProcedureList; pp; pp = pp->next)
|
||||
{
|
||||
if (pp->nextTime > net_time)
|
||||
if(pp->nextTime > net_time)
|
||||
break;
|
||||
pollProcedureList = pp->next;
|
||||
pp->procedure(pp->arg);
|
||||
|
@ -888,14 +888,14 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
|
|||
PollProcedure *pp, *prev;
|
||||
|
||||
proc->nextTime = Sys_DoubleTime() + timeOffset;
|
||||
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
|
||||
for(pp = pollProcedureList, prev = NULL; pp; pp = pp->next)
|
||||
{
|
||||
if (pp->nextTime >= proc->nextTime)
|
||||
if(pp->nextTime >= proc->nextTime)
|
||||
break;
|
||||
prev = pp;
|
||||
}
|
||||
|
||||
if (prev == NULL)
|
||||
if(prev == NULL)
|
||||
{
|
||||
proc->next = pollProcedureList;
|
||||
pollProcedureList = proc;
|
||||
|
|
|
@ -28,10 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
void PL_SetWindowIcon(void);
|
||||
|
||||
/* platform dependent cleanup */
|
||||
void PL_VID_Shutdown (void);
|
||||
void PL_VID_Shutdown(void);
|
||||
|
||||
/* retrieve text from the clipboard (returns Z_Malloc()'ed data) */
|
||||
char *PL_GetClipboardData (void);
|
||||
char *PL_GetClipboardData(void);
|
||||
|
||||
/* show an error dialog */
|
||||
void PL_ErrorDialog(const char *text);
|
||||
|
|
703
source/pr_cmds.c
703
source/pr_cmds.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
113
source/pr_exec.c
113
source/pr_exec.c
|
@ -129,8 +129,8 @@ static const char *pr_opnames[] =
|
|||
"BITOR"
|
||||
};
|
||||
|
||||
const char *PR_GlobalString (int32_t ofs);
|
||||
const char *PR_GlobalStringNoContents (int32_t ofs);
|
||||
const char *PR_GlobalString(int32_t ofs);
|
||||
const char *PR_GlobalStringNoContents(int32_t ofs);
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
@ -140,36 +140,36 @@ const char *PR_GlobalStringNoContents (int32_t ofs);
|
|||
PR_PrintStatement
|
||||
=================
|
||||
*/
|
||||
static void PR_PrintStatement (dstatement_t *s)
|
||||
static void PR_PrintStatement(dstatement_t *s)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if ((uint32_t)s->op < sizeof(pr_opnames)/sizeof(pr_opnames[0]))
|
||||
if((uint32_t)s->op < sizeof(pr_opnames) / sizeof(pr_opnames[0]))
|
||||
{
|
||||
Con_Printf("%s ", pr_opnames[s->op]);
|
||||
i = strlen(pr_opnames[s->op]);
|
||||
for ( ; i < 10; i++)
|
||||
for(; i < 10; i++)
|
||||
Con_Printf(" ");
|
||||
}
|
||||
|
||||
if (s->op == OP_IF || s->op == OP_IFNOT)
|
||||
if(s->op == OP_IF || s->op == OP_IFNOT)
|
||||
Con_Printf("%sbranch %" PRIi32 "", PR_GlobalString(s->a), s->b);
|
||||
else if (s->op == OP_GOTO)
|
||||
else if(s->op == OP_GOTO)
|
||||
{
|
||||
Con_Printf("branch %" PRIi32 "", s->a);
|
||||
}
|
||||
else if ((uint32_t)(s->op-OP_STORE_F) < 6)
|
||||
else if((uint32_t)(s->op - OP_STORE_F) < 6)
|
||||
{
|
||||
Con_Printf("%s", PR_GlobalString(s->a));
|
||||
Con_Printf("%s", PR_GlobalStringNoContents(s->b));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s->a)
|
||||
if(s->a)
|
||||
Con_Printf("%s", PR_GlobalString(s->a));
|
||||
if (s->b)
|
||||
if(s->b)
|
||||
Con_Printf("%s", PR_GlobalString(s->b));
|
||||
if (s->c)
|
||||
if(s->c)
|
||||
Con_Printf("%s", PR_GlobalStringNoContents(s->c));
|
||||
}
|
||||
Con_Printf("\n");
|
||||
|
@ -180,22 +180,22 @@ static void PR_PrintStatement (dstatement_t *s)
|
|||
PR_StackTrace
|
||||
============
|
||||
*/
|
||||
static void PR_StackTrace (void)
|
||||
static void PR_StackTrace(void)
|
||||
{
|
||||
int32_t i;
|
||||
dfunction_t *f;
|
||||
|
||||
if (pr_depth == 0)
|
||||
if(pr_depth == 0)
|
||||
{
|
||||
Con_Printf("<NO STACK>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pr_stack[pr_depth].f = pr_xfunction;
|
||||
for (i = pr_depth; i >= 0; i--)
|
||||
for(i = pr_depth; i >= 0; i--)
|
||||
{
|
||||
f = pr_stack[i].f;
|
||||
if (!f)
|
||||
if(!f)
|
||||
{
|
||||
Con_Printf("<NO FUNCTION>\n");
|
||||
}
|
||||
|
@ -213,13 +213,13 @@ PR_Profile_f
|
|||
|
||||
============
|
||||
*/
|
||||
void PR_Profile_f (void)
|
||||
void PR_Profile_f(void)
|
||||
{
|
||||
int32_t i, num;
|
||||
int32_t pmax;
|
||||
dfunction_t *f, *best;
|
||||
|
||||
if (!sv.active)
|
||||
if(!sv.active)
|
||||
return;
|
||||
|
||||
num = 0;
|
||||
|
@ -227,23 +227,24 @@ void PR_Profile_f (void)
|
|||
{
|
||||
pmax = 0;
|
||||
best = NULL;
|
||||
for (i = 0; i < progs->numfunctions; i++)
|
||||
for(i = 0; i < progs->numfunctions; i++)
|
||||
{
|
||||
f = &pr_functions[i];
|
||||
if (f->profile > pmax)
|
||||
if(f->profile > pmax)
|
||||
{
|
||||
pmax = f->profile;
|
||||
best = f;
|
||||
}
|
||||
}
|
||||
if (best)
|
||||
if(best)
|
||||
{
|
||||
if (num < 10)
|
||||
if(num < 10)
|
||||
Con_Printf("%7" PRIi32 " %s\n", best->profile, PR_GetString(best->s_name));
|
||||
num++;
|
||||
best->profile = 0;
|
||||
}
|
||||
} while (best);
|
||||
}
|
||||
while(best);
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,14 +255,14 @@ PR_RunError
|
|||
Aborts the currently executing function
|
||||
============
|
||||
*/
|
||||
void PR_RunError (const char *error, ...)
|
||||
void PR_RunError(const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
q_vsnprintf (string, sizeof(string), error, argptr);
|
||||
va_end (argptr);
|
||||
va_start(argptr, error);
|
||||
q_vsnprintf(string, sizeof(string), error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
PR_PrintStatement(pr_statements + pr_xstatement);
|
||||
PR_StackTrace();
|
||||
|
@ -280,32 +281,32 @@ PR_EnterFunction
|
|||
Returns the new program statement counter
|
||||
====================
|
||||
*/
|
||||
static int32_t PR_EnterFunction (dfunction_t *f)
|
||||
static int32_t PR_EnterFunction(dfunction_t *f)
|
||||
{
|
||||
int32_t i, j, c, o;
|
||||
|
||||
pr_stack[pr_depth].s = pr_xstatement;
|
||||
pr_stack[pr_depth].f = pr_xfunction;
|
||||
pr_depth++;
|
||||
if (pr_depth >= MAX_STACK_DEPTH)
|
||||
if(pr_depth >= MAX_STACK_DEPTH)
|
||||
PR_RunError("stack overflow");
|
||||
|
||||
// save off any locals that the new function steps on
|
||||
c = f->locals;
|
||||
if (localstack_used + c > LOCALSTACK_SIZE)
|
||||
if(localstack_used + c > LOCALSTACK_SIZE)
|
||||
PR_RunError("PR_ExecuteProgram: locals stack overflow\n");
|
||||
|
||||
for (i = 0; i < c ; i++)
|
||||
for(i = 0; i < c ; i++)
|
||||
localstack[localstack_used + i] = ((int32_t *)pr_globals)[f->parm_start + i];
|
||||
localstack_used += c;
|
||||
|
||||
// copy parameters
|
||||
o = f->parm_start;
|
||||
for (i = 0; i < f->numparms; i++)
|
||||
for(i = 0; i < f->numparms; i++)
|
||||
{
|
||||
for (j = 0; j < f->parm_size[i]; j++)
|
||||
for(j = 0; j < f->parm_size[i]; j++)
|
||||
{
|
||||
((int32_t *)pr_globals)[o] = ((int32_t *)pr_globals)[OFS_PARM0 + i*3 + j];
|
||||
((int32_t *)pr_globals)[o] = ((int32_t *)pr_globals)[OFS_PARM0 + i * 3 + j];
|
||||
o++;
|
||||
}
|
||||
}
|
||||
|
@ -319,20 +320,20 @@ static int32_t PR_EnterFunction (dfunction_t *f)
|
|||
PR_LeaveFunction
|
||||
====================
|
||||
*/
|
||||
static int32_t PR_LeaveFunction (void)
|
||||
static int32_t PR_LeaveFunction(void)
|
||||
{
|
||||
int32_t i, c;
|
||||
|
||||
if (pr_depth <= 0)
|
||||
if(pr_depth <= 0)
|
||||
Host_Error("prog stack underflow");
|
||||
|
||||
// Restore locals from the stack
|
||||
c = pr_xfunction->locals;
|
||||
localstack_used -= c;
|
||||
if (localstack_used < 0)
|
||||
if(localstack_used < 0)
|
||||
PR_RunError("PR_ExecuteProgram: locals stack underflow");
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
for(i = 0; i < c; i++)
|
||||
((int32_t *)pr_globals)[pr_xfunction->parm_start + i] = localstack[localstack_used + i];
|
||||
|
||||
// up stack
|
||||
|
@ -353,7 +354,7 @@ The interpretation main loop
|
|||
#define OPB ((eval_t *)&pr_globals[(uint16_t)st->b])
|
||||
#define OPC ((eval_t *)&pr_globals[(uint16_t)st->c])
|
||||
|
||||
void PR_ExecuteProgram (func_t fnum)
|
||||
void PR_ExecuteProgram(func_t fnum)
|
||||
{
|
||||
eval_t *ptr;
|
||||
dstatement_t *st;
|
||||
|
@ -362,11 +363,11 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
edict_t *ed;
|
||||
int32_t exitdepth;
|
||||
|
||||
if (!fnum || fnum >= progs->numfunctions)
|
||||
if(!fnum || fnum >= progs->numfunctions)
|
||||
{
|
||||
if (pr_global_struct->self)
|
||||
ED_Print (PROG_TO_EDICT(pr_global_struct->self));
|
||||
Host_Error ("PR_ExecuteProgram: NULL function");
|
||||
if(pr_global_struct->self)
|
||||
ED_Print(PROG_TO_EDICT(pr_global_struct->self));
|
||||
Host_Error("PR_ExecuteProgram: NULL function");
|
||||
}
|
||||
|
||||
f = &pr_functions[fnum];
|
||||
|
@ -379,20 +380,20 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
st = &pr_statements[PR_EnterFunction(f)];
|
||||
startprofile = profile = 0;
|
||||
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
st++; /* next statement */
|
||||
|
||||
if (++profile > 100000)
|
||||
if(++profile > 100000)
|
||||
{
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("runaway loop error");
|
||||
}
|
||||
|
||||
if (pr_trace)
|
||||
if(pr_trace)
|
||||
PR_PrintStatement(st);
|
||||
|
||||
switch (st->op)
|
||||
switch(st->op)
|
||||
{
|
||||
case OP_ADD_F:
|
||||
OPC->_float = OPA->_float + OPB->_float;
|
||||
|
@ -547,7 +548,7 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
if (ed == (edict_t *)sv.edicts && sv.state == ss_active)
|
||||
if(ed == (edict_t *)sv.edicts && sv.state == ss_active)
|
||||
{
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("assignment to world entity");
|
||||
|
@ -579,12 +580,12 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
break;
|
||||
|
||||
case OP_IFNOT:
|
||||
if (!OPA->_int)
|
||||
if(!OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_IF:
|
||||
if (OPA->_int)
|
||||
if(OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
|
@ -605,13 +606,14 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
startprofile = profile;
|
||||
pr_xstatement = st - pr_statements;
|
||||
pr_argc = st->op - OP_CALL0;
|
||||
if (!OPA->function)
|
||||
if(!OPA->function)
|
||||
PR_RunError("NULL function");
|
||||
newf = &pr_functions[OPA->function];
|
||||
if (newf->first_statement < 0)
|
||||
{ // Built-in function
|
||||
if(newf->first_statement < 0)
|
||||
{
|
||||
// Built-in function
|
||||
int32_t i = -newf->first_statement;
|
||||
if (i >= pr_numbuiltins)
|
||||
if(i >= pr_numbuiltins)
|
||||
PR_RunError("Bad builtin call number %" PRIi32 "", i);
|
||||
pr_builtins[i]();
|
||||
break;
|
||||
|
@ -629,8 +631,9 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
pr_globals[OFS_RETURN + 1] = pr_globals[(uint16_t)st->a + 1];
|
||||
pr_globals[OFS_RETURN + 2] = pr_globals[(uint16_t)st->a + 2];
|
||||
st = &pr_statements[PR_LeaveFunction()];
|
||||
if (pr_depth == exitdepth)
|
||||
{ // Done
|
||||
if(pr_depth == exitdepth)
|
||||
{
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -68,28 +68,28 @@ extern float *pr_globals; /* same as pr_global_struct */
|
|||
extern int32_t pr_edict_size; /* in bytes */
|
||||
|
||||
|
||||
void PR_Init (void);
|
||||
void PR_Init(void);
|
||||
|
||||
void PR_ExecuteProgram (func_t fnum);
|
||||
void PR_LoadProgs (void);
|
||||
void PR_ExecuteProgram(func_t fnum);
|
||||
void PR_LoadProgs(void);
|
||||
|
||||
const char *PR_GetString (int32_t num);
|
||||
int32_t PR_SetEngineString (const char *s);
|
||||
int32_t PR_AllocString (int32_t bufferlength, char **ptr);
|
||||
const char *PR_GetString(int32_t num);
|
||||
int32_t PR_SetEngineString(const char *s);
|
||||
int32_t PR_AllocString(int32_t bufferlength, char **ptr);
|
||||
|
||||
void PR_Profile_f (void);
|
||||
void PR_Profile_f(void);
|
||||
|
||||
edict_t *ED_Alloc (void);
|
||||
void ED_Free (edict_t *ed);
|
||||
edict_t *ED_Alloc(void);
|
||||
void ED_Free(edict_t *ed);
|
||||
|
||||
void ED_Print (edict_t *ed);
|
||||
void ED_Write (FILE *f, edict_t *ed);
|
||||
const char *ED_ParseEdict (const char *data, edict_t *ent);
|
||||
void ED_Print(edict_t *ed);
|
||||
void ED_Write(FILE *f, edict_t *ed);
|
||||
const char *ED_ParseEdict(const char *data, edict_t *ent);
|
||||
|
||||
void ED_WriteGlobals (FILE *f);
|
||||
const char *ED_ParseGlobals (const char *data);
|
||||
void ED_WriteGlobals(FILE *f);
|
||||
const char *ED_ParseGlobals(const char *data);
|
||||
|
||||
void ED_LoadFromFile (const char *data);
|
||||
void ED_LoadFromFile(const char *data);
|
||||
|
||||
/*
|
||||
#define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
|
||||
|
@ -118,7 +118,7 @@ int32_t NUM_FOR_EDICT(edict_t *e);
|
|||
|
||||
extern int32_t type_size[8];
|
||||
|
||||
typedef void (*builtin_t) (void);
|
||||
typedef void (*builtin_t)(void);
|
||||
extern builtin_t *pr_builtins;
|
||||
extern int32_t pr_numbuiltins;
|
||||
|
||||
|
@ -130,13 +130,13 @@ extern int32_t pr_xstatement;
|
|||
|
||||
extern uint16_t pr_crc;
|
||||
|
||||
noreturn void PR_RunError (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
noreturn void PR_RunError(const char *error, ...) FUNC_PRINTF(1, 2);
|
||||
#ifdef __WATCOMC__
|
||||
#pragma aux PR_RunError aborts;
|
||||
#endif
|
||||
|
||||
void ED_PrintEdicts (void);
|
||||
void ED_PrintNum (int32_t ent);
|
||||
void ED_PrintEdicts(void);
|
||||
void ED_PrintNum(int32_t ent);
|
||||
|
||||
eval_t *GetEdictFieldValue(edict_t *ed, const char *field);
|
||||
|
||||
|
|
|
@ -162,12 +162,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define svc_time 7 // [float] server time
|
||||
#define svc_print 8 // [string] null terminated string
|
||||
#define svc_stufftext 9 // [string] stuffed into client's console buffer
|
||||
// the string should be \n terminated
|
||||
// the string should be \n terminated
|
||||
#define svc_setangle 10 // [angle3] set the view angle to this absolute value
|
||||
#define svc_serverinfo 11 // [long] version
|
||||
// [string] signon string
|
||||
// [string]..[0]model cache
|
||||
// [string]...[0]sounds cache
|
||||
// [string] signon string
|
||||
// [string]..[0]model cache
|
||||
// [string]...[0]sounds cache
|
||||
#define svc_lightstyle 12 // [byte] [string]
|
||||
#define svc_updatename 13 // [byte] [string]
|
||||
#define svc_updatefrags 14 // [byte] [int16_t]
|
||||
|
|
|
@ -63,10 +63,15 @@ static inline int32_t q_isblank(int32_t c)
|
|||
|
||||
static inline int32_t q_isspace(int32_t c)
|
||||
{
|
||||
switch(c) {
|
||||
case ' ': case '\t':
|
||||
case '\n': case '\r':
|
||||
case '\f': case '\v': return 1;
|
||||
switch(c)
|
||||
{
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\f':
|
||||
case '\v':
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -89,37 +89,37 @@ typedef struct
|
|||
int32_t dataofs; /* chunk starts this many bytes from file start */
|
||||
} wavinfo_t;
|
||||
|
||||
void S_Init (void);
|
||||
void S_Startup (void);
|
||||
void S_Shutdown (void);
|
||||
void S_StartSound (int32_t entnum, int32_t entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
|
||||
void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
|
||||
void S_StopSound (int32_t entnum, int32_t entchannel);
|
||||
void S_Init(void);
|
||||
void S_Startup(void);
|
||||
void S_Shutdown(void);
|
||||
void S_StartSound(int32_t entnum, int32_t entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
|
||||
void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation);
|
||||
void S_StopSound(int32_t entnum, int32_t entchannel);
|
||||
void S_StopAllSounds(bool clear);
|
||||
void S_ClearBuffer (void);
|
||||
void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up);
|
||||
void S_ExtraUpdate (void);
|
||||
void S_ClearBuffer(void);
|
||||
void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up);
|
||||
void S_ExtraUpdate(void);
|
||||
|
||||
void S_BlockSound (void);
|
||||
void S_UnblockSound (void);
|
||||
void S_BlockSound(void);
|
||||
void S_UnblockSound(void);
|
||||
|
||||
sfx_t *S_PrecacheSound (const char *sample);
|
||||
void S_TouchSound (const char *sample);
|
||||
void S_ClearPrecache (void);
|
||||
void S_BeginPrecaching (void);
|
||||
void S_EndPrecaching (void);
|
||||
void S_PaintChannels (int32_t endtime);
|
||||
void S_InitPaintChannels (void);
|
||||
sfx_t *S_PrecacheSound(const char *sample);
|
||||
void S_TouchSound(const char *sample);
|
||||
void S_ClearPrecache(void);
|
||||
void S_BeginPrecaching(void);
|
||||
void S_EndPrecaching(void);
|
||||
void S_PaintChannels(int32_t endtime);
|
||||
void S_InitPaintChannels(void);
|
||||
|
||||
/* picks a channel based on priorities, empty slots, number of channels */
|
||||
channel_t *SND_PickChannel (int32_t entnum, int32_t entchannel);
|
||||
channel_t *SND_PickChannel(int32_t entnum, int32_t entchannel);
|
||||
|
||||
/* spatializes a channel */
|
||||
void SND_Spatialize (channel_t *ch);
|
||||
void SND_Spatialize(channel_t *ch);
|
||||
|
||||
/* music stream support */
|
||||
void S_RawSamples(int32_t samples, int32_t rate, int32_t width, int32_t channels, byte * data, float volume);
|
||||
/* Expects data in signed 16 bit, or unsigned 8 bit format. */
|
||||
/* Expects data in signed 16 bit, or unsigned 8 bit format. */
|
||||
|
||||
/* initializes cycling through a DMA buffer and returns information on it */
|
||||
bool SNDDMA_Init(dma_t *dma);
|
||||
|
@ -179,12 +179,12 @@ extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
|||
|
||||
extern cvar_t bgmvolume;
|
||||
|
||||
void S_LocalSound (const char *name);
|
||||
sfxcache_t *S_LoadSound (sfx_t *s);
|
||||
void S_LocalSound(const char *name);
|
||||
sfxcache_t *S_LoadSound(sfx_t *s);
|
||||
|
||||
wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength);
|
||||
wavinfo_t GetWavinfo(const char *name, byte *wav, int32_t wavlength);
|
||||
|
||||
void SND_InitScaletable (void);
|
||||
void SND_InitScaletable(void);
|
||||
|
||||
#endif /* __QUAKE_SOUND__ */
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@ _Static_assert(sizeof(float) == 4, "float not correct size");
|
|||
_Static_assert(sizeof(int32_t) == 4, "int32_t not correct size");
|
||||
|
||||
/* make sure enums are the size of ints for structure packing */
|
||||
enum dummy_enum {
|
||||
enum dummy_enum
|
||||
{
|
||||
dummy_value
|
||||
};
|
||||
_Static_assert(sizeof(enum dummy_enum) == sizeof(int32_t), "enum not sizeof(int32_t)");
|
||||
|
|
376
source/qs_bmp.h
376
source/qs_bmp.h
|
@ -1,189 +1,189 @@
|
|||
0x42, 0x4d, 0xc6, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x02, 0x00, 0x00, 0x28, 0x00,
|
||||
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0xa4, 0x00,
|
||||
0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x05, 0x06, 0x07, 0x00, 0x06, 0x06,
|
||||
0x07, 0x00, 0x07, 0x06, 0x07, 0x00, 0x06, 0x07, 0x06, 0x00, 0x06, 0x07, 0x07, 0x00, 0x07, 0x07,
|
||||
0x07, 0x00, 0x07, 0x08, 0x07, 0x00, 0x08, 0x08, 0x08, 0x00, 0x07, 0x08, 0x09, 0x00, 0x08, 0x08,
|
||||
0x09, 0x00, 0x07, 0x09, 0x08, 0x00, 0x08, 0x09, 0x08, 0x00, 0x09, 0x09, 0x08, 0x00, 0x08, 0x09,
|
||||
0x09, 0x00, 0x09, 0x09, 0x09, 0x00, 0x08, 0x09, 0x0a, 0x00, 0x09, 0x09, 0x0a, 0x00, 0x09, 0x09,
|
||||
0x0b, 0x00, 0x09, 0x0a, 0x09, 0x00, 0x08, 0x0a, 0x0a, 0x00, 0x09, 0x0a, 0x0a, 0x00, 0x0a, 0x0a,
|
||||
0x0a, 0x00, 0x09, 0x0a, 0x0b, 0x00, 0x0a, 0x0a, 0x0b, 0x00, 0x09, 0x0a, 0x0c, 0x00, 0x09, 0x0b,
|
||||
0x0b, 0x00, 0x0a, 0x0b, 0x0b, 0x00, 0x0a, 0x0b, 0x0c, 0x00, 0x0b, 0x0b, 0x0c, 0x00, 0x0a, 0x0b,
|
||||
0x0d, 0x00, 0x0b, 0x0c, 0x0c, 0x00, 0x0b, 0x0c, 0x0d, 0x00, 0x0a, 0x0c, 0x0e, 0x00, 0x0b, 0x0c,
|
||||
0x0e, 0x00, 0x0c, 0x0c, 0x0f, 0x00, 0x0b, 0x0d, 0x0d, 0x00, 0x0b, 0x0d, 0x0e, 0x00, 0x0c, 0x0d,
|
||||
0x0e, 0x00, 0x0c, 0x0d, 0x0f, 0x00, 0x0d, 0x0d, 0x0f, 0x00, 0x0b, 0x0d, 0x10, 0x00, 0x0c, 0x0d,
|
||||
0x10, 0x00, 0x0c, 0x0e, 0x0f, 0x00, 0x0d, 0x0e, 0x0f, 0x00, 0x0c, 0x0e, 0x10, 0x00, 0x0d, 0x0e,
|
||||
0x10, 0x00, 0x0b, 0x0e, 0x11, 0x00, 0x0c, 0x0e, 0x11, 0x00, 0x0d, 0x0e, 0x11, 0x00, 0x0d, 0x0f,
|
||||
0x10, 0x00, 0x0d, 0x0f, 0x11, 0x00, 0x0e, 0x0f, 0x11, 0x00, 0x0d, 0x0f, 0x12, 0x00, 0x0e, 0x0f,
|
||||
0x12, 0x00, 0x0d, 0x0f, 0x13, 0x00, 0x0e, 0x10, 0x11, 0x00, 0x0d, 0x10, 0x12, 0x00, 0x0b, 0x10,
|
||||
0x13, 0x00, 0x0e, 0x10, 0x12, 0x00, 0x0e, 0x10, 0x13, 0x00, 0x0d, 0x10, 0x14, 0x00, 0x0e, 0x10,
|
||||
0x14, 0x00, 0x0d, 0x11, 0x13, 0x00, 0x0e, 0x11, 0x13, 0x00, 0x0f, 0x11, 0x13, 0x00, 0x0e, 0x11,
|
||||
0x14, 0x00, 0x0f, 0x11, 0x14, 0x00, 0x0f, 0x11, 0x15, 0x00, 0x0f, 0x12, 0x14, 0x00, 0x0f, 0x12,
|
||||
0x15, 0x00, 0x10, 0x12, 0x15, 0x00, 0x0f, 0x12, 0x16, 0x00, 0x10, 0x12, 0x16, 0x00, 0x0f, 0x12,
|
||||
0x17, 0x00, 0x0f, 0x13, 0x16, 0x00, 0x10, 0x13, 0x16, 0x00, 0x10, 0x13, 0x17, 0x00, 0x11, 0x13,
|
||||
0x17, 0x00, 0x11, 0x13, 0x18, 0x00, 0x10, 0x14, 0x17, 0x00, 0x11, 0x14, 0x17, 0x00, 0x10, 0x14,
|
||||
0x18, 0x00, 0x12, 0x15, 0x18, 0x00, 0x10, 0x15, 0x19, 0x00, 0x12, 0x15, 0x19, 0x00, 0x10, 0x15,
|
||||
0x1a, 0x00, 0x11, 0x15, 0x1a, 0x00, 0x12, 0x15, 0x1a, 0x00, 0x12, 0x15, 0x1b, 0x00, 0x11, 0x16,
|
||||
0x1a, 0x00, 0x12, 0x16, 0x1a, 0x00, 0x13, 0x16, 0x1a, 0x00, 0x12, 0x16, 0x1b, 0x00, 0x13, 0x16,
|
||||
0x1b, 0x00, 0x12, 0x17, 0x1b, 0x00, 0x13, 0x17, 0x1b, 0x00, 0x13, 0x17, 0x1c, 0x00, 0x14, 0x17,
|
||||
0x1c, 0x00, 0x14, 0x17, 0x1d, 0x00, 0x13, 0x18, 0x1d, 0x00, 0x14, 0x18, 0x1d, 0x00, 0x15, 0x18,
|
||||
0x1f, 0x00, 0x14, 0x19, 0x1d, 0x00, 0x15, 0x19, 0x1d, 0x00, 0x15, 0x19, 0x1e, 0x00, 0x15, 0x19,
|
||||
0x1f, 0x00, 0x16, 0x19, 0x1f, 0x00, 0x15, 0x19, 0x20, 0x00, 0x16, 0x1a, 0x1e, 0x00, 0x14, 0x1a,
|
||||
0x1f, 0x00, 0x15, 0x1a, 0x1f, 0x00, 0x16, 0x1a, 0x1f, 0x00, 0x15, 0x1a, 0x20, 0x00, 0x16, 0x1a,
|
||||
0x21, 0x00, 0x15, 0x1b, 0x21, 0x00, 0x17, 0x1b, 0x22, 0x00, 0x17, 0x1b, 0x23, 0x00, 0x16, 0x1c,
|
||||
0x22, 0x00, 0x17, 0x1d, 0x22, 0x00, 0x17, 0x1d, 0x23, 0x00, 0x18, 0x1d, 0x23, 0x00, 0x19, 0x1d,
|
||||
0x23, 0x00, 0x17, 0x1d, 0x24, 0x00, 0x18, 0x1e, 0x23, 0x00, 0x18, 0x1e, 0x24, 0x00, 0x18, 0x1e,
|
||||
0x25, 0x00, 0x19, 0x1e, 0x25, 0x00, 0x18, 0x1e, 0x26, 0x00, 0x19, 0x1f, 0x26, 0x00, 0x1a, 0x1f,
|
||||
0x26, 0x00, 0x1a, 0x1f, 0x27, 0x00, 0x1a, 0x1f, 0x28, 0x00, 0x1a, 0x20, 0x26, 0x00, 0x19, 0x20,
|
||||
0x27, 0x00, 0x1a, 0x20, 0x27, 0x00, 0x1a, 0x20, 0x28, 0x00, 0x1b, 0x20, 0x29, 0x00, 0x1b, 0x21,
|
||||
0x28, 0x00, 0x1b, 0x21, 0x29, 0x00, 0x1c, 0x21, 0x2a, 0x00, 0x1d, 0x22, 0x29, 0x00, 0x1c, 0x22,
|
||||
0x2a, 0x00, 0x1d, 0x22, 0x2a, 0x00, 0x1e, 0x23, 0x2c, 0x00, 0x1d, 0x24, 0x2b, 0x00, 0x1d, 0x24,
|
||||
0x2c, 0x00, 0x1c, 0x24, 0x2d, 0x00, 0x1e, 0x25, 0x2d, 0x00, 0x1f, 0x25, 0x2e, 0x00, 0x1e, 0x26,
|
||||
0x2e, 0x00, 0x1f, 0x26, 0x2e, 0x00, 0x1f, 0x26, 0x30, 0x00, 0x21, 0x27, 0x2e, 0x00, 0x20, 0x27,
|
||||
0x2f, 0x00, 0x20, 0x27, 0x31, 0x00, 0x20, 0x29, 0x32, 0x00, 0x20, 0x29, 0x33, 0x00, 0x21, 0x2a,
|
||||
0x33, 0x00, 0x24, 0x2c, 0x35, 0x00, 0x24, 0x2c, 0x38, 0x00, 0x26, 0x31, 0x3b, 0x00, 0x27, 0x31,
|
||||
0x3b, 0x00, 0xff, 0x00, 0xff, 0x00, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x05, 0x1a, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x48, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4a, 0x54, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a, 0x8c, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x41, 0x5e, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x0d, 0x27, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1b, 0x1f, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x00, 0x32, 0x69, 0x29,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x21, 0x38, 0x63, 0x2b,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3d, 0x2b, 0x1c, 0x0e,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5d, 0x7e, 0x2b, 0x08,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5d, 0x80, 0x4d, 0x4c,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x24, 0x4a, 0x9c, 0xa1,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x10, 0x39, 0x76, 0x46, 0x6d, 0x9a,
|
||||
0x60, 0x3f, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x01, 0x78, 0x8e, 0x32, 0x37, 0x81, 0x6c, 0x2a, 0x3c,
|
||||
0x55, 0x2c, 0x1d, 0x2d, 0x17, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x06, 0x27, 0x55, 0x82, 0x9b, 0x45, 0x0e, 0x47, 0x61, 0x0f, 0x1a,
|
||||
0x0f, 0x20, 0x62, 0x28, 0x0f, 0x18, 0x08, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0x35, 0x1b, 0x40, 0x98, 0x4d, 0x18, 0x15, 0x1c, 0x26, 0x1b, 0x3b, 0x49,
|
||||
0x20, 0x46, 0x67, 0x1b, 0x13, 0x0c, 0x15, 0x20, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0x25, 0x4d, 0x3c, 0x34, 0x2b, 0x1c, 0x08, 0x0b, 0x0f, 0x1b, 0x32, 0x9e, 0x8a,
|
||||
0x08, 0x27, 0x22, 0x0f, 0x36, 0x6f, 0x75, 0x3b, 0x39, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0x7d, 0x7a, 0x56, 0x48, 0x68, 0x32, 0x06, 0xa3, 0xa3, 0xa3, 0x14, 0x40, 0x86, 0x6e,
|
||||
0xa3, 0xa3, 0xa3, 0x06, 0x2d, 0x85, 0x92, 0x5b, 0x32, 0x6a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0x1c, 0x58, 0x8a, 0x65, 0x18, 0x21, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x07, 0x43, 0x83, 0x43,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x73, 0x91, 0x7f, 0x62, 0x20, 0x15, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1e, 0x31, 0x0f, 0x2e, 0x1c, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1b, 0x1b, 0x32, 0x16,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x43, 0x3b, 0x22, 0x55, 0x47, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x72, 0x9d, 0x60, 0x33, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2d, 0x0f, 0x1b, 0x0f,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x11, 0x2d, 0x93, 0x55, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x50,
|
||||
0x44, 0x90, 0x8a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3a, 0x77, 0x88, 0x47,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x45, 0x25, 0x25, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a,
|
||||
0x51, 0x23, 0x43, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x57, 0x5a, 0xa0, 0x84, 0x87,
|
||||
0x74, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x02, 0x08, 0x8f, 0x8b, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, 0x96,
|
||||
0x6a, 0x41, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4e, 0x95, 0x68, 0x5a, 0x4b, 0x7b,
|
||||
0x70, 0x4c, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x04, 0x53, 0x8d, 0x79, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x79, 0x80,
|
||||
0x5b, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x0e, 0x7c, 0x94, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4f, 0x6a,
|
||||
0x47, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5f, 0x40, 0x1b, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x46, 0x2d,
|
||||
0x08, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x97, 0x82, 0x18, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x58, 0x43,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x69, 0x5c, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x71, 0x40,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x65, 0x60, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x52, 0x2d,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x66, 0x5e, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2d, 0x20,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x6f, 0x6b, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2b, 0x5b,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2e, 0x44, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x41,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x40, 0x1e, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x10, 0x38,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x69, 0x42, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3b,
|
||||
0x19, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x03, 0x20, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x53,
|
||||
0x1d, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4f, 0x15, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1d, 0x09, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x48, 0x89, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1e, 0x33, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5b, 0x39, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0x3b, 0x2a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x59, 0x9f, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0x33, 0x0a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2f, 0x64, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0x1d, 0x2b, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x12, 0x99, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0x49, 0x3e, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1c, 0x36, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x30, 0x5e, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a, 0x48, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3
|
||||
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0xa4, 0x00,
|
||||
0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x05, 0x06, 0x07, 0x00, 0x06, 0x06,
|
||||
0x07, 0x00, 0x07, 0x06, 0x07, 0x00, 0x06, 0x07, 0x06, 0x00, 0x06, 0x07, 0x07, 0x00, 0x07, 0x07,
|
||||
0x07, 0x00, 0x07, 0x08, 0x07, 0x00, 0x08, 0x08, 0x08, 0x00, 0x07, 0x08, 0x09, 0x00, 0x08, 0x08,
|
||||
0x09, 0x00, 0x07, 0x09, 0x08, 0x00, 0x08, 0x09, 0x08, 0x00, 0x09, 0x09, 0x08, 0x00, 0x08, 0x09,
|
||||
0x09, 0x00, 0x09, 0x09, 0x09, 0x00, 0x08, 0x09, 0x0a, 0x00, 0x09, 0x09, 0x0a, 0x00, 0x09, 0x09,
|
||||
0x0b, 0x00, 0x09, 0x0a, 0x09, 0x00, 0x08, 0x0a, 0x0a, 0x00, 0x09, 0x0a, 0x0a, 0x00, 0x0a, 0x0a,
|
||||
0x0a, 0x00, 0x09, 0x0a, 0x0b, 0x00, 0x0a, 0x0a, 0x0b, 0x00, 0x09, 0x0a, 0x0c, 0x00, 0x09, 0x0b,
|
||||
0x0b, 0x00, 0x0a, 0x0b, 0x0b, 0x00, 0x0a, 0x0b, 0x0c, 0x00, 0x0b, 0x0b, 0x0c, 0x00, 0x0a, 0x0b,
|
||||
0x0d, 0x00, 0x0b, 0x0c, 0x0c, 0x00, 0x0b, 0x0c, 0x0d, 0x00, 0x0a, 0x0c, 0x0e, 0x00, 0x0b, 0x0c,
|
||||
0x0e, 0x00, 0x0c, 0x0c, 0x0f, 0x00, 0x0b, 0x0d, 0x0d, 0x00, 0x0b, 0x0d, 0x0e, 0x00, 0x0c, 0x0d,
|
||||
0x0e, 0x00, 0x0c, 0x0d, 0x0f, 0x00, 0x0d, 0x0d, 0x0f, 0x00, 0x0b, 0x0d, 0x10, 0x00, 0x0c, 0x0d,
|
||||
0x10, 0x00, 0x0c, 0x0e, 0x0f, 0x00, 0x0d, 0x0e, 0x0f, 0x00, 0x0c, 0x0e, 0x10, 0x00, 0x0d, 0x0e,
|
||||
0x10, 0x00, 0x0b, 0x0e, 0x11, 0x00, 0x0c, 0x0e, 0x11, 0x00, 0x0d, 0x0e, 0x11, 0x00, 0x0d, 0x0f,
|
||||
0x10, 0x00, 0x0d, 0x0f, 0x11, 0x00, 0x0e, 0x0f, 0x11, 0x00, 0x0d, 0x0f, 0x12, 0x00, 0x0e, 0x0f,
|
||||
0x12, 0x00, 0x0d, 0x0f, 0x13, 0x00, 0x0e, 0x10, 0x11, 0x00, 0x0d, 0x10, 0x12, 0x00, 0x0b, 0x10,
|
||||
0x13, 0x00, 0x0e, 0x10, 0x12, 0x00, 0x0e, 0x10, 0x13, 0x00, 0x0d, 0x10, 0x14, 0x00, 0x0e, 0x10,
|
||||
0x14, 0x00, 0x0d, 0x11, 0x13, 0x00, 0x0e, 0x11, 0x13, 0x00, 0x0f, 0x11, 0x13, 0x00, 0x0e, 0x11,
|
||||
0x14, 0x00, 0x0f, 0x11, 0x14, 0x00, 0x0f, 0x11, 0x15, 0x00, 0x0f, 0x12, 0x14, 0x00, 0x0f, 0x12,
|
||||
0x15, 0x00, 0x10, 0x12, 0x15, 0x00, 0x0f, 0x12, 0x16, 0x00, 0x10, 0x12, 0x16, 0x00, 0x0f, 0x12,
|
||||
0x17, 0x00, 0x0f, 0x13, 0x16, 0x00, 0x10, 0x13, 0x16, 0x00, 0x10, 0x13, 0x17, 0x00, 0x11, 0x13,
|
||||
0x17, 0x00, 0x11, 0x13, 0x18, 0x00, 0x10, 0x14, 0x17, 0x00, 0x11, 0x14, 0x17, 0x00, 0x10, 0x14,
|
||||
0x18, 0x00, 0x12, 0x15, 0x18, 0x00, 0x10, 0x15, 0x19, 0x00, 0x12, 0x15, 0x19, 0x00, 0x10, 0x15,
|
||||
0x1a, 0x00, 0x11, 0x15, 0x1a, 0x00, 0x12, 0x15, 0x1a, 0x00, 0x12, 0x15, 0x1b, 0x00, 0x11, 0x16,
|
||||
0x1a, 0x00, 0x12, 0x16, 0x1a, 0x00, 0x13, 0x16, 0x1a, 0x00, 0x12, 0x16, 0x1b, 0x00, 0x13, 0x16,
|
||||
0x1b, 0x00, 0x12, 0x17, 0x1b, 0x00, 0x13, 0x17, 0x1b, 0x00, 0x13, 0x17, 0x1c, 0x00, 0x14, 0x17,
|
||||
0x1c, 0x00, 0x14, 0x17, 0x1d, 0x00, 0x13, 0x18, 0x1d, 0x00, 0x14, 0x18, 0x1d, 0x00, 0x15, 0x18,
|
||||
0x1f, 0x00, 0x14, 0x19, 0x1d, 0x00, 0x15, 0x19, 0x1d, 0x00, 0x15, 0x19, 0x1e, 0x00, 0x15, 0x19,
|
||||
0x1f, 0x00, 0x16, 0x19, 0x1f, 0x00, 0x15, 0x19, 0x20, 0x00, 0x16, 0x1a, 0x1e, 0x00, 0x14, 0x1a,
|
||||
0x1f, 0x00, 0x15, 0x1a, 0x1f, 0x00, 0x16, 0x1a, 0x1f, 0x00, 0x15, 0x1a, 0x20, 0x00, 0x16, 0x1a,
|
||||
0x21, 0x00, 0x15, 0x1b, 0x21, 0x00, 0x17, 0x1b, 0x22, 0x00, 0x17, 0x1b, 0x23, 0x00, 0x16, 0x1c,
|
||||
0x22, 0x00, 0x17, 0x1d, 0x22, 0x00, 0x17, 0x1d, 0x23, 0x00, 0x18, 0x1d, 0x23, 0x00, 0x19, 0x1d,
|
||||
0x23, 0x00, 0x17, 0x1d, 0x24, 0x00, 0x18, 0x1e, 0x23, 0x00, 0x18, 0x1e, 0x24, 0x00, 0x18, 0x1e,
|
||||
0x25, 0x00, 0x19, 0x1e, 0x25, 0x00, 0x18, 0x1e, 0x26, 0x00, 0x19, 0x1f, 0x26, 0x00, 0x1a, 0x1f,
|
||||
0x26, 0x00, 0x1a, 0x1f, 0x27, 0x00, 0x1a, 0x1f, 0x28, 0x00, 0x1a, 0x20, 0x26, 0x00, 0x19, 0x20,
|
||||
0x27, 0x00, 0x1a, 0x20, 0x27, 0x00, 0x1a, 0x20, 0x28, 0x00, 0x1b, 0x20, 0x29, 0x00, 0x1b, 0x21,
|
||||
0x28, 0x00, 0x1b, 0x21, 0x29, 0x00, 0x1c, 0x21, 0x2a, 0x00, 0x1d, 0x22, 0x29, 0x00, 0x1c, 0x22,
|
||||
0x2a, 0x00, 0x1d, 0x22, 0x2a, 0x00, 0x1e, 0x23, 0x2c, 0x00, 0x1d, 0x24, 0x2b, 0x00, 0x1d, 0x24,
|
||||
0x2c, 0x00, 0x1c, 0x24, 0x2d, 0x00, 0x1e, 0x25, 0x2d, 0x00, 0x1f, 0x25, 0x2e, 0x00, 0x1e, 0x26,
|
||||
0x2e, 0x00, 0x1f, 0x26, 0x2e, 0x00, 0x1f, 0x26, 0x30, 0x00, 0x21, 0x27, 0x2e, 0x00, 0x20, 0x27,
|
||||
0x2f, 0x00, 0x20, 0x27, 0x31, 0x00, 0x20, 0x29, 0x32, 0x00, 0x20, 0x29, 0x33, 0x00, 0x21, 0x2a,
|
||||
0x33, 0x00, 0x24, 0x2c, 0x35, 0x00, 0x24, 0x2c, 0x38, 0x00, 0x26, 0x31, 0x3b, 0x00, 0x27, 0x31,
|
||||
0x3b, 0x00, 0xff, 0x00, 0xff, 0x00, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x05, 0x1a, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x48, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4a, 0x54, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a, 0x8c, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x41, 0x5e, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x0d, 0x27, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1b, 0x1f, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x00, 0x32, 0x69, 0x29,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x21, 0x38, 0x63, 0x2b,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3d, 0x2b, 0x1c, 0x0e,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5d, 0x7e, 0x2b, 0x08,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5d, 0x80, 0x4d, 0x4c,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x24, 0x4a, 0x9c, 0xa1,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x10, 0x39, 0x76, 0x46, 0x6d, 0x9a,
|
||||
0x60, 0x3f, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x01, 0x78, 0x8e, 0x32, 0x37, 0x81, 0x6c, 0x2a, 0x3c,
|
||||
0x55, 0x2c, 0x1d, 0x2d, 0x17, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x06, 0x27, 0x55, 0x82, 0x9b, 0x45, 0x0e, 0x47, 0x61, 0x0f, 0x1a,
|
||||
0x0f, 0x20, 0x62, 0x28, 0x0f, 0x18, 0x08, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0x35, 0x1b, 0x40, 0x98, 0x4d, 0x18, 0x15, 0x1c, 0x26, 0x1b, 0x3b, 0x49,
|
||||
0x20, 0x46, 0x67, 0x1b, 0x13, 0x0c, 0x15, 0x20, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0x25, 0x4d, 0x3c, 0x34, 0x2b, 0x1c, 0x08, 0x0b, 0x0f, 0x1b, 0x32, 0x9e, 0x8a,
|
||||
0x08, 0x27, 0x22, 0x0f, 0x36, 0x6f, 0x75, 0x3b, 0x39, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0x7d, 0x7a, 0x56, 0x48, 0x68, 0x32, 0x06, 0xa3, 0xa3, 0xa3, 0x14, 0x40, 0x86, 0x6e,
|
||||
0xa3, 0xa3, 0xa3, 0x06, 0x2d, 0x85, 0x92, 0x5b, 0x32, 0x6a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0x1c, 0x58, 0x8a, 0x65, 0x18, 0x21, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x07, 0x43, 0x83, 0x43,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x73, 0x91, 0x7f, 0x62, 0x20, 0x15, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1e, 0x31, 0x0f, 0x2e, 0x1c, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1b, 0x1b, 0x32, 0x16,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x43, 0x3b, 0x22, 0x55, 0x47, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x72, 0x9d, 0x60, 0x33, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2d, 0x0f, 0x1b, 0x0f,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x11, 0x2d, 0x93, 0x55, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x50,
|
||||
0x44, 0x90, 0x8a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3a, 0x77, 0x88, 0x47,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x45, 0x25, 0x25, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a,
|
||||
0x51, 0x23, 0x43, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x57, 0x5a, 0xa0, 0x84, 0x87,
|
||||
0x74, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x02, 0x08, 0x8f, 0x8b, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, 0x96,
|
||||
0x6a, 0x41, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4e, 0x95, 0x68, 0x5a, 0x4b, 0x7b,
|
||||
0x70, 0x4c, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x04, 0x53, 0x8d, 0x79, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x79, 0x80,
|
||||
0x5b, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x0e, 0x7c, 0x94, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4f, 0x6a,
|
||||
0x47, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5f, 0x40, 0x1b, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x46, 0x2d,
|
||||
0x08, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x97, 0x82, 0x18, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x58, 0x43,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x69, 0x5c, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x71, 0x40,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x65, 0x60, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x52, 0x2d,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x66, 0x5e, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2d, 0x20,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x6f, 0x6b, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2b, 0x5b,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2e, 0x44, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x25, 0x41,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x40, 0x1e, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x10, 0x38,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x69, 0x42, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x3b,
|
||||
0x19, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x03, 0x20, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x53,
|
||||
0x1d, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x4f, 0x15, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1d, 0x09, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x48, 0x89, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0x1e, 0x33, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x5b, 0x39, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0x3b, 0x2a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x59, 0x9f, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0x33, 0x0a, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x2f, 0x64, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0x1d, 0x2b, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x12, 0x99, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0x49, 0x3e, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x1c, 0x36, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x30, 0x5e, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0x8a, 0x48, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3,
|
||||
0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3
|
||||
|
|
|
@ -67,7 +67,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
#define MIN_EDICTS 256 // johnfitz -- lowest allowed value for max_edicts cvar
|
||||
#define MAX_EDICTS 32000 // johnfitz -- highest allowed value for max_edicts cvar
|
||||
// ents past 8192 can't play sounds in the standard protocol
|
||||
// ents past 8192 can't play sounds in the standard protocol
|
||||
#define MAX_LIGHTSTYLES 64
|
||||
#define MAX_MODELS 2048 // johnfitz -- was 256
|
||||
#define MAX_SOUNDS 2048 // johnfitz -- was 256
|
||||
|
@ -252,7 +252,7 @@ extern double host_frametime;
|
|||
extern byte *host_colormap;
|
||||
extern int32_t host_framecount; // incremented every frame, never reset
|
||||
extern double realtime; // not bounded in any way, changed at
|
||||
// start of every frame, never reset
|
||||
// start of every frame, never reset
|
||||
|
||||
typedef struct filelist_item_s
|
||||
{
|
||||
|
@ -264,33 +264,33 @@ extern filelist_item_t *modlist;
|
|||
extern filelist_item_t *extralevels;
|
||||
extern filelist_item_t *demolist;
|
||||
|
||||
void Host_ClearMemory (void);
|
||||
void Host_ServerFrame (void);
|
||||
void Host_InitCommands (void);
|
||||
void Host_Init (void);
|
||||
void Host_ClearMemory(void);
|
||||
void Host_ServerFrame(void);
|
||||
void Host_InitCommands(void);
|
||||
void Host_Init(void);
|
||||
void Host_Shutdown(void);
|
||||
void Host_Callback_Notify (cvar_t *var); /* callback function for CVAR_NOTIFY */
|
||||
noreturn void Host_Error (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
noreturn void Host_EndGame (const char *message, ...) FUNC_PRINTF(1,2);
|
||||
void Host_Callback_Notify(cvar_t *var); /* callback function for CVAR_NOTIFY */
|
||||
noreturn void Host_Error(const char *error, ...) FUNC_PRINTF(1, 2);
|
||||
noreturn void Host_EndGame(const char *message, ...) FUNC_PRINTF(1, 2);
|
||||
#ifdef __WATCOMC__
|
||||
#pragma aux Host_Error aborts;
|
||||
#pragma aux Host_EndGame aborts;
|
||||
#endif
|
||||
void Host_Frame (float time);
|
||||
void Host_Quit_f (void);
|
||||
void Host_ClientCommands (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void Host_ShutdownServer (bool crash);
|
||||
void Host_WriteConfiguration (void);
|
||||
void Host_Frame(float time);
|
||||
void Host_Quit_f(void);
|
||||
void Host_ClientCommands(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
void Host_ShutdownServer(bool crash);
|
||||
void Host_WriteConfiguration(void);
|
||||
|
||||
void ExtraMaps_Init (void);
|
||||
void Modlist_Init (void);
|
||||
void DemoList_Init (void);
|
||||
void ExtraMaps_Init(void);
|
||||
void Modlist_Init(void);
|
||||
void DemoList_Init(void);
|
||||
|
||||
void DemoList_Rebuild (void);
|
||||
void DemoList_Rebuild(void);
|
||||
|
||||
extern int32_t current_skill; // skill level for currently loaded level (in case
|
||||
// the user changes the cvar while the level is
|
||||
// running, this reflects the level actually in use)
|
||||
// the user changes the cvar while the level is
|
||||
// running, this reflects the level actually in use)
|
||||
|
||||
extern bool isDedicated;
|
||||
|
||||
|
|
530
source/r_alias.c
530
source/r_alias.c
File diff suppressed because it is too large
Load Diff
740
source/r_brush.c
740
source/r_brush.c
File diff suppressed because it is too large
Load Diff
535
source/r_part.c
535
source/r_part.c
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
R_GetSpriteFrame
|
||||
================
|
||||
*/
|
||||
mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
|
||||
mspriteframe_t *R_GetSpriteFrame(entity_t *currentent)
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
|
@ -39,13 +39,13 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
|
|||
psprite = (msprite_t *) currentent->model->cache.data;
|
||||
frame = currentent->frame;
|
||||
|
||||
if ((frame >= psprite->numframes) || (frame < 0))
|
||||
if((frame >= psprite->numframes) || (frame < 0))
|
||||
{
|
||||
Con_DPrintf ("R_DrawSprite: no such frame %" PRIi32 " for '%s'\n", frame, currentent->model->name);
|
||||
Con_DPrintf("R_DrawSprite: no such frame %" PRIi32 " for '%s'\n", frame, currentent->model->name);
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
if (psprite->frames[frame].type == SPR_SINGLE)
|
||||
if(psprite->frames[frame].type == SPR_SINGLE)
|
||||
{
|
||||
pspriteframe = psprite->frames[frame].frameptr;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
|
|||
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
||||
pintervals = pspritegroup->intervals;
|
||||
numframes = pspritegroup->numframes;
|
||||
fullinterval = pintervals[numframes-1];
|
||||
fullinterval = pintervals[numframes - 1];
|
||||
|
||||
time = cl.time + currentent->syncbase;
|
||||
|
||||
|
@ -62,9 +62,9 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
|
|||
// are positive, so we don't have to worry about division by 0
|
||||
targettime = time - ((int32_t)(time / fullinterval)) * fullinterval;
|
||||
|
||||
for (i=0 ; i<(numframes-1) ; i++)
|
||||
for(i = 0 ; i < (numframes - 1) ; i++)
|
||||
{
|
||||
if (pintervals[i] > targettime)
|
||||
if(pintervals[i] > targettime)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
|
|||
R_DrawSpriteModel -- johnfitz -- rewritten: now supports all orientations
|
||||
=================
|
||||
*/
|
||||
void R_DrawSpriteModel (entity_t *e)
|
||||
void R_DrawSpriteModel(entity_t *e)
|
||||
{
|
||||
vec3_t point, v_forward, v_right, v_up;
|
||||
msprite_t *psprite;
|
||||
|
@ -89,7 +89,7 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
|
||||
//TODO: frustum cull it?
|
||||
|
||||
frame = R_GetSpriteFrame (e);
|
||||
frame = R_GetSpriteFrame(e);
|
||||
psprite = (msprite_t *) currententity->model->cache.data;
|
||||
|
||||
switch(psprite->type)
|
||||
|
@ -119,7 +119,7 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
s_right = vright;
|
||||
break;
|
||||
case SPR_ORIENTED: //pitch yaw roll are independent of camera
|
||||
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
||||
AngleVectors(currententity->angles, v_forward, v_right, v_up);
|
||||
s_up = v_up;
|
||||
s_right = v_right;
|
||||
break;
|
||||
|
@ -141,42 +141,42 @@ void R_DrawSpriteModel (entity_t *e)
|
|||
}
|
||||
|
||||
//johnfitz: offset decals
|
||||
if (psprite->type == SPR_ORIENTED)
|
||||
GL_PolygonOffset (OFFSET_DECAL);
|
||||
if(psprite->type == SPR_ORIENTED)
|
||||
GL_PolygonOffset(OFFSET_DECAL);
|
||||
|
||||
glColor3f (1,1,1);
|
||||
glColor3f(1, 1, 1);
|
||||
|
||||
GL_DisableMultitexture();
|
||||
|
||||
GL_Bind(frame->gltexture);
|
||||
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glBegin (GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glBegin(GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris
|
||||
|
||||
glTexCoord2f (0, frame->tmax);
|
||||
VectorMA (e->origin, frame->down, s_up, point);
|
||||
VectorMA (point, frame->left, s_right, point);
|
||||
glVertex3fv (point);
|
||||
glTexCoord2f(0, frame->tmax);
|
||||
VectorMA(e->origin, frame->down, s_up, point);
|
||||
VectorMA(point, frame->left, s_right, point);
|
||||
glVertex3fv(point);
|
||||
|
||||
glTexCoord2f (0, 0);
|
||||
VectorMA (e->origin, frame->up, s_up, point);
|
||||
VectorMA (point, frame->left, s_right, point);
|
||||
glVertex3fv (point);
|
||||
glTexCoord2f(0, 0);
|
||||
VectorMA(e->origin, frame->up, s_up, point);
|
||||
VectorMA(point, frame->left, s_right, point);
|
||||
glVertex3fv(point);
|
||||
|
||||
glTexCoord2f (frame->smax, 0);
|
||||
VectorMA (e->origin, frame->up, s_up, point);
|
||||
VectorMA (point, frame->right, s_right, point);
|
||||
glVertex3fv (point);
|
||||
glTexCoord2f(frame->smax, 0);
|
||||
VectorMA(e->origin, frame->up, s_up, point);
|
||||
VectorMA(point, frame->right, s_right, point);
|
||||
glVertex3fv(point);
|
||||
|
||||
glTexCoord2f (frame->smax, frame->tmax);
|
||||
VectorMA (e->origin, frame->down, s_up, point);
|
||||
VectorMA (point, frame->right, s_right, point);
|
||||
glVertex3fv (point);
|
||||
glTexCoord2f(frame->smax, frame->tmax);
|
||||
VectorMA(e->origin, frame->down, s_up, point);
|
||||
VectorMA(point, frame->right, s_right, point);
|
||||
glVertex3fv(point);
|
||||
|
||||
glEnd ();
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
glEnd();
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
//johnfitz: offset decals
|
||||
if (psprite->type == SPR_ORIENTED)
|
||||
GL_PolygonOffset (OFFSET_NONE);
|
||||
if(psprite->type == SPR_ORIENTED)
|
||||
GL_PolygonOffset(OFFSET_NONE);
|
||||
}
|
||||
|
|
695
source/r_world.c
695
source/r_world.c
File diff suppressed because it is too large
Load Diff
|
@ -135,31 +135,31 @@ extern refdef_t r_refdef;
|
|||
extern vec3_t r_origin, vpn, vright, vup;
|
||||
|
||||
|
||||
void R_Init (void);
|
||||
void R_InitTextures (void);
|
||||
void R_InitEfrags (void);
|
||||
void R_RenderView (void); // must set r_refdef first
|
||||
void R_ViewChanged (vrect_t *pvrect, int32_t lineadj, float aspect);
|
||||
// called whenever r_refdef or vid change
|
||||
void R_Init(void);
|
||||
void R_InitTextures(void);
|
||||
void R_InitEfrags(void);
|
||||
void R_RenderView(void); // must set r_refdef first
|
||||
void R_ViewChanged(vrect_t *pvrect, int32_t lineadj, float aspect);
|
||||
// called whenever r_refdef or vid change
|
||||
//void R_InitSky (struct texture_s *mt); // called at level load
|
||||
|
||||
void R_CheckEfrags (void); //johnfitz
|
||||
void R_AddEfrags (entity_t *ent);
|
||||
void R_CheckEfrags(void); //johnfitz
|
||||
void R_AddEfrags(entity_t *ent);
|
||||
|
||||
void R_NewMap (void);
|
||||
void R_NewMap(void);
|
||||
|
||||
|
||||
void R_ParseParticleEffect (void);
|
||||
void R_RunParticleEffect (vec3_t org, vec3_t dir, int32_t color, int32_t count);
|
||||
void R_RocketTrail (vec3_t start, vec3_t end, int32_t type);
|
||||
void R_EntityParticles (entity_t *ent);
|
||||
void R_BlobExplosion (vec3_t org);
|
||||
void R_ParticleExplosion (vec3_t org);
|
||||
void R_ParticleExplosion2 (vec3_t org, int32_t colorStart, int32_t colorLength);
|
||||
void R_LavaSplash (vec3_t org);
|
||||
void R_TeleportSplash (vec3_t org);
|
||||
void R_ParseParticleEffect(void);
|
||||
void R_RunParticleEffect(vec3_t org, vec3_t dir, int32_t color, int32_t count);
|
||||
void R_RocketTrail(vec3_t start, vec3_t end, int32_t type);
|
||||
void R_EntityParticles(entity_t *ent);
|
||||
void R_BlobExplosion(vec3_t org);
|
||||
void R_ParticleExplosion(vec3_t org);
|
||||
void R_ParticleExplosion2(vec3_t org, int32_t colorStart, int32_t colorLength);
|
||||
void R_LavaSplash(vec3_t org);
|
||||
void R_TeleportSplash(vec3_t org);
|
||||
|
||||
void R_PushDlights (void);
|
||||
void R_PushDlights(void);
|
||||
|
||||
|
||||
//
|
||||
|
@ -168,11 +168,11 @@ void R_PushDlights (void);
|
|||
extern int32_t reinit_surfcache; // if 1, surface cache is currently empty and
|
||||
extern bool r_cache_thrash; // set if thrashing the surface cache
|
||||
|
||||
int32_t D_SurfaceCacheForRes (int32_t width, int32_t height);
|
||||
void D_FlushCaches (void);
|
||||
void D_DeleteSurfaceCache (void);
|
||||
void D_InitCaches (void *buffer, int32_t size);
|
||||
void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int32_t lineadj);
|
||||
int32_t D_SurfaceCacheForRes(int32_t width, int32_t height);
|
||||
void D_FlushCaches(void);
|
||||
void D_DeleteSurfaceCache(void);
|
||||
void D_InitCaches(void *buffer, int32_t size);
|
||||
void R_SetVrect(vrect_t *pvrect, vrect_t *pvrectin, int32_t lineadj);
|
||||
|
||||
#endif /* _QUAKE_RENDER_H */
|
||||
|
||||
|
|
962
source/sbar.c
962
source/sbar.c
File diff suppressed because it is too large
Load Diff
|
@ -28,19 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern int32_t sb_lines; // scan lines to draw
|
||||
|
||||
void Sbar_Init (void);
|
||||
void Sbar_LoadPics (void);
|
||||
void Sbar_Init(void);
|
||||
void Sbar_LoadPics(void);
|
||||
|
||||
void Sbar_Changed (void);
|
||||
void Sbar_Changed(void);
|
||||
// call whenever any of the client stats represented on the sbar changes
|
||||
|
||||
void Sbar_Draw (void);
|
||||
void Sbar_Draw(void);
|
||||
// called every frame by screen
|
||||
|
||||
void Sbar_IntermissionOverlay (void);
|
||||
void Sbar_IntermissionOverlay(void);
|
||||
// called each frame after the level has been completed
|
||||
|
||||
void Sbar_FinaleOverlay (void);
|
||||
void Sbar_FinaleOverlay(void);
|
||||
|
||||
#endif /* _QUAKE_SBAR_H */
|
||||
|
||||
|
|
|
@ -25,21 +25,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// screen.h
|
||||
|
||||
void SCR_Init (void);
|
||||
void SCR_LoadPics (void);
|
||||
void SCR_Init(void);
|
||||
void SCR_LoadPics(void);
|
||||
|
||||
void SCR_UpdateScreen (void);
|
||||
void SCR_UpdateScreen(void);
|
||||
|
||||
|
||||
void SCR_SizeUp (void);
|
||||
void SCR_SizeDown (void);
|
||||
void SCR_BringDownConsole (void);
|
||||
void SCR_CenterPrint (const char *str);
|
||||
void SCR_SizeUp(void);
|
||||
void SCR_SizeDown(void);
|
||||
void SCR_BringDownConsole(void);
|
||||
void SCR_CenterPrint(const char *str);
|
||||
|
||||
void SCR_BeginLoadingPlaque (void);
|
||||
void SCR_EndLoadingPlaque (void);
|
||||
void SCR_BeginLoadingPlaque(void);
|
||||
void SCR_EndLoadingPlaque(void);
|
||||
|
||||
int32_t SCR_ModalMessage (const char *text, float timeout); //johnfitz -- added timeout
|
||||
int32_t SCR_ModalMessage(const char *text, float timeout); //johnfitz -- added timeout
|
||||
|
||||
extern float scr_con_current;
|
||||
extern float scr_conlines; // lines of console to display
|
||||
|
@ -54,10 +54,11 @@ extern cvar_t scr_viewsize;
|
|||
|
||||
extern cvar_t scr_sbaralpha; //johnfitz
|
||||
|
||||
void SCR_UpdateWholeScreen (void);
|
||||
void SCR_UpdateWholeScreen(void);
|
||||
|
||||
//johnfitz -- stuff for 2d drawing control
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
CANVAS_NONE,
|
||||
CANVAS_DEFAULT,
|
||||
CANVAS_CONSOLE,
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct
|
|||
byte reliable_datagram_buf[MAX_DATAGRAM];
|
||||
|
||||
sizebuf_t signon;
|
||||
byte signon_buf[MAX_MSGLEN-2]; //johnfitz -- was 8192, now uses MAX_MSGLEN
|
||||
byte signon_buf[MAX_MSGLEN - 2]; //johnfitz -- was 8192, now uses MAX_MSGLEN
|
||||
|
||||
unsigned protocol; //johnfitz
|
||||
unsigned protocolflags;
|
||||
|
@ -191,42 +191,42 @@ extern edict_t *sv_player;
|
|||
|
||||
//===========================================================
|
||||
|
||||
void SV_Init (void);
|
||||
void SV_Init(void);
|
||||
|
||||
void SV_StartParticle (vec3_t org, vec3_t dir, int32_t color, int32_t count);
|
||||
void SV_StartSound (edict_t *entity, int32_t channel, const char *sample, int32_t volume,
|
||||
void SV_StartParticle(vec3_t org, vec3_t dir, int32_t color, int32_t count);
|
||||
void SV_StartSound(edict_t *entity, int32_t channel, const char *sample, int32_t volume,
|
||||
float attenuation);
|
||||
|
||||
void SV_DropClient (bool crash);
|
||||
void SV_DropClient(bool crash);
|
||||
|
||||
void SV_SendClientMessages (void);
|
||||
void SV_ClearDatagram (void);
|
||||
void SV_SendClientMessages(void);
|
||||
void SV_ClearDatagram(void);
|
||||
|
||||
int32_t SV_ModelIndex (const char *name);
|
||||
int32_t SV_ModelIndex(const char *name);
|
||||
|
||||
void SV_SetIdealPitch (void);
|
||||
void SV_SetIdealPitch(void);
|
||||
|
||||
void SV_AddUpdates (void);
|
||||
void SV_AddUpdates(void);
|
||||
|
||||
void SV_ClientThink (void);
|
||||
void SV_AddClientToServer (struct qsocket_s *ret);
|
||||
void SV_ClientThink(void);
|
||||
void SV_AddClientToServer(struct qsocket_s *ret);
|
||||
|
||||
void SV_ClientPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void SV_BroadcastPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
|
||||
void SV_ClientPrintf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
void SV_BroadcastPrintf(const char *fmt, ...) FUNC_PRINTF(1, 2);
|
||||
|
||||
void SV_Physics (void);
|
||||
void SV_Physics(void);
|
||||
|
||||
bool SV_CheckBottom (edict_t *ent);
|
||||
bool SV_movestep (edict_t *ent, vec3_t move, bool relink);
|
||||
bool SV_CheckBottom(edict_t *ent);
|
||||
bool SV_movestep(edict_t *ent, vec3_t move, bool relink);
|
||||
|
||||
void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg);
|
||||
void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg);
|
||||
|
||||
void SV_MoveToGoal (void);
|
||||
void SV_MoveToGoal(void);
|
||||
|
||||
void SV_CheckForNewClients (void);
|
||||
void SV_RunClients (void);
|
||||
void SV_SaveSpawnparms ();
|
||||
void SV_SpawnServer (const char *server);
|
||||
void SV_CheckForNewClients(void);
|
||||
void SV_RunClients(void);
|
||||
void SV_SaveSpawnparms();
|
||||
void SV_SpawnServer(const char *server);
|
||||
|
||||
#endif /* _QUAKE_SERVER_H */
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ static void S_CodecRegister(snd_codec_t *codec)
|
|||
S_CodecInit
|
||||
=================
|
||||
*/
|
||||
void S_CodecInit (void)
|
||||
void S_CodecInit(void)
|
||||
{
|
||||
snd_codec_t *codec;
|
||||
codecs = NULL;
|
||||
|
@ -79,7 +79,7 @@ void S_CodecInit (void)
|
|||
#endif
|
||||
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
codec->initialize();
|
||||
codec = codec->next;
|
||||
|
@ -91,10 +91,10 @@ void S_CodecInit (void)
|
|||
S_CodecShutdown
|
||||
=================
|
||||
*/
|
||||
void S_CodecShutdown (void)
|
||||
void S_CodecShutdown(void)
|
||||
{
|
||||
snd_codec_t *codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
codec->shutdown();
|
||||
codec = codec->next;
|
||||
|
@ -107,90 +107,94 @@ void S_CodecShutdown (void)
|
|||
S_CodecOpenStream
|
||||
=================
|
||||
*/
|
||||
snd_stream_t *S_CodecOpenStreamType (const char *filename, uint32_t type)
|
||||
snd_stream_t *S_CodecOpenStreamType(const char *filename, uint32_t type)
|
||||
{
|
||||
snd_codec_t *codec;
|
||||
snd_stream_t *stream;
|
||||
|
||||
if (type == CODECTYPE_NONE)
|
||||
if(type == CODECTYPE_NONE)
|
||||
{
|
||||
Con_Printf("Bad type for %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
if (type == codec->type)
|
||||
if(type == codec->type)
|
||||
break;
|
||||
codec = codec->next;
|
||||
}
|
||||
if (!codec)
|
||||
if(!codec)
|
||||
{
|
||||
Con_Printf("Unknown type for %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
stream = S_CodecUtilOpen(filename, codec);
|
||||
if (stream) {
|
||||
if (codec->codec_open(stream))
|
||||
if(stream)
|
||||
{
|
||||
if(codec->codec_open(stream))
|
||||
stream->status = STREAM_PLAY;
|
||||
else S_CodecUtilClose(&stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
snd_stream_t *S_CodecOpenStreamExt (const char *filename)
|
||||
snd_stream_t *S_CodecOpenStreamExt(const char *filename)
|
||||
{
|
||||
snd_codec_t *codec;
|
||||
snd_stream_t *stream;
|
||||
const char *ext;
|
||||
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext)
|
||||
if(! *ext)
|
||||
{
|
||||
Con_Printf("No extension for %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
if (!q_strcasecmp(ext, codec->ext))
|
||||
if(!q_strcasecmp(ext, codec->ext))
|
||||
break;
|
||||
codec = codec->next;
|
||||
}
|
||||
if (!codec)
|
||||
if(!codec)
|
||||
{
|
||||
Con_Printf("Unknown extension for %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
stream = S_CodecUtilOpen(filename, codec);
|
||||
if (stream) {
|
||||
if (codec->codec_open(stream))
|
||||
if(stream)
|
||||
{
|
||||
if(codec->codec_open(stream))
|
||||
stream->status = STREAM_PLAY;
|
||||
else S_CodecUtilClose(&stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
snd_stream_t *S_CodecOpenStreamAny (const char *filename)
|
||||
snd_stream_t *S_CodecOpenStreamAny(const char *filename)
|
||||
{
|
||||
snd_codec_t *codec;
|
||||
snd_stream_t *stream;
|
||||
const char *ext;
|
||||
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext) /* try all available */
|
||||
if(! *ext) /* try all available */
|
||||
{
|
||||
char tmp[MAX_QPATH];
|
||||
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
q_snprintf(tmp, sizeof(tmp), "%s.%s", filename, codec->ext);
|
||||
stream = S_CodecUtilOpen(tmp, codec);
|
||||
if (stream) {
|
||||
if (codec->codec_open(stream)) {
|
||||
if(stream)
|
||||
{
|
||||
if(codec->codec_open(stream))
|
||||
{
|
||||
stream->status = STREAM_PLAY;
|
||||
return stream;
|
||||
}
|
||||
|
@ -204,20 +208,21 @@ snd_stream_t *S_CodecOpenStreamAny (const char *filename)
|
|||
else /* use the name as is */
|
||||
{
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
if (!q_strcasecmp(ext, codec->ext))
|
||||
if(!q_strcasecmp(ext, codec->ext))
|
||||
break;
|
||||
codec = codec->next;
|
||||
}
|
||||
if (!codec)
|
||||
if(!codec)
|
||||
{
|
||||
Con_Printf("Unknown extension for %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
stream = S_CodecUtilOpen(filename, codec);
|
||||
if (stream) {
|
||||
if (codec->codec_open(stream))
|
||||
if(stream)
|
||||
{
|
||||
if(codec->codec_open(stream))
|
||||
stream->status = STREAM_PLAY;
|
||||
else S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
@ -225,33 +230,33 @@ snd_stream_t *S_CodecOpenStreamAny (const char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
bool S_CodecForwardStream (snd_stream_t *stream, uint32_t type)
|
||||
bool S_CodecForwardStream(snd_stream_t *stream, uint32_t type)
|
||||
{
|
||||
snd_codec_t *codec = codecs;
|
||||
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
if (type == codec->type)
|
||||
if(type == codec->type)
|
||||
break;
|
||||
codec = codec->next;
|
||||
}
|
||||
if (!codec) return false;
|
||||
if(!codec) return false;
|
||||
stream->codec = codec;
|
||||
return codec->codec_open(stream);
|
||||
}
|
||||
|
||||
void S_CodecCloseStream (snd_stream_t *stream)
|
||||
void S_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
stream->status = STREAM_NONE;
|
||||
stream->codec->codec_close(stream);
|
||||
}
|
||||
|
||||
int32_t S_CodecRewindStream (snd_stream_t *stream)
|
||||
int32_t S_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
return stream->codec->codec_rewind(stream);
|
||||
}
|
||||
|
||||
int32_t S_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
int32_t S_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
{
|
||||
return stream->codec->codec_read(stream, bytes, buffer);
|
||||
}
|
||||
|
@ -268,7 +273,7 @@ snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
|
|||
/* Try to open the file */
|
||||
length = (long) COM_FOpenFile(filename, &handle, NULL);
|
||||
pak = file_from_pak;
|
||||
if (length == -1)
|
||||
if(length == -1)
|
||||
{
|
||||
Con_DPrintf("Couldn't open %s\n", filename);
|
||||
return NULL;
|
||||
|
@ -294,12 +299,12 @@ void S_CodecUtilClose(snd_stream_t **stream)
|
|||
*stream = NULL;
|
||||
}
|
||||
|
||||
int32_t S_CodecIsAvailable (uint32_t type)
|
||||
int32_t S_CodecIsAvailable(uint32_t type)
|
||||
{
|
||||
snd_codec_t *codec = codecs;
|
||||
while (codec)
|
||||
while(codec)
|
||||
{
|
||||
if (type == codec->type)
|
||||
if(type == codec->type)
|
||||
return codec->initialized;
|
||||
codec = codec->next;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ typedef struct snd_info_s
|
|||
int32_t dataofs;
|
||||
} snd_info_t;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
STREAM_NONE = -1,
|
||||
STREAM_INIT,
|
||||
STREAM_PAUSE,
|
||||
|
@ -58,26 +59,26 @@ typedef struct snd_stream_s
|
|||
} snd_stream_t;
|
||||
|
||||
|
||||
void S_CodecInit (void);
|
||||
void S_CodecShutdown (void);
|
||||
void S_CodecInit(void);
|
||||
void S_CodecShutdown(void);
|
||||
|
||||
/* Callers of the following S_CodecOpenStream* functions
|
||||
* are reponsible for attaching any path to the filename */
|
||||
|
||||
snd_stream_t *S_CodecOpenStreamType (const char *filename, uint32_t type);
|
||||
/* Decides according to the required type. */
|
||||
snd_stream_t *S_CodecOpenStreamType(const char *filename, uint32_t type);
|
||||
/* Decides according to the required type. */
|
||||
|
||||
snd_stream_t *S_CodecOpenStreamAny (const char *filename);
|
||||
/* Decides according to file extension. if the
|
||||
snd_stream_t *S_CodecOpenStreamAny(const char *filename);
|
||||
/* Decides according to file extension. if the
|
||||
* name has no extension, try all available. */
|
||||
|
||||
snd_stream_t *S_CodecOpenStreamExt (const char *filename);
|
||||
/* Decides according to file extension. the name
|
||||
snd_stream_t *S_CodecOpenStreamExt(const char *filename);
|
||||
/* Decides according to file extension. the name
|
||||
* MUST have an extension. */
|
||||
|
||||
void S_CodecCloseStream (snd_stream_t *stream);
|
||||
int32_t S_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer);
|
||||
int32_t S_CodecRewindStream (snd_stream_t *stream);
|
||||
void S_CodecCloseStream(snd_stream_t *stream);
|
||||
int32_t S_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer);
|
||||
int32_t S_CodecRewindStream(snd_stream_t *stream);
|
||||
|
||||
snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec);
|
||||
void S_CodecUtilClose(snd_stream_t **stream);
|
||||
|
@ -96,8 +97,8 @@ void S_CodecUtilClose(snd_stream_t **stream);
|
|||
#define CODECTYPE_WAVE CODECTYPE_WAV
|
||||
#define CODECTYPE_MIDI CODECTYPE_MID
|
||||
|
||||
int32_t S_CodecIsAvailable (uint32_t type);
|
||||
/* return 1 if available, 0 if codec failed init
|
||||
int32_t S_CodecIsAvailable(uint32_t type);
|
||||
/* return 1 if available, 0 if codec failed init
|
||||
* or -1 if no such codec is present. */
|
||||
|
||||
#endif /* _SND_CODEC_H_ */
|
||||
|
|
|
@ -48,8 +48,8 @@ struct snd_codec_s
|
|||
snd_codec_t *next;
|
||||
};
|
||||
|
||||
bool S_CodecForwardStream (snd_stream_t *stream, uint32_t type);
|
||||
/* Forward a stream to another codec of 'type' type. */
|
||||
bool S_CodecForwardStream(snd_stream_t *stream, uint32_t type);
|
||||
/* Forward a stream to another codec of 'type' type. */
|
||||
|
||||
#endif /* _SND_CODECI_H_ */
|
||||
|
||||
|
|
427
source/snd_dma.c
427
source/snd_dma.c
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,8 @@ typedef unsigned FLAC_SIZE_T;
|
|||
typedef size_t FLAC_SIZE_T;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
FLAC__StreamDecoder *decoder;
|
||||
fshandle_t *file;
|
||||
snd_info_t *info;
|
||||
|
@ -77,27 +78,27 @@ typedef struct {
|
|||
|
||||
/* CALLBACK FUNCTIONS: */
|
||||
static void
|
||||
flac_error_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_error_func(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
ff->error = -1;
|
||||
Con_Printf ("FLAC: decoder error %" PRIi32 "\n", status);
|
||||
Con_Printf("FLAC: decoder error %" PRIi32 "\n", status);
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
flac_read_func (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||
flac_read_func(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
||||
FLAC_SIZE_T *bytes, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
if (*bytes > 0)
|
||||
if(*bytes > 0)
|
||||
{
|
||||
*bytes = FS_fread(buffer, 1, *bytes, ff->file);
|
||||
if (FS_ferror(ff->file))
|
||||
if(FS_ferror(ff->file))
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
if (*bytes == 0)
|
||||
if(*bytes == 0)
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
|
@ -105,79 +106,81 @@ flac_read_func (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[],
|
|||
}
|
||||
|
||||
static FLAC__StreamDecoderSeekStatus
|
||||
flac_seek_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_seek_func(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
if (FS_fseek(ff->file, (long)absolute_byte_offset, SEEK_SET) < 0)
|
||||
if(FS_fseek(ff->file, (long)absolute_byte_offset, SEEK_SET) < 0)
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderTellStatus
|
||||
flac_tell_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_tell_func(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
long pos = FS_ftell (ff->file);
|
||||
long pos = FS_ftell(ff->file);
|
||||
(void)decoder;
|
||||
if (pos < 0) return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
if(pos < 0) return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
*absolute_byte_offset = (FLAC__uint64) pos;
|
||||
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderLengthStatus
|
||||
flac_length_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_length_func(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__uint64 *stream_length, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
*stream_length = (FLAC__uint64) FS_filelength (ff->file);
|
||||
*stream_length = (FLAC__uint64) FS_filelength(ff->file);
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
||||
}
|
||||
|
||||
static FLAC__bool
|
||||
flac_eof_func (const FLAC__StreamDecoder *decoder, void *client_data)
|
||||
flac_eof_func(const FLAC__StreamDecoder *decoder, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
if (FS_feof (ff->file)) return true;
|
||||
if(FS_feof(ff->file)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderWriteStatus
|
||||
flac_write_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_write_func(const FLAC__StreamDecoder *decoder,
|
||||
const FLAC__Frame *frame, const FLAC__int32 * const buffer[],
|
||||
void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
|
||||
if (!ff->buffer) {
|
||||
ff->buffer = (byte *) malloc (ff->info->blocksize * ff->info->channels * ff->info->width);
|
||||
if (!ff->buffer) {
|
||||
if(!ff->buffer)
|
||||
{
|
||||
ff->buffer = (byte *) malloc(ff->info->blocksize * ff->info->channels * ff->info->width);
|
||||
if(!ff->buffer)
|
||||
{
|
||||
ff->error = -1; /* needn't set this here, but... */
|
||||
Con_Printf("Insufficient memory for fLaC audio\n");
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (ff->info->channels == 1)
|
||||
if(ff->info->channels == 1)
|
||||
{
|
||||
unsigned i;
|
||||
const FLAC__int32 *in = buffer[0];
|
||||
|
||||
if (ff->info->bits == 8)
|
||||
if(ff->info->bits == 8)
|
||||
{
|
||||
byte *out = ff->buffer;
|
||||
for (i = 0; i < frame->header.blocksize; i++)
|
||||
for(i = 0; i < frame->header.blocksize; i++)
|
||||
*out++ = *in++ + 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
int16_t *out = (int16_t *) ff->buffer;
|
||||
for (i = 0; i < frame->header.blocksize; i++)
|
||||
for(i = 0; i < frame->header.blocksize; i++)
|
||||
*out++ = *in++;
|
||||
}
|
||||
}
|
||||
|
@ -187,11 +190,11 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
|
|||
const FLAC__int32 *li = buffer[0];
|
||||
const FLAC__int32 *ri = buffer[1];
|
||||
|
||||
if (ff->info->bits == 8)
|
||||
if(ff->info->bits == 8)
|
||||
{
|
||||
char *lo = (char *) ff->buffer + 0;
|
||||
char *ro = (char *) ff->buffer + 1;
|
||||
for (i = 0; i < frame->header.blocksize; i++, lo++, ro++)
|
||||
for(i = 0; i < frame->header.blocksize; i++, lo++, ro++)
|
||||
{
|
||||
*lo++ = *li++ + 128;
|
||||
*ro++ = *ri++ + 128;
|
||||
|
@ -201,7 +204,7 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
|
|||
{
|
||||
int16_t *lo = (int16_t *) ff->buffer + 0;
|
||||
int16_t *ro = (int16_t *) ff->buffer + 1;
|
||||
for (i = 0; i < frame->header.blocksize; i++, lo++, ro++)
|
||||
for(i = 0; i < frame->header.blocksize; i++, lo++, ro++)
|
||||
{
|
||||
*lo++ = *li++;
|
||||
*ro++ = *ri++;
|
||||
|
@ -215,12 +218,12 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
|
|||
}
|
||||
|
||||
static void
|
||||
flac_meta_func (const FLAC__StreamDecoder *decoder,
|
||||
flac_meta_func(const FLAC__StreamDecoder *decoder,
|
||||
const FLAC__StreamMetadata *metadata, void *client_data)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
(void)decoder;
|
||||
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
{
|
||||
ff->info->rate = metadata->data.stream_info.sample_rate;
|
||||
ff->info->bits = metadata->data.stream_info.bits_per_sample;
|
||||
|
@ -232,24 +235,24 @@ flac_meta_func (const FLAC__StreamDecoder *decoder,
|
|||
}
|
||||
|
||||
|
||||
static bool S_FLAC_CodecInitialize (void)
|
||||
static bool S_FLAC_CodecInitialize(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void S_FLAC_CodecShutdown (void)
|
||||
static void S_FLAC_CodecShutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool S_FLAC_CodecOpenStream (snd_stream_t *stream)
|
||||
static bool S_FLAC_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
flacfile_t *ff;
|
||||
int32_t rc;
|
||||
|
||||
ff = (flacfile_t *) Z_Malloc(sizeof(flacfile_t));
|
||||
|
||||
ff->decoder = FLAC__stream_decoder_new ();
|
||||
if (ff->decoder == NULL)
|
||||
ff->decoder = FLAC__stream_decoder_new();
|
||||
if(ff->decoder == NULL)
|
||||
{
|
||||
Con_Printf("Unable to create fLaC decoder\n");
|
||||
goto _fail;
|
||||
|
@ -261,16 +264,16 @@ static bool S_FLAC_CodecOpenStream (snd_stream_t *stream)
|
|||
ff->info->dataofs = -1; /* check for STREAMINFO metadata existence */
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_decoder_set_error_callback (ff->decoder, flac_error_func);
|
||||
FLAC__seekable_stream_decoder_set_read_callback (ff->decoder, flac_read_func);
|
||||
FLAC__seekable_stream_decoder_set_seek_callback (ff->decoder, flac_seek_func);
|
||||
FLAC__seekable_stream_decoder_set_tell_callback (ff->decoder, flac_tell_func);
|
||||
FLAC__seekable_stream_decoder_set_length_callback (ff->decoder, flac_length_func);
|
||||
FLAC__seekable_stream_decoder_set_eof_callback (ff->decoder, flac_eof_func);
|
||||
FLAC__seekable_stream_decoder_set_write_callback (ff->decoder, flac_write_func);
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback (ff->decoder, flac_meta_func);
|
||||
FLAC__seekable_stream_decoder_set_client_data (ff->decoder, ff);
|
||||
rc = FLAC__seekable_stream_decoder_init (ff->decoder);
|
||||
FLAC__seekable_stream_decoder_set_error_callback(ff->decoder, flac_error_func);
|
||||
FLAC__seekable_stream_decoder_set_read_callback(ff->decoder, flac_read_func);
|
||||
FLAC__seekable_stream_decoder_set_seek_callback(ff->decoder, flac_seek_func);
|
||||
FLAC__seekable_stream_decoder_set_tell_callback(ff->decoder, flac_tell_func);
|
||||
FLAC__seekable_stream_decoder_set_length_callback(ff->decoder, flac_length_func);
|
||||
FLAC__seekable_stream_decoder_set_eof_callback(ff->decoder, flac_eof_func);
|
||||
FLAC__seekable_stream_decoder_set_write_callback(ff->decoder, flac_write_func);
|
||||
FLAC__seekable_stream_decoder_set_metadata_callback(ff->decoder, flac_meta_func);
|
||||
FLAC__seekable_stream_decoder_set_client_data(ff->decoder, ff);
|
||||
rc = FLAC__seekable_stream_decoder_init(ff->decoder);
|
||||
#else
|
||||
rc = FLAC__stream_decoder_init_stream(ff->decoder,
|
||||
flac_read_func,
|
||||
|
@ -283,14 +286,14 @@ static bool S_FLAC_CodecOpenStream (snd_stream_t *stream)
|
|||
flac_error_func,
|
||||
ff);
|
||||
#endif
|
||||
if (rc != FLAC__STREAM_DECODER_INIT_STATUS_OK) /* unlikely */
|
||||
if(rc != FLAC__STREAM_DECODER_INIT_STATUS_OK) /* unlikely */
|
||||
{
|
||||
Con_Printf ("FLAC: decoder init error %" PRIi32 "\n", rc);
|
||||
Con_Printf("FLAC: decoder init error %" PRIi32 "\n", rc);
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
rc = FLAC__stream_decoder_process_until_end_of_metadata (ff->decoder);
|
||||
if (rc == false || ff->error)
|
||||
rc = FLAC__stream_decoder_process_until_end_of_metadata(ff->decoder);
|
||||
if(rc == false || ff->error)
|
||||
{
|
||||
rc = FLAC__stream_decoder_get_state(ff->decoder);
|
||||
Con_Printf("%s not a valid flac file? (decoder state %" PRIi32 ")\n",
|
||||
|
@ -298,17 +301,17 @@ static bool S_FLAC_CodecOpenStream (snd_stream_t *stream)
|
|||
goto _fail;
|
||||
}
|
||||
|
||||
if (ff->info->dataofs < 0)
|
||||
if(ff->info->dataofs < 0)
|
||||
{
|
||||
Con_Printf("%s has no STREAMINFO\n", stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
if (ff->info->bits != 8 && ff->info->bits != 16)
|
||||
if(ff->info->bits != 8 && ff->info->bits != 16)
|
||||
{
|
||||
Con_Printf("%s is not 8 or 16 bit\n", stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
if (ff->info->channels != 1 && ff->info->channels != 2)
|
||||
if(ff->info->channels != 1 && ff->info->channels != 2)
|
||||
{
|
||||
Con_Printf("Unsupported number of channels %" PRIi32 " in %s\n",
|
||||
ff->info->channels, stream->name);
|
||||
|
@ -318,65 +321,71 @@ static bool S_FLAC_CodecOpenStream (snd_stream_t *stream)
|
|||
return true;
|
||||
|
||||
_fail:
|
||||
if (ff->decoder)
|
||||
if(ff->decoder)
|
||||
{
|
||||
FLAC__stream_decoder_finish (ff->decoder);
|
||||
FLAC__stream_decoder_delete (ff->decoder);
|
||||
FLAC__stream_decoder_finish(ff->decoder);
|
||||
FLAC__stream_decoder_delete(ff->decoder);
|
||||
}
|
||||
Z_Free(ff);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t S_FLAC_CodecReadStream (snd_stream_t *stream, int32_t len, void *buffer)
|
||||
static int32_t S_FLAC_CodecReadStream(snd_stream_t *stream, int32_t len, void *buffer)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) stream->priv;
|
||||
byte *buf = (byte *) buffer;
|
||||
int32_t count = 0;
|
||||
|
||||
while (len) {
|
||||
while(len)
|
||||
{
|
||||
int32_t res = 0;
|
||||
if (ff->size == ff->pos)
|
||||
FLAC__stream_decoder_process_single (ff->decoder);
|
||||
if (ff->error) return -1;
|
||||
if(ff->size == ff->pos)
|
||||
FLAC__stream_decoder_process_single(ff->decoder);
|
||||
if(ff->error) return -1;
|
||||
res = ff->size - ff->pos;
|
||||
if (res > len)
|
||||
if(res > len)
|
||||
res = len;
|
||||
if (res > 0) {
|
||||
memcpy (buf, ff->buffer + ff->pos, res);
|
||||
if(res > 0)
|
||||
{
|
||||
memcpy(buf, ff->buffer + ff->pos, res);
|
||||
count += res;
|
||||
len -= res;
|
||||
buf += res;
|
||||
ff->pos += res;
|
||||
} else if (res < 0) { /* error */
|
||||
}
|
||||
else if(res < 0) /* error */
|
||||
{
|
||||
return -1;
|
||||
} else {
|
||||
Con_DPrintf ("FLAC: EOF\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_DPrintf("FLAC: EOF\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void S_FLAC_CodecCloseStream (snd_stream_t *stream)
|
||||
static void S_FLAC_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) stream->priv;
|
||||
|
||||
FLAC__stream_decoder_finish (ff->decoder);
|
||||
FLAC__stream_decoder_delete (ff->decoder);
|
||||
FLAC__stream_decoder_finish(ff->decoder);
|
||||
FLAC__stream_decoder_delete(ff->decoder);
|
||||
|
||||
if (ff->buffer)
|
||||
if(ff->buffer)
|
||||
free(ff->buffer);
|
||||
Z_Free(ff);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int32_t S_FLAC_CodecRewindStream (snd_stream_t *stream)
|
||||
static int32_t S_FLAC_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
flacfile_t *ff = (flacfile_t *) stream->priv;
|
||||
|
||||
ff->pos = ff->size = 0;
|
||||
if (FLAC__stream_decoder_seek_absolute(ff->decoder, 0)) return 0;
|
||||
if(FLAC__stream_decoder_seek_absolute(ff->decoder, 0)) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
126
source/snd_mem.c
126
source/snd_mem.c
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
ResampleSfx
|
||||
================
|
||||
*/
|
||||
static void ResampleSfx (sfx_t *sfx, int32_t inrate, int32_t inwidth, byte *data)
|
||||
static void ResampleSfx(sfx_t *sfx, int32_t inrate, int32_t inwidth, byte *data)
|
||||
{
|
||||
int32_t outcount;
|
||||
int32_t srcsample;
|
||||
|
@ -36,19 +36,19 @@ static void ResampleSfx (sfx_t *sfx, int32_t inrate, int32_t inwidth, byte *data
|
|||
int32_t sample, samplefrac, fracstep;
|
||||
sfxcache_t *sc;
|
||||
|
||||
sc = (sfxcache_t *) Cache_Check (&sfx->cache);
|
||||
if (!sc)
|
||||
sc = (sfxcache_t *) Cache_Check(&sfx->cache);
|
||||
if(!sc)
|
||||
return;
|
||||
|
||||
stepscale = (float)inrate / shm->speed; // this is usually 0.5, 1, or 2
|
||||
|
||||
outcount = sc->length / stepscale;
|
||||
sc->length = outcount;
|
||||
if (sc->loopstart != -1)
|
||||
if(sc->loopstart != -1)
|
||||
sc->loopstart = sc->loopstart / stepscale;
|
||||
|
||||
sc->speed = shm->speed;
|
||||
if (loadas8bit.value)
|
||||
if(loadas8bit.value)
|
||||
sc->width = 1;
|
||||
else
|
||||
sc->width = inwidth;
|
||||
|
@ -56,26 +56,26 @@ static void ResampleSfx (sfx_t *sfx, int32_t inrate, int32_t inwidth, byte *data
|
|||
|
||||
// resample / decimate to the current source rate
|
||||
|
||||
if (stepscale == 1 && inwidth == 1 && sc->width == 1)
|
||||
if(stepscale == 1 && inwidth == 1 && sc->width == 1)
|
||||
{
|
||||
// fast special case
|
||||
for (i = 0; i < outcount; i++)
|
||||
((int8_t *)sc->data)[i] = (int32_t)( (uint8_t)(data[i]) - 128);
|
||||
for(i = 0; i < outcount; i++)
|
||||
((int8_t *)sc->data)[i] = (int32_t)((uint8_t)(data[i]) - 128);
|
||||
}
|
||||
else
|
||||
{
|
||||
// general case
|
||||
samplefrac = 0;
|
||||
fracstep = stepscale*256;
|
||||
for (i = 0; i < outcount; i++)
|
||||
fracstep = stepscale * 256;
|
||||
for(i = 0; i < outcount; i++)
|
||||
{
|
||||
srcsample = samplefrac >> 8;
|
||||
samplefrac += fracstep;
|
||||
if (inwidth == 2)
|
||||
sample = LittleShort ( ((int16_t *)data)[srcsample] );
|
||||
if(inwidth == 2)
|
||||
sample = LittleShort(((int16_t *)data)[srcsample]);
|
||||
else
|
||||
sample = (int32_t)( (uint8_t)(data[srcsample]) - 128) << 8;
|
||||
if (sc->width == 2)
|
||||
sample = (int32_t)((uint8_t)(data[srcsample]) - 128) << 8;
|
||||
if(sc->width == 2)
|
||||
((int16_t *)sc->data)[i] = sample;
|
||||
else
|
||||
((int8_t *)sc->data)[i] = sample >> 8;
|
||||
|
@ -90,7 +90,7 @@ static void ResampleSfx (sfx_t *sfx, int32_t inrate, int32_t inwidth, byte *data
|
|||
S_LoadSound
|
||||
==============
|
||||
*/
|
||||
sfxcache_t *S_LoadSound (sfx_t *s)
|
||||
sfxcache_t *S_LoadSound(sfx_t *s)
|
||||
{
|
||||
char namebuffer[256];
|
||||
byte *data;
|
||||
|
@ -98,11 +98,11 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
int32_t len;
|
||||
float stepscale;
|
||||
sfxcache_t *sc;
|
||||
byte stackbuf[1*1024]; // avoid dirtying the cache heap
|
||||
byte stackbuf[1 * 1024]; // avoid dirtying the cache heap
|
||||
|
||||
// see if still in memory
|
||||
sc = (sfxcache_t *) Cache_Check (&s->cache);
|
||||
if (sc)
|
||||
sc = (sfxcache_t *) Cache_Check(&s->cache);
|
||||
if(sc)
|
||||
return sc;
|
||||
|
||||
// Con_Printf ("S_LoadSound: %x\n", (int32_t)stackbuf);
|
||||
|
@ -115,20 +115,20 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
|
||||
data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf), NULL);
|
||||
|
||||
if (!data)
|
||||
if(!data)
|
||||
{
|
||||
Con_Printf ("Couldn't load %s\n", namebuffer);
|
||||
Con_Printf("Couldn't load %s\n", namebuffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
info = GetWavinfo (s->name, data, com_filesize);
|
||||
if (info.channels != 1)
|
||||
info = GetWavinfo(s->name, data, com_filesize);
|
||||
if(info.channels != 1)
|
||||
{
|
||||
Con_Printf ("%s is a stereo sample\n",s->name);
|
||||
Con_Printf("%s is a stereo sample\n", s->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (info.width != 1 && info.width != 2)
|
||||
if(info.width != 1 && info.width != 2)
|
||||
{
|
||||
Con_Printf("%s is not 8 or 16 bit\n", s->name);
|
||||
return NULL;
|
||||
|
@ -139,14 +139,14 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
|
||||
len = len * info.width * info.channels;
|
||||
|
||||
if (info.samples == 0 || len == 0)
|
||||
if(info.samples == 0 || len == 0)
|
||||
{
|
||||
Con_Printf("%s has zero samples\n", s->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sc = (sfxcache_t *) Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
|
||||
if (!sc)
|
||||
sc = (sfxcache_t *) Cache_Alloc(&s->cache, len + sizeof(sfxcache_t), s->name);
|
||||
if(!sc)
|
||||
return NULL;
|
||||
|
||||
sc->length = info.samples;
|
||||
|
@ -155,7 +155,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
sc->width = info.width;
|
||||
sc->stereo = info.channels;
|
||||
|
||||
ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
|
||||
ResampleSfx(s, sc->speed, sc->width, data + info.dataofs);
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
@ -176,32 +176,32 @@ static byte *last_chunk;
|
|||
static byte *iff_data;
|
||||
static int32_t iff_chunk_len;
|
||||
|
||||
static int16_t GetLittleShort (void)
|
||||
static int16_t GetLittleShort(void)
|
||||
{
|
||||
int16_t val = 0;
|
||||
val = *data_p;
|
||||
val = val + (*(data_p+1)<<8);
|
||||
val = val + (*(data_p + 1) << 8);
|
||||
data_p += 2;
|
||||
return val;
|
||||
}
|
||||
|
||||
static int32_t GetLittleLong (void)
|
||||
static int32_t GetLittleLong(void)
|
||||
{
|
||||
int32_t val = 0;
|
||||
val = *data_p;
|
||||
val = val + (*(data_p+1)<<8);
|
||||
val = val + (*(data_p+2)<<16);
|
||||
val = val + (*(data_p+3)<<24);
|
||||
val = val + (*(data_p + 1) << 8);
|
||||
val = val + (*(data_p + 2) << 16);
|
||||
val = val + (*(data_p + 3) << 24);
|
||||
data_p += 4;
|
||||
return val;
|
||||
}
|
||||
|
||||
static void FindNextChunk (const char *name)
|
||||
static void FindNextChunk(const char *name)
|
||||
{
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
// Need at least 8 bytes for a chunk
|
||||
if (last_chunk + 8 >= iff_end)
|
||||
if(last_chunk + 8 >= iff_end)
|
||||
{
|
||||
data_p = NULL;
|
||||
return;
|
||||
|
@ -209,7 +209,7 @@ static void FindNextChunk (const char *name)
|
|||
|
||||
data_p = last_chunk + 4;
|
||||
iff_chunk_len = GetLittleLong();
|
||||
if (iff_chunk_len < 0 || iff_chunk_len > iff_end - data_p)
|
||||
if(iff_chunk_len < 0 || iff_chunk_len > iff_end - data_p)
|
||||
{
|
||||
data_p = NULL;
|
||||
Con_DPrintf2("bad \"%s\" chunk length (%" PRIi32 ")\n", name, iff_chunk_len);
|
||||
|
@ -217,19 +217,19 @@ static void FindNextChunk (const char *name)
|
|||
}
|
||||
last_chunk = data_p + ((iff_chunk_len + 1) & ~1);
|
||||
data_p -= 8;
|
||||
if (!Q_strncmp((char *)data_p, name, 4))
|
||||
if(!Q_strncmp((char *)data_p, name, 4))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void FindChunk (const char *name)
|
||||
static void FindChunk(const char *name)
|
||||
{
|
||||
last_chunk = iff_data;
|
||||
FindNextChunk (name);
|
||||
FindNextChunk(name);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void DumpChunks (void)
|
||||
static void DumpChunks(void)
|
||||
{
|
||||
char str[5];
|
||||
|
||||
|
@ -237,12 +237,13 @@ static void DumpChunks (void)
|
|||
data_p = iff_data;
|
||||
do
|
||||
{
|
||||
memcpy (str, data_p, 4);
|
||||
memcpy(str, data_p, 4);
|
||||
data_p += 4;
|
||||
iff_chunk_len = GetLittleLong();
|
||||
Con_Printf ("0x%x : %s (%" PRIi32 ")\n", (int32_t)(data_p - 4), str, iff_chunk_len);
|
||||
Con_Printf("0x%x : %s (%" PRIi32 ")\n", (int32_t)(data_p - 4), str, iff_chunk_len);
|
||||
data_p += (iff_chunk_len + 1) & ~1;
|
||||
} while (data_p < iff_end);
|
||||
}
|
||||
while(data_p < iff_end);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -251,16 +252,16 @@ static void DumpChunks (void)
|
|||
GetWavinfo
|
||||
============
|
||||
*/
|
||||
wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
||||
wavinfo_t GetWavinfo(const char *name, byte *wav, int32_t wavlength)
|
||||
{
|
||||
wavinfo_t info;
|
||||
int32_t i;
|
||||
int32_t format;
|
||||
int32_t samples;
|
||||
|
||||
memset (&info, 0, sizeof(info));
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (!wav)
|
||||
if(!wav)
|
||||
return info;
|
||||
|
||||
iff_data = wav;
|
||||
|
@ -268,7 +269,7 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
|||
|
||||
// find "RIFF" chunk
|
||||
FindChunk("RIFF");
|
||||
if (!(data_p && !Q_strncmp((char *)data_p + 8, "WAVE", 4)))
|
||||
if(!(data_p && !Q_strncmp((char *)data_p + 8, "WAVE", 4)))
|
||||
{
|
||||
Con_Printf("%s missing RIFF/WAVE chunks\n", name);
|
||||
return info;
|
||||
|
@ -277,18 +278,18 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
|||
// get "fmt " chunk
|
||||
iff_data = data_p + 12;
|
||||
#if 0
|
||||
DumpChunks ();
|
||||
DumpChunks();
|
||||
#endif
|
||||
|
||||
FindChunk("fmt ");
|
||||
if (!data_p)
|
||||
if(!data_p)
|
||||
{
|
||||
Con_Printf("%s is missing fmt chunk\n", name);
|
||||
return info;
|
||||
}
|
||||
data_p += 8;
|
||||
format = GetLittleShort();
|
||||
if (format != WAV_FORMAT_PCM)
|
||||
if(format != WAV_FORMAT_PCM)
|
||||
{
|
||||
Con_Printf("%s is not Microsoft PCM format\n", name);
|
||||
return info;
|
||||
|
@ -298,24 +299,25 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
|||
info.rate = GetLittleLong();
|
||||
data_p += 4 + 2;
|
||||
i = GetLittleShort();
|
||||
if (i != 8 && i != 16)
|
||||
if(i != 8 && i != 16)
|
||||
return info;
|
||||
info.width = i / 8;
|
||||
|
||||
// get cue chunk
|
||||
FindChunk("cue ");
|
||||
if (data_p)
|
||||
if(data_p)
|
||||
{
|
||||
data_p += 32;
|
||||
info.loopstart = GetLittleLong();
|
||||
// Con_Printf("loopstart=%" PRIi32 "\n", sfx->loopstart);
|
||||
|
||||
// if the next chunk is a LIST chunk, look for a cue length marker
|
||||
FindNextChunk ("LIST");
|
||||
if (data_p)
|
||||
FindNextChunk("LIST");
|
||||
if(data_p)
|
||||
{
|
||||
if (!strncmp((char *)data_p + 28, "mark", 4))
|
||||
{ // this is not a proper parse, but it works with cooledit...
|
||||
if(!strncmp((char *)data_p + 28, "mark", 4))
|
||||
{
|
||||
// this is not a proper parse, but it works with cooledit...
|
||||
data_p += 24;
|
||||
i = GetLittleLong(); // samples in loop
|
||||
info.samples = info.loopstart + i;
|
||||
|
@ -328,7 +330,7 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
|||
|
||||
// find data chunk
|
||||
FindChunk("data");
|
||||
if (!data_p)
|
||||
if(!data_p)
|
||||
{
|
||||
Con_Printf("%s is missing data chunk\n", name);
|
||||
return info;
|
||||
|
@ -337,10 +339,10 @@ wavinfo_t GetWavinfo (const char *name, byte *wav, int32_t wavlength)
|
|||
data_p += 4;
|
||||
samples = GetLittleLong() / info.width;
|
||||
|
||||
if (info.samples)
|
||||
if(info.samples)
|
||||
{
|
||||
if (samples < info.samples)
|
||||
Sys_Error ("%s has a bad loop length", name);
|
||||
if(samples < info.samples)
|
||||
Sys_Error("%s has a bad loop length", name);
|
||||
}
|
||||
else
|
||||
info.samples = samples;
|
||||
|
|
|
@ -42,8 +42,9 @@
|
|||
#define DMODE_SIMDMIXER 0x0800 /* enable SIMD mixing */
|
||||
#endif
|
||||
|
||||
typedef struct _mik_priv {
|
||||
/* struct MREADER in libmikmod <= 3.2.0-beta2
|
||||
typedef struct _mik_priv
|
||||
{
|
||||
/* struct MREADER in libmikmod <= 3.2.0-beta2
|
||||
* doesn't have iobase members. adding them here
|
||||
* so that if we compile against 3.2.0-beta2, we
|
||||
* can still run OK against 3.2.0b3 and newer. */
|
||||
|
@ -53,46 +54,46 @@ typedef struct _mik_priv {
|
|||
MODULE *module;
|
||||
} mik_priv_t;
|
||||
|
||||
static int32_t MIK_Seek (MREADER *r, long ofs, int32_t whence)
|
||||
static int32_t MIK_Seek(MREADER *r, long ofs, int32_t whence)
|
||||
{
|
||||
return FS_fseek(((mik_priv_t *)r)->fh, ofs, whence);
|
||||
}
|
||||
|
||||
static long MIK_Tell (MREADER *r)
|
||||
static long MIK_Tell(MREADER *r)
|
||||
{
|
||||
return FS_ftell(((mik_priv_t *)r)->fh);
|
||||
}
|
||||
|
||||
static BOOL MIK_Read (MREADER *r, void *ptr, size_t siz)
|
||||
static BOOL MIK_Read(MREADER *r, void *ptr, size_t siz)
|
||||
{
|
||||
return !!FS_fread(ptr, siz, 1, ((mik_priv_t *)r)->fh);
|
||||
}
|
||||
|
||||
static int32_t MIK_Get (MREADER *r)
|
||||
static int32_t MIK_Get(MREADER *r)
|
||||
{
|
||||
return FS_fgetc(((mik_priv_t *)r)->fh);
|
||||
}
|
||||
|
||||
static BOOL MIK_Eof (MREADER *r)
|
||||
static BOOL MIK_Eof(MREADER *r)
|
||||
{
|
||||
return FS_feof(((mik_priv_t *)r)->fh);
|
||||
}
|
||||
|
||||
static bool S_MIKMOD_CodecInitialize (void)
|
||||
static bool S_MIKMOD_CodecInitialize(void)
|
||||
{
|
||||
if (mikmod_codec.initialized)
|
||||
if(mikmod_codec.initialized)
|
||||
return true;
|
||||
|
||||
/* set mode flags to only we like: */
|
||||
md_mode = 0;
|
||||
if ((shm->samplebits / 8) == 2)
|
||||
if((shm->samplebits / 8) == 2)
|
||||
md_mode |= DMODE_16BITS;
|
||||
if (shm->channels == 2)
|
||||
if(shm->channels == 2)
|
||||
md_mode |= DMODE_STEREO;
|
||||
md_mode |= DMODE_SOFT_MUSIC; /* this is a software-only mixer */
|
||||
|
||||
/* md_mixfreq is UWORD, so something like 96000 isn't OK */
|
||||
md_mixfreq = (shm->speed < 65536)? shm->speed : 48000;
|
||||
md_mixfreq = (shm->speed < 65536) ? shm->speed : 48000;
|
||||
|
||||
/* keeping md_device as 0 which is default (auto-detect: we
|
||||
* only register drv_nos, and it will be the only one found.)
|
||||
|
@ -104,7 +105,7 @@ static bool S_MIKMOD_CodecInitialize (void)
|
|||
|
||||
MikMod_RegisterDriver(&drv_nos); /* only need the "nosound" driver, none else */
|
||||
MikMod_RegisterAllLoaders();
|
||||
if (S_MIKMOD_initlib(NULL))
|
||||
if(S_MIKMOD_initlib(NULL))
|
||||
{
|
||||
Con_DPrintf("Could not initialize MikMod: %s\n", MikMod_strerror(MikMod_errno));
|
||||
return false;
|
||||
|
@ -117,16 +118,16 @@ static bool S_MIKMOD_CodecInitialize (void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void S_MIKMOD_CodecShutdown (void)
|
||||
static void S_MIKMOD_CodecShutdown(void)
|
||||
{
|
||||
if (mikmod_codec.initialized)
|
||||
if(mikmod_codec.initialized)
|
||||
{
|
||||
mikmod_codec.initialized = false;
|
||||
MikMod_Exit();
|
||||
}
|
||||
}
|
||||
|
||||
static bool S_MIKMOD_CodecOpenStream (snd_stream_t *stream)
|
||||
static bool S_MIKMOD_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
mik_priv_t *priv;
|
||||
|
||||
|
@ -140,7 +141,7 @@ static bool S_MIKMOD_CodecOpenStream (snd_stream_t *stream)
|
|||
priv->fh = &stream->fh;
|
||||
|
||||
priv->module = Player_LoadGeneric((MREADER *)stream->priv, 64, 0);
|
||||
if (!priv->module)
|
||||
if(!priv->module)
|
||||
{
|
||||
Con_DPrintf("Could not load module: %s\n", MikMod_strerror(MikMod_errno));
|
||||
Z_Free(stream->priv);
|
||||
|
@ -157,22 +158,22 @@ static bool S_MIKMOD_CodecOpenStream (snd_stream_t *stream)
|
|||
Player_Start(priv->module);
|
||||
|
||||
stream->info.rate = md_mixfreq;
|
||||
stream->info.bits = (md_mode & DMODE_16BITS)? 16: 8;
|
||||
stream->info.bits = (md_mode & DMODE_16BITS) ? 16 : 8;
|
||||
stream->info.width = stream->info.bits / 8;
|
||||
stream->info.channels = (md_mode & DMODE_STEREO)? 2 : 1;
|
||||
/* Con_DPrintf("Playing %s (%" PRIi32 " chn)\n", priv->module->songname, priv->module->numchn);*/
|
||||
stream->info.channels = (md_mode & DMODE_STEREO) ? 2 : 1;
|
||||
/* Con_DPrintf("Playing %s (%" PRIi32 " chn)\n", priv->module->songname, priv->module->numchn);*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t S_MIKMOD_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
static int32_t S_MIKMOD_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
{
|
||||
if (!Player_Active())
|
||||
if(!Player_Active())
|
||||
return 0;
|
||||
return (int32_t) VC_WriteBytes((SBYTE *)buffer, bytes);
|
||||
}
|
||||
|
||||
static void S_MIKMOD_CodecCloseStream (snd_stream_t *stream)
|
||||
static void S_MIKMOD_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
Player_Stop();
|
||||
Player_Free(((mik_priv_t *)stream->priv)->module);
|
||||
|
@ -180,9 +181,9 @@ static void S_MIKMOD_CodecCloseStream (snd_stream_t *stream)
|
|||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int32_t S_MIKMOD_CodecRewindStream (snd_stream_t *stream)
|
||||
static int32_t S_MIKMOD_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
Player_SetPosition (0);
|
||||
Player_SetPosition(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
190
source/snd_mix.c
190
source/snd_mix.c
|
@ -31,32 +31,32 @@ int16_t *snd_out;
|
|||
|
||||
static int32_t snd_vol;
|
||||
|
||||
static void Snd_WriteLinearBlastStereo16 (void)
|
||||
static void Snd_WriteLinearBlastStereo16(void)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t val;
|
||||
|
||||
for (i = 0; i < snd_linear_count; i += 2)
|
||||
for(i = 0; i < snd_linear_count; i += 2)
|
||||
{
|
||||
val = snd_p[i] / 256;
|
||||
if (val > 0x7fff)
|
||||
if(val > 0x7fff)
|
||||
snd_out[i] = 0x7fff;
|
||||
else if (val < (int16_t)0x8000)
|
||||
else if(val < (int16_t)0x8000)
|
||||
snd_out[i] = (int16_t)0x8000;
|
||||
else
|
||||
snd_out[i] = val;
|
||||
|
||||
val = snd_p[i+1] / 256;
|
||||
if (val > 0x7fff)
|
||||
snd_out[i+1] = 0x7fff;
|
||||
else if (val < (int16_t)0x8000)
|
||||
snd_out[i+1] = (int16_t)0x8000;
|
||||
val = snd_p[i + 1] / 256;
|
||||
if(val > 0x7fff)
|
||||
snd_out[i + 1] = 0x7fff;
|
||||
else if(val < (int16_t)0x8000)
|
||||
snd_out[i + 1] = (int16_t)0x8000;
|
||||
else
|
||||
snd_out[i+1] = val;
|
||||
snd_out[i + 1] = val;
|
||||
}
|
||||
}
|
||||
|
||||
static void S_TransferStereo16 (int32_t endtime)
|
||||
static void S_TransferStereo16(int32_t endtime)
|
||||
{
|
||||
int32_t lpos;
|
||||
int32_t lpaintedtime;
|
||||
|
@ -64,7 +64,7 @@ static void S_TransferStereo16 (int32_t endtime)
|
|||
snd_p = (int32_t *) paintbuffer;
|
||||
lpaintedtime = paintedtime;
|
||||
|
||||
while (lpaintedtime < endtime)
|
||||
while(lpaintedtime < endtime)
|
||||
{
|
||||
// handle recirculating buffer issues
|
||||
lpos = lpaintedtime & ((shm->samples >> 1) - 1);
|
||||
|
@ -72,28 +72,28 @@ static void S_TransferStereo16 (int32_t endtime)
|
|||
snd_out = (int16_t *)shm->buffer + (lpos << 1);
|
||||
|
||||
snd_linear_count = (shm->samples >> 1) - lpos;
|
||||
if (lpaintedtime + snd_linear_count > endtime)
|
||||
if(lpaintedtime + snd_linear_count > endtime)
|
||||
snd_linear_count = endtime - lpaintedtime;
|
||||
|
||||
snd_linear_count <<= 1;
|
||||
|
||||
// write a linear blast of samples
|
||||
Snd_WriteLinearBlastStereo16 ();
|
||||
Snd_WriteLinearBlastStereo16();
|
||||
|
||||
snd_p += snd_linear_count;
|
||||
lpaintedtime += (snd_linear_count >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void S_TransferPaintBuffer (int32_t endtime)
|
||||
static void S_TransferPaintBuffer(int32_t endtime)
|
||||
{
|
||||
int32_t out_idx, out_mask;
|
||||
int32_t count, step, val;
|
||||
int32_t *p;
|
||||
|
||||
if (shm->samplebits == 16 && shm->channels == 2)
|
||||
if(shm->samplebits == 16 && shm->channels == 2)
|
||||
{
|
||||
S_TransferStereo16 (endtime);
|
||||
S_TransferStereo16(endtime);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,46 +103,46 @@ static void S_TransferPaintBuffer (int32_t endtime)
|
|||
out_idx = paintedtime * shm->channels & out_mask;
|
||||
step = 3 - shm->channels;
|
||||
|
||||
if (shm->samplebits == 16)
|
||||
if(shm->samplebits == 16)
|
||||
{
|
||||
int16_t *out = (int16_t *)shm->buffer;
|
||||
while (count--)
|
||||
while(count--)
|
||||
{
|
||||
val = *p / 256;
|
||||
p+= step;
|
||||
if (val > 0x7fff)
|
||||
p += step;
|
||||
if(val > 0x7fff)
|
||||
val = 0x7fff;
|
||||
else if (val < (int16_t)0x8000)
|
||||
else if(val < (int16_t)0x8000)
|
||||
val = (int16_t)0x8000;
|
||||
out[out_idx] = val;
|
||||
out_idx = (out_idx + 1) & out_mask;
|
||||
}
|
||||
}
|
||||
else if (shm->samplebits == 8 && !shm->signed8)
|
||||
else if(shm->samplebits == 8 && !shm->signed8)
|
||||
{
|
||||
uint8_t *out = shm->buffer;
|
||||
while (count--)
|
||||
while(count--)
|
||||
{
|
||||
val = *p / 256;
|
||||
p+= step;
|
||||
if (val > 0x7fff)
|
||||
p += step;
|
||||
if(val > 0x7fff)
|
||||
val = 0x7fff;
|
||||
else if (val < (int16_t)0x8000)
|
||||
else if(val < (int16_t)0x8000)
|
||||
val = (int16_t)0x8000;
|
||||
out[out_idx] = (val / 256) + 128;
|
||||
out_idx = (out_idx + 1) & out_mask;
|
||||
}
|
||||
}
|
||||
else if (shm->samplebits == 8) /* S8 format, e.g. with Amiga AHI */
|
||||
else if(shm->samplebits == 8) /* S8 format, e.g. with Amiga AHI */
|
||||
{
|
||||
int8_t *out = (int8_t *) shm->buffer;
|
||||
while (count--)
|
||||
while(count--)
|
||||
{
|
||||
val = *p / 256;
|
||||
p+= step;
|
||||
if (val > 0x7fff)
|
||||
p += step;
|
||||
if(val > 0x7fff)
|
||||
val = 0x7fff;
|
||||
else if (val < (int16_t)0x8000)
|
||||
else if(val < (int16_t)0x8000)
|
||||
val = (int16_t)0x8000;
|
||||
out[out_idx] = (val / 256);
|
||||
out_idx = (out_idx + 1) & out_mask;
|
||||
|
@ -165,36 +165,37 @@ f_c is the filter cutoff frequency, as a fraction of the samplerate
|
|||
static void S_MakeBlackmanWindowKernel(float *kernel, int32_t M, float f_c)
|
||||
{
|
||||
int32_t i;
|
||||
for (i = 0; i <= M; i++)
|
||||
for(i = 0; i <= M; i++)
|
||||
{
|
||||
if (i == M/2)
|
||||
if(i == M / 2)
|
||||
{
|
||||
kernel[i] = 2 * M_PI * f_c;
|
||||
}
|
||||
else
|
||||
{
|
||||
kernel[i] = ( sin(2 * M_PI * f_c * (i - M/2.0)) / (i - (M/2.0)) )
|
||||
* (0.42 - 0.5*cos(2 * M_PI * i / (double)M)
|
||||
+ 0.08*cos(4 * M_PI * i / (double)M) );
|
||||
kernel[i] = (sin(2 * M_PI * f_c * (i - M / 2.0)) / (i - (M / 2.0)))
|
||||
* (0.42 - 0.5 * cos(2 * M_PI * i / (double)M)
|
||||
+ 0.08 * cos(4 * M_PI * i / (double)M));
|
||||
}
|
||||
}
|
||||
|
||||
// normalize the kernel so all of the values sum to 1
|
||||
{
|
||||
float sum = 0;
|
||||
for (i = 0; i <= M; i++)
|
||||
for(i = 0; i <= M; i++)
|
||||
{
|
||||
sum += kernel[i];
|
||||
}
|
||||
|
||||
for (i = 0; i <= M; i++)
|
||||
for(i = 0; i <= M; i++)
|
||||
{
|
||||
kernel[i] /= sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float *memory; // kernelsize floats
|
||||
float *kernel; // kernelsize floats
|
||||
int32_t kernelsize; // M+1, rounded up to be a multiple of 16
|
||||
|
@ -205,10 +206,10 @@ typedef struct {
|
|||
|
||||
static void S_UpdateFilter(filter_t *filter, int32_t M, float f_c)
|
||||
{
|
||||
if (filter->f_c != f_c || filter->M != M)
|
||||
if(filter->f_c != f_c || filter->M != M)
|
||||
{
|
||||
if (filter->memory != NULL) free(filter->memory);
|
||||
if (filter->kernel != NULL) free(filter->kernel);
|
||||
if(filter->memory != NULL) free(filter->memory);
|
||||
if(filter->kernel != NULL) free(filter->kernel);
|
||||
|
||||
filter->M = M;
|
||||
filter->f_c = f_c;
|
||||
|
@ -249,9 +250,9 @@ static void S_ApplyFilter(filter_t *filter, int32_t *data, int32_t stride, int32
|
|||
// memory holds the previous filter->kernelsize samples of input.
|
||||
memcpy(input, filter->memory, filter->kernelsize * sizeof(float));
|
||||
|
||||
for (i=0; i<count; i++)
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
input[filter->kernelsize+i] = data[i * stride] / (32768.0 * 256.0);
|
||||
input[filter->kernelsize + i] = data[i * stride] / (32768.0 * 256.0);
|
||||
}
|
||||
|
||||
// copy out the last filter->kernelsize samples to 'memory' for next time
|
||||
|
@ -260,17 +261,17 @@ static void S_ApplyFilter(filter_t *filter, int32_t *data, int32_t stride, int32
|
|||
// apply the filter
|
||||
parity = filter->parity;
|
||||
|
||||
for (i=0; i<count; i++)
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
const float *input_plus_i = input + i;
|
||||
float val[4] = {0, 0, 0, 0};
|
||||
|
||||
for (j = (4 - parity) % 4; j < kernelsize; j+=16)
|
||||
for(j = (4 - parity) % 4; j < kernelsize; j += 16)
|
||||
{
|
||||
val[0] += kernel[j] * input_plus_i[j];
|
||||
val[1] += kernel[j+4] * input_plus_i[j+4];
|
||||
val[2] += kernel[j+8] * input_plus_i[j+8];
|
||||
val[3] += kernel[j+12] * input_plus_i[j+12];
|
||||
val[1] += kernel[j + 4] * input_plus_i[j + 4];
|
||||
val[2] += kernel[j + 8] * input_plus_i[j + 8];
|
||||
val[3] += kernel[j + 12] * input_plus_i[j + 12];
|
||||
}
|
||||
|
||||
// 4.0 factor is to increase volume by 12 dB; this is to make up the
|
||||
|
@ -301,19 +302,29 @@ static void S_LowpassFilter(int32_t *data, int32_t stride, int32_t count,
|
|||
int32_t M;
|
||||
float bw, f_c;
|
||||
|
||||
switch ((int32_t)snd_filterquality.value)
|
||||
switch((int32_t)snd_filterquality.value)
|
||||
{
|
||||
case 1:
|
||||
M = 126; bw = 0.900; break;
|
||||
M = 126;
|
||||
bw = 0.900;
|
||||
break;
|
||||
case 2:
|
||||
M = 150; bw = 0.915; break;
|
||||
M = 150;
|
||||
bw = 0.915;
|
||||
break;
|
||||
case 3:
|
||||
M = 174; bw = 0.930; break;
|
||||
M = 174;
|
||||
bw = 0.930;
|
||||
break;
|
||||
case 4:
|
||||
M = 198; bw = 0.945; break;
|
||||
M = 198;
|
||||
bw = 0.945;
|
||||
break;
|
||||
case 5:
|
||||
default:
|
||||
M = 222; bw = 0.960; break;
|
||||
M = 222;
|
||||
bw = 0.960;
|
||||
break;
|
||||
}
|
||||
|
||||
f_c = (bw * 11025 / 2.0) / 44100.0;
|
||||
|
@ -330,10 +341,10 @@ CHANNEL MIXING
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int32_t endtime, int32_t paintbufferstart);
|
||||
static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int32_t endtime, int32_t paintbufferstart);
|
||||
static void SND_PaintChannelFrom8(channel_t *ch, sfxcache_t *sc, int32_t endtime, int32_t paintbufferstart);
|
||||
static void SND_PaintChannelFrom16(channel_t *ch, sfxcache_t *sc, int32_t endtime, int32_t paintbufferstart);
|
||||
|
||||
void S_PaintChannels (int32_t endtime)
|
||||
void S_PaintChannels(int32_t endtime)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t end, ltime, count;
|
||||
|
@ -342,11 +353,11 @@ void S_PaintChannels (int32_t endtime)
|
|||
|
||||
snd_vol = sfxvolume.value * 256;
|
||||
|
||||
while (paintedtime < endtime)
|
||||
while(paintedtime < endtime)
|
||||
{
|
||||
// if paintbuffer is smaller than DMA buffer
|
||||
end = endtime;
|
||||
if (endtime - paintedtime > PAINTBUFFER_SIZE)
|
||||
if(endtime - paintedtime > PAINTBUFFER_SIZE)
|
||||
end = paintedtime + PAINTBUFFER_SIZE;
|
||||
|
||||
// clear the paint buffer
|
||||
|
@ -354,30 +365,31 @@ void S_PaintChannels (int32_t endtime)
|
|||
|
||||
// paint in the channels.
|
||||
ch = snd_channels;
|
||||
for (i = 0; i < total_channels; i++, ch++)
|
||||
for(i = 0; i < total_channels; i++, ch++)
|
||||
{
|
||||
if (!ch->sfx)
|
||||
if(!ch->sfx)
|
||||
continue;
|
||||
if (!ch->leftvol && !ch->rightvol)
|
||||
if(!ch->leftvol && !ch->rightvol)
|
||||
continue;
|
||||
sc = S_LoadSound (ch->sfx);
|
||||
if (!sc)
|
||||
sc = S_LoadSound(ch->sfx);
|
||||
if(!sc)
|
||||
continue;
|
||||
|
||||
ltime = paintedtime;
|
||||
|
||||
while (ltime < end)
|
||||
{ // paint up to end
|
||||
if (ch->end < end)
|
||||
while(ltime < end)
|
||||
{
|
||||
// paint up to end
|
||||
if(ch->end < end)
|
||||
count = ch->end - ltime;
|
||||
else
|
||||
count = end - ltime;
|
||||
|
||||
if (count > 0)
|
||||
if(count > 0)
|
||||
{
|
||||
// the last param to SND_PaintChannelFrom is the index
|
||||
// to start painting to in the paintbuffer, usually 0.
|
||||
if (sc->width == 1)
|
||||
if(sc->width == 1)
|
||||
SND_PaintChannelFrom8(ch, sc, count, ltime - paintedtime);
|
||||
else
|
||||
SND_PaintChannelFrom16(ch, sc, count, ltime - paintedtime);
|
||||
|
@ -386,15 +398,16 @@ void S_PaintChannels (int32_t endtime)
|
|||
}
|
||||
|
||||
// if at end of loop, restart
|
||||
if (ltime >= ch->end)
|
||||
if(ltime >= ch->end)
|
||||
{
|
||||
if (sc->loopstart >= 0)
|
||||
if(sc->loopstart >= 0)
|
||||
{
|
||||
ch->pos = sc->loopstart;
|
||||
ch->end = ltime + sc->length - ch->pos;
|
||||
}
|
||||
else
|
||||
{ // channel just stopped
|
||||
{
|
||||
// channel just stopped
|
||||
ch->sfx = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -405,14 +418,14 @@ void S_PaintChannels (int32_t endtime)
|
|||
// clip each sample to 0dB, then reduce by 6dB (to leave some headroom for
|
||||
// the lowpass filter and the music). the lowpass will smooth out the
|
||||
// clipping
|
||||
for (i=0; i<end-paintedtime; i++)
|
||||
for(i = 0; i < end - paintedtime; i++)
|
||||
{
|
||||
paintbuffer[i].left = CLAMP(-32768 * 256, paintbuffer[i].left, 32767 * 256) / 2;
|
||||
paintbuffer[i].right = CLAMP(-32768 * 256, paintbuffer[i].right, 32767 * 256) / 2;
|
||||
}
|
||||
|
||||
// apply a lowpass filter
|
||||
if (sndspeed.value == 11025 && shm->speed == 44100)
|
||||
if(sndspeed.value == 11025 && shm->speed == 44100)
|
||||
{
|
||||
static filter_t memory_l, memory_r;
|
||||
S_LowpassFilter((int32_t *)paintbuffer, 2, end - paintedtime, &memory_l);
|
||||
|
@ -420,14 +433,15 @@ void S_PaintChannels (int32_t endtime)
|
|||
}
|
||||
|
||||
// paint in the music
|
||||
if (s_rawend >= paintedtime)
|
||||
{ // copy from the streaming sound source
|
||||
if(s_rawend >= paintedtime)
|
||||
{
|
||||
// copy from the streaming sound source
|
||||
int32_t s;
|
||||
int32_t stop;
|
||||
|
||||
stop = (end < s_rawend) ? end : s_rawend;
|
||||
|
||||
for (i = paintedtime; i < stop; i++)
|
||||
for(i = paintedtime; i < stop; i++)
|
||||
{
|
||||
s = i & (MAX_RAW_SAMPLES - 1);
|
||||
// lower music by 6db to match sfx
|
||||
|
@ -446,15 +460,15 @@ void S_PaintChannels (int32_t endtime)
|
|||
}
|
||||
}
|
||||
|
||||
void SND_InitScaletable (void)
|
||||
void SND_InitScaletable(void)
|
||||
{
|
||||
int32_t i, j;
|
||||
int32_t scale;
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
for(i = 0; i < 32; i++)
|
||||
{
|
||||
scale = i * 8 * 256 * sfxvolume.value;
|
||||
for (j = 0; j < 256; j++)
|
||||
for(j = 0; j < 256; j++)
|
||||
{
|
||||
/* When compiling with gcc-4.1.0 at optimisations O1 and
|
||||
higher, the tricky int8_t type conversion is not
|
||||
|
@ -469,23 +483,23 @@ void SND_InitScaletable (void)
|
|||
}
|
||||
|
||||
|
||||
static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int32_t count, int32_t paintbufferstart)
|
||||
static void SND_PaintChannelFrom8(channel_t *ch, sfxcache_t *sc, int32_t count, int32_t paintbufferstart)
|
||||
{
|
||||
int32_t data;
|
||||
int32_t *lscale, *rscale;
|
||||
uint8_t *sfx;
|
||||
int32_t i;
|
||||
|
||||
if (ch->leftvol > 255)
|
||||
if(ch->leftvol > 255)
|
||||
ch->leftvol = 255;
|
||||
if (ch->rightvol > 255)
|
||||
if(ch->rightvol > 255)
|
||||
ch->rightvol = 255;
|
||||
|
||||
lscale = snd_scaletable[ch->leftvol >> 3];
|
||||
rscale = snd_scaletable[ch->rightvol >> 3];
|
||||
sfx = (uint8_t *)sc->data + ch->pos;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
data = sfx[i];
|
||||
paintbuffer[paintbufferstart + i].left += lscale[data];
|
||||
|
@ -495,7 +509,7 @@ static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int32_t count,
|
|||
ch->pos += count;
|
||||
}
|
||||
|
||||
static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int32_t count, int32_t paintbufferstart)
|
||||
static void SND_PaintChannelFrom16(channel_t *ch, sfxcache_t *sc, int32_t count, int32_t paintbufferstart)
|
||||
{
|
||||
int32_t data;
|
||||
int32_t left, right;
|
||||
|
@ -509,7 +523,7 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int32_t count
|
|||
rightvol /= 256;
|
||||
sfx = (int16_t *)sc->data + ch->pos;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
data = sfx[i];
|
||||
// this was causing integer overflow as observed in quakespasm
|
||||
|
|
116
source/snd_mp3.c
116
source/snd_mp3.c
|
@ -69,7 +69,7 @@ typedef struct _mp3_priv_t
|
|||
* Returns 0 if the frame is not an ID3 tag, tag length if it is */
|
||||
static inline bool tag_is_id3v1(const uint8_t *data, size_t length)
|
||||
{
|
||||
if (length >= 3 &&
|
||||
if(length >= 3 &&
|
||||
data[0] == 'T' && data[1] == 'A' && data[2] == 'G')
|
||||
{
|
||||
return true;
|
||||
|
@ -79,7 +79,7 @@ static inline bool tag_is_id3v1(const uint8_t *data, size_t length)
|
|||
|
||||
static inline bool tag_is_id3v2(const uint8_t *data, size_t length)
|
||||
{
|
||||
if (length >= 10 &&
|
||||
if(length >= 10 &&
|
||||
(data[0] == 'I' && data[1] == 'D' && data[2] == '3') &&
|
||||
data[3] < 0xff && data[4] < 0xff &&
|
||||
data[6] < 0x80 && data[7] < 0x80 && data[8] < 0x80 && data[9] < 0x80)
|
||||
|
@ -97,14 +97,14 @@ static inline bool tag_is_apetag(const uint8_t *data, size_t length)
|
|||
{
|
||||
uint32_t v;
|
||||
|
||||
if (length < 32) return false;
|
||||
if (memcmp(data,"APETAGEX",8) != 0)
|
||||
if(length < 32) return false;
|
||||
if(memcmp(data, "APETAGEX", 8) != 0)
|
||||
return false;
|
||||
v = (data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8];
|
||||
if (v != 2000U/* && v != 1000U*/)
|
||||
v = (data[11] << 24) | (data[10] << 16) | (data[9] << 8) | data[8];
|
||||
if(v != 2000U/* && v != 1000U*/)
|
||||
return false;
|
||||
v = 0;
|
||||
if (memcmp(&data[24],&v,4) != 0 || memcmp(&data[28],&v,4) != 0)
|
||||
if(memcmp(&data[24], &v, 4) != 0 || memcmp(&data[28], &v, 4) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -113,23 +113,23 @@ static size_t mp3_tagsize(const uint8_t *data, size_t length)
|
|||
{
|
||||
size_t size;
|
||||
|
||||
if (tag_is_id3v1(data, length))
|
||||
if(tag_is_id3v1(data, length))
|
||||
return 128;
|
||||
|
||||
if (tag_is_id3v2(data, length))
|
||||
if(tag_is_id3v2(data, length))
|
||||
{
|
||||
uint8_t flags = data[5];
|
||||
size = 10 + (data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9];
|
||||
if (flags & ID3_TAG_FLAG_FOOTERPRESENT)
|
||||
size = 10 + (data[6] << 21) + (data[7] << 14) + (data[8] << 7) + data[9];
|
||||
if(flags & ID3_TAG_FLAG_FOOTERPRESENT)
|
||||
size += 10;
|
||||
for ( ; size < length && !data[size]; ++size)
|
||||
for(; size < length && !data[size]; ++size)
|
||||
; /* Consume padding */
|
||||
return size;
|
||||
}
|
||||
|
||||
if (tag_is_apetag(data, length))
|
||||
if(tag_is_apetag(data, length))
|
||||
{
|
||||
size = (data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12];
|
||||
size = (data[15] << 24) | (data[14] << 16) | (data[13] << 8) | data[12];
|
||||
size += 32;
|
||||
return size;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ static int32_t mp3_inputtag(snd_stream_t *stream)
|
|||
*/
|
||||
remaining = p->stream.bufend - p->stream.next_frame;
|
||||
tagsize = mp3_tagsize(p->stream.this_frame, remaining);
|
||||
if (tagsize != 0)
|
||||
if(tagsize != 0)
|
||||
{
|
||||
mad_stream_skip(&p->stream, tagsize);
|
||||
rc = 0;
|
||||
|
@ -200,10 +200,10 @@ static int32_t mp3_inputdata(snd_stream_t *stream)
|
|||
|
||||
bytes_read = FS_fread(p->mp3_buffer + remaining, 1,
|
||||
MP3_BUFFER_SIZE - remaining, &stream->fh);
|
||||
if (bytes_read == 0)
|
||||
if(bytes_read == 0)
|
||||
return -1;
|
||||
|
||||
mad_stream_buffer(&p->stream, p->mp3_buffer, bytes_read+remaining);
|
||||
mad_stream_buffer(&p->stream, p->mp3_buffer, bytes_read + remaining);
|
||||
p->stream.error = MAD_ERROR_NONE;
|
||||
|
||||
return 0;
|
||||
|
@ -224,7 +224,7 @@ static int32_t mp3_startread(snd_stream_t *stream)
|
|||
* can be processed later.
|
||||
*/
|
||||
ReadSize = FS_fread(p->mp3_buffer, 1, MP3_BUFFER_SIZE, &stream->fh);
|
||||
if (!ReadSize || FS_ferror(&stream->fh))
|
||||
if(!ReadSize || FS_ferror(&stream->fh))
|
||||
return -1;
|
||||
|
||||
mad_stream_buffer(&p->stream, p->mp3_buffer, ReadSize);
|
||||
|
@ -234,12 +234,12 @@ static int32_t mp3_startread(snd_stream_t *stream)
|
|||
* at the beginning of the audio file.
|
||||
*/
|
||||
p->stream.error = MAD_ERROR_NONE;
|
||||
while (mad_frame_decode(&p->frame,&p->stream))
|
||||
while(mad_frame_decode(&p->frame, &p->stream))
|
||||
{
|
||||
/* check whether input buffer needs a refill */
|
||||
if (p->stream.error == MAD_ERROR_BUFLEN)
|
||||
if(p->stream.error == MAD_ERROR_BUFLEN)
|
||||
{
|
||||
if (mp3_inputdata(stream) == -1)
|
||||
if(mp3_inputdata(stream) == -1)
|
||||
return -1;/* EOF with no valid data */
|
||||
|
||||
continue;
|
||||
|
@ -256,7 +256,7 @@ static int32_t mp3_startread(snd_stream_t *stream)
|
|||
p->stream.error = MAD_ERROR_NONE;
|
||||
}
|
||||
|
||||
if (p->stream.error)
|
||||
if(p->stream.error)
|
||||
{
|
||||
Con_Printf("MP3: No valid MP3 frame found\n");
|
||||
return -1;
|
||||
|
@ -277,8 +277,8 @@ static int32_t mp3_startread(snd_stream_t *stream)
|
|||
|
||||
p->frame_count = 1;
|
||||
|
||||
mad_timer_add(&p->timer,p->frame.header.duration);
|
||||
mad_synth_frame(&p->synth,&p->frame);
|
||||
mad_timer_add(&p->timer, p->frame.header.duration);
|
||||
mad_synth_frame(&p->synth, &p->frame);
|
||||
stream->info.rate = p->synth.pcm.samplerate;
|
||||
stream->info.bits = MP3_MAD_SAMPLEBITS;
|
||||
stream->info.width = MP3_MAD_SAMPLEWIDTH;
|
||||
|
@ -304,20 +304,20 @@ static int32_t mp3_decode(snd_stream_t *stream, byte *buf, int32_t len)
|
|||
x = (p->synth.pcm.length - p->cursamp) * stream->info.channels;
|
||||
donow = q_min(len, x);
|
||||
i = 0;
|
||||
while (i < donow)
|
||||
while(i < donow)
|
||||
{
|
||||
for (chan = 0; chan < stream->info.channels; chan++)
|
||||
for(chan = 0; chan < stream->info.channels; chan++)
|
||||
{
|
||||
sample = p->synth.pcm.samples[chan][p->cursamp];
|
||||
/* convert from fixed to int16_t,
|
||||
* write in host-endian format. */
|
||||
if (sample <= -MAD_F_ONE)
|
||||
if(sample <= -MAD_F_ONE)
|
||||
sample = -0x7FFF;
|
||||
else if (sample >= MAD_F_ONE)
|
||||
else if(sample >= MAD_F_ONE)
|
||||
sample = 0x7FFF;
|
||||
else
|
||||
sample >>= (MAD_F_FRACBITS + 1 - 16);
|
||||
if (host_bigendian)
|
||||
if(host_bigendian)
|
||||
{
|
||||
*buf++ = (sample >> 8) & 0xFF;
|
||||
*buf++ = sample & 0xFF;
|
||||
|
@ -335,13 +335,13 @@ static int32_t mp3_decode(snd_stream_t *stream, byte *buf, int32_t len)
|
|||
len -= donow;
|
||||
done += donow;
|
||||
|
||||
if (len == 0)
|
||||
if(len == 0)
|
||||
break;
|
||||
|
||||
/* check whether input buffer needs a refill */
|
||||
if (p->stream.error == MAD_ERROR_BUFLEN)
|
||||
if(p->stream.error == MAD_ERROR_BUFLEN)
|
||||
{
|
||||
if (mp3_inputdata(stream) == -1)
|
||||
if(mp3_inputdata(stream) == -1)
|
||||
{
|
||||
/* check feof() ?? */
|
||||
Con_DPrintf("mp3 EOF\n");
|
||||
|
@ -349,16 +349,16 @@ static int32_t mp3_decode(snd_stream_t *stream, byte *buf, int32_t len)
|
|||
}
|
||||
}
|
||||
|
||||
if (mad_frame_decode(&p->frame, &p->stream))
|
||||
if(mad_frame_decode(&p->frame, &p->stream))
|
||||
{
|
||||
if (MAD_RECOVERABLE(p->stream.error))
|
||||
if(MAD_RECOVERABLE(p->stream.error))
|
||||
{
|
||||
mp3_inputtag(stream);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p->stream.error == MAD_ERROR_BUFLEN)
|
||||
if(p->stream.error == MAD_ERROR_BUFLEN)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
|
@ -372,7 +372,8 @@ static int32_t mp3_decode(snd_stream_t *stream, byte *buf, int32_t len)
|
|||
mad_timer_add(&p->timer, p->frame.header.duration);
|
||||
mad_synth_frame(&p->synth, &p->frame);
|
||||
p->cursamp = 0;
|
||||
} while (1);
|
||||
}
|
||||
while(1);
|
||||
|
||||
return done;
|
||||
}
|
||||
|
@ -388,31 +389,31 @@ static int32_t mp3_stopread(snd_stream_t *stream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool S_MP3_CodecInitialize (void)
|
||||
static bool S_MP3_CodecInitialize(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void S_MP3_CodecShutdown (void)
|
||||
static void S_MP3_CodecShutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
||||
static bool S_MP3_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
int32_t err;
|
||||
|
||||
stream->priv = calloc(1, sizeof(mp3_priv_t));
|
||||
if (!stream->priv)
|
||||
if(!stream->priv)
|
||||
{
|
||||
Con_Printf("Insufficient memory for MP3 audio\n");
|
||||
return false;
|
||||
}
|
||||
err = mp3_startread(stream);
|
||||
if (err != 0)
|
||||
if(err != 0)
|
||||
{
|
||||
Con_Printf("%s is not a valid mp3 file\n", stream->name);
|
||||
}
|
||||
else if (stream->info.channels != 1 && stream->info.channels != 2)
|
||||
else if(stream->info.channels != 1 && stream->info.channels != 2)
|
||||
{
|
||||
Con_Printf("Unsupported number of channels %" PRIi32 " in %s\n",
|
||||
stream->info.channels, stream->name);
|
||||
|
@ -425,20 +426,20 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int32_t S_MP3_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
static int32_t S_MP3_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
{
|
||||
int32_t res = mp3_decode(stream, (byte *)buffer, bytes / stream->info.width);
|
||||
return res * stream->info.width;
|
||||
}
|
||||
|
||||
static void S_MP3_CodecCloseStream (snd_stream_t *stream)
|
||||
static void S_MP3_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
mp3_stopread(stream);
|
||||
free(stream->priv);
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int32_t S_MP3_CodecRewindStream (snd_stream_t *stream)
|
||||
static int32_t S_MP3_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
mp3_priv_t *p = (mp3_priv_t *) stream->priv;
|
||||
size_t initial_bitrate = p->frame.header.bitrate;
|
||||
|
@ -460,7 +461,7 @@ static int32_t S_MP3_CodecRewindStream (snd_stream_t *stream)
|
|||
mad_frame_init(&p->frame);
|
||||
mad_synth_init(&p->synth);
|
||||
|
||||
while (1) /* Read data from the MP3 file */
|
||||
while(1) /* Read data from the MP3 file */
|
||||
{
|
||||
int32_t bytes_read, padding = 0;
|
||||
size_t leftover = p->stream.bufend - p->stream.next_frame;
|
||||
|
@ -468,39 +469,40 @@ static int32_t S_MP3_CodecRewindStream (snd_stream_t *stream)
|
|||
memcpy(p->mp3_buffer, p->stream.this_frame, leftover);
|
||||
bytes_read = FS_fread(p->mp3_buffer + leftover, (size_t) 1,
|
||||
MP3_BUFFER_SIZE - leftover, &stream->fh);
|
||||
if (bytes_read <= 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
Con_DPrintf("seek failure. unexpected EOF (frames=%" PRIu32 " leftover=%" PRIu32 ")\n",
|
||||
p->frame_count, leftover);
|
||||
break;
|
||||
}
|
||||
for ( ; !depadded && padding < bytes_read && !p->mp3_buffer[padding]; ++padding)
|
||||
for(; !depadded && padding < bytes_read && !p->mp3_buffer[padding]; ++padding)
|
||||
;
|
||||
depadded = true;
|
||||
mad_stream_buffer(&p->stream, p->mp3_buffer + padding, leftover + bytes_read - padding);
|
||||
|
||||
while (1) /* Decode frame headers */
|
||||
while(1) /* Decode frame headers */
|
||||
{
|
||||
static uint16_t samples;
|
||||
p->stream.error = MAD_ERROR_NONE;
|
||||
|
||||
/* Not an audio frame */
|
||||
if (mad_header_decode(&p->frame.header, &p->stream) == -1)
|
||||
if(mad_header_decode(&p->frame.header, &p->stream) == -1)
|
||||
{
|
||||
if (p->stream.error == MAD_ERROR_BUFLEN)
|
||||
if(p->stream.error == MAD_ERROR_BUFLEN)
|
||||
break; /* Normal behaviour; get some more data from the file */
|
||||
if (!MAD_RECOVERABLE(p->stream.error))
|
||||
if(!MAD_RECOVERABLE(p->stream.error))
|
||||
{
|
||||
Con_DPrintf("unrecoverable MAD error\n");
|
||||
break;
|
||||
}
|
||||
if (p->stream.error == MAD_ERROR_LOSTSYNC)
|
||||
if(p->stream.error == MAD_ERROR_LOSTSYNC)
|
||||
{
|
||||
size_t available = (p->stream.bufend - p->stream.this_frame);
|
||||
tagsize = mp3_tagsize(p->stream.this_frame, (size_t) available);
|
||||
if (tagsize)
|
||||
{ /* It's some ID3 tags, so just skip */
|
||||
if (tagsize >= available)
|
||||
if(tagsize)
|
||||
{
|
||||
/* It's some ID3 tags, so just skip */
|
||||
if(tagsize >= available)
|
||||
{
|
||||
FS_fseek(&stream->fh,
|
||||
(ptrdiff_t)tagsize - (ptrdiff_t)available,
|
||||
|
@ -529,7 +531,7 @@ static int32_t S_MP3_CodecRewindStream (snd_stream_t *stream)
|
|||
p->frame_count++;
|
||||
mad_timer_add(&p->timer, p->frame.header.duration);
|
||||
|
||||
mad_frame_decode(&p->frame,&p->stream);
|
||||
mad_frame_decode(&p->frame, &p->stream);
|
||||
mad_synth_frame(&p->synth, &p->frame);
|
||||
p->cursamp = 0;
|
||||
return 0;
|
||||
|
|
|
@ -45,29 +45,29 @@ typedef struct _mp3_priv_t
|
|||
* however our FS_fread() and FS_fseek() return fread() and fseek()
|
||||
* compatible values. */
|
||||
|
||||
static ssize_t mp3_read (void *f, void *buf, size_t size)
|
||||
static ssize_t mp3_read(void *f, void *buf, size_t size)
|
||||
{
|
||||
ssize_t ret = (ssize_t) FS_fread(buf, 1, size, (fshandle_t *)f);
|
||||
if (ret == 0 && errno != 0)
|
||||
if(ret == 0 && errno != 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static off_t mp3_seek (void *f, off_t offset, int32_t whence)
|
||||
static off_t mp3_seek(void *f, off_t offset, int32_t whence)
|
||||
{
|
||||
if (f == NULL) return (-1);
|
||||
if (FS_fseek((fshandle_t *)f, (long) offset, whence) < 0)
|
||||
return (off_t)-1;
|
||||
if(f == NULL) return (-1);
|
||||
if(FS_fseek((fshandle_t *)f, (long) offset, whence) < 0)
|
||||
return (off_t) -1;
|
||||
return (off_t) FS_ftell((fshandle_t *)f);
|
||||
}
|
||||
|
||||
static bool S_MP3_CodecInitialize (void)
|
||||
static bool S_MP3_CodecInitialize(void)
|
||||
{
|
||||
if (!mp3_codec.initialized)
|
||||
if(!mp3_codec.initialized)
|
||||
{
|
||||
if (mpg123_init() != MPG123_OK)
|
||||
if(mpg123_init() != MPG123_OK)
|
||||
{
|
||||
Con_Printf ("Could not initialize mpg123\n");
|
||||
Con_Printf("Could not initialize mpg123\n");
|
||||
return false;
|
||||
}
|
||||
mp3_codec.initialized = true;
|
||||
|
@ -77,16 +77,16 @@ static bool S_MP3_CodecInitialize (void)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void S_MP3_CodecShutdown (void)
|
||||
static void S_MP3_CodecShutdown(void)
|
||||
{
|
||||
if (mp3_codec.initialized)
|
||||
if(mp3_codec.initialized)
|
||||
{
|
||||
mp3_codec.initialized = false;
|
||||
mpg123_exit();
|
||||
}
|
||||
}
|
||||
|
||||
static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
||||
static bool S_MP3_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
long rate = 0;
|
||||
int32_t encoding = 0, channels = 0;
|
||||
|
@ -95,14 +95,14 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
stream->priv = Z_Malloc(sizeof(mp3_priv_t));
|
||||
priv = (mp3_priv_t *) stream->priv;
|
||||
priv->handle = mpg123_new(NULL, NULL);
|
||||
if (priv->handle == NULL)
|
||||
if(priv->handle == NULL)
|
||||
{
|
||||
Con_Printf("Unable to allocate mpg123 handle\n");
|
||||
goto _fail;
|
||||
}
|
||||
priv->handle_newed = 1;
|
||||
|
||||
if (mpg123_replace_reader_handle(priv->handle, mp3_read, mp3_seek, NULL) != MPG123_OK ||
|
||||
if(mpg123_replace_reader_handle(priv->handle, mp3_read, mp3_seek, NULL) != MPG123_OK ||
|
||||
mpg123_open_handle(priv->handle, &stream->fh) != MPG123_OK)
|
||||
{
|
||||
Con_Printf("Unable to open mpg123 handle\n");
|
||||
|
@ -110,13 +110,13 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
}
|
||||
priv->handle_opened = 1;
|
||||
|
||||
if (mpg123_getformat(priv->handle, &rate, &channels, &encoding) != MPG123_OK)
|
||||
if(mpg123_getformat(priv->handle, &rate, &channels, &encoding) != MPG123_OK)
|
||||
{
|
||||
Con_Printf("Unable to retrieve mpg123 format for %s\n", stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
switch (channels)
|
||||
switch(channels)
|
||||
{
|
||||
case MPG123_MONO:
|
||||
stream->info.channels = 1;
|
||||
|
@ -131,7 +131,7 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
|
||||
stream->info.rate = rate;
|
||||
|
||||
switch (encoding)
|
||||
switch(encoding)
|
||||
{
|
||||
case MPG123_ENC_UNSIGNED_8:
|
||||
stream->info.bits = 8;
|
||||
|
@ -155,7 +155,7 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
encoding = MPG123_ENC_SIGNED_16;
|
||||
break;
|
||||
}
|
||||
if (mpg123_format_support(priv->handle, rate, encoding) == 0)
|
||||
if(mpg123_format_support(priv->handle, rate, encoding) == 0)
|
||||
{
|
||||
Con_Printf("Unsupported format for %s\n", stream->name);
|
||||
goto _fail;
|
||||
|
@ -165,23 +165,23 @@ static bool S_MP3_CodecOpenStream (snd_stream_t *stream)
|
|||
|
||||
return true;
|
||||
_fail:
|
||||
if (priv)
|
||||
if(priv)
|
||||
{
|
||||
if (priv->handle_opened)
|
||||
if(priv->handle_opened)
|
||||
mpg123_close(priv->handle);
|
||||
if (priv->handle_newed)
|
||||
if(priv->handle_newed)
|
||||
mpg123_delete(priv->handle);
|
||||
Z_Free(stream->priv);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t S_MP3_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
static int32_t S_MP3_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
{
|
||||
mp3_priv_t *priv = (mp3_priv_t *) stream->priv;
|
||||
size_t bytes_read = 0;
|
||||
int32_t res = mpg123_read (priv->handle, (uint8_t *)buffer, (size_t)bytes, &bytes_read);
|
||||
switch (res)
|
||||
int32_t res = mpg123_read(priv->handle, (uint8_t *)buffer, (size_t)bytes, &bytes_read);
|
||||
switch(res)
|
||||
{
|
||||
case MPG123_DONE:
|
||||
Con_DPrintf("mp3 EOF\n");
|
||||
|
@ -191,7 +191,7 @@ static int32_t S_MP3_CodecReadStream (snd_stream_t *stream, int32_t bytes, void
|
|||
return -1; /* error */
|
||||
}
|
||||
|
||||
static void S_MP3_CodecCloseStream (snd_stream_t *stream)
|
||||
static void S_MP3_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
mp3_priv_t *priv = (mp3_priv_t *) stream->priv;
|
||||
mpg123_close(priv->handle);
|
||||
|
@ -200,11 +200,11 @@ static void S_MP3_CodecCloseStream (snd_stream_t *stream)
|
|||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int32_t S_MP3_CodecRewindStream (snd_stream_t *stream)
|
||||
static int32_t S_MP3_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
mp3_priv_t *priv = (mp3_priv_t *) stream->priv;
|
||||
off_t res = mpg123_seek(priv->handle, 0, SEEK_SET);
|
||||
if (res >= 0) return (0);
|
||||
if(res >= 0) return (0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,35 +34,35 @@
|
|||
|
||||
/* CALLBACK FUNCTIONS: */
|
||||
|
||||
static int32_t opc_fclose (void *f)
|
||||
static int32_t opc_fclose(void *f)
|
||||
{
|
||||
(void)f;
|
||||
return 0; /* we fclose() elsewhere. */
|
||||
}
|
||||
|
||||
static int32_t opc_fread (void *f, uint8_t *buf, int32_t size)
|
||||
static int32_t opc_fread(void *f, uint8_t *buf, int32_t size)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (size < 0)
|
||||
if(size < 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = (int32_t) FS_fread(buf, 1, (size_t)size, (fshandle_t *)f);
|
||||
if (ret == 0 && errno != 0)
|
||||
if(ret == 0 && errno != 0)
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t opc_fseek (void *f, opus_int64 off, int32_t whence)
|
||||
static int32_t opc_fseek(void *f, opus_int64 off, int32_t whence)
|
||||
{
|
||||
if (f == NULL) return (-1);
|
||||
if(f == NULL) return (-1);
|
||||
return FS_fseek((fshandle_t *)f, (long) off, whence);
|
||||
}
|
||||
|
||||
static opus_int64 opc_ftell (void *f)
|
||||
static opus_int64 opc_ftell(void *f)
|
||||
{
|
||||
return (opus_int64) FS_ftell((fshandle_t *)f);
|
||||
}
|
||||
|
@ -71,20 +71,20 @@ static const OpusFileCallbacks opc_qfs =
|
|||
{
|
||||
(int32_t (*)(void *, uint8_t *, int32_t)) opc_fread,
|
||||
(int32_t (*)(void *, opus_int64, int32_t)) opc_fseek,
|
||||
(opus_int64 (*)(void *)) opc_ftell,
|
||||
(opus_int64(*)(void *)) opc_ftell,
|
||||
(int32_t (*)(void *)) opc_fclose
|
||||
};
|
||||
|
||||
static bool S_OPUS_CodecInitialize (void)
|
||||
static bool S_OPUS_CodecInitialize(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void S_OPUS_CodecShutdown (void)
|
||||
static void S_OPUS_CodecShutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
static bool S_OPUS_CodecOpenStream (snd_stream_t *stream)
|
||||
static bool S_OPUS_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
OggOpusFile *opFile;
|
||||
const OpusHead *op_info;
|
||||
|
@ -92,7 +92,7 @@ static bool S_OPUS_CodecOpenStream (snd_stream_t *stream)
|
|||
int32_t res;
|
||||
|
||||
opFile = op_open_callbacks(&stream->fh, &opc_qfs, NULL, 0, &res);
|
||||
if (!opFile)
|
||||
if(!opFile)
|
||||
{
|
||||
Con_Printf("%s is not a valid Opus file (error %" PRIi32 ").\n",
|
||||
stream->name, res);
|
||||
|
@ -101,14 +101,14 @@ static bool S_OPUS_CodecOpenStream (snd_stream_t *stream)
|
|||
|
||||
stream->priv = opFile;
|
||||
|
||||
if (!op_seekable(opFile))
|
||||
if(!op_seekable(opFile))
|
||||
{
|
||||
Con_Printf("Opus stream %s not seekable.\n", stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
op_info = op_head(opFile, -1);
|
||||
if (!op_info)
|
||||
if(!op_info)
|
||||
{
|
||||
Con_Printf("Unable to get stream information for %s.\n", stream->name);
|
||||
goto _fail;
|
||||
|
@ -116,14 +116,14 @@ static bool S_OPUS_CodecOpenStream (snd_stream_t *stream)
|
|||
|
||||
/* FIXME: handle section changes */
|
||||
numstreams = op_info->stream_count;
|
||||
if (numstreams != 1)
|
||||
if(numstreams != 1)
|
||||
{
|
||||
Con_Printf("More than one (%" PRIi64 ") stream in %s\n",
|
||||
(long)op_info->stream_count, stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
if (op_info->channel_count != 1 && op_info->channel_count != 2)
|
||||
if(op_info->channel_count != 1 && op_info->channel_count != 2)
|
||||
{
|
||||
Con_Printf("Unsupported number of channels %" PRIi32 " in %s\n",
|
||||
op_info->channel_count, stream->name);
|
||||
|
@ -142,55 +142,55 @@ static bool S_OPUS_CodecOpenStream (snd_stream_t *stream)
|
|||
|
||||
return true;
|
||||
_fail:
|
||||
if (opFile)
|
||||
if(opFile)
|
||||
op_free(opFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t S_OPUS_CodecReadStream (snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
static int32_t S_OPUS_CodecReadStream(snd_stream_t *stream, int32_t bytes, void *buffer)
|
||||
{
|
||||
int32_t section; /* FIXME: handle section changes */
|
||||
int32_t cnt, res, rem;
|
||||
opus_int16 * ptr;
|
||||
|
||||
rem = bytes / stream->info.width;
|
||||
if (rem / stream->info.channels <= 0)
|
||||
if(rem / stream->info.channels <= 0)
|
||||
return 0;
|
||||
|
||||
cnt = 0;
|
||||
ptr = (opus_int16 *) buffer;
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
/* op_read() yields 16-bit output using native endian ordering. returns
|
||||
* the number of samples read per channel on success, or a negative value
|
||||
* on failure. */
|
||||
res = op_read((OggOpusFile *)stream->priv, ptr, rem, §ion);
|
||||
if (res <= 0)
|
||||
if(res <= 0)
|
||||
break;
|
||||
cnt += res;
|
||||
res *= stream->info.channels;
|
||||
rem -= res;
|
||||
if (rem <= 0)
|
||||
if(rem <= 0)
|
||||
break;
|
||||
ptr += res;
|
||||
}
|
||||
|
||||
if (res < 0)
|
||||
if(res < 0)
|
||||
return res;
|
||||
|
||||
cnt *= (stream->info.channels * stream->info.width);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static void S_OPUS_CodecCloseStream (snd_stream_t *stream)
|
||||
static void S_OPUS_CodecCloseStream(snd_stream_t *stream)
|
||||
{
|
||||
op_free((OggOpusFile *)stream->priv);
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int32_t S_OPUS_CodecRewindStream (snd_stream_t *stream)
|
||||
static int32_t S_OPUS_CodecRewindStream(snd_stream_t *stream)
|
||||
{
|
||||
return op_pcm_seek ((OggOpusFile *)stream->priv, 0);
|
||||
return op_pcm_seek((OggOpusFile *)stream->priv, 0);
|
||||
}
|
||||
|
||||
snd_codec_t opus_codec =
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue