Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automapper: fix wrong tile orientation and correctly handle border tiles #1190

Merged
merged 1 commit into from Feb 9, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/game/editor/auto_map.cpp
Expand Up @@ -133,16 +133,13 @@ void CTilesetMapper::Proceed(CLayerTiles *pLayer, int ConfigID)

pTile->m_Index = BaseTile;

if(y == 0 || y == pLayer->m_Height-1 || x == 0 || x == pLayer->m_Width-1)
continue;

for(int i = 0; i < pConf->m_aRules.size(); ++i)
{
bool RespectRules = true;
for(int j = 0; j < pConf->m_aRules[i].m_aConditions.size() && RespectRules; ++j)
{
CRuleCondition *pCondition = &pConf->m_aRules[i].m_aConditions[j];
int CheckIndex = (y+pCondition->m_Y)*pLayer->m_Width+(x+pCondition->m_X);
int CheckIndex = clamp((y+pCondition->m_Y), 0, pLayer->m_Height-1)*pLayer->m_Width+clamp((x+pCondition->m_X), 0, pLayer->m_Width-1);

if(CheckIndex < 0 || CheckIndex >= MaxIndex)
RespectRules = false;
Expand All @@ -167,6 +164,7 @@ void CTilesetMapper::Proceed(CLayerTiles *pLayer, int ConfigID)
if(RespectRules && (pConf->m_aRules[i].m_Random <= 1 || (int)((float)rand() / ((float)RAND_MAX + 1) * pConf->m_aRules[i].m_Random) == 1))
{
pTile->m_Index = pConf->m_aRules[i].m_Index;
pTile->m_Flags = 0;

// rotate
if(pConf->m_aRules[i].m_Rotation == 90)
Expand Down