~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/engine/ePlayer.cpp

  • Committer: SwagTron
  • Date: 2019-03-05 07:13:03 UTC
  • Revision ID: swagtron-20190305071303-5m4cn9hs6h8ydsgf
- Ported toggle from 0.4. Seems kind of hacky. Had to add another FindConfigItem of type tConfItemBase due to tab completion using the previous tString function. Plan to change this later, but I really needed the toggle function. Tried to cast the two, but that did not work out. Seemed like the bug-less option for the time being. Those unfamiliar with this function, you can now toggle boolean commands (Ex. toggle text_out)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3044
3044
}
3045
3045
#endif // DEDICATED
3046
3046
 
3047
 
//static bool se_silenceDead = false;
3048
 
//static tSettingItem<bool> se_silenceDeadConf("SILENCE_DEAD", se_silenceDead);
 
3047
static bool se_silenceDead = false;
 
3048
static tSettingItem<bool> se_silenceDeadConf("SILENCE_DEAD", se_silenceDead);
3049
3049
 
3050
3050
// help message printed out to whoever asks for it
3051
3051
static tString se_helpMessage("");
4647
4647
    return false;
4648
4648
}
4649
4649
 
4650
 
#ifndef DEDICATED
4651
 
static bool se_enableChatCommands = true;
4652
 
static tSettingItem<bool> se_enableChatCommandsConf( "CHAT_LOCAL_COMMANDS", se_enableChatCommands );
4653
 
 
4654
 
//our local commands (should always be lowercase)
4655
 
static char const * const se_localChatCommands[] = {
4656
 
    "/console",
4657
 
    "/listcolors",
4658
 
    "/colors",
4659
 
    "/info",
4660
 
    "/rgb"
4661
 
};
4662
 
#endif //if not dedicated
4663
 
 
4664
4650
void ePlayerNetID::Chat(const tString &s_orig)
4665
4651
{
4666
4652
    tColoredString s( s_orig );
4667
4653
    s.NetFilter();
4668
4654
 
4669
4655
#ifndef DEDICATED
4670
 
 
4671
 
    std::string chatString(s_orig);
4672
 
    std::istringstream passedString(chatString);
4673
 
 
4674
 
    tString command;
4675
 
 
4676
 
    passedString >> command;
4677
 
    tToLower( command );
4678
 
    tConfItemBase::EatWhitespace(passedString);
4679
 
 
4680
 
    bool isLocalCommand  = false;
4681
 
 
4682
 
    for (int i = sizeof(se_localChatCommands)/sizeof(se_localChatCommands[0]) - 1; i >= 0; --i)
 
4656
    // check for direct console commands
 
4657
    if( s_orig.StartsWith("/console") )
4683
4658
    {
4684
 
        if (command.StartsWith(se_localChatCommands[i]))
4685
 
        {
4686
 
            isLocalCommand = true;
 
4659
        // direct commands are executed at owner level
 
4660
        tCurrentAccessLevel level( tAccessLevel_Owner, true );
 
4661
 
 
4662
        tString params("");
 
4663
        if (s_orig.StrPos(" ") == -1)
 
4664
            return;
 
4665
        else
 
4666
            params = s_orig.SubStr(s_orig.StrPos(" ") + 1);
 
4667
 
 
4668
        if ( tRecorder::IsPlayingBack() )
 
4669
        {
 
4670
            tConfItemBase::LoadPlayback();
 
4671
        }
 
4672
        else
 
4673
        {
 
4674
            std::stringstream s(static_cast< char const * >( params ) );
 
4675
            tConfItemBase::LoadAll(s);
4687
4676
        }
4688
4677
    }
4689
 
 
4690
 
    if (isLocalCommand && se_enableChatCommands && (s_orig.StartsWith("/")))
 
4678
    //Not sure if this is a good short handle. Maybe something like /colors? Then introduce the basic list if no parameters are sent, but if a players name is sent give that players colors alone.
 
4679
    else if( s_orig.StartsWith("/listcolors") || s_orig.StartsWith("/colors") )
4691
4680
    {
4692
 
        // check for direct console commands
4693
 
        if (command == "/console")
4694
 
        {
4695
 
            // direct commands are executed at owner level
4696
 
            tCurrentAccessLevel level( tAccessLevel_Owner, true );
4697
 
 
4698
 
            tString params("");
4699
 
            if (s_orig.StrPos(" ") == -1)
4700
 
                return;
4701
 
            else
4702
 
                params = s_orig.SubStr(s_orig.StrPos(" ") + 1);
4703
 
 
4704
 
            if ( tRecorder::IsPlayingBack() )
4705
 
            {
4706
 
                tConfItemBase::LoadPlayback();
4707
 
            }
4708
 
            else
4709
 
            {
4710
 
                std::stringstream s(static_cast< char const * >( params ) );
4711
 
                tConfItemBase::LoadAll(s);
4712
 
            }
4713
 
        }
4714
 
        //Short handle for grabbing player colors.
4715
 
        else if ((command == "/listcolors") || (command == "/colors"))
4716
 
        {
4717
 
            listPlayerColors(tString(s_orig));
4718
 
        }
4719
 
        //Short handle for grabbing player information.
4720
 
        else if (command == "/info")
4721
 
        {
4722
 
            listPlayerInfo(tString(s_orig));
4723
 
        }
4724
 
        //Short handle for changing our RGB values.
4725
 
        else if (command == "/rgb")
4726
 
        {
4727
 
            currentPlayerRGB(tString(s_orig));
4728
 
        }
 
4681
        con << "Player Colors: \n";
 
4682
        se_listPlayerColors();
4729
4683
    }
4730
4684
    else
4731
 
#endif //if not dedicated
 
4685
#endif
4732
4686
    {
4733
4687
        tString retStr(s);
4734
4688
        if (eBannedWords::BadWordTrigger(this, retStr))
4737
4691
 
4738
4692
        switch (sn_GetNetState())
4739
4693
        {
4740
 
        case nCLIENT:
4741
 
        {
4742
 
            se_NewChatMessage( this, s )->BroadCast();
4743
 
            break;
4744
 
        }
4745
 
        case nSERVER:
4746
 
        {
4747
 
            se_BroadcastChat( this, s );
 
4694
            case nCLIENT:
 
4695
            {
 
4696
                se_NewChatMessage( this, s )->BroadCast();
 
4697
                break;
 
4698
            }
 
4699
            case nSERVER:
 
4700
            {
 
4701
                se_BroadcastChat( this, s );
4748
4702
 
4749
 
            // falling through on purpose
4750
 
            // break;
4751
 
        }
4752
 
        default:
4753
 
        {
4754
 
            se_DisplayChatLocally( this, s );
4755
 
            break;
4756
 
        }
 
4703
                // falling through on purpose
 
4704
                // break;
 
4705
            }
 
4706
            default:
 
4707
            {
 
4708
                se_DisplayChatLocally( this, s );
 
4709
                break;
 
4710
            }
4757
4711
        }
4758
4712
    }
4759
4713
}
4773
4727
}
4774
4728
*/
4775
4729
 
4776
 
// identify a local human player
 
4730
// identify a local player
4777
4731
ePlayerNetID *se_GetLocalPlayer()
4778
4732
{
4779
4733
    for(int i=0; i<se_PlayerNetIDs.Len(); i++)
4780
4734
    {
4781
4735
        ePlayerNetID *p = se_PlayerNetIDs[i];
4782
4736
 
4783
 
        if( p->Owner() == sn_myNetID && p->IsHuman())
 
4737
        if( p->Owner() == sn_myNetID )
4784
4738
            return p;
4785
4739
    }
4786
4740
    return NULL;
8119
8073
#endif
8120
8074
}
8121
8075
 
8122
 
// Should we hide the chat flag in tab when the user is silenced?
8123
 
