Skip to content

Added a game_crash entity that allows mappers to crash the game and display a message#523

Closed
Wikot235 wants to merge 2 commits intomapbase-source:developfrom
Wikot235:game_crash
Closed

Added a game_crash entity that allows mappers to crash the game and display a message#523
Wikot235 wants to merge 2 commits intomapbase-source:developfrom
Wikot235:game_crash

Conversation

@Wikot235
Copy link
Copy Markdown

@Wikot235 Wikot235 commented Apr 3, 2026

game_crash

This PR adds a new game_crash entity to Mapbase, it allows mappers to crash the game and display a message.

Inputs

  • Crash

Keyvalues

  • title - text in the top bar of the message box
  • message - text in the message box
  • type - how the entity behaves when the crash input is fired, 0 - crashes without a message box, 1 - crashes with an engine error window, 2 - crashes with a message box

Now, you might be wondering, what is the difference between type 1 and type 2. There is one big problem with the Error() function used in type 1, you can't change the title of the window, as the function declaration is in tier0 (which we don't have access to).

Because of that, I created the type 2, it's using the MessageBoxA function from windows.h, but it's not perfect either, the first thing, is that I can't perfectly replicate the behavior of the Error() function. The Error() function makes the message box appear AFTER the game window is closed, but with MessageBoxA it shows the message box and only after clicking OK it closes the game window. Apart from that, it generates lots of "macro redefinition" warnings. It only works on Windows, on other OS it will fall back to Error(), but I have no idea how Error() behaves on Linux to be honest, so that might be unnecessary.


PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

@Wikot235 Wikot235 marked this pull request as draft April 3, 2026 18:09
@Blixibon
Copy link
Copy Markdown
Member

This may come across as more of a personal philosophy than something relating to a specific guideline, but I don't think maps should have the intentional ability to crash the game. The only benevolent use I could see for it is a gag or 4th wall break of some kind, and I don't think that's worth having in Mapbase itself. Source engine games and mods aren't always lightweight, and depending on the context, it can be very inconvenient to have to relaunch them. I briefly considered adding an Error input to logic_console way back in 2018 and decided against it for this reason.

(also, for future reference, I noticed this file isn't mounted by a VPC, which is needed for new code files. In this case, you would've needed to put it in server_mapbase.vpc)

@Blixibon Blixibon closed this Apr 23, 2026
@Wikot235
Copy link
Copy Markdown
Author

Yeah, I agree, the use cases for this entity are very niche, but isn't giving mappers more freedom one of the goals of Mapbase? I just don't understand why we shouldn't give mod makers more freedom over what happens in their maps. Of course, if someone really wants it, they can just add it with a few lines of code, but why make it so much more complicated when we could just have an entity for that?

@TeamSpen210
Copy link
Copy Markdown

If you really want to crash the game, there's a crash command. Though, you probably shouldn't, just disconnect or exit.

@GrubPL
Copy link
Copy Markdown

GrubPL commented May 8, 2026

Ngl one of the only times where crashing (with an error message) should be considered a feature when it's done to like make sure the games directory is the correct name
(And maybe a few others I'm not thinkin about)

But it shouldn't be an entity that can just crash your game because the mapper wanted to, it just seems a bit too niche, and as TeamSpen210 said, there's already a crash command

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.

4 participants