Logo
~Sockets~
~Examples~
~Contact~

List.cpp

Go to the documentation of this file.
00001 // List.cpp
00002 // released 2006-09-25
00003 /*
00004 Copyright (C) 2006  Anders Hedstrom (grymse@alhem.net)
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 */
00020 //#include <stdio.h>
00021 #include <libfuture.h>
00022 #include <Parse.h>
00023 #include <Utility.h>
00024 
00025 #include "List.h"
00026 #include "InSocket.h"
00027 #include "Player.h"
00028 #include "Area.h"
00029 
00030 
00031 void List::Execute(InSocket *from,const std::string& param,Parse& pa)
00032 {
00033         Database& db = from -> GetDatabase();
00034         Query q(db);
00035         if (param == "terrain")
00036         {
00037                 Player pl(db, from -> GetAccountName());
00038                 Area area(db, pl.GetArea());
00039                 q.get_result("select * from terrain where area=" + Utility::l2string(area.GetNum()));
00040                 while (q.fetch_row())
00041                 {
00042                         db::Terrain t(&db, &q);
00043                         from -> Send(t.tcolor + t.tchar + "&n    " + t.name + (t.impassable ? "    (Impassable)" : "") + "\n");
00044                 }
00045                 q.free_result();
00046         }
00047         else
00048         if (param == "wizards")
00049         {
00050                 q.get_result("select * from account where wizard<>0");
00051                 while (q.fetch_row())
00052                 {
00053                         db::Account x(&db, &q);
00054                         from -> Send("  " + x.display_name + "\n");
00055                 }
00056                 q.free_result();
00057         }
00058         else
00059         if (param == "areas")
00060         {
00061                 q.get_result("select * from area");
00062                 while (q.fetch_row())
00063                 {
00064                         db::Area area(&db, &q);
00065                         from -> Sendf("#%ld: %2ldx%2ld %s\n", area.num, area.width, area.height, area.name.c_str());
00066                 }
00067                 q.free_result();
00068         }
00069         else
00070         {
00071                 from -> Send("List what?\n");
00072         }
00073         from -> SetPrompt();
00074 }
00075 
00076 
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