Skip to content

Remove crosshair network from (C)NEOPlayer datatable, simplify caching - #2053

Open
nullsystem wants to merge 3 commits into
NeotokyoRebuild:masterfrom
nullsystem:XHairRefactorDataCache
Open

Remove crosshair network from (C)NEOPlayer datatable, simplify caching#2053
nullsystem wants to merge 3 commits into
NeotokyoRebuild:masterfrom
nullsystem:XHairRefactorDataCache

Conversation

@nullsystem

Copy link
Copy Markdown
Collaborator

Description

Crosshair is already now networked in player resource, so no longer needed to be networked from server to client in (C)NEOPlayer and turned into a simple array server-side. The networked crosshair caching also simplified in client-side crosshair HUD.

Toolchain

  • Linux GCC Distro Native Arch/GCC 16

Linked Issues

  • fixes #
  • related #

Crosshair is already now networked in player resource, so no longer
needed to be networked from server to client in (C)NEOPlayer and turned
into a simple array server-side. The networked crosshair caching also
simplified in client-side crosshair HUD.
@nullsystem
nullsystem force-pushed the XHairRefactorDataCache branch from 63b8211 to c819142 Compare August 6, 2026 22:44
@nullsystem
nullsystem requested a review from a team August 7, 2026 08:43
@sunmachine sunmachine self-assigned this Aug 9, 2026
@sunmachine
sunmachine self-requested a review August 9, 2026 15:54
@sunmachine

Copy link
Copy Markdown
Contributor

Found a bug where the crosshair gets stale.

I am moving fast this morning but I was able to cobble the repro together @nullsystem.

As for a fix, I think you just need to clear the cached compare string m_szLocalStrPlayerCrosshair[0] = '\0' whenever the non-spectator path imports into m_crosshairInfo. Like when inside the !bTakeSpecCrosshair block at hud_crosshair.cpp line 543, so the spectator path can never skip a re-import based on a cache that no longer describes m_crosshairInfo.

Bug reproduction steps

Two scripts

xhairtest.cfg

// Spectator crosshair repro, phase 1: launch.
//
// Tests a client-side caching issue where toggling cl_neo_crosshair_network
// off and back on while spectating a player can leave YOUR crosshair rendered
// instead of the spectated player's (relevant to the caching changes in
// https://github.com/NeotokyoRebuild/neo/pull/2053).
//
// Run from the console:  exec xhairtest
// After the map finishes loading, press F9 and follow the echoed steps.
//
// Prerequisite (one time): in Settings -> Crosshair, enable the HIPFIRE
// crosshair option for your own config. The stock default hides the
// crosshair entirely unless aiming down sights, so "crosshair visible at
// hipfire" is the signal that separates your crosshair from the spectated
// bot's default one.
//
// NOTE: this rebinds F8/F9/F10 (binds are archived in config.cfg).
// Restore your own binds afterwards if you use those keys.

// Keep the roster at exactly the one bot we add manually (quota default is 10!)
neo_bot_quota 0

// Deterministic starting state for the test
cl_neo_crosshair_network 1
crosshair 1

bind F9  "exec xhairtest_bots"
bind F8  "spec_next; spec_mode 4"
bind F10 "toggle cl_neo_crosshair_network 0 1"

echo ""
echo ">>> xhairtest: loading ntre_oilstain_ctg — press F9 once the map is up."
echo ""

map ntre_oilstain_ctg

xhairtest_bots.cfg

// Spectator crosshair repro, phase 2: bot + spectate.
// Executed by pressing F9 (bound in xhairtest.cfg). 
// Pressing F9 multiple times adds more bots.
//
// With players on only one team the round stays Idle, so no round transition
// fires the client-side crosshair cache resets (resetPlayersCrosshair) that
// could mask the stale-cache bug. If the bot never spawns while Idle, add a
// second bot on the other team (bot_add nsf noquota) to force a round start —
// the test still works, just run the toggles within a single round.

// nb_stop is cheat-flagged; cheats also let you freeze the bot later if wanted
sv_cheats 1

bot_add jinrai noquota XHAIRBOT
jointeam 1

echo ""
echo ">>> xhairtest steps:"
echo ">>>  1. Press F8 until you are FIRST-PERSON on XHAIRBOT (crosshair only draws in-eye)."
echo ">>>     While the bot is NOT aiming, seeing NO crosshair is correct:"
echo ">>>     its default config hides the crosshair at hipfire."
echo ">>>  2. Press F10 (network OFF) -> YOUR hipfire-enabled crosshair appears."
echo ">>>  3. Press F10 again (network ON), wait ~1s:"
echo ">>>       Expected: crosshair disappears again (bot default, hipfire hidden)."
echo ">>>       Bugged:   YOUR crosshair stays until the spec target changes."
echo ""

Launch options: +exec xhairtest
Crosshair settings: Make sure you have hipfire crosshair enabled for ease of testing.

Procedure

  1. Launch. xhairtest.cfg auto-execs: binds F8/F9/F10, sets neo_bot_quota 0, loads ntre_oilstain_ctg.
  2. Press F9 (runs xhairtest_bots.cfg: adds XHAIRBOT on Jinrai, puts you on spectator). If stuck on "NOT ENOUGH PLAYERS": bot_add nsf noquota, then optionally nb_stop 1.
  3. Press F8 until first-person on any bot. Baseline should be no crosshair (bot default hides hipfire. crosshair only draws ADS/in-eye).
  4. Press F10 (network OFF) → your crosshair appears.
  5. Press F10 again (network ON), might be a frame delay on this one.

Correct: crosshair disappears. Verified on master
Bugged: your crosshair stays — and persists even when switching bots, since all bots share the identical default serial. Verified on nullsystem:XHairRefactorDataCache

Video demo

ntre_bug_pr_2053_smol.mp4

@sunmachine sunmachine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my above post.

@nullsystem
nullsystem requested a review from sunmachine August 13, 2026 19:23
@nullsystem

Copy link
Copy Markdown
Collaborator Author

@sunmachine Moved the string copy to the later if block to fix it: f8f5bbd

@nullsystem nullsystem added the New Changes for Reviewers New changes has been made. This label is mostly to notify reviewers. label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Changes for Reviewers New changes has been made. This label is mostly to notify reviewers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants