8696
8705
return listinfo << "\n";
8708
static tString se_colorVarFile("colors.txt");
8709
static tConfItem<tString> se_colorVarFileConf("RGB_COLORS_FILE", se_colorVarFile);
8711
static void se_loadSavedColor(int lineNumber)
8713
tArray<tString> colors;
8716
if (tDirectories::Var().Open(i, se_colorVarFile))
8720
std::string sayLine;
8721
std::getline(i, sayLine);
8722
std::istringstream s(sayLine);
8728
if (params.Filter() != "")
8729
colors.Insert(params);
8734
tString currentLine = colors[lineNumber];
8735
if (currentLine != "")
8738
tString Name = currentLine.ExtractNonBlankSubString(pos);
8739
tString ColorOne = currentLine.ExtractNonBlankSubString(pos);
8740
ColorOne.RemoveSubStr(0, 1);
8741
int Color1 = atoi(ColorOne);
8742
int Color2 = atoi(currentLine.ExtractNonBlankSubString(pos));
8743
int Color3 = atoi(currentLine.ExtractNonBlankSubString(pos));
8747
se_MakeColorValid(c1, c2, c3, 1.0f);
8748
if (tColoredString::HasColors(Name))
8750
con << tOutput("$player_colors_loading");
8751
con << (lineNumber + 1) << ") " << Name << "0xRESETT (" << Color1 << ", " << Color2
8752
<< ", " << Color3 << ")\n";
8756
con << tOutput("$player_colors_loading");
8757
con << (lineNumber + 1) << ") "
8758
<< tColoredString::ColorString(c1 / 15, c2 / 15, c3 / 15) << Name << "0xRESETT ("
8759
<< Color1 << ", " << Color2 << ", " << Color3 << ")\n";
8761
ePlayer::PlayerConfig(0)->rgb[0] = Color1;
8762
ePlayer::PlayerConfig(0)->rgb[1] = Color2;
8763
ePlayer::PlayerConfig(0)->rgb[2] = Color3;
8767
static int se_savedColorsCount()
8771
if (tDirectories::Var().Open(i, se_colorVarFile))
8775
std::string sayLine;
8776
std::getline(i, sayLine);
8777
std::istringstream s(sayLine);
8782
if (params.Filter() != "")
8792
static void se_SavedColors(int savedColorsCount)
8794
tArray<tString> colors;
8797
if (tDirectories::Var().Open(i, se_colorVarFile))
8801
std::string sayLine;
8802
std::getline(i, sayLine);
8803
std::istringstream s(sayLine);
8809
if (params.Filter() != "")
8810
colors.Insert(params);
8815
for (int index = 0; index <= savedColorsCount; index++)
8817
tString currentLine = colors[index];
8818
if (currentLine != "")
8821
tString Name = currentLine.ExtractNonBlankSubString(pos);
8822
tString ColorOne = currentLine.ExtractNonBlankSubString(pos);
8823
ColorOne.RemoveSubStr(0, 1);
8824
int Color1 = atoi(ColorOne);
8825
int Color2 = atoi(currentLine.ExtractNonBlankSubString(pos));
8826
int Color3 = atoi(currentLine.ExtractNonBlankSubString(pos));
8830
se_MakeColorValid(c1, c2, c3, 1.0f);
8831
if (tColoredString::HasColors(Name))
8833
con << (index + 1) << ") " << Name << "0xRESETT (" << Color1 << ", " << Color2
8834
<< ", " << Color3 << ")\n";
8838
con << (index + 1) << ") " << tColoredString::ColorString(c1 / 15, c2 / 15, c3 / 15)
8839
<< Name << "0xRESETT (" << Color1 << ", " << Color2 << ", " << Color3 << ")\n";
8699
8846
// Allow us to change our current RGB easily.
8700
8847
// Usage: /rgb with no parameters displays current rgb.
8701
// /rgb 15 3 3 Would set player 1's RGB to R15 G3 B3.
8848
// /rgb 15 3 3 Would set player 1's RGB to R15 G3 B3.
8702
8849
// /rgb unique gives all players unique colors.
8703
8850
// /rgb random gives all players random colors.
8704
// /rgb 2 15 3 3 Will change player 2's colors to 15 3 3.
8851
// /rgb 2 15 3 3 Will change player 2's colors to 15 3 3.
8852
// /rgb save would save your current colors to colors.txt
8853
// /rgb save player would save the players current colors to colors.txt
8854
// /rgb list would list your current saved colors.
8855
// /rgb load 1 would load from line #1 in the list.
8856
// /rgb clear would clear your current list of saved colors.
8705
8857
void ePlayerNetID::currentPlayerRGB(tString s_orig)
8707
8859
if (s_orig.StrPos(" ") == -1)
8709
8861
con << tOutput("$player_colors_current_text");
8710
for(int i=0; i<MAX_PLAYERS; ++i )
8862
for (int i = 0; i < MAX_PLAYERS; ++i)
8712
bool in_game=ePlayer::PlayerIsInGame(i);
8713
ePlayer *me=ePlayer::PlayerConfig(i);
8864
bool in_game = ePlayer::PlayerIsInGame(i);
8865
ePlayer* me = ePlayer::PlayerConfig(i);
8715
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8867
tCONTROLLED_PTR(ePlayerNetID)& p = me->netPlayer;
8716
8868
if (bool(p) && in_game)
8718
8870
tColoredString listColors;
8719
listColors << p->GetColoredName() << "0xRESETT (" << ePlayer::PlayerConfig(i)->rgb[0] << ", " << ePlayer::PlayerConfig(i)->rgb[1] << ", " << ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8871
listColors << p->GetColoredName() << "0xRESETT ("
8872
<< ePlayer::PlayerConfig(i)->rgb[0] << ", "
8873
<< ePlayer::PlayerConfig(i)->rgb[1] << ", "
8874
<< ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8720
8875
con << listColors;
8734
8895
correctParameters = true;
8737
//For now everyone gets random colors.
8738
for(int i=0; i<MAX_PLAYERS; ++i )
8898
// For now everyone gets random colors.
8899
for (int i = 0; i < MAX_PLAYERS; ++i)
8740
8901
bool in_game = ePlayer::PlayerIsInGame(i);
8741
ePlayer *me = ePlayer::PlayerConfig(i);
8902
ePlayer* me = ePlayer::PlayerConfig(i);
8743
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
8904
tCONTROLLED_PTR(ePlayerNetID)& p = me->netPlayer;
8745
8906
if (bool(p) && in_game)
8747
8908
se_RandomizeColor(me);
8752
else if(passedString[1] == "unique")
8912
else if (passedString[1] == "help")
8916
con << tOutput("$player_colors_command_help", se_colorVarFile);
8918
else if (passedString[1] == "save")
8922
bool foundPlayer = false;
8924
if (passedString.Len() == 2)
8929
if (tDirectories::Var().Open(o, se_colorVarFile, std::ios::app))
8931
con << tOutput("$player_colors_saved");
8932
for (int i = 0; i < MAX_PLAYERS; ++i)
8934
bool in_game = ePlayer::PlayerIsInGame(i);
8935
ePlayer* me = ePlayer::PlayerConfig(i);
8937
tCONTROLLED_PTR(ePlayerNetID)& p = me->netPlayer;
8939
if (bool(p) && in_game)
8941
o << ePlayerNetID::gatherPlayerColor(p,0);
8942
con << ePlayerNetID::gatherPlayerColor(p);;
8948
con << tOutput("$players_color_error");
8952
else if (passedString.Len() >= 3)
8954
for (int i = 0; i <= se_PlayerNetIDs.Len() - 1; i++)
8956
ePlayerNetID* p = se_PlayerNetIDs(i);
8957
if (p->GetName().Filter().Contains(passedString[2].Filter()))
8961
if (tDirectories::Var().Open(o, se_colorVarFile, std::ios::app))
8963
con << tOutput("$player_colors_saved");
8964
o << ePlayerNetID::gatherPlayerColor(p,0);
8965
con << ePlayerNetID::gatherPlayerColor(p);;
8969
con << tOutput("$players_color_error");
8976
con << tOutput("$player_colors_not_found", passedString[2]);
8981
else if (passedString[1] == "load")
8984
int savedColorsCount = se_savedColorsCount();
8986
if (passedString.Len() == 2)
8988
con << tOutput("$player_colors_changed_usage_error");
8991
else if (passedString.Len() == 3)
8993
correctParameters = true;
8994
int lineNumber = (atoi(passedString[2]) - 1);
8995
if ((lineNumber >= 0) && lineNumber <= savedColorsCount - 1)
8997
se_loadSavedColor(lineNumber);
9001
correctParameters = false;
9003
con << tOutput("$players_color_line_not_found", se_colorVarFile,
9004
savedColorsCount, lineNumber + 1);
9008
else if (passedString[1] == "list")
9012
int savedColorsCount = se_savedColorsCount();
9013
con << tOutput("$players_color_list", savedColorsCount, se_colorVarFile);
9014
if (savedColorsCount > 0)
9016
se_SavedColors(savedColorsCount);
9020
con << tOutput("$player_colors_empty");
9023
else if (passedString[1] == "clear")
9028
if (tDirectories::Var().Open(o, se_colorVarFile))
9033
con << tOutput("$player_colors_cleared", se_colorVarFile);
9035
else if (passedString[1] == "unique" && !(help || random || load || save || list || clear))
8754
9037
correctParameters = true;
8756
//Also everyone gets unique colors if sent.
8757
for(int i=0; i<MAX_PLAYERS; ++i )
9040
// Also everyone gets unique colors if sent.
9041
for (int i = 0; i < MAX_PLAYERS; ++i)
8759
bool in_game=ePlayer::PlayerIsInGame(i);
8760
ePlayer *me=ePlayer::PlayerConfig(i);
9043
bool in_game = ePlayer::PlayerIsInGame(i);
9044
ePlayer* me = ePlayer::PlayerConfig(i);
8762
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
9046
tCONTROLLED_PTR(ePlayerNetID)& p = me->netPlayer;
8764
9048
if (bool(p) && in_game)
8766
se_UniqueColor(me,p);
9050
se_UniqueColor(me, p);
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 ))
9055
// Not really checking if the strings passed parameters are numbers,
9056
// but if someone did /rgb asd asd asd it would just make it 0 0 0.
9057
else if (passedString.Len() >= 4
9058
&& !(help || random || unique || load || save || list || clear))
8774
//Guess we must be ID 0?
9060
// Guess we must be ID 0?
8775
9061
if (passedString.Len() == 4)
8777
9063
correctParameters = true;
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);
9065
int r = atoi(passedString[1]);
9066
int g = atoi(passedString[2]);
9067
int b = atoi(passedString[3]);
8783
9069
ePlayer::PlayerConfig(0)->rgb[0] = r;
8784
9070
ePlayer::PlayerConfig(0)->rgb[1] = g;
8785
9071
ePlayer::PlayerConfig(0)->rgb[2] = b;
8788
else if (passedString.Len() == 5)
9073
else if (passedString.Len() == 5
9074
&& !(help || random || unique || load || save || list || clear))
8790
ourID = (unsigned short) strtoul(passedString[1], NULL, 0);
9076
ourID = atoi(passedString[1]);
8791
9077
if ((ourID <= MAX_PLAYERS) && (ourID > 0))
8793
9079
correctParameters = true;
8795
bool in_game=ePlayer::PlayerIsInGame(ourID-1);
8796
ePlayer *me=ePlayer::PlayerConfig(ourID-1);
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);
8802
ePlayer::PlayerConfig(ourID-1)->rgb[0] = r;
8803
ePlayer::PlayerConfig(ourID-1)->rgb[1] = g;
8804
ePlayer::PlayerConfig(ourID-1)->rgb[2] = b;
9081
bool in_game = ePlayer::PlayerIsInGame(ourID - 1);
9082
ePlayer* me = ePlayer::PlayerConfig(ourID - 1);
9084
int r = atoi(passedString[2]);
9085
int g = atoi(passedString[3]);
9086
int b = atoi(passedString[4]);
9088
ePlayer::PlayerConfig(ourID - 1)->rgb[0] = r;
9089
ePlayer::PlayerConfig(ourID - 1)->rgb[1] = g;
9090
ePlayer::PlayerConfig(ourID - 1)->rgb[2] = b;
8812
9098
con << tOutput("$player_colors_current_text");
8814
for(int i=0; i<MAX_PLAYERS; ++i )
9100
for (int i = 0; i < MAX_PLAYERS; ++i)
8816
bool in_game=ePlayer::PlayerIsInGame(i);
8817
ePlayer *me=ePlayer::PlayerConfig(i);
9102
bool in_game = ePlayer::PlayerIsInGame(i);
9103
ePlayer* me = ePlayer::PlayerConfig(i);
8819
tCONTROLLED_PTR(ePlayerNetID) &p=me->netPlayer;
9105
tCONTROLLED_PTR(ePlayerNetID)& p = me->netPlayer;
8820
9106
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";
9108
ePlayerNetID::Update();
9109
tColoredString listColors;
9110
listColors << i + 1 << ") " << p->GetColoredName() << "0xRESETT ("
9111
<< ePlayer::PlayerConfig(i)->rgb[0] << ", "
9112
<< ePlayer::PlayerConfig(i)->rgb[1] << ", "
9113
<< ePlayer::PlayerConfig(i)->rgb[2] << ")\n";
8823
9114
con << listColors;
8825
if(!(bool(p) && in_game) && ourID-1 == i)
9116
if (!(bool(p) && in_game) && ourID - 1 == i)
8827
con << tOutput("$player_colors_changed_text", ourID, ePlayer::PlayerConfig(i)->rgb[0], ePlayer::PlayerConfig(i)->rgb[1], ePlayer::PlayerConfig(i)->rgb[2]);
9118
con << tOutput("$player_colors_changed_text", ourID,
9119
ePlayer::PlayerConfig(i)->rgb[0], ePlayer::PlayerConfig(i)->rgb[1],
9120
ePlayer::PlayerConfig(i)->rgb[2]);
8833
con << tOutput("$player_colors_changed_usage_error");
9126
// If hideError is enabled we wont display the error message.
9129
con << tOutput("$player_colors_changed_usage_error");
8841
9135
static nSettingItem<int> se_pingCharityServerConf("PING_CHARITY_SERVER",sn_pingCharityServer );
8842
9136
static nVersionFeature se_pingCharityServerControlled( 14 );