Skip to content

Separate crosshair for pistol+shotgun and hipfire + unit tests#1804

Open
nullsystem wants to merge 5 commits intoNeotokyoRebuild:masterfrom
nullsystem:GH-661_WepTypeCrosshair
Open

Separate crosshair for pistol+shotgun and hipfire + unit tests#1804
nullsystem wants to merge 5 commits intoNeotokyoRebuild:masterfrom
nullsystem:GH-661_WepTypeCrosshair

Conversation

@nullsystem
Copy link
Collaborator

@nullsystem nullsystem commented Mar 9, 2026

Description

Removed hipfire convar and now part of crosshair bit-flag in serialization. Separate crosshair for secondary/pistols and shotguns, the others (SMGs, rifles, and machine guns) only for default crosshair. Grenades, knife, and snipers never gets the normal crosshair.

NeoUI added in ringbox-flags, similar to ringbox-bool but for flags rather than bools.

Serialization to/from string now saving bytes by omiting values same as their default counterpart and doing run-length encoding on empty segments.

Add further sanity checking, import limits to the defined bounds, validator also checks the bounds and utilized when cl_neo_crosshair set directly.

Added in unit testing, for crosshair and just-serialization functionalities.

DONE:

  • Compress non-default by default crosshair
  • Run-length encode multiple empty ;;
  • NeoUI - Replace "reverse bool labels" with custom 2-size labels
  • Maybe more general enum for weapon types
  • Unit test serialization cross versions + compression, and some functions
  • Check longest possible serialization string

Toolchain

  • Linux GCC Distro Native Arch Linux/GCC 15

Linked Issues

@nullsystem nullsystem force-pushed the GH-661_WepTypeCrosshair branch 15 times, most recently from e8e3957 to 3bcd481 Compare March 14, 2026 15:16
@nullsystem nullsystem changed the title Separate crosshair for pistol+shotgun and hipfire Separate crosshair for pistol+shotgun and hipfire + unit testing Mar 14, 2026
@nullsystem nullsystem changed the title Separate crosshair for pistol+shotgun and hipfire + unit testing Separate crosshair for pistol+shotgun and hipfire + unit tests Mar 14, 2026
@nullsystem nullsystem force-pushed the GH-661_WepTypeCrosshair branch from 3bcd481 to 8b11208 Compare March 15, 2026 00:32
@nullsystem nullsystem marked this pull request as ready for review March 15, 2026 00:32
@nullsystem nullsystem force-pushed the GH-661_WepTypeCrosshair branch 3 times, most recently from 7ccea53 to 760b839 Compare March 15, 2026 01:08
@nullsystem nullsystem requested a review from a team March 15, 2026 01:24
Removed hipfire convar and now part of crosshair bit-flag in
serialization. Separate crosshair for secondary/pistols and
shotguns, the others (SMGs, rifles, and machine guns) only for
default crosshair. Grenades, knife, and snipers never gets the
normal crosshair.

NeoUI added in ringbox-flags, similar to ringbox-bool but for
flags rather than bools.

Added in unit testing, for crosshair and just-serialization
functionalities.

DONE checklists:
* Compress non-default by default crosshair
* Run-length encode multiple empty ;;;;...
* Maybe more general enum for weapon types
* Check longest possible serialization string
* Unit test serialization cross versions + compression, and some functions
* Upgrade crosshair on startup if needed

* fixes NeotokyoRebuild#661
@nullsystem nullsystem force-pushed the GH-661_WepTypeCrosshair branch from 760b839 to c38b083 Compare March 15, 2026 01:30
@sunzenshen sunzenshen requested a review from a team March 15, 2026 04:40
@nullsystem nullsystem requested a review from sunzenshen March 15, 2026 09:59
Fixup bound logic issue and extern arrays.
@nullsystem nullsystem force-pushed the GH-661_WepTypeCrosshair branch from f0be621 to f8c2bf1 Compare March 15, 2026 10:01
@nullsystem
Copy link
Collaborator Author

@sunzenshen Updated for code review changes: f8c2bf1

sunzenshen
sunzenshen previously approved these changes Mar 15, 2026
Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

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

Optional nits: I'm not sure if the Valve utilities are that much better or even up to date but might as well point them out to decide if we want to keep using them.

@sunzenshen sunzenshen requested a review from a team March 15, 2026 16:35
@sunzenshen sunzenshen requested a review from a team March 15, 2026 16:41
Use C++ style var copy, use V_* for atoi atof
@nullsystem
Copy link
Collaborator Author

@sunzenshen 2nd code review changes: 5536977

@nullsystem nullsystem requested a review from sunzenshen March 15, 2026 20:41
@nullsystem
Copy link
Collaborator Author

@sunzenshen More sanity checking in place: 2c554ea

Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

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

The crosshairs in game look good to me, though there is a bit of a UI quirk with 1080p resolution, where if I scroll down with mousewheel on one tab, if I go to a tab that is currently set to a default to others single line config, it looks initially like the page is empty, though that can be rectified by scrolling up with the mousewheel. Maybe the scroll of the page should be reset to the start when a tab is clicked?

crosshair-scroll-transitions-to-next-tab.mp4

root setting UI reset Y-pos on crosshair-type tab change,
use V_strcpy_safe over V_memcpy for copying to mutable string
@nullsystem
Copy link
Collaborator Author

@sunzenshen 3rd code review changes: 196821d

Copy link
Contributor

@sunzenshen sunzenshen left a comment

Choose a reason for hiding this comment

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

Also tested the tab switching and the page start reset looks good.

@sunzenshen sunzenshen requested a review from a team March 16, 2026 00:57
@AdamTadeusz
Copy link
Contributor

I would argue that, since the zr68l is a dmr with the same scope with backup iron sights that the mx has, that it should also get a hip fire crosshair. Also no grenade crosshair? 🥺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Custom crosshair - Secondary different crosshair

3 participants