Brief: //dnl ch74

- Couple map editor fixes.
Details:
- Map loading not properly set Vanilla global variable switch.
- Loading AIMNAS maps of version 28 cause CTD due to incorrect StackedObjectData loading sizeof.
- Only in editor mode and if NAS setting is on inseparable and default attachments will be always add, but default attachments will not, so older maps should be converted from mapeditor to new version.
- Fix CTD if try to place items from tab selection which contains no items.
- There was missing part from ch4 for mouse wheel support in mapeditor.
- There was conflict between keyboard and mouse events creating problems when try to select taskbar options by mouse.
- Fix annoying message of using improper attachment during item place if item consist of default or inseparable attachments.
- Remove hints to display if loading map from editor.
- Fix CTD if have previously selected merc and loading another (smaller) map.
- Saving map as Vanilla will check if attachment is valid for 1.12, that means you will lost some stuff from NIV if save in Vanilla mode, so you should always save map in newest format if want play map in 1.13.
- Add correct weight recalculation when saving in Vanilla format using old OBJECTTYPE.
- Remove entry points check during map save as Scheinworld reported problem with basement levels and similar maps which doesn't need entry points.
- Fix displaying wrong map version in summary window because MapInfo is incorrectly saved in all previous mapeditors.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6530 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Kriplo
2013-10-25 18:48:37 +00:00
parent c5e72c4265
commit f008316275
12 changed files with 101 additions and 46 deletions
+4
View File
@@ -907,7 +907,11 @@ void AddSelectedItemToWorld( INT32 sGridNo )
fEditorCreateItemFromKeyboard = FALSE;
}
else
{
if(!eInfo.pusItemIndex)//dnl ch74 181013
return;
CreateItem( eInfo.pusItemIndex[eInfo.sSelItemIndex], 100, &gTempObject );
}
}
usFlags = 0;
switch( gTempObject.usItem )
+1 -1
View File
@@ -1755,7 +1755,7 @@ void ReEvaluateAttachmentStatii()
case 5: usAttachment = UNDER_GLAUNCHER; break;
default: Assert(0); continue;
}
if( ValidItemAttachment( gpItem, usAttachment, TRUE ) )
if( ValidItemAttachment( gpItem, usAttachment, TRUE, FALSE ) )//dnl ch74 211013
EnableButton( guiAttachmentButton[ i ] );
else
DisableButton( guiAttachmentButton[ i ] );
+1 -9
View File
@@ -46,8 +46,6 @@
#include <vfs/Core/vfs.h>//dnl ch37 110909
#endif
INT16 gsMouseWheelDeltaValue;
//===========================================================================
BOOLEAN gfErrorCatch = FALSE;
@@ -1117,6 +1115,7 @@ UINT32 ProcessFileIO()
fRaiseWorld = FALSE;//dnl ch3 210909
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( gfShowPits )
AddAllPits();
@@ -1271,10 +1270,3 @@ UINT32 LoadSaveScreenShutdown( )
}
#endif
+2 -3
View File
@@ -165,7 +165,7 @@ BOOLEAN fDontUseRandom = TRUE;//dnl ch8 210909
BOOLEAN fDontUseClick = FALSE;//dnl ch7 210909
BOOLEAN fShowHighGround = FALSE;//dnl ch2 210909
BOOLEAN fRaiseWorld = FALSE;//dnl ch3 210909
BOOLEAN gfVanillaMode = TRUE;//dnl ch33 091009
BOOLEAN gfVanillaMode = FALSE;//dnl ch33 091009 //dnl ch74 191013 by default is better to save all maps in newest format
BOOLEAN gfResizeMapOnLoading = FALSE;
INT32 TestButtons[10];
@@ -1379,14 +1379,13 @@ void HandleJA2ToolbarSelection( void )
//
// Select action to be taken based on the user's current key press (if any)
//
extern INT8 gbCurrSelect;
extern void DeleteSelectedMercsItem();
void HandleKeyboardShortcuts( )
{
static INT32 iSavedMode;
static BOOLEAN fShowTrees = TRUE;
while( DequeueEvent( &EditorInputEvent ) )
while( PeekSpecificEvent(KEY_DOWN | KEY_UP | KEY_REPEAT) && DequeueEvent( &EditorInputEvent ) )//dnl ch74 221013
{
if( !HandleSummaryInput( &EditorInputEvent ) && !HandleTextInput( &EditorInputEvent ) && EditorInputEvent.usEvent == KEY_DOWN )
{
+20 -4
View File
@@ -141,6 +141,7 @@
#include "connect.h"
#include "Map Screen Interface Map Inventory.h"//dnl ch51 081009
#include "Sys Globals.h"//dnl ch74 201013
/////////////////////////////////////////////////////
//
@@ -2602,8 +2603,8 @@ BOOLEAN StackedObjectData::Load( INT8** hBuffer, float dMajorMapVersion, UINT8 u
// are now used. Due to this, we only have to reduce for the sizes of bDirtLevel and sObjectFlag, but not sRepairThreshold (sizeof(ObjectData) is now 40).
// But of course, we now 'read' the values for sRepairThreshold, but there weren't any in older map versions, resulting in garbage values - we therefore set that manually to 100
// Of course, once the ObjectData-Class is altered, this has to be altered as well!
LOADDATA(&(this->data), *hBuffer, sizeof(ObjectData) - (sizeof(this->data.bDirtLevel) + sizeof(this->data.sObjectFlag) ) );
//dnl ch74 241013 We cannot change past so hardcode 32 simply because that was sizeof(ObjectData) before current and all future changes ;-)
LOADDATA(&(this->data), *hBuffer, /*sizeof(ObjectData) - (sizeof(this->data.bDirtLevel) + sizeof(this->data.sObjectFlag) )*/32);
this->data.sRepairThreshold = 100;
}
else
@@ -2797,7 +2798,7 @@ BOOLEAN OBJECTTYPE::Load( INT8** hBuffer, float dMajorMapVersion, UINT8 ubMinorM
LOADDATA( &OldSavedObject101, *hBuffer, sizeof(OLD_OBJECTTYPE_101) );
(*this) = OldSavedObject101;
}
#if 0//dnl ch74 201013 only inseparable attachments should always exist but rather at gun status instead of 100%, if default attachments is missing then problem is map which should be fixed by modders with latest mapeditor or have really old savegame but that should not be fix just by magically add missing default attachment :-)
RemoveProhibitedAttachments(NULL, this, (*this).usItem);
//Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you?
@@ -2811,7 +2812,22 @@ BOOLEAN OBJECTTYPE::Load( INT8** hBuffer, float dMajorMapVersion, UINT8 ubMinorM
CreateItem(Item [ (*this).usItem ].defaultattachments[cnt],100,&defaultAttachment);
this->AttachObject(NULL,&defaultAttachment, FALSE);
}
#else
if(this->usItem && (gGameOptions.ubAttachmentSystem || gfEditMode))
{
RemoveProhibitedAttachments(NULL, this, this->usItem);
//Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you?
//this should fix that...
for(UINT8 cnt=0; cnt<MAX_DEFAULT_ATTACHMENTS; cnt++)
{
if(Item[this->usItem].defaultattachments[cnt] == NONE || !(gGameOptions.ubAttachmentSystem && Item[Item[this->usItem].defaultattachments[cnt]].inseparable || gfEditMode))
break;
OBJECTTYPE defaultAttachment;
CreateItem(Item[this->usItem].defaultattachments[cnt], (*this)[0]->data.gun.bGunStatus, &defaultAttachment);
this->AttachObject(NULL, &defaultAttachment, FALSE);
}
}
#endif
return TRUE;
}
+13 -4
View File
@@ -14,7 +14,6 @@
//**
#include "types.h"
#include <windows.h>
#include <winuser.h>//dnl
#include <stdio.h>
#include <memory.h>
#include "debug.h"
@@ -80,8 +79,8 @@ UINT32 guiX2ButtonRepeatTimer;
BOOLEAN gfTrackMousePos; // TRUE = queue mouse movement events, FALSE = don't
BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed
BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed
BOOLEAN gfMiddleButtonState;//dnl TRUE = Pressed, FALSE = Not Pressed
//INT16 gsMouseWheelDeltaValue;//dnl positive value indicates that the wheel was rotated forward, negative value indicates that the wheel was rotated backward, and user handler procedure for mouse wheel should restore after usege this value to zero!
BOOLEAN gfMiddleButtonState;//dnl ch4 210909 TRUE = Pressed, FALSE = Not Pressed
INT16 gsMouseWheelDeltaValue;//dnl ch4 210909 positive value indicates that the wheel was rotated forward, negative value indicates that the wheel was rotated backward, and user handler procedure for mouse wheel should restore after usege this value to zero!
BOOLEAN gfX1ButtonState;
BOOLEAN gfX2ButtonState;
@@ -188,7 +187,8 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
QueueEvent(X2_BUTTON_UP, 0, uiParam);
}
break;
case WM_MOUSEWHEEL:
case WM_MOUSEWHEEL:
gsMouseWheelDeltaValue = GetMouseWheelDeltaValue(((MOUSEHOOKSTRUCTEX *)lParam)->mouseData);//dnl ch4 210909
if(p_mhs->mouseData==(WHEEL_DELTA<<16)) //up MessageBeep(-1);
QueueEvent(MOUSE_WHEEL_UP, 0, uiParam);
if(p_mhs->mouseData==(-WHEEL_DELTA<<16)) //dn MessageBeep(0x00000040L);
@@ -1754,3 +1754,12 @@ INT16 GetMouseWheelDeltaValue( UINT32 wParam )
return( sDelta / WHEEL_DELTA );
}
BOOLEAN PeekSpecificEvent(UINT32 uiMaskFlags)//dnl ch74 221013
{
BOOLEAN result = FALSE;
EnterCriticalSection(&gcsInputQueueLock);
if(gusQueueCount > 0 && (gEventQueue[gusHeadIndex].usEvent & uiMaskFlags))
result = TRUE;
LeaveCriticalSection(&gcsInputQueueLock);
return(result);
}
+5 -9
View File
@@ -30,9 +30,6 @@
#define X2_BUTTON_DOWN 0x8040
#define X2_BUTTON_UP 0x8050
#define X2_BUTTON_REPEAT 0x8060
//#define MIDDLE_BUTTON_UP 0x1000//dnl
//#define MIDDLE_BUTTON_DOWN 0x2000//dnl
#define SHIFT_DOWN 0x01
#define CTRL_DOWN 0x02
@@ -117,25 +114,24 @@ BOOLEAN InputEventInside(InputAtom *Event, UINT32 uiX1, UINT32 uiY1, UINT32 uiX2
INT16 GetMouseWheelDeltaValue( UINT32 wParam );
extern void DequeueAllKeyBoardEvents();
extern BOOLEAN PeekSpecificEvent(UINT32 uiMaskFlags);//dnl ch74 221013
extern BOOLEAN gfKeyState[256]; // TRUE = Pressed, FALSE = Not Pressed
extern INT16 gusMouseXPos; // X position of the mouse on screen
extern INT16 gusMouseYPos; // y position of the mouse on screen
extern INT16 gsMouseWheelDeltaValue;//dnl
extern INT16 gsMouseWheelDeltaValue;//dnl ch4 210909
extern BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed
extern BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed
extern BOOLEAN gfMiddleButtonState;//dnl TRUE = Pressed, FALSE = Not Pressed
extern BOOLEAN gfMiddleButtonState;//dnl ch4 210909 TRUE = Pressed, FALSE = Not Pressed
extern BOOLEAN gfSGPInputReceived;
#define _KeyDown(a) gfKeyState[(a)]
#define _LeftButtonDown gfLeftButtonState
#define _RightButtonDown gfRightButtonState
#define _MiddleButtonDown gfMiddleButtonState//dnl
#define _WheelValue gsMouseWheelDeltaValue//dnl
#define _MiddleButtonDown gfMiddleButtonState//dnl ch4 210909
#define _WheelValue gsMouseWheelDeltaValue//dnl ch4 210909
#define _MouseXPos gusMouseXPos
#define _MouseYPos gusMouseYPos
+12 -4
View File
@@ -1125,13 +1125,18 @@ OLD_OBJECTTYPE_101& OLD_OBJECTTYPE_101::operator=(OBJECTTYPE& src)
if((void*)this != (void*)&src)
{
memset(this, 0, sizeof(OLD_OBJECTTYPE_101));
if(src.usItem >= OLD_MAXITEMS)//dnl ch74 191013
{
this->fFlags = OBJECT_UNDROPPABLE;
return(*this);
}
this->usItem = src.usItem;
this->ubNumberOfObjects = src.ubNumberOfObjects;
this->ubWeight = (UINT8)CalculateObjectWeight(&src);//dnl??? need test, probably this should be calculated after you create old object
this->fFlags = src.fFlags;
this->ubMission = src.ubMission;
this->ubNumberOfObjects = src.ubNumberOfObjects;
this->usItem = src.usItem;
this->ubWeight = Item[this->usItem].ubWeight * this->ubNumberOfObjects;//dnl ch74 191013
if(ubNumberOfObjects == 1)
{
this->ugYucky.bGunStatus = (INT8)src[0]->data.gun.bGunStatus;
@@ -1158,6 +1163,8 @@ OLD_OBJECTTYPE_101& OLD_OBJECTTYPE_101::operator=(OBJECTTYPE& src)
this->ugYucky.usGunAmmoItem = src[0]->data.gun.usGunAmmoItem;
this->ugYucky.bGunAmmoStatus = (INT8)src[0]->data.gun.bGunAmmoStatus;
this->ugYucky.ubGunState = src[0]->data.gun.ubGunState;
if(this->ugYucky.ubGunAmmoType && this->ugYucky.ubGunShotsLeft)//dnl ch74 191013
this->ubWeight += Item[this->ugYucky.usGunAmmoItem].ubWeight;
break;
}
@@ -1211,9 +1218,10 @@ OLD_OBJECTTYPE_101& OLD_OBJECTTYPE_101::operator=(OBJECTTYPE& src)
int i = 0;
for(attachmentList::iterator iter=src[0]->attachments.begin(); iter!=src[0]->attachments.end(); ++iter)
{
//dnl??? this part should check if attachment is valid for 1.12, but then means you will lost some stuff from NIV, and if you wnat play map in older 1.13 versions this is not good
//if(iter->usItem)
// ;
//dnl ch74 191013 check if attachment is valid for 1.12, that means you will lost some stuff from NIV if save in Vanilla mode, so you should always save map in newest format if want play map in 1.13
if(iter->usItem >= OLD_MAXITEMS || iter->usItem == NONE)
continue;
this->ubWeight += Item[iter->usItem].ubWeight;
this->usAttachItem[i] = iter->usItem;
this->bAttachStatus[i] = (INT8)(*iter)[0]->data.objectStatus;
if(++i >= OLD_MAX_ATTACHMENTS_101)
+1 -1
View File
@@ -1249,7 +1249,7 @@ typedef enum ePOCKET_TYPE
#define FIRST_ARMOUR 161
#define FIRST_MISC 201
#define FIRST_KEY 271
#define OLD_MAXITEMS 351//dnl ch74 191013
#define NOTHING NONE
typedef enum
{
+15 -1
View File
@@ -56,6 +56,7 @@
#include "drugs and alcohol.h"
#include "Food.h"
#include "opplist.h"
#include "Sys Globals.h"//dnl ch74 201013
#endif
#ifdef JA2UB
@@ -7842,6 +7843,7 @@ BOOLEAN CreateItem( UINT16 usItem, INT16 bStatus, OBJECTTYPE * pObj )
{
(*pObj).fFlags |= OBJECT_UNDROPPABLE;
}
#if 0//dnl ch74 201013 create default attachments rather at gun status instead of 100%
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){
if(Item [ usItem ].defaultattachments[cnt] == 0)
break;
@@ -7851,9 +7853,21 @@ BOOLEAN CreateItem( UINT16 usItem, INT16 bStatus, OBJECTTYPE * pObj )
CreateItem(Item [ usItem ].defaultattachments[cnt],100,&defaultAttachment);
pObj->AttachObject(NULL,&defaultAttachment, FALSE);
}
#else
if(gGameOptions.ubAttachmentSystem || gfEditMode)
{
for(UINT8 cnt=0; cnt<MAX_DEFAULT_ATTACHMENTS; cnt++)
{
if(Item[usItem].defaultattachments[cnt] == NONE)
break;
OBJECTTYPE defaultAttachment;
CreateItem(Item[usItem].defaultattachments[cnt], (*pObj)[0]->data.gun.bGunStatus, &defaultAttachment);
pObj->AttachObject(NULL, &defaultAttachment, FALSE);
}
}
#endif
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("CreateItem: return %d",fRet));
return( fRet );
}
+15 -5
View File
@@ -559,13 +559,21 @@ void TrashWorldItems()
}
}
//dnl ch33 150909
//dnl ch33 150909 //dnl ch74 191013
void SaveWorldItemsToMap(HWFILE fp, float dMajorMapVersion, UINT8 ubMinorMapVersion)
{
UINT32 i, uiBytesWritten, uiActualNumWorldItems;
UINT32 i, uiBytesWritten, uiActualNumWorldItems=0;
OLD_WORLDITEM_101 oldWorldItem;
uiActualNumWorldItems = GetNumUsedWorldItems();
for(i=0; i<guiNumWorldItems; i++)
{
if(gWorldItems[i].fExists)
{
if(dMajorMapVersion == VANILLA_MAJOR_MAP_VERSION && ubMinorMapVersion == VANILLA_MINOR_MAP_VERSION && gWorldItems[i].object.usItem >= OLD_MAXITEMS)
continue;
uiActualNumWorldItems++;
}
}
FileWrite(fp, &uiActualNumWorldItems, sizeof(UINT32), &uiBytesWritten);
for(i=0; i<guiNumWorldItems; i++)
{
@@ -573,6 +581,8 @@ void SaveWorldItemsToMap(HWFILE fp, float dMajorMapVersion, UINT8 ubMinorMapVers
{
if(dMajorMapVersion == VANILLA_MAJOR_MAP_VERSION && ubMinorMapVersion == VANILLA_MINOR_MAP_VERSION)
{
if(gWorldItems[i].object.usItem >= OLD_MAXITEMS)
continue;
oldWorldItem = gWorldItems[i];
FileWrite(fp, &oldWorldItem, sizeof(OLD_WORLDITEM_101), &uiBytesWritten);
}
@@ -704,7 +714,7 @@ void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorM
{ //all armed bombs are buried
dummyItem.bVisible = BURIED;
}
#if 0//dnl ch74 201013 this is already done in OBJECTTYPE::Load()
//Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you?
//this should fix that...
for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++)
@@ -716,7 +726,7 @@ void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorM
CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment);
dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE);
}
#endif
AddItemToPoolAndGetIndex( dummyItem.sGridNo, &dummyItem.object, dummyItem.bVisible, dummyItem.ubLevel, dummyItem.usFlags, dummyItem.bRenderZHeightAboveLevel, dummyItem.soldierID, &iItemIndex );
gWorldItems[ iItemIndex ].ubNonExistChance = dummyItem.ubNonExistChance;
}
+12 -5
View File
@@ -2284,10 +2284,9 @@ BOOLEAN SaveWorld(const STR8 puiFilename, FLOAT dMajorMapVersion, UINT8 ubMinorM
if( uiFlags & MAP_WORLDLIGHTS_SAVED )
{
SaveMapLights( hfile );
}
#if 0//dnl ch74 191013 from 050611 Scheinworld reported problem with basement levels and similar maps which doesn't need entry points so decide to remove this check completely
if(gMapInformation.sCenterGridNo == -1 || gMapInformation.ubEditorSmoothingType == SMOOTHING_NORMAL && (gMapInformation.sNorthGridNo == -1 && gMapInformation.sEastGridNo == -1 && gMapInformation.sSouthGridNo == -1 && gMapInformation.sWestGridNo == -1))//dnl ch17 290909
{
swprintf(gzErrorCatchString, L"SAVE ABORTED! Center and at least one of (N,S,E,W) entry point should be set.");
@@ -2295,6 +2294,8 @@ BOOLEAN SaveWorld(const STR8 puiFilename, FLOAT dMajorMapVersion, UINT8 ubMinorM
FileClose(hfile);
return(FALSE);
}
#endif
gMapInformation.ubMapVersion = ubMinorMapVersion;//dnl ch74 241013 all this years MapInfo saves incorrect version :-(
SaveMapInformation(hfile, dMajorMapVersion, ubMinorMapVersion);//dnl ch33 150909
if( uiFlags & MAP_FULLSOLDIER_SAVED )
@@ -2602,6 +2603,8 @@ BOOLEAN EvaluateWorld(STR8 pSector, UINT8 ubLevel)
// Read Map Information
pSummary->MapInfo.Load(&pBuffer, dMajorMapVersion);
if(pSummary->MapInfo.ubMapVersion != ubMinorMapVersion)//dnl ch74 241013 stupid fix because MapInfo is incorrectly saved in all previous mapeditor if you edit existing map
pSummary->MapInfo.ubMapVersion = ubMinorMapVersion;
if(uiFlags & MAP_FULLSOLDIER_SAVED)
{
@@ -2882,7 +2885,8 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor
gfCaves = FALSE;
// Flugente: select loadscreen hint
SetNewLoadScreenHint();
if(!gfEditMode)//dnl ch74 211013
SetNewLoadScreenHint();
SetRelativeStartAndEndPercentage(0, 0, 1, L"Trashing world...");
#ifdef JA2TESTVERSION
@@ -2919,7 +2923,8 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor
// We enlarge the map
SetWorldSize(iNewMapWorldRows, iNewMapWorldCols);
// Uncheck "vanilla map saving", because it is not allowed on maps > 160x160
// Uncheck "vanilla map saving", because it is not allowed on maps > 160x160
gfVanillaMode = FALSE;//dnl ch74 191013
UnclickEditorButton(OPTIONS_VANILLA_MODE);
// Reset
@@ -2933,12 +2938,14 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor
// We still have the "normal" map size AND the map is saved in vanilla format
if ((iRowSize <= OLD_WORLD_ROWS && iRowSize <= OLD_WORLD_COLS) && (dMajorMapVersion == VANILLA_MAJOR_MAP_VERSION && ubMinorMapVersion == VANILLA_MINOR_MAP_VERSION))
{
// Check "vanilla map saving"
// Check "vanilla map saving"
gfVanillaMode = TRUE;//dnl ch74 191013
ClickEditorButton(OPTIONS_VANILLA_MODE);
}
else
{
// Uncheck "vanilla map saving"
gfVanillaMode = FALSE;//dnl ch74 191013
UnclickEditorButton(OPTIONS_VANILLA_MODE);
}
}