equal
deleted
inserted
replaced
28 startGraphics(); |
28 startGraphics(); |
29 |
29 |
30 return *game_state; |
30 return *game_state; |
31 } |
31 } |
32 |
32 |
33 GameState& Engine::setupGame (void) { |
33 void Engine::setupGame (const TerrainConfig &config) { |
34 // proxy off to setupGame(Terrain *) |
34 // proxy off to setupGame(Terrain *) |
35 return setupGame(new Terrain(TERRAIN_WIDTH, TERRAIN_HEIGHT, TERRAIN_RANDOM_SEED)); |
35 setupGame(new Terrain(config)); |
36 } |
36 } |
37 |
37 |
38 void Engine::setupGraphics (const GraphicsConfiguration &config) { |
38 void Engine::setupGraphics (const GraphicsConfig &config) { |
39 // store config |
39 // store config |
40 graphics_config = &config; |
40 graphics_config = &config; |
41 |
41 |
42 // start already? |
42 // start already? |
43 if (game_state) |
43 if (game_state) |
53 } |
53 } |
54 |
54 |
55 void Engine::setupNetworkServer (const std::string &listen_port) { |
55 void Engine::setupNetworkServer (const std::string &listen_port) { |
56 NetworkEndpoint listen_addr(listen_port); |
56 NetworkEndpoint listen_addr(listen_port); |
57 |
57 |
58 // setup default game |
58 assert(terrain && game_state); |
59 setupGame(); |
59 |
60 |
|
61 // create the server |
60 // create the server |
62 net_server = new NetworkServer(*game_state, listen_addr); |
61 net_server = new NetworkServer(*game_state, listen_addr); |
63 } |
62 } |
64 |
63 |
65 void Engine::setupNetworkClient (const std::string &connect_host, const std::string &connect_port) { |
64 void Engine::setupNetworkClient (const std::string &connect_host, const std::string &connect_port) { |
69 // begin connecting, the client will callback us with setupGame once it's connected |
68 // begin connecting, the client will callback us with setupGame once it's connected |
70 net_client_connect = new NetworkClientConnect(*this, connect_addr); |
69 net_client_connect = new NetworkClientConnect(*this, connect_addr); |
71 } |
70 } |
72 |
71 |
73 void Engine::setupSinglePlayer (void) { |
72 void Engine::setupSinglePlayer (void) { |
74 // setup default game |
73 assert(terrain && game_state); |
75 setupGame(); |
|
76 |
74 |
77 // create player directly |
75 // create player directly |
78 LocalPlayer* lp = new SinglePlayer(*game_state); |
76 LocalPlayer* lp = new SinglePlayer(*game_state); |
79 |
77 |
80 // add to gamestate |
78 // add to gamestate |