From 31959bc355c471c573828bf63932850e46c4b5bc Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Feb 2008 23:06:00 +0000 Subject: more entities --- src/client/client.cc | 2 +- src/client/console.cc | 2 +- src/core/Makefile.am | 6 ++-- src/core/application.cc | 36 ++++++++++---------- src/core/application.h | 28 ++++++++------- src/core/clientstate.cc | 26 -------------- src/core/clientstate.h | 29 ---------------- src/core/commandbuffer.cc | 37 ++++++++++---------- src/core/commandbuffer.h | 10 +++--- src/core/core.h | 34 +++++++++++++------ src/core/cvar.cc | 25 +++++++------- src/core/cvar.h | 28 +++++++++------ src/core/entity.cc | 50 ++++++++++++++++++++++++--- src/core/entity.h | 86 +++++++++++++++++++++++++++++++++++++---------- src/core/func.cc | 8 ++--- src/core/func.h | 5 +-- src/core/gameinterface.cc | 7 ++-- src/core/gameinterface.h | 23 +++++++------ src/core/player.cc | 26 ++++++++++++++ src/core/player.h | 36 ++++++++++++++++++++ src/game/game.cc | 5 ++- src/game/shared.h | 4 +-- src/game/ship.cc | 2 +- src/game/ship.h | 2 -- src/game/star.cc | 2 +- src/server/server.cc | 2 -- 26 files changed, 323 insertions(+), 198 deletions(-) delete mode 100644 src/core/clientstate.cc delete mode 100644 src/core/clientstate.h create mode 100644 src/core/player.cc create mode 100644 src/core/player.h diff --git a/src/client/client.cc b/src/client/client.cc index faf9ac3..5243d28 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -85,7 +85,7 @@ void Client::init() con_print << "Initializing client..." << std::endl; // initialize core - core::localstate.name = "Client"; + core::localplayer.name = "Client"; core::Application::init(); // initialize SDL, but do not initialize any subsystems diff --git a/src/client/console.cc b/src/client/console.cc index 1c2ab1e..c59f477 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -261,7 +261,7 @@ void keypressed(const SDL_keysym &keysym) input_pos++; break; case SDLK_BACKSPACE: - if ((*history.rbegin()).size() && input_pos) { + if ((*history_pos).size() && input_pos) { (*history_pos).erase(input_pos-1, 1); input_pos--; } diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 1d330ef..ced2ce5 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -1,13 +1,13 @@ METASOURCES = AUTO INCLUDES = -I$(top_srcdir)/src -libcore_la_SOURCES = application.cc clientstate.cc commandbuffer.cc cvar.cc \ - entity.cc func.cc gameinterface.cc +libcore_la_SOURCES = application.cc commandbuffer.cc cvar.cc entity.cc func.cc \ + gameinterface.cc player.cc libcore_la_LDFLAGS = -avoid-version -no-undefined libcore_la_LIBADD = $(top_builddir)/src/math/libmath.la \ $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/filesystem/libfilesystem.la noinst_LTLIBRARIES = libcore.la noinst_HEADERS = application.h commandbuffer.h core.h cvar.h entity.h func.h \ - gameinterface.h + gameinterface.h player.h diff --git a/src/core/application.cc b/src/core/application.cc index 5979fc7..36d1c5a 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -104,7 +104,7 @@ Application::Application() sys::quit(2); } application_instance = this; - + sys::signal(SIGHUP, signal_handler); sys::signal(SIGINT, signal_handler); sys::signal(SIGQUIT, signal_handler); @@ -125,22 +125,22 @@ void Application::init() { con_print << "Initializing core..." << std::endl; con_debug << "Debug messages enabled" << std::endl; - + // initialize core subsystems filesystem::init(); - + // register our functions func::add("print", func_print); func::add("help", func_help); func::add("quit", func_quit); - + func::add("connect", func_connect); func::add("disconnect", func_disconnect); - + func::add("list_var", func_list_var); func::add("list_func", func_list_func); func::add("list_ent", func_list_ent); - + if (game()) game()->connected = false; current_time = 0; @@ -149,12 +149,12 @@ void Application::init() void Application::shutdown() { con_print << "Shutting down core..." << std::endl; - + if (game() && game()->connected) disconnect(); - + //if (game()) unload(); - + filesystem::shutdown(); } @@ -169,14 +169,14 @@ void Application::connect() con_warn << "No game module loaded!" << std::endl; return; } - + if (game()->connected) { con_warn << "Connected. Disconnect first." << std::endl; } entity::clear(); game()->current_time = 0; - + if (game()->connected = game()->init()) { con_print << "Connected." << std::endl; } else { @@ -190,31 +190,31 @@ void Application::disconnect() con_warn << "No game module loaded!" << std::endl; return; } - + if (!game()->connected) { con_warn << "Not connected." << std::endl; return; } - + game()->shutdown(); - + game()->connected = false; game()->current_time = 0; - + entity::clear(); - + con_print << "Disconnected." << std::endl; } void Application::frame(float seconds) { current_time += seconds; - + if (game() && game()->connected) { game()->current_time += seconds; game()->frame(seconds); } - + // execute commands in the buffer commandbuffer::execute(); } diff --git a/src/core/application.h b/src/core/application.h index 34e0a97..1e2869a 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -7,43 +7,45 @@ #ifndef __INCLUDED_CORE_APPLICATION_H__ #define __INCLUDED_CORE_APPLICATION_H__ -namespace core { +namespace core +{ /// core interface for the client and server Application classes -class Application { +class Application +{ public: /// default constructor Application(); - + /// default destructor virtual ~Application(); - + /// initialize the application virtual void init(); - + /// shutdown the application virtual void shutdown(); - + /// run a core frame virtual void frame(float seconds); - + /// a pointer to the current console instance static Application *instance(); - + /// quit the application virtual void quit(int status); - + /// load the game module void connect(); - + /// disconnect from the game module void disconnect(); - + /// time the core has been running, in seconds float current_time; - + /// global application object - static Application *application_instance; + static Application *application_instance; }; diff --git a/src/core/clientstate.cc b/src/core/clientstate.cc deleted file mode 100644 index 19daab9..0000000 --- a/src/core/clientstate.cc +++ /dev/null @@ -1,26 +0,0 @@ -/* - core/clientstate.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2. -*/ - -#include "core/clientstate.h" - -namespace core -{ - -ClientState::ClientState() -{ - dirty = false; - id = 0; - name.clear(); -} - -ClientState::~ClientState() -{ -} - -ClientState localstate; - -} - diff --git a/src/core/clientstate.h b/src/core/clientstate.h deleted file mode 100644 index ef912ed..0000000 --- a/src/core/clientstate.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - core/clientstate.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2. -*/ - -#ifndef __INCLUDED_CORE_CLIENTSTATE_H__ -#define __INCLUDED_CORE_CLIENTSTATE_H__ - -#include - -namespace core -{ - -class ClientState { -public: - ClientState(); - ~ClientState(); - - std::string name; - unsigned int id; - bool dirty; -}; - -extern ClientState localstate; - -} - -#endif // __INCLUDED_CORE_CLIENTSTATE_H__ diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 965f428..c381d38 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -17,16 +17,17 @@ namespace core std::stringstream cmd(std::stringstream::in | std::stringstream::out); -namespace commandbuffer { +namespace commandbuffer +{ void exec(const char *text) { std::stringstream cmdstream(text); std::string cmdname; - + if (!(cmdstream >> cmdname)) return; - + // is it a function Func f = func::find(cmdname); if (f) { @@ -34,7 +35,7 @@ void exec(const char *text) f(cmdstream); return; } - + // is it a cvar Cvar cv = cvar::find(cmdname); if (cv) { @@ -43,15 +44,15 @@ void exec(const char *text) if (cmdstream >> args) { // we're setting a new value char c; - while(cmdstream >> c) + while (cmdstream >> c) args += c; (*cv) = args; } - + con_print << cmdname << " " << cv->text() << std::endl; return; } - + con_print << "Unknown command '" << cmdname << "'" << std::endl; } @@ -59,12 +60,12 @@ void execute() { if (core::cmd.eof()) return; - + char line[MAXCMDSIZE]; while (core::cmd.getline(line, MAXCMDSIZE-1)) { exec(line); } - + cmd.clear(); } @@ -74,14 +75,14 @@ void clear() while (core::cmd.getline(line, MAXCMDSIZE-1)); } -void complete(std::string &input, size_t &pos) +void complete(std::string &input, size_t &pos) { std::list match; - + std::string partial = input.substr(0, pos); if (!partial.size()) return; - + // search function registry for matches std::map::iterator f; for (f = func::registry.begin(); f != func::registry.end(); f++) { @@ -90,7 +91,7 @@ void complete(std::string &input, size_t &pos) //con_print << " " << (*f).first << std::endl; } } - + // search cvar registry for matches std::map::iterator c; for (c = cvar::registry.begin(); c != cvar::registry.end(); c++) { @@ -99,12 +100,12 @@ void complete(std::string &input, size_t &pos) //con_print << " " << (*c).first << std::endl; } } - + if (!match.size()) return; - + std::string maxmatch(*match.begin()); - + if (match.size() > 1) { std::list::iterator l; for (l = match.begin(); l !=match.end(); l++) { @@ -121,13 +122,13 @@ void complete(std::string &input, size_t &pos) con_print << match.size() << " matches" << std::endl; } - + if (maxmatch.size() > partial.size()) { if (match.size()==1) maxmatch += ' '; input.replace(0, pos, maxmatch); pos = maxmatch.size(); } - + } } // namespace commandbuffer diff --git a/src/core/commandbuffer.h b/src/core/commandbuffer.h index 6f5b324..22f53d2 100644 --- a/src/core/commandbuffer.h +++ b/src/core/commandbuffer.h @@ -1,7 +1,7 @@ /* core/commandbuffer.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_COMMANDBUFFER_H__ @@ -13,12 +13,14 @@ // C++ headers #include -namespace core { +namespace core +{ /// global buffer to hold the command stream extern std::stringstream cmd; -namespace commandbuffer { +namespace commandbuffer +{ /// execute the commands in the buffer void execute(); diff --git a/src/core/core.h b/src/core/core.h index 6a2d855..0e23386 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -1,30 +1,42 @@ /* core/core.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_H__ #define __INCLUDED_CORE_H__ -#include "core/clientstate.h" +#include "core/player.h" #include "core/gameinterface.h" #include "core/application.h" /// core contains the basic functionality of the engine namespace core { - /// pointer to the current GameInterface - inline GameInterface *game() { return GameInterface::instance(); } +/// pointer to the current GameInterface +inline GameInterface *game() +{ + return GameInterface::instance(); +} - /// pointer to the current ApplicationInterface - inline Application *application() { return Application::instance(); } +/// pointer to the current ApplicationInterface +inline Application *application() +{ + return Application::instance(); +} - /// true if the core is connected to a game module - inline bool connected() { return (GameInterface::instance() && GameInterface::instance()->connected); } +/// true if the core is connected to a game module +inline bool connected() +{ + return (GameInterface::instance() && GameInterface::instance()->connected); +} - /// return the time the core has been running, in seconds - inline float time() { return Application::instance()->current_time; } +/// return the time the core has been running, in seconds +inline float time() +{ + return Application::instance()->current_time; +} }; #include "core/commandbuffer.h" diff --git a/src/core/cvar.cc b/src/core/cvar.cc index 9d1c167..2350b56 100644 --- a/src/core/cvar.cc +++ b/src/core/cvar.cc @@ -1,7 +1,7 @@ /* core/cvar.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #include "core/cvar.h" @@ -14,7 +14,8 @@ #include -namespace core { +namespace core +{ Cvar_t::Cvar_t(unsigned int cvarflags) { @@ -53,19 +54,19 @@ Cvar_t & Cvar_t::operator=(float other) return (*this); } -unsigned int Cvar_t::flags() const -{ +unsigned int Cvar_t::flags() const +{ return(cvar_flags); } -float Cvar_t::value() const -{ - return(cvar_value); +float Cvar_t::value() const +{ + return(cvar_value); } -const std::string &Cvar_t::text() const -{ - return(cvar_text); +const std::string &Cvar_t::text() const +{ + return(cvar_text); } namespace cvar @@ -156,7 +157,7 @@ Cvar find(const char *name) void list() { - std::map::iterator it; + std::map::iterator it; for (it = registry.begin(); it != registry.end(); it++) { con_print << " "<< (*it).first << " " << (*it).second->text() << std::endl; } diff --git a/src/core/cvar.h b/src/core/cvar.h index 205a416..9b23563 100644 --- a/src/core/cvar.h +++ b/src/core/cvar.h @@ -1,7 +1,7 @@ /* core/cvar.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_CVAR_H__ @@ -10,18 +10,21 @@ #include #include -namespace core { +namespace core +{ /// the cvar container class -class Cvar_t { +class Cvar_t +{ public: - Cvar_t(unsigned int cvflags = 0); + Cvar_t(unsigned int cvflags = 0); + Cvar_t &operator=(const char *other); Cvar_t &operator=(const std::string &other); Cvar_t &operator=(int other); Cvar_t &operator=(float other); - + unsigned int flags() const; float value() const; const std::string &text() const; @@ -36,30 +39,33 @@ private: typedef Cvar_t *Cvar; /// the cvar registry -namespace cvar +namespace cvar { +/// cvar flags +enum Flags {Archive=2, ReadOnly=4}; + /// get a cvar value from the registry /** If the a cvar with the given name already exists in the registry, - * its value will not be changed. If the cvar does not exist, + * its value will not be changed. If the cvar does not exist, * it will be created */ Cvar get(const char *name, const char *value, int flags=0); /// get a cvar value from the registry /** If the a cvar with the given name already exists in the registry, - * its value will not be changed. If the cvar does not exist, + * its value will not be changed. If the cvar does not exist, * it will be created */ Cvar get(const char *name, float value, int flags=0); /// set a cvar value /** If the a cvar with the given name already exists in the registry, - * its value will be replaced + * its value will be replaced */ Cvar set(const char *name, const char *value, int flags=0); /// set a cvar value /** If the a cvar with the given name already exists in the registry, - * its value will be replaced + * its value will be replaced */ Cvar set(const char *name, float value, int flags=0); diff --git a/src/core/entity.cc b/src/core/entity.cc index c8736da..7f23213 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -11,33 +11,71 @@ namespace core { -Entity::Entity(unsigned int entity_type, unsigned int entity_flags) +// --- Entity ----------------------------------------------------- + +Entity::Entity(unsigned int entity_flags, unsigned int entity_type) { flags = entity_flags; type = entity_type; + core::entity::add(this); } Entity::~Entity() +{} + +// --- EntityDynamic ------------------------------------------ + +EntityDynamic::EntityDynamic(unsigned int entity_flags, unsigned int entity_type) : + Entity(entity_type, entity_flags), + speed(0,0,0) +{ + +} + +// --- EntityControlable ------------------------------------------ + +EntityControlable::EntityControlable(unsigned int entity_flags, unsigned int entity_type) : + EntityDynamic(entity_type, entity_flags) { + owner = 0; } -namespace entity +// --- namespace entity ------------------------------------------- + +namespace entity { std::vector registry; void add(Entity *ent) { - ent->id = (unsigned int) registry.size(); + std::vector::iterator it; + unsigned int entity_id = 1; + for (it=registry.begin(); it != registry.end() && entity_id == (*it)->id; it++) { + entity_id++; + } + ent->id = entity_id; registry.push_back(ent); } +void remove(unsigned int entity_id) +{ + std::vector::iterator it; + for (it=registry.begin(); it != registry.end(); it++) { + if (entity_id == (*it)->id) { + delete((*it)); + registry.erase(it); + return; + } + } +} + void clear() { std::vector::iterator it; for (it=registry.begin(); it != registry.end(); it++) { - delete (*it); + delete(*it); (*it) = 0; } registry.clear(); @@ -47,7 +85,9 @@ void list() { std::vector::iterator it; for (it=registry.begin(); it != registry.end(); it++) { - con_print << " id " << std::setw(3) << (*it)->id << " type " << std::setw(2) << (*it)->type << std::endl; + con_print << " id " << std::setw(3) << (*it)->id + << " type " << std::setw(2) << (*it)->type + << " " << (*it)->label << std::endl; } con_print << registry.size() << " registered entities" << std::endl; } diff --git a/src/core/entity.h b/src/core/entity.h index ef9168b..8efb2aa 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -7,45 +7,97 @@ #ifndef __INCLUDED_CORE_ENTITY_H__ #define __INCLUDED_CORE_ENTITY_H__ +#include "core/core.h" +#include "core/player.h" #include "math/mathlib.h" #include namespace core { +namespace entity +{ + +/// Entity flags +enum Flags {Static=1}; + +/// Entity type constants +enum Type {None = 0, Dynamic = 1, Controlable = 2}; + +} + /// The base world entity. All gameworld entities must derive from this class. -class Entity { +class Entity +{ public: /// create a new entity and add it to the registry - Entity(unsigned int entity_type, unsigned int entity_flags=0); + Entity(unsigned int entity_flags = 0, unsigned int entity_type = entity::None); virtual ~Entity(); - - /// core id of the entity + + /// id of the entity unsigned int id; + /// flags + unsigned int flags; + + /// type + unsigned int type; + + /// base shape + unsigned int base_shape; + + /// base color + math::Color base_color; + + /// label + std::string label; + + /* updateable */ + /// location of the entity math::Vector3f location; +}; - /// flags - unsigned int flags; +/// an entity that can move +class EntityDynamic : public Entity +{ +public: + EntityDynamic(unsigned int entity_flags = 0, unsigned int entity_type=entity::Dynamic); - /// type - unsigned int type; + /* updateable */ + + /// speed vector, in game units / second + math::Vector3f speed; }; -namespace entity { +/// an entity that can be controlled by a player +class EntityControlable : public EntityDynamic +{ +public: + EntityControlable(unsigned int entity_flags = 0, unsigned int entity_type=entity::Controlable); + + /// owner of this controllable entity + Player *owner; +}; + + +namespace entity +{ + +/// base entity shapes +enum Shapes {Diamond=0, Cube=1, Sphere=2}; - /// the entity registry - extern std::vector registry; +/// the entity registry +extern std::vector registry; - /// add an entity to the registry - void add(Entity *ent); +/// add an entity to the registry +void add(Entity *ent); - /// clear the entity registry - void clear(); +/// clear the entity registry +void clear(); - /// list the entity registry - void list(); +/// list the entity registry +void list(); } } diff --git a/src/core/func.cc b/src/core/func.cc index 664af4a..9f64906 100644 --- a/src/core/func.cc +++ b/src/core/func.cc @@ -11,7 +11,7 @@ namespace core { -namespace func +namespace func { std::map registry; @@ -44,9 +44,9 @@ Func find(const std::string &functionname) void list() { std::map::iterator it; - for (it = registry.begin(); it != registry.end(); it++) { - con_print << " " << (*it).first << std::endl; - } + for (it = registry.begin(); it != registry.end(); it++) { + con_print << " " << (*it).first << std::endl; + } con_print << registry.size() << " registered functions" << std::endl; } diff --git a/src/core/func.h b/src/core/func.h index 3a58295..ae158b5 100644 --- a/src/core/func.h +++ b/src/core/func.h @@ -17,10 +17,11 @@ namespace core { /// function pointer type -typedef void (* Func)(std::stringstream &args); +typedef void(* Func)(std::stringstream &args); /// the function registry -namespace func { +namespace func +{ /// add a function to the registry void add(const char *functionname, Func functionptr); diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index 639a522..26e05da 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -1,7 +1,7 @@ /* core/gameinterface.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #include "core/gameinterface.h" @@ -10,7 +10,8 @@ #include -namespace core { +namespace core +{ GameInterface *GameInterface::gameinterface_instance = 0; diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index dde7f12..2e61ffb 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -1,7 +1,7 @@ /* core/gameinterface.h - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_GAMEINTERFACE_H__ @@ -13,33 +13,34 @@ namespace core /// abstract interface from the core to the game-specific code /** The real game class has to derive from this class */ -class GameInterface { +class GameInterface +{ public: /// create a new game singleton GameInterface(); /// destroy the game singleton virtual ~GameInterface(); - + /// initialize the game virtual bool init() = 0; - + /// shutdown the game virtual void shutdown() = 0; - + /// run one frame of the game /** @param sec time since the previous frame, in seconds */ - virtual void frame (float seconds) = 0; - + virtual void frame(float seconds) = 0; + /// a pointer to the current game instance static GameInterface * instance(); - + /// true if the game is ready and running bool connected; - + /// time the game has been running, in seconds float current_time; - + private: static GameInterface *gameinterface_instance; }; diff --git a/src/core/player.cc b/src/core/player.cc new file mode 100644 index 0000000..5eae8ec --- /dev/null +++ b/src/core/player.cc @@ -0,0 +1,26 @@ +/* + core/player.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2. +*/ + +#include "core/player.h" + +namespace core +{ + +Player::Player() +{ + id = 0; + name.clear(); + dirty = false; +} + +Player::~Player() +{ +} + +Player localplayer; + +} + diff --git a/src/core/player.h b/src/core/player.h new file mode 100644 index 0000000..e5ff396 --- /dev/null +++ b/src/core/player.h @@ -0,0 +1,36 @@ +/* + core/clientstate.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2. +*/ + +#ifndef __INCLUDED_CORE_PLAYER_H__ +#define __INCLUDED_CORE_PLAYER_H__ + +#include "core/core.h" + +#include +namespace core +{ + +class Player +{ +public: + Player(); + ~Player(); + + /// name of the player + std::string name; + + /// core id of the player + unsigned int id; + + /// dirty state + bool dirty; +}; + +extern Player localplayer; + +} + +#endif // __INCLUDED_CORE_PLAYER_H__ diff --git a/src/game/game.cc b/src/game/game.cc index f8b8596..8a50e33 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -97,10 +97,13 @@ bool Game::init() con_print << " " << sectors[n]->label << " " << sectors[n]->name << std::endl; */ - ship = new Ship(); star = new Star(); star->location = Vector3f(256.0f, 0.0f, 256.0f); + star->label = "star: Sabishi Hoshi"; + + ship = new Ship(); ship->location = Vector3f(0,0,0); + ship->label = "ship: Micron Vector"; return true; } diff --git a/src/game/shared.h b/src/game/shared.h index 5c04309..a9228a3 100644 --- a/src/game/shared.h +++ b/src/game/shared.h @@ -10,8 +10,8 @@ namespace game { // entity type constants - const unsigned int ship_enttype = 1; - const unsigned int star_enttype = 2; + const unsigned int ship_enttype = 256; + const unsigned int star_enttype = 257; } diff --git a/src/game/ship.cc b/src/game/ship.cc index 9252f1d..1ef4b9d 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -17,7 +17,7 @@ using math::degrees180f; namespace game { -Ship::Ship() : core::Entity(ship_enttype) +Ship::Ship() : core::Entity(0, ship_enttype) { speed = 0; yaw_current = 0; diff --git a/src/game/ship.h b/src/game/ship.h index f83c41e..e919f38 100644 --- a/src/game/ship.h +++ b/src/game/ship.h @@ -42,8 +42,6 @@ public: float speed_max; /// yaw turn speed float yaw_speed; - - static const unsigned int type_id=1; private: /// current yaw, angle in XZ plane, 0-360 float yaw_current; diff --git a/src/game/star.cc b/src/game/star.cc index a8b5e87..4ef22de 100644 --- a/src/game/star.cc +++ b/src/game/star.cc @@ -10,7 +10,7 @@ namespace game { -Star::Star() : core::Entity(star_enttype), +Star::Star() : core::Entity(0, star_enttype), color(1,1,1,1) { radius = 48; diff --git a/src/server/server.cc b/src/server/server.cc index 1c298e8..b065eea 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -5,7 +5,6 @@ */ #include "core/core.h" -#include "core/clientstate.h" #include "server/console.h" #include "server/server.h" #include "server/timer.h" @@ -59,7 +58,6 @@ void Server::init() con_print << "Initializing server..." << std::endl; - core::localstate.name = "Console"; core::Application::init(); console::init(); -- cgit v1.2.3