![]() |
Setcmd Class ReferenceCommand: set terrain | wizard | name | view.
More...
|
Public Member Functions | |
Setcmd () | |
void | Execute (InSocket *, const std::string ¶ms, Parse &) |
Execute command. | |
std::string | Category () |
Get command category. |
Definition at line 28 of file Set.h.
Setcmd::Setcmd | ( | ) | [inline] |
Definition at line 31 of file Set.h.
References Command::AddArgument().
00031 : Command("set") { 00032 AddArgument("terrain", true); 00033 AddArgument("wizard", true); 00034 AddArgument("name"); 00035 AddArgument("view", true); 00036 }
void Setcmd::Execute | ( | InSocket * | , | |
const std::string & | arg, | |||
Parse & | ||||
) | [virtual] |
Execute command.
Implements Command.
Definition at line 32 of file Set.cpp.
References Terrain::Exists(), Player::GetArea(), Terrain::GetChar(), Player::GetChunk(), Player::GetChunkX(), Player::GetChunkY(), Player::GetName(), Player::IsWizard(), Look::LookMap(), Player::SetDisplayName(), and Player::SetWizView().
00033 { 00034 Database& db = from -> GetDatabase(); 00035 Player pl(db, from -> GetAccountName()); 00036 std::string rest = pa.getrest(); 00037 if (param == "wizard" && pl.IsWizard()) 00038 { 00039 Player a(db, rest); 00040 if (a.Exists()) 00041 { 00042 a.SetWizard(!a.IsWizard()); 00043 a.Save(); 00044 from -> Send(a.GetDisplayName() + " is now" + (a.IsWizard()?"":" NOT") + " a wizard.\n"); 00045 } 00046 else 00047 { 00048 from -> Send("Can't find " + rest + ".\n"); 00049 } 00050 from -> SetPrompt(); 00051 } 00052 else 00053 if (param == "terrain" && pl.IsWizard()) 00054 { 00055 if (rest.size()) 00056 { 00057 Area area(db, pl.GetArea()); 00058 Terrain t(db, area, rest[0]); 00059 if (t.Exists()) 00060 { 00061 Chunk chunk(db, area, pl.GetChunk()); 00062 chunk.Set(pl.GetChunkX(),pl.GetChunkY(),t.GetChar()); 00063 chunk.Save(); 00064 from -> Send("Ok.\n"); 00065 } 00066 else 00067 { 00068 from -> Send("Can't find terrain " + rest + ".\n"); 00069 } 00070 } 00071 else 00072 { 00073 from -> Send("Set terrain?\n"); 00074 } 00075 from -> SetPrompt(); 00076 } 00077 else 00078 if (param == "name") 00079 { 00080 if (rest.size()) 00081 { 00082 cstring name = rest; 00083 if (!strcmp(name.uc_str(), pl.GetName().c_str())) 00084 { 00085 pl.SetDisplayName(rest); 00086 from -> Send("Ok.\n"); 00087 } 00088 else 00089 { 00090 from -> Send("Name mismatch, please try again.\n"); 00091 } 00092 } 00093 else 00094 { 00095 from -> Send("Set your name to what?\n"); 00096 } 00097 from -> SetPrompt(); 00098 } 00099 else 00100 if (param == "view") 00101 { 00102 if (rest.size() && (rest[0] == 'w' || rest[0] == 'W')) 00103 { 00104 Player pl(db, from -> GetAccountName()); 00105 pl.SetWizView(1); 00106 } 00107 else 00108 { 00109 pl.SetWizView(0); 00110 } 00111 Look::LookMap(from); 00112 from -> SetPrompt(); 00113 } 00114 else 00115 { 00116 from -> Send("Set what?\n"); 00117 from -> SetPrompt(); 00118 } 00119 }
std::string Setcmd::Category | ( | ) | [inline, virtual] |