]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/showspecs
authorMario <zacjardine@y7mail.com>
Tue, 14 Apr 2015 22:59:14 +0000 (08:59 +1000)
committerMario <zacjardine@y7mail.com>
Tue, 14 Apr 2015 22:59:14 +0000 (08:59 +1000)
Conflicts:
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/common/constants.qh
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc

1  2 
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/server/cl_client.qc

diff --combined defaultXonotic.cfg
index a83a2577b0bd568c9b019cbe906a3554628f5e97,4f02d145e0276f7d66ae0a9036c3b9d9d6191cd2..4d3c1fea781856a841a6ed030eb1789a1abb9b15
@@@ -10,7 -10,7 +10,7 @@@
  // e.g. Xonotic 1.5.1 RC1 will be 15101
  set g_xonoticversion git "Xonotic version (formatted for humans)"
  
- gameversion 700 // 0.7.0
+ gameversion 800 // 0.8.0
  gameversion_min 0 // git builds see all versions
  gameversion_max 65535 // git builds see all versions
  
@@@ -34,6 -34,8 +34,8 @@@ seta g_configversion 0        "Configuration f
  // other aliases
  alias +hook +button6
  alias -hook -button6
+ alias +jetpack +button10
+ alias -jetpack -button10
  alias use "impulse 21"
  
  // for backwards compatibility
@@@ -44,23 -46,26 +46,26 @@@ alias dropweapon "impulse 17
  alias +show_info +button7
  alias -show_info -button7
  
- bind f6 team_auto
  // merge lightmaps up to 2048x2048 textures
  mod_q3bsp_lightmapmergepower 4
  
  // player defaults
  _cl_color "112.211" // same effect as 112, but menuqc can detect this as the default and not intentionally set
- _cl_name Player
+ _cl_name ""
+ seta _cl_gender 0 "storage cvar for current player gender (0 = undisclosed, 1 = male, 2 = female)"
  _cl_playermodel models/player/erebus.iqm
  _cl_playerskin 0
  
- seta cl_reticle 1 "control for toggling whether ANY zoom reticles are shown"
- seta cl_reticle_stretch 0 "whether to stretch reticles so they fit the screen (brakes image proportions)"
- seta cl_reticle_item_nex 1 "draw aiming reticle for the nex weapon's zoom, 0 disables and values between 0 and 1 change alpha"
- seta cl_reticle_item_normal 1 "draw reticle when zooming with the zoom button, 0 disables and values between 0 and 1 change alpha"
+ seta cl_reticle 1 "enable zoom reticles"
+ seta cl_reticle_stretch 0 "stretch reticles so they fit the screen (breaks image proportions)"
+ seta cl_reticle_normal 1 "draw an aiminig reticle when zooming with the zoom button"
+ seta cl_reticle_normal_alpha 1 "alpha of the normal reticle"
+ seta cl_reticle_weapon 1 "draw custom aiming reticle when zooming with certain weapons"
+ seta cl_reticle_weapon_alpha 1 "alpha of the custom reticle"
  fov 100
- seta cl_velocityzoom 0        "velocity based zooming of fov, negative values zoom out"
+ seta cl_velocityzoom_enabled 0 "velocity based zooming of fov"
+ seta cl_velocityzoom_factor 0 "factor of fov zooming (negative values zoom out)"
  seta cl_velocityzoom_type 3 "how to factor in speed, 1 = all velocity in all directions, 2 = velocity only in forward direction (can be negative), 3 = velocity only in forward direction (limited to forward only)"
  seta cl_velocityzoom_speed 1000 "target speed for fov factoring"
  seta cl_velocityzoom_time 0.2 "time value for averaging speed values"
@@@ -220,10 -225,14 +225,14 @@@ set sv_ready_restart 0 "if set to 1 all
  set sv_ready_restart_after_countdown 0        "if set to 1 the players and map items are reset after the countdown ended, otherwise they're reset already at the beginning of the countdown"
  set sv_ready_restart_repeatable 0     "allows the players to restart the game as often as needed"
  
- seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy"
+ seta cl_hitsound 1 "play a hit notifier sound when you have hit an enemy, 1: same pitch 2: increase pitch with more damage 3: decrease pitch with more damage"
  set cl_hitsound_antispam_time 0.05 "don't play the hitsound more often than this"
+ seta cl_hitsound_min_pitch 0.75 "minimum pitch of hit sound"
+ seta cl_hitsound_max_pitch 1.5 "maximum pitch of hit sound"
+ seta cl_hitsound_nom_damage 25 "damage amount at which hitsound bases pitch off"
  
- seta cl_eventchase_death 1 "camera goes into 3rd person mode when the player is dead"
+ seta cl_eventchase_death 1 "camera goes into 3rd person mode when the player is dead; set to 2 to active the effect only when the corpse doesn't move anymore"
+ seta cl_eventchase_nexball 1 "camera goes into 3rd person mode when in nexball game-mode"
  seta cl_eventchase_distance 140 "final camera distance"
  seta cl_eventchase_speed 1.3 "how fast the camera slides back, 0 is instant"
  seta cl_eventchase_maxs "12 12 8" "max size of eventchase camera bbox"
@@@ -256,8 -265,8 +265,8 @@@ set sv_timeout_number 2    "how many timeo
  set sv_timeout_leadtime 4     "how long the players will be informed that a timeout was called before it starts, in seconds"
  set sv_timeout_resumetime 3   "how long the remaining timeout-time will be after a player called the timein command"
  
- set g_allow_oldnexbeam 0 "If enabled, clients are allowed to use old v2.3 Nexgun beam"
- seta cl_particles_oldnexbeam 0 "Uses the old v2.3 Nexgun beam instead of the new beam, only works if server allows it (g_allow_oldnexbeam 1)"
+ set g_allow_oldvortexbeam 0 "If enabled, clients are allowed to use old v2.3 Vortex beam"
+ seta cl_particles_oldvortexbeam 0 "Uses the old v2.3 Vortex beam instead of the new beam, only works if server allows it (g_allow_oldvortexbeam 1)"
  
  set g_telefrags 1 "telefragging, i.e. killing someone who stands in the way of someone who is teleporting"
  set g_telefrags_teamplay 1 "never telefrag team mates"
@@@ -359,9 -368,9 +368,9 @@@ set bot_ai_keyboard_threshold 0.5
  set bot_ai_aimskill_offset 0.3 "Amount of error induced to the bots aim"
  set bot_ai_aimskill_think 1 "Aiming velocity. Use values below 1 for slower aiming"
  set bot_ai_custom_weapon_priority_distances "300 850" "Define close and far distances in any order. Based on the distance to the enemy bots will choose different weapons"
- set bot_ai_custom_weapon_priority_far   "minstanex nex rifle electro rocketlauncher grenadelauncher hagar hlac crylink laser uzi fireball seeker shotgun tuba minelayer"      "Desired weapons for far distances ordered by priority"
- set bot_ai_custom_weapon_priority_mid   "minstanex rocketlauncher nex fireball seeker grenadelauncher electro uzi crylink hlac hagar shotgun laser rifle tuba minelayer"      "Desired weapons for middle distances ordered by priority"
- set bot_ai_custom_weapon_priority_close "minstanex shotgun nex uzi hlac tuba seeker hagar crylink grenadelauncher electro rocketlauncher laser fireball rifle minelayer"      "Desired weapons for close distances ordered by priority"
+ set bot_ai_custom_weapon_priority_far   "vaporizer vortex rifle electro devastator mortar hagar hlac crylink blaster machinegun fireball seeker shotgun tuba minelayer"       "Desired weapons for far distances ordered by priority"
+ set bot_ai_custom_weapon_priority_mid   "vaporizer devastator vortex fireball seeker mortar electro machinegun crylink hlac hagar shotgun blaster rifle tuba minelayer arc shockwave" "Desired weapons for middle distances ordered by priority"
+ set bot_ai_custom_weapon_priority_close "vaporizer shotgun vortex machinegun hlac tuba seeker hagar crylink mortar electro devastator blaster fireball rifle minelayer arc shockwave" "Desired weapons for close distances ordered by priority"
  set bot_ai_weapon_combo 1     "Enable bots to do weapon combos"
  set bot_ai_weapon_combo_threshold 0.4 "Try to make a combo N seconds after the last attack"
  set bot_ai_friends_aware_pickup_radius "500"  "Bots will not pickup items if a team mate is this distance near the item"
@@@ -415,9 -424,7 +424,7 @@@ set g_use_ammunition 1 "if set to 0 al
  set g_pickup_items -1 "if set to 0 all items (health, armor, ammo, weapons...) are removed from the map, if 1 they are forced to spawn"
  set g_weaponarena "0" "put in a list of weapons to enable a weapon arena mode, or try \"all\" or \"most\""
  set g_weaponarena_random "0"  "if set to a number, only that weapon count is given on every spawn (randomly)"
- set g_weaponarena_random_with_laser "1"       "additionally, always provide the laser in random weapon arena games"
- set g_midair 0 "if set to 1 you can only apply damage to your opponent while he is airborne"
- set g_midair_shieldtime 0.3 "number of seconds you are still invincible since you lost contact to the ground"
+ set g_weaponarena_random_with_blaster "1"     "additionally, always provide the blaster in random weapon arena games"
  set g_spawnpoints_auto_move_out_of_solid 0 "if set to 1 you will see a warning if a spawn point was placed inside a solid"
  set g_forced_respawn 0 "if set to 1 and a player died, that player gets automatically respawned once <g_respawn_delay> seconds are over"
  set g_fullbrightplayers 0 "brightens up player models (note that the color, skin or model of the players does not change!)"
@@@ -455,8 -462,6 +462,6 @@@ seta menu_sandbox_edit_physics 
  seta menu_sandbox_edit_force 1
  seta menu_sandbox_edit_material ""
  
- bind f7 menu_showsandboxtools
  seta menu_monsters_edit_spawn ""
  seta menu_monsters_edit_skin 0
  seta menu_monsters_edit_movetarget 1
@@@ -467,10 -472,13 +472,13 @@@ set g_botclip_collisions 1 "0 = disabl
  set g_grappling_hook 0 "let players spawn with the grappling hook which allows them to pull themselves up"
  
  set g_spawn_alloweffects 1 "allow clients to enable spawn point and event effects such as particles and sounds, see cl_spawn_ cvars for more info"
- set g_spawn_furthest 1 "this amount of the spawns shall be far away from any players"
+ set g_spawn_furthest 1.0 "this amount of the spawns shall be far away from any players"
  set g_spawn_useallspawns 0 "use all spawns, e.g. also team spawns in non-teamplay, and all spawns, even enemy spawns, in teamplay"
  // respawn delay
- set g_respawn_delay 2 "number of seconds you have to wait before you can respawn again"
+ set g_respawn_delay_small 2 "small game number of seconds you have to wait before you can respawn again"
+ set g_respawn_delay_small_count 0 "Player count per team for g_respawn_delay_small. <=0 values mean the minimum amount of players to have gameplay (typically 2 in FFA, 1 in teamplay)."
+ set g_respawn_delay_large 2 "large game number of seconds you have to wait before you can respawn again"
+ set g_respawn_delay_large_count 8 "Player count per team for g_respawn_delay_large. <=0 values mean the minimum amount of players to have gameplay (typically 2 in FFA, 1 in teamplay)."
  set g_respawn_delay_max 0 "number of seconds you can wait before you're forced to respawn (only effective with g_forced_respawn 1)"
  set g_respawn_waves 0 "respawn in waves (every n seconds), intended to decrease overwhelming base attacks"
  
@@@ -483,7 -491,7 +491,7 @@@ seta timelimit_suddendeath 5 "number o
  set g_tdm 0 "Team Deathmatch: the team who kills their opponents most often wins"
  set g_tdm_on_dm_maps 0 "when this is set, all DM maps automatically support TDM"
  
- seta teamplay_mode 4 "default teamplay setting in team games. 1 = no friendly fire, self damage. 2 = friendly fire and self damage enabled. 3 = no friendly fire, but self damage enabled. 4 = obey the following four cvars"
+ seta teamplay_mode 4 "default teamplay setting in team games. 1 = no friendly fire, self damage. 2 = friendly fire and self damage enabled. 3 = no friendly fire, but self damage enabled. 4 = obey the cvars g_mirrordamage*, g_friendlyfire* and g_teamdamage_threshold*"
  seta g_mirrordamage 0.700000  "for teamplay 4: mirror damage factor"
  seta g_mirrordamage_virtual 1 "for teamplay 4: do not actually apply mirror damage, just show graphics effect for it"
  seta g_friendlyfire 0.500000  "for teamplay 4: fiendly fire factor"
@@@ -504,8 -512,6 +512,6 @@@ set g_bloodloss 0   "amount of health b
  
  set g_footsteps 1     "serverside footstep sounds"
  
- set g_deathglow 1.25 "when enabled, players stop glowing after they die (the value specifies glow fading speed)"
  set g_multijump 0     "Number of multiple jumps to allow (jumping again in the air), -1 allows for infinite jumps"
  set g_multijump_add 0 "0 = make the current z velocity equal to jumpvelocity, 1 = add jumpvelocity to the current z velocity"
  set g_multijump_speed -999999 "Minimum vertical speed a player must have in order to jump again"
@@@ -539,13 -545,14 +545,14 @@@ gl_picmip_other 1 // so, picmip -1 is b
  r_mipsprites 1
  r_mipskins 1
  r_shadow_realtime_world_lightmaps 1
+ r_shadow_realtime_world_importlightentitiesfrommap 0 // Whether build process uses keepLights is nontransparent and may change, so better make keepLights not matter.
  cl_decals_fadetime 5
- cl_decals_time 2
+ cl_decals_time 1
  seta cl_gunalign 3 "Gun alignment; 1 = center (if allowed by g_shootfromclient) or right, 2 = center (if allowed by g_shootfromclient) or left, 3 = right only, 4 = left only"
  seta cl_nogibs 0 "reduce number of violence effects, or remove them totally"
  seta cl_particlegibs 0 "simpler gibs"
  seta cl_gibs_damageforcescale 3.5 "force to push around gibs"
- seta cl_gibs_lifetime 5 "average lifetime of gibs"
+ seta cl_gibs_lifetime 2.5 "average lifetime of gibs"
  seta cl_gibs_velocity_scale 1 "gib throw velocity force scale"
  seta cl_gibs_velocity_random 1 "gib throw velocity randomness scale"
  seta cl_gibs_velocity_up 1 "extra z velocity for gibs"
@@@ -557,7 -564,7 +564,7 @@@ seta cl_casings_shell_time 30 "shell ca
  seta cl_casings_bronze_time 10 "bullet casings lifetime"
  seta cl_casings_ticrate 0.1 "ticrate for casings"
  seta cl_casings_sloppy 1 "sloppy casings, may temporarily penetrate walls"
- seta cl_projectiles_sloppy 0 "sloppy projectiles, may temporarily penetrate walls"
+ seta cl_projectiles_sloppy 1 "sloppy projectiles, may temporarily penetrate walls"
  cl_stainmaps 0
  cl_particles_smoke 1
  vid_gl20 1
@@@ -624,19 -631,6 +631,6 @@@ alias togglezoom "${_togglezoom}zoom
  
  alias reload "impulse 20"
  
- // movement
- bind w +forward
- bind a +moveleft
- bind s +back
- bind d +moveright
- bind UPARROW +forward
- bind LEFTARROW +moveleft
- bind DOWNARROW +back
- bind RIGHTARROW +moveright
- bind SHIFT +crouch
- bind ENTER +jump
- bind SPACE +jump
  // weapons
  alias weapon_group_1 "impulse 1"
  alias weapon_group_2 "impulse 2"
@@@ -649,102 -643,6 +643,6 @@@ alias weapon_group_8 "impulse 8
  alias weapon_group_9 "impulse 9"
  alias weapon_group_0 "impulse 14" // cycles the superweapons
  exec weapons.cfg
