Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-11-08 14:34:44 +0000
committerStijn Buys <ingar@osirion.org>2010-11-08 14:34:44 +0000
commitb7dc0938eb7d59f928bbcf2a3a4877a6f60940e5 (patch)
tree5b4b4353f2012fced4180072e0b0def8ba8d22db /src/game
parentb685a594ae43aa30173912c9fb1177d507ec5a08 (diff)
moved clear() from game::Game~ to core::GameServer~ (solves FIXME),
unified bounding box code into math::BoundingBox3f class
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc118
-rw-r--r--src/game/base/game.h10
2 files changed, 81 insertions, 47 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 40c7c28..f110962 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -11,6 +11,7 @@
#include "auxiliary/functions.h"
#include "core/gameserver.h"
#include "core/parser.h"
+#include "core/range.h"
#include "core/descriptions.h"
#include "filesystem/filesystem.h"
#include "filesystem/inifile.h"
@@ -114,34 +115,6 @@ void Game::func_spectate(core::Player *player, std::string const &args)
player->set_view(0);
}
-// a player sends standard hails
-void Game::func_hail(core::Player *player, std::string const &args)
-{
- if (player->mute()) {
- player->send("^WYou have been muted");
- return;
- }
-
- std::string target;
- std::istringstream is(args);
- if (!(is >> target)) {
- player->send("Usage: hail [player]");
- return;
- }
-
- core::Player *targetplayer = core::server()->find_player(target);
- if (!targetplayer) {
- player->send("Player " + target + "^N not found");
- return;
- }
-
- player->send("^BYou hail " + targetplayer->name());
- player->sound("com/hail");
-
- targetplayer->send("^B" + player->name() + "^B hails you");
- targetplayer->sound("com/hail");
-}
-
// a player actives the hyperspace jump drive on his ship
void Game::func_jump(core::Player *player, std::string const &args)
{
@@ -165,7 +138,7 @@ void Game::func_impulse(core::Player *player, std::string const &args)
}
// a player sends a docking request
-void Game::func_dock(core::Player *player, core::Entity *entity)
+void Game::func_target_dock(core::Player *player, core::Entity *entity)
{
if (!player->control())
return;
@@ -214,12 +187,12 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
return;
if (entity->moduletype() == jumpgate_enttype) {
- // jumpgates their own docking function
+ // jumpgates have their own docking function
JumpGate *jumpgate = static_cast<JumpGate *>(entity);
jumpgate->func_dock(ship);
return;
- } else {
+ } else {
ship->get_location().assign(entity->location());
ship->set_state(core::Entity::Docked);
ship->reset();
@@ -235,6 +208,64 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
}
}
+// a player sends a standard hail
+void Game::func_target_hail(core::Player *player, core::Entity *entity)
+{
+ // TODO spam protection
+ if (!entity)
+ return;
+
+ if (!player->control())
+ return;
+
+ if (player->control()->zone() != entity->zone())
+ return;
+
+ if (player->mute()) {
+ player->send("^WYou have been muted");
+ return;
+ }
+
+ core::Player *target = (entity->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(entity)->owner() : 0 );
+ if (!target)
+ return;
+
+ if (math::distance(player->control()->location(), entity->location()) > core::range::fxdistance) {
+ player->send("^WTarget " + target->name() + " ^Wout of range");
+ }
+ player->send("^BYou hail " + target->name());
+ player->sound("com/hail");
+
+ target->send("^B" + player->name() + "^B hails you");
+ target->sound("com/hail");
+}
+
+// a player sends a trade request
+void Game::func_target_trade(core::Player *player, core::Entity *entity)
+{
+ if (!entity)
+ return;
+
+ if (!player->control())
+ return;
+
+ core::Player *target = (entity->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(entity)->owner() : 0 );
+ if ((!target) || (target == player))
+ return;
+
+ if (entity != target->control())
+ return;
+
+ if (target->control()->state() != core::Entity::Normal)
+ return;
+
+ if (player->control()->state() != core::Entity::Normal)
+ return;
+
+
+ player->send("^WTrade requests are not implemented at this time");
+}
+
// cheats
void Game::func_give(core::Player *player, const std::string &args)
{
@@ -850,9 +881,6 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("join", Game::func_join);
func->set_info("join the game");
- func = core::Func::add("hail", Game::func_hail);
- func->set_info("send a standard hail");
-
func = core::Func::add("spectate", Game::func_spectate);
func->set_info("leave the game and spectate");
@@ -889,8 +917,14 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("goto", Game::func_goto);
func->set_info("[string] goto to an entity within the zone");
- func = core::Func::add("@dock", Game::func_dock);
- func->set_info("dock with target object");
+ func = core::Func::add("@dock", Game::func_target_dock);
+ func->set_info("send a docking request to target");
+
+ func = core::Func::add("@hail", Game::func_target_hail);
+ func->set_info("send a standard hail to target");
+
+ func = core::Func::add("@trade", Game::func_target_trade);
+ func->set_info("send a trade request to target");
// add engine variables
g_impulsespeed = core::Cvar::get("g_impulsespeed", "1500", core::Cvar::Game | core::Cvar::Archive);
@@ -899,13 +933,13 @@ Game::Game() : core::Module("Project::OSiRiON", true)
g_jumppointrange = core::Cvar::get("g_jumppointrange", "512", core::Cvar::Game | core::Cvar::Archive);
g_jumppointrange->set_info("[float] jumppoint range");
- g_devel = core::Cvar::get("g_devel", "0", core::Cvar::Archive);
+ g_devel = core::Cvar::get("g_devel", "0", core::Cvar::Game | core::Cvar::Archive);
g_devel->set_info("[bool] enable or disable developer mode");
- g_damping = core::Cvar::get("g_damping", "0.1", core::Cvar::Archive);
+ g_damping = core::Cvar::get("g_damping", "0.1", core::Cvar::Game | core::Cvar::Archive);
g_damping->set_info("[float] physics damping factor (0-1)");
- g_deplete = core::Cvar::get("g_deplete", "60", core::Cvar::Archive);
+ g_deplete = core::Cvar::get("g_deplete", "60", core::Cvar::Game | core::Cvar::Archive);
g_deplete->set_info("[int] number of seconds to deplete 1 unit of cargo from inventories");
}
@@ -915,11 +949,7 @@ Game::~Game()
g_jumppointrange = 0;
g_devel = 0;
g_damping = 0;
- // game functions are automaticly removed
-
- // FIXME move cleanup sequence to core::
- // we explicity clear game data to prevent bullet from beeing confused
- core::game()->clear();
+ g_deplete = 0;
Default::clear();
}
diff --git a/src/game/base/game.h b/src/game/base/game.h
index dd47cef..3859122 100644
--- a/src/game/base/game.h
+++ b/src/game/base/game.h
@@ -107,14 +107,12 @@ private:
bool load_settings();
- /* ---- engine functions ----------------------------------- */
+ /* ---- game functions ------------------------------------- */
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_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);
static void func_respawn(core::Player *player, std::string const &args);
static void func_goto(core::Player *player, const std::string &args);
@@ -124,6 +122,12 @@ private:
static void func_specs(core::Player *player, const std::string &args);
static void func_eject(core::Player *player, const std::string &args);
static void func_beam(core::Player *player, const std::string &args);
+
+ /* ---- target functions ----------------------------------- */
+
+ static void func_target_dock(core::Player *player, core::Entity *entity);
+ static void func_target_hail(core::Player *player, core::Entity *entity);
+ static void func_target_trade(core::Player *player, core::Entity *entity);
};
/// factory function