Add maximum number of moveable objects in networking games
This commit is contained in:
parent
9061d527df
commit
87ce3931e5
@ -206,8 +206,13 @@
|
|||||||
steering-reduction: Reduce a remote kart's steering by this factor
|
steering-reduction: Reduce a remote kart's steering by this factor
|
||||||
each frame. This helps reduces oversteering by high latency
|
each frame. This helps reduces oversteering by high latency
|
||||||
clients when they only do minor steering adjustments.
|
clients when they only do minor steering adjustments.
|
||||||
|
max-moveable-objects: Maximum number of moveable objects in a track
|
||||||
|
when networking is on. Objects will be hidden if total count is
|
||||||
|
larger than this value.
|
||||||
-->
|
-->
|
||||||
<networking state-frequency="10" steering-reduction="1.0"/>
|
<networking state-frequency="10"
|
||||||
|
steering-reduction="1.0"
|
||||||
|
max-moveable-objects="15"/>
|
||||||
|
|
||||||
<!-- 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
|
||||||
@ -541,6 +546,6 @@
|
|||||||
<!-- List of default ports used, by default STK use random ports for client.
|
<!-- List of default ports used, by default STK use random ports for client.
|
||||||
The server discovery port has to be the same across all clients and servers.
|
The server discovery port has to be the same across all clients and servers.
|
||||||
-->
|
-->
|
||||||
<network server-discovery-port="2757" client-port="2758" server-port="2759"/>
|
<network-ports server-discovery-port="2757" client-port="2758" server-port="2759"/>
|
||||||
|
|
||||||
</config>
|
</config>
|
||||||
|
@ -152,10 +152,10 @@ void STKConfig::load(const std::string &filename)
|
|||||||
CHECK_NEG(m_default_track_friction, "physics default-track-friction");
|
CHECK_NEG(m_default_track_friction, "physics default-track-friction");
|
||||||
CHECK_NEG(m_physics_fps, "physics fps" );
|
CHECK_NEG(m_physics_fps, "physics fps" );
|
||||||
CHECK_NEG(m_network_state_frequeny, "network state-frequency" );
|
CHECK_NEG(m_network_state_frequeny, "network state-frequency" );
|
||||||
|
CHECK_NEG(m_max_moveable_objects, "network max-moveable-objects");
|
||||||
CHECK_NEG(m_network_steering_reduction,"network steering-reduction" );
|
CHECK_NEG(m_network_steering_reduction,"network steering-reduction" );
|
||||||
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
|
CHECK_NEG(m_default_moveable_friction, "physics default-moveable-friction");
|
||||||
CHECK_NEG(m_solver_iterations, "physics: solver-iterations" );
|
CHECK_NEG(m_solver_iterations, "physics: solver-iterations" );
|
||||||
CHECK_NEG(m_network_state_frequeny, "network solver-state-frequency" );
|
|
||||||
CHECK_NEG(m_solver_split_impulse_thresh,"physics: solver-split-impulse-threshold");
|
CHECK_NEG(m_solver_split_impulse_thresh,"physics: solver-split-impulse-threshold");
|
||||||
|
|
||||||
// Square distance to make distance checks cheaper (no sqrt)
|
// Square distance to make distance checks cheaper (no sqrt)
|
||||||
@ -199,6 +199,7 @@ void STKConfig::init_defaults()
|
|||||||
m_donate_url = "";
|
m_donate_url = "";
|
||||||
m_password_reset_url = "";
|
m_password_reset_url = "";
|
||||||
m_network_state_frequeny = -100;
|
m_network_state_frequeny = -100;
|
||||||
|
m_max_moveable_objects = -100;
|
||||||
m_solver_iterations = -100;
|
m_solver_iterations = -100;
|
||||||
m_solver_set_flags = 0;
|
m_solver_set_flags = 0;
|
||||||
m_solver_reset_flags = 0;
|
m_solver_reset_flags = 0;
|
||||||
@ -436,6 +437,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("state-frequency", &m_network_state_frequeny);
|
networking_node->get("state-frequency", &m_network_state_frequeny);
|
||||||
|
networking_node->get("max-moveable-objects", &m_max_moveable_objects);
|
||||||
networking_node->get("steering-reduction", &m_network_steering_reduction);
|
networking_node->get("steering-reduction", &m_network_steering_reduction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,14 +479,14 @@ void STKConfig::getAllData(const XMLNode * root)
|
|||||||
tc->get("quality", &m_tc_quality);
|
tc->get("quality", &m_tc_quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const XMLNode *tc = root->getNode("network"))
|
if (const XMLNode *np = root->getNode("network-ports"))
|
||||||
{
|
{
|
||||||
unsigned server_discovery_port = 0;
|
unsigned server_discovery_port = 0;
|
||||||
unsigned client_port = 0;
|
unsigned client_port = 0;
|
||||||
unsigned server_port = 0;
|
unsigned server_port = 0;
|
||||||
tc->get("server-discovery-port", &server_discovery_port);
|
np->get("server-discovery-port", &server_discovery_port);
|
||||||
tc->get("client-port", &client_port);
|
np->get("client-port", &client_port);
|
||||||
tc->get("server-port", &server_port);
|
np->get("server-port", &server_port);
|
||||||
m_server_discovery_port = (uint16_t)server_discovery_port;
|
m_server_discovery_port = (uint16_t)server_discovery_port;
|
||||||
m_client_port = (uint16_t)client_port;
|
m_client_port = (uint16_t)client_port;
|
||||||
m_server_port = (uint16_t)server_port;
|
m_server_port = (uint16_t)server_port;
|
||||||
|
@ -89,6 +89,9 @@ public:
|
|||||||
/** How many state updates per second the server will send. */
|
/** How many state updates per second the server will send. */
|
||||||
int m_network_state_frequeny;
|
int m_network_state_frequeny;
|
||||||
|
|
||||||
|
/** Maximum number of moveable objects in a track when networking is on. */
|
||||||
|
int m_max_moveable_objects;
|
||||||
|
|
||||||
/** In case of a network race, remote karts will get their steering somewhat
|
/** In case of a network race, remote karts will get their steering somewhat
|
||||||
* reduced each frame. This reduces stutter when a kart only does small
|
* reduced each frame. This reduces stutter when a kart only does small
|
||||||
* steering adjustments. */
|
* steering adjustments. */
|
||||||
|
@ -122,7 +122,6 @@ void SoccerWorld::init()
|
|||||||
Log::fatal("SoccerWorld","Ball is missing in soccer field, abort.");
|
Log::fatal("SoccerWorld","Ball is missing in soccer field, abort.");
|
||||||
|
|
||||||
m_bgd.init(m_ball->getPhysicalObject()->getRadius());
|
m_bgd.init(m_ball->getPhysicalObject()->getRadius());
|
||||||
m_ball_body->setActivationState(DISABLE_DEACTIVATION);
|
|
||||||
|
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
@ -232,6 +232,8 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setPaused(bool mode){ m_animator->setPaused(mode); }
|
void setPaused(bool mode){ m_animator->setPaused(mode); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void setInitiallyVisible(bool val) { m_initially_visible = val; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns if a kart can drive on this object. */
|
/** Returns if a kart can drive on this object. */
|
||||||
bool isDriveable() const { return m_is_driveable; }
|
bool isDriveable() const { return m_is_driveable; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -20,9 +20,11 @@
|
|||||||
|
|
||||||
#include "animations/ipo.hpp"
|
#include "animations/ipo.hpp"
|
||||||
#include "animations/three_d_animation.hpp"
|
#include "animations/three_d_animation.hpp"
|
||||||
|
#include "config/stk_config.hpp"
|
||||||
#include "graphics/lod_node.hpp"
|
#include "graphics/lod_node.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
|
#include "network/network_config.hpp"
|
||||||
#include "physics/physical_object.hpp"
|
#include "physics/physical_object.hpp"
|
||||||
#include "tracks/track_object.hpp"
|
#include "tracks/track_object.hpp"
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
@ -66,14 +68,37 @@ void TrackObjectManager::add(const XMLNode &xml_node, scene::ISceneNode* parent,
|
|||||||
*/
|
*/
|
||||||
void TrackObjectManager::init()
|
void TrackObjectManager::init()
|
||||||
{
|
{
|
||||||
for_var_in(TrackObject*, curr, m_all_objects)
|
int moveable_objects = 0;
|
||||||
|
bool warned = false;
|
||||||
|
for (unsigned i = 0; i < m_all_objects.m_contents_vector.size(); i++)
|
||||||
{
|
{
|
||||||
|
TrackObject* curr = m_all_objects.m_contents_vector[i];
|
||||||
curr->onWorldReady();
|
curr->onWorldReady();
|
||||||
|
|
||||||
|
if (moveable_objects > stk_config->m_max_moveable_objects)
|
||||||
|
{
|
||||||
|
if (!warned)
|
||||||
|
{
|
||||||
|
Log::warn("TrackObjectManager",
|
||||||
|
"Too many moveable objects (>%d) in networking.",
|
||||||
|
stk_config->m_max_moveable_objects);
|
||||||
|
warned = true;
|
||||||
|
}
|
||||||
|
curr->setInitiallyVisible(false);
|
||||||
|
curr->setEnabled(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// onWorldReady will hide some track objects using scripting
|
// onWorldReady will hide some track objects using scripting
|
||||||
if (curr->isEnabled() && curr->getPhysicalObject() &&
|
if (NetworkConfig::get()->isNetworking() &&
|
||||||
|
curr->isEnabled() && curr->getPhysicalObject() &&
|
||||||
curr->getPhysicalObject()->isDynamic())
|
curr->getPhysicalObject()->isDynamic())
|
||||||
|
{
|
||||||
|
curr->getPhysicalObject()->getBody()
|
||||||
|
->setActivationState(DISABLE_DEACTIVATION);
|
||||||
curr->getPhysicalObject()->addForRewind();
|
curr->getPhysicalObject()->addForRewind();
|
||||||
|
moveable_objects++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user