mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
Brief: //dnl ch86
- Fixing mapeditor move building and improving some related mapeditor stuff. Details: - Change the way exit grids are add, remove, save and load through editor, also add undo option for exit grids and you can place unlimited number of them. - Fix incorrect gridno save in temporary map file for bigmap exit grids. - Increase maximum number of light sprite from 256 to 4096 per map. - Using DEL key for QuickEraseMapTile will now erase ItemPool too, and with improved function DeleteStuffFromMapTile will erase light sprites, exit grids and door locks. - Cliff hang tiles used for middle cliffs are now possible to erase with when erase button is on. - Add support for undo door locks, also you can now erase them if erase button is on. - Move building function is completely rewrite and will properly move exit grids, door locks, lights and items too. - Removing unnecessary tiles during copy building is improved too. - Fix undo function for light sprites which now will also store all three types and undo them properly. - Fix CTD situation if tile elements are deleted and after that items too, then undo will crash mapeditor. - Fix spawning of item pool cursors during when adding items. - Fix text glitches over door locks form. - Fix sticky tooltip when loadsave screen or door locks form is active. - High ground marking cursors will not be drawn in invisible map tiles anymore to increase speed and maybe fix some render problems but I doubt it. - Move GLOCK_17_ForUseWithLOS item generation from init.cpp to los.cpp to avoid potential problems if global world items array not set. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7004 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+101
-12
@@ -23,6 +23,7 @@
|
||||
#include "Text.h"
|
||||
#endif
|
||||
|
||||
#if 0//dnl ch86 180214
|
||||
BOOLEAN gfLoadingExitGrids = FALSE;
|
||||
|
||||
//used by editor.
|
||||
@@ -56,9 +57,17 @@ UINT guiExitGridsCount = 0;
|
||||
// pExitGrid->ubGotoSectorZ = (UINT8)((iExitGridInfo & 0x00f00000)>>20);
|
||||
// pExitGrid->usGridNo = (UINT16)(iExitGridInfo & 0x0000ffff);
|
||||
//}
|
||||
#else
|
||||
BOOLEAN gfLoadingExitGrids = FALSE;
|
||||
BOOLEAN gfOverrideInsertionWithExitGrid = FALSE;
|
||||
EXITGRID gExitGrid;
|
||||
EXITGRID *ExitGridTable = NULL;
|
||||
UINT16 gusNumExitGrids = 0;
|
||||
#endif
|
||||
|
||||
BOOLEAN GetExitGrid( UINT32 usMapIndex, EXITGRID *pExitGrid )
|
||||
{
|
||||
#if 0//dnl ch86 170214
|
||||
LEVELNODE *pShadow;
|
||||
pShadow = gpWorldLevelData[ usMapIndex ].pShadowHead;
|
||||
//Search through object layer for an exitgrid
|
||||
@@ -75,6 +84,19 @@ BOOLEAN GetExitGrid( UINT32 usMapIndex, EXITGRID *pExitGrid )
|
||||
pShadow = pShadow->pNext;
|
||||
}
|
||||
return FALSE;
|
||||
#else
|
||||
INT32 i = 0;
|
||||
while(i < gusNumExitGrids)
|
||||
{
|
||||
if(ExitGridTable[i].iMapIndex == usMapIndex)
|
||||
{
|
||||
*pExitGrid = ExitGridTable[i];
|
||||
return(TRUE);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN ExitGridAtGridNo( UINT32 usMapIndex )
|
||||
@@ -110,9 +132,9 @@ BOOLEAN GetExitGridLevelNode( UINT32 usMapIndex, LEVELNODE **ppLevelNode )
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void AddExitGridToWorld( INT32 iMapIndex, EXITGRID *pExitGrid )
|
||||
{
|
||||
#if 0//dnl ch86 180214
|
||||
LEVELNODE *pShadow, *tail;
|
||||
pShadow = gpWorldLevelData[ iMapIndex ].pShadowHead;
|
||||
|
||||
@@ -147,15 +169,76 @@ void AddExitGridToWorld( INT32 iMapIndex, EXITGRID *pExitGrid )
|
||||
{
|
||||
AddExitGridToMapTempFile( iMapIndex, pExitGrid, gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
|
||||
}
|
||||
#else
|
||||
pExitGrid->iMapIndex = iMapIndex;
|
||||
INT32 i = 0, j = -1;
|
||||
while(i < gusNumExitGrids)
|
||||
{
|
||||
if(ExitGridTable[i].iMapIndex == pExitGrid->iMapIndex)
|
||||
{
|
||||
j = -1;
|
||||
break;
|
||||
}
|
||||
if(j == -1 && ExitGridTable[i].iMapIndex == NOWHERE)
|
||||
j = i;
|
||||
i++;
|
||||
}
|
||||
if(j != -1)
|
||||
i = j;
|
||||
if(i == gusNumExitGrids)
|
||||
{
|
||||
gusNumExitGrids++;
|
||||
ExitGridTable = (EXITGRID*)MemRealloc(ExitGridTable, gusNumExitGrids*sizeof(EXITGRID));
|
||||
Assert(ExitGridTable);
|
||||
}
|
||||
ExitGridTable[i] = *pExitGrid;
|
||||
LEVELNODE *pShadow = gpWorldLevelData[iMapIndex].pShadowHead;
|
||||
while(pShadow)
|
||||
{
|
||||
if(pShadow->uiFlags & LEVELNODE_EXITGRID)
|
||||
break;
|
||||
pShadow = pShadow->pNext;
|
||||
}
|
||||
if(!pShadow)
|
||||
{
|
||||
AddShadowToHead(iMapIndex, MOCKFLOOR1);
|
||||
pShadow = gpWorldLevelData[iMapIndex].pShadowHead;
|
||||
pShadow->uiFlags |= (LEVELNODE_EXITGRID | LEVELNODE_HIDDEN);
|
||||
if(!gfEditMode && !gfLoadingExitGrids)
|
||||
AddExitGridToMapTempFile(iMapIndex, pExitGrid, gWorldSectorX, gWorldSectorY, gbWorldSectorZ);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RemoveExitGridFromWorld( INT32 iMapIndex )
|
||||
{
|
||||
#if 0//dnl ch86 180214
|
||||
UINT16 usDummy;
|
||||
if( TypeExistsInShadowLayer( iMapIndex, MOCKFLOOR, &usDummy ) )
|
||||
{
|
||||
RemoveAllShadowsOfTypeRange( iMapIndex, MOCKFLOOR, MOCKFLOOR );
|
||||
}
|
||||
#else
|
||||
INT32 i = 0;
|
||||
while(i < gusNumExitGrids)
|
||||
{
|
||||
if(ExitGridTable[i].iMapIndex == iMapIndex)
|
||||
{
|
||||
ExitGridTable[i].iMapIndex = NOWHERE;
|
||||
RemoveAllShadowsOfTypeRange(iMapIndex, MOCKFLOOR, MOCKFLOOR);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TrashExitGridTable(void)//dnl ch86 170214
|
||||
{
|
||||
if(ExitGridTable)
|
||||
MemFree(ExitGridTable);
|
||||
ExitGridTable = NULL;
|
||||
gusNumExitGrids = 0;
|
||||
}
|
||||
|
||||
//dnl ch42 250909
|
||||
@@ -163,13 +246,13 @@ EXITGRID& EXITGRID::operator=(const _OLD_EXITGRID& src)
|
||||
{
|
||||
if((void*)this != (void*)&src)
|
||||
{
|
||||
iMapIndex = src.sMapIndex;//dnl ch86 170214
|
||||
usGridNo = src.usGridNo;
|
||||
ubGotoSectorX = src.ubGotoSectorX;
|
||||
ubGotoSectorY = src.ubGotoSectorY;
|
||||
ubGotoSectorZ = src.ubGotoSectorZ;
|
||||
}
|
||||
return(*this);
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN EXITGRID::Load(INT8** hBuffer, FLOAT dMajorMapVersion)
|
||||
@@ -177,7 +260,7 @@ BOOLEAN EXITGRID::Load(INT8** hBuffer, FLOAT dMajorMapVersion)
|
||||
if(dMajorMapVersion < 7.0)
|
||||
{
|
||||
_OLD_EXITGRID OldExitGrid;
|
||||
LOADDATA(&OldExitGrid, *hBuffer, 5);// Never use sizeof(_OLD_EXITGRID) because return 6 and all maps was saved with 5 bytes
|
||||
LOADDATA(&OldExitGrid, *hBuffer, 2+5);// Never use sizeof(_OLD_EXITGRID) because return 6 and all maps was saved with 2+5 bytes //dnl ch86 170214
|
||||
*this = OldExitGrid;
|
||||
}
|
||||
else
|
||||
@@ -192,12 +275,13 @@ BOOLEAN EXITGRID::Save(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMapVer
|
||||
_OLD_EXITGRID OldExitGrid;
|
||||
if(dMajorMapVersion == VANILLA_MAJOR_MAP_VERSION && ubMinorMapVersion == VANILLA_MINOR_MAP_VERSION)
|
||||
{
|
||||
OldExitGrid.sMapIndex = iMapIndex;//dnl ch86 170214
|
||||
OldExitGrid.usGridNo = usGridNo;
|
||||
OldExitGrid.ubGotoSectorX = ubGotoSectorX;
|
||||
OldExitGrid.ubGotoSectorY = ubGotoSectorY;
|
||||
OldExitGrid.ubGotoSectorZ = ubGotoSectorZ;
|
||||
pData = &OldExitGrid;
|
||||
uiBytesToWrite = 5;// Never use sizeof(_OLD_EXITGRID) because return 6 and all maps was saved with 5 bytes
|
||||
uiBytesToWrite = 2+5;// Never use sizeof(_OLD_EXITGRID) because return 6 and all maps was saved with 2+5 bytes //dnl ch86 170214
|
||||
}
|
||||
UINT32 uiBytesWritten = 0;
|
||||
FileWrite(hFile, pData, uiBytesToWrite, &uiBytesWritten);
|
||||
@@ -211,15 +295,18 @@ void LoadExitGrids(INT8** hBuffer, FLOAT dMajorMapVersion)
|
||||
UINT16 usNumExitGrids;
|
||||
INT32 usMapIndex;
|
||||
EXITGRID ExitGrid;
|
||||
|
||||
#if 0//dnl ch86 170214
|
||||
// New world is loading so trash all old EXITGRID's
|
||||
memset(gpExitGrids, 0, sizeof(gpExitGrids));
|
||||
guiExitGridsCount = 0;
|
||||
|
||||
#else
|
||||
TrashExitGridTable();
|
||||
#endif
|
||||
gfLoadingExitGrids = TRUE;
|
||||
LOADDATA(&usNumExitGrids, *hBuffer, sizeof(usNumExitGrids));
|
||||
for(int i=0; i<usNumExitGrids; i++)
|
||||
{
|
||||
#if 0//dnl ch86 170214
|
||||
if(dMajorMapVersion < 7.0)
|
||||
{
|
||||
UINT16 usOldMapIndex;
|
||||
@@ -233,6 +320,12 @@ void LoadExitGrids(INT8** hBuffer, FLOAT dMajorMapVersion)
|
||||
gMapTrn.GetTrnCnt(usMapIndex);
|
||||
//gMapTrn.GetTrnCnt(ExitGrid.usGridNo);//dnl ch56 151009 This is gridno in sector which size you don't know, so no translation here
|
||||
AddExitGridToWorld(usMapIndex, &ExitGrid);
|
||||
#else
|
||||
ExitGrid.Load(hBuffer, dMajorMapVersion);
|
||||
gMapTrn.GetTrnCnt(ExitGrid.iMapIndex);
|
||||
usMapIndex = ExitGrid.iMapIndex;
|
||||
AddExitGridToWorld(usMapIndex, &ExitGrid);
|
||||
#endif
|
||||
}
|
||||
gfLoadingExitGrids = FALSE;
|
||||
}
|
||||
@@ -247,6 +340,7 @@ void SaveExitGrids(HWFILE hFile, UINT16 usNumExitGrids, FLOAT dMajorMapVersion,
|
||||
{
|
||||
if(GetExitGrid(i, &ExitGrid))
|
||||
{
|
||||
#if 0//dnl ch86 170214
|
||||
if(dMajorMapVersion < 7.0)
|
||||
{
|
||||
UINT16 usOldMapIndex = i;
|
||||
@@ -254,6 +348,7 @@ void SaveExitGrids(HWFILE hFile, UINT16 usNumExitGrids, FLOAT dMajorMapVersion,
|
||||
}
|
||||
else
|
||||
FileWrite(hFile, &i, sizeof(i), &uiBytesWritten);
|
||||
#endif
|
||||
ExitGrid.Save(hFile, dMajorMapVersion, ubMinorMapVersion);
|
||||
usNumSaved++;
|
||||
}
|
||||
@@ -304,7 +399,6 @@ void AttemptToChangeFloorLevel( INT8 bRelativeZLevel )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INT32 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT32 sSweetGridNo, INT8 ubRadius, UINT8 *pubDirection )
|
||||
{
|
||||
INT16 sTop, sBottom;
|
||||
@@ -417,7 +511,6 @@ INT32 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT32 sSwee
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadius )
|
||||
{
|
||||
INT16 sTop, sBottom;
|
||||
@@ -472,7 +565,3 @@ INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadiu
|
||||
return( NOWHERE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user