static bool se_HideSilencedPlayersTabChatFlag    = true;
8124
 
static tSettingItem<bool> se_HideSilencedPlayersTabChatFlagConf("HIDE_SILENCED_SCOREBOARD_CHATFLAG", se_HideSilencedPlayersTabChatFlag  );
8125
8076
 
8126
8077
tString ePlayerNetID::Ranking( int MAX, bool cut )
8127
8078
{
8169
8120
            // line << tColoredString::ColorString( p->r/15.0, p->g/15.0, p->b/15.0 ) << name << tColoredString::ColorString(1,1,1);
8170
8121
 
8171
8122
            // however, using the streaming operator is a lot cleaner. The example is left, as it really can be usefull in some situations.
8172
 
            
8173
8123
            if (p->IsChatting())
8174
 
            {
8175
 
                // If the HIDE_SILENCED_SCOREBOARD_CHATFLAG command is set to false and the player is not silenced, show the tab chatflag.
8176
 
                if (!(se_HideSilencedPlayersTabChatFlag && p->AccessSilenced()))
8177
 
                {
8178
 
                    line << tColoredString::ColorString(-1, -1, -1) << "*";
8179
 
                }
8180
 
            }
 
8124
                line << tColoredString::ColorString(-1,-1,-1) << "*";
8181
8125
            line.SetPos(2, cut);
8182
8126
            line << *p;
8183
8127
            line.SetPos(19, false );
8459
8403
}
8460
8404
 
8461
8405
 
8462
 
static int se_RandomizeColorRange = 32;
8463
 
static tSettingItem<int> se_RandomizeColorRangeConf("PLAYER_RANDOM_COLOR_RANGE", se_RandomizeColorRange);
8464
 
 
8465
 
//This seems more random. Stolen from the old randomize color, but no comparing. 
 
8406
//This seems more random. Stolen from the old randomize color, but no comparing. Also another bonus, generates multi colored cycle / tails with the limit increase to 32.
8466
8407
static void se_RandomizeColor(ePlayer * l)
8467
8408
{
8468
8409
    int currentRGB[3];
8469
8410
    int newRGB[3];
8470
 
  
 
8411
    
8471
8412
    static tReproducibleRandomizer randomizer;
8472
8413
 
8473
8414
    for( int i = 2; i >= 0; --i )
8474
 
    {
8475
 
        currentRGB[i] = l->rgb[i];
8476
 
        newRGB[i] = randomizer.Get(se_RandomizeColorRange+1);
8477
 
    }
 
8415
        {
 
8416
            currentRGB[i] = l->rgb[i];
 
8417
            newRGB[i] = randomizer.Get(32);
 
8418
        }
8478
8419
 
8479
8420
    for( int i = 2; i >= 0; --i )
8480
 
    {
8481
 
        l->rgb[i] = newRGB[i];
8482
 
    }
 
8421
        {
 
8422
            l->rgb[i] = newRGB[i];
 
8423
        }
8483
8424
}
8484
8425
 
8485
 
 
8486
8426
//This didnt seem to be too random, more like picking a unique color no one else currently has.
8487
8427
static void se_UniqueColor( ePlayer * l, ePlayerNetID * p )
8488
8428
{
8532
8472
}
8533
8473
 
8534
8474
//Gather all the rgb colors and put them in a nice list.
8535
 
//Usage /colors with no parameters returns all players and their colors.
8536
 
//      /colors playername returns that specific players color or more depending if the search term is found in other player names
8537
 
void ePlayerNetID::listPlayerColors(tString s_orig)
8538
 
