Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-16 12:22:33 +0000
committerStijn Buys <ingar@osirion.org>2008-02-16 12:22:33 +0000
commitd6ee7ec642cc6b3097c8d321a1a00630e24027d1 (patch)
tree35f56e5168cc3e12724898b9efb81b4b2938f575 /src/game/game.cc
parent715d0c3952a3a1d59b64074e472d0a9a3b414351 (diff)
initial client-to-server connection
Diffstat (limited to 'src/game/game.cc')
-rw-r--r--src/game/game.cc43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/game/game.cc b/src/game/game.cc
index f8452f7..7dff676 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -21,30 +21,46 @@ namespace game
/// a player joins the game
void func_join(core::Player &player, std::stringstream &args)
{
+ if (player.control)
+ return;
+
Ship *ship = new Ship();
ship->location = math::Vector3f(0,0,0);
ship->label = "ship: <" + player.name + "> Micron Vector";
ship->owner = &player;
- player.controled = ship;
+ player.control = ship;
+
+ // net message
+ std::ostringstream osstream;
+ osstream << "msg info " << player.name << " joins the game\n";
+ core::net_broadcast(osstream, player.id);
+ // console message
con_print << player.name << " joins the game" << std::endl;
- /// TODO net broadcast
}
/// a player joins the spectators
void func_spectate(core::Player &player, std::stringstream &args)
{
- con_print << player.name << " joins the spectators" << std::endl;
- /// TODO net broadcast
+ if (!player.control)
+ return;
+
+ // net message
+ std::ostringstream osstream;
+ osstream << "msg info " << player.name << " spectates\n";
+ core::net_broadcast(osstream, player.id);
+
+ // console message
+ con_print << player.name << " spectates" << std::endl;
- if (player.controled) {
- // player only has one ship for now
- core::entity::remove(player.controled->id);
- player.controled = 0;
+ if (player.control) {
+ // player has only ship for now
+ core::entity::remove(player.control->id);
+ player.control = 0;
}
}
-Game::Game()
+Game::Game() : core::GameInterface("Project::OSiRiON")
{
}
@@ -132,6 +148,7 @@ bool Game::init()
con_print << " " << sectors[n]->label << " " << sectors[n]->name << std::endl;
*/
+ // set up some stuff in the game world
Star *star = new Star();
star->location = Vector3f(256.0f, 0.0f, 256.0f);
star->label = "star: Sabishi Hoshi";
@@ -162,6 +179,7 @@ bool Game::init()
axis->location = Vector3f(0, 0, 0);
axis->label = "axis: Origin";
+ // add game functions
core::func::add("join", func_join, core::func::Game);
core::func::add("spectate", func_spectate, core::func::Game);
@@ -196,8 +214,11 @@ void Game::player_connect(core::Player &player)
void Game::player_disconnect(core::Player &player)
{
- std::stringstream args;
- game::func_spectate(player, args);
+ if (player.control) {
+ // player has only one ship for now
+ core::entity::remove(player.control->id);
+ player.control = 0;
+ }
}
} // namespace game