Skip to content

Commit

Permalink
Introduce new server and game state interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Nov 9, 2015
1 parent 5f87b29 commit f4d3160
Show file tree
Hide file tree
Showing 37 changed files with 439 additions and 299 deletions.
2 changes: 1 addition & 1 deletion src/xrGame/GamePersistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ void CGamePersistent::OnEvent(EVENT E, u64 P1, u64 P2)
LPSTR saved_name = (LPSTR)(P1);

Level().remove_objects ();
game_sv_Single *game = smart_cast<game_sv_Single*>(Level().Server->game);
game_sv_Single *game = smart_cast<game_sv_Single*>(Level().Server->GetGameState());
R_ASSERT (game);
game->restart_simulator (saved_name);
xr_free (saved_name);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ void CLevel::OnRender()
}
}
// [7/5/2005]
if (Server && Server->game) Server->game->OnRender();
if (Server && Server->GetGameState()) Server->GetGameState()->OnRender();
// [7/5/2005]
ObjectSpace.dbgRender();
UI().Font().pFontStat->OutSet(170, 630);
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/Level_network_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ void CLevel::SimulateServerUpdate()

void CLevel::SpawnDemoSpectator()
{
R_ASSERT(Server && Server->game);
R_ASSERT(Server && Server->GetGameState());
m_current_spectator = NULL;
game_sv_mp* tmp_sv_game = smart_cast<game_sv_mp*>(Server->game);
game_sv_mp* tmp_sv_game = smart_cast<game_sv_mp*>(Server->GetGameState());
game_cl_mp* mp_cl_game = smart_cast<game_cl_mp*>(Level().game);

CSE_Spectator* specentity = smart_cast<CSE_Spectator*>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void CBaseMonster::settings_overrides()
void CBaseMonster::on_before_sell (CInventoryItem *item)
{
// since there can be only single item in the monster inventory
CSE_Abstract *object = Level().Server->game->get_entity_from_eid(item->object().ID());
CSE_Abstract *object = Level().Server->GetGameState()->get_entity_from_eid(item->object().ID());
VERIFY (object);
CSE_ALifeObject *alife_object = smart_cast<CSE_ALifeObject*>(object);
if (alife_object)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_combat_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void print_time(LPCSTR S, _TIME_ID tTimeID)
}
/**/
CALifeCombatManager::CALifeCombatManager (xrServer *server, LPCSTR section) :
CALifeCombatManager::CALifeCombatManager (IPureServer *server, LPCSTR section) :
CALifeSimulatorBase (server,section)
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_combat_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CALifeCombatManager : public virtual CALifeSimulatorBase, CRandom {
void vfFinishCombat (ALife::ECombatResult tCombatResult);
/**/
public:
CALifeCombatManager (xrServer *server, LPCSTR section);
CALifeCombatManager (IPureServer *server, LPCSTR section);
/**
virtual ~CALifeCombatManager ();
IC ALife::ECombatType combat_type () const;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_communication_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CSortByOwnerPredicate {
};
/**/

CALifeCommunicationManager::CALifeCommunicationManager (xrServer *server, LPCSTR section) :
CALifeCommunicationManager::CALifeCommunicationManager (IPureServer *server, LPCSTR section) :
CALifeSimulatorBase (server,section)
{
// m_tpItems1.reserve (MAX_STACK_DEPTH);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_communication_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CALifeCommunicationManager : public virtual CALifeSimulatorBase {
#endif
/**/
public:
CALifeCommunicationManager (xrServer *server, LPCSTR section);
CALifeCommunicationManager (IPureServer *server, LPCSTR section);
/**
virtual ~CALifeCommunicationManager ();
void communicate_with_customer (CSE_ALifeHumanAbstract *tpALifeHumanAbstract, CSE_ALifeTrader *tpALifeTrader);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_interaction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using namespace ALife;
/**/
CALifeInteractionManager::CALifeInteractionManager (xrServer*server, LPCSTR section) :
CALifeInteractionManager::CALifeInteractionManager (IPureServer *server, LPCSTR section) :
CALifeCombatManager (server,section),
CALifeCommunicationManager (server,section),
CALifeSimulatorBase (server,section)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_interaction_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CALifeInteractionManager :
/**/
public:
CALifeInteractionManager (xrServer *server, LPCSTR section);
CALifeInteractionManager (IPureServer *server, LPCSTR section);
/**
virtual ~CALifeInteractionManager ();
void check_for_interaction (CSE_ALifeSchedulable *tpALifeSchedulable);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void restart_all ()
#endif // DEBUG
}

CALifeSimulator::CALifeSimulator (xrServer *server, shared_str *command_line) :
CALifeSimulator::CALifeSimulator (IPureServer *server, shared_str *command_line) :
CALifeUpdateManager (server,alife_section),
CALifeInteractionManager (server,alife_section),
CALifeSimulatorBase (server,alife_section)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CALifeSimulator :
virtual void reload (LPCSTR section);

public:
CALifeSimulator (xrServer *server, shared_str* command_line);
CALifeSimulator (IPureServer *server, shared_str* command_line);
virtual ~CALifeSimulator ();
virtual void destroy ();
IReader const* get_config ( shared_str config ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_simulator_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

using namespace ALife;

CALifeSimulatorBase::CALifeSimulatorBase (xrServer *server, LPCSTR section)
CALifeSimulatorBase::CALifeSimulatorBase (IPureServer *server, LPCSTR section)
{
m_server = server;
m_initialized = false;
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/alife_simulator_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "game_graph_space.h"
#include "Common/object_interfaces.h"

class xrServer;
class IPureServer;
class CALifeSimulatorHeader;
class CALifeTimeManager;
class CALifeSpawnRegistry;
Expand All @@ -37,7 +37,7 @@ namespace inventory { namespace upgrade {

class CALifeSimulatorBase : public IPureDestroyableObject {
protected:
xrServer *m_server;
IPureServer *m_server;
CALifeSimulatorHeader *m_header;
CALifeTimeManager *m_time_manager;
CALifeSpawnRegistry *m_spawns;
Expand Down Expand Up @@ -75,7 +75,7 @@ class CALifeSimulatorBase : public IPureDestroyableObject {
IC inventory::upgrade::Manager &inventory_upgrade_manager () const;

public:
CALifeSimulatorBase (xrServer *server, LPCSTR section);
CALifeSimulatorBase (IPureServer *server, LPCSTR section);
virtual ~CALifeSimulatorBase ();
virtual void destroy ();
IC bool initialized () const;
Expand All @@ -89,7 +89,7 @@ class CALifeSimulatorBase : public IPureDestroyableObject {
IC const CALifeSmartTerrainRegistry &smart_terrains () const;
IC const CALifeGroupRegistry &groups () const;
IC CRandom32 &random ();
IC xrServer &server () const;
IC IPureServer &server () const;
IC const CALifeTimeManager &time_manager () const;
IC shared_str *server_command_line () const;
template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_simulator_base_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ IC void CALifeSimulatorBase::setup_command_line (shared_str *command_lin
m_server_command_line = command_line;
}

IC xrServer &CALifeSimulatorBase::server () const
IC IPureServer &CALifeSimulatorBase::server () const
{
VERIFY (m_server);
return (*m_server);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_storage_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CALifeStorageManager : public virtual CALifeSimulatorBase {
void load (void *buffer, const u32 &buffer_size, LPCSTR file_name);

public:
IC CALifeStorageManager (xrServer *server, LPCSTR section);
IC CALifeStorageManager (IPureServer *server, LPCSTR section);
virtual ~CALifeStorageManager ();
bool load (LPCSTR save_name = 0);
void save (LPCSTR save_name = 0, bool update_name = true);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_storage_manager_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

IC CALifeStorageManager::CALifeStorageManager (xrServer *server, LPCSTR section) :
IC CALifeStorageManager::CALifeStorageManager (IPureServer *server, LPCSTR section) :
inherited (server,section)
{
m_section = section;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_surge_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CALifeSurgeManager : public virtual CALifeSimulatorBase {
void spawn_new_objects ();

public:
IC CALifeSurgeManager (xrServer *server, LPCSTR section);
IC CALifeSurgeManager (IPureServer *server, LPCSTR section);
virtual ~CALifeSurgeManager ();
};

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_surge_manager_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

IC CALifeSurgeManager::CALifeSurgeManager (xrServer *server, LPCSTR section) :
IC CALifeSurgeManager::CALifeSurgeManager (IPureServer *server, LPCSTR section) :
inherited (server,section)
{
}
6 changes: 3 additions & 3 deletions src/xrGame/alife_switch_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
using namespace ALife;

struct remove_non_savable_predicate {
xrServer *m_server;
IPureServer *m_server;

IC remove_non_savable_predicate(xrServer *server)
IC remove_non_savable_predicate(IPureServer *server)
{
VERIFY (server);
m_server = server;
}

IC bool operator() (const ALife::_OBJECT_ID &id) const
{
CSE_Abstract *object = m_server->game->get_entity_from_eid(id);
CSE_Abstract *object = m_server->GetGameState()->get_entity_from_eid(id);
VERIFY (object);
CSE_ALifeObject *alife_object = smart_cast<CSE_ALifeObject*>(object);
VERIFY (alife_object);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_switch_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CALifeSwitchManager : public virtual CALifeSimulatorBase, CRandom {
void add_online (CSE_ALifeDynamicObject *object, bool update_registries = true);

public:
IC CALifeSwitchManager (xrServer *server, LPCSTR section);
IC CALifeSwitchManager (IPureServer *server, LPCSTR section);
virtual ~CALifeSwitchManager ();
void switch_object (CSE_ALifeDynamicObject *object);
IC float online_distance () const;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_switch_manager_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

IC CALifeSwitchManager::CALifeSwitchManager (xrServer *server, LPCSTR section) :
IC CALifeSwitchManager::CALifeSwitchManager (IPureServer *server, LPCSTR section) :
inherited (server,section)
{
m_switch_distance = pSettings->r_float(section,"switch_distance");
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_update_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CSwitchPredicate {
}
};

CALifeUpdateManager::CALifeUpdateManager (xrServer *server, LPCSTR section) :
CALifeUpdateManager::CALifeUpdateManager (IPureServer *server, LPCSTR section) :
CALifeSwitchManager (server,section),
CALifeSurgeManager (server,section),
CALifeStorageManager (server,section),
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/alife_update_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CALifeUpdateManager :
virtual void reload (LPCSTR section);

public:
CALifeUpdateManager (xrServer *server, LPCSTR section);
CALifeUpdateManager (IPureServer *server, LPCSTR section);
virtual ~CALifeUpdateManager ();
virtual shared_str shedule_Name () const { return shared_str("alife_simulator"); };
virtual float shedule_Scale ();
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class CCC_ALifeProcessTime : public IConsole_Command {
CCC_ALifeProcessTime(LPCSTR N) : IConsole_Command(N) { };
virtual void Execute(LPCSTR args) {
if ((GameID() == eGameIDSingle) &&ai().get_alife()) {
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->game);
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->GetGameState());
VERIFY (tpGame);
int id1 = 0;
sscanf(args ,"%d",&id1);
Expand All @@ -337,7 +337,7 @@ class CCC_ALifeObjectsPerUpdate : public IConsole_Command {
CCC_ALifeObjectsPerUpdate(LPCSTR N) : IConsole_Command(N) { };
virtual void Execute(LPCSTR args) {
if ((GameID() == eGameIDSingle) &&ai().get_alife()) {
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->game);
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->GetGameState());
VERIFY (tpGame);
int id1 = 0;
sscanf(args ,"%d",&id1);
Expand All @@ -353,7 +353,7 @@ class CCC_ALifeSwitchFactor : public IConsole_Command {
CCC_ALifeSwitchFactor(LPCSTR N) : IConsole_Command(N) { };
virtual void Execute(LPCSTR args) {
if ((GameID() == eGameIDSingle) &&ai().get_alife()) {
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->game);
game_sv_Single *tpGame = smart_cast<game_sv_Single *>(Level().Server->GetGameState());
VERIFY (tpGame);
float id1 = 0;
sscanf(args ,"%f",&id1);
Expand Down Expand Up @@ -1358,7 +1358,7 @@ struct CCC_StartTimeSingle : public IConsole_Command {
if (!Level().Server)
return;

if (!Level().Server->game)
if (!Level().Server->GetGameState())
return;

Level().SetGameTimeFactor(g_qwStartGameTime,g_fTimeFactor);
Expand All @@ -1385,7 +1385,7 @@ struct CCC_TimeFactorSingle : public CCC_Float {
if (!Level().Server)
return;

if (!Level().Server->game)
if (!Level().Server->GetGameState())
return;

Level().SetGameTimeFactor(g_fTimeFactor);
Expand Down
Loading

0 comments on commit f4d3160

Please sign in to comment.