diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-26 10:56:45 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-01-26 10:56:45 +0000 |
commit | 69ccb03b44f324f17d02b9e27e71c34850f71139 (patch) | |
tree | e5970b86bbe0cce062d66b13d70f16f5c4ae912d | |
parent | 3e424a68b7dd438ba1a316af3a92f01dde7c71ac (diff) | |
download | mana-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.gz mana-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.bz2 mana-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.xz mana-69ccb03b44f324f17d02b9e27e71c34850f71139.zip |
Moved some setup code out of the game loop into the setup functions. Setup functions are now called from the outside.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/game.cpp | 78 | ||||
-rw-r--r-- | src/game.h | 7 | ||||
-rw-r--r-- | src/main.cpp | 2 |
4 files changed, 59 insertions, 34 deletions
@@ -1,3 +1,9 @@ +2006-01-26 Björn Steinbrink <B.Steinbrink@gmx.de> + + * src/game.cpp, src/game.h, src/main.cpp: Moved some setup code out of + the game loop into the setup functions. Setup functions are now called + from the outside. + 2006-01-22 Eugenio Favalli <elvenprogrammer@gmail.com> * The Mana World.dev, src/main.cpp: Updated Dev-Cpp project file, fixed diff --git a/src/game.cpp b/src/game.cpp index edc1789f..2387a041 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -115,6 +115,17 @@ DebugWindow *debugWindow; BeingManager *beingManager = NULL; +BeingHandler *beingHandler; +BuySellHandler *buySellHandler; +ChatHandler *chatHandler; +EquipmentHandler *equipmentHandler; +InventoryHandler *inventoryHandler; +ItemHandler *itemHandler; +NPCHandler *npcHandler; +PlayerHandler *playerHandler; +SkillHandler *skillHandler; +TradeHandler *tradeHandler; + const int MAX_TIME = 10000; /** @@ -253,6 +264,9 @@ void destroyGuiWindows() void do_init(Network *network) { + createGuiWindows(network); + engine = new Engine(network); + beingManager = new BeingManager(network); // Initialize timers @@ -288,6 +302,28 @@ void do_init(Network *network) logger->log("Buttons: %i", SDL_JoystickNumButtons(joypad)); } } + + beingHandler = new BeingHandler(); + buySellHandler = new BuySellHandler(); + chatHandler = new ChatHandler(); + equipmentHandler = new EquipmentHandler(); + inventoryHandler = new InventoryHandler(); + itemHandler = new ItemHandler(); + npcHandler = new NPCHandler(); + playerHandler = new PlayerHandler(); + skillHandler = new SkillHandler(); + tradeHandler = new TradeHandler(); + + network->registerHandler(beingHandler); + network->registerHandler(buySellHandler); + network->registerHandler(chatHandler); + network->registerHandler(equipmentHandler); + network->registerHandler(inventoryHandler); + network->registerHandler(itemHandler); + network->registerHandler(npcHandler); + network->registerHandler(playerHandler); + network->registerHandler(skillHandler); + network->registerHandler(tradeHandler); } bool saveScreenshot(SDL_Surface *screenshot) @@ -316,34 +352,8 @@ bool saveScreenshot(SDL_Surface *screenshot) void game(Network *network) { - createGuiWindows(network); - engine = new Engine(network); - do_init(network); - int gameTime = tick_time; - BeingHandler beingHandler; - BuySellHandler buySellHandler; - ChatHandler chatHandler; - EquipmentHandler equipmentHandler; - InventoryHandler inventoryHandler; - ItemHandler itemHandler; - NPCHandler npcHandler; - PlayerHandler playerHandler; - SkillHandler skillHandler; - TradeHandler tradeHandler; - - network->registerHandler(&beingHandler); - network->registerHandler(&buySellHandler); - network->registerHandler(&chatHandler); - network->registerHandler(&equipmentHandler); - network->registerHandler(&inventoryHandler); - network->registerHandler(&itemHandler); - network->registerHandler(&npcHandler); - network->registerHandler(&playerHandler); - network->registerHandler(&skillHandler); - network->registerHandler(&tradeHandler); - while (!done) { // Handle all necessary game logic @@ -372,16 +382,24 @@ void game(Network *network) network->flush(); network->dispatchMessages(); } - - do_exit(network); } -void do_exit(Network *network) +void do_exit() { + delete beingHandler; + delete buySellHandler; + delete chatHandler; + delete equipmentHandler; + delete inventoryHandler; + delete itemHandler; + delete npcHandler; + delete playerHandler; + delete skillHandler; + delete tradeHandler; + delete engine; delete player_node; destroyGuiWindows(); - network->disconnect(); if (joypad != NULL) { @@ -30,7 +30,6 @@ #define SPEECH_MAX_TIME 100 class Network; -class NPC; extern std::string map_path; extern int fps; @@ -67,14 +66,14 @@ void game(Network*); void do_input(Network*); /** - * Parse data received from map server into input buffer + * Initialize */ -void do_parse(Network*); +void do_init(Network*); /** * Clean the engine */ -void do_exit(Network*); +void do_exit(); /** * Returns elapsed time. (Warning: very unsafe function, it supposes the delay diff --git a/src/main.cpp b/src/main.cpp index 5fe43598..9c45614b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -607,7 +607,9 @@ int main(int argc, char *argv[]) login_wallpaper = NULL; logger->log("State: GAME"); + do_init(network); game(network); + do_exit(); state = EXIT_STATE; break; |