# HG changeset patch # User peter1138 # Date 1164393562 0 # Node ID a479ef9c16a5eb6cf6270600616b9c10d228a83d # Parent d64a7dc0fcdb402e0beaecdb797291b677cf91d1 (svn r7250) -Codechange: Shuffle sprite loading and character width caching around a bit. This reduces the number of times the sprites are loaded from 5 to 2, just for the intro game. diff -r d64a7dc0fcdb -r a479ef9c16a5 genworld.c --- a/genworld.c Fri Nov 24 18:37:40 2006 +0000 +++ b/genworld.c Fri Nov 24 18:39:22 2006 +0000 @@ -252,18 +252,19 @@ /* Make sure everything is done via OWNER_NONE */ _current_player = OWNER_NONE; + /* Load the right landscape stuff */ + GfxLoadSprites(); + LoadStringWidthTable(); + InitializeGame(IG_DATE_RESET, _gw.size_x, _gw.size_y); PrepareGenerateWorldProgress(); /* Re-init the windowing system */ ResetWindowSystem(); - LoadStringWidthTable(); /* Create toolbars */ SetupColorsAndInitialWindow(); - /* Load the right landscape stuff */ - GfxLoadSprites(); if (_network_dedicated || (_gw.thread = OTTDCreateThread(&_GenerateWorld, NULL)) == NULL) { DEBUG(misc, 1) ("[Sl] Cannot create savegame thread, reverting to single-threaded mode..."); diff -r d64a7dc0fcdb -r a479ef9c16a5 gfx.c --- a/gfx.c Fri Nov 24 18:37:40 2006 +0000 +++ b/gfx.c Fri Nov 24 18:39:22 2006 +0000 @@ -1613,6 +1613,9 @@ { uint i; + /* Initialize the unicode to sprite mapping table */ + InitializeUnicodeGlyphMap(); + /* Normal font */ for (i = 0; i != 224; i++) { _stringwidth_table[FS_NORMAL][i] = GetGlyphWidth(FS_NORMAL, i + 32); diff -r d64a7dc0fcdb -r a479ef9c16a5 misc_gui.c --- a/misc_gui.c Fri Nov 24 18:37:40 2006 +0000 +++ b/misc_gui.c Fri Nov 24 18:39:22 2006 +0000 @@ -1659,6 +1659,7 @@ if (p1 == 4) p1 = 0; _opt.landscape = p1; GfxLoadSprites(); + LoadStringWidthTable(); MarkWholeScreenDirty(); return _opt.landscape; } diff -r d64a7dc0fcdb -r a479ef9c16a5 openttd.c --- a/openttd.c Fri Nov 24 18:37:40 2006 +0000 +++ b/openttd.c Fri Nov 24 18:39:22 2006 +0000 @@ -281,9 +281,6 @@ CLRBITS(_display_opt, DO_TRANS_BUILDINGS); // don't make buildings transparent in intro _opt_ptr = &_opt_newgame; - GfxLoadSprites(); - LoadStringWidthTable(); - // Setup main window ResetWindowSystem(); SetupColorsAndInitialWindow(); @@ -439,11 +436,6 @@ // This must be done early, since functions use the InvalidateWindow* calls InitWindowSystem(); - GfxLoadSprites(); - /* Initialize the unicode to sprite mapping table */ - InitializeUnicodeGlyphMap(); - LoadStringWidthTable(); - DEBUG(driver, 1) ("Loading drivers..."); LoadDriver(SOUND_DRIVER, _ini_sounddriver); LoadDriver(MUSIC_DRIVER, _ini_musicdriver); @@ -463,7 +455,6 @@ /* Make sure _patches is filled with _patches_newgame if we switch to a game directly */ if (_switch_mode != SM_NONE) { _opt = _opt_newgame; - GfxLoadSprites(); UpdatePatches(); } @@ -655,11 +646,8 @@ return; } - GfxLoadSprites(); - // Reinitialize windows ResetWindowSystem(); - LoadStringWidthTable(); SetupColorsAndInitialWindow(); @@ -1157,6 +1145,7 @@ // Load the sprites GfxLoadSprites(); + LoadStringWidthTable(); /* Connect front and rear engines of multiheaded trains and converts * subtype to the new format */