diff --git a/Editor/Editor Modes.cpp b/Editor/Editor Modes.cpp index 0951a6e3..e5e9d025 100644 --- a/Editor/Editor Modes.cpp +++ b/Editor/Editor Modes.cpp @@ -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 ); diff --git a/Editor/EditorTerrain.cpp b/Editor/EditorTerrain.cpp index 7bafed27..458d8461 100644 --- a/Editor/EditorTerrain.cpp +++ b/Editor/EditorTerrain.cpp @@ -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--; diff --git a/Editor/Road Smoothing.cpp b/Editor/Road Smoothing.cpp index 0498b917..d80c52e8 100644 --- a/Editor/Road Smoothing.cpp +++ b/Editor/Road Smoothing.cpp @@ -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++; diff --git a/Editor/edit_sys.cpp b/Editor/edit_sys.cpp index ce301a5b..a269cf55 100644 --- a/Editor/edit_sys.cpp +++ b/Editor/edit_sys.cpp @@ -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