Map editor changes from Kriplo (DNL).

Adding roads from “Draw Roads” selection will first remove exact the same road tile object before placing the same again at the same location.  
Adding roads from “Place banks and cliffs” option now will not put same road in same map element just once.  
Whenever you chose to place rocs,bu ches,tree,junk, or any what call PasteStructureCommon() will first remove exact element before it put again.  
“Fill area” will not go to endless recursion loop when try to fill inside buildings, ending with stack overflow.  


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2361 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
ChrisL
2008-09-26 23:41:37 +00:00
parent 6f2af55cba
commit 92b1865817
4 changed files with 17 additions and 3 deletions
+1
View File
@@ -195,6 +195,7 @@ void SetEditorTerrainTaskbarMode( UINT16 usNewMode )
UnclickEditorButton( TERRAIN_FGROUND_TEXTURES );
UnclickEditorButton( TERRAIN_BGROUND_TEXTURES );
UnclickEditorButton( TERRAIN_PLACE_CLIFFS );
UnclickEditorButton( TERRAIN_PLACE_ROADS );//dnl Without this road button always remain in clicked state
UnclickEditorButton( TERRAIN_PLACE_DEBRIS );
UnclickEditorButton( TERRAIN_PLACE_TREES );
UnclickEditorButton( TERRAIN_PLACE_ROCKS );
+12 -2
View File
@@ -215,8 +215,9 @@ void ChooseWeightedTerrainTile()
UINT32 guiSearchType;
// TODO: change this variable name if not too time consuming (jonathanl)
extern UINT32 count; // symbol exist already in gamescreen.cpp, this is a REALLY bad global symbol name!!! (jonathanl)
UINT32 maxCount=0, calls=0;
//dnl as jonathanl wrote count is changed to Count so this line could be deleted, extern UINT32 count; // symbol exist already in gamescreen.cpp, this is a REALLY bad global symbol name!!! (jonathanl)
//dnl Generally globals below are not necessary because is only informational for author, Count contains number of current Fill() recursions on stack, maxCount contains the maximum number of Fill() recursions that was putted on Stack during runtime, calls contains total number of Fill() calls during the runtime
UINT32 Count=0, maxCount=0, calls=0;
void Fill( INT32 x, INT32 y )
{
@@ -237,7 +238,16 @@ void Fill( INT32 x, INT32 y )
}
GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex , &uiCheckType );
if( guiSearchType == uiCheckType )
{
PasteTextureCommon( iMapIndex );
//dnl This condition is mandatory because PasteTextureCommon() not returning information if was successful in adding a tile, without this condition endless loop of calling recursion Fill() was occur when tile was not add. Still without checking Count Stack breach could appear in future if we decide to use very large maps!!!
GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex , &uiCheckType );
if( guiSearchType == uiCheckType )
{
Count--;
return;
}
}
else
{
count--;
+1 -1
View File
@@ -409,7 +409,7 @@ void PlaceRoadMacroAtGridNo( INT32 iMapIndex, INT32 iMacroID )
while( gRoadMacros[ i ].sMacroID == iMacroID )
{
AddToUndoList( iMapIndex + gRoadMacros[ i ].sOffset );
RemoveAllObjectsOfTypeRange( i, ROADPIECES, ROADPIECES );
RemoveAllObjectsOfTypeRange( iMapIndex + gRoadMacros[ i ].sOffset, ROADPIECES, ROADPIECES );//dnl this was but is very wrong and leading to stacking tilesets, RemoveAllObjectsOfTypeRange( i, ROADPIECES, ROADPIECES );
GetTileIndexFromTypeSubIndex( ROADPIECES, (UINT16)(i+1) , &usTileIndex );
AddObjectToHead( iMapIndex + gRoadMacros[ i ].sOffset, usTileIndex );
i++;
+3
View File
@@ -577,6 +577,8 @@ void PasteStructureCommon( UINT32 iMapIndex )
fOkayToAdd = OkayToAddStructureToWorld( (INT16)iMapIndex, 0, gTileDatabase[ (gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) ].pDBStructureRef, INVALID_STRUCTURE_ID );
if ( fOkayToAdd || (gTileDatabase[ (gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) ].pDBStructureRef == NULL) )
{
//dnl Remove existing structure before adding the same, seems to solve problem with stacking but possibly dangerous and completly untested
RemoveStruct( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );//dnl
// Actual structure info is added by the functions below
AddStructToHead( iMapIndex, (UINT16)(gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex) );
// For now, adjust to shadows by a hard-coded amount,
@@ -640,6 +642,7 @@ void PasteBanks( UINT32 iMapIndex, UINT16 usStructIndex , BOOLEAN fReplace)
{
if ( usUseObjIndex == FIRSTROAD )
{
RemoveObject( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) );//dnl without this road stacking occur when you holding left mouse key and pasting roads in bank selection
AddObjectToHead( iMapIndex, (UINT16)( gTileTypeStartIndex[ usUseObjIndex ] + usUseIndex ) );
}
else