mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-26 08:41:13 +02:00
c18e4573f1
* probably working getting visitable objects at certain position (to be tested)
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
#include "stdafx.h"
|
|
#include "CObjectHandler.h"
|
|
#include "../CGameInfo.h"
|
|
#include "CGeneralTextHandler.h"
|
|
#include "CLodHandler.h"
|
|
#include "CAmbarCendamo.h"
|
|
#include "mapHandler.h"
|
|
#include "CDefObjInfoHandler.h"
|
|
|
|
void CObjectHandler::loadObjects()
|
|
{
|
|
int ID=0;
|
|
std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("OBJNAMES.TXT");
|
|
int it=0;
|
|
while (it<buf.length()-1)
|
|
{
|
|
CObject nobj;
|
|
CGeneralTextHandler::loadToIt(nobj.name,buf,it,3);
|
|
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))
|
|
nobj.name = nobj.name.substr(0, nobj.name.size()-1);
|
|
objects.push_back(nobj);
|
|
}
|
|
}
|
|
|
|
bool CObjectInstance::operator <(const CObjectInstance &cmp) const
|
|
{
|
|
if(CGI->ac->map.defy[this->defNumber].printPriority==1 && CGI->ac->map.defy[cmp.defNumber].printPriority==0)
|
|
return true;
|
|
if(CGI->ac->map.defy[cmp.defNumber].printPriority==1 && CGI->ac->map.defy[this->defNumber].printPriority==0)
|
|
return false;
|
|
if(this->pos.y<cmp.pos.y)
|
|
return true;
|
|
if(this->pos.y>cmp.pos.y)
|
|
return false;
|
|
if(CGI->ac->map.defy[this->defNumber].isOnDefList && !(CGI->ac->map.defy[cmp.defNumber].isOnDefList))
|
|
return true;
|
|
if(CGI->ac->map.defy[cmp.defNumber].isOnDefList && !(CGI->ac->map.defy[this->defNumber].isOnDefList))
|
|
return false;
|
|
if(!CGI->ac->map.defy[this->defNumber].isVisitable() && CGI->ac->map.defy[cmp.defNumber].isVisitable())
|
|
return true;
|
|
if(!CGI->ac->map.defy[cmp.defNumber].isVisitable() && CGI->ac->map.defy[this->defNumber].isVisitable())
|
|
return false;
|
|
if(this->pos.x<cmp.pos.x)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
int CObjectInstance::getWidth() const
|
|
{
|
|
return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->w/32;
|
|
}
|
|
|
|
int CObjectInstance::getHeight() const
|
|
{
|
|
return CGI->mh->reader->map.defy[defNumber].handler->ourImages[0].bitmap->h/32;
|
|
}
|
|
|
|
bool CObjectInstance::visitableAt(int x, int y) const
|
|
{
|
|
if(x<0 || y<0 || x>=getWidth() || y>=getHeight())
|
|
return false;
|
|
if((CGI->dobjinfo->objs[defObjInfoNumber].visitMap[y] >> (7-x)) & 1)
|
|
return true;
|
|
return false;
|
|
}
|