

1·
18 days agoYou actually shouldn’t do this!
This doesn’t introduce a new scope, so accidentally using x outside of the case block is UB. Instead you should introduce a new scope like so:
switch (foo) {
case BAZ: {
int x = ...;
foobar(x);
}
}
Sadly I don’t think that’s possible. Modern games are much larger and more complex than the traditional games that you could use save states in.
Not only would you need to save several gigs of RAM to disk, you also need to somehow capture the state of things like graphics cards and potentially the filesystem and other devices, none of which are trivial.