2007-08-15 18:13:11 +03:00
|
|
|
#include "stdafx.h"
|
2007-08-17 20:42:21 +03:00
|
|
|
#include "CConsoleHandler.h"
|
|
|
|
#include "CAdvmapInterface.h"
|
2007-08-15 18:13:11 +03:00
|
|
|
#include "SDL.h"
|
|
|
|
#include "SDL_thread.h"
|
2007-08-17 20:42:21 +03:00
|
|
|
#include "CGameInfo.h"
|
|
|
|
#include "global.h"
|
2007-08-29 15:18:31 +03:00
|
|
|
#include "CGameState.h"
|
|
|
|
#include "CCallback.h"
|
2007-09-18 16:30:26 +03:00
|
|
|
#include "CPathfinder.h"
|
|
|
|
#include "mapHandler.h"
|
2007-08-17 20:42:21 +03:00
|
|
|
#include <sstream>
|
2007-08-15 18:13:11 +03:00
|
|
|
|
2007-09-30 19:16:00 +03:00
|
|
|
int internalFunc(void * callback)
|
2007-08-15 18:13:11 +03:00
|
|
|
{
|
2007-09-30 19:16:00 +03:00
|
|
|
CCallback * cb = (CCallback*)callback;
|
2007-08-15 18:13:11 +03:00
|
|
|
char * usersMessage = new char[500];
|
|
|
|
std::string readed;
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
std::cin.getline(usersMessage, 500);
|
2007-08-17 20:42:21 +03:00
|
|
|
std::istringstream readed;
|
|
|
|
std::string pom(usersMessage);
|
|
|
|
readed.str(pom);
|
|
|
|
std::string cn; //command name
|
|
|
|
readed >> cn;
|
2007-08-29 15:18:31 +03:00
|
|
|
int3 src, dst;
|
|
|
|
|
|
|
|
int heronum;
|
|
|
|
int3 dest;
|
|
|
|
|
2007-08-17 20:42:21 +03:00
|
|
|
switch (*cn.c_str())
|
|
|
|
{
|
|
|
|
case 'P':
|
2007-08-29 15:18:31 +03:00
|
|
|
std::cout<<"Policzyc sciezke."<<std::endl;
|
2007-08-17 20:42:21 +03:00
|
|
|
readed>>src>>dst;
|
|
|
|
LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]);
|
|
|
|
break;
|
2007-08-29 15:18:31 +03:00
|
|
|
case 'm': //number of heroes
|
|
|
|
std::cout<<"Number of heroes: "<<CGI->heroh->heroInstances.size()<<std::endl;
|
|
|
|
break;
|
|
|
|
case 'H': //position of hero
|
|
|
|
readed>>heronum;
|
2007-10-05 21:16:22 +03:00
|
|
|
std::cout<<"Position of hero "<<heronum<<": "<<CGI->heroh->heroInstances[heronum]->getPosition(false)<<std::endl;
|
2007-08-29 15:18:31 +03:00
|
|
|
break;
|
2007-10-05 21:16:22 +03:00
|
|
|
case 'M': //move heroa
|
|
|
|
{
|
|
|
|
readed>>heronum>>dest;
|
|
|
|
const CHeroInstance * hero = cb->getHeroInfo(0,heronum,0);
|
|
|
|
CPath * path = CGI->pathf->getPath(hero->getPosition(false),dest,hero);
|
|
|
|
cb->moveHero(heronum, path, 0, 0);
|
|
|
|
delete path;
|
|
|
|
break;
|
|
|
|
}
|
2007-10-05 21:10:33 +03:00
|
|
|
case 'D': //pos description
|
|
|
|
readed>>src;
|
|
|
|
CGI->mh->getObjDescriptions(src);
|
|
|
|
break;
|
|
|
|
case 'T': //test rect
|
|
|
|
readed>>src;
|
|
|
|
for(int g=0; g<8; ++g)
|
|
|
|
{
|
|
|
|
for(int v=0; v<8; ++v)
|
|
|
|
{
|
|
|
|
int3 csrc = src;
|
|
|
|
csrc.y+=g;
|
|
|
|
csrc.x+=v;
|
|
|
|
if(CGI->mh->getObjDescriptions(csrc).size())
|
|
|
|
std::cout<<'x';
|
|
|
|
else
|
|
|
|
std::cout<<'o';
|
|
|
|
}
|
|
|
|
std::cout<<std::endl;
|
|
|
|
}
|
2007-10-13 23:31:50 +03:00
|
|
|
break;
|
2007-08-17 20:42:21 +03:00
|
|
|
}
|
|
|
|
//SDL_Delay(100);
|
2007-08-15 18:13:11 +03:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConsoleHandler::runConsole()
|
|
|
|
{
|
2007-09-30 19:16:00 +03:00
|
|
|
SDL_Thread * myth = SDL_CreateThread(&internalFunc, cb);
|
2007-08-15 18:13:11 +03:00
|
|
|
}
|