- bind 0 weapon_group_0
- bind 1 weapon_group_1
- bind 2 weapon_group_2
- bind 3 weapon_group_3
- bind 4 weapon_group_4
- bind 5 weapon_group_5
- bind 6 weapon_group_6
- bind 7 weapon_group_7
- bind 8 weapon_group_8
- bind 9 weapon_group_9
- bind q weaplast
- bind MOUSE1 +fire
- bind MOUSE2 +fire2
- bind MOUSE3 togglezoom
- bind MOUSE4 weaplast
- bind MOUSE5 +hook
- bind MWHEELUP weapnext
- bind MWHEELDOWN weapprev
- bind r reload
- bind BACKSPACE dropweapon
- bind g dropweapon
- bind f +use
- bind v +button8 // drag object
- // misc
- bind e +hook
- bind ` toggleconsole
- bind ~ toggleconsole
- bind TAB +showscores
- bind ESCAPE togglemenu
- bind t messagemode
- bind y messagemode2
- bind z messagemode2
- bind u "+con_chat_maximize"
- bind m +hud_panel_radar_maximized
- bind i +show_info
- bind PAUSE pause
- bind F10 menu_showquitdialog
- bind F11 disconnect
- bind F12 screenshot
- bind F4 ready
- bind ALT +showaccuracy
- // Gamepad defaults. Tested with Logitech Rumblepad 2, I hope similar ones works as well.
- bind JOY1 "+crouch"
- bind JOY2 "+jump"
- bind JOY3 "weapprev"
- bind JOY4 "weapnext"
- bind JOY5 "+fire2"
- bind JOY6 "+fire"
- bind JOY7 "+zoom"
- bind JOY8 "dropweapon"
- bind JOY9 "menu_showteamselect"
- bind JOY10 "+show_info"
- bind JOY11 "+showscores"
- bind JOY12 "+con_chat_maximize"
- seta joyadvanced "1"
- seta joyadvaxisr "2"
- seta joyadvaxisx "3"
- seta joyadvaxisy "1"
- seta joyadvaxisz "4"
- seta joysidesensitivity "1.0"
- seta joypitchsensitivity "0.9"
- seta joyyawsensitivity "-1.8"
- // SDL only
- seta joy_deadzoneforward "0.05"
- seta joy_deadzonepitch "0.05"
- seta joy_deadzoneside "0.05"
- seta joy_deadzoneup "0.05"
- seta joy_deadzoneyaw "0.05"
- seta joy_sensitivitypitch "0.9"
- seta joy_sensitivityyaw "-1.8"
- // team say
- bind kp_ins messagemode
- bind kp_del messagemode2
- bind kp_end "+userbind 1"
- bind kp_downarrow "+userbind 2"
- bind kp_pgdn "+userbind 3"
- bind kp_leftarrow "+userbind 4"
- bind kp_5 "+userbind 6"
- bind kp_rightarrow "+userbind 7"
- bind kp_home "+userbind 9"
- bind kp_uparrow "+userbind 10"
- bind kp_pgup "+userbind 11"
- bind kp_multiply "+userbind 12"
- bind kp_slash "+userbind 13"
- bind kp_enter "+userbind 16"
- bind kp_plus "+userbind 17"
- bind kp_minus "+userbind 18"
- bind F1 vyes
- bind F2 vno
- //used for spectate/observer mode
- bind F3 spec
  
  // score log
  set sv_logscores_console 0    "print scores to server console"
@@@ -809,6 -707,12 +707,12 @@@ seta g_maplist_votable_nodetail 1        "node
  seta g_maplist_votable_abstain 0      "when 1, you can abstain from your vote"
  seta g_maplist_votable_screenshot_dir "maps levelshots"       "where to look for map screenshots"
  
+ set sv_vote_gametype 0 "show a vote screen for gametypes before map vote screen"
+ set sv_vote_gametype_keeptwotime 10 "show only 2 options for this amount of time during gametype vote screen"
+ set sv_vote_gametype_options "dm ctf ca lms tdm ft"
+ set sv_vote_gametype_timeout 20
+ set sv_vote_gametype_default_current 1 "Keep the current gametype if no one votes"
  set g_chat_flood_spl 3        "normal chat: seconds between lines to not count as flooding"
  set g_chat_flood_lmax 2       "normal chat: maximum number of lines per chat message at once"
  set g_chat_flood_burst 2      "normal chat: allow bursts of so many chat lines"
@@@ -884,48 -788,12 +788,12 @@@ set g_banned_list_idmode "1"    "when set
  
  r_labelsprites_scale 0.40625 // labels sprites get displayed at 0.5x from 640x480 to 1280x1024, and at 1x from 1600x1200 onwards
  
- // usercommands. These can be edited and bound by the menu.
- seta "userbind1_press" "say_team quad soon";  seta "userbind1_release" "";  seta "userbind1_description" "team: quad soon"
- seta "userbind2_press" "say_team free item %x^7 (l:%y^7); g_waypointsprite_team_here_p";  seta "userbind2_release" "";  seta "userbind2_description" "team: free item, icon"
- seta "userbind3_press" "say_team took item (l:%l^7); g_waypointsprite_team_here";  seta "userbind3_release" "";  seta "userbind3_description" "team: took item, icon"
- seta "userbind4_press" "say_team negative";  seta "userbind4_release" "";  seta "userbind4_description" "team: negative"
- seta "userbind5_press" "say_team positive";  seta "userbind5_release" "";  seta "userbind5_description" "team: positive"
- seta "userbind6_press" "say_team need help (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_helpme; cmd voice needhelp";  seta "userbind6_release" "";  seta "userbind6_description" "team: need help, icon"
- seta "userbind7_press" "say_team enemy seen (l:%y^7); g_waypointsprite_team_danger_p; cmd voice incoming";  seta "userbind7_release" "";  seta "userbind7_description" "team: enemy seen, icon"
- seta "userbind8_press" "say_team flag seen (l:%y^7); g_waypointsprite_team_here_p; cmd voice seenflag";  seta "userbind8_release" "";  seta "userbind8_description" "team: flag seen, icon"
- seta "userbind9_press" "say_team defending (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here";  seta "userbind9_release" "";  seta "userbind9_description" "team: defending, icon"
- seta "userbind10_press" "say_team roaming (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here";  seta "userbind10_release" "";  seta "userbind10_description" "team: roaming, icon"
- seta "userbind11_press" "say_team attacking (l:%l^7) (h:%h^7 a:%a^7 w:%w^7); g_waypointsprite_team_here";  seta "userbind11_release" "";  seta "userbind11_description" "team: attacking, icon"
- seta "userbind12_press" "say_team killed flagcarrier (l:%y^7); g_waypointsprite_team_here_p"; seta "userbind12_release" ""; seta "userbind12_description" "team: killed flag, icon"
- seta "userbind13_press" "say_team dropped flag (l:%d^7); g_waypointsprite_team_here_d"; seta "userbind13_release" ""; seta "userbind13_description" "team: dropped flag, icon"
- seta "userbind14_press" "say_team dropped gun %w^7 (l:%l^7); g_waypointsprite_team_here; wait; dropweapon"; seta "userbind14_release" ""; seta "userbind14_description" "team: drop gun, icon"
- // TODO change this to "use" once we can
- seta "userbind15_press" "say_team dropped flag/key %w^7 (l:%l^7); g_waypointsprite_team_here; wait; +use"; seta "userbind15_release" "-use"; seta "userbind15_description" "team: drop flag/key, icon"
- seta "userbind16_press" "say :-) / nice one"; seta "userbind16_release" ""; seta "userbind16_description" "chat: nice one"
- seta "userbind17_press" "say good game"; seta "userbind17_release" ""; seta "userbind17_description" "chat: good game"
- seta "userbind18_press" "say hi / good luck and have fun"; seta "userbind18_release" ""; seta "userbind18_description" "chat: hi / good luck"
- seta "userbind19_press" "+showscores; +con_chat_maximize"; seta "userbind19_release" "-showscores; -con_chat_maximize"; seta "userbind19_description" "scoreboard / chat history"
- seta "userbind20_press" "toggle cl_capturevideo"; seta "userbind20_release" ""; seta "userbind20_description" "toggle recording .avi"
- seta "userbind21_press" "toggle vid_fullscreen; vid_restart"; seta "userbind21_release" ""; seta "userbind21_description" "toggle fullscreen"
- seta "userbind22_press" ""; seta "userbind22_release" ""; seta "userbind22_description" ""
- seta "userbind23_press" ""; seta "userbind23_release" ""; seta "userbind23_description" ""
- seta "userbind24_press" ""; seta "userbind24_release" ""; seta "userbind24_description" ""
- seta "userbind25_press" ""; seta "userbind25_release" ""; seta "userbind25_description" ""
- seta "userbind26_press" ""; seta "userbind26_release" ""; seta "userbind26_description" ""
- seta "userbind27_press" ""; seta "userbind27_release" ""; seta "userbind27_description" ""
- seta "userbind28_press" ""; seta "userbind28_release" ""; seta "userbind28_description" ""
- seta "userbind29_press" ""; seta "userbind29_release" ""; seta "userbind29_description" ""
- seta "userbind30_press" ""; seta "userbind30_release" ""; seta "userbind30_description" ""
- seta "userbind31_press" ""; seta "userbind31_release" ""; seta "userbind31_description" ""
- seta "userbind32_press" ""; seta "userbind32_release" ""; seta "userbind32_description" ""
- alias _userbind_call "${$1}"
- alias +userbind "_userbind_call userbind${1}_press"
- alias -userbind "_userbind_call userbind${1}_release"
+ exec binds-xonotic.cfg
  
  // we must change its default from 1.0 to 1 to be consistent with menuqc
  set slowmo 1
  
- seta menu_skin "luminos"
+ seta menu_skin "luma"
  set menu_slowmo 1
  seta menu_sounds 0 "enables menu sound effects. 1 enables click sounds, 2 also enables hover sounds"
  seta menu_tooltips 1 "menu tooltips: 0 disabled, 1 enabled, 2 also shows cvar or console command (when available) changed or executed by the item"
@@@ -956,19 -824,19 +824,19 @@@ seta scoreboard_accuracy_border_thickne
  seta scoreboard_accuracy_doublerows 0 "use two rows instead of one"
  seta scoreboard_accuracy_nocolors 0 "don't use colors displaying accuracy stats"
  seta scoreboard_accuracy 1 "show weapon accuracy stats panel on scoreboard; colors can be configured with accuracy_color* cvars"
- seta scoreboard_color_bg_r 0 "red color component of the scoreboard background"
- seta scoreboard_color_bg_g 0.4 "green color component of the scoreboard background"
- seta scoreboard_color_bg_b 0.6 "blue color component of the scoreboard background"
- seta scoreboard_color_bg_team 0.5 "team color multiplier of the scoreboard background"
- seta scoreboard_alpha_bg 0.6 "scoreboard background alpha"
+ seta scoreboard_color_bg_r 0.125 "red color component of the scoreboard background"
+ seta scoreboard_color_bg_g 0.55 "green color component of the scoreboard background"
+ seta scoreboard_color_bg_b 0.875 "blue color component of the scoreboard background"
+ seta scoreboard_color_bg_team 0.6 "team color multiplier of the scoreboard background"
+ seta scoreboard_alpha_bg 0.7 "scoreboard background alpha"
  seta scoreboard_alpha_fg 1 "scoreboard foreground alpha"
  seta scoreboard_alpha_name 0.9 "alpha of player text in scoreboard list other than self"
  seta scoreboard_alpha_name_self 1 "alpha of player text in scoreboard list of self"
  seta scoreboard_fadeinspeed 10 "speed at which scoreboard fades in, higher is faster (0 = instant)"
  seta scoreboard_fadeoutspeed 5 "speed at which scoreboard fades out, higher is faster (0 = instant)"
  seta scoreboard_highlight 1 "enable highlighting for rows and columns in the scoreboard"
- seta scoreboard_highlight_alpha 0.10 "highlight alpha value (depends on hud_scoreboard_highlight 1)"
- seta scoreboard_highlight_alpha_self 0.25 "self highlight alpha value"
+ seta scoreboard_highlight_alpha 0.08 "highlight alpha value (depends on hud_scoreboard_highlight 1)"
+ seta scoreboard_highlight_alpha_self 0.3 "self highlight alpha value"
  seta scoreboard_offset_left 0.15 "how far (by percent) the scoreboard is offset from the left screen edge"
  seta scoreboard_offset_right 0.15 "how far (by percent) the scoreboard is offset from the right screen edge"
  seta scoreboard_offset_vertical 0.05 "how far (by percent) the scoreboard is offset from the top and bottom of the screen"
@@@ -1004,7 -872,7 +872,7 @@@ seta menu_slist_categories_CAT_SERVERS_
  seta menu_slist_categories_CAT_XPM_override "CAT_NORMAL"
  seta menu_slist_categories_CAT_MODIFIED_override ""
  seta menu_slist_categories_CAT_OVERKILL_override ""
- seta menu_slist_categories_CAT_MINSTAGIB_override ""
+ seta menu_slist_categories_CAT_INSTAGIB_override ""
  seta menu_slist_categories_CAT_DEFRAG_override ""
  
  seta menu_weaponarena ""
@@@ -1052,7 -920,7 +920,7 @@@ set con_completion_gotomap        ma
  set con_completion_vmap               map
  set con_completion_vnextmap   map
  set con_completion_vdomap     map
- set con_completion_playermodel        models/player/*.iqm
+ set con_completion_playermodel        "models/player/*.iqm"
  
  // helper
  // these non-saved engine cvars shall be saved
@@@ -1070,6 -938,8 +938,8 @@@ makesaved vid_gl1
  makesaved vid_gl20
  makesaved v_idlescale
  makesaved v_kicktime
+ makesaved music_playlist_list0
+ makesaved music_playlist_random0
  
  // ticrate
  //sys_ticrate 0.0166667 // 60fps. This would be ideal, but kills home routers.
@@@ -1119,7 -989,7 +989,7 @@@ cd remap $g_cdtracks_remaplis
  set sv_intermission_cdtrack ""
  
  set g_cdtracks_dontusebydefault "rising-of-the-phoenix"
- set menu_cdtrack "rising-of-the-phoenix"
+ seta menu_cdtrack "rising-of-the-phoenix"
  
  set sv_maxidle 0 "kick players idle for more than this amount of time in seconds"
  set sv_maxidle_spectatorsareidle 0 "when sv_maxidle is not 0, assume spectators are idle too"
@@@ -1134,14 -1004,14 +1004,14 @@@ sv_allowdownloads 0 // download protoco
  
  set g_jump_grunt 0    "Do you make a grunting noise every time you jump? Is it the same grunting noise every time?"
  
- seta cl_weaponpriority "minstanex nex fireball grenadelauncher uzi hagar rifle electro rocketlauncher crylink minelayer shotgun hlac tuba laser porto seeker hook" "weapon priority list"
+ seta cl_weaponpriority "vaporizer vortex fireball mortar machinegun hagar rifle arc electro devastator crylink minelayer shotgun hlac tuba blaster porto seeker hook" "weapon priority list"
  seta cl_weaponpriority_useforcycling 0 "when set, weapon cycling by the mouse wheel makes use of the weapon priority list (the special value 2 uses the weapon ID list for cycling)"
- seta cl_weaponpriority0 "rocketlauncher grenadelauncher hagar seeker fireball" "use impulse 200 for prev gun from this list, 210 for best gun, 220 for next gun.  Default value: explosives"
- seta cl_weaponpriority1 "minstanex nex crylink hlac electro laser"             "use impulse 201 for prev gun from this list, 211 for best gun, 221 for next gun.  Default value: energy"
- seta cl_weaponpriority2 "minstanex nex rifle"                           "use impulse 202 for prev gun from this list, 212 for best gun, 222 for next gun.  Default value: hitscan exact"
- seta cl_weaponpriority3 "minstanex nex rifle uzi shotgun"               "use impulse 203 for prev gun from this list, 213 for best gun, 223 for next gun.  Default value: hitscan all"
- seta cl_weaponpriority4 "grenadelauncher minelayer hlac hagar crylink seeker shotgun"    "use impulse 204 for prev gun from this list, 214 for best gun, 224 for next gun.  Default value: spam weapons"
- seta cl_weaponpriority5 "laser hook porto"                                     "use impulse 205 for prev gun from this list, 215 for best gun, 225 for next gun.  Default value: weapons for moving"
+ seta cl_weaponpriority0 "devastator mortar hagar seeker fireball" "use impulse 200 for prev gun from this list, 210 for best gun, 220 for next gun.  Default value: explosives"
+ seta cl_weaponpriority1 "vaporizer vortex crylink hlac arc electro blaster shockwave"             "use impulse 201 for prev gun from this list, 211 for best gun, 221 for next gun.  Default value: energy"
+ seta cl_weaponpriority2 "vaporizer vortex rifle"                           "use impulse 202 for prev gun from this list, 212 for best gun, 222 for next gun.  Default value: hitscan exact"
+ seta cl_weaponpriority3 "vaporizer vortex rifle machinegun shotgun"               "use impulse 203 for prev gun from this list, 213 for best gun, 223 for next gun.  Default value: hitscan all"
+ seta cl_weaponpriority4 "mortar minelayer hlac hagar crylink seeker shotgun"    "use impulse 204 for prev gun from this list, 214 for best gun, 224 for next gun.  Default value: spam weapons"
+ seta cl_weaponpriority5 "blaster shockwave hook porto"                                     "use impulse 205 for prev gun from this list, 215 for best gun, 225 for next gun.  Default value: weapons for moving"
  seta cl_weaponpriority6 "" "use impulse 206 for prev gun from this list, 216 for best gun, 226 for next gun"
  seta cl_weaponpriority7 "" "use impulse 207 for prev gun from this list, 217 for best gun, 227 for next gun"
  seta cl_weaponpriority8 "" "use impulse 208 for prev gun from this list, 218 for best gun, 228 for next gun"
@@@ -1165,9 -1035,9 +1035,9 @@@ seta cl_clippedspectating 1 "movement c
  
  seta cl_autoscreenshot 1 "Take a screenshot upon the end of a match... 0 = Disable completely, 1 = Allow sv_autoscreenshot to take a screenshot when requested, 2 = Always take an autoscreenshot anyway."
  
+ seta cl_jetpack_jump 1 "Activate jetpack by pressing jump in the air. 0 = Disable, 1 = Stop when touching ground, 2 = Enable"
  // must be at the bottom of this file:
- // alias for switching the teamselect menu
- bind f5 menu_showteamselect
  
  set g_bugrigs 0
  set g_bugrigs_planar_movement 1       "BROTRR bug emulation"
@@@ -1228,7 -1098,7 +1098,7 @@@ seta cl_gentle_gibs 0           "client side gen
  seta cl_gentle_messages 0     "client side gentle mode (only replaces frag messages/centerprints)"
  seta cl_gentle_damage 0               "client side gentle mode (only replaces damage flash); when set to 1, a white flash replaces the blood image, when set to 2, a randomily colored flash is used instead"
  
- set g_jetpack 0 "Jetpack mutator (uses the hook's button, can't coexist with the offhand hook, but only with the onhand one)"
+ set g_jetpack 0 "Jetpack mutator"
  
  set g_running_guns 0 "... or wonder, till it drives you mad, what would have followed if you had."
  set g_bastet 0 "don't try"
@@@ -1254,7 -1124,7 +1124,7 @@@ set bot_sound_monopoly 0 "when enabled
  
  set cl_loddistance1 1024
  set cl_loddistance2 3072
- seta cl_playerdetailreduction 1       "the higher, the less detailed player models are displayed (LOD)"
+ seta cl_playerdetailreduction 4       "the higher, the less detailed player models are displayed (LOD)"
  seta cl_modeldetailreduction 1        "the higher, the less detailed certain map models are displayed (LOD)"
  
  set g_mapinfo_settemp_acl "+*" "ACL for mapinfo setting cvars"
@@@ -1302,8 -1172,6 +1172,6 @@@ set sv_accuracy_data_send 1 "1 send wea
  set cl_accuracy_data_share 0 "1 share my weapon accuracy data statistics with other players, 0 keep my weapon accuracy data statistics hidden"
  set cl_accuracy_data_receive 0 "1 receive weapon accuracy data statistics at the end of the match"
  
- set developer_fteqccbugs 0 "check fteqcc bugs on startup"
- set _allow_unacceptable_compiler_bugs 0 "don't bail out if certain bugs are detected (HANDLE WITH CARE)"
  set spawn_debug 0 "use all spawns one by one, then abort, to verify all spawnpoints"
  set loddebug 0 "force this LOD level"
  set spawn_debugview 0 "display spawnpoints and their rating on spawn to debug spawnpoint rating calculation"
@@@ -1367,25 -1235,7 +1235,7 @@@ volume 
  // sucks less than the old one
  cl_decals_newsystem 1
  
- // NOTE: this only replaces weapons on the map
- // use g_start_weapon_* to also replace the on-startup weapons!
- // example: g_weaponreplace_nex "nex minstanex", then Nexes become MinstaNexes 50% of the times
- // set the cvars to "0" to totally disable a weapon
- set g_weaponreplace_laser ""
- set g_weaponreplace_shotgun ""
- set g_weaponreplace_uzi ""
- set g_weaponreplace_grenadelauncher ""
- set g_weaponreplace_electro ""
- set g_weaponreplace_crylink ""
- set g_weaponreplace_nex ""
- set g_weaponreplace_hagar ""
- set g_weaponreplace_rocketlauncher ""
- set g_weaponreplace_porto ""
- set g_weaponreplace_minstanex ""
- set g_weaponreplace_hook ""
- set g_weaponreplace_tuba ""
- set g_weaponreplace_fireball ""
- set sv_q3acompat_machineshotgunswap 0 "shorthand for swapping uzi and shotgun (for Q3A map compatibility in mapinfo files)"
+ set sv_q3acompat_machineshotgunswap 0 "shorthand for swapping machinegun and shotgun (for Q3A map compatibility in mapinfo files)"
  
  set g_movement_highspeed 1 "movement speed modification factor (only changes movement when above maxspeed)"
  
@@@ -1432,6 -1282,7 +1282,7 @@@ r_shadow_glossintensity 
  r_fakelight 1
  
  r_water_hideplayer 1 // hide your own feet/player model in refraction views, this way you don't see half of your body under water
+ r_water_refractdistort 0.019
  
  // strength sound settings
  set sv_strengthsound_antispam_time 0.1 "minimum distance of strength sounds"
@@@ -1538,8 -1389,7 +1389,7 @@@ scr_loadingscreen_scale_base 
  scr_loadingscreen_scale_limit 2
  
  // other config files
- exec mutator_new_toys.cfg // run BEFORE balance to make sure balance wins
- exec balanceXonotic.cfg
+ exec balance-xonotic.cfg
  exec effects-normal.cfg
  exec physicsX.cfg
  exec turrets.cfg
@@@ -1558,7 -1408,7 +1408,7 @@@ exec _hud_common.cf
  exec _hud_descriptions.cfg
  // exec the default skin config
  // please add any new cvars into the hud_save script in qcsrc/client/hud_config.qc for consistency
- exec hud_luminos.cfg
+ exec hud_luma.cfg
  
  
  // ... and now that everything is configured/aliased, we can do some things:
@@@ -1582,5 -1432,7 +1432,12 @@@ set cl_fullbright_items 0 "enable fullb
  set cl_weapon_stay_color "2 0.5 0.5" "Color of picked up weapons when g_weapon_stay > 0"
  set cl_weapon_stay_alpha 0.75 "Alpha of picked up weapons when g_weapon_stay > 0"
  
++<<<<<<< HEAD
 +set sv_showspectators 0
 +set cl_showspectators 1
++=======
+ // Facility for config.cfg use ONLY.
+ // Interpreted in post-config.cfg.
+ seta menu_forced_saved_cvars "" "These cvars will always be saved, despite engine/Xonotic cvar saving status"
+ set menu_reverted_nonsaved_cvars "" "These cvars are currently marked as saved in the flags, but have been reverted and won't stay saved. INTERNAL USE ONLY."
++>>>>>>> master
index 64ef41ff54a11fc377d4e36e03f3d2702e2d2442,e35bf82dd2759122afc2cf11d46707ef5fc1177b..488115f703eae5be5fab42ba70464a51ac688f53
- float autocvar__con_chat_maximized;
- float autocvar__hud_configure;
+ #ifndef CLIENT_AUTOCVARS_H
+ #define CLIENT_AUTOCVARS_H
+ bool autocvar__con_chat_maximized;
+ bool autocvar__hud_configure;
  string autocvar__hud_panelorder;
  float autocvar__menu_alpha;
  string autocvar_accuracy_color_levels;
  float autocvar_bgmvolume;
float autocvar_camera_chase_smoothly;
float autocvar_camera_enable;
float autocvar_camera_forward_follows;
float autocvar_camera_free;
bool autocvar_camera_chase_smoothly;
bool autocvar_camera_enable;
bool autocvar_camera_forward_follows;
bool autocvar_camera_free;
  float autocvar_camera_look_attenuation;
  float autocvar_camera_look_player;
  float autocvar_camera_mouse_threshold;
float autocvar_camera_reset;
bool autocvar_camera_reset;
  float autocvar_camera_speed_attenuation;
  float autocvar_camera_speed_chase;
  float autocvar_camera_speed_free;
  float autocvar_camera_speed_roll;
float autocvar_chase_active;
float autocvar_cl_allow_uid2name;
int autocvar_chase_active;
int autocvar_cl_allow_uid2name;
  string autocvar_cl_announcer;
var float autocvar_cl_announcer_antispam = 2;
var float autocvar_cl_announcer_maptime = 3;
float autocvar_cl_autodemo_delete;
float autocvar_cl_autodemo_delete_keeprecords;
float autocvar_cl_casings;
+ float autocvar_cl_announcer_antispam = 2;
+ float autocvar_cl_announcer_maptime = 3;
bool autocvar_cl_autodemo_delete;
bool autocvar_cl_autodemo_delete_keeprecords;
bool autocvar_cl_casings;
  float autocvar_cl_casings_bronze_time;
var float autocvar_cl_casings_maxcount = 100;
int autocvar_cl_casings_maxcount = 100;
  float autocvar_cl_casings_shell_time;
var float autocvar_cl_casings_sloppy = 1;
var float autocvar_cl_casings_ticrate = 0.1;
float autocvar_cl_db_saveasdump;
float autocvar_cl_deathscoreboard;
bool autocvar_cl_casings_sloppy = 1;
+ float autocvar_cl_casings_ticrate = 0.1;
bool autocvar_cl_db_saveasdump;
bool autocvar_cl_deathscoreboard;
  float autocvar_cl_effects_lightningarc_branchfactor_add;
  float autocvar_cl_effects_lightningarc_branchfactor_start;
  float autocvar_cl_effects_lightningarc_drift_end;
  float autocvar_cl_effects_lightningarc_drift_start;
  float autocvar_cl_effects_lightningarc_segmentlength;
float autocvar_cl_effects_lightningarc_simple;
float autocvar_cl_gentle;
float autocvar_cl_gentle_damage;
float autocvar_cl_gentle_gibs;
float autocvar_cl_gentle_messages;
var float autocvar_cl_gibs_damageforcescale = 3.5;
var float autocvar_cl_gibs_lifetime = 14;
var float autocvar_cl_gibs_maxcount = 100;
var float autocvar_cl_gibs_sloppy = 1;
var float autocvar_cl_gibs_ticrate = 0.1;
var float autocvar_cl_gibs_velocity_random = 1;
var float autocvar_cl_gibs_velocity_scale = 1;
var float autocvar_cl_gibs_avelocity_scale = 1;
bool autocvar_cl_effects_lightningarc_simple;
int autocvar_cl_gentle;
int autocvar_cl_gentle_damage;
int autocvar_cl_gentle_gibs;
int autocvar_cl_gentle_messages;
+ float autocvar_cl_gibs_damageforcescale = 3.5;
+ float autocvar_cl_gibs_lifetime = 14;
+ float autocvar_cl_gibs_maxcount = 100;
bool autocvar_cl_gibs_sloppy = 1;
+ float autocvar_cl_gibs_ticrate = 0.1;
+ float autocvar_cl_gibs_velocity_random = 1;
+ float autocvar_cl_gibs_velocity_scale = 1;
+ float autocvar_cl_gibs_avelocity_scale = 1;
  float autocvar_cl_gibs_velocity_up;
float autocvar_cl_gunalign;
float autocvar_cl_hidewaypoints;
float autocvar_cl_lockview;
float autocvar_cl_nogibs;
float autocvar_cl_orthoview;
float autocvar_cl_orthoview_nofog;
float autocvar_cl_particlegibs;
float autocvar_cl_particles_oldnexbeam;
int autocvar_cl_gunalign;
bool autocvar_cl_hidewaypoints;
bool autocvar_cl_lockview;
bool autocvar_cl_nogibs;
bool autocvar_cl_orthoview;
bool autocvar_cl_orthoview_nofog;
bool autocvar_cl_particlegibs;
bool autocvar_cl_particles_oldvortexbeam;
  float autocvar_cl_particles_quality;
- float autocvar_cl_projectiles_sloppy;
- float autocvar_cl_readpicture_force;
- var float autocvar_cl_reticle = 1;
- float autocvar_cl_reticle_item_nex;
- float autocvar_cl_reticle_item_normal;
- float autocvar_cl_reticle_stretch;
- float autocvar_cl_spawn_event_particles;
- var float autocvar_cl_spawn_event_sound = 1;
+ bool autocvar_cl_projectiles_sloppy;
+ bool autocvar_cl_readpicture_force;
+ bool autocvar_cl_reticle = 1;
+ float autocvar_cl_reticle_normal_alpha = 1;
+ bool autocvar_cl_reticle_weapon = 1;
+ float autocvar_cl_reticle_weapon_alpha = 1;
+ bool autocvar_cl_reticle_stretch;
+ bool autocvar_cl_spawn_event_particles;
+ bool autocvar_cl_spawn_event_sound = 1;
  // float autocvar_cl_spawn_point_model;
- float autocvar_cl_spawn_point_particles;
- var float autocvar_cl_spawnzoom = 1;
- var float autocvar_cl_spawnzoom_speed = 1;
- var float autocvar_cl_spawnzoom_factor = 2;
- float autocvar_cl_stripcolorcodes;
- var float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
- var float autocvar_cl_vehicle_spiderbot_cross_size = 1;
- var float autocvar_cl_vehicles_hud_tactical = 1;
- float autocvar_cl_velocityzoom;
- var float autocvar_cl_velocityzoom_type = 3;
+ bool autocvar_cl_spawn_point_particles;
+ bool autocvar_cl_spawnzoom = 1;
+ float autocvar_cl_spawnzoom_speed = 1;
+ float autocvar_cl_spawnzoom_factor = 2;
+ bool autocvar_cl_stripcolorcodes;
+ float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
+ float autocvar_cl_vehicle_spiderbot_cross_size = 1;
+ bool autocvar_cl_vehicles_hud_tactical = 1;
+ bool autocvar_cl_velocityzoom_enabled;
+ float autocvar_cl_velocityzoom_factor;
+ int autocvar_cl_velocityzoom_type = 3;
  float autocvar_cl_velocityzoom_speed;
  float autocvar_cl_velocityzoom_time;
  string autocvar_cl_weaponpriority;
  float autocvar_cl_zoomfactor;
  float autocvar_cl_zoomsensitivity;
  float autocvar_cl_zoomspeed;
var float autocvar_cl_unpress_zoom_on_spawn = 1;
var float autocvar_cl_unpress_zoom_on_death = 1;
var float autocvar_cl_unpress_zoom_on_weapon_switch = 1;
var float autocvar_cl_unpress_attack_on_weapon_switch = 1;
float autocvar_con_chat;
bool autocvar_cl_unpress_zoom_on_spawn = 1;
bool autocvar_cl_unpress_zoom_on_death = 1;
bool autocvar_cl_unpress_zoom_on_weapon_switch = 1;
bool autocvar_cl_unpress_attack_on_weapon_switch = 1;
bool autocvar_con_chat;
  float autocvar_con_chatpos;
float autocvar_con_chatrect;
bool autocvar_con_chatrect;
  float autocvar_con_chatsize;
  float autocvar_con_chattime;
  float autocvar_con_notify;
@@@ -98,55 -103,60 +103,60 @@@ float autocvar_con_notifysize
  string autocvar_crosshair;
  float autocvar_crosshair_alpha;
  string autocvar_crosshair_color;
float autocvar_crosshair_color_special;
var float autocvar_crosshair_color_special_rainbow_brightness = 2;
var float autocvar_crosshair_color_special_rainbow_delay = 0.1;
float autocvar_crosshair_dot;
int autocvar_crosshair_color_special;
+ float autocvar_crosshair_color_special_rainbow_brightness = 2;
+ float autocvar_crosshair_color_special_rainbow_delay = 0.1;
bool autocvar_crosshair_dot;
  float autocvar_crosshair_dot_alpha;
  string autocvar_crosshair_dot_color;
var float autocvar_crosshair_dot_color_custom = 1;
bool autocvar_crosshair_dot_color_custom = 1;
  float autocvar_crosshair_dot_size;
float autocvar_crosshair_effect_scalefade;
var float autocvar_crosshair_effect_time = 0.2;
var float autocvar_crosshair_enabled = 1;
float autocvar_crosshair_hitindication;
bool autocvar_crosshair_effect_scalefade;
+ float autocvar_crosshair_effect_time = 0.2;
bool autocvar_crosshair_enabled = 1;
bool autocvar_crosshair_hitindication;
  string autocvar_crosshair_hitindication_color;
  string autocvar_crosshair_hitindication_per_weapon_color;
  float autocvar_crosshair_hitindication_speed;
- float autocvar_crosshair_hittest;
- float autocvar_crosshair_hittest_blur;
- float autocvar_crosshair_hittest_showimpact;
- float autocvar_crosshair_per_weapon;
+ bool autocvar_crosshair_hittest;
+ bool autocvar_crosshair_hittest_blur;
+ float autocvar_crosshair_hittest_scale = 1.25;
+ bool autocvar_crosshair_hittest_showimpact;
+ bool autocvar_crosshair_per_weapon;
  float autocvar_crosshair_pickup;
  float autocvar_crosshair_pickup_speed;
float autocvar_crosshair_ring;
float autocvar_crosshair_ring_inner;
float autocvar_crosshair_ring_minelayer;
bool autocvar_crosshair_ring;
bool autocvar_crosshair_ring_inner;
bool autocvar_crosshair_ring_minelayer;
  float autocvar_crosshair_ring_minelayer_alpha;
float autocvar_crosshair_ring_hagar;
bool autocvar_crosshair_ring_hagar;
  float autocvar_crosshair_ring_hagar_alpha;
- float autocvar_crosshair_ring_nex;
- float autocvar_crosshair_ring_nex_alpha;
- float autocvar_crosshair_ring_nex_currentcharge_movingavg_rate;
- float autocvar_crosshair_ring_nex_currentcharge_scale;
- float autocvar_crosshair_ring_nex_inner_alpha;
- float autocvar_crosshair_ring_nex_inner_color_blue;
- float autocvar_crosshair_ring_nex_inner_color_green;
- float autocvar_crosshair_ring_nex_inner_color_red;
+ bool autocvar_crosshair_ring_vortex = 1;
+ float autocvar_crosshair_ring_vortex_alpha = 0.15;
+ float autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate = 0.05;
+ float autocvar_crosshair_ring_vortex_currentcharge_scale = 30;
+ float autocvar_crosshair_ring_vortex_inner_alpha = 0.15;
+ float autocvar_crosshair_ring_vortex_inner_color_blue = 0;
+ float autocvar_crosshair_ring_vortex_inner_color_green = 0;
+ float autocvar_crosshair_ring_vortex_inner_color_red = 0.8;
+ bool autocvar_crosshair_ring_arc = 1;
+ vector autocvar_crosshair_ring_arc_hot_color = '1 0 0';
+ float autocvar_crosshair_ring_arc_cold_alpha = 0.2;
+ float autocvar_crosshair_ring_arc_hot_alpha = 0.5;
  float autocvar_crosshair_ring_size;
float autocvar_crosshair_ring_reload;
bool autocvar_crosshair_ring_reload;
  float autocvar_crosshair_ring_reload_alpha;
  float autocvar_crosshair_ring_reload_size;
  float autocvar_crosshair_size;
float autocvar_ekg;
int autocvar_ekg;
  float autocvar_fov;
  float autocvar_g_balance_damagepush_speedfactor;
  float autocvar_g_balance_tuba_attenuation;
  float autocvar_g_balance_tuba_fadetime;
  float autocvar_g_balance_tuba_volume;
float autocvar_g_balance_tuba_pitchstep;
int autocvar_g_balance_tuba_pitchstep;
  float autocvar_g_warmup_limit;
float autocvar_g_waypointsprite_uppercase;
bool autocvar_g_waypointsprite_uppercase;
  float autocvar_g_waypointsprite_alpha;
  float autocvar_g_waypointsprite_crosshairfadealpha;
  float autocvar_g_waypointsprite_crosshairfadedistance;
@@@ -167,17 -177,17 +177,17 @@@ float autocvar_g_waypointsprite_minalph
  float autocvar_g_waypointsprite_minscale;
  float autocvar_g_waypointsprite_normdistance;
  float autocvar_g_waypointsprite_scale;
float autocvar_g_waypointsprite_spam;
int autocvar_g_waypointsprite_spam;
  float autocvar_g_waypointsprite_timealphaexponent;
var float autocvar_g_waypointsprite_turrets = TRUE;
var float autocvar_g_waypointsprite_turrets_maxdist = 5000;
var float autocvar_hud_cursormode = TRUE;
bool autocvar_g_waypointsprite_turrets = true;
+ float autocvar_g_waypointsprite_turrets_maxdist = 5000;
bool autocvar_hud_cursormode = true;
  float autocvar_hud_colorflash_alpha;
float autocvar_hud_configure_checkcollisions;
float autocvar_hud_configure_grid;
bool autocvar_hud_configure_checkcollisions;
bool autocvar_hud_configure_grid;
  float autocvar_hud_configure_grid_alpha;
float autocvar_hud_configure_teamcolorforced;
float autocvar_hud_contents;
bool autocvar_hud_configure_teamcolorforced;
bool autocvar_hud_contents;
  float autocvar_hud_contents_blur;
  float autocvar_hud_contents_blur_alpha;
  float autocvar_hud_contents_fadeintime;
@@@ -188,7 -198,7 +198,7 @@@ float autocvar_hud_contents_slime_alpha
  string autocvar_hud_contents_slime_color;
  float autocvar_hud_contents_water_alpha;
  string autocvar_hud_contents_water_color;
float autocvar_hud_damage;
bool autocvar_hud_damage;
  float autocvar_hud_damage_blur;
  float autocvar_hud_damage_blur_alpha;
  string autocvar_hud_damage_color;
@@@ -202,180 -212,197 +212,197 @@@ float autocvar_hud_damage_pain_threshol
  float autocvar_hud_damage_pain_threshold_lower_health;
  float autocvar_hud_damage_pain_threshold_pulsating_min;
  float autocvar_hud_damage_pain_threshold_pulsating_period;
float autocvar_hud_powerup;
float autocvar_hud_postprocessing;
bool autocvar_hud_powerup;
bool autocvar_hud_postprocessing;
  float autocvar_hud_postprocessing_maxbluralpha;
  float autocvar_hud_postprocessing_maxblurradius;
  string autocvar_hud_dock;
  float autocvar_hud_dock_alpha;
  string autocvar_hud_dock_color;
- float autocvar_hud_dock_color_team;
- float autocvar_hud_panel_ammo;
- float autocvar_hud_panel_ammo_iconalign;
- float autocvar_hud_panel_ammo_maxammo;
- float autocvar_hud_panel_ammo_onlycurrent;
- float autocvar_hud_panel_ammo_progressbar;
+ bool autocvar_hud_dock_color_team;
+ bool autocvar_hud_panel_ammo;
+ bool autocvar_hud_panel_ammo_iconalign; // TODO: check if this should be turned into an int
+ int autocvar_hud_panel_ammo_maxammo;
+ bool autocvar_hud_panel_ammo_onlycurrent;
+ float autocvar_hud_panel_ammo_noncurrent_alpha = 0.7;
+ float autocvar_hud_panel_ammo_noncurrent_scale = 1;
+ bool autocvar_hud_panel_ammo_progressbar;
  string autocvar_hud_panel_ammo_progressbar_name;
  float autocvar_hud_panel_ammo_progressbar_xoffset;
float autocvar_hud_panel_ammo_text;
bool autocvar_hud_panel_ammo_text;
  string autocvar_hud_panel_bg;
  float autocvar_hud_panel_bg_alpha;
  float autocvar_hud_panel_bg_border;
- vector autocvar_hud_panel_bg_color;
- float autocvar_hud_panel_bg_color_team;
+ vector autocvar_hud_panel_bg_color; // TODO: int?
+ float autocvar_hud_panel_bg_color_team; // ^
  float autocvar_hud_panel_bg_padding;
float autocvar_hud_panel_centerprint;
bool autocvar_hud_panel_centerprint;
  float autocvar_hud_panel_centerprint_align;
var float autocvar_hud_panel_centerprint_fade_in = 0.2;
var float autocvar_hud_panel_centerprint_fade_out = 0.5;
var float autocvar_hud_panel_centerprint_fade_subsequent = 1;
var float autocvar_hud_panel_centerprint_fade_subsequent_passone = 3;
var float autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha = 0.5;
var float autocvar_hud_panel_centerprint_fade_subsequent_passtwo = 10;
var float autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha = 0.5;
var float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75;
var float autocvar_hud_panel_centerprint_fade_minfontsize = 0;
float autocvar_hud_panel_centerprint_flip;
+ float autocvar_hud_panel_centerprint_fade_in = 0.2;
+ float autocvar_hud_panel_centerprint_fade_out = 0.5;
+ float autocvar_hud_panel_centerprint_fade_subsequent = 1;
+ float autocvar_hud_panel_centerprint_fade_subsequent_passone = 3;
+ float autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha = 0.5;
+ float autocvar_hud_panel_centerprint_fade_subsequent_passtwo = 10;
+ float autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha = 0.5;
+ float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75;
+ float autocvar_hud_panel_centerprint_fade_minfontsize = 0;
bool autocvar_hud_panel_centerprint_flip;
  float autocvar_hud_panel_centerprint_fontscale;
  float autocvar_hud_panel_centerprint_time;
float autocvar_hud_panel_chat;
float autocvar_hud_panel_engineinfo;
bool autocvar_hud_panel_chat;
bool autocvar_hud_panel_engineinfo;
  float autocvar_hud_panel_engineinfo_framecounter_decimals;
  float autocvar_hud_panel_engineinfo_framecounter_time;
  float autocvar_hud_panel_fg_alpha;
float autocvar_hud_panel_healtharmor;
float autocvar_hud_panel_healtharmor_baralign;
float autocvar_hud_panel_healtharmor_flip;
float autocvar_hud_panel_healtharmor_iconalign;
float autocvar_hud_panel_healtharmor_maxarmor;
float autocvar_hud_panel_healtharmor_maxhealth;
float autocvar_hud_panel_healtharmor_progressbar;
bool autocvar_hud_panel_healtharmor;
int autocvar_hud_panel_healtharmor_baralign;
bool autocvar_hud_panel_healtharmor_flip;
int autocvar_hud_panel_healtharmor_iconalign;
int autocvar_hud_panel_healtharmor_maxarmor;
int autocvar_hud_panel_healtharmor_maxhealth;
bool autocvar_hud_panel_healtharmor_progressbar;
  string autocvar_hud_panel_healtharmor_progressbar_armor;
  string autocvar_hud_panel_healtharmor_progressbar_health;
float autocvar_hud_panel_healtharmor_progressbar_gfx;
bool autocvar_hud_panel_healtharmor_progressbar_gfx;
  float autocvar_hud_panel_healtharmor_progressbar_gfx_damage;
  float autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth;
  float autocvar_hud_panel_healtharmor_progressbar_gfx_smooth;
float autocvar_hud_panel_healtharmor_text;
float autocvar_hud_panel_infomessages;
float autocvar_hud_panel_infomessages_flip;
float autocvar_hud_panel_modicons;
float autocvar_hud_panel_modicons_ca_layout;
float autocvar_hud_panel_modicons_dom_layout;
float autocvar_hud_panel_modicons_freezetag_layout;
float autocvar_hud_panel_notify;
int autocvar_hud_panel_healtharmor_text;
bool autocvar_hud_panel_infomessages;
bool autocvar_hud_panel_infomessages_flip;
bool autocvar_hud_panel_modicons;
int autocvar_hud_panel_modicons_ca_layout;
int autocvar_hud_panel_modicons_dom_layout;
int autocvar_hud_panel_modicons_freezetag_layout;
bool autocvar_hud_panel_notify;
  float autocvar_hud_panel_notify_fadetime;
  float autocvar_hud_panel_notify_flip;
  float autocvar_hud_panel_notify_fontsize;
  float autocvar_hud_panel_notify_time;
- float autocvar_hud_panel_physics;
+ float autocvar_hud_panel_notify_icon_aspect;
+ bool autocvar_hud_panel_physics;
  float autocvar_hud_panel_physics_acceleration_progressbar_mode;
  float autocvar_hud_panel_physics_acceleration_progressbar_scale;
  float autocvar_hud_panel_physics_acceleration_progressbar_nonlinear;
  float autocvar_hud_panel_physics_acceleration_max;
float autocvar_hud_panel_physics_progressbar;
float autocvar_hud_panel_physics_acceleration_vertical;
float autocvar_hud_panel_physics_baralign;
float autocvar_hud_panel_physics_flip;
int autocvar_hud_panel_physics_progressbar;
bool autocvar_hud_panel_physics_acceleration_vertical;
int autocvar_hud_panel_physics_baralign;
bool autocvar_hud_panel_physics_flip;
  float autocvar_hud_panel_physics_speed_max;
float autocvar_hud_panel_physics_speed_unit;
float autocvar_hud_panel_physics_speed_unit_show;
float autocvar_hud_panel_physics_speed_vertical;
float autocvar_hud_panel_physics_text;
int autocvar_hud_panel_physics_speed_unit;
bool autocvar_hud_panel_physics_speed_unit_show;
bool autocvar_hud_panel_physics_speed_vertical;
int autocvar_hud_panel_physics_text;
  float autocvar_hud_panel_physics_text_scale;
float autocvar_hud_panel_physics_topspeed;
bool autocvar_hud_panel_physics_topspeed;
  float autocvar_hud_panel_physics_topspeed_time;
- float autocvar_hud_panel_powerups;
- float autocvar_hud_panel_powerups_baralign;
- float autocvar_hud_panel_powerups_flip;
- float autocvar_hud_panel_powerups_iconalign;
- float autocvar_hud_panel_powerups_progressbar;
+ bool autocvar_hud_panel_powerups;
+ int autocvar_hud_panel_powerups_baralign;
+ bool autocvar_hud_panel_powerups_flip;
+ int autocvar_hud_panel_powerups_iconalign;
+ bool autocvar_hud_panel_powerups_progressbar;
+ bool autocvar_hud_panel_buffs;
+ //float autocvar_hud_panel_buffs_iconalign;
  string autocvar_hud_panel_powerups_progressbar_shield;
  string autocvar_hud_panel_powerups_progressbar_strength;
  string autocvar_hud_panel_powerups_progressbar_superweapons;
float autocvar_hud_panel_powerups_text;
float autocvar_hud_panel_pressedkeys;
bool autocvar_hud_panel_powerups_text;
int autocvar_hud_panel_pressedkeys;
  float autocvar_hud_panel_pressedkeys_aspect;
float autocvar_hud_panel_pressedkeys_attack;
float autocvar_hud_panel_racetimer;
float autocvar_hud_panel_radar;
bool autocvar_hud_panel_pressedkeys_attack;
bool autocvar_hud_panel_racetimer;
int autocvar_hud_panel_radar;
  float autocvar_hud_panel_radar_foreground_alpha;
  float autocvar_hud_panel_radar_maximized_scale;
  vector autocvar_hud_panel_radar_maximized_size;
  float autocvar_hud_panel_radar_rotation;
  float autocvar_hud_panel_radar_scale;
float autocvar_hud_panel_radar_zoommode;
int autocvar_hud_panel_radar_zoommode;
  float autocvar_hud_panel_radar_maximized_rotation;
float autocvar_hud_panel_radar_maximized_zoommode;
float autocvar_hud_panel_score;
float autocvar_hud_panel_score_rankings;
float autocvar_hud_panel_timer;
float autocvar_hud_panel_timer_increment;
int autocvar_hud_panel_radar_maximized_zoommode;
bool autocvar_hud_panel_score;
bool autocvar_hud_panel_score_rankings;
bool autocvar_hud_panel_timer;
bool autocvar_hud_panel_timer_increment;
  float autocvar_hud_panel_update_interval;
float autocvar_hud_panel_vote;
bool autocvar_hud_panel_vote;
  float autocvar_hud_panel_vote_alreadyvoted_alpha;
  string autocvar_hud_panel_vote_bg_alpha;
float autocvar_hud_panel_weapons;
float autocvar_hud_panel_weapons_accuracy;
float autocvar_hud_panel_weapons_ammo;
bool autocvar_hud_panel_weapons;
bool autocvar_hud_panel_weapons_accuracy;
bool autocvar_hud_panel_weapons_ammo;
  float autocvar_hud_panel_weapons_ammo_alpha;
  string autocvar_hud_panel_weapons_ammo_color;
- float autocvar_hud_panel_weapons_ammo_full_cells;
- float autocvar_hud_panel_weapons_ammo_full_fuel;
- float autocvar_hud_panel_weapons_ammo_full_nails;
- float autocvar_hud_panel_weapons_ammo_full_rockets;
- float autocvar_hud_panel_weapons_ammo_full_shells;
+ int autocvar_hud_panel_weapons_ammo_full_cells;
+ int autocvar_hud_panel_weapons_ammo_full_plasma;
+ int autocvar_hud_panel_weapons_ammo_full_fuel;
+ int autocvar_hud_panel_weapons_ammo_full_nails;
+ int autocvar_hud_panel_weapons_ammo_full_rockets;
+ int autocvar_hud_panel_weapons_ammo_full_shells;
  float autocvar_hud_panel_weapons_aspect;
float autocvar_hud_panel_weapons_complainbubble;
bool autocvar_hud_panel_weapons_complainbubble;
  string autocvar_hud_panel_weapons_complainbubble_color_donthave;
  string autocvar_hud_panel_weapons_complainbubble_color_outofammo;
  string autocvar_hud_panel_weapons_complainbubble_color_unavailable;
  float autocvar_hud_panel_weapons_complainbubble_fadetime;
  float autocvar_hud_panel_weapons_complainbubble_padding;
  float autocvar_hud_panel_weapons_complainbubble_time;
- float autocvar_hud_panel_weapons_label;
- float autocvar_hud_panel_weapons_onlyowned;
+ int autocvar_hud_panel_weapons_label;
+ float autocvar_hud_panel_weapons_label_scale = 0.5;
+ bool autocvar_hud_panel_weapons_onlyowned;
  float autocvar_hud_panel_weapons_timeout;
float autocvar_hud_panel_weapons_timeout_effect;
int autocvar_hud_panel_weapons_timeout_effect;
  float autocvar_hud_panel_weapons_timeout_fadebgmin;
  float autocvar_hud_panel_weapons_timeout_fadefgmin;
- var float autocvar_hud_panel_weapons_timeout_speed_in = 0.25;
- var float autocvar_hud_panel_weapons_timeout_speed_out = 0.75;
+ float autocvar_hud_panel_weapons_timeout_speed_in = 0.25;
+ float autocvar_hud_panel_weapons_timeout_speed_out = 0.75;
+ vector autocvar_hud_progressbar_acceleration_color;
+ vector autocvar_hud_progressbar_acceleration_neg_color;
  float autocvar_hud_progressbar_alpha;
- float autocvar_hud_showbinds;
- float autocvar_hud_showbinds_limit;
- float autocvar__hud_showbinds_reload;
- float autocvar_hud_shownames;
- float autocvar_hud_shownames_enemies;
+ vector autocvar_hud_progressbar_armor_color;
+ vector autocvar_hud_progressbar_fuel_color;
+ vector autocvar_hud_progressbar_health_color;
+ vector autocvar_hud_progressbar_nexball_color;
+ vector autocvar_hud_progressbar_shield_color;
+ vector autocvar_hud_progressbar_speed_color;
+ vector autocvar_hud_progressbar_strength_color;
+ vector autocvar_hud_progressbar_superweapons_color;
+ bool autocvar_hud_showbinds;
+ bool autocvar_hud_showbinds_limit;
+ bool autocvar__hud_showbinds_reload;
+ bool autocvar_hud_shownames;
+ bool autocvar_hud_shownames_enemies;
  float autocvar_hud_shownames_crosshairdistance;
  float autocvar_hud_shownames_crosshairdistance_time;
  float autocvar_hud_shownames_crosshairdistance_antioverlap;
float autocvar_hud_shownames_self;
float autocvar_hud_shownames_status;
bool autocvar_hud_shownames_self;
bool autocvar_hud_shownames_status;
  float autocvar_hud_shownames_statusbar_height;
  float autocvar_hud_shownames_aspect;
  float autocvar_hud_shownames_fontsize;
float autocvar_hud_shownames_decolorize;
int autocvar_hud_shownames_decolorize;
  float autocvar_hud_shownames_alpha;
float autocvar_hud_shownames_resize;
bool autocvar_hud_shownames_resize;
  float autocvar_hud_shownames_mindistance;
  float autocvar_hud_shownames_maxdistance;
float autocvar_hud_shownames_antioverlap;
bool autocvar_hud_shownames_antioverlap;
  float autocvar_hud_shownames_antioverlap_distance;
  float autocvar_hud_shownames_offset;
  string autocvar_hud_skin;
  float autocvar_menu_mouse_speed;
  string autocvar_menu_skin;
float autocvar_r_fakelight;
float autocvar_r_fullbright;
int autocvar_r_fakelight;
int autocvar_r_fullbright;
  float autocvar_r_letterbox;
float autocvar_scoreboard_accuracy;
float autocvar_scoreboard_accuracy_doublerows;
float autocvar_scoreboard_accuracy_nocolors;
bool autocvar_scoreboard_accuracy;
bool autocvar_scoreboard_accuracy_doublerows;
bool autocvar_scoreboard_accuracy_nocolors;
  float autocvar_scoreboard_alpha_bg;
var float autocvar_scoreboard_alpha_fg = 1.0;
var float autocvar_scoreboard_alpha_name = 0.9;
var float autocvar_scoreboard_alpha_name_self = 1;
+ float autocvar_scoreboard_alpha_fg = 1.0;
+ float autocvar_scoreboard_alpha_name = 0.9;
+ float autocvar_scoreboard_alpha_name_self = 1;
  float autocvar_scoreboard_bg_scale;
  float autocvar_scoreboard_border_thickness;
  float autocvar_scoreboard_color_bg_b;
@@@ -383,50 -410,63 +410,64 @@@ float autocvar_scoreboard_color_bg_g
  float autocvar_scoreboard_color_bg_r;
  float autocvar_scoreboard_color_bg_team;
  string autocvar_scoreboard_columns;
var float autocvar_scoreboard_fadeinspeed = 10;
var float autocvar_scoreboard_fadeoutspeed = 5;
float autocvar_scoreboard_highlight;
var float autocvar_scoreboard_highlight_alpha = 0.10;
var float autocvar_scoreboard_highlight_alpha_self = 0.25;
+ float autocvar_scoreboard_fadeinspeed = 10;
+ float autocvar_scoreboard_fadeoutspeed = 5;
bool autocvar_scoreboard_highlight;
+ float autocvar_scoreboard_highlight_alpha = 0.10;
+ float autocvar_scoreboard_highlight_alpha_self = 0.25;
  float autocvar_scoreboard_offset_left;
  float autocvar_scoreboard_offset_right;
  float autocvar_scoreboard_offset_vertical;
  float autocvar_scoreboard_respawntime_decimals;
float autocvar_v_flipped;
bool autocvar_v_flipped;
  float autocvar_vid_conheight;
  float autocvar_vid_conwidth;
  float autocvar_vid_pixelheight;
  float autocvar_viewsize;
- float autocvar_cl_hitsound;
+ int autocvar_cl_hitsound;
+ float autocvar_cl_hitsound_min_pitch = 0.75;
+ float autocvar_cl_hitsound_max_pitch = 1.5;
+ float autocvar_cl_hitsound_nom_damage = 25;
  float autocvar_cl_hitsound_antispam_time;
- var float autocvar_cl_eventchase_death = 1;
- var float autocvar_cl_eventchase_distance = 140;
- var float autocvar_cl_eventchase_speed = 1.3;
- var vector autocvar_cl_eventchase_maxs = '12 12 8';
- var vector autocvar_cl_eventchase_mins = '-12 -12 -8';
- var vector autocvar_cl_eventchase_viewoffset = '0 0 20';
- float autocvar_cl_lerpexcess;
+ int autocvar_cl_eventchase_death = 1;
+ int autocvar_cl_eventchase_nexball = 1;
+ float autocvar_cl_eventchase_distance = 140;
+ float autocvar_cl_eventchase_speed = 1.3;
+ vector autocvar_cl_eventchase_maxs = '12 12 8';
+ vector autocvar_cl_eventchase_mins = '-12 -12 -8';
+ vector autocvar_cl_eventchase_viewoffset = '0 0 20';
+ float autocvar_cl_lerpexcess; // TODO: int?
  string autocvar__togglezoom;
float autocvar_cl_damageeffect;
int autocvar_cl_damageeffect;
  float autocvar_cl_damageeffect_ticrate;
  float autocvar_cl_damageeffect_bones;
float autocvar_cl_damageeffect_distribute;
bool autocvar_cl_damageeffect_distribute;
  float autocvar_cl_damageeffect_lifetime;
  float autocvar_cl_damageeffect_lifetime_min;
  float autocvar_cl_damageeffect_lifetime_max;
float autocvar_cl_playerdetailreduction;
float autocvar_cl_modeldetailreduction;
int autocvar_cl_playerdetailreduction;
int autocvar_cl_modeldetailreduction;
  float autocvar_cl_loddistance1 = 768;
  float autocvar_cl_loddistance2 = 2048;
float autocvar_cl_forceplayermodels;
float autocvar_cl_forceplayercolors;
bool autocvar_cl_forceplayermodels;
bool autocvar_cl_forceplayercolors;
  string autocvar_cl_forcemyplayermodel;
float autocvar_cl_forcemyplayerskin;
float autocvar_cl_forcemyplayercolors;
float autocvar__cl_color;
float autocvar__cl_playerskin;
int autocvar_cl_forcemyplayerskin;
int autocvar_cl_forcemyplayercolors;
int autocvar__cl_color;
int autocvar__cl_playerskin;
  string autocvar__cl_playermodel;
  float autocvar_cl_deathglow;
float autocvar_developer_csqcentities;
bool autocvar_developer_csqcentities;
  float autocvar_g_jetpack_attenuation;
- float autocvar_cl_showspectators;
++bool autocvar_cl_showspectators;
+ string autocvar_crosshair_hmg = "";
+ vector autocvar_crosshair_hmg_color = '0.2 1.0 0.2';
+ float autocvar_crosshair_hmg_alpha = 1;
+ float autocvar_crosshair_hmg_size = 1;
+ string autocvar_crosshair_rpc = "";
+ vector autocvar_crosshair_rpc_color = '0.2 1.0 0.2';
+ float autocvar_crosshair_rpc_alpha = 1;
+ float autocvar_crosshair_rpc_size = 1;
+ int autocvar_cl_nade_timer;
+ #endif
diff --combined qcsrc/client/hud.qc
index 08dcd6d382ea212259e0654d21fb8b18348e97bf,74a5df16627d45735fbbbbb876475ea428da3bf8..2aaa81bd512e48e56b4dadbc1e00d1244d8d52cc
@@@ -1,3 -1,11 +1,11 @@@
+ #include "scoreboard.qh"
+ #include "teamradar.qh"
+ #include "../common/buffs.qh"
+ #include "../common/counting.qh"
+ #include "../common/mapinfo.qh"
+ #include "../common/nades.qh"
+ #include "../server/t_items.qh"
  /*
  ==================
  Misc HUD functions
  //   1/4 height: bottom part
  void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize)
  {
-     if (theBorderSize_x < 0 && theBorderSize_y < 0) // draw whole image as it is
+     if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is
      {
                drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
                return;
      }
-       if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
+       if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border
        {
                // draw only the central part
                drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
        vector width, height;
        vector bW, bH;
        //pic = draw_UseSkinFor(pic);
-       width = eX * theSize_x;
-       height = eY * theSize_y;
-       if(theSize_x <= theBorderSize_x * 2)
+       width = eX * theSize.x;
+       height = eY * theSize.y;
+       if(theSize.x <= theBorderSize.x * 2)
        {
                // not wide enough... draw just left and right then
-               bW = eX * (0.25 * theSize_x / (theBorderSize_x * 2));
-               if(theSize_y <= theBorderSize_y * 2)
+               bW = eX * (0.25 * theSize.x / (theBorderSize.x * 2));
+               if(theSize.y <= theBorderSize.y * 2)
                {
                        // not high enough... draw just corners
-                       bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
+                       bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
                        drawsubpic(theOrigin,                 width * 0.5 + height * 0.5, pic, '0 0 0',           bW + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width   * 0.5, width * 0.5 + height * 0.5, pic, eX - bW,           bW + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + height  * 0.5, width * 0.5 + height * 0.5, pic, eY - bH,           bW + bH, theColor, theAlpha, 0);
@@@ -47,7 -55,7 +55,7 @@@
                }
                else
                {
-                       dY = theBorderSize_x * eY;
+                       dY = theBorderSize.x * eY;
                        drawsubpic(theOrigin,                             width * 0.5          +     dY, pic, '0 0    0',           '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width * 0.5,               width * 0.5          +     dY, pic, '0 0    0' + eX - bW, '0 0.25 0' + bW, theColor, theAlpha, 0);
                        drawsubpic(theOrigin                        + dY, width * 0.5 + height - 2 * dY, pic, '0 0.25 0',           '0 0.5  0' + bW, theColor, theAlpha, 0);
        }
        else
        {
-               if(theSize_y <= theBorderSize_y * 2)
+               if(theSize.y <= theBorderSize.y * 2)
                {
                        // not high enough... draw just top and bottom then
-                       bH = eY * (0.25 * theSize_y / (theBorderSize_y * 2));
-                       dX = theBorderSize_x * eX;
+                       bH = eY * (0.25 * theSize.y / (theBorderSize.y * 2));
+                       dX = theBorderSize.x * eX;
                        drawsubpic(theOrigin,                                         dX + height * 0.5, pic, '0    0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + dX,                        width - 2 * dX + height * 0.5, pic, '0.25 0 0',           '0.5  0 0' + bH, theColor, theAlpha, 0);
                        drawsubpic(theOrigin + width - dX,                            dX + height * 0.5, pic, '0.75 0 0',           '0.25 0 0' + bH, theColor, theAlpha, 0);
@@@ -72,8 -80,8 +80,8 @@@
                }
                else
                {
-                       dX = theBorderSize_x * eX;
-                       dY = theBorderSize_x * eY;
+                       dX = theBorderSize.x * eX;
+                       dY = theBorderSize.x * eY;
                        drawsubpic(theOrigin,                                        dX          +     dY, pic, '0    0    0', '0.25 0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin                  + dX,      width - 2 * dX          +     dY, pic, '0.25 0    0', '0.5  0.25 0', theColor, theAlpha, 0);
                        drawsubpic(theOrigin          + width - dX,                  dX          +     dY, pic, '0.75 0    0', '0.25 0.25 0', theColor, theAlpha, 0);
@@@ -92,65 -100,111 +100,111 @@@ vector HUD_Get_Num_Color (float x, floa
        float blinkingamt;
        vector color;
        if(x >= maxvalue) {
-               color_x = sin(2*M_PI*time);
-               color_y = 1;
-               color_z = sin(2*M_PI*time);
+               color.x = sin(2*M_PI*time);
+               color.y = 1;
+               color.z = sin(2*M_PI*time);
        }
        else if(x > maxvalue * 0.75) {
-               color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
-               color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
-               color_z = 0;
+               color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
+               color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
+               color.z = 0;
        }
        else if(x > maxvalue * 0.5) {
-               color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
-               color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
-               color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
+               color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
+               color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
+               color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
        }
        else if(x > maxvalue * 0.25) {
-               color_x = 1;
-               color_y = 1;
-               color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
+               color.x = 1;
+               color.y = 1;
+               color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
        }
        else if(x > maxvalue * 0.1) {
-               color_x = 1;
-               color_y = (x-20)*90/27/100; // green value between 0 -> 1
-               color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
+               color.x = 1;
+               color.y = (x-20)*90/27/100; // green value between 0 -> 1
+               color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
        }
        else {
-               color_x = 1;
-               color_y = 0;
-               color_z = 0;
+               color.x = 1;
+               color.y = 0;
+               color.z = 0;
        }
  
        blinkingamt = (1 - x/maxvalue/0.25);
        if(blinkingamt > 0)
        {
-               color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
-               color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
-               color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
+               color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
+               color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
+               color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
        }
        return color;
  }
  
+ float HUD_GetRowCount(float item_count, vector size, float item_aspect)
+ {
+       float aspect = size_y / size_x;
+       return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
+ }
+ vector HUD_GetTableSize(float item_count, vector psize, float item_aspect)
+ {
+       float columns, rows;
+       float ratio, best_ratio = 0;
+       float best_columns = 1, best_rows = 1;
+       bool vertical = (psize.x / psize.y >= item_aspect);
+       if(vertical)
+       {
+               psize = eX * psize.y + eY * psize.x;
+               item_aspect = 1 / item_aspect;
+       }
+       rows = ceil(sqrt(item_count));
+       columns = ceil(item_count/rows);
+       while(columns >= 1)
+       {
+               ratio = (psize.x/columns) / (psize.y/rows);
+               if(ratio > item_aspect)
+                       ratio = item_aspect * item_aspect / ratio;
+               if(ratio <= best_ratio)
+                       break; // ratio starts decreasing by now, skip next configurations
+               best_columns = columns;
+               best_rows = rows;
+               best_ratio = ratio;
+               if(columns == 1)
+                       break;
+               --columns;
+               rows = ceil(item_count/columns);
+       }
+       if(vertical)
+               return eX * best_rows + eY * best_columns;
+       else
+               return eX * best_columns + eY * best_rows;
+ }
  float stringwidth_colors(string s, vector theSize)
  {
-       return stringwidth(s, TRUE, theSize);
+       return stringwidth(s, true, theSize);
  }
  
  float stringwidth_nocolors(string s, vector theSize)
  {
-       return stringwidth(s, FALSE, theSize);
+       return stringwidth(s, false, theSize);
  }
  
  void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
  {
-       position_x -= 2 / 3 * strlen(text) * theScale_x;
+       position.x -= 2 / 3 * strlen(text) * theScale.x;
        drawstring(position, text, theScale, rgb, theAlpha, flag);
  }
  
  void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
  {
-       position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale_x);
+       position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
        drawstring(position, text, theScale, rgb, theAlpha, flag);
  }
  
@@@ -218,9 -272,9 +272,9 @@@ string MakeRaceString(float cp, float m
        if(histime < 0)
                return strcat(col, cpname);
        else if(hisname == "")
-               return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
+               return strcat(col, sprintf("%s (%s)", cpname, timestr));
        else
-               return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
+               return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(hisname, col, lapstr)));
  }
  
  // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
@@@ -232,7 -286,7 +286,7 @@@ float race_CheckName(string net_name) 
        return 0;
  }
  
- float GetPlayerColorForce(float i)
+ float GetPlayerColorForce(int i)
  {
        if(!teamplay)
                return 0;
                return stof(getplayerkeyvalue(i, "colors")) & 15;
  }
  
- float GetPlayerColor(float i)
+ float GetPlayerColor(int i)
  {
        if(!playerslots[i].gotscores) // unconnected
                return NUM_SPECTATOR;
                return GetPlayerColorForce(i);
  }
  
- string GetPlayerName(float i)
+ string GetPlayerName(int i)
  {
        return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
  }
@@@ -263,9 -317,10 +317,10 @@@ HUD panel
  */
  
  // draw the background/borders
- #define HUD_Panel_DrawBg(theAlpha)\
- if(panel_bg != "0" && panel_bg != "")\
-       draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
+ #define HUD_Panel_DrawBg(theAlpha) do {                                                                                                                                                               \
+       if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")                                                                                               \
+               draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
+ } while(0)
  
  //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
  void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
                }
  
          if (baralign == 1) // bottom align
-                       theOrigin_y += (1 - length_ratio) * theSize_y;
+                       theOrigin.y += (1 - length_ratio) * theSize.y;
          else if (baralign == 2) // center align
-             theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y;
+             theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
          else if (baralign == 3) // center align, positive values down, negative up
                {
-                       theSize_y *= 0.5;
+                       theSize.y *= 0.5;
                        if (length_ratio > 0)
-                               theOrigin_y += theSize_y;
+                               theOrigin.y += theSize.y;
                        else
                        {
-                               theOrigin_y += (1 + length_ratio) * theSize_y;
+                               theOrigin.y += (1 + length_ratio) * theSize.y;
                                length_ratio = -length_ratio;
                        }
                }
-               theSize_y *= length_ratio;
+               theSize.y *= length_ratio;
  
                vector bH;
-               width = eX * theSize_x;
-               height = eY * theSize_y;
-               if(theSize_y <= theSize_x * 2)
+               width = eX * theSize.x;
+               height = eY * theSize.y;
+               if(theSize.y <= theSize.x * 2)
                {
                        // button not high enough
                        // draw just upper and lower part then
-                       square = eY * theSize_y * 0.5;
-                       bH = eY * (0.25 * theSize_y / (theSize_x * 2));
+                       square = eY * theSize.y * 0.5;
+                       bH = eY * (0.25 * theSize.y / (theSize.x * 2));
                        drawsubpic(theOrigin,          square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
                }
                else
                {
-                       square = eY * theSize_x;
+                       square = eY * theSize.x;
                        drawsubpic(theOrigin,                   width   +     square, pic, '0 0    0', '1 0.25 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin +          square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5  0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + height - square, width   +     square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
                }
  
                if (baralign == 1) // right align
-                       theOrigin_x += (1 - length_ratio) * theSize_x;
+                       theOrigin.x += (1 - length_ratio) * theSize.x;
          else if (baralign == 2) // center align
-             theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x;
+             theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
          else if (baralign == 3) // center align, positive values on the right, negative on the left
                {
-                       theSize_x *= 0.5;
+                       theSize.x *= 0.5;
                        if (length_ratio > 0)
-                               theOrigin_x += theSize_x;
+                               theOrigin.x += theSize.x;
                        else
                        {
-                               theOrigin_x += (1 + length_ratio) * theSize_x;
+                               theOrigin.x += (1 + length_ratio) * theSize.x;
                                length_ratio = -length_ratio;
                        }
                }
-               theSize_x *= length_ratio;
+               theSize.x *= length_ratio;
  
                vector bW;
-               width = eX * theSize_x;
-               height = eY * theSize_y;
-               if(theSize_x <= theSize_y * 2)
+               width = eX * theSize.x;
+               height = eY * theSize.y;
+               if(theSize.x <= theSize.y * 2)
                {
                        // button not wide enough
                        // draw just left and right part then
-                       square = eX * theSize_x * 0.5;
-                       bW = eX * (0.25 * theSize_x / (theSize_y * 2));
+                       square = eX * theSize.x * 0.5;
+                       bW = eX * (0.25 * theSize.x / (theSize.y * 2));
                        drawsubpic(theOrigin,          square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
                }
                else
                {
-                       square = eX * theSize_y;
+                       square = eX * theSize.y;
                        drawsubpic(theOrigin,                  height  +     square, pic, '0    0 0', '0.25 1 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin +         square, theSize - 2 * square, pic, '0.25 0 0', '0.5  1 0', theColor, theAlpha, drawflag);
                        drawsubpic(theOrigin + width - square, height  +     square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
@@@ -382,19 -437,18 +437,18 @@@ void HUD_Panel_DrawHighlight(vector pos
                pic = "gfx/hud/default/num_leading";
        }
  
-       drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
-       if(mySize_x/mySize_y > 2)
-               drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
-       drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
+       drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
+       if(mySize.x/mySize.y > 2)
+               drawsubpic(pos + eX * mySize.y, eX * (mySize.x - 2 * mySize.y) + eY * mySize.y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
+       drawsubpic(pos + eX * mySize.x - eX * min(mySize.x * 0.5, mySize.y), eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
  }
  
  // Weapon icons (#0)
  //
  entity weaponorder[WEP_MAXCOUNT];
- void weaponorder_swap(float i, float j, entity pass)
+ void weaponorder_swap(int i, int j, entity pass)
  {
-       entity h;
-       h = weaponorder[i];
+       entity h = weaponorder[i];
        weaponorder[i] = weaponorder[j];
        weaponorder[j] = h;
  }
@@@ -408,60 -462,23 +462,23 @@@ float weaponorder_cmp(float i, float j
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
  }
  
- float GetAmmoStat(float i)
- {
-       switch(i)
-       {
-               case 0: return STAT_SHELLS;
-               case 1: return STAT_NAILS;
-               case 2: return STAT_ROCKETS;
-               case 3: return STAT_CELLS;
-               case 4: return STAT_FUEL;
-               default: return -1;
-       }
- }
- float GetAmmoTypeForWep(float i)
- {
-       switch(i)
-       {
-               case WEP_SHOTGUN: return 0;
-               case WEP_UZI: return 1;
-               case WEP_GRENADE_LAUNCHER: return 2;
-               case WEP_MINE_LAYER: return 2;
-               case WEP_ELECTRO: return 3;
-               case WEP_CRYLINK: return 3;
-               case WEP_HLAC: return 3;
-               case WEP_MINSTANEX: return 3;
-               case WEP_NEX: return 3;
-               case WEP_RIFLE: return 1;
-               case WEP_HAGAR: return 2;
-               case WEP_ROCKET_LAUNCHER: return 2;
-               case WEP_SEEKER: return 2;
-               case WEP_FIREBALL: return 4;
-               case WEP_HOOK: return 3;
-               default: return -1;
-       }
- }
  void HUD_Weapons(void)
  {
        // declarations
        WepSet weapons_stat = WepSet_GetFromStat();
        float i, f, a;
-       float screen_ar, center_x = 0, center_y;
+       float screen_ar;
+       vector center = '0 0 0';
        float weapon_count, weapon_id;
-       float row, column, rows = 0, columns;
+       float row, column, rows = 0, columns = 0;
+       bool vertical_order = true;
        float aspect = autocvar_hud_panel_weapons_aspect;
  
-       float panel_weapon_accuracy;
        float timeout = autocvar_hud_panel_weapons_timeout;
        float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
        float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
  
-       float ammo_type, ammo_full;
-       float barsize_x = 0, barsize_y = 0, baroffset_x = 0, baroffset_y = 0;
+       vector barsize = '0 0 0', baroffset = '0 0 0';
        vector ammo_color = '1 0 1';
        float ammo_alpha = 1;
  
        float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
  
        vector weapon_pos, weapon_size = '0 0 0';
-       local noref vector old_panel_size; // fteqcc sucks
        vector color;
  
        // check to see if we want to continue
  
        // update generic hud functions
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
        // figure out weapon order (how the weapons are sorted) // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
-               float weapon_cnt;
+               int weapon_cnt;
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
                if(weaponorder_byimpulse)
        if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
                complain_weapon = 0;
  
+       if(autocvar__hud_configure)
+       {
+               if(!weapons_stat)
+                       for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
+                               weapons_stat |= WepSet_FromWeapon(i);
+               #if 0
+               /// debug code
+               if(cvar("wep_add"))
+               {
+                       weapons_stat = '0 0 0';
+                       float countw = 1 + floor((floor(time * cvar("wep_add"))) % WEP_COUNT);
+                       for(i = WEP_FIRST; i <= countw; ++i)
+                               weapons_stat |= WepSet_FromWeapon(i);
+               }
+               #endif
+       }
        // determine which weapons are going to be shown
        if (autocvar_hud_panel_weapons_onlyowned)
        {
                if(autocvar__hud_configure)
                {
-                       if (!weapons_stat)
-                               for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
-                                       weapons_stat |= WepSet_FromWeapon(i);
                        if(menu_enabled != 2)
                                HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
                }
                // do we own this weapon?
                weapon_count = 0;
                for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
-                       if(weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon))
+                       if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
                                ++weapon_count;
  
-               // add it anyway if weaponcomplain is shown
-               if(complain_weapon)
-                       ++weapon_count;
  
                // might as well commit suicide now, no reason to live ;)
                if (weapon_count == 0)
                        return;
                }
  
-               old_panel_size = panel_size;
-               if(panel_bg_padding)
-                       old_panel_size -= '2 2 0' * panel_bg_padding;
+               vector old_panel_size = panel_size;
+               vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
  
-               // first find values for the standard table (with all the weapons)
-               rows = old_panel_size_y/old_panel_size_x;
-               rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
-               columns = ceil(WEP_COUNT/rows);
-               weapon_size_x = old_panel_size_x / columns;
-               weapon_size_y = old_panel_size_y / rows;
+               // get the all-weapons layout
+               vector table_size = HUD_GetTableSize(WEP_COUNT, padded_panel_size, aspect);
+               columns = table_size.x;
+               rows = table_size.y;
+               weapon_size.x = padded_panel_size.x / columns;
+               weapon_size.y = padded_panel_size.y / rows;
  
-               // change table values to include only the owned weapons
-               // weapon_size won't be changed
-               if(weapon_count <= rows)
+               // NOTE: although weapons should aways look the same even if onlyowned is enabled,
+               // we enlarge them a bit when possible to better match the desired aspect ratio
+               if(padded_panel_size.x / padded_panel_size.y < aspect)
                {
-                       rows = weapon_count;
-                       columns = 1;
+                       // maximum number of rows that allows to display items with the desired aspect ratio
+                       float max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect));
+                       columns = min(columns, ceil(weapon_count / max_rows));
+                       rows = ceil(weapon_count / columns);
+                       weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
+                       weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
+                       vertical_order = false;
                }
                else
+               {
+                       float max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect));
+                       rows = min(rows, ceil(weapon_count / max_columns));
                        columns = ceil(weapon_count / rows);
+                       weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y);
+                       weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect);
+                       vertical_order = true;
+               }
  
                // reduce size of the panel
-               panel_size_x = columns * weapon_size_x;
-               panel_size_y = rows * weapon_size_y;
-               panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
-               panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
-               if(panel_bg_padding)
-                       panel_size += '2 2 0' * panel_bg_padding;
+               panel_size.x = columns * weapon_size.x;
+               panel_size.y = rows * weapon_size.y;
+               panel_size += '2 2 0' * panel_bg_padding;
+               // center the resized panel, or snap it to the screen edge when close enough
+               if(panel_pos.x > vid_conwidth * 0.001)
+               {
+                       if(panel_pos.x + old_panel_size.x > vid_conwidth * 0.999)
+                               panel_pos.x += old_panel_size.x - panel_size.x;
+                       else
+                               panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
+               }
+               else if(old_panel_size.x > vid_conwidth * 0.999)
+                       panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
+               if(panel_pos.y > vid_conheight * 0.001)
+               {
+                       if(panel_pos.y + old_panel_size.y > vid_conheight * 0.999)
+                               panel_pos.y += old_panel_size.y - panel_size.y;
+                       else
+                               panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
+               }
+               else if(old_panel_size.y > vid_conheight * 0.999)
+                       panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
        }
        else
                weapon_count = WEP_COUNT;
                        if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
                        {
                                f *= f; // for a cooler movement
-                               center_x = panel_pos_x + panel_size_x/2;
-                               center_y = panel_pos_y + panel_size_y/2;
+                               center.x = panel_pos.x + panel_size.x/2;
+                               center.y = panel_pos.y + panel_size.y/2;
                                screen_ar = vid_conwidth/vid_conheight;
-                               if (center_x/center_y < screen_ar) //bottom left
+                               if (center.x/center.y < screen_ar) //bottom left
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
-                                               panel_pos_y += f * (vid_conheight - panel_pos_y);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
+                                               panel_pos.y += f * (vid_conheight - panel_pos.y);
                                        else //left
-                                               panel_pos_x -= f * (panel_pos_x + panel_size_x);
+                                               panel_pos.x -= f * (panel_pos.x + panel_size.x);
                                }
                                else //top right
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //right
-                                               panel_pos_x += f * (vid_conwidth - panel_pos_x);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //right
+                                               panel_pos.x += f * (vid_conwidth - panel_pos.x);
                                        else //top
-                                               panel_pos_y -= f * (panel_pos_y + panel_size_y);
+                                               panel_pos.y -= f * (panel_pos.y + panel_size.y);
                                }
                                if(f == 1)
-                                       center_x = -1; // mark the panel as off screen
+                                       center.x = -1; // mark the panel as off screen
                        }
                        weaponprevtime = time - (1 - f) * timein_effect_length;
                }
                        {
                                f *= f; // for a cooler movement
                                f = 1 - f;
-                               center_x = panel_pos_x + panel_size_x/2;
-                               center_y = panel_pos_y + panel_size_y/2;
+                               center.x = panel_pos.x + panel_size.x/2;
+                               center.y = panel_pos.y + panel_size.y/2;
                                screen_ar = vid_conwidth/vid_conheight;
-                               if (center_x/center_y < screen_ar) //bottom left
+                               if (center.x/center.y < screen_ar) //bottom left
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
-                                               panel_pos_y += f * (vid_conheight - panel_pos_y);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
+                                               panel_pos.y += f * (vid_conheight - panel_pos.y);
                                        else //left
-                                               panel_pos_x -= f * (panel_pos_x + panel_size_x);
+                                               panel_pos.x -= f * (panel_pos.x + panel_size.x);
                                }
                                else //top right
                                {
-                                       if ((vid_conwidth - center_x)/center_y < screen_ar) //right
-                                               panel_pos_x += f * (vid_conwidth - panel_pos_x);
+                                       if ((vid_conwidth - center.x)/center.y < screen_ar) //right
+                                               panel_pos.x += f * (vid_conwidth - panel_pos.x);
                                        else //top
-                                               panel_pos_y -= f * (panel_pos_y + panel_size_y);
+                                               panel_pos.y -= f * (panel_pos.y + panel_size.y);
                                }
                        }
                }
        // draw the background, then change the virtual size of it to better fit other items inside
        HUD_Panel_DrawBg(1);
  
-       if(center_x == -1)
+       if(center.x == -1)
        {
                draw_endBoldFont();
                return;
  
        if(!rows) // if rows is > 0 onlyowned code has already updated these vars
        {
-               rows = panel_size_y/panel_size_x;
-               rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
-               columns = ceil(weapon_count/rows);
-               weapon_size = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
+               vector table_size = HUD_GetTableSize(WEP_COUNT, panel_size, aspect);
+               columns = table_size.x;
+               rows = table_size.y;
+               weapon_size.x = panel_size.x / columns;
+               weapon_size.y = panel_size.y / rows;
+               vertical_order = (panel_size.x / panel_size.y >= aspect);
        }
  
        // calculate position/size for visual bar displaying ammount of ammo status
                ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
                ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
  
-               if(weapon_size_x/weapon_size_y > aspect)
+               if(weapon_size.x/weapon_size.y > aspect)
                {
-                       barsize_x = aspect * weapon_size_y;
-                       barsize_y = weapon_size_y;
-                       baroffset_x = (weapon_size_x - barsize_x) / 2;
+                       barsize.x = aspect * weapon_size.y;
+                       barsize.y = weapon_size.y;
+                       baroffset.x = (weapon_size.x - barsize.x) / 2;
                }
                else
                {
-                       barsize_y = 1/aspect * weapon_size_x;
-                       barsize_x = weapon_size_x;
-                       baroffset_y = (weapon_size_y - barsize_y) / 2;
+                       barsize.y = 1/aspect * weapon_size.x;
+                       barsize.x = weapon_size.x;
+                       baroffset.y = (weapon_size.y - barsize.y) / 2;
                }
        }
        if(autocvar_hud_panel_weapons_accuracy)
                Accuracy_LoadColors();
  
+       // draw items
        row = column = 0;
+       vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                // retrieve information about the current weapon to be drawn
  
                // figure out the drawing position of weapon
                weapon_pos = (panel_pos
-                       + eX * column * weapon_size_x
-                       + eY * row * weapon_size_y);
+                       + eX * column * weapon_size.x
+                       + eY * row * weapon_size.y);
  
                // draw background behind currently selected weapon
                if(self.weapon == switchweapon)
                // draw the weapon accuracy
                if(autocvar_hud_panel_weapons_accuracy)
                {
-                       panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
+                       float panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
                        if(panel_weapon_accuracy >= 0)
                        {
                                color = Accuracy_GetColor(panel_weapon_accuracy);
                if(weapons_stat & WepSet_FromWeapon(self.weapon))
                {
                        // draw the weapon image
-                       drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
                        // draw weapon label string
                        switch(autocvar_hud_panel_weapons_label)
                        {
                                case 1: // weapon number
-                                       drawstring(weapon_pos, ftos(weapon_id), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, ftos(weapon_id), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                case 2: // bind
-                                       drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                case 3: // weapon name
-                                       drawstring(weapon_pos, self.netname, '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawstring(weapon_pos, strtolower(self.message), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                        break;
  
                                default: // nothing
                        }
  
                        // draw ammo status bar
-                       if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO)
+                       if(autocvar_hud_panel_weapons_ammo && (self.ammo_field != ammo_none))
                        {
-                               a = 0;
-                               ammo_type = GetAmmoTypeForWep(self.weapon);
-                               if(ammo_type != -1)
-                                       a = getstati(GetAmmoStat(ammo_type)); // how much ammo do we have?
+                               float ammo_full;
+                               a = getstati(GetAmmoStat(self.ammo_field)); // how much ammo do we have?
  
                                if(a > 0)
                                {
-                                       switch(ammo_type) {
-                                               case 0: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break;
-                                               case 1: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break;
-                                               case 2: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
-                                               case 3: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break;
-                                               case 4: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break;
+                                       switch(self.ammo_field)
+                                       {
+                                               case ammo_shells:  ammo_full = autocvar_hud_panel_weapons_ammo_full_shells;  break;
+                                               case ammo_nails:   ammo_full = autocvar_hud_panel_weapons_ammo_full_nails;   break;
+                                               case ammo_rockets: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
+                                               case ammo_cells:   ammo_full = autocvar_hud_panel_weapons_ammo_full_cells;   break;
+                                               case ammo_plasma:  ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma;  break;
+                                               case ammo_fuel:    ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel;    break;
                                                default: ammo_full = 60;
                                        }
  
                                        drawsetcliparea(
-                                               weapon_pos_x + baroffset_x,
-                                               weapon_pos_y + baroffset_y,
-                                               barsize_x * bound(0, a/ammo_full, 1),
-                                               barsize_y);
-                                       drawpic_aspect_skin(weapon_pos, "weapon_ammo", weapon_size, ammo_color, ammo_alpha, DRAWFLAG_NORMAL);
+                                               weapon_pos.x + baroffset.x,
+                                               weapon_pos.y + baroffset.y,
+                                               barsize.x * bound(0, a/ammo_full, 1),
+                                               barsize.y
+                                       );
+                                       drawpic_aspect_skin(
+                                               weapon_pos,
+                                               "weapon_ammo",
+                                               weapon_size,
+                                               ammo_color,
+                                               ammo_alpha,
+                                               DRAWFLAG_NORMAL
+                                       );
                                        drawresetcliparea();
                                }
                        }
                }
                else // draw a "ghost weapon icon" if you don't have the weapon
                {
-                       drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
                }
  
                // draw the complain message
                        drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
  
+               #if 0
+               /// debug code
+               if(!autocvar_hud_panel_weapons_onlyowned)
+               {
+                       drawfill(weapon_pos + '1 1 0', weapon_size - '2 2 0', '1 1 1', panel_fg_alpha * 0.2, DRAWFLAG_NORMAL);
+                       drawstring(weapon_pos, ftos(i + 1), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               }
+               #endif
                // continue with new position for the next weapon
-               ++row;
-               if(row >= rows)
+               if(vertical_order)
                {
-                       row = 0;
                        ++column;
+                       if(column >= columns)
+                       {
+                               column = 0;
+                               ++row;
+                       }
+               }
+               else
+               {
+                       ++row;
+                       if(row >= rows)
+                       {
+                               row = 0;
+                               ++column;
+                       }
                }
        }
  
  }
  
  // Ammo (#1)
- //
- // TODO: macro
- float GetAmmoItemCode(float i)
+ void DrawNadeScoreBar(vector myPos, vector mySize, vector color)
  {
-       switch(i)
-       {
-               case 0: return IT_SHELLS;
-               case 1: return IT_NAILS;
-               case 2: return IT_ROCKETS;
-               case 3: return IT_CELLS;
-               case 4: return IT_FUEL;
-               default: return -1;
-       }
+       HUD_Panel_DrawProgressBar(
+               myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
+               mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
+               autocvar_hud_panel_ammo_progressbar_name,
+               getstatf(STAT_NADE_BONUS_SCORE), 0, 0, color,
+               autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
  }
  
string GetAmmoPicture(float i)
void DrawAmmoNades(vector myPos, vector mySize, float draw_expanding, float expand_time)
  {
-       switch(i)
+       float theAlpha = 1, a, b;
+       vector nade_color, picpos, numpos;
+       nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE));
+       a = getstatf(STAT_NADE_BONUS);
+       b = getstatf(STAT_NADE_BONUS_SCORE);
+       if(autocvar_hud_panel_ammo_iconalign)
+       {
+               numpos = myPos;
+               picpos = myPos + eX * 2 * mySize.y;
+       }
+       else
        {
-               case 0: return "ammo_shells";
-               case 1: return "ammo_bullets";
-               case 2: return "ammo_rockets";
-               case 3: return "ammo_cells";
-               case 4: return "ammo_fuel";
-               default: return "";
+               numpos = myPos + eX * mySize.y;
+               picpos = myPos;
+       }
+       DrawNadeScoreBar(myPos, mySize, nade_color);
+       if(b > 0 || a > 0)
+       {
+               if(autocvar_hud_panel_ammo_text)
+                       drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+               if(draw_expanding)
+                       drawpic_aspect_skin_expanding(picpos, "nade_nbg", '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, expand_time);
+               drawpic_aspect_skin(picpos, "nade_bg" , '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(picpos, "nade_nbg" , '1 1 0' * mySize.y, nade_color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
        }
  }
  
- void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
+ void DrawAmmoItem(vector myPos, vector mySize, .float ammoType, float isCurrent, float isInfinite)
  {
-       float a;
+       if(ammoType == ammo_none)
+               return;
+       // Initialize variables
+       float ammo;
        if(autocvar__hud_configure)
        {
-               currently_selected = (itemcode == 2); //rockets always selected
-               a = 31 + mod(itemcode*93, 128);
+               isCurrent = (ammoType == ammo_rockets); // Rockets always current
+               ammo = 60;
        }
        else
-               a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
-       vector color;
-       if(infinite_ammo)
-               color = '0 0.5 0.75';
-       else if(a < 10)
-               color = '0.7 0 0';
-       else
-               color = '1 1 1';
+               ammo = getstati(GetAmmoStat(ammoType));
  
-       float theAlpha;
-       if(currently_selected)
-               theAlpha = 1;
-       else
-               theAlpha = 0.7;
+       if(!isCurrent)
+       {
+               float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
+               myPos = myPos + (mySize - mySize * scale) * 0.5;
+               mySize = mySize * scale;
+       }
  
-       vector picpos, numpos;
+       vector iconPos, textPos;
        if(autocvar_hud_panel_ammo_iconalign)
        {
-               numpos = myPos;
-               picpos = myPos + eX * 2 * mySize_y;
+               iconPos = myPos + eX * 2 * mySize.y;
+               textPos = myPos;
        }
        else
        {
-               numpos = myPos + eX * mySize_y;
-               picpos = myPos;
+               iconPos = myPos;
+               textPos = myPos + eX * mySize.y;
        }
  
-       if (currently_selected)
+       float isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
+       vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
+       vector textColor;
+       if(isInfinite)
+               textColor = '0.2 0.95 0';
+       else if(isShadowed)
+               textColor = '0 0 0';
+       else if(ammo < 10)
+               textColor = '0.8 0.04 0';
+       else
+               textColor = '1 1 1';
+       float alpha;
+       if(isCurrent)
+               alpha = panel_fg_alpha;
+       else if(isShadowed)
+               alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
+       else
+               alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
+       string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
+       // Draw item
+       if(isCurrent)
                drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
-     if(a > 0 && autocvar_hud_panel_ammo_progressbar)
-         HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+       if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
+               HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x, autocvar_hud_panel_ammo_progressbar_name, ammo/autocvar_hud_panel_ammo_maxammo, 0, 0, textColor, autocvar_hud_progressbar_alpha * alpha, DRAWFLAG_NORMAL);
  
-     if(autocvar_hud_panel_ammo_text)
-     {
-         if(a > 0 || infinite_ammo)
-             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
-         else // "ghost" ammo count
-             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
-     }
-       if(a > 0 || infinite_ammo)
-               drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
-       else // "ghost" ammo icon
-               drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
+       if(autocvar_hud_panel_ammo_text)
+               drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
  }
  
+ float nade_prevstatus;
+ float nade_prevframe;
+ float nade_statuschange_time;
  void HUD_Ammo(void)
  {
-     if(hud != HUD_NORMAL) return;
+       if(hud != HUD_NORMAL) return;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_ammo) return;
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
        }
  
        float rows = 0, columns, row, column;
+       float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
+       float draw_nades = (nade_cnt > 0 || nade_score > 0), nade_statuschange_elapsedtime;
+       float total_ammo_count;
        vector ammo_size;
        if (autocvar_hud_panel_ammo_onlycurrent)
-               ammo_size = mySize;
+               total_ammo_count = 1;
        else
-       {
-               rows = mySize_y/mySize_x;
-               rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
-               //                               ^^^ ammo item aspect goes here
+               total_ammo_count = AMMO_COUNT;
  
-               columns = ceil(AMMO_COUNT/rows);
-               ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+       if(draw_nades)
+       {
+               ++total_ammo_count;
+               if (nade_cnt != nade_prevframe)
+               {
+                       nade_statuschange_time = time;
+                       nade_prevstatus = nade_prevframe;
+                       nade_prevframe = nade_cnt;
+               }
        }
+       else
+               nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
+       rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
+       columns = ceil((total_ammo_count)/rows);
+       ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
  
-       local vector offset = '0 0 0'; // fteqcc sucks
+       vector offset = '0 0 0'; // fteqcc sucks
        float newSize;
-       if(ammo_size_x/ammo_size_y > 3)
+       if(ammo_size.x/ammo_size.y > 3)
        {
-               newSize = 3 * ammo_size_y;
-               offset_x = ammo_size_x - newSize;
-               pos_x += offset_x/2;
-               ammo_size_x = newSize;
+               newSize = 3 * ammo_size.y;
+               offset.x = ammo_size.x - newSize;
+               pos.x += offset.x/2;
+               ammo_size.x = newSize;
        }
        else
        {
-               newSize = 1/3 * ammo_size_x;
-               offset_y = ammo_size_y - newSize;
-               pos_y += offset_y/2;
-               ammo_size_y = newSize;
+               newSize = 1/3 * ammo_size.x;
+               offset.y = ammo_size.y - newSize;
+               pos.y += offset.y/2;
+               ammo_size.y = newSize;
        }
  
-       float i, stat_items, currently_selected, infinite_ammo;
-       infinite_ammo = FALSE;
-       if (autocvar_hud_panel_ammo_onlycurrent)
+       float i;
+       float infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
+       row = column = 0;
+       if(autocvar_hud_panel_ammo_onlycurrent)
        {
                if(autocvar__hud_configure)
                {
-                       DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
+                       DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
                }
                else
                {
-                       stat_items = getstati(STAT_ITEMS, 0, 24);
-                       if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
-                               infinite_ammo = TRUE;
-                       for (i = 0; i < AMMO_COUNT; ++i) {
-                               currently_selected = stat_items & GetAmmoItemCode(i);
-                               if (currently_selected)
-                               {
-                                       DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
-                                       break;
-                               }
-                       }
+                       DrawAmmoItem(
+                               pos,
+                               ammo_size,
+                               (get_weaponinfo(switchweapon)).ammo_field,
+                               true,
+                               infinite_ammo
+                       );
+               }
+               ++row;
+               if(row >= rows)
+               {
+                       row = 0;
+                       column = column + 1;
                }
        }
        else
        {
-               stat_items = getstati(STAT_ITEMS, 0, 24);
-               if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
-                       infinite_ammo = TRUE;
+               .float ammotype;
                row = column = 0;
-               for (i = 0; i < AMMO_COUNT; ++i) {
-                       currently_selected = stat_items & GetAmmoItemCode(i);
-                       DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
+               for(i = 0; i < AMMO_COUNT; ++i)
+               {
+                       ammotype = GetAmmoFieldFromNum(i);
+                       DrawAmmoItem(
+                               pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
+                               ammo_size,
+                               ammotype,
+                               ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
+                               infinite_ammo
+                       );
                        ++row;
                        if(row >= rows)
                        {
                }
        }
  
+       if (draw_nades)
+       {
+               nade_statuschange_elapsedtime = time - nade_statuschange_time;
+               float f = bound(0, nade_statuschange_elapsedtime*2, 1);
+               DrawAmmoNades(pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
+       }
        draw_endBoldFont();
  }
  
@@@ -1047,76 -1207,76 +1207,76 @@@ void DrawNumIcon_expanding(vector myPos
  
        if (vertical)
        {
-               if(mySize_y/mySize_x > 2)
+               if(mySize.y/mySize.x > 2)
                {
-                       newSize_y = 2 * mySize_x;
-                       newSize_x = mySize_x;
+                       newSize.y = 2 * mySize.x;
+                       newSize.x = mySize.x;
  
-                       newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
-                       newPos_x = myPos_x;
+                       newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+                       newPos.x = myPos.x;
                }
                else
                {
-                       newSize_x = 1/2 * mySize_y;
-                       newSize_y = mySize_y;
+                       newSize.x = 1/2 * mySize.y;
+                       newSize.y = mySize.y;
  
-                       newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
-                       newPos_y = myPos_y;
+                       newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+                       newPos.y = myPos.y;
                }
  
                if(icon_right_align)
                {
                        numpos = newPos;
-                       picpos = newPos + eY * newSize_x;
+                       picpos = newPos + eY * newSize.x;
                }
                else
                {
                        picpos = newPos;
-                       numpos = newPos + eY * newSize_x;
+                       numpos = newPos + eY * newSize.x;
                }
  
-               newSize_y /= 2;
+               newSize.y /= 2;
                drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
                // make number smaller than icon, it looks better
                // reduce only y to draw numbers with different number of digits with the same y size
-               numpos_y += newSize_y * ((1 - 0.7) / 2);
-               newSize_y *= 0.7;
+               numpos.y += newSize.y * ((1 - 0.7) / 2);
+               newSize.y *= 0.7;
                drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
                return;
        }
  
-       if(mySize_x/mySize_y > 3)
+       if(mySize.x/mySize.y > 3)
        {
-               newSize_x = 3 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 3 * mySize.y;
+               newSize.y = mySize.y;
  
-               newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
-               newPos_y = myPos_y;
+               newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+               newPos.y = myPos.y;
        }
        else
        {
-               newSize_y = 1/3 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/3 * mySize.x;
+               newSize.x = mySize.x;
  
-               newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
-               newPos_x = myPos_x;
+               newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+               newPos.x = myPos.x;
        }
  
        if(icon_right_align) // right align
        {
                numpos = newPos;
-               picpos = newPos + eX * 2 * newSize_y;
+               picpos = newPos + eX * 2 * newSize.y;
        }
        else // left align
        {
-               numpos = newPos + eX * newSize_y;
+               numpos = newPos + eX * newSize.y;
                picpos = newPos;
        }
  
        // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
        // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
-       drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
-       drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
+       drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
+       drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
  }
  
  void DrawNumIcon(vector myPos, vector mySize, float x, string icon, float vertical, float icon_right_align, vector color, float theAlpha)
@@@ -1155,7 -1315,6 +1315,6 @@@ void HUD_Powerups(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
                mySize -= '2 2 0' * panel_bg_padding;
        }
  
-       float panel_ar = mySize_x/mySize_y;
+       float panel_ar = mySize.x/mySize.y;
        float is_vertical = (panel_ar < 1);
        vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0';
  
        {
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
-                       mySize_x *= (1.0 / 3.0);
-                       superweapons_offset_x = mySize_x;
+                       mySize.x *= (1.0 / 3.0);
+                       superweapons_offset.x = mySize.x;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_x = 2*mySize_x;
+                               shield_offset.x = 2*mySize.x;
                        else
-                               strength_offset_x = 2*mySize_x;
+                               strength_offset.x = 2*mySize.x;
                }
                else
                {
-                       mySize_y *= (1.0 / 3.0);
-                       superweapons_offset_y = mySize_y;
+                       mySize.y *= (1.0 / 3.0);
+                       superweapons_offset.y = mySize.y;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_y = 2*mySize_y;
+                               shield_offset.y = 2*mySize.y;
                        else
-                               strength_offset_y = 2*mySize_y;
+                               strength_offset.y = 2*mySize.y;
                }
        }
        else
        {
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
-                       mySize_x *= 0.5;
+                       mySize.x *= 0.5;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_x = mySize_x;
+                               shield_offset.x = mySize.x;
                        else
-                               strength_offset_x = mySize_x;
+                               strength_offset.x = mySize.x;
                }
                else
                {
-                       mySize_y *= 0.5;
+                       mySize.y *= 0.5;
                        if (autocvar_hud_panel_powerups_flip)
-                               shield_offset_y = mySize_y;
+                               shield_offset.y = mySize.y;
                        else
-                               strength_offset_y = mySize_y;
+                               strength_offset.y = mySize.y;
                }
        }
  
                const float maxshield = 30;
                float shield = ceil(shield_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(shield);
-                       HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, autocvar_hud_progressbar_shield_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(shield > 1)
                const float maxstrength = 30;
                float strength = ceil(strength_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(strength);
-                       HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, autocvar_hud_progressbar_strength_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(strength > 1)
                const float maxsuperweapons = 30;
                float superweapons = ceil(superweapons_time);
                if(autocvar_hud_panel_powerups_progressbar)
-               {
-                       HUD_Panel_GetProgressBarColor(superweapons);
-                       HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, autocvar_hud_progressbar_superweapons_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                if(autocvar_hud_panel_powerups_text)
                {
                        if(superweapons > 1)
@@@ -1396,7 -1546,6 +1546,6 @@@ void HUD_HealthArmor(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
                v = healtharmor_maxdamage(health, armor, armorblockpercent, DEATH_WEAPON);
  
                float x;
-               x = floor(v_x + 1);
+               x = floor(v.x + 1);
  
          float maxtotal = maxhealth + maxarmor;
                string biggercount;
-               if(v_z) // NOT fully armored
+               if(v.z) // NOT fully armored
                {
                        biggercount = "health";
                        if(autocvar_hud_panel_healtharmor_progressbar)
-                       {
-                               HUD_Panel_GetProgressBarColor(health);
-                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       }
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(armor)
              if(autocvar_hud_panel_healtharmor_text)
-                               drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(pos + eX * mySize.x - eX * 0.5 * mySize.y, "armor", '0.5 0.5 0' * mySize.y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
                }
                else
                {
                        biggercount = "armor";
                        if(autocvar_hud_panel_healtharmor_progressbar)
-                       {
-                               HUD_Panel_GetProgressBarColor(armor);
-                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       }
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        if(health)
              if(autocvar_hud_panel_healtharmor_text)
-                               drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawpic_aspect_skin(pos + eX * mySize.x - eX * 0.5 * mySize.y, "health", '0.5 0.5 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
          if(autocvar_hud_panel_healtharmor_text)
                        DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
  
                if(fuel)
-               {
-                       HUD_Panel_GetProgressBarColor(fuel);
-                       HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
-               }
+                       HUD_Panel_DrawProgressBar(pos, eX * mySize.x + eY * 0.2 * mySize.y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
        }
        else
        {
-               float panel_ar = mySize_x/mySize_y;
+               float panel_ar = mySize.x/mySize.y;
                float is_vertical = (panel_ar < 1);
                vector health_offset = '0 0 0', armor_offset = '0 0 0';
                if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
                {
-                       mySize_x *= 0.5;
+                       mySize.x *= 0.5;
                        if (autocvar_hud_panel_healtharmor_flip)
-                               health_offset_x = mySize_x;
+                               health_offset.x = mySize.x;
                        else
-                               armor_offset_x = mySize_x;
+                               armor_offset.x = mySize.x;
                }
                else
                {
-                       mySize_y *= 0.5;
+                       mySize.y *= 0.5;
                        if (autocvar_hud_panel_healtharmor_flip)
-                               health_offset_y = mySize_y;
+                               health_offset.y = mySize.y;
                        else
-                               armor_offset_y = mySize_y;
+                               armor_offset.y = mySize.y;
                }
  
                float health_baralign, armor_baralign, fuel_baralign;
                {
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(health);
                                float p_health, pain_health_alpha;
                                p_health = health;
                                pain_health_alpha = 1;
                                                if (time - health_damagetime < 1)
                                                {
                                                        float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
-                                                       HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
+                                                       HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
                                                }
                                        }
                                        prev_health = health;
                                                pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
                                        }
                                }
-                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
                {
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(armor);
                                float p_armor;
                                p_armor = armor;
                                if (autocvar_hud_panel_healtharmor_progressbar_gfx)
                                                if (time - armor_damagetime < 1)
                                                {
                                                        float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
-                                                       HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
+                                                       HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
                                                }
                                        }
                                        prev_armor = armor;
                                }
-                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
                                DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
                if(fuel)
                {
                        if (is_vertical)
-                               mySize_x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
+                               mySize.x *= 0.2 / 2; //if vertical always halve x to not cover too much numbers with 3 digits
                        else
-                               mySize_y *= 0.2;
+                               mySize.y *= 0.2;
                        if (panel_ar >= 4)
-                               mySize_x *= 2; //restore full panel size
+                               mySize.x *= 2; //restore full panel size
                        else if (panel_ar < 1/4)
-                               mySize_y *= 2; //restore full panel size
-                       HUD_Panel_GetProgressBarColor(fuel);
-                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                               mySize.y *= 2; //restore full panel size
+                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
  }
  
  void HUD_Notify_Push(string icon, string attacker, string victim)
  {
-       if(icon != "")
-       {
-               --kn_index;
-               if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; }
-               notify_times[kn_index] = time;
+       if (icon == "")
+               return;
+       ++notify_count;
+       --notify_index;
+       if (notify_index == -1)
+               notify_index = NOTIFY_MAX_ENTRIES-1;
  
-               // icon
-               if(notify_icon[kn_index]) { strunzone(notify_icon[kn_index]); }
-               notify_icon[kn_index] = strzone(icon);
+       // Free old strings
+       if (notify_attackers[notify_index])
+               strunzone(notify_attackers[notify_index]);
  
-               // attacker
-               if(notify_attackers[kn_index]) { strunzone(notify_attackers[kn_index]); }
-               notify_attackers[kn_index] = strzone(attacker);
+       if (notify_victims[notify_index])
+               strunzone(notify_victims[notify_index]);
  
-               // victim
-               if(notify_victims[kn_index]) { strunzone(notify_victims[kn_index]); }
-               notify_victims[kn_index] = strzone(victim);
+       if (notify_icons[notify_index])
+               strunzone(notify_icons[notify_index]);
+       // Allocate new strings
+       if (victim != "")
+       {
+               notify_attackers[notify_index] = strzone(attacker);
+               notify_victims[notify_index] = strzone(victim);
+       }
+       else
+       {
+               // In case of a notification without a victim, the attacker
+               // is displayed on the victim's side. Instead of special
+               // treatment later on, we can simply switch them here.
+               notify_attackers[notify_index] = string_null;
+               notify_victims[notify_index] = strzone(attacker);
        }
+       notify_icons[notify_index] = strzone(icon);
+       notify_times[notify_index] = time;
  }
  
  void HUD_Notify(void)
  {
-       if(!autocvar__hud_configure)
-       {
-               if(!autocvar_hud_panel_notify) return;
-       }
+       if (!autocvar__hud_configure)
+               if (!autocvar_hud_panel_notify)
+                       return;
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
-       vector pos, mySize;
-       pos = panel_pos;
-       mySize = panel_size;
        HUD_Panel_DrawBg(1);
-       if(panel_bg_padding)
+       if (!autocvar__hud_configure)
+               if (notify_count == 0)
+                       return;
+       vector pos, size;
+       pos  = panel_pos;
+       size = panel_size;
+       if (panel_bg_padding)
        {
-               pos += '1 1 0' * panel_bg_padding;
-               mySize -= '2 2 0' * panel_bg_padding;
+               pos  += '1 1 0' * panel_bg_padding;
+               size -= '2 2 0' * panel_bg_padding;
        }
  
-       float entries, height;
-       entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES);
-       height = mySize_y/entries;
+       float fade_start = max(0, autocvar_hud_panel_notify_time);
+       float fade_time = max(0, autocvar_hud_panel_notify_fadetime);
+       float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect);
  
-       vector fontsize;
-       float fontheight = height * autocvar_hud_panel_notify_fontsize;
-       fontsize = '0.5 0.5 0' * fontheight;
+       float entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
+       float entry_height = size.y / entry_count;
  
-       float a;
-       float when;
-       when = autocvar_hud_panel_notify_time;
-       float fadetime;
-       fadetime = autocvar_hud_panel_notify_fadetime;
+       float panel_width_half = size.x * 0.5;
+       float icon_width_half = entry_height * icon_aspect / 2;
+       float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN;
+       vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize;
+       vector icon_size = (eX * icon_aspect + eY) * entry_height;
+       vector icon_left = eX * (panel_width_half - icon_width_half);
+       vector attacker_right = eX * name_maxwidth;
+       vector victim_left = eX * (size.x - name_maxwidth);
  
-       vector pos_attacker, pos_victim, pos_icon;
-       float width_attacker;
+       vector attacker_pos, victim_pos, icon_pos;
        string attacker, victim, icon;
+       float i, j, count, step, limit, alpha;
  
-       float i, j, step, limit;
-       if(autocvar_hud_panel_notify_flip) //order items from the top down
+       if (autocvar_hud_panel_notify_flip)
        {
+               // Order items from the top down
                i = 0;
                step = +1;
-               limit = entries;
+               limit = entry_count;
        }
-       else //order items from the bottom up
+       else
        {
-               i = entries - 1;
+               // Order items from the bottom up
+               i = entry_count - 1;
                step = -1;
                limit = -1;
        }
  
-       for(j = kn_index;  i != limit;  i += step, ++j)
+       for (j = notify_index, count = 0; i != limit; i += step, ++j, ++count)
        {
                if(autocvar__hud_configure)
                {
-                       if (step == +1)
-                               a = i;
-                       else // inverse order
-                               a = entries - 1 - i;
-                       attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       icon = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname);
-                       a = bound(0, (when - a) / 4, 1);
-                       goto hud_config_notifyprint;
+                       attacker = sprintf(_("Player %d"), count + 1);
+                       victim = sprintf(_("Player %d"), count + 2);
+                       icon = get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
+                       alpha = bound(0, 1.2 - count / entry_count, 1);
                }
                else
                {
-                       if (j == KN_MAX_ENTRIES)
+                       if (j == NOTIFY_MAX_ENTRIES)
                                j = 0;
  
-                       if(notify_times[j] + when > time)
-                               a = 1;
-                       else if(fadetime)
+                       if (notify_times[j] + fade_start > time)
+                               alpha = 1;
+                       else if (fade_time != 0)
                        {
-                               a = bound(0, (notify_times[j] + when + fadetime - time) / fadetime, 1);
-                               if(!a)
-                               {
+                               alpha = bound(0, (notify_times[j] + fade_start + fade_time - time) / fade_time, 1);
+                               if (alpha == 0)
                                        break;
-                               }
                        }
                        else
-                       {
                                break;
-                       }
  
                        attacker = notify_attackers[j];
                        victim = notify_victims[j];
-                       icon = notify_icon[j];
+                       icon = notify_icons[j];
                }
  
-               //type = notify_deathtype[j];
-               //w = DEATH_WEAPONOF(type);
-               if(icon != "")
+               if (icon != "" && victim != "")
                {
-                       if((attacker != "") && (victim == ""))
-                       {
-                               // Y [used by] X
-                               attacker = textShortenToWidth(attacker, 0.73 * mySize_x - height, fontsize, stringwidth_colors);
-                               pos_attacker = pos + eX * (0.27 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
-                               pos_icon = pos + eX * 0.25 * mySize_x - eX * height + eY * i * height;
+                       vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size.y));
  
-                               drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
-                               drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
-                       }
-                       else if((attacker != "") && (victim != ""))
+                       icon_pos = pos + icon_left + eY * i * entry_height;
+                       drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+                       victim = textShortenToWidth(victim, name_maxwidth, font_size, stringwidth_colors);
+                       victim_pos = pos + victim_left + name_top;
+                       drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+                       if (attacker != "")
                        {
-                               // X [did action to] Y
-                               attacker = textShortenToWidth(attacker, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                               victim = textShortenToWidth(victim, 0.48 * mySize_x - height, fontsize, stringwidth_colors);
- :hud_config_notifyprint
-                               width_attacker = stringwidth(attacker, TRUE, fontsize);
-                               pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
-                               pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
-                               pos_icon = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
-                               drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
-                               drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
-                               drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                               attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors);
+                               attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
+                               drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
                        }
                }
        }
+       notify_count = count;
  }
  
  // Timer (#5)
@@@ -1786,7 -1928,6 +1928,6 @@@ void HUD_Timer(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
@@@ -1850,24 -1991,35 +1991,35 @@@ void HUD_Radar(void
                {
                        if (autocvar_hud_panel_radar == 0) return;
                        if (autocvar_hud_panel_radar != 2 && !teamplay) return;
+                       if(radar_panel_modified)
+                       {
+                               panel.update_time = time; // forces reload of panel attributes
+                               radar_panel_modified = false;
+                       }
                }
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        float f = 0;
  
        if (hud_panel_radar_maximized && !autocvar__hud_configure)
        {
                panel_size = autocvar_hud_panel_radar_maximized_size;
-               panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
-               panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
-               panel_pos_x = (vid_conwidth - panel_size_x) / 2;
-               panel_pos_y = (vid_conheight - panel_size_y) / 2;
+               panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
+               panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
+               panel_pos.x = (vid_conwidth - panel_size.x) / 2;
+               panel_pos.y = (vid_conheight - panel_size.y) / 2;
  
+               string panel_bg;
                panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
-               if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback
+               if(precache_pic(panel_bg) == "")
+                       panel_bg = "gfx/hud/default/border_default"; // fallback
+               if(!radar_panel_modified && panel_bg != panel.current_panel_bg)
+                       radar_panel_modified = true;
+               if(panel.current_panel_bg)
+                       strunzone(panel.current_panel_bg);
+               panel.current_panel_bg = strzone(panel_bg);
  
                switch(hud_panel_radar_maximized_zoommode)
                {
                switch(hud_panel_radar_maximized_rotation)
                {
                        case 0:
-                               teamradar_angle = view_angles_y - 90;
+                               teamradar_angle = view_angles.y - 90;
                                break;
                        default:
                                teamradar_angle = 90 * hud_panel_radar_maximized_rotation;
                switch(hud_panel_radar_rotation)
                {
                        case 0:
-                               teamradar_angle = view_angles_y - 90;
+                               teamradar_angle = view_angles.y - 90;
                                break;
                        default:
                                teamradar_angle = 90 * hud_panel_radar_rotation;
                vector c0, c1, c2, c3, span;
                c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
                c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
-               c2 = rotate('1 0 0' * mi_min_x + '0 1 0' * mi_max_y, teamradar_angle * DEG2RAD);
-               c3 = rotate('1 0 0' * mi_max_x + '0 1 0' * mi_min_y, teamradar_angle * DEG2RAD);
+               c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
+               c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
                span = '0 0 0';
-               span_x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
-               span_y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
+               span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
+               span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
  
                // max-min distance must fit the radar in x=x, y=y
                bigsize = min(
-                       teamradar_size2d_x * scale2d / (1.05 * span_x),
-                       teamradar_size2d_y * scale2d / (1.05 * span_y)
+                       teamradar_size2d.x * scale2d / (1.05 * span.x),
+                       teamradar_size2d.y * scale2d / (1.05 * span.y)
                );
        }
  
                + (1 - f) * view_origin);
  
        drawsetcliparea(
-               pos_x,
-               pos_y,
-               mySize_x,
-               mySize_y
+               pos.x,
+               pos.y,
+               mySize.x,
+               mySize.y
        );
  
        draw_teamradar_background(hud_panel_radar_foreground_alpha);
  // Score (#7)
  //
  void HUD_UpdatePlayerTeams();
- void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
+ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
  {
        float score;
        entity tm = world, pl;
- #define SCOREPANEL_MAX_ENTRIES 6
- #define SCOREPANEL_ASPECTRATIO 2
-       float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
-       vector fontsize = '1 1 0' * (mySize_y/entries);
+       float SCOREPANEL_MAX_ENTRIES = 6;
+       float SCOREPANEL_ASPECTRATIO = 2;
+       float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
+       vector fontsize = '1 1 0' * (mySize.y/entries);
  
        vector rgb, score_color;
        rgb = '1 1 1';
        score_color = '1 1 1';
  
-       float name_size = mySize_x*0.75;
-       float spacing_size = mySize_x*0.04;
+       float name_size = mySize.x*0.75;
+       float spacing_size = mySize.x*0.04;
        const float highlight_alpha = 0.2;
        float i = 0, me_printed = 0, first_pl = 0;
        string s;
                if (team_count)
                {
                        // show team scores in the first line
-                       float score_size = mySize_x / team_count;
+                       float score_size = mySize.x / team_count;
                        players_per_team = max(2, ceil((entries - 1) / team_count));
                        for(i=0; i<team_count; ++i) {
                                if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
-                                       HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize.y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        first_pl = 1;
-                       pos_y += fontsize_y;
+                       pos.y += fontsize.y;
                }
                score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
                for (i=first_pl; i<entries; ++i)
                        if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
                        {
                                rgb = '1 1 0';
-                               drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                s = GetPlayerName(player_localnum);
                                score = 7;
                        }
                        if (team_count)
                                score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
                        s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
-                       drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       pos_y += fontsize_y;
+                       pos.y += fontsize.y;
                }
                return;
        }
        if (team_count)
        {
                // show team scores in the first line
-               float score_size = mySize_x / team_count;
+               float score_size = mySize.x / team_count;
                for(tm = teams.sort_next; tm; tm = tm.sort_next) {
                        if(tm.team == NUM_SPECTATOR)
                                continue;
                        if (tm.team == myteam)
-                               drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                       drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        ++i;
                }
                first_pl = 1;
-               pos_y += fontsize_y;
+               pos.y += fontsize.y;
                tm = teams.sort_next;
        }
        i = first_pl;
                        if (i == first_pl)
                                rgb = '0 1 0'; //first: green
                        me_printed = 1;
-                       drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                if (team_count)
                        score_color = Team_ColorRGB(pl.team) * 0.8;
                s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
-               drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               pos_y += fontsize_y;
+               pos.y += fontsize.y;
                ++i;
        }
        while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != NUM_SPECTATOR || (tm = tm.sort_next)));
@@@ -2146,7 -2298,6 +2298,6 @@@ void HUD_Score(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
        vector distribution_color;
        entity tm, pl, me;
  
- #ifdef COMPAT_XON050_ENGINE
-       me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
- #else
        me = playerslots[player_localentnum - 1];
- #endif
  
        if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
                string timer, distrtimer;
                                distribution_color = '1 0 0';
                                sign = "+";
                        }
-                       drawstring_aspect(pos + eX * 0.75 * mySize_x, strcat(sign, distrtimer), eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(pos + eX * 0.75 * mySize.x, strcat(sign, distrtimer), eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                // race record display
                if (distribution <= 0)
-                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos, timer, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
        } else if (!teamplay) { // non-teamgames
                if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
                {
-                       HUD_Score_Rankings(pos, mySize, me, 0);
+                       HUD_Score_Rankings(pos, mySize, me);
                        return;
                }
                // me vector := [team/connected frags id]
                {
                        if (distribution > 0)
                                distribution_str = strcat("+", distribution_str);
-                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
-               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(pos + eX * 0.75 * mySize.x, distribution_str, eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
        } else { // teamgames
-               float scores_count = 0, row, column, rows = 0, columns = 0;
-               local noref vector offset = '0 0 0';
+               float row, column, rows = 0, columns = 0;
+               vector offset = '0 0 0';
                vector score_pos, score_size; //for scores other than myteam
-               if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
+               if(autocvar_hud_panel_score_rankings)
                {
-                       for(tm = teams.sort_next; tm, tm.team != NUM_SPECTATOR; tm = tm.sort_next)
-                               ++scores_count;
-                       if (autocvar_hud_panel_score_rankings)
-                       {
-                               HUD_Score_Rankings(pos, mySize, me, scores_count);
-                               return;
-                       }
-                       rows = mySize_y/mySize_x;
-                       rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
-                       //                               ^^^ ammo item aspect goes here
-                       columns = ceil(scores_count/rows);
-                       score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
+                       HUD_Score_Rankings(pos, mySize, me);
+                       return;
+               }
+               if(spectatee_status == -1)
+               {
+                       rows = HUD_GetRowCount(team_count, mySize, 3);
+                       columns = ceil(team_count/rows);
+                       score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
  
                        float newSize;
-                       if(score_size_x/score_size_y > 3)
+                       if(score_size.x/score_size.y > 3)
                        {
-                               newSize = 3 * score_size_y;
-                               offset_x = score_size_x - newSize;
-                               pos_x += offset_x/2;
-                               score_size_x = newSize;
+                               newSize = 3 * score_size.y;
+                               offset.x = score_size.x - newSize;
+                               pos.x += offset.x/2;
+                               score_size.x = newSize;
                        }
                        else
                        {
-                               newSize = 1/3 * score_size_x;
-                               offset_y = score_size_y - newSize;
-                               pos_y += offset_y/2;
-                               score_size_y = newSize;
+                               newSize = 1/3 * score_size.x;
+                               offset.y = score_size.y - newSize;
+                               pos.y += offset.y/2;
+                               score_size.y = newSize;
                        }
                }
                else
-                       score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
+                       score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3);
  
                float max_fragcount;
                max_fragcount = -99;
  
                        if (spectatee_status == -1)
                        {
-                               score_pos = pos + eX * column * (score_size_x + offset_x) + eY * row * (score_size_y + offset_y);
+                               score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y);
                                if (max_fragcount == score)
                                        HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                                drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        else if(tm.team == myteam) {
                                if (max_fragcount == score)
-                                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        } else {
                                if (max_fragcount == score)
-                                       HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos + eX * 0.75 * mySize_x + eY * (1/3) * rows * mySize_y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                                ++rows;
                        }
                }
@@@ -2341,7 -2482,6 +2482,6 @@@ void HUD_RaceTimer (void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
  
        // always force 4:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 4)
+       if(mySize.x/mySize.y > 4)
        {
-               newSize_x = 4 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 4 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/4 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/4 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
        mySize = newSize;
  
        if(autocvar__hud_configure)
        {
                s = "0:13:37";
-               drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.60 0.60 0' * mySize_y), s, '0.60 0.60 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.60 0.60 0' * mySize.y), s, '0.60 0.60 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                s = _("^1Intermediate 1 (+15.42)");
-               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.60 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.60 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
                s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
-               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize_y) + eY * 0.80 * mySize_y, s, '1 1 0' * 0.20 * mySize_y, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.80 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        else if(race_checkpointtime)
        {
  
                if(s != "" && a > 0)
                {
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
  
                if(race_penaltytime)
                        if(a > 0)
                        {
                                s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
-                               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.8 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.8 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }
                }
  
                if(forcetime != "")
                {
                        a = bound(0, (time - race_checkpointtime) / 0.5, 1);
-                       drawstring_expanding(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize_y), forcetime, '1 1 0' * 0.6 * mySize_y, '1 1 1', panel_fg_alpha, 0, a);
+                       drawstring_expanding(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(forcetime, false, '1 1 0' * 0.6 * mySize.y), forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a);
                }
                else
                        a = 1;
                if(race_laptime && race_checkpoint != 255)
                {
                        s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
-                       drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.6 0.6 0' * mySize_y), s, '0.6 0.6 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.6 0.6 0' * mySize.y), s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
        }
        else
                {
                        a = bound(0, 2 - (time - race_mycheckpointtime), 1);
                        s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy);
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
                if(race_othercheckpointtime && race_othercheckpointenemy != "")
                {
                        a = bound(0, 2 - (time - race_othercheckpointtime), 1);
                        s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy);
-                       drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
  
                if(race_penaltytime && !race_penaltyaccumulator)
                                        s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
                                else
                                        s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
-                               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize_y) + eY * 0.6 * mySize_y, s, '1 1 0' * 0.2 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                               drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }
                }
        }
@@@ -2542,7 -2682,6 +2682,6 @@@ void HUD_Vote(void
                return;
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        if(uid2name_dialog)
        {
  
        // always force 3:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 3)
+       if(mySize.x/mySize.y > 3)
        {
-               newSize_x = 3 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 3 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/3 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/3 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
        mySize = newSize;
  
        s = _("A vote has been called for:");
        if(uid2name_dialog)
                s = _("Allow servers to store and display your name?");
-       drawstring_aspect(pos, s, eX * mySize_x + eY * (2/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
-       s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (1/8), stringwidth_colors);
+       drawstring_aspect(pos, s, eX * mySize.x + eY * (2/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
+       s = textShortenToWidth(vote_called_vote, mySize.x, '1 1 0' * mySize.y * (1/8), stringwidth_colors);
        if(autocvar__hud_configure)
                s = _("^1Configure the HUD");
-       drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
+       drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize.y, s, eX * mySize.x + eY * (1.75/8) * mySize.y, a, DRAWFLAG_NORMAL);
  
        // print the yes/no counts
      s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
-       drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '0 1 0', a, DRAWFLAG_NORMAL);
      s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
-       drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos + eX * 0.5 * mySize.x + eY * (4/8) * mySize.y, s, eX * 0.5 * mySize.x + eY * (1.5/8) * mySize.y, '1 0 0', a, DRAWFLAG_NORMAL);
  
        // draw the progress bar backgrounds
-       drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_back", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+       drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_back", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
  
        // draw the highlights
        if(vote_highlighted == 1) {
-               drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x, pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
        else if(vote_highlighted == -1) {
-               drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x + 0.5 * mySize.x, pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_voted", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        // draw the progress bars
        if(vote_yescount && vote_needed)
        {
-               drawsetcliparea(pos_x, pos_y, mySize_x * 0.5 * (vote_yescount/vote_needed), mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x, pos.y, mySize.x * 0.5 * (vote_yescount/vote_needed), mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        if(vote_nocount && vote_needed)
        {
-               drawsetcliparea(pos_x + mySize_x - mySize_x * 0.5 * (vote_nocount/vote_needed), pos_y, mySize_x * 0.5, mySize_y);
-               drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_prog", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
+               drawsetcliparea(pos.x + mySize.x - mySize.x * 0.5 * (vote_nocount/vote_needed), pos.y, mySize.x * 0.5, mySize.y);
+               drawpic_skin(pos + eY * (5/8) * mySize.y, "voteprogress_prog", eX * mySize.x + eY * (3/8) * mySize.y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
  
        drawresetcliparea();
  
  float mod_active; // is there any active mod icon?
  
- void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
+ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
  {
-       float stat;
-       string pic;
-       vector color;
- #ifdef GMQCC
-       stat = -1;
-       pic = "";
-       color = '0 0 0';
- #endif
+       float stat = -1;
+       string pic = "";
+       vector color = '0 0 0';
        switch(i)
        {
                case 0:
                        break;
        }
  
-       if(mySize_x/mySize_y > aspect_ratio)
+       if(mySize.x/mySize.y > aspect_ratio)
        {
-               i = aspect_ratio * mySize_y;
-               myPos_x = myPos_x + (mySize_x - i) / 2;
-               mySize_x = i;
+               i = aspect_ratio * mySize.y;
+               myPos.x = myPos.x + (mySize.x - i) / 2;
+               mySize.x = i;
        }
        else
        {
-               i = 1/aspect_ratio * mySize_x;
-               myPos_y = myPos_y + (mySize_y - i) / 2;
-               mySize_y = i;
+               i = 1/aspect_ratio * mySize.x;
+               myPos.y = myPos.y + (mySize.y - i) / 2;
+               mySize.y = i;
        }
  
        if(layout)
        {
-               drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(myPos + eX * 0.7 * mySize_x, ftos(stat), eX * 0.3 * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        else
                drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
  void HUD_Mod_CA(vector myPos, vector mySize)
  {
        mod_active = 1; // required in each mod function that always shows something
-       entity tm;
-       float teams_count = 0;
-       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-               if(tm.team != NUM_SPECTATOR)
-                       ++teams_count;
  
-       float layout;
+       int layout;
        if(gametype == MAPINFO_TYPE_CA)
                layout = autocvar_hud_panel_modicons_ca_layout;
        else //if(gametype == MAPINFO_TYPE_FREEZETAG)
                layout = autocvar_hud_panel_modicons_freezetag_layout;
        float rows, columns, aspect_ratio;
-       rows = mySize_y/mySize_x;
        aspect_ratio = (layout) ? 2 : 1;
-       rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
-       columns = ceil(teams_count/rows);
+       rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
+       columns = ceil(team_count/rows);
  
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
-       itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
-       for(i=0; i<teams_count; ++i)
+       itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
+       for(i=0; i<team_count; ++i)
        {
-               pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
+               pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
  
                DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
  
@@@ -2847,24 -2975,24 +2975,24 @@@ void HUD_Mod_CTF(vector pos, vector myS
                        break;
        }
  
-       if(mySize_x > mySize_y) {
+       if(mySize.x > mySize.y) {
                if (myteam == NUM_TEAM_1) { // always draw own flag on left
                        redflag_pos = pos;
-                       blueflag_pos = pos + eX * 0.5 * mySize_x;
+                       blueflag_pos = pos + eX * 0.5 * mySize.x;
                } else {
                        blueflag_pos = pos;
-                       redflag_pos = pos + eX * 0.5 * mySize_x;
+                       redflag_pos = pos + eX * 0.5 * mySize.x;
                }
-               flag_size = eX * 0.5 * mySize_x + eY * mySize_y;
+               flag_size = eX * 0.5 * mySize.x + eY * mySize.y;
        } else {
                if (myteam == NUM_TEAM_1) { // always draw own flag on left
                        redflag_pos = pos;
-                       blueflag_pos = pos + eY * 0.5 * mySize_y;
+                       blueflag_pos = pos + eY * 0.5 * mySize.y;
                } else {
                        blueflag_pos = pos;
-                       redflag_pos = pos + eY * 0.5 * mySize_y;
+                       redflag_pos = pos + eY * 0.5 * mySize.y;
                }
-               flag_size = eY * 0.5 * mySize_y + eX * mySize_x;
+               flag_size = eY * 0.5 * mySize.y + eX * mySize.x;
        }
  
        f = bound(0, redflag_statuschange_elapsedtime*2, 1);
  }
  
  // Keyhunt HUD modicon section
- float kh_runheretime;
- void HUD_Mod_KH_Reset(void)
- {
-       kh_runheretime = 0;
- }
+ vector KH_SLOTS[4];
  
  void HUD_Mod_KH(vector pos, vector mySize)
  {
        mod_active = 1; // keyhunt should never hide the mod icons panel
-       float kh_keys;
-       float keyteam;
-       float a, aa;
-       vector p = '0 0 0', pa, kh_size = '0 0 0', kh_asize = '0 0 0';
  
-       kh_keys = getstati(STAT_KH_KEYS);
+       // Read current state
  
-       p_x = pos_x;
-       if(mySize_x > mySize_y)
-       {
-               p_y = pos_y + 0.25 * mySize_y;
-               pa = p - eY * 0.25 * mySize_y;
+       float state = getstati(STAT_KH_KEYS);
+       float i, key_state;
+       float all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
+       all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
  
-               kh_size_x = mySize_x * 0.25;
-               kh_size_y = 0.75 * mySize_y;
-               kh_asize_x = mySize_x * 0.25;
-               kh_asize_y = mySize_y * 0.25;
-       }
-       else
+       for(i = 0; i < 4; ++i)
        {
-               p_y = pos_y + 0.125 * mySize_y;
-               pa = p - eY * 0.125 * mySize_y;
+               key_state = (bitshift(state, i * -5) & 31) - 1;
  
-               kh_size_x = mySize_x * 0.5;
-               kh_size_y = 0.375 * mySize_y;
-               kh_asize_x = mySize_x * 0.5;
-               kh_asize_y = mySize_y * 0.125;
-       }
+               if(key_state == -1)
+                       continue;
  
-       float i, key;
+               if(key_state == 30)
+               {
+                       ++carrying_keys;
+                       key_state = myteam;
+               }
  
-       float keycount;
-       keycount = 0;
-       for(i = 0; i < 4; ++i)
-       {
-               key = floor(kh_keys / pow(32, i)) & 31;
-               keyteam = key - 1;
-               if(keyteam == 30 && keycount <= 4)
-                       keycount += 4;
-               if(keyteam == myteam || keyteam == -1 || keyteam == 30)
-                       keycount += 1;
+               switch(key_state)
+               {
+                       case NUM_TEAM_1: ++team1_keys; break;
+                       case NUM_TEAM_2: ++team2_keys; break;
+                       case NUM_TEAM_3: ++team3_keys; break;
+                       case NUM_TEAM_4: ++team4_keys; break;
+                       case 29: ++dropped_keys; break;
+               }
+               ++all_keys;
        }
  
-       // this yields 8 exactly if "RUN HERE" shows
+       // Calculate slot measurements
  
-       if(keycount == 8)
+       vector slot_size;
+       if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
        {
-               if(!kh_runheretime)
-                       kh_runheretime = time;
-               pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
+               // Quadratic arrangement
+               slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
+               KH_SLOTS[0] = pos;
+               KH_SLOTS[1] = pos + eX * slot_size.x;
+               KH_SLOTS[2] = pos + eY * slot_size.y;
+               KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
        }
        else
-               kh_runheretime = 0;
-       for(i = 0; i < 4; ++i)
        {
-               key = floor(kh_keys / pow(32, i)) & 31;
-               keyteam = key - 1;
-               switch(keyteam)
+               if(mySize.x > mySize.y)
                {
-                       case 30: // my key
-                               keyteam = myteam;
-                               a = 1;
-                               aa = 1;
-                               break;
-                       case -1: // no key
-                               a = 0;
-                               aa = 0;
-                               break;
-                       default: // owned or dropped
-                               a = 0.2;
-                               aa = 0.5;
-                               break;
+                       // Horizontal arrangement
+                       slot_size = eX * mySize.x / all_keys + eY * mySize.y;
+                       for(i = 0; i < all_keys; ++i)
+                               KH_SLOTS[i] = pos + eX * slot_size.x * i;
                }
-               a = a * panel_fg_alpha;
-               aa = aa * panel_fg_alpha;
-               if(a > 0)
+               else
                {
-                       switch(keyteam)
-                       {
-                               case NUM_TEAM_1:
-                                       drawpic_aspect_skin(pa, "kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_2:
-                                       drawpic_aspect_skin(pa, "kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_3:
-                                       drawpic_aspect_skin(pa, "kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case NUM_TEAM_4:
-                                       drawpic_aspect_skin(pa, "kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               default:
-                                       break;
-                       }
-                       switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
-                       {
-                               case 0:
-                                       drawpic_aspect_skin(p, "kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 1:
-                                       drawpic_aspect_skin(p, "kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 2:
-                                       drawpic_aspect_skin(p, "kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                               case 3:
-                                       drawpic_aspect_skin(p, "kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL);  // show 30% theAlpha key
-                                       break;
-                       }
+                       // Vertical arrangement
+                       slot_size = eX * mySize.x + eY * mySize.y / all_keys;
+                       for(i = 0; i < all_keys; ++i)
+                               KH_SLOTS[i] = pos + eY * slot_size.y * i;
                }
-               if(mySize_x > mySize_y)
+       }
+       // Make icons blink in case of RUN HERE
+       float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
+       float alpha;
+       alpha = 1;
+       if(carrying_keys)
+               switch(myteam)
+               {
+                       case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
+                       case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
+               }
+       // Draw icons
+       i = 0;
+       while(team1_keys--)
+               if(myteam == NUM_TEAM_1 && carrying_keys)
                {
-                       p_x += 0.25 * mySize_x;
-                       pa_x += 0.25 * mySize_x;
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
                }
                else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team2_keys--)
+               if(myteam == NUM_TEAM_2 && carrying_keys)
                {
-                       if(i == 1)
-                       {
-                               p_y = pos_y + 0.625 * mySize_y;
-                               pa_y = pos_y + 0.5 * mySize_y;
-                               p_x = pos_x;
-                               pa_x = pos_x;
-                       }
-                       else
-                       {
-                               p_x += 0.5 * mySize_x;
-                               pa_x += 0.5 * mySize_x;
-                       }
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
                }
-       }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team3_keys--)
+               if(myteam == NUM_TEAM_3 && carrying_keys)
+               {
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
+               }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(team4_keys--)
+               if(myteam == NUM_TEAM_4 && carrying_keys)
+               {
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+                       --carrying_keys;
+               }
+               else
+                       drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
+       while(dropped_keys--)
+               drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
  }
  
  // Keepaway HUD mod icon
@@@ -3052,12 -3164,12 +3164,12 @@@ void HUD_Mod_Keepaway(vector pos, vecto
  
        vector kaball_pos, kaball_size;
  
-       if(mySize_x > mySize_y) {
-               kaball_pos = pos + eX * 0.25 * mySize_x;
-               kaball_size = eX * 0.5 * mySize_x + eY * mySize_y;
+       if(mySize.x > mySize.y) {
+               kaball_pos = pos + eX * 0.25 * mySize.x;
+               kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
        } else {
-               kaball_pos = pos + eY * 0.25 * mySize_y;
-               kaball_size = eY * 0.5 * mySize_y + eX * mySize_x;
+               kaball_pos = pos + eY * 0.25 * mySize.y;
+               kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
        }
  
        float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
                drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
  
        if(kaball)
-               drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
  }
  
  
@@@ -3087,22 -3199,17 +3199,17 @@@ void HUD_Mod_NexBall(vector pos, vecto
        //Manage the progress bar if any
        if (nb_pb_starttime > 0)
        {
-               dt = mod(time - nb_pb_starttime, nb_pb_period);
+               dt = (time - nb_pb_starttime) % nb_pb_period;
                // one period of positive triangle
                p = 2 * dt / nb_pb_period;
                if (p > 1)
                        p = 2 - p;
  
-               //Draw the filling
-               HUD_Panel_GetProgressBarColor(nexball);
-               if(mySize_x > mySize_y)
-                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-               else
-                       HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize.x <= mySize.y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
  
        if (stat_items & IT_KEY1)
-               drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  }
  
  // Race/CTS HUD mod icons
@@@ -3151,16 -3258,16 +3258,16 @@@ void HUD_Mod_Race(vector pos, vector my
  
        vector textPos, medalPos;
        float squareSize;
-       if(mySize_x > mySize_y) {
+       if(mySize.x > mySize.y) {
                // text on left side
-               squareSize = min(mySize_y, mySize_x/2);
-               textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
-               medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
+               squareSize = min(mySize.y, mySize.x/2);
+               textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
+               medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
        } else {
                // text on top
-               squareSize = min(mySize_x, mySize_y/2);
-               textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);
-               medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
+               squareSize = min(mySize.x, mySize.y/2);
+               textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
+               medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
        }
  
        f = time - crecordtime_change_time;
        }
  }
  
- void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, float i)
+ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, float i)
  {
-       float stat, pps_ratio;
-       string pic;
-       vector color;
- #ifdef GMQCC
-       stat = -1;
-       pic = "";
-       color = '0 0 0';
- #endif
+       float stat = -1;
+       string pic = "";
+       vector color = '0 0 0';
        switch(i)
        {
                case 0:
                        color = '1 0 1';
                        break;
        }
-       pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
+       float pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS);
  
-       if(mySize_x/mySize_y > aspect_ratio)
+       if(mySize.x/mySize.y > aspect_ratio)
        {
-               i = aspect_ratio * mySize_y;
-               myPos_x = myPos_x + (mySize_x - i) / 2;
-               mySize_x = i;
+               i = aspect_ratio * mySize.y;
+               myPos.x = myPos.x + (mySize.x - i) / 2;
+               mySize.x = i;
        }
        else
        {
-               i = 1/aspect_ratio * mySize_x;
-               myPos_y = myPos_y + (mySize_y - i) / 2;
-               mySize_y = i;
+               i = 1/aspect_ratio * mySize.x;
+               myPos.y = myPos.y + (mySize.y - i) / 2;
+               mySize.y = i;
        }
  
        if (layout) // show text too
                //draw the text
                color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
                if (layout == 2) // average pps
-                       drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
                else // percentage of average pps
-                       drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
  
        //draw the icon
-       drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        if (stat > 0)
        {
-               drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio);
-               drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
+               drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                drawresetcliparea();
        }
  }
  void HUD_Mod_Dom(vector myPos, vector mySize)
  {
        mod_active = 1; // required in each mod function that always shows something
-       entity tm;
-       float teams_count = 0;
-       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-               if(tm.team != NUM_SPECTATOR)
-                       ++teams_count;
  
-       float layout = autocvar_hud_panel_modicons_dom_layout;
+       int layout = autocvar_hud_panel_modicons_dom_layout;
        float rows, columns, aspect_ratio;
-       rows = mySize_y/mySize_x;
        aspect_ratio = (layout) ? 3 : 1;
-       rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count);
-       columns = ceil(teams_count/rows);
+       rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
+       columns = ceil(team_count/rows);
  
        int i;
        float row = 0, column = 0;
        vector pos, itemSize;
-       itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
-       for(i=0; i<teams_count; ++i)
+       itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
+       for(i=0; i<team_count; ++i)
        {
-               pos = myPos + eX * column * itemSize_x + eY * row * itemSize_y;
+               pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
  
                DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
  
        }
  }
  
+ void HUD_ModIcons_SetFunc()
+ {
+       switch(gametype)
+       {
+               case MAPINFO_TYPE_KEYHUNT:              HUD_ModIcons_GameType = HUD_Mod_KH; break;
+               case MAPINFO_TYPE_CTF:                  HUD_ModIcons_GameType = HUD_Mod_CTF; break;
+               case MAPINFO_TYPE_NEXBALL:              HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
+               case MAPINFO_TYPE_CTS:
+               case MAPINFO_TYPE_RACE:         HUD_ModIcons_GameType = HUD_Mod_Race; break;
+               case MAPINFO_TYPE_CA:
+               case MAPINFO_TYPE_FREEZETAG:    HUD_ModIcons_GameType = HUD_Mod_CA; break;
+               case MAPINFO_TYPE_DOMINATION:   HUD_ModIcons_GameType = HUD_Mod_Dom; break;
+               case MAPINFO_TYPE_KEEPAWAY:     HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
+       }
+ }
  float mod_prev; // previous state of mod_active to check for a change
  float mod_alpha;
  float mod_change; // "time" when mod_active changed
@@@ -3365,18 -3477,13 +3477,13 @@@ void HUD_ModIcons(void
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_modicons) return;
-               if (gametype != MAPINFO_TYPE_CTF && gametype != MAPINFO_TYPE_KEYHUNT && gametype != MAPINFO_TYPE_NEXBALL && gametype != MAPINFO_TYPE_CTS && gametype != MAPINFO_TYPE_RACE && gametype != MAPINFO_TYPE_CA && gametype != MAPINFO_TYPE_FREEZETAG && gametype != MAPINFO_TYPE_KEEPAWAY && gametype != MAPINFO_TYPE_DOMINATION) return;
+               if(!HUD_ModIcons_GameType) return;
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
-       vector pos, mySize;
-       pos = panel_pos;
-       mySize = panel_size;
        if(mod_active != mod_prev) {
                mod_change = time;
                mod_prev = mod_active;
  
        if(panel_bg_padding)
        {
-               pos += '1 1 0' * panel_bg_padding;
-               mySize -= '2 2 0' * panel_bg_padding;
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
        }
  
-       // these MUST be ran in order to update mod_active
-       if(gametype == MAPINFO_TYPE_KEYHUNT)
-               HUD_Mod_KH(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CTF || autocvar__hud_configure)
-               HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
-       else if(gametype == MAPINFO_TYPE_NEXBALL)
-               HUD_Mod_NexBall(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE)
-               HUD_Mod_Race(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_CA || gametype == MAPINFO_TYPE_FREEZETAG)
-               HUD_Mod_CA(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_DOMINATION)
-               HUD_Mod_Dom(pos, mySize);
-       else if(gametype == MAPINFO_TYPE_KEEPAWAY)
-               HUD_Mod_Keepaway(pos, mySize);
+       if(autocvar__hud_configure)
+               HUD_Mod_CTF(panel_pos, panel_size);
+       else
+               HUD_ModIcons_GameType(panel_pos, panel_size);
  
        draw_endBoldFont();
  }
@@@ -3426,7 -3522,6 +3522,6 @@@ void HUD_PressedKeys(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
        if(aspect)
        {
                vector newSize = '0 0 0';
-               if(mySize_x/mySize_y > aspect)
+               if(mySize.x/mySize.y > aspect)
                {
-                       newSize_x = aspect * mySize_y;
-                       newSize_y = mySize_y;
+                       newSize.x = aspect * mySize.y;
+                       newSize.y = mySize.y;
  
-                       pos_x = pos_x + (mySize_x - newSize_x) / 2;
+                       pos.x = pos.x + (mySize.x - newSize.x) / 2;
                }
                else
                {
-                       newSize_y = 1/aspect * mySize_x;
-                       newSize_x = mySize_x;
+                       newSize.y = 1/aspect * mySize.x;
+                       newSize.x = mySize.x;
  
-                       pos_y = pos_y + (mySize_y - newSize_y) / 2;
+                       pos.y = pos.y + (mySize.y - newSize.y) / 2;
                }
                mySize = newSize;
        }
  
        vector keysize;
-       keysize = eX * mySize_x * (1/3.0) + eY * mySize_y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
+       keysize = eX * mySize.x * (1/3.0) + eY * mySize.y * (1/(3.0 - !autocvar_hud_panel_pressedkeys_attack));
        float pressedkeys;
        pressedkeys = getstatf(STAT_PRESSED_KEYS);
  
        if(autocvar_hud_panel_pressedkeys_attack)
        {
-               drawpic_aspect_skin(pos + eX * keysize_x * 0.5, ((pressedkeys & KEY_ATCK) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawpic_aspect_skin(pos + eX * keysize_x * 1.5, ((pressedkeys & KEY_ATCK2) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               pos_y += keysize_y;
+               drawpic_aspect_skin(pos + eX * keysize.x * 0.5, ((pressedkeys & KEY_ATCK) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos + eX * keysize.x * 1.5, ((pressedkeys & KEY_ATCK2) ? "key_atck_inv.tga" : "key_atck.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               pos.y += keysize.y;
        }
  
        drawpic_aspect_skin(pos, ((pressedkeys & KEY_CROUCH) ? "key_crouch_inv.tga" : "key_crouch.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       pos_y += keysize_y;
+       drawpic_aspect_skin(pos + eX * keysize.x, ((pressedkeys & KEY_FORWARD) ? "key_forward_inv.tga" : "key_forward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_JUMP) ? "key_jump_inv.tga" : "key_jump.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       pos.y += keysize.y;
        drawpic_aspect_skin(pos, ((pressedkeys & KEY_LEFT) ? "key_left_inv.tga" : "key_left.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-       drawpic_aspect_skin(pos + eX * keysize_x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x, ((pressedkeys & KEY_BACKWARD) ? "key_backward_inv.tga" : "key_backward.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  }
  
  // Handle chat as a panel (#12)
@@@ -3494,24 -3589,32 +3589,32 @@@ void HUD_Chat(void
                        return;
                }
                if(autocvar__con_chat_maximized)
+               {
                        if(!hud_draw_maximized) return;
+               }
+               else if(chat_panel_modified)
+               {
+                       panel.update_time = time; // forces reload of panel attributes
+                       chat_panel_modified = false;
+               }
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
        {
-               panel_pos_y = panel_bg_border;
-               panel_size_y = vid_conheight - panel_bg_border * 2;
-               if(panel_bg == "0") // force a border when maximized
+               panel_pos.y = panel_bg_border;
+               panel_size.y = vid_conheight - panel_bg_border * 2;
+               if(panel.current_panel_bg == "0") // force a border when maximized
                {
-                       if(precache_pic(panel_bg) == "") {
-                               panel_bg = strcat(hud_skin_path, "/border_default");
-                               if(precache_pic(panel_bg) == "") {
-                                       panel_bg = "gfx/hud/default/border_default";
-                               }
-                       }
+                       string panel_bg;
+                       panel_bg = strcat(hud_skin_path, "/border_default");
+                       if(precache_pic(panel_bg) == "")
+                               panel_bg = "gfx/hud/default/border_default";
+                       if(panel.current_panel_bg)
+                               strunzone(panel.current_panel_bg);
+                       panel.current_panel_bg = strzone(panel_bg);
+                       chat_panel_modified = true;
                }
                panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75
        }
        if (!autocvar_con_chatrect)
                cvar_set("con_chatrect", "1");
  
-       cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
-       cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
+       cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
+       cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
  
-       cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
-       cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
+       cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
+       cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
  
        if(autocvar__hud_configure)
        {
                                a = panel_fg_alpha;
                        else
                                a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
-                       drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
-                       pos_y += chatsize_y;
+                       drawcolorcodedstring(pos, textShortenToWidth(_("^3Player^7: This is the chat area."), mySize.x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
+                       pos.y += chatsize.y;
                }
        }
  }
@@@ -3572,7 -3675,6 +3675,6 @@@ void HUD_EngineInfo(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
  
  // Info messages panel (#14)
  //
- #define drawInfoMessage(s)\
-       if(autocvar_hud_panel_infomessages_flip)\
-               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
-       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
-       o_y += fontsize_y;
+ #define drawInfoMessage(s) do {                                                                                                                                                                               \
+       if(autocvar_hud_panel_infomessages_flip)                                                                                                                                                \
+               o.x = pos.x + mySize.x - stringwidth(s, true, fontsize);                                                                                                        \
+       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);                                                                                                               \
+       o.y += fontsize.y;                                                                                                                                                                                              \
+ } while(0)
  void HUD_InfoMessages(void)
  {
        if(!autocvar__hud_configure)
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
  
        // always force 5:1 aspect
        vector newSize = '0 0 0';
-       if(mySize_x/mySize_y > 5)
+       if(mySize.x/mySize.y > 5)
        {
-               newSize_x = 5 * mySize_y;
-               newSize_y = mySize_y;
+               newSize.x = 5 * mySize.y;
+               newSize.y = mySize.y;
  
-               pos_x = pos_x + (mySize_x - newSize_x) / 2;
+               pos.x = pos.x + (mySize.x - newSize.x) / 2;
        }
        else
        {
-               newSize_y = 1/5 * mySize_x;
-               newSize_x = mySize_x;
+               newSize.y = 1/5 * mySize.x;
+               newSize.x = mySize.x;
  
-               pos_y = pos_y + (mySize_y - newSize_y) / 2;
+               pos.y = pos.y + (mySize.y - newSize.y) / 2;
        }
  
        mySize = newSize;
        o = pos;
  
        vector fontsize;
-       fontsize = '0.20 0.20 0' * mySize_y;
+       fontsize = '0.20 0.20 0' * mySize.y;
  
        float a;
        a = panel_fg_alpha;
                        if(spectatee_status == -1)
                                s = _("^1Observing");
                        else
- #ifdef COMPAT_XON050_ENGINE
-                               s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(spectatee_status - 1));
- #else
                                s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
- #endif
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(spectatee_status == -1)
                                s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
                        else
                                s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(spectatee_status == -1)
                                s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
                        else
                                s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        if(gametype == MAPINFO_TYPE_LMS)
                        {
                        }
                        else
                                s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
  
                        //show restart countdown:
                        if (time < getstatf(STAT_GAMESTARTTIME)) {
                                countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
                                s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
                                drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                               o_y += fontsize_y;
+                               o.y += fontsize.y;
                        }
                }
                if(warmup_stage && !intermission)
                {
                        s = _("^2Currently in ^1warmup^2 stage!");
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
-               
 +              if(autocvar_cl_showspectators)
 +              if(num_spectators)
-               if not(spectatee_status)
++              //if(spectatee_status != -1)
 +              {
-                       s = _("^1Spectating you:");
-                       drawInfoMessage(s)
++                      s = ((spectatee_status) ? _("^1Spectating this player:") : _("^1Spectating you:"));
++                      //drawInfoMessage(s)
 +                      float limit = min(num_spectators, MAX_SPECTATORS);
 +                      float i;
 +                      for(i = 0; i < limit; ++i)
 +                      {
 +                              float slot = spectatorlist[i];
-                               s = strcat("^3", GetPlayerName(slot));
-                               drawInfoMessage(s)
++                              if(i == 0)
++                                      s = strcat(s, " ^3", GetPlayerName(slot));
++                              else
++                                      s = strcat("^3", GetPlayerName(slot));
++                              drawInfoMessage(s);
 +                      }
 +              }
 +
                string blinkcolor;
-               if(mod(time, 1) >= 0.5)
+               if(time % 1 >= 0.5)
                        blinkcolor = "^1";
                else
                        blinkcolor = "^3";
                                else
                                        s = _("^2Waiting for others to ready up...");
                        }
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
                else if(warmup_stage && !intermission && !spectatee_status)
                {
                        s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
-                       drawInfoMessage(s)
+                       drawInfoMessage(s);
                }
  
                if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
                        tm = teams.sort_next;
                        if (tm)
                        {
-                               for(; tm.sort_next; tm = tm.sort_next)
+                               for (; tm.sort_next; tm = tm.sort_next)
                                {
                                        if(!tm.team_size || tm.team == NUM_SPECTATOR)
                                                continue;
                                        if (tm.team != NUM_SPECTATOR)
                                        if (tm.team_size == ts_max)
                                                s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
-                                       drawInfoMessage(s)
+                                       drawInfoMessage(s);
                                }
                        }
                }
        else
        {
                s = _("^7Press ^3ESC ^7to show HUD options.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3Doubleclick ^7a panel for panel-specific options.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
                s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
-               drawInfoMessage(s)
+               drawInfoMessage(s);
        }
  }
  
@@@ -3836,7 -3918,6 +3937,6 @@@ void HUD_Physics(void
        }
  
        HUD_Panel_UpdateCvars();
-       HUD_Panel_ApplyFadeAlpha();
  
        draw_beginBoldFont();
  
        else if(autocvar_hud_panel_physics_speed_vertical)
                speed = floor( vlen(vel) * conversion_factor + 0.5 );
        else
-               speed = floor( vlen(vel - vel_z * '0 0 1') * conversion_factor + 0.5 );
+               speed = floor( vlen(vel - vel.z * '0 0 1') * conversion_factor + 0.5 );
  
        //compute acceleration
        float acceleration, f;
                if(autocvar_hud_panel_physics_acceleration_vertical)
                        acceleration = (vlen(vel) - vlen(acc_prevspeed));
                else
-                       acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z));
+                       acceleration = (vlen(vel - '0 0 1' * vel.z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed.z));
  
                acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665);
  
        }
  
        //compute layout
-       float panel_ar = panel_size_x/panel_size_y;
+       float panel_ar = panel_size.x/panel_size.y;
        vector speed_offset = '0 0 0', acceleration_offset = '0 0 0';
        if (panel_ar >= 5 && !acceleration_progressbar_scale)
        {
-               panel_size_x *= 0.5;
+               panel_size.x *= 0.5;
                if (autocvar_hud_panel_physics_flip)
-                       speed_offset_x = panel_size_x;
+                       speed_offset.x = panel_size.x;
                else
-                       acceleration_offset_x = panel_size_x;
+                       acceleration_offset.x = panel_size.x;
        }
        else
        {
-               panel_size_y *= 0.5;
+               panel_size.y *= 0.5;
                if (autocvar_hud_panel_physics_flip)
-                       speed_offset_y = panel_size_y;
+                       speed_offset.y = panel_size.y;
                else
-                       acceleration_offset_y = panel_size_y;
+                       acceleration_offset.y = panel_size.y;
        }
        float speed_baralign, acceleration_baralign;
        if (autocvar_hud_panel_physics_baralign == 1)
        //draw speed
        if(speed)
        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
-       {
-               HUD_Panel_GetProgressBarColor(speed);
-               HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-       }
+               HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, autocvar_hud_progressbar_speed_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
        {
-               tmp_size_x = panel_size_x * 0.75;
-               tmp_size_y = panel_size_y * text_scale;
+               tmp_size.x = panel_size.x * 0.75;
+               tmp_size.y = panel_size.y * text_scale;
                if (speed_baralign)
-                       tmp_offset_x = panel_size_x - tmp_size_x;
+                       tmp_offset.x = panel_size.x - tmp_size.x;
                //else
                        //tmp_offset_x = 0;
-               tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
+               tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
                drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
                //draw speed unit
                if (speed_baralign)
-                       tmp_offset_x = 0;
+                       tmp_offset.x = 0;
                else
-                       tmp_offset_x = tmp_size_x;
+                       tmp_offset.x = tmp_size.x;
                if (autocvar_hud_panel_physics_speed_unit_show)
                {
                        //tmp_offset_y = 0;
-                       tmp_size_x = panel_size_x * (1 - 0.75);
-                       tmp_size_y = panel_size_y * 0.4 * text_scale;
-                       tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2;
+                       tmp_size.x = panel_size.x * (1 - 0.75);
+                       tmp_size.y = panel_size.y * 0.4 * text_scale;
+                       tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
        }
                        if(speed < top_speed)
                        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 2)
                        {
-                               float peak_offset_x;
+                               float peak_offsetX;
                                vector peak_size = '0 0 0';
                                if (speed_baralign == 0)
-                                       peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x;
+                                       peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x;
                  else if (speed_baralign == 1)
-                                       peak_offset_x = (1 - min(top_speed, max_speed)/max_speed) * panel_size_x;
+                                       peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
                  else // if (speed_baralign == 2)
-                     peak_offset_x = min(top_speed, max_speed)/max_speed * panel_size_x * 0.5;
-                               //if speed is not 0 the speed progressbar already fetched the color
-                               if (speed == 0)
-                                       HUD_Panel_GetProgressBarColor(speed);
-                               peak_size_x = floor(panel_size_x * 0.01 + 1.5);
-                 peak_size_y = panel_size_y;
+                     peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
+                               peak_size.x = floor(panel_size.x * 0.01 + 1.5);
+                 peak_size.y = panel_size.y;
                  if (speed_baralign == 2) // draw two peaks, on both sides
                  {
-                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x + peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size_x - peak_offset_x + peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x + peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x - peak_offsetX + peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                  }
                  else
-                     drawfill(panel_pos + speed_offset + eX * (peak_offset_x - peak_size_x), peak_size, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                     drawfill(panel_pos + speed_offset + eX * (peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
  
                        //top speed
-                       tmp_offset_y = panel_size_y * 0.4;
-                       tmp_size_x = panel_size_x * (1 - 0.75);
-                       tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale;
-                       tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2;
+                       tmp_offset.y = panel_size.y * 0.4;
+                       tmp_size.x = panel_size.x * (1 - 0.75);
+                       tmp_size.y = (panel_size.y - tmp_offset.y) * text_scale;
+                       tmp_offset.y += (panel_size.y - tmp_offset.y - tmp_size.y) / 2;
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                else
        if(acceleration)
        if(autocvar_hud_panel_physics_progressbar == 1 || autocvar_hud_panel_physics_progressbar == 3)
        {
-               if (acceleration < 0)
-                       HUD_Panel_GetProgressBarColor(acceleration_neg);
+               vector progressbar_color;
+               if(acceleration < 0)
+                       progressbar_color = autocvar_hud_progressbar_acceleration_neg_color;
                else
-                       HUD_Panel_GetProgressBarColor(acceleration);
+                       progressbar_color = autocvar_hud_progressbar_acceleration_color;
  
                f = acceleration/autocvar_hud_panel_physics_acceleration_max;
                if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
  
                if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
                {
-                       tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY;
+                       tmp_size = acceleration_progressbar_scale * panel_size.x * eX + panel_size.y * eY;
  
                        if (acceleration_baralign == 1)
-                               tmp_offset_x = panel_size_x - tmp_size_x;
+                               tmp_offset.x = panel_size.x - tmp_size.x;
                        else if (acceleration_baralign == 2 || acceleration_baralign == 3)
-                               tmp_offset_x = (panel_size_x - tmp_size_x) / 2;
+                               tmp_offset.x = (panel_size.x - tmp_size.x) / 2;
                        else
-                               tmp_offset_x = 0;
-                       tmp_offset_y = 0;
+                               tmp_offset.x = 0;
+                       tmp_offset.y = 0;
                }
                else
                {
  
                HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
-       tmp_size_x = panel_size_x;
-       tmp_size_y = panel_size_y * text_scale;
-       tmp_offset_x = 0;
-       tmp_offset_y = (panel_size_y - tmp_size_y) / 2;
+       tmp_size.x = panel_size.x;
+       tmp_size.y = panel_size.y * text_scale;
+       tmp_offset.x = 0;
+       tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
                drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
  
  
  // CenterPrint (#16)
  //
- #define CENTERPRINT_MAX_MSGS 10
- #define CENTERPRINT_MAX_ENTRIES 50
- #define CENTERPRINT_SPACING 0.7
+ const float CENTERPRINT_MAX_MSGS = 10;
+ const float CENTERPRINT_MAX_ENTRIES = 50;
+ const float CENTERPRINT_SPACING = 0.7;
  float cpm_index;
  string centerprint_messages[CENTERPRINT_MAX_MSGS];
  float centerprint_msgID[CENTERPRINT_MAX_MSGS];
@@@ -4138,7 -4214,7 +4233,7 @@@ void centerprint_generic(float new_id, 
                return;
  
        if (!centerprint_showing)
-               centerprint_showing = TRUE;
+               centerprint_showing = true;
  
        for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
@@@ -4210,20 -4286,20 +4305,20 @@@ void HUD_CenterPrint (void
        {
                if(!autocvar_hud_panel_centerprint) return;
  
-               if (hud_configure_prev && hud_configure_prev != -1)
+               if(hud_configure_prev)
                        reset_centerprint_messages();
        }
        else
        {
-               if (!hud_configure_prev)
+               if(!hud_configure_prev)
                        reset_centerprint_messages();
                if (time > hud_configure_cp_generation_time)
                {
                        float r;
                        r = random();
-                       if (r > 0.9)
+                       if (r > 0.75)
                                centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
-                       else if (r > 0.8)
+                       else if (r > 0.5)
                                centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
                        else
                                centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
                }
        }
  
+       // this panel fades only when the menu does
+       float hud_fade_alpha_save = 0;
+       if(scoreboard_fade_alpha)
+       {
+               hud_fade_alpha_save = hud_fade_alpha;
+               hud_fade_alpha = 1 - autocvar__menu_alpha;
+       }
        HUD_Panel_UpdateCvars();
  
-       // this panel doesn't fade when showing the scoreboard
-       if(autocvar__menu_alpha)
-               HUD_Panel_ApplyFadeAlpha();
        if(scoreboard_fade_alpha)
        {
+               hud_fade_alpha = hud_fade_alpha_save;
                // move the panel below the scoreboard
                if (scoreboard_bottom >= 0.96 * vid_conheight)
                        return;
                vector target_pos;
  
-               target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
+               target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x);
  
-               if(target_pos_y > panel_pos_y)
+               if(target_pos.y > panel_pos.y)
                {
                        panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
-                       panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
+                       panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
                }
        }
  
        // fontsize = '1 1 0' * height;
        height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
        fontsize = '1 1 0' * height;
-       entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
+       entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
  
        float i, j, k, n, g;
-       float a, sz, align, current_msg_pos_y = 0, msg_size;
+       float a, sz, align, current_msg_posY = 0, msg_size;
        vector pos;
        string ts;
-       float all_messages_expired = TRUE;
+       float all_messages_expired = true;
  
        pos = panel_pos;
        if (autocvar_hud_panel_centerprint_flip)
-               pos_y += panel_size_y;
+               pos.y += panel_size.y;
        align = bound(0, autocvar_hud_panel_centerprint_align, 1);
        for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
                                continue;
                }
  
-               all_messages_expired = FALSE;
+               all_messages_expired = false;
  
                // fade the centerprint_hud in/out
                if(centerprint_time[j] < 0)  // Expired but forced. Expire time is the fade-in time.
                else // Expiring soon, so fade it out.
                        a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
  
-               if (a <= 0.5/255.0)  // Guaranteed invisible - don't show.
+               // while counting down show it anyway in order to hold the current message position
+               if (a <= 0.5/255.0 && centerprint_countdown_num[j] == 0)  // Guaranteed invisible - don't show.
                        continue;
                if (a > 1)
                        a = 1;
                                getWrappedLine_remaining = argv(k);
                                while(getWrappedLine_remaining)
                                {
-                                       ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
+                                       ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
                                        if (ts != "")
-                                               pos_y -= fontsize_y;
+                                               pos.y -= fontsize.y;
                                        else
-                                               pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
+                                               pos.y -= fontsize.y * CENTERPRINT_SPACING/2;
                                }
                        }
-                       current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
+                       current_msg_posY = pos.y; // save starting pos (first line) of the current message
                }
  
-               msg_size = pos_y;
+               msg_size = pos.y;
                for(k = 0; k < n; ++k)
                {
                        getWrappedLine_remaining = argv(k);
                        while(getWrappedLine_remaining)
                        {
-                               ts = getWrappedLine(panel_size_x * sz, fontsize, stringwidth_colors);
+                               ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
                                if (ts != "")
                                {
                                        if (align)
-                                               pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
+                                               pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
                                        if (a > 0.5/255.0)  // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
-                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a, DRAWFLAG_NORMAL);
-                                       pos_y += fontsize_y;
+                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
+                                       pos.y += fontsize.y;
                                }
                                else
-                                       pos_y += fontsize_y * CENTERPRINT_SPACING/2;
+                                       pos.y += fontsize.y * CENTERPRINT_SPACING/2;
                        }
                }
  
                ++g; // move next position number up
  
-               msg_size = pos_y - msg_size;
+               msg_size = pos.y - msg_size;
                if (autocvar_hud_panel_centerprint_flip)
                {
-                       pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
+                       pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
+                               pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
  
-                       if (pos_y < panel_pos_y) // check if the next message can be shown
+                       if (pos.y < panel_pos.y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
                                return;
                }
                else
                {
-                       pos_y += CENTERPRINT_SPACING * fontsize_y;
+                       pos.y += CENTERPRINT_SPACING * fontsize.y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz));
+                               pos.y -= (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
  
-                       if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown
+                       if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
                        {
                                drawfontscale = '1 1 0';
                                return;
        drawfontscale = '1 1 0';
        if (all_messages_expired)
        {
-               centerprint_showing = FALSE;
+               centerprint_showing = false;
                reset_centerprint_messages();
        }
  }
  
+ // Buffs (#18)
+ //
+ void HUD_Buffs(void)
+ {
+       float buffs = getstati(STAT_BUFFS, 0, 24);
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_buffs) return;
+               if(spectatee_status == -1) return;
+               if(getstati(STAT_HEALTH) <= 0) return;
+               if(!buffs) return;
+       }
+       else
+       {
+               buffs = Buff_Type_first.items; // force first buff
+       }
+       float b = 0; // counter to tell other functions that we have buffs
+       entity e;
+       string s = "";
+       for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
+       {
+               ++b;
+               string o = strcat(rgb_to_hexcolor(Buff_Color(e.items)), Buff_PrettyName(e.items));
+               if(s == "")
+                       s = o;
+               else
+                       s = strcat(s, " ", o);
+       }
+       HUD_Panel_UpdateCvars();
+       draw_beginBoldFont();
+       vector pos, mySize;
+       pos = panel_pos;
+       mySize = panel_size;
+       HUD_Panel_DrawBg(bound(0, b, 1));
+       if(panel_bg_padding)
+       {
+               pos += '1 1 0' * panel_bg_padding;
+               mySize -= '2 2 0' * panel_bg_padding;
+       }
+       //float panel_ar = mySize_x/mySize_y;
+       //float is_vertical = (panel_ar < 1);
+       //float buff_iconalign = autocvar_hud_panel_buffs_iconalign;
+       vector buff_offset = '0 0 0';
+       for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
+       {
+               //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1);
+               drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+       }
+       draw_endBoldFont();
+ }
  /*
  ==================
  Main HUD system
  void HUD_Reset (void)
  {
        // reset gametype specific icons
-       if(gametype == MAPINFO_TYPE_KEYHUNT)
-               HUD_Mod_KH_Reset();
-       else if(gametype == MAPINFO_TYPE_CTF)
+       if(gametype == MAPINFO_TYPE_CTF)
                HUD_Mod_CTF_Reset();
  }
  
  void HUD_Main (void)
  {
-       float i;
+       int i;
        // global hud theAlpha fade
        if(menu_enabled == 1)
                hud_fade_alpha = 1;
        if(scoreboard_fade_alpha)
                hud_fade_alpha = (1 - scoreboard_fade_alpha);
  
-       if(autocvar__hud_configure)
-               if(isdemo())
-                       HUD_Configure_Exit_Force();
+       HUD_Configure_Frame();
  
        if(intermission == 2) // no hud during mapvote
-       {
-               if (autocvar__hud_configure)
-                       HUD_Configure_Exit_Force();
                hud_fade_alpha = 0;
-       }
-       else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
-               hud_fade_alpha = 1;
  
        // panels that we want to be active together with the scoreboard
-       // they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu
+       // they must fade only when the menu does
        if(scoreboard_fade_alpha == 1)
        {
                (panel = HUD_PANEL(CENTERPRINT)).panel_draw();
                hud_skin_prev = strzone(autocvar_hud_skin);
        }
  
-       // HUD configure visible grid
-       if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
-       {
-               hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
-               hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
-               hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth;
-               hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
-               vector s;
-               // x-axis
-               s = eX + eY * vid_conheight;
-               for(i = 1; i < 1/hud_configure_gridSize_x; ++i)
-                       drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
-               // y-axis
-               s = eY + eX * vid_conwidth;
-               for(i = 1; i < 1/hud_configure_gridSize_y; ++i)
-                       drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
-       }
- #ifdef COMPAT_XON050_ENGINE
-     current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum;
- #else
      current_player = player_localentnum;
- #endif
  
        // draw the dock
        if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
                        }
                        else if(hud_dock_color == "pants") {
                                f = stof(getplayerkeyvalue(current_player - 1, "colors"));
-                               color = colormapPaletteColor(mod(f, 16), 1);
+                               color = colormapPaletteColor(f % 16, 1);
                        }
                        else
                                color = stov(hud_dock_color);
                        }
                }
                if (warning)
-                       print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
+                       dprint("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
  
                cvar_set("_hud_panelorder", s);
                if(hud_panelorder_prev)
        if(autocvar__con_chat_maximized)
                (panel = HUD_PANEL(CHAT)).panel_draw();
  
-       if(autocvar__hud_configure)
-       {
-               if(tab_panel)
-               {
-                       panel = tab_panel;
-                       HUD_Panel_UpdatePosSize()
-                       drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
-               }
-               if(highlightedPanel)
-               {
-                       panel = highlightedPanel;
-                       HUD_Panel_UpdatePosSize()
-                       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
-               }
-               if(!hud_configure_prev || hud_configure_prev == -1)
-               {
-                       if(autocvar_hud_cursormode) { setcursormode(1); }
-                       hudShiftState = 0;
-                       for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
-                               hud_panel[panel_order[i]].update_time = time;
-               }
-       }
-       else if(hud_configure_prev && hud_configure_prev != -1 && autocvar_hud_cursormode)
-               setcursormode(0);
+       HUD_Configure_PostDraw();
  
        hud_configure_prev = autocvar__hud_configure;
-       if (!autocvar__hud_configure) // hud config mode disabled, enable normal theAlpha stuff again
-               if (menu_enabled)
-                       menu_enabled = 0;
  }
diff --combined qcsrc/client/main.qc
index 0000000000000000000000000000000000000000,36ec4f7b8c2525c2712566410ae80be9977ab50f..71198ebc3e23e5223f3cadf4c7506504725b9892
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1317 +1,1333 @@@
+ #include "mapvoting.qh"
+ #include "modeleffects.qh"
+ #include "particles.qh"
+ #include "scoreboard.qh"
+ #include "shownames.qh"
+ #include "target_music.qh"
+ #include "tturrets.qh"
+ #include "tuba.qh"
+ #include "wall.qh"
+ #include "waypointsprites.qh"
+ #include "vehicles/vehicles.qh"
+ #include "../server/vehicles/bumblebee.qh"
+ #include "../common/net_notice.qh"
+ #include "../common/monsters/monsters.qh"
+ #include "../warpzonelib/client.qh"
+ // --------------------------------------------------------------------------
+ // BEGIN REQUIRED CSQC FUNCTIONS
+ //include "main.qh"
+ entity clearentity_ent;
+ void clearentity(entity e)
+ {
+       if (!clearentity_ent)
+       {
+               clearentity_ent = spawn();
+               clearentity_ent.classname = "clearentity";
+       }
+       int n = e.entnum;
+       copyentity(clearentity_ent, e);
+       e.entnum = n;
+ }
+ #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
+ void menu_show_error()
+ {
+       drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
+ }
+ // CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
+ // Useful for precaching things
+ void menu_sub_null()
+ {
+ }
+ string forcefog;
+ void WaypointSprite_Load();
+ void ConsoleCommand_macro_init();
+ void CSQC_Init(void)
+ {
+       prvm_language = cvar_string("prvm_language");
+ #ifdef WATERMARK
+       dprintf("^4CSQC Build information: ^1%s\n", WATERMARK);
+ #endif
+       int i;
+       binddb = db_create();
+       tempdb = db_create();
+       ClientProgsDB = db_load("client.db");
+       compressShortVector_init();
+       draw_endBoldFont();
+       menu_visible = false;
+       menu_show = menu_show_error;
+       menu_action = func_null;
+       for(i = 0; i < 255; ++i)
+               if(getplayerkeyvalue(i, "viewentity") == "")
+                       break;
+       maxclients = i;
+       //registercommand("hud_configure");
+       //registercommand("hud_save");
+       //registercommand("menu_action");
+       ConsoleCommand_macro_init();
+       registercvar("hud_usecsqc", "1");
+       registercvar("scoreboard_columns", "default");
+       registercvar("cl_nade_type", "3");
+       registercvar("cl_pokenade_type", "zombie");
+       gametype = 0;
+       // hud_fields uses strunzone on the titles!
+       for(i = 0; i < MAX_HUD_FIELDS; ++i)
+               hud_title[i] = strzone("(null)");
+       Cmd_HUD_SetFields(0);
+       postinit = false;
+       calledhooks = 0;
+       teams = Sort_Spawn();
+       players = Sort_Spawn();
+       GetTeam(NUM_SPECTATOR, true); // add specs first
+       // needs to be done so early because of the constants they create
+       CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
+       CALL_ACCUMULATED_FUNCTION(RegisterMonsters);
+       CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
+       CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
+       CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
+       CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
+       CALL_ACCUMULATED_FUNCTION(RegisterBuffs);
+       WaypointSprite_Load();
+       // precaches
+       precache_model("null");
+       precache_sound("misc/hit.wav");
+       precache_sound("misc/typehit.wav");
+       Projectile_Precache();
+       Hook_Precache();
+       GibSplash_Precache();
+       Casings_Precache();
+       Vehicles_Precache();
+       turrets_precache();
+       Tuba_Precache();
+       CSQCPlayer_Precache();
+       if(autocvar_cl_reticle)
+       {
+               precache_pic("gfx/reticle_normal");
+               // weapon reticles are precached in weapon files
+       }
+       get_mi_min_max_texcoords(1); // try the CLEVER way first
+       minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
+       shortmapname = mi_shortname;
+       if(precache_pic(minimapname) == "")
+       {
+               // but maybe we have a non-clever minimap
+               minimapname = strcat("gfx/", mi_shortname, "_mini.tga");
+               if(precache_pic(minimapname) == "")
+                       minimapname = ""; // FAIL
+               else
+                       get_mi_min_max_texcoords(0); // load new texcoords
+       }
+       mi_center = (mi_min + mi_max) * 0.5;
+       mi_scale = mi_max - mi_min;
+       minimapname = strzone(minimapname);
+       WarpZone_Init();
+       hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
+       draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
+ }
+ // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
+ void Shutdown(void)
+ {
+       WarpZone_Shutdown();
+       remove(teams);
+       remove(players);
+       db_close(binddb);
+       db_close(tempdb);
+       if(autocvar_cl_db_saveasdump)
+               db_dump(ClientProgsDB, "client.db");
+       else
+               db_save(ClientProgsDB, "client.db");
+       db_close(ClientProgsDB);
+       if(camera_active)
+               cvar_set("chase_active",ftos(chase_active_backup));
+       // unset the event chasecam's chase_active
+       if(autocvar_chase_active < 0)
+               cvar_set("chase_active", "0");
+       if (!isdemo())
+       {
+               if (!(calledhooks & HOOK_START))
+                       localcmd("\n_cl_hook_gamestart nop\n");
+               if (!(calledhooks & HOOK_END))
+                       localcmd("\ncl_hook_gameend\n");
+       }
+ }
+ .float has_team;
+ float SetTeam(entity o, int Team)
+ {
+       entity tm;
+       if(teamplay)
+       {
+               switch(Team)
+               {
+                       case -1:
+                       case NUM_TEAM_1:
+                       case NUM_TEAM_2:
+                       case NUM_TEAM_3:
+                       case NUM_TEAM_4:
+                               break;
+                       default:
+                               if(GetTeam(Team, false) == world)
+                               {
+                                       dprintf("trying to switch to unsupported team %d\n", Team);
+                                       Team = NUM_SPECTATOR;
+                               }
+                               break;
+               }
+       }
+       else
+       {
+               switch(Team)
+               {
+                       case -1:
+                       case 0:
+                               break;
+                       default:
+                               if(GetTeam(Team, false) == world)
+                               {
+                                       dprintf("trying to switch to unsupported team %d\n", Team);
+                                       Team = NUM_SPECTATOR;
+                               }
+                               break;
+               }
+       }
+       if(Team == -1) // leave
+       {
+               if(o.has_team)
+               {
+                       tm = GetTeam(o.team, false);
+                       tm.team_size -= 1;
+                       o.has_team = 0;
+                       return true;
+               }
+       }
+       else
+       {
+               if (!o.has_team)
+               {
+                       o.team = Team;
+                       tm = GetTeam(Team, true);
+                       tm.team_size += 1;
+                       o.has_team = 1;
+                       return true;
+               }
+               else if(Team != o.team)
+               {
+                       tm = GetTeam(o.team, false);
+                       tm.team_size -= 1;
+                       o.team = Team;
+                       tm = GetTeam(Team, true);
+                       tm.team_size += 1;
+                       return true;
+               }
+       }
+       return false;
+ }
+ void Playerchecker_Think()
+ {
+     int i;
+       entity e;
+       for(i = 0; i < maxclients; ++i)
+       {
+               e = playerslots[i];
+               if(GetPlayerName(i) == "")
+               {
+                       if(e.sort_prev)
+                       {
+                               // player disconnected
+                               SetTeam(e, -1);
+                               RemovePlayer(e);
+                               e.sort_prev = world;
+                               //e.gotscores = 0;
+                       }
+               }
+               else
+               {
+                       if (!e.sort_prev)
+                       {
+                               // player connected
+                               if (!e)
+                                       playerslots[i] = e = spawn();
+                               e.sv_entnum = i;
+                               e.ping = 0;
+                               e.ping_packetloss = 0;
+                               e.ping_movementloss = 0;
+                               //e.gotscores = 0; // we might already have the scores...
+                               SetTeam(e, GetPlayerColor(i)); // will not hurt; later updates come with HUD_UpdatePlayerTeams
+                               RegisterPlayer(e);
+                               HUD_UpdatePlayerPos(e);
+                       }
+               }
+       }
+       self.nextthink = time + 0.2;
+ }
+ void Porto_Init();
+ void TrueAim_Init();
+ void PostInit(void)
+ {
+       entity playerchecker;
+       playerchecker = spawn();
+       playerchecker.think = Playerchecker_Think;
+       playerchecker.nextthink = time + 0.2;
+       Porto_Init();
+       TrueAim_Init();
+       postinit = true;
+ }
+ // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client.
+ // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine.
+ // All keys are in ascii.
+ // bInputType = 0 is key pressed, 1 is key released, 2 and 3 are mouse input.
+ // In the case of keyboard input, nPrimary is the ascii code, and nSecondary is 0.
+ // In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
+ // In the case of mouse input after a setcursormode(1) call, nPrimary is xpos, nSecondary is ypos.
+ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
+ {
+       float bSkipKey;
+       bSkipKey = false;
+       if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
+               return true;
+       if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
+               return true;
+       if(menu_visible && menu_action)
+               if(menu_action(bInputType, nPrimary, nSecondary))
+                       return true;
+       return bSkipKey;
+ }
+ // END REQUIRED CSQC FUNCTIONS
+ // --------------------------------------------------------------------------
+ // --------------------------------------------------------------------------
+ // BEGIN OPTIONAL CSQC FUNCTIONS
+ void Ent_RemoveEntCS()
+ {
+       entcs_receiver[self.sv_entnum] = world;
+ }
+ void Ent_ReadEntCS()
+ {
+     int sf;
+       InterpolateOrigin_Undo();
+       self.classname = "entcs_receiver";
+       sf = ReadByte();
+       if(sf & 1)
+               self.sv_entnum = ReadByte();
+       if(sf & 2)
+       {
+               self.origin_x = ReadShort();
+               self.origin_y = ReadShort();
+               self.origin_z = ReadShort();
+               setorigin(self, self.origin);
+       }
+       if(sf & 4)
+       {
+               self.angles_y = ReadByte() * 360.0 / 256;
+               self.angles_x = self.angles_z = 0;
+       }
+       if(sf & 8)
+               self.healthvalue = ReadByte() * 10;
+       if(sf & 16)
+               self.armorvalue = ReadByte() * 10;
+       entcs_receiver[self.sv_entnum] = self;
+       self.entremove = Ent_RemoveEntCS;
+       self.iflags |= IFLAG_ORIGIN;
+       InterpolateOrigin_Note();
+ }
+ void Ent_Remove();
+ void Ent_RemovePlayerScore()
+ {
+       if(self.owner) {
+               SetTeam(self.owner, -1);
+               self.owner.gotscores = 0;
+               for(int i = 0; i < MAX_SCORE; ++i) {
+                       self.owner.(scores[i]) = 0; // clear all scores
+               }
+       }
+ }
+ void Ent_ReadPlayerScore()
+ {
+       int i, n;
+       bool isNew;
+       entity o;
+       // damnit -.- don't want to go change every single .sv_entnum in hud.qc AGAIN
+       // (no I've never heard of M-x replace-string, sed, or anything like that)
+       isNew = !self.owner; // workaround for DP bug
+       n = ReadByte()-1;
+ #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
+       if(!isNew && n != self.sv_entnum)
+       {
+               //print("A CSQC entity changed its owner!\n");
+               printf("A CSQC entity changed its owner! (edict: %d, classname: %s)\n", num_for_edict(self), self.classname);
+               isNew = true;
+               Ent_Remove();
+               self.enttype = ENT_CLIENT_SCORES;
+       }
+ #endif
+       self.sv_entnum = n;
+       if (!(playerslots[self.sv_entnum]))
+               playerslots[self.sv_entnum] = spawn();
+       o = self.owner = playerslots[self.sv_entnum];
+       o.sv_entnum = self.sv_entnum;
+       o.gotscores = 1;
+       //if (!o.sort_prev)
+       //      RegisterPlayer(o);
+       //playerchecker will do this for us later, if it has not already done so
+     int sf, lf;
+ #if MAX_SCORE <= 8
+       sf = ReadByte();
+       lf = ReadByte();
+ #else
+       sf = ReadShort();
+       lf = ReadShort();
+ #endif
+     int p;
+       for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
+               if(sf & p)
+               {
+                       if(lf & p)
+                               o.(scores[i]) = ReadInt24_t();
+                       else
+                               o.(scores[i]) = ReadChar();
+               }
+       if(o.sort_prev)
+               HUD_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
+       self.entremove = Ent_RemovePlayerScore;
+ }
+ void Ent_ReadTeamScore()
+ {
+       int i;
+       entity o;
+       self.team = ReadByte();
+       o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
+     int sf, lf;
+ #if MAX_TEAMSCORE <= 8
+       sf = ReadByte();
+       lf = ReadByte();
+ #else
+       sf = ReadShort();
+       lf = ReadShort();
+ #endif
+       int p;
+       for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
+               if(sf & p)
+               {
+                       if(lf & p)
+                               o.(teamscores[i]) = ReadInt24_t();
+                       else
+                               o.(teamscores[i]) = ReadChar();
+               }
+       HUD_UpdateTeamPos(o);
+ }
+ void Ent_ClientData()
+ {
+       float newspectatee_status;
+     int f = ReadByte();
+       scoreboard_showscores_force = (f & 1);
+       if(f & 2)
+       {
+               newspectatee_status = ReadByte();
+               if(newspectatee_status == player_localnum + 1)
+                       newspectatee_status = -1; // observing
+       }
+       else
+               newspectatee_status = 0;
+       spectatorbutton_zoom = (f & 4);
+       if(f & 8)
+       {
+               angles_held_status = 1;
+               angles_held.x = ReadAngle();
+               angles_held.y = ReadAngle();
+               angles_held.z = 0;
+       }
+       else
+               angles_held_status = 0;
++      if(f & 16)
++      {
++              num_spectators = ReadByte();
++
++              float i, slot;
++
++              for(i = 0; i < MAX_SPECTATORS; ++i)
++                      spectatorlist[i] = 0; // reset list first
++
++              for(i = 0; i < num_spectators; ++i)
++              {
++                      slot = ReadByte();
++                      spectatorlist[i] = slot - 1;
++              }
++      }
++
+       if(newspectatee_status != spectatee_status)
+       {
+               // clear race stuff
+               race_laptime = 0;
+               race_checkpointtime = 0;
+       }
+       if (autocvar_hud_panel_healtharmor_progressbar_gfx)
+       {
+               if ( (spectatee_status == -1 && newspectatee_status > 0) //before observing, now spectating
+                 || (spectatee_status > 0 && newspectatee_status > 0 && spectatee_status != newspectatee_status) //changed spectated player
+               )
+                       prev_p_health = -1;
+               else if(spectatee_status && !newspectatee_status) //before observing/spectating, now playing
+                       prev_health = -1;
+       }
+       spectatee_status = newspectatee_status;
+       // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
+ }
+ void Ent_Nagger()
+ {
+     int i, j, b, f;
+     int nags = ReadByte(); // NAGS NAGS NAGS NAGS NAGS NAGS NADZ NAGS NAGS NAGS
+       if(!(nags & 4))
+       {
+               if(vote_called_vote)
+                       strunzone(vote_called_vote);
+               vote_called_vote = string_null;
+               vote_active = 0;
+       }
+       else
+       {
+               vote_active = 1;
+       }
+       if(nags & 64)
+       {
+               vote_yescount = ReadByte();
+               vote_nocount = ReadByte();
+               vote_needed = ReadByte();
+               vote_highlighted = ReadChar();
+       }
+       if(nags & 128)
+       {
+               if(vote_called_vote)
+                       strunzone(vote_called_vote);
+               vote_called_vote = strzone(ColorTranslateRGB(ReadString()));
+       }
+       if(nags & 1)
+       {
+               for(j = 0; j < maxclients; ++j)
+                       if(playerslots[j])
+                               playerslots[j].ready = 1;
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       f = ReadByte();
+                       for(j = i-1, b = 1; b < 256; b *= 2, ++j)
+                               if (!(f & b))
+                                       if(playerslots[j])
+                                               playerslots[j].ready = 0;
+               }
+       }
+       ready_waiting = (nags & 1);
+       ready_waiting_for_me = (nags & 2);
+       vote_waiting = (nags & 4);
+       vote_waiting_for_me = (nags & 8);
+       warmup_stage = (nags & 16);
+ }
+ void Ent_EliminatedPlayers()
+ {
+     int i, j, b, f;
+     int sf = ReadByte();
+       if(sf & 1)
+       {
+               for(j = 0; j < maxclients; ++j)
+                       if(playerslots[j])
+                               playerslots[j].eliminated = 1;
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       f = ReadByte();
+                       for(j = i-1, b = 1; b < 256; b *= 2, ++j)
+                               if (!(f & b))
+                                       if(playerslots[j])
+                                               playerslots[j].eliminated = 0;
+               }
+       }
+ }
+ void Ent_RandomSeed()
+ {
+       float s;
+       prandom_debug();
+       s = ReadShort();
+       psrandom(s);
+ }
+ void Ent_ReadAccuracy(void)
+ {
+     int f, w;
+     int sf = ReadInt24_t();
+       if(sf == 0)
+       {
+               for(w = 0; w <= WEP_LAST - WEP_FIRST; ++w)
+                       weapon_accuracy[w] = -1;
+               return;
+       }
+       for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w)
+       {
+               if(sf & f)
+               {
+             int b = ReadByte();
+                       if(b == 0)
+                               weapon_accuracy[w] = -1;
+                       else if(b == 255)
+                               weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
+                       else
+                               weapon_accuracy[w] = (b - 1.0) / 100.0;
+               }
+               if(f == 0x800000)
+                       f = 1;
+               else
+                       f *= 2;
+       }
+ }
+ void Spawn_Draw(void)
+ {
+       pointparticles(self.cnt, self.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
+ }
+ void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
+ {
+       float teamnum = (ReadByte() - 1);
+       vector spn_origin;
+       spn_origin.x = ReadShort();
+       spn_origin.y = ReadShort();
+       spn_origin.z = ReadShort();
+       if(is_new)
+       {
+               self.origin = spn_origin;
+               setsize(self, PL_MIN, PL_MAX);
+               droptofloor();
+               /*if(autocvar_cl_spawn_point_model) // needs a model first
+               {
+                       self.mdl = "models/spawnpoint.md3";
+                       self.colormod = Team_ColorRGB(teamnum);
+                       precache_model(self.mdl);
+                       setmodel(self, self.mdl);
+                       self.drawmask = MASK_NORMAL;
+                       //self.movetype = MOVETYPE_NOCLIP;
+                       //self.draw = Spawn_Draw;
+               }*/
+               if(autocvar_cl_spawn_point_particles)
+               {
+                       if((serverflags & SERVERFLAG_TEAMPLAY))
+                       {
+                               switch(teamnum)
+                               {
+                                       case NUM_TEAM_1: self.cnt = particleeffectnum("spawn_point_red"); break;
+                                       case NUM_TEAM_2: self.cnt = particleeffectnum("spawn_point_blue"); break;
+                                       case NUM_TEAM_3: self.cnt = particleeffectnum("spawn_point_yellow"); break;
+                                       case NUM_TEAM_4: self.cnt = particleeffectnum("spawn_point_pink"); break;
+                                       default: self.cnt = particleeffectnum("spawn_point_neutral"); break;
+                               }
+                       }
+                       else { self.cnt = particleeffectnum("spawn_point_neutral"); }
+                       self.draw = Spawn_Draw;
+               }
+       }
+       //printf("Ent_ReadSpawnPoint(is_new = %d); origin = %s, team = %d, effect = %d\n", is_new, vtos(self.origin), teamnum, self.cnt);
+ }
+ void Ent_ReadSpawnEvent(float is_new)
+ {
+       // If entnum is 0, ONLY do the local spawn actions
+       // this way the server can disable the sending of
+       // spawn origin or such to clients if wanted.
+       float entnum = ReadByte();
+       if(entnum)
+       {
+               self.origin_x = ReadShort();
+               self.origin_y = ReadShort();
+               self.origin_z = ReadShort();
+               if(is_new)
+               {
+                       float teamnum = GetPlayerColor(entnum - 1);
+                       if(autocvar_cl_spawn_event_particles)
+                       {
+                               switch(teamnum)
+                               {
+                                       case NUM_TEAM_1: pointparticles(particleeffectnum("spawn_event_red"), self.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_2: pointparticles(particleeffectnum("spawn_event_blue"), self.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_3: pointparticles(particleeffectnum("spawn_event_yellow"), self.origin, '0 0 0', 1); break;
+                                       case NUM_TEAM_4: pointparticles(particleeffectnum("spawn_event_pink"), self.origin, '0 0 0', 1); break;
+                                       default: pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); break;
+                               }
+                       }
+                       if(autocvar_cl_spawn_event_sound)
+                       {
+                               sound(self, CH_TRIGGER, "misc/spawn.wav", VOL_BASE, ATTEN_NORM);
+                       }
+               }
+       }
+       // local spawn actions
+       if(is_new && (!entnum || (entnum == player_localentnum)))
+       {
+               zoomin_effect = 1;
+               current_viewzoom = (1 / bound(1, autocvar_cl_spawnzoom_factor, 16));
+               if(autocvar_cl_unpress_zoom_on_spawn)
+               {
+                       localcmd("-zoom\n");
+                       button_zoom = false;
+               }
+       }
+       //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum);
+ }
+ // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
+ // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
+ void Ent_RadarLink();
+ void Ent_Init();
+ void Ent_ScoresInfo();
+ void CSQC_Ent_Update(float bIsNewEntity)
+ {
+       float t;
+       float savetime;
+       t = ReadByte();
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Ent_Update(%d) with self=%i self.entnum=%d self.enttype=%d t=%d\n", bIsNewEntity, self, self.entnum, self.enttype, t);
+       // set up the "time" global for received entities to be correct for interpolation purposes
+       savetime = time;
+       if(servertime)
+       {
+               time = servertime;
+       }
+       else
+       {
+               serverprevtime = time;
+               serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+               time = serverprevtime + serverdeltatime;
+       }
+ #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
+       if(self.enttype)
+       {
+               if(t != self.enttype || bIsNewEntity)
+               {
+                       //print("A CSQC entity changed its type!\n");
+                       printf("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", num_for_edict(self), self.entnum, self.enttype, t);
+                       Ent_Remove();
+                       clearentity(self);
+                       bIsNewEntity = 1;
+               }
+       }
+       else
+       {
+               if(!bIsNewEntity)
+               {
+                       printf("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(self), self.entnum, t);
+                       bIsNewEntity = 1;
+               }
+       }
+ #endif
+       self.enttype = t;
+       switch(t)
+       {
+               case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
+               case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
+               case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
+               case ENT_CLIENT_POINTPARTICLES: Ent_PointParticles(); break;
+               case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
+               case ENT_CLIENT_LASER: Ent_Laser(); break;
+               case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
+               case ENT_CLIENT_ELIMINATEDPLAYERS: Ent_EliminatedPlayers(); break;
+               case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
+               case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
+               case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
+               case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
+               case ENT_CLIENT_DAMAGEINFO: Ent_DamageInfo(bIsNewEntity); break;
+               case ENT_CLIENT_CASING: Ent_Casing(bIsNewEntity); break;
+               case ENT_CLIENT_INIT: Ent_Init(); break;
+               case ENT_CLIENT_SCORES_INFO: Ent_ScoresInfo(); break;
+               case ENT_CLIENT_MAPVOTE: Ent_MapVote(); break;
+               case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break;
+               case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break;
+               case ENT_CLIENT_WALL: Ent_Wall(); break;
+               case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break;
+               case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break;
+               case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break;
+               case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break;
+               case ENT_CLIENT_WARPZONE_TELEPORTED: WarpZone_Teleported_Read(bIsNewEntity); break;
+               case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
+               case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break;
+               case ENT_CLIENT_ARC_BEAM: Ent_ReadArcBeam(bIsNewEntity); break;
+               case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
+               case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
+               case ENT_CLIENT_TURRET: ent_turret(); break;
+               case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break;
+               case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break;
+               case ENT_CLIENT_BUMBLE_RAYGUN: bumble_raygun_read(bIsNewEntity); break;
+               case ENT_CLIENT_SPAWNPOINT: Ent_ReadSpawnPoint(bIsNewEntity); break;
+               case ENT_CLIENT_SPAWNEVENT: Ent_ReadSpawnEvent(bIsNewEntity); break;
+               case ENT_CLIENT_NOTIFICATION: Read_Notification(bIsNewEntity); break;
+               case ENT_CLIENT_HEALING_ORB: ent_healer(); break;
+               default:
+                       //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
+                       error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", self.enttype, num_for_edict(self), self.classname));
+                       break;
+       }
+       time = savetime;
+ }
+ // Destructor, but does NOT deallocate the entity by calling remove(). Also
+ // used when an entity changes its type. For an entity that someone interacts
+ // with others, make sure it can no longer do so.
+ void Ent_Remove()
+ {
+       if(self.entremove)
+               self.entremove();
+       if(self.skeletonindex)
+       {
+               skel_delete(self.skeletonindex);
+               self.skeletonindex = 0;
+       }
+       if(self.snd_looping > 0)
+       {
+               sound(self, self.snd_looping, "misc/null.wav", VOL_BASE, autocvar_g_jetpack_attenuation);
+               self.snd_looping = 0;
+       }
+       self.enttype = 0;
+       self.classname = "";
+       self.draw = menu_sub_null;
+       self.entremove = menu_sub_null;
+       // TODO possibly set more stuff to defaults
+ }
+ // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed.  Essentially call remove(self) as well.
+ void CSQC_Ent_Remove()
+ {
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Ent_Remove() with self=%i self.entnum=%d self.enttype=%d\n", self, self.entnum, self.enttype);
+       if(wasfreed(self))
+       {
+               print("WARNING: CSQC_Ent_Remove called for already removed entity. Packet loss?\n");
+               return;
+       }
+       if(self.enttype)
+               Ent_Remove();
+       remove(self);
+ }
+ void Gamemode_Init()
+ {
+       if (!isdemo())
+       {
+               if(!(calledhooks & HOOK_START))
+                       localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
+               calledhooks |= HOOK_START;
+       }
+ }
+ // CSQC_Parse_StuffCmd : Provides the stuffcmd string in the first parameter that the server provided.  To execute standard behavior, simply execute localcmd with the string.
+ void CSQC_Parse_StuffCmd(string strMessage)
+ {
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Parse_StuffCmd(\"%s\")\n", strMessage);
+       localcmd(strMessage);
+ }
+ // CSQC_Parse_Print : Provides the print string in the first parameter that the server provided.  To execute standard behavior, simply execute print with the string.
+ void CSQC_Parse_Print(string strMessage)
+ {
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Parse_Print(\"%s\")\n", strMessage);
+       print(ColorTranslateRGB(strMessage));
+ }
+ // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
+ void CSQC_Parse_CenterPrint(string strMessage)
+ {
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Parse_CenterPrint(\"%s\")\n", strMessage);
+       centerprint_hud(strMessage);
+ }
+ string notranslate_fogcmd1 = "\nfog ";
+ string notranslate_fogcmd2 = "\nr_fog_exp2 0\nr_drawfog 1\n";
+ void Fog_Force()
+ {
+       // TODO somehow thwart prvm_globalset client ...
+       if(autocvar_cl_orthoview && autocvar_cl_orthoview_nofog)
+               { localcmd("\nr_drawfog 0\n"); }
+       else if(forcefog != "")
+               { localcmd(strcat(notranslate_fogcmd1, forcefog, notranslate_fogcmd2)); }
+ }
+ void Gamemode_Init();
+ void Ent_ScoresInfo()
+ {
+     int i;
+       self.classname = "ent_client_scores_info";
+       gametype = ReadInt24_t();
+       HUD_ModIcons_SetFunc();
+       for(i = 0; i < MAX_SCORE; ++i)
+       {
+               if(scores_label[i])
+                       strunzone(scores_label[i]);
+               scores_label[i] = strzone(ReadString());
+               scores_flags[i] = ReadByte();
+       }
+       for(i = 0; i < MAX_TEAMSCORE; ++i)
+       {
+               if(teamscores_label[i])
+                       strunzone(teamscores_label[i]);
+               teamscores_label[i] = strzone(ReadString());
+               teamscores_flags[i] = ReadByte();
+       }
+       HUD_InitScores();
+       Gamemode_Init();
+ }
+ void Ent_Init()
+ {
+       self.classname = "ent_client_init";
+       nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
+       hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
+       hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
+       hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
+       hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
+       arc_shotorigin[0] = decompressShotOrigin(ReadInt24_t());
+       arc_shotorigin[1] = decompressShotOrigin(ReadInt24_t());
+       arc_shotorigin[2] = decompressShotOrigin(ReadInt24_t());
+       arc_shotorigin[3] = decompressShotOrigin(ReadInt24_t());
+       if(forcefog)
+               strunzone(forcefog);
+       forcefog = strzone(ReadString());
+       armorblockpercent = ReadByte() / 255.0;
+       g_balance_mortar_bouncefactor = ReadCoord();
+       g_balance_mortar_bouncestop = ReadCoord();
+       g_balance_electro_secondary_bouncefactor = ReadCoord();
+       g_balance_electro_secondary_bouncestop = ReadCoord();
+       vortex_scope = !ReadByte();
+       rifle_scope = !ReadByte();
+       serverflags = ReadByte();
+       minelayer_maxmines = ReadByte();
+       hagar_maxrockets = ReadByte();
+       g_trueaim_minrange = ReadCoord();
+       g_balance_porto_secondary = ReadByte();
+       if(!postinit)
+               PostInit();
+ }
+ void Net_ReadRace()
+ {
+       float b;
+       b = ReadByte();
+       switch(b)
+       {
+               case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
+                       race_checkpoint = ReadByte();
+                       race_time = ReadInt24_t();
+                       race_previousbesttime = ReadInt24_t();
+                       if(race_previousbestname)
+                               strunzone(race_previousbestname);
+                       race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
+                       race_checkpointtime = time;
+                       if(race_checkpoint == 0 || race_checkpoint == 254)
+                       {
+                               race_penaltyaccumulator = 0;
+                               race_laptime = time; // valid
+                       }
+                       break;
+               case RACE_NET_CHECKPOINT_CLEAR:
+                       race_laptime = 0;
+                       race_checkpointtime = 0;
+                       break;
+               case RACE_NET_CHECKPOINT_NEXT_SPEC_QUALIFYING:
+                       race_laptime = ReadCoord();
+                       race_checkpointtime = -99999;
+                       // fall through
+               case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
+                       race_nextcheckpoint = ReadByte();
+                       race_nextbesttime = ReadInt24_t();
+                       if(race_nextbestname)
+                               strunzone(race_nextbestname);
+                       race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
+                       break;
+               case RACE_NET_CHECKPOINT_HIT_RACE:
+                       race_mycheckpoint = ReadByte();
+                       race_mycheckpointtime = time;
+                       race_mycheckpointdelta = ReadInt24_t();
+                       race_mycheckpointlapsdelta = ReadByte();
+                       if(race_mycheckpointlapsdelta >= 128)
+                               race_mycheckpointlapsdelta -= 256;
+                       if(race_mycheckpointenemy)
+                               strunzone(race_mycheckpointenemy);
+                       race_mycheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
+                       break;
+               case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
+                       race_othercheckpoint = ReadByte();
+                       race_othercheckpointtime = time;
+                       race_othercheckpointdelta = ReadInt24_t();
+                       race_othercheckpointlapsdelta = ReadByte();
+                       if(race_othercheckpointlapsdelta >= 128)
+                               race_othercheckpointlapsdelta -= 256;
+                       if(race_othercheckpointenemy)
+                               strunzone(race_othercheckpointenemy);
+                       race_othercheckpointenemy = strzone(ColorTranslateRGB(ReadString()));
+                       break;
+               case RACE_NET_PENALTY_RACE:
+                       race_penaltyeventtime = time;
+                       race_penaltytime = ReadShort();
+                       //race_penaltyaccumulator += race_penaltytime;
+                       if(race_penaltyreason)
+                               strunzone(race_penaltyreason);
+                       race_penaltyreason = strzone(ReadString());
+                       break;
+               case RACE_NET_PENALTY_QUALIFYING:
+                       race_penaltyeventtime = time;
+                       race_penaltytime = ReadShort();
+                       race_penaltyaccumulator += race_penaltytime;
+                       if(race_penaltyreason)
+                               strunzone(race_penaltyreason);
+                       race_penaltyreason = strzone(ReadString());
+                       break;
+               case RACE_NET_SERVER_RECORD:
+                       race_server_record = ReadInt24_t();
+                       break;
+               case RACE_NET_SPEED_AWARD:
+                       race_speedaward = ReadInt24_t();
+                       if(race_speedaward_holder)
+                               strunzone(race_speedaward_holder);
+                       race_speedaward_holder = strzone(ReadString());
+                       break;
+               case RACE_NET_SPEED_AWARD_BEST:
+                       race_speedaward_alltimebest = ReadInt24_t();
+                       if(race_speedaward_alltimebest_holder)
+                               strunzone(race_speedaward_alltimebest_holder);
+                       race_speedaward_alltimebest_holder = strzone(ReadString());
+                       break;
+               case RACE_NET_SERVER_RANKINGS:
+                       float prevpos, del;
+             int pos = ReadShort();
+                       prevpos = ReadShort();
+                       del = ReadShort();
+                       // move other rankings out of the way
+             int i;
+                       if (prevpos) {
+                               for (i=prevpos-1;i>pos-1;--i) {
+                                       grecordtime[i] = grecordtime[i-1];
+                                       if(grecordholder[i])
+                                               strunzone(grecordholder[i]);
+                                       grecordholder[i] = strzone(grecordholder[i-1]);
+                               }
+                       } else if (del) { // a record has been deleted by the admin
+                               for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
+                                       if (i == RANKINGS_CNT-1) { // clear out last record
+                                               grecordtime[i] = 0;
+                                               if (grecordholder[i])
+                                                       strunzone(grecordholder[i]);
+                                               grecordholder[i] = string_null;
+                                       }
+                                       else {
+                                               grecordtime[i] = grecordtime[i+1];
+                                               if (grecordholder[i])
+                                                       strunzone(grecordholder[i]);
+                                               grecordholder[i] = strzone(grecordholder[i+1]);
+                                       }
+                               }
+                       } else { // player has no ranked record yet
+                               for (i=RANKINGS_CNT-1;i>pos-1;--i) {
+                                       grecordtime[i] = grecordtime[i-1];
+                                       if(grecordholder[i])
+                                               strunzone(grecordholder[i]);
+                                       grecordholder[i] = strzone(grecordholder[i-1]);
+                               }
+                       }
+                       // store new ranking
+                       if(grecordholder[pos-1] != "")
+                               strunzone(grecordholder[pos-1]);
+                       grecordholder[pos-1] = strzone(ReadString());
+                       grecordtime[pos-1] = ReadInt24_t();
+                       if(grecordholder[pos-1] == GetPlayerName(player_localnum))
+                               race_myrank = pos;
+                       break;
+               case RACE_NET_SERVER_STATUS:
+                       race_status = ReadShort();
+                       if(race_status_name)
+                               strunzone(race_status_name);
+                       race_status_name = strzone(ReadString());
+       }
+ }
+ void Net_TeamNagger()
+ {
+       teamnagger = 1;
+ }
+ void Net_ReadPingPLReport()
+ {
+       int e, pi, pl, ml;
+       e = ReadByte();
+       pi = ReadShort();
+       pl = ReadByte();
+       ml = ReadByte();
+       if (!(playerslots[e]))
+               return;
+       playerslots[e].ping = pi;
+       playerslots[e].ping_packetloss = pl / 255.0;
+       playerslots[e].ping_movementloss = ml / 255.0;
+ }
+ void Net_WeaponComplain()
+ {
+       complain_weapon = ReadByte();
+       if(complain_weapon_name)
+               strunzone(complain_weapon_name);
+       complain_weapon_name = strzone(WEP_NAME(complain_weapon));
+       complain_weapon_type = ReadByte();
+       complain_weapon_time = time;
+       weapontime = time; // ping the weapon panel
+       switch(complain_weapon_type)
+       {
+               case 0: Local_Notification(MSG_MULTI, ITEM_WEAPON_NOAMMO, complain_weapon); break;
+               case 1: Local_Notification(MSG_MULTI, ITEM_WEAPON_DONTHAVE, complain_weapon); break;
+               default: Local_Notification(MSG_MULTI, ITEM_WEAPON_UNAVAILABLE, complain_weapon); break;
+       }
+ }
+ // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
+ // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
+ // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
+ float CSQC_Parse_TempEntity()
+ {
+       float bHandled;
+               bHandled  = true;
+       // Acquire TE ID
+       float nTEID;
+               nTEID = ReadByte();
+       if(autocvar_developer_csqcentities)
+               printf("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
+               // NOTE: Could just do return instead of break...
+       switch(nTEID)
+       {
+               case TE_CSQC_TARGET_MUSIC:
+                       Net_TargetMusic();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_PICTURE:
+                       Net_MapVote_Picture();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_RACE:
+                       Net_ReadRace();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_VORTEXBEAMPARTICLE:
+                       Net_ReadVortexBeamParticle();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_TEAMNAGGER:
+                       Net_TeamNagger();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_ARC:
+                       Net_ReadArc();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_PINGPLREPORT:
+                       Net_ReadPingPLReport();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_WEAPONCOMPLAIN:
+                       Net_WeaponComplain();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_VEHICLESETUP:
+                       Net_VehicleSetup();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_SVNOTICE:
+                       cl_notice_read();
+                       bHandled = true;
+                       break;
+               case TE_CSQC_SHOCKWAVEPARTICLE:
+                       Net_ReadShockwaveParticle();
+                       bHandled = true;
+                       break;
+               default:
+                       // No special logic for this temporary entity; return 0 so the engine can handle it
+                       bHandled = false;
+                       break;
+       }
+       return bHandled;
+ }
+ string getcommandkey(string text, string command)
+ {
+       string keys;
+       float n, j, k, l = 0;
+       if (!autocvar_hud_showbinds)
+               return text;
+       keys = db_get(binddb, command);
+       if (keys == "")
+       {
+               n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
+               for(j = 0; j < n; ++j)
+               {
+                       k = stof(argv(j));
+                       if(k != -1)
+                       {
+                               if ("" == keys)
+                                       keys = keynumtostring(k);
+                               else
+                                       keys = strcat(keys, ", ", keynumtostring(k));
+                               ++l;
+                               if (autocvar_hud_showbinds_limit > 0 && autocvar_hud_showbinds_limit <= l)
+                                       break;
+                       }
+               }
+               if (keys == "")
+                       keys = "NO_KEY";
+               db_put(binddb, command, keys);
+       }
+       if (keys == "NO_KEY") {
+               if (autocvar_hud_showbinds > 1)
+                       return sprintf(_("%s (not bound)"), text);
+               else
+                       return text;
+       }
+       else if (autocvar_hud_showbinds > 1)
+               return sprintf("%s (%s)", text, keys);
+       else
+               return keys;
+ }
diff --combined qcsrc/client/main.qh
index ce4f09a44596f67387b8a38ea27ec26be6d888c6,b8823e6296d4de67aed98f1f2da417aa00ff0381..bf0bb74b0c0ab2fffd46441ddaa6ce1a1decb6b1
@@@ -1,7 -1,10 +1,10 @@@
+ #ifndef MAIN_H
+ #define MAIN_H
  // --------------------------------------------------------------------------
  // MENU Functionality
  
- #define DATABUF_PING 0
+ const float DATABUF_PING = 0;
  #define DATABUF_CAPTURES (1*maxclients)
  #define DATABUF_DEATHS (2*maxclients)
  #define DATABUF_RETURNS (3*maxclients)
@@@ -27,7 -30,6 +30,6 @@@ string minimapname
  // --------------------------------------------------------------------------
  // General stuff
  
- float drawfont;
  float postinit;
  float gametype;
  
  //.float ctf_state;
  //.float health;
  
- #define FONT_DEFAULT 0
- #define FONT_USER 8
+ float FONT_USER = 8;
  
  // --------------------------------------------------------------------------
  // Scoreboard stuff
  
- #define MAX_HUD_FIELDS 16
+ const int MAX_HUD_FIELDS = 16;
  
- #define SP_END -1
+ const int SP_END = -1;
  
- #define SP_PING -2
- #define SP_NAME -3
- #define SP_KDRATIO -4
- #define SP_CLRATIO -5
- #define SP_PL -6
- #define SP_FRAGS -7
- #define SP_SUM -8
+ const int SP_PING = -2;
+ const int SP_NAME = -3;
+ const int SP_KDRATIO = -4;
+ const int SP_CLRATIO = -5;
+ const int SP_PL = -6;
+ const int SP_FRAGS = -7;
+ const int SP_SUM = -8;
  
- #define SP_SEPARATOR -100
+ const int SP_SEPARATOR = -100;
  
  float hud_field[MAX_HUD_FIELDS + 1];
  float hud_size[MAX_HUD_FIELDS + 1];
  string hud_title[MAX_HUD_FIELDS + 1];
float hud_num_fields;
int hud_num_fields;
  
  string scores_label[MAX_SCORE];
float scores_flags[MAX_SCORE];
int scores_flags[MAX_SCORE];
  string teamscores_label[MAX_SCORE];
float teamscores_flags[MAX_SCORE];
- .float scores[MAX_SCORE];
int teamscores_flags[MAX_SCORE];
+ .int scores[MAX_SCORE];
  .float teamscores[MAX_TEAMSCORE];
  
  #define IS_INCREASING(x) ( (x)&SFL_LOWER_IS_BETTER )
@@@ -86,20 -87,21 +87,21 @@@ entity teamslots[17];    // 17 teams (i
  .float gotscores;
  .entity owner;
  .float ready;
+ .float eliminated;
  
  .void(void) draw;
  .void(void) draw2d;
  .void(void) entremove;
  float drawframetime;
- vector view_origin, view_angles, view_forward, view_right, view_up;
+ vector view_origin, view_forward, view_right, view_up;
  
  float button_zoom;
  float spectatorbutton_zoom;
  float button_attack2;
  
float activeweapon;
float switchingweapon;
float switchweapon;
int activeweapon;
int switchingweapon;
int switchweapon;
  float current_viewzoom;
  float zoomin_effect;
  float warmup_stage;
@@@ -117,7 -119,7 +119,7 @@@ float current_zoomfraction
  float cs_project_is_b0rked;
  float vid_width, vid_height, vid_pixelheight;
  
- float camera_active;          // Demo camera is active if set to TRUE
+ float camera_active;          // Demo camera is active if set to true
  float chase_active_backup;
  float camera_roll;
  vector camera_direction;
  void centerprint_hud(string strMessage);
  void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num);
  
- #define ALPHA_MIN_VISIBLE 0.003
+ const float ALPHA_MIN_VISIBLE = 0.003;
  
  float armorblockpercent;
  
  //hooks
float calledhooks;
- #define HOOK_START    1
- #define HOOK_END      2
int calledhooks;
+ const int HOOK_START =    1;
+ const int HOOK_END =      2;
  
  .float ping, ping_packetloss, ping_movementloss;
  
- float g_balance_grenadelauncher_bouncefactor;
- float g_balance_grenadelauncher_bouncestop;
+ float g_balance_mortar_bouncefactor;
+ float g_balance_mortar_bouncestop;
  float g_balance_electro_secondary_bouncefactor;
  float g_balance_electro_secondary_bouncestop;
  float g_trueaim_minrange;
@@@ -146,8 -148,5 +148,10 @@@ entity entcs_receiver[255]; // 255 is t
  
  float hud;
  float view_quality;
- float framecount;
 +
- float num_spectators;
- #define MAX_SPECTATORS 7
- float spectatorlist[MAX_SPECTATORS];
++int num_spectators;
++const int MAX_SPECTATORS = 7;
++int spectatorlist[MAX_SPECTATORS];
++
+ int framecount;
+ #endif
index 8bc0e458950b09b8de619e07d445eda3133fbb5f,3bc5cc762f231b2e92f8df7dfdfe4b05e9d55bb1..fe12ffc0393134d27b7311ec0b612e562bc98a0f
@@@ -1,17 -1,41 +1,72 @@@
- void race_send_recordtime(float msg);
- void race_SendRankings(float pos, float prevpos, float del, float msg);
+ #include "waypointsprites.qh"
+ #include "cl_impulse.qh"
+ #include "cl_player.qh"
+ #include "ent_cs.qh"
+ #include "g_subs.qh"
+ #include "ipban.qh"
+ #include "miscfunctions.qh"
+ #include "portals.qh"
+ #include "teamplay.qh"
+ #include "playerdemo.qh"
+ #include "secret.qh"
+ #include "bot/bot.qh"
+ #include "bot/navigation.qh"
+ #include "weapons/hitplot.qh"
+ #include "weapons/weaponsystem.qh"
+ #include "../common/net_notice.qh"
+ #include "../common/monsters/sv_monsters.qh"
+ #include "../warpzonelib/server.qh"
+ float c1, c2, c3, c4;
  
  void send_CSQC_teamnagger() {
        WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
        WriteByte(MSG_BROADCAST, TE_CSQC_TEAMNAGGER);
  }
  
- float ClientData_Send(entity to, float sf)
 -float ClientData_Send(entity to, int sf)
++int CountSpectators(entity player, entity to)
++{
++      if(!player) { return 0; } // not sure how, but best to be safe
++
++      entity head;
++      float spec_count = 0;
++      FOR_EACH_REALCLIENT(head)
++      {
++              if(IS_SPEC(head))
++              if(head != to)
++              if(head.enemy == player)
++                      spec_count += 1;
++      }
++
++      return spec_count;
++}
++
++void WriteSpectators(entity player, entity to)
++{
++      if(!player) { return; } // not sure how, but best to be safe
++
++      entity head;
++      FOR_EACH_REALCLIENT(head)
++      {
++              if(IS_SPEC(head))
++              if(head != to)
++              if(head.enemy == player)
++                      WriteByte(MSG_ENTITY, num_for_edict(head));
++      }
++}
++
++bool ClientData_Send(entity to, int sf)
  {
        if(to != self.owner)
        {
                error("wtf");
-               return FALSE;
+               return false;
        }
  
        entity e;
@@@ -30,6 -54,6 +85,8 @@@
                sf |= 4; // zoomed
        if(e.porto_v_angle_held)
                sf |= 8; // angles held
++      // always check spectators
++      sf |= 16; // spectator handling?
  
        WriteByte(MSG_ENTITY, ENT_CLIENT_CLIENTDATA);
        WriteByte(MSG_ENTITY, sf);
  
        if(sf & 8)
        {
-               WriteAngle(MSG_ENTITY, e.v_angle_x);
-               WriteAngle(MSG_ENTITY, e.v_angle_y);
+               WriteAngle(MSG_ENTITY, e.v_angle.x);
+               WriteAngle(MSG_ENTITY, e.v_angle.y);
+       }
++      if(sf & 16)
++      {
++              float specs = CountSpectators(e, to);
++              WriteByte(MSG_ENTITY, specs);
++              WriteSpectators(e, to);
 +      }
 +
-       return TRUE;
+       return true;
  }
  
  void ClientData_Attach()
  {
-       Net_LinkEntity(self.clientdata = spawn(), FALSE, 0, ClientData_Send);
+       Net_LinkEntity(self.clientdata = spawn(), false, 0, ClientData_Send);
        self.clientdata.drawonlytoclient = self;
        self.clientdata.owner = self;
  }
@@@ -76,6 -100,8 +140,8 @@@ void ClientData_Touch(entity e
  
  .string netname_previous;
  
+ void SetSpectator(entity player, entity spectatee);
  
  /*
  =============
@@@ -136,14 -162,14 +202,17 @@@ putting a client as observer in the ser
  =============
  */
  void FixPlayermodel();
- void UpdateSpectators(entity is_spec, entity is_player);
  void PutObserverInServer (void)
  {
--      entity  spot;
++      entity spot;
++
++      SetSpectator(self, world);
++
      self.hud = HUD_NORMAL;
-       race_PreSpawnObserver();
  
-       spot = SelectSpawnPoint (TRUE);
+       if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); }
+       spot = SelectSpawnPoint (true);
        if(!spot)
                error("No spawnpoints for observers?!?\n");
        RemoveGrapplingHook(self); // Wazat's Grappling Hook
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, self);
        }
-       
-       UpdateSpectators(self, self); // don't update spectators or spectatees
  
-       if((g_race && g_race_qualifying) || g_cts)
-       {
-               if(PlayerScore_Add(self, SP_RACE_FASTEST, 0))
-                       self.frags = FRAGS_LMS_LOSER;
-               else
-                       self.frags = FRAGS_SPECTATOR;
-       }
-       else
-               self.frags = FRAGS_SPECTATOR;
+       self.frags = FRAGS_SPECTATOR;
  
        MUTATOR_CALLHOOK(MakePlayerObserver);
  
        Portal_ClearAll(self);
  
+       Unfreeze(self);
        if(self.alivetime)
        {
                if(!warmup_stage)
-                       PlayerStats_Event(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
+                       PS_GR_P_ADDVAL(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
                self.alivetime = 0;
        }
  
                if(autocvar_g_chat_nospectators == 1 || (cvar("g_warmup") && !(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS);
  
-               if(self.just_joined == FALSE) {
+               if(self.just_joined == false) {
                        LogTeamchange(self.playerid, -1, 4);
                } else
-                       self.just_joined = FALSE;
+                       self.just_joined = false;
        }
  
        PlayerScore_Clear(self); // clear scores when needed
        self.spectatortime = time;
  
        self.classname = "observer";
-       self.iscreature = FALSE;
+       self.iscreature = false;
        self.teleportable = TELEPORT_SIMPLE;
-       self.damagedbycontents = FALSE;
+       self.damagedbycontents = false;
        self.health = -666;
        self.takedamage = DAMAGE_NO;
        self.solid = SOLID_NOT;
        self.deadflag = DEAD_NO;
        self.angles = spot.angles;
        self.angles_z = 0;
-       self.fixangle = TRUE;
-       self.crouch = FALSE;
+       self.fixangle = true;
+       self.crouch = false;
+       self.revival_time = 0;
  
        setorigin (self, (spot.origin + PL_VIEW_OFS)); // offset it so that the spectator spawns higher off the ground, looks better this way
        self.prevorigin = self.origin;
        self.punchvector = '0 0 0';
        self.oldvelocity = self.velocity;
        self.fire_endtime = -1;
+       self.event_damage = func_null;
  }
  
  .float model_randomizer;
@@@ -279,14 -299,14 +342,14 @@@ void FixPlayermodel(
  
        defaultmodel = "";
        defaultskin = 0;
-       chmdl = FALSE;
+       chmdl = false;
  
        if(autocvar_sv_defaultcharacter == 1)
        {
                if(teamplay)
                {
                        string s;
-                       s = Team_ColorName_Lower(self.team);
+                       s = Static_Team_ColorName_Lower(self.team);
                        if(s != "neutral")
                        {
                                defaultmodel = cvar_string(strcat("sv_defaultplayermodel_", s));
                        m2 = self.maxs;
                        setplayermodel (self, defaultmodel);
                        setsize (self, m1, m2);
-                       chmdl = TRUE;
+                       chmdl = true;
                }
  
                oldskin = self.skin;
                        m2 = self.maxs;
                        setplayermodel (self, self.playermodel);
                        setsize (self, m1, m2);
-                       chmdl = TRUE;
+                       chmdl = true;
                }
  
                oldskin = self.skin;
@@@ -376,6 -396,8 +439,8 @@@ void PutClientInServer (void
                WriteEntity(MSG_ONE, self);
        }
  
+       SetSpectator(self, world);
        // reset player keys
        self.itemkeys = 0;
  
                accuracy_resend(self);
  
                if(self.team < 0)
-                       JoinBestTeam(self, FALSE, TRUE);
+                       JoinBestTeam(self, false, true);
  
-               race_PreSpawn();
-               spot = SelectSpawnPoint (FALSE);
+               spot = SelectSpawnPoint (false);
                if(!spot)
                {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
                        vehicles_exit(VHEF_RELESE);
  
                self.classname = "player";
-               self.wasplayer = TRUE;
-               self.iscreature = TRUE;
+               self.wasplayer = true;
+               self.iscreature = true;
                self.teleportable = TELEPORT_NORMAL;
-               self.damagedbycontents = TRUE;
+               self.damagedbycontents = true;
                self.movetype = MOVETYPE_WALK;
                self.solid = SOLID_SLIDEBOX;
                self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
                self.effects |= EF_TELEPORT_BIT | EF_RESTARTANIM_BIT;
                self.air_finished = time + 12;
                self.dmg = 2;
-               if(autocvar_g_balance_nex_charge)
+               if(WEP_CVAR(vortex, charge))
                {
-                       if(autocvar_g_balance_nex_secondary_chargepool)
-                               self.nex_chargepool_ammo = 1;
-                       self.nex_charge = autocvar_g_balance_nex_charge_start;
+                       if(WEP_CVAR_SEC(vortex, chargepool))
+                               self.vortex_chargepool_ammo = 1;
+                       self.vortex_charge = WEP_CVAR(vortex, charge_start);
                }
  
                if(warmup_stage)
                        self.ammo_nails = warmup_start_ammo_nails;
                        self.ammo_rockets = warmup_start_ammo_rockets;
                        self.ammo_cells = warmup_start_ammo_cells;
+                       self.ammo_plasma = warmup_start_ammo_plasma;
                        self.ammo_fuel = warmup_start_ammo_fuel;
                        self.health = warmup_start_health;
                        self.armorvalue = warmup_start_armorvalue;
                        self.ammo_nails = start_ammo_nails;
                        self.ammo_rockets = start_ammo_rockets;
                        self.ammo_cells = start_ammo_cells;
+                       self.ammo_plasma = start_ammo_plasma;
                        self.ammo_fuel = start_ammo_fuel;
                        self.health = start_health;
                        self.armorvalue = start_armorvalue;
                else
                        self.superweapons_finished = 0;
  
-               if(g_weaponarena_random)
+               if(g_weaponarena_random) // WEAPONTODO: more stuff that should be in a mutator. also: rename those cvars
                {
-                       if(g_weaponarena_random_with_laser)
-                               self.weapons &= ~WEPSET_LASER;
+                       if(g_weaponarena_random_with_blaster)
+                               self.weapons &= ~WEPSET_BLASTER;
                        W_RandomWeapons(self, g_weaponarena_random);
-                       if(g_weaponarena_random_with_laser)
-                               self.weapons |= WEPSET_LASER;
+                       if(g_weaponarena_random_with_blaster)
+                               self.weapons |= WEPSET_BLASTER;
                }
  
                self.items = start_items;
                self.angles = spot.angles;
  
                self.angles_z = 0; // never spawn tilted even if the spot says to
-               self.fixangle = TRUE; // turn this way immediately
+               if(IS_BOT_CLIENT(self))
+                       self.v_angle = self.angles;
+               self.fixangle = true; // turn this way immediately
                self.velocity = '0 0 0';
                self.avelocity = '0 0 0';
                self.punchangle = '0 0 0';
                self.punchvector = '0 0 0';
                self.oldvelocity = self.velocity;
                self.fire_endtime = -1;
+               self.revival_time = 0;
  
                entity spawnevent = spawn();
                spawnevent.owner = self;
-               Net_LinkEntity(spawnevent, FALSE, 0.5, SpawnEvent_Send);
+               Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send);
+               // Cut off any still running player sounds.
+               stopsound(self, CH_PLAYER_SINGLE);
  
                self.model = "";
                FixPlayermodel();
                self.drawonlytoclient = world;
  
-               self.crouch = FALSE;
+               self.crouch = false;
                self.view_ofs = PL_VIEW_OFS;
                setsize (self, PL_MIN, PL_MAX);
                self.spawnorigin = spot.origin;
-               setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24));
+               setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
                // don't reset back to last position, even if new position is stuck in solid
                self.oldorigin = self.origin;
                self.prevorigin = self.origin;
  
                self.event_damage = PlayerDamage;
  
-               self.bot_attack = TRUE;
-               self.monster_attack = TRUE;
-               
+               self.bot_attack = true;
+               self.monster_attack = true;
                self.spider_slowness = 0;
  
-               self.statdraintime = time + 5;
                self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = 0;
  
                if(self.killcount == -666) {
                self.colormod = '1 1 1' * autocvar_g_player_brightness;
                self.exteriorweaponentity.alpha = default_weapon_alpha;
  
-               self.speedrunning = FALSE;
-               race_PostSpawn(spot);
+               self.speedrunning = false;
  
                //stuffcmd(self, "chase_active 0");
                //stuffcmd(self, "set viewsize $tmpviewsize \n");
                // reset fields the weapons may use
                for (j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
-                       weapon_action(j, WR_RESETPLAYER);
+                       WEP_ACTION(j, WR_RESETPLAYER);
  
                        // all weapons must be fully loaded when we spawn
-                       entity e;
-                       e = get_weaponinfo(j);
+                       entity e = get_weaponinfo(j);
                        if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
-                               self.(weapon_load[j]) = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+                               self.(weapon_load[j]) = e.reloading_ammo;
                }
  
                oldself = self;
                        activator = world;
                self = oldself;
  
+               Unfreeze(self);
                spawn_spot = spot;
                MUTATOR_CALLHOOK(PlayerSpawn);
  
        {
                PutObserverInServer ();
        }
-       
-       UpdateSpectators(((IS_PLAYER(self)) ? world : self), ((IS_SPEC(self) || IS_OBSERVER(self)) ? self : world));
  }
  
  .float ebouncefactor, ebouncestop; // electro's values
@@@ -635,31 -659,28 +702,28 @@@ float ClientInit_SendEntity(entity to, 
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[1]));
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[2]));
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[3]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[0]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[1]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[2]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[3]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[0]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[1]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[2]));
-       WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[3]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(arc_shotorigin[0]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(arc_shotorigin[1]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(arc_shotorigin[2]));
+       WriteInt24_t(MSG_ENTITY, compressShotOrigin(arc_shotorigin[3]));
        if(sv_foginterval && world.fog != "")
                WriteString(MSG_ENTITY, world.fog);
        else
                WriteString(MSG_ENTITY, "");
        WriteByte(MSG_ENTITY, self.count * 255.0); // g_balance_armor_blockpercent
-       WriteCoord(MSG_ENTITY, self.bouncefactor); // g_balance_grenadelauncher_bouncefactor
-       WriteCoord(MSG_ENTITY, self.bouncestop); // g_balance_grenadelauncher_bouncestop
-       WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_grenadelauncher_bouncefactor
-       WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_grenadelauncher_bouncestop
-       WriteByte(MSG_ENTITY, autocvar_g_balance_nex_secondary); // client has to know if it should zoom or not
-       WriteByte(MSG_ENTITY, autocvar_g_balance_rifle_secondary); // client has to know if it should zoom or not
+       WriteCoord(MSG_ENTITY, self.bouncefactor); // g_balance_mortar_bouncefactor // WEAPONTODO
+       WriteCoord(MSG_ENTITY, self.bouncestop); // g_balance_mortar_bouncestop
+       WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_mortar_bouncefactor
+       WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_mortar_bouncestop
+       WriteByte(MSG_ENTITY, WEP_CVAR(vortex, secondary)); // client has to know if it should zoom or not // WEAPONTODO
+       WriteByte(MSG_ENTITY, WEP_CVAR(rifle, secondary)); // client has to know if it should zoom or not // WEAPONTODO
        WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
-       WriteByte(MSG_ENTITY, autocvar_g_balance_minelayer_limit); // minelayer max mines
-       WriteByte(MSG_ENTITY, autocvar_g_balance_hagar_secondary_load_max); // hagar max loadable rockets
+       WriteByte(MSG_ENTITY, WEP_CVAR(minelayer, limit)); // minelayer max mines // WEAPONTODO
+       WriteByte(MSG_ENTITY, WEP_CVAR_SEC(hagar, load_max)); // hagar max loadable rockets // WEAPONTODO
        WriteCoord(MSG_ENTITY, autocvar_g_trueaim_minrange);
-       WriteByte(MSG_ENTITY, autocvar_g_balance_porto_secondary);
-       return TRUE;
+       WriteByte(MSG_ENTITY, WEP_CVAR(porto, secondary)); // WEAPONTODO
+       return true;
  }
  
  void ClientInit_CheckUpdate()
                self.count = autocvar_g_balance_armor_blockpercent;
                self.SendFlags |= 1;
        }
-       if(self.bouncefactor != autocvar_g_balance_grenadelauncher_bouncefactor)
+       if(self.bouncefactor != autocvar_g_balance_mortar_bouncefactor) // WEAPONTODO
        {
-               self.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
+               self.bouncefactor = autocvar_g_balance_mortar_bouncefactor;
                self.SendFlags |= 1;
        }
-       if(self.bouncestop != autocvar_g_balance_grenadelauncher_bouncestop)
+       if(self.bouncestop != autocvar_g_balance_mortar_bouncestop)
        {
-               self.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
+               self.bouncestop = autocvar_g_balance_mortar_bouncestop;
                self.SendFlags |= 1;
        }
        if(self.ebouncefactor != autocvar_g_balance_electro_secondary_bouncefactor)
@@@ -699,7 -720,7 +763,7 @@@ void ClientInit_Spawn(
        e = spawn();
        e.classname = "clientinit";
        e.think = ClientInit_CheckUpdate;
-       Net_LinkEntity(e, FALSE, 0, ClientInit_SendEntity);
+       Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
  
        o = self;
        self = e;
@@@ -758,7 -779,7 +822,7 @@@ void ClientKill_Now_TeamChange(
  {
        if(self.killindicator_teamchange == -1)
        {
-               JoinBestTeam( self, FALSE, TRUE );
+               JoinBestTeam( self, false, true );
        }
        else if(self.killindicator_teamchange == -2)
        {
@@@ -791,8 -812,8 +855,8 @@@ void ClientKill_Now(
        if(self.killindicator_teamchange)
                ClientKill_Now_TeamChange();
  
-       // in any case:
-       Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
+       if(IS_PLAYER(self))
+               Damage(self, self, self, 100000, DEATH_KILL, self.origin, '0 0 0');
  
        // now I am sure the player IS dead
  }
@@@ -946,7 -967,7 +1010,7 @@@ void ClientKill (void
  {
        if(gameover) return;
        if(self.player_blocked) return;
-       if(self.freezetag_frozen) return;
+       if(self.frozen) return;
  
        ClientKill_TeamChange(0);
  }
@@@ -972,23 -993,6 +1036,6 @@@ void FixClientCvars(entity e
                stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
        if(autocvar_sv_gentle)
                stuffcmd(e, "cl_cmd settemp cl_gentle 1\n");
-       /*
-        * we no longer need to stuff this. Remove this comment block if you feel
-        * 2.3 and higher (or was it 2.2.3?) don't need these any more
-       stuffcmd(e, strcat("cl_gravity ", ftos(autocvar_sv_gravity), "\n"));
-       stuffcmd(e, strcat("cl_movement_accelerate ", ftos(autocvar_sv_accelerate), "\n"));
-       stuffcmd(e, strcat("cl_movement_friction ", ftos(autocvar_sv_friction), "\n"));
-       stuffcmd(e, strcat("cl_movement_maxspeed ", ftos(autocvar_sv_maxspeed), "\n"));
-       stuffcmd(e, strcat("cl_movement_airaccelerate ", ftos(autocvar_sv_airaccelerate), "\n"));
-       stuffcmd(e, strcat("cl_movement_maxairspeed ", ftos(autocvar_sv_maxairspeed), "\n"));
-       stuffcmd(e, strcat("cl_movement_stopspeed ", ftos(autocvar_sv_stopspeed), "\n"));
-       stuffcmd(e, strcat("cl_movement_jumpvelocity ", ftos(autocvar_sv_jumpvelocity), "\n"));
-       stuffcmd(e, strcat("cl_movement_stepheight ", ftos(autocvar_sv_stepheight), "\n"));
-       stuffcmd(e, strcat("set cl_movement_friction_on_land ", ftos(autocvar_sv_friction_on_land), "\n"));
-       stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(autocvar_sv_airaccel_qw), "\n"));
-       stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(autocvar_sv_airaccel_sideways_friction), "\n"));
-       stuffcmd(e, "cl_movement_edgefriction 1\n");
-        */
  }
  
  float PlayerInIDList(entity p, string idlist)
        float n, i;
        string s;
  
-       // NOTE: we do NOT check crypto_keyfp here, an unsigned ID is fine too for this
+       // NOTE: we do NOT check crypto_idfp_signed here, an unsigned ID is fine too for this
        if (!p.crypto_idfp)
                return 0;
  
        return 0;
  }
  
+ #ifdef DP_EXT_PRECONNECT
+ /*
+ =============
+ ClientPreConnect
+ Called once (not at each match start) when a client begins a connection to the server
+ =============
+ */
+ void ClientPreConnect (void)
+ {
+       if(autocvar_sv_eventlog)
+       {
+               GameLogEcho(sprintf(":connect:%d:%d:%s",
+                       self.playerid,
+                       num_for_edict(self),
+                       ((IS_REAL_CLIENT(self)) ? self.netaddress : "bot")
+               ));
+       }
+ }
+ #endif
  /*
  =============
  ClientConnect
@@@ -1052,6 -1077,8 +1120,8 @@@ void ClientConnect (void
                player_count = 0;
        }
  
+       if(IS_REAL_CLIENT(self)) { PlayerStats_PlayerBasic_CheckUpdate(self); }
        PlayerScore_Attach(self);
        ClientData_Attach();
        accuracy_init(self);
  
        anticheat_init();
  
-       race_PreSpawnObserver();
        // identify the right forced team
        if(autocvar_g_campaign)
        {
                if(self.team_forced > 0)
                        self.team_forced = 0;
  
-       JoinBestTeam(self, FALSE, FALSE); // if the team number is valid, keep it
+       JoinBestTeam(self, false, false); // if the team number is valid, keep it
  
        if((autocvar_sv_spectate == 1) || autocvar_g_campaign || self.team_forced < 0) {
                self.classname = "observer";
  
        self.playerid = (playerid_last = playerid_last + 1);
  
-       PlayerStats_AddEvent(sprintf("kills-%d", self.playerid));
+       PlayerStats_GameReport_AddEvent(sprintf("kills-%d", self.playerid));
  
      if(IS_BOT_CLIENT(self))
-         PlayerStats_AddPlayer(self);
+         PlayerStats_GameReport_AddPlayer(self);
  
        if(autocvar_sv_eventlog)
                GameLogEcho(strcat(":join:", ftos(self.playerid), ":", ftos(num_for_edict(self)), ":", ((IS_REAL_CLIENT(self)) ? self.netaddress : "bot"), ":", self.netname));
  
        LogTeamchange(self.playerid, self.team, 1);
  
-       self.just_joined = TRUE;  // stop spamming the eventlog with additional lines when the client connects
+       self.just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
  
        self.netname_previous = strzone(self.netname);
  
        // Wazat's grappling hook
        SetGrappleHookBindings();
  
+       // Jetpack binds
+       stuffcmd(self, "alias +jetpack +button10\n");
+       stuffcmd(self, "alias -jetpack -button10\n");
        // get version info from player
        stuffcmd(self, "cmd clientversion $gameversion\n");
  
        if(!sv_foginterval && world.fog != "")
                stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
  
-       if(autocvar_g_hitplots || strstrofs(strcat(" ", autocvar_g_hitplots_individuals, " "), strcat(" ", self.netaddress, " "), 0) >= 0)
-       {
-               self.hitplotfh = fopen(strcat("hits-", matchid, "-", self.netaddress, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
-               fputs(self.hitplotfh, strcat("#name ", self.netname, "\n"));
-       }
-       else
-               self.hitplotfh = -1;
-       if(g_race || g_cts) {
-               string rr;
-               if(g_cts)
-                       rr = CTS_RECORD;
-               else
-                       rr = RACE_RECORD;
+       W_HitPlotOpen(self);
  
-               msg_entity = self;
-               race_send_recordtime(MSG_ONE);
-               race_send_speedaward(MSG_ONE);
-               speedaward_alltimebest = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed")));
-               speedaward_alltimebest_holder = uid2name(db_get(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp")));
-               race_send_speedaward_alltimebest(MSG_ONE);
-               float i;
-               for (i = 1; i <= RANKINGS_CNT; ++i) {
-                       race_SendRankings(i, 0, 0, MSG_ONE);
-               }
-       }
-       else if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
+       if(autocvar_sv_teamnagger && !(autocvar_bot_vs_human && (c3==-1 && c4==-1)) && !g_ca && !g_cts && !g_race) // teamnagger is currently bad for ca, race & cts
                send_CSQC_teamnagger();
  
        CheatInitClient();
        if(IS_REAL_CLIENT(self))
                sv_notice_join();
  
+       for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
+               entity oldself = self;
+               self = e;
+               e.init_for_player(oldself);
+               self = oldself;
+       }
        MUTATOR_CALLHOOK(ClientConnect);
  }
  /*
@@@ -1259,8 -1269,6 +1312,6 @@@ Called when a client disconnects from t
  void ReadyCount();
  void ClientDisconnect (void)
  {
-       UpdateSpectators(self, world);
        if(self.vehicle)
            vehicles_exit(VHEF_RELESE);
  
                return;
        }
  
-       PlayerStats_AddGlobalInfo(self);
+       PlayerStats_GameReport_FinalizePlayer(self);
++      SetSpectator(self, world);
++
+       if(IS_PLAYER(self)) { pointparticles(particleeffectnum("spawn_event_neutral"), self.origin, '0 0 0', 1); }
  
        CheatShutdownClient();
  
-       if(self.hitplotfh >= 0)
-       {
-               fclose(self.hitplotfh);
-               self.hitplotfh = -1;
-       }
+       W_HitPlotClose(self);
  
        anticheat_report();
        anticheat_shutdown();
  
        Portal_ClearAll(self);
  
+       Unfreeze(self);
        RemoveGrapplingHook(self);
  
        // Here, everything has been done that requires this player to be a client.
@@@ -1373,7 -1381,7 +1426,7 @@@ void UpdateChatBubble(
                self.chatbubbleentity.nextthink = time;
                setmodel(self.chatbubbleentity, "models/misc/chatbubble.spr"); // precision set below
                //setorigin(self.chatbubbleentity, self.origin + '0 0 15' + self.maxs_z * '0 0 1');
-               setorigin(self.chatbubbleentity, '0 0 15' + self.maxs_z * '0 0 1');
+               setorigin(self.chatbubbleentity, '0 0 15' + self.maxs.z * '0 0 1');
                setattachment(self.chatbubbleentity, self, "");  // sticks to moving player better, also conserves bandwidth
                self.chatbubbleentity.mdl = self.chatbubbleentity.model;
                self.chatbubbleentity.model = "";
@@@ -1432,7 -1440,7 +1485,7 @@@ void player_powerups (void
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
        olditems = self.items;
  
-       if((self.items & IT_USING_JETPACK) && !self.deadflag)
+       if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover)
                self.modelflags |= MF_ROCKET;
        else
                self.modelflags &= ~MF_ROCKET;
        Fire_ApplyDamage(self);
        Fire_ApplyEffect(self);
  
-       if (!g_minstagib)
+       if (!g_instagib)
        {
                if (self.items & IT_STRENGTH)
                {
@@@ -1592,9 -1600,16 +1645,16 @@@ float CalcRotRegen(float current, floa
  
  void player_regen (void)
  {
+       float max_mod, regen_mod, rot_mod, limit_mod;
+       max_mod = regen_mod = rot_mod = limit_mod = 1;
+       regen_mod_max = max_mod;
+       regen_mod_regen = regen_mod;
+       regen_mod_rot = rot_mod;
+       regen_mod_limit = limit_mod;
        if(!MUTATOR_CALLHOOK(PlayerRegen))
+       if(!self.frozen)
        {
-               float minh, mina, maxh, maxa, limith, limita, max_mod, regen_mod, rot_mod, limit_mod;
+               float minh, mina, maxh, maxa, limith, limita;
                maxh = autocvar_g_balance_health_rotstable;
                maxa = autocvar_g_balance_armor_rotstable;
                minh = autocvar_g_balance_health_regenstable;
                limith = autocvar_g_balance_health_limit;
                limita = autocvar_g_balance_armor_limit;
  
-               max_mod = regen_mod = rot_mod = limit_mod = 1;
+               max_mod = regen_mod_max;
+               regen_mod = regen_mod_regen;
+               rot_mod = regen_mod_rot;
+               limit_mod = regen_mod_limit;
  
                maxh = maxh * max_mod;
                minh = minh * max_mod;
@@@ -1643,12 -1661,12 +1706,12 @@@ void SetZoomState(float z
  
  void GetPressedKeys(void) {
        MUTATOR_CALLHOOK(GetPressedKeys);
-       if (self.movement_x > 0) // get if movement keys are pressed
+       if (self.movement.x > 0) // get if movement keys are pressed
        {       // forward key pressed
                self.pressedkeys |= KEY_FORWARD;
                self.pressedkeys &= ~KEY_BACKWARD;
        }
-       else if (self.movement_x < 0)
+       else if (self.movement.x < 0)
        {       // backward key pressed
                self.pressedkeys |= KEY_BACKWARD;
                self.pressedkeys &= ~KEY_FORWARD;
                self.pressedkeys &= ~KEY_BACKWARD;
        }
  
-       if (self.movement_y > 0)
+       if (self.movement.y > 0)
        {       // right key pressed
                self.pressedkeys |= KEY_RIGHT;
                self.pressedkeys &= ~KEY_LEFT;
        }
-       else if (self.movement_y < 0)
+       else if (self.movement.y < 0)
        {       // left key pressed
                self.pressedkeys |= KEY_LEFT;
                self.pressedkeys &= ~KEY_RIGHT;
@@@ -1706,6 -1724,7 +1769,7 @@@ void SpectateCopy(entity spectatee) 
        self.armortype = spectatee.armortype;
        self.armorvalue = spectatee.armorvalue;
        self.ammo_cells = spectatee.ammo_cells;
+       self.ammo_plasma = spectatee.ammo_plasma;
        self.ammo_shells = spectatee.ammo_shells;
        self.ammo_nails = spectatee.ammo_nails;
        self.ammo_rockets = spectatee.ammo_rockets;
        self.switchweapon = spectatee.switchweapon;
        self.switchingweapon = spectatee.switchingweapon;
        self.weapon = spectatee.weapon;
-       self.nex_charge = spectatee.nex_charge;
-       self.nex_chargepool_ammo = spectatee.nex_chargepool_ammo;
+       self.vortex_charge = spectatee.vortex_charge;
+       self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo;
        self.hagar_load = spectatee.hagar_load;
+       self.arc_heat_percent = spectatee.arc_heat_percent;
        self.minelayer_mines = spectatee.minelayer_mines;
        self.punchangle = spectatee.punchangle;
        self.view_ofs = spectatee.view_ofs;
        self.dmg_inflictor = spectatee.dmg_inflictor;
        self.v_angle = spectatee.v_angle;
        self.angles = spectatee.v_angle;
+       self.frozen = spectatee.frozen;
+       self.revive_progress = spectatee.revive_progress;
        if(!self.BUTTON_USE)
-               self.fixangle = TRUE;
+               self.fixangle = true;
        setorigin(self, spectatee.origin);
        setsize(self, spectatee.mins, spectatee.maxs);
        SetZoomState(spectatee.zoomstate);
        self.hud = spectatee.hud;
        if(spectatee.vehicle)
      {
-         self.fixangle = FALSE;
+         self.fixangle = false;
          //self.velocity = spectatee.vehicle.velocity;
          self.vehicle_health = spectatee.vehicle_health;
          self.vehicle_shield = spectatee.vehicle_shield;
          msg_entity = self;
  
          WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
-             WriteAngle(MSG_ONE,  spectatee.v_angle_x);
-             WriteAngle(MSG_ONE,  spectatee.v_angle_y);
-             WriteAngle(MSG_ONE,  spectatee.v_angle_z);
+             WriteAngle(MSG_ONE,  spectatee.v_angle.x);
+             WriteAngle(MSG_ONE,  spectatee.v_angle.y);
+             WriteAngle(MSG_ONE,  spectatee.v_angle.z);
  
          //WriteByte (MSG_ONE, SVC_SETVIEW);
          //    WriteEntity(MSG_ONE, self);
      }
  }
  
- float SpectateUpdate() {
+ float SpectateUpdate()
+ {
        if(!self.enemy)
            return 0;
  
-       if (self == self.enemy)
-               return 0;
-       if (!IS_PLAYER(self.enemy))
+       if(!IS_PLAYER(self.enemy) || self == self.enemy)
        {
-               self.enemy = world;
+               SetSpectator(self, world);
                return 0;
        }
  
        return 1;
  }
  
void UpdateSpectators(entity is_spec, entity is_player)
float SpectateSet()
  {
-       entity head, spec;
-       float specs = 0;
-       FOR_EACH_REALCLIENT(head)
-       {
-               msg_entity = head;
-               WriteByte(MSG_ONE, SVC_TEMPENTITY);
-               WriteByte(MSG_ONE, TE_CSQC_SPECINFO);
-               
-               specs = 0;
-               
-               FOR_EACH_SPEC(spec) if(spec.enemy == head && is_player != spec && spec != is_player)
-                       ++specs;
-       
-               if(IS_SPEC(head) || IS_OBSERVER(head) || head == is_spec || !autocvar_sv_showspectators)
-               {
-                       WriteByte(MSG_ONE, 0);
-                       continue;
-               }
-               
-               WriteByte(MSG_ONE, specs);
-               FOR_EACH_SPEC(spec) if(spec.enemy == head && is_player != spec)
-                       WriteByte(MSG_ONE, num_for_edict(spec));
-       }
 -      if(self.enemy.classname != "player")
++      if(!IS_PLAYER(self.enemy))
+               return false;
 -      /*if(self.enemy.vehicle)
 -      {
 -              msg_entity = self;
 -              WriteByte(MSG_ONE, SVC_SETVIEW);
 -              WriteEntity(MSG_ONE, self.enemy);
 -              //stuffcmd(self, "set viewsize $tmpviewsize \n");
++      ClientData_Touch(self.enemy);
 -              self.movetype = MOVETYPE_NONE;
 -              accuracy_resend(self);
 -      }
 -      else
 -      {*/
 -              msg_entity = self;
 -              WriteByte(MSG_ONE, SVC_SETVIEW);
 -              WriteEntity(MSG_ONE, self.enemy);
 -              //stuffcmd(self, "set viewsize $tmpviewsize \n");
 -              self.movetype = MOVETYPE_NONE;
 -              accuracy_resend(self);
++      msg_entity = self;
++      WriteByte(MSG_ONE, SVC_SETVIEW);
++      WriteEntity(MSG_ONE, self.enemy);
++      //stuffcmd(self, "set viewsize $tmpviewsize \n");
++      self.movetype = MOVETYPE_NONE;
++      accuracy_resend(self);
++
++      if(!SpectateUpdate())
++              PutObserverInServer();
 -              if(!SpectateUpdate())
 -                      PutObserverInServer();
 -      //}
+       return true;
  }
  
float SpectateSet()
void SetSpectator(entity player, entity spectatee)
  {
-       if(self.enemy.classname != "player")
-               return FALSE;
-       /*if(self.enemy.vehicle)
-       {
+       entity old_spectatee = player.enemy;
  
-               msg_entity = self;
-               WriteByte(MSG_ONE, SVC_SETVIEW);
-               WriteEntity(MSG_ONE, self.enemy);
-               //stuffcmd(self, "set viewsize $tmpviewsize \n");
+       player.enemy = spectatee;
  
-               self.movetype = MOVETYPE_NONE;
-               accuracy_resend(self);
-       }
-       else
-       {*/
-               msg_entity = self;
-               WriteByte(MSG_ONE, SVC_SETVIEW);
-               WriteEntity(MSG_ONE, self.enemy);
-               //stuffcmd(self, "set viewsize $tmpviewsize \n");
-               self.movetype = MOVETYPE_NONE;
-               accuracy_resend(self);
+       // WEAPONTODO
+       // these are required to fix the spectator bug with arc
+       if(old_spectatee && old_spectatee.arc_beam) { old_spectatee.arc_beam.SendFlags |= ARC_SF_SETTINGS; }
+       if(player.enemy && player.enemy.arc_beam) { player.enemy.arc_beam.SendFlags |= ARC_SF_SETTINGS; }
 +
-               if(!SpectateUpdate())
-                       PutObserverInServer();
-       //}
-       return TRUE;
++      // needed to update spectator list
++      if(old_spectatee) { ClientData_Touch(old_spectatee); }
  }
  
  float Spectate(entity pl)
  {
        if(g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
--      if(pl.team != self.team)
++      if(DIFF_TEAM(pl, self))
                return 0;
  
-       self.enemy = pl;
+       SetSpectator(self, pl);
        return SpectateSet();
  }
  
  // Returns next available player to spectate if g_ca_spectate_enemies == 0
--entity CA_SpectateNext(entity start) {
--      if (start.team == self.team) {
--              return start;
--      }
++entity CA_SpectateNext(entity start)
++{
++      if(SAME_TEAM(start, self)) { return start; }
  
        other = start;
        // continue from current player
--      while(other && other.team != self.team) {
++      while(other && DIFF_TEAM(other, self))
                other = find(other, classname, "player");
--      }
  
--      if (!other) {
++      if (!other)
++      {
                // restart from begining
                other = find(other, classname, "player");
--              while(other && other.team != self.team) {
++              while(other && DIFF_TEAM(other, self))
                        other = find(other, classname, "player");
--              }
        }
  
        return other;
@@@ -1884,20 -1889,16 +1925,19 @@@ float SpectateNext(
  {
        other = find(self.enemy, classname, "player");
  
--      if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) {
++      if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
++      {
                // CA and ca players when spectating enemies is forbidden
                other = CA_SpectateNext(other);
--      } else {
++      }
++      else
++      {
                // other modes and ca spectators or spectating enemies is allowed
                if (!other)
                        other = find(other, classname, "player");
        }
  
-       if (other)
-       {
-               self.enemy = other;
-               UpdateSpectators(world, world);
-       }
+       if(other) { SetSpectator(self, other); }
  
        return SpectateSet();
  }
@@@ -1907,7 -1908,7 +1947,7 @@@ float SpectatePrev(
        // NOTE: chain order is from the highest to the lower entnum (unlike find)
        other = findchain(classname, "player");
        if (!other) // no player
-               return FALSE;
+               return false;
  
        entity first = other;
        // skip players until current spectated player
                        while(other.team != self.team)
                                other = other.chain;
                        if(other == self.enemy)
-                               return TRUE;
+                               return true;
                }
        }
        else
                else
                        other = first;
        }
-       self.enemy = other;
-       UpdateSpectators(world, world);
+       SetSpectator(self, other);
        return SpectateSet();
  }
  
@@@ -1976,9 -1976,10 +2015,12 @@@ void LeaveSpectatorMode(
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0)
                {
                        self.classname = "player";
+                       nades_RemoveBonus(self);
++                      SetSpectator(self, world);
 +
                        if(autocvar_g_campaign || autocvar_g_balance_teams)
-                               { JoinBestTeam(self, FALSE, TRUE); }
+                               { JoinBestTeam(self, false, true); }
  
                        if(autocvar_g_campaign)
                                { campaign_bots_may_start = 1; }
  
  /**
   * Determines whether the player is allowed to join. This depends on cvar
-  * g_maxplayers, if it isn't used this function always return TRUE, otherwise
+  * g_maxplayers, if it isn't used this function always return true, otherwise
   * it checks whether the number of currently playing players exceeds g_maxplayers.
   * @return int number of free slots for players, 0 if none
   */
@@@ -2031,7 -2032,7 +2073,7 @@@ float nJoinAllowed(entity ignore) 
  
        float currentlyPlaying = 0;
        FOR_EACH_REALCLIENT(e)
-               if(IS_PLAYER(e) || e.caplayer == 1)
+               if(IS_PLAYER(e) || e.caplayer)
                        currentlyPlaying += 1;
  
        if(currentlyPlaying < autocvar_g_maxplayers)
   * g_maxplayers_spectator_blocktime seconds
   */
  void checkSpectatorBlock() {
-       if(IS_SPEC(self) || IS_OBSERVER(self)) {
+       if(IS_SPEC(self) || IS_OBSERVER(self))
+       if(!self.caplayer)
+       if(IS_REAL_CLIENT(self))
+       {
                if( time > (self.spectatortime + autocvar_g_maxplayers_spectator_blocktime) ) {
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_QUIT_KICK_SPECTATING);
                        dropclient(self);
@@@ -2194,6 -2198,33 +2239,33 @@@ void PlayerUseKey(
        MUTATOR_CALLHOOK(PlayerUseKey);
  }
  
+ float isInvisibleString(string s)
+ {
+       float i, n, c;
+       s = strdecolorize(s);
+       for((i = 0), (n = strlen(s)); i < n; ++i)
+       {
+               c = str2chr(s, i);
+               switch(c)
+               {
+                       case 0:
+                       case 32: // space
+                               break;
+                       case 192: // charmap space
+                               if (!autocvar_utf8_enable)
+                                       break;
+                               return false;
+                       case 160: // space in unicode fonts
+                       case 0xE000 + 192: // utf8 charmap space
+                               if (autocvar_utf8_enable)
+                                       break;
+                       default:
+                               return false;
+               }
+       }
+       return true;
+ }
  /*
  =============
  PlayerPreThink
@@@ -2203,14 -2234,14 +2275,14 @@@ Called every frame for each client befo
  */
  .float usekeypressed;
  void() nexball_setstatus;
- .float items_added;
+ .int items_added;
  void PlayerPreThink (void)
  {
        WarpZone_PlayerPhysics_FixVAngle();
  
        self.stat_game_starttime = game_starttime;
        self.stat_round_starttime = round_starttime;
-       self.stat_allow_oldnexbeam = autocvar_g_allow_oldnexbeam;
+       self.stat_allow_oldvortexbeam = autocvar_g_allow_oldvortexbeam;
        self.stat_leadlimit = autocvar_leadlimit;
  
        if(frametime)
  
        zoomstate_set = 0;
  
-       if(self.netname_previous != self.netname)
-       {
+       // Savage: Check for nameless players
+       if (isInvisibleString(self.netname)) {
 -              string new_name = strzone(strcat("Player@", self.netaddress));
++              string new_name = strzone(strcat("Player@", ftos(self.playerid)));
+               if(autocvar_sv_eventlog)
+                       GameLogEcho(strcat(":name:", ftos(self.playerid), ":", new_name));
+               if(self.netname_previous)
+                       strunzone(self.netname_previous);
+               self.netname_previous = strzone(new_name);
+               self.netname = self.netname_previous;
+               // stuffcmd(self, strcat("name ", self.netname, "\n"));
+       } else if(self.netname_previous != self.netname) {
                if(autocvar_sv_eventlog)
                        GameLogEcho(strcat(":name:", ftos(self.playerid), ":", self.netname));
                if(self.netname_previous)
                return;
  #endif
  
+       if(self.frozen == 2)
+       {
+               self.revive_progress = bound(0, self.revive_progress + frametime * self.revive_speed, 1);
+               self.health = max(1, self.revive_progress * start_health);
+               self.iceblock.alpha = bound(0.2, 1 - self.revive_progress, 1);
+               if(self.revive_progress >= 1)
+                       Unfreeze(self);
+       }
+       else if(self.frozen == 3)
+       {
+               self.revive_progress = bound(0, self.revive_progress - frametime * self.revive_speed, 1);
+               self.health = max(0, autocvar_g_nades_ice_health + (start_health-autocvar_g_nades_ice_health) * self.revive_progress );
+               if(self.health < 1)
+               {
+                       if(self.vehicle)
+                               vehicles_exit(VHEF_RELESE);
+                       self.event_damage(self, self.frozen_by, 1, DEATH_NADE_ICE_FREEZE, self.origin, '0 0 0');
+               }
+               else if ( self.revive_progress <= 0 )
+                       Unfreeze(self);
+       }
        MUTATOR_CALLHOOK(PlayerPreThink);
  
        if(!self.cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
                        // FIXME turn this into CSQC stuff
                        self.v_angle = self.lastV_angle;
                        self.angles = self.lastV_angle;
-                       self.fixangle = TRUE;
+                       self.fixangle = true;
                }
  
                if(frametime)
                {
-                       if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge)
+                       if(self.weapon == WEP_VORTEX && WEP_CVAR(vortex, charge))
                        {
-                               self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
-                               self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
-                               self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.nex_charge / autocvar_g_balance_nex_charge_animlimit);
+                               self.weaponentity_glowmod_x = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
+                               self.weaponentity_glowmod_y = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
+                               self.weaponentity_glowmod_z = autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_half * min(1, self.vortex_charge / WEP_CVAR(vortex, charge_animlimit));
  
-                               if(self.nex_charge > autocvar_g_balance_nex_charge_animlimit)
+                               if(self.vortex_charge > WEP_CVAR(vortex, charge_animlimit))
                                {
-                                       self.weaponentity_glowmod_x = self.weaponentity_glowmod_x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
-                                       self.weaponentity_glowmod_y = self.weaponentity_glowmod_y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
-                                       self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_animlimit) / (1 - autocvar_g_balance_nex_charge_animlimit);
+                                       self.weaponentity_glowmod_x = self.weaponentity_glowmod.x + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_red_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
+                                       self.weaponentity_glowmod_y = self.weaponentity_glowmod.y + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_green_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
+                                       self.weaponentity_glowmod_z = self.weaponentity_glowmod.z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.vortex_charge - WEP_CVAR(vortex, charge_animlimit)) / (1 - WEP_CVAR(vortex, charge_animlimit));
                                }
                        }
                        else
-                               self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, TRUE) * 2;
+                               self.weaponentity_glowmod = colormapPaletteColor(self.clientcolors & 0x0F, true) * 2;
  
                        player_powerups();
                }
                        do_crouch = 0;
                if(self.vehicle)
                        do_crouch = 0;
-               if(self.freezetag_frozen)
+               if(self.frozen)
                        do_crouch = 0;
-               if(self.weapon == WEP_SHOTGUN && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink)
+               // WEAPONTODO: THIS SHIT NEEDS TO GO EVENTUALLY
+               // It cannot be predicted by the engine!
+               if((self.weapon == WEP_SHOCKWAVE || self.weapon == WEP_SHOTGUN) && self.weaponentity.wframe == WFRAME_FIRE2 && time < self.weapon_nextthink)
                        do_crouch = 0;
  
                if (do_crouch)
                {
                        if (!self.crouch)
                        {
-                               self.crouch = TRUE;
+                               self.crouch = true;
                                self.view_ofs = PL_CROUCH_VIEW_OFS;
                                setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX);
-                               // setanim(self, self.anim_duck, FALSE, TRUE, TRUE); // this anim is BROKEN anyway
+                               // setanim(self, self.anim_duck, false, true, true); // this anim is BROKEN anyway
                        }
                }
                else
                {
                        if (self.crouch)
                        {
-                               tracebox(self.origin, PL_MIN, PL_MAX, self.origin, FALSE, self);
+                               tracebox(self.origin, PL_MIN, PL_MAX, self.origin, false, self);
                                if (!trace_startsolid)
                                {
-                                       self.crouch = FALSE;
+                                       self.crouch = false;
                                        self.view_ofs = PL_VIEW_OFS;
                                        setsize (self, PL_MIN, PL_MAX);
                                }
  
                player_regen();
  
-               // rot nex charge to the charge limit
-               if(autocvar_g_balance_nex_charge_rot_rate && self.nex_charge > autocvar_g_balance_nex_charge_limit && self.nex_charge_rottime < time)
-                       self.nex_charge = bound(autocvar_g_balance_nex_charge_limit, self.nex_charge - autocvar_g_balance_nex_charge_rot_rate * frametime / W_TICSPERFRAME, 1);
+               // WEAPONTODO: Add a weapon request for this
+               // rot vortex charge to the charge limit
+               if(WEP_CVAR(vortex, charge_rot_rate) && self.vortex_charge > WEP_CVAR(vortex, charge_limit) && self.vortex_charge_rottime < time)
+                       self.vortex_charge = bound(WEP_CVAR(vortex, charge_limit), self.vortex_charge - WEP_CVAR(vortex, charge_rot_rate) * frametime / W_TICSPERFRAME, 1);
  
                if(frametime)
                        player_anim();
                SpectatorThink();
        }
  
+       // WEAPONTODO: Add weapon request for this
        if(!zoomstate_set)
-               SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_NEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE && autocvar_g_balance_rifle_secondary == 0));
+               SetZoomState(self.BUTTON_ZOOM || self.BUTTON_ZOOMSCRIPT || (self.BUTTON_ATCK2 && self.weapon == WEP_VORTEX) || (self.BUTTON_ATCK2 && self.weapon == WEP_RIFLE && WEP_CVAR(rifle, secondary) == 0)); // WEAPONTODO
  
        float oldspectatee_status;
        oldspectatee_status = self.spectatee_status;
        if(self.spectatee_status != oldspectatee_status)
        {
                ClientData_Touch(self);
-               if(g_race || g_cts)
-                       race_InitSpectator();
        }
  
        if(self.teamkill_soundtime)
  
        target_voicescript_next(self);
  
+       // WEAPONTODO: Move into weaponsystem somehow
        // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring
        if(!self.weapon)
                self.clip_load = self.clip_size = 0;
  }
  
- float isInvisibleString(string s)
- {
-       float i, n, c;
-       s = strdecolorize(s);
-       for((i = 0), (n = strlen(s)); i < n; ++i)
-       {
-               c = str2chr(s, i);
-               switch(c)
-               {
-                       case 0:
-                       case 32: // space
-                               break;
-                       case 192: // charmap space
-                               if (!autocvar_utf8_enable)
-                                       break;
-                               return FALSE;
-                       case 160: // space in unicode fonts
-                       case 0xE000 + 192: // utf8 charmap space
-                               if (autocvar_utf8_enable)
-                                       break;
-                       default:
-                               return FALSE;
-               }
-       }
-       return TRUE;
- }
  /*
  =============
  PlayerPostThink
@@@ -2566,12 -2607,6 +2648,6 @@@ Called every frame for each client afte
  .float idlekick_lasttimeleft;
  void PlayerPostThink (void)
  {
-       // Savage: Check for nameless players
-       if (isInvisibleString(self.netname)) {
-               self.netname = "Player";
-               stuffcmd(self, strcat("name ", self.netname, substring(ftos(random()), 2, -1), "\n"));
-       }
        if(sv_maxidle > 0 && frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
        if(IS_PLAYER(self) || sv_maxidle_spectatorsareidle)
        {
        }
        */
  
-       //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
        if(self.waypointsprite_attachedforcarrier)
                WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, autocvar_g_balance_armor_blockpercent, DEATH_WEAPON));
  
        playerdemo_write();
  
-       if((g_cts || g_race) && self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
-       {
-               if (!self.stored_netname)
-                       self.stored_netname = strzone(uid2name(self.crypto_idfp));
-               if(self.stored_netname != self.netname)
-               {
-                       db_put(ServerProgsDB, strcat("/uid2name/", self.crypto_idfp), self.netname);
-                       strunzone(self.stored_netname);
-                       self.stored_netname = strzone(self.netname);
-               }
-       }
-       /*
-       if(g_race)
-               dprintf("%f %.6f\n", time, race_GetFractionalLapCount(self));
-       */
        CSQCMODEL_AUTOUPDATE();
  }