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-11-08 10:17:37 +0000
committerStijn Buys <ingar@osirion.org>2008-11-08 10:17:37 +0000
commit4cad4a27677b0490d3ba0018bc3404961f925ed5 (patch)
treef9d59542f27f66a9fb4c8938f40aec66994449fc
parent27ab3566118e77754fefb32a41ee06cf24a59dfe (diff)
docking, bumps network protocol version
-rw-r--r--osirion.kdevelop2
-rw-r--r--src/client/client.cc1
-rw-r--r--src/client/notifications.cc6
-rw-r--r--src/client/notifications.h2
-rw-r--r--src/client/view.cc13
-rw-r--r--src/core/Makefile.am6
-rw-r--r--src/core/application.cc151
-rw-r--r--src/core/application.h30
-rw-r--r--src/core/commandbuffer.cc2
-rw-r--r--src/core/entity.cc2
-rw-r--r--src/core/entity.h4
-rw-r--r--src/core/net.h2
-rw-r--r--src/core/parser.cc15
-rw-r--r--src/core/parser.h3
-rw-r--r--src/core/player.cc18
-rw-r--r--src/core/player.h8
-rw-r--r--src/core/zone.cc8
-rw-r--r--src/core/zone.h9
-rw-r--r--src/game/base/base.cc97
-rw-r--r--src/game/base/base.h1
-rw-r--r--src/game/base/ship.cc29
-rw-r--r--src/render/camera.cc48
-rw-r--r--src/render/draw.cc60
23 files changed, 360 insertions, 157 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 78eee5d..4afbfd0 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/client/libclient.la</activetarget>
+ <activetarget>src/core/libcore.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
diff --git a/src/client/client.cc b/src/client/client.cc
index 667a060..4f6b878 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -247,6 +247,7 @@ void Client::shutdown()
void Client::notify_connect()
{
+ view()->notify()->clear();
ui::root()->hide_menu();
}
diff --git a/src/client/notifications.cc b/src/client/notifications.cc
index b7c11fd..256f110 100644
--- a/src/client/notifications.cc
+++ b/src/client/notifications.cc
@@ -26,6 +26,12 @@ Notifications::~Notifications()
{
}
+void Notifications::clear()
+{
+ notify_log.clear();
+ notify_timestamp.clear();
+}
+
void Notifications::event_text(const std::string & text)
{
while (notify_log.size() >= NOTIFY_LOG_SIZE) {
diff --git a/src/client/notifications.h b/src/client/notifications.h
index be168fb..db3dd3e 100644
--- a/src/client/notifications.h
+++ b/src/client/notifications.h
@@ -22,6 +22,8 @@ public:
void event_text(const std::string & text);
+ void clear();
+
protected:
/// draw notifications
void draw();
diff --git a/src/client/view.cc b/src/client/view.cc
index 3ee6460..9eb9c33 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -505,7 +505,14 @@ void draw_hud()
std::stringstream status;
// draw a basic HUD
- if (core::localcontrol() && core::localcontrol()->zone()) {
+ if(core::localplayer()->view()) {
+ Text::setcolor('N'); //set normal color
+ Text::draw(render::Camera::width()-4-Text::fontwidth()*32, render::Camera::height()-Text::fontheight()*3-4, core::localcontrol()->zone()->name());
+
+ Text::setcolor('B'); //set bold color
+ Text::draw(render::Camera::width() - 4-Text::fontwidth()*32, render::Camera::height() - Text::fontheight()*2 -4, core::localplayer()->view()->name());
+
+ } else if (core::localcontrol() && core::localcontrol()->zone()) {
core::Zone *zone = core::localcontrol()->zone();
// draw targets
@@ -638,7 +645,7 @@ void draw_cursor()
if (ui::console()->visible()) {
ui::root()->set_pointer();
- } else if(ui::root()->active()) {
+ } else if(core::localplayer()->view() || ui::root()->active()) {
ui::root()->set_pointer("pointer");
@@ -693,7 +700,7 @@ void frame(float elapsed)
render::draw(elapsed); // draw the world
targets::draw(); // validate current target, render sound
- if (targets::current()) // draw target docks etc
+ if (!core::localplayer()->view() && targets::current()) // draw target docks etc
draw_entity_world_target(targets::current());
render::Camera::ortho();
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 18d8185..edd62e1 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -12,5 +12,7 @@ libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
noinst_LTLIBRARIES = libcore.la
noinst_HEADERS = application.h clientstate.h commandbuffer.h core.h cvar.h \
- entity.h func.h gameconnection.h gameinterface.h gameserver.h message.h module.h net.h \
- netclient.h netconnection.h netserver.h player.h range.h stats.h timer.h parser.h
+ entity.h func.h gameconnection.h gameinterface.h gameserver.h message.h module.h \
+ net.h netclient.h netconnection.h netserver.h player.h range.h stats.h \
+ timer.h parser.h
+
diff --git a/src/core/application.cc b/src/core/application.cc
index 09e900d..300aaa6 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -27,69 +27,7 @@
namespace core
{
-// --------------- engine functions ------------------------------
-void func_help(std::string const &args)
-{
- std::istringstream argstream(args);
- std::string topic;
- if (!(argstream >> topic))
- topic.assign("help");
-
- topic.append(".txt");
- CommandBuffer::print_file("help/" + topic);
-}
-
-void func_quit(std::string const &args)
-{
- application()->shutdown();
- application()->quit(0);
-}
-
-void func_connect(std::string const &args)
-{
- std::istringstream argstream(args);
- std::string host;
- if (!(argstream >> host))
- host.clear();
-
- application()->connect(host);
-}
-
-void func_disconnect(std::string const &args)
-{
- application()->disconnect();
-}
-
-void func_say(std::string const &args)
-{
- if (connection()) {
- connection()->say(args);
- } else if (server()) {
- server()->say(localplayer(), args);
- } else {
- con_print << "Not connected." << std::endl;
- }
-}
-
-void func_msg(std::string const &args)
-{
- if (connection()) {
- connection()->private_message(args);
- } else if (server()) {
- server()->private_message(localplayer(), args);
- } else {
- con_print << "Not connected." << std::endl;
- }
-}
-
-void func_load(std::string const &args)
-{
- std::string name(args);
- aux::to_label(name);
- application()->load(name);
-}
-
-// --------------- signal_handler -----------------------------------
+/* ---- signal handler --------------------------------------------- */
#ifndef _WIN32
extern "C" void signal_handler(int signum)
@@ -101,11 +39,11 @@ extern "C" void signal_handler(int signum)
case SIGTERM:
if (Application::instance()) {
con_warn << "Received signal " << signum << ", shutting down...\n";
- application()->shutdown();
- application()->quit(0);
+ Application::instance()->shutdown();
+ Application::instance()->quit(0);
} else {
std::cerr << "Received signal " << signum << ", terminated...\n";
- application()->quit(1);
+ Application::instance()->quit(1);
}
break;
#ifdef HAVE_CURSES
@@ -115,13 +53,13 @@ extern "C" void signal_handler(int signum)
#endif
default:
std::cerr << "Received signal " << signum << ", terminated...\n";
- application()->quit(1);
+ Application::instance()->quit(1);
break;
}
}
#endif
-// --------------- Application -----------------------------
+/* ---- class Application ------------------------------------------ */
Application *Application::application_instance = 0;
@@ -229,25 +167,25 @@ void Application::init(int count, char **arguments)
// register our engine functions
Func *func = 0;
- func = Func::add("help", func_help);
+ func = Func::add("help", Application::func_help);
func->set_info("help function");
- func = Func::add("quit", func_quit);
+ func = Func::add("quit", Application::func_quit);
func->set_info("exit the application");
- func = Func::add("load", func_load);
+ func = Func::add("load", Application::func_load);
func->set_info("[str] load a game module");
- func = Func::add("connect", func_connect);
+ func = Func::add("connect", Application::func_connect);
func->set_info("[ip] without ip, create a game");
- func = Func::add("disconnect", func_disconnect);
+ func = Func::add("disconnect", Application::func_disconnect);
func->set_info("leave the current game");
- func = Func::add("say", func_say);
+ func = Func::add("say", Application::func_say);
func->set_info("say [text] say something on the public chat");
- func = Func::add("msg", func_msg);
+ func = Func::add("msg", Application::func_msg);
func->set_info("msg [player] [text] send a private message to another player");
func = 0;
@@ -552,4 +490,67 @@ void Application::notify_remove_sound(size_t source)
// Dedicated servers don't need sounds
}
+/* -- static engine functions -------------------------------------- */
+
+void Application::func_help(std::string const &args)
+{
+ std::istringstream argstream(args);
+ std::string topic;
+ if (!(argstream >> topic))
+ topic.assign("help");
+
+ topic.append(".txt");
+ CommandBuffer::print_file("help/" + topic);
+}
+
+void Application::func_quit(std::string const &args)
+{
+ Application::instance()->shutdown();
+ Application::instance()->quit(0);
+}
+
+void Application::func_connect(std::string const &args)
+{
+ std::istringstream argstream(args);
+ std::string host;
+ if (!(argstream >> host))
+ host.clear();
+
+ Application::instance()->connect(host);
+}
+
+void Application::func_disconnect(std::string const &args)
+{
+ Application::instance()->disconnect();
+}
+
+void Application::func_say(std::string const &args)
+{
+ if (connection()) {
+ connection()->say(args);
+ } else if (server()) {
+ server()->say(localplayer(), args);
+ } else {
+ con_print << "Not connected." << std::endl;
+ }
+}
+
+void Application::func_msg(std::string const &args)
+{
+ if (connection()) {
+ connection()->private_message(args);
+ } else if (server()) {
+ server()->private_message(localplayer(), args);
+ } else {
+ con_print << "Not connected." << std::endl;
+ }
+}
+
+void Application::func_load(std::string const &args)
+{
+ std::string name(args);
+ aux::to_label(name);
+ Application::instance()->load(name);
+}
+
}
diff --git a/src/core/application.h b/src/core/application.h
index f241aa3..bb76cfe 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -39,7 +39,7 @@ public:
/// true if the core is connected to a running game interface
inline bool connected() const { return (application_game && application_game->running()); }
- /// return the game interface, returns 0 if the pplication is not connected to a game
+ /// return the game interface, returns 0 if the application is not connected to a game
inline GameInterface *game() { return application_game; }
/*----- mutators ------------------------------------------------- */
@@ -84,8 +84,6 @@ public:
/// remove sound source notification
virtual void notify_remove_sound(size_t source);
-/*----- static --------------------------------------------------- */
-
/// a pointer to the current application instance
static inline Application *instance() { return application_instance; }
@@ -108,23 +106,31 @@ protected:
private:
/// time the core has been running
unsigned long application_timestamp;
+
GameInterface *application_game;
+ Module *module_interactive;
+
static Application *application_instance;
- /// last loaded interactive module
- Module *module_interactive;
+ /*-- engine functions --*/
+
+ static void func_help(std::string const &args);
+ static void func_quit(std::string const &args);
+ static void func_connect(std::string const &args);
+ static void func_disconnect(std::string const &args);
+ static void func_say(std::string const &args);
+ static void func_msg(std::string const &args);
+ static void func_load(std::string const &args);
};
-/// pointer to the current Application
+/// pointer to the application
inline Application *application() { return Application::instance(); }
-/// pointer to the current GameInterface
-inline GameInterface *game() { return Application::instance()->game(); }
-
/// pointer to the console
-inline sys::ConsoleInterface *console() { return sys::ConsoleInterface::instance(); };
+inline sys::ConsoleInterface *console() { return sys::ConsoleInterface::instance(); }
-} // namespace core
+/// pointer to the game interface
+inline GameInterface *game() { return Application::instance()->game(); }
+}
#endif // __INCLUDED_CORE_APPLICATION_H__
-
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index d3cb4f2..71ad37f 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -240,7 +240,7 @@ void CommandBuffer::exec(std::string const &cmdline)
// target function
unsigned int id = 0;
if ((cmdstream >> id)) {
- con_debug << "target function " << command << " " << id << std::endl;
+ //con_debug << "target function " << command << " " << id << std::endl;
Entity *entity = Entity::find(id);
if (entity)
f->exec(game()->localplayer(), entity);
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 539c8d5..9bc3f3c 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -83,7 +83,7 @@ void Entity::list()
con_print << entity_registry.size() << " registered entities" << std::endl;
}
-/*----- class Entity ----------------------------------------------- */
+/* ---- class Entity ----------------------------------------------- */
Entity::Entity(unsigned int flags) :
entity_location(0.0f, 0.0f, 0.0f),
diff --git a/src/core/entity.h b/src/core/entity.h
index 149419b..09b52a1 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -35,7 +35,7 @@ class Entity
{
public:
/// Entity flags
- enum Flags {Static=1, Solid=2, Bright=4, Dock=8};
+ enum Flags {Static=1, Solid=2, Bright=4, Dockable=8};
/// Entity type constants
enum Type {Default=0, Dynamic=1, Controlable=2, Globe=3};
@@ -44,7 +44,7 @@ public:
enum Shape {Diamond=0, Sphere=1, Cube=2, Axis=3};
/// EntityDynamic event state classes
- enum Event {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5};
+ enum Event {Normal=0, NoPower=1, ImpulseInitiate=2, Impulse=3, JumpInitiate=4, Jump=5, Docked=6};
/// create a new entity and add it to the registry
Entity(unsigned int flags = 0);
diff --git a/src/core/net.h b/src/core/net.h
index 92a17c5..fe264e8 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 12;
+const unsigned int PROTOCOLVERSION = 13;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;
diff --git a/src/core/parser.cc b/src/core/parser.cc
index 39eb073..6af3903 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -10,6 +10,21 @@
namespace core {
+bool Parser::read_entity_menu(core::Entity *entity, const std::string &menufilename)
+{
+ filesystem::IniFile inifile;
+ inifile.open(menufilename);
+
+ if (!inifile.is_open()) {
+ return false;
+ }
+
+ con_debug << " " << inifile.name() << std::endl;
+
+ inifile.close();
+ return true;
+}
+
bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
{
std::string shapename;
diff --git a/src/core/parser.h b/src/core/parser.h
index 78a1087..fec27c4 100644
--- a/src/core/parser.h
+++ b/src/core/parser.h
@@ -18,6 +18,9 @@ class Parser {
public:
/// read default entity keys from an ini file
static bool got_entity_key(filesystem::IniFile &inifile, core::Entity *entity);
+
+ /// read entity menus
+ static bool read_entity_menu(core::Entity *entity, const std::string &menufilename);
};
}
diff --git a/src/core/player.cc b/src/core/player.cc
index 26ea070..f5f28bd 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -35,6 +35,7 @@ void Player::clear()
player_rcon = false;
player_mute = false;
player_mission_target = 0;
+ player_view = 0;
clear_assets();
player_control = 0;
@@ -46,6 +47,7 @@ void Player::set_control(EntityControlable *entitycontrolable)
if (entitycontrolable) {
set_zone(entitycontrolable->zone());
+ player_view = 0;
}
player_dirty = true;
}
@@ -58,6 +60,15 @@ void Player::set_zone(Zone *zone)
}
}
+void Player::set_view(Entity *view)
+{
+ player_view = view;
+ player_dirty = true;
+ if (player_view) {
+ set_zone(player_view->zone());
+ }
+}
+
void Player::set_mission_target(Entity *new_mission_target)
{
if (new_mission_target != player_mission_target) {
@@ -119,8 +130,9 @@ void Player::serialize_server_update(std::ostream & os) const
unsigned int zo = (zone() ? zone()->id() : 0);
unsigned int co = (player_control ? player_control->id() : 0);
unsigned int mission = (player_mission_target ? player_mission_target->id() : 0);
+ unsigned int view = (player_view ? player_view->id() : 0);
- os << player_id << " " << zo << " " << co << " " << mission << " " << player_color << " \"" << player_name << "\"";
+ os << player_id << " " << zo << " " << view << " " << co << " " << mission << " " << player_color << " \"" << player_name << "\"";
}
void Player::receive_server_update(std::istream &is)
@@ -131,6 +143,10 @@ void Player::receive_server_update(std::istream &is)
is >> zo;
set_zone(Zone::find(zo));
+ unsigned int view = 0;
+ is >> view;
+ set_view(Entity::find(view));
+
unsigned int co = 0;
is >> co;
if (co) {
diff --git a/src/core/player.h b/src/core/player.h
index c527433..44ee923 100644
--- a/src/core/player.h
+++ b/src/core/player.h
@@ -70,6 +70,9 @@ public:
/// mission target
inline Entity *mission_target() { return player_mission_target; }
+ /// view
+ inline Entity *view() { return player_view; }
+
/*----- mutators -------------------------------------------------- */
/// serialize player info to a stream
@@ -104,6 +107,8 @@ public:
void set_mission_target(Entity *new_mission_target);
+ void set_view(Entity *view);
+
inline void set_dirty() { player_dirty = true; }
/* -- should actually not be public --*/
@@ -138,6 +143,9 @@ private:
// the entity the Player is currently controling
EntityControlable *player_control;
+ // the entity the PLayer is currently looking at
+ Entity *player_view;
+
Entity *player_mission_target;
// the zone the player is currently in
diff --git a/src/core/zone.cc b/src/core/zone.cc
index 2dfc5c2..5d9c48f 100644
--- a/src/core/zone.cc
+++ b/src/core/zone.cc
@@ -118,7 +118,7 @@ void Zone ::clear()
zone_registry.clear();
}
-/* ---- The Zone class --------------------------------------------- */
+/* ---- class Zone ------------------------------------------------- */
Zone::Zone(std::string const & label) :
zone_label(label)
@@ -127,6 +127,7 @@ Zone::Zone(std::string const & label) :
zone_name.clear();
zone_sky.clear();
zone_sky_texture = 0;
+ zone_defaultview = 0;
}
Zone::Zone(std::istream & is)
@@ -197,6 +198,7 @@ void Zone::serialize_server_update(std::ostream & os) const
os << zone_label << " ";
os << "\"" << zone_name << "\" ";
os << "\"" << zone_sky << "\" ";
+ os << (zone_defaultview ? zone_defaultview->id() : 0 );
}
@@ -205,6 +207,7 @@ void Zone::receive_server_update(std::istream &is)
is >> zone_label;
std::string n;
+ unsigned int id = 0;
char c;
while ( (is.get(c)) && (c != '"'));
@@ -218,6 +221,9 @@ void Zone::receive_server_update(std::istream &is)
n += c;
zone_sky.assign(n);
n.clear();
+
+ is >> id;
+ zone_defaultview = Entity::find(id);
}
}
diff --git a/src/core/zone.h b/src/core/zone.h
index bb2074e..4b64ffb 100644
--- a/src/core/zone.h
+++ b/src/core/zone.h
@@ -71,7 +71,6 @@ public:
/// create a zone from stream data
Zone(std::istream & is);
-
/// delete a zone
~Zone();
@@ -92,6 +91,9 @@ public:
/// texture id for the sky
inline size_t sky_texture() const { return zone_sky_texture; }
+ /// default zone view
+ inline Entity *default_view() {return zone_defaultview; }
+
/// find an entity inside a zone
Entity *find_entity(Entity *entity);
@@ -115,6 +117,9 @@ public:
/// set the texture id for the sky
inline void set_sky_texture(size_t texture) { zone_sky_texture = texture; }
+ ///set the default view
+ inline void set_default_view(Entity *entity) { zone_defaultview = entity; }
+
/* ---- serializers ---------------------------------------- */
/// serialize a server-to-client update on a stream
@@ -145,6 +150,8 @@ private:
Content zone_content;
static Registry zone_registry;
+
+ Entity *zone_defaultview;
};
}
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index 6a3738e..a5492ea 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -6,6 +6,7 @@
#include <vector>
#include <string>
+#include <assert.h>
#include "auxiliary/functions.h"
#include "core/gameserver.h"
@@ -39,11 +40,15 @@ void func_join(core::Player *player, std::string const &args)
if (player->control())
return;
- player->set_zone(Base::default_zone);
Ship *ship = new Ship(player, Base::default_shipmodel);
- ship->set_zone(Base::default_zone);
+ ship->set_zone(player->zone());
player->set_control(ship);
+/*
+ core::Entity *dock = ship->zone()->default_view();
+ ship->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
+ ship->entity_axis.assign(dock->axis());
+*/
core::server()->send_sound(player, "game/buy-ship");
std::string message("^B");
@@ -68,6 +73,11 @@ void func_spectate(core::Player *player, std::string const &args)
if (player->control()) {
player->remove_asset(player->control());
}
+
+ if (!player->zone())
+ player->set_zone(Base::default_zone);
+
+ player->set_view(0);
}
/// a player buys a ship
@@ -99,13 +109,14 @@ void func_buy(core::Player *player, std::string const &args)
}
Ship * ship = new Ship(player, shipmodel);
- if (player->zone()) {
- ship->set_zone(player->zone());
- } else {
- ship->set_zone(Base::default_zone);
+ ship->set_zone(player->zone());
+ if (player->view()) {
+ core::Entity *dock = player->view();
+ ship->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
+ ship->entity_axis.assign(dock->axis());
}
+
player->set_control(ship);
-
core::server()->broadcast("^B" + player->name() + " ^Bpurchased " + aux::article(shipmodel->name()));
core::server()->send_sound(player, "game/buy-ship");
@@ -168,7 +179,42 @@ void func_dock(core::Player *player,core::Entity *entity)
if (player->control()->zone() != entity->zone())
return;
- core::server()->send(player, "^BSending docking request to " + entity->name() + "^B...");
+ if ((entity->flags() & core::Entity::Dockable) == 0)
+ return;
+
+ if (player->control()->eventstate() == core::Entity::Docked)
+ return;
+
+ if (math::distance(entity->location(), player->control()->location()) > 2.0f * entity->radius()) {
+ core::server()->send(player, "^B" + entity->name() + " is out of range!");
+ return;
+ }
+
+ player->control()->location().assign(entity->location());
+ player->control()->set_eventstate(core::Entity::Docked);
+ player->set_view(entity);
+ core::server()->send(player, "^BDocking at " + entity->name() + "^B...");
+}
+
+/// launch request
+void func_launch(core::Player *player, std::string const &args)
+{
+ if (!player->control())
+ return;
+
+ if (!player->view())
+ return;
+
+ if (player->control()->eventstate() != core::Entity::Docked)
+ return;
+
+ assert(player->view()->zone() == player->control()->zone());
+
+ core::Entity *dock = player->view();
+ player->control()->entity_location.assign(dock->location() + (dock->axis().forward() * dock->radius()*2.0f));
+ player->control()->entity_axis.assign(dock->axis());
+ player->control()->set_eventstate(core::Entity::Normal);
+ player->set_view(0);
}
/* -- class Base static members ----------------------------------- */
@@ -224,7 +270,10 @@ void Base::init()
func->set_info("buy a ship");
func = core::Func::add("@dock", (core::TargetFuncPtr) func_dock);
- func->set_info("send a docking request");
+ 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->set_info("[string] activate or deactivate hyperspace jump drive");
@@ -243,7 +292,7 @@ void Base::init()
g_impulseacceleration = core::Cvar::get("g_impulseacceleration", "5", core::Cvar::Game | core::Cvar::Archive);
g_impulseacceleration->set_info("[float] acceleration of the impulse drive");
- g_strafespeed = core::Cvar::get("g_strafespeed", "0.003", core::Cvar::Game | core::Cvar::Archive);
+ g_strafespeed = core::Cvar::get("g_strafespeed", "0.01", core::Cvar::Game | core::Cvar::Archive);
g_strafespeed->set_info("[float] strafe speed");
g_jumppointrange = core::Cvar::get("g_jumppointrange", "512", core::Cvar::Game | core::Cvar::Archive);
@@ -276,6 +325,8 @@ bool Base::load_world()
return false;
}
+ con_print << "^BLoading world..." << std::endl;
+
core::Zone *zone = 0;
std::string label;
@@ -349,6 +400,8 @@ bool Base::load_zone(core::Zone *zone)
return false;
}
+ con_print << "^BLoading zone " << zone->label() << "..." << std::endl;
+
size_t count = 0;
Planet *planet = 0;
@@ -461,6 +514,17 @@ bool Base::load_zone(core::Zone *zone)
continue;
} else if (zoneini.got_key_float("rotationspeed", planet->entity_rotationspeed)) {
continue;
+ } else if (zoneini.got_key_bool("dock", b)) {
+ if (b)
+ planet->set_flag(core::Entity::Dockable);
+ else
+ planet->unset_flag(core::Entity::Dockable);
+
+ } else if (zoneini.got_key_bool("default", b)) {
+ if (b) {
+ zone->set_default_view(planet);
+ }
+ continue;
} else {
zoneini.unkown_key();
}
@@ -482,6 +546,17 @@ bool Base::load_zone(core::Zone *zone)
} else if (zoneini.in_section("entity")) {
if (core::Parser::got_entity_key(zoneini, entity)) {
continue;
+ } else if (zoneini.got_key_bool("default", b)) {
+ if (b) {
+ zone->set_default_view(entity);
+ }
+ } else if (zoneini.got_key_bool("dock", b)) {
+ if (b) {
+ entity->set_flag(core::Entity::Dockable);
+ //core::Parser::read_entity_menu(entity, "zones/" + zone->label() + "/" + entity->label());
+ } else {
+ entity->unset_flag(core::Entity::Dockable);
+ }
} else {
zoneini.unkown_key();
}
@@ -625,6 +700,8 @@ void Base::player_connect(core::Player *player)
{
std::string args;
player->set_zone(default_zone);
+ player->set_view(0); // not docked
+
func_spectate(player, args);
}
diff --git a/src/game/base/base.h b/src/game/base/base.h
index 34b3bd7..fcf39d1 100644
--- a/src/game/base/base.h
+++ b/src/game/base/base.h
@@ -29,6 +29,7 @@ const unsigned int star_enttype = 257;
const unsigned int planet_enttype = 258;
const unsigned int navpoint_enttype = 259;
const unsigned int jumppoint_enttype = 260;
+const unsigned int jumpgate_enttype = 261;
/// the base Project::OSiRiON game model
class Base : public core::Module {
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 412668d..20f37c8 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -59,14 +59,13 @@ void Ship::reset()
}
void Ship::impulse()
{
- if (entity_eventstate == core::Entity::Jump) {
- return;
-
- } else if ((entity_eventstate == core::Entity::Impulse) || (entity_eventstate == core::Entity::ImpulseInitiate)) {
+ if ((entity_eventstate == core::Entity::Impulse) || (entity_eventstate == core::Entity::ImpulseInitiate)) {
entity_eventstate = core::Entity::Normal;
-
+
+ } else if (entity_eventstate != core::Entity::Normal) {
+ return;
+
} else {
-
if (entity_eventstate == core::Entity::JumpInitiate) {
ship_jumpdrive_timer = 0;
entity_timer = 0;
@@ -87,6 +86,10 @@ void Ship::impulse()
void Ship::jump(std::string const &args)
{
+ if (entity_eventstate == core::Entity::Docked) {
+ return;
+ }
+
// devel mode provides instant jump access to arbitrary systems
if (Base::g_devel->value() && (args.size())) {
@@ -215,7 +218,19 @@ void Ship::frame(float seconds)
// target axis
math::Axis target_axis(entity_axis);
- if (entity_eventstate == core::Entity::JumpInitiate) {
+ if (entity_eventstate == core::Entity::Docked) {
+
+ target_thrust = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_direction = 0;
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+
+ entity_speed = 0;
+ return;
+
+ } else if (entity_eventstate == core::Entity::JumpInitiate) {
if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
diff --git a/src/render/camera.cc b/src/render/camera.cc
index 852e93f..04d899f 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -207,25 +207,45 @@ void Camera::frame(float seconds)
math::Axis target_axis;
float d = 0;
- if (!core::localcontrol()) {
-
+ if (core::localplayer()->view()) {
if (camera_mode != Overview) {
set_mode(Overview);
}
-
- // TODO read Zone overview positions
- camera_eye.clear();
- camera_target.clear();
- camera_axis.clear();
- pitch_current = pitch_overview;
- camera_axis.change_pitch(pitch_current);
-
- //distance = 20.0f;
- distance = 8.0f;
+ } else if (core::localcontrol()) {
+ if (camera_mode == Overview) {
+ set_mode(Track);
+ }
+ } else {
+ if (camera_mode != Overview) {
+ set_mode(Overview);
+ }
+ }
+ if (mode() == Overview) {
+ camera_eye.clear();
+
+ if (core::localplayer()->view()) {
+ // player view entity
+ camera_target.assign(core::localplayer()->view()->location());
+ camera_axis.assign(core::localplayer()->view()->axis());
+ camera_axis.change_direction(180.0f);
+ distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 2.0f;
+
+ } else if (core::localplayer()->zone()->default_view()) {
+ // default zone view entity
+ camera_target.assign(core::localplayer()->zone()->default_view()->location());
+ camera_axis.assign(core::localplayer()->zone()->default_view()->axis());
+ camera_axis.change_direction(180.0f);
+ distance = math::max(core::localplayer()->zone()->default_view()->radius(), 1.0f) * 2.0f;
+ } else {
+ // default location (0,0,0)
+ camera_target.clear();
+ camera_axis.clear();
+ pitch_current = pitch_overview;
+ camera_axis.change_pitch(pitch_current);
+ distance = 8.0f;
+ }
} else {
- if (mode() == Overview)
- set_mode(Track);
camera_target.assign(core::localcontrol()->state()->location());
target_axis.assign(core::localcontrol()->state()->axis());
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 7bbb89c..1b1262f 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -112,32 +112,21 @@ void pass_prepare(float seconds)
}
}
- entity->state()->state_visible = false;
- entity->state()->state_detailvisible = false;
- entity->state()->state_targetable = false;
-
- entity->state()->state_distance = math::distance(Camera::eye(), entity->state()->location());
+ entity->state()->state_visible = entity->visible();
- // calculate visibility for entities with models
- if (entity->model()) {
-
- float r = entity->model()->radius();
- math::clamp(r, 1.0f, farplane / drawfxdistance);
- if (entity->state()->distance() < drawfxdistance * r) {
- // entites within detail range
- entity->state()->state_visible = true;
- entity->state()->state_detailvisible = true;
- } else if (entity->state()->distance() < drawdistance * r && entity->state()->distance() < core::range::max) {
- // entities within drawing distance, outside detail range
- entity->state()->state_visible = true;
- entity->state()->state_detailvisible = false;
+ if ((entity->type() == core::Entity::Controlable)) {
+ if (static_cast<core::EntityDynamic *>(entity)->eventstate() == core::Entity::Docked) {
+ entity->state()->state_visible = false;
}
+ }
- } else {
- entity->state()->state_visible = true;
+ entity->state()->state_detailvisible = false;
+ entity->state()->state_targetable = false;
+ entity->state()->state_distance = math::distance(Camera::eye(), entity->state()->location());
- if (entity->type() == core::Entity::Globe) {
-
+ if (entity->state()->visible()) {
+ // globes
+ if (entity->type() == core::Entity::Globe) {
core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
// add the globe to the globes list
@@ -174,8 +163,26 @@ void pass_prepare(float seconds)
gl::enable(GL_LIGHT1);
has_zone_light = true;
}
- }
- }
+
+ } else if (entity->model()) {
+
+ float r = entity->model()->radius();
+ math::clamp(r, 1.0f, farplane / drawfxdistance);
+ if (entity->state()->distance() < drawfxdistance * r) {
+ // entites within detail range
+ entity->state()->state_visible = true;
+ entity->state()->state_detailvisible = true;
+ } else if (entity->state()->distance() < drawdistance * r && entity->state()->distance() < core::range::max) {
+ // entities within drawing distance, outside detail range
+ entity->state()->state_visible = true;
+ entity->state()->state_detailvisible = false;
+ } else {
+ // out of range
+ entity->state()->state_visible = false;
+ entity->state()->state_detailvisible = false;
+ }
+ }
+ }
}
}
@@ -1076,7 +1083,10 @@ void draw(float seconds)
gl::depthmask(GL_FALSE); // disable depth buffer writing
draw_pass_spacegrid(); // draw the blue spacegrid
- Dust::draw(zone_color); // draw spacedust
+
+ if (!core::localplayer()->view()) {
+ Dust::draw(zone_color); // draw spacedust
+ }
draw_pass_model_fx(seconds); // draw entity lights and engines