astyle
parent
00a944ce24
commit
ef6a1262c5
1072
source/anorm_dots.h
1072
source/anorm_dots.h
File diff suppressed because it is too large
Load Diff
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 },
|
||||
|
|
|
@ -31,140 +31,140 @@
|
|||
#if defined(__DJGPP__) || defined(__MSDOS__) || defined(__DOS__) || defined(_MSDOS)
|
||||
|
||||
# if !defined(PLATFORM_DOS)
|
||||
# define PLATFORM_DOS 1
|
||||
# define PLATFORM_DOS 1
|
||||
# endif
|
||||
|
||||
#elif defined(__OS2__) || defined(__EMX__)
|
||||
|
||||
# if !defined(PLATFORM_OS2)
|
||||
# define PLATFORM_OS2 1
|
||||
# define PLATFORM_OS2 1
|
||||
# endif
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__NT__) || defined(_Windows)
|
||||
|
||||
# if !defined(PLATFORM_WINDOWS)
|
||||
# define PLATFORM_WINDOWS 1
|
||||
# define PLATFORM_WINDOWS 1
|
||||
# endif
|
||||
|
||||
#elif defined(__APPLE__) && defined(__MACH__) /* Mac OS X */
|
||||
#elif defined(__APPLE__) && defined(__MACH__) /* Mac OS X */
|
||||
|
||||
# if !defined(PLATFORM_OSX)
|
||||
# define PLATFORM_OSX 1
|
||||
# define PLATFORM_OSX 1
|
||||
# endif
|
||||
|
||||
#elif defined(macintosh) /* Mac OS classic */
|
||||
#elif defined(macintosh) /* Mac OS classic */
|
||||
|
||||
# if !defined(PLATFORM_MAC)
|
||||
# define PLATFORM_MAC 1
|
||||
# define PLATFORM_MAC 1
|
||||
# endif
|
||||
|
||||
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
|
||||
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
|
||||
defined(__amigaos__) || defined(__amigaos4__) ||defined(__amigados__) || \
|
||||
defined(AMIGA) || defined(_AMIGA) || defined(__AMIGA__)
|
||||
|
||||
# if !defined(PLATFORM_AMIGA)
|
||||
# define PLATFORM_AMIGA 1
|
||||
# define PLATFORM_AMIGA 1
|
||||
# endif
|
||||
|
||||
#elif defined(__riscos__)
|
||||
|
||||
# if !defined(PLATFORM_RISCOS)
|
||||
# define PLATFORM_RISCOS 1
|
||||
# define PLATFORM_RISCOS 1
|
||||
# endif
|
||||
|
||||
#else /* here goes the unix platforms */
|
||||
#else /* here goes the unix platforms */
|
||||
|
||||
#if defined(__unix) || defined(__unix__) || defined(unix) || \
|
||||
defined(__linux__) || defined(__linux) || \
|
||||
defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
|
||||
defined(__OpenBSD__) || defined(__NetBSD__) || \
|
||||
defined(__hpux) || defined(__hpux__) || defined(_hpux) || \
|
||||
defined(__sun) || defined(sun) || \
|
||||
defined(__sgi) || defined(sgi) || defined(__sgi__) || \
|
||||
defined(__GNU__) /* GNU/Hurd */ || \
|
||||
#if defined(__unix) || defined(__unix__) || defined(unix) || \
|
||||
defined(__linux__) || defined(__linux) || \
|
||||
defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
|
||||
defined(__OpenBSD__) || defined(__NetBSD__) || \
|
||||
defined(__hpux) || defined(__hpux__) || defined(_hpux) || \
|
||||
defined(__sun) || defined(sun) || \
|
||||
defined(__sgi) || defined(sgi) || defined(__sgi__) || \
|
||||
defined(__GNU__) /* GNU/Hurd */ || \
|
||||
defined(__QNX__) || defined(__QNXNTO__)
|
||||
# if !defined(PLATFORM_UNIX)
|
||||
# define PLATFORM_UNIX 1
|
||||
# define PLATFORM_UNIX 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PLATFORM_xxx */
|
||||
#endif /* PLATFORM_xxx */
|
||||
|
||||
|
||||
#if defined (PLATFORM_OSX) /* OS X is unix-based */
|
||||
#if defined (PLATFORM_OSX) /* OS X is unix-based */
|
||||
# if !defined(PLATFORM_UNIX)
|
||||
# define PLATFORM_UNIX 2
|
||||
# define PLATFORM_UNIX 2
|
||||
# endif
|
||||
#endif /* OS X -> PLATFORM_UNIX */
|
||||
#endif /* OS X -> PLATFORM_UNIX */
|
||||
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||
defined(__FreeBSD_kernel__) /* Debian GNU/kFreeBSD */ || \
|
||||
defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
# if !defined(PLATFORM_BSD)
|
||||
# define PLATFORM_BSD 1
|
||||
# define PLATFORM_BSD 1
|
||||
# endif
|
||||
#endif /* PLATFORM_BSD (for convenience) */
|
||||
#endif /* PLATFORM_BSD (for convenience) */
|
||||
|
||||
|
||||
#if defined(PLATFORM_AMIGA) && !defined(PLATFORM_AMIGAOS3)
|
||||
# if !defined(__MORPHOS__) && !defined(__AROS__) && !defined(__amigaos4__)
|
||||
# define PLATFORM_AMIGAOS3 1
|
||||
# define PLATFORM_AMIGAOS3 1
|
||||
# endif
|
||||
#endif /* PLATFORM_AMIGAOS3 (for convenience) */
|
||||
#endif /* PLATFORM_AMIGAOS3 (for convenience) */
|
||||
|
||||
|
||||
#if defined(_WIN64)
|
||||
# define PLATFORM_STRING "Win64"
|
||||
# define PLATFORM_STRING "Win64"
|
||||
#elif defined(PLATFORM_WINDOWS)
|
||||
# define PLATFORM_STRING "Windows"
|
||||
# define PLATFORM_STRING "Windows"
|
||||
#elif defined(PLATFORM_DOS)
|
||||
# define PLATFORM_STRING "DOS"
|
||||
# define PLATFORM_STRING "DOS"
|
||||
#elif defined(PLATFORM_OS2)
|
||||
# define PLATFORM_STRING "OS/2"
|
||||
# define PLATFORM_STRING "OS/2"
|
||||
#elif defined(__linux__) || defined(__linux)
|
||||
# define PLATFORM_STRING "Linux"
|
||||
# define PLATFORM_STRING "Linux"
|
||||
#elif defined(__DragonFly__)
|
||||
# define PLATFORM_STRING "DragonFly"
|
||||
# define PLATFORM_STRING "DragonFly"
|
||||
#elif defined(__FreeBSD__)
|
||||
# define PLATFORM_STRING "FreeBSD"
|
||||
# define PLATFORM_STRING "FreeBSD"
|
||||
#elif defined(__NetBSD__)
|
||||
# define PLATFORM_STRING "NetBSD"
|
||||
# define PLATFORM_STRING "NetBSD"
|
||||
#elif defined(__OpenBSD__)
|
||||
# define PLATFORM_STRING "OpenBSD"
|
||||
# define PLATFORM_STRING "OpenBSD"
|
||||
#elif defined(__MORPHOS__)
|
||||
# define PLATFORM_STRING "MorphOS"
|
||||
# define PLATFORM_STRING "MorphOS"
|
||||
#elif defined(__AROS__)
|
||||
# define PLATFORM_STRING "AROS"
|
||||
# define PLATFORM_STRING "AROS"
|
||||
#elif defined(__amigaos4__)
|
||||
# define PLATFORM_STRING "AmigaOS4"
|
||||
# define PLATFORM_STRING "AmigaOS4"
|
||||
#elif defined(PLATFORM_AMIGA)
|
||||
# define PLATFORM_STRING "AmigaOS"
|
||||
# define PLATFORM_STRING "AmigaOS"
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_STRING "QNX"
|
||||
# define PLATFORM_STRING "QNX"
|
||||
#elif defined(PLATFORM_OSX)
|
||||
# define PLATFORM_STRING "MacOSX"
|
||||
# define PLATFORM_STRING "MacOSX"
|
||||
#elif defined(PLATFORM_MAC)
|
||||
# define PLATFORM_STRING "MacOS"
|
||||
# define PLATFORM_STRING "MacOS"
|
||||
#elif defined(__hpux) || defined(__hpux__) || defined(_hpux)
|
||||
# define PLATFORM_STRING "HP-UX"
|
||||
# define PLATFORM_STRING "HP-UX"
|
||||
#elif (defined(__sun) || defined(sun)) && (defined(__svr4__) || defined(__SVR4))
|
||||
# define PLATFORM_STRING "Solaris"
|
||||
# define PLATFORM_STRING "Solaris"
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_STRING "SunOS"
|
||||
# define PLATFORM_STRING "SunOS"
|
||||
#elif defined(__sgi) || defined(sgi) || defined(__sgi__)
|
||||
# define PLATFORM_STRING "Irix"
|
||||
# define PLATFORM_STRING "Irix"
|
||||
#elif defined(PLATFORM_RISCOS)
|
||||
# define PLATFORM_STRING "RiscOS"
|
||||
# define PLATFORM_STRING "RiscOS"
|
||||
#elif defined(__GNU__)
|
||||
# define PLATFORM_STRING "GNU/Hurd"
|
||||
# define PLATFORM_STRING "GNU/Hurd"
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
# define PLATFORM_STRING "Unix"
|
||||
# define PLATFORM_STRING "Unix"
|
||||
#else
|
||||
# define PLATFORM_STRING "Unknown"
|
||||
# warning "Platform is UNKNOWN."
|
||||
#endif /* PLATFORM_STRING */
|
||||
# define PLATFORM_STRING "Unknown"
|
||||
# warning "Platform is UNKNOWN."
|
||||
#endif /* PLATFORM_STRING */
|
||||
|
||||
#endif /* ARCHDEFS_H */
|
||||
|
||||
|
|
256
source/bgmusic.c
256
source/bgmusic.c
|
@ -27,13 +27,13 @@
|
|||
#include "bgmusic.h"
|
||||
#include "cdaudio.h"
|
||||
|
||||
#define MUSIC_DIRNAME "music"
|
||||
#define MUSIC_DIRNAME "music"
|
||||
|
||||
bool bgmloop;
|
||||
cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE};
|
||||
bool bgmloop;
|
||||
cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE};
|
||||
|
||||
static bool no_extmusic= false;
|
||||
static float old_volume = -1.0f;
|
||||
static bool no_extmusic = false;
|
||||
static float old_volume = -1.0f;
|
||||
|
||||
typedef enum _bgm_player
|
||||
{
|
||||
|
@ -44,17 +44,17 @@ typedef enum _bgm_player
|
|||
|
||||
typedef struct music_handler_s
|
||||
{
|
||||
uint32_t type; /* 1U << n (see snd_codec.h) */
|
||||
bgm_player_t player; /* Enumerated bgm player type */
|
||||
int32_t is_available; /* -1 means not present */
|
||||
const char *ext; /* Expected file extension */
|
||||
const char *dir; /* Where to look for music file */
|
||||
struct music_handler_s *next;
|
||||
uint32_t type; /* 1U << n (see snd_codec.h) */
|
||||
bgm_player_t player; /* Enumerated bgm player type */
|
||||
int32_t is_available; /* -1 means not present */
|
||||
const char *ext; /* Expected file extension */
|
||||
const char *dir; /* Where to look for music file */
|
||||
struct music_handler_s *next;
|
||||
} music_handler_t;
|
||||
|
||||
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 },
|
||||
|
@ -69,61 +69,61 @@ static music_handler_t wanted_handlers[] =
|
|||
|
||||
static music_handler_t *music_handlers = NULL;
|
||||
|
||||
#define ANY_CODECTYPE 0xFFFFFFFF
|
||||
#define CDRIP_TYPES (CODECTYPE_VORBIS | CODECTYPE_MP3 | CODECTYPE_FLAC | CODECTYPE_WAV | CODECTYPE_OPUS)
|
||||
#define CDRIPTYPE(x) (((x) & CDRIP_TYPES) != 0)
|
||||
#define ANY_CODECTYPE 0xFFFFFFFF
|
||||
#define CDRIP_TYPES (CODECTYPE_VORBIS | CODECTYPE_MP3 | CODECTYPE_FLAC | CODECTYPE_WAV | CODECTYPE_OPUS)
|
||||
#define CDRIPTYPE(x) (((x) & CDRIP_TYPES) != 0)
|
||||
|
||||
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,29 +135,29 @@ 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 */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
wanted_handlers[i].is_available =
|
||||
S_CodecIsAvailable(wanted_handlers[i].type);
|
||||
S_CodecIsAvailable(wanted_handlers[i].type);
|
||||
break;
|
||||
case BGM_NONE:
|
||||
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,47 +170,47 @@ bool BGM_Init (void)
|
|||
}
|
||||
}
|
||||
|
||||
return CDAudio_Init ();
|
||||
return CDAudio_Init();
|
||||
}
|
||||
|
||||
void BGM_Shutdown (void)
|
||||
void BGM_Shutdown(void)
|
||||
{
|
||||
BGM_Stop();
|
||||
/* sever our connections to
|
||||
* midi_drv and snd_codec */
|
||||
/* 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)
|
||||
handler->dir, filename, handler->ext);
|
||||
switch(handler->player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
if (bgmstream)
|
||||
return; /* success */
|
||||
if(bgmstream)
|
||||
return; /* success */
|
||||
break;
|
||||
case BGM_NONE:
|
||||
default:
|
||||
|
@ -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,45 +230,45 @@ 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 &&
|
||||
!q_strcasecmp(ext, handler->ext))
|
||||
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 */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
if (bgmstream)
|
||||
return; /* success */
|
||||
if(bgmstream)
|
||||
return; /* success */
|
||||
break;
|
||||
case BGM_NONE:
|
||||
default:
|
||||
|
@ -278,68 +278,68 @@ 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
|
||||
* 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
|
||||
* is below *.ogg in the music_handler order, the mp3 will still
|
||||
* have priority over track02.ogg from, say, id1.
|
||||
*/
|
||||
/* 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
|
||||
* is below *.ogg in the music_handler order, the mp3 will still
|
||||
* have priority over track02.ogg from, say, id1.
|
||||
*/
|
||||
char tmp[MAX_QPATH];
|
||||
const char *ext;
|
||||
uint32_t path_id, prev_id, type;
|
||||
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))
|
||||
MUSIC_DIRNAME, (int32_t)track, handler->ext);
|
||||
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);
|
||||
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,85 +349,85 @@ 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. */
|
||||
int32_t bufferSamples;
|
||||
int32_t fileSamples;
|
||||
int32_t fileBytes;
|
||||
byte raw[16384];
|
||||
int32_t res; /* Number of bytes read. */
|
||||
int32_t bufferSamples;
|
||||
int32_t fileSamples;
|
||||
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 /
|
||||
(bgmstream->info.width * bgmstream->info.channels);
|
||||
(bgmstream->info.width * bgmstream->info.channels);
|
||||
}
|
||||
|
||||
/* 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,
|
||||
bgmstream->info.channels,
|
||||
raw, bgmvolume.value);
|
||||
bgmstream->info.width,
|
||||
bgmstream->info.channels,
|
||||
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();
|
||||
|
@ -449,7 +449,7 @@ static void BGM_UpdateStream (void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else /* res < 0: some read error */
|
||||
else /* res < 0: some read error */
|
||||
{
|
||||
Con_Printf("Stream read 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();
|
||||
}
|
||||
|
|
|
@ -25,19 +25,19 @@
|
|||
#ifndef _BGMUSIC_H_
|
||||
#define _BGMUSIC_H_
|
||||
|
||||
extern bool bgmloop;
|
||||
extern cvar_t bgm_extmusic;
|
||||
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_ */
|
||||
#endif /* _BGMUSIC_H_ */
|
||||
|
||||
|
|
298
source/bspfile.h
298
source/bspfile.h
|
@ -25,39 +25,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// upper design bounds
|
||||
|
||||
#define MAX_MAP_HULLS 4
|
||||
#define MAX_MAP_HULLS 4
|
||||
|
||||
#define MAX_MAP_MODELS 256
|
||||
#define MAX_MAP_BRUSHES 4096
|
||||
#define MAX_MAP_ENTITIES 1024
|
||||
#define MAX_MAP_ENTSTRING 65536
|
||||
#define MAX_MAP_MODELS 256
|
||||
#define MAX_MAP_BRUSHES 4096
|
||||
#define MAX_MAP_ENTITIES 1024
|
||||
#define MAX_MAP_ENTSTRING 65536
|
||||
|
||||
#define MAX_MAP_PLANES 32767
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are contents
|
||||
#define MAX_MAP_CLIPNODES 32767
|
||||
//#define MAX_MAP_LEAFS 80000 //johnfitz -- was 8192
|
||||
#define MAX_MAP_VERTS 65535
|
||||
#define MAX_MAP_FACES 65535
|
||||
#define MAX_MAP_MARKSURFACES 65535
|
||||
#define MAX_MAP_TEXINFO 4096
|
||||
#define MAX_MAP_EDGES 256000
|
||||
#define MAX_MAP_SURFEDGES 512000
|
||||
#define MAX_MAP_TEXTURES 512
|
||||
#define MAX_MAP_MIPTEX 0x200000
|
||||
#define MAX_MAP_LIGHTING 0x100000
|
||||
#define MAX_MAP_VISIBILITY 0x100000
|
||||
#define MAX_MAP_PLANES 32767
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are contents
|
||||
#define MAX_MAP_CLIPNODES 32767
|
||||
//#define MAX_MAP_LEAFS 80000 //johnfitz -- was 8192
|
||||
#define MAX_MAP_VERTS 65535
|
||||
#define MAX_MAP_FACES 65535
|
||||
#define MAX_MAP_MARKSURFACES 65535
|
||||
#define MAX_MAP_TEXINFO 4096
|
||||
#define MAX_MAP_EDGES 256000
|
||||
#define MAX_MAP_SURFEDGES 512000
|
||||
#define MAX_MAP_TEXTURES 512
|
||||
#define MAX_MAP_MIPTEX 0x200000
|
||||
#define MAX_MAP_LIGHTING 0x100000
|
||||
#define MAX_MAP_VISIBILITY 0x100000
|
||||
|
||||
#define MAX_MAP_PORTALS 65536
|
||||
#define MAX_MAP_PORTALS 65536
|
||||
|
||||
// key / value pair sizes
|
||||
|
||||
#define MAX_KEY 32
|
||||
#define MAX_VALUE 1024
|
||||
#define MAX_KEY 32
|
||||
#define MAX_VALUE 1024
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#define BSPVERSION 29
|
||||
#define BSPVERSION 29
|
||||
|
||||
/* RMQ support (2PSB). 32bits instead of shorts for all but bbox sizes (which
|
||||
* still use shorts) */
|
||||
|
@ -66,249 +66,249 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
/* BSP2 support. 32bits instead of shorts for everything (bboxes use floats) */
|
||||
#define BSP2VERSION_BSP2 (('B' << 0) | ('S' << 8) | ('P' << 16) | ('2'<<24))
|
||||
|
||||
#define TOOLVERSION 2
|
||||
#define TOOLVERSION 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t fileofs, filelen;
|
||||
int32_t fileofs, filelen;
|
||||
} lump_t;
|
||||
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14
|
||||
|
||||
#define HEADER_LUMPS 15
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float mins[3], maxs[3];
|
||||
float origin[3];
|
||||
int32_t headnode[MAX_MAP_HULLS];
|
||||
int32_t visleafs; // not including the solid leaf 0
|
||||
int32_t firstface, numfaces;
|
||||
float mins[3], maxs[3];
|
||||
float origin[3];
|
||||
int32_t headnode[MAX_MAP_HULLS];
|
||||
int32_t visleafs; // not including the solid leaf 0
|
||||
int32_t firstface, numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t version;
|
||||
lump_t lumps[HEADER_LUMPS];
|
||||
int32_t version;
|
||||
lump_t lumps[HEADER_LUMPS];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t nummiptex;
|
||||
int32_t dataofs[4]; // [nummiptex]
|
||||
int32_t nummiptex;
|
||||
int32_t dataofs[4]; // [nummiptex]
|
||||
} dmiptexlump_t;
|
||||
|
||||
#define MIPLEVELS 4
|
||||
#define MIPLEVELS 4
|
||||
typedef struct miptex_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
} miptex_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float point[3];
|
||||
float point[3];
|
||||
} dvertex_t;
|
||||
|
||||
|
||||
// 0-2 are axial planes
|
||||
#define PLANE_X 0
|
||||
#define PLANE_Y 1
|
||||
#define PLANE_Z 2
|
||||
#define PLANE_X 0
|
||||
#define PLANE_Y 1
|
||||
#define PLANE_Z 2
|
||||
|
||||
// 3-5 are non-axial planes snapped to the nearest
|
||||
#define PLANE_ANYX 3
|
||||
#define PLANE_ANYY 4
|
||||
#define PLANE_ANYZ 5
|
||||
#define PLANE_ANYX 3
|
||||
#define PLANE_ANYY 4
|
||||
#define PLANE_ANYZ 5
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float normal[3];
|
||||
float dist;
|
||||
int32_t type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||
float normal[3];
|
||||
float dist;
|
||||
int32_t type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||
} dplane_t;
|
||||
|
||||
|
||||
#define CONTENTS_EMPTY -1
|
||||
#define CONTENTS_SOLID -2
|
||||
#define CONTENTS_WATER -3
|
||||
#define CONTENTS_SLIME -4
|
||||
#define CONTENTS_LAVA -5
|
||||
#define CONTENTS_SKY -6
|
||||
#define CONTENTS_ORIGIN -7 // removed at csg time
|
||||
#define CONTENTS_CLIP -8 // changed to contents_solid
|
||||
#define CONTENTS_EMPTY -1
|
||||
#define CONTENTS_SOLID -2
|
||||
#define CONTENTS_WATER -3
|
||||
#define CONTENTS_SLIME -4
|
||||
#define CONTENTS_LAVA -5
|
||||
#define CONTENTS_SKY -6
|
||||
#define CONTENTS_ORIGIN -7 // removed at csg time
|
||||
#define CONTENTS_CLIP -8 // changed to contents_solid
|
||||
|
||||
#define CONTENTS_CURRENT_0 -9
|
||||
#define CONTENTS_CURRENT_90 -10
|
||||
#define CONTENTS_CURRENT_180 -11
|
||||
#define CONTENTS_CURRENT_270 -12
|
||||
#define CONTENTS_CURRENT_UP -13
|
||||
#define CONTENTS_CURRENT_DOWN -14
|
||||
#define CONTENTS_CURRENT_0 -9
|
||||
#define CONTENTS_CURRENT_90 -10
|
||||
#define CONTENTS_CURRENT_180 -11
|
||||
#define CONTENTS_CURRENT_270 -12
|
||||
#define CONTENTS_CURRENT_UP -13
|
||||
#define CONTENTS_CURRENT_DOWN -14
|
||||
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
int16_t mins[3]; // for sphere culling
|
||||
int16_t maxs[3];
|
||||
uint16_t firstface;
|
||||
uint16_t numfaces; // counting both sides
|
||||
int32_t planenum;
|
||||
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
int16_t mins[3]; // for sphere culling
|
||||
int16_t maxs[3];
|
||||
uint16_t firstface;
|
||||
uint16_t numfaces; // counting both sides
|
||||
} dsnode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
int16_t mins[3]; // for sphere culling
|
||||
int16_t maxs[3];
|
||||
uint32_t firstface;
|
||||
uint32_t numfaces; // counting both sides
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
int16_t mins[3]; // for sphere culling
|
||||
int16_t maxs[3];
|
||||
uint32_t firstface;
|
||||
uint32_t numfaces; // counting both sides
|
||||
} dl1node_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
float mins[3]; // for sphere culling
|
||||
float maxs[3];
|
||||
uint32_t firstface;
|
||||
uint32_t numfaces; // counting both sides
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are -(leafs+1), not nodes
|
||||
float mins[3]; // for sphere culling
|
||||
float maxs[3];
|
||||
uint32_t firstface;
|
||||
uint32_t numfaces; // counting both sides
|
||||
} dl2node_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int16_t children[2]; // negative numbers are contents
|
||||
int32_t planenum;
|
||||
int16_t children[2]; // negative numbers are contents
|
||||
} dsclipnode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are contents
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are contents
|
||||
} dlclipnode_t;
|
||||
|
||||
|
||||
typedef struct texinfo_s
|
||||
{
|
||||
float vecs[2][4]; // [s/t][xyz offset]
|
||||
int32_t miptex;
|
||||
int32_t flags;
|
||||
float vecs[2][4]; // [s/t][xyz offset]
|
||||
int32_t miptex;
|
||||
int32_t flags;
|
||||
} texinfo_t;
|
||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||
#define TEX_MISSING 2 // johnfitz -- this texinfo does not have a texture
|
||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||
#define TEX_MISSING 2 // johnfitz -- this texinfo does not have a texture
|
||||
|
||||
// note that edge 0 is never used, because negative edge nums are used for
|
||||
// counterclockwise use of the edge in a face
|
||||
typedef struct
|
||||
{
|
||||
uint16_t v[2]; // vertex numbers
|
||||
uint16_t v[2]; // vertex numbers
|
||||
} dsedge_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t v[2]; // vertex numbers
|
||||
uint32_t v[2]; // vertex numbers
|
||||
} dledge_t;
|
||||
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define MAXLIGHTMAPS 4
|
||||
typedef struct
|
||||
{
|
||||
int16_t planenum;
|
||||
int16_t side;
|
||||
int16_t planenum;
|
||||
int16_t side;
|
||||
|
||||
int32_t firstedge; // we must support > 64k edges
|
||||
int16_t numedges;
|
||||
int16_t texinfo;
|
||||
int32_t firstedge; // we must support > 64k edges
|
||||
int16_t numedges;
|
||||
int16_t texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t lightofs; // start of [numstyles*surfsize] samples
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t lightofs; // start of [numstyles*surfsize] samples
|
||||
} dsface_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t planenum;
|
||||
int32_t side;
|
||||
int32_t planenum;
|
||||
int32_t side;
|
||||
|
||||
int32_t firstedge; // we must support > 64k edges
|
||||
int32_t numedges;
|
||||
int32_t texinfo;
|
||||
int32_t firstedge; // we must support > 64k edges
|
||||
int32_t numedges;
|
||||
int32_t texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t lightofs; // start of [numstyles*surfsize] samples
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t lightofs; // start of [numstyles*surfsize] samples
|
||||
} dlface_t;
|
||||
|
||||
#define AMBIENT_WATER 0
|
||||
#define AMBIENT_SKY 1
|
||||
#define AMBIENT_SLIME 2
|
||||
#define AMBIENT_LAVA 3
|
||||
#define AMBIENT_WATER 0
|
||||
#define AMBIENT_SKY 1
|
||||
#define AMBIENT_SLIME 2
|
||||
#define AMBIENT_LAVA 3
|
||||
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
|
||||
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
|
||||
// all other leafs need visibility info
|
||||
typedef struct
|
||||
{
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
|
||||
int16_t mins[3]; // for frustum culling
|
||||
int16_t maxs[3];
|
||||
int16_t mins[3]; // for frustum culling
|
||||
int16_t maxs[3];
|
||||
|
||||
uint16_t firstmarksurface;
|
||||
uint16_t nummarksurfaces;
|
||||
uint16_t firstmarksurface;
|
||||
uint16_t nummarksurfaces;
|
||||
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
} dsleaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
|
||||
int16_t mins[3]; // for frustum culling
|
||||
int16_t maxs[3];
|
||||
int16_t mins[3]; // for frustum culling
|
||||
int16_t maxs[3];
|
||||
|
||||
uint32_t firstmarksurface;
|
||||
uint32_t nummarksurfaces;
|
||||
uint32_t firstmarksurface;
|
||||
uint32_t nummarksurfaces;
|
||||
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
} dl1leaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
int32_t contents;
|
||||
int32_t visofs; // -1 = no visibility info
|
||||
|
||||
float mins[3]; // for frustum culling
|
||||
float maxs[3];
|
||||
float mins[3]; // for frustum culling
|
||||
float maxs[3];
|
||||
|
||||
uint32_t firstmarksurface;
|
||||
uint32_t nummarksurfaces;
|
||||
uint32_t firstmarksurface;
|
||||
uint32_t nummarksurfaces;
|
||||
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
byte ambient_level[NUM_AMBIENTS];
|
||||
} dl2leaf_t;
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
||||
#endif /* __BSPFILE_H */
|
||||
#endif /* __BSPFILE_H */
|
||||
|
||||
|
|
330
source/cd_sdl.c
330
source/cd_sdl.c
|
@ -35,39 +35,39 @@
|
|||
#include "cdaudio.h"
|
||||
|
||||
static bool cdValid = false;
|
||||
static bool playing = false;
|
||||
static bool wasPlaying = false;
|
||||
static bool enabled = true;
|
||||
static bool playing = false;
|
||||
static bool wasPlaying = false;
|
||||
static bool enabled = true;
|
||||
static bool playLooping = false;
|
||||
static byte remap[100];
|
||||
static byte playTrack;
|
||||
static double endOfTrack = -1.0, pausetime = -1.0;
|
||||
static SDL_CD *cd_handle;
|
||||
static int32_t cd_dev = -1;
|
||||
static float old_cdvolume;
|
||||
static bool hw_vol_works = true;
|
||||
static byte remap[100];
|
||||
static byte playTrack;
|
||||
static double endOfTrack = -1.0, pausetime = -1.0;
|
||||
static SDL_CD *cd_handle;
|
||||
static int32_t cd_dev = -1;
|
||||
static float old_cdvolume;
|
||||
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() */
|
||||
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;
|
||||
|
@ -77,42 +77,42 @@ static int32_t CDAudio_GetAudioDiskInfo(void)
|
|||
|
||||
int32_t CDAudio_Play(byte track, bool looping)
|
||||
{
|
||||
int32_t len_m, len_s, len_f;
|
||||
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;
|
||||
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,232 +221,232 @@ 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;
|
||||
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",
|
||||
current_min, current_sec, current_frame * 60 / CD_FPS,
|
||||
length_min, length_sec, length_frame * 60 / CD_FPS);
|
||||
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);
|
||||
}
|
||||
Con_Printf("Volume is %f\n", bgmvolume.value);
|
||||
|
||||
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
|
||||
supports cdrom volume control some day. */
|
||||
/* 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
|
||||
supports cdrom volume control some day. */
|
||||
/* 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
|
||||
supports cdrom volume control some day. */
|
||||
return CD_SetVolume (NULL);
|
||||
/* FIXME: write proper code in here when SDL
|
||||
supports cdrom volume control some day. */
|
||||
return CD_SetVolume(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CDAudio_Update(void)
|
||||
{
|
||||
CDstatus curstat;
|
||||
/* static double lastchk;*/
|
||||
CDstatus curstat;
|
||||
/* 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 */
|
||||
/* 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,
|
||||
* but tolerate args like "D" or "D:", as well. */
|
||||
/* 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] != '\\' &&
|
||||
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,9 +454,9 @@ 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 */
|
||||
/* make it uppercase for SDL */
|
||||
drive[0] = *arg - ('a' - 'A');
|
||||
drive[1] = ':';
|
||||
drive[2] = '\\';
|
||||
|
@ -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.
|
||||
* not needed for windows due to the way SDL_cdrom works. */
|
||||
/* 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
|
||||
|
@ -488,91 +488,91 @@ static void export_cddev_arg (void)
|
|||
|
||||
int32_t CDAudio_Init(void)
|
||||
{
|
||||
int32_t i, sdl_num_drives;
|
||||
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 == 1 ? ' ' : 's');
|
||||
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)
|
||||
cd_dev = 0; /* default drive */
|
||||
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",
|
||||
SDL_CDName(cd_dev), SDL_GetError());
|
||||
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() */
|
||||
SDL_CDStop(cd_handle); /* see CDAudio_Stop() */
|
||||
#endif
|
||||
SDL_CDClose(cd_handle);
|
||||
cd_handle = NULL;
|
||||
|
|
|
@ -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 */
|
||||
#endif /* __CDAUDIO_H */
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "quakedef.h"
|
||||
|
||||
|
||||
static fshandle_t *cfg_file;
|
||||
static fshandle_t *cfg_file;
|
||||
|
||||
/*
|
||||
===================
|
||||
|
@ -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;
|
||||
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;
|
||||
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;
|
||||
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,21 +22,21 @@
|
|||
#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
|
||||
// locking your cvars.
|
||||
|
||||
#endif /* __CFGFILE_H */
|
||||
#endif /* __CFGFILE_H */
|
||||
|
|
|
@ -23,22 +23,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
cvar_t chase_back = {"chase_back", "100", CVAR_NONE};
|
||||
cvar_t chase_up = {"chase_up", "16", CVAR_NONE};
|
||||
cvar_t chase_right = {"chase_right", "0", CVAR_NONE};
|
||||
cvar_t chase_active = {"chase_active", "0", CVAR_NONE};
|
||||
cvar_t chase_back = {"chase_back", "100", CVAR_NONE};
|
||||
cvar_t chase_up = {"chase_up", "16", CVAR_NONE};
|
||||
cvar_t chase_right = {"chase_right", "0", CVAR_NONE};
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
//+ up[i]*chase_up.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];
|
||||
}
|
||||
|
||||
|
|
325
source/cl_demo.c
325
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);
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
@ -37,8 +37,8 @@ read from the demo file.
|
|||
*/
|
||||
|
||||
// from ProQuake: space to fill out the demo header for record at any time
|
||||
static byte demo_head[3][MAX_MSGLEN];
|
||||
static int32_t demo_head_size[2];
|
||||
static byte demo_head[3][MAX_MSGLEN];
|
||||
static int32_t demo_head_size[2];
|
||||
|
||||
/*
|
||||
==============
|
||||
|
@ -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;
|
||||
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;
|
||||
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)
|
||||
return 0; // already read this frame's message
|
||||
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 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)
|
||||
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
|
||||
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,34 +142,34 @@ 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;
|
||||
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");
|
||||
// discard nop keepalive message
|
||||
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
|
||||
// record messages before full connection, so that a
|
||||
// demo record can happen after connection is done
|
||||
memcpy(demo_head[cls.signon], net_message.data, net_message.cursize);
|
||||
demo_head_size[cls.signon] = net_message.cursize;
|
||||
}
|
||||
|
@ -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;
|
||||
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,35 +379,35 @@ CL_PlayDemo_f
|
|||
play [demoname]
|
||||
====================
|
||||
*/
|
||||
void CL_PlayDemo_f (void)
|
||||
void CL_PlayDemo_f(void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
int32_t i, c;
|
||||
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);
|
||||
cls.demonum = -1; // stop demo loop
|
||||
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);
|
||||
cls.demonum = -1; // stop demo loop
|
||||
Con_Printf("ERROR: demo \"%s\" is invalid\n", name);
|
||||
return;
|
||||
}
|
||||
if (neg)
|
||||
if(neg)
|
||||
cls.forcetrack = -cls.forcetrack;
|
||||
|
||||
cls.demoplayback = true;
|
||||
|
@ -457,19 +458,19 @@ CL_FinishTimeDemo
|
|||
|
||||
====================
|
||||
*/
|
||||
static void CL_FinishTimeDemo (void)
|
||||
static void CL_FinishTimeDemo(void)
|
||||
{
|
||||
int32_t frames;
|
||||
float time;
|
||||
int32_t frames;
|
||||
float time;
|
||||
|
||||
cls.timedemo = false;
|
||||
|
||||
// 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
|
||||
|
@ -499,6 +500,6 @@ void CL_TimeDemo_f (void)
|
|||
|
||||
cls.timedemo = true;
|
||||
cls.td_startframe = host_framecount;
|
||||
cls.td_lastframe = -1; // get a new message this frame
|
||||
cls.td_lastframe = -1; // get a new message this frame
|
||||
}
|
||||
|
||||
|
|
|
@ -51,117 +51,221 @@ state bit 2 is edge triggered on the down to up transition
|
|||
*/
|
||||
|
||||
|
||||
kbutton_t in_mlook, in_klook;
|
||||
kbutton_t in_left, in_right, in_forward, in_back;
|
||||
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
||||
kbutton_t in_strafe, in_speed, in_use, in_jump, in_attack;
|
||||
kbutton_t in_up, in_down;
|
||||
kbutton_t in_mlook, in_klook;
|
||||
kbutton_t in_left, in_right, in_forward, in_back;
|
||||
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
||||
kbutton_t in_strafe, in_speed, in_use, in_jump, in_attack;
|
||||
kbutton_t in_up, in_down;
|
||||
|
||||
int32_t in_impulse;
|
||||
int32_t in_impulse;
|
||||
|
||||
|
||||
void KeyDown (kbutton_t *b)
|
||||
void KeyDown(kbutton_t *b)
|
||||
{
|
||||
int32_t k;
|
||||
const char *c;
|
||||
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
|
||||
k = -1; // typed manually at the console for continuous down
|
||||
|
||||
if (k == b->down[0] || k == b->down[1])
|
||||
return; // repeating key
|
||||
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)
|
||||
return; // still down
|
||||
b->state |= 1 + 2; // down + impulse down
|
||||
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;
|
||||
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
|
||||
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])
|
||||
return; // some other key is still holding it down
|
||||
return; // key up without coresponding down (menu pass through)
|
||||
if(b->down[0] || b->down[1])
|
||||
return; // some other key is still holding it down
|
||||
|
||||
if (!(b->state & 1))
|
||||
return; // still up (this should not happen)
|
||||
b->state &= ~1; // now up
|
||||
b->state |= 4; // impulse up
|
||||
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,46 +277,46 @@ 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;
|
||||
float val;
|
||||
bool impulsedown, impulseup, down;
|
||||
|
||||
impulsedown = key->state & 2;
|
||||
impulseup = key->state & 4;
|
||||
down = key->state & 1;
|
||||
val = 0;
|
||||
|
||||
if (impulsedown && !impulseup)
|
||||
if(impulsedown && !impulseup)
|
||||
{
|
||||
if (down)
|
||||
val = 0.5; // pressed and held this frame
|
||||
if(down)
|
||||
val = 0.5; // pressed and held this frame
|
||||
else
|
||||
val = 0; // I_Error ();
|
||||
val = 0; // I_Error ();
|
||||
}
|
||||
if (impulseup && !impulsedown)
|
||||
if(impulseup && !impulsedown)
|
||||
{
|
||||
if (down)
|
||||
val = 0; // I_Error ();
|
||||
if(down)
|
||||
val = 0; // I_Error ();
|
||||
else
|
||||
val = 0; // released this frame
|
||||
val = 0; // released this frame
|
||||
}
|
||||
if (!impulsedown && !impulseup)
|
||||
if(!impulsedown && !impulseup)
|
||||
{
|
||||
if (down)
|
||||
val = 1.0; // held the entire frame
|
||||
if(down)
|
||||
val = 1.0; // held the entire frame
|
||||
else
|
||||
val = 0; // up the entire frame
|
||||
val = 0; // up the entire frame
|
||||
}
|
||||
if (impulsedown && impulseup)
|
||||
if(impulsedown && impulseup)
|
||||
{
|
||||
if (down)
|
||||
val = 0.75; // released and re-pressed this frame
|
||||
if(down)
|
||||
val = 0.75; // released and re-pressed this frame
|
||||
else
|
||||
val = 0.25; // pressed and released this frame
|
||||
val = 0.25; // pressed and released this frame
|
||||
}
|
||||
|
||||
key->state &= 1; // clear impulses
|
||||
key->state &= 1; // clear impulses
|
||||
|
||||
return val;
|
||||
}
|
||||
|
@ -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;
|
||||
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,12 +441,12 @@ 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;
|
||||
sizebuf_t buf;
|
||||
byte data[128];
|
||||
int32_t i;
|
||||
int32_t bits;
|
||||
sizebuf_t buf;
|
||||
byte data[128];
|
||||
|
||||
buf.maxsize = 128;
|
||||
buf.cursize = 0;
|
||||
|
@ -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);
|
||||
//johnfitz
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
640
source/cl_main.c
640
source/cl_main.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
334
source/cl_tent.c
334
source/cl_tent.c
|
@ -23,32 +23,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
int32_t num_temp_entities;
|
||||
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
beam_t cl_beams[MAX_BEAMS];
|
||||
int32_t num_temp_entities;
|
||||
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
beam_t cl_beams[MAX_BEAMS];
|
||||
|
||||
sfx_t *cl_sfx_wizhit;
|
||||
sfx_t *cl_sfx_knighthit;
|
||||
sfx_t *cl_sfx_tink1;
|
||||
sfx_t *cl_sfx_ric1;
|
||||
sfx_t *cl_sfx_ric2;
|
||||
sfx_t *cl_sfx_ric3;
|
||||
sfx_t *cl_sfx_r_exp3;
|
||||
sfx_t *cl_sfx_wizhit;
|
||||
sfx_t *cl_sfx_knighthit;
|
||||
sfx_t *cl_sfx_tink1;
|
||||
sfx_t *cl_sfx_ric1;
|
||||
sfx_t *cl_sfx_ric2;
|
||||
sfx_t *cl_sfx_ric3;
|
||||
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;
|
||||
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,149 +113,149 @@ void CL_ParseBeam (qmodel_t *m)
|
|||
CL_ParseTEnt
|
||||
=================
|
||||
*/
|
||||
void CL_ParseTEnt (void)
|
||||
void CL_ParseTEnt(void)
|
||||
{
|
||||
int32_t type;
|
||||
vec3_t pos;
|
||||
dlight_t *dl;
|
||||
int32_t rnd;
|
||||
int32_t colorStart, colorLength;
|
||||
int32_t type;
|
||||
vec3_t pos;
|
||||
dlight_t *dl;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
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));
|
||||
case TE_LIGHTNING1: // lightning bolts
|
||||
CL_ParseBeam(Mod_ForName("progs/bolt.mdl", true));
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING2: // lightning bolts
|
||||
CL_ParseBeam (Mod_ForName("progs/bolt2.mdl", true));
|
||||
case TE_LIGHTNING2: // lightning bolts
|
||||
CL_ParseBeam(Mod_ForName("progs/bolt2.mdl", true));
|
||||
break;
|
||||
|
||||
case TE_LIGHTNING3: // lightning bolts
|
||||
CL_ParseBeam (Mod_ForName("progs/bolt3.mdl", true));
|
||||
case TE_LIGHTNING3: // lightning bolts
|
||||
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));
|
||||
case TE_BEAM: // grappling hook beam
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
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,72 +289,72 @@ 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;
|
||||
vec3_t dist, org;
|
||||
float d;
|
||||
entity_t *ent;
|
||||
float yaw, pitch;
|
||||
float forward;
|
||||
int32_t i, j; //johnfitz -- use j instead of using i twice, so we don't corrupt memory
|
||||
beam_t *b;
|
||||
vec3_t dist, org;
|
||||
float d;
|
||||
entity_t *ent;
|
||||
float yaw, pitch;
|
||||
float forward;
|
||||
|
||||
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 coming from the player, update the start position
|
||||
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);
|
||||
// calculate pitch and yaw
|
||||
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);
|
||||
// add new entities for the lightning
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
383
source/client.h
383
source/client.h
|
@ -27,72 +27,73 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int32_t length;
|
||||
char map[MAX_STYLESTRING];
|
||||
char average; //johnfitz
|
||||
char peak; //johnfitz
|
||||
int32_t length;
|
||||
char map[MAX_STYLESTRING];
|
||||
char average; //johnfitz
|
||||
char peak; //johnfitz
|
||||
} lightstyle_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[MAX_SCOREBOARDNAME];
|
||||
float entertime;
|
||||
int32_t frags;
|
||||
int32_t colors; // two 4 bit fields
|
||||
byte translations[VID_GRADES*256];
|
||||
char name[MAX_SCOREBOARDNAME];
|
||||
float entertime;
|
||||
int32_t frags;
|
||||
int32_t colors; // two 4 bit fields
|
||||
byte translations[VID_GRADES * 256];
|
||||
} scoreboard_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t destcolor[3];
|
||||
int32_t percent; // 0-256
|
||||
int32_t destcolor[3];
|
||||
int32_t percent; // 0-256
|
||||
} cshift_t;
|
||||
|
||||
#define CSHIFT_CONTENTS 0
|
||||
#define CSHIFT_DAMAGE 1
|
||||
#define CSHIFT_BONUS 2
|
||||
#define CSHIFT_POWERUP 3
|
||||
#define NUM_CSHIFTS 4
|
||||
#define CSHIFT_CONTENTS 0
|
||||
#define CSHIFT_DAMAGE 1
|
||||
#define CSHIFT_BONUS 2
|
||||
#define CSHIFT_POWERUP 3
|
||||
#define NUM_CSHIFTS 4
|
||||
|
||||
#define NAME_LENGTH 64
|
||||
#define NAME_LENGTH 64
|
||||
|
||||
|
||||
//
|
||||
// client_state_t should hold all pieces of the client state
|
||||
//
|
||||
|
||||
#define SIGNONS 4 // signon messages to receive before connected
|
||||
#define SIGNONS 4 // signon messages to receive before connected
|
||||
|
||||
#define MAX_DLIGHTS 64 //johnfitz -- was 32
|
||||
#define MAX_DLIGHTS 64 //johnfitz -- was 32
|
||||
typedef struct
|
||||
{
|
||||
vec3_t origin;
|
||||
float radius;
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
float minlight; // don't add when contributing less
|
||||
int32_t key;
|
||||
vec3_t color; //johnfitz -- lit support via lordhavoc
|
||||
vec3_t origin;
|
||||
float radius;
|
||||
float die; // stop lighting after this time
|
||||
float decay; // drop this each second
|
||||
float minlight; // don't add when contributing less
|
||||
int32_t key;
|
||||
vec3_t color; //johnfitz -- lit support via lordhavoc
|
||||
} dlight_t;
|
||||
|
||||
|
||||
#define MAX_BEAMS 32 //johnfitz -- was 24
|
||||
#define MAX_BEAMS 32 //johnfitz -- was 24
|
||||
typedef struct
|
||||
{
|
||||
int32_t entity;
|
||||
struct qmodel_s *model;
|
||||
float endtime;
|
||||
vec3_t start, end;
|
||||
int32_t entity;
|
||||
struct qmodel_s *model;
|
||||
float endtime;
|
||||
vec3_t start, end;
|
||||
} beam_t;
|
||||
|
||||
#define MAX_MAPSTRING 2048
|
||||
#define MAX_DEMOS 8
|
||||
#define MAX_DEMONAME 16
|
||||
#define MAX_MAPSTRING 2048
|
||||
#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;
|
||||
|
||||
//
|
||||
|
@ -101,39 +102,39 @@ ca_connected // valid netcon, talking to a server
|
|||
//
|
||||
typedef struct
|
||||
{
|
||||
cactive_t state;
|
||||
cactive_t state;
|
||||
|
||||
// personalization data sent to server
|
||||
char spawnparms[MAX_MAPSTRING]; // to restart a level
|
||||
char spawnparms[MAX_MAPSTRING]; // to restart a level
|
||||
|
||||
// demo loop control
|
||||
int32_t demonum; // -1 = don't play demos
|
||||
char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
|
||||
int32_t demonum; // -1 = don't play demos
|
||||
char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
|
||||
|
||||
// demo recording info must be here, because record is started before
|
||||
// entering a map (and clearing client_state_t)
|
||||
bool demorecording;
|
||||
bool demoplayback;
|
||||
bool demorecording;
|
||||
bool demoplayback;
|
||||
|
||||
// did the user pause demo playback? (separate from cl.paused because we don't
|
||||
// want a svc_setpause inside the demo to actually pause demo playback).
|
||||
bool demopaused;
|
||||
bool demopaused;
|
||||
|
||||
bool timedemo;
|
||||
int32_t forcetrack; // -1 = use normal cd track
|
||||
FILE *demofile;
|
||||
int32_t td_lastframe; // to meter out one message a frame
|
||||
int32_t td_startframe; // host_framecount at start
|
||||
float td_starttime; // realtime at second frame of timedemo
|
||||
bool timedemo;
|
||||
int32_t forcetrack; // -1 = use normal cd track
|
||||
FILE *demofile;
|
||||
int32_t td_lastframe; // to meter out one message a frame
|
||||
int32_t td_startframe; // host_framecount at start
|
||||
float td_starttime; // realtime at second frame of timedemo
|
||||
|
||||
// connection information
|
||||
int32_t signon; // 0 to SIGNONS
|
||||
struct qsocket_s *netcon;
|
||||
sizebuf_t message; // writing buffer to send to server
|
||||
int32_t signon; // 0 to SIGNONS
|
||||
struct qsocket_s *netcon;
|
||||
sizebuf_t message; // writing buffer to send to server
|
||||
|
||||
} client_static_t;
|
||||
|
||||
extern client_static_t cls;
|
||||
extern client_static_t cls;
|
||||
|
||||
//
|
||||
// the client_state_t structure is wiped completely at every
|
||||
|
@ -141,236 +142,236 @@ extern client_static_t cls;
|
|||
//
|
||||
typedef struct
|
||||
{
|
||||
int32_t movemessages; // since connecting to this server
|
||||
// throw out the first couple, so the player
|
||||
// doesn't accidentally do something the
|
||||
// first frame
|
||||
usercmd_t cmd; // last command sent to the server
|
||||
int32_t movemessages; // since connecting to this server
|
||||
// throw out the first couple, so the player
|
||||
// doesn't accidentally do something the
|
||||
// first frame
|
||||
usercmd_t cmd; // last command sent to the server
|
||||
|
||||
// information for local display
|
||||
int32_t stats[MAX_CL_STATS]; // health, etc
|
||||
int32_t items; // inventory bit flags
|
||||
float item_gettime[32]; // cl.time of aquiring item, for blinking
|
||||
float faceanimtime; // use anim frame if cl.time < this
|
||||
int32_t stats[MAX_CL_STATS]; // health, etc
|
||||
int32_t items; // inventory bit flags
|
||||
float item_gettime[32]; // cl.time of aquiring item, for blinking
|
||||
float faceanimtime; // use anim frame if cl.time < this
|
||||
|
||||
cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
|
||||
cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
|
||||
cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
|
||||
cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
|
||||
|
||||
// the client maintains its own idea of view angles, which are
|
||||
// sent to the server each frame. The server sets punchangle when
|
||||
// the view is temporarliy offset, and an angle reset commands at the start
|
||||
// of each level and after teleporting.
|
||||
vec3_t mviewangles[2]; // during demo playback viewangles is lerped
|
||||
// between these
|
||||
vec3_t viewangles;
|
||||
vec3_t mviewangles[2]; // during demo playback viewangles is lerped
|
||||
// between these
|
||||
vec3_t viewangles;
|
||||
|
||||
vec3_t mvelocity[2]; // update by server, used for lean+bob
|
||||
// (0 is newest)
|
||||
vec3_t velocity; // lerped between mvelocity[0] and [1]
|
||||
vec3_t mvelocity[2]; // update by server, used for lean+bob
|
||||
// (0 is newest)
|
||||
vec3_t velocity; // lerped between mvelocity[0] and [1]
|
||||
|
||||
vec3_t punchangle; // temporary offset
|
||||
vec3_t punchangle; // temporary offset
|
||||
|
||||
// pitch drifting vars
|
||||
float idealpitch;
|
||||
float pitchvel;
|
||||
bool nodrift;
|
||||
float driftmove;
|
||||
double laststop;
|
||||
float idealpitch;
|
||||
float pitchvel;
|
||||
bool nodrift;
|
||||
float driftmove;
|
||||
double laststop;
|
||||
|
||||
float viewheight;
|
||||
float crouch; // local amount for smoothing stepups
|
||||
float viewheight;
|
||||
float crouch; // local amount for smoothing stepups
|
||||
|
||||
bool paused; // send over by server
|
||||
bool onground;
|
||||
bool inwater;
|
||||
bool paused; // send over by server
|
||||
bool onground;
|
||||
bool inwater;
|
||||
|
||||
int32_t intermission; // don't change view angle, full screen, etc
|
||||
int32_t completed_time; // latched at intermission start
|
||||
int32_t intermission; // don't change view angle, full screen, etc
|
||||
int32_t completed_time; // latched at intermission start
|
||||
|
||||
double mtime[2]; // the timestamp of last two messages
|
||||
double time; // clients view of time, should be between
|
||||
// servertime and oldservertime to generate
|
||||
// a lerp point for other data
|
||||
double oldtime; // previous cl.time, time-oldtime is used
|
||||
// to decay light values and smooth step ups
|
||||
double mtime[2]; // the timestamp of last two messages
|
||||
double time; // clients view of time, should be between
|
||||
// servertime and oldservertime to generate
|
||||
// a lerp point for other data
|
||||
double oldtime; // previous cl.time, time-oldtime is used
|
||||
// to decay light values and smooth step ups
|
||||
|
||||
|
||||
float last_received_message; // (realtime) for net trouble icon
|
||||
float last_received_message; // (realtime) for net trouble icon
|
||||
|
||||
//
|
||||
// information that is static for the entire time connected to a server
|
||||
//
|
||||
struct qmodel_s *model_precache[MAX_MODELS];
|
||||
struct sfx_s *sound_precache[MAX_SOUNDS];
|
||||
struct qmodel_s *model_precache[MAX_MODELS];
|
||||
struct sfx_s *sound_precache[MAX_SOUNDS];
|
||||
|
||||
char mapname[128];
|
||||
char levelname[128]; // for display on solo scoreboard //johnfitz -- was 40.
|
||||
int32_t viewentity; // cl_entitites[cl.viewentity] = player
|
||||
int32_t maxclients;
|
||||
int32_t gametype;
|
||||
char mapname[128];
|
||||
char levelname[128]; // for display on solo scoreboard //johnfitz -- was 40.
|
||||
int32_t viewentity; // cl_entitites[cl.viewentity] = player
|
||||
int32_t maxclients;
|
||||
int32_t gametype;
|
||||
|
||||
// refresh related state
|
||||
struct qmodel_s *worldmodel; // cl_entitites[0].model
|
||||
struct efrag_s *free_efrags;
|
||||
int32_t num_efrags;
|
||||
int32_t num_entities; // held in cl_entities array
|
||||
int32_t num_statics; // held in cl_staticentities array
|
||||
entity_t viewent; // the gun model
|
||||
struct qmodel_s *worldmodel; // cl_entitites[0].model
|
||||
struct efrag_s *free_efrags;
|
||||
int32_t num_efrags;
|
||||
int32_t num_entities; // held in cl_entities array
|
||||
int32_t num_statics; // held in cl_staticentities array
|
||||
entity_t viewent; // the gun model
|
||||
|
||||
int32_t cdtrack, looptrack; // cd audio
|
||||
int32_t cdtrack, looptrack; // cd audio
|
||||
|
||||
// frag scoreboard
|
||||
scoreboard_t *scores; // [cl.maxclients]
|
||||
scoreboard_t *scores; // [cl.maxclients]
|
||||
|
||||
unsigned protocol; //johnfitz
|
||||
unsigned protocolflags;
|
||||
unsigned protocol; //johnfitz
|
||||
unsigned protocolflags;
|
||||
} client_state_t;
|
||||
|
||||
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
extern cvar_t cl_name;
|
||||
extern cvar_t cl_color;
|
||||
extern cvar_t cl_name;
|
||||
extern cvar_t cl_color;
|
||||
|
||||
extern cvar_t cl_upspeed;
|
||||
extern cvar_t cl_forwardspeed;
|
||||
extern cvar_t cl_backspeed;
|
||||
extern cvar_t cl_sidespeed;
|
||||
extern cvar_t cl_upspeed;
|
||||
extern cvar_t cl_forwardspeed;
|
||||
extern cvar_t cl_backspeed;
|
||||
extern cvar_t cl_sidespeed;
|
||||
|
||||
extern cvar_t cl_movespeedkey;
|
||||
extern cvar_t cl_movespeedkey;
|
||||
|
||||
extern cvar_t cl_yawspeed;
|
||||
extern cvar_t cl_pitchspeed;
|
||||
extern cvar_t cl_yawspeed;
|
||||
extern cvar_t cl_pitchspeed;
|
||||
|
||||
extern cvar_t cl_anglespeedkey;
|
||||
extern cvar_t cl_anglespeedkey;
|
||||
|
||||
extern cvar_t cl_alwaysrun; // QuakeSpasm
|
||||
extern cvar_t cl_alwaysrun; // QuakeSpasm
|
||||
|
||||
extern cvar_t cl_autofire;
|
||||
extern cvar_t cl_autofire;
|
||||
|
||||
extern cvar_t cl_shownet;
|
||||
extern cvar_t cl_nolerp;
|
||||
extern cvar_t cl_shownet;
|
||||
extern cvar_t cl_nolerp;
|
||||
|
||||
extern cvar_t cfg_unbindall;
|
||||
extern cvar_t cfg_unbindall;
|
||||
|
||||
extern cvar_t cl_pitchdriftspeed;
|
||||
extern cvar_t lookspring;
|
||||
extern cvar_t lookstrafe;
|
||||
extern cvar_t sensitivity;
|
||||
extern cvar_t cl_pitchdriftspeed;
|
||||
extern cvar_t lookspring;
|
||||
extern cvar_t lookstrafe;
|
||||
extern cvar_t sensitivity;
|
||||
|
||||
extern cvar_t m_pitch;
|
||||
extern cvar_t m_yaw;
|
||||
extern cvar_t m_forward;
|
||||
extern cvar_t m_side;
|
||||
extern cvar_t m_pitch;
|
||||
extern cvar_t m_yaw;
|
||||
extern cvar_t m_forward;
|
||||
extern cvar_t m_side;
|
||||
|
||||
|
||||
#define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64
|
||||
#define MAX_STATIC_ENTITIES 4096 //ericw -- was 512 //johnfitz -- was 128
|
||||
#define MAX_VISEDICTS 4096 // larger, now we support BSP2
|
||||
#define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64
|
||||
#define MAX_STATIC_ENTITIES 4096 //ericw -- was 512 //johnfitz -- was 128
|
||||
#define MAX_VISEDICTS 4096 // larger, now we support BSP2
|
||||
|
||||
extern client_state_t cl;
|
||||
extern client_state_t cl;
|
||||
|
||||
// FIXME, allocate dynamically
|
||||
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
extern dlight_t cl_dlights[MAX_DLIGHTS];
|
||||
extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
extern beam_t cl_beams[MAX_BEAMS];
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
extern int32_t cl_numvisedicts;
|
||||
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
extern dlight_t cl_dlights[MAX_DLIGHTS];
|
||||
extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
|
||||
extern beam_t cl_beams[MAX_BEAMS];
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
extern int32_t cl_numvisedicts;
|
||||
|
||||
extern entity_t *cl_entities; //johnfitz -- was a static array, now on hunk
|
||||
extern int32_t cl_max_edicts; //johnfitz -- only changes when new map loads
|
||||
extern entity_t *cl_entities; //johnfitz -- was a static array, now on hunk
|
||||
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
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
int32_t down[2]; // key nums holding it down
|
||||
int32_t state; // low bit is down state
|
||||
int32_t down[2]; // key nums holding it down
|
||||
int32_t state; // low bit is down state
|
||||
} kbutton_t;
|
||||
|
||||
extern kbutton_t in_mlook, in_klook;
|
||||
extern kbutton_t in_strafe;
|
||||
extern kbutton_t in_speed;
|
||||
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;
|
||||
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_ */
|
||||
#endif /* _CLIENT_H_ */
|
||||
|
||||
|
|
502
source/cmd.c
502
source/cmd.c
|
@ -24,22 +24,22 @@ 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
|
||||
#define MAX_ALIAS_NAME 32
|
||||
|
||||
#define CMDLINE_LENGTH 256 //johnfitz -- mirrored in common.c
|
||||
|
||||
typedef struct cmdalias_s
|
||||
{
|
||||
struct cmdalias_s *next;
|
||||
char name[MAX_ALIAS_NAME];
|
||||
char *value;
|
||||
struct cmdalias_s *next;
|
||||
char name[MAX_ALIAS_NAME];
|
||||
char *value;
|
||||
} cmdalias_t;
|
||||
|
||||
cmdalias_t *cmd_alias;
|
||||
cmdalias_t *cmd_alias;
|
||||
|
||||
bool cmd_wait;
|
||||
bool cmd_wait;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -60,21 +60,21 @@ void Cmd_Wait_f (void)
|
|||
/*
|
||||
=============================================================================
|
||||
|
||||
COMMAND BUFFER
|
||||
COMMAND BUFFER
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
sizebuf_t cmd_text;
|
||||
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;
|
||||
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;
|
||||
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
|
||||
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;
|
||||
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] == ';')
|
||||
break; // don't break if inside a quoted string
|
||||
if (text[i] == '\n')
|
||||
if(!(quotes & 1) && text[i] == ';')
|
||||
break; // don't break if inside a quoted string
|
||||
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;
|
||||
|
@ -204,7 +205,7 @@ void Cbuf_Execute (void)
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
SCRIPT COMMANDS
|
||||
SCRIPT COMMANDS
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
@ -219,34 +220,34 @@ 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];
|
||||
int32_t i, j, plus;
|
||||
char cmds[CMDLINE_LENGTH];
|
||||
int32_t i, j, plus;
|
||||
|
||||
plus = false; // On Unix, argv[0] is command name
|
||||
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
|
||||
plus = false;
|
||||
else if (plus)
|
||||
else if(cmdline.string[i] == '-' &&
|
||||
(i == 0 || cmdline.string[i - 1] == ' ')) //johnfitz -- allow hypenated map names with +map
|
||||
plus = false;
|
||||
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;
|
||||
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;
|
||||
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,72 +304,72 @@ 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];
|
||||
int32_t i, c;
|
||||
const char *s;
|
||||
cmdalias_t *a;
|
||||
char cmd[1024];
|
||||
int32_t i, c;
|
||||
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
|
||||
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[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;
|
||||
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;
|
||||
cmdalias_t *blah;
|
||||
|
||||
while (cmd_alias)
|
||||
while(cmd_alias)
|
||||
{
|
||||
blah = cmd_alias->next;
|
||||
Z_Free(cmd_alias->value);
|
||||
|
@ -431,31 +432,31 @@ void Cmd_Unaliasall_f (void)
|
|||
/*
|
||||
=============================================================================
|
||||
|
||||
COMMAND EXECUTION
|
||||
COMMAND EXECUTION
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
typedef struct cmd_function_s
|
||||
{
|
||||
struct cmd_function_s *next;
|
||||
const char *name;
|
||||
xcommand_t function;
|
||||
struct cmd_function_s *next;
|
||||
const char *name;
|
||||
xcommand_t function;
|
||||
} cmd_function_t;
|
||||
|
||||
|
||||
#define MAX_ARGS 80
|
||||
#define MAX_ARGS 80
|
||||
|
||||
static int32_t cmd_argc;
|
||||
static char *cmd_argv[MAX_ARGS];
|
||||
static char cmd_null_string[] = "";
|
||||
static const char *cmd_args = NULL;
|
||||
static int32_t cmd_argc;
|
||||
static char *cmd_argv[MAX_ARGS];
|
||||
static char cmd_null_string[] = "";
|
||||
static const char *cmd_args = NULL;
|
||||
|
||||
cmd_source_t cmd_source;
|
||||
cmd_source_t cmd_source;
|
||||
|
||||
//johnfitz -- better tab completion
|
||||
//static cmd_function_t *cmd_functions; // possible commands to execute
|
||||
cmd_function_t *cmd_functions; // possible commands to execute
|
||||
//static cmd_function_t *cmd_functions; // possible commands to execute
|
||||
cmd_function_t *cmd_functions; // possible commands to execute
|
||||
//johnfitz
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
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;
|
||||
|
@ -526,33 +527,33 @@ void Cmd_Apropos_f(void)
|
|||
{
|
||||
char tmpbuf[256];
|
||||
int32_t hits = 0;
|
||||
cmd_function_t *cmd;
|
||||
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;
|
||||
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)
|
||||
cmd_args = text;
|
||||
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 *cmd;
|
||||
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;
|
||||
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;
|
||||
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_function_t *cmd;
|
||||
cmdalias_t *a;
|
||||
|
||||
cmd_source = src;
|
||||
Cmd_TokenizeString (text);
|
||||
Cmd_TokenizeString(text);
|
||||
|
||||
// execute the command line
|
||||
if (!Cmd_Argc())
|
||||
return; // no tokens
|
||||
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)
|
||||
return; // not really connected
|
||||
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;
|
||||
|
|
44
source/cmd.h
44
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,58 +70,58 @@ not apropriate.
|
|||
|
||||
*/
|
||||
|
||||
typedef void (*xcommand_t) (void);
|
||||
typedef void (*xcommand_t)(void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
src_client, // came in over a net connection as a clc_stringcmd
|
||||
// host_client will be valid during this state.
|
||||
src_command // from the command buffer
|
||||
src_client, // came in over a net connection as a clc_stringcmd
|
||||
// host_client will be valid during this state.
|
||||
src_command // from the command buffer
|
||||
} cmd_source_t;
|
||||
|
||||
extern cmd_source_t cmd_source;
|
||||
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
|
||||
|
||||
#endif /* _QUAKE_CMD_H */
|
||||
#endif /* _QUAKE_CMD_H */
|
||||
|
||||
|
|
1582
source/common.c
1582
source/common.c
File diff suppressed because it is too large
Load Diff
288
source/common.h
288
source/common.h
|
@ -28,166 +28,166 @@ 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',
|
||||
possible loss of data */
|
||||
/* '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',
|
||||
possible loss of data (/Wp64 warning) */
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* _WIN32 */
|
||||
/* 'var' : conversion from 'size_t' to 'type',
|
||||
possible loss of data (/Wp64 warning) */
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
#define q_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define q_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define CLAMP(_minval, x, _maxval) \
|
||||
((x) < (_minval) ? (_minval) : \
|
||||
(x) > (_maxval) ? (_maxval) : (x))
|
||||
#undef min
|
||||
#undef max
|
||||
#define q_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define q_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define CLAMP(_minval, x, _maxval) \
|
||||
((x) < (_minval) ? (_minval) : \
|
||||
(x) > (_maxval) ? (_maxval) : (x))
|
||||
|
||||
typedef struct sizebuf_s
|
||||
{
|
||||
bool allowoverflow; // if false, do a Sys_Error
|
||||
bool overflowed; // set to true if the buffer size failed
|
||||
byte *data;
|
||||
int32_t maxsize;
|
||||
int32_t cursize;
|
||||
bool allowoverflow; // if false, do a Sys_Error
|
||||
bool overflowed; // set to true if the buffer size failed
|
||||
byte *data;
|
||||
int32_t maxsize;
|
||||
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
|
||||
|
||||
//============================================================================
|
||||
|
||||
typedef struct link_s
|
||||
{
|
||||
struct link_s *prev, *next;
|
||||
struct link_s *prev, *next;
|
||||
} 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)
|
||||
// FIXME: remove this mess!
|
||||
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (intptr_t)&(((t *)0)->m)))
|
||||
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (intptr_t)&(((t *)0)->m)))
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern bool host_bigendian;
|
||||
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
|
||||
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;
|
||||
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;
|
||||
extern char **com_argv;
|
||||
extern int32_t com_argc;
|
||||
extern char **com_argv;
|
||||
|
||||
extern int32_t safemode;
|
||||
extern int32_t safemode;
|
||||
/* safe mode: in true, the engine will behave as if one
|
||||
of these arguments were actually on the command line:
|
||||
-nosound, -nocdaudio, -nomidi, -stdvid, -dibonly,
|
||||
-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
|
||||
|
||||
|
||||
|
@ -196,26 +196,26 @@ char *va (const char *format, ...) FUNC_PRINTF(1,2);
|
|||
// QUAKEFS
|
||||
typedef struct
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
int32_t filepos, filelen;
|
||||
char name[MAX_QPATH];
|
||||
int32_t filepos, filelen;
|
||||
} packfile_t;
|
||||
|
||||
typedef struct pack_s
|
||||
{
|
||||
char filename[MAX_OSPATH];
|
||||
int32_t handle;
|
||||
int32_t numfiles;
|
||||
packfile_t *files;
|
||||
char filename[MAX_OSPATH];
|
||||
int32_t handle;
|
||||
int32_t numfiles;
|
||||
packfile_t *files;
|
||||
} pack_t;
|
||||
|
||||
typedef struct searchpath_s
|
||||
{
|
||||
uint32_t path_id; // identifier assigned to the game directory
|
||||
// Note that <install_dir>/game1 and
|
||||
// <userdir>/game1 have the same id.
|
||||
char filename[MAX_OSPATH];
|
||||
pack_t *pack; // only one of filename / pack will be used
|
||||
struct searchpath_s *next;
|
||||
uint32_t path_id; // identifier assigned to the game directory
|
||||
// Note that <install_dir>/game1 and
|
||||
// <userdir>/game1 have the same id.
|
||||
char filename[MAX_OSPATH];
|
||||
pack_t *pack; // only one of filename / pack will be used
|
||||
struct searchpath_s *next;
|
||||
} searchpath_t;
|
||||
|
||||
extern searchpath_t *com_searchpaths;
|
||||
|
@ -224,40 +224,40 @@ extern searchpath_t *com_base_searchpaths;
|
|||
extern int32_t com_filesize;
|
||||
struct cache_user_s;
|
||||
|
||||
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
|
||||
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,
|
||||
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,
|
||||
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).
|
||||
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,
|
||||
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).
|
||||
|
||||
// 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.
|
||||
|
@ -281,10 +281,10 @@ const char *COM_ParseStringNewline(const char *buffer);
|
|||
typedef struct _fshandle_t
|
||||
{
|
||||
FILE *file;
|
||||
bool pak; /* is the file read from a pak */
|
||||
long start; /* file or data start position */
|
||||
long length; /* file or data size */
|
||||
long pos; /* current position relative to start */
|
||||
bool pak; /* is the file read from a pak */
|
||||
long start; /* file or data start position */
|
||||
long length; /* file or data size */
|
||||
long pos; /* current position relative to start */
|
||||
} fshandle_t;
|
||||
|
||||
size_t FS_fread(void *ptr, size_t size, size_t nmemb, fshandle_t *fh);
|
||||
|
@ -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 */
|
||||
extern struct cvar_s registered;
|
||||
extern bool standard_quake, rogue, hipnotic;
|
||||
extern bool fitzmode;
|
||||
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
|
||||
|
||||
#endif /* _Q_COMMON_H */
|
||||
#endif /* _Q_COMMON_H */
|
||||
|
||||
|
|
823
source/console.c
823
source/console.c
File diff suppressed because it is too large
Load Diff
|
@ -28,42 +28,42 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
extern int32_t con_totallines;
|
||||
extern int32_t con_backscroll;
|
||||
extern bool con_forcedup; // because no entities to refresh
|
||||
extern bool con_forcedup; // because no entities to refresh
|
||||
extern bool con_initialized;
|
||||
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 */
|
||||
#endif /* __CONSOLE_H */
|
||||
|
||||
|
|
76
source/crc.c
76
source/crc.c
|
@ -27,43 +27,43 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// and the initial and final xor values shown below... in other words, the
|
||||
// CCITT standard CRC used by XMODEM
|
||||
|
||||
#define CRC_INIT_VALUE 0xffff
|
||||
#define CRC_XOR_VALUE 0x0000
|
||||
#define CRC_INIT_VALUE 0xffff
|
||||
#define CRC_XOR_VALUE 0x0000
|
||||
|
||||
static uint16_t crctable[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
void CRC_Init(uint16_t *crcvalue)
|
||||
|
@ -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;
|
||||
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 */
|
||||
#endif /* _QUAKE_CRC_H */
|
||||
|
||||
|
|
369
source/cvar.c
369
source/cvar.c
|
@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
static cvar_t *cvar_vars;
|
||||
static char cvar_null_string[] = "";
|
||||
static cvar_t *cvar_vars;
|
||||
static char cvar_null_string[] = "";
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
|
@ -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;
|
||||
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,26 +57,26 @@ 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",
|
||||
(cvar->flags & CVAR_ARCHIVE) ? "*" : " ",
|
||||
(cvar->flags & CVAR_NOTIFY) ? "s" : " ",
|
||||
cvar->name,
|
||||
cvar->string);
|
||||
Con_SafePrintf("%s%s %s \"%s\"\n",
|
||||
(cvar->flags & CVAR_ARCHIVE) ? "*" : " ",
|
||||
(cvar->flags & CVAR_NOTIFY) ? "s" : " ",
|
||||
cvar->name,
|
||||
cvar->string);
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
int32_t len;
|
||||
|
||||
if (!strcmp(var->string, value))
|
||||
return; // no change
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
//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;
|
||||
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;
|
||||
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;
|
||||
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,30 +530,30 @@ 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
|
||||
char value[512];
|
||||
bool set_rom;
|
||||
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 ||
|
||||
strcmp(variable->name, cvar_vars->name) < 0) // insert at front
|
||||
if(cvar_vars == NULL ||
|
||||
strcmp(variable->name, cvar_vars->name) < 0) // insert at front
|
||||
{
|
||||
variable->next = cvar_vars;
|
||||
cvar_vars = variable;
|
||||
|
@ -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,12 +596,12 @@ 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;
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ it is sufficient to initialize a cvar_t with just the first two fields,
|
|||
or you can add a ,true flag for variables that you want saved to the
|
||||
configuration file when the game is quit:
|
||||
|
||||
cvar_t r_draworder = {"r_draworder","1"};
|
||||
cvar_t scr_screensize = {"screensize","1",true};
|
||||
cvar_t r_draworder = {"r_draworder","1"};
|
||||
cvar_t scr_screensize = {"screensize","1",true};
|
||||
|
||||
Cvars must be registered before use, or they will have a 0 value instead
|
||||
of the float interpretation of the string.
|
||||
|
@ -55,89 +55,89 @@ teamplay = cvar("teamplay");
|
|||
cvar_set ("registered", "1");
|
||||
|
||||
The user can access cvars from the console in two ways:
|
||||
r_draworder prints the current value
|
||||
r_draworder 0 sets the current value to 0
|
||||
r_draworder prints the current value
|
||||
r_draworder 0 sets the current value to 0
|
||||
|
||||
Cvars are restricted from having the same names as commands to keep this
|
||||
interface from being ambiguous.
|
||||
|
||||
*/
|
||||
|
||||
#define CVAR_NONE 0
|
||||
#define CVAR_ARCHIVE (1U << 0) // if set, causes it to be saved to config
|
||||
#define CVAR_NOTIFY (1U << 1) // changes will be broadcasted to all players (q1)
|
||||
#define CVAR_SERVERINFO (1U << 2) // added to serverinfo will be sent to clients (q1/net_dgrm.c and qwsv)
|
||||
#define CVAR_USERINFO (1U << 3) // added to userinfo, will be sent to server (qwcl)
|
||||
#define CVAR_CHANGED (1U << 4)
|
||||
#define CVAR_ROM (1U << 6)
|
||||
#define CVAR_LOCKED (1U << 8) // locked temporarily
|
||||
#define CVAR_REGISTERED (1U << 10) // the var is added to the list of variables
|
||||
#define CVAR_CALLBACK (1U << 16) // var has a callback
|
||||
#define CVAR_NONE 0
|
||||
#define CVAR_ARCHIVE (1U << 0) // if set, causes it to be saved to config
|
||||
#define CVAR_NOTIFY (1U << 1) // changes will be broadcasted to all players (q1)
|
||||
#define CVAR_SERVERINFO (1U << 2) // added to serverinfo will be sent to clients (q1/net_dgrm.c and qwsv)
|
||||
#define CVAR_USERINFO (1U << 3) // added to userinfo, will be sent to server (qwcl)
|
||||
#define CVAR_CHANGED (1U << 4)
|
||||
#define CVAR_ROM (1U << 6)
|
||||
#define CVAR_LOCKED (1U << 8) // locked temporarily
|
||||
#define CVAR_REGISTERED (1U << 10) // the var is added to the list of variables
|
||||
#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
|
||||
{
|
||||
const char *name;
|
||||
const char *string;
|
||||
uint32_t flags;
|
||||
float value;
|
||||
const char *default_string; //johnfitz -- remember defaults for reset function
|
||||
cvarcallback_t callback;
|
||||
struct cvar_s *next;
|
||||
const char *name;
|
||||
const char *string;
|
||||
uint32_t flags;
|
||||
float value;
|
||||
const char *default_string; //johnfitz -- remember defaults for reset function
|
||||
cvarcallback_t callback;
|
||||
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
|
||||
|
||||
#endif /* __CVAR_H__ */
|
||||
#endif /* __CVAR_H__ */
|
||||
|
||||
|
|
|
@ -26,23 +26,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// draw.h -- these are the only functions outside the refresh allowed
|
||||
// to touch the vid buffer
|
||||
|
||||
extern qpic_t *draw_disc; // also used on sbar
|
||||
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 */
|
||||
#endif /* _QUAKE_DRAW_H */
|
||||
|
||||
|
|
|
@ -38,153 +38,171 @@
|
|||
#define HAVE_DOS_BASED_FILE_SYSTEM 1
|
||||
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
|
||||
|
||||
#define HAS_DRIVE_SPEC(f) ((f)[0] && ((f)[1] == ':'))
|
||||
#define STRIP_DRIVE_SPEC(f) ((f) + 2)
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
|
||||
#define HAS_DRIVE_SPEC(f) ((f)[0] && ((f)[1] == ':'))
|
||||
#define STRIP_DRIVE_SPEC(f) ((f) + 2)
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
|
||||
/* both '/' and '\\' work as dir separator. djgpp likes changing
|
||||
* '\\' into '/', so I define DIR_SEPARATOR_CHAR as '/' for djgpp,
|
||||
* '\\' otherwise. */
|
||||
#ifdef __DJGPP__
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#else
|
||||
#define DIR_SEPARATOR_CHAR '\\'
|
||||
#define DIR_SEPARATOR_STR "\\"
|
||||
#define DIR_SEPARATOR_CHAR '\\'
|
||||
#define DIR_SEPARATOR_STR "\\"
|
||||
#endif
|
||||
/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
|
||||
only semi-absolute. This is because the users of IS_ABSOLUTE_PATH
|
||||
want to know whether to prepend the current working directory to
|
||||
a file name, which should not be done with a name like d:foo. */
|
||||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC((f)))
|
||||
#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 ? */
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
#else
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
/* ----------------- AmigaOS, MorphOS, AROS, etc: ----------------- */
|
||||
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
|
||||
#elif defined(__MORPHOS__) || defined(__AROS__) || defined(AMIGAOS) || \
|
||||
defined(__amigaos__) || defined(__amigaos4__) ||defined(__amigados__) || \
|
||||
defined(AMIGA) || defined(_AMIGA) || defined(__AMIGA__)
|
||||
|
||||
#define HAS_DRIVE_SPEC(f) (0) /* */
|
||||
#define STRIP_DRIVE_SPEC(f) (f) /* */
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == ':')
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (strchr((f), ':')))
|
||||
#define HAS_DRIVE_SPEC(f) (0) /* */
|
||||
#define STRIP_DRIVE_SPEC(f) (f) /* */
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == ':')
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (strchr((f), ':')))
|
||||
#define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path) {
|
||||
char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
|
||||
{
|
||||
char *p = strchr(_the_path, ':');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (char *_the_path) {
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
static inline char *FIND_LAST_DIRSEP(char *_the_path)
|
||||
{
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
const char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
static inline const char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
const char *p = strchr(_the_path, ':');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline const char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
const char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
static inline const char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
const char *p = strrchr(_the_path, '/');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
#else
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path) {
|
||||
char *p = strchr(_the_path, ':');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
static inline char *FIND_FIRST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
char *p = strchr(_the_path, ':');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (const char *_the_path) {
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if (p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
char *p = strrchr(_the_path, '/');
|
||||
if(p != NULL) return p;
|
||||
return strchr(_the_path, ':');
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
/* ---------------------- assumed UNIX-ish : ---------------------- */
|
||||
#else /* */
|
||||
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/')
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
|
||||
#define HAS_DRIVE_SPEC(f) (0)
|
||||
#define STRIP_DRIVE_SPEC(f) (f)
|
||||
#define IS_DIR_SEPARATOR(c) ((c) == '/')
|
||||
#define DIR_SEPARATOR_CHAR '/'
|
||||
#define DIR_SEPARATOR_STR "/"
|
||||
#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
|
||||
#define HAS_DRIVE_SPEC(f) (0)
|
||||
#define STRIP_DRIVE_SPEC(f) (f)
|
||||
|
||||
#ifdef __cplusplus
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path) {
|
||||
return strchr(_the_path, '/');
|
||||
static inline char *FIND_FIRST_DIRSEP(char *_the_path)
|
||||
{
|
||||
return strchr(_the_path, '/');
|
||||
}
|
||||
static inline char *FIND_LAST_DIRSEP (char *_the_path) {
|
||||
return strrchr(_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) {
|
||||
return strchr(_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) {
|
||||
return strrchr(_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) {
|
||||
return strchr(_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) {
|
||||
return strrchr(_the_path, '/');
|
||||
static inline char *FIND_LAST_DIRSEP(const char *_the_path)
|
||||
{
|
||||
return strrchr(_the_path, '/');
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
|
|
605
source/gl_draw.c
605
source/gl_draw.c
|
@ -27,82 +27,82 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
//extern uint8_t d_15to8table[65536]; //johnfitz -- never used
|
||||
|
||||
cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz
|
||||
cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz
|
||||
|
||||
qpic_t *draw_disc;
|
||||
qpic_t *draw_backtile;
|
||||
qpic_t *draw_disc;
|
||||
qpic_t *draw_backtile;
|
||||
|
||||
gltexture_t *char_texture; //johnfitz
|
||||
qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling
|
||||
qpic_t *pic_nul; //johnfitz -- for missing gfx, don't crash
|
||||
qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling
|
||||
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
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gltexture_t *gltexture;
|
||||
float sl, tl, sh, th;
|
||||
float sl, tl, sh, th;
|
||||
} glpic_t;
|
||||
|
||||
canvastype currentcanvas = CANVAS_NONE; //johnfitz -- for GL_SetCanvas
|
||||
|
@ -115,29 +115,29 @@ canvastype currentcanvas = CANVAS_NONE; //johnfitz -- for GL_SetCanvas
|
|||
|
||||
typedef struct cachepic_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
qpic_t pic;
|
||||
byte padding[32]; // for appended glpic
|
||||
char name[MAX_QPATH];
|
||||
qpic_t pic;
|
||||
byte padding[32]; // for appended glpic
|
||||
} cachepic_t;
|
||||
|
||||
#define MAX_CACHED_PICS 128
|
||||
cachepic_t menu_cachepics[MAX_CACHED_PICS];
|
||||
int32_t menu_numcachepics;
|
||||
#define MAX_CACHED_PICS 128
|
||||
cachepic_t menu_cachepics[MAX_CACHED_PICS];
|
||||
int32_t menu_numcachepics;
|
||||
|
||||
byte menuplyr_pixels[4096];
|
||||
byte menuplyr_pixels[4096];
|
||||
|
||||
// scrap allocation
|
||||
// Allocate all the little status bar obejcts into a single texture
|
||||
// to crutch up stupid hardware / drivers
|
||||
|
||||
#define MAX_SCRAPS 2
|
||||
#define BLOCK_WIDTH 256
|
||||
#define BLOCK_HEIGHT 256
|
||||
#define MAX_SCRAPS 2
|
||||
#define BLOCK_WIDTH 256
|
||||
#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
|
||||
bool scrap_dirty;
|
||||
gltexture_t *scrap_textures[MAX_SCRAPS]; //johnfitz
|
||||
int32_t scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||
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;
|
||||
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,16 +194,16 @@ 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;
|
||||
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],
|
||||
"", (src_offset_t)scrap_texels[i], TEXPREF_ALPHA | TEXPREF_OVERWRITE | TEXPREF_NOPICMIP);
|
||||
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);
|
||||
}
|
||||
|
||||
scrap_dirty = false;
|
||||
|
@ -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;
|
||||
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;
|
||||
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,
|
||||
offset, TEXPREF_ALPHA | TEXPREF_PAD | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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,
|
||||
WADFILENAME, offset, TEXPREF_ALPHA | TEXPREF_NEAREST | TEXPREF_NOPICMIP | TEXPREF_CONCHARS);
|
||||
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,25 +371,25 @@ void Draw_LoadPics (void)
|
|||
Draw_NewGame -- johnfitz
|
||||
===============
|
||||
*/
|
||||
void Draw_NewGame (void)
|
||||
void Draw_NewGame(void)
|
||||
{
|
||||
cachepic_t *pic;
|
||||
int32_t i;
|
||||
cachepic_t *pic;
|
||||
int32_t i;
|
||||
|
||||
// empty scrap and reallocate gltextures
|
||||
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;
|
||||
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)
|
||||
return; // totally off screen
|
||||
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)
|
||||
return; // totally off screen
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
|
126
source/gl_fog.c
126
source/gl_fog.c
|
@ -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:
|
||||
|
@ -130,38 +130,38 @@ void Fog_FogCommand_f (void)
|
|||
break;
|
||||
case 2:
|
||||
Fog_Update(q_max(0.0, atof(Cmd_Argv(1))),
|
||||
fog_red,
|
||||
fog_green,
|
||||
fog_blue,
|
||||
0.0);
|
||||
fog_red,
|
||||
fog_green,
|
||||
fog_blue,
|
||||
0.0);
|
||||
break;
|
||||
case 3: //TEST
|
||||
Fog_Update(q_max(0.0, atof(Cmd_Argv(1))),
|
||||
fog_red,
|
||||
fog_green,
|
||||
fog_blue,
|
||||
atof(Cmd_Argv(2)));
|
||||
fog_red,
|
||||
fog_green,
|
||||
fog_blue,
|
||||
atof(Cmd_Argv(2)));
|
||||
break;
|
||||
case 4:
|
||||
Fog_Update(fog_density,
|
||||
CLAMP(0.0, atof(Cmd_Argv(1)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
0.0);
|
||||
CLAMP(0.0, atof(Cmd_Argv(1)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
0.0);
|
||||
break;
|
||||
case 5:
|
||||
Fog_Update(q_max(0.0, atof(Cmd_Argv(1))),
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(4)), 1.0),
|
||||
0.0);
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(4)), 1.0),
|
||||
0.0);
|
||||
break;
|
||||
case 6: //TEST
|
||||
Fog_Update(q_max(0.0, atof(Cmd_Argv(1))),
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(4)), 1.0),
|
||||
atof(Cmd_Argv(5)));
|
||||
CLAMP(0.0, atof(Cmd_Argv(2)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(3)), 1.0),
|
||||
CLAMP(0.0, atof(Cmd_Argv(4)), 1.0),
|
||||
atof(Cmd_Argv(5)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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,17 +394,17 @@ void Fog_Init (void)
|
|||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
|
||||
Fog_SetupState ();
|
||||
Fog_SetupState();
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
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);
|
||||
}
|
||||
|
|
339
source/gl_mesh.c
339
source/gl_mesh.c
|
@ -32,79 +32,79 @@ ALIAS MODEL DISPLAY LIST GENERATION
|
|||
=================================================================
|
||||
*/
|
||||
|
||||
qmodel_t *aliasmodel;
|
||||
aliashdr_t *paliashdr;
|
||||
qmodel_t *aliasmodel;
|
||||
aliashdr_t *paliashdr;
|
||||
|
||||
int32_t used[8192]; // bool
|
||||
int32_t used[8192]; // bool
|
||||
|
||||
// the command list holds counts and s/t values that are valid for
|
||||
// every frame
|
||||
int32_t commands[8192];
|
||||
int32_t numcommands;
|
||||
int32_t commands[8192];
|
||||
int32_t numcommands;
|
||||
|
||||
// all frames will have their vertexes rearranged and expanded
|
||||
// so they are in the order expected by the command list
|
||||
int32_t vertexorder[8192];
|
||||
int32_t numorder;
|
||||
int32_t vertexorder[8192];
|
||||
int32_t numorder;
|
||||
|
||||
int32_t allverts, alltris;
|
||||
int32_t allverts, alltris;
|
||||
|
||||
int32_t stripverts[128];
|
||||
int32_t striptris[128];
|
||||
int32_t stripcount;
|
||||
int32_t stripverts[128];
|
||||
int32_t striptris[128];
|
||||
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;
|
||||
mtriangle_t *last, *check;
|
||||
int32_t k;
|
||||
int32_t m1, m2;
|
||||
int32_t j;
|
||||
mtriangle_t *last, *check;
|
||||
int32_t k;
|
||||
|
||||
used[starttri] = 2;
|
||||
|
||||
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,51 +127,51 @@ 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;
|
||||
mtriangle_t *last, *check;
|
||||
int32_t k;
|
||||
int32_t m1, m2;
|
||||
int32_t j;
|
||||
mtriangle_t *last, *check;
|
||||
int32_t k;
|
||||
|
||||
used[starttri] = 2;
|
||||
|
||||
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,63 +198,63 @@ 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;
|
||||
float s, t;
|
||||
int32_t len, bestlen, besttype;
|
||||
int32_t bestverts[1024];
|
||||
int32_t besttris[1024];
|
||||
int32_t type;
|
||||
int32_t i, j, k;
|
||||
int32_t startv;
|
||||
float s, t;
|
||||
int32_t len, bestlen, besttype;
|
||||
int32_t bestverts[1024];
|
||||
int32_t besttris[1024];
|
||||
int32_t type;
|
||||
|
||||
//
|
||||
// build tristrips
|
||||
//
|
||||
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;
|
||||
int32_t tmp;
|
||||
|
||||
// emit a vertex into the reorder buffer
|
||||
k = bestverts[j];
|
||||
|
@ -263,64 +263,64 @@ 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)
|
||||
s += pheader->skinwidth / 2; // on back side
|
||||
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;
|
||||
|
||||
// *(float *)&commands[numcommands++] = s;
|
||||
// *(float *)&commands[numcommands++] = t;
|
||||
// *(float *)&commands[numcommands++] = s;
|
||||
// *(float *)&commands[numcommands++] = t;
|
||||
// NOTE: 4 == sizeof(int32_t)
|
||||
// == sizeof(float)
|
||||
memcpy (&tmp, &s, 4);
|
||||
// == sizeof(float)
|
||||
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
|
||||
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;
|
||||
trivertx_t *verts;
|
||||
float hscale, vscale; //johnfitz -- padded skins
|
||||
int32_t count; //johnfitz -- precompute texcoords for padded skins
|
||||
int32_t *loadcmds; //johnfitz
|
||||
int32_t i, j;
|
||||
int32_t *cmds;
|
||||
trivertx_t *verts;
|
||||
float hscale, vscale; //johnfitz -- padded skins
|
||||
int32_t count; //johnfitz -- precompute texcoords for padded skins
|
||||
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);
|
||||
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,11 +440,11 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
|
|||
}
|
||||
|
||||
// upload immediately
|
||||
GLMesh_LoadVertexBuffer (aliasmodel, pheader);
|
||||
GLMesh_LoadVertexBuffer(aliasmodel, pheader);
|
||||
}
|
||||
|
||||
#define NUMVERTEXNORMALS 162
|
||||
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
|
||||
#define NUMVERTEXNORMALS 162
|
||||
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -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,20 +502,20 @@ 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];
|
||||
|
||||
xyz[v].xyz[0] = trivert.v[0];
|
||||
xyz[v].xyz[1] = trivert.v[1];
|
||||
xyz[v].xyz[2] = trivert.v[2];
|
||||
xyz[v].xyz[3] = 1; // need w 1 for 4 byte vertex compression
|
||||
xyz[v].xyz[3] = 1; // need w 1 for 4 byte vertex compression
|
||||
|
||||
// map the normal coordinates in [-1..1] to [-127..127] and store in an uint8_t.
|
||||
// this introduces some error (less than 0.004), but the normals were very coarse
|
||||
|
@ -522,7 +523,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
|
|||
xyz[v].normal[0] = 127 * r_avertexnormals[trivert.lightnormalindex][0];
|
||||
xyz[v].normal[1] = 127 * r_avertexnormals[trivert.lightnormalindex][1];
|
||||
xyz[v].normal[2] = 127 * r_avertexnormals[trivert.lightnormalindex][2];
|
||||
xyz[v].normal[3] = 0; // unused; for 4-byte alignment
|
||||
xyz[v].normal[3] = 0; // unused; for 4-byte alignment
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
1867
source/gl_model.c
1867
source/gl_model.c
File diff suppressed because it is too large
Load Diff
|
@ -35,10 +35,10 @@ m*_t structures are in-memory
|
|||
|
||||
// entity effects
|
||||
|
||||
#define EF_BRIGHTFIELD 1
|
||||
#define EF_MUZZLEFLASH 2
|
||||
#define EF_BRIGHTLIGHT 4
|
||||
#define EF_DIMLIGHT 8
|
||||
#define EF_BRIGHTFIELD 1
|
||||
#define EF_MUZZLEFLASH 2
|
||||
#define EF_BRIGHTLIGHT 4
|
||||
#define EF_DIMLIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
|
@ -56,141 +56,142 @@ BRUSH MODELS
|
|||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
vec3_t position;
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
#define SIDE_FRONT 0
|
||||
#define SIDE_BACK 1
|
||||
#define SIDE_ON 2
|
||||
#define SIDE_FRONT 0
|
||||
#define SIDE_BACK 1
|
||||
#define SIDE_ON 2
|
||||
|
||||
|
||||
// plane_t structure
|
||||
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
byte type; // for texture axis selection and fast side tests
|
||||
byte signbits; // signx + signy<<1 + signz<<1
|
||||
byte pad[2];
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
byte type; // for texture axis selection and fast side tests
|
||||
byte signbits; // signx + signy<<1 + signz<<1
|
||||
byte pad[2];
|
||||
} mplane_t;
|
||||
|
||||
// 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;
|
||||
|
||||
typedef struct texture_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
struct gltexture_s *gltexture; //johnfitz -- pointer to gltexture
|
||||
struct gltexture_s *fullbright; //johnfitz -- fullbright mask texture
|
||||
struct gltexture_s *warpimage; //johnfitz -- for water animation
|
||||
bool update_warp; //johnfitz -- update warp this frame
|
||||
struct msurface_s *texturechains[2]; // for texture chains
|
||||
int32_t anim_total; // total tenths in sequence ( 0 = no)
|
||||
int32_t anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
struct gltexture_s *gltexture; //johnfitz -- pointer to gltexture
|
||||
struct gltexture_s *fullbright; //johnfitz -- fullbright mask texture
|
||||
struct gltexture_s *warpimage; //johnfitz -- for water animation
|
||||
bool update_warp; //johnfitz -- update warp this frame
|
||||
struct msurface_s *texturechains[2]; // for texture chains
|
||||
int32_t anim_total; // total tenths in sequence ( 0 = no)
|
||||
int32_t anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frmae 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
} texture_t;
|
||||
|
||||
|
||||
#define SURF_PLANEBACK 2
|
||||
#define SURF_DRAWSKY 4
|
||||
#define SURF_DRAWSPRITE 8
|
||||
#define SURF_DRAWTURB 0x10
|
||||
#define SURF_DRAWTILED 0x20
|
||||
#define SURF_DRAWBACKGROUND 0x40
|
||||
#define SURF_UNDERWATER 0x80
|
||||
#define SURF_NOTEXTURE 0x100 //johnfitz
|
||||
#define SURF_DRAWFENCE 0x200
|
||||
#define SURF_DRAWLAVA 0x400
|
||||
#define SURF_DRAWSLIME 0x800
|
||||
#define SURF_DRAWTELE 0x1000
|
||||
#define SURF_DRAWWATER 0x2000
|
||||
#define SURF_PLANEBACK 2
|
||||
#define SURF_DRAWSKY 4
|
||||
#define SURF_DRAWSPRITE 8
|
||||
#define SURF_DRAWTURB 0x10
|
||||
#define SURF_DRAWTILED 0x20
|
||||
#define SURF_DRAWBACKGROUND 0x40
|
||||
#define SURF_UNDERWATER 0x80
|
||||
#define SURF_NOTEXTURE 0x100 //johnfitz
|
||||
#define SURF_DRAWFENCE 0x200
|
||||
#define SURF_DRAWLAVA 0x400
|
||||
#define SURF_DRAWSLIME 0x800
|
||||
#define SURF_DRAWTELE 0x1000
|
||||
#define SURF_DRAWWATER 0x2000
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
uint32_t v[2];
|
||||
uint32_t cachededgeoffset;
|
||||
uint32_t v[2];
|
||||
uint32_t cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4];
|
||||
float mipadjust;
|
||||
texture_t *texture;
|
||||
int32_t flags;
|
||||
float vecs[2][4];
|
||||
float mipadjust;
|
||||
texture_t *texture;
|
||||
int32_t flags;
|
||||
} mtexinfo_t;
|
||||
|
||||
#define VERTEXSIZE 7
|
||||
#define VERTEXSIZE 7
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int32_t numverts;
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int32_t numverts;
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
} glpoly_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
{
|
||||
int32_t visframe; // should be drawn when node is crossed
|
||||
bool culled; // johnfitz -- for frustum culling
|
||||
float mins[3]; // johnfitz -- for frustum culling
|
||||
float maxs[3]; // johnfitz -- for frustum culling
|
||||
int32_t visframe; // should be drawn when node is crossed
|
||||
bool culled; // johnfitz -- for frustum culling
|
||||
float mins[3]; // johnfitz -- for frustum culling
|
||||
float maxs[3]; // johnfitz -- for frustum culling
|
||||
|
||||
mplane_t *plane;
|
||||
int32_t flags;
|
||||
mplane_t *plane;
|
||||
int32_t flags;
|
||||
|
||||
int32_t firstedge; // look up in model->surfedges[], negative numbers
|
||||
int32_t numedges; // are backwards edges
|
||||
int32_t firstedge; // look up in model->surfedges[], negative numbers
|
||||
int32_t numedges; // are backwards edges
|
||||
|
||||
int16_t texturemins[2];
|
||||
int16_t extents[2];
|
||||
int16_t texturemins[2];
|
||||
int16_t extents[2];
|
||||
|
||||
int32_t light_s, light_t; // gl lightmap coordinates
|
||||
int32_t light_s, light_t; // gl lightmap coordinates
|
||||
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
int32_t vbo_firstvert; // index of this surface's first vert in the VBO
|
||||
int32_t vbo_firstvert; // index of this surface's first vert in the VBO
|
||||
|
||||
// lighting info
|
||||
int32_t dlightframe;
|
||||
uint32_t dlightbits[(MAX_DLIGHTS + 31) >> 5];
|
||||
// int32_t is 32 bits, need an array for MAX_DLIGHTS > 32
|
||||
int32_t dlightframe;
|
||||
uint32_t dlightbits[(MAX_DLIGHTS + 31) >> 5];
|
||||
// int32_t is 32 bits, need an array for MAX_DLIGHTS > 32
|
||||
|
||||
int32_t lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
bool cached_dlight; // true if dynamic light in cache
|
||||
byte *samples; // [numstyles*surfsize]
|
||||
int32_t lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int32_t cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
bool cached_dlight; // true if dynamic light in cache
|
||||
byte *samples; // [numstyles*surfsize]
|
||||
} msurface_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int32_t contents; // 0, to differentiate from leafs
|
||||
int32_t visframe; // node needs to be traversed if current
|
||||
int32_t contents; // 0, to differentiate from leafs
|
||||
int32_t visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
struct mnode_s *parent;
|
||||
|
||||
// node specific
|
||||
mplane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
mplane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
|
||||
int32_t firstsurface;
|
||||
int32_t numsurfaces;
|
||||
int32_t firstsurface;
|
||||
int32_t numsurfaces;
|
||||
} mnode_t;
|
||||
|
||||
|
||||
|
@ -198,40 +199,40 @@ typedef struct mnode_s
|
|||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int32_t contents; // wil be a negative contents number
|
||||
int32_t visframe; // node needs to be traversed if current
|
||||
int32_t contents; // wil be a negative contents number
|
||||
int32_t visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
struct mnode_s *parent;
|
||||
|
||||
// leaf specific
|
||||
byte *compressed_vis;
|
||||
efrag_t *efrags;
|
||||
byte *compressed_vis;
|
||||
efrag_t *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int32_t nummarksurfaces;
|
||||
int32_t key; // BSP sequence number for leaf's contents
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
msurface_t **firstmarksurface;
|
||||
int32_t nummarksurfaces;
|
||||
int32_t key; // BSP sequence number for leaf's contents
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
} mleaf_t;
|
||||
|
||||
//johnfitz -- for clipnodes>32k
|
||||
typedef struct mclipnode_s
|
||||
{
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are contents
|
||||
int32_t planenum;
|
||||
int32_t children[2]; // negative numbers are contents
|
||||
} mclipnode_t;
|
||||
//johnfitz
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
mclipnode_t *clipnodes; //johnfitz -- was dclipnode_t
|
||||
mplane_t *planes;
|
||||
int32_t firstclipnode;
|
||||
int32_t lastclipnode;
|
||||
vec3_t clip_mins;
|
||||
vec3_t clip_maxs;
|
||||
mclipnode_t *clipnodes; //johnfitz -- was dclipnode_t
|
||||
mplane_t *planes;
|
||||
int32_t firstclipnode;
|
||||
int32_t lastclipnode;
|
||||
vec3_t clip_mins;
|
||||
vec3_t clip_maxs;
|
||||
} hull_t;
|
||||
|
||||
/*
|
||||
|
@ -246,34 +247,34 @@ SPRITE MODELS
|
|||
// FIXME: shorten these?
|
||||
typedef struct mspriteframe_s
|
||||
{
|
||||
int32_t width, height;
|
||||
float up, down, left, right;
|
||||
float smax, tmax; //johnfitz -- image might be padded
|
||||
struct gltexture_s *gltexture;
|
||||
int32_t width, height;
|
||||
float up, down, left, right;
|
||||
float smax, tmax; //johnfitz -- image might be padded
|
||||
struct gltexture_s *gltexture;
|
||||
} mspriteframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
int32_t numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
} mspriteframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t type;
|
||||
int32_t maxwidth;
|
||||
int32_t maxheight;
|
||||
int32_t numframes;
|
||||
float beamlength; // remove?
|
||||
void *cachespot; // remove?
|
||||
mspriteframedesc_t frames[1];
|
||||
int32_t type;
|
||||
int32_t maxwidth;
|
||||
int32_t maxheight;
|
||||
int32_t numframes;
|
||||
float beamlength; // remove?
|
||||
void *cachespot; // remove?
|
||||
mspriteframedesc_t frames[1];
|
||||
} msprite_t;
|
||||
|
||||
|
||||
|
@ -308,79 +309,81 @@ typedef struct meshst_s
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int32_t firstpose;
|
||||
int32_t numposes;
|
||||
float interval;
|
||||
trivertx_t bboxmin;
|
||||
trivertx_t bboxmax;
|
||||
int32_t frame;
|
||||
char name[16];
|
||||
int32_t firstpose;
|
||||
int32_t numposes;
|
||||
float interval;
|
||||
trivertx_t bboxmin;
|
||||
trivertx_t bboxmax;
|
||||
int32_t frame;
|
||||
char name[16];
|
||||
} maliasframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
trivertx_t bboxmin;
|
||||
trivertx_t bboxmax;
|
||||
int32_t frame;
|
||||
trivertx_t bboxmin;
|
||||
trivertx_t bboxmax;
|
||||
int32_t frame;
|
||||
} maliasgroupframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t numframes;
|
||||
int32_t intervals;
|
||||
maliasgroupframedesc_t frames[1];
|
||||
int32_t numframes;
|
||||
int32_t intervals;
|
||||
maliasgroupframedesc_t frames[1];
|
||||
} maliasgroup_t;
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct mtriangle_s {
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
typedef struct mtriangle_s
|
||||
{
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
} mtriangle_t;
|
||||
|
||||
|
||||
#define MAX_SKINS 32
|
||||
typedef struct {
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
vec3_t scale_origin;
|
||||
float boundingradius;
|
||||
vec3_t eyeposition;
|
||||
int32_t numskins;
|
||||
int32_t skinwidth;
|
||||
int32_t skinheight;
|
||||
int32_t numverts;
|
||||
int32_t numtris;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
int32_t flags;
|
||||
float size;
|
||||
#define MAX_SKINS 32
|
||||
typedef struct
|
||||
{
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
vec3_t scale_origin;
|
||||
float boundingradius;
|
||||
vec3_t eyeposition;
|
||||
int32_t numskins;
|
||||
int32_t skinwidth;
|
||||
int32_t skinheight;
|
||||
int32_t numverts;
|
||||
int32_t numtris;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
int32_t flags;
|
||||
float size;
|
||||
|
||||
//ericw -- used to populate vbo
|
||||
int32_t numverts_vbo; // number of verts with unique x,y,z,s,t
|
||||
intptr_t meshdesc; // offset into extradata: numverts_vbo aliasmesh_t
|
||||
int32_t numindexes;
|
||||
intptr_t indexes; // offset into extradata: numindexes unsigned shorts
|
||||
intptr_t vertexes; // offset into extradata: numposes*vertsperframe trivertx_t
|
||||
int32_t numverts_vbo; // number of verts with unique x,y,z,s,t
|
||||
intptr_t meshdesc; // offset into extradata: numverts_vbo aliasmesh_t
|
||||
int32_t numindexes;
|
||||
intptr_t indexes; // offset into extradata: numindexes unsigned shorts
|
||||
intptr_t vertexes; // offset into extradata: numposes*vertsperframe trivertx_t
|
||||
//ericw --
|
||||
|
||||
int32_t numposes;
|
||||
int32_t poseverts;
|
||||
int32_t posedata; // numposes*poseverts trivert_t
|
||||
int32_t commands; // gl command list with embedded s/t
|
||||
struct gltexture_s *gltextures[MAX_SKINS][4]; //johnfitz
|
||||
struct gltexture_s *fbtextures[MAX_SKINS][4]; //johnfitz
|
||||
int32_t texels[MAX_SKINS]; // only for player skins
|
||||
maliasframedesc_t frames[1]; // variable sized
|
||||
int32_t numposes;
|
||||
int32_t poseverts;
|
||||
int32_t posedata; // numposes*poseverts trivert_t
|
||||
int32_t commands; // gl command list with embedded s/t
|
||||
struct gltexture_s *gltextures[MAX_SKINS][4]; //johnfitz
|
||||
struct gltexture_s *fbtextures[MAX_SKINS][4]; //johnfitz
|
||||
int32_t texels[MAX_SKINS]; // only for player skins
|
||||
maliasframedesc_t frames[1]; // variable sized
|
||||
} aliashdr_t;
|
||||
|
||||
#define MAXALIASVERTS 2000 //johnfitz -- was 1024
|
||||
#define MAXALIASFRAMES 256
|
||||
#define MAXALIASTRIS 2048
|
||||
extern aliashdr_t *pheader;
|
||||
extern stvert_t stverts[MAXALIASVERTS];
|
||||
extern mtriangle_t triangles[MAXALIASTRIS];
|
||||
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
||||
#define MAXALIASVERTS 2000 //johnfitz -- was 1024
|
||||
#define MAXALIASFRAMES 256
|
||||
#define MAXALIASTRIS 2048
|
||||
extern aliashdr_t *pheader;
|
||||
extern stvert_t stverts[MAXALIASVERTS];
|
||||
extern mtriangle_t triangles[MAXALIASTRIS];
|
||||
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
||||
|
||||
//===================================================================
|
||||
|
||||
|
@ -390,130 +393,130 @@ extern trivertx_t *poseverts[MAXALIASFRAMES];
|
|||
|
||||
typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t;
|
||||
|
||||
#define EF_ROCKET 1 // leave a trail
|
||||
#define EF_GRENADE 2 // leave a trail
|
||||
#define EF_GIB 4 // leave a trail
|
||||
#define EF_ROTATE 8 // rotate (bonus items)
|
||||
#define EF_TRACER 16 // green split trail
|
||||
#define EF_ZOMGIB 32 // small blood trail
|
||||
#define EF_TRACER2 64 // orange split trail + rotate
|
||||
#define EF_TRACER3 128 // purple trail
|
||||
#define MF_HOLEY (1u<<14) // MarkV/QSS -- make index 255 transparent on mdl's
|
||||
#define EF_ROCKET 1 // leave a trail
|
||||
#define EF_GRENADE 2 // leave a trail
|
||||
#define EF_GIB 4 // leave a trail
|
||||
#define EF_ROTATE 8 // rotate (bonus items)
|
||||
#define EF_TRACER 16 // green split trail
|
||||
#define EF_ZOMGIB 32 // small blood trail
|
||||
#define EF_TRACER2 64 // orange split trail + rotate
|
||||
#define EF_TRACER3 128 // purple trail
|
||||
#define MF_HOLEY (1u<<14) // MarkV/QSS -- make index 255 transparent on mdl's
|
||||
|
||||
//johnfitz -- extra flags for rendering
|
||||
#define MOD_NOLERP 256 //don't lerp when animating
|
||||
#define MOD_NOSHADOW 512 //don't cast a shadow
|
||||
#define MOD_FBRIGHTHACK 1024 //when fullbrights are disabled, use a hack to render this model brighter
|
||||
#define MOD_NOLERP 256 //don't lerp when animating
|
||||
#define MOD_NOSHADOW 512 //don't cast a shadow
|
||||
#define MOD_FBRIGHTHACK 1024 //when fullbrights are disabled, use a hack to render this model brighter
|
||||
//johnfitz
|
||||
|
||||
typedef struct qmodel_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
uint32_t path_id; // path id of the game directory
|
||||
// that this model came from
|
||||
bool needload; // bmodels and sprites don't cache normally
|
||||
char name[MAX_QPATH];
|
||||
uint32_t path_id; // path id of the game directory
|
||||
// that this model came from
|
||||
bool needload; // bmodels and sprites don't cache normally
|
||||
|
||||
modtype_t type;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
modtype_t type;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
|
||||
int32_t flags;
|
||||
int32_t flags;
|
||||
|
||||
//
|
||||
// volume occupied by the model graphics
|
||||
//
|
||||
vec3_t mins, maxs;
|
||||
vec3_t ymins, ymaxs; //johnfitz -- bounds for entities with nonzero yaw
|
||||
vec3_t rmins, rmaxs; //johnfitz -- bounds for entities with nonzero pitch or roll
|
||||
vec3_t mins, maxs;
|
||||
vec3_t ymins, ymaxs; //johnfitz -- bounds for entities with nonzero yaw
|
||||
vec3_t rmins, rmaxs; //johnfitz -- bounds for entities with nonzero pitch or roll
|
||||
//johnfitz -- removed float radius;
|
||||
|
||||
//
|
||||
// solid volume for clipping
|
||||
//
|
||||
bool clipbox;
|
||||
vec3_t clipmins, clipmaxs;
|
||||
bool clipbox;
|
||||
vec3_t clipmins, clipmaxs;
|
||||
|
||||
//
|
||||
// brush model
|
||||
//
|
||||
int32_t firstmodelsurface, nummodelsurfaces;
|
||||
int32_t firstmodelsurface, nummodelsurfaces;
|
||||
|
||||
int32_t numsubmodels;
|
||||
dmodel_t *submodels;
|
||||
int32_t numsubmodels;
|
||||
dmodel_t *submodels;
|
||||
|
||||
int32_t numplanes;
|
||||
mplane_t *planes;
|
||||
int32_t numplanes;
|
||||
mplane_t *planes;
|
||||
|
||||
int32_t numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *leafs;
|
||||
int32_t numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *leafs;
|
||||
|
||||
int32_t numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
int32_t numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int32_t numedges;
|
||||
medge_t *edges;
|
||||
int32_t numedges;
|
||||
medge_t *edges;
|
||||
|
||||
int32_t numnodes;
|
||||
mnode_t *nodes;
|
||||
int32_t numnodes;
|
||||
mnode_t *nodes;
|
||||
|
||||
int32_t numtexinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
int32_t numtexinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
int32_t numsurfaces;
|
||||
msurface_t *surfaces;
|
||||
int32_t numsurfaces;
|
||||
msurface_t *surfaces;
|
||||
|
||||
int32_t numsurfedges;
|
||||
int32_t *surfedges;
|
||||
int32_t numsurfedges;
|
||||
int32_t *surfedges;
|
||||
|
||||
int32_t numclipnodes;
|
||||
mclipnode_t *clipnodes; //johnfitz -- was dclipnode_t
|
||||
int32_t numclipnodes;
|
||||
mclipnode_t *clipnodes; //johnfitz -- was dclipnode_t
|
||||
|
||||
int32_t nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
int32_t nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
hull_t hulls[MAX_MAP_HULLS];
|
||||
hull_t hulls[MAX_MAP_HULLS];
|
||||
|
||||
int32_t numtextures;
|
||||
texture_t **textures;
|
||||
int32_t numtextures;
|
||||
texture_t **textures;
|
||||
|
||||
byte *visdata;
|
||||
byte *lightdata;
|
||||
char *entities;
|
||||
byte *visdata;
|
||||
byte *lightdata;
|
||||
char *entities;
|
||||
|
||||
bool viswarn; // for Mod_DecompressVis()
|
||||
bool viswarn; // for Mod_DecompressVis()
|
||||
|
||||
int32_t bspversion;
|
||||
int32_t bspversion;
|
||||
|
||||
//
|
||||
// alias model
|
||||
//
|
||||
|
||||
GLuint meshvbo;
|
||||
GLuint meshindexesvbo;
|
||||
int32_t vboindexofs; // offset in vbo of the hdr->numindexes unsigned shorts
|
||||
int32_t vboxyzofs; // offset in vbo of hdr->numposes*hdr->numverts_vbo meshxyz_t
|
||||
int32_t vbostofs; // offset in vbo of hdr->numverts_vbo meshst_t
|
||||
GLuint meshvbo;
|
||||
GLuint meshindexesvbo;
|
||||
int32_t vboindexofs; // offset in vbo of the hdr->numindexes unsigned shorts
|
||||
int32_t vboxyzofs; // offset in vbo of hdr->numposes*hdr->numverts_vbo meshxyz_t
|
||||
int32_t vbostofs; // offset in vbo of hdr->numverts_vbo meshst_t
|
||||
|
||||
//
|
||||
// additional model data
|
||||
//
|
||||
cache_user_t cache; // only access through Mod_Extradata
|
||||
cache_user_t cache; // only access through Mod_Extradata
|
||||
|
||||
} qmodel_t;
|
||||
|
||||
//============================================================================
|
||||
|
||||
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__
|
||||
#endif // __MODEL__
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
mnode_t *r_pefragtopnode;
|
||||
mnode_t *r_pefragtopnode;
|
||||
|
||||
|
||||
//===========================================================================
|
||||
|
@ -31,7 +31,7 @@ mnode_t *r_pefragtopnode;
|
|||
/*
|
||||
===============================================================================
|
||||
|
||||
ENTITY FRAGMENT FUNCTIONS
|
||||
ENTITY FRAGMENT FUNCTIONS
|
||||
|
||||
ericw -- GLQuake only uses efrags for static entities, and they're never
|
||||
removed, so I trimmed out unused functionality and fields in efrag_t.
|
||||
|
@ -39,50 +39,50 @@ removed, so I trimmed out unused functionality and fields in efrag_t.
|
|||
Now, efrags are just a linked list for each leaf of the static
|
||||
entities that touch that leaf. The efrags are hunk-allocated so there is no
|
||||
fixed limit.
|
||||
|
||||
|
||||
This is inspired by MH's tutorial, and code from RMQEngine.
|
||||
http://forums.insideqc.com/viewtopic.php?t=1930
|
||||
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
vec3_t r_emins, r_emaxs;
|
||||
vec3_t r_emins, r_emaxs;
|
||||
|
||||
entity_t *r_addent;
|
||||
entity_t *r_addent;
|
||||
|
||||
|
||||
#define EXTRA_EFRAGS 128
|
||||
#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;
|
||||
ef->leafnext = NULL;
|
||||
|
||||
|
||||
cl.num_efrags++;
|
||||
|
||||
|
||||
return ef;
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
cl.free_efrags = (efrag_t *) Hunk_AllocName (EXTRA_EFRAGS * sizeof (efrag_t), "efrags");
|
||||
|
||||
for (i = 0; i < EXTRA_EFRAGS - 1; i++)
|
||||
|
||||
cl.free_efrags = (efrag_t *) Hunk_AllocName(EXTRA_EFRAGS * sizeof(efrag_t), "efrags");
|
||||
|
||||
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;
|
||||
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)
|
||||
// split on this plane
|
||||
// if this is the first splitter of this bmodel, remember it
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
int32_t r_dlightframecount;
|
||||
int32_t r_dlightframecount;
|
||||
|
||||
extern cvar_t r_flatlightstyles; //johnfitz
|
||||
|
||||
|
@ -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,50 +70,51 @@ 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;
|
||||
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;
|
||||
vec3_t v;
|
||||
float rad;
|
||||
int32_t i, j;
|
||||
float a;
|
||||
vec3_t v;
|
||||
float rad;
|
||||
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
|
||||
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,54 +167,58 @@ 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;
|
||||
vec3_t impact;
|
||||
float dist, l, maxdist;
|
||||
int32_t i, j, s, t;
|
||||
mplane_t *splitplane;
|
||||
msurface_t *surf;
|
||||
vec3_t impact;
|
||||
float dist, l, maxdist;
|
||||
int32_t i, j, s, t;
|
||||
|
||||
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;
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,26 +268,26 @@ LIGHT SAMPLING
|
|||
=============================================================================
|
||||
*/
|
||||
|
||||
mplane_t *lightplane;
|
||||
vec3_t lightspot;
|
||||
vec3_t lightcolor; //johnfitz -- lit support via lordhavoc
|
||||
mplane_t *lightplane;
|
||||
vec3_t lightspot;
|
||||
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;
|
||||
float front, back, frac;
|
||||
vec3_t mid;
|
||||
|
||||
loc0:
|
||||
if (node->contents < 0)
|
||||
return false; // didn't hit anything
|
||||
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))
|
||||
return true; // hit something
|
||||
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);
|
||||
// check for impact on this node
|
||||
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)
|
||||
continue; // no lightmaps
|
||||
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]);
|
||||
// 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]);
|
||||
|
||||
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);
|
||||
// go down back side
|
||||
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;
|
||||
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,15 +78,15 @@ 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;
|
||||
byte *rgb;
|
||||
int32_t s;
|
||||
|
||||
(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;
|
||||
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,25 +278,25 @@ 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;
|
||||
aliashdr_t *paliashdr;
|
||||
int32_t skinnum;
|
||||
char name[64];
|
||||
byte *pixels;
|
||||
aliashdr_t *paliashdr;
|
||||
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,
|
||||
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file, paliashdr->gltextures[skinnum][0]->source_offset, TEXPREF_PAD | TEXPREF_OVERWRITE);
|
||||
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;
|
||||
int32_t i;
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
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;
|
||||
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,30 +609,30 @@ 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;
|
||||
break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
cache = ¤t_element_array_buffer;
|
||||
break;
|
||||
default:
|
||||
Host_Error("GL_BindBuffer: unsupported target %" PRIi32 "", (int32_t)target);
|
||||
return;
|
||||
case GL_ARRAY_BUFFER:
|
||||
cache = ¤t_array_buffer;
|
||||
break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
cache = ¤t_element_array_buffer;
|
||||
break;
|
||||
default:
|
||||
Host_Error("GL_BindBuffer: unsupported target %" PRIi32 "", (int32_t)target);
|
||||
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
744
source/gl_sky.c
744
source/gl_sky.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -24,45 +24,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
//gl_texmgr.h -- fitzquake's texture manager. manages opengl texture images
|
||||
|
||||
#define TEXPREF_NONE 0x0000
|
||||
#define TEXPREF_MIPMAP 0x0001 // generate mipmaps
|
||||
#define TEXPREF_NONE 0x0000
|
||||
#define TEXPREF_MIPMAP 0x0001 // generate mipmaps
|
||||
// TEXPREF_NEAREST and TEXPREF_LINEAR aren't supposed to be ORed with TEX_MIPMAP
|
||||
#define TEXPREF_LINEAR 0x0002 // force linear
|
||||
#define TEXPREF_NEAREST 0x0004 // force nearest
|
||||
#define TEXPREF_ALPHA 0x0008 // allow alpha
|
||||
#define TEXPREF_PAD 0x0010 // allow padding
|
||||
#define TEXPREF_PERSIST 0x0020 // never free
|
||||
#define TEXPREF_OVERWRITE 0x0040 // overwrite existing same-name texture
|
||||
#define TEXPREF_NOPICMIP 0x0080 // always load full-sized
|
||||
#define TEXPREF_FULLBRIGHT 0x0100 // use fullbright mask palette
|
||||
#define TEXPREF_NOBRIGHT 0x0200 // use nobright mask palette
|
||||
#define TEXPREF_CONCHARS 0x0400 // use conchars palette
|
||||
#define TEXPREF_WARPIMAGE 0x0800 // resize this texture when warpimagesize changes
|
||||
#define TEXPREF_LINEAR 0x0002 // force linear
|
||||
#define TEXPREF_NEAREST 0x0004 // force nearest
|
||||
#define TEXPREF_ALPHA 0x0008 // allow alpha
|
||||
#define TEXPREF_PAD 0x0010 // allow padding
|
||||
#define TEXPREF_PERSIST 0x0020 // never free
|
||||
#define TEXPREF_OVERWRITE 0x0040 // overwrite existing same-name texture
|
||||
#define TEXPREF_NOPICMIP 0x0080 // always load full-sized
|
||||
#define TEXPREF_FULLBRIGHT 0x0100 // use fullbright mask palette
|
||||
#define TEXPREF_NOBRIGHT 0x0200 // use nobright mask palette
|
||||
#define TEXPREF_CONCHARS 0x0400 // use conchars palette
|
||||
#define TEXPREF_WARPIMAGE 0x0800 // resize this texture when warpimagesize changes
|
||||
|
||||
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;
|
||||
qmodel_t *owner;
|
||||
GLuint texnum;
|
||||
struct gltexture_s *next;
|
||||
qmodel_t *owner;
|
||||
//managed by image loading
|
||||
char name[64];
|
||||
uint32_t width; //size of image as it exists in opengl
|
||||
uint32_t height; //size of image as it exists in opengl
|
||||
uint32_t flags;
|
||||
char source_file[MAX_QPATH]; //relative filepath to data source, or "" if source is in memory
|
||||
src_offset_t source_offset; //byte offset into file, or memory address
|
||||
enum srcformat source_format; //format of pixel data (indexed, lightmap, or rgba)
|
||||
uint32_t source_width; //size of image in source data
|
||||
uint32_t source_height; //size of image in source data
|
||||
uint16_t source_crc; //generated by source data before modifications
|
||||
int8_t shirt; //0-13 shirt color, or -1 if never colormapped
|
||||
int8_t pants; //0-13 pants color, or -1 if never colormapped
|
||||
char name[64];
|
||||
uint32_t width; //size of image as it exists in opengl
|
||||
uint32_t height; //size of image as it exists in opengl
|
||||
uint32_t flags;
|
||||
char source_file[MAX_QPATH]; //relative filepath to data source, or "" if source is in memory
|
||||
src_offset_t source_offset; //byte offset into file, or memory address
|
||||
enum srcformat source_format; //format of pixel data (indexed, lightmap, or rgba)
|
||||
uint32_t source_width; //size of image in source data
|
||||
uint32_t source_height; //size of image in source data
|
||||
uint16_t source_crc; //generated by source data before modifications
|
||||
int8_t shirt; //0-13 shirt color, or -1 if never colormapped
|
||||
int8_t pants; //0-13 pants color, or -1 if never colormapped
|
||||
//used for rendering
|
||||
int32_t visframe; //matches r_framecount if texture was bound this frame
|
||||
int32_t visframe; //matches r_framecount if texture was bound this frame
|
||||
} gltexture_t;
|
||||
|
||||
extern gltexture_t *notexture;
|
||||
|
@ -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,
|
||||
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);
|
||||
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);
|
||||
|
||||
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 */
|
||||
#endif /* _GL_TEXMAN_H */
|
||||
|
||||
|
|
1151
source/gl_vidsdl.c
1151
source/gl_vidsdl.c
File diff suppressed because it is too large
Load Diff
174
source/gl_warp.c
174
source/gl_warp.c
|
@ -31,7 +31,7 @@ cvar_t r_waterwarp = {"r_waterwarp", "1", CVAR_NONE};
|
|||
int32_t gl_warpimagesize;
|
||||
float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
|
||||
|
||||
float turbsin[] =
|
||||
float turbsin[] =
|
||||
{
|
||||
#include "gl_warp_sin.h"
|
||||
};
|
||||
|
@ -45,108 +45,108 @@ float turbsin[] =
|
|||
//
|
||||
//==============================================================================
|
||||
|
||||
extern qmodel_t *loadmodel;
|
||||
extern qmodel_t *loadmodel;
|
||||
|
||||
msurface_t *warpface;
|
||||
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;
|
||||
int32_t i, j;
|
||||
float *v;
|
||||
|
||||
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;
|
||||
float m;
|
||||
float *v;
|
||||
vec3_t front[64], back[64];
|
||||
int32_t f, b;
|
||||
float dist[64];
|
||||
float frac;
|
||||
glpoly_t *poly;
|
||||
float s, t;
|
||||
int32_t i, j, k;
|
||||
vec3_t mins, maxs;
|
||||
float m;
|
||||
float *v;
|
||||
vec3_t front[64], back[64];
|
||||
int32_t f, b;
|
||||
float dist[64];
|
||||
float frac;
|
||||
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,19 +157,19 @@ 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;
|
||||
vec3_t verts[64];
|
||||
int32_t i;
|
||||
|
||||
warpface = 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;
|
||||
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,68 +17,68 @@
|
|||
* 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,
|
||||
-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,
|
||||
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,
|
||||
-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,
|
||||
|
||||
|
|
412
source/glquake.h
412
source/glquake.h
|
@ -24,35 +24,36 @@ 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;
|
||||
extern int32_t glx, gly, glwidth, glheight;
|
||||
|
||||
#define GL_UNUSED_TEXTURE (~(GLuint)0)
|
||||
#define GL_UNUSED_TEXTURE (~(GLuint)0)
|
||||
|
||||
// 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
|
||||
#define MAX_LBM_HEIGHT 480
|
||||
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
|
||||
// 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
|
||||
#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
|
||||
|
||||
#define SKYSHIFT 7
|
||||
#define SKYSIZE (1 << SKYSHIFT)
|
||||
#define SKYMASK (SKYSIZE - 1)
|
||||
#define SKYSHIFT 7
|
||||
#define SKYSIZE (1 << SKYSHIFT)
|
||||
#define SKYMASK (SKYSIZE - 1)
|
||||
|
||||
#define BACKFACE_EPSILON 0.01
|
||||
#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;
|
||||
|
||||
|
@ -60,87 +61,87 @@ typedef enum {
|
|||
typedef struct particle_s
|
||||
{
|
||||
// driver-usable fields
|
||||
vec3_t org;
|
||||
float color;
|
||||
vec3_t org;
|
||||
float color;
|
||||
// drivers never touch the following fields
|
||||
struct particle_s *next;
|
||||
vec3_t vel;
|
||||
float ramp;
|
||||
float die;
|
||||
ptype_t type;
|
||||
struct particle_s *next;
|
||||
vec3_t vel;
|
||||
float ramp;
|
||||
float die;
|
||||
ptype_t type;
|
||||
} particle_t;
|
||||
|
||||
|
||||
//====================================================
|
||||
|
||||
extern bool r_cache_thrash; // compatability
|
||||
extern vec3_t modelorg, r_entorigin;
|
||||
extern entity_t *currententity;
|
||||
extern int32_t r_visframecount; // ??? what difs?
|
||||
extern int32_t r_framecount;
|
||||
extern mplane_t frustum[4];
|
||||
extern bool r_cache_thrash; // compatability
|
||||
extern vec3_t modelorg, r_entorigin;
|
||||
extern entity_t *currententity;
|
||||
extern int32_t r_visframecount; // ??? what difs?
|
||||
extern int32_t r_framecount;
|
||||
extern mplane_t frustum[4];
|
||||
|
||||
//
|
||||
// view origin
|
||||
//
|
||||
extern vec3_t vup;
|
||||
extern vec3_t vpn;
|
||||
extern vec3_t vright;
|
||||
extern vec3_t r_origin;
|
||||
extern vec3_t vup;
|
||||
extern vec3_t vpn;
|
||||
extern vec3_t vright;
|
||||
extern vec3_t r_origin;
|
||||
|
||||
//
|
||||
// screen size info
|
||||
//
|
||||
extern refdef_t r_refdef;
|
||||
extern mleaf_t *r_viewleaf, *r_oldviewleaf;
|
||||
extern int32_t d_lightstylevalue[256]; // 8.8 fraction of base light value
|
||||
extern refdef_t r_refdef;
|
||||
extern mleaf_t *r_viewleaf, *r_oldviewleaf;
|
||||
extern int32_t d_lightstylevalue[256]; // 8.8 fraction of base light value
|
||||
|
||||
extern cvar_t r_norefresh;
|
||||
extern cvar_t r_drawentities;
|
||||
extern cvar_t r_drawworld;
|
||||
extern cvar_t r_drawviewmodel;
|
||||
extern cvar_t r_speeds;
|
||||
extern cvar_t r_pos;
|
||||
extern cvar_t r_waterwarp;
|
||||
extern cvar_t r_fullbright;
|
||||
extern cvar_t r_lightmap;
|
||||
extern cvar_t r_shadows;
|
||||
extern cvar_t r_wateralpha;
|
||||
extern cvar_t r_lavaalpha;
|
||||
extern cvar_t r_telealpha;
|
||||
extern cvar_t r_slimealpha;
|
||||
extern cvar_t r_dynamic;
|
||||
extern cvar_t r_novis;
|
||||
extern cvar_t r_scale;
|
||||
extern cvar_t r_norefresh;
|
||||
extern cvar_t r_drawentities;
|
||||
extern cvar_t r_drawworld;
|
||||
extern cvar_t r_drawviewmodel;
|
||||
extern cvar_t r_speeds;
|
||||
extern cvar_t r_pos;
|
||||
extern cvar_t r_waterwarp;
|
||||
extern cvar_t r_fullbright;
|
||||
extern cvar_t r_lightmap;
|
||||
extern cvar_t r_shadows;
|
||||
extern cvar_t r_wateralpha;
|
||||
extern cvar_t r_lavaalpha;
|
||||
extern cvar_t r_telealpha;
|
||||
extern cvar_t r_slimealpha;
|
||||
extern cvar_t r_dynamic;
|
||||
extern cvar_t r_novis;
|
||||
extern cvar_t r_scale;
|
||||
|
||||
extern cvar_t gl_clear;
|
||||
extern cvar_t gl_cull;
|
||||
extern cvar_t gl_smoothmodels;
|
||||
extern cvar_t gl_affinemodels;
|
||||
extern cvar_t gl_polyblend;
|
||||
extern cvar_t gl_flashblend;
|
||||
extern cvar_t gl_nocolors;
|
||||
extern cvar_t gl_clear;
|
||||
extern cvar_t gl_cull;
|
||||
extern cvar_t gl_smoothmodels;
|
||||
extern cvar_t gl_affinemodels;
|
||||
extern cvar_t gl_polyblend;
|
||||
extern cvar_t gl_flashblend;
|
||||
extern cvar_t gl_nocolors;
|
||||
|
||||
extern cvar_t gl_playermip;
|
||||
extern cvar_t gl_playermip;
|
||||
|
||||
extern cvar_t gl_subdivide_size;
|
||||
extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
|
||||
extern cvar_t gl_subdivide_size;
|
||||
extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
|
||||
|
||||
extern int32_t gl_stencilbits;
|
||||
extern int32_t gl_stencilbits;
|
||||
|
||||
// Multitexture
|
||||
extern bool mtexenabled;
|
||||
extern bool gl_mtexable;
|
||||
extern bool mtexenabled;
|
||||
extern bool gl_mtexable;
|
||||
extern PFNGLMULTITEXCOORD2FARBPROC GL_MTexCoord2fFunc;
|
||||
extern PFNGLACTIVETEXTUREARBPROC GL_SelectTextureFunc;
|
||||
extern PFNGLCLIENTACTIVETEXTUREARBPROC GL_ClientActiveTextureFunc;
|
||||
extern GLint gl_max_texture_units; //ericw
|
||||
extern PFNGLCLIENTACTIVETEXTUREARBPROC GL_ClientActiveTextureFunc;
|
||||
extern GLint gl_max_texture_units; //ericw
|
||||
|
||||
//johnfitz -- anisotropic filtering
|
||||
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
extern float gl_max_anisotropy;
|
||||
extern bool gl_anisotropy_able;
|
||||
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
extern float gl_max_anisotropy;
|
||||
extern bool gl_anisotropy_able;
|
||||
|
||||
//ericw -- VBO
|
||||
extern PFNGLBINDBUFFERARBPROC GL_BindBufferFunc;
|
||||
|
@ -148,35 +149,35 @@ extern PFNGLBUFFERDATAARBPROC GL_BufferDataFunc;
|
|||
extern PFNGLBUFFERSUBDATAARBPROC GL_BufferSubDataFunc;
|
||||
extern PFNGLDELETEBUFFERSARBPROC GL_DeleteBuffersFunc;
|
||||
extern PFNGLGENBUFFERSARBPROC GL_GenBuffersFunc;
|
||||
extern bool gl_vbo_able;
|
||||
extern bool gl_vbo_able;
|
||||
//ericw
|
||||
|
||||
//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;
|
||||
|
@ -201,13 +202,13 @@ extern QS_PFNGLUNIFORM1IPROC GL_Uniform1iFunc;
|
|||
extern QS_PFNGLUNIFORM1FPROC GL_Uniform1fFunc;
|
||||
extern QS_PFNGLUNIFORM3FPROC GL_Uniform3fFunc;
|
||||
extern QS_PFNGLUNIFORM4FPROC GL_Uniform4fFunc;
|
||||
extern bool gl_glsl_able;
|
||||
extern bool gl_glsl_gamma_able;
|
||||
extern bool gl_glsl_alias_able;
|
||||
extern bool gl_glsl_able;
|
||||
extern bool gl_glsl_gamma_able;
|
||||
extern bool gl_glsl_alias_able;
|
||||
// ericw --
|
||||
|
||||
//ericw -- NPOT texture support
|
||||
extern bool gl_texture_NPOT;
|
||||
extern bool gl_texture_NPOT;
|
||||
|
||||
//johnfitz -- polygon offset
|
||||
#define OFFSET_BMODEL 1
|
||||
|
@ -215,21 +216,21 @@ 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
|
||||
#define GL_COMBINE_EXT 0x8570
|
||||
#define GL_COMBINE_RGB_EXT 0x8571
|
||||
#define GL_COMBINE_ALPHA_EXT 0x8572
|
||||
#define GL_RGB_SCALE_EXT 0x8573
|
||||
#define GL_CONSTANT_EXT 0x8576
|
||||
#define GL_PRIMARY_COLOR_EXT 0x8577
|
||||
#define GL_PREVIOUS_EXT 0x8578
|
||||
#define GL_SOURCE0_RGB_EXT 0x8580
|
||||
#define GL_SOURCE1_RGB_EXT 0x8581
|
||||
#define GL_SOURCE0_ALPHA_EXT 0x8588
|
||||
#define GL_SOURCE1_ALPHA_EXT 0x8589
|
||||
#define GL_COMBINE_EXT 0x8570
|
||||
#define GL_COMBINE_RGB_EXT 0x8571
|
||||
#define GL_COMBINE_ALPHA_EXT 0x8572
|
||||
#define GL_RGB_SCALE_EXT 0x8573
|
||||
#define GL_CONSTANT_EXT 0x8576
|
||||
#define GL_PRIMARY_COLOR_EXT 0x8577
|
||||
#define GL_PREVIOUS_EXT 0x8578
|
||||
#define GL_SOURCE0_RGB_EXT 0x8580
|
||||
#define GL_SOURCE1_RGB_EXT 0x8581
|
||||
#define GL_SOURCE0_ALPHA_EXT 0x8588
|
||||
#define GL_SOURCE1_ALPHA_EXT 0x8589
|
||||
extern bool gl_texture_env_combine;
|
||||
extern bool gl_texture_env_add; // for GL_EXT_texture_env_add
|
||||
|
||||
|
@ -240,23 +241,25 @@ extern float rs_megatexels;
|
|||
|
||||
//johnfitz -- track developer statistics that vary every frame
|
||||
extern cvar_t devstats;
|
||||
typedef struct {
|
||||
int32_t packetsize;
|
||||
int32_t edicts;
|
||||
int32_t visedicts;
|
||||
int32_t efrags;
|
||||
int32_t tempents;
|
||||
int32_t beams;
|
||||
int32_t dlights;
|
||||
typedef struct
|
||||
{
|
||||
int32_t packetsize;
|
||||
int32_t edicts;
|
||||
int32_t visedicts;
|
||||
int32_t efrags;
|
||||
int32_t tempents;
|
||||
int32_t beams;
|
||||
int32_t dlights;
|
||||
} devstats_t;
|
||||
extern devstats_t dev_stats, dev_peakstats;
|
||||
|
||||
//ohnfitz -- reduce overflow warning spam
|
||||
typedef struct {
|
||||
double packetsize;
|
||||
double efrags;
|
||||
double beams;
|
||||
double varstring;
|
||||
typedef struct
|
||||
{
|
||||
double packetsize;
|
||||
double efrags;
|
||||
double beams;
|
||||
double varstring;
|
||||
} overflowtimes_t;
|
||||
extern overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured
|
||||
#define CONSOLE_RESPAM_TIME 3 // seconds between repeated warning messages
|
||||
|
@ -270,107 +273,108 @@ 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;
|
||||
|
||||
extern float map_wateralpha, map_lavaalpha, map_telealpha, map_slimealpha; //ericw
|
||||
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 */
|
||||
#endif /* __GLQUAKE_H */
|
||||
|
||||
|
|
720
source/host.c
720
source/host.c
File diff suppressed because it is too large
Load Diff
1649
source/host_cmd.c
1649
source/host_cmd.c
File diff suppressed because it is too large
Load Diff
345
source/image.c
345
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;
|
||||
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,38 +102,39 @@ byte *Image_LoadImage (const char *name, int32_t *width, int32_t *height)
|
|||
//
|
||||
//==============================================================================
|
||||
|
||||
typedef struct targaheader_s {
|
||||
uint8_t id_length, colormap_type, image_type;
|
||||
uint16_t colormap_index, colormap_length;
|
||||
uint8_t colormap_size;
|
||||
uint16_t x_origin, y_origin, width, height;
|
||||
uint8_t pixel_size, attributes;
|
||||
typedef struct targaheader_s
|
||||
{
|
||||
uint8_t id_length, colormap_type, image_type;
|
||||
uint16_t colormap_index, colormap_length;
|
||||
uint8_t colormap_size;
|
||||
uint16_t x_origin, y_origin, width, height;
|
||||
uint8_t pixel_size, attributes;
|
||||
} targaheader_t;
|
||||
|
||||
#define TARGAHEADERSIZE 18 //size on disk
|
||||
|
||||
targaheader_t targa_header;
|
||||
|
||||
int32_t fgetLittleShort (FILE *f)
|
||||
int32_t fgetLittleShort(FILE *f)
|
||||
{
|
||||
byte b1, b2;
|
||||
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;
|
||||
byte b1, b2, b3, b4;
|
||||
|
||||
b1 = fgetc(f);
|
||||
b2 = fgetc(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];
|
||||
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,15 +190,15 @@ 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;
|
||||
int32_t row, column;
|
||||
byte *targa_rgba;
|
||||
int32_t realrow; //johnfitz -- fix for upside-down targas
|
||||
bool upside_down; //johnfitz -- fix for upside-down targas
|
||||
stdio_buffer_t *buf;
|
||||
int32_t columns, rows, numPixels;
|
||||
byte *pixbuf;
|
||||
int32_t row, column;
|
||||
byte *targa_rgba;
|
||||
int32_t realrow; //johnfitz -- fix for upside-down targas
|
||||
bool upside_down; //johnfitz -- fix for upside-down targas
|
||||
stdio_buffer_t *buf;
|
||||
|
||||
targa_header.id_length = fgetc(fin);
|
||||
targa_header.colormap_type = fgetc(fin);
|
||||
|
@ -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:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,18 +387,18 @@ byte *Image_LoadTGA (FILE *fin, int32_t *width, int32_t *height)
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int8_t signature;
|
||||
int8_t version;
|
||||
int8_t encoding;
|
||||
int8_t bits_per_pixel;
|
||||
uint16_t xmin,ymin,xmax,ymax;
|
||||
uint16_t hdpi,vdpi;
|
||||
uint8_t colortable[48];
|
||||
int8_t reserved;
|
||||
int8_t color_planes;
|
||||
uint16_t bytes_per_line;
|
||||
uint16_t palette_type;
|
||||
uint8_t filler[58];
|
||||
int8_t signature;
|
||||
int8_t version;
|
||||
int8_t encoding;
|
||||
int8_t bits_per_pixel;
|
||||
uint16_t xmin, ymin, xmax, ymax;
|
||||
uint16_t hdpi, vdpi;
|
||||
uint8_t colortable[48];
|
||||
int8_t reserved;
|
||||
int8_t color_planes;
|
||||
uint16_t bytes_per_line;
|
||||
uint16_t palette_type;
|
||||
uint8_t filler[58];
|
||||
} pcxheader_t;
|
||||
|
||||
/*
|
||||
|
@ -403,51 +406,51 @@ 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;
|
||||
byte *p, *data;
|
||||
byte palette[768];
|
||||
pcxheader_t pcx;
|
||||
int32_t x, y, w, h, readbyte, runlength, start;
|
||||
byte *p, *data;
|
||||
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++;
|
||||
|
@ -487,15 +490,15 @@ byte *Image_LoadPCX (FILE *f, int32_t *width, int32_t *height)
|
|||
|
||||
static byte *CopyFlipped(const byte *data, int32_t width, int32_t height, int32_t bpp)
|
||||
{
|
||||
int32_t y, rowsize;
|
||||
byte *flipped;
|
||||
int32_t y, rowsize;
|
||||
byte *flipped;
|
||||
|
||||
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,60 +512,60 @@ 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;
|
||||
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];
|
||||
byte *flipped;
|
||||
uint8_t *filters;
|
||||
uint8_t *png;
|
||||
size_t pngsize;
|
||||
LodePNGState state;
|
||||
char pathname[MAX_OSPATH];
|
||||
byte *flipped;
|
||||
uint8_t *filters;
|
||||
uint8_t *png;
|
||||
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 */
|
||||
#endif /* GL_IMAGE_H */
|
||||
|
||||
|
|
612
source/in_sdl.c
612
source/in_sdl.c
File diff suppressed because it is too large
Load Diff
|
@ -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 */
|
||||
#endif /* _QUAKE_INPUT_H */
|
||||
|
||||
|
|
559
source/keys.c
559
source/keys.c
File diff suppressed because it is too large
Load Diff
262
source/keys.h
262
source/keys.h
|
@ -26,175 +26,175 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
// these are the key numbers that should be passed to Key_Event
|
||||
//
|
||||
#define K_TAB 9
|
||||
#define K_ENTER 13
|
||||
#define K_ESCAPE 27
|
||||
#define K_SPACE 32
|
||||
#define K_TAB 9
|
||||
#define K_ENTER 13
|
||||
#define K_ESCAPE 27
|
||||
#define K_SPACE 32
|
||||
|
||||
// normal keys should be passed as lowercased ascii
|
||||
|
||||
#define K_BACKSPACE 127
|
||||
#define K_UPARROW 128
|
||||
#define K_DOWNARROW 129
|
||||
#define K_LEFTARROW 130
|
||||
#define K_RIGHTARROW 131
|
||||
#define K_BACKSPACE 127
|
||||
#define K_UPARROW 128
|
||||
#define K_DOWNARROW 129
|
||||
#define K_LEFTARROW 130
|
||||
#define K_RIGHTARROW 131
|
||||
|
||||
#define K_ALT 132
|
||||
#define K_CTRL 133
|
||||
#define K_SHIFT 134
|
||||
#define K_F1 135
|
||||
#define K_F2 136
|
||||
#define K_F3 137
|
||||
#define K_F4 138
|
||||
#define K_F5 139
|
||||
#define K_F6 140
|
||||
#define K_F7 141
|
||||
#define K_F8 142
|
||||
#define K_F9 143
|
||||
#define K_F10 144
|
||||
#define K_F11 145
|
||||
#define K_F12 146
|
||||
#define K_INS 147
|
||||
#define K_DEL 148
|
||||
#define K_PGDN 149
|
||||
#define K_PGUP 150
|
||||
#define K_HOME 151
|
||||
#define K_END 152
|
||||
#define K_ALT 132
|
||||
#define K_CTRL 133
|
||||
#define K_SHIFT 134
|
||||
#define K_F1 135
|
||||
#define K_F2 136
|
||||
#define K_F3 137
|
||||
#define K_F4 138
|
||||
#define K_F5 139
|
||||
#define K_F6 140
|
||||
#define K_F7 141
|
||||
#define K_F8 142
|
||||
#define K_F9 143
|
||||
#define K_F10 144
|
||||
#define K_F11 145
|
||||
#define K_F12 146
|
||||
#define K_INS 147
|
||||
#define K_DEL 148
|
||||
#define K_PGDN 149
|
||||
#define K_PGUP 150
|
||||
#define K_HOME 151
|
||||
#define K_END 152
|
||||
|
||||
#define K_KP_NUMLOCK 153
|
||||
#define K_KP_SLASH 154
|
||||
#define K_KP_STAR 155
|
||||
#define K_KP_MINUS 156
|
||||
#define K_KP_HOME 157
|
||||
#define K_KP_UPARROW 158
|
||||
#define K_KP_PGUP 159
|
||||
#define K_KP_PLUS 160
|
||||
#define K_KP_LEFTARROW 161
|
||||
#define K_KP_5 162
|
||||
#define K_KP_RIGHTARROW 163
|
||||
#define K_KP_END 164
|
||||
#define K_KP_DOWNARROW 165
|
||||
#define K_KP_PGDN 166
|
||||
#define K_KP_ENTER 167
|
||||
#define K_KP_INS 168
|
||||
#define K_KP_DEL 169
|
||||
#define K_KP_NUMLOCK 153
|
||||
#define K_KP_SLASH 154
|
||||
#define K_KP_STAR 155
|
||||
#define K_KP_MINUS 156
|
||||
#define K_KP_HOME 157
|
||||
#define K_KP_UPARROW 158
|
||||
#define K_KP_PGUP 159
|
||||
#define K_KP_PLUS 160
|
||||
#define K_KP_LEFTARROW 161
|
||||
#define K_KP_5 162
|
||||
#define K_KP_RIGHTARROW 163
|
||||
#define K_KP_END 164
|
||||
#define K_KP_DOWNARROW 165
|
||||
#define K_KP_PGDN 166
|
||||
#define K_KP_ENTER 167
|
||||
#define K_KP_INS 168
|
||||
#define K_KP_DEL 169
|
||||
|
||||
#define K_COMMAND 170
|
||||
#define K_COMMAND 170
|
||||
|
||||
#define K_PAUSE 255
|
||||
#define K_PAUSE 255
|
||||
|
||||
//
|
||||
// mouse buttons generate virtual keys
|
||||
//
|
||||
#define K_MOUSE1 200
|
||||
#define K_MOUSE2 201
|
||||
#define K_MOUSE3 202
|
||||
#define K_MOUSE1 200
|
||||
#define K_MOUSE2 201
|
||||
#define K_MOUSE3 202
|
||||
|
||||
//
|
||||
// joystick buttons
|
||||
//
|
||||
#define K_JOY1 203
|
||||
#define K_JOY2 204
|
||||
#define K_JOY3 205
|
||||
#define K_JOY4 206
|
||||
#define K_JOY1 203
|
||||
#define K_JOY2 204
|
||||
#define K_JOY3 205
|
||||
#define K_JOY4 206
|
||||
// aux keys are for multi-buttoned joysticks to generate so they can use
|
||||
// the normal binding process
|
||||
// aux29-32: reserved for the HAT (POV) switch motion
|
||||
#define K_AUX1 207
|
||||
#define K_AUX2 208
|
||||
#define K_AUX3 209
|
||||
#define K_AUX4 210
|
||||
#define K_AUX5 211
|
||||
#define K_AUX6 212
|
||||
#define K_AUX7 213
|
||||
#define K_AUX8 214
|
||||
#define K_AUX9 215
|
||||
#define K_AUX10 216
|
||||
#define K_AUX11 217
|
||||
#define K_AUX12 218
|
||||
#define K_AUX13 219
|
||||
#define K_AUX14 220
|
||||
#define K_AUX15 221
|
||||
#define K_AUX16 222
|
||||
#define K_AUX17 223
|
||||
#define K_AUX18 224
|
||||
#define K_AUX19 225
|
||||
#define K_AUX20 226
|
||||
#define K_AUX21 227
|
||||
#define K_AUX22 228
|
||||
#define K_AUX23 229
|
||||
#define K_AUX24 230
|
||||
#define K_AUX25 231
|
||||
#define K_AUX26 232
|
||||
#define K_AUX27 233
|
||||
#define K_AUX28 234
|
||||
#define K_AUX29 235
|
||||
#define K_AUX30 236
|
||||
#define K_AUX31 237
|
||||
#define K_AUX32 238
|
||||
#define K_AUX1 207
|
||||
#define K_AUX2 208
|
||||
#define K_AUX3 209
|
||||
#define K_AUX4 210
|
||||
#define K_AUX5 211
|
||||
#define K_AUX6 212
|
||||
#define K_AUX7 213
|
||||
#define K_AUX8 214
|
||||
#define K_AUX9 215
|
||||
#define K_AUX10 216
|
||||
#define K_AUX11 217
|
||||
#define K_AUX12 218
|
||||
#define K_AUX13 219
|
||||
#define K_AUX14 220
|
||||
#define K_AUX15 221
|
||||
#define K_AUX16 222
|
||||
#define K_AUX17 223
|
||||
#define K_AUX18 224
|
||||
#define K_AUX19 225
|
||||
#define K_AUX20 226
|
||||
#define K_AUX21 227
|
||||
#define K_AUX22 228
|
||||
#define K_AUX23 229
|
||||
#define K_AUX24 230
|
||||
#define K_AUX25 231
|
||||
#define K_AUX26 232
|
||||
#define K_AUX27 233
|
||||
#define K_AUX28 234
|
||||
#define K_AUX29 235
|
||||
#define K_AUX30 236
|
||||
#define K_AUX31 237
|
||||
#define K_AUX32 238
|
||||
|
||||
// JACK: Intellimouse(c) Mouse Wheel Support
|
||||
|
||||
#define K_MWHEELUP 239
|
||||
#define K_MWHEELDOWN 240
|
||||
#define K_MWHEELUP 239
|
||||
#define K_MWHEELDOWN 240
|
||||
|
||||
// thumb buttons
|
||||
#define K_MOUSE4 241
|
||||
#define K_MOUSE5 242
|
||||
#define K_MOUSE4 241
|
||||
#define K_MOUSE5 242
|
||||
|
||||
// SDL2 game controller keys
|
||||
#define K_LTHUMB 243
|
||||
#define K_RTHUMB 244
|
||||
#define K_LSHOULDER 245
|
||||
#define K_RSHOULDER 246
|
||||
#define K_ABUTTON 247
|
||||
#define K_BBUTTON 248
|
||||
#define K_XBUTTON 249
|
||||
#define K_YBUTTON 250
|
||||
#define K_LTRIGGER 251
|
||||
#define K_RTRIGGER 252
|
||||
#define K_LTHUMB 243
|
||||
#define K_RTHUMB 244
|
||||
#define K_LSHOULDER 245
|
||||
#define K_RSHOULDER 246
|
||||
#define K_ABUTTON 247
|
||||
#define K_BBUTTON 248
|
||||
#define K_XBUTTON 249
|
||||
#define K_YBUTTON 250
|
||||
#define K_LTRIGGER 251
|
||||
#define K_RTRIGGER 252
|
||||
|
||||
#define MAX_KEYS 256
|
||||
#define MAX_KEYS 256
|
||||
|
||||
#define MAXCMDLINE 256
|
||||
#define MAXCMDLINE 256
|
||||
|
||||
typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
|
||||
|
||||
extern keydest_t key_dest;
|
||||
extern char *keybindings[MAX_KEYS];
|
||||
extern keydest_t key_dest;
|
||||
extern char *keybindings[MAX_KEYS];
|
||||
|
||||
#define CMDLINES 64
|
||||
#define CMDLINES 64
|
||||
|
||||
extern char key_lines[CMDLINES][MAXCMDLINE];
|
||||
extern int32_t edit_line;
|
||||
extern int32_t key_linepos;
|
||||
extern int32_t key_insert;
|
||||
extern double key_blinktime;
|
||||
extern char key_lines[CMDLINES][MAXCMDLINE];
|
||||
extern int32_t edit_line;
|
||||
extern int32_t key_linepos;
|
||||
extern int32_t key_insert;
|
||||
extern double key_blinktime;
|
||||
|
||||
extern bool chat_team;
|
||||
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 */
|
||||
#endif /* _QUAKE_KEYS_H */
|
||||
|
||||
|
|
|
@ -29,18 +29,18 @@ static const Uint8 bmp_bytes[] =
|
|||
#include "qs_bmp.h"
|
||||
};
|
||||
|
||||
void PL_SetWindowIcon (void)
|
||||
void PL_SetWindowIcon(void)
|
||||
{
|
||||
SDL_RWops *rwop;
|
||||
SDL_Surface *icon;
|
||||
Uint32 colorkey;
|
||||
SDL_RWops *rwop;
|
||||
SDL_Surface *icon;
|
||||
Uint32 colorkey;
|
||||
|
||||
/* 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,32 +49,32 @@ 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)
|
||||
#define MAX_CLIPBOARDTXT MAXCMDLINE /* 256 */
|
||||
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
|
||||
* such as an ip address, etc: do chop the size
|
||||
* here, otherwise we may experience Z_Malloc()
|
||||
* failures and all other not-oh-so-fun stuff. */
|
||||
/* this is intended for simple small text copies
|
||||
* such as an ip address, etc: do chop the size
|
||||
* here, otherwise we may experience Z_Malloc()
|
||||
* 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;
|
||||
}
|
||||
|
|
8463
source/lodepng.c
8463
source/lodepng.c
File diff suppressed because it is too large
Load Diff
390
source/lodepng.h
390
source/lodepng.h
|
@ -90,11 +90,11 @@ source files with custom allocators.*/
|
|||
/*The PNG color types (also used for raw).*/
|
||||
typedef enum LodePNGColorType
|
||||
{
|
||||
LCT_GREY = 0, /*greyscale: 1,2,4,8,16 bit*/
|
||||
LCT_RGB = 2, /*RGB: 8,16 bit*/
|
||||
LCT_PALETTE = 3, /*palette: 1,2,4,8 bit*/
|
||||
LCT_GREY_ALPHA = 4, /*greyscale with alpha: 8,16 bit*/
|
||||
LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/
|
||||
LCT_GREY = 0, /*greyscale: 1,2,4,8,16 bit*/
|
||||
LCT_RGB = 2, /*RGB: 8,16 bit*/
|
||||
LCT_PALETTE = 3, /*palette: 1,2,4,8 bit*/
|
||||
LCT_GREY_ALPHA = 4, /*greyscale with alpha: 8,16 bit*/
|
||||
LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/
|
||||
} LodePNGColorType;
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
|
@ -255,21 +255,21 @@ const char* lodepng_error_text(unsigned code);
|
|||
typedef struct LodePNGDecompressSettings LodePNGDecompressSettings;
|
||||
struct LodePNGDecompressSettings
|
||||
{
|
||||
/* Check LodePNGDecoderSettings for more ignorable errors */
|
||||
unsigned ignore_adler32; /*if 1, continue and don't give an error message if the Adler32 checksum is corrupted*/
|
||||
/* Check LodePNGDecoderSettings for more ignorable errors */
|
||||
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*,
|
||||
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*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
/*use custom zlib decoder instead of built in one (default: null)*/
|
||||
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*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
|
||||
const void* custom_context; /*optional custom settings for custom functions*/
|
||||
const void* custom_context; /*optional custom settings for custom functions*/
|
||||
};
|
||||
|
||||
extern const LodePNGDecompressSettings lodepng_default_decompress_settings;
|
||||
|
@ -284,26 +284,26 @@ between speed and compression ratio.
|
|||
typedef struct LodePNGCompressSettings LodePNGCompressSettings;
|
||||
struct LodePNGCompressSettings /*deflate = compress*/
|
||||
{
|
||||
/*LZ77 related settings*/
|
||||
unsigned btype; /*the block type for LZ (0, 1, 2 or 3, see zlib standard). Should be 2 for proper compression.*/
|
||||
unsigned use_lz77; /*whether or not to use LZ77. Should be 1 for proper compression.*/
|
||||
unsigned windowsize; /*must be a power of two <= 32768. higher compresses more but is slower. Default value: 2048.*/
|
||||
unsigned minmatch; /*mininum lz77 length. 3 is normally best, 6 can be better for some PNGs. Default: 0*/
|
||||
unsigned nicematch; /*stop searching if >= this length found. Set to 258 for best compression. Default: 128*/
|
||||
unsigned lazymatching; /*use lazy matching: better compression but a bit slower. Default: true*/
|
||||
/*LZ77 related settings*/
|
||||
unsigned btype; /*the block type for LZ (0, 1, 2 or 3, see zlib standard). Should be 2 for proper compression.*/
|
||||
unsigned use_lz77; /*whether or not to use LZ77. Should be 1 for proper compression.*/
|
||||
unsigned windowsize; /*must be a power of two <= 32768. higher compresses more but is slower. Default value: 2048.*/
|
||||
unsigned minmatch; /*mininum lz77 length. 3 is normally best, 6 can be better for some PNGs. Default: 0*/
|
||||
unsigned nicematch; /*stop searching if >= this length found. Set to 258 for best compression. Default: 128*/
|
||||
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*,
|
||||
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*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGCompressSettings*);
|
||||
/*use custom zlib encoder instead of built in one (default: null)*/
|
||||
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*,
|
||||
const uint8_t*, size_t,
|
||||
const LodePNGCompressSettings*);
|
||||
|
||||
const void* custom_context; /*optional custom settings for custom functions*/
|
||||
const void* custom_context; /*optional custom settings for custom functions*/
|
||||
};
|
||||
|
||||
extern const LodePNGCompressSettings lodepng_default_compress_settings;
|
||||
|
@ -318,41 +318,41 @@ format, and is used both for PNG and raw image data in LodePNG.
|
|||
*/
|
||||
typedef struct LodePNGColorMode
|
||||
{
|
||||
/*header (IHDR)*/
|
||||
LodePNGColorType colortype; /*color type, see PNG standard or documentation further in this header file*/
|
||||
unsigned bitdepth; /*bits per sample, see PNG standard or documentation further in this header file*/
|
||||
/*header (IHDR)*/
|
||||
LodePNGColorType colortype; /*color type, see PNG standard or documentation further in this header file*/
|
||||
unsigned bitdepth; /*bits per sample, see PNG standard or documentation further in this header file*/
|
||||
|
||||
/*
|
||||
palette (PLTE and tRNS)
|
||||
/*
|
||||
palette (PLTE and tRNS)
|
||||
|
||||
Dynamically allocated with the colors of the palette, including alpha.
|
||||
When encoding a PNG, to store your colors in the palette of the LodePNGColorMode, first use
|
||||
lodepng_palette_clear, then for each color use lodepng_palette_add.
|
||||
If you encode an image without alpha with palette, don't forget to put value 255 in each A byte of the palette.
|
||||
Dynamically allocated with the colors of the palette, including alpha.
|
||||
When encoding a PNG, to store your colors in the palette of the LodePNGColorMode, first use
|
||||
lodepng_palette_clear, then for each color use lodepng_palette_add.
|
||||
If you encode an image without alpha with palette, don't forget to put value 255 in each A byte of the palette.
|
||||
|
||||
When decoding, by default you can ignore this palette, since LodePNG already
|
||||
fills the palette colors in the pixels of the raw RGBA output.
|
||||
When decoding, by default you can ignore this palette, since LodePNG already
|
||||
fills the palette colors in the pixels of the raw RGBA output.
|
||||
|
||||
The palette is only supported for color type 3.
|
||||
*/
|
||||
uint8_t* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/
|
||||
size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/
|
||||
The palette is only supported for color type 3.
|
||||
*/
|
||||
uint8_t* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/
|
||||
size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/
|
||||
|
||||
/*
|
||||
transparent color key (tRNS)
|
||||
/*
|
||||
transparent color key (tRNS)
|
||||
|
||||
This color uses the same bit depth as the bitdepth value in this struct, which can be 1-bit to 16-bit.
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same.
|
||||
This color uses the same bit depth as the bitdepth value in this struct, which can be 1-bit to 16-bit.
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same.
|
||||
|
||||
When decoding, by default you can ignore this information, since LodePNG sets
|
||||
pixels with this key to transparent already in the raw RGBA output.
|
||||
When decoding, by default you can ignore this information, since LodePNG sets
|
||||
pixels with this key to transparent already in the raw RGBA output.
|
||||
|
||||
The color key is only supported for color types 0 and 2.
|
||||
*/
|
||||
unsigned key_defined; /*is a transparent color key given? 0 = false, 1 = true*/
|
||||
unsigned key_r; /*red/greyscale component of color key*/
|
||||
unsigned key_g; /*green component of color key*/
|
||||
unsigned key_b; /*blue component of color key*/
|
||||
The color key is only supported for color types 0 and 2.
|
||||
*/
|
||||
unsigned key_defined; /*is a transparent color key given? 0 = false, 1 = true*/
|
||||
unsigned key_r; /*red/greyscale component of color key*/
|
||||
unsigned key_g; /*green component of color key*/
|
||||
unsigned key_b; /*blue component of color key*/
|
||||
} LodePNGColorMode;
|
||||
|
||||
/*init, cleanup and copy functions to use with this struct*/
|
||||
|
@ -395,90 +395,90 @@ size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* colo
|
|||
/*The information of a Time chunk in PNG.*/
|
||||
typedef struct LodePNGTime
|
||||
{
|
||||
unsigned year; /*2 bytes used (0-65535)*/
|
||||
unsigned month; /*1-12*/
|
||||
unsigned day; /*1-31*/
|
||||
unsigned hour; /*0-23*/
|
||||
unsigned minute; /*0-59*/
|
||||
unsigned second; /*0-60 (to allow for leap seconds)*/
|
||||
unsigned year; /*2 bytes used (0-65535)*/
|
||||
unsigned month; /*1-12*/
|
||||
unsigned day; /*1-31*/
|
||||
unsigned hour; /*0-23*/
|
||||
unsigned minute; /*0-59*/
|
||||
unsigned second; /*0-60 (to allow for leap seconds)*/
|
||||
} LodePNGTime;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
||||
/*Information about the PNG image, except pixels, width and height.*/
|
||||
typedef struct LodePNGInfo
|
||||
{
|
||||
/*header (IHDR), palette (PLTE) and transparency (tRNS) chunks*/
|
||||
unsigned compression_method;/*compression method of the original file. Always 0.*/
|
||||
unsigned filter_method; /*filter method of the original file*/
|
||||
unsigned interlace_method; /*interlace method of the original file*/
|
||||
LodePNGColorMode color; /*color type and bits, palette and transparency of the PNG file*/
|
||||
/*header (IHDR), palette (PLTE) and transparency (tRNS) chunks*/
|
||||
unsigned compression_method;/*compression method of the original file. Always 0.*/
|
||||
unsigned filter_method; /*filter method of the original file*/
|
||||
unsigned interlace_method; /*interlace method of the original file*/
|
||||
LodePNGColorMode color; /*color type and bits, palette and transparency of the PNG file*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
/*
|
||||
suggested background color chunk (bKGD)
|
||||
This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit.
|
||||
/*
|
||||
suggested background color chunk (bKGD)
|
||||
This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit.
|
||||
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same. When encoding
|
||||
the encoder writes the red one. For palette PNGs: When decoding, the RGB value
|
||||
will be stored, not a palette index. But when encoding, specify the index of
|
||||
the palette in background_r, the other two are then ignored.
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same. When encoding
|
||||
the encoder writes the red one. For palette PNGs: When decoding, the RGB value
|
||||
will be stored, not a palette index. But when encoding, specify the index of
|
||||
the palette in background_r, the other two are then ignored.
|
||||
|
||||
The decoder does not use this background color to edit the color of pixels.
|
||||
*/
|
||||
unsigned background_defined; /*is a suggested background color given?*/
|
||||
unsigned background_r; /*red component of suggested background color*/
|
||||
unsigned background_g; /*green component of suggested background color*/
|
||||
unsigned background_b; /*blue component of suggested background color*/
|
||||
The decoder does not use this background color to edit the color of pixels.
|
||||
*/
|
||||
unsigned background_defined; /*is a suggested background color given?*/
|
||||
unsigned background_r; /*red component of suggested background color*/
|
||||
unsigned background_g; /*green component of suggested background color*/
|
||||
unsigned background_b; /*blue component of suggested background color*/
|
||||
|
||||
/*
|
||||
non-international text chunks (tEXt and zTXt)
|
||||
/*
|
||||
non-international text chunks (tEXt and zTXt)
|
||||
|
||||
The char** arrays each contain num strings. The actual messages are in
|
||||
text_strings, while text_keys are keywords that give a short description what
|
||||
the actual text represents, e.g. Title, Author, Description, or anything else.
|
||||
The char** arrays each contain num strings. The actual messages are in
|
||||
text_strings, while text_keys are keywords that give a short description what
|
||||
the actual text represents, e.g. Title, Author, Description, or anything else.
|
||||
|
||||
A keyword is minimum 1 character and maximum 79 characters long. It's
|
||||
discouraged to use a single line length longer than 79 characters for texts.
|
||||
A keyword is minimum 1 character and maximum 79 characters long. It's
|
||||
discouraged to use a single line length longer than 79 characters for texts.
|
||||
|
||||
Don't allocate these text buffers yourself. Use the init/cleanup functions
|
||||
correctly and use lodepng_add_text and lodepng_clear_text.
|
||||
*/
|
||||
size_t text_num; /*the amount of texts in these char** buffers (there may be more texts in itext)*/
|
||||
char** text_keys; /*the keyword of a text chunk (e.g. "Comment")*/
|
||||
char** text_strings; /*the actual text*/
|
||||
Don't allocate these text buffers yourself. Use the init/cleanup functions
|
||||
correctly and use lodepng_add_text and lodepng_clear_text.
|
||||
*/
|
||||
size_t text_num; /*the amount of texts in these char** buffers (there may be more texts in itext)*/
|
||||
char** text_keys; /*the keyword of a text chunk (e.g. "Comment")*/
|
||||
char** text_strings; /*the actual text*/
|
||||
|
||||
/*
|
||||
international text chunks (iTXt)
|
||||
Similar to the non-international text chunks, but with additional strings
|
||||
"langtags" and "transkeys".
|
||||
*/
|
||||
size_t itext_num; /*the amount of international texts in this PNG*/
|
||||
char** itext_keys; /*the English keyword of the text chunk (e.g. "Comment")*/
|
||||
char** itext_langtags; /*language tag for this text's language, ISO/IEC 646 string, e.g. ISO 639 language tag*/
|
||||
char** itext_transkeys; /*keyword translated to the international language - UTF-8 string*/
|
||||
char** itext_strings; /*the actual international text - UTF-8 string*/
|
||||
/*
|
||||
international text chunks (iTXt)
|
||||
Similar to the non-international text chunks, but with additional strings
|
||||
"langtags" and "transkeys".
|
||||
*/
|
||||
size_t itext_num; /*the amount of international texts in this PNG*/
|
||||
char** itext_keys; /*the English keyword of the text chunk (e.g. "Comment")*/
|
||||
char** itext_langtags; /*language tag for this text's language, ISO/IEC 646 string, e.g. ISO 639 language tag*/
|
||||
char** itext_transkeys; /*keyword translated to the international language - UTF-8 string*/
|
||||
char** itext_strings; /*the actual international text - UTF-8 string*/
|
||||
|
||||
/*time chunk (tIME)*/
|
||||
unsigned time_defined; /*set to 1 to make the encoder generate a tIME chunk*/
|
||||
LodePNGTime time;
|
||||
/*time chunk (tIME)*/
|
||||
unsigned time_defined; /*set to 1 to make the encoder generate a tIME chunk*/
|
||||
LodePNGTime time;
|
||||
|
||||
/*phys chunk (pHYs)*/
|
||||
unsigned phys_defined; /*if 0, there is no pHYs chunk and the values below are undefined, if 1 else there is one*/
|
||||
unsigned phys_x; /*pixels per unit in x direction*/
|
||||
unsigned phys_y; /*pixels per unit in y direction*/
|
||||
unsigned phys_unit; /*may be 0 (unknown unit) or 1 (metre)*/
|
||||
/*phys chunk (pHYs)*/
|
||||
unsigned phys_defined; /*if 0, there is no pHYs chunk and the values below are undefined, if 1 else there is one*/
|
||||
unsigned phys_x; /*pixels per unit in x direction*/
|
||||
unsigned phys_y; /*pixels per unit in y direction*/
|
||||
unsigned phys_unit; /*may be 0 (unknown unit) or 1 (metre)*/
|
||||
|
||||
/*
|
||||
unknown chunks
|
||||
There are 3 buffers, one for each position in the PNG where unknown chunks can appear
|
||||
each buffer contains all unknown chunks for that position consecutively
|
||||
The 3 buffers are the unknown chunks between certain critical chunks:
|
||||
0: IHDR-PLTE, 1: PLTE-IDAT, 2: IDAT-IEND
|
||||
Do not allocate or traverse this data yourself. Use the chunk traversing functions declared
|
||||
later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.
|
||||
*/
|
||||
uint8_t* unknown_chunks_data[3];
|
||||
size_t unknown_chunks_size[3]; /*size in bytes of the unknown chunks, given for protection*/
|
||||
/*
|
||||
unknown chunks
|
||||
There are 3 buffers, one for each position in the PNG where unknown chunks can appear
|
||||
each buffer contains all unknown chunks for that position consecutively
|
||||
The 3 buffers are the unknown chunks between certain critical chunks:
|
||||
0: IHDR-PLTE, 1: PLTE-IDAT, 2: IDAT-IEND
|
||||
Do not allocate or traverse this data yourself. Use the chunk traversing functions declared
|
||||
later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.
|
||||
*/
|
||||
uint8_t* unknown_chunks_data[3];
|
||||
size_t unknown_chunks_size[3]; /*size in bytes of the unknown chunks, given for protection*/
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
} LodePNGInfo;
|
||||
|
||||
|
@ -519,19 +519,19 @@ decoder, but not the Info settings from the Info structs.
|
|||
*/
|
||||
typedef struct LodePNGDecoderSettings
|
||||
{
|
||||
LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/
|
||||
LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/
|
||||
|
||||
/* Check LodePNGDecompressSettings for more ignorable errors */
|
||||
unsigned ignore_crc; /*ignore CRC checksums*/
|
||||
unsigned ignore_critical; /*ignore unknown critical chunks*/
|
||||
unsigned ignore_end; /*ignore issues at end of file if possible (missing IEND chunk, too large chunk, ...)*/
|
||||
/* Check LodePNGDecompressSettings for more ignorable errors */
|
||||
unsigned ignore_crc; /*ignore CRC checksums*/
|
||||
unsigned ignore_critical; /*ignore unknown critical chunks*/
|
||||
unsigned ignore_end; /*ignore issues at end of file if possible (missing IEND chunk, too large chunk, ...)*/
|
||||
|
||||
unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/
|
||||
unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
unsigned read_text_chunks; /*if false but remember_unknown_chunks is true, they're stored in the unknown chunks*/
|
||||
/*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/
|
||||
unsigned remember_unknown_chunks;
|
||||
unsigned read_text_chunks; /*if false but remember_unknown_chunks is true, they're stored in the unknown chunks*/
|
||||
/*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/
|
||||
unsigned remember_unknown_chunks;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
} LodePNGDecoderSettings;
|
||||
|
||||
|
@ -542,35 +542,35 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);
|
|||
/*automatically use color type with less bits per pixel if losslessly possible. Default: AUTO*/
|
||||
typedef enum LodePNGFilterStrategy
|
||||
{
|
||||
/*every filter at zero*/
|
||||
LFS_ZERO,
|
||||
/*Use filter that gives minimum sum, as described in the official PNG filter heuristic.*/
|
||||
LFS_MINSUM,
|
||||
/*Use the filter type that gives smallest Shannon entropy for this scanline. Depending
|
||||
on the image, this is better or worse than minsum.*/
|
||||
LFS_ENTROPY,
|
||||
/*
|
||||
Brute-force-search PNG filters by compressing each filter for each scanline.
|
||||
Experimental, very slow, and only rarely gives better compression than MINSUM.
|
||||
*/
|
||||
LFS_BRUTE_FORCE,
|
||||
/*use predefined_filters buffer: you specify the filter type for each scanline*/
|
||||
LFS_PREDEFINED
|
||||
/*every filter at zero*/
|
||||
LFS_ZERO,
|
||||
/*Use filter that gives minimum sum, as described in the official PNG filter heuristic.*/
|
||||
LFS_MINSUM,
|
||||
/*Use the filter type that gives smallest Shannon entropy for this scanline. Depending
|
||||
on the image, this is better or worse than minsum.*/
|
||||
LFS_ENTROPY,
|
||||
/*
|
||||
Brute-force-search PNG filters by compressing each filter for each scanline.
|
||||
Experimental, very slow, and only rarely gives better compression than MINSUM.
|
||||
*/
|
||||
LFS_BRUTE_FORCE,
|
||||
/*use predefined_filters buffer: you specify the filter type for each scanline*/
|
||||
LFS_PREDEFINED
|
||||
} LodePNGFilterStrategy;
|
||||
|
||||
/*Gives characteristics about the colors of the image, which helps decide which color model to use for encoding.
|
||||
Used internally by default if "auto_convert" is enabled. Public because it's useful for custom algorithms.*/
|
||||
typedef struct LodePNGColorProfile
|
||||
{
|
||||
unsigned colored; /*not greyscale*/
|
||||
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
|
||||
uint16_t key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
|
||||
uint16_t key_g;
|
||||
uint16_t key_b;
|
||||
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
|
||||
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
|
||||
uint8_t palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
|
||||
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
|
||||
unsigned colored; /*not greyscale*/
|
||||
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
|
||||
uint16_t key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
|
||||
uint16_t key_g;
|
||||
uint16_t key_b;
|
||||
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
|
||||
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
|
||||
uint8_t palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
|
||||
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
|
||||
} LodePNGColorProfile;
|
||||
|
||||
void lodepng_color_profile_init(LodePNGColorProfile* profile);
|
||||
|
@ -588,32 +588,32 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
|||
/*Settings for the encoder.*/
|
||||
typedef struct LodePNGEncoderSettings
|
||||
{
|
||||
LodePNGCompressSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/
|
||||
LodePNGCompressSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/
|
||||
|
||||
unsigned auto_convert; /*automatically choose output PNG color type. Default: true*/
|
||||
unsigned auto_convert; /*automatically choose output PNG color type. Default: true*/
|
||||
|
||||
/*If true, follows the official PNG heuristic: if the PNG uses a palette or lower than
|
||||
8 bit depth, set all filters to zero. Otherwise use the filter_strategy. Note that to
|
||||
completely follow the official PNG heuristic, filter_palette_zero must be true and
|
||||
filter_strategy must be LFS_MINSUM*/
|
||||
unsigned filter_palette_zero;
|
||||
/*Which filter strategy to use when not using zeroes due to filter_palette_zero.
|
||||
Set filter_palette_zero to 0 to ensure always using your chosen strategy. Default: LFS_MINSUM*/
|
||||
LodePNGFilterStrategy filter_strategy;
|
||||
/*used if filter_strategy is LFS_PREDEFINED. In that case, this must point to a buffer with
|
||||
the same length as the amount of scanlines in the image, and each value must <= 5. You
|
||||
have to cleanup this buffer, LodePNG will never free it. Don't forget that filter_palette_zero
|
||||
must be set to 0 to ensure this is also used on palette or low bitdepth images.*/
|
||||
const uint8_t* predefined_filters;
|
||||
/*If true, follows the official PNG heuristic: if the PNG uses a palette or lower than
|
||||
8 bit depth, set all filters to zero. Otherwise use the filter_strategy. Note that to
|
||||
completely follow the official PNG heuristic, filter_palette_zero must be true and
|
||||
filter_strategy must be LFS_MINSUM*/
|
||||
unsigned filter_palette_zero;
|
||||
/*Which filter strategy to use when not using zeroes due to filter_palette_zero.
|
||||
Set filter_palette_zero to 0 to ensure always using your chosen strategy. Default: LFS_MINSUM*/
|
||||
LodePNGFilterStrategy filter_strategy;
|
||||
/*used if filter_strategy is LFS_PREDEFINED. In that case, this must point to a buffer with
|
||||
the same length as the amount of scanlines in the image, and each value must <= 5. You
|
||||
have to cleanup this buffer, LodePNG will never free it. Don't forget that filter_palette_zero
|
||||
must be set to 0 to ensure this is also used on palette or low bitdepth images.*/
|
||||
const uint8_t* predefined_filters;
|
||||
|
||||
/*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).
|
||||
If colortype is 3, PLTE is _always_ created.*/
|
||||
unsigned force_palette;
|
||||
/*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).
|
||||
If colortype is 3, PLTE is _always_ created.*/
|
||||
unsigned force_palette;
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
/*add LodePNG identifier and version as a text chunk, for debugging*/
|
||||
unsigned add_id;
|
||||
/*encode text chunks as zTXt chunks instead of tEXt chunks, and use compression in iTXt chunks*/
|
||||
unsigned text_compression;
|
||||
/*add LodePNG identifier and version as a text chunk, for debugging*/
|
||||
unsigned add_id;
|
||||
/*encode text chunks as zTXt chunks instead of tEXt chunks, and use compression in iTXt chunks*/
|
||||
unsigned text_compression;
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
} LodePNGEncoderSettings;
|
||||
|
||||
|
@ -626,17 +626,17 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings);
|
|||
typedef struct LodePNGState
|
||||
{
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
LodePNGDecoderSettings decoder; /*the decoding settings*/
|
||||
LodePNGDecoderSettings decoder; /*the decoding settings*/
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
LodePNGEncoderSettings encoder; /*the encoding settings*/
|
||||
LodePNGEncoderSettings encoder; /*the encoding settings*/
|
||||
#endif /*LODEPNG_COMPILE_ENCODER*/
|
||||
LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/
|
||||
LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/
|
||||
unsigned error;
|
||||
LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/
|
||||
LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/
|
||||
unsigned error;
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* For the lodepng::State subclass. */
|
||||
virtual ~LodePNGState(){}
|
||||
/* For the lodepng::State subclass. */
|
||||
virtual ~LodePNGState() {}
|
||||
#endif
|
||||
} LodePNGState;
|
||||
|
||||
|
@ -823,11 +823,11 @@ namespace lodepng
|
|||
#ifdef LODEPNG_COMPILE_PNG
|
||||
class State : public LodePNGState
|
||||
{
|
||||
public:
|
||||
State();
|
||||
State(const State& other);
|
||||
virtual ~State();
|
||||
State& operator=(const State& other);
|
||||
public:
|
||||
State();
|
||||
State(const State& other);
|
||||
virtual ~State();
|
||||
State& operator=(const State& other);
|
||||
};
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
|
|
|
@ -26,35 +26,37 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <stdio.h>
|
||||
|
||||
/* need at least SDL_2.0.0 */
|
||||
#define SDL_MIN_X 2
|
||||
#define SDL_MIN_Y 0
|
||||
#define SDL_MIN_Z 0
|
||||
#define SDL_REQUIREDVERSION (SDL_VERSIONNUM(SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z))
|
||||
#define SDL_NEW_VERSION_REJECT (SDL_VERSIONNUM(3,0,0))
|
||||
#define SDL_MIN_X 2
|
||||
#define SDL_MIN_Y 0
|
||||
#define SDL_MIN_Z 0
|
||||
#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());
|
||||
}
|
||||
|
@ -63,7 +65,7 @@ static void Sys_InitSDL (void)
|
|||
|
||||
#define DEFAULT_MEMORY (256 * 1024 * 1024) // ericw -- was 72MB (64-bit) / 64MB (32-bit)
|
||||
|
||||
static quakeparms_t parms;
|
||||
static quakeparms_t parms;
|
||||
|
||||
// On OS X we call SDL_main from the launcher, but SDL2 doesn't redefine main
|
||||
// as SDL_main on OS X anymore, so we do it ourselves.
|
||||
|
@ -73,8 +75,8 @@ static quakeparms_t parms;
|
|||
|
||||
int32_t main(int32_t argc, char *argv[])
|
||||
{
|
||||
int32_t t;
|
||||
double time, oldtime, newtime;
|
||||
int32_t t;
|
||||
double time, oldtime, newtime;
|
||||
|
||||
host_parms = &parms;
|
||||
parms.basedir = ".";
|
||||
|
@ -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,52 +116,52 @@ 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)
|
||||
{
|
||||
/* If we have no input focus at all, sleep a bit */
|
||||
if (!VID_HasMouseOrInputFocus() || cl.paused)
|
||||
while(1)
|
||||
{
|
||||
SDL_Delay(16);
|
||||
}
|
||||
/* If we're minimised, sleep a bit more */
|
||||
if (VID_IsMinimized())
|
||||
{
|
||||
scr_skipupdate = 1;
|
||||
SDL_Delay(32);
|
||||
}
|
||||
else
|
||||
{
|
||||
scr_skipupdate = 0;
|
||||
}
|
||||
newtime = Sys_DoubleTime ();
|
||||
time = newtime - oldtime;
|
||||
/* If we have no input focus at all, sleep a bit */
|
||||
if(!VID_HasMouseOrInputFocus() || cl.paused)
|
||||
{
|
||||
SDL_Delay(16);
|
||||
}
|
||||
/* If we're minimised, sleep a bit more */
|
||||
if(VID_IsMinimized())
|
||||
{
|
||||
scr_skipupdate = 1;
|
||||
SDL_Delay(32);
|
||||
}
|
||||
else
|
||||
{
|
||||
scr_skipupdate = 0;
|
||||
}
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
|
||||
Host_Frame (time);
|
||||
Host_Frame(time);
|
||||
|
||||
if (time < sys_throttle.value && !cls.timedemo)
|
||||
SDL_Delay(1);
|
||||
if(time < sys_throttle.value && !cls.timedemo)
|
||||
SDL_Delay(1);
|
||||
|
||||
oldtime = newtime;
|
||||
}
|
||||
oldtime = newtime;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
292
source/mathlib.c
292
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,9 +54,9 @@ 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 pos;
|
||||
int32_t i;
|
||||
float minelem = 1.0F;
|
||||
vec3_t tempvec;
|
||||
|
@ -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
|
||||
|
@ -91,15 +91,15 @@ void PerpendicularVector( vec3_t dst, const vec3_t src )
|
|||
/*-----------------------------------------------------------------*/
|
||||
|
||||
|
||||
float anglemod(float a)
|
||||
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,72 +111,72 @@ 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;
|
||||
float dist1, dist2;
|
||||
int32_t sides;
|
||||
|
||||
#if 0 // this is done by the BOX_ON_PLANE_SIDE macro before calling this
|
||||
// function
|
||||
#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");
|
||||
dist1 = dist2 = 0; // shut up compiler
|
||||
Sys_Error("BoxOnPlaneSide: Bad signbits");
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t i;
|
||||
vec3_t corners[2];
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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,26 +354,26 @@ 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];
|
||||
in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
||||
in1[0][2] * in2[2][1];
|
||||
in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
||||
in1[0][2] * in2[2][2];
|
||||
in1[0][2] * in2[2][2];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||
in1[1][2] * in2[2][0];
|
||||
in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||
in1[1][2] * in2[2][1];
|
||||
in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||
in1[1][2] * in2[2][2];
|
||||
in1[1][2] * in2[2][2];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
||||
in1[2][2] * in2[2][0];
|
||||
in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
||||
in1[2][2] * in2[2][1];
|
||||
in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
||||
in1[2][2] * in2[2][2];
|
||||
in1[2][2] * in2[2][2];
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,32 +382,32 @@ 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];
|
||||
in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
||||
in1[0][2] * in2[2][1];
|
||||
in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
||||
in1[0][2] * in2[2][2];
|
||||
in1[0][2] * in2[2][2];
|
||||
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
|
||||
in1[0][2] * in2[2][3] + in1[0][3];
|
||||
in1[0][2] * in2[2][3] + in1[0][3];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||
in1[1][2] * in2[2][0];
|
||||
in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||
in1[1][2] * in2[2][1];
|
||||
in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||
in1[1][2] * in2[2][2];
|
||||
in1[1][2] * in2[2][2];
|
||||
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
|
||||
in1[1][2] * in2[2][3] + in1[1][3];
|
||||
in1[1][2] * in2[2][3] + in1[1][3];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
||||
in1[2][2] * in2[2][0];
|
||||
in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
||||
in1[2][2] * in2[2][1];
|
||||
in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
||||
in1[2][2] * in2[2][2];
|
||||
in1[2][2] * in2[2][2];
|
||||
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
||||
in1[2][2] * in2[2][3] + in1[2][3];
|
||||
in1[2][2] * in2[2][3] + in1[2][3];
|
||||
}
|
||||
|
||||
|
||||
|
@ -421,22 +421,22 @@ quotient must fit in 32 bits.
|
|||
====================
|
||||
*/
|
||||
|
||||
void FloorDivMod (double numer, double denom, int32_t *quotient,
|
||||
int32_t *rem)
|
||||
void FloorDivMod(double numer, double denom, int32_t *quotient,
|
||||
int32_t *rem)
|
||||
{
|
||||
int32_t q, r;
|
||||
double x;
|
||||
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);
|
||||
|
@ -445,13 +445,13 @@ void FloorDivMod (double numer, double denom, int32_t *quotient,
|
|||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// perform operations with positive values, and fix mod to make floor-based
|
||||
//
|
||||
//
|
||||
// perform operations with positive values, and fix mod to make floor-based
|
||||
//
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
107
source/mathlib.h
107
source/mathlib.h
|
@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
#define M_PI_DIV_180 (M_PI / 180.0) //johnfitz
|
||||
|
@ -38,12 +38,17 @@ struct mplane_s;
|
|||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
#define nanmask (255 << 23) /* 7F800000 */
|
||||
#if 0 /* macro is violating strict aliasing rules */
|
||||
#define IS_NAN(x) (((*(int32_t *) (char *) &x) & nanmask) == nanmask)
|
||||
#define nanmask (255 << 23) /* 7F800000 */
|
||||
#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);
|
||||
}
|
||||
|
@ -61,61 +66,61 @@ static inline int32_t IS_NAN (float x) {
|
|||
// QuakeSpasm: To avoid strict aliasing violations, use a float/int32_t union instead of type punning.
|
||||
#define VectorNormalizeFast(_v)\
|
||||
{\
|
||||
union { float f; int32_t i; } _y, _number;\
|
||||
_number.f = DotProduct(_v, _v);\
|
||||
if (_number.f != 0.0)\
|
||||
{\
|
||||
_y.i = 0x5f3759df - (_number.i >> 1);\
|
||||
_y.f = _y.f * (1.5f - (_number.f * 0.5f * _y.f * _y.f));\
|
||||
VectorScale(_v, _y.f, _v);\
|
||||
}\
|
||||
union { float f; int32_t i; } _y, _number;\
|
||||
_number.f = DotProduct(_v, _v);\
|
||||
if (_number.f != 0.0)\
|
||||
{\
|
||||
_y.i = 0x5f3759df - (_number.i >> 1);\
|
||||
_y.f = _y.f * (1.5f - (_number.f * 0.5f * _y.f * _y.f));\
|
||||
VectorScale(_v, _y.f, _v);\
|
||||
}\
|
||||
}
|
||||
|
||||
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,
|
||||
int32_t *rem);
|
||||
int32_t GreatestCommonDivisor (int32_t i1, int32_t i2);
|
||||
void FloorDivMod(double numer, double denom, int32_t *quotient,
|
||||
int32_t *rem);
|
||||
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);
|
||||
float anglemod(float a);
|
||||
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);
|
||||
|
||||
|
||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||
(((p)->type < 3)? \
|
||||
( \
|
||||
((p)->dist <= (emins)[(p)->type])? \
|
||||
1 \
|
||||
: \
|
||||
( \
|
||||
((p)->dist >= (emaxs)[(p)->type])?\
|
||||
2 \
|
||||
: \
|
||||
3 \
|
||||
) \
|
||||
) \
|
||||
: \
|
||||
BoxOnPlaneSide( (emins), (emaxs), (p)))
|
||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||
(((p)->type < 3)? \
|
||||
( \
|
||||
((p)->dist <= (emins)[(p)->type])? \
|
||||
1 \
|
||||
: \
|
||||
( \
|
||||
((p)->dist >= (emaxs)[(p)->type])?\
|
||||
2 \
|
||||
: \
|
||||
3 \
|
||||
) \
|
||||
) \
|
||||
: \
|
||||
BoxOnPlaneSide( (emins), (emaxs), (p)))
|
||||
|
||||
#endif /* __MATHLIB_H */
|
||||
#endif /* __MATHLIB_H */
|
||||
|
||||
|
|
2082
source/menu.c
2082
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 */
|
||||
#endif /* _QUAKE_MENU_H */
|
||||
|
||||
|
|
|
@ -47,95 +47,106 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#endif
|
||||
|
||||
#define ALIAS_VERSION 6
|
||||
#define ALIAS_VERSION 6
|
||||
|
||||
#define ALIAS_ONSEAM 0x0020
|
||||
#define ALIAS_ONSEAM 0x0020
|
||||
|
||||
// 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 {
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
vec3_t scale_origin;
|
||||
float boundingradius;
|
||||
vec3_t eyeposition;
|
||||
int32_t numskins;
|
||||
int32_t skinwidth;
|
||||
int32_t skinheight;
|
||||
int32_t numverts;
|
||||
int32_t numtris;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
int32_t flags;
|
||||
float size;
|
||||
typedef struct
|
||||
{
|
||||
int32_t ident;
|
||||
int32_t version;
|
||||
vec3_t scale;
|
||||
vec3_t scale_origin;
|
||||
float boundingradius;
|
||||
vec3_t eyeposition;
|
||||
int32_t numskins;
|
||||
int32_t skinwidth;
|
||||
int32_t skinheight;
|
||||
int32_t numverts;
|
||||
int32_t numtris;
|
||||
int32_t numframes;
|
||||
synctype_t synctype;
|
||||
int32_t flags;
|
||||
float size;
|
||||
} mdl_t;
|
||||
|
||||
// TODO: could be shorts
|
||||
|
||||
typedef struct {
|
||||
int32_t onseam;
|
||||
int32_t s;
|
||||
int32_t t;
|
||||
typedef struct
|
||||
{
|
||||
int32_t onseam;
|
||||
int32_t s;
|
||||
int32_t t;
|
||||
} stvert_t;
|
||||
|
||||
typedef struct dtriangle_s {
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
typedef struct dtriangle_s
|
||||
{
|
||||
int32_t facesfront;
|
||||
int32_t vertindex[3];
|
||||
} dtriangle_t;
|
||||
|
||||
#define DT_FACES_FRONT 0x0010
|
||||
#define DT_FACES_FRONT 0x0010
|
||||
|
||||
// This mirrors trivert_t in trilib.h, is present so Quake knows how to
|
||||
// load this data
|
||||
|
||||
typedef struct {
|
||||
byte v[3];
|
||||
byte lightnormalindex;
|
||||
typedef struct
|
||||
{
|
||||
byte v[3];
|
||||
byte lightnormalindex;
|
||||
} trivertx_t;
|
||||
|
||||
typedef struct {
|
||||
trivertx_t bboxmin; // lightnormal isn't used
|
||||
trivertx_t bboxmax; // lightnormal isn't used
|
||||
char name[16]; // frame name from grabbing
|
||||
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 {
|
||||
int32_t numframes;
|
||||
trivertx_t bboxmin; // lightnormal isn't used
|
||||
trivertx_t bboxmax; // lightnormal isn't used
|
||||
typedef struct
|
||||
{
|
||||
int32_t numframes;
|
||||
trivertx_t bboxmin; // lightnormal isn't used
|
||||
trivertx_t bboxmax; // lightnormal isn't used
|
||||
} daliasgroup_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t numskins;
|
||||
typedef struct
|
||||
{
|
||||
int32_t numskins;
|
||||
} daliasskingroup_t;
|
||||
|
||||
typedef struct {
|
||||
float interval;
|
||||
typedef struct
|
||||
{
|
||||
float interval;
|
||||
} daliasinterval_t;
|
||||
|
||||
typedef struct {
|
||||
float interval;
|
||||
typedef struct
|
||||
{
|
||||
float interval;
|
||||
} daliasskininterval_t;
|
||||
|
||||
typedef struct {
|
||||
aliasframetype_t type;
|
||||
typedef struct
|
||||
{
|
||||
aliasframetype_t type;
|
||||
} daliasframetype_t;
|
||||
|
||||
typedef struct {
|
||||
aliasskintype_t type;
|
||||
typedef struct
|
||||
{
|
||||
aliasskintype_t type;
|
||||
} daliasskintype_t;
|
||||
|
||||
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
|
||||
// little-endian "IDPO"
|
||||
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
|
||||
// little-endian "IDPO"
|
||||
|
||||
#endif /* _MODELGEN_H */
|
||||
#endif /* _MODELGEN_H */
|
||||
|
||||
|
|
76
source/net.h
76
source/net.h
|
@ -22,64 +22,64 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
/*
|
||||
net.h
|
||||
quake's interface to the networking layer
|
||||
network functions and data, common to the
|
||||
whole engine
|
||||
net.h
|
||||
quake's interface to the networking layer
|
||||
network functions and data, common to the
|
||||
whole engine
|
||||
*/
|
||||
|
||||
#ifndef _QUAKE_NET_H
|
||||
#define _QUAKE_NET_H
|
||||
|
||||
|
||||
#define NET_NAMELEN 64
|
||||
#define NET_NAMELEN 64
|
||||
|
||||
#define NET_MAXMESSAGE 64000 /* ericw -- was 32000 */
|
||||
#define NET_MAXMESSAGE 64000 /* ericw -- was 32000 */
|
||||
|
||||
extern int32_t DEFAULTnet_hostport;
|
||||
extern int32_t net_hostport;
|
||||
extern int32_t DEFAULTnet_hostport;
|
||||
extern int32_t net_hostport;
|
||||
|
||||
extern cvar_t hostname;
|
||||
extern cvar_t hostname;
|
||||
|
||||
extern double net_time;
|
||||
extern sizebuf_t net_message;
|
||||
extern int32_t net_activeconnections;
|
||||
extern double net_time;
|
||||
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
|
||||
// returns -1 if the connection died
|
||||
|
||||
int32_t NET_SendToAll(sizebuf_t *data, double blocktime);
|
||||
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,28 +88,28 @@ 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:
|
||||
extern bool slistInProgress;
|
||||
extern bool slistSilent;
|
||||
extern bool slistLocal;
|
||||
extern bool slistInProgress;
|
||||
extern bool slistSilent;
|
||||
extern bool slistLocal;
|
||||
|
||||
extern int32_t hostCacheCount;
|
||||
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:
|
||||
*/
|
||||
extern bool ipxAvailable;
|
||||
extern bool tcpipAvailable;
|
||||
extern char my_ipx_address[NET_NAMELEN];
|
||||
extern char my_tcpip_address[NET_NAMELEN];
|
||||
extern bool ipxAvailable;
|
||||
extern bool tcpipAvailable;
|
||||
extern char my_ipx_address[NET_NAMELEN];
|
||||
extern char my_tcpip_address[NET_NAMELEN];
|
||||
|
||||
#endif /* _QUAKE_NET_H */
|
||||
#endif /* _QUAKE_NET_H */
|
||||
|
||||
|
|
|
@ -31,27 +31,27 @@ struct qsockaddr
|
|||
uint8_t qsa_family;
|
||||
#else
|
||||
int16_t qsa_family;
|
||||
#endif /* BSD, sockaddr */
|
||||
#endif /* BSD, sockaddr */
|
||||
uint8_t qsa_data[14];
|
||||
};
|
||||
|
||||
#define NET_HEADERSIZE (2 * sizeof(uint32_t))
|
||||
#define NET_DATAGRAMSIZE (MAX_DATAGRAM + NET_HEADERSIZE)
|
||||
#define NET_HEADERSIZE (2 * sizeof(uint32_t))
|
||||
#define NET_DATAGRAMSIZE (MAX_DATAGRAM + NET_HEADERSIZE)
|
||||
|
||||
// NetHeader flags
|
||||
#define NETFLAG_LENGTH_MASK 0x0000ffff
|
||||
#define NETFLAG_DATA 0x00010000
|
||||
#define NETFLAG_ACK 0x00020000
|
||||
#define NETFLAG_NAK 0x00040000
|
||||
#define NETFLAG_EOM 0x00080000
|
||||
#define NETFLAG_UNRELIABLE 0x00100000
|
||||
#define NETFLAG_CTL 0x80000000
|
||||
#define NETFLAG_LENGTH_MASK 0x0000ffff
|
||||
#define NETFLAG_DATA 0x00010000
|
||||
#define NETFLAG_ACK 0x00020000
|
||||
#define NETFLAG_NAK 0x00040000
|
||||
#define NETFLAG_EOM 0x00080000
|
||||
#define NETFLAG_UNRELIABLE 0x00100000
|
||||
#define NETFLAG_CTL 0x80000000
|
||||
|
||||
#if (NETFLAG_LENGTH_MASK & NET_MAXMESSAGE) != NET_MAXMESSAGE
|
||||
#error "NET_MAXMESSAGE must fit within NETFLAG_LENGTH_MASK"
|
||||
#endif
|
||||
|
||||
#define NET_PROTOCOL_VERSION 3
|
||||
#define NET_PROTOCOL_VERSION 3
|
||||
|
||||
/**
|
||||
|
||||
|
@ -61,184 +61,184 @@ Quake game protocol (documented elsewhere) is used.
|
|||
|
||||
|
||||
General notes:
|
||||
game_name is currently always "QUAKE", but is there so this same protocol
|
||||
can be used for future games as well; can you say Quake2?
|
||||
game_name is currently always "QUAKE", but is there so this same protocol
|
||||
can be used for future games as well; can you say Quake2?
|
||||
|
||||
CCREQ_CONNECT
|
||||
string game_name "QUAKE"
|
||||
byte net_protocol_version NET_PROTOCOL_VERSION
|
||||
string game_name "QUAKE"
|
||||
byte net_protocol_version NET_PROTOCOL_VERSION
|
||||
|
||||
CCREQ_SERVER_INFO
|
||||
string game_name "QUAKE"
|
||||
byte net_protocol_version NET_PROTOCOL_VERSION
|
||||
string game_name "QUAKE"
|
||||
byte net_protocol_version NET_PROTOCOL_VERSION
|
||||
|
||||
CCREQ_PLAYER_INFO
|
||||
byte player_number
|
||||
byte player_number
|
||||
|
||||
CCREQ_RULE_INFO
|
||||
string rule
|
||||
string rule
|
||||
|
||||
CCREP_ACCEPT
|
||||
long port
|
||||
long port
|
||||
|
||||
CCREP_REJECT
|
||||
string reason
|
||||
string reason
|
||||
|
||||
CCREP_SERVER_INFO
|
||||
string server_address
|
||||
string host_name
|
||||
string level_name
|
||||
byte current_players
|
||||
byte max_players
|
||||
byte protocol_version NET_PROTOCOL_VERSION
|
||||
string server_address
|
||||
string host_name
|
||||
string level_name
|
||||
byte current_players
|
||||
byte max_players
|
||||
byte protocol_version NET_PROTOCOL_VERSION
|
||||
|
||||
CCREP_PLAYER_INFO
|
||||
byte player_number
|
||||
string name
|
||||
long colors
|
||||
long frags
|
||||
long connect_time
|
||||
string address
|
||||
byte player_number
|
||||
string name
|
||||
long colors
|
||||
long frags
|
||||
long connect_time
|
||||
string address
|
||||
|
||||
CCREP_RULE_INFO
|
||||
string rule
|
||||
string value
|
||||
string rule
|
||||
string value
|
||||
|
||||
note:
|
||||
There are two address forms used above. The short form is just a
|
||||
port number. The address that goes along with the port is defined as
|
||||
"whatever address you receive this reponse from". This lets us use
|
||||
the host OS to solve the problem of multiple host addresses (possibly
|
||||
with no routing between them); the host will use the right address
|
||||
when we reply to the inbound connection request. The long from is
|
||||
a full address and port in a string. It is used for returning the
|
||||
address of a server that is not running locally.
|
||||
note:
|
||||
There are two address forms used above. The short form is just a
|
||||
port number. The address that goes along with the port is defined as
|
||||
"whatever address you receive this reponse from". This lets us use
|
||||
the host OS to solve the problem of multiple host addresses (possibly
|
||||
with no routing between them); the host will use the right address
|
||||
when we reply to the inbound connection request. The long from is
|
||||
a full address and port in a string. It is used for returning the
|
||||
address of a server that is not running locally.
|
||||
|
||||
**/
|
||||
|
||||
#define CCREQ_CONNECT 0x01
|
||||
#define CCREQ_SERVER_INFO 0x02
|
||||
#define CCREQ_PLAYER_INFO 0x03
|
||||
#define CCREQ_RULE_INFO 0x04
|
||||
#define CCREQ_CONNECT 0x01
|
||||
#define CCREQ_SERVER_INFO 0x02
|
||||
#define CCREQ_PLAYER_INFO 0x03
|
||||
#define CCREQ_RULE_INFO 0x04
|
||||
|
||||
#define CCREP_ACCEPT 0x81
|
||||
#define CCREP_REJECT 0x82
|
||||
#define CCREP_SERVER_INFO 0x83
|
||||
#define CCREP_PLAYER_INFO 0x84
|
||||
#define CCREP_RULE_INFO 0x85
|
||||
#define CCREP_ACCEPT 0x81
|
||||
#define CCREP_REJECT 0x82
|
||||
#define CCREP_SERVER_INFO 0x83
|
||||
#define CCREP_PLAYER_INFO 0x84
|
||||
#define CCREP_RULE_INFO 0x85
|
||||
|
||||
typedef struct qsocket_s
|
||||
{
|
||||
struct qsocket_s *next;
|
||||
double connecttime;
|
||||
double lastMessageTime;
|
||||
double lastSendTime;
|
||||
struct qsocket_s *next;
|
||||
double connecttime;
|
||||
double lastMessageTime;
|
||||
double lastSendTime;
|
||||
|
||||
bool disconnected;
|
||||
bool canSend;
|
||||
bool sendNext;
|
||||
bool disconnected;
|
||||
bool canSend;
|
||||
bool sendNext;
|
||||
|
||||
int32_t driver;
|
||||
int32_t landriver;
|
||||
sys_socket_t socket;
|
||||
void *driverdata;
|
||||
int32_t driver;
|
||||
int32_t landriver;
|
||||
sys_socket_t socket;
|
||||
void *driverdata;
|
||||
|
||||
uint32_t ackSequence;
|
||||
uint32_t sendSequence;
|
||||
uint32_t unreliableSendSequence;
|
||||
int32_t sendMessageLength;
|
||||
byte sendMessage [NET_MAXMESSAGE];
|
||||
uint32_t ackSequence;
|
||||
uint32_t sendSequence;
|
||||
uint32_t unreliableSendSequence;
|
||||
int32_t sendMessageLength;
|
||||
byte sendMessage [NET_MAXMESSAGE];
|
||||
|
||||
uint32_t receiveSequence;
|
||||
uint32_t unreliableReceiveSequence;
|
||||
int32_t receiveMessageLength;
|
||||
byte receiveMessage [NET_MAXMESSAGE];
|
||||
uint32_t receiveSequence;
|
||||
uint32_t unreliableReceiveSequence;
|
||||
int32_t receiveMessageLength;
|
||||
byte receiveMessage [NET_MAXMESSAGE];
|
||||
|
||||
struct qsockaddr addr;
|
||||
char address[NET_NAMELEN];
|
||||
struct qsockaddr addr;
|
||||
char address[NET_NAMELEN];
|
||||
|
||||
} qsocket_t;
|
||||
|
||||
extern qsocket_t *net_activeSockets;
|
||||
extern qsocket_t *net_freeSockets;
|
||||
extern int32_t net_numsockets;
|
||||
extern qsocket_t *net_activeSockets;
|
||||
extern qsocket_t *net_freeSockets;
|
||||
extern int32_t net_numsockets;
|
||||
|
||||
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);
|
||||
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);
|
||||
} net_landriver_t;
|
||||
|
||||
#define MAX_NET_DRIVERS 8
|
||||
extern net_landriver_t net_landrivers[];
|
||||
extern const int32_t net_numlandrivers;
|
||||
#define MAX_NET_DRIVERS 8
|
||||
extern net_landriver_t net_landrivers[];
|
||||
extern const int32_t net_numlandrivers;
|
||||
|
||||
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);
|
||||
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);
|
||||
} net_driver_t;
|
||||
|
||||
extern net_driver_t net_drivers[];
|
||||
extern const int32_t net_numdrivers;
|
||||
extern net_driver_t net_drivers[];
|
||||
extern const int32_t net_numdrivers;
|
||||
|
||||
/* Loop driver must always be registered the first */
|
||||
#define IS_LOOP_DRIVER(p) ((p) == 0)
|
||||
#define IS_LOOP_DRIVER(p) ((p) == 0)
|
||||
|
||||
extern int32_t net_driverlevel;
|
||||
extern int32_t net_driverlevel;
|
||||
|
||||
extern int32_t messagesSent;
|
||||
extern int32_t messagesReceived;
|
||||
extern int32_t unreliableMessagesSent;
|
||||
extern int32_t unreliableMessagesReceived;
|
||||
extern int32_t messagesSent;
|
||||
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);
|
||||
|
||||
|
||||
#define HOSTCACHESIZE 8
|
||||
#define HOSTCACHESIZE 8
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[16];
|
||||
char map[16];
|
||||
char cname[32];
|
||||
int32_t users;
|
||||
int32_t maxusers;
|
||||
int32_t driver;
|
||||
int32_t ldriver;
|
||||
char name[16];
|
||||
char map[16];
|
||||
char cname[32];
|
||||
int32_t users;
|
||||
int32_t maxusers;
|
||||
int32_t driver;
|
||||
int32_t ldriver;
|
||||
struct qsockaddr addr;
|
||||
} hostcache_t;
|
||||
|
||||
|
@ -248,13 +248,13 @@ extern hostcache_t hostcache[HOSTCACHESIZE];
|
|||
|
||||
typedef struct _PollProcedure
|
||||
{
|
||||
struct _PollProcedure *next;
|
||||
double nextTime;
|
||||
void (*procedure)(void *);
|
||||
void *arg;
|
||||
struct _PollProcedure *next;
|
||||
double nextTime;
|
||||
void (*procedure)(void *);
|
||||
void *arg;
|
||||
} PollProcedure;
|
||||
|
||||
void SchedulePollProcedure(PollProcedure *pp, double timeOffset);
|
||||
|
||||
#endif /* __NET_DEFS_H */
|
||||
#endif /* __NET_DEFS_H */
|
||||
|
||||
|
|
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 */
|
||||
#endif /* __NET_DATAGRAM_H */
|
||||
|
||||
|
|
|
@ -26,38 +26,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "net_defs.h"
|
||||
#include "net_loop.h"
|
||||
|
||||
static bool localconnectpending = false;
|
||||
static qsocket_t *loop_client = NULL;
|
||||
static qsocket_t *loop_server = NULL;
|
||||
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;
|
||||
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 */
|
||||
#endif /* __NET_LOOP_H */
|
||||
|
||||
|
|
|
@ -25,53 +25,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "quakedef.h"
|
||||
#include "net_defs.h"
|
||||
|
||||
qsocket_t *net_activeSockets = NULL;
|
||||
qsocket_t *net_freeSockets = NULL;
|
||||
int32_t net_numsockets = 0;
|
||||
qsocket_t *net_activeSockets = NULL;
|
||||
qsocket_t *net_freeSockets = NULL;
|
||||
int32_t net_numsockets = 0;
|
||||
|
||||
bool ipxAvailable = false;
|
||||
bool tcpipAvailable = false;
|
||||
bool ipxAvailable = false;
|
||||
bool tcpipAvailable = false;
|
||||
|
||||
int32_t net_hostport;
|
||||
int32_t DEFAULTnet_hostport = 26000;
|
||||
int32_t net_hostport;
|
||||
int32_t DEFAULTnet_hostport = 26000;
|
||||
|
||||
char my_ipx_address[NET_NAMELEN];
|
||||
char my_tcpip_address[NET_NAMELEN];
|
||||
char my_ipx_address[NET_NAMELEN];
|
||||
char my_tcpip_address[NET_NAMELEN];
|
||||
|
||||
static bool listening = false;
|
||||
static bool listening = false;
|
||||
|
||||
bool slistInProgress = false;
|
||||
bool slistSilent = false;
|
||||
bool slistLocal = true;
|
||||
static double slistStartTime;
|
||||
static int32_t slistLastShown;
|
||||
bool slistInProgress = false;
|
||||
bool slistSilent = false;
|
||||
bool slistLocal = true;
|
||||
static double slistStartTime;
|
||||
static int32_t slistLastShown;
|
||||
|
||||
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};
|
||||
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};
|
||||
|
||||
sizebuf_t net_message;
|
||||
int32_t net_activeconnections = 0;
|
||||
sizebuf_t net_message;
|
||||
int32_t net_activeconnections = 0;
|
||||
|
||||
int32_t messagesSent = 0;
|
||||
int32_t messagesReceived = 0;
|
||||
int32_t unreliableMessagesSent = 0;
|
||||
int32_t unreliableMessagesReceived = 0;
|
||||
int32_t messagesSent = 0;
|
||||
int32_t messagesReceived = 0;
|
||||
int32_t unreliableMessagesSent = 0;
|
||||
int32_t unreliableMessagesReceived = 0;
|
||||
|
||||
static cvar_t net_messagetimeout = {"net_messagetimeout","300",CVAR_NONE};
|
||||
cvar_t hostname = {"hostname", "UNNAMED", 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
|
||||
#define sfunc net_drivers[sock->driver]
|
||||
#define dfunc net_drivers[net_driverlevel]
|
||||
#define sfunc net_drivers[sock->driver]
|
||||
#define dfunc net_drivers[net_driverlevel]
|
||||
|
||||
int32_t net_driverlevel;
|
||||
int32_t net_driverlevel;
|
||||
|
||||
double net_time;
|
||||
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;
|
||||
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;
|
||||
|
@ -127,24 +127,24 @@ qsocket_t *NET_NewQSocket (void)
|
|||
|
||||
void NET_FreeQSocket(qsocket_t *sock)
|
||||
{
|
||||
qsocket_t *s;
|
||||
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;
|
||||
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;
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,11 +263,11 @@ static void PrintSlistHeader(void)
|
|||
|
||||
static void PrintSlist(void)
|
||||
{
|
||||
int32_t n;
|
||||
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;
|
||||
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,76 +328,76 @@ void NET_SlistSort (void)
|
|||
}
|
||||
|
||||
|
||||
const char *NET_SlistPrintServer (int32_t idx)
|
||||
const char *NET_SlistPrintServer(int32_t idx)
|
||||
{
|
||||
static char string[64];
|
||||
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,
|
||||
hostcache[idx].users, hostcache[idx].maxusers);
|
||||
hostcache[idx].name, hostcache[idx].map,
|
||||
hostcache[idx].users, hostcache[idx].maxusers);
|
||||
}
|
||||
else
|
||||
{
|
||||
q_snprintf(string, sizeof(string), "%-15.15s %-15.15s\n",
|
||||
hostcache[idx].name, hostcache[idx].map);
|
||||
hostcache[idx].name, hostcache[idx].map);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
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,57 +414,57 @@ 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;
|
||||
int32_t numdrivers = net_numdrivers;
|
||||
qsocket_t *ret;
|
||||
int32_t n;
|
||||
int32_t numdrivers = net_numdrivers;
|
||||
|
||||
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;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
@ -603,19 +603,19 @@ NET_SendMessage
|
|||
|
||||
Try to send a complete length+message unit over the reliable stream.
|
||||
returns 0 if the message cannot be delivered reliably, but the connection
|
||||
is still considered valid
|
||||
is still considered valid
|
||||
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;
|
||||
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;
|
||||
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,24 +674,24 @@ 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;
|
||||
int32_t count = 0;
|
||||
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). */
|
||||
double start;
|
||||
int32_t i;
|
||||
int32_t count = 0;
|
||||
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;
|
||||
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;
|
||||
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
|
||||
&& cls.state == ca_dedicated
|
||||
)
|
||||
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;
|
||||
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;
|
||||
|
|
108
source/net_sys.h
108
source/net_sys.h
|
@ -29,8 +29,8 @@
|
|||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \
|
||||
defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \
|
||||
#if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \
|
||||
defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \
|
||||
defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__)
|
||||
/* struct sockaddr has uint8_t sa_len as the first member in BSD
|
||||
* variants and the family member is also an uint8_t instead of an
|
||||
|
@ -39,12 +39,12 @@
|
|||
* provide a struct sockaddr doesn't hurt either (see down below for the
|
||||
* compile time asserts.) */
|
||||
/* FIXME : GET RID OF THIS ABOMINATION !!! */
|
||||
#define HAVE_SA_LEN 1
|
||||
#define SA_FAM_OFFSET 1
|
||||
#define HAVE_SA_LEN 1
|
||||
#define SA_FAM_OFFSET 1
|
||||
#else
|
||||
#undef HAVE_SA_LEN
|
||||
#define SA_FAM_OFFSET 0
|
||||
#endif /* BSD, sockaddr */
|
||||
#undef HAVE_SA_LEN
|
||||
#define SA_FAM_OFFSET 0
|
||||
#endif /* BSD, sockaddr */
|
||||
|
||||
/* unix includes and compatibility macros */
|
||||
#if defined(PLATFORM_UNIX) || defined(PLATFORM_RISCOS)
|
||||
|
@ -54,32 +54,32 @@
|
|||
#if defined(__sun) || defined(sun)
|
||||
#include <sys/filio.h>
|
||||
#include <sys/sockio.h>
|
||||
#endif /* __sunos__ */
|
||||
#endif /* __sunos__ */
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
typedef int32_t sys_socket_t;
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKET_ERROR (-1)
|
||||
typedef int32_t sys_socket_t;
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKET_ERROR (-1)
|
||||
|
||||
#define SOCKETERRNO errno
|
||||
#define ioctlsocket ioctl
|
||||
#define closesocket close
|
||||
#define selectsocket select
|
||||
#define IOCTLARG_P(x) /* (char *) */ x
|
||||
#define SOCKETERRNO errno
|
||||
#define ioctlsocket ioctl
|
||||
#define closesocket close
|
||||
#define selectsocket select
|
||||
#define IOCTLARG_P(x) /* (char *) */ x
|
||||
|
||||
#define NET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define NET_ECONNREFUSED ECONNREFUSED
|
||||
#define NET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define NET_ECONNREFUSED ECONNREFUSED
|
||||
|
||||
#define socketerror(x) strerror((x))
|
||||
#define socketerror(x) strerror((x))
|
||||
|
||||
_Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
|
||||
"HAVE_SA_LEN not defined correctly");
|
||||
|
||||
#endif /* end of unix stuff */
|
||||
#endif /* end of unix stuff */
|
||||
|
||||
|
||||
/* amiga includes and compatibility macros */
|
||||
|
@ -95,34 +95,34 @@ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
|
|||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
typedef int32_t sys_socket_t;
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKET_ERROR (-1)
|
||||
typedef int32_t sys_socket_t;
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKET_ERROR (-1)
|
||||
|
||||
typedef uint32_t in_addr_t;
|
||||
|
||||
#define SOCKETERRNO Errno()
|
||||
#define ioctlsocket IoctlSocket
|
||||
#define closesocket CloseSocket
|
||||
#define selectsocket(_N,_R,_W,_E,_T) \
|
||||
WaitSelect((_N),(_R),(_W),(_E),(_T),NULL)
|
||||
#define IOCTLARG_P(x) (char *) x
|
||||
#define SOCKETERRNO Errno()
|
||||
#define ioctlsocket IoctlSocket
|
||||
#define closesocket CloseSocket
|
||||
#define selectsocket(_N,_R,_W,_E,_T) \
|
||||
WaitSelect((_N),(_R),(_W),(_E),(_T),NULL)
|
||||
#define IOCTLARG_P(x) (char *) x
|
||||
#if defined(__amigaos4__) || defined(PLATFORM_AMIGAOS3)
|
||||
#define inet_ntoa(x) Inet_NtoA(x.s_addr) /* Inet_NtoA(*(ULONG*)&x) */
|
||||
#define h_errno Errno()
|
||||
#define inet_ntoa(x) Inet_NtoA(x.s_addr) /* Inet_NtoA(*(ULONG*)&x) */
|
||||
#define h_errno Errno()
|
||||
#endif
|
||||
|
||||
#define NET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define NET_ECONNREFUSED ECONNREFUSED
|
||||
#define NET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define NET_ECONNREFUSED ECONNREFUSED
|
||||
|
||||
#define socketerror(x) strerror((x))
|
||||
#define socketerror(x) strerror((x))
|
||||
/* there is h_errno but no hstrerror() */
|
||||
#define hstrerror(x) strerror((x))
|
||||
#define hstrerror(x) strerror((x))
|
||||
|
||||
_Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
|
||||
"HAVE_SA_LEN not defined correctly");
|
||||
|
||||
#endif /* end of amiga bsdsocket.library stuff */
|
||||
#endif /* end of amiga bsdsocket.library stuff */
|
||||
|
||||
|
||||
/* windows includes and compatibility macros */
|
||||
|
@ -138,48 +138,48 @@ _Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
|
|||
|
||||
/* there is no in_addr_t on windows: define it as
|
||||
the type of the S_addr of in_addr structure */
|
||||
typedef u_long in_addr_t; /* uint32_t */
|
||||
typedef u_long in_addr_t; /* uint32_t */
|
||||
|
||||
/* on windows, socklen_t is to be a winsock2 thing */
|
||||
#if !defined(IP_MSFILTER_SIZE)
|
||||
typedef int32_t socklen_t;
|
||||
#endif /* socklen_t type */
|
||||
typedef int32_t socklen_t;
|
||||
#endif /* socklen_t type */
|
||||
|
||||
typedef SOCKET sys_socket_t;
|
||||
typedef SOCKET sys_socket_t;
|
||||
|
||||
#define selectsocket select
|
||||
#define IOCTLARG_P(x) /* (u_long *) */ x
|
||||
#define selectsocket select
|
||||
#define IOCTLARG_P(x) /* (u_long *) */ x
|
||||
|
||||
#define SOCKETERRNO WSAGetLastError()
|
||||
#define NET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define NET_ECONNREFUSED WSAECONNREFUSED
|
||||
#define SOCKETERRNO WSAGetLastError()
|
||||
#define NET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define NET_ECONNREFUSED WSAECONNREFUSED
|
||||
/* must #include "wsaerror.h" for this : */
|
||||
#define socketerror(x) __WSAE_StrError((x))
|
||||
#define socketerror(x) __WSAE_StrError((x))
|
||||
|
||||
_Static_assert(offsetof(struct sockaddr, sa_family) == SA_FAM_OFFSET,
|
||||
"HAVE_SA_LEN not defined correctly");
|
||||
|
||||
#endif /* end of windows stuff */
|
||||
#endif /* end of windows stuff */
|
||||
|
||||
|
||||
/* macros which may still be missing */
|
||||
|
||||
#if !defined(INADDR_NONE)
|
||||
#define INADDR_NONE ((in_addr_t) 0xffffffff)
|
||||
#endif /* INADDR_NONE */
|
||||
#define INADDR_NONE ((in_addr_t) 0xffffffff)
|
||||
#endif /* INADDR_NONE */
|
||||
|
||||
#if !defined(INADDR_LOOPBACK)
|
||||
#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* 127.0.0.1 */
|
||||
#endif /* INADDR_LOOPBACK */
|
||||
#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* 127.0.0.1 */
|
||||
#endif /* INADDR_LOOPBACK */
|
||||
|
||||
|
||||
#if !defined(MAXHOSTNAMELEN)
|
||||
/* SUSv2 guarantees that `Host names are limited to 255 bytes'.
|
||||
POSIX 1003.1-2001 guarantees that `Host names (not including
|
||||
the terminating NUL) are limited to HOST_NAME_MAX bytes'. */
|
||||
#define MAXHOSTNAMELEN 256
|
||||
#endif /* MAXHOSTNAMELEN */
|
||||
#define MAXHOSTNAMELEN 256
|
||||
#endif /* MAXHOSTNAMELEN */
|
||||
|
||||
|
||||
#endif /* __NET_SYS_H__ */
|
||||
#endif /* __NET_SYS_H__ */
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ 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);
|
||||
|
||||
#endif /* _QUAKE_PLATFORM_H */
|
||||
#endif /* _QUAKE_PLATFORM_H */
|
||||
|
||||
|
|
1069
source/pr_cmds.c
1069
source/pr_cmds.c
File diff suppressed because it is too large
Load Diff
|
@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// this file is shared by quake and qcc
|
||||
|
||||
typedef int32_t func_t;
|
||||
typedef int32_t string_t;
|
||||
typedef int32_t func_t;
|
||||
typedef int32_t string_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -40,17 +40,17 @@ typedef enum
|
|||
ev_pointer
|
||||
} etype_t;
|
||||
|
||||
#define OFS_NULL 0
|
||||
#define OFS_RETURN 1
|
||||
#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
|
||||
#define OFS_PARM1 7
|
||||
#define OFS_PARM2 10
|
||||
#define OFS_PARM3 13
|
||||
#define OFS_PARM4 16
|
||||
#define OFS_PARM5 19
|
||||
#define OFS_PARM6 22
|
||||
#define OFS_PARM7 25
|
||||
#define RESERVED_OFS 28
|
||||
#define OFS_NULL 0
|
||||
#define OFS_RETURN 1
|
||||
#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
|
||||
#define OFS_PARM1 7
|
||||
#define OFS_PARM2 10
|
||||
#define OFS_PARM3 13
|
||||
#define OFS_PARM4 16
|
||||
#define OFS_PARM5 19
|
||||
#define OFS_PARM6 22
|
||||
#define OFS_PARM7 25
|
||||
#define RESERVED_OFS 28
|
||||
|
||||
|
||||
enum
|
||||
|
@ -134,64 +134,64 @@ enum
|
|||
|
||||
typedef struct statement_s
|
||||
{
|
||||
uint16_t op;
|
||||
int16_t a, b, c;
|
||||
uint16_t op;
|
||||
int16_t a, b, c;
|
||||
} dstatement_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t type; // if DEF_SAVEGLOBAL bit is set
|
||||
// the variable needs to be saved in savegames
|
||||
uint16_t ofs;
|
||||
int32_t s_name;
|
||||
uint16_t type; // if DEF_SAVEGLOBAL bit is set
|
||||
// the variable needs to be saved in savegames
|
||||
uint16_t ofs;
|
||||
int32_t s_name;
|
||||
} ddef_t;
|
||||
|
||||
#define DEF_SAVEGLOBAL (1<<15)
|
||||
#define DEF_SAVEGLOBAL (1<<15)
|
||||
|
||||
#define MAX_PARMS 8
|
||||
#define MAX_PARMS 8
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t first_statement; // negative numbers are builtins
|
||||
int32_t parm_start;
|
||||
int32_t locals; // total ints of parms + locals
|
||||
int32_t first_statement; // negative numbers are builtins
|
||||
int32_t parm_start;
|
||||
int32_t locals; // total ints of parms + locals
|
||||
|
||||
int32_t profile; // runtime
|
||||
int32_t profile; // runtime
|
||||
|
||||
int32_t s_name;
|
||||
int32_t s_file; // source file defined in
|
||||
int32_t s_name;
|
||||
int32_t s_file; // source file defined in
|
||||
|
||||
int32_t numparms;
|
||||
byte parm_size[MAX_PARMS];
|
||||
int32_t numparms;
|
||||
byte parm_size[MAX_PARMS];
|
||||
} dfunction_t;
|
||||
|
||||
|
||||
#define PROG_VERSION 6
|
||||
#define PROG_VERSION 6
|
||||
typedef struct
|
||||
{
|
||||
int32_t version;
|
||||
int32_t crc; // check of header file
|
||||
int32_t version;
|
||||
int32_t crc; // check of header file
|
||||
|
||||
int32_t ofs_statements;
|
||||
int32_t numstatements; // statement 0 is an error
|
||||
int32_t ofs_statements;
|
||||
int32_t numstatements; // statement 0 is an error
|
||||
|
||||
int32_t ofs_globaldefs;
|
||||
int32_t numglobaldefs;
|
||||
int32_t ofs_globaldefs;
|
||||
int32_t numglobaldefs;
|
||||
|
||||
int32_t ofs_fielddefs;
|
||||
int32_t numfielddefs;
|
||||
int32_t ofs_fielddefs;
|
||||
int32_t numfielddefs;
|
||||
|
||||
int32_t ofs_functions;
|
||||
int32_t numfunctions; // function 0 is an empty
|
||||
int32_t ofs_functions;
|
||||
int32_t numfunctions; // function 0 is an empty
|
||||
|
||||
int32_t ofs_strings;
|
||||
int32_t numstrings; // first string is a null string
|
||||
int32_t ofs_strings;
|
||||
int32_t numstrings; // first string is a null string
|
||||
|
||||
int32_t ofs_globals;
|
||||
int32_t numglobals;
|
||||
int32_t ofs_globals;
|
||||
int32_t numglobals;
|
||||
|
||||
int32_t entityfields;
|
||||
int32_t entityfields;
|
||||
} dprograms_t;
|
||||
|
||||
#endif /* __PR_COMP_H */
|
||||
#endif /* __PR_COMP_H */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
663
source/pr_exec.c
663
source/pr_exec.c
|
@ -23,22 +23,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int32_t s;
|
||||
dfunction_t *f;
|
||||
int32_t s;
|
||||
dfunction_t *f;
|
||||
} prstack_t;
|
||||
|
||||
#define MAX_STACK_DEPTH 64 /* was 32 */
|
||||
static prstack_t pr_stack[MAX_STACK_DEPTH];
|
||||
static int32_t pr_depth;
|
||||
#define MAX_STACK_DEPTH 64 /* was 32 */
|
||||
static prstack_t pr_stack[MAX_STACK_DEPTH];
|
||||
static int32_t pr_depth;
|
||||
|
||||
#define LOCALSTACK_SIZE 2048
|
||||
static int32_t localstack[LOCALSTACK_SIZE];
|
||||
static int32_t localstack_used;
|
||||
#define LOCALSTACK_SIZE 2048
|
||||
static int32_t localstack[LOCALSTACK_SIZE];
|
||||
static int32_t localstack_used;
|
||||
|
||||
bool pr_trace;
|
||||
dfunction_t *pr_xfunction;
|
||||
int32_t pr_xstatement;
|
||||
int32_t pr_argc;
|
||||
bool pr_trace;
|
||||
dfunction_t *pr_xfunction;
|
||||
int32_t pr_xstatement;
|
||||
int32_t pr_argc;
|
||||
|
||||
static const char *pr_opnames[] =
|
||||
{
|
||||
|
@ -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;
|
||||
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;
|
||||
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;
|
||||
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,21 +255,21 @@ 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_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();
|
||||
|
||||
Con_Printf("%s\n", string);
|
||||
|
||||
pr_depth = 0; // dump the stack so host_error can shutdown functions
|
||||
pr_depth = 0; // dump the stack so host_error can shutdown functions
|
||||
|
||||
Host_Error("Program error");
|
||||
}
|
||||
|
@ -280,38 +281,38 @@ 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;
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
pr_xfunction = f;
|
||||
return f->first_statement - 1; // offset the s++
|
||||
return f->first_statement - 1; // offset the s++
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
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,20 +354,20 @@ 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;
|
||||
dfunction_t *f, *newf;
|
||||
eval_t *ptr;
|
||||
dstatement_t *st;
|
||||
dfunction_t *f, *newf;
|
||||
int32_t profile, startprofile;
|
||||
edict_t *ed;
|
||||
int32_t exitdepth;
|
||||
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,274 +380,276 @@ void PR_ExecuteProgram (func_t fnum)
|
|||
st = &pr_statements[PR_EnterFunction(f)];
|
||||
startprofile = profile = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
st++; /* next statement */
|
||||
|
||||
if (++profile > 100000)
|
||||
while(1)
|
||||
{
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("runaway loop error");
|
||||
}
|
||||
st++; /* next statement */
|
||||
|
||||
if (pr_trace)
|
||||
PR_PrintStatement(st);
|
||||
|
||||
switch (st->op)
|
||||
{
|
||||
case OP_ADD_F:
|
||||
OPC->_float = OPA->_float + OPB->_float;
|
||||
break;
|
||||
case OP_ADD_V:
|
||||
OPC->vector[0] = OPA->vector[0] + OPB->vector[0];
|
||||
OPC->vector[1] = OPA->vector[1] + OPB->vector[1];
|
||||
OPC->vector[2] = OPA->vector[2] + OPB->vector[2];
|
||||
break;
|
||||
|
||||
case OP_SUB_F:
|
||||
OPC->_float = OPA->_float - OPB->_float;
|
||||
break;
|
||||
case OP_SUB_V:
|
||||
OPC->vector[0] = OPA->vector[0] - OPB->vector[0];
|
||||
OPC->vector[1] = OPA->vector[1] - OPB->vector[1];
|
||||
OPC->vector[2] = OPA->vector[2] - OPB->vector[2];
|
||||
break;
|
||||
|
||||
case OP_MUL_F:
|
||||
OPC->_float = OPA->_float * OPB->_float;
|
||||
break;
|
||||
case OP_MUL_V:
|
||||
OPC->_float = OPA->vector[0] * OPB->vector[0] +
|
||||
OPA->vector[1] * OPB->vector[1] +
|
||||
OPA->vector[2] * OPB->vector[2];
|
||||
break;
|
||||
case OP_MUL_FV:
|
||||
OPC->vector[0] = OPA->_float * OPB->vector[0];
|
||||
OPC->vector[1] = OPA->_float * OPB->vector[1];
|
||||
OPC->vector[2] = OPA->_float * OPB->vector[2];
|
||||
break;
|
||||
case OP_MUL_VF:
|
||||
OPC->vector[0] = OPB->_float * OPA->vector[0];
|
||||
OPC->vector[1] = OPB->_float * OPA->vector[1];
|
||||
OPC->vector[2] = OPB->_float * OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_DIV_F:
|
||||
OPC->_float = OPA->_float / OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_BITAND:
|
||||
OPC->_float = (int32_t)OPA->_float & (int32_t)OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_BITOR:
|
||||
OPC->_float = (int32_t)OPA->_float | (int32_t)OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_GE:
|
||||
OPC->_float = OPA->_float >= OPB->_float;
|
||||
break;
|
||||
case OP_LE:
|
||||
OPC->_float = OPA->_float <= OPB->_float;
|
||||
break;
|
||||
case OP_GT:
|
||||
OPC->_float = OPA->_float > OPB->_float;
|
||||
break;
|
||||
case OP_LT:
|
||||
OPC->_float = OPA->_float < OPB->_float;
|
||||
break;
|
||||
case OP_AND:
|
||||
OPC->_float = OPA->_float && OPB->_float;
|
||||
break;
|
||||
case OP_OR:
|
||||
OPC->_float = OPA->_float || OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_NOT_F:
|
||||
OPC->_float = !OPA->_float;
|
||||
break;
|
||||
case OP_NOT_V:
|
||||
OPC->_float = !OPA->vector[0] && !OPA->vector[1] && !OPA->vector[2];
|
||||
break;
|
||||
case OP_NOT_S:
|
||||
OPC->_float = !OPA->string || !*PR_GetString(OPA->string);
|
||||
break;
|
||||
case OP_NOT_FNC:
|
||||
OPC->_float = !OPA->function;
|
||||
break;
|
||||
case OP_NOT_ENT:
|
||||
OPC->_float = (PROG_TO_EDICT(OPA->edict) == sv.edicts);
|
||||
break;
|
||||
|
||||
case OP_EQ_F:
|
||||
OPC->_float = OPA->_float == OPB->_float;
|
||||
break;
|
||||
case OP_EQ_V:
|
||||
OPC->_float = (OPA->vector[0] == OPB->vector[0]) &&
|
||||
(OPA->vector[1] == OPB->vector[1]) &&
|
||||
(OPA->vector[2] == OPB->vector[2]);
|
||||
break;
|
||||
case OP_EQ_S:
|
||||
OPC->_float = !strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string));
|
||||
break;
|
||||
case OP_EQ_E:
|
||||
OPC->_float = OPA->_int == OPB->_int;
|
||||
break;
|
||||
case OP_EQ_FNC:
|
||||
OPC->_float = OPA->function == OPB->function;
|
||||
break;
|
||||
|
||||
case OP_NE_F:
|
||||
OPC->_float = OPA->_float != OPB->_float;
|
||||
break;
|
||||
case OP_NE_V:
|
||||
OPC->_float = (OPA->vector[0] != OPB->vector[0]) ||
|
||||
(OPA->vector[1] != OPB->vector[1]) ||
|
||||
(OPA->vector[2] != OPB->vector[2]);
|
||||
break;
|
||||
case OP_NE_S:
|
||||
OPC->_float = strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string));
|
||||
break;
|
||||
case OP_NE_E:
|
||||
OPC->_float = OPA->_int != OPB->_int;
|
||||
break;
|
||||
case OP_NE_FNC:
|
||||
OPC->_float = OPA->function != OPB->function;
|
||||
break;
|
||||
|
||||
case OP_STORE_F:
|
||||
case OP_STORE_ENT:
|
||||
case OP_STORE_FLD: // integers
|
||||
case OP_STORE_S:
|
||||
case OP_STORE_FNC: // pointers
|
||||
OPB->_int = OPA->_int;
|
||||
break;
|
||||
case OP_STORE_V:
|
||||
OPB->vector[0] = OPA->vector[0];
|
||||
OPB->vector[1] = OPA->vector[1];
|
||||
OPB->vector[2] = OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_STOREP_F:
|
||||
case OP_STOREP_ENT:
|
||||
case OP_STOREP_FLD: // integers
|
||||
case OP_STOREP_S:
|
||||
case OP_STOREP_FNC: // pointers
|
||||
ptr = (eval_t *)((byte *)sv.edicts + OPB->_int);
|
||||
ptr->_int = OPA->_int;
|
||||
break;
|
||||
case OP_STOREP_V:
|
||||
ptr = (eval_t *)((byte *)sv.edicts + OPB->_int);
|
||||
ptr->vector[0] = OPA->vector[0];
|
||||
ptr->vector[1] = OPA->vector[1];
|
||||
ptr->vector[2] = OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_ADDRESS:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
if (ed == (edict_t *)sv.edicts && sv.state == ss_active)
|
||||
if(++profile > 100000)
|
||||
{
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("assignment to world entity");
|
||||
PR_RunError("runaway loop error");
|
||||
}
|
||||
OPC->_int = (byte *)((int32_t *)&ed->v + OPB->_int) - (byte *)sv.edicts;
|
||||
break;
|
||||
|
||||
case OP_LOAD_F:
|
||||
case OP_LOAD_FLD:
|
||||
case OP_LOAD_ENT:
|
||||
case OP_LOAD_S:
|
||||
case OP_LOAD_FNC:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int;
|
||||
break;
|
||||
if(pr_trace)
|
||||
PR_PrintStatement(st);
|
||||
|
||||
case OP_LOAD_V:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int);
|
||||
OPC->vector[0] = ptr->vector[0];
|
||||
OPC->vector[1] = ptr->vector[1];
|
||||
OPC->vector[2] = ptr->vector[2];
|
||||
break;
|
||||
|
||||
case OP_IFNOT:
|
||||
if (!OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_IF:
|
||||
if (OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_GOTO:
|
||||
st += st->a - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_CALL0:
|
||||
case OP_CALL1:
|
||||
case OP_CALL2:
|
||||
case OP_CALL3:
|
||||
case OP_CALL4:
|
||||
case OP_CALL5:
|
||||
case OP_CALL6:
|
||||
case OP_CALL7:
|
||||
case OP_CALL8:
|
||||
pr_xfunction->profile += profile - startprofile;
|
||||
startprofile = profile;
|
||||
pr_xstatement = st - pr_statements;
|
||||
pr_argc = st->op - OP_CALL0;
|
||||
if (!OPA->function)
|
||||
PR_RunError("NULL function");
|
||||
newf = &pr_functions[OPA->function];
|
||||
if (newf->first_statement < 0)
|
||||
{ // Built-in function
|
||||
int32_t i = -newf->first_statement;
|
||||
if (i >= pr_numbuiltins)
|
||||
PR_RunError("Bad builtin call number %" PRIi32 "", i);
|
||||
pr_builtins[i]();
|
||||
switch(st->op)
|
||||
{
|
||||
case OP_ADD_F:
|
||||
OPC->_float = OPA->_float + OPB->_float;
|
||||
break;
|
||||
case OP_ADD_V:
|
||||
OPC->vector[0] = OPA->vector[0] + OPB->vector[0];
|
||||
OPC->vector[1] = OPA->vector[1] + OPB->vector[1];
|
||||
OPC->vector[2] = OPA->vector[2] + OPB->vector[2];
|
||||
break;
|
||||
|
||||
case OP_SUB_F:
|
||||
OPC->_float = OPA->_float - OPB->_float;
|
||||
break;
|
||||
case OP_SUB_V:
|
||||
OPC->vector[0] = OPA->vector[0] - OPB->vector[0];
|
||||
OPC->vector[1] = OPA->vector[1] - OPB->vector[1];
|
||||
OPC->vector[2] = OPA->vector[2] - OPB->vector[2];
|
||||
break;
|
||||
|
||||
case OP_MUL_F:
|
||||
OPC->_float = OPA->_float * OPB->_float;
|
||||
break;
|
||||
case OP_MUL_V:
|
||||
OPC->_float = OPA->vector[0] * OPB->vector[0] +
|
||||
OPA->vector[1] * OPB->vector[1] +
|
||||
OPA->vector[2] * OPB->vector[2];
|
||||
break;
|
||||
case OP_MUL_FV:
|
||||
OPC->vector[0] = OPA->_float * OPB->vector[0];
|
||||
OPC->vector[1] = OPA->_float * OPB->vector[1];
|
||||
OPC->vector[2] = OPA->_float * OPB->vector[2];
|
||||
break;
|
||||
case OP_MUL_VF:
|
||||
OPC->vector[0] = OPB->_float * OPA->vector[0];
|
||||
OPC->vector[1] = OPB->_float * OPA->vector[1];
|
||||
OPC->vector[2] = OPB->_float * OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_DIV_F:
|
||||
OPC->_float = OPA->_float / OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_BITAND:
|
||||
OPC->_float = (int32_t)OPA->_float & (int32_t)OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_BITOR:
|
||||
OPC->_float = (int32_t)OPA->_float | (int32_t)OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_GE:
|
||||
OPC->_float = OPA->_float >= OPB->_float;
|
||||
break;
|
||||
case OP_LE:
|
||||
OPC->_float = OPA->_float <= OPB->_float;
|
||||
break;
|
||||
case OP_GT:
|
||||
OPC->_float = OPA->_float > OPB->_float;
|
||||
break;
|
||||
case OP_LT:
|
||||
OPC->_float = OPA->_float < OPB->_float;
|
||||
break;
|
||||
case OP_AND:
|
||||
OPC->_float = OPA->_float && OPB->_float;
|
||||
break;
|
||||
case OP_OR:
|
||||
OPC->_float = OPA->_float || OPB->_float;
|
||||
break;
|
||||
|
||||
case OP_NOT_F:
|
||||
OPC->_float = !OPA->_float;
|
||||
break;
|
||||
case OP_NOT_V:
|
||||
OPC->_float = !OPA->vector[0] && !OPA->vector[1] && !OPA->vector[2];
|
||||
break;
|
||||
case OP_NOT_S:
|
||||
OPC->_float = !OPA->string || !*PR_GetString(OPA->string);
|
||||
break;
|
||||
case OP_NOT_FNC:
|
||||
OPC->_float = !OPA->function;
|
||||
break;
|
||||
case OP_NOT_ENT:
|
||||
OPC->_float = (PROG_TO_EDICT(OPA->edict) == sv.edicts);
|
||||
break;
|
||||
|
||||
case OP_EQ_F:
|
||||
OPC->_float = OPA->_float == OPB->_float;
|
||||
break;
|
||||
case OP_EQ_V:
|
||||
OPC->_float = (OPA->vector[0] == OPB->vector[0]) &&
|
||||
(OPA->vector[1] == OPB->vector[1]) &&
|
||||
(OPA->vector[2] == OPB->vector[2]);
|
||||
break;
|
||||
case OP_EQ_S:
|
||||
OPC->_float = !strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string));
|
||||
break;
|
||||
case OP_EQ_E:
|
||||
OPC->_float = OPA->_int == OPB->_int;
|
||||
break;
|
||||
case OP_EQ_FNC:
|
||||
OPC->_float = OPA->function == OPB->function;
|
||||
break;
|
||||
|
||||
case OP_NE_F:
|
||||
OPC->_float = OPA->_float != OPB->_float;
|
||||
break;
|
||||
case OP_NE_V:
|
||||
OPC->_float = (OPA->vector[0] != OPB->vector[0]) ||
|
||||
(OPA->vector[1] != OPB->vector[1]) ||
|
||||
(OPA->vector[2] != OPB->vector[2]);
|
||||
break;
|
||||
case OP_NE_S:
|
||||
OPC->_float = strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string));
|
||||
break;
|
||||
case OP_NE_E:
|
||||
OPC->_float = OPA->_int != OPB->_int;
|
||||
break;
|
||||
case OP_NE_FNC:
|
||||
OPC->_float = OPA->function != OPB->function;
|
||||
break;
|
||||
|
||||
case OP_STORE_F:
|
||||
case OP_STORE_ENT:
|
||||
case OP_STORE_FLD: // integers
|
||||
case OP_STORE_S:
|
||||
case OP_STORE_FNC: // pointers
|
||||
OPB->_int = OPA->_int;
|
||||
break;
|
||||
case OP_STORE_V:
|
||||
OPB->vector[0] = OPA->vector[0];
|
||||
OPB->vector[1] = OPA->vector[1];
|
||||
OPB->vector[2] = OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_STOREP_F:
|
||||
case OP_STOREP_ENT:
|
||||
case OP_STOREP_FLD: // integers
|
||||
case OP_STOREP_S:
|
||||
case OP_STOREP_FNC: // pointers
|
||||
ptr = (eval_t *)((byte *)sv.edicts + OPB->_int);
|
||||
ptr->_int = OPA->_int;
|
||||
break;
|
||||
case OP_STOREP_V:
|
||||
ptr = (eval_t *)((byte *)sv.edicts + OPB->_int);
|
||||
ptr->vector[0] = OPA->vector[0];
|
||||
ptr->vector[1] = OPA->vector[1];
|
||||
ptr->vector[2] = OPA->vector[2];
|
||||
break;
|
||||
|
||||
case OP_ADDRESS:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
if(ed == (edict_t *)sv.edicts && sv.state == ss_active)
|
||||
{
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("assignment to world entity");
|
||||
}
|
||||
OPC->_int = (byte *)((int32_t *)&ed->v + OPB->_int) - (byte *)sv.edicts;
|
||||
break;
|
||||
|
||||
case OP_LOAD_F:
|
||||
case OP_LOAD_FLD:
|
||||
case OP_LOAD_ENT:
|
||||
case OP_LOAD_S:
|
||||
case OP_LOAD_FNC:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
OPC->_int = ((eval_t *)((int32_t *)&ed->v + OPB->_int))->_int;
|
||||
break;
|
||||
|
||||
case OP_LOAD_V:
|
||||
ed = PROG_TO_EDICT(OPA->edict);
|
||||
#ifdef PARANOID
|
||||
NUM_FOR_EDICT(ed); // Make sure it's in range
|
||||
#endif
|
||||
ptr = (eval_t *)((int32_t *)&ed->v + OPB->_int);
|
||||
OPC->vector[0] = ptr->vector[0];
|
||||
OPC->vector[1] = ptr->vector[1];
|
||||
OPC->vector[2] = ptr->vector[2];
|
||||
break;
|
||||
|
||||
case OP_IFNOT:
|
||||
if(!OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_IF:
|
||||
if(OPA->_int)
|
||||
st += st->b - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_GOTO:
|
||||
st += st->a - 1; /* -1 to offset the st++ */
|
||||
break;
|
||||
|
||||
case OP_CALL0:
|
||||
case OP_CALL1:
|
||||
case OP_CALL2:
|
||||
case OP_CALL3:
|
||||
case OP_CALL4:
|
||||
case OP_CALL5:
|
||||
case OP_CALL6:
|
||||
case OP_CALL7:
|
||||
case OP_CALL8:
|
||||
pr_xfunction->profile += profile - startprofile;
|
||||
startprofile = profile;
|
||||
pr_xstatement = st - pr_statements;
|
||||
pr_argc = st->op - OP_CALL0;
|
||||
if(!OPA->function)
|
||||
PR_RunError("NULL function");
|
||||
newf = &pr_functions[OPA->function];
|
||||
if(newf->first_statement < 0)
|
||||
{
|
||||
// Built-in function
|
||||
int32_t i = -newf->first_statement;
|
||||
if(i >= pr_numbuiltins)
|
||||
PR_RunError("Bad builtin call number %" PRIi32 "", i);
|
||||
pr_builtins[i]();
|
||||
break;
|
||||
}
|
||||
// Normal function
|
||||
st = &pr_statements[PR_EnterFunction(newf)];
|
||||
break;
|
||||
|
||||
case OP_DONE:
|
||||
case OP_RETURN:
|
||||
pr_xfunction->profile += profile - startprofile;
|
||||
startprofile = profile;
|
||||
pr_xstatement = st - pr_statements;
|
||||
pr_globals[OFS_RETURN] = pr_globals[(uint16_t)st->a];
|
||||
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
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_STATE:
|
||||
ed = PROG_TO_EDICT(pr_global_struct->self);
|
||||
ed->v.nextthink = pr_global_struct->time + 0.1;
|
||||
ed->v.frame = OPA->_float;
|
||||
ed->v.think = OPB->function;
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("Bad opcode %" PRIi32 "", st->op);
|
||||
}
|
||||
// Normal function
|
||||
st = &pr_statements[PR_EnterFunction(newf)];
|
||||
break;
|
||||
|
||||
case OP_DONE:
|
||||
case OP_RETURN:
|
||||
pr_xfunction->profile += profile - startprofile;
|
||||
startprofile = profile;
|
||||
pr_xstatement = st - pr_statements;
|
||||
pr_globals[OFS_RETURN] = pr_globals[(uint16_t)st->a];
|
||||
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
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_STATE:
|
||||
ed = PROG_TO_EDICT(pr_global_struct->self);
|
||||
ed->v.nextthink = pr_global_struct->time + 0.1;
|
||||
ed->v.frame = OPA->_float;
|
||||
ed->v.think = OPB->function;
|
||||
break;
|
||||
|
||||
default:
|
||||
pr_xstatement = st - pr_statements;
|
||||
PR_RunError("Bad opcode %" PRIi32 "", st->op);
|
||||
}
|
||||
} /* end of while(1) loop */
|
||||
} /* end of while(1) loop */
|
||||
}
|
||||
#undef OPA
|
||||
#undef OPB
|
||||
|
|
|
@ -24,5 +24,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "progdefs.q1"
|
||||
|
||||
#endif /* __PROGDEFS_H */
|
||||
#endif /* __PROGDEFS_H */
|
||||
|
||||
|
|
138
source/progs.h
138
source/progs.h
|
@ -23,122 +23,122 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef _QUAKE_PROGS_H
|
||||
#define _QUAKE_PROGS_H
|
||||
|
||||
#include "pr_comp.h" /* defs shared with qcc */
|
||||
#include "progdefs.h" /* generated by program cdefs */
|
||||
#include "pr_comp.h" /* defs shared with qcc */
|
||||
#include "progdefs.h" /* generated by program cdefs */
|
||||
|
||||
typedef union eval_s
|
||||
{
|
||||
string_t string;
|
||||
float _float;
|
||||
float vector[3];
|
||||
func_t function;
|
||||
int32_t _int;
|
||||
int32_t edict;
|
||||
string_t string;
|
||||
float _float;
|
||||
float vector[3];
|
||||
func_t function;
|
||||
int32_t _int;
|
||||
int32_t edict;
|
||||
} eval_t;
|
||||
|
||||
#define MAX_ENT_LEAFS 32
|
||||
#define MAX_ENT_LEAFS 32
|
||||
typedef struct edict_s
|
||||
{
|
||||
bool free;
|
||||
link_t area; /* linked to a division node or leaf */
|
||||
bool free;
|
||||
link_t area; /* linked to a division node or leaf */
|
||||
|
||||
int32_t num_leafs;
|
||||
int32_t leafnums[MAX_ENT_LEAFS];
|
||||
int32_t num_leafs;
|
||||
int32_t leafnums[MAX_ENT_LEAFS];
|
||||
|
||||
entity_state_t baseline;
|
||||
uint8_t alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
|
||||
bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
|
||||
entity_state_t baseline;
|
||||
uint8_t alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
|
||||
bool sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
|
||||
|
||||
float freetime; /* sv.time when the object was freed */
|
||||
entvars_t v; /* C exported fields from progs */
|
||||
float freetime; /* sv.time when the object was freed */
|
||||
entvars_t v; /* C exported fields from progs */
|
||||
|
||||
/* other fields from progs come immediately after */
|
||||
} edict_t;
|
||||
|
||||
#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
|
||||
#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern dprograms_t *progs;
|
||||
extern dfunction_t *pr_functions;
|
||||
extern dstatement_t *pr_statements;
|
||||
extern globalvars_t *pr_global_struct;
|
||||
extern float *pr_globals; /* same as pr_global_struct */
|
||||
extern dprograms_t *progs;
|
||||
extern dfunction_t *pr_functions;
|
||||
extern dstatement_t *pr_statements;
|
||||
extern globalvars_t *pr_global_struct;
|
||||
extern float *pr_globals; /* same as pr_global_struct */
|
||||
|
||||
extern int32_t pr_edict_size; /* in bytes */
|
||||
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))
|
||||
#define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts) / pr_edict_size)
|
||||
#define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
|
||||
#define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts) / pr_edict_size)
|
||||
*/
|
||||
edict_t *EDICT_NUM(int32_t n);
|
||||
int32_t NUM_FOR_EDICT(edict_t *e);
|
||||
|
||||
#define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
|
||||
#define NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
|
||||
|
||||
#define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
|
||||
#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
|
||||
#define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
|
||||
#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
|
||||
|
||||
#define G_FLOAT(o) (pr_globals[o])
|
||||
#define G_INT(o) (*(int32_t *)&pr_globals[o])
|
||||
#define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int32_t *)&pr_globals[o]))
|
||||
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
|
||||
#define G_VECTOR(o) (&pr_globals[o])
|
||||
#define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
|
||||
#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
|
||||
#define G_FLOAT(o) (pr_globals[o])
|
||||
#define G_INT(o) (*(int32_t *)&pr_globals[o])
|
||||
#define G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(int32_t *)&pr_globals[o]))
|
||||
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
|
||||
#define G_VECTOR(o) (&pr_globals[o])
|
||||
#define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
|
||||
#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
|
||||
|
||||
#define E_FLOAT(e,o) (((float*)&e->v)[o])
|
||||
#define E_INT(e,o) (*(int32_t *)&((float*)&e->v)[o])
|
||||
#define E_VECTOR(e,o) (&((float*)&e->v)[o])
|
||||
#define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)&e->v)[o]))
|
||||
#define E_FLOAT(e,o) (((float*)&e->v)[o])
|
||||
#define E_INT(e,o) (*(int32_t *)&((float*)&e->v)[o])
|
||||
#define E_VECTOR(e,o) (&((float*)&e->v)[o])
|
||||
#define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)&e->v)[o]))
|
||||
|
||||
extern int32_t type_size[8];
|
||||
extern int32_t type_size[8];
|
||||
|
||||
typedef void (*builtin_t) (void);
|
||||
extern builtin_t *pr_builtins;
|
||||
extern int32_t pr_numbuiltins;
|
||||
typedef void (*builtin_t)(void);
|
||||
extern builtin_t *pr_builtins;
|
||||
extern int32_t pr_numbuiltins;
|
||||
|
||||
extern int32_t pr_argc;
|
||||
extern int32_t pr_argc;
|
||||
|
||||
extern bool pr_trace;
|
||||
extern dfunction_t *pr_xfunction;
|
||||
extern int32_t pr_xstatement;
|
||||
extern bool pr_trace;
|
||||
extern dfunction_t *pr_xfunction;
|
||||
extern int32_t pr_xstatement;
|
||||
|
||||
extern uint16_t pr_crc;
|
||||
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);
|
||||
|
||||
#endif /* _QUAKE_PROGS_H */
|
||||
#endif /* _QUAKE_PROGS_H */
|
||||
|
||||
|
|
|
@ -25,124 +25,124 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// protocol.h -- communications protocols
|
||||
|
||||
#define PROTOCOL_NETQUAKE 15 //johnfitz -- standard quake protocol
|
||||
#define PROTOCOL_FITZQUAKE 666 //johnfitz -- added new protocol for fitzquake 0.85
|
||||
#define PROTOCOL_RMQ 999
|
||||
#define PROTOCOL_NETQUAKE 15 //johnfitz -- standard quake protocol
|
||||
#define PROTOCOL_FITZQUAKE 666 //johnfitz -- added new protocol for fitzquake 0.85
|
||||
#define PROTOCOL_RMQ 999
|
||||
|
||||
// PROTOCOL_RMQ protocol flags
|
||||
#define PRFL_SHORTANGLE (1 << 1)
|
||||
#define PRFL_FLOATANGLE (1 << 2)
|
||||
#define PRFL_24BITCOORD (1 << 3)
|
||||
#define PRFL_FLOATCOORD (1 << 4)
|
||||
#define PRFL_EDICTSCALE (1 << 5)
|
||||
#define PRFL_ALPHASANITY (1 << 6) // cleanup insanity with alpha
|
||||
#define PRFL_INT32COORD (1 << 7)
|
||||
#define PRFL_MOREFLAGS (1 << 31) // not supported
|
||||
#define PRFL_SHORTANGLE (1 << 1)
|
||||
#define PRFL_FLOATANGLE (1 << 2)
|
||||
#define PRFL_24BITCOORD (1 << 3)
|
||||
#define PRFL_FLOATCOORD (1 << 4)
|
||||
#define PRFL_EDICTSCALE (1 << 5)
|
||||
#define PRFL_ALPHASANITY (1 << 6) // cleanup insanity with alpha
|
||||
#define PRFL_INT32COORD (1 << 7)
|
||||
#define PRFL_MOREFLAGS (1 << 31) // not supported
|
||||
|
||||
// if the high bit of the servercmd is set, the low bits are fast update flags:
|
||||
#define U_MOREBITS (1<<0)
|
||||
#define U_ORIGIN1 (1<<1)
|
||||
#define U_ORIGIN2 (1<<2)
|
||||
#define U_ORIGIN3 (1<<3)
|
||||
#define U_ANGLE2 (1<<4)
|
||||
#define U_STEP (1<<5) //johnfitz -- was U_NOLERP, renamed since it's only used for MOVETYPE_STEP
|
||||
#define U_FRAME (1<<6)
|
||||
#define U_SIGNAL (1<<7) // just differentiates from other updates
|
||||
#define U_MOREBITS (1<<0)
|
||||
#define U_ORIGIN1 (1<<1)
|
||||
#define U_ORIGIN2 (1<<2)
|
||||
#define U_ORIGIN3 (1<<3)
|
||||
#define U_ANGLE2 (1<<4)
|
||||
#define U_STEP (1<<5) //johnfitz -- was U_NOLERP, renamed since it's only used for MOVETYPE_STEP
|
||||
#define U_FRAME (1<<6)
|
||||
#define U_SIGNAL (1<<7) // just differentiates from other updates
|
||||
|
||||
// svc_update can pass all of the fast update bits, plus more
|
||||
#define U_ANGLE1 (1<<8)
|
||||
#define U_ANGLE3 (1<<9)
|
||||
#define U_MODEL (1<<10)
|
||||
#define U_COLORMAP (1<<11)
|
||||
#define U_SKIN (1<<12)
|
||||
#define U_EFFECTS (1<<13)
|
||||
#define U_LONGENTITY (1<<14)
|
||||
#define U_ANGLE1 (1<<8)
|
||||
#define U_ANGLE3 (1<<9)
|
||||
#define U_MODEL (1<<10)
|
||||
#define U_COLORMAP (1<<11)
|
||||
#define U_SKIN (1<<12)
|
||||
#define U_EFFECTS (1<<13)
|
||||
#define U_LONGENTITY (1<<14)
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- new bits
|
||||
#define U_EXTEND1 (1<<15)
|
||||
#define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline
|
||||
#define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte)
|
||||
#define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte)
|
||||
#define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ent->v.nextthink - sv.time, used for lerping
|
||||
#define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored
|
||||
#define U_UNUSED21 (1<<21)
|
||||
#define U_UNUSED22 (1<<22)
|
||||
#define U_EXTEND2 (1<<23) // another byte to follow, future expansion
|
||||
#define U_EXTEND1 (1<<15)
|
||||
#define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline
|
||||
#define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte)
|
||||
#define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte)
|
||||
#define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ent->v.nextthink - sv.time, used for lerping
|
||||
#define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored
|
||||
#define U_UNUSED21 (1<<21)
|
||||
#define U_UNUSED22 (1<<22)
|
||||
#define U_EXTEND2 (1<<23) // another byte to follow, future expansion
|
||||
//johnfitz
|
||||
|
||||
//johnfitz -- PROTOCOL_NEHAHRA transparency
|
||||
#define U_TRANS (1<<15)
|
||||
#define U_TRANS (1<<15)
|
||||
//johnfitz
|
||||
|
||||
#define SU_VIEWHEIGHT (1<<0)
|
||||
#define SU_IDEALPITCH (1<<1)
|
||||
#define SU_PUNCH1 (1<<2)
|
||||
#define SU_PUNCH2 (1<<3)
|
||||
#define SU_PUNCH3 (1<<4)
|
||||
#define SU_VELOCITY1 (1<<5)
|
||||
#define SU_VELOCITY2 (1<<6)
|
||||
#define SU_VELOCITY3 (1<<7)
|
||||
#define SU_UNUSED8 (1<<8) //AVAILABLE BIT
|
||||
#define SU_ITEMS (1<<9)
|
||||
#define SU_ONGROUND (1<<10) // no data follows, the bit is it
|
||||
#define SU_INWATER (1<<11) // no data follows, the bit is it
|
||||
#define SU_WEAPONFRAME (1<<12)
|
||||
#define SU_ARMOR (1<<13)
|
||||
#define SU_WEAPON (1<<14)
|
||||
#define SU_VIEWHEIGHT (1<<0)
|
||||
#define SU_IDEALPITCH (1<<1)
|
||||
#define SU_PUNCH1 (1<<2)
|
||||
#define SU_PUNCH2 (1<<3)
|
||||
#define SU_PUNCH3 (1<<4)
|
||||
#define SU_VELOCITY1 (1<<5)
|
||||
#define SU_VELOCITY2 (1<<6)
|
||||
#define SU_VELOCITY3 (1<<7)
|
||||
#define SU_UNUSED8 (1<<8) //AVAILABLE BIT
|
||||
#define SU_ITEMS (1<<9)
|
||||
#define SU_ONGROUND (1<<10) // no data follows, the bit is it
|
||||
#define SU_INWATER (1<<11) // no data follows, the bit is it
|
||||
#define SU_WEAPONFRAME (1<<12)
|
||||
#define SU_ARMOR (1<<13)
|
||||
#define SU_WEAPON (1<<14)
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- new bits
|
||||
#define SU_EXTEND1 (1<<15) // another byte to follow
|
||||
#define SU_WEAPON2 (1<<16) // 1 byte, this is .weaponmodel & 0xFF00 (second byte)
|
||||
#define SU_ARMOR2 (1<<17) // 1 byte, this is .armorvalue & 0xFF00 (second byte)
|
||||
#define SU_AMMO2 (1<<18) // 1 byte, this is .currentammo & 0xFF00 (second byte)
|
||||
#define SU_SHELLS2 (1<<19) // 1 byte, this is .ammo_shells & 0xFF00 (second byte)
|
||||
#define SU_NAILS2 (1<<20) // 1 byte, this is .ammo_nails & 0xFF00 (second byte)
|
||||
#define SU_ROCKETS2 (1<<21) // 1 byte, this is .ammo_rockets & 0xFF00 (second byte)
|
||||
#define SU_CELLS2 (1<<22) // 1 byte, this is .ammo_cells & 0xFF00 (second byte)
|
||||
#define SU_EXTEND2 (1<<23) // another byte to follow
|
||||
#define SU_WEAPONFRAME2 (1<<24) // 1 byte, this is .weaponframe & 0xFF00 (second byte)
|
||||
#define SU_WEAPONALPHA (1<<25) // 1 byte, this is alpha for weaponmodel, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
|
||||
#define SU_UNUSED26 (1<<26)
|
||||
#define SU_UNUSED27 (1<<27)
|
||||
#define SU_UNUSED28 (1<<28)
|
||||
#define SU_UNUSED29 (1<<29)
|
||||
#define SU_UNUSED30 (1<<30)
|
||||
#define SU_EXTEND3 (1<<31) // another byte to follow, future expansion
|
||||
#define SU_EXTEND1 (1<<15) // another byte to follow
|
||||
#define SU_WEAPON2 (1<<16) // 1 byte, this is .weaponmodel & 0xFF00 (second byte)
|
||||
#define SU_ARMOR2 (1<<17) // 1 byte, this is .armorvalue & 0xFF00 (second byte)
|
||||
#define SU_AMMO2 (1<<18) // 1 byte, this is .currentammo & 0xFF00 (second byte)
|
||||
#define SU_SHELLS2 (1<<19) // 1 byte, this is .ammo_shells & 0xFF00 (second byte)
|
||||
#define SU_NAILS2 (1<<20) // 1 byte, this is .ammo_nails & 0xFF00 (second byte)
|
||||
#define SU_ROCKETS2 (1<<21) // 1 byte, this is .ammo_rockets & 0xFF00 (second byte)
|
||||
#define SU_CELLS2 (1<<22) // 1 byte, this is .ammo_cells & 0xFF00 (second byte)
|
||||
#define SU_EXTEND2 (1<<23) // another byte to follow
|
||||
#define SU_WEAPONFRAME2 (1<<24) // 1 byte, this is .weaponframe & 0xFF00 (second byte)
|
||||
#define SU_WEAPONALPHA (1<<25) // 1 byte, this is alpha for weaponmodel, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
|
||||
#define SU_UNUSED26 (1<<26)
|
||||
#define SU_UNUSED27 (1<<27)
|
||||
#define SU_UNUSED28 (1<<28)
|
||||
#define SU_UNUSED29 (1<<29)
|
||||
#define SU_UNUSED30 (1<<30)
|
||||
#define SU_EXTEND3 (1<<31) // another byte to follow, future expansion
|
||||
//johnfitz
|
||||
|
||||
// a sound with no channel is a local only sound
|
||||
#define SND_VOLUME (1<<0) // a byte
|
||||
#define SND_ATTENUATION (1<<1) // a byte
|
||||
#define SND_LOOPING (1<<2) // a long
|
||||
#define SND_VOLUME (1<<0) // a byte
|
||||
#define SND_ATTENUATION (1<<1) // a byte
|
||||
#define SND_LOOPING (1<<2) // a long
|
||||
|
||||
#define DEFAULT_SOUND_PACKET_VOLUME 255
|
||||
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
|
||||
#define DEFAULT_SOUND_PACKET_VOLUME 255
|
||||
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- new bits
|
||||
#define SND_LARGEENTITY (1<<3) // a int16_t + byte (instead of just a int16_t)
|
||||
#define SND_LARGESOUND (1<<4) // a int16_t soundindex (instead of a byte)
|
||||
#define SND_LARGEENTITY (1<<3) // a int16_t + byte (instead of just a int16_t)
|
||||
#define SND_LARGESOUND (1<<4) // a int16_t soundindex (instead of a byte)
|
||||
//johnfitz
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- flags for entity baseline messages
|
||||
#define B_LARGEMODEL (1<<0) // modelindex is int16_t instead of byte
|
||||
#define B_LARGEFRAME (1<<1) // frame is int16_t instead of byte
|
||||
#define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
|
||||
#define B_LARGEMODEL (1<<0) // modelindex is int16_t instead of byte
|
||||
#define B_LARGEFRAME (1<<1) // frame is int16_t instead of byte
|
||||
#define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
|
||||
//johnfitz
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- alpha encoding
|
||||
#define ENTALPHA_DEFAULT 0 //entity's alpha is "default" (i.e. water obeys r_wateralpha) -- must be zero so zeroed out memory works
|
||||
#define ENTALPHA_ZERO 1 //entity is invisible (lowest possible alpha)
|
||||
#define ENTALPHA_ONE 255 //entity is fully opaque (highest possible alpha)
|
||||
#define ENTALPHA_ENCODE(a) (((a)==0)?ENTALPHA_DEFAULT:Q_rint(CLAMP(1,(a)*254.0f+1,255))) //server convert to byte to send to client
|
||||
#define ENTALPHA_DECODE(a) (((a)==ENTALPHA_DEFAULT)?1.0f:((float)(a)-1)/(254)) //client convert to float for rendering
|
||||
#define ENTALPHA_TOSAVE(a) (((a)==ENTALPHA_DEFAULT)?0.0f:(((a)==ENTALPHA_ZERO)?-1.0f:((float)(a)-1)/(254))) //server convert to float for savegame
|
||||
#define ENTALPHA_DEFAULT 0 //entity's alpha is "default" (i.e. water obeys r_wateralpha) -- must be zero so zeroed out memory works
|
||||
#define ENTALPHA_ZERO 1 //entity is invisible (lowest possible alpha)
|
||||
#define ENTALPHA_ONE 255 //entity is fully opaque (highest possible alpha)
|
||||
#define ENTALPHA_ENCODE(a) (((a)==0)?ENTALPHA_DEFAULT:Q_rint(CLAMP(1,(a)*254.0f+1,255))) //server convert to byte to send to client
|
||||
#define ENTALPHA_DECODE(a) (((a)==ENTALPHA_DEFAULT)?1.0f:((float)(a)-1)/(254)) //client convert to float for rendering
|
||||
#define ENTALPHA_TOSAVE(a) (((a)==ENTALPHA_DEFAULT)?0.0f:(((a)==ENTALPHA_ZERO)?-1.0f:((float)(a)-1)/(254))) //server convert to float for savegame
|
||||
//johnfitz
|
||||
|
||||
// defaults for clientinfo messages
|
||||
#define DEFAULT_VIEWHEIGHT 22
|
||||
#define DEFAULT_VIEWHEIGHT 22
|
||||
|
||||
// game types sent by serverinfo
|
||||
// these determine which intermission screen plays
|
||||
#define GAME_COOP 0
|
||||
#define GAME_DEATHMATCH 1
|
||||
#define GAME_COOP 0
|
||||
#define GAME_DEATHMATCH 1
|
||||
|
||||
//==================
|
||||
// note that there are some defs.qc that mirror to these numbers
|
||||
|
@ -152,106 +152,106 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
// server to client
|
||||
//
|
||||
#define svc_bad 0
|
||||
#define svc_nop 1
|
||||
#define svc_disconnect 2
|
||||
#define svc_updatestat 3 // [byte] [long]
|
||||
#define svc_version 4 // [long] server version
|
||||
#define svc_setview 5 // [int16_t] entity number
|
||||
#define svc_sound 6 // <see code>
|
||||
#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
|
||||
#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
|
||||
#define svc_lightstyle 12 // [byte] [string]
|
||||
#define svc_updatename 13 // [byte] [string]
|
||||
#define svc_updatefrags 14 // [byte] [int16_t]
|
||||
#define svc_clientdata 15 // <shortbits + data>
|
||||
#define svc_stopsound 16 // <see code>
|
||||
#define svc_updatecolors 17 // [byte] [byte]
|
||||
#define svc_particle 18 // [vec3] <variable>
|
||||
#define svc_damage 19
|
||||
#define svc_spawnstatic 20
|
||||
//#define svc_spawnbinary 21
|
||||
#define svc_spawnbaseline 22
|
||||
#define svc_temp_entity 23
|
||||
#define svc_setpause 24 // [byte] on / off
|
||||
#define svc_signonnum 25 // [byte] used for the signon sequence
|
||||
#define svc_centerprint 26 // [string] to put in center of the screen
|
||||
#define svc_killedmonster 27
|
||||
#define svc_foundsecret 28
|
||||
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
|
||||
#define svc_intermission 30 // [string] music
|
||||
#define svc_finale 31 // [string] music [string] text
|
||||
#define svc_cdtrack 32 // [byte] track [byte] looptrack
|
||||
#define svc_sellscreen 33
|
||||
#define svc_cutscene 34
|
||||
#define svc_bad 0
|
||||
#define svc_nop 1
|
||||
#define svc_disconnect 2
|
||||
#define svc_updatestat 3 // [byte] [long]
|
||||
#define svc_version 4 // [long] server version
|
||||
#define svc_setview 5 // [int16_t] entity number
|
||||
#define svc_sound 6 // <see code>
|
||||
#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
|
||||
#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
|
||||
#define svc_lightstyle 12 // [byte] [string]
|
||||
#define svc_updatename 13 // [byte] [string]
|
||||
#define svc_updatefrags 14 // [byte] [int16_t]
|
||||
#define svc_clientdata 15 // <shortbits + data>
|
||||
#define svc_stopsound 16 // <see code>
|
||||
#define svc_updatecolors 17 // [byte] [byte]
|
||||
#define svc_particle 18 // [vec3] <variable>
|
||||
#define svc_damage 19
|
||||
#define svc_spawnstatic 20
|
||||
//#define svc_spawnbinary 21
|
||||
#define svc_spawnbaseline 22
|
||||
#define svc_temp_entity 23
|
||||
#define svc_setpause 24 // [byte] on / off
|
||||
#define svc_signonnum 25 // [byte] used for the signon sequence
|
||||
#define svc_centerprint 26 // [string] to put in center of the screen
|
||||
#define svc_killedmonster 27
|
||||
#define svc_foundsecret 28
|
||||
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
|
||||
#define svc_intermission 30 // [string] music
|
||||
#define svc_finale 31 // [string] music [string] text
|
||||
#define svc_cdtrack 32 // [byte] track [byte] looptrack
|
||||
#define svc_sellscreen 33
|
||||
#define svc_cutscene 34
|
||||
|
||||
//johnfitz -- PROTOCOL_FITZQUAKE -- new server messages
|
||||
#define svc_skybox 37 // [string] name
|
||||
#define svc_bf 40
|
||||
#define svc_fog 41 // [byte] density [byte] red [byte] green [byte] blue [float] time
|
||||
#define svc_spawnbaseline2 42 // support for large modelindex, large framenum, alpha, using flags
|
||||
#define svc_spawnstatic2 43 // support for large modelindex, large framenum, alpha, using flags
|
||||
#define svc_spawnstaticsound2 44 // [coord3] [int16_t] samp [byte] vol [byte] aten
|
||||
#define svc_skybox 37 // [string] name
|
||||
#define svc_bf 40
|
||||
#define svc_fog 41 // [byte] density [byte] red [byte] green [byte] blue [float] time
|
||||
#define svc_spawnbaseline2 42 // support for large modelindex, large framenum, alpha, using flags
|
||||
#define svc_spawnstatic2 43 // support for large modelindex, large framenum, alpha, using flags
|
||||
#define svc_spawnstaticsound2 44 // [coord3] [int16_t] samp [byte] vol [byte] aten
|
||||
//johnfitz
|
||||
|
||||
//
|
||||
// client to server
|
||||
//
|
||||
#define clc_bad 0
|
||||
#define clc_nop 1
|
||||
#define clc_disconnect 2
|
||||
#define clc_move 3 // [usercmd_t]
|
||||
#define clc_stringcmd 4 // [string] message
|
||||
#define clc_bad 0
|
||||
#define clc_nop 1
|
||||
#define clc_disconnect 2
|
||||
#define clc_move 3 // [usercmd_t]
|
||||
#define clc_stringcmd 4 // [string] message
|
||||
|
||||
//
|
||||
// temp entity events
|
||||
//
|
||||
#define TE_SPIKE 0
|
||||
#define TE_SUPERSPIKE 1
|
||||
#define TE_GUNSHOT 2
|
||||
#define TE_EXPLOSION 3
|
||||
#define TE_TAREXPLOSION 4
|
||||
#define TE_LIGHTNING1 5
|
||||
#define TE_LIGHTNING2 6
|
||||
#define TE_WIZSPIKE 7
|
||||
#define TE_KNIGHTSPIKE 8
|
||||
#define TE_LIGHTNING3 9
|
||||
#define TE_LAVASPLASH 10
|
||||
#define TE_TELEPORT 11
|
||||
#define TE_EXPLOSION2 12
|
||||
#define TE_SPIKE 0
|
||||
#define TE_SUPERSPIKE 1
|
||||
#define TE_GUNSHOT 2
|
||||
#define TE_EXPLOSION 3
|
||||
#define TE_TAREXPLOSION 4
|
||||
#define TE_LIGHTNING1 5
|
||||
#define TE_LIGHTNING2 6
|
||||
#define TE_WIZSPIKE 7
|
||||
#define TE_KNIGHTSPIKE 8
|
||||
#define TE_LIGHTNING3 9
|
||||
#define TE_LAVASPLASH 10
|
||||
#define TE_TELEPORT 11
|
||||
#define TE_EXPLOSION2 12
|
||||
|
||||
// PGM 01/21/97
|
||||
#define TE_BEAM 13
|
||||
#define TE_BEAM 13
|
||||
// PGM 01/21/97
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
uint16_t modelindex; //johnfitz -- was int32_t
|
||||
uint16_t frame; //johnfitz -- was int32_t
|
||||
uint8_t colormap; //johnfitz -- was int32_t
|
||||
uint8_t skin; //johnfitz -- was int32_t
|
||||
uint8_t alpha; //johnfitz -- added
|
||||
int32_t effects;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
uint16_t modelindex; //johnfitz -- was int32_t
|
||||
uint16_t frame; //johnfitz -- was int32_t
|
||||
uint8_t colormap; //johnfitz -- was int32_t
|
||||
uint8_t skin; //johnfitz -- was int32_t
|
||||
uint8_t alpha; //johnfitz -- added
|
||||
int32_t effects;
|
||||
} entity_state_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t viewangles;
|
||||
vec3_t viewangles;
|
||||
|
||||
// intended velocities
|
||||
float forwardmove;
|
||||
float sidemove;
|
||||
float upmove;
|
||||
float forwardmove;
|
||||
float sidemove;
|
||||
float upmove;
|
||||
} usercmd_t;
|
||||
|
||||
#endif /* _QUAKE_PROTOCOL_H */
|
||||
#endif /* _QUAKE_PROTOCOL_H */
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static inline int32_t q_isdigit(int32_t c)
|
|||
static inline int32_t q_isxdigit(int32_t c)
|
||||
{
|
||||
return (q_isdigit(c) || (c >= 'a' && c <= 'f') ||
|
||||
(c >= 'A' && c <= 'F'));
|
||||
(c >= 'A' && c <= 'F'));
|
||||
}
|
||||
|
||||
static inline int32_t q_isalnum(int32_t c)
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
162
source/q_sound.h
162
source/q_sound.h
|
@ -34,92 +34,92 @@ typedef struct
|
|||
|
||||
typedef struct sfx_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
cache_user_t cache;
|
||||
char name[MAX_QPATH];
|
||||
cache_user_t cache;
|
||||
} sfx_t;
|
||||
|
||||
/* !!! if this is changed, it must be changed in asm_i386.h too !!! */
|
||||
typedef struct
|
||||
{
|
||||
int32_t length;
|
||||
int32_t loopstart;
|
||||
int32_t speed;
|
||||
int32_t width;
|
||||
int32_t stereo;
|
||||
byte data[1]; /* variable sized */
|
||||
int32_t length;
|
||||
int32_t loopstart;
|
||||
int32_t speed;
|
||||
int32_t width;
|
||||
int32_t stereo;
|
||||
byte data[1]; /* variable sized */
|
||||
} sfxcache_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t channels;
|
||||
int32_t samples; /* mono samples in buffer */
|
||||
int32_t submission_chunk; /* don't mix less than this # */
|
||||
int32_t samplepos; /* in mono samples */
|
||||
int32_t samplebits;
|
||||
int32_t signed8; /* device opened for S8 format? (e.g. Amiga AHI) */
|
||||
int32_t speed;
|
||||
uint8_t *buffer;
|
||||
int32_t channels;
|
||||
int32_t samples; /* mono samples in buffer */
|
||||
int32_t submission_chunk; /* don't mix less than this # */
|
||||
int32_t samplepos; /* in mono samples */
|
||||
int32_t samplebits;
|
||||
int32_t signed8; /* device opened for S8 format? (e.g. Amiga AHI) */
|
||||
int32_t speed;
|
||||
uint8_t *buffer;
|
||||
} dma_t;
|
||||
|
||||
/* !!! if this is changed, it must be changed in asm_i386.h too !!! */
|
||||
typedef struct
|
||||
{
|
||||
sfx_t *sfx; /* sfx number */
|
||||
int32_t leftvol; /* 0-255 volume */
|
||||
int32_t rightvol; /* 0-255 volume */
|
||||
int32_t end; /* end time in global paintsamples */
|
||||
int32_t pos; /* sample position in sfx */
|
||||
int32_t looping; /* where to loop, -1 = no looping */
|
||||
int32_t entnum; /* to allow overriding a specific sound */
|
||||
int32_t entchannel;
|
||||
vec3_t origin; /* origin of sound effect */
|
||||
vec_t dist_mult; /* distance multiplier (attenuation/clipK) */
|
||||
int32_t master_vol; /* 0-255 master volume */
|
||||
sfx_t *sfx; /* sfx number */
|
||||
int32_t leftvol; /* 0-255 volume */
|
||||
int32_t rightvol; /* 0-255 volume */
|
||||
int32_t end; /* end time in global paintsamples */
|
||||
int32_t pos; /* sample position in sfx */
|
||||
int32_t looping; /* where to loop, -1 = no looping */
|
||||
int32_t entnum; /* to allow overriding a specific sound */
|
||||
int32_t entchannel;
|
||||
vec3_t origin; /* origin of sound effect */
|
||||
vec_t dist_mult; /* distance multiplier (attenuation/clipK) */
|
||||
int32_t master_vol; /* 0-255 master volume */
|
||||
} channel_t;
|
||||
|
||||
#define WAV_FORMAT_PCM 1
|
||||
#define WAV_FORMAT_PCM 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t rate;
|
||||
int32_t width;
|
||||
int32_t channels;
|
||||
int32_t loopstart;
|
||||
int32_t samples;
|
||||
int32_t dataofs; /* chunk starts this many bytes from file start */
|
||||
int32_t rate;
|
||||
int32_t width;
|
||||
int32_t channels;
|
||||
int32_t loopstart;
|
||||
int32_t samples;
|
||||
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);
|
||||
|
@ -147,44 +147,44 @@ void SNDDMA_UnblockSound(void);
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
#define MAX_CHANNELS 1024 // ericw -- was 512 /* johnfitz -- was 128 */
|
||||
#define MAX_DYNAMIC_CHANNELS 128 /* johnfitz -- was 8 */
|
||||
#define MAX_CHANNELS 1024 // ericw -- was 512 /* johnfitz -- was 128 */
|
||||
#define MAX_DYNAMIC_CHANNELS 128 /* johnfitz -- was 8 */
|
||||
|
||||
extern channel_t snd_channels[MAX_CHANNELS];
|
||||
/* 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds
|
||||
extern channel_t snd_channels[MAX_CHANNELS];
|
||||
/* 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds
|
||||
* MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc
|
||||
* MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds
|
||||
*/
|
||||
|
||||
extern volatile dma_t *shm;
|
||||
extern volatile dma_t *shm;
|
||||
|
||||
extern int32_t total_channels;
|
||||
extern int32_t soundtime;
|
||||
extern int32_t paintedtime;
|
||||
extern int32_t s_rawend;
|
||||
extern int32_t total_channels;
|
||||
extern int32_t soundtime;
|
||||
extern int32_t paintedtime;
|
||||
extern int32_t s_rawend;
|
||||
|
||||
extern vec3_t listener_origin;
|
||||
extern vec3_t listener_forward;
|
||||
extern vec3_t listener_right;
|
||||
extern vec3_t listener_up;
|
||||
extern vec3_t listener_origin;
|
||||
extern vec3_t listener_forward;
|
||||
extern vec3_t listener_right;
|
||||
extern vec3_t listener_up;
|
||||
|
||||
extern cvar_t sndspeed;
|
||||
extern cvar_t snd_mixspeed;
|
||||
extern cvar_t snd_filterquality;
|
||||
extern cvar_t sfxvolume;
|
||||
extern cvar_t loadas8bit;
|
||||
extern cvar_t sndspeed;
|
||||
extern cvar_t snd_mixspeed;
|
||||
extern cvar_t snd_filterquality;
|
||||
extern cvar_t sfxvolume;
|
||||
extern cvar_t loadas8bit;
|
||||
|
||||
#define MAX_RAW_SAMPLES 8192
|
||||
extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
||||
#define MAX_RAW_SAMPLES 8192
|
||||
extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
||||
|
||||
extern cvar_t bgmvolume;
|
||||
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__ */
|
||||
#endif /* __QUAKE_SOUND__ */
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* q_stdinc.h - includes the minimum necessary stdc headers,
|
||||
* defines common and / or missing types.
|
||||
* defines common and / or missing types.
|
||||
*
|
||||
* NOTE: for net stuff use net_sys.h,
|
||||
* for byte order use q_endian.h,
|
||||
* for math stuff use mathlib.h,
|
||||
* for locale-insensitive ctype.h functions use q_ctype.h.
|
||||
* NOTE: for net stuff use net_sys.h,
|
||||
* for byte order use q_endian.h,
|
||||
* for math stuff use mathlib.h,
|
||||
* for locale-insensitive ctype.h functions use q_ctype.h.
|
||||
*
|
||||
* Copyright (C) 1996-1997 Id Software, Inc.
|
||||
* Copyright (C) 2007-2011 O.Sezer <sezero@users.sourceforge.net>
|
||||
|
@ -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)");
|
||||
|
@ -62,10 +63,10 @@ _Static_assert(sizeof(enum dummy_enum) == sizeof(int32_t), "enum not sizeof(int3
|
|||
typedef uint8_t byte;
|
||||
|
||||
/* math */
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
typedef vec_t vec5_t[5];
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
typedef vec_t vec5_t[5];
|
||||
|
||||
/* MAX_OSPATH (max length of a filesystem pathname, i.e. PATH_MAX)
|
||||
* Note: See GNU Hurd and others' notes about brokenness of this:
|
||||
|
@ -75,30 +76,30 @@ typedef vec_t vec5_t[5];
|
|||
#if !defined(PATH_MAX)
|
||||
/* equivalent values? */
|
||||
#if defined(MAXPATHLEN)
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#elif defined(_WIN32) && defined(_MAX_PATH)
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#define PATH_MAX _MAX_PATH
|
||||
#elif defined(_WIN32) && defined(MAX_PATH)
|
||||
#define PATH_MAX MAX_PATH
|
||||
#define PATH_MAX MAX_PATH
|
||||
#else /* fallback */
|
||||
#define PATH_MAX 1024
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
#endif /* PATH_MAX */
|
||||
#endif /* PATH_MAX */
|
||||
|
||||
#define MAX_OSPATH PATH_MAX
|
||||
#define MAX_OSPATH PATH_MAX
|
||||
|
||||
/* function attributes, etc */
|
||||
#if defined(__GNUC__)
|
||||
#define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
|
||||
#define FUNC_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
|
||||
#else
|
||||
#define FUNC_PRINTF(x,y)
|
||||
#endif
|
||||
|
||||
/* argument format attributes for function pointers are supported for gcc >= 3.1 */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
|
||||
#define FUNCP_PRINTF FUNC_PRINTF
|
||||
#define FUNCP_PRINTF FUNC_PRINTF
|
||||
#else
|
||||
#define FUNCP_PRINTF(x,y)
|
||||
#endif
|
||||
|
||||
#endif /* __QSTDINC_H */
|
||||
#endif /* __QSTDINC_H */
|
||||
|
|
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
|
||||
|
|
|
@ -30,157 +30,157 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define FITZQUAKE_VERSION "0.85" //johnfitz
|
||||
#define QUAKESPASM_VERSION "0.93.1"
|
||||
|
||||
//define PARANOID // speed sapping error checking
|
||||
//define PARANOID // speed sapping error checking
|
||||
|
||||
#define GAMENAME "id1" // directory to look in by default
|
||||
#define GAMENAME "id1" // directory to look in by default
|
||||
|
||||
#include "q_stdinc.h"
|
||||
|
||||
#define MINIMUM_MEMORY 0x550000
|
||||
#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000)
|
||||
#define MINIMUM_MEMORY 0x550000
|
||||
#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000)
|
||||
|
||||
#define MAX_NUM_ARGVS 50
|
||||
#define MAX_NUM_ARGVS 50
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
#define PITCH 0
|
||||
|
||||
// left / right
|
||||
#define YAW 1
|
||||
#define YAW 1
|
||||
|
||||
// fall over
|
||||
#define ROLL 2
|
||||
#define ROLL 2
|
||||
|
||||
|
||||
#define MAX_QPATH 64 // max length of a quake game pathname
|
||||
#define MAX_QPATH 64 // max length of a quake game pathname
|
||||
|
||||
#define ON_EPSILON 0.1 // point on plane side epsilon
|
||||
#define ON_EPSILON 0.1 // point on plane side epsilon
|
||||
|
||||
#define DIST_EPSILON 0.03125 // 1/32 epsilon to keep floating point happy (moved from world.c)
|
||||
#define DIST_EPSILON 0.03125 // 1/32 epsilon to keep floating point happy (moved from world.c)
|
||||
|
||||
#define MAX_MSGLEN 64000 // max length of a reliable message //ericw -- was 32000
|
||||
#define MAX_DATAGRAM 32000 // max length of unreliable message //johnfitz -- was 1024
|
||||
#define MAX_MSGLEN 64000 // max length of a reliable message //ericw -- was 32000
|
||||
#define MAX_DATAGRAM 32000 // max length of unreliable message //johnfitz -- was 1024
|
||||
|
||||
#define DATAGRAM_MTU 1400 // johnfitz -- actual limit for unreliable messages to nonlocal clients
|
||||
#define DATAGRAM_MTU 1400 // johnfitz -- actual limit for unreliable messages to nonlocal clients
|
||||
|
||||
//
|
||||
// per-level limits
|
||||
//
|
||||
#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
|
||||
#define MAX_LIGHTSTYLES 64
|
||||
#define MAX_MODELS 2048 // johnfitz -- was 256
|
||||
#define MAX_SOUNDS 2048 // johnfitz -- was 256
|
||||
#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
|
||||
#define MAX_LIGHTSTYLES 64
|
||||
#define MAX_MODELS 2048 // johnfitz -- was 256
|
||||
#define MAX_SOUNDS 2048 // johnfitz -- was 256
|
||||
|
||||
#define SAVEGAME_COMMENT_LENGTH 39
|
||||
#define SAVEGAME_COMMENT_LENGTH 39
|
||||
|
||||
#define MAX_STYLESTRING 64
|
||||
#define MAX_STYLESTRING 64
|
||||
|
||||
//
|
||||
// stats are integers communicated to the client by the server
|
||||
//
|
||||
#define MAX_CL_STATS 32
|
||||
#define STAT_HEALTH 0
|
||||
#define STAT_FRAGS 1
|
||||
#define STAT_WEAPON 2
|
||||
#define STAT_AMMO 3
|
||||
#define STAT_ARMOR 4
|
||||
#define STAT_WEAPONFRAME 5
|
||||
#define STAT_SHELLS 6
|
||||
#define STAT_NAILS 7
|
||||
#define STAT_ROCKETS 8
|
||||
#define STAT_CELLS 9
|
||||
#define STAT_ACTIVEWEAPON 10
|
||||
#define STAT_TOTALSECRETS 11
|
||||
#define STAT_TOTALMONSTERS 12
|
||||
#define STAT_SECRETS 13 // bumped on client side by svc_foundsecret
|
||||
#define STAT_MONSTERS 14 // bumped by svc_killedmonster
|
||||
#define MAX_CL_STATS 32
|
||||
#define STAT_HEALTH 0
|
||||
#define STAT_FRAGS 1
|
||||
#define STAT_WEAPON 2
|
||||
#define STAT_AMMO 3
|
||||
#define STAT_ARMOR 4
|
||||
#define STAT_WEAPONFRAME 5
|
||||
#define STAT_SHELLS 6
|
||||
#define STAT_NAILS 7
|
||||
#define STAT_ROCKETS 8
|
||||
#define STAT_CELLS 9
|
||||
#define STAT_ACTIVEWEAPON 10
|
||||
#define STAT_TOTALSECRETS 11
|
||||
#define STAT_TOTALMONSTERS 12
|
||||
#define STAT_SECRETS 13 // bumped on client side by svc_foundsecret
|
||||
#define STAT_MONSTERS 14 // bumped by svc_killedmonster
|
||||
|
||||
// stock defines
|
||||
//
|
||||
#define IT_SHOTGUN 1
|
||||
#define IT_SUPER_SHOTGUN 2
|
||||
#define IT_NAILGUN 4
|
||||
#define IT_SUPER_NAILGUN 8
|
||||
#define IT_GRENADE_LAUNCHER 16
|
||||
#define IT_ROCKET_LAUNCHER 32
|
||||
#define IT_LIGHTNING 64
|
||||
#define IT_SUPER_LIGHTNING 128
|
||||
#define IT_SHELLS 256
|
||||
#define IT_NAILS 512
|
||||
#define IT_ROCKETS 1024
|
||||
#define IT_CELLS 2048
|
||||
#define IT_AXE 4096
|
||||
#define IT_ARMOR1 8192
|
||||
#define IT_ARMOR2 16384
|
||||
#define IT_ARMOR3 32768
|
||||
#define IT_SUPERHEALTH 65536
|
||||
#define IT_KEY1 131072
|
||||
#define IT_KEY2 262144
|
||||
#define IT_INVISIBILITY 524288
|
||||
#define IT_INVULNERABILITY 1048576
|
||||
#define IT_SUIT 2097152
|
||||
#define IT_QUAD 4194304
|
||||
#define IT_SIGIL1 (1<<28)
|
||||
#define IT_SIGIL2 (1<<29)
|
||||
#define IT_SIGIL3 (1<<30)
|
||||
#define IT_SIGIL4 (1<<31)
|
||||
#define IT_SHOTGUN 1
|
||||
#define IT_SUPER_SHOTGUN 2
|
||||
#define IT_NAILGUN 4
|
||||
#define IT_SUPER_NAILGUN 8
|
||||
#define IT_GRENADE_LAUNCHER 16
|
||||
#define IT_ROCKET_LAUNCHER 32
|
||||
#define IT_LIGHTNING 64
|
||||
#define IT_SUPER_LIGHTNING 128
|
||||
#define IT_SHELLS 256
|
||||
#define IT_NAILS 512
|
||||
#define IT_ROCKETS 1024
|
||||
#define IT_CELLS 2048
|
||||
#define IT_AXE 4096
|
||||
#define IT_ARMOR1 8192
|
||||
#define IT_ARMOR2 16384
|
||||
#define IT_ARMOR3 32768
|
||||
#define IT_SUPERHEALTH 65536
|
||||
#define IT_KEY1 131072
|
||||
#define IT_KEY2 262144
|
||||
#define IT_INVISIBILITY 524288
|
||||
#define IT_INVULNERABILITY 1048576
|
||||
#define IT_SUIT 2097152
|
||||
#define IT_QUAD 4194304
|
||||
#define IT_SIGIL1 (1<<28)
|
||||
#define IT_SIGIL2 (1<<29)
|
||||
#define IT_SIGIL3 (1<<30)
|
||||
#define IT_SIGIL4 (1<<31)
|
||||
|
||||
//===========================================
|
||||
//rogue changed and added defines
|
||||
|
||||
#define RIT_SHELLS 128
|
||||
#define RIT_NAILS 256
|
||||
#define RIT_ROCKETS 512
|
||||
#define RIT_CELLS 1024
|
||||
#define RIT_AXE 2048
|
||||
#define RIT_LAVA_NAILGUN 4096
|
||||
#define RIT_LAVA_SUPER_NAILGUN 8192
|
||||
#define RIT_MULTI_GRENADE 16384
|
||||
#define RIT_MULTI_ROCKET 32768
|
||||
#define RIT_PLASMA_GUN 65536
|
||||
#define RIT_ARMOR1 8388608
|
||||
#define RIT_ARMOR2 16777216
|
||||
#define RIT_ARMOR3 33554432
|
||||
#define RIT_LAVA_NAILS 67108864
|
||||
#define RIT_PLASMA_AMMO 134217728
|
||||
#define RIT_MULTI_ROCKETS 268435456
|
||||
#define RIT_SHIELD 536870912
|
||||
#define RIT_ANTIGRAV 1073741824
|
||||
#define RIT_SUPERHEALTH 2147483648
|
||||
#define RIT_SHELLS 128
|
||||
#define RIT_NAILS 256
|
||||
#define RIT_ROCKETS 512
|
||||
#define RIT_CELLS 1024
|
||||
#define RIT_AXE 2048
|
||||
#define RIT_LAVA_NAILGUN 4096
|
||||
#define RIT_LAVA_SUPER_NAILGUN 8192
|
||||
#define RIT_MULTI_GRENADE 16384
|
||||
#define RIT_MULTI_ROCKET 32768
|
||||
#define RIT_PLASMA_GUN 65536
|
||||
#define RIT_ARMOR1 8388608
|
||||
#define RIT_ARMOR2 16777216
|
||||
#define RIT_ARMOR3 33554432
|
||||
#define RIT_LAVA_NAILS 67108864
|
||||
#define RIT_PLASMA_AMMO 134217728
|
||||
#define RIT_MULTI_ROCKETS 268435456
|
||||
#define RIT_SHIELD 536870912
|
||||
#define RIT_ANTIGRAV 1073741824
|
||||
#define RIT_SUPERHEALTH 2147483648
|
||||
|
||||
//MED 01/04/97 added hipnotic defines
|
||||
//===========================================
|
||||
//hipnotic added defines
|
||||
#define HIT_PROXIMITY_GUN_BIT 16
|
||||
#define HIT_MJOLNIR_BIT 7
|
||||
#define HIT_LASER_CANNON_BIT 23
|
||||
#define HIT_PROXIMITY_GUN (1<<HIT_PROXIMITY_GUN_BIT)
|
||||
#define HIT_MJOLNIR (1<<HIT_MJOLNIR_BIT)
|
||||
#define HIT_LASER_CANNON (1<<HIT_LASER_CANNON_BIT)
|
||||
#define HIT_WETSUIT (1<<(23+2))
|
||||
#define HIT_EMPATHY_SHIELDS (1<<(23+3))
|
||||
#define HIT_PROXIMITY_GUN_BIT 16
|
||||
#define HIT_MJOLNIR_BIT 7
|
||||
#define HIT_LASER_CANNON_BIT 23
|
||||
#define HIT_PROXIMITY_GUN (1<<HIT_PROXIMITY_GUN_BIT)
|
||||
#define HIT_MJOLNIR (1<<HIT_MJOLNIR_BIT)
|
||||
#define HIT_LASER_CANNON (1<<HIT_LASER_CANNON_BIT)
|
||||
#define HIT_WETSUIT (1<<(23+2))
|
||||
#define HIT_EMPATHY_SHIELDS (1<<(23+3))
|
||||
|
||||
//===========================================
|
||||
|
||||
#define MAX_SCOREBOARD 16
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
#define MAX_SCOREBOARD 16
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
|
||||
#define SOUND_CHANNELS 8
|
||||
#define SOUND_CHANNELS 8
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *basedir;
|
||||
const char *userdir; // user's directory on UNIX platforms.
|
||||
// if user directories are enabled, basedir
|
||||
// and userdir will point to different
|
||||
// memory locations, otherwise to the same.
|
||||
int32_t argc;
|
||||
char **argv;
|
||||
void *membase;
|
||||
int32_t memsize;
|
||||
int32_t numcpus;
|
||||
int32_t errstate;
|
||||
const char *userdir; // user's directory on UNIX platforms.
|
||||
// if user directories are enabled, basedir
|
||||
// and userdir will point to different
|
||||
// memory locations, otherwise to the same.
|
||||
int32_t argc;
|
||||
char **argv;
|
||||
void *membase;
|
||||
int32_t memsize;
|
||||
int32_t numcpus;
|
||||
int32_t errstate;
|
||||
} quakeparms_t;
|
||||
|
||||
#include "common.h"
|
||||
|
@ -203,7 +203,7 @@ typedef struct
|
|||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
#include "console.h"
|
||||
|
@ -220,8 +220,8 @@ typedef struct
|
|||
#include "gl_model.h"
|
||||
#include "world.h"
|
||||
|
||||
#include "image.h" //johnfitz
|
||||
#include "gl_texmgr.h" //johnfitz
|
||||
#include "image.h" //johnfitz
|
||||
#include "gl_texmgr.h" //johnfitz
|
||||
#include "input.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
|
@ -239,60 +239,60 @@ extern bool noclip_anglehack;
|
|||
//
|
||||
// host
|
||||
//
|
||||
extern quakeparms_t *host_parms;
|
||||
extern quakeparms_t *host_parms;
|
||||
|
||||
extern cvar_t sys_ticrate;
|
||||
extern cvar_t sys_throttle;
|
||||
extern cvar_t sys_nostdout;
|
||||
extern cvar_t developer;
|
||||
extern cvar_t max_edicts; //johnfitz
|
||||
extern cvar_t sys_ticrate;
|
||||
extern cvar_t sys_throttle;
|
||||
extern cvar_t sys_nostdout;
|
||||
extern cvar_t developer;
|
||||
extern cvar_t max_edicts; //johnfitz
|
||||
|
||||
extern bool host_initialized; // true if into command execution
|
||||
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
|
||||
extern bool host_initialized; // true if into command execution
|
||||
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
|
||||
|
||||
typedef struct filelist_item_s
|
||||
{
|
||||
char name[32];
|
||||
struct filelist_item_s *next;
|
||||
char name[32];
|
||||
struct filelist_item_s *next;
|
||||
} filelist_item_t;
|
||||
|
||||
extern filelist_item_t *modlist;
|
||||
extern filelist_item_t *extralevels;
|
||||
extern filelist_item_t *demolist;
|
||||
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)
|
||||
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)
|
||||
|
||||
extern bool isDedicated;
|
||||
extern bool isDedicated;
|
||||
|
||||
#endif /* QUAKEDEFS_H */
|
||||
#endif /* QUAKEDEFS_H */
|
||||
|
||||
|
|
766
source/r_alias.c
766
source/r_alias.c
File diff suppressed because it is too large
Load Diff
946
source/r_brush.c
946
source/r_brush.c
File diff suppressed because it is too large
Load Diff
761
source/r_part.c
761
source/r_part.c
File diff suppressed because it is too large
Load Diff
|
@ -28,24 +28,24 @@ 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;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int32_t i, numframes, frame;
|
||||
float *pintervals, fullinterval, targettime, time;
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int32_t i, numframes, frame;
|
||||
float *pintervals, fullinterval, targettime, time;
|
||||
|
||||
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,17 +54,17 @@ 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;
|
||||
|
||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
||||
// are positive, so we don't have to worry about division by 0
|
||||
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
||||
// 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,17 +79,17 @@ 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;
|
||||
mspriteframe_t *frame;
|
||||
float *s_up, *s_right;
|
||||
float angle, sr, cr;
|
||||
vec3_t point, v_forward, v_right, v_up;
|
||||
msprite_t *psprite;
|
||||
mspriteframe_t *frame;
|
||||
float *s_up, *s_right;
|
||||
float angle, sr, cr;
|
||||
|
||||
//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);
|
||||
}
|
||||
|
|
889
source/r_world.c
889
source/r_world.c
File diff suppressed because it is too large
Load Diff
200
source/render.h
200
source/render.h
|
@ -25,154 +25,154 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// refresh.h -- public interface to refresh functions
|
||||
|
||||
#define MAXCLIPPLANES 11
|
||||
#define MAXCLIPPLANES 11
|
||||
|
||||
#define TOP_RANGE 16 // soldier uniform colors
|
||||
#define BOTTOM_RANGE 96
|
||||
#define TOP_RANGE 16 // soldier uniform colors
|
||||
#define BOTTOM_RANGE 96
|
||||
|
||||
//=============================================================================
|
||||
|
||||
typedef struct efrag_s
|
||||
{
|
||||
struct efrag_s *leafnext;
|
||||
struct entity_s *entity;
|
||||
struct efrag_s *leafnext;
|
||||
struct entity_s *entity;
|
||||
} efrag_t;
|
||||
|
||||
//johnfitz -- for lerping
|
||||
#define LERP_MOVESTEP (1<<0) //this is a MOVETYPE_STEP entity, enable movement lerp
|
||||
#define LERP_RESETANIM (1<<1) //disable anim lerping until next anim frame
|
||||
#define LERP_RESETANIM2 (1<<2) //set this and previous flag to disable anim lerping for two anim frames
|
||||
#define LERP_RESETMOVE (1<<3) //disable movement lerping until next origin/angles change
|
||||
#define LERP_FINISH (1<<4) //use lerpfinish time from server update instead of assuming interval of 0.1
|
||||
#define LERP_MOVESTEP (1<<0) //this is a MOVETYPE_STEP entity, enable movement lerp
|
||||
#define LERP_RESETANIM (1<<1) //disable anim lerping until next anim frame
|
||||
#define LERP_RESETANIM2 (1<<2) //set this and previous flag to disable anim lerping for two anim frames
|
||||
#define LERP_RESETMOVE (1<<3) //disable movement lerping until next origin/angles change
|
||||
#define LERP_FINISH (1<<4) //use lerpfinish time from server update instead of assuming interval of 0.1
|
||||
//johnfitz
|
||||
|
||||
typedef struct entity_s
|
||||
{
|
||||
bool forcelink; // model changed
|
||||
bool forcelink; // model changed
|
||||
|
||||
int32_t update_type;
|
||||
int32_t update_type;
|
||||
|
||||
entity_state_t baseline; // to fill in defaults in updates
|
||||
entity_state_t baseline; // to fill in defaults in updates
|
||||
|
||||
double msgtime; // time of last update
|
||||
vec3_t msg_origins[2]; // last two updates (0 is newest)
|
||||
vec3_t origin;
|
||||
vec3_t msg_angles[2]; // last two updates (0 is newest)
|
||||
vec3_t angles;
|
||||
struct qmodel_s *model; // NULL = no model
|
||||
struct efrag_s *efrag; // linked list of efrags
|
||||
int32_t frame;
|
||||
float syncbase; // for client-side animations
|
||||
byte *colormap;
|
||||
int32_t effects; // light, particles, etc
|
||||
int32_t skinnum; // for Alias models
|
||||
int32_t visframe; // last frame this entity was
|
||||
// found in an active leaf
|
||||
double msgtime; // time of last update
|
||||
vec3_t msg_origins[2]; // last two updates (0 is newest)
|
||||
vec3_t origin;
|
||||
vec3_t msg_angles[2]; // last two updates (0 is newest)
|
||||
vec3_t angles;
|
||||
struct qmodel_s *model; // NULL = no model
|
||||
struct efrag_s *efrag; // linked list of efrags
|
||||
int32_t frame;
|
||||
float syncbase; // for client-side animations
|
||||
byte *colormap;
|
||||
int32_t effects; // light, particles, etc
|
||||
int32_t skinnum; // for Alias models
|
||||
int32_t visframe; // last frame this entity was
|
||||
// found in an active leaf
|
||||
|
||||
int32_t dlightframe; // dynamic lighting
|
||||
int32_t dlightbits;
|
||||
int32_t dlightframe; // dynamic lighting
|
||||
int32_t dlightbits;
|
||||
|
||||
// FIXME: could turn these into a union
|
||||
int32_t trivial_accept;
|
||||
struct mnode_s *topnode; // for bmodels, first world node
|
||||
// that splits bmodel, or NULL if
|
||||
// not split
|
||||
int32_t trivial_accept;
|
||||
struct mnode_s *topnode; // for bmodels, first world node
|
||||
// that splits bmodel, or NULL if
|
||||
// not split
|
||||
|
||||
byte alpha; //johnfitz -- alpha
|
||||
byte lerpflags; //johnfitz -- lerping
|
||||
float lerpstart; //johnfitz -- animation lerping
|
||||
float lerptime; //johnfitz -- animation lerping
|
||||
float lerpfinish; //johnfitz -- lerping -- server sent us a more accurate interval, use it instead of 0.1
|
||||
int16_t previouspose; //johnfitz -- animation lerping
|
||||
int16_t currentpose; //johnfitz -- animation lerping
|
||||
// int16_t futurepose; //johnfitz -- animation lerping
|
||||
float movelerpstart; //johnfitz -- transform lerping
|
||||
vec3_t previousorigin; //johnfitz -- transform lerping
|
||||
vec3_t currentorigin; //johnfitz -- transform lerping
|
||||
vec3_t previousangles; //johnfitz -- transform lerping
|
||||
vec3_t currentangles; //johnfitz -- transform lerping
|
||||
byte alpha; //johnfitz -- alpha
|
||||
byte lerpflags; //johnfitz -- lerping
|
||||
float lerpstart; //johnfitz -- animation lerping
|
||||
float lerptime; //johnfitz -- animation lerping
|
||||
float lerpfinish; //johnfitz -- lerping -- server sent us a more accurate interval, use it instead of 0.1
|
||||
int16_t previouspose; //johnfitz -- animation lerping
|
||||
int16_t currentpose; //johnfitz -- animation lerping
|
||||
// int16_t futurepose; //johnfitz -- animation lerping
|
||||
float movelerpstart; //johnfitz -- transform lerping
|
||||
vec3_t previousorigin; //johnfitz -- transform lerping
|
||||
vec3_t currentorigin; //johnfitz -- transform lerping
|
||||
vec3_t previousangles; //johnfitz -- transform lerping
|
||||
vec3_t currentangles; //johnfitz -- transform lerping
|
||||
} entity_t;
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
vrect_t vrect; // subwindow in video for refresh
|
||||
// FIXME: not need vrect next field here?
|
||||
vrect_t aliasvrect; // scaled Alias version
|
||||
int32_t vrectright, vrectbottom; // right & bottom screen coords
|
||||
int32_t aliasvrectright, aliasvrectbottom; // scaled Alias versions
|
||||
float vrectrightedge; // rightmost right edge we care about,
|
||||
// for use in edge list
|
||||
float fvrectx, fvrecty; // for floating-point compares
|
||||
float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
|
||||
int32_t vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20
|
||||
int32_t vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
|
||||
float fvrectright_adj, fvrectbottom_adj;
|
||||
// right and bottom edges, for clamping
|
||||
float fvrectright; // rightmost edge, for Alias clamping
|
||||
float fvrectbottom; // bottommost edge, for Alias clamping
|
||||
float horizontalFieldOfView; // at Z = 1.0, this many X is visible
|
||||
// 2.0 = 90 degrees
|
||||
float xOrigin; // should probably allways be 0.5
|
||||
float yOrigin; // between be around 0.3 to 0.5
|
||||
vrect_t vrect; // subwindow in video for refresh
|
||||
// FIXME: not need vrect next field here?
|
||||
vrect_t aliasvrect; // scaled Alias version
|
||||
int32_t vrectright, vrectbottom; // right & bottom screen coords
|
||||
int32_t aliasvrectright, aliasvrectbottom; // scaled Alias versions
|
||||
float vrectrightedge; // rightmost right edge we care about,
|
||||
// for use in edge list
|
||||
float fvrectx, fvrecty; // for floating-point compares
|
||||
float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
|
||||
int32_t vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20
|
||||
int32_t vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
|
||||
float fvrectright_adj, fvrectbottom_adj;
|
||||
// right and bottom edges, for clamping
|
||||
float fvrectright; // rightmost edge, for Alias clamping
|
||||
float fvrectbottom; // bottommost edge, for Alias clamping
|
||||
float horizontalFieldOfView; // at Z = 1.0, this many X is visible
|
||||
// 2.0 = 90 degrees
|
||||
float xOrigin; // should probably allways be 0.5
|
||||
float yOrigin; // between be around 0.3 to 0.5
|
||||
|
||||
vec3_t vieworg;
|
||||
vec3_t viewangles;
|
||||
vec3_t vieworg;
|
||||
vec3_t viewangles;
|
||||
|
||||
float fov_x, fov_y;
|
||||
float fov_x, fov_y;
|
||||
|
||||
int32_t ambientlight;
|
||||
int32_t ambientlight;
|
||||
} refdef_t;
|
||||
|
||||
|
||||
//
|
||||
// refresh
|
||||
//
|
||||
extern int32_t reinit_surfcache;
|
||||
extern int32_t reinit_surfcache;
|
||||
|
||||
|
||||
extern refdef_t r_refdef;
|
||||
extern vec3_t r_origin, vpn, vright, vup;
|
||||
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_InitSky (struct texture_s *mt); // called at level load
|
||||
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);
|
||||
|
||||
|
||||
//
|
||||
// surface cache related
|
||||
//
|
||||
extern int32_t reinit_surfcache; // if 1, surface cache is currently empty and
|
||||
extern bool r_cache_thrash; // set if thrashing the surface cache
|
||||
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 */
|
||||
#endif /* _QUAKE_RENDER_H */
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define IDC_PROGRESS 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
|
@ -22,5 +22,5 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _QUAKE_RESOURCE_H */
|
||||
#endif /* _QUAKE_RESOURCE_H */
|
||||
|
||||
|
|
1172
source/sbar.c
1172
source/sbar.c
File diff suppressed because it is too large
Load Diff
|
@ -26,21 +26,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// the status bar is only redrawn if something has changed, but if anything
|
||||
// does, the entire thing will be redrawn for the next vid.numpages frames.
|
||||
|
||||
extern int32_t sb_lines; // scan lines to draw
|
||||
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 */
|
||||
#endif /* _QUAKE_SBAR_H */
|
||||
|
||||
|
|
|
@ -25,39 +25,40 @@ 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
|
||||
extern float scr_con_current;
|
||||
extern float scr_conlines; // lines of console to display
|
||||
|
||||
extern int32_t sb_lines;
|
||||
extern int32_t sb_lines;
|
||||
|
||||
extern int32_t clearnotify; // set to 0 whenever notify text is drawn
|
||||
extern bool scr_disabled_for_loading;
|
||||
extern bool scr_skipupdate;
|
||||
extern int32_t clearnotify; // set to 0 whenever notify text is drawn
|
||||
extern bool scr_disabled_for_loading;
|
||||
extern bool scr_skipupdate;
|
||||
|
||||
extern cvar_t scr_viewsize;
|
||||
extern cvar_t scr_viewsize;
|
||||
|
||||
extern cvar_t scr_sbaralpha; //johnfitz
|
||||
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,
|
||||
|
@ -70,15 +71,15 @@ typedef enum {
|
|||
CANVAS_TOPRIGHT,
|
||||
CANVAS_INVALID = -1
|
||||
} canvastype;
|
||||
extern cvar_t scr_menuscale;
|
||||
extern cvar_t scr_sbarscale;
|
||||
extern cvar_t scr_conwidth;
|
||||
extern cvar_t scr_conscale;
|
||||
extern cvar_t scr_scale;
|
||||
extern cvar_t scr_crosshairscale;
|
||||
extern cvar_t scr_menuscale;
|
||||
extern cvar_t scr_sbarscale;
|
||||
extern cvar_t scr_conwidth;
|
||||
extern cvar_t scr_conscale;
|
||||
extern cvar_t scr_scale;
|
||||
extern cvar_t scr_crosshairscale;
|
||||
//johnfitz
|
||||
|
||||
extern int32_t scr_tileclear_updates; //johnfitz
|
||||
|
||||
#endif /* _QUAKE_SCREEN_H */
|
||||
#endif /* _QUAKE_SCREEN_H */
|
||||
|
||||
|
|
262
source/server.h
262
source/server.h
|
@ -27,11 +27,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int32_t maxclients;
|
||||
int32_t maxclientslimit;
|
||||
struct client_s *clients; // [maxclients]
|
||||
int32_t serverflags; // episode completion information
|
||||
bool changelevel_issued; // cleared when at SV_SpawnServer
|
||||
int32_t maxclients;
|
||||
int32_t maxclientslimit;
|
||||
struct client_s *clients; // [maxclients]
|
||||
int32_t serverflags; // episode completion information
|
||||
bool changelevel_issued; // cleared when at SV_SpawnServer
|
||||
} server_static_t;
|
||||
|
||||
//=============================================================================
|
||||
|
@ -40,193 +40,193 @@ typedef enum {ss_loading, ss_active} server_state_t;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
bool active; // false if only a net client
|
||||
bool active; // false if only a net client
|
||||
|
||||
bool paused;
|
||||
bool loadgame; // handle connections specially
|
||||
bool paused;
|
||||
bool loadgame; // handle connections specially
|
||||
|
||||
double time;
|
||||
double time;
|
||||
|
||||
int32_t lastcheck; // used by PF_checkclient
|
||||
double lastchecktime;
|
||||
int32_t lastcheck; // used by PF_checkclient
|
||||
double lastchecktime;
|
||||
|
||||
char name[64]; // map name
|
||||
char modelname[64]; // maps/<name>.bsp, for model_precache[0]
|
||||
struct qmodel_s *worldmodel;
|
||||
const char *model_precache[MAX_MODELS]; // NULL terminated
|
||||
struct qmodel_s *models[MAX_MODELS];
|
||||
const char *sound_precache[MAX_SOUNDS]; // NULL terminated
|
||||
const char *lightstyles[MAX_LIGHTSTYLES];
|
||||
int32_t num_edicts;
|
||||
int32_t max_edicts;
|
||||
edict_t *edicts; // can NOT be array indexed, because
|
||||
// edict_t is variable sized, but can
|
||||
// be used to reference the world ent
|
||||
server_state_t state; // some actions are only valid during load
|
||||
char name[64]; // map name
|
||||
char modelname[64]; // maps/<name>.bsp, for model_precache[0]
|
||||
struct qmodel_s *worldmodel;
|
||||
const char *model_precache[MAX_MODELS]; // NULL terminated
|
||||
struct qmodel_s *models[MAX_MODELS];
|
||||
const char *sound_precache[MAX_SOUNDS]; // NULL terminated
|
||||
const char *lightstyles[MAX_LIGHTSTYLES];
|
||||
int32_t num_edicts;
|
||||
int32_t max_edicts;
|
||||
edict_t *edicts; // can NOT be array indexed, because
|
||||
// edict_t is variable sized, but can
|
||||
// be used to reference the world ent
|
||||
server_state_t state; // some actions are only valid during load
|
||||
|
||||
sizebuf_t datagram;
|
||||
byte datagram_buf[MAX_DATAGRAM];
|
||||
sizebuf_t datagram;
|
||||
byte datagram_buf[MAX_DATAGRAM];
|
||||
|
||||
sizebuf_t reliable_datagram; // copied to all clients at end of frame
|
||||
byte reliable_datagram_buf[MAX_DATAGRAM];
|
||||
sizebuf_t reliable_datagram; // copied to all clients at end of frame
|
||||
byte reliable_datagram_buf[MAX_DATAGRAM];
|
||||
|
||||
sizebuf_t signon;
|
||||
byte signon_buf[MAX_MSGLEN-2]; //johnfitz -- was 8192, now uses MAX_MSGLEN
|
||||
sizebuf_t signon;
|
||||
byte signon_buf[MAX_MSGLEN - 2]; //johnfitz -- was 8192, now uses MAX_MSGLEN
|
||||
|
||||
unsigned protocol; //johnfitz
|
||||
unsigned protocolflags;
|
||||
unsigned protocol; //johnfitz
|
||||
unsigned protocolflags;
|
||||
} server_t;
|
||||
|
||||
|
||||
#define NUM_PING_TIMES 16
|
||||
#define NUM_SPAWN_PARMS 16
|
||||
#define NUM_PING_TIMES 16
|
||||
#define NUM_SPAWN_PARMS 16
|
||||
|
||||
typedef struct client_s
|
||||
{
|
||||
bool active; // false = client is free
|
||||
bool spawned; // false = don't send datagrams
|
||||
bool dropasap; // has been told to go to another level
|
||||
bool sendsignon; // only valid before spawned
|
||||
bool active; // false = client is free
|
||||
bool spawned; // false = don't send datagrams
|
||||
bool dropasap; // has been told to go to another level
|
||||
bool sendsignon; // only valid before spawned
|
||||
|
||||
double last_message; // reliable messages must be sent
|
||||
// periodically
|
||||
double last_message; // reliable messages must be sent
|
||||
// periodically
|
||||
|
||||
struct qsocket_s *netconnection; // communications handle
|
||||
struct qsocket_s *netconnection; // communications handle
|
||||
|
||||
usercmd_t cmd; // movement
|
||||
vec3_t wishdir; // intended motion calced from cmd
|
||||
usercmd_t cmd; // movement
|
||||
vec3_t wishdir; // intended motion calced from cmd
|
||||
|
||||
sizebuf_t message; // can be added to at any time,
|
||||
// copied and clear once per frame
|
||||
byte msgbuf[MAX_MSGLEN];
|
||||
edict_t *edict; // EDICT_NUM(clientnum+1)
|
||||
char name[32]; // for printing to other people
|
||||
int32_t colors;
|
||||
sizebuf_t message; // can be added to at any time,
|
||||
// copied and clear once per frame
|
||||
byte msgbuf[MAX_MSGLEN];
|
||||
edict_t *edict; // EDICT_NUM(clientnum+1)
|
||||
char name[32]; // for printing to other people
|
||||
int32_t colors;
|
||||
|
||||
float ping_times[NUM_PING_TIMES];
|
||||
int32_t num_pings; // ping_times[num_pings%NUM_PING_TIMES]
|
||||
float ping_times[NUM_PING_TIMES];
|
||||
int32_t num_pings; // ping_times[num_pings%NUM_PING_TIMES]
|
||||
|
||||
// spawn parms are carried from level to level
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
|
||||
// client known data for deltas
|
||||
int32_t old_frags;
|
||||
int32_t old_frags;
|
||||
} client_t;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// edict->movetype values
|
||||
#define MOVETYPE_NONE 0 // never moves
|
||||
#define MOVETYPE_ANGLENOCLIP 1
|
||||
#define MOVETYPE_ANGLECLIP 2
|
||||
#define MOVETYPE_WALK 3 // gravity
|
||||
#define MOVETYPE_STEP 4 // gravity, special edge handling
|
||||
#define MOVETYPE_FLY 5
|
||||
#define MOVETYPE_TOSS 6 // gravity
|
||||
#define MOVETYPE_PUSH 7 // no clip to world, push and crush
|
||||
#define MOVETYPE_NOCLIP 8
|
||||
#define MOVETYPE_FLYMISSILE 9 // extra size to monsters
|
||||
#define MOVETYPE_BOUNCE 10
|
||||
#define MOVETYPE_NONE 0 // never moves
|
||||
#define MOVETYPE_ANGLENOCLIP 1
|
||||
#define MOVETYPE_ANGLECLIP 2
|
||||
#define MOVETYPE_WALK 3 // gravity
|
||||
#define MOVETYPE_STEP 4 // gravity, special edge handling
|
||||
#define MOVETYPE_FLY 5
|
||||
#define MOVETYPE_TOSS 6 // gravity
|
||||
#define MOVETYPE_PUSH 7 // no clip to world, push and crush
|
||||
#define MOVETYPE_NOCLIP 8
|
||||
#define MOVETYPE_FLYMISSILE 9 // extra size to monsters
|
||||
#define MOVETYPE_BOUNCE 10
|
||||
|
||||
// edict->solid values
|
||||
#define SOLID_NOT 0 // no interaction with other objects
|
||||
#define SOLID_TRIGGER 1 // touch on edge, but not blocking
|
||||
#define SOLID_BBOX 2 // touch on edge, block
|
||||
#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
|
||||
#define SOLID_BSP 4 // bsp clip, touch on edge, block
|
||||
#define SOLID_NOT 0 // no interaction with other objects
|
||||
#define SOLID_TRIGGER 1 // touch on edge, but not blocking
|
||||
#define SOLID_BBOX 2 // touch on edge, block
|
||||
#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground
|
||||
#define SOLID_BSP 4 // bsp clip, touch on edge, block
|
||||
|
||||
// edict->deadflag values
|
||||
#define DEAD_NO 0
|
||||
#define DEAD_DYING 1
|
||||
#define DEAD_DEAD 2
|
||||
#define DEAD_NO 0
|
||||
#define DEAD_DYING 1
|
||||
#define DEAD_DEAD 2
|
||||
|
||||
#define DAMAGE_NO 0
|
||||
#define DAMAGE_YES 1
|
||||
#define DAMAGE_AIM 2
|
||||
#define DAMAGE_NO 0
|
||||
#define DAMAGE_YES 1
|
||||
#define DAMAGE_AIM 2
|
||||
|
||||
// edict->flags
|
||||
#define FL_FLY 1
|
||||
#define FL_SWIM 2
|
||||
//#define FL_GLIMPSE 4
|
||||
#define FL_CONVEYOR 4
|
||||
#define FL_CLIENT 8
|
||||
#define FL_INWATER 16
|
||||
#define FL_MONSTER 32
|
||||
#define FL_GODMODE 64
|
||||
#define FL_NOTARGET 128
|
||||
#define FL_ITEM 256
|
||||
#define FL_ONGROUND 512
|
||||
#define FL_PARTIALGROUND 1024 // not all corners are valid
|
||||
#define FL_WATERJUMP 2048 // player jumping out of water
|
||||
#define FL_JUMPRELEASED 4096 // for jump debouncing
|
||||
#define FL_FLY 1
|
||||
#define FL_SWIM 2
|
||||
//#define FL_GLIMPSE 4
|
||||
#define FL_CONVEYOR 4
|
||||
#define FL_CLIENT 8
|
||||
#define FL_INWATER 16
|
||||
#define FL_MONSTER 32
|
||||
#define FL_GODMODE 64
|
||||
#define FL_NOTARGET 128
|
||||
#define FL_ITEM 256
|
||||
#define FL_ONGROUND 512
|
||||
#define FL_PARTIALGROUND 1024 // not all corners are valid
|
||||
#define FL_WATERJUMP 2048 // player jumping out of water
|
||||
#define FL_JUMPRELEASED 4096 // for jump debouncing
|
||||
|
||||
// entity effects
|
||||
|
||||
#define EF_BRIGHTFIELD 1
|
||||
#define EF_MUZZLEFLASH 2
|
||||
#define EF_BRIGHTLIGHT 4
|
||||
#define EF_DIMLIGHT 8
|
||||
#define EF_BRIGHTFIELD 1
|
||||
#define EF_MUZZLEFLASH 2
|
||||
#define EF_BRIGHTLIGHT 4
|
||||
#define EF_DIMLIGHT 8
|
||||
|
||||
#define SPAWNFLAG_NOT_EASY 256
|
||||
#define SPAWNFLAG_NOT_MEDIUM 512
|
||||
#define SPAWNFLAG_NOT_HARD 1024
|
||||
#define SPAWNFLAG_NOT_DEATHMATCH 2048
|
||||
#define SPAWNFLAG_NOT_EASY 256
|
||||
#define SPAWNFLAG_NOT_MEDIUM 512
|
||||
#define SPAWNFLAG_NOT_HARD 1024
|
||||
#define SPAWNFLAG_NOT_DEATHMATCH 2048
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern cvar_t teamplay;
|
||||
extern cvar_t skill;
|
||||
extern cvar_t deathmatch;
|
||||
extern cvar_t coop;
|
||||
extern cvar_t fraglimit;
|
||||
extern cvar_t timelimit;
|
||||
extern cvar_t teamplay;
|
||||
extern cvar_t skill;
|
||||
extern cvar_t deathmatch;
|
||||
extern cvar_t coop;
|
||||
extern cvar_t fraglimit;
|
||||
extern cvar_t timelimit;
|
||||
|
||||
extern server_static_t svs; // persistant server info
|
||||
extern server_t sv; // local server
|
||||
extern server_static_t svs; // persistant server info
|
||||
extern server_t sv; // local server
|
||||
|
||||
extern client_t *host_client;
|
||||
extern client_t *host_client;
|
||||
|
||||
extern edict_t *sv_player;
|
||||
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,
|
||||
float attenuation);
|
||||
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 */
|
||||
#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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
@ -201,57 +205,58 @@ snd_stream_t *S_CodecOpenStreamAny (const char *filename)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
else /* use the name as is */
|
||||
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);
|
||||
else S_CodecUtilClose(&stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -50,55 +51,55 @@ typedef struct snd_stream_s
|
|||
{
|
||||
fshandle_t fh;
|
||||
bool pak;
|
||||
char name[MAX_QPATH]; /* name of the source file */
|
||||
char name[MAX_QPATH]; /* name of the source file */
|
||||
snd_info_t info;
|
||||
stream_status_t status;
|
||||
snd_codec_t *codec; /* codec handling this stream */
|
||||
void *priv; /* data private to the codec. */
|
||||
snd_codec_t *codec; /* codec handling this stream */
|
||||
void *priv; /* data private to the codec. */
|
||||
} 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
|
||||
* name has no extension, try all available. */
|
||||
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
|
||||
* MUST have an extension. */
|
||||
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);
|
||||
|
||||
|
||||
#define CODECTYPE_NONE 0
|
||||
#define CODECTYPE_MID (1U << 0)
|
||||
#define CODECTYPE_MOD (1U << 1)
|
||||
#define CODECTYPE_FLAC (1U << 2)
|
||||
#define CODECTYPE_WAV (1U << 3)
|
||||
#define CODECTYPE_MP3 (1U << 4)
|
||||
#define CODECTYPE_VORBIS (1U << 5)
|
||||
#define CODECTYPE_OPUS (1U << 6)
|
||||
#define CODECTYPE_UMX (1U << 7)
|
||||
#define CODECTYPE_NONE 0
|
||||
#define CODECTYPE_MID (1U << 0)
|
||||
#define CODECTYPE_MOD (1U << 1)
|
||||
#define CODECTYPE_FLAC (1U << 2)
|
||||
#define CODECTYPE_WAV (1U << 3)
|
||||
#define CODECTYPE_MP3 (1U << 4)
|
||||
#define CODECTYPE_VORBIS (1U << 5)
|
||||
#define CODECTYPE_OPUS (1U << 6)
|
||||
#define CODECTYPE_UMX (1U << 7)
|
||||
|
||||
#define CODECTYPE_WAVE CODECTYPE_WAV
|
||||
#define CODECTYPE_MIDI CODECTYPE_MID
|
||||
#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
|
||||
* or -1 if no such codec is present. */
|
||||
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_ */
|
||||
#endif /* _SND_CODEC_H_ */
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ typedef void (*CODEC_CLOSE)(snd_stream_t *stream);
|
|||
|
||||
struct snd_codec_s
|
||||
{
|
||||
uint32_t type; /* handled data type. (1U << n) */
|
||||
bool initialized; /* init succeedded */
|
||||
const char *ext; /* expected extension */
|
||||
uint32_t type; /* handled data type. (1U << n) */
|
||||
bool initialized; /* init succeedded */
|
||||
const char *ext; /* expected extension */
|
||||
CODEC_INIT initialize;
|
||||
CODEC_SHUTDOWN shutdown;
|
||||
CODEC_OPEN codec_open;
|
||||
|
@ -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_ */
|
||||
#endif /* _SND_CODECI_H_ */
|
||||
|
||||
|
|
639
source/snd_dma.c
639
source/snd_dma.c
File diff suppressed because it is too large
Load Diff
|
@ -38,36 +38,37 @@
|
|||
#endif
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
#define FLAC__StreamDecoder FLAC__SeekableStreamDecoder
|
||||
#define FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus
|
||||
#define FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus
|
||||
#define FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus
|
||||
#define FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus
|
||||
#define FLAC__StreamDecoder FLAC__SeekableStreamDecoder
|
||||
#define FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus
|
||||
#define FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus
|
||||
#define FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus
|
||||
#define FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus
|
||||
|
||||
#define FLAC__stream_decoder_new FLAC__seekable_stream_decoder_new
|
||||
#define FLAC__stream_decoder_finish FLAC__seekable_stream_decoder_finish
|
||||
#define FLAC__stream_decoder_delete FLAC__seekable_stream_decoder_delete
|
||||
#define FLAC__stream_decoder_process_single FLAC__seekable_stream_decoder_process_single
|
||||
#define FLAC__stream_decoder_seek_absolute FLAC__seekable_stream_decoder_seek_absolute
|
||||
#define FLAC__stream_decoder_process_until_end_of_metadata FLAC__seekable_stream_decoder_process_until_end_of_metadata
|
||||
#define FLAC__stream_decoder_get_state FLAC__seekable_stream_decoder_get_state
|
||||
#define FLAC__stream_decoder_new FLAC__seekable_stream_decoder_new
|
||||
#define FLAC__stream_decoder_finish FLAC__seekable_stream_decoder_finish
|
||||
#define FLAC__stream_decoder_delete FLAC__seekable_stream_decoder_delete
|
||||
#define FLAC__stream_decoder_process_single FLAC__seekable_stream_decoder_process_single
|
||||
#define FLAC__stream_decoder_seek_absolute FLAC__seekable_stream_decoder_seek_absolute
|
||||
#define FLAC__stream_decoder_process_until_end_of_metadata FLAC__seekable_stream_decoder_process_until_end_of_metadata
|
||||
#define FLAC__stream_decoder_get_state FLAC__seekable_stream_decoder_get_state
|
||||
|
||||
#define FLAC__STREAM_DECODER_INIT_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_OK
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_CONTINUE FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_ABORT FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK /* !!! */
|
||||
#define FLAC__STREAM_DECODER_WRITE_STATUS_ABORT FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
|
||||
#define FLAC__STREAM_DECODER_SEEK_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_SEEK_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_TELL_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_TELL_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_LENGTH_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_INIT_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_OK
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_CONTINUE FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_ABORT FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK /* !!! */
|
||||
#define FLAC__STREAM_DECODER_WRITE_STATUS_ABORT FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
|
||||
#define FLAC__STREAM_DECODER_SEEK_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_SEEK_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_TELL_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
|
||||
#define FLAC__STREAM_DECODER_TELL_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
|
||||
#define FLAC__STREAM_DECODER_LENGTH_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
|
||||
typedef unsigned FLAC_SIZE_T;
|
||||
#else
|
||||
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__StreamDecoderErrorStatus status, void *client_data)
|
||||
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_SIZE_T *bytes, void *client_data)
|
||||
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__uint64 absolute_byte_offset, void *client_data)
|
||||
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__uint64 *absolute_byte_offset, void *client_data)
|
||||
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__uint64 *stream_length, void *client_data)
|
||||
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,
|
||||
const FLAC__Frame *frame, const FLAC__int32 * const buffer[],
|
||||
void *client_data)
|
||||
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,41 +218,41 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
|
|||
}
|
||||
|
||||
static void
|
||||
flac_meta_func (const FLAC__StreamDecoder *decoder,
|
||||
const FLAC__StreamMetadata *metadata, void *client_data)
|
||||
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;
|
||||
ff->info->width = ff->info->bits / 8;
|
||||
ff->info->channels = metadata->data.stream_info.channels;
|
||||
ff->info->blocksize = metadata->data.stream_info.max_blocksize;
|
||||
ff->info->dataofs = 0; /* got the STREAMINFO metadata */
|
||||
ff->info->dataofs = 0; /* got the STREAMINFO metadata */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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,129 +264,135 @@ 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,
|
||||
flac_seek_func,
|
||||
flac_tell_func,
|
||||
flac_length_func,
|
||||
flac_eof_func,
|
||||
flac_write_func,
|
||||
flac_meta_func,
|
||||
flac_error_func,
|
||||
ff);
|
||||
flac_read_func,
|
||||
flac_seek_func,
|
||||
flac_tell_func,
|
||||
flac_length_func,
|
||||
flac_eof_func,
|
||||
flac_write_func,
|
||||
flac_meta_func,
|
||||
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",
|
||||
stream->name, rc);
|
||||
stream->name, rc);
|
||||
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);
|
||||
ff->info->channels, stream->name);
|
||||
goto _fail;
|
||||
}
|
||||
|
||||
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)
|
||||
free(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;
|
||||
}
|
||||
|
||||
snd_codec_t flac_codec =
|
||||
{
|
||||
CODECTYPE_FLAC,
|
||||
true, /* always available. */
|
||||
true, /* always available. */
|
||||
"flac",
|
||||
S_FLAC_CodecInitialize,
|
||||
S_FLAC_CodecShutdown,
|
||||
|
@ -394,5 +403,5 @@ snd_codec_t flac_codec =
|
|||
NULL
|
||||
};
|
||||
|
||||
#endif /* USE_CODEC_FLAC */
|
||||
#endif /* USE_CODEC_FLAC */
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue