00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "Map.h"
00021 #include "InSocket.h"
00022 #include "Player.h"
00023 #include "Area.h"
00024 #include "Chunk.h"
00025 #include "Terrain.h"
00026
00027
00028 void Map::Execute(InSocket *from,const std::string& params,Parse&)
00029 {
00030 Database& db = from -> GetDatabase();
00031 Player pl(db, from -> GetAccountName());
00032 Area area(db, pl.GetArea());
00033 Chunk chunk(db, area, pl.GetChunk());
00034 int xmin,xmax,ymin,ymax;
00035 std::string colorstr;
00036 area.GetAreaBorders(chunk.GetZ(),xmin,xmax,ymin,ymax);
00037
00038 for (int ch_y = ymax; ch_y >= ymin; ch_y--)
00039 {
00040 for (int y = 0; y < area.GetHeight(); y++)
00041 {
00042 for (int ch_x = xmin; ch_x <= xmax; ch_x++)
00043 {
00044 Chunk cc(db, area, ch_x, ch_y, chunk.GetZ() );
00045 for (int x = 0; x < area.GetWidth(); x++)
00046 {
00047 long xcoord = ch_x * area.GetWidth() + x;
00048 long ycoord = ch_y * area.GetHeight() + area.GetHeight() - y - 1;
00049 if (pl.Seen(area, xcoord, ycoord, chunk.GetZ()))
00050 {
00051 if (cc.Exists())
00052 {
00053 std::string tmp;
00054 tmp += cc.Get(x,y);
00055 Terrain t(db, area, tmp[0]);
00056 if (t.GetColor() != colorstr)
00057 {
00058 from -> Send("&n" + t.GetColor());
00059 colorstr = t.GetColor();
00060 }
00061 from -> Send(tmp);
00062 }
00063 else
00064 {
00065 from -> Send("&n ");
00066 colorstr = "&n";
00067 }
00068 }
00069 else
00070 {
00071 from -> Send("&n ");
00072 colorstr = "&n";
00073 }
00074 }
00075 }
00076 from -> Send("&n\n");
00077 colorstr = "&n";
00078 }
00079 }
00080 from -> SetPrompt();
00081 }
00082
00083