diff --git a/Editor/Editor Taskbar Utils.cpp b/Editor/Editor Taskbar Utils.cpp index d4306b5b..538fff4f 100644 --- a/Editor/Editor Taskbar Utils.cpp +++ b/Editor/Editor Taskbar Utils.cpp @@ -1036,7 +1036,7 @@ void ProcessEditorRendering() if( gfSummaryWindowActive ) RenderSummaryWindow(); - else if( !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() ) + else if( !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() && !gfEditingDoor )//dnl ch86 220214 RenderMercStrings(); if( gfEditingDoor ) @@ -1046,7 +1046,7 @@ void ProcessEditorRendering() RenderAllTextFields(); RenderEditorInfo(); - if( !gfSummaryWindowActive && !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() ) + if( !gfSummaryWindowActive && !gfGotoGridNoUI && !gfKeyboardItemCreationUI && !InOverheadMap() && !gfEditingDoor )//dnl ch86 220214 { if( gpItem && gsItemGridNo != -1 ) RenderSelectedItemBlownUp(); @@ -1064,7 +1064,7 @@ void ProcessEditorRendering() //It is set to false when before we save the buffer, so the buttons don't get //rendered with hilites, in case the mouse is over one. gfRenderHilights = TRUE; - if(!gfSummaryWindowActive && !gfScrollInertia)//dnl ch77 131113 //dnl ch78 271113 + if(!gfSummaryWindowActive && !gfScrollInertia && !gfEditingDoor)//dnl ch77 131113 //dnl ch78 271113 //dnl ch86 210214 RenderButtonsFastHelp(); } diff --git a/Editor/Editor Undo.cpp b/Editor/Editor Undo.cpp index fb0b1a29..c9481fa8 100644 --- a/Editor/Editor Undo.cpp +++ b/Editor/Editor Undo.cpp @@ -19,6 +19,10 @@ #include "Render Fun.h" //for access to gubWorldRoomInfo; #include "Cursor Modes.h" #include "Exit Grids.h" + //dnl ch86 110214 + #include "keys.h" + #include "EditorItems.h" + #include "EditorMapInfo.h" #endif /* @@ -70,18 +74,30 @@ void DisableUndo() gfUndoEnabled = FALSE; } -// undo node data element +// undo node data element //dnl ch86 210214 typedef struct { - INT32 iMapIndex; - MAP_ELEMENT *pMapTile; - BOOLEAN fLightSaved; //determines that a light has been saved - UINT8 ubLightRadius; //the radius of the light to build if undo is called - UINT8 ubLightID; //only applies if a light was saved. - //DBrot: More Rooms - //UINT8 ubRoomNum; - UINT16 usRoomNum; -} undo_struct; + INT32 iMapIndex; + INT32 iNewMapIndex;// item pool translation when move bulding + MAP_ELEMENT *pMapTile; + ITEM_POOL *pItemPool; + UINT8 ubItemPoolLevel; + UINT8 ubLightRadius;// radius of prime light + UINT8 ubLightID;// only applies if a light was saved. + UINT8 ubLightRadius1;// radius of night light + UINT8 ubLightID1; + UINT8 ubLightRadius2;// radius of 24h light + UINT8 ubLightID2; + UINT8 ubExitGridX; + UINT8 ubExitGridY; + UINT8 ubExitGridZ; + UINT16 usRoomNum;//DBrot: More Rooms + INT32 iExitGridNo; + BOOLEAN fLocked; + UINT8 ubTrapLevel; + UINT8 ubTrapID; + UINT8 ubLockID; +}undo_struct; // Undo stack node typedef struct TAG_undo_stack @@ -357,7 +373,7 @@ void CropStackToMaxLength( INT32 iMaxCmds ) } } - +#if 0//dnl ch86 200214 //We are adding a light to the undo list. We won't save the mapelement, nor will //we validate the gridno in the binary tree. This works differently than a mapelement, //because lights work on a different system. By setting the fLightSaved flag to TRUE, @@ -406,6 +422,7 @@ void AddLightToUndoList( INT32 iMapIndex, INT32 iLightRadius, UINT8 ubLightID ) CropStackToMaxLength( MAX_UNDO_COMMAND_LENGTH ); } +#endif BOOLEAN AddToUndoList( INT32 iMapIndex ) { @@ -482,12 +499,35 @@ BOOLEAN AddToUndoListCmd( INT32 iMapIndex, INT32 iCmdCount ) return( FALSE ); } + //dnl ch86 210214 + memset(pUndoInfo, 0, sizeof(undo_struct)); + EXITGRID ExitGrid; + if(GetExitGrid(iMapIndex, &ExitGrid)) + { + pUndoInfo->iExitGridNo = ExitGrid.usGridNo; + pUndoInfo->ubExitGridX = ExitGrid.ubGotoSectorX; + pUndoInfo->ubExitGridY = ExitGrid.ubGotoSectorY; + pUndoInfo->ubExitGridZ = ExitGrid.ubGotoSectorZ; + } + FindLight(iMapIndex, PRIMETIME_LIGHT, &pUndoInfo->ubLightRadius, &pUndoInfo->ubLightID); + FindLight(iMapIndex, NIGHTTIME_LIGHT, &pUndoInfo->ubLightRadius1, &pUndoInfo->ubLightID1); + FindLight(iMapIndex, ALWAYSON_LIGHT, &pUndoInfo->ubLightRadius2, &pUndoInfo->ubLightID2); + DOOR *pDoor; + if((pDoor=FindDoorInfoAtGridNo(iMapIndex)) != NULL) + { + pUndoInfo->fLocked = pDoor->fLocked; + pUndoInfo->ubTrapLevel = pDoor->ubTrapLevel; + pUndoInfo->ubTrapID = pDoor->ubTrapID; + pUndoInfo->ubLockID = pDoor->ubLockID; + } + else + pUndoInfo->ubLockID = NUM_LOCKS; + pUndoInfo->iNewMapIndex = iMapIndex; + GetItemPoolFromGround(iMapIndex, &pUndoInfo->pItemPool); + // copy the room number information (it's not in the mapelement structure) pUndoInfo->usRoomNum = gusWorldRoomInfo[ iMapIndex ]; - pUndoInfo->fLightSaved = FALSE; - pUndoInfo->ubLightRadius = 0; - pUndoInfo->ubLightID = 0; pUndoInfo->pMapTile = pData; pUndoInfo->iMapIndex = iMapIndex; @@ -581,7 +621,6 @@ BOOLEAN RemoveAllFromUndoList( void ) return( TRUE ); } - BOOLEAN ExecuteUndoList( void ) { INT32 iCmdCount, iCurCount; @@ -603,7 +642,7 @@ BOOLEAN ExecuteUndoList( void ) while ( (iCurCount < iCmdCount) && (gpTileUndoStack != NULL) ) { iUndoMapIndex = gpTileUndoStack->pData->iMapIndex; - +#if 0//dnl ch86 201214 fExitGrid = ExitGridAtGridNo( iUndoMapIndex ); // Find which map tile we are to "undo" @@ -622,6 +661,7 @@ BOOLEAN ExecuteUndoList( void ) gfIgnoreUndoCmdsForLights = FALSE; } else +#endif { // We execute the undo command node by simply swapping the contents // of the undo's MAP_ELEMENT with the world's element. SwapMapElementWithWorld( iUndoMapIndex, gpTileUndoStack->pData->pMapTile ); @@ -629,6 +669,57 @@ BOOLEAN ExecuteUndoList( void ) // copy the room number information back gusWorldRoomInfo[ iUndoMapIndex ] = gpTileUndoStack->pData->usRoomNum; + //dnl ch86 220214 + if(fExitGrid = gpTileUndoStack->pData->ubExitGridX && gpTileUndoStack->pData->ubExitGridY) + { + EXITGRID ExitGrid; + ExitGrid.usGridNo = gpTileUndoStack->pData->iExitGridNo; + ExitGrid.ubGotoSectorX = gpTileUndoStack->pData->ubExitGridX; + ExitGrid.ubGotoSectorY = gpTileUndoStack->pData->ubExitGridY; + ExitGrid.ubGotoSectorZ = gpTileUndoStack->pData->ubExitGridZ; + AddExitGridToWorld(iUndoMapIndex, &ExitGrid); + } + else + RemoveExitGridFromWorld(iUndoMapIndex); + INT16 sX, sY; + ConvertGridNoToXY(iUndoMapIndex, &sX, &sY); + if(gpTileUndoStack->pData->ubLightRadius) + PlaceLight(gpTileUndoStack->pData->ubLightRadius, sX, sY, gpTileUndoStack->pData->ubLightID, PRIMETIME_LIGHT); + else + RemoveLight(sX, sY, PRIMETIME_LIGHT); + if(gpTileUndoStack->pData->ubLightRadius1) + PlaceLight(gpTileUndoStack->pData->ubLightRadius1, sX, sY, gpTileUndoStack->pData->ubLightID1, NIGHTTIME_LIGHT); + else + RemoveLight(sX, sY, NIGHTTIME_LIGHT); + if(gpTileUndoStack->pData->ubLightRadius2) + PlaceLight(gpTileUndoStack->pData->ubLightRadius2, sX, sY, gpTileUndoStack->pData->ubLightID2, ALWAYSON_LIGHT); + else + RemoveLight(sX, sY, ALWAYSON_LIGHT); + if(gpTileUndoStack->pData->ubLockID < NUM_LOCKS) + { + DOOR Door; + memset(&Door, 0, sizeof(DOOR)); + Door.sGridNo = iUndoMapIndex; + Door.fLocked = gpTileUndoStack->pData->fLocked; + Door.ubTrapLevel = gpTileUndoStack->pData->ubTrapLevel; + Door.ubTrapID = gpTileUndoStack->pData->ubTrapID; + Door.ubLockID = gpTileUndoStack->pData->ubLockID; + AddDoorInfoToTable(&Door); + } + else + { + RemoveDoorInfoFromTable(iUndoMapIndex); + RemoveAllTopmostsOfTypeRange(iUndoMapIndex, ROTATINGKEY, ROTATINGKEY); + } + if(gpTileUndoStack->pData->pItemPool) + { + ItemPoolListMove(gpTileUndoStack->pData->iNewMapIndex, gpTileUndoStack->pData->iMapIndex, gpTileUndoStack->pData->pItemPool); + AddItemPoolGraphic(gpTileUndoStack->pData->pItemPool); + ShowItemCursor(iUndoMapIndex); + } + else + HideItemCursor(iUndoMapIndex); + // Now we smooth out the changes... //SmoothUndoMapTileTerrain( iUndoMapIndex, gpTileUndoStack->pData->pMapTile ); SmoothAllTerrainTypeRadius( iUndoMapIndex, 1, TRUE ); @@ -645,7 +736,7 @@ BOOLEAN ExecuteUndoList( void ) //an undo is called, the item is erased, but a cursor is added! I'm quickly //hacking around this by erasing all cursors here. RemoveAllTopmostsOfTypeRange( iUndoMapIndex, FIRSTPOINTERS, FIRSTPOINTERS ); - +#if 0//dnl ch86 110214 if( fExitGrid && !ExitGridAtGridNo( iUndoMapIndex ) ) { //An exitgrid has been removed, so get rid of the associated indicator. RemoveTopmost( iUndoMapIndex, FIRSTPOINTERS8 ); @@ -654,6 +745,10 @@ BOOLEAN ExecuteUndoList( void ) { //An exitgrid has been added, so add the associated indicator AddTopmostToTail( iUndoMapIndex, FIRSTPOINTERS8 ); } +#else + if(gfShowExitGrids && fExitGrid) + AddTopmostToTail(iUndoMapIndex, FIRSTPOINTERS8); +#endif } return( TRUE ); @@ -873,6 +968,11 @@ BOOLEAN CopyMapElementFromWorld( MAP_ELEMENT *pNewMapElement, INT32 iMapIndex ) pNewLevelNode = NULL; while( pOldLevelNode ) { + if(pOldLevelNode->uiFlags & LEVELNODE_ITEM)//dnl ch86 220214 skip items as they will be added depending of item pool content + { + pOldLevelNode = pOldLevelNode->pNext; + continue; + } //copy the level node pLevelNode = ( LEVELNODE* )MemAlloc( sizeof( LEVELNODE ) ); if( !pLevelNode ) @@ -1010,5 +1110,96 @@ void DetermineUndoState() } } +//dnl ch86 240214 +BOOLEAN CheckMapIndexInUndoList(INT32 iMapIndex) +{ + undo_stack *curr = gpTileUndoStack; + while(curr) + { + if(curr->pData->iMapIndex == iMapIndex) + return(TRUE); + curr = curr->pNext; + } + return(FALSE); +} + +void UpdateItemPoolInUndoList(INT32 iMapIndex, ITEM_POOL *pItemPoolOld, ITEM_POOL *pItemPoolNew) +{ + if(pItemPoolOld == pItemPoolNew) + return; + undo_stack *curr = gpTileUndoStack; + while(curr) + { + if(pItemPoolOld && curr->pData->pItemPool == pItemPoolOld || !pItemPoolOld && curr->pData->iMapIndex == iMapIndex) + curr->pData->pItemPool = pItemPoolNew; + curr = curr->pNext; + } +} + +void UpdateItemPoolMoveInUndoList(INT32 iMapIndex, INT32 iNewMapIndex) +{ + INT32 iCurCount = 0; + undo_stack *curr = gpTileUndoStack; + while(curr && iCurCount < gpTileUndoStack->iCmdCount) + { + if(curr->pData->iMapIndex == iMapIndex) + { + curr->pData->iNewMapIndex = iNewMapIndex; + return; + } + iCurCount++; + curr = curr->pNext; + } +} + +extern LEVELNODE *AddItemGraphicToWorld(INVTYPE *pItem, INT32 sGridNo, UINT8 ubLevel); +void AddItemPoolGraphic(ITEM_POOL *pItemPoolHead) +{ + ITEM_POOL *pItemPool = pItemPoolHead; + while(pItemPool) + { + pItemPool->pLevelNode = AddItemGraphicToWorld(&Item[gWorldItems[pItemPool->iItemIndex].object.usItem], gWorldItems[pItemPool->iItemIndex].sGridNo, gWorldItems[pItemPool->iItemIndex].ubLevel); + pItemPool->pLevelNode->pItemPool = pItemPoolHead; + pItemPool = pItemPool->pNext; + } +} + +void UndoItemPoolGraphicInUndoList(void)// use only for reconstruct item pool graphic if building was paste over them +{ + ITEM_POOL *pItemPool; + INT32 iCurCount = 0; + undo_stack *curr = gpTileUndoStack; + while(curr && iCurCount < gpTileUndoStack->iCmdCount) + { + if(curr->pData->pItemPool && curr->pData->iMapIndex == curr->pData->iNewMapIndex && !GetItemPoolFromGround(curr->pData->iMapIndex, &pItemPool)) + { + AddItemPoolGraphic(curr->pData->pItemPool); + ShowItemCursor(curr->pData->iMapIndex); + } + iCurCount++; + curr = curr->pNext; + } +} + +void MergeItemPoolInUndoList(INT32 iMapIndex, ITEM_POOL *pItemPool) +{ + INT32 iCurCount = 0; + undo_stack *curr = gpTileUndoStack; + while(curr && iCurCount < gpTileUndoStack->iCmdCount) + { + if(curr->pData->pItemPool && curr->pData->iMapIndex == iMapIndex && curr->pData->iMapIndex == curr->pData->iNewMapIndex) + { + DeleteItemNode(iMapIndex);// remove merged duplicate node from the list + while(pItemPool->pNext) + pItemPool = pItemPool->pNext; + pItemPool->pNext = curr->pData->pItemPool; + curr->pData->pItemPool->pPrev = pItemPool; + curr->pData->pItemPool = NULL; + break; + } + iCurCount++; + curr = curr->pNext; + } +} #endif diff --git a/Editor/Editor Undo.h b/Editor/Editor Undo.h index cf81a584..c7b470a4 100644 --- a/Editor/Editor Undo.h +++ b/Editor/Editor Undo.h @@ -18,5 +18,13 @@ void DetermineUndoState(); // Undo command flags #define MAX_UNDO_COMMAND_LENGTH 10 +//dnl ch86 220214 +BOOLEAN CheckMapIndexInUndoList(INT32 iMapIndex); +void UpdateItemPoolInUndoList(INT32 iMapIndex, ITEM_POOL *pItemPoolOld, ITEM_POOL *pItemPoolNew); +void UpdateItemPoolMoveInUndoList(INT32 iMapIndex, INT32 iNewMapIndex); +void AddItemPoolGraphic(ITEM_POOL *pItemPoolHead); +void UndoItemPoolGraphicInUndoList(void); +void MergeItemPoolInUndoList(INT32 iMapIndex, ITEM_POOL *pItemPool); + +#endif #endif -#endif \ No newline at end of file diff --git a/Editor/EditorBuildings.cpp b/Editor/EditorBuildings.cpp index 71b9c60f..1f3e6ccf 100644 --- a/Editor/EditorBuildings.cpp +++ b/Editor/EditorBuildings.cpp @@ -28,6 +28,12 @@ #include "selectwin.h" #include "Simple Render Utils.h" #include "Text.h" + //dnl ch86 100214 + #include "lighting.h" + #include "Exit Grids.h" + #include "editscreen.h" + #include "EditorItems.h" + #include "EditorMapInfo.h" #endif BOOLEAN fBuildingShowRoofs, fBuildingShowWalls, fBuildingShowRoomInfo; @@ -297,7 +303,7 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo ) { MAP_ELEMENT *pSrcMapElement; LEVELNODE *pNode; - UINT16 usType; + //UINT16 usType;//dnl ch86 110214 DeleteStuffFromMapTile( iDstGridNo ); DeleteAllLandLayers( iDstGridNo ); @@ -318,19 +324,22 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo ) pNode = pSrcMapElement->pObjectHead; while( pNode ) { - AddObjectToTail( iDstGridNo, pNode->usIndex ); + if(pNode->usIndex != GOODRING1)//dnl ch86 130214 skip light circle marker + AddObjectToTail(iDstGridNo, pNode->usIndex); pNode = pNode->pNext; } pNode = pSrcMapElement->pStructHead; while( pNode ) { - AddStructToTail( iDstGridNo, pNode->usIndex ); + if(!(pNode->uiFlags & LEVELNODE_ITEM))//dnl ch86 120214 skip items + AddStructToTail(iDstGridNo, pNode->usIndex); pNode = pNode->pNext; } pNode = pSrcMapElement->pShadowHead; while( pNode ) { - AddShadowToTail( iDstGridNo, pNode->usIndex ); + if(!(pNode->uiFlags & LEVELNODE_EXITGRID))//dnl ch86 120214 skip exit grids + AddShadowToTail(iDstGridNo, pNode->usIndex); pNode = pNode->pNext; } pNode = pSrcMapElement->pRoofHead; @@ -342,22 +351,26 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo ) pNode = pSrcMapElement->pOnRoofHead; while( pNode ) { - AddOnRoofToTail( iDstGridNo, pNode->usIndex ); + if(!(pNode->uiFlags & LEVELNODE_ITEM))//dnl ch86 120214 skip items + AddOnRoofToTail(iDstGridNo, pNode->usIndex); pNode = pNode->pNext; } pNode = pSrcMapElement->pTopmostHead; while( pNode ) { - if( pNode->usIndex != FIRSTPOINTERS1 ) + if( !(pNode->usIndex == FIRSTPOINTERS1 || pNode->usIndex == ROTATINGKEY1 || pNode->usIndex == SELRING1) )//dnl ch86 130214 AddTopmostToTail( iDstGridNo, pNode->usIndex ); pNode = pNode->pNext; } +#if 0//dnl ch86 110214 for ( usType = FIRSTROOF; usType <= LASTSLANTROOF; usType++ ) { HideStructOfGivenType( iDstGridNo, usType, (BOOLEAN)(!fBuildingShowRoofs) ); } +#endif } +#if 0//dnl ch86 220214 void MoveBuilding( INT32 iMapIndex ) { BUILDINGLAYOUTNODE *curr; @@ -386,6 +399,69 @@ void MoveBuilding( INT32 iMapIndex ) } MarkWorldDirty(); } +#else +void MoveBuilding( INT32 iMapIndex ) +{ + INT8 bLightType; + UINT8 ubLightRadius, ubLightId; + INT16 sX, sY; + INT32 iOffset, iNewGridNo; + EXITGRID ExitGrid; + DOOR Door, *pDoor; + BUILDINGLAYOUTNODE *curr; + if(!gpBuildingLayoutList) + return; + SortBuildingLayout(iMapIndex); + iOffset = iMapIndex - gsBuildingLayoutAnchorGridNo; + if(iOffset == 0)//dnl ch32 080909 + return; + // First time, set the undo gridnos to everything effected. + curr = gpBuildingLayoutList; + while(curr) + { + AddToUndoList(curr->sGridNo); + AddToUndoList(curr->sGridNo + iOffset); + curr = curr->next; + } + // Now, move the building + curr = gpBuildingLayoutList; + while(curr) + { + iNewGridNo = curr->sGridNo + iOffset; + PasteMapElementToNewMapElement(curr->sGridNo, iNewGridNo); + PasteRoomNumber(iNewGridNo, gusWorldRoomInfo[curr->sGridNo]); + if(GetExitGrid(curr->sGridNo, &ExitGrid)) + AddExitGridToWorld(iNewGridNo, &ExitGrid); + ConvertGridNoToXY(iNewGridNo, &sX, &sY); + for(bLightType=PRIMETIME_LIGHT; bLightTypesGridNo, bLightType, &ubLightRadius, &ubLightId)) + PlaceLight(ubLightRadius, sX, sY, ubLightId, bLightType); + if((pDoor=FindDoorInfoAtGridNo(curr->sGridNo)) != NULL) + { + Door = *pDoor; + Door.sGridNo = iNewGridNo; + AddDoorInfoToTable(&Door); + AddTopmostToHead(Door.sGridNo, ROTATINGKEY1); + } + ITEM_POOL *pItemPool; + if(GetItemPoolFromGround(curr->sGridNo, &pItemPool)) + { + MergeItemPoolInUndoList(iNewGridNo, pItemPool); + UpdateItemPoolMoveInUndoList(curr->sGridNo, iNewGridNo); + ItemPoolListMove(curr->sGridNo, iNewGridNo, pItemPool); + AddItemPoolGraphic(pItemPool); + ShowItemCursor(iNewGridNo); + } + DeleteStuffFromMapTile(curr->sGridNo); + curr = curr->next; + } + UndoItemPoolGraphicInUndoList();// Reconstruct item pool graphic if buliding was paste over them + UpdateRoofsView(); + UpdateWallsView(); + MarkWorldDirty(); + LightSpriteRenderAll(); +} +#endif void PasteBuilding( INT32 iMapIndex ) { @@ -410,14 +486,12 @@ void PasteBuilding( INT32 iMapIndex ) while( curr ) { PasteMapElementToNewMapElement( curr->sGridNo, curr->sGridNo + iOffset ); - //dnl ch85 070214 - RemoveAllObjectsOfTypeRange(curr->sGridNo + iOffset, GOODRING, GOODRING); - RemoveAllTopmostsOfTypeRange(curr->sGridNo + iOffset, ROTATINGKEY, SELRING); - RemoveAllStructsOfTypeRange(curr->sGridNo + iOffset, GUNS, P2ITEMS); - RemoveAllStructsOfTypeRange(curr->sGridNo + iOffset, P3ITEMS, P3ITEMS); - RemoveAllStructsOfTypeRange(curr->sGridNo + iOffset, P4ITEMS, P20ITEMS); curr = curr->next; } + //dnl ch86 220214 + UndoItemPoolGraphicInUndoList(); + UpdateRoofsView(); + UpdateWallsView(); MarkWorldDirty(); } @@ -767,13 +841,4 @@ void ExtractAndUpdateBuildingInfo() SetActiveField( 0 ); } - - #endif - - - - - - - diff --git a/Editor/EditorItems.cpp b/Editor/EditorItems.cpp index feb8cdb9..ab696a77 100644 --- a/Editor/EditorItems.cpp +++ b/Editor/EditorItems.cpp @@ -43,6 +43,7 @@ #include "Pits.h" #include "keys.h" #include "InterfaceItemImages.h" + #include "Editor Undo.h"//dnl ch86 220214 #endif #include @@ -844,7 +845,7 @@ void ShowItemCursor( INT32 iMapIndex ) pNode = gpWorldLevelData[ iMapIndex ].pTopmostHead; while( pNode ) { - if( pNode->usIndex == SELRING ) + if( pNode->usIndex == SELRING1 )//dnl ch86 240214 return; pNode = pNode->pNext; } @@ -982,6 +983,8 @@ void AddSelectedItemToWorld( INT32 sGridNo ) break; } + ITEM_POOL *pItemPoolOld; + GetItemPoolFromGround(sGridNo, &pItemPoolOld);//dnl ch86 220214 pObject = InternalAddItemToPool( &sGridNo, &gTempObject, bVisibility, 0, usFlags, 0, -1, &iItemIndex ); if( gTempObject.usItem != OWNERSHIP ) { @@ -1026,6 +1029,7 @@ void AddSelectedItemToWorld( INT32 sGridNo ) if( !GetItemPoolFromGround( sGridNo, &pItemPool ) ) Assert( 0 ); + UpdateItemPoolInUndoList(sGridNo, pItemPoolOld, pItemPool);//dnl ch86 220214 while( pItemPool ) { if( &(gWorldItems[ pItemPool->iItemIndex ].object) == pObject ) @@ -1122,7 +1126,7 @@ void DeleteSelectedItem() { SpecifyItemToEdit( NULL, -1 ); //First, check to see if there even is a currently selected item. - if( iCurrentTaskbar == TASK_MERCS ) + if( gsSelectedMercID != -1 )//dnl ch86 220214 { DeleteSelectedMercsItem(); return; @@ -1136,7 +1140,6 @@ void DeleteSelectedItem() SpecifyItemToEdit( &gWorldItems[ gpItemPool->pNext->iItemIndex ].object, gpItemPool->sGridNo ); } sGridNo = gpItemPool->sGridNo; - //remove the item if( gWorldItems[ gpItemPool->iItemIndex ].object.usItem == ACTION_ITEM ) { @@ -1148,10 +1151,16 @@ void DeleteSelectedItem() if( gpEditingItemPool == gpItemPool ) gpEditingItemPool = NULL; RemoveItemFromPool( sGridNo, gpItemPool->iItemIndex, 0 ); +#if 0//dnl ch86 220214 gpItemPool = NULL; - //determine if there are still any items at this location if( GetItemPoolFromGround( sGridNo, &gpItemPool ) ) +#else + ITEM_POOL *pItemPoolOld = gpItemPool; + GetItemPoolFromGround(sGridNo, &gpItemPool); + UpdateItemPoolInUndoList(sGridNo, pItemPoolOld, gpItemPool); + if(gpItemPool) +#endif { //reset display for remaining items SpecifyItemToEdit( &gWorldItems[ gpItemPool->iItemIndex ].object, gpItemPool->sGridNo ); } @@ -1173,7 +1182,7 @@ void DeleteSelectedItem() gpCurrItemPoolNode = pIPCurr->next; else gpCurrItemPoolNode = pIPHead; - if( gpCurrItemPoolNode ) + if( gpCurrItemPoolNode && iCurrentTaskbar == TASK_ITEMS )//dnl ch86 220214 { //get the item pool at this node's gridno. GetItemPoolFromGround( gpCurrItemPoolNode->sGridNo, &gpItemPool ); @@ -1776,4 +1785,48 @@ void ScrollEditorItemsInfo(BOOLEAN fForward)//dnl ch80 011213 gfRenderTaskbar = TRUE; } +//dnl ch86 120214 +BOOLEAN ItemPoolListMove(INT32 iOldGridNo, INT32 iNewGridNo, ITEM_POOL *pItemPool) +{ + while(pItemPool) + { + if(gWorldItems[pItemPool->iItemIndex].sGridNo == iOldGridNo) + gWorldItems[pItemPool->iItemIndex].sGridNo = iNewGridNo; + pItemPool->sGridNo = iNewGridNo; + pItemPool = pItemPool->pNext; + } + IPListNode *curr = pIPHead; + while(curr) + { + if(curr->sGridNo == iOldGridNo) + curr->sGridNo = iNewGridNo; + curr = curr->next; + } + return(TRUE); +} + +BOOLEAN DeleteItemNode(INT32 iMapIndex) +{ + IPListNode *pIPPrev = NULL, *pIPCurr = pIPHead; + while(pIPCurr) + { + if(pIPCurr->sGridNo == iMapIndex)// remove node from the list + { + if(pIPPrev) + pIPPrev->next = pIPCurr->next;// middle of list + else + pIPHead = pIPHead->next;// head of list + if(pIPCurr->next)// move the curr item pool to the next one + gpCurrItemPoolNode = pIPCurr->next; + else + gpCurrItemPoolNode = pIPHead; + MemFree(pIPCurr); + pIPCurr = NULL; + return(TRUE); + } + pIPPrev = pIPCurr, pIPCurr = pIPCurr->next; + } + return(FALSE); +} + #endif diff --git a/Editor/EditorItems.h b/Editor/EditorItems.h index 57a65d74..6e684aab 100644 --- a/Editor/EditorItems.h +++ b/Editor/EditorItems.h @@ -61,13 +61,10 @@ void HandleItemsPanel( UINT16 usScreenX, UINT16 usScreenY, INT8 bEvent ); extern INT32 giDefaultExistChance; +//dnl ch86 120214 +typedef struct TAG_ITEM_POOL ITEM_POOL; +BOOLEAN ItemPoolListMove(INT32 iOldGridNo, INT32 iNewGridNo, ITEM_POOL *pItemPool); +BOOLEAN DeleteItemNode(INT32 iMapIndex); + #endif #endif - - - - - - - - diff --git a/Editor/EditorMapInfo.h b/Editor/EditorMapInfo.h index dbcbb5d1..b9cbdf7a 100644 --- a/Editor/EditorMapInfo.h +++ b/Editor/EditorMapInfo.h @@ -26,8 +26,10 @@ enum { PRIMETIME_LIGHT, NIGHTTIME_LIGHT, - ALWAYSON_LIGHT + ALWAYSON_LIGHT, + ANY_LIGHT//dnl ch86 210214 }; + void ChangeLightDefault( INT8 bLightType ); extern INT8 gbDefaultLightType; diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 32febc58..412beaa6 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -44,6 +44,7 @@ #include "Scheduling.h" #include "MessageBoxScreen.h" #include //dnl ch37 110909 + #include "Exit Grids.h"//dnl ch86 190214 #endif //=========================================================================== @@ -155,6 +156,7 @@ void LoadSaveScreenEntry() gfDeleteFile = FALSE; gfNoFiles = FALSE; gfSaveError = FALSE;//dnl ch37 200909 + RestoreBackgroundRects();//dnl ch86 210214 // setup filename dialog box // (*.dat and *.map) as file filter @@ -666,7 +668,7 @@ void DrawFileDialog(void) MarkButtonsDirty(); RenderButtons(); - RenderButtonsFastHelp(); + //RenderButtonsFastHelp();//dnl ch86 210214 disable this because of sticky tooltip from taskbar SetFont( FONT10ARIAL ); SetFontForeground( FONT_LTKHAKI ); @@ -1056,6 +1058,11 @@ UINT32 ProcessFileIO() CreateMessageBox((STR16)(_BS(L" Error saving ") << (const char*)ubNewFilename << L" file. Try another filename? " << _BS::wget).c_str() ); return(guiCurrentScreen); } + if(gfShowExitGrids)//dnl ch86 190214 + { + gfShowExitGrids = FALSE; + ShowExitGrids(); + } if( gfShowPits ) AddAllPits(); GetSectorFromFileName(gzFilename, gWorldSectorX, gWorldSectorY, gbWorldSectorZ, fAltMap);//dnl ch31 140909 @@ -1156,6 +1163,11 @@ UINT32 ProcessFileIO() ShowHighGround(4);//dnl ch41 210909 SetRenderCenter(WORLD_COLS/2, WORLD_ROWS/2);//dnl ch43 280909 gsSelectedMercGridNo = 0;//dnl ch74 241013 to prevent CTD in IndicateSelectedMerc after loading + if(gfShowExitGrids)//dnl ch86 190214 + { + gfShowExitGrids = FALSE; + ShowExitGrids(); + } if( gfShowPits ) AddAllPits(); diff --git a/Editor/edit_sys.cpp b/Editor/edit_sys.cpp index 286503e2..a7d0bed9 100644 --- a/Editor/edit_sys.cpp +++ b/Editor/edit_sys.cpp @@ -28,6 +28,10 @@ #include "environment.h" #include "Simple Render Utils.h" #include "Road Smoothing.h" + //dnl ch86 140214 + #include "Keys.h" + #include "EditorMapInfo.h" + #include "EditorItems.h" #endif BOOLEAN PasteHigherTextureFromRadius( INT32 iMapIndex, UINT32 uiNewType, UINT8 ubRadius ); @@ -60,6 +64,9 @@ void QuickEraseMapTile( INT32 iMapIndex ) { if ( iMapIndex >= 0x80000000 ) return; + if(GetItemPoolFromGround(iMapIndex, &gpItemPool))//dnl ch86 220214 + while(gpItemPool) + DeleteSelectedItem(); AddToUndoList( iMapIndex ); DeleteStuffFromMapTile( iMapIndex ); MarkWorldDirty(); @@ -71,26 +78,24 @@ void QuickEraseMapTile( INT32 iMapIndex ) // // Common delete function for both QuickEraseMapTile and EraseMapTile // -void DeleteStuffFromMapTile( INT32 iMapIndex ) +void DeleteStuffFromMapTile(INT32 iMapIndex)//dnl ch86 140214 { - //UINT16 usUseIndex; - //UINT16 usType; - //UINT32 uiCheckType; - //UINT16 usDummy; - - //GetTileType( gpWorldLevelData[ iMapIndex ].pLandHead->usIndex, &uiCheckType ); - //RemoveLand( iMapIndex, gpWorldLevelData[ iMapIndex ].pLandHead->usIndex ); - //SmoothTerrainRadius( iMapIndex, uiCheckType, 1, TRUE ); - - RemoveExitGridFromWorld( iMapIndex ); - RemoveAllStructsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllObjectsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllShadowsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllLandsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllRoofsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllOnRoofsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - RemoveAllTopmostsOfTypeRange( iMapIndex, FIRSTTEXTURE, WIREFRAMES ); - PasteRoomNumber( iMapIndex, 0 ); + INT16 sX, sY; + ConvertGridNoToXY(iMapIndex, &sX, &sY); + for(INT8 bLightType=PRIMETIME_LIGHT; bLightTypeubShadeLevel = DEFAULT_SHADE_LEVEL; } - AddLightToUndoList( iMapIndex, 0, 0 ); + //AddLightToUndoList( iMapIndex, 0, 0 );//dnl ch86 200214 return( TRUE ); } @@ -3240,6 +3245,7 @@ BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType ) // Returns TRUE if deleted the light, otherwise, returns FALSE. // i.e. FALSE is not an error condition! // +#if 0//dnl ch86 210214 BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY ) { INT32 iCount; @@ -3297,7 +3303,25 @@ BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY ) return( fRemovedLight ); } +#else +BOOLEAN RemoveLight(INT16 iMapX, INT16 iMapY, INT8 bLightType) +{ + INT32 iCount, iMapIndex; + UINT8 ubLightRadius, ubLightId; + BOOLEAN fRemovedLight = FALSE; + iMapIndex = FASTMAPROWCOLTOPOS(iMapY, iMapX); + while(FindLight(iMapIndex, bLightType, &ubLightRadius, &ubLightId, &iCount)) + { + LightSpritePower(iCount, FALSE); + LightSpriteDestroy(iCount); + fRemovedLight = TRUE; + } + if(fRemovedLight && !FindLight(iMapIndex, ANY_LIGHT, &ubLightRadius, &ubLightId)) + RemoveAllObjectsOfTypeRange(iMapIndex, GOODRING, GOODRING); + return(fRemovedLight); +} +#endif //---------------------------------------------------------------------------------------------- // ShowLightPositionHandles @@ -3818,6 +3842,8 @@ void HandleMouseClicksInGameScreen()//dnl ch80 011213 static UINT32 iLastMapIndexLB(-1), iLastMapIndexRB(-1), iLastMapIndexMB(-1); INT16 sX, sY; BOOLEAN fPrevState; + UINT8 ubLightRadius, ubLightId;//dnl ch86 210214 + if(!GetMouseXY(&sGridX, &sGridY)) return; if(iCurrentTaskbar == TASK_OPTIONS || iCurrentTaskbar == TASK_NONE)// if in taskbar modes which don't process clicks in the world @@ -3838,7 +3864,13 @@ void HandleMouseClicksInGameScreen()//dnl ch80 011213 for(sX=(INT16)gSelectRegion.iLeft; sX<=(INT16)gSelectRegion.iRight; sX++) { if(iDrawMode == (DRAW_MODE_LIGHT + DRAW_MODE_ERASE)) - RemoveLight(sX, sY); + { + if(FindLight(iMapIndex, gbDefaultLightType, &ubLightRadius, &ubLightId))//dnl ch86 210214 + { + AddToUndoList(iMapIndex); + RemoveLight(sX, sY, gbDefaultLightType); + } + } else EraseMapTile(MAPROWCOLTOPOS(sY, sX)); } @@ -3927,8 +3959,12 @@ void HandleMouseClicksInGameScreen()//dnl ch80 011213 case DRAW_MODE_CIVILIAN: AddMercToWorld(iMapIndex);// Handle adding mercs to the world break; - case DRAW_MODE_LIGHT: - PlaceLight(gsLightRadius, sGridX, sGridY, 0);// Add a normal light to the world + case DRAW_MODE_LIGHT://dnl ch86 210214 + if(FindLight(iMapIndex, gbDefaultLightType, &ubLightRadius, &ubLightId) && ubLightRadius == gsLightRadius && ubLightId == 0) + break; + AddToUndoList(iMapIndex); + RemoveLight(sGridX, sGridY, gbDefaultLightType); + PlaceLight(gsLightRadius, sGridX, sGridY, 0, gbDefaultLightType);// Add a normal light to the world break; case DRAW_MODE_SAW_ROOM: case DRAW_MODE_ROOM: @@ -4420,6 +4456,7 @@ void DrawObjectsBasedOnSelectionRegion() { INT32 x, y, iMapIndex; BOOLEAN fSkipTest; + EXITGRID ExitGrid;//dnl ch86 190214 //Certain drawing modes are placed with 100% density. Those cases are checked here, //so the density test can be skipped. @@ -4447,9 +4484,13 @@ void DrawObjectsBasedOnSelectionRegion() switch( iDrawMode ) { case DRAW_MODE_EXITGRID: - AddToUndoList( iMapIndex ); - AddExitGridToWorld( iMapIndex, &gExitGrid ); - AddTopmostToTail( iMapIndex, FIRSTPOINTERS8 ); + if(GetExitGrid(iMapIndex, &ExitGrid) == FALSE || !ExitGrid.Equal(gExitGrid))//dnl ch86 190214 + { + RemoveTopmost(iMapIndex, FIRSTPOINTERS8); + AddToUndoList(iMapIndex); + AddExitGridToWorld(iMapIndex, &gExitGrid); + AddTopmostToTail(iMapIndex, FIRSTPOINTERS8); + } break; case DRAW_MODE_DEBRIS: PasteDebris( iMapIndex ); break; case DRAW_MODE_FLOORS: PasteSingleFloor( iMapIndex ); break; @@ -4535,7 +4576,7 @@ UINT32 EditScreenHandle( void ) // If editing mercs, handle that stuff ProcessMercEditing(); - if(!gfSummaryWindowActive)//dnl ch78 261113 + if(!gfSummaryWindowActive && !gfEditingDoor)//dnl ch78 261113 //dnl ch86 220214 EnsureStatusOfEditorButtons(); // Handle scrolling of the map if needed @@ -4680,7 +4721,7 @@ void ShowHighGround(INT32 iShowHighGroundCommand)//dnl ch2 210909 case 0: for(int cnt=0; cntiLight == iCount) + break; + if(cnt == MAX_NUM_SOLDIERS) + { + *pubLightRadius = pLightNames[LightSprites[iCount].iTemplate][4] - '0'; + *pubLightId = LightSprites[iCount].uiLightType; + if(piSprite) + *piSprite = iCount; + return(TRUE); + } + } + } + return(FALSE); +} + #else //non-editor version #include "types.h" @@ -4785,4 +4855,3 @@ UINT32 EditScreenShutdown( ) } #endif - diff --git a/Editor/editscreen.h b/Editor/editscreen.h index 50a51951..78e0d025 100644 --- a/Editor/editscreen.h +++ b/Editor/editscreen.h @@ -45,8 +45,11 @@ UINT32 WaitForSelectionWindowResponse( void ); UINT32 WaitForMessageBoxResponse( UINT32 uiCurrentScreen ); UINT32 WaitForHelpScreenResponse( void ); -BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType ); -BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY ); +//dnl ch86 210214 +BOOLEAN FindLight(INT32 iGridNo, INT8 bLightType, UINT8 *pubLightRadius, UINT8 *pubLightId, INT32 *piSprite=NULL); +BOOLEAN PlaceLight(INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType, INT8 bLightType); +BOOLEAN RemoveLight(INT16 iMapX, INT16 iMapY, INT8 bLightType); + extern BOOLEAN gfMercResetUponEditorEntry; void ShowEditorToolbar( INT32 iNewTaskMode ); diff --git a/Init.cpp b/Init.cpp index b06b1441..20750e54 100644 --- a/Init.cpp +++ b/Init.cpp @@ -118,7 +118,7 @@ extern BOOLEAN gfUseConsecutiveQuickSaveSlots; extern HINSTANCE ghInstance; -extern OBJECTTYPE GLOCK_17_ForUseWithLOS; +//extern OBJECTTYPE GLOCK_17_ForUseWithLOS;//dnl ch86 120214 // Prepends the language prefix to the file name in a proposed path. static void AddLanguagePrefix(STR fileName, const STR language) @@ -1525,7 +1525,7 @@ UINT32 InitializeJA2(void) //ADB When a merc calcs CTGT for a thrown item he uses a GLOCK temp item //but we don't want to recreate it every single time CTGT is called, so init the GLOCK here - CreateItem(GLOCK_17, 100, &GLOCK_17_ForUseWithLOS); + //CreateItem(GLOCK_17, 100, &GLOCK_17_ForUseWithLOS);//dnl ch86 120214 move to LOS.cpp #ifdef JA2BETAVERSION diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index 66ed84d1..efe4dbb7 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -6083,6 +6083,8 @@ INT8 ChanceToGetThrough( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOAT d UINT16 oldAttackingWeapon = pFirer->usAttackingWeapon; //GLOCK_17_ForUseWithLOS is init in InitializeJA2() + if(GLOCK_17_ForUseWithLOS.usItem != GLOCK_17)//dnl ch86 120214 + CreateItem(GLOCK_17, 100, &GLOCK_17_ForUseWithLOS); pFirer->inv[ HANDPOS ] = GLOCK_17_ForUseWithLOS; pFirer->usAttackingWeapon = GLOCK_17; @@ -8099,7 +8101,7 @@ FLOAT CalcEffectiveMagFactor( SOLDIERTYPE *pShooter, FLOAT fRealMagFactor ) return fRealMagFactor; FLOAT fMaxEffectiveMagFactor = fRealMagFactor * gGameCTHConstants.SCOPE_EFFECTIVENESS_MULTIPLIER; - FLOAT fFinalEffectiveFactor = 0.1; + FLOAT fFinalEffectiveFactor = 0.1f; // new trait system grants special thresholds if ( gGameOptions.fNewTraitSystem ) diff --git a/TileEngine/Exit Grids.cpp b/TileEngine/Exit Grids.cpp index 38a46261..d5cbf429 100644 --- a/TileEngine/Exit Grids.cpp +++ b/TileEngine/Exit Grids.cpp @@ -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; iusGridNo, &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 diff --git a/TileEngine/SaveLoadMap.cpp b/TileEngine/SaveLoadMap.cpp index 473fd553..ac74c050 100644 --- a/TileEngine/SaveLoadMap.cpp +++ b/TileEngine/SaveLoadMap.cpp @@ -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; diff --git a/TileEngine/SaveLoadMap.h b/TileEngine/SaveLoadMap.h index 05efca65..f0298532 100644 --- a/TileEngine/SaveLoadMap.h +++ b/TileEngine/SaveLoadMap.h @@ -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 ); diff --git a/TileEngine/lighting.h b/TileEngine/lighting.h index 5f2f2b8f..c7d65a90 100644 --- a/TileEngine/lighting.h +++ b/TileEngine/lighting.h @@ -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 diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index 1e12d6bd..486277cb 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -3552,6 +3552,7 @@ void TrashWorld( void ) TrashDoorTable(); TrashMapEdgepoints(); TrashDoorStatusArray(); + TrashExitGridTable();//dnl ch86 170214 //gfBlitBattleSectorLocator = FALSE; gfWorldLoaded = FALSE; diff --git a/TileEngine/worlddef.h b/TileEngine/worlddef.h index 763ec3f0..db8447bf 100644 --- a/TileEngine/worlddef.h +++ b/TileEngine/worlddef.h @@ -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 diff --git a/TileEngine/worldman.cpp b/TileEngine/worldman.cpp index 2679984c..f0944cc2 100644 --- a/TileEngine/worldman.cpp +++ b/TileEngine/worldman.cpp @@ -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