Make the number of state updated the server sends configurable.

This commit is contained in:
hiker 2017-11-24 18:33:26 +11:00
parent 37ee602f28
commit b08e2f56e1
4 changed files with 9 additions and 20 deletions

View File

@ -158,16 +158,10 @@
away if there is an explosion. --> away if there is an explosion. -->
<explosion impulse-objects="500.0" /> <explosion impulse-objects="500.0" />
<!-- Networking - the current networking code is outdated and will not <!-- Networking
work anymore - so for now don't enable this. state-frequency: how many states the server will send per second.
For the new networking code:
combine-threshold: Maximum time a network event can be different
from an existing time step info to be combined into one. This
reduces the number of time steps necessary (for slightly larger
inaccuracies).
--> -->
<networking enable="false" <networking state-frequency="10" />
combine-threshold="0.05" />
<!-- The field od views for 1-4 player split screen. fov-3 is <!-- The field od views for 1-4 player split screen. fov-3 is
actually not used (since 3 player split screen uses the actually not used (since 3 player split screen uses the

View File

@ -138,8 +138,8 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_replay_delta_pos2, "replay delta-position" ); CHECK_NEG(m_replay_delta_pos2, "replay delta-position" );
CHECK_NEG(m_replay_dt, "replay delta-t" ); CHECK_NEG(m_replay_dt, "replay delta-t" );
CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" ); CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" );
CHECK_NEG(m_network_combine_threshold, "network combine-threshold" );
CHECK_NEG(m_default_track_friction, "physics default-track-friction"); CHECK_NEG(m_default_track_friction, "physics default-track-friction");
CHECK_NEG(m_network_state_frequeny, "network state-frequency");
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction"); CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
// Square distance to make distance checks cheaper (no sqrt) // Square distance to make distance checks cheaper (no sqrt)
@ -174,9 +174,8 @@ void STKConfig::init_defaults()
m_replay_delta_angle = -100; m_replay_delta_angle = -100;
m_replay_delta_pos2 = -100; m_replay_delta_pos2 = -100;
m_replay_dt = -100; m_replay_dt = -100;
m_network_combine_threshold = -100; m_network_state_frequeny = -100;
m_title_music = NULL; m_title_music = NULL;
m_enable_networking = true;
m_smooth_normals = false; m_smooth_normals = false;
m_same_powerup_mode = POWERUP_MODE_ONLY_IF_SAME; m_same_powerup_mode = POWERUP_MODE_ONLY_IF_SAME;
m_ai_acceleration = 1.0f; m_ai_acceleration = 1.0f;
@ -351,8 +350,7 @@ void STKConfig::getAllData(const XMLNode * root)
if (const XMLNode *networking_node = root->getNode("networking")) if (const XMLNode *networking_node = root->getNode("networking"))
{ {
networking_node->get("enable", &m_enable_networking); networking_node->get("state-frequency", &m_network_state_frequeny);
networking_node->get("combine-threshold", &m_network_combine_threshold);
} }
if(const XMLNode *replay_node = root->getNode("replay")) if(const XMLNode *replay_node = root->getNode("replay"))

View File

@ -82,10 +82,8 @@ public:
bool m_smooth_normals; /**< If normals for raycasts for wheels bool m_smooth_normals; /**< If normals for raycasts for wheels
should be interpolated. */ should be interpolated. */
/** Network events that are less than this value apart will be executed /** How many state updates per second the server will send. */
* at the same time (instead of adding a new time step, which causes int m_network_state_frequeny;
* one more time step to be simulated). */
float m_network_combine_threshold;
/** If the angle between a normal on a vertex and the normal of the /** If the angle between a normal on a vertex and the normal of the
* triangle are more than this value, the physics will use the normal * triangle are more than this value, the physics will use the normal
@ -110,7 +108,6 @@ public:
m_max_track_version; /**<version supported by this binary. */ m_max_track_version; /**<version supported by this binary. */
int m_max_display_news; /**<How often a news message is displayed int m_max_display_news; /**<How often a news message is displayed
before it is ignored. */ before it is ignored. */
bool m_enable_networking;
/** Disable steering if skidding is stopped. This can help in making /** Disable steering if skidding is stopped. This can help in making
* skidding more controllable (since otherwise when trying to steer while * skidding more controllable (since otherwise when trying to steer while

View File

@ -77,7 +77,7 @@ void RewindManager::reset()
m_is_rewinding = false; m_is_rewinding = false;
m_not_rewound_time = 0; m_not_rewound_time = 0;
m_overall_state_size = 0; m_overall_state_size = 0;
m_state_frequency = 0.1f; // save 10 states a second m_state_frequency = 1.0f / stk_config->m_network_state_frequeny;
m_last_saved_state = -9999.9f; // forces initial state save m_last_saved_state = -9999.9f; // forces initial state save
if(!m_enable_rewind_manager) return; if(!m_enable_rewind_manager) return;