mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-05-09 13:11:40 -04:00
split out some big functions from MapData .
This commit is contained in:
parent
98079e43d0
commit
6e0eb71f29
8 changed files with 689 additions and 601 deletions
|
@ -1416,7 +1416,9 @@ void CIsoView::OnMouseMove(UINT nFlags, CPoint point)
|
|||
|
||||
// if(abs(m_FlattenLastX-x)<2 && abs(m_FlattenLastY-y)<2) //ReachableFrom(x+y*Map->GetIsoSize(), m_mapx+m_mapy*Map->GetIsoSize()))
|
||||
int ground = Map->GetFielddataAt(x + (y)*Map->GetIsoSize())->wGround;
|
||||
if (ground == 0xFFFF) ground = 0;
|
||||
if (ground == 0xFFFF) {
|
||||
ground = 0;
|
||||
}
|
||||
|
||||
//if((*tiledata)[ground].bMorphable)
|
||||
{
|
||||
|
@ -1433,25 +1435,30 @@ void CIsoView::OnMouseMove(UINT nFlags, CPoint point)
|
|||
for (m = left; m < right; m++) {
|
||||
for (n = top; n < bottom; n++) {
|
||||
int pos = x + m + (y + n) * isosize;
|
||||
|
||||
int ground = Map->GetFielddataAt(pos)->wGround;
|
||||
if (ground == 0xFFFF) ground = 0;
|
||||
if (ground == 0xFFFF) {
|
||||
ground = 0;
|
||||
}
|
||||
/*int ground1=Map->GetFielddataAt(pos-m)->wGround;
|
||||
if(ground1==0xFFFF) ground=0;
|
||||
int ground2=Map->GetFielddataAt(pos-n*isosize)->wGround;
|
||||
if(ground2==0xFFFF) ground=0;*/
|
||||
|
||||
|
||||
|
||||
if (!(*tiledata)[ground].bMorphable) {
|
||||
|
||||
{
|
||||
if (n <= 0 /*&& !(*tiledata)[ground1].bMorphable*/) top = n + 1;
|
||||
if (m <= 0 /*&& !(*tiledata)[ground2].bMorphable*/) left = m + 1;
|
||||
if (n > 0 /*&& !(*tiledata)[ground1].bMorphable*/) bottom = n;
|
||||
if (m > 0 /*&& !(*tiledata)[ground2].bMorphable*/) right = m;
|
||||
if (n <= 0 /*&& !(*tiledata)[ground1].bMorphable*/) {
|
||||
top = n + 1;
|
||||
}
|
||||
if (m <= 0 /*&& !(*tiledata)[ground2].bMorphable*/) {
|
||||
left = m + 1;
|
||||
}
|
||||
if (n > 0 /*&& !(*tiledata)[ground1].bMorphable*/) {
|
||||
bottom = n;
|
||||
}
|
||||
if (m > 0 /*&& !(*tiledata)[ground2].bMorphable*/) {
|
||||
right = m;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (n < top) {
|
||||
|
@ -1473,32 +1480,25 @@ void CIsoView::OnMouseMove(UINT nFlags, CPoint point)
|
|||
for (m = left; m < right; m++) {
|
||||
for (n = top; n < bottom; n++) {
|
||||
int ground = Map->GetFielddataAt(x + m + (y + n) * Map->GetIsoSize())->wGround;
|
||||
if (ground == 0xFFFF) ground = 0;
|
||||
|
||||
|
||||
if (ground == 0xFFFF) {
|
||||
ground = 0;
|
||||
}
|
||||
|
||||
if ((*tiledata)[ground].bMorphable) {
|
||||
int i;
|
||||
int max = isosize * isosize;
|
||||
for (i = 0; i < max; i++)
|
||||
for (i = 0; i < max; i++) {
|
||||
Map->SetReserved(i, 0);
|
||||
|
||||
|
||||
}
|
||||
// do not make any slopes yet, we do this once we´re finished with the whole area!
|
||||
// helps to speed up performance!
|
||||
ChangeTileHeight(x + m + (y + n) * isosize, m_FlattenHeight, FALSE, FALSE, TRUE);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
if (n == 0 && m == 0)
|
||||
if (n == 0 && m == 0) {
|
||||
doNotSave = TRUE;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1507,9 +1507,11 @@ void CIsoView::OnMouseMove(UINT nFlags, CPoint point)
|
|||
*/
|
||||
ASSERT(m_funcRect.left <= m_funcRect.right);
|
||||
ASSERT(m_funcRect.top <= m_funcRect.bottom);
|
||||
for (m = m_funcRect.left - 1; m <= m_funcRect.right + 1; m++)
|
||||
for (n = m_funcRect.top - 1; n <= m_funcRect.bottom + 1; n++)
|
||||
for (m = m_funcRect.left - 1; m <= m_funcRect.right + 1; m++) {
|
||||
for (n = m_funcRect.top - 1; n <= m_funcRect.bottom + 1; n++) {
|
||||
Map->CreateSlopesAt(m + n * isosize);
|
||||
}
|
||||
}
|
||||
|
||||
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
|
||||
if (!doNotSave) {
|
||||
|
@ -4060,23 +4062,37 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
|
||||
//if(dwX==0 || dwY==0 || dwX+dwY<mapwidth || dwX+dwY>mapwidth+mapheight*2 || (dwY>mapwidth && dwX<dwY-mapwidth) || (dwX>mapwidth && dwY+mapwidth<dwX)) return;
|
||||
//if( dwX<2|| dwY<2 || dwX+dwY<mapwidth+2 || dwX+dwY+2>mapwidth+mapheight*2 || (dwY+2>mapwidth && dwX-2<dwY-mapwidth) || (dwX+2>mapwidth && dwY+mapwidth-2<dwX)) return;
|
||||
if (dwX < 1 || dwY < 1 || dwX + dwY<mapwidth + 1 || dwX + dwY>mapwidth + mapheight * 2 || (dwY + 1 > mapwidth && dwX - 1 < dwY - mapwidth) || (dwX + 1 > mapwidth && dwY + mapwidth - 1 < dwX)) return;
|
||||
|
||||
|
||||
if (dwX < 1 || dwY < 1 || dwX + dwY<mapwidth + 1 || dwX + dwY>mapwidth + mapheight * 2
|
||||
|| (dwY + 1 > mapwidth && dwX - 1 < dwY - mapwidth)
|
||||
|| (dwX + 1 > mapwidth && dwY + mapwidth - 1 < dwX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
FIELDDATA orig_fd = *Map->GetFielddataAt(dwPos);
|
||||
|
||||
//if(bOnlyHeighten && dwNewHeight<orig_fd.bHeight) return;
|
||||
|
||||
if (orig_fd.wGround == 0xFFFF) orig_fd.wGround = 0;
|
||||
if (orig_fd.wGround == 0xFFFF) {
|
||||
orig_fd.wGround = 0;
|
||||
}
|
||||
int orig_ground = orig_fd.wGround;
|
||||
|
||||
if (orig_fd.bReserved) return;
|
||||
if (orig_fd.bReserved) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dwX < m_funcRect.left) m_funcRect.left = dwX;
|
||||
if (dwY < m_funcRect.top) m_funcRect.top = dwY;
|
||||
if (dwX > m_funcRect.right) m_funcRect.right = dwX;
|
||||
if (dwY > m_funcRect.bottom) m_funcRect.bottom = dwY;
|
||||
if (dwX < m_funcRect.left) {
|
||||
m_funcRect.left = dwX;
|
||||
}
|
||||
if (dwY < m_funcRect.top) {
|
||||
m_funcRect.top = dwY;
|
||||
}
|
||||
if (dwX > m_funcRect.right) {
|
||||
m_funcRect.right = dwX;
|
||||
}
|
||||
if (dwY > m_funcRect.bottom) {
|
||||
m_funcRect.bottom = dwY;
|
||||
}
|
||||
|
||||
BOOL bCliffNext = FALSE;
|
||||
/*if(bOnlyHeighten)
|
||||
|
@ -4107,11 +4123,11 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
Map->SetReserved(dwPos, 1);
|
||||
|
||||
|
||||
if (!(*tiledata)[orig_ground].bMorphable) bNonMorpheableMove = TRUE;
|
||||
|
||||
if (!(*tiledata)[orig_ground].bMorphable) {
|
||||
bNonMorpheableMove = TRUE;
|
||||
}
|
||||
Map->SetHeightAt(dwPos, dwNewHeight);
|
||||
|
||||
|
||||
int i, e;
|
||||
for (i = -1; i < 2; i++) {
|
||||
for (e = -1; e < 2; e++) {
|
||||
|
@ -4119,20 +4135,25 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
int pos = dwPos + i + (e)*isosize;
|
||||
|
||||
FIELDDATA fd = *Map->GetFielddataAt(pos);
|
||||
if (fd.wGround == 0xFFFF) fd.wGround = 0;
|
||||
if (fd.wGround == 0xFFFF) {
|
||||
fd.wGround = 0;
|
||||
}
|
||||
|
||||
BOOL bAllowed = TRUE;
|
||||
|
||||
if (dwX == 0 && i == -1) bAllowed = FALSE;
|
||||
else if (dwY == 0 && e == -1) bAllowed = FALSE;
|
||||
else if (dwX == isosize - 1 && i == 1) bAllowed = FALSE;
|
||||
else if (dwY == isosize - 1 && e == 1) bAllowed = FALSE;
|
||||
|
||||
|
||||
if (dwX == 0 && i == -1) {
|
||||
bAllowed = FALSE;
|
||||
} else if (dwY == 0 && e == -1) {
|
||||
bAllowed = FALSE;
|
||||
} else if (dwX == isosize - 1 && i == 1) {
|
||||
bAllowed = FALSE;
|
||||
} else if (dwY == isosize - 1 && e == 1) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
if (bOnlyThisTile) {
|
||||
if (fd.wGround != orig_fd.wGround) bAllowed = FALSE; // was another tile
|
||||
|
||||
else {
|
||||
if (fd.wGround != orig_fd.wGround) {
|
||||
bAllowed = FALSE; // was another tile
|
||||
} else {
|
||||
// we now need to check if it is really the same tile or just the same tile type (!)
|
||||
int of = orig_fd.bSubTile;
|
||||
int f = fd.bSubTile;
|
||||
|
@ -4142,20 +4163,15 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
int oy = of % width;
|
||||
int x = f / width;
|
||||
int y = f % width;
|
||||
|
||||
if (x - ox != i || y - oy != e) bAllowed = FALSE;
|
||||
if (x - ox != i || y - oy != e) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ground = fd.wGround;
|
||||
|
||||
|
||||
if (bAllowed && !fd.bReserved && pos > 0 && pos < mapsize) {
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL bDestMorphable = (*tiledata)[fd.wGround].bMorphable;
|
||||
TILEDATA destTile = (*tiledata)[fd.wGround];
|
||||
TILEDATA sourceTile = (*tiledata)[orig_fd.wGround];
|
||||
|
@ -4164,50 +4180,62 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
if (e == 1 && i == 1) {
|
||||
int leftGround = Map->GetFielddataAt(dwPos + 1)->wGround;
|
||||
int rightGround = Map->GetFielddataAt(dwPos + isosize)->wGround;
|
||||
if (leftGround == 0xFFFF) leftGround = 0;
|
||||
if (rightGround == 0xFFFF) rightGround = 0;
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable)
|
||||
if (leftGround == 0xFFFF) {
|
||||
leftGround = 0;
|
||||
}
|
||||
if (rightGround == 0xFFFF) {
|
||||
rightGround = 0;
|
||||
}
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
}
|
||||
if (e == -1 && i == -1) {
|
||||
int leftGround = Map->GetFielddataAt(dwPos - 1)->wGround;
|
||||
int rightGround = Map->GetFielddataAt(dwPos - isosize)->wGround;
|
||||
if (leftGround == 0xFFFF) leftGround = 0;
|
||||
if (rightGround == 0xFFFF) rightGround = 0;
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable)
|
||||
if (leftGround == 0xFFFF) {
|
||||
leftGround = 0;
|
||||
}
|
||||
if (rightGround == 0xFFFF) {
|
||||
rightGround = 0;
|
||||
}
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
}
|
||||
if (e == -1 && i == 1) {
|
||||
int leftGround = Map->GetFielddataAt(dwPos - 1)->wGround;
|
||||
int rightGround = Map->GetFielddataAt(dwPos + isosize)->wGround;
|
||||
if (leftGround == 0xFFFF) leftGround = 0;
|
||||
if (rightGround == 0xFFFF) rightGround = 0;
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable)
|
||||
if (leftGround == 0xFFFF) {
|
||||
leftGround = 0;
|
||||
}
|
||||
if (rightGround == 0xFFFF) {
|
||||
rightGround = 0;
|
||||
}
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
}
|
||||
if (e == 1 && i == -1) {
|
||||
int leftGround = Map->GetFielddataAt(dwPos + 1)->wGround;
|
||||
int rightGround = Map->GetFielddataAt(dwPos - isosize)->wGround;
|
||||
if (leftGround == 0xFFFF) leftGround = 0;
|
||||
if (rightGround == 0xFFFF) rightGround = 0;
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable)
|
||||
if (leftGround == 0xFFFF) {
|
||||
leftGround = 0;
|
||||
}
|
||||
if (rightGround == 0xFFFF) {
|
||||
rightGround = 0;
|
||||
}
|
||||
if (!(*tiledata)[leftGround].bMorphable && !(*tiledata)[rightGround].bMorphable) {
|
||||
bAllowed = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (/*(*tiledata)[ground].bMorphable &&*/ bAllowed) {
|
||||
int need_diff = (*tiledata)[ground].tiles[fd.bSubTile].bZHeight - (*tiledata)[orig_ground].tiles[orig_fd.bSubTile].bZHeight;
|
||||
|
||||
|
||||
//if(Map->GetHeightAt(pos)-dwNewHeight!=need_diff || !bNonMorpheableMove)
|
||||
{
|
||||
int diff = fd.bHeight - dwNewHeight;
|
||||
|
||||
/*
|
||||
Activate this code to use the huge slopes
|
||||
Removed because it did look worse than the normal slopes
|
||||
|
@ -4218,15 +4246,15 @@ void __fastcall CIsoView::ChangeTileHeight(DWORD dwPos, DWORD dwNewHeight, BOOL
|
|||
if(diff<-1) diff++;
|
||||
if(diff>1) diff--;
|
||||
}*/
|
||||
|
||||
|
||||
if (!bNonMorpheableMove && bDestMorphable) {
|
||||
//if(!bOnlyHeighten)//!bCliffNext)
|
||||
{
|
||||
if (diff < -1)
|
||||
if (diff < -1) {
|
||||
ChangeTileHeight(pos, dwNewHeight - 1, bNonMorpheableMove, bOnlyThisTile, bNoSlopes);
|
||||
if (diff > 1)
|
||||
}
|
||||
if (diff > 1) {
|
||||
ChangeTileHeight(pos, dwNewHeight + 1, bNonMorpheableMove, bOnlyThisTile, bNoSlopes);
|
||||
}
|
||||
}
|
||||
/*else
|
||||
{
|
||||
|
|
|
@ -24,13 +24,21 @@
|
|||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "structs.h"
|
||||
#if !defined(AFX_MAP_H__9278CAC0_D4E7_11D3_B63B_444553540001__INCLUDED_)
|
||||
#define AFX_MAP_H__9278CAC0_D4E7_11D3_B63B_444553540001__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "structs.h"
|
||||
#include "variables.h"
|
||||
#include "macros.h"
|
||||
#include "ovrlinline.h"
|
||||
#include "Tube.h"
|
||||
|
||||
#include "IniFile.h" // Hinzugefügt von der Klassenansicht
|
||||
|
||||
extern TILEDATA** tiledata;
|
||||
extern DWORD* tiledata_count;
|
||||
|
@ -54,15 +62,6 @@ extern int rampset;
|
|||
|
||||
|
||||
|
||||
#if !defined(AFX_MAP_H__9278CAC0_D4E7_11D3_B63B_444553540001__INCLUDED_)
|
||||
#define AFX_MAP_H__9278CAC0_D4E7_11D3_B63B_444553540001__INCLUDED_
|
||||
|
||||
#include "IniFile.h" // Hinzugefügt von der Klassenansicht
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <array>
|
||||
|
||||
#define MAPDATA_UPDATE_FROM_INI 0
|
||||
#define MAPDATA_UPDATE_TO_INI 1
|
||||
#define MAPDATA_UPDATE_TO_INI_ALL 2
|
||||
|
@ -181,160 +180,13 @@ public:
|
|||
void SetReserved(DWORD dwPos, BYTE val);
|
||||
DWORD GetTileID(DWORD dwTileSet, int iTile);
|
||||
int GetNecessarySlope(DWORD dwPos);
|
||||
void CreateSlopesAt(DWORD dwPos)
|
||||
{
|
||||
//OutputDebugString("CreateSlopes()\n");
|
||||
|
||||
FIELDDATA m = *GetFielddataAt(dwPos);
|
||||
if (m.wGround == 0xFFFF) m.wGround = 0;
|
||||
|
||||
TILEDATA& d = (*tiledata)[m.wGround];
|
||||
|
||||
int ns = -1;
|
||||
int i, e, p = 0;
|
||||
int h[3][3];
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (e = 0; e < 3; e++) {
|
||||
int pos = dwPos + (i - 1) + (e - 1) * m_IsoSize;
|
||||
if (pos < 0 || pos >= m_IsoSize * m_IsoSize) {
|
||||
h[i][e] = 0;
|
||||
} else {
|
||||
FIELDDATA m2 = *GetFielddataAt(pos);
|
||||
|
||||
h[i][e] = m.bHeight - m2.bHeight;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// check if the current tile must be heightened anyway
|
||||
if (!theApp.m_Options.bDisableSlopeCorrection && d.bMorphable) {
|
||||
if ((h[0][1] < 0 && h[2][1] < 0) || (h[1][0] < 0 && h[1][2] < 0)
|
||||
|
||||
|| (h[1][0] < 0 && h[0][2] < 0 && h[0][1] >= 0)
|
||||
|| (h[1][0] < 0 && h[2][2] < 0 && h[2][1] >= 0)
|
||||
|
||||
|| (h[0][1] < 0 && h[2][0] < 0 && h[1][0] >= 0)
|
||||
|| (h[0][1] < 0 && h[2][2] < 0 && h[1][2] >= 0)
|
||||
|
||||
|| (h[1][2] < 0 && h[0][0] < 0 && h[0][1] >= 0)
|
||||
|| (h[1][2] < 0 && h[2][0] < 0 && h[2][1] >= 0)
|
||||
|
||||
|| (h[2][1] < 0 && h[0][0] < 0 && h[1][0] >= 0)
|
||||
|| (h[2][1] < 0 && h[0][2] < 0 && h[1][2] >= 0)
|
||||
|
||||
|| (h[1][0] < 0 && h[0][1] < 0 && h[0][0] >= 0)
|
||||
|| (h[0][1] < 0 && h[1][2] < 0 && h[0][2] >= 0)
|
||||
|| (h[1][2] < 0 && h[2][1] < 0 && h[2][2] >= 0)
|
||||
|| (h[2][1] < 0 && h[1][0] < 0 && h[2][0] >= 0)
|
||||
|
||||
) {
|
||||
SetHeightAt(dwPos, m.bHeight + 1);
|
||||
for (i = -1; i < 2; i++)
|
||||
for (e = -1; e < 2; e++)
|
||||
CreateSlopesAt(dwPos + i + e * m_IsoSize);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL checkOtherSlopes = FALSE;
|
||||
|
||||
|
||||
if (h[0][0] == -1 && h[2][2] == -1 && h[2][0] >= 0 && h[0][2] >= 0 && h[1][0] >= 0 && h[1][2] >= 0 && h[0][1] >= 0 && h[2][1] >= 0) ns = SLOPE_UP_LEFTTOP_AND_RIGHTBOTTOM;
|
||||
if (h[0][2] == -1 && h[2][0] == -1 && h[0][0] >= 0 && h[2][2] >= 0 && h[0][1] >= 0 && h[1][0] >= 0 && h[1][2] >= 0 && h[2][1] >= 0) ns = SLOPE_UP_LEFTBOTTOM_AND_RIGHTTOP;
|
||||
|
||||
|
||||
|
||||
|
||||
if (ns == -1)
|
||||
if (h[1][0] == -1 && h[0][1] != -1 && h[1][2] != -1 && h[2][1] != -1) {
|
||||
ns = SLOPE_UP_LEFT;
|
||||
} else if (h[0][1] == -1 && h[1][0] != -1 && h[2][1] != -1 && h[1][2] != -1) {
|
||||
ns = SLOPE_UP_TOP;
|
||||
} else if (h[1][2] == -1 && h[0][1] != -1 && h[1][0] != -1 && h[2][1] != -1) {
|
||||
ns = SLOPE_UP_RIGHT;
|
||||
} else if (h[2][1] == -1 && h[0][1] != -1 && h[1][0] != -1 && h[1][2] != -1) {
|
||||
ns = SLOPE_UP_BOTTOM;
|
||||
}
|
||||
|
||||
if (ns == -1) {
|
||||
if (h[0][0] == -2) ns = SLOPE_DOWN_BOTTOM;
|
||||
if (h[2][0] == -2) ns = SLOPE_DOWN_RIGHT;
|
||||
if (h[0][2] == -2) ns = SLOPE_DOWN_LEFT;
|
||||
if (h[2][2] == -2) ns = SLOPE_DOWN_TOP;
|
||||
}
|
||||
|
||||
if (ns == -1 && h[0][0] == -1) {
|
||||
if (h[1][0] == -1 && h[0][1] == -1) ns = SLOPE_DOWN_RIGHTBOTTOM;
|
||||
else if (h[1][0] == 0 && h[0][1] == 0) ns = SLOPE_UP_LEFTTOP;
|
||||
//else if(h[2][2]==1) ns=SLOPE_DOWN_BOTTOM;
|
||||
}
|
||||
|
||||
if (ns == -1 && h[2][0] == -1) {
|
||||
if (h[1][0] == -1 && h[2][1] == -1) ns = SLOPE_DOWN_RIGHTTOP;
|
||||
else if (h[1][0] == 0 && h[2][1] == 0) ns = SLOPE_UP_LEFTBOTTOM;
|
||||
//else if(h[0][2]==1) ns=SLOPE_DOWN_RIGHT;
|
||||
}
|
||||
if (ns == -1 && h[0][2] == -1) {
|
||||
if (h[1][2] == -1 && h[0][1] == -1) ns = SLOPE_DOWN_LEFTBOTTOM;
|
||||
else if (h[1][2] == 0 && h[0][1] == 0) ns = SLOPE_UP_RIGHTTOP;
|
||||
//else if(h[2][0]==1) ns=SLOPE_DOWN_LEFT;
|
||||
}
|
||||
if (ns == -1 && h[2][2] == -1) {
|
||||
if (h[1][2] == -1 && h[2][1] == -1) ns = SLOPE_DOWN_LEFTTOP;
|
||||
else if (h[1][2] == 0 && h[2][1] == 0) ns = SLOPE_UP_RIGHTBOTTOM;
|
||||
//else if(h[0][0]==1) ns=SLOPE_DOWN_TOP;
|
||||
}
|
||||
|
||||
if (ns == -1 && h[1][0] == -1 && h[2][1] == -1) ns = SLOPE_DOWN_RIGHTTOP;
|
||||
if (ns == -1 && h[1][2] == -1 && h[2][1] == -1) ns = SLOPE_DOWN_LEFTTOP;
|
||||
if (ns == -1 && h[1][0] == -1 && h[0][1] == -1) ns = SLOPE_DOWN_RIGHTBOTTOM;
|
||||
if (ns == -1 && h[1][2] == -1 && h[0][1] == -1) ns = SLOPE_DOWN_LEFTBOTTOM;
|
||||
|
||||
|
||||
int rampbase = rampset_start;//atoi((*tiles).sections["General"].values["RampBase"]);
|
||||
int rampsmooth = tiles->GetInteger("General", "RampSmooth");
|
||||
|
||||
if (ns == -1 && (d.wTileSet == rampset || d.wTileSet == rampsmooth) && d.bMorphable) {
|
||||
SetTileAt(dwPos, 0, 0);
|
||||
}
|
||||
if (tiledata == &un_tiledata) {
|
||||
int r = ramp2set;
|
||||
int m = pave2set;
|
||||
|
||||
if (ns == -1 && (d.wTileSet == r || d.wTileSet == m) && d.bMorphable) {
|
||||
SetTileAt(dwPos, pave2set_start/*GetTileID(m,0)*/, 0);
|
||||
}
|
||||
}
|
||||
if (d.bMorphable && ns != -1) {
|
||||
if (tiledata == &un_tiledata) // NEW URBAN FIX FOR URBAN PAVEMENT
|
||||
{
|
||||
|
||||
//[NewUrbanInfo]
|
||||
//Morphable2=114
|
||||
//Ramps2=117
|
||||
int r = ramp2set;
|
||||
int m = pave2set;
|
||||
if (d.wTileSet == r || d.wTileSet == m)
|
||||
rampbase = ramp2set_start;
|
||||
|
||||
|
||||
}
|
||||
|
||||
SetTileAt(dwPos, rampbase + ns - 1, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CreateSlopesAt(DWORD dwPos);
|
||||
void CreateMap(DWORD dwWidth, DWORD dwHeight, LPCTSTR lpTerrainType, DWORD dwGroundHeight);
|
||||
BOOL SetTileAt(DWORD dwPos, DWORD dwID, DWORD dwTile)
|
||||
{
|
||||
if (dwPos > fielddata_size) return FALSE;
|
||||
if (dwPos > fielddata_size) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int replacement = 0; // MW fix: ignore for bridges
|
||||
if ((*tiledata)[dwID].bReplacementCount && tiles->GetInteger("General", "BridgeSet") != (*tiledata)[dwID].wTileSet) {
|
||||
|
@ -356,7 +208,9 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (fielddata[dwPos].bRedrawTerrain) break;
|
||||
if (fielddata[dwPos].bRedrawTerrain) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Mini_UpdatePos(dwPos % m_IsoSize, dwPos / m_IsoSize, IsMultiplayer());
|
||||
|
@ -737,187 +591,8 @@ protected:
|
|||
}
|
||||
|
||||
|
||||
__forceinline void Mini_UpdatePos(const int i, const int e, bool isMultiplayer)
|
||||
{
|
||||
const int pwidth = m_mini_biinfo.bmiHeader.biWidth;
|
||||
const int pheight = m_mini_biinfo.bmiHeader.biHeight;
|
||||
|
||||
if (m_mini_colors.empty() || !tiledata)
|
||||
return;
|
||||
|
||||
|
||||
const DWORD dwIsoSize = m_IsoSize;
|
||||
const int pitch = m_mini_pitch;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetMiniMapPos(i, e, x, y);
|
||||
y = pheight - y - 1;
|
||||
|
||||
int xiso = i;
|
||||
int yiso = e;
|
||||
|
||||
if (xiso >= m_IsoSize)
|
||||
xiso = m_IsoSize - 1;
|
||||
if (yiso >= m_IsoSize)
|
||||
yiso = m_IsoSize - 1;
|
||||
if (xiso < 0)
|
||||
xiso = 0;
|
||||
if (yiso < 0)
|
||||
yiso = 0;
|
||||
|
||||
DWORD dwPos = xiso + yiso * dwIsoSize;
|
||||
|
||||
int dwDrawPos = (x * 3 + y * pitch);
|
||||
|
||||
int size = pitch * pheight;
|
||||
|
||||
if (dwDrawPos >= size || x >= pwidth || y >= pheight || x < 0 || y < 0) return;
|
||||
if (dwPos >= m_IsoSize * m_IsoSize) return;
|
||||
if (dwDrawPos + 3 >= m_mini_colors.size()) return;
|
||||
|
||||
RGBTRIPLE& col = (RGBTRIPLE&)m_mini_colors[dwDrawPos];
|
||||
RGBTRIPLE& col_r = (RGBTRIPLE&)m_mini_colors[(dwDrawPos + sizeof(RGBTRIPLE)) < size ? dwDrawPos + sizeof(RGBTRIPLE) : dwDrawPos];
|
||||
|
||||
|
||||
FIELDDATA td;
|
||||
td = *GetFielddataAt(dwPos);
|
||||
|
||||
|
||||
|
||||
STDOBJECTDATA sod;
|
||||
sod.house = "";
|
||||
int ic;
|
||||
for (ic = 0; ic < SUBPOS_COUNT; ic++) {
|
||||
if (td.infantry[ic] >= 0) {
|
||||
GetStdInfantryData(td.infantry[ic], &sod);
|
||||
}
|
||||
}
|
||||
if (td.structure >= 0) {
|
||||
GetStdStructureData(td.structure, &sod);
|
||||
}
|
||||
if (td.aircraft >= 0) {
|
||||
GetStdAircraftData(td.aircraft, &sod);
|
||||
}
|
||||
if (td.unit >= 0) {
|
||||
GetStdUnitData(td.unit, &sod);
|
||||
}
|
||||
|
||||
|
||||
int ground = (td.wGround >= (*tiledata_count)) ? 0 : td.wGround;
|
||||
int subt = td.bSubTile;
|
||||
int ttype = 0;
|
||||
if (subt < (*tiledata)[ground].wTileCount) ttype = (*tiledata)[ground].tiles[subt].bTerrainType;
|
||||
|
||||
|
||||
// mw added check:
|
||||
if (subt >= (*tiledata)[ground].wTileCount) return;
|
||||
|
||||
RGBTRIPLE& l = (*tiledata)[ground].tiles[subt].rgbLeft;
|
||||
RGBTRIPLE& r = (*tiledata)[ground].tiles[subt].rgbRight;
|
||||
|
||||
int pos = GetHeightAt(dwPos);
|
||||
|
||||
col.rgbtBlue = l.rgbtBlue;
|
||||
col.rgbtGreen = l.rgbtGreen;
|
||||
col.rgbtRed = l.rgbtRed;
|
||||
col_r.rgbtBlue = r.rgbtBlue;
|
||||
col_r.rgbtGreen = r.rgbtGreen;
|
||||
col_r.rgbtRed = r.rgbtRed;
|
||||
|
||||
if (isGreenTiberium(td.overlay)) {
|
||||
#ifndef RA2_MODE
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 200;
|
||||
col.rgbtRed = 0;
|
||||
col_r = col;
|
||||
#else
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 250;
|
||||
col.rgbtRed = 250;
|
||||
col_r = col;
|
||||
#endif
|
||||
} else if (td.overlay == OVRL_VEINS) {
|
||||
col.rgbtBlue = 120;
|
||||
col.rgbtGreen = 180;
|
||||
col.rgbtRed = 190;
|
||||
col_r = col;
|
||||
} else if (td.overlay == OVRL_VEINHOLE || td.overlay == OVRL_VEINHOLEBORDER) {
|
||||
col.rgbtBlue = 120;
|
||||
col.rgbtGreen = 160;
|
||||
col.rgbtRed = 165;
|
||||
col_r = col;
|
||||
} else if (td.overlay != 0xFF) {
|
||||
col.rgbtBlue = 20;
|
||||
col.rgbtGreen = 20;
|
||||
col.rgbtRed = 20;
|
||||
col_r = col;
|
||||
}
|
||||
|
||||
|
||||
if (sod.house.GetLength() > 0) {
|
||||
/*
|
||||
if(strstr(sod.house, houses[1].name))
|
||||
{
|
||||
col.rgbtRed=255;
|
||||
col.rgbtGreen=0;
|
||||
col.rgbtBlue=0;
|
||||
}
|
||||
else if(strstr(sod.house,houses[0].name))
|
||||
{
|
||||
col.rgbtRed=180;
|
||||
col.rgbtGreen=180;
|
||||
col.rgbtBlue=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.rgbtRed=200;
|
||||
col.rgbtGreen=200;
|
||||
col.rgbtBlue=200;
|
||||
}*/
|
||||
COLORREF c = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->GetColor(sod.house);
|
||||
|
||||
col.rgbtRed = GetRValue(c);
|
||||
col.rgbtBlue = GetBValue(c);
|
||||
col.rgbtGreen = GetGValue(c);
|
||||
col_r = col;
|
||||
}
|
||||
|
||||
// MW: ADD: make red start pos dots
|
||||
if (isMultiplayer) {
|
||||
CString id;
|
||||
DWORD p;
|
||||
int wp = td.waypoint;
|
||||
BOOL startpos = FALSE;
|
||||
int i, e;
|
||||
for (i = -1; i < 2; i++) {
|
||||
for (e = -1; e < 2; e++) {
|
||||
if (dwPos + i + e * m_IsoSize < fielddata_size) {
|
||||
int w = GetWaypointAt(dwPos + i + e * m_IsoSize);
|
||||
if (w >= 0) {
|
||||
GetWaypointData(w, &id, &p);
|
||||
if (atoi(id) < 8) {
|
||||
startpos = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (startpos) break;
|
||||
}
|
||||
if (startpos) {
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 0;
|
||||
col.rgbtRed = 255;
|
||||
col_r = col;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Mini_UpdatePos(const int i, const int e, bool isMultiplayer);
|
||||
|
||||
// helper function. Is val==iSet1 or val=iSet2?
|
||||
__forceinline BOOL st(int val, int iSet)
|
||||
{
|
||||
|
@ -957,182 +632,7 @@ public:
|
|||
void Redo();
|
||||
void SmoothAllAt(DWORD dwPos);
|
||||
|
||||
__forceinline void SmoothAt(DWORD dwPos, int iSmoothSet, int iLatSet, int iTargetSet, BOOL bIgnoreShore = TRUE)
|
||||
{
|
||||
int i;
|
||||
int its, iss, ils;
|
||||
int iLatGround = tilesets_start[iLatSet];
|
||||
int iSmoothGround = tilesets_start[iSmoothSet];
|
||||
its = (*tiledata)[tilesets_start[iTargetSet]].tiles[0].bTerrainType;
|
||||
iss = (*tiledata)[iSmoothGround].tiles[0].bTerrainType;
|
||||
ils = (*tiledata)[iLatGround].tiles[0].bTerrainType;
|
||||
|
||||
|
||||
|
||||
FIELDDATA m = *GetFielddataAt(dwPos);
|
||||
if (m.wGround == 0xFFFF) m.wGround = 0;
|
||||
|
||||
// do we have that certain LAT tile here?
|
||||
if ((*tiledata)[m.wGround].wTileSet != iSmoothSet && (*tiledata)[m.wGround].wTileSet != iLatSet) return;
|
||||
|
||||
//if(m.wGround==iLatGround) m.wGround=iSmoothGround;
|
||||
|
||||
if (its == iss && (*tiledata)[m.wGround].wTileSet == iSmoothSet) m.wGround = iLatGround;
|
||||
|
||||
if (its == iss) ils += 1;
|
||||
|
||||
BOOL bOnlyLat = TRUE;
|
||||
//BOOL bNoLat=TRUE;
|
||||
int ns = -1;
|
||||
int e, p = 0;
|
||||
int ts[3][3]; // terrain info
|
||||
|
||||
int set = (*tiledata)[m.wGround].wTileSet;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (e = 0; e < 3; e++) {
|
||||
int pos = dwPos + (i - 1) + (e - 1) * m_IsoSize;
|
||||
if (pos < 0 || pos >= fielddata_size) {
|
||||
ts[i][e] = 0;
|
||||
} else {
|
||||
FIELDDATA m2 = *GetFielddataAt(pos);
|
||||
if (m2.wGround == 0xFFFF) m2.wGround = 0;
|
||||
|
||||
int cur_set = (*tiledata)[m2.wGround].wTileSet;
|
||||
|
||||
//if(cur_set==iSmoothSet) bNoLat=FALSE;
|
||||
//
|
||||
|
||||
if (its == iss && cur_set == iSmoothSet) {
|
||||
m2.wGround = iLatGround; cur_set = iLatSet;
|
||||
}
|
||||
|
||||
if (cur_set == iSmoothSet || cur_set == iTargetSet) bOnlyLat = FALSE;
|
||||
|
||||
/*if(cur_set != iSmoothSet && cur_set!= iLatSet && cur_set!=iTargetSet)
|
||||
{
|
||||
ts[i][e]=(*tiledata)[m2.wGround].tiles[m2.bSubTile].bTerrainType;
|
||||
if((*tiledata)[m2.wGround].wTileSet!=shoreset)
|
||||
{
|
||||
ts[i][e]=0;//ts[i][e]+1; // make sure you don´t smooth at it except it´s shore
|
||||
}
|
||||
//if(bIgnoreShore && (*tiledata)[m2.wGround].wTileSet==shoreset)
|
||||
// ts[i][e]=0;//ts[i][e]+1;
|
||||
}
|
||||
else*/ if (its == iss && cur_set != set) {
|
||||
if (cur_set == shoreset && !bIgnoreShore)
|
||||
ts[i][e] = its;
|
||||
else if (cur_set != iSmoothSet && cur_set != iTargetSet && cur_set != iLatSet)
|
||||
ts[i][e] = 0;
|
||||
else
|
||||
ts[i][e] = its;
|
||||
} else if (its == iss && cur_set == set)
|
||||
ts[i][e] = ils;
|
||||
else {
|
||||
ts[i][e] = (*tiledata)[m2.wGround].tiles[m2.bSubTile].bTerrainType;
|
||||
|
||||
if (cur_set != shoreset && cur_set != iLatSet && cur_set != iSmoothSet) {
|
||||
ts[i][e] = 0;//ts[i][e]+1; // make sure you don´t smooth at it except it´s shore
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if(bOnlyLat) return;
|
||||
|
||||
|
||||
int needed = -1;
|
||||
|
||||
// 1/1 is smoothed tile
|
||||
|
||||
if (ts[1][1] == ils) {
|
||||
// single lat
|
||||
if (ts[0][1] != ils && ts[1][0] != ils
|
||||
&& ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 16;
|
||||
else if (ts[0][1] == ils && ts[1][0] == ils
|
||||
&& ts[1][2] == ils && ts[2][1] == ils)
|
||||
needed = 0;
|
||||
else if (ts[0][1] == ils && ts[2][1] == ils &&
|
||||
ts[1][0] != ils && ts[1][2] != ils)
|
||||
needed = 11;
|
||||
else if (ts[1][0] == ils && ts[1][2] == ils &&
|
||||
ts[0][1] != ils && ts[2][1] != ils)
|
||||
needed = 6;
|
||||
else if (ts[1][0] != ils && ts[0][1] == ils &&
|
||||
ts[2][1] == ils)
|
||||
needed = 9;
|
||||
else if (ts[2][1] != ils && ts[1][0] == ils &&
|
||||
ts[1][2] == ils)
|
||||
needed = 5;
|
||||
else if (ts[1][2] != ils && ts[0][1] == ils &&
|
||||
ts[2][1] == ils)
|
||||
needed = 3;
|
||||
else if (ts[0][1] != ils && ts[1][0] == ils &&
|
||||
ts[1][2] == ils)
|
||||
needed = 2;
|
||||
else if (ts[0][1] == ils && ts[1][0] != ils &&
|
||||
ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 15;
|
||||
else if (ts[1][2] == ils && ts[1][0] != ils &&
|
||||
ts[0][1] != ils && ts[2][1] != ils)
|
||||
needed = 14;
|
||||
else if (ts[2][1] == ils && ts[1][0] != ils &&
|
||||
ts[0][1] != ils && ts[1][2] != ils)
|
||||
needed = 12;
|
||||
else if (ts[1][0] == ils && ts[0][1] != ils &&
|
||||
ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 8;
|
||||
else if (ts[1][0] != ils && ts[2][1] != ils)
|
||||
needed = 13;
|
||||
else if (ts[1][0] != ils && ts[0][1] != ils)
|
||||
needed = 10;
|
||||
else if (ts[2][1] != ils && ts[1][2] != ils)
|
||||
needed = 7;
|
||||
else if (ts[0][1] != ils && ts[1][2] != ils)
|
||||
needed = 4;
|
||||
|
||||
|
||||
} else if (ts[1][1] == its) {
|
||||
// replace target set instead of smooth set
|
||||
//if(st(ts[0][0], && ts[0][1]
|
||||
}
|
||||
|
||||
|
||||
needed -= 1;
|
||||
if (needed >= 0) {
|
||||
/*for(i=0;i<*tiledata_count;i++)
|
||||
{
|
||||
if((*tiledata)[i].wTileSet==iLatSet)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
i = tilesets_start[iLatSet];
|
||||
|
||||
// i is first lat tile
|
||||
int e;
|
||||
for (e = 0; e < needed; e++) {
|
||||
i += (*tiledata)[i].wTileCount;
|
||||
}
|
||||
|
||||
SetTileAt(dwPos, i, 0);
|
||||
} else if (needed == -1) {
|
||||
/*for(i=0;i<*tiledata_count;i++)
|
||||
{
|
||||
if((*tiledata)[i].wTileSet==iSmoothSet)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
i = tilesets_start[iSmoothSet];
|
||||
|
||||
// i is first lat tile
|
||||
SetTileAt(dwPos, i, 0);
|
||||
}
|
||||
}
|
||||
void SmoothAt(DWORD dwPos, int iSmoothSet, int iLatSet, int iTargetSet, BOOL bIgnoreShore = TRUE);
|
||||
|
||||
BOOL GetLocalSize(RECT* rect) const;
|
||||
void Undo();
|
||||
|
|
189
MissionEditor/MapOperationMiniMap.cpp
Normal file
189
MissionEditor/MapOperationMiniMap.cpp
Normal file
|
@ -0,0 +1,189 @@
|
|||
#include "stdafx.h"
|
||||
#include "MapData.h"
|
||||
|
||||
void CMapData::Mini_UpdatePos(const int i, const int e, bool isMultiplayer)
|
||||
{
|
||||
const int pwidth = m_mini_biinfo.bmiHeader.biWidth;
|
||||
const int pheight = m_mini_biinfo.bmiHeader.biHeight;
|
||||
|
||||
if (m_mini_colors.empty() || !tiledata) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const DWORD dwIsoSize = m_IsoSize;
|
||||
const int pitch = m_mini_pitch;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetMiniMapPos(i, e, x, y);
|
||||
y = pheight - y - 1;
|
||||
|
||||
int xiso = i;
|
||||
int yiso = e;
|
||||
|
||||
if (xiso >= m_IsoSize)
|
||||
xiso = m_IsoSize - 1;
|
||||
if (yiso >= m_IsoSize)
|
||||
yiso = m_IsoSize - 1;
|
||||
if (xiso < 0)
|
||||
xiso = 0;
|
||||
if (yiso < 0)
|
||||
yiso = 0;
|
||||
|
||||
DWORD dwPos = xiso + yiso * dwIsoSize;
|
||||
|
||||
int dwDrawPos = (x * 3 + y * pitch);
|
||||
|
||||
int size = pitch * pheight;
|
||||
|
||||
if (dwDrawPos >= size || x >= pwidth || y >= pheight || x < 0 || y < 0) {
|
||||
return;
|
||||
}
|
||||
if (dwPos >= m_IsoSize * m_IsoSize) {
|
||||
return;
|
||||
}
|
||||
if (dwDrawPos + 3 >= m_mini_colors.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RGBTRIPLE& col = (RGBTRIPLE&)m_mini_colors[dwDrawPos];
|
||||
RGBTRIPLE& col_r = (RGBTRIPLE&)m_mini_colors[(dwDrawPos + sizeof(RGBTRIPLE)) < size ? dwDrawPos + sizeof(RGBTRIPLE) : dwDrawPos];
|
||||
|
||||
|
||||
FIELDDATA td;
|
||||
td = *GetFielddataAt(dwPos);
|
||||
|
||||
STDOBJECTDATA sod;
|
||||
sod.house = "";
|
||||
int ic;
|
||||
for (ic = 0; ic < SUBPOS_COUNT; ic++) {
|
||||
if (td.infantry[ic] >= 0) {
|
||||
GetStdInfantryData(td.infantry[ic], &sod);
|
||||
}
|
||||
}
|
||||
if (td.structure >= 0) {
|
||||
GetStdStructureData(td.structure, &sod);
|
||||
}
|
||||
if (td.aircraft >= 0) {
|
||||
GetStdAircraftData(td.aircraft, &sod);
|
||||
}
|
||||
if (td.unit >= 0) {
|
||||
GetStdUnitData(td.unit, &sod);
|
||||
}
|
||||
|
||||
int ground = (td.wGround >= (*tiledata_count)) ? 0 : td.wGround;
|
||||
int subt = td.bSubTile;
|
||||
int ttype = 0;
|
||||
|
||||
if (subt < (*tiledata)[ground].wTileCount) {
|
||||
ttype = (*tiledata)[ground].tiles[subt].bTerrainType;
|
||||
}
|
||||
|
||||
// mw added check:
|
||||
if (subt >= (*tiledata)[ground].wTileCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
RGBTRIPLE& l = (*tiledata)[ground].tiles[subt].rgbLeft;
|
||||
RGBTRIPLE& r = (*tiledata)[ground].tiles[subt].rgbRight;
|
||||
|
||||
int pos = GetHeightAt(dwPos);
|
||||
|
||||
col.rgbtBlue = l.rgbtBlue;
|
||||
col.rgbtGreen = l.rgbtGreen;
|
||||
col.rgbtRed = l.rgbtRed;
|
||||
col_r.rgbtBlue = r.rgbtBlue;
|
||||
col_r.rgbtGreen = r.rgbtGreen;
|
||||
col_r.rgbtRed = r.rgbtRed;
|
||||
|
||||
if (isGreenTiberium(td.overlay)) {
|
||||
#ifndef RA2_MODE
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 200;
|
||||
col.rgbtRed = 0;
|
||||
col_r = col;
|
||||
#else
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 250;
|
||||
col.rgbtRed = 250;
|
||||
col_r = col;
|
||||
#endif
|
||||
} else if (td.overlay == OVRL_VEINS) {
|
||||
col.rgbtBlue = 120;
|
||||
col.rgbtGreen = 180;
|
||||
col.rgbtRed = 190;
|
||||
col_r = col;
|
||||
} else if (td.overlay == OVRL_VEINHOLE || td.overlay == OVRL_VEINHOLEBORDER) {
|
||||
col.rgbtBlue = 120;
|
||||
col.rgbtGreen = 160;
|
||||
col.rgbtRed = 165;
|
||||
col_r = col;
|
||||
} else if (td.overlay != 0xFF) {
|
||||
col.rgbtBlue = 20;
|
||||
col.rgbtGreen = 20;
|
||||
col.rgbtRed = 20;
|
||||
col_r = col;
|
||||
}
|
||||
|
||||
|
||||
if (sod.house.GetLength() > 0) {
|
||||
/*
|
||||
if(strstr(sod.house, houses[1].name))
|
||||
{
|
||||
col.rgbtRed=255;
|
||||
col.rgbtGreen=0;
|
||||
col.rgbtBlue=0;
|
||||
}
|
||||
else if(strstr(sod.house,houses[0].name))
|
||||
{
|
||||
col.rgbtRed=180;
|
||||
col.rgbtGreen=180;
|
||||
col.rgbtBlue=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.rgbtRed=200;
|
||||
col.rgbtGreen=200;
|
||||
col.rgbtBlue=200;
|
||||
}*/
|
||||
COLORREF c = ((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview->GetColor(sod.house);
|
||||
|
||||
col.rgbtRed = GetRValue(c);
|
||||
col.rgbtBlue = GetBValue(c);
|
||||
col.rgbtGreen = GetGValue(c);
|
||||
col_r = col;
|
||||
}
|
||||
|
||||
// MW: ADD: make red start pos dots
|
||||
if (isMultiplayer) {
|
||||
CString id;
|
||||
DWORD p;
|
||||
int wp = td.waypoint;
|
||||
BOOL startpos = FALSE;
|
||||
int i, e;
|
||||
for (i = -1; i < 2; i++) {
|
||||
for (e = -1; e < 2; e++) {
|
||||
if (dwPos + i + e * m_IsoSize < fielddata_size) {
|
||||
int w = GetWaypointAt(dwPos + i + e * m_IsoSize);
|
||||
if (w >= 0) {
|
||||
GetWaypointData(w, &id, &p);
|
||||
if (atoi(id) < 8) {
|
||||
startpos = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (startpos) {
|
||||
col.rgbtBlue = 0;
|
||||
col.rgbtGreen = 0;
|
||||
col.rgbtRed = 255;
|
||||
col_r = col;
|
||||
}
|
||||
}
|
||||
}
|
173
MissionEditor/MapOperationSlopes.cpp
Normal file
173
MissionEditor/MapOperationSlopes.cpp
Normal file
|
@ -0,0 +1,173 @@
|
|||
#include "stdafx.h"
|
||||
#include "MapData.h"
|
||||
|
||||
void CMapData::CreateSlopesAt(DWORD dwPos)
|
||||
{
|
||||
//OutputDebugString("CreateSlopes()\n");
|
||||
|
||||
auto& m = *GetFielddataAt(dwPos);
|
||||
if (m.wGround == 0xFFFF) {
|
||||
m.wGround = 0;
|
||||
}
|
||||
|
||||
TILEDATA& d = (*tiledata)[m.wGround];
|
||||
|
||||
int ns = -1;
|
||||
int i, e, p = 0;
|
||||
int h[3][3];
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (e = 0; e < 3; e++) {
|
||||
int pos = dwPos + (i - 1) + (e - 1) * m_IsoSize;
|
||||
if (pos < 0 || pos >= m_IsoSize * m_IsoSize) {
|
||||
h[i][e] = 0;
|
||||
} else {
|
||||
auto const& m2 = *GetFielddataAt(pos);
|
||||
h[i][e] = m.bHeight - m2.bHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the current tile must be heightened anyway
|
||||
if (!theApp.m_Options.bDisableSlopeCorrection && d.bMorphable) {
|
||||
if ((h[0][1] < 0 && h[2][1] < 0) || (h[1][0] < 0 && h[1][2] < 0)
|
||||
|| (h[1][0] < 0 && h[0][2] < 0 && h[0][1] >= 0)
|
||||
|| (h[1][0] < 0 && h[2][2] < 0 && h[2][1] >= 0)
|
||||
|
||||
|| (h[0][1] < 0 && h[2][0] < 0 && h[1][0] >= 0)
|
||||
|| (h[0][1] < 0 && h[2][2] < 0 && h[1][2] >= 0)
|
||||
|
||||
|| (h[1][2] < 0 && h[0][0] < 0 && h[0][1] >= 0)
|
||||
|| (h[1][2] < 0 && h[2][0] < 0 && h[2][1] >= 0)
|
||||
|
||||
|| (h[2][1] < 0 && h[0][0] < 0 && h[1][0] >= 0)
|
||||
|| (h[2][1] < 0 && h[0][2] < 0 && h[1][2] >= 0)
|
||||
|
||||
|| (h[1][0] < 0 && h[0][1] < 0 && h[0][0] >= 0)
|
||||
|| (h[0][1] < 0 && h[1][2] < 0 && h[0][2] >= 0)
|
||||
|| (h[1][2] < 0 && h[2][1] < 0 && h[2][2] >= 0)
|
||||
|| (h[2][1] < 0 && h[1][0] < 0 && h[2][0] >= 0)
|
||||
|
||||
) {
|
||||
SetHeightAt(dwPos, m.bHeight + 1);
|
||||
for (i = -1; i < 2; i++) {
|
||||
for (e = -1; e < 2; e++) {
|
||||
CreateSlopesAt(dwPos + i + e * m_IsoSize);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL checkOtherSlopes = FALSE;
|
||||
|
||||
if (h[0][0] == -1 && h[2][2] == -1 && h[2][0] >= 0 && h[0][2] >= 0 && h[1][0] >= 0 && h[1][2] >= 0 && h[0][1] >= 0 && h[2][1] >= 0) {
|
||||
ns = SLOPE_UP_LEFTTOP_AND_RIGHTBOTTOM;
|
||||
}
|
||||
if (h[0][2] == -1 && h[2][0] == -1 && h[0][0] >= 0 && h[2][2] >= 0 && h[0][1] >= 0 && h[1][0] >= 0 && h[1][2] >= 0 && h[2][1] >= 0) {
|
||||
ns = SLOPE_UP_LEFTBOTTOM_AND_RIGHTTOP;
|
||||
}
|
||||
|
||||
if (ns == -1) {
|
||||
if (h[1][0] == -1 && h[0][1] != -1 && h[1][2] != -1 && h[2][1] != -1) {
|
||||
ns = SLOPE_UP_LEFT;
|
||||
} else if (h[0][1] == -1 && h[1][0] != -1 && h[2][1] != -1 && h[1][2] != -1) {
|
||||
ns = SLOPE_UP_TOP;
|
||||
} else if (h[1][2] == -1 && h[0][1] != -1 && h[1][0] != -1 && h[2][1] != -1) {
|
||||
ns = SLOPE_UP_RIGHT;
|
||||
} else if (h[2][1] == -1 && h[0][1] != -1 && h[1][0] != -1 && h[1][2] != -1) {
|
||||
ns = SLOPE_UP_BOTTOM;
|
||||
}
|
||||
|
||||
if (ns == -1) {
|
||||
if (h[0][0] == -2) {
|
||||
ns = SLOPE_DOWN_BOTTOM;
|
||||
}
|
||||
if (h[2][0] == -2) {
|
||||
ns = SLOPE_DOWN_RIGHT;
|
||||
}
|
||||
if (h[0][2] == -2) {
|
||||
ns = SLOPE_DOWN_LEFT;
|
||||
}
|
||||
if (h[2][2] == -2) {
|
||||
ns = SLOPE_DOWN_TOP;
|
||||
}
|
||||
}
|
||||
|
||||
if (ns == -1 && h[0][0] == -1) {
|
||||
if (h[1][0] == -1 && h[0][1] == -1) {
|
||||
ns = SLOPE_DOWN_RIGHTBOTTOM;
|
||||
} else if (h[1][0] == 0 && h[0][1] == 0) {
|
||||
ns = SLOPE_UP_LEFTTOP;
|
||||
}
|
||||
//else if(h[2][2]==1) ns=SLOPE_DOWN_BOTTOM;
|
||||
}
|
||||
|
||||
if (ns == -1 && h[2][0] == -1) {
|
||||
if (h[1][0] == -1 && h[2][1] == -1) {
|
||||
ns = SLOPE_DOWN_RIGHTTOP;
|
||||
} else if (h[1][0] == 0 && h[2][1] == 0) {
|
||||
ns = SLOPE_UP_LEFTBOTTOM;
|
||||
}
|
||||
//else if(h[0][2]==1) ns=SLOPE_DOWN_RIGHT;
|
||||
}
|
||||
if (ns == -1 && h[0][2] == -1) {
|
||||
if (h[1][2] == -1 && h[0][1] == -1) {
|
||||
ns = SLOPE_DOWN_LEFTBOTTOM;
|
||||
} else if (h[1][2] == 0 && h[0][1] == 0) {
|
||||
ns = SLOPE_UP_RIGHTTOP;
|
||||
}
|
||||
//else if(h[2][0]==1) ns=SLOPE_DOWN_LEFT;
|
||||
}
|
||||
if (ns == -1 && h[2][2] == -1) {
|
||||
if (h[1][2] == -1 && h[2][1] == -1) {
|
||||
ns = SLOPE_DOWN_LEFTTOP;
|
||||
} else if (h[1][2] == 0 && h[2][1] == 0) {
|
||||
ns = SLOPE_UP_RIGHTBOTTOM;
|
||||
}
|
||||
//else if(h[0][0]==1) ns=SLOPE_DOWN_TOP;
|
||||
}
|
||||
|
||||
if (ns == -1 && h[1][0] == -1 && h[2][1] == -1) {
|
||||
ns = SLOPE_DOWN_RIGHTTOP;
|
||||
}
|
||||
if (ns == -1 && h[1][2] == -1 && h[2][1] == -1) {
|
||||
ns = SLOPE_DOWN_LEFTTOP;
|
||||
}
|
||||
if (ns == -1 && h[1][0] == -1 && h[0][1] == -1) {
|
||||
ns = SLOPE_DOWN_RIGHTBOTTOM;
|
||||
}
|
||||
if (ns == -1 && h[1][2] == -1 && h[0][1] == -1) {
|
||||
ns = SLOPE_DOWN_LEFTBOTTOM;
|
||||
}
|
||||
|
||||
int rampbase = rampset_start;//atoi((*tiles).sections["General"].values["RampBase"]);
|
||||
int rampsmooth = tiles->GetInteger("General", "RampSmooth");
|
||||
|
||||
if (ns == -1 && (d.wTileSet == rampset || d.wTileSet == rampsmooth) && d.bMorphable) {
|
||||
SetTileAt(dwPos, 0, 0);
|
||||
}
|
||||
if (tiledata == &un_tiledata) {
|
||||
int r = ramp2set;
|
||||
int m = pave2set;
|
||||
|
||||
if (ns == -1 && (d.wTileSet == r || d.wTileSet == m) && d.bMorphable) {
|
||||
SetTileAt(dwPos, pave2set_start/*GetTileID(m,0)*/, 0);
|
||||
}
|
||||
}
|
||||
if (d.bMorphable && ns != -1) {
|
||||
// NEW URBAN FIX FOR URBAN PAVEMENT
|
||||
if (tiledata == &un_tiledata) {
|
||||
//[NewUrbanInfo]
|
||||
//Morphable2=114
|
||||
//Ramps2=117
|
||||
int r = ramp2set;
|
||||
int m = pave2set;
|
||||
if (d.wTileSet == r || d.wTileSet == m) {
|
||||
rampbase = ramp2set_start;
|
||||
}
|
||||
}
|
||||
SetTileAt(dwPos, rampbase + ns - 1, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
185
MissionEditor/MapOperationSmooth.cpp
Normal file
185
MissionEditor/MapOperationSmooth.cpp
Normal file
|
@ -0,0 +1,185 @@
|
|||
#include "stdafx.h"
|
||||
#include "MapData.h"
|
||||
|
||||
void CMapData::SmoothAt(DWORD dwPos, int iSmoothSet, int iLatSet, int iTargetSet, BOOL bIgnoreShore)
|
||||
{
|
||||
int i;
|
||||
int its, iss, ils;
|
||||
int iLatGround = tilesets_start[iLatSet];
|
||||
int iSmoothGround = tilesets_start[iSmoothSet];
|
||||
its = (*tiledata)[tilesets_start[iTargetSet]].tiles[0].bTerrainType;
|
||||
iss = (*tiledata)[iSmoothGround].tiles[0].bTerrainType;
|
||||
ils = (*tiledata)[iLatGround].tiles[0].bTerrainType;
|
||||
|
||||
FIELDDATA m = *GetFielddataAt(dwPos);
|
||||
if (m.wGround == 0xFFFF) {
|
||||
m.wGround = 0;
|
||||
}
|
||||
|
||||
// do we have that certain LAT tile here?
|
||||
if ((*tiledata)[m.wGround].wTileSet != iSmoothSet && (*tiledata)[m.wGround].wTileSet != iLatSet) {
|
||||
return;
|
||||
}
|
||||
|
||||
//if(m.wGround==iLatGround) m.wGround=iSmoothGround;
|
||||
|
||||
if (its == iss && (*tiledata)[m.wGround].wTileSet == iSmoothSet) {
|
||||
m.wGround = iLatGround;
|
||||
}
|
||||
|
||||
if (its == iss) {
|
||||
ils += 1;
|
||||
}
|
||||
|
||||
BOOL bOnlyLat = TRUE;
|
||||
//BOOL bNoLat=TRUE;
|
||||
int ns = -1;
|
||||
int e, p = 0;
|
||||
int ts[3][3]; // terrain info
|
||||
|
||||
int set = (*tiledata)[m.wGround].wTileSet;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (e = 0; e < 3; e++) {
|
||||
int pos = dwPos + (i - 1) + (e - 1) * m_IsoSize;
|
||||
if (pos < 0 || pos >= fielddata_size) {
|
||||
ts[i][e] = 0;
|
||||
} else {
|
||||
FIELDDATA m2 = *GetFielddataAt(pos);
|
||||
if (m2.wGround == 0xFFFF) m2.wGround = 0;
|
||||
|
||||
int cur_set = (*tiledata)[m2.wGround].wTileSet;
|
||||
|
||||
//if(cur_set==iSmoothSet) bNoLat=FALSE;
|
||||
//
|
||||
|
||||
if (its == iss && cur_set == iSmoothSet) {
|
||||
m2.wGround = iLatGround; cur_set = iLatSet;
|
||||
}
|
||||
|
||||
if (cur_set == iSmoothSet || cur_set == iTargetSet) bOnlyLat = FALSE;
|
||||
|
||||
/*if(cur_set != iSmoothSet && cur_set!= iLatSet && cur_set!=iTargetSet)
|
||||
{
|
||||
ts[i][e]=(*tiledata)[m2.wGround].tiles[m2.bSubTile].bTerrainType;
|
||||
if((*tiledata)[m2.wGround].wTileSet!=shoreset)
|
||||
{
|
||||
ts[i][e]=0;//ts[i][e]+1; // make sure you don´t smooth at it except it´s shore
|
||||
}
|
||||
//if(bIgnoreShore && (*tiledata)[m2.wGround].wTileSet==shoreset)
|
||||
// ts[i][e]=0;//ts[i][e]+1;
|
||||
}
|
||||
else*/ if (its == iss && cur_set != set) {
|
||||
if (cur_set == shoreset && !bIgnoreShore)
|
||||
ts[i][e] = its;
|
||||
else if (cur_set != iSmoothSet && cur_set != iTargetSet && cur_set != iLatSet)
|
||||
ts[i][e] = 0;
|
||||
else
|
||||
ts[i][e] = its;
|
||||
} else if (its == iss && cur_set == set)
|
||||
ts[i][e] = ils;
|
||||
else {
|
||||
ts[i][e] = (*tiledata)[m2.wGround].tiles[m2.bSubTile].bTerrainType;
|
||||
|
||||
if (cur_set != shoreset && cur_set != iLatSet && cur_set != iSmoothSet) {
|
||||
ts[i][e] = 0;//ts[i][e]+1; // make sure you don´t smooth at it except it´s shore
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if(bOnlyLat) return;
|
||||
|
||||
|
||||
int needed = -1;
|
||||
|
||||
// 1/1 is smoothed tile
|
||||
|
||||
if (ts[1][1] == ils) {
|
||||
// single lat
|
||||
if (ts[0][1] != ils && ts[1][0] != ils
|
||||
&& ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 16;
|
||||
else if (ts[0][1] == ils && ts[1][0] == ils
|
||||
&& ts[1][2] == ils && ts[2][1] == ils)
|
||||
needed = 0;
|
||||
else if (ts[0][1] == ils && ts[2][1] == ils &&
|
||||
ts[1][0] != ils && ts[1][2] != ils)
|
||||
needed = 11;
|
||||
else if (ts[1][0] == ils && ts[1][2] == ils &&
|
||||
ts[0][1] != ils && ts[2][1] != ils)
|
||||
needed = 6;
|
||||
else if (ts[1][0] != ils && ts[0][1] == ils &&
|
||||
ts[2][1] == ils)
|
||||
needed = 9;
|
||||
else if (ts[2][1] != ils && ts[1][0] == ils &&
|
||||
ts[1][2] == ils)
|
||||
needed = 5;
|
||||
else if (ts[1][2] != ils && ts[0][1] == ils &&
|
||||
ts[2][1] == ils)
|
||||
needed = 3;
|
||||
else if (ts[0][1] != ils && ts[1][0] == ils &&
|
||||
ts[1][2] == ils)
|
||||
needed = 2;
|
||||
else if (ts[0][1] == ils && ts[1][0] != ils &&
|
||||
ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 15;
|
||||
else if (ts[1][2] == ils && ts[1][0] != ils &&
|
||||
ts[0][1] != ils && ts[2][1] != ils)
|
||||
needed = 14;
|
||||
else if (ts[2][1] == ils && ts[1][0] != ils &&
|
||||
ts[0][1] != ils && ts[1][2] != ils)
|
||||
needed = 12;
|
||||
else if (ts[1][0] == ils && ts[0][1] != ils &&
|
||||
ts[1][2] != ils && ts[2][1] != ils)
|
||||
needed = 8;
|
||||
else if (ts[1][0] != ils && ts[2][1] != ils)
|
||||
needed = 13;
|
||||
else if (ts[1][0] != ils && ts[0][1] != ils)
|
||||
needed = 10;
|
||||
else if (ts[2][1] != ils && ts[1][2] != ils)
|
||||
needed = 7;
|
||||
else if (ts[0][1] != ils && ts[1][2] != ils)
|
||||
needed = 4;
|
||||
|
||||
|
||||
} else if (ts[1][1] == its) {
|
||||
// replace target set instead of smooth set
|
||||
//if(st(ts[0][0], && ts[0][1]
|
||||
}
|
||||
|
||||
|
||||
needed -= 1;
|
||||
if (needed >= 0) {
|
||||
/*for(i=0;i<*tiledata_count;i++)
|
||||
{
|
||||
if((*tiledata)[i].wTileSet==iLatSet)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
i = tilesets_start[iLatSet];
|
||||
|
||||
// i is first lat tile
|
||||
int e;
|
||||
for (e = 0; e < needed; e++) {
|
||||
i += (*tiledata)[i].wTileCount;
|
||||
}
|
||||
|
||||
SetTileAt(dwPos, i, 0);
|
||||
} else if (needed == -1) {
|
||||
/*for(i=0;i<*tiledata_count;i++)
|
||||
{
|
||||
if((*tiledata)[i].wTileSet==iSmoothSet)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
i = tilesets_start[iSmoothSet];
|
||||
|
||||
// i is first lat tile
|
||||
SetTileAt(dwPos, i, 0);
|
||||
}
|
||||
}
|
|
@ -509,6 +509,9 @@
|
|||
<ClCompile Include="MapLoadingDlg.cpp" />
|
||||
<ClCompile Include="MapModifier.cpp" />
|
||||
<ClCompile Include="MapOpenDialog.cpp" />
|
||||
<ClCompile Include="MapOperationMiniMap.cpp" />
|
||||
<ClCompile Include="MapOperationSlopes.cpp" />
|
||||
<ClCompile Include="MapOperationSmooth.cpp" />
|
||||
<ClCompile Include="MapValidator.cpp" />
|
||||
<ClCompile Include="MiniMap.cpp" />
|
||||
<ClCompile Include="MMXSavingOptionsDlg.cpp" />
|
||||
|
|
|
@ -291,6 +291,15 @@
|
|||
<ClCompile Include="VoxelDrawer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapOperationSlopes.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapOperationSmooth.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapOperationMiniMap.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MissionEditor.rc">
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "FinalSun.h"
|
||||
#include "MapData.h"
|
||||
|
||||
class CMapData;
|
||||
using TranslationMap = map<CString, XCString>;
|
||||
|
||||
// the map
|
||||
|
|
Loading…
Add table
Reference in a new issue