Skip to content

Fix up Lua command/cvar safety

James R. requested to merge strong-lua-command-restrictions into next

Most of this is work done a couple years ago by Hannu_Hanhi, with light refactoring by me today.

Bug fixes

  • The toggle and add commands can no longer be used to bypass Lua restrictions on cvars.
  • Lua cvar restrictions can no longer be bypassed by chaining commands with a semicolon.

API

  • Replaced CV_NOLUA with CV_ALLOWLUA, cvars now opt in to Lua mutability (stronger definition).
  • Adds COM_LUA, pass to COM_AddCommand. Commands registered with COM_LUA can be called from Lua, commands without this flag cannot.
  • LUA SCRIPT RELEVANT: CV_NOLUA has been replaced by CV_ALLOWLUA. All other changes do not affect the Lua API.

Big list of cvars and commands

Click to expand
Cvars Lua can change           Cvars Lua CANNOT change         Commands Lua can run       Commands Lua CANNOT run
-----------------------        ------------------------        -------------------        ------------
advancemap                     1upsound                        add                        alias
allowexitlevel                 addons_folder                   addfile                    exec
allowjoin                      addons_md5                      addfolder                  wait
allowmlook                     addons_option                   archivetest                cls
allowseenames                  addons_search_case              ban                        bind
allowteamchange                addons_search_type              banip                      saveconfig
autobalance                    addons_showall                  causecfail                 loadconfig
basenumlaps                    alwaysgrabmouse                 cecho                      changeconfig
cam2_adjust                    alwaysmlook                     cechoduration              playdemo
cam2_centertoggle              alwaysmlook2                    cechoflags                 timedemo
cam2_curdist                   apng_compress_level             changeteam                 setcontrol
cam2_curheight                 apng_downscale                  changeteam2                setcontrol2
cam2_dist                      apng_memory_level               charability                listserv
cam2_height                    apng_speed                      charspeed                  vid_mode
cam2_lockaimassist             apng_strategy                   cheats
cam2_lockedinput               apng_window_size                clearbans
cam2_orbit                     autobrake                       clearscores
cam2_rotate                    autobrake2                      connect
cam2_rotspeed                  autorecord                      countmobjs
cam2_shiftfacingchar           bgamma                          csay
cam2_simpledist                bhue                            demote
cam2_simpleheight              blamecfail                      devmode
cam2_speed                     bsaturation                     displayplayer
cam2_still                     cd_update                       downloads
cam2_turnfacingability         cd_volume                       drop
cam2_turnfacingchar            cgamma                          droprate
cam2_turnfacinginput           chasecam                        dumplua
cam2_turnfacingspindash        chasecam2                       echo
cam2_turnmultiplier            chasemlook                      exitgame
cam_adjust                     chasemlook2                     exitlevel
cam_centertoggle               chatbacktint                    gametype
cam_curdist                    chatheight                      getallemeralds
cam_curheight                  chatmode                        getplayernum
cam_dist                       chatnotifications               god
cam_height                     chatspamprotection              gravflip
cam_lockaimassist              chattime                        help
cam_lockedinput                chatwidth                       hurtme
cam_orbit                      chooseskin                      isgamemodified
cam_rotate                     chue                            jumptoaxis
cam_rotspeed                   closedcaptioning                kick
cam_shiftfacingchar            compactscoreboard               listwad
cam_simpledist                 con_backcolor                   login
cam_simpleheight               con_backpic                     manual
cam_speed                      con_height                      map
cam_still                      con_hudlines                    mapmd5
cam_turnfacingability          con_hudtime                     masterserver_update
cam_turnfacingchar             con_speed                       memdump
cam_turnfacinginput            con_textsize                    memfree
cam_turnfacingspindash         configanalog                    mod_details
cam_turnmultiplier             configanalog2                   motd
color                          controlperkey                   noclip
color2                         cpusleep                        nodes
competitionboxes               crosshair                       notarget
cooplives                      crosshair2                      numnodes
coopstarposts                  csaturation                     numthinkers
countdowntime                  defaultcolor                    objectplace
exitmove                       defaultcolor2                   password
flagtime                       defaultskin                     pause
forceskin                      defaultskin2                    ping
friendlyfire                   digimusic                       playintro
gravity                        digmusicvolume                  promote
hidetime                       directionchar                   quit
inttime                        directionchar2                  reloadbans
itemfinder                     downloading                     resendgamestate
killingdead                    downloadspeed                   resetcamera
matchboxes                     drawdist                        resetemeralds
maxplayers                     drawdist_nights                 restartaudio
mute                           drawdist_precip                 retry
numlaps                        dummyconsvar                    rteleport
overtime                       dummycontinues                  runsoc
pausepermission                dummycutscenes                  savecheckpoint
playersforexit                 dummylives                      say
pointlimit                     dummyloadless                   sayteam
powerstones                    dummymarathon                   sayto
respawndelay                   dummymares                      scale
respawnitem                    dummyrings                      screenshot
respawnitemtime                dummyscramble                   serverchangeteam
restrictskinchange             dummyteam                       setcontinues
ringslinger                    dumpconsistency                 setlives
runscripts                     execversion                     setrings
scrambleonchange               ffloorclip                      showbanlist
seenames                       fishcake                        showmap
servername                     flipcam                         showscores
showhud                        flipcam2                        showtime
showinputjoy                   fov                             skynum
skin                           fpscap                          startmovie
skin2                          freedemocamera                  stopdemo
specialrings                   fullscreen                      stopmovie
startinglives                  gamma                           suicide
tailspickup                    ggamma                          teleport
teamscramble                   ghost_bestrings                 toggle
timelimit                      ghost_bestscore                 togglemodified
touchtag                       ghost_besttime                  toggletwod
tv_1up                         ghost_guest                     tunes
tv_bombshield                  ghost_last                      version
tv_eggman                      ghue                            vid_info
tv_forceshield                 gif_downscale                   vid_modelist
tv_invincibility               gif_dynamicdelay                vid_nummodes
tv_jumpshield                  gif_localcolortable             weather
tv_recycler                    gif_optimize
tv_ringshield                  gr_allowclientshaders
tv_superring                   gr_anisotropicmode
tv_supersneaker                gr_batching
tv_teleporter                  gr_clipwalls
tv_watershield                 gr_coronas
                               gr_coronasize
                               gr_dynamiclighting
                               gr_fakecontrast
                               gr_filtermode
                               gr_fovchange
                               gr_modelinterpolation
                               gr_modellighting
                               gr_models
                               gr_shaders
                               gr_shearing
                               gr_skydome
                               gr_slopecontrast
                               gr_solvetjoin
                               gr_spritebillboarding
                               gr_staticlighting
                               gsaturation
                               hazardlog
                               homremoval
                               invertmouse
                               invertmouse2
                               joindelay
                               joinnextround
                               jointimeout
                               joy_deadzone
                               joy_deadzone2
                               joy_digdeadzone
                               joy_digdeadzone2
                               joyaxis2_fire
                               joyaxis2_firenormal
                               joyaxis2_jump
                               joyaxis2_look
                               joyaxis2_move
                               joyaxis2_side
                               joyaxis2_spin
                               joyaxis2_turn
                               joyaxis_fire
                               joyaxis_firenormal
                               joyaxis_jump
                               joyaxis_look
                               joyaxis_move
                               joyaxis_side
                               joyaxis_spin
                               joyaxis_turn
                               masterserver
                               masterserver_update_rate
                               maxping
                               maxportals
                               maxsend
                               mgamma
                               mhue
                               midimusic
                               midimusicvolume
                               midiplayer
                               midisoundbank
                               midisoundfont
                               modfilter
                               mouse2opt
                               mouse2port
                               mousemove
                               mousemove2
                               mousesens
                               mousesens2
                               mouseysens
                               mouseysens2
                               movebob
                               movie_folder
                               movie_option
                               moviemode_mode
                               msaturation
                               musicpref
                               name
                               name2
                               netstat
                               netticbuffer
                               nettimeout
                               newgametype
                               nextmap
                               noticedownload
                               op_flags
                               op_hoopflags
                               op_mapthingnum
                               op_speed
                               padport
                               padport2
                               padscale
                               padscale2
                               pauseifunfocused
                               perfstats
                               pingtimeout
                               playbackspeed
                               playmusicifunfocused
                               playsoundsifunfocused
                               png_compress_level
                               png_memory_level
                               png_strategy
                               png_window_size
                               powerupdisplay
                               precachesound
                               precipdensity
                               ps_descriptor
                               ps_samplesize
                               rejointimeout
                               renderer
                               renderstats
                               renderview
                               resetmusic
                               resetmusicbyheader
                               resynchattempts
                               rgamma
                               rhue
                               rollingdemos
                               rsaturation
                               samplerate
                               saturation
                               scr_depth
                               scr_height
                               scr_width
                               screenshot_colorprofile
                               screenshot_folder
                               screenshot_option
                               serversort
                               sessionanalog
                               sessionanalog2
                               shadow
                               showfocuslost
                               showfps
                               showjoinaddress
                               showping
                               skipmapcheck
                               skybox
                               snd_channels
                               sounds
                               soundtest
                               soundvolume
                               stereoreverse
                               stretch
                               surround
                               timerres
                               timescale
                               translucency
                               translucenthud
                               tutorialprompt
                               use_gamepad
                               use_gamepad2
                               use_mouse
                               use_mouse2
                               vid_wait
                               ygamma
                               yhue
                               ysaturation

Merge request reports

Loading