#pragma once

const int FRAGS_PLAYER             = -1; ///< not 0 because all fields are initially 0
const int FRAGS_PLAYER_NONSOLID    = -616; ///< independent player
const int FRAGS_SPECTATOR          = -666; ///< engine expects this value
const int FRAGS_PLAYER_OUT_OF_GAME = -669; ///< still shown with a score and/or a team, but currently forced to spec/observe

///////////////////////////
// cvar constants

const int CVAR_SAVE     = BIT(0);
const int CVAR_NOTIFY   = BIT(1);
const int CVAR_READONLY = BIT(2);

// server flags
// NOTE: the engine doesn't clear serverflags on map change (gotomap)
const int SERVERFLAG_ALLOW_FULLBRIGHT   = BIT(0);
const int SERVERFLAG_TEAMPLAY           = BIT(1);
const int SERVERFLAG_PLAYERSTATS        = BIT(2);
const int SERVERFLAG_PLAYERSTATS_CUSTOM = BIT(3);
const int SERVERFLAG_FORBID_PICKUPTIMER = BIT(4);

const int SPECIES_HUMAN       = 0;
const int SPECIES_ROBOT_SOLID = 1;
const int SPECIES_ALIEN       = 2;
const int SPECIES_ANIMAL      = 3;
const int SPECIES_ROBOT_RUSTY = 4;
const int SPECIES_ROBOT_SHINY = 5;
const int SPECIES_RESERVED    = 15;

#ifdef GAMEQC
const int RANKINGS_CNT = 99;

///////////////////////////
// keys pressed
const int KEY_FORWARD  = BIT(0);
const int KEY_BACKWARD = BIT(1);
const int KEY_LEFT     = BIT(2);
const int KEY_RIGHT    = BIT(3);
const int KEY_JUMP     = BIT(4);
const int KEY_CROUCH   = BIT(5);
const int KEY_ATCK     = BIT(6);
const int KEY_ATCK2    = BIT(7);

///////////////////////////
// csqc communication stuff

const int HUD_NORMAL = 0;
const int HUD_BUMBLEBEE_GUN = 25;

// a bit more constant
const vector PL_MAX_CONST = '16 16 45';
const vector PL_MIN_CONST = '-16 -16 -24';
const vector PL_CROUCH_MAX_CONST = '16 16 25';
const vector PL_CROUCH_MIN_CONST = '-16 -16 -24';

const float PL_CORPSE_SCALE = 0.235; // average hitbox height is scaled by this when the player dies

// generic entity flags
// engine flags can't be redefined as they are used by the engine (unfortunately), they are listed here for posterity
#ifdef CSQC
const int FL_FLY                          = 1;    /* BIT(0) */
const int FL_SWIM                         = 2;    /* BIT(1) */
const int FL_CLIENT                       = 8;    /* BIT(3) */ // set for all client edicts
const int FL_INWATER                      = 16;   /* BIT(4) */ // for enter / leave water splash
const int FL_MONSTER                      = 32;   /* BIT(5) */
const int FL_GODMODE                      = 64;   /* BIT(6) */ // player cheat
const int FL_NOTARGET                     = 128;  /* BIT(7) */ // player cheat
const int FL_ITEM                         = 256;  /* BIT(8) */ // extra wide size for bonus items IF sv_legacy_bbox_expand is 1
const int FL_ONGROUND                     = 512;  /* BIT(9) */ // standing on something
const int FL_PARTIALGROUND                = 1024; /* BIT(10) */ // not all corners are valid
const int FL_WATERJUMP                    = 2048; /* BIT(11) */ // player jumping out of water
const int FL_JUMPRELEASED                 = 4096; /* BIT(12) */ // for jump debouncing
#endif
const int FL_WEAPON                       = BIT(13);
const int FL_POWERUP                      = BIT(14);
const int FL_PROJECTILE                   = BIT(15);
const int FL_TOSSED                       = BIT(16);
const int FL_SPAWNING                     = BIT(17);
const int FL_PICKUPITEMS                  = BIT(18);
const int FL_DUCKED                       = BIT(19);
const int FL_ONSLICK                      = BIT(20);

// initialization stages
const int INITPRIO_FIRST                  = 0;
const int INITPRIO_GAMETYPE               = 0;
const int INITPRIO_GAMETYPE_FALLBACK      = 1;
const int INITPRIO_FINDTARGET             = 10;
const int INITPRIO_DROPTOFLOOR            = 20;
const int INITPRIO_SETLOCATION            = 90;
const int INITPRIO_LINKDOORS              = 91;
const int INITPRIO_LAST                   = 99;

// effects
const int EF_SHOCK = 262144;
const int EF_SPEED = 524288;
#endif

#if defined(SVQC)
	#define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT)
#elif defined(CSQC)
	#define EFMASK_CHEAP (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NODRAW | EF_NOSHADOW | EF_SELECTABLE | EF_TELEPORT_BIT)
#endif
