Skip to content

Search extension from the end of the map name instead of from the start.#142

Merged
sezero merged 1 commit intosezero:masterfrom
Diordany:pr-search-extension
Jan 15, 2026
Merged

Search extension from the end of the map name instead of from the start.#142
sezero merged 1 commit intosezero:masterfrom
Diordany:pr-search-extension

Conversation

@Diordany
Copy link
Contributor

@Diordany Diordany commented Jan 15, 2026

Currently, the map command scans the name for a .bsp extension using strstr(). This works fine for any map that follows the naming style name.bsp, but would break with pre.bspname.bsp because it searches for the first occurence of .bsp from the start.

In the patch, I first search for the . character using Q_strrchr() which searches in reverse from the end of the string. If found, it compares using Q_strcmp() and terminates the string there if the extension was found.

I tested this by invoking the following commands:

map start
disconnect
map start.bsp
disconnect
map death
disconnect
map death.bsp
disconnect
map a.bspdeath
disconnect
map a.bspdeath.bsp

My id1/maps directory in fact has the files for testing purposes:

death.bsp
a.bspdeath.bsp

death.bsp → Death's Taste

@sezero sezero merged commit 155dc34 into sezero:master Jan 15, 2026
8 checks passed
@sezero
Copy link
Owner

sezero commented Jan 15, 2026

Thanks, this.is in. Pu1shed a minor follow-up tıo it.

@Diordany Diordany deleted the pr-search-extension branch January 15, 2026 17:48
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.

2 participants