[Freeciv-Dev] concerning the use of assert
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
I've had a little discussion with Ross about the use of asserts. While I
enjoy using them liberally myself, I can see his point about making the
game a minefield of potential cores that can often be avoided when we can
instead return to a sane state.
The problem with doing such error recovery instead of an assert is that
with an assert we get error reporting, with the former the error goes
unreported.
There should be a way to get the best of both worlds.
How about a function which can be called instead of assert, and which
writes a bug report to file then creates a savegame to match, and finally
notifies the player that a bug was detected and that he/she should send
the bug report in to us. Maybe we could even launch gdb on ourself to get
a backtrace on some platforms. Then do error recovery as best as we can.
The interface could be something like
bool error(condition)
which returns (!condition), so that we can do
if (error(punit == NULL || pdefender == NULL)) {
/* error recovery */
return;
}
and then on some commandline switch becomes an assert(FALSE) instead for
debugging.
Though maybe the create-savegame part should be separate from the error()
call, since we may not always be in a position to create a sane
savegame...
Other ideas?
Yours
Per
"I don't see why people are so upset about cloning sheep. American
television networks have been doing that to their audiences for years."
-- Jello Biafra
- [Freeciv-Dev] concerning the use of assert,
Per I. Mathisen <=
- [Freeciv-Dev] Re: concerning the use of assert, Per I. Mathisen, 2002/09/01
- [Freeciv-Dev] Re: concerning the use of assert, Gregory Berkolaiko, 2002/09/01
- [Freeciv-Dev] Re: concerning the use of assert, Per I. Mathisen, 2002/09/01
- [Freeciv-Dev] Re: concerning the use of assert, Raimar Falke, 2002/09/06
- [Freeciv-Dev] Re: concerning the use of assert, Per I. Mathisen, 2002/09/08
- [Freeciv-Dev] Re: concerning the use of assert, Raimar Falke, 2002/09/09
- [Freeciv-Dev] Re: concerning the use of assert, Per I. Mathisen, 2002/09/09
- [Freeciv-Dev] autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/10
- [Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Ross W. Wetmore, 2002/09/13
- [Freeciv-Dev] Re: autobacktrace (was: concerning the use of assert), Reinier Post, 2002/09/13
|
|