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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//dnl ch42 250909
|
||||
typedef struct
|
||||
{
|
||||
INT16 sMapIndex;//dnl ch86 170214 not exist in v1.12, add to simplify load
|
||||
INT16 usGridNo;
|
||||
UINT8 ubGotoSectorX;
|
||||
UINT8 ubGotoSectorY;
|
||||
@@ -17,14 +18,17 @@ class EXITGRID// For exit grids (object level)
|
||||
{
|
||||
// If an item pool is also in same gridno, then this would be a separate levelnode in the object level list
|
||||
public:
|
||||
INT32 iMapIndex;//dnl ch86 170214
|
||||
INT32 usGridNo;// Sweet spot for placing mercs in new sector.
|
||||
UINT8 ubGotoSectorX;
|
||||
UINT8 ubGotoSectorY;
|
||||
UINT8 ubGotoSectorZ;
|
||||
public:
|
||||
EXITGRID() : iMapIndex(-1), usGridNo(0), ubGotoSectorX(1), ubGotoSectorY(1), ubGotoSectorZ(0) {}//dnl ch86 180214
|
||||
EXITGRID& operator=(const _OLD_EXITGRID& src);
|
||||
BOOLEAN Load(INT8** hBuffer, FLOAT dMajorMapVersion);
|
||||
BOOLEAN Save(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMapVersion);
|
||||
BOOLEAN Equal(EXITGRID &ExitGrid) { return(!memcmp(&this->usGridNo, &ExitGrid.usGridNo, sizeof(usGridNo)+sizeof(ubGotoSectorX)+sizeof(ubGotoSectorY)+sizeof(ubGotoSectorZ))); }
|
||||
};
|
||||
|
||||
BOOLEAN ExitGridAtGridNo( UINT32 usMapIndex );
|
||||
@@ -33,6 +37,7 @@ BOOLEAN GetExitGrid( UINT32 usMapIndex, EXITGRID *pExitGrid );
|
||||
|
||||
void AddExitGridToWorld( INT32 iMapIndex, EXITGRID *pExitGrid );
|
||||
void RemoveExitGridFromWorld( INT32 iMapIndex );
|
||||
void TrashExitGridTable(void);//dnl ch86 170214
|
||||
//dnl ch42 250909
|
||||
void SaveExitGrids(HWFILE hFile, UINT16 usNumExitGrids, FLOAT dMajorMapVersion, UINT8 ubMinorMapVersion);
|
||||
void LoadExitGrids(INT8** hBuffer, FLOAT dMajorMapVersion);
|
||||
@@ -41,11 +46,11 @@ void AttemptToChangeFloorLevel( INT8 bRelativeZLevel );
|
||||
|
||||
extern EXITGRID gExitGrid;
|
||||
extern BOOLEAN gfOverrideInsertionWithExitGrid;
|
||||
extern BOOLEAN gfShowExitGrids;//dnl ch86 190214
|
||||
|
||||
// Finds closest ExitGrid of same type as is at gridno, within a radius. Checks
|
||||
// valid paths, destinations, etc.
|
||||
INT32 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT32 sSweetGridNo, INT8 ubRadius, UINT8 *pubDirection );
|
||||
|
||||
INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadius );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -464,7 +464,7 @@ BOOLEAN LoadAllMapChangesFromMapTempFileAndApplyThem( )
|
||||
{
|
||||
EXITGRID ExitGrid;
|
||||
gfLoadingExitGrids = TRUE;
|
||||
ExitGrid.usGridNo = pMap->usSubImageIndex;
|
||||
ExitGrid.usGridNo = (UINT32)pMap->usHiExitGridNo << 16 | pMap->usSubImageIndex;//dnl ch86 260214 was ExitGrid.usGridNo = pMap->usSubImageIndex;
|
||||
ExitGrid.ubGotoSectorX = (UINT8) pMap->usImageType;
|
||||
ExitGrid.ubGotoSectorY = (UINT8) ( pMap->usImageType >> 8 ) ;
|
||||
ExitGrid.ubGotoSectorZ = pMap->ubExtra;
|
||||
@@ -1130,6 +1130,7 @@ void AddExitGridToMapTempFile( INT32 usGridNo, EXITGRID *pExitGrid, INT16 sSecto
|
||||
|
||||
Map.usImageType = pExitGrid->ubGotoSectorX | ( pExitGrid->ubGotoSectorY << 8 );
|
||||
Map.usSubImageIndex = pExitGrid->usGridNo;
|
||||
Map.usHiExitGridNo = pExitGrid->usGridNo >> 16;//dnl ch86 260214
|
||||
|
||||
Map.ubExtra = pExitGrid->ubGotoSectorZ;
|
||||
Map.ubType = SLM_EXIT_GRIDS;
|
||||
|
||||
@@ -50,26 +50,22 @@ enum
|
||||
SLM_MINE_PRESENT,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct//dnl ch86 250214
|
||||
{
|
||||
INT32 usGridNo; //The gridno the graphic will be applied to
|
||||
UINT16 usImageType; //graphic index
|
||||
UINT16 usSubImageIndex; //
|
||||
// UINT16 usIndex;
|
||||
UINT8 ubType; // the layer it will be applied to
|
||||
|
||||
UINT8 ubExtra; // Misc. variable used to strore arbritary values
|
||||
INT32 usGridNo; // The gridno the graphic will be applied to
|
||||
UINT16 usImageType; // graphic index
|
||||
UINT16 usSubImageIndex; // ExitGrid low WORD of usGridno is stored here
|
||||
UINT8 ubType; // the layer it will be applied to
|
||||
UINT8 ubExtra; // Misc. variable used to strore arbritary values
|
||||
UINT16 usHiExitGridNo; // ExitGrid.usGridno is store in usSubImageIndex which is not enough for big maps so high WORD goes here just to preserve compatibility
|
||||
} MODIFY_MAP;
|
||||
|
||||
|
||||
// Call this function, to set whether the map changes will be added to the map temp file
|
||||
void ApplyMapChangesToMapTempFile( BOOLEAN fAddToMap );
|
||||
|
||||
BOOLEAN SaveModifiedMapStructToMapTempFile( MODIFY_MAP *pMap, INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ );
|
||||
|
||||
|
||||
|
||||
|
||||
//Applies a change TO THE MAP TEMP file
|
||||
void AddStructToMapTempFile( INT32 iMapIndex, UINT16 usIndex );
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define LIGHT_OMNI_R8 "LTO8.LHT"
|
||||
|
||||
#define MAX_LIGHT_TEMPLATES 32 // maximum number of light types
|
||||
#define MAX_LIGHT_SPRITES 256 // maximum number of light types
|
||||
#define MAX_LIGHT_SPRITES 4096 // maximum number of light types //dnl ch86 100214 was 256
|
||||
#define SHADE_MIN 15 // DARKEST shade value
|
||||
#define SHADE_MAX 1 // LIGHTEST shade value
|
||||
|
||||
|
||||
@@ -3552,6 +3552,7 @@ void TrashWorld( void )
|
||||
TrashDoorTable();
|
||||
TrashMapEdgepoints();
|
||||
TrashDoorStatusArray();
|
||||
TrashExitGridTable();//dnl ch86 170214
|
||||
|
||||
//gfBlitBattleSectorLocator = FALSE;
|
||||
gfWorldLoaded = FALSE;
|
||||
|
||||
@@ -160,7 +160,7 @@ struct LEVELNODE
|
||||
INT32 uiAPCost; // FOR AP DISPLAY
|
||||
//SB: change packed exitgrid for EXITGRID *
|
||||
// INT32 iExitGridInfo;
|
||||
void * pExitGridInfo;
|
||||
// void * pExitGridInfo;//dnl ch86 190214
|
||||
}; // ( 4 byte union )
|
||||
|
||||
union
|
||||
|
||||
@@ -1942,7 +1942,7 @@ BOOLEAN RemoveShadow( INT32 iMapIndex, UINT16 usIndex )
|
||||
{
|
||||
pOldShadow->pNext = pShadow->pNext;
|
||||
}
|
||||
#ifdef JA2EDITOR//dnl ch80 011213
|
||||
#if 0//#ifdef JA2EDITOR//dnl ch80 011213 //dnl ch86 190214
|
||||
if(pShadow->uiFlags & LEVELNODE_EXITGRID && pShadow->pExitGridInfo)
|
||||
memset(pShadow->pExitGridInfo, 0, sizeof(EXITGRID));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user