@@ -245,6 +245,8 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
245245 m_controller = NULL ;
246246 m_tyres = new Tyres (this );
247247 m_is_disqualified = false ;
248+ m_rally_start = false ;
249+ m_rally_wait_mode = false ;
248250 m_is_under_tme_ruleset = true ;
249251 m_initial_color = 0 .0f ;
250252 m_saved_controller = NULL ;
@@ -3364,6 +3366,57 @@ void Kart::updatePhysics(int ticks)
33643366 // Cap speed if necessary
33653367 const Material *m = getMaterial ();
33663368
3369+ bool wait_mode = false ;
3370+
3371+ RaceManager::RallyOrder *rally_order = RaceManager::get ()->getRallyOrder ();
3372+ RaceManager::RallyPlayer *current_player = NULL ;
3373+ LinearWorld* lw = dynamic_cast <LinearWorld*>(World::getWorld ());
3374+ std::string name = StringUtils::wideToUtf8 (getController ()->getName ());
3375+ if (lw && rally_order) {
3376+ for (RaceManager::RallyPlayer &p : rally_order->players ) {
3377+ if (p.username == name) {
3378+ current_player = &p;
3379+ break ;
3380+ }
3381+ }
3382+ }
3383+
3384+ if (!current_player) {
3385+ // TODO: Build a fake player as per the strategy variables - need a support procedure for this
3386+ }
3387+
3388+ float time = World::getWorld ()->getTime ();
3389+ if (current_player) {
3390+ if (current_player->gap_to_leader
3391+ <=
3392+ (float )rally_order->warmup_cutoff )
3393+ {
3394+ if (time < current_player->gap_to_leader ) {
3395+ setSlowdown (MaxSpeed::MS_DECREASE_STOP, getKartProperties ()->getTyresPitSpeedFraction (), stk_config->time2Ticks (0 .1f ), -1 );
3396+ m_rally_start = true ;
3397+ } else {
3398+ setSlowdown (MaxSpeed::MS_DECREASE_STOP, getKartProperties ()->getTyresPitSpeedFraction (), stk_config->time2Ticks (0 .1f ), 0 );
3399+ m_rally_start = false ;
3400+ }
3401+ } else {
3402+ if (time < current_player->gap_to_leader ) {
3403+ m_rally_wait_mode = true ;
3404+ m_rally_start = true ;
3405+ } else {
3406+ m_rally_wait_mode = false ;
3407+ m_rally_start = false ;
3408+ }
3409+ }
3410+ }
3411+
3412+ // TODO: ACTUALLY MAKE THE RALLYORDER BE FILLED UP PROPERLY
3413+ // SO THIS HACK OF A TEST FOR WARMUP MODE ISN'T NEEDED
3414+ // if (time < 40.0) {
3415+ // m_rally_wait_mode = true;
3416+ // } else {
3417+ // m_rally_wait_mode = false;
3418+ // }
3419+
33673420
33683421 ItemPolicy *item_policy = RaceManager::get ()->getItemPolicy ();
33693422 item_policy->enforceVirtualPaceCarRulesForKart (this );
@@ -3379,7 +3432,9 @@ void Kart::updatePhysics(int ticks)
33793432
33803433 uint32_t rules = item_policy->m_policy_sections [leader_sec].m_rules ;
33813434
3382- if (rules & ItemPolicyRules::IPT_GHOST_KARTS) {
3435+ if (m_rally_start) {
3436+ getBody ()->setTag (GHOST_NO_COLLECTIBLE_KART_TAG);
3437+ } else if (rules & ItemPolicyRules::IPT_GHOST_KARTS) {
33833438 getBody ()->setTag (NO_COLLISION_KART_TAG);
33843439 } else {
33853440 getBody ()->setTag (KART_TAG);
0 commit comments