src/Console.cpp

00001 #include <iostream>
00002 #include <string>
00003 #include "Console.h"
00004 #include "CommandManager.h"
00005 
00006 Console::Console(Server * server)
00007         :cmdManager(CommandManager::getInstance())
00008 {
00009         this->data.self = this;
00010         this->data.running = true;
00011         this->data.banner = "\n:: Welcome to Last Online ::\n\npre-alpha version\nPlease refer to http://last-online.sourceforge.net for more informations.";
00012 
00013         this->data.myThread = SDL_CreateThread(this->startThread, &(this->data));
00014 
00015         this->cmdManager->setServer(server);    // Sets the Command Manager server.
00016 }
00017 
00018 Console::~Console()
00019 {
00020 }
00021 
00022 int Console::startThread(void * data){
00023         ConsoleData * trueData =  reinterpret_cast<ConsoleData *>(data);
00024         trueData->self->startConsole(trueData);
00025 
00026         return 1;
00027 }
00028 
00029 void Console::startConsole(ConsoleData * data){
00030                 bool exit = false;
00031 
00032                 std::string selection;
00033                 std::cout << data->banner.c_str() << std::endl;
00034                 do{
00035                         std::cout << std::endl << "> ";
00036                         std::getline(std::cin, selection);
00037                         this->cmdManager->processCommand(selection);
00038                 }while(!exit);
00039 }
00040 
00041 void Console::setServer(Server* myServer){
00042         this->cmdManager->setServer(myServer); // Sets the CommandManager's Server.
00043 }

Generated on Mon Dec 3 04:30:12 2007 for lo-testserver by  doxygen 1.3.9.1