00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <Parse.h>
00021
00022 #include "Set.h"
00023 #include "InSocket.h"
00024 #include "Chunk.h"
00025 #include "Player.h"
00026 #include "cstring.h"
00027 #include "Terrain.h"
00028 #include "Area.h"
00029 #include "Look.h"
00030
00031
00032 void Setcmd::Execute(InSocket *from,const std::string& param,Parse& pa)
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 }
00120
00121