{
8539
 
 
8540
 
    if (se_PlayerNetIDs.Len()>0)
8541
 
    {
8542
 
        if (s_orig.StrPos(" ") == -1)
8543
 
        {
8544
 
            con << tOutput("$player_colors_text");
8545
 
 
8546
 
            for ( int i = 0; i <= se_PlayerNetIDs.Len()-1; i++ )
8547
 
            {
8548
 
                ePlayerNetID *p=se_PlayerNetIDs(i);
8549
 
                con << (i+1) << ": " << gatherPlayerColor(p);
8550
 
 
8551
 
            }
8552
 
        }
8553
 
        else
8554
 
        {
8555
 
            tArray<tString> msgsExt = s_orig.Split(" ");
8556
 
            bool playerFound = false;
8557
 
 
8558
 
            con << tOutput("$player_colors_text");
8559
 
 
8560
 
            for(int i = 0; i < msgsExt.Len(); i++)
8561
 
            {
8562
 
                tString word = msgsExt[i];
8563
 
                int j = 0;
8564
 
                for ( int i = 0; i <= se_PlayerNetIDs.Len()-1; i++ )
8565
 
                {
8566
 
                    ePlayerNetID *p=se_PlayerNetIDs(i);
8567
 
 
8568
 
                    if (p->GetName().Filter().Contains(word.Filter()))
8569
 
                    {
8570
 
                        playerFound = true;
8571
 
 
8572
 
                        con << (j+1) << ": " << gatherPlayerColor(p);
8573
 
                        j++;
8574
 
 
8575
 
                    }
8576
 
                }
8577
 
            }
8578
 
            //No one found.
8579
 
            if (!playerFound)
8580
 
            {
8581
 
                con << tOutput("$player_not_found_text", msgsExt[1]);
8582
 
            }
8583
 
 
8584
 
        }
8585
 
 
8586
 
    }
8587
 
}
8588
 
 
8589
 
//Not sure if this is better / faster but better looking I guess?
8590
 
tColoredString ePlayerNetID::gatherPlayerColor(ePlayerNetID * p)
8591
 
{
8592
 
tColoredString listColors;
8593
 
return listColors << p->GetColoredName() << "0xRESETT (" << p->r << ", " << p->g << ", " << p->b << ")\n";
8594
 
}
8595
 
 
8596
 
 
8597
 
 
8598
 
/*
8599
 
List player information.
8600
 
Displays:
8601
 
Colored Name
8602
 
Position
8603
 
Direction
8604
 
Used Rubber out of max
8605
 
Speed
8606
 
Spectating / Playing
8607
 
Chatting
8608
 
Sometimes Alive / Dead
8609
 
Usage: /info - Returns own information
8610
 
       /info playername - Returns that players name. (or more depending if the search word is found in more than one player)
8611
 
*/
8612
 
 
8613
 
void ePlayerNetID::listPlayerInfo(tString s_orig)
8614
 
{
8615
 
 
8616
 
    if (se_PlayerNetIDs.Len()>0)
8617
 
    {
8618
 
        if (s_orig.StrPos(" ") == -1)
8619
 
        {
8620
 
            con << tOutput("$player_info_text");
8621
 
            ePlayerNetID *p = se_GetLocalPlayer();
8622
 
            con << gatherPlayerInfo(p);
8623
 
        }
8624
 
        else
8625
 
        {
8626
 
            tArray<tString> msgsExt = s_orig.Split(" ");
8627
 
            tArray<ePlayerNetID *> foundPlayers;
8628
 
            bool playerFound = false;
8629
 
            con << tOutput("$player_info_text");
8630
 
            for(int i = 0; i < msgsExt.Len(); i++)
8631
 
            {
8632
 
                tString word = msgsExt[i];
8633
 
 
8634
 
                for(int i=0; i < se_PlayerNetIDs.Len(); i++)
8635
 
                {
8636
 
                    ePlayerNetID *p=se_PlayerNetIDs(i);
8637
 
 
8638
 
                    if (p->GetName().Filter().Contains(word.Filter()))
8639
 
                    {
8640
 
                        playerFound = true;
8641
 
 
8642
 
                        con << gatherPlayerInfo(p);
8643
 
 
8644
 
                    }
8645
 
                }
8646
 
            }
8647
 
 
8648
 
            if (!playerFound)
8649
 
            {
8650
 
                con << tOutput("$player_not_found_text", msgsExt[1]);
8651
 
            }
8652
 
 
8653
 
        }
8654
 
 
8655
 
    }
8656
 
}
8657
 
 
8658
 
 
8659
 
 
8660
 
tColoredString ePlayerNetID::gatherPlayerInfo(ePlayerNetID * p)
8661
 
{
8662
 
    tColoredString listinfo;
8663
 
    listinfo << "Results for " << p->GetColoredName() << "0xRESETT: \n";
8664
 
 
8665
 
    ///Status. Includes player type, spectating or playing, and if the player is chatting.
8666
 
    listinfo << "Status: ";
8667
 
    (p->IsHuman()) ? listinfo << "Human" : listinfo << "Bot";
8668
 
 
8669
 
    //Oddly IsSpectating returned some confusing results.
8670
 
    (!p->CurrentTeam()) ? listinfo << ", Spectating" : listinfo << ", Playing";
8671
 
 
8672
 
    //Are we chatting / out of focus? Calculating the time worked for our local player but didnt work too well for players who joined before us.
8673
 
    (p->IsChatting()) ? listinfo << ", Chatting" : listinfo << ""; // ("<< fabs(p->TimeChatting()) << ") seconds\n" : listinfo << "\n";
8674
 
 
8675
 
 
8676
 
    //Only grab this information if the player is an active object.
8677
 
    if (p->Object() && p->currentTeam)
8678
 
    {
8679
 
        //If the player is an active object, are they alive? Pretty sure we know this already but no harm in including it.
8680
 
        (p->Object()->Alive()) ? listinfo << ", Alive\n" : listinfo << ", Dead\n";
8681
 
 
8682
 
        //Only grab this information if the player is an alive object.
8683
 
        if (p->Object()->Alive())
8684
 
        {
8685
 
            gCycle *pCycle = dynamic_cast<gCycle *>(p->Object());
8686
 
 
8687
 
            listinfo <<  "Position: x: " << pCycle->MapPosition().x << ", y: " << pCycle->MapPosition().y  << "\n";
8688
 
 
8689
 
            //Had trouble converting the direction to an angle, will have to visit this later
8690
 
            listinfo << "Map Direction: " << "x: " << pCycle->MapDirection().x << ", y: " << pCycle->MapDirection().y << "\n";
8691
 
            listinfo << "Speed: " << pCycle->verletSpeed_  << "\n";
8692
 
            listinfo << "Rubber: " << pCycle->GetRubber() << "/" << sg_rubberCycle << "\n";
8693
 
        }
8694
 
    }
8695
 
 
8696
 
    return listinfo << "\n";
8697
 
}
8698
 
 
8699
 
// Allow us to change our current RGB easily.
8700
 
// Usage: /rgb with no parameters displays current rgb.
8701
 
//        /rgb 15 3 3 Would set player 1's RGB to R15 G3 B3. 
8702
 
//        /rgb unique gives all players unique colors.
8703
 
//        /rgb random gives all players random colors.
8704
 
//        /rgb 2 15 3 3 Will change player 2's colors to 15 3 3. 
8705
 
void ePlayerNetID::currentPlayerRGB(tString s_orig)
8706
 
{
8707
 
    if (s_orig.StrPos(" ") == -1)
8708
 
    {
8709
 
        con << tOutput("$player_colors_current_text");
8710
 
        for(int i=0; i<MAX_PLAYERS; ++i )
8711
 
        {
8712
 
            bool in_game=ePlayer::PlayerIsInGame(i);
8713
 
            ePlayer *me=ePlayer::PlayerConfig(i);
8714
 
            tASSERT(me);
8715
 
            tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8716
 
            if (bool(p) && in_game)
8717
 
            {
8718
 
                tColoredString listColors;
8719
 
                listColors << p->GetColoredName() << "0xRESETT (" << ePlayer::PlayerConfig(i)->rgb[0] << ", " << ePlayer::PlayerConfig(i)->rgb[1] << ", " << ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8720
 
                con << listColors;
8721
 
            }
8722
 
        }
8723
 
    }
8724
 
    else
8725
 
    {
8726
 
        tArray<tString> passedString = s_orig.Split(" ");
8727
 
        bool correctParameters = false;
8728
 
        bool random = false;
8729
 
        bool unique = false;
8730
 
        int ourID = 0;
8731
 
 
8732
 
        if (passedString[1] == "random")
8733
 
        {
8734
 
            correctParameters = true;
8735
 
            random = true;
8736
 
 
8737
 
            //For now everyone gets random colors.
8738
 
            for(int i=0; i<MAX_PLAYERS; ++i )
8739
 
            {
8740
 
                bool in_game = ePlayer::PlayerIsInGame(i);
8741
 
                ePlayer *me = ePlayer::PlayerConfig(i);
8742
 
                tASSERT(me);
8743
 
                tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8744
 
 
8745
 
                if (bool(p) && in_game)
8746
 
                {
8747
 
                    se_RandomizeColor(me);
8748
 
                }
8749
 
            }
8750
 
 
8751
 
        }
8752
 
        else if(passedString[1] == "unique")
8753
 
        {
8754
 
            correctParameters = true;
8755
 
            unique = true;
8756
 
            //Also everyone gets unique colors if sent.
8757
 
            for(int i=0; i<MAX_PLAYERS; ++i )
8758
 
            {
8759
 
                bool in_game=ePlayer::PlayerIsInGame(i);
8760
 
                ePlayer *me=ePlayer::PlayerConfig(i);
8761
 
                tASSERT(me);
8762
 
                tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8763
 
 
8764
 
                if (bool(p) && in_game)
8765
 
                {
8766
 
                    se_UniqueColor(me,p);
8767
 
                }
8768
 
            }
8769
 
        }
8770
 
 
8771
 
        //Not really checking if the strings passed parameters are numbers, but if someone did /rgb asd asd asd it would just make it 0 0 0.
8772
 
        else if (passedString.Len() >= 4 && !(random || unique ))
8773
 
        {
8774
 
            //Guess we must be ID 0?
8775
 
            if (passedString.Len() == 4)
8776
 
            {
8777
 
                correctParameters = true;
8778
 
 
8779
 
                unsigned short r = (unsigned short) strtoul(passedString[1], NULL, 0);
8780
 
                unsigned short g = (unsigned short) strtoul(passedString[2], NULL, 0);
8781
 
                unsigned short b = (unsigned short) strtoul(passedString[3], NULL, 0);
8782
 
                
8783
 
                ePlayer::PlayerConfig(0)->rgb[0] = r;
8784
 
                ePlayer::PlayerConfig(0)->rgb[1] = g;
8785
 
                ePlayer::PlayerConfig(0)->rgb[2] = b;
8786
 
 
8787
 
            }
8788
 
            else if (passedString.Len() == 5)
8789
 
            {
8790
 
                ourID = (unsigned short) strtoul(passedString[1], NULL, 0);
8791
 
                if ((ourID <= MAX_PLAYERS) && (ourID > 0))
8792
 
                {
8793
 
                    correctParameters = true;
8794
 
 
8795
 
                    bool in_game=ePlayer::PlayerIsInGame(ourID-1);
8796
 
                    ePlayer *me=ePlayer::PlayerConfig(ourID-1);
8797
 
 
8798
 
                    unsigned short r = (unsigned short) strtoul(passedString[2], NULL, 0);
8799
 
                    unsigned short g = (unsigned short) strtoul(passedString[3], NULL, 0);
8800
 
                    unsigned short b = (unsigned short) strtoul(passedString[4], NULL, 0);
8801
 
 
8802
 
                    ePlayer::PlayerConfig(ourID-1)->rgb[0] = r;
8803
 
                    ePlayer::PlayerConfig(ourID-1)->rgb[1] = g;
8804
 
                    ePlayer::PlayerConfig(ourID-1)->rgb[2] = b;
8805
 
                }
8806
 
            }
8807
 
        }
8808
 
 
8809
 
        // If the correct parameters are passed, display the changes.
8810
 
        if (correctParameters)
8811
 
        {
8812
 
            con << tOutput("$player_colors_current_text");
8813
 
 
8814
 
            for(int i=0; i<MAX_PLAYERS; ++i )
8815
 
            {
8816
 
                bool in_game=ePlayer::PlayerIsInGame(i);
8817
 
                ePlayer *me=ePlayer::PlayerConfig(i);
8818
 
                tASSERT(me);
8819
 
                tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8820
 
                if (bool(p) && in_game)
8821
 
                {   tColoredString listColors;
8822
 
                    listColors << i+1 << ": " << p->GetColoredName() << "0xRESETT (" << ePlayer::PlayerConfig(i)->rgb[0] << ", " << ePlayer::PlayerConfig(i)->rgb[1] << ", " << ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8823
 
                    con << listColors;
8824
 
                }
8825
 
                if(!(bool(p) && in_game) && ourID-1 == i)
8826
 
                {
8827
 
                    con << tOutput("$player_colors_changed_text", ourID, ePlayer::PlayerConfig(i)->rgb[0], ePlayer::PlayerConfig(i)->rgb[1], ePlayer::PlayerConfig(i)->rgb[2]);
8828
 
                }
8829
 
            }
8830
 
        }
8831
 
        else
8832
 
        {
8833
 
            con << tOutput("$player_colors_changed_usage_error");
8834
 
        }
8835
 
    }
8836
 
}
8837
 
 
8838
 
 
 
8475
static void se_listPlayerColors()
 
8476
{
 
8477
    tColoredString listColors;
 
8478
     for ( int i = 0; i <= se_PlayerNetIDs.Len()-1; i++ )
 
8479
    {
 
8480
        ePlayerNetID * otherPlayers = se_PlayerNetIDs(i);
 
8481
 
 
8482
 
 
8483
        listColors << (i+1) << ": " << otherPlayers->GetColoredName() << "0xRESETT (" << otherPlayers->r << ", " << otherPlayers->g << ", " << otherPlayers->b << ")\n";
 
8484
     
 
8485
        con << listColors;
 
8486
 
 
8487
        listColors  = "";
 
8488
 
 
8489
    }
 
8490
}
8839
8491
 
8840
8492
 
8841
8493
static nSettingItem<int> se_pingCharityServerConf("PING_CHARITY_SERVER",sn_pingCharityServer );
10651
10303
 
10652
10304
static void Silence_conf(std::istream &s)
10653
10305
{
 
10306
    if ( se_NeedsServer( "SILENCE", s ) )
 
10307
    {
 
10308
        return;
 
10309
    }
 
10310
 
10654
10311
    ePlayerNetID * p = ReadPlayer( s );
10655
10312
    if ( p && !p->IsSilenced() )
10656
10313
    {
10657
 
#ifndef DEDICATED
10658
 
        if ( sn_GetNetState() == nCLIENT )
10659
 
            sn_ConsoleOut( tOutput( "$player_silenced_local", p->GetColoredName() ) );
10660
 
        else
10661
 
#endif
10662
 
            sn_ConsoleOut( tOutput( "$player_silenced", p->GetColoredName() ) );
 
10314
        sn_ConsoleOut( tOutput( "$player_silenced", p->GetColoredName() ) );
10663
10315
        p->SetSilenced( true );
10664
10316
    }
10665
10317
}
10669
10321
 
10670
10322
static void SilenceAll_conf(std::istream &s)
10671
10323
{
10672
 
    if (se_PlayerNetIDs.Len() > 0)
 
10324
    if ( se_NeedsServer( "SILENCE_ALL", s ) )
 
10325
    {
 
10326
        return;
 
10327
    }
 
10328
 
 
10329
    if (se_PlayerNetIDs.Len()>0)
10673
10330
    {
10674
10331
        int max = se_PlayerNetIDs.Len();
10675
 
        for (int i = 0; i < max; i++)
10676
 
        {
10677
 
            ePlayerNetID *p = se_PlayerNetIDs(i);
10678
 
 
10679
 
            #ifndef DEDICATED
10680
 
            if ((sn_GetNetState() == nCLIENT) && (p && !p->IsSilenced()) && ((p->Owner() != ::sn_myNetID)))
10681
 
            {
10682
 
                p->SetSilenced(true);
10683
 
            }
10684
 
            else
10685
 
            #endif
10686
 
            {
10687
 
                if ((sn_GetNetState() == nSERVER) && (p && !p->IsSilenced()))
10688
 
                {
10689
 
                    p->SetSilenced(true);
10690
 
                }
10691
 
            }
10692
 
        }
10693
 
        #ifndef DEDICATED
10694
 
        if (sn_GetNetState() == nCLIENT)
10695
 
        {
10696
 
            sn_ConsoleOut(tOutput("$player_silenced_all_local"));
10697
 
        }
10698
 
        #endif
10699
 
        if (sn_GetNetState() == nSERVER)
10700
 
        {
10701
 
            sn_ConsoleOut(tOutput("$player_silenced_all"));
10702
 
        }
 
10332
        for(int i=0; i<max; i++)
 
10333
        {
 
10334
            ePlayerNetID *p=se_PlayerNetIDs(i);
 
10335
            if ( p && !p->IsSilenced() )
 
10336
            {
 
10337
                p->SetSilenced( true );
 
10338
            }
 
10339
        }
 
10340
        sn_ConsoleOut( tOutput( "$player_silenced_all") );
10703
10341
    }
10704
10342
}
10705
10343
 
10706
 
 
10707
10344
static tConfItemFunc silenceall_conf("SILENCE_ALL",&SilenceAll_conf);
10708
10345
static tAccessLevelSetter se_silenceallConfLevel( silenceall_conf, tAccessLevel_Moderator );
10709
10346
 
10710
10347
static void Voice_conf(std::istream &s)
10711
10348
{
 
10349
    if ( se_NeedsServer( "VOICE", s ) || se_NeedsServer( "UNSILENCE", s ))
 
10350
    {
 
10351
        return;
 
10352
    }
 
10353
 
10712
10354
    ePlayerNetID * p = ReadPlayer( s );
10713
10355
    if ( p && p->IsSilenced() )
10714
10356
    {
10715
 
#ifndef DEDICATED
10716
 
        if ( sn_GetNetState() == nCLIENT )
10717
 
            sn_ConsoleOut( tOutput( "$player_voiced_local", p->GetColoredName() ) );
10718
 
        else
10719
 
#endif
10720
 
            sn_ConsoleOut( tOutput( "$player_voiced", p->GetColoredName() ) );
 
10357
        sn_ConsoleOut( tOutput( "$player_voiced", p->GetColoredName() ) );
10721
10358
        p->SetSilenced( false );
10722
10359
    }
10723
10360
}
10729
10366
 
10730
10367
static void VoiceAll(std::istream &s)
10731
10368
{
 
10369
    if ( se_NeedsServer( "VOICE_ALL", s ) || se_NeedsServer( "UNSILENCE_ALL", s ))
 
10370
    {
 
10371
        return;
 
10372
    }
10732
10373
    if (se_PlayerNetIDs.Len()>0)
10733
10374
    {
10734
10375
        int max = se_PlayerNetIDs.Len();
10740
10381
                p->SetSilenced( false );
10741
10382
            }
10742
10383
        }
10743
 
 
10744
 
        #ifndef DEDICATED
10745
 
        if ( sn_GetNetState() == nCLIENT )
10746
 
            sn_ConsoleOut( tOutput( "$player_voiced_all_local") );
10747
 
        else
10748
 
#endif
10749
10384
        sn_ConsoleOut( tOutput( "$player_voiced_all") );
10750
10385
    }
10751
10386
}