Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-11-08 10:59:47 +0000
committerStijn Buys <ingar@osirion.org>2008-11-08 10:59:47 +0000
commit2182933986afd7e17cf9072d8f2e3333fa110cd4 (patch)
treea278558fa48c6948ba07c1d61338dd2bc560631f /src
parent4cad4a27677b0490d3ba0018bc3404961f925ed5 (diff)
docking, join menu
Diffstat (limited to 'src')
-rw-r--r--src/client/client.cc4
-rw-r--r--src/core/commandbuffer.cc23
-rw-r--r--src/game/base/base.cc94
-rw-r--r--src/game/base/base.h20
-rw-r--r--src/ui/menu.cc3
5 files changed, 86 insertions, 58 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 4f6b878..823a384 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -212,6 +212,10 @@ void Client::frame(unsigned long timestamp)
if (!core::game()->interactive() && !ui::root()->active()) {
ui::root()->show_menu("main");
}
+
+ if (core::game()->interactive() && !ui::root()->active() && !core::localcontrol()) {
+ ui::root()->show_menu("join");
+ }
}
video::frame((float)(timestamp - previous_timestamp) / 1000.0f);
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 71ad37f..4addd10 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -307,11 +307,26 @@ void CommandBuffer::exec()
if (cmdbuf.eof())
return;
- char line[MAXCMDSIZE];
-
- while (core::cmd().getline(line, MAXCMDSIZE-1)) {
- exec(std::string(line));
+ std::string line;
+ char c;
+ bool quote = false;
+
+ while ( core::cmd().read(&c , 1) && c) {
+ if ( c =='\n') {
+ exec(line);
+ line.clear();
+ } else if (c == '"') {
+ quote = !quote;
+ } else if ((c == ';') && !quote) {
+ exec(line);
+ line.clear();
+ } else {
+ line +=c;
+ }
}
+
+ if (line.size())
+ exec(line);
cmdbuf.clear();
}
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index a5492ea..dfde132 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -26,16 +26,26 @@
namespace base
{
-/* -- engine game functions ---------------------------------------- */
+/* -- class Base static members ----------------------------------- */
+
+// game variables
+core::Cvar *Base::g_impulsespeed = 0;
+core::Cvar *Base::g_impulseacceleration = 0;
+core::Cvar *Base::g_strafespeed = 0;
+core::Cvar *Base::g_jumppointrange = 0;
+core::Cvar *Base::g_devel = 0;
-/// list the ship model registry
-void func_list_ship(std::string const &args)
+core::Zone *Base::default_zone = 0;
+ShipModel *Base::default_shipmodel = 0;
+
+// list the ship model registry
+void Base::func_list_ship(std::string const &args)
{
ShipModel::list();
}
-/// a player joins the game
-void func_join(core::Player *player, std::string const &args)
+// a player joins the game
+void Base::func_join(core::Player *player, std::string const &args)
{
if (player->control())
return;
@@ -59,8 +69,8 @@ void func_join(core::Player *player, std::string const &args)
player->player_dirty = true;
}
-/// a player joins the spectators
-void func_spectate(core::Player *player, std::string const &args)
+// a player joins the spectators
+void Base::func_spectate(core::Player *player, std::string const &args)
{
if (!player->control())
return;
@@ -80,8 +90,8 @@ void func_spectate(core::Player *player, std::string const &args)
player->set_view(0);
}
-/// a player buys a ship
-void func_buy(core::Player *player, std::string const &args)
+// a player buys a ship
+void Base::func_buy(core::Player *player, std::string const &args)
{
std::string shipname;
@@ -125,8 +135,8 @@ void func_buy(core::Player *player, std::string const &args)
}
}
-/// a player sends standard hails
-void func_hail(core::Player *player, std::string const &args)
+// a player sends standard hails
+void Base::func_hail(core::Player *player, std::string const &args)
{
std::string target;
std::istringstream is(args);
@@ -148,8 +158,8 @@ void func_hail(core::Player *player, std::string const &args)
core::server()->send_sound(targetplayer, "com/hail");
}
-/// a player actives the hyperspace jump drive on his ship
-void func_jump(core::Player *player, std::string const &args)
+// a player actives the hyperspace jump drive on his ship
+void Base::func_jump(core::Player *player, std::string const &args)
{
if (!player->control())
return;
@@ -159,8 +169,8 @@ void func_jump(core::Player *player, std::string const &args)
ship->jump(args);
}
-/// a player actives the kinetic impulse drive on his ship
-void func_impulse(core::Player *player, std::string const &args)
+// a player actives the kinetic impulse drive on his ship
+void Base::func_impulse(core::Player *player, std::string const &args)
{
if (!player->control())
return;
@@ -170,8 +180,8 @@ void func_impulse(core::Player *player, std::string const &args)
ship->impulse();
}
-/// a player sends a docking request
-void func_dock(core::Player *player,core::Entity *entity)
+// a player sends a docking request
+void Base::func_dock(core::Player *player,core::Entity *entity)
{
if (!player->control())
return;
@@ -196,8 +206,8 @@ void func_dock(core::Player *player,core::Entity *entity)
core::server()->send(player, "^BDocking at " + entity->name() + "^B...");
}
-/// launch request
-void func_launch(core::Player *player, std::string const &args)
+// launch request
+void Base::func_launch(core::Player *player, std::string const &args)
{
if (!player->control())
return;
@@ -217,19 +227,6 @@ void func_launch(core::Player *player, std::string const &args)
player->set_view(0);
}
-/* -- class Base static members ----------------------------------- */
-
-// game variables
-core::Cvar *Base::g_impulsespeed = 0;
-core::Cvar *Base::g_impulseacceleration = 0;
-core::Cvar *Base::g_strafespeed = 0;
-core::Cvar *Base::g_jumppointrange = 0;
-core::Cvar *Base::g_devel = 0;
-
-// game defaults
-core::Zone *Base::default_zone = 0;
-ShipModel *Base::default_shipmodel = 0;
-
/* -- class Base -------------------------------------------------- */
Base::Base() : core::Module("base", "Project::OSiRiON", true)
@@ -256,34 +253,35 @@ void Base::init()
return;
}
- // add engine game functions
+ // add engine functions
core::Func *func = 0;
+
+ func = core::Func::add("list_ship", Base::func_list_ship);
+ func->set_info("list ship statistics");
- func = core::Func::add("join", (core::GameFuncPtr) func_join);
+ func = core::Func::add("join", Base::func_join);
func->set_info("join the game");
- func = core::Func::add("hail", (core::GameFuncPtr) func_hail);
+
+ func = core::Func::add("hail", Base::func_hail);
func->set_info("send a standard hail");
- func = core::Func::add("spectate", (core::GameFuncPtr) func_spectate);
+
+ func = core::Func::add("spectate", Base::func_spectate);
func->set_info("leave the game and spectate");
- func = core::Func::add("buy", (core::GameFuncPtr) func_buy);
+ func = core::Func::add("buy", Base::func_buy);
func->set_info("buy a ship");
- func = core::Func::add("@dock", (core::TargetFuncPtr) func_dock);
- func->set_info("dock with target object");
-
- func = core::Func::add("launch", (core::GameFuncPtr) func_launch);
- func->set_info("launch to space when docked");
-
- func = core::Func::add("jump", (core::GameFuncPtr) func_jump);
+ func = core::Func::add("jump", Base::func_jump);
func->set_info("[string] activate or deactivate hyperspace jump drive");
- func = core::Func::add("impulse", (core::GameFuncPtr) func_impulse);
+ func = core::Func::add("impulse", Base::func_impulse);
func->set_info("activate are deactive kinetic impulse drive");
- // add engine core functions
- func = core::Func::add("list_ship", (core::FuncPtr) func_list_ship);
- func->set_info("list ship statistics");
+ func = core::Func::add("launch", Base::func_launch);
+ func->set_info("launch to space when docked");
+
+ func = core::Func::add("@dock", Base::func_dock);
+ func->set_info("dock with target object");
// add engine variables
g_impulsespeed = core::Cvar::get("g_impulsespeed", "15", core::Cvar::Game | core::Cvar::Archive);
diff --git a/src/game/base/base.h b/src/game/base/base.h
index fcf39d1..6979335 100644
--- a/src/game/base/base.h
+++ b/src/game/base/base.h
@@ -63,12 +63,6 @@ public:
/// game variable: enable or disable development mode
static core::Cvar *g_devel;
- /// default zone
- static core::Zone *default_zone;
-
- /// default ship model
- static ShipModel *default_shipmodel;
-
protected:
/// initialize the game
void init();
@@ -86,6 +80,20 @@ private:
bool load_ships();
+ static core::Zone *default_zone;
+ static ShipModel *default_shipmodel;
+
+ /* ---- engine functions ----------------------------------- */
+
+ static void func_list_ship(std::string const &args);
+ static void func_join(core::Player *player, std::string const &args);
+ static void func_spectate(core::Player *player, std::string const &args);
+ static void func_buy(core::Player *player, std::string const &args);
+ static void func_hail(core::Player *player, std::string const &args);
+ static void func_jump(core::Player *player, std::string const &args);
+ static void func_impulse(core::Player *player, std::string const &args);
+ static void func_dock(core::Player *player,core::Entity *entity);
+ static void func_launch(core::Player *player, std::string const &args);
};
}
diff --git a/src/ui/menu.cc b/src/ui/menu.cc
index 6931bd4..8421f7f 100644
--- a/src/ui/menu.cc
+++ b/src/ui/menu.cc
@@ -89,6 +89,9 @@ void Menu::load()
button->set_text(strval);
} else if (ini.got_key_string("command", strval)) {
+ for (size_t i =0; i <= strval.size(); i++) {
+ if (strval[i] == ',') strval[i] = ';';
+ }
button->set_command(strval);
} else if (ini.got_key_string("align", strval)) {