Make explosive items timeout configurable in stk_config

This commit is contained in:
Benau 2018-12-22 10:33:01 +08:00
parent 3292c8f0c3
commit 31e14b14c6
4 changed files with 13 additions and 11 deletions

View File

@ -184,8 +184,10 @@
new: always get a new item. new: always get a new item.
only-if-same: if the random item is the same one as the only-if-same: if the random item is the same one as the
one currently owned, increase the number, otherwise one currently owned, increase the number, otherwise
no more/new item s are given to the kart. --> no more/new item s are given to the kart.
<powerup collect-mode="new"/> no-explosive-items-timeout determines if world time is less than this value
then no cake or basketball is given by bonus boxes. -->
<powerup collect-mode="new" no-explosive-items-timeout="15.0"/>
<!-- time: How long a switch is being effective. <!-- time: How long a switch is being effective.
items for each item list the index of the item it is switched with. items for each item list the index of the item it is switched with.
Order: giftbox, banana, big-nitro, small-nitro, bubble-gum, nolok-bubble-gum, Order: giftbox, banana, big-nitro, small-nitro, bubble-gum, nolok-bubble-gum,
@ -202,7 +204,6 @@
<explosion impulse-objects="500.0" /> <explosion impulse-objects="500.0" />
<!-- Networking <!-- Networking
state-frequency: how many states the server will send per second.
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.
@ -210,8 +211,7 @@
when networking is on. Objects will be hidden if total count is when networking is on. Objects will be hidden if total count is
larger than this value. larger than this value.
--> -->
<networking state-frequency="10" <networking steering-reduction="1.0"
steering-reduction="1.0"
max-moveable-objects="15"/> 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

View File

@ -151,7 +151,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" ); CHECK_NEG(m_smooth_angle_limit, "physics smooth-angle-limit" );
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_no_explosive_items_timeout,"powerup no-explosive-items-timeout" );
CHECK_NEG(m_max_moveable_objects, "network max-moveable-objects"); 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");
@ -203,7 +203,7 @@ void STKConfig::init_defaults()
m_minimap_player_icon = -100; m_minimap_player_icon = -100;
m_donate_url = ""; m_donate_url = "";
m_password_reset_url = ""; m_password_reset_url = "";
m_network_state_frequeny = -100; m_no_explosive_items_timeout = -100.0f;
m_max_moveable_objects = -100; m_max_moveable_objects = -100;
m_solver_iterations = -100; m_solver_iterations = -100;
m_solver_set_flags = 0; m_solver_set_flags = 0;
@ -416,6 +416,8 @@ void STKConfig::getAllData(const XMLNode * root)
Log::warn("StkConfig", "Invalid item mode '%s' - ignored.", Log::warn("StkConfig", "Invalid item mode '%s' - ignored.",
s.c_str()); s.c_str());
} }
powerup_node->get("no-explosive-items-timeout",
&m_no_explosive_items_timeout);
} }
if(const XMLNode *switch_node= root->getNode("switch")) if(const XMLNode *switch_node= root->getNode("switch"))
@ -444,7 +446,6 @@ 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("max-moveable-objects", &m_max_moveable_objects); 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);
} }

View File

@ -86,8 +86,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. */
/** How many state updates per second the server will send. */ /** Prevent early explosive items before this world time. */
int m_network_state_frequeny; float m_no_explosive_items_timeout;
/** Maximum number of moveable objects in a track when networking is on. */ /** Maximum number of moveable objects in a track when networking is on. */
int m_max_moveable_objects; int m_max_moveable_objects;

View File

@ -604,7 +604,8 @@ PowerupManager::PowerupType PowerupManager::getRandomPowerup(unsigned int pos,
*n=1; *n=1;
// Prevents early explosive items // Prevents early explosive items
if (stk_config->ticks2Time(World::getWorld()->getTicksSinceStart()) < 15.) if (stk_config->ticks2Time(World::getWorld()->getTicksSinceStart()) <
stk_config->m_no_explosive_items_timeout)
{ {
if (powerup == POWERUP_CAKE || powerup == POWERUP_RUBBERBALL) if (powerup == POWERUP_CAKE || powerup == POWERUP_RUBBERBALL)
powerup = POWERUP_BOWLING; powerup = POWERUP_BOWLING;