CObjectHandler.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "stdafx.h"
  2. #include "CObjectHandler.h"
  3. #include "../CGameInfo.h"
  4. #include "CGeneralTextHandler.h"
  5. #include "CLodHandler.h"
  6. #include "CAmbarCendamo.h"
  7. #include "mapHandler.h"
  8. #include "CDefObjInfoHandler.h"
  9. void CObjectHandler::loadObjects()
  10. {
  11. int ID=0;
  12. std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("OBJNAMES.TXT");
  13. int it=0;
  14. while (it<buf.length()-1)
  15. {
  16. CObject nobj;
  17. CGeneralTextHandler::loadToIt(nobj.name,buf,it,3);
  18. if(nobj.name.size() && (nobj.name[nobj.name.size()-1]==(char)10 || nobj.name[nobj.name.size()-1]==(char)13 || nobj.name[nobj.name.size()-1]==(char)9))
  19. nobj.name = nobj.name.substr(0, nobj.name.size()-1);
  20. objects.push_back(nobj);
  21. }
  22. }
  23. bool CObjectInstance::operator <(const CObjectInstance &cmp) const
  24. {
  25. if(CGI->ac->map.defy[this->defNumber].printPriority==1 && CGI->ac->map.defy[cmp.defNumber].printPriority==0)
  26. return true;
  27. if(CGI->ac->map.defy[cmp.defNumber].printPriority==1 && CGI->ac->map.defy[this->defNumber].printPriority==0)
  28. return false;
  29. if(this->pos.y<cmp.pos.y)
  30. return true;
  31. if(this->pos.y>cmp.pos.y)
  32. return false;
  33. if(CGI->ac->map.defy[this->defNumber].isOnDefList && !(CGI->ac->map.defy[cmp.defNumber].isOnDefList))
  34. return true;
  35. if(CGI->ac->map.defy[cmp.defNumber].isOnDefList && !(CGI->ac->map.defy[this->defNumber].isOnDefList))
  36. return false;
  37. if(!CGI->ac->map.defy[this->defNumber].isVisitable() && CGI->ac->map.defy[cmp.defNumber].isVisitable())
  38. return true;
  39. if(!CGI->ac->map.defy[cmp.defNumber].isVisitable() && CGI->ac->map.defy[this->defNumber].isVisitable())
  40. return false;
  41. if(this->pos.x<cmp.pos.x)
  42. return true;
  43. return false;
  44. }
  45. int CObjectInstance::getWidth() const
  46. {
  47. return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->w/32;
  48. }
  49. int CObjectInstance::getHeight() const
  50. {
  51. return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->h/32;
  52. }
  53. bool CObjectInstance::visitableAt(int x, int y) const
  54. {
  55. if(x<0 || y<0 || x>=getWidth() || y>=getHeight())
  56. return false;
  57. if((CGI->dobjinfo->objs[defObjInfoNumber].visitMap[y] >> (7-x)) & 1)
  58. return true;
  59. return false;
  60. }