@@ -2173,6 +2173,79 @@ HSCRIPT CASW_Player::ScriptGetNPC() const
21732173 return ToHScript ( GetNPC () );
21742174}
21752175
2176+ CON_COMMAND ( rd_set_spectate_order, " Space separated list of marine profile numbers. List can be partial. No args for unset." )
2177+ {
2178+ CASW_Player *pPlayer = ToASW_Player ( UTIL_GetCommandClient () );
2179+ if ( !pPlayer )
2180+ {
2181+ Warning ( " rd_set_spectate_order: No Player (not connected to server?)\n " );
2182+ return ;
2183+ }
2184+
2185+ const int nProfiles = args.ArgC () - 1 ;
2186+
2187+ if ( nProfiles == 0 )
2188+ {
2189+ Msg (" rd_set_spectate_order: unset\n " );
2190+ pPlayer->UnsetSpectatingOrder ();
2191+ return ;
2192+ }
2193+ if ( nProfiles > ASW_NUM_MARINE_PROFILES )
2194+ {
2195+ Warning ( " rd_set_spectate_order: Incorrect number of profiles (%d > %d)\n " , nProfiles, ASW_NUM_MARINE_PROFILES );
2196+ return ;
2197+ }
2198+
2199+ int iProfiles[ASW_NUM_MARINE_PROFILES ];
2200+
2201+ // parse input
2202+ for ( int i = 0 ; i < nProfiles; i++ )
2203+ {
2204+ const int iProfile = atoi ( args[i + 1 ] );
2205+
2206+ if ( iProfile < 0 || iProfile >= ASW_NUM_MARINE_PROFILES )
2207+ {
2208+ Warning ( " rd_set_spectate_order: Incorrect profile number (#%d: %s)\n " , i + 1 , args[i + 1 ] );
2209+ return ;
2210+ }
2211+
2212+ for ( int j = 0 ; j < i; j++ )
2213+ {
2214+ if ( iProfiles[j] == iProfile )
2215+ {
2216+ Warning ( " rd_set_spectate_order: Duplicate profile number (#%d: %d)\n " , i + 1 , iProfile );
2217+ return ;
2218+ }
2219+ }
2220+
2221+ iProfiles[i] = iProfile;
2222+ }
2223+
2224+ pPlayer->SetSpectatingOrder ( iProfiles, nProfiles );
2225+ }
2226+
2227+ // Don't need all marine profiles; rest will have worst priority
2228+ void CASW_Player::SetSpectatingOrder ( const int * iProfiles, int nProfiles )
2229+ {
2230+ // Prefill with worst priority in case a profile is not in the list or is invalid
2231+ for ( int i = 0 ; i < ASW_NUM_MARINE_PROFILES ; i++ )
2232+ {
2233+ m_iSpectatingMapping[i] = INT_MAX ;
2234+ }
2235+
2236+ nProfiles = MIN ( nProfiles, ASW_NUM_MARINE_PROFILES );
2237+ for ( int i = 0 ; i < nProfiles; i++ )
2238+ {
2239+ const int iProfile = iProfiles[i];
2240+ if ( iProfiles[i] >= 0 && iProfiles[i] < ASW_NUM_MARINE_PROFILES )
2241+ {
2242+ m_iSpectatingMapping[iProfiles[i]] = i;
2243+ }
2244+ }
2245+
2246+ m_bSpectatingInOrder = true ;
2247+ }
2248+
21762249void CASW_Player::SpectateNextMarine ()
21772250{
21782251 CASW_Game_Resource* pGameResource = ASWGameResource ();
0 commit comments