summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-26 10:56:45 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-01-26 10:56:45 +0000
commit69ccb03b44f324f17d02b9e27e71c34850f71139 (patch)
treee5970b86bbe0cce062d66b13d70f16f5c4ae912d /src/game.cpp
parent3e424a68b7dd438ba1a316af3a92f01dde7c71ac (diff)
downloadmana-client-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.gz
mana-client-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.bz2
mana-client-69ccb03b44f324f17d02b9e27e71c34850f71139.tar.xz
mana-client-69ccb03b44f324f17d02b9e27e71c34850f71139.zip
Moved some setup code out of the game loop into the setup functions. Setup functions are now called from the outside.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp78
1 files changed, 48 insertions, 30 deletions
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)
{