Commit 3c6d873fe5584c41a0038758e52ecca843c1e182

  • avatar
  • Bertram <bertram @ceg…el.net>
  • Thu Oct 22 02:31:21 CEST 2009
Optimized game startup sequence for eAthena in order to cope a bit better with network errors.

Unfortunately, it isn't enough: The bug seems to be elsewhere...
  
9797 particleEngine->setMap(newMap);
9898 viewport->setMap(newMap);
9999
100 delete mCurrentMap;
101 mCurrentMap = newMap;
102
103 Net::getGameHandler()->mapLoaded(mapPath);
104
100105 // Initialize map-based particle effects
101106 if (newMap)
102107 newMap->initializeParticleEffects(particleEngine);
112112 if (newMusic != oldMusic)
113113 sound.playMusic(newMusic);
114114
115 delete mCurrentMap;
116 mCurrentMap = newMap;
117
118 Net::getGameHandler()->mapLoaded(mapPath);
119115 return true;
120116}
121117
src/game.cpp
(52 / 45)
  
212212}
213213
214214/**
215 * Initialize every game sub-engines in the right order
216 */
217static void initEngines()
218{
219 engine = new Engine;
220
221 beingManager = new BeingManager;
222 commandHandler = new CommandHandler;
223 floorItemManager = new FloorItemManager;
224 channelManager = new ChannelManager;
225 effectManager = new EffectManager;
226
227 particleEngine = new Particle(NULL);
228 particleEngine->setupEngine();
229}
230
231/**
215232 * Create all the various globally accessible gui windows
216233 */
217234static void createGuiWindows()
318318{
319319 done = false;
320320
321 createGuiWindows();
321 createGuiWindows();
322322
323 mWindowMenu = new WindowMenu;
324 windowContainer->add(mWindowMenu);
323 mWindowMenu = new WindowMenu;
324 windowContainer->add(mWindowMenu);
325325
326 engine = new Engine;
326 initEngines();
327327
328 beingManager = new BeingManager;
329 commandHandler = new CommandHandler;
330 floorItemManager = new FloorItemManager;
331 channelManager = new ChannelManager;
332 effectManager = new EffectManager;
328 // Initialize logic and seconds counters
329 tick_time = 0;
330 mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL);
331 mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL);
333332
334 particleEngine = new Particle(NULL);
335 particleEngine->setupEngine();
333 // This part is eAthena specific
334 // For TMWserv, the map is obtained
335 // with the GPMSG_PLAYER_MAP_CHANGE flag.
336 map_path = map_path.substr(0, map_path.rfind("."));
337 if (!map_path.empty())
338 engine->changeMap(map_path);
336339
337 // Initialize logic and seconds counters
338 tick_time = 0;
339 mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL);
340 mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL);
340 // Initialize beings
341 beingManager->setPlayer(player_node);
341342
342 // Initialize frame limiting
343 config.addListener("fpslimit", this);
344 optionChanged("fpslimit");
343 /*
344 * To prevent the server from sending data before the client
345 * has initialized, I've modified it to wait for a "ping"
346 * from the client to complete its initialization
347 *
348 * Note: This only affects the latest eAthena version. This
349 * packet is handled by the older version, but its response
350 * is ignored by the client
351 */
352 Net::getGameHandler()->ping(tick_time);
345353
346 // Initialize beings
347 beingManager->setPlayer(player_node);
354 // Initialize frame limiting
355 config.addListener("fpslimit", this);
356 optionChanged("fpslimit");
348357
349 Joystick::init();
350 // TODO: The user should be able to choose which one to use
351 // Open the first device
352 if (Joystick::getNumberOfJoysticks() > 0)
353 joystick = new Joystick(0);
358 Joystick::init();
359 // TODO: The user should be able to choose which one to use
360 // Open the first device
361 if (Joystick::getNumberOfJoysticks() > 0)
362 joystick = new Joystick(0);
354363
355 // fade out logon-music here too to give the desired effect of "flowing"
356 // into the game.
357 sound.fadeOutMusic(1000);
358 map_path = map_path.substr(0, map_path.rfind("."));
359
360 if (!map_path.empty())
361 engine->changeMap(map_path);
362
363 setupWindow->setInGame(true);
364
365 /*
366 * To prevent the server from sending data before the client
367 * has initialized, I've modified it to wait for a "ping"
368 * from the client to complete its initialization
369 *
370 * Note: This only affects the latest eAthena version. This
371 * packet is handled by the older version, but its response
372 * is ignored by the client
373 */
374 Net::getGameHandler()->ping(tick_time);
364 setupWindow->setInGame(true);
375365}
376366
377367Game::~Game()
  
10921092
10931093 case STATE_CONNECT_GAME:
10941094 logger->log("State: CONNECT GAME");
1095
1096 // Allow any alpha opacity
1097 SkinLoader::instance()->setMinimumOpacity(-1.0f);
1098
1099 // Fade out logon-music here too to give the desired effect
1100 // of "flowing" into the game.
1101 sound.fadeOutMusic(1000);
1102
10951103 Net::getGameHandler()->connect();
10961104 currentDialog = new ConnectionDialog(STATE_SWITCH_CHARACTER);
10971105 break;
11101110 config.setValue("lastCharacter", player_node->getName());
11111111
11121112 Net::getGameHandler()->inGame();
1113
1114 // Allow any alpha opacity
1115 SkinLoader::instance()->setMinimumOpacity(-1.0f);
1116
1117 sound.fadeOutMusic(1000);
11181113
11191114 delete setupButton;
11201115 delete desktop;