Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/camera.cc12
-rw-r--r--src/client/client.cc6
-rw-r--r--src/client/console.cc8
-rw-r--r--src/client/draw.cc52
-rw-r--r--src/client/input.cc33
-rw-r--r--src/client/video.cc12
6 files changed, 65 insertions, 58 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index d0f25f3..03a4e1b 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -82,7 +82,7 @@ void set_mode(Mode newmode) {
case Track:
// switch camera to Track mode
mode = Track;
- yaw_target = core::localplayer.control->direction;
+ yaw_target = core::Player::local.control->direction();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;
@@ -91,7 +91,7 @@ void set_mode(Mode newmode) {
case Free:
// switch camera to Free mode
mode = Free;
- yaw_target = core::localplayer.control->direction;
+ yaw_target = core::Player::local.control->direction();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;
@@ -112,7 +112,7 @@ void set_mode(Mode newmode) {
void next_mode()
{
- if (!core::localplayer.control) {
+ if (!core::Player::local.control) {
set_mode(Overview);
return;
}
@@ -133,7 +133,7 @@ void next_mode()
void draw(float elapsed)
{
- if (!core::localplayer.control) {
+ if (!core::Player::local.control) {
// switch the camera to Overview of the player is not controling anything
if (mode != Overview) {
set_mode(Overview);
@@ -142,11 +142,11 @@ void draw(float elapsed)
if (mode == Overview)
set_mode(Track);
- camera::target = core::localplayer.control->location;
+ camera::target = core::Player::local.control->location();
}
if (mode == Track) {
- yaw_target = core::localplayer.control->direction;
+ yaw_target = core::Player::local.control->direction();
}
if ((mode == Free) || (mode == Track)) {
diff --git a/src/client/client.cc b/src/client/client.cc
index 407fb5a..b93fe35 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -83,7 +83,7 @@ void Client::init()
con_print << "Initializing client..." << std::endl;
// initialize core
- core::sv_dedicated = core::cvar::set("sv_dedicated", "0", core::cvar::ReadOnly);
+ core::Cvar::sv_dedicated = core::Cvar::set("sv_private", "0");
core::Application::init();
// initialize SDL, but do not initialize any subsystems
@@ -102,7 +102,7 @@ void Client::init()
input::init();
// add engine functions
- core::func::add("r_restart", func_r_restart);
+ core::Func::add("r_restart", (core::FuncPtr) func_r_restart);
}
void Client::run()
@@ -141,7 +141,7 @@ void Client::shutdown()
console::flush();
// remove engine functions
- core::func::remove("r_restart");
+ core::Func::remove("r_restart");
console::shutdown();
console::flush();
diff --git a/src/client/console.cc b/src/client/console.cc
index c352969..5fb382e 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -76,7 +76,7 @@ void init()
console_visible = false;
// add engine functions
- core::func::add("con_toggle", func_con_toggle);
+ core::Func::add("con_toggle", (core::FuncPtr) func_con_toggle);
text.clear();
console_scroll = 0;
@@ -96,7 +96,7 @@ void shutdown()
save_history();
// remove engine functions
- core::func::remove("con_toggle");
+ core::Func::remove("con_toggle");
text.clear();
console_scroll = 0;
@@ -209,7 +209,7 @@ void keypressed(const SDL_keysym &keysym)
switch( keysym.sym ) {
case SDLK_TAB:
- core::commandbuffer::complete( (*history_pos), input_pos);
+ core::CommandBuffer::complete( (*history_pos), input_pos);
break;
case SDLK_RETURN:
if ((*history_pos).size()) {
@@ -218,7 +218,7 @@ void keypressed(const SDL_keysym &keysym)
history.pop_front();
}
- core::cmd << (*history_pos) << std::endl;
+ core::cmd() << (*history_pos) << std::endl;
(*history.rbegin()) = (*history_pos);
history.push_back("");
diff --git a/src/client/draw.cc b/src/client/draw.cc
index 021cf3a..72a67c2 100644
--- a/src/client/draw.cc
+++ b/src/client/draw.cc
@@ -4,7 +4,7 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "core/player.h"
+#include "core/core.h"
#include "render/render.h"
#include "render/sphere.h"
#include "render/box.h"
@@ -20,16 +20,16 @@ render::Box cube(math::Vector3f(0.5f, 0.5f, 0.5f), math::Vector3f(-0.5f, -0.5f,
void draw_entity_sphere(core::Entity *entity)
{
- render::gl::color(entity->core_color);
- sphere.radius = entity->core_radius;
+ render::gl::color(entity->color());
+ sphere.radius = entity->radius();
sphere.draw();
}
void draw_entity_cube(core::Entity *entity)
{
- cube.topcolor = entity->core_color;
- cube.bottomcolor = entity->core_color * 0.7f;
- cube.radius = entity->core_radius;
+ cube.topcolor = entity->color();
+ cube.bottomcolor = entity->color();
+ cube.radius = entity->radius();
cube.draw();
}
@@ -37,11 +37,11 @@ void draw_entity_cube(core::Entity *entity)
void draw_entity_diamond(core::Entity *entity)
{
using namespace render;
- float r = entity->core_radius;
+ float r = entity->radius();
gl::begin(gl::Lines);
gl::color(1.0f, 0.0f, 0.0f);
gl::vertex(r,0.0f,0.0f);
- gl::color(entity->core_color);
+ gl::color(entity->color());
gl::vertex(-r,0.0f,0.0f);
gl::vertex(0.0f,0.0f,r/2);
@@ -52,22 +52,22 @@ void draw_entity_diamond(core::Entity *entity)
gl::end();
}
-// draw an entity of core_type core::entity::Default
+// draw an entity of entity_type core::Entity::Default
void draw_entity_default(core::Entity *entity)
{
render::gl::push();
- render::gl::translate(entity->location);
+ render::gl::translate(entity->location());
- switch(entity->core_shape) {
- case core::entity::Sphere:
+ switch(entity->shape()) {
+ case core::Entity::Sphere:
draw_entity_sphere(entity);
break;
- case core::entity::Diamond:
+ case core::Entity::Diamond:
draw_entity_diamond(entity);
break;
- case core::entity::Cube:
+ case core::Entity::Cube:
default:
draw_entity_cube(entity);
@@ -96,9 +96,9 @@ void draw_ship(core::EntityControlable *entity)
using namespace render;
gl::push();
- gl::translate(entity->location);
+ gl::translate(entity->location());
gl::scale(0.2f, 0.2f, 0.2f);
- gl::rotate(entity->direction, 0.0f, 1.0f, 0.0f );
+ gl::rotate(entity->direction(), 0.0f, 1.0f, 0.0f );
Vector3f tl(0.25, 0.125, 0.125);
Vector3f br(-0.25, -0.125, -0.125);
@@ -127,14 +127,14 @@ void draw_ship(core::EntityControlable *entity)
cockpit.bottomcolor = engine1.bottomcolor;
cockpit.draw();
- if(entity->target_thrust > 0 ) {
+ if(entity->thrust() > 0 ) {
gl::color(1.0f,0 ,0 );
gl::begin(gl::Lines);
gl::vertex(-0.5f, 0, 0.185);
- gl::vertex(-0.5f-0.25f*entity->target_thrust, 0, 0.185);
+ gl::vertex(-0.5f-0.25f*entity->thrust(), 0, 0.185);
gl::vertex(-0.5f, 0, -0.185f);
- gl::vertex(-0.5f-0.25f*entity->target_thrust, 0, -0.185f);
+ gl::vertex(-0.5f-0.25f*entity->thrust(), 0, -0.185f);
gl::end();
}
@@ -207,14 +207,14 @@ void draw_world(float seconds)
// draw entities
using namespace render;
- std::vector<core::Entity *>::iterator it;
- for (it=core::entity::registry.begin(); it != core::entity::registry.end(); it++) {
- switch ( (*it)->core_type()) {
- case core::entity::Default:
- draw_entity_default((*it));
+ std::map<unsigned int, core::Entity *>::iterator it;
+ for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
+ switch ((*it).second->type()) {
+ case core::Entity::Default:
+ draw_entity_default((*it).second);
break;
- case core::entity::Controlable:
- draw_ship(static_cast<core::EntityControlable *>(*it));
+ case core::Entity::Controlable:
+ draw_ship(static_cast<core::EntityControlable *> ((*it).second));
default:
break;
}
diff --git a/src/client/input.cc b/src/client/input.cc
index ee16038..9053725 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -20,7 +20,9 @@ namespace input
{
// local offset to make turns
-float turn_offset;
+float local_turn_offset;
+// local thrust setting
+float local_thrust;
void init()
{
@@ -63,23 +65,27 @@ void keypressed(const SDL_keysym &keysym)
break;
case SDLK_KP_PLUS:
// TODO set core entity params
- core::localplayer.control->target_thrust += 0.08f;
+ local_thrust += 0.08f;
+ if (local_thrust > 1.0f)
+ local_thrust = 1.0f;
break;
case SDLK_KP_MINUS:
// TODO set core entity params
- core::localplayer.control->target_thrust -= 0.1f;
+ local_thrust -= 0.1f;
+ if (local_thrust < 0.0f)
+ local_thrust = 0.0f;
break;
case SDLK_KP4:
// TODO set core entity params
- turn_offset += 5;
- if (turn_offset > 90)
- turn_offset = 90;
+ local_turn_offset += 5;
+ if (local_turn_offset > 90)
+ local_turn_offset = 90;
break;
case SDLK_KP6:
// TODO set core entity params
- turn_offset -= 5;
- if (turn_offset < -90)
- turn_offset = -90;
+ local_turn_offset -= 5;
+ if (local_turn_offset < -90)
+ local_turn_offset = -90;
break;
default:
break;
@@ -95,7 +101,7 @@ void frame(float seconds)
switch (event.type) {
case SDL_KEYUP:
- if (!console::visible() && core::application()->connected() && core::localplayer.control)
+ if (!console::visible() && core::application()->connected() && core::Player::local.control)
// send key events to the game world
keyreleased(event.key.keysym);
break;
@@ -105,7 +111,7 @@ void frame(float seconds)
} else if (console::visible()) {
// send key events to the console
console::keypressed(event.key.keysym);
- } else if (core::application()->connected() && core::localplayer.control) {
+ } else if (core::application()->connected() && core::Player::local.control) {
// send key events to the game world
keypressed(event.key.keysym);
}
@@ -117,8 +123,9 @@ void frame(float seconds)
}
- if (!console::visible() && core::application()->connected() && core::localplayer.control) {
- core::localplayer.control->target_direction = math::degrees360f(core::localplayer.control->direction+turn_offset);
+ if (!console::visible() && core::application()->connected() && core::Player::local.control) {
+ core::Player::local.control->set_thrust(local_thrust);
+ core::Player::local.control->set_direction(math::degrees360f(core::Player::local.control->direction() + local_turn_offset));
}
}
diff --git a/src/client/video.cc b/src/client/video.cc
index b441e67..dfdf511 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -31,9 +31,9 @@ float aspect = 1;
//--- cvars -------------------------------------------------------
-core::Cvar r_width;
-core::Cvar r_height;
-core::Cvar r_fullscreen;
+core::Cvar *r_width;
+core::Cvar *r_height;
+core::Cvar *r_fullscreen;
void reset()
{
@@ -52,9 +52,9 @@ bool init()
con_print << "Initializing video..." << std::endl;
// initialize cvars
- r_width = core::cvar::get("r_width", width_default);
- r_height = core::cvar::get("r_height", height_default);
- r_fullscreen = core::cvar::get("r_fullscreen", "0");
+ r_width = core::Cvar::get("r_width", width_default, core::Cvar::Archive);
+ r_height = core::Cvar::get("r_height", height_default, core::Cvar::Archive);
+ r_fullscreen = core::Cvar::get("r_fullscreen", "0", core::Cvar::Archive);
int bpp = 0;
int flags = 0;