From 453b30e387f8d8ab1839d96b0d1f9a8fea841292 Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 6 Feb 2006 09:18:04 +0000 Subject: (svn r3564) Several smaller changes: - Don't treat non-booleans as booleans - Reduce variable scope - Bracing - Use DeMorgan's law to make conditionals easier to read - if cascade -> switch - Replace some magic numbers by symbolic names - Avoid assignments within other statements --- openttd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'openttd.c') diff --git a/openttd.c b/openttd.c index 0649ab55a..6a50ce66c 100644 --- a/openttd.c +++ b/openttd.c @@ -657,7 +657,7 @@ static void StartScenario(void) } _opt_ptr = &_opt; - memcpy(&_opt_ptr->diff, &_opt_newgame.diff, sizeof(GameDifficulty)); + memcpy(&_opt_ptr->diff, &_opt_newgame.diff, sizeof(_opt_ptr->diff)); _opt.diff_level = _opt_newgame.diff_level; // Inititalize data @@ -731,7 +731,7 @@ void SwitchMode(int new_mode) case SM_NEWGAME: /* New Game --> 'Random game' */ #ifdef ENABLE_NETWORK if (_network_server) { - snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "Random Map"); + snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map"); } #endif /* ENABLE_NETWORK */ MakeNewGame(); @@ -740,7 +740,7 @@ void SwitchMode(int new_mode) case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ #ifdef ENABLE_NETWORK if (_network_server) { - snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded scenario)", _file_to_saveload.title); + snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title); } #endif /* ENABLE_NETWORK */ StartScenario(); @@ -757,7 +757,7 @@ void SwitchMode(int new_mode) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // decrease pause counter (was increased from opening load dialog) #ifdef ENABLE_NETWORK if (_network_server) { - snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded game)", _file_to_saveload.title); + snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); } #endif /* ENABLE_NETWORK */ } -- cgit v1.2.3-70-g09d2