From a618bd241cef27405ded750d350dce5ba6c2e51b Mon Sep 17 00:00:00 2001 From: Wanne Date: Sun, 29 Jul 2012 11:47:36 +0000 Subject: [PATCH] - ActionItems Fix: Increased number of action items from 255 (0-254) to 501 (0-500) (by Jazz) o See file: ActionItems.xml git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5425 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Editor/Item Statistics.cpp | 28 +++++----- Editor/Item Statistics.h | 92 ++++++++++++++++---------------- Editor/XML_ActionItems.cpp | 15 +++--- TileEngine/Explosion Control.cpp | 3 +- 4 files changed, 73 insertions(+), 65 deletions(-) diff --git a/Editor/Item Statistics.cpp b/Editor/Item Statistics.cpp index c2b09431..dacfb234 100644 --- a/Editor/Item Statistics.cpp +++ b/Editor/Item Statistics.cpp @@ -100,7 +100,7 @@ CHAR16 temp[30]; if( (*pItem)[0]->data.misc.bActionValue != ACTION_ITEM_BLOW_UP ) { - for (i= ACTIONITEM_TRIP_KLAXON; i<=ACTIONITEM_NEW; i++ ) + for (i= ACTIONITEM_TRIP_KLAXON; i< NUM_ACTIONITEMS; /*=ACTIONITEM_NEW;*/ i++ ) { if ( ActionItemsValues[ i ].BlowUp == 0 ) { @@ -115,14 +115,17 @@ if( (*pItem)[0]->data.misc.bActionValue != ACTION_ITEM_BLOW_UP ) } else { - for (i= ACTIONITEM_TRIP_KLAXON; i<=ACTIONITEM_NEW; i++ ) + for (i= ACTIONITEM_TRIP_KLAXON; i< NUM_ACTIONITEMS; /*=ACTIONITEM_NEW;*/ i++ ) { if ( ActionItemsValues[ i ].BlowUp == 1 ) { if ( (*pItem)[0]->data.misc.bActionValue == ACTION_ITEM_BLOW_UP ) { if ( (*pItem)[0]->data.misc.usBombItem == ActionItemsValues[ i ].BombItem ) + { + wcscpy(temp, gszActionItemDesc[i]); o = i; + } } } } @@ -245,7 +248,7 @@ void ToggleDetonator( GUI_BUTTON *btn, INT32 reason ); UINT32 guiActionItemButton; void ActionItemCallback( GUI_BUTTON *btn, INT32 reason ); -INT8 gbActionItemIndex = ACTIONITEM_MEDIUM; +/*INT8*/ INT16 gbActionItemIndex = ACTIONITEM_MEDIUM; INT8 gbDefaultBombTrapLevel = 9; void RemoveBombFromWorldByItemIndex( INT32 iItemIndex ); @@ -353,7 +356,7 @@ void DisableItemStatsPanel() } -void ExecuteItemStatsCmd( UINT8 ubAction ) +void ExecuteItemStatsCmd( /*UINT8*/ UINT16 ubAction ) { switch( ubAction ) { @@ -1501,22 +1504,23 @@ void ActionItemCallback( GUI_BUTTON *btn, INT32 reason ) } } -void ChangeActionItem( OBJECTTYPE *pItem, INT8 bActionItemIndex ) +void ChangeActionItem( OBJECTTYPE *pItem, /*INT8*/ INT16 bActionItemIndex ) { -UINT32 i; -pItem->usItem = ACTION_ITEM; +/*UINT32*/ INT16 i; //(*pItem)[0]->data.misc.bActionValue = ACTION_ITEM_BLOW_UP; - for (i= ACTIONITEM_TRIP_KLAXON; i<=ACTIONITEM_NEW; i++ ) + for (i= ACTIONITEM_TRIP_KLAXON; i< NUM_ACTIONITEMS; /*=ACTIONITEM_NEW;*/ i++ ) { - if ( bActionItemIndex == i && ActionItemsValues[ i ].BlowUp == 1 ) + pItem->usItem = ACTION_ITEM; + + if ( bActionItemIndex == i && ActionItemsValues[ i ].BlowUp == 1 ) { - (*pItem)[0]->data.misc.usBombItem = ActionItemsValues[ i ].BombItem; (*pItem)[0]->data.misc.bActionValue = ACTION_ITEM_BLOW_UP; + (*pItem)[0]->data.misc.usBombItem = ActionItemsValues[ i ].BombItem; } else if ( bActionItemIndex == i && ActionItemsValues[ i ].BlowUp == 0 ) { - (*pItem)[0]->data.misc.usBombItem = ActionItemsValues[ i ].BombItem; + (*pItem)[0]->data.misc.usBombItem = NOTHING; //ActionItemsValues[ i ].BombItem; (*pItem)[0]->data.misc.bActionValue = ActionItemsValues[ i ].ActionID; } } @@ -1679,7 +1683,7 @@ pItem->usItem = ACTION_ITEM; */ } -void UpdateActionItem( INT8 bActionItemIndex ) +void UpdateActionItem( /*INT8*/ INT16 bActionItemIndex ) { gbActionItemIndex = bActionItemIndex; //used for future new actionitems as the default. diff --git a/Editor/Item Statistics.h b/Editor/Item Statistics.h index cb836f94..c84c5895 100644 --- a/Editor/Item Statistics.h +++ b/Editor/Item Statistics.h @@ -1,50 +1,8 @@ #include "BuildDefines.h" -#ifdef JA2EDITOR #ifndef __ITEM_STATISTICS_H #define __ITEM_STATISTICS_H -//#include "Item Types.h" - -//forward declarations of common classes to eliminate includes -class OBJECTTYPE; -class SOLDIERTYPE; - - -//Handles the dynamic changing of text input fields and button modes depending on the currently edited -//item. Both the merc's inventory panel, and the items tab use the same code to accomplish this. - -//Set if we are editing items from the items tab. Otherwise, it is assumed that we are -//editing items from the merc's inventory panel. -extern BOOLEAN gfItemEditingMode; - -//Set if we need to update the panel. -extern BOOLEAN gfRenderItemStatsPanel; - -void SpecifyItemToEdit( OBJECTTYPE *pItem, INT32 iMapIndex ); - -void ShowItemStatsPanel(); -void HideItemStatsPanel(); -void EnableItemStatsPanel(); -void DisableItemStatsPanel(); - -//called from the taskbar renderer. -void UpdateItemStatsPanel(); - -enum -{ - ITEMSTATS_APPLY, - ITEMSTATS_CANCEL, - ITEMSTATS_DEFAULT, - ITEMSTATS_DELETE, - ITEMSTATS_HIDE, - ITEMSTATS_SHOW, -}; -void ExecuteItemStatsCmd( UINT8 ubAction ); - -extern OBJECTTYPE *gpItem; -extern INT32 gsItemGridNo; - //enumerations for all of the different action items. Used by the popup menu for //changing the type of action item. When modified, an equivalent text array must be //changed as well. @@ -98,14 +56,58 @@ enum NUM_ACTIONITEMS }; + +#ifdef JA2EDITOR + +//#include "Item Types.h" + +//forward declarations of common classes to eliminate includes +class OBJECTTYPE; +class SOLDIERTYPE; + + +//Handles the dynamic changing of text input fields and button modes depending on the currently edited +//item. Both the merc's inventory panel, and the items tab use the same code to accomplish this. + +//Set if we are editing items from the items tab. Otherwise, it is assumed that we are +//editing items from the merc's inventory panel. +extern BOOLEAN gfItemEditingMode; + +//Set if we need to update the panel. +extern BOOLEAN gfRenderItemStatsPanel; + +void SpecifyItemToEdit( OBJECTTYPE *pItem, INT32 iMapIndex ); + +void ShowItemStatsPanel(); +void HideItemStatsPanel(); +void EnableItemStatsPanel(); +void DisableItemStatsPanel(); + +//called from the taskbar renderer. +void UpdateItemStatsPanel(); + +enum +{ + ITEMSTATS_APPLY, + ITEMSTATS_CANCEL, + ITEMSTATS_DEFAULT, + ITEMSTATS_DELETE, + ITEMSTATS_HIDE, + ITEMSTATS_SHOW, +}; +void ExecuteItemStatsCmd( /*UINT8*/ UINT16 ubAction ); + +extern OBJECTTYPE *gpItem; +extern INT32 gsItemGridNo; + extern CHAR16 gszActionItemDesc[ NUM_ACTIONITEMS ][ 30 ]; //Returns a pointer to one of the above string array. extern const STR16 GetActionItemName( OBJECTTYPE *pItem ); //Called by the popup menu, when a selection is made. -extern void UpdateActionItem( INT8 bActionItemIndex ); +extern void UpdateActionItem( /*INT8*/ INT16 bActionItemIndex ); //Changes an action item into the type specified by the ACTIONITEM enumeration. -extern void ChangeActionItem( OBJECTTYPE *pItem, INT8 bActionItemIndex ); -extern INT8 gbActionItemIndex; +extern void ChangeActionItem( OBJECTTYPE *pItem, /*INT8*/ INT16 bActionItemIndex ); +extern /*INT8*/ INT16 gbActionItemIndex; extern INT8 gbDefaultBombTrapLevel; extern void SetOwnershipGroup( UINT8 ubNewGroup ); diff --git a/Editor/XML_ActionItems.cpp b/Editor/XML_ActionItems.cpp index eca5543e..676d183d 100644 --- a/Editor/XML_ActionItems.cpp +++ b/Editor/XML_ActionItems.cpp @@ -52,10 +52,10 @@ actionItemsStartElementHandle(void *userData, const XML_Char *name, const XML_Ch } else if(pData->curElement == ELEMENT && (strcmp(name, "uiIndex") == 0 || + strcmp(name, "Name") == 0 || strcmp(name, "ActionID") == 0 || - strcmp(name, "Name") == 0 || - strcmp(name, "BombItem") == 0 || - strcmp(name, "Blow_up") == 0 )) + strcmp(name, "Blow_up") == 0 || + strcmp(name, "BombItem") == 0 )) { pData->curElement = ELEMENT_PROPERTY; @@ -149,7 +149,7 @@ actionItemsEndElementHandle(void *userData, const XML_Char *name) else if(strcmp(name, "BombItem") == 0) { pData->curElement = ELEMENT; - pData->curActionItems.BombItem = (UINT32) atol(pData->szCharData); + pData->curActionItems.BombItem = (UINT16) atol(pData->szCharData); } pData->maxReadDepth--; } @@ -221,7 +221,7 @@ BOOLEAN ReadInActionItems(STR fileName, BOOLEAN localizedVersion) return( TRUE ); } -BOOLEAN WriteInActionItems( STR fileName) +BOOLEAN WriteInActionItems(STR fileName) { HWFILE hFile; @@ -235,13 +235,14 @@ BOOLEAN WriteInActionItems( STR fileName) UINT32 cnt; FilePrintf(hFile,"\r\n"); - for(cnt = 0;cnt < 501;cnt++) + for(cnt = 0;cnt < /*501*/NUM_ACTIONITEMS;cnt++) { FilePrintf(hFile,"\t\r\n"); FilePrintf(hFile,"\t\t%d\r\n", cnt); FilePrintf(hFile,"\t\tEmpty action\r\n"); FilePrintf(hFile,"\t\t%d\r\n", ActionItemsValues[cnt].ActionID); - FilePrintf(hFile,"\t\t%d\r\n", ActionItemsValues[cnt].BlowUp); + FilePrintf(hFile,"\t\t%d\r\n", ActionItemsValues[cnt].BlowUp); + FilePrintf(hFile,"\t\t%d\r\n", ActionItemsValues[cnt].BombItem); FilePrintf(hFile,"\t\r\n"); } FilePrintf(hFile,"\r\n"); diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index df978ee8..528053ca 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -77,6 +77,7 @@ #include "LuaInitNPCs.h" #include "Luaglobal.h" +#include "Item Statistics.h" #ifdef JA2UB @@ -3117,7 +3118,7 @@ void PerformItemAction( INT32 sGridNo, OBJECTTYPE * pObj ) #ifdef LUA_EXPLOSION_CONTROL - for (UINT32 i = ACTION_ITEM_OPEN_DOOR; i <= ACTION_ITEM_NEW; i++ ) + for (UINT32 i = ACTION_ITEM_OPEN_DOOR; i < NUM_ACTIONITEMS; /*= ACTION_ITEM_NEW;*/ i++ ) { if ( (*pObj)[0]->data.misc.bActionValue == i ) LetLuaPerformItemAction( i, sGridNo, 0 );