(svn r12921) -Codechange: coding style fixes and documentation updates.

This commit is contained in:
rubidium 2008-04-29 18:19:29 +00:00
parent 299b15c2bf
commit 6056d1fb31

View File

@ -101,10 +101,11 @@ extern Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf); extern void ShowOSErrorBox(const char *buf);
extern void InitializeRailGUI(); extern void InitializeRailGUI();
/* TODO: usrerror() for errors which are not of an internal nature but /**
* caused by the user, i.e. missing files or fatal configuration errors. * Error handling for fatal errors.
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */ * @param s the string to print.
* @note Does NEVER return.
*/
void CDECL error(const char *s, ...) void CDECL error(const char *s, ...)
{ {
va_list va; va_list va;
@ -121,6 +122,10 @@ void CDECL error(const char *s, ...)
exit(1); exit(1);
} }
/**
* Shows some information on the console/a popup box depending on the OS.
* @param str the text to show.
*/
void CDECL ShowInfoF(const char *str, ...) void CDECL ShowInfoF(const char *str, ...)
{ {
va_list va; va_list va;
@ -131,13 +136,16 @@ void CDECL ShowInfoF(const char *str, ...)
ShowInfo(buf); ShowInfo(buf);
} }
/** The current revision of OpenTTD */
extern const char _openttd_revision[]; extern const char _openttd_revision[];
static void showhelp()
{
char buf[4096], *p;
p = buf; /**
* Show the help message when someone passed a wrong parameter.
*/
static void ShowHelp()
{
char buf[4096];
char *p = buf;
p += snprintf(p, lengthof(buf), "OpenTTD %s\n", _openttd_revision); p += snprintf(p, lengthof(buf), "OpenTTD %s\n", _openttd_revision);
p = strecpy(p, p = strecpy(p,
@ -253,7 +261,12 @@ md_continue_here:;
} }
} }
/**
* Extract the resolution from the given string and store
* it in the 'res' parameter.
* @param res variable to store the resolution in.
* @param s the string to decompose.
*/
static void ParseResolution(int res[2], const char *s) static void ParseResolution(int res[2], const char *s)
{ {
const char *t = strchr(s, 'x'); const char *t = strchr(s, 'x');
@ -430,7 +443,7 @@ int ttd_main(int argc, char *argv[])
case 'x': save_config = false; break; case 'x': save_config = false; break;
case -2: case -2:
case 'h': case 'h':
showhelp(); ShowHelp();
return 0; return 0;
} }
} }
@ -778,7 +791,8 @@ static void StartScenario()
* @param filename file to be loaded * @param filename file to be loaded
* @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD
* @param newgm switch to this mode of loading fails due to some unknown error * @param newgm switch to this mode of loading fails due to some unknown error
* @param subdir default directory to look for filename, set to 0 if not needed */ * @param subdir default directory to look for filename, set to 0 if not needed
*/
bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir) bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir)
{ {
byte ogm = _game_mode; byte ogm = _game_mode;
@ -944,10 +958,11 @@ void SwitchMode(int new_mode)
} }
/* State controlling game loop. /**
* The state must not be changed from anywhere * State controlling game loop.
* but here. * The state must not be changed from anywhere but here.
* That check is enforced in DoCommand. */ * That check is enforced in DoCommand.
*/
void StateGameLoop() void StateGameLoop()
{ {
/* dont execute the state loop during pause */ /* dont execute the state loop during pause */
@ -1044,8 +1059,7 @@ static void DoAutosave()
#if defined(PSP) #if defined(PSP)
/* Autosaving in networking is too time expensive for the PSP */ /* Autosaving in networking is too time expensive for the PSP */
if (_networking) if (_networking) return;
return;
#endif /* PSP */ #endif /* PSP */
if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) { if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
@ -1061,8 +1075,9 @@ static void DoAutosave()
} }
DEBUG(sl, 2, "Autosaving to '%s'", buf); DEBUG(sl, 2, "Autosaving to '%s'", buf);
if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) {
ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0);
}
} }
static void ScrollMainViewport(int x, int y) static void ScrollMainViewport(int x, int y)
@ -1075,6 +1090,7 @@ static void ScrollMainViewport(int x, int y)
WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom); WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
} }
} }
/** /**
* Describes all the different arrow key combinations the game allows * Describes all the different arrow key combinations the game allows
* when it is in scrolling mode. * when it is in scrolling mode.
@ -1189,9 +1205,7 @@ void BeforeSaveGame()
static void ConvertTownOwner() static void ConvertTownOwner()
{ {
TileIndex tile; for (TileIndex tile = 0; tile != MapSize(); tile++) {
for (tile = 0; tile != MapSize(); tile++) {
switch (GetTileType(tile)) { switch (GetTileType(tile)) {
case MP_ROAD: case MP_ROAD:
if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) { if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) {