From 3e11b10e3f0248996525ecf1872973fa879c4b28 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 31 May 2023 23:34:47 +0000 Subject: [PATCH] Useful tools for debugging --- qcsrc/server/client.qc | 31 +++++++++++++++++++++ qcsrc/server/client.qh | 1 + xonotic-client.cfg | 12 +++++++++ xonotic-server.cfg | 61 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index f78d772c5..886a29163 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -2064,6 +2065,32 @@ bool joinAllowed(entity this) return true; } +void show_entnum(entity this) +{ + // waypoint editor implements a similar feature for waypoints + if (waypointeditor_enabled) + return; + + if (wasfreed(this.wp_aimed)) + this.wp_aimed = NULL; + + WarpZone_crosshair_trace_plusvisibletriggers(this); + entity ent = NULL; + if (trace_ent) + { + ent = trace_ent; + if (ent != this.wp_aimed) + { + string str = sprintf( + "^7ent #%d\n^8 netname: ^3%s\n^8 classname: ^5%s\n^8 origin: ^2'%s'", + etof(ent), ent.netname, ent.classname, vtos(ent.origin)); + debug_text_3d((ent.absmin + ent.absmax) * 0.5, str, 0, 7, '0 0 0'); + } + } + if (this.wp_aimed != ent) + this.wp_aimed = ent; +} + .string shootfromfixedorigin; .bool dualwielding_prev; bool PlayerThink(entity this) @@ -2085,6 +2112,8 @@ bool PlayerThink(entity this) if (frametime) player_powerups(this); + if (frametime && autocvar_sv_show_entnum) show_entnum(this); + if (IS_DEAD(this)) { if (this.personal && g_race_qualifying) { if (time > this.respawn_time) { @@ -2229,6 +2258,8 @@ void ObserverOrSpectatorThink(entity this) } } + if (frametime && autocvar_sv_show_entnum) show_entnum(this); + if (IS_BOT_CLIENT(this) && !CS(this).autojoin_checked) { CS(this).autojoin_checked = true; diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 33b9d4511..b9ce6fdf0 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -7,6 +7,7 @@ #include bool autocvar__notarget; +bool autocvar_sv_show_entnum; int autocvar_g_balance_armor_start; float autocvar_g_balance_pause_armor_rot_spawn; float autocvar_g_balance_pause_fuel_rot_spawn; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index add42efd3..0fa5f4a44 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -700,6 +700,18 @@ seta cl_cts_noautoswitch 0 "Prevent forced switching to new weapons in CTS" set cl_stripcolorcodes 0 "experimental feature (notes: strips ALL color codes from messages!)" +// prints view position and orientation +alias posview_camera_info "prvm_globalget client view_origin _posview_tmpcvar1; prvm_globalget client view_angles _posview_tmpcvar2; _posview_camera_info_2" +alias _posview_camera_info_2 "echo view_origin ^7\"$_posview_tmpcvar1\"; echo view_angles ^7\"$_posview_tmpcvar2\"" + +// prints csqcplayer position and orientation +// NOTE: for some reason .angles contains only yaw, .v_angles only pitch, .v_angle_old both +alias posview_csqcplayer_info "prvm_globalget client csqcplayer _posview_tmpcvar1; _posview_csqcplayer_info2" +alias _posview_csqcplayer_info2 "prvm_edictget client $_posview_tmpcvar1 origin _posview_tmpcvar1; prvm_edictget client $_posview_tmpcvar1 v_angle_old _posview_tmpcvar2; _posview_csqcplayer_info3" +alias _posview_csqcplayer_info3 "echo csqcplayer origin ^7\"$_posview_tmpcvar1\"; echo csqcplayer angles ^7\"$_posview_tmpcvar2\"" +set _posview_tmpcvar1 "0" +set _posview_tmpcvar2 "0" + // Demo camera set camera_enable 0 "Enables the camera for demo playback" set camera_free 0 "Free camera instead of chasing the player" diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 03404ebf4..346fdbb58 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -497,6 +497,44 @@ set debug_text_3d_default_align 0 "Default text alignment for debug_text_3d()" set debug_text_3d_default_duration 10 "Default duration for debug_text_3d()" set debug_text_3d_default_velocity "0 -10 0" "Default velocity for debug_text_3d() in screen coords (X and Y from top left)" +///////// qc debugger shortcuts ///////// +// breakpoint +alias ps_b "prvm_breakpoint server ${* ?}" +alias pc_b "prvm_breakpoint client ${* ?}" +alias pm_b "prvm_breakpoint menu ${* ?}" + +// entity +alias ps_e "prvm_edict server ${* ?}" +alias pc_e "prvm_edict client ${* ?}" +alias pm_e "prvm_edict menu ${* ?}" + +// field get +alias ps_fg "prvm_edictget server ${* ?}" +alias pc_fg "prvm_edictget client ${* ?}" +alias pm_fg "prvm_edictget menu ${* ?}" +// field set +alias ps_fs "prvm_edictset server ${* ?}" +alias pc_fs "prvm_edictset client ${* ?}" +alias pm_fs "prvm_edictset menu ${* ?}" +// field watchpoint +alias ps_fw "prvm_edictwatchpoint server ${* ?}" +alias pc_fw "prvm_edictwatchpoint client ${* ?}" +alias pm_fw "prvm_edictwatchpoint menu ${* ?}" + +// global get +alias ps_gg "prvm_globalget server ${* ?}" +alias pc_gg "prvm_globalget client ${* ?}" +alias pm_gg "prvm_globalget menu ${* ?}" +// global set +alias ps_gs "prvm_globalset server ${* ?}" +alias pc_gs "prvm_globalset client ${* ?}" +alias pm_gs "prvm_globalset menu ${* ?}" +// global watchpoint +alias ps_gw "prvm_globalwatchpoint server ${* ?}" +alias pc_gw "prvm_globalwatchpoint client ${* ?}" +alias pm_gw "prvm_globalwatchpoint menu ${* ?}" +///////// qc debugger shortcuts END ///////// + // otherwise, antilag breaks sv_gameplayfix_consistentplayerprethink 1 @@ -563,6 +601,27 @@ set g_playerstats_playerdetail_autoupdatetime 1800 // automatically update every // autoscreenshots set g_max_info_autoscreenshot 3 "how many info_autoscreenshot entities are allowed" + +// commands for saving and reloading the current posistion and view, even after a map restart +// useful for taking screenshots and comparing things +alias posview_load "_posview_set \"$_posview_pos\" \"$_posview_angles\"" +alias posview_save "_posview_save_to_cvars _posview_pos _posview_angles; _posview_save_$posview_verbose" +alias _posview_save_0 "" +alias _posview_save_1 "posview_info" + +// NOTE without ^7 the quote mark wouldn't be printed +alias posview_info "echo saved player posview:; echo _posview_pos ^7\"$_posview_pos\"; echo _posview_angles ^7\"$_posview_angles\"" +seta posview_verbose 1 "also print posview on save so that a previously saved posview can be restored by copying it from the OS console log and pasted to the Xonotic console" + +// internal commands: +// _posview_set : sets the specified position and view angles ("x y z" "pitch yaw roll") +// _posview_save_to_cvars : saves current position and view angles to the specified cvars +alias _posview_set "prvm_edictset server 1 origin \"$1\"; prvm_edictset server 1 fixangle 1; prvm_edictset server 1 angles \"$2\"" +alias _posview_save_to_cvars "prvm_edictget server 1 origin ${1 ?}; prvm_edictget server 1 v_angle ${2 ?}" +seta _posview_pos "0 0 0" +seta _posview_angles "0 0 0" + + // mod names for server browser // note: the lowest of these that mismatches default is used set g_mod_physics "" "Current physics config name" @@ -591,6 +650,8 @@ set sv_showspectators 1 "Show who's spectating who in the player info panel when set sv_damagetext 2 "<= 0: disabled, >= 1: visible to spectators, >= 2: visible to attacker, >= 3: all players see everyone's damage" +set sv_show_entnum 0 "Show the number and some info of the entity you're aiming at" + set sv_showfps 0 "Show player's FPS counters in the scoreboard. This setting acts as a delay in seconds between updates. NOTE: this feature gathers performance telemetry, it may require consent from players on the server depending on your legislation" set sv_doors_always_open 0 "If set to 1 don't close doors which after they were open" -- 2.39.2