CDefObjInfoHandler.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #define VCMI_DLL
  2. #include "../stdafx.h"
  3. #include "CDefObjInfoHandler.h"
  4. #include "../CGameInfo.h"
  5. #include "CLodHandler.h"
  6. #include <sstream>
  7. #include "../lib/VCMI_Lib.h"
  8. extern CLodHandler * bitmaph;
  9. bool CGDefInfo::isVisitable()
  10. {
  11. for (int i=0; i<6; i++)
  12. {
  13. if (visitMap[i])
  14. return true;
  15. }
  16. return false;
  17. }
  18. CGDefInfo::CGDefInfo()
  19. {
  20. visitDir = (8|16|32|64|128); //4,5,6,7,8 - any not-from-up direction
  21. }
  22. void CDefObjInfoHandler::load()
  23. {
  24. VLC->dobjinfo = this;
  25. nodrze<int> ideki;
  26. std::istringstream inp(bitmaph->getTextFile("ZOBJCTS.TXT"));
  27. int objNumber;
  28. inp>>objNumber;
  29. for(int hh=0; hh<objNumber; ++hh)
  30. {
  31. CGDefInfo* nobj = new CGDefInfo();
  32. nobj->handler = NULL;
  33. std::string dump;
  34. inp>>nobj->name;
  35. std::transform(nobj->name.begin(), nobj->name.end(), nobj->name.begin(), (int(*)(int))toupper);
  36. for(int o=0; o<6; ++o)
  37. {
  38. nobj->blockMap[o] = 0xff;
  39. nobj->visitMap[o] = 0x00;
  40. }
  41. std::string mapStr;
  42. inp>>mapStr;
  43. std::reverse(mapStr.begin(), mapStr.end());
  44. for(int v=0; v<mapStr.size(); ++v)
  45. {
  46. if(mapStr[v]=='0')
  47. {
  48. nobj->blockMap[v/8] &= 255 - (128 >> (v%8));
  49. }
  50. }
  51. inp>>mapStr;
  52. std::reverse(mapStr.begin(), mapStr.end());
  53. for(int v=0; v<mapStr.size(); ++v)
  54. {
  55. if(mapStr[v]=='1')
  56. {
  57. nobj->visitMap[v/8] |= (128 >> (v%8));
  58. }
  59. }
  60. for(int yy=0; yy<2; ++yy) //first - on which types of terrain object can be placed;
  61. inp>>dump; //second -in which terrains' menus object in the editor will be available (?)
  62. inp>>nobj->id;
  63. inp>>nobj->subid;
  64. inp>>nobj->type;
  65. inp>>nobj->printPriority;
  66. gobjs[nobj->id][nobj->subid] = nobj;
  67. if(nobj->id==98)
  68. castles[nobj->subid]=nobj;
  69. }
  70. }