/*
 * Copyright (c) 2011 Rudolf Polzer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */
#pragma once

#include <common/csqcmodel_settings.qh>

noref string csqcmodel_license = "\
Copyright (c) 2011 Rudolf Polzer\
\
Permission is hereby granted, free of charge, to any person obtaining a copy\
of this software and associated documentation files (the \"Software\"), to\
deal in the Software without restriction, including without limitation the\
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\
sell copies of the Software, and to permit persons to whom the Software is\
furnished to do so, subject to the following conditions:\
\
The above copyright notice and this permission notice shall be included in\
all copies or substantial portions of the Software.\
\
THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\
IN THE SOFTWARE.\
"; // "

.vector glowmod;
.vector view_ofs;
.int frame;
.float frame1time;
.int frame2;
.float frame2time;
.float lerpfrac;

const int ISPLAYER_MODEL = BIT(0); // using a player model
const int ISPLAYER_CLIENT = BIT(1); // is a client
const int ISPLAYER_LOCAL = BIT(2); // is the local player
const int ISPLAYER_PLAYER = BIT(3); // is a player in the match

const int CSQCMODEL_PROPERTY_FRAME = BIT(23);
const int CSQCMODEL_PROPERTY_TELEPORTED = BIT(22); // the "teleport bit" cancelling interpolation
const int CSQCMODEL_PROPERTY_MODELINDEX = BIT(21);
const int CSQCMODEL_PROPERTY_ORIGIN = BIT(20);
const int CSQCMODEL_PROPERTY_YAW = BIT(19);
const int CSQCMODEL_PROPERTY_PITCHROLL = BIT(18);
const int CSQCMODEL_PROPERTY_FRAME2 = BIT(17);
const int CSQCMODEL_PROPERTY_LERPFRAC = BIT(16);
const int CSQCMODEL_PROPERTY_SIZE = BIT(15);

#define ALLPROPERTIES_COMMON \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_FRAME, int, ReadByte, WriteByte, frame) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_MODELINDEX, int, ReadShort, WriteShort, modelindex) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_ORIGIN, vector, ReadVector, WriteVector, origin) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_SIZE, vector, ReadVector, WriteVector, mins) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_SIZE, vector, ReadVector, WriteVector, maxs) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_PITCHROLL, float, ReadAngle, WriteAngle, angles_x) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_YAW, float, ReadAngle, WriteAngle, angles_y) \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_PITCHROLL, float, ReadAngle, WriteAngle, angles_z) \
	CSQCMODEL_EXTRAPROPERTIES

#ifdef CSQCMODEL_HAVE_TWO_FRAMES
.float frame3;
.float frame3time;
.float lerpfrac3;
.float frame4;
.float frame4time;
.float lerpfrac4;
#define ALLPROPERTIES ALLPROPERTIES_COMMON \
	CSQCMODEL_PROPERTY(CSQCMODEL_PROPERTY_FRAME2, int, ReadByte, WriteByte, frame2) \
	CSQCMODEL_PROPERTY_SCALED(CSQCMODEL_PROPERTY_LERPFRAC, float, ReadByte, WriteByte, lerpfrac, 255, 0, 255)
#else
#define ALLPROPERTIES ALLPROPERTIES_COMMON
#endif

#define CL_MAX_USERCMDS 128 // must be a power of 2 and == engine's CL_MAX_USERCMDS
