From 8abef6c82dbe305d3f9ca9338da5194cbcf0991d Mon Sep 17 00:00:00 2001 From: Jesse <69196954+ThisAMJ@users.noreply.github.com> Date: Thu, 13 Apr 2023 09:47:32 +1000 Subject: [PATCH] docs: update cvars list also add pipe escape, path fallback, cvar filter, and EOF LF to cvars.js also add contribution tutorial for generator TODO: should cvars.js be in docs? to make it more obvious what it's for --- cvars.js | 12 +++++-- docs/contributing.md | 5 +++ docs/cvars.md | 69 +++++++++++++++++++++++----------------- src/Features/Hud/Hud.cpp | 2 +- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/cvars.js b/cvars.js index 092d779cc..c4a605c9b 100644 --- a/cvars.js +++ b/cvars.js @@ -10,7 +10,9 @@ class Cvar { } }; -fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => { +let path = process.argv[2] || process.cwd(); + +fs.readFile(path + '/sar.cvars', 'utf-8', (err, data) => { if (err) { return console.error(err); } @@ -25,6 +27,9 @@ fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => { } } + // Hide internal and user-defined config+ cvars + cvars = cvars.filter(e => !(e.name.startsWith('_') || e.description == "SAR function command.\n" || e.description == "SAR alias command.\n")); + const compareCvar = (a, b) => { if (a.startsWith('-') || a.startsWith('+')) { a = a.substring(1); @@ -39,12 +44,13 @@ fs.readFile(process.argv[2] + '/sar.cvars', 'utf-8', (err, data) => { for (let cvar of cvars.sort((a, b) => compareCvar(a.name, b.name))) { body += '\n|'; body += (cvar.games.length > 0) ? `${cvar.name}` : cvar.name; - body += `|${cvar.value}|${cvar.description.replace(/')}|`; + body += `|${cvar.value}|${cvar.description.replace(/([<\|])/g, '\\$1').replace(/\n/g, '
')}|`; } fs.writeFileSync('docs/cvars.md', `# SAR: Cvars |Name|Default|Description| -|---|---|---|${body}`); +|---|---|---|${body} +`); }); diff --git a/docs/contributing.md b/docs/contributing.md index 2c757af1c..b52c22c71 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -277,6 +277,11 @@ auto funcAddress = Memory::Absolute(MODULE("engine"), 0xdeadbeef); ### Console Commands +Periodically, the `docs/cvars.md` file should be updated to match the list of +cvars. This can be done by doing the `sar_cvars_dump_doc` command ingame, +then doing `node "/cvars.js" ""` (assuming you +have NodeJS). + #### Variables ```cpp diff --git a/docs/cvars.md b/docs/cvars.md index 368973bf0..6fd5456be 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -66,7 +66,7 @@ |ghost_show_spec_chat|1|Show chat messages from spectators when not spectating.
| |ghost_spec_connect|cmd|ghost_spec_connect \ \ - connect to the server as a spectator
ex: 'localhost 53000' - '127.0.0.1 53000' - '89.10.20.20 53000'.
| |ghost_spec_next|cmd|ghost_spec_next [samemap] - spectate the next ghost
| -|ghost_spec_pov|cmd|ghost_spec_pov \ - spectate the specified ghost
| +|ghost_spec_pov|cmd|ghost_spec_pov \ - spectate the specified ghost
| |ghost_spec_prev|cmd|ghost_spec_prev - spectate the previous ghost
| |ghost_spec_see_spectators|0|Whether to see other spectators while spectating.
| |ghost_spec_thirdperson|0|Whether to spectate ghost from a third-person perspective.
| @@ -95,6 +95,7 @@ |sar_always_transmit_heavy_ents|0|Always transmit large but seldom changing edicts to clients to prevent lag spikes.
| |sar_autojump|0|Enables automatic jumping on the server.
| |sar_autorecord|0|Enables or disables automatic demo recording.
| +|sar_autostrafe|0|Automatically strafes in your current wishdir.
| |sar_avg_result|cmd|sar_avg_result - prints result of average
| |sar_avg_start|cmd|sar_avg_start - starts calculating the average when using timer
| |sar_avg_stop|cmd|sar_avg_stop - stops average calculation
| @@ -123,7 +124,7 @@ |sar_cheat_hud|1|Display a warning in the HUD when cheats are active. 0 = disable, 1 = display if sv_cheats off, 2 = display always
| |sar_cheat_hud_x|-4|X position of the cheat warning HUD.
| |sar_cheat_hud_y|4|Y position of the cheat warning HUD.
| -|sar_check_update|cmd|sar_check_update [release|pre] - check whether the latest version of SAR is being used
| +|sar_check_update|cmd|sar_check_update [release\|pre] - check whether the latest version of SAR is being used
| |sar_clear_lines|cmd|sar_clear_lines - clears all active drawline overlays
| |sar_cm_rightwarp|0|Fix CM wrongwarp.
| |sar_con_filter|0|Enable the console filter
| @@ -178,8 +179,8 @@ |sar_ei_hud_x|0|X offset of entity inspection HUD.
| |sar_ei_hud_y|0|Y offset of entity inspection HUD.
| |sar_ei_hud_z|0|Z offset of entity inspection HUD.
| -|sar_ent_info|cmd|sar_ent_info [name] - show info about the entity under the crosshair or with the given name
| -|sar_ent_slot_serial|cmd|sar_ent_slot_serial \ [value] - prints entity slot serial number, or sets it if additional parameter is specified.
| +|sar_ent_info|cmd|sar_ent_info [selector] - show info about the entity under the crosshair or with the given name
| +|sar_ent_slot_serial|cmd|sar_ent_slot_serial \ [value] - prints entity slot serial number, or sets it if additional parameter is specified.
Banned in most categories, check with the rules before use!
| |sar_exit|cmd|sar_exit - removes all function hooks, registered commands and unloads the module
| |sar_expand|cmd|sar_expand [cmd]... - run a command after expanding svar substitutions
| |sar_export_stats|cmd|sar_export_stats \ - export the stats to the specifed path in a .csv file
| @@ -190,8 +191,7 @@ |sar_fcps_clear|cmd|sar_fcps_clear - clear the FCPS event history.
| |sar_fcps_override|0|Override FCPS for tracing results.
| |sar_find_client_class|cmd|sar_find_client_class \ - finds specific client class tables and props with their offset
| -|sar_find_ent|cmd|sar_find_ent \ - finds entity in the entity list by name
| -|sar_find_ents|cmd|sar_find_ents \ - finds entities in the entity list by class name
| +|sar_find_ents|cmd|sar_find_ents \ - finds entities in the entity list by class name
| |sar_find_server_class|cmd|sar_find_server_class \ - finds specific server class tables and props with their offset
| |sar_fix_reloaded_cheats|1|Overrides map execution of specific console commands in Reloaded in order to separate map usage from player usage for these commands.
| |sar_font_get_name|cmd|sar_font_get_name \ - gets the name of a font from its index
| @@ -201,7 +201,7 @@ |sar_function|cmd|sar_function \ [command] [args]... - create a function, replacing $1, $2 etc in the command string with the respective argument, and more. If no command is specified, prints the given function
| |sar_function_run|cmd|sar_function_run \ [args]... - run a function with the given arguments
| |sar_geteyepos|cmd|sar_geteyepos [slot] - get the view position (portal shooting origin) and view angles of a certain player.
| -|sar_getpos|cmd|sar_getpos [slot] [server|client] - get the absolute origin and angles of a particular player from either the server or client. Defaults to slot 0 and server.
| +|sar_getpos|cmd|sar_getpos [slot] [server\|client] - get the absolute origin and angles of a particular player from either the server or client. Defaults to slot 0 and server.
| |sar_give_betsrighter|cmd|sar_give_betsrighter [n] - gives the player in slot n (0 by default) betsrighter.
| |sar_give_fly|cmd|sar_give_fly [n] - gives the player in slot n (0 by default) preserved crouchfly.
| |sar_groundframes_reset|cmd|sar_groundframes_reset - reset recorded groundframe statistics.
| @@ -216,13 +216,13 @@ |sar_hud_eyeoffset|0|Draws player's eye offset.
0 = Default,
1 = eye offset including precision error,
2 = raw eye offset.
| |sar_hud_font_color|255 255 255 255|RGBA font color of HUD.
| |sar_hud_font_index|0|Font index of HUD.
| -|sar_hud_frame|0|Draws current frame count.
| |sar_hud_fps|0|Show fps (frames per second) on the SAR hud.
1 - Show fps
2 - Show fps with fps cap
| +|sar_hud_frame|0|Draws current frame count.
| |sar_hud_ghost_spec|0|Show the name of the ghost you're currently spectating.
| |sar_hud_grounded|0|Draws the state of player being on ground.
| |sar_hud_groundframes|0|Draws the number of ground frames since last landing. Setting it to 2 preserves the value.
| |sar_hud_groundspeed|0|Draw the speed of the player upon leaving the ground.
| -|sar_hud_hide_text|cmd|sar_hud_hide_text \ - hides the nth text value in the HUD
| +|sar_hud_hide_text|cmd|sar_hud_hide_text \ - hides the nth text value in the HUD
| |sar_hud_inspection|0|Draws entity inspection data.
| |sar_hud_jump|0|Draws current jump distance.
| |sar_hud_jump_peak|0|Draws longest jump distance.
| @@ -243,7 +243,7 @@ |sar_hud_session|0|Draws current session tick.
| |sar_hud_set_text|cmd|sar_hud_set_text \ \... - sets and shows the nth text value in the HUD
| |sar_hud_set_text_color|cmd|sar_hud_set_text_color \ [color] - sets the color of the nth text value in the HUD. Reset by not giving color.
| -|sar_hud_show_text|cmd|sar_hud_show_text \ - shows the nth text value in the HUD
| +|sar_hud_show_text|cmd|sar_hud_show_text \ - shows the nth text value in the HUD
| |sar_hud_spacing|1|Spacing between elements of HUD.
| |sar_hud_steps|0|Draws total step count.
| |sar_hud_strafesync_color|0 150 250 255|RGBA font color of strafesync HUD.
| @@ -258,6 +258,7 @@ |sar_hud_text||DEPRECATED: Use sar_hud_set_text.
| |sar_hud_text||DEPRECATED: Use sar_hud_set_text.
| |sar_hud_timer|0|Draws current value of timer.
| +|sar_hud_toggle_text|cmd|sar_hud_toggle_text \ - toggles the nth text value in the HUD
| |sar_hud_trace|0|Draws info about current trace bbox tick.
| |sar_hud_velang|0|Draw the angle of the player's horizontal velocity vector.
| |sar_hud_velocity|0|Draws velocity of the client.
0 = Default,
1 = X, Y, Z
2 = X:Y
3 = X:Y, Z
4 = X:Y:Z
5 = X, Y, X:Y, Z
| @@ -272,10 +273,10 @@ |sar_ihud_clear_background|cmd|sar_ihud_clear_background
| |sar_ihud_grid_padding|2|Padding between grid squares of input HUD.
| |sar_ihud_grid_size|60|Grid square size of input HUD.
| -|sar_ihud_modify|cmd|sar_ihud_modify \ [param=value]... - modifies parameters in given element.
Params: enabled, text, pos, x, y, width, height, font, background, highlight, textcolor, texthighlight, image, highlightimage, minhold.
| +|sar_ihud_modify|cmd|sar_ihud_modify \ [param=value]... - modifies parameters in given element.
Params: enabled, text, pos, x, y, width, height, font, background, highlight, textcolor, texthighlight, image, highlightimage, minhold.
| |sar_ihud_preset|cmd|sar_ihud_preset \ - modifies input hud based on given preset
| |sar_ihud_set_background|cmd|sar_ihud_set_background \ \ \ \ \
| -|sar_ihud_setpos|cmd|sar_ihud_setpos \ \ - automatically sets the position of input HUD.
| +|sar_ihud_setpos|cmd|sar_ihud_setpos \ \ - automatically sets the position of input HUD.
| |sar_ihud_x|2|X position of input HUD.
| |sar_ihud_y|2|Y position of input HUD.
| |sar_import_stats|cmd|sar_import_stats \ - import the stats from the specified .csv file
| @@ -297,7 +298,7 @@ |sar_lphud_reset|cmd|sar_lphud_reset - resets lp counter
| |sar_lphud_reset_on_changelevel|0|Reset the lp counter on any changelevel or restart_level. Useful for ILs.
| |sar_lphud_set|cmd|sar_lphud_set \ - sets lp counter to given number
| -|sar_lphud_setpos|cmd|sar_lphud_setpos \ \ - automatically sets the position of least portals HUD.
| +|sar_lphud_setpos|cmd|sar_lphud_setpos \ \ - automatically sets the position of least portals HUD.
| |sar_lphud_x|-10|x pos of lp counter.
| |sar_lphud_y|-10|y pos of lp counter.
| |sar_minimap_load|cmd|sar_minimap_load \ - load a minimap from a JSON file.
| @@ -357,7 +358,7 @@ |sar_patch_cfg|0|Patches Crouch Flying Glitch.
| |sar_pause_at|-1|Pause at the specified tick. -1 to deactivate it.
| |sar_pause_for|0|Pause for this amount of ticks.
| -|sar_pip_align|cmd|sar_pip_align \ \ - aligns the remote view.
| +|sar_pip_align|cmd|sar_pip_align \ \ - aligns the remote view.
| |sar_portalgun_hud|0|Enables the portalgun HUD.
| |sar_portalgun_hud_x|5|The x position of the portalgun HUD.
| |sar_portalgun_hud_y|5|The y position of the portalgun HUD.
| @@ -431,7 +432,7 @@ |sar_speedrun_export_all|cmd|sar_speedrun_export_all \ - export the results of many speedruns to the specified CSV file
| |sar_speedrun_offset|0|Start speedruns with this time on the timer.
| |sar_speedrun_pause|cmd|sar_speedrun_pause - pause the speedrun timer
| -|sar_speedrun_recover|cmd|sar_speedrun_recover \ - recover a crashed run by resuming the timer at the given time on next load
| +|sar_speedrun_recover|cmd|sar_speedrun_recover \ - recover a crashed run by resuming the timer at the given time on next load
| |sar_speedrun_reset|cmd|sar_speedrun_reset - reset the speedrun timer
| |sar_speedrun_reset_categories|cmd|sar_speedrun_reset_categories - delete all custom categories and rules, reverting to the builtin ones
| |sar_speedrun_reset_export|cmd|sar_speedrun_reset_export - reset the log of complete and incomplete runs to be exported
| @@ -473,6 +474,16 @@ |sar_strafe_quality_height|50|The height of the strafe quality HUD.
| |sar_strafe_quality_ticks|40|The number of ticks to average over for the strafe quality HUD.
| |sar_strafe_quality_width|300|The width of the strafe quality HUD.
| +|sar_strafehud|0|Enables or disables strafe hud.
| +|sar_strafehud_avg_sample_count|60|How many samples to use for average counter.
| +|sar_strafehud_detail_scale|4|The detail scale for the lines of hud.
| +|sar_strafehud_font|13|Font used by strafe hud.
| +|sar_strafehud_lock_mode|1|Lock mode used by strafe hud:
0 - view direction
1 - velocity direction
2 - absolute angles
| +|sar_strafehud_match_accel_scale|0|Match the scales for minimum and maximum deceleration.
| +|sar_strafehud_size|256|The width and height of the strafe hud.
| +|sar_strafehud_use_friction|0|Use ground friction when calculating acceleration.
| +|sar_strafehud_x|-10|The X position of the strafe hud.
| +|sar_strafehud_y|10|The Y position of the strafe hud.
| |sar_strafesync|0|Shows strafe sync stats.
| |sar_strafesync_noground|1|0: Always run.
1: Do not run when on ground.
| |sar_strafesync_pause|cmd|sar_strafesync_pause - pause strafe sync session
| @@ -502,7 +513,7 @@ |sar_tas_restore_fps|1|Restore fps_max and host_framerate after TAS playback.
| |sar_tas_resume|cmd|sar_tas_resume - resumes TAS playback
| |sar_tas_save_raw|cmd|sar_tas_save_raw - saves a processed version of just processed script
| -|sar_tas_server|0|Enable the remote TAS server.
| +|sar_tas_server|0|Enable the remote TAS server. Setting this value to something higher than one will bind the server on that port.
| |sar_tas_skipto|0|Fast-forwards the TAS playback until given playback tick.
| |sar_tas_stop|cmd|sar_tas_stop - stop TAS playing
| |sar_tas_tools_enabled|1|Enables tool processing for TAS script making.
| @@ -528,7 +539,7 @@ |sar_toast_font|6|The font index to use for toasts.
| |sar_toast_net_create|cmd|sar_toast_net_create \ \ - create a toast, also sending it to your coop partner
| |sar_toast_net_disable|0|Disable network toasts.
| -|sar_toast_setpos|cmd|sar_toast_setpos \ \ - set the position of the toasts HUD
| +|sar_toast_setpos|cmd|sar_toast_setpos \ \ - set the position of the toasts HUD
| |sar_toast_tag_dismiss_all|cmd|sar_toast_tag_dismiss_all \ - dismiss all active toasts with the given tag
| |sar_toast_tag_set_color|cmd|sar_toast_tag_set_color \ \ - set the color of the specified toast tag to an sRGB color
| |sar_toast_tag_set_duration|cmd|sar_toast_tag_set_duration \ \ - set the duration of the specified toast tag in seconds. The duration may be given as 'forever'
| @@ -559,7 +570,7 @@ |sar_trace_teleport_at|cmd|sar_trace_teleport_at \ [player slot] [trace name] - teleports the player at the given trace tick on the given trace ID (defaults to hovered one or the first one ever made) in the given slot (defaults to 0).
| |sar_trace_teleport_eye|cmd|sar_trace_teleport_eye \ [player slot] [trace name] - teleports the player to the eye position at the given trace tick on the given trace (defaults to hovered one or the first one ever made) in the given slot (defaults to 0).
| |sar_trace_use_shot_eyeoffset|1|Uses eye offset and angles accurate for portal shooting.
| -|sar_update|cmd|sar_update [release|pre] [exit] [force] - update SAR to the latest version. If exit is given, exit the game upon successful update; if force is given, always re-install, even if it may be a downgrade
| +|sar_update|cmd|sar_update [release\|pre] [exit] [force] - update SAR to the latest version. If exit is given, exit the game upon successful update; if force is given, always re-install, even if it may be a downgrade
| |sar_velocitygraph|0|Shows velocity graph.
| |sar_velocitygraph_background|0|Background of velocity graph.
| |sar_velocitygraph_font_index|21|Font index of velocity graph.
| @@ -580,29 +591,29 @@ |sar_workshop_update|cmd|sar_workshop_update - updates the workshop map list
| |seq|cmd|seq \... - runs a sequence of commands one tick after one another
| |svar_abs|cmd|svar_abs \ - perform the given operation on an svar
| -|svar_add|cmd|svar_add \ \ - perform the given operation on an svar
| +|svar_add|cmd|svar_add \ \ - perform the given operation on an svar
| |svar_capture|cmd|svar_capture \ \ [args]... - capture a command's output and place it into an svar, removing newlines
| |svar_ceil|cmd|svar_ceil \ - perform the given operation on an svar
| |svar_count|cmd|svar_count - prints a count of all the defined svars
| -|svar_div|cmd|svar_div \ \ - perform the given operation on an svar
| -|svar_fadd|cmd|svar_fadd \ \ - perform the given operation on an svar
| -|svar_fdiv|cmd|svar_fdiv \ \ - perform the given operation on an svar
| +|svar_div|cmd|svar_div \ \ - perform the given operation on an svar
| +|svar_fadd|cmd|svar_fadd \ \ - perform the given operation on an svar
| +|svar_fdiv|cmd|svar_fdiv \ \ - perform the given operation on an svar
| |svar_floor|cmd|svar_floor \ - perform the given operation on an svar
| -|svar_fmod|cmd|svar_fmod \ \ - perform the given operation on an svar
| -|svar_fmul|cmd|svar_fmul \ \ - perform the given operation on an svar
| +|svar_fmod|cmd|svar_fmod \ \ - perform the given operation on an svar
| +|svar_fmul|cmd|svar_fmul \ \ - perform the given operation on an svar
| |svar_from_cvar|cmd|svar_from_cvar \ \ - capture a cvar's value and place it into an svar, removing newlines
| -|svar_fsub|cmd|svar_fsub \ \ - perform the given operation on an svar
| +|svar_fsub|cmd|svar_fsub \ \ - perform the given operation on an svar
| |svar_get|cmd|svar_get \ - get the value of a svar
| -|svar_mod|cmd|svar_mod \ \ - perform the given operation on an svar
| -|svar_mul|cmd|svar_mul \ \ - perform the given operation on an svar
| +|svar_mod|cmd|svar_mod \ \ - perform the given operation on an svar
| +|svar_mul|cmd|svar_mul \ \ - perform the given operation on an svar
| |svar_no_persist|cmd|svar_no_persist \ - unmark an svar as persistent
| |svar_persist|cmd|svar_persist \ - mark an svar as persistent
| |svar_round|cmd|svar_round \ - perform the given operation on an svar
| |svar_set|cmd|svar_set \ \ - set a svar (SAR variable) to a given value
| -|svar_sub|cmd|svar_sub \ \ - perform the given operation on an svar
| +|svar_sub|cmd|svar_sub \ \ - perform the given operation on an svar
| |svar_substr|cmd|svar_substr \ \ [len] - sets a svar to its substring.
| |wait|cmd|wait \ \ - wait for the amount of ticks specified
| |wait_for|cmd|wait_for \ \ - wait for the amount of ticks specified
| |wait_mode|0|When the pending commands should be executed. 0 is absolute, 1 is relative to when you entered the wait command.
| |wait_persist_across_loads|0|Whether pending commands should be carried across loads (1) or just be dropped (0).
| -|wait_to|cmd|wait_to \ \ - run this command on the specified session tick
| \ No newline at end of file +|wait_to|cmd|wait_to \ \ - run this command on the specified session tick
| diff --git a/src/Features/Hud/Hud.cpp b/src/Features/Hud/Hud.cpp index 957c1dd8b..6662bced1 100644 --- a/src/Features/Hud/Hud.cpp +++ b/src/Features/Hud/Hud.cpp @@ -857,7 +857,7 @@ HUD_ELEMENT_MODE2(ent_slot_serial, "0", 0, 4096, ctx->DrawElement("ent slot %d serial: %d", mode, serial); } -HUD_ELEMENT_MODE2(fps, "0", 0, 2, "Show fps (frames per second) on the SAR hud.\n", HudType_InGame | HudType_Paused | HudType_Menu) { +HUD_ELEMENT_MODE2(fps, "0", 0, 2, "Show fps (frames per second) on the SAR hud.\n1 - Show fps\n2 - Show fps with fps cap\n", HudType_InGame | HudType_Paused | HudType_Menu) { if (mode == 1) { ctx->DrawElement("fps: %.0f", g_cur_fps); } else if (mode == 2) {