/* base/game.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_BASE_H__ #define __INCLUDED_BASE_H__ #include #include #include "base/ship.h" #include "base/shipmodel.h" #include "base/star.h" #include "core/module.h" #include "core/application.h" #include "core/gameinterface.h" #include "filesystem/inifile.h" #include "sys/sys.h" /// the base game module /** the base game module contains the game-specific code for Project::OSiRiON */ namespace game { // entity type constants const unsigned int ship_enttype = 256; 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; const unsigned int station_enttype = 262; const unsigned int cargopod_enttype = 263; const unsigned int spacemine_enttype = 264; const unsigned int race_enttype = 280; // planet docking distance const float planet_safe_distance = 50.0f; // ship engine delay times const float jump_timer_delay = 5.0f; const float jump_cooldown_delay = 2.0f; const float impulse_timer_delay = 3.0f; /// default player settings class Default { public: static core::Zone *zone; static core::Entity *view; static ShipModel *shipmodel; static long credits; static void clear(); }; /// the base Project::OSiRiON game model class Game : public core::Module { public: Game(); virtual ~Game(); /// run one game frame void frame(float seconds); /// is called when a player connects virtual void player_connect(core::Player *player); /// is called when a player disconnects virtual void player_disconnect(core::Player *player); /// load a player data virtual void player_load(core::Player *player); /// save player data virtual void player_save(core::Player *player); /// singleplayer load game function virtual void game_load(core::Player *player, filesystem::IniFile & inifile); /// singleplayer save game function virtual void game_save(core::Player *player, std::ostream & os); /* --- game variables -------------------------------------- */ /// game variable: maximum speed of the impulse drive static core::Cvar *g_impulsespeed; /// game variable: jumppoint range static core::Cvar *g_jumppointrange; /// game variable: enable or disable development mode (cheat mode) static core::Cvar *g_devel; /// game variable: number of seconds it takes for 1 unit of cargo to deplete from station inventories static core::Cvar *g_deplete; /// physics variable: default damping factor of space static core::Cvar *g_damping; private: bool load_world(); bool load_zone(core::Zone *zone); bool validate_zone(core::Zone *zone); bool generate_entity_menus(core::Entity *entity); bool load_commodities(); bool load_settings(); /* ---- 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_jump(core::Player *player, std::string const &args); static void func_impulse(core::Player *player, std::string const &args); 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_freeflight(core::Player *player, std::string const &args); static void func_goto(core::Player *player, const std::string &args); static void func_buy(core::Player *player, std::string const &args); static void func_sell(core::Player *player, const std::string &args); static void func_give(core::Player *player, const std::string &args); 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_drop(core::Player *player, std::string const &args); static void func_mount(core::Player *player, const std::string &args); static void func_unmount(core::Player *player, const std::string &args); static void func_beam(core::Player *player, const std::string &args); static void func_wingmen(core::Player *player, const std::string &args); /* ---- target functions ----------------------------------- */ static void func_target_goto(core::Player *player, core::Entity *entity); 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 core::Module *factory(); } #endif // __INCLUDED_BASE_H__