CConsoleHandler.cpp 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "stdafx.h"
  2. #include "CConsoleHandler.h"
  3. #include "CAdvmapInterface.h"
  4. #include "SDL.h"
  5. #include "SDL_thread.h"
  6. #include "CGameInfo.h"
  7. #include "global.h"
  8. #include <sstream>
  9. int internalFunc(void * nothingUsed)
  10. {
  11. char * usersMessage = new char[500];
  12. std::string readed;
  13. while(true)
  14. {
  15. std::cin.getline(usersMessage, 500);
  16. std::istringstream readed;
  17. std::string pom(usersMessage);
  18. readed.str(pom);
  19. std::string cn; //command name
  20. readed >> cn;
  21. switch (*cn.c_str())
  22. {
  23. case 'P':
  24. std::cout<<"Policzyc sciezke."<<std::endl;
  25. int3 src, dst;
  26. readed>>src>>dst;
  27. LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]);
  28. break;
  29. }
  30. //SDL_Delay(100);
  31. }
  32. return -1;
  33. }
  34. void CConsoleHandler::runConsole()
  35. {
  36. SDL_Thread * myth = SDL_CreateThread(&internalFunc, NULL);
  37. }