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:
Kriplo
2014-03-02 11:25:11 +00:00
parent db9ecb102d
commit a665154a62
22 changed files with 633 additions and 126 deletions
+3 -3
View File
@@ -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();
}
+204 -13
View File
@@ -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,17 +74,29 @@ void DisableUndo()
gfUndoEnabled = FALSE;
}
// undo node data element
// undo node data element //dnl ch86 210214
typedef struct
{
INT32 iMapIndex;
INT32 iNewMapIndex;// item pool translation when move bulding
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
ITEM_POOL *pItemPool;
UINT8 ubItemPoolLevel;
UINT8 ubLightRadius;// radius of prime light
UINT8 ubLightID;// only applies if a light was saved.
//DBrot: More Rooms
//UINT8 ubRoomNum;
UINT16 usRoomNum;
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
@@ -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
+8
View File
@@ -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
+82 -17
View File
@@ -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,18 +324,21 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo )
pNode = pSrcMapElement->pObjectHead;
while( pNode )
{
if(pNode->usIndex != GOODRING1)//dnl ch86 130214 skip light circle marker
AddObjectToTail(iDstGridNo, pNode->usIndex);
pNode = pNode->pNext;
}
pNode = pSrcMapElement->pStructHead;
while( pNode )
{
if(!(pNode->uiFlags & LEVELNODE_ITEM))//dnl ch86 120214 skip items
AddStructToTail(iDstGridNo, pNode->usIndex);
pNode = pNode->pNext;
}
pNode = pSrcMapElement->pShadowHead;
while( pNode )
{
if(!(pNode->uiFlags & LEVELNODE_EXITGRID))//dnl ch86 120214 skip exit grids
AddShadowToTail(iDstGridNo, pNode->usIndex);
pNode = pNode->pNext;
}
@@ -342,22 +351,26 @@ void PasteMapElementToNewMapElement( INT32 iSrcGridNo, INT32 iDstGridNo )
pNode = pSrcMapElement->pOnRoofHead;
while( pNode )
{
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; bLightType<ANY_LIGHT; bLightType++)
if(FindLight(curr->sGridNo, 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
+58 -5
View File
@@ -43,6 +43,7 @@
#include "Pits.h"
#include "keys.h"
#include "InterfaceItemImages.h"
#include "Editor Undo.h"//dnl ch86 220214
#endif
#include <vfs/Tools/vfs_log.h>
@@ -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
+5 -8
View File
@@ -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
+3 -1
View File
@@ -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;
+13 -1
View File
@@ -44,6 +44,7 @@
#include "Scheduling.h"
#include "MessageBoxScreen.h"
#include <vfs/Core/vfs.h>//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();
+24 -11
View File
@@ -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,17 +78,15 @@ 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 );
INT16 sX, sY;
ConvertGridNoToXY(iMapIndex, &sX, &sY);
for(INT8 bLightType=PRIMETIME_LIGHT; bLightType<ANY_LIGHT; bLightType++)
RemoveLight(sX, sY, bLightType);
RemoveAllTopmostsOfTypeRange(iMapIndex, ROTATINGKEY, ROTATINGKEY);
RemoveDoorInfoFromTable(iMapIndex);
RemoveTopmost(iMapIndex, FIRSTPOINTERS8);
RemoveExitGridFromWorld(iMapIndex);
RemoveAllStructsOfTypeRange(iMapIndex, FIRSTTEXTURE, WIREFRAMES);
RemoveAllObjectsOfTypeRange(iMapIndex, FIRSTTEXTURE, WIREFRAMES);
@@ -164,7 +169,7 @@ void EraseMapTile( INT32 iMapIndex )
RemoveAllObjectsOfTypeRange( iMapIndex, FIRSTROAD, LASTROAD );
// Note, for this routine, cliffs are considered a subset of banks
RemoveAllStructsOfTypeRange( iMapIndex, ANIOSTRUCT, ANIOSTRUCT );
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTCLIFF, LASTBANKS );
RemoveAllStructsOfTypeRange( iMapIndex, FIRSTCLIFFHANG, LASTBANKS );//dnl ch86 190214
RemoveAllShadowsOfTypeRange( iMapIndex, FIRSTCLIFFSHADOW, LASTCLIFFSHADOW );
RemoveAllObjectsOfTypeRange( iMapIndex, FIRSTCLIFFHANG, LASTCLIFFHANG );
RemoveAllStructsOfTypeRange( iMapIndex, FENCESTRUCT, FENCESTRUCT );
@@ -212,6 +217,14 @@ void EraseMapTile( INT32 iMapIndex )
case DRAW_MODE_ROADS:
RemoveAllObjectsOfTypeRange( iMapIndex, ROADPIECES, ROADPIECES );
break;
case DRAW_MODE_DOORKEYS://dnl ch86 220214
if(FindDoorInfoAtGridNo(iMapIndex))
{
AddToUndoList(iMapIndex);
RemoveDoorInfoFromTable(iMapIndex);
RemoveAllTopmostsOfTypeRange(iMapIndex, ROTATINGKEY, ROTATINGKEY);
}
break;
default:
//DeleteStuffFromMapTile( iMapIndex );
break;
+1 -1
View File
@@ -29,7 +29,7 @@ extern UINT32 gDoCliffs;
void EraseMapTile( INT32 iMapIndex );
void QuickEraseMapTile( INT32 iMapIndex );
void DeleteStuffFromMapTile( INT32 iMapIndex );
void DeleteStuffFromMapTile(INT32 iMapIndex);//dnl ch86 140214
void PasteDebris( INT32 iMapIndex );
+80 -11
View File
@@ -1331,6 +1331,7 @@ void HandleJA2ToolbarSelection( void )
case DRAW_MODE_ISOLATEDPOINT:
case DRAW_MODE_HIGH_GROUND://dnl ch1 210909
case DRAW_MODE_DOORKEYS://dnl ch86 220214
iDrawMode += DRAW_MODE_ERASE;
break;
@@ -1392,6 +1393,8 @@ void HandleKeyboardShortcuts( )
{
if(InOverheadMap() && !(EditorInputEvent.usParam == ESC))//dnl ch81 031213
return;
if(gfEditingDoor && !(EditorInputEvent.usParam == ESC || EditorInputEvent.usParam == ENTER))//dnl ch86 220214
return;
if( gfGotoGridNoUI )
{
switch( EditorInputEvent.usParam )
@@ -2606,8 +2609,10 @@ UINT32 PerformSelectedAction( void )
ExtractAndUpdateOptions();
return(LOADSAVE_SCREEN);
case ACTION_UNDO:
case ACTION_UNDO://dnl ch86 240213
ExecuteUndoList();
UpdateRoofsView();
UpdateWallsView();
gfRenderWorld = TRUE;
break;
@@ -3157,7 +3162,7 @@ void ShowCurrentSlotImage( HVOBJECT hVObj, INT32 iWindow )
//
// Creates and places a light of selected radius and color into the world.
//
BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType )
BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType, INT8 bLightType )//dnl ch86 210214
{
INT32 iLightHandle;
UINT8 ubIntensity;
@@ -3208,7 +3213,7 @@ BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType )
return( FALSE );
}
switch( gbDefaultLightType )
switch( bLightType )//dnl ch86 210214
{
case PRIMETIME_LIGHT:
LightSprites[ iLightHandle ].uiFlags |= LIGHT_PRIMETIME;
@@ -3225,7 +3230,7 @@ BOOLEAN PlaceLight( INT16 sRadius, INT16 iMapX, INT16 iMapY, INT16 sType )
gpWorldLevelData[ iMapIndex ].pObjectHead->ubShadeLevel = 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:
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; cnt<WORLD_MAX; cnt++)
{
if(!gpWorldLevelData[cnt].sHeight)
if(!gpWorldLevelData[cnt].sHeight && GridNoOnVisibleWorldTile(cnt))//dnl ch86 210214
{
RemoveTopmost(cnt, FIRSTPOINTERS7);
{
@@ -4695,7 +4736,7 @@ void ShowHighGround(INT32 iShowHighGroundCommand)//dnl ch2 210909
ScreenMsg(FONT_MCOLOR_WHITE, MSG_INTERFACE, pShowHighGroundText[0] );
for(int cnt=0; cnt<WORLD_MAX; cnt++)
{
if(gpWorldLevelData[cnt].sHeight)
if(gpWorldLevelData[cnt].sHeight && GridNoOnVisibleWorldTile(cnt))//dnl ch86 210214
{
RemoveTopmost(cnt, FIRSTPOINTERS11);
{
@@ -4763,6 +4804,35 @@ void RemoveKeyboardItemCreationUI()
MarkWorldDirty();
}
BOOLEAN FindLight(INT32 iGridNo, INT8 bLightType, UINT8 *pubLightRadius, UINT8 *pubLightId, INT32 *piSprite)//dnl ch86 210214
{
INT8 bSpriteLightType;
INT16 sX, sY;
INT32 iCount, cnt;
SOLDIERTYPE *pSoldier;
ConvertGridNoToXY(iGridNo, &sX, &sY);
for(iCount=0; iCount<MAX_LIGHT_SPRITES; iCount++)
{
bSpriteLightType = (LightSprites[iCount].uiFlags & LIGHT_PRIMETIME ? PRIMETIME_LIGHT : (LightSprites[iCount].uiFlags & LIGHT_NIGHTTIME ? NIGHTTIME_LIGHT : ALWAYSON_LIGHT));
if((LightSprites[iCount].uiFlags & LIGHT_SPR_ACTIVE) && LightSprites[iCount].iX == sX && LightSprites[iCount].iY == sY && (bLightType == bSpriteLightType || bLightType == ANY_LIGHT))
{
for(cnt=0; cnt<MAX_NUM_SOLDIERS; cnt++)
if(GetSoldier(&pSoldier, cnt) && pSoldier->iLight == 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
+5 -2
View File
@@ -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 );
+2 -2
View File
@@ -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
+3 -1
View File
@@ -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 )
+101 -12
View File
@@ -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 );
}
}
+6 -1
View File
@@ -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
+2 -1
View File
@@ -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;
+3 -7
View File
@@ -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;
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 );
+1 -1
View File
@@ -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
+1
View File
@@ -3552,6 +3552,7 @@ void TrashWorld( void )
TrashDoorTable();
TrashMapEdgepoints();
TrashDoorStatusArray();
TrashExitGridTable();//dnl ch86 170214
//gfBlitBattleSectorLocator = FALSE;
gfWorldLoaded = FALSE;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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