Logo
~Sockets~
~Examples~
~Contact~

Map Class Reference
[Commands]

Command: show map. More...

#include <Map.h>

Inheritance diagram for Map:

Inheritance graph
[legend]
Collaboration diagram for Map:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Map ()
void Execute (InSocket *, const std::string &params, Parse &)
 Execute command.
std::string Category ()
 Get command category.

Detailed Description

Command: show map.

Definition at line 28 of file Map.h.


Constructor & Destructor Documentation

Map::Map (  )  [inline]

Definition at line 31 of file Map.h.

00031 : Command("map") {}


Member Function Documentation

void Map::Execute ( InSocket ,
const std::string &  arg,
Parse &   
) [virtual]

Execute command.

Implements Command.

Definition at line 28 of file Map.cpp.

References Player::GetArea(), Player::GetChunk(), Terrain::GetColor(), and Player::Seen().

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 }

std::string Map::Category (  )  [inline, virtual]

Get command category.

Implements Command.

Definition at line 35 of file Map.h.

00035 { return "Navigation"; }


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4