From 76186058af85bc07fc59aae7375c5fd9172dc3be Mon Sep 17 00:00:00 2001 From: SpaceViking Date: Wed, 17 Mar 2010 02:42:30 +0000 Subject: [PATCH] Flexible merchant updates git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3404 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Arms Dealer Init.cpp | 87 ++-- Tactical/Arms Dealer Init.h | 15 +- Tactical/ArmsDealerInvInit.cpp | 42 +- Tactical/ShopKeeper Interface.cpp | 132 +++---- Tactical/XML.h | 8 + Tactical/XML_TonyInventory.cpp | 631 +++++++++++++++++++++++++++--- 6 files changed, 715 insertions(+), 200 deletions(-) diff --git a/Tactical/Arms Dealer Init.cpp b/Tactical/Arms Dealer Init.cpp index bf9ce3cf..2b447ff1 100644 --- a/Tactical/Arms Dealer Init.cpp +++ b/Tactical/Arms Dealer Init.cpp @@ -35,40 +35,41 @@ UINT8 gubLastSpecialItemAddedAtElement = 255; // THIS STRUCTURE HAS UNCHANGING INFO THAT DOESN'T GET SAVED/RESTORED/RESET // TODO: externalize -ARMS_DEALER_INFO ArmsDealerInfo[ NUM_ARMS_DEALERS ] = +const ARMS_DEALER_INFO DefaultarmsDealerInfo[ NUM_ARMS_DEALERS ] = { //Buying Selling Merc ID# Type Initial Flags //Price Price Of Cash //Modifier Modifier Dealer -/* Tony */ { 0.75f, 1.25f, TONY, ARMS_DEALER_BUYS_SELLS, 15000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE }, -/* Franz Hinkle */ { 1.0f, 1.5f, FRANZ, ARMS_DEALER_BUYS_SELLS, 5000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE }, -/* Keith Hemps */ { 0.75f, 1.0f, KEITH, ARMS_DEALER_BUYS_SELLS, 1500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE }, -/* Jake Cameron */ { 0.8f, 1.1f, JAKE, ARMS_DEALER_BUYS_SELLS, 2500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE }, -/* Gabby Mulnick*/ { 1.0f, 1.0f, GABBY, ARMS_DEALER_BUYS_SELLS, 3000, ARMS_DEALER_GIVES_CHANGE }, +/* Tony */ { 0.75f, 1.25f, TONY, ARMS_DEALER_BUYS_SELLS, 15000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 15000, 15000, 0, 1, 10, 1, 10, 2, 3, false, false }, +/* Franz Hinkle */ { 1.0f, 1.5f, FRANZ, ARMS_DEALER_BUYS_SELLS, 5000, ARMS_DEALER_SOME_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 5000, 5000, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Keith Hemps */ { 0.75f, 1.0f, KEITH, ARMS_DEALER_BUYS_SELLS, 1500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 1500, 1500, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Jake Cameron */ { 0.8f, 1.1f, JAKE, ARMS_DEALER_BUYS_SELLS, 2500, ARMS_DEALER_ONLY_USED_ITEMS | ARMS_DEALER_GIVES_CHANGE, 2500, 2500, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Gabby Mulnick*/ { 1.0f, 1.0f, GABBY, ARMS_DEALER_BUYS_SELLS, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Devin Connell*/ { 0.75f, 1.25f, DEVIN, ARMS_DEALER_SELLS_ONLY, 5000, ARMS_DEALER_GIVES_CHANGE }, -/* Howard Filmore*/ { 1.0f, 1.0f, HOWARD, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE }, -/* Sam Rozen */ { 1.0f, 1.0f, SAM, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE }, -/* Frank */ { 1.0f, 1.0f, FRANK, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS }, +/* Devin Connell*/ { 0.75f, 1.25f, DEVIN, ARMS_DEALER_SELLS_ONLY, 5000, ARMS_DEALER_GIVES_CHANGE , 5000, 5000, 0, 3, 10, 0, 10, 2, 3, false, false }, +/* Howard Filmore*/ { 1.0f, 1.0f, HOWARD, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Sam Rozen */ { 1.0f, 1.0f, SAM, ARMS_DEALER_SELLS_ONLY, 3000, ARMS_DEALER_GIVES_CHANGE , 3000, 3000, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Frank */ { 1.0f, 1.0f, FRANK, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Bar Bro 1 */ { 1.0f, 1.0f, HERVE, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS }, -/* Bar Bro 2 */ { 1.0f, 1.0f, PETER, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS }, -/* Bar Bro 3 */ { 1.0f, 1.0f, ALBERTO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS }, -/* Bar Bro 4 */ { 1.0f, 1.0f, CARLO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS }, +/* Bar Bro 1 */ { 1.0f, 1.0f, HERVE, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Bar Bro 2 */ { 1.0f, 1.0f, PETER, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Bar Bro 3 */ { 1.0f, 1.0f, ALBERTO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, +/* Bar Bro 4 */ { 1.0f, 1.0f, CARLO, ARMS_DEALER_SELLS_ONLY, 250, ARMS_DEALER_ACCEPTS_GIFTS , 250, 250, 0, 1, 10, 0, 100, 1, 2, false, true }, -/* Micky O'Brien*/ { 1.0f, 1.4f, MICKY, ARMS_DEALER_BUYS_ONLY, 10000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE }, +/* Micky O'Brien*/ { 1.0f, 1.4f, MICKY, ARMS_DEALER_BUYS_ONLY, 10000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 10000, 10000, 0, 1, 10, 1, 10, 1, 2, false, true }, //Repair Repair //Speed Cost -/* Arnie Brunzwell*/{ 0.1f, 0.8f, ARNIE, ARMS_DEALER_REPAIRS, 1500, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE }, -/* Fredo */ { 0.6f, 0.6f, FREDO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE }, -/* Perko */ { 1.0f, 0.4f, PERKO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE }, +/* Arnie Brunzwell*/{ 0.1f, 0.8f, ARNIE, ARMS_DEALER_REPAIRS, 1500, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1500, 1500, 0, 1, 10, 1, 10, 1, 2, false, true }, +/* Fredo */ { 0.6f, 0.6f, FREDO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, +/* Perko */ { 1.0f, 0.4f, PERKO, ARMS_DEALER_REPAIRS, 1000, ARMS_DEALER_HAS_NO_INVENTORY | ARMS_DEALER_GIVES_CHANGE, 1000, 1000, 0, 1, 10, 1, 10, 1, 2, false, true }, -/* Elgin */ { 1.0f, 1.0f, DRUGGIST, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS }, -/* Manny */ { 1.0f, 1.0f, MANNY, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS }, +/* Elgin */ { 1.0f, 1.0f, DRUGGIST, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 1, 10, 1, 2, false, true }, +/* Manny */ { 1.0f, 1.0f, MANNY, ARMS_DEALER_SELLS_ONLY, 500, ARMS_DEALER_ACCEPTS_GIFTS , 500, 500, 0, 1, 10, 1, 10, 1, 2, false, true }, }; +std::vector armsDealerInfo (NUM_ARMS_DEALERS); // THESE GET SAVED/RESTORED/RESET @@ -146,6 +147,7 @@ void InitAllArmsDealers() UINT8 ubArmsDealer; ShutDownArmsDealers(); + //Initialize the initial status & inventory for each of the arms dealers for( ubArmsDealer = 0; ubArmsDealer < NUM_ARMS_DEALERS; ubArmsDealer++ ) { @@ -167,10 +169,10 @@ void InitializeOneArmsDealer( UINT8 ubArmsDealer ) gArmsDealersInventory.resize(gArmsDealersInventory.size() + 1); //Reset the arms dealers cash on hand to the default initial value - gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash = ArmsDealerInfo[ ubArmsDealer ].iInitialCash; + gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash = armsDealerInfo[ ubArmsDealer ].iInitialCash; //if the arms dealer isn't supposed to have any items (includes all repairmen) - if( ArmsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) + if( armsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) { return; } @@ -305,7 +307,7 @@ void SimulateArmsDealerCustomer() continue; //if the arms dealer isn't supposed to have any items (includes all repairmen) - if( ArmsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) + if( armsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) continue; memset (&numPerfectItems, 0, sizeof(numPerfectItems)); @@ -380,10 +382,13 @@ void DailyCheckOnItemQuantities() continue; //Reset the arms dealers cash on hand to the default initial value - gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash = ArmsDealerInfo[ ubArmsDealer ].iInitialCash; + gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash = gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash * armsDealerInfo[ ubArmsDealer ].dailyRetained / 100 + + armsDealerInfo[ ubArmsDealer ].dailyIncrement; + if (gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash > armsDealerInfo[ ubArmsDealer ].dailyMaximum) + gArmsDealerStatus[ ubArmsDealer ].uiArmsDealersCash = armsDealerInfo[ ubArmsDealer ].dailyMaximum; //if the arms dealer isn't supposed to have any items (includes all repairmen) - if( ArmsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) + if( armsDealerInfo[ ubArmsDealer ].uiFlags & ARMS_DEALER_HAS_NO_INVENTORY ) continue; int numTotalItems[MAXITEMS] = { 0 }; @@ -437,15 +442,7 @@ void DailyCheckOnItemQuantities() } else { - if ( ( ubArmsDealer == ARMS_DEALER_TONY ) || ( ubArmsDealer == ARMS_DEALER_DEVIN ) ) - { - // the stuff Tony and Devin sell is imported, so it takes longer to arrive (for game balance) - ubReorderDays = ( UINT8) ( 2 + Random( 2 ) ); // 2-3 days - } - else - { - ubReorderDays = ( UINT8) ( 1 + Random( 2 ) ); // 1-2 days - } + ubReorderDays = ( UINT8) ( armsDealerInfo[ ubArmsDealer ].daysDelayMin + Random( armsDealerInfo[ ubArmsDealer ].daysDelayMax - armsDealerInfo[ ubArmsDealer ].daysDelayMin ) ); //Determine when the inventory should arrive uiArrivalDay = GetWorldDay() + ubReorderDays; // consider changing this to minutes @@ -1018,7 +1015,7 @@ BOOLEAN IsMercADealer( UINT8 ubMercID ) //loop through the list of arms dealers for( cnt=0; cnt DealerItemList; extern std::vector gArmsDealersInventory; void OrderDealerItems(int armsDealer, int usItem, int numItems, int arrivalDay); -extern ARMS_DEALER_INFO ArmsDealerInfo[ NUM_ARMS_DEALERS ]; +extern const ARMS_DEALER_INFO DefaultarmsDealerInfo[ NUM_ARMS_DEALERS ]; +extern std::vector armsDealerInfo; extern ARMS_DEALER_STATUS gArmsDealerStatus[ NUM_ARMS_DEALERS ]; diff --git a/Tactical/ArmsDealerInvInit.cpp b/Tactical/ArmsDealerInvInit.cpp index 72d4d397..629f9a3b 100644 --- a/Tactical/ArmsDealerInvInit.cpp +++ b/Tactical/ArmsDealerInvInit.cpp @@ -885,8 +885,10 @@ DEALER_POSSIBLE_INV *GetPointerToDealersPossibleInventory( UINT8 ubArmsDealerID //Madd: added boolean fUsed UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEAN fUsed ) { - UINT8 ubItemCoolness; - UINT8 ubMinCoolness, ubMaxCoolness; + unsigned ubItemCoolness; + unsigned ubMinCoolness, ubMaxCoolness; + + const int bobbyRaysID = -1; // item suitability varies with the player's maximum progress through the game. The farther he gets, the better items @@ -899,7 +901,6 @@ UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEA } // items normally not sold at shops are unsuitable -// if ( Item[ usItemIndex ].fFlags & ITEM_NOT_BUYABLE ) if ( Item[ usItemIndex ].notbuyable ) { return(ITEM_SUITABILITY_NONE); @@ -915,25 +916,12 @@ UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEA } // the following staple items are always deemed highly suitable regardless of player's progress: - //switch (usItemIndex) - //{ - // case FIRSTAIDKIT: - // case MEDICKIT: - // case TOOLKIT: - // case LOCKSMITHKIT: - - // case CANTEEN: - // case CROWBAR: - // case JAR: - // case JAR_ELIXIR: - // case JAR_CREATURE_BLOOD: if ( Item[usItemIndex].medical || Item[usItemIndex].canteen || Item[usItemIndex].medicalkit || Item[usItemIndex].locksmithkit || Item[usItemIndex].toolkit || Item[usItemIndex].crowbar || Item[usItemIndex].jar ) return(ITEM_SUITABILITY_ALWAYS); - //} // If it's not BobbyRay, Tony, or Devin - if ((bArmsDealer != -1) && (bArmsDealer != ARMS_DEALER_TONY) && (bArmsDealer != ARMS_DEALER_DEVIN)) + if (bArmsDealer != bobbyRaysID && armsDealerInfo[bArmsDealer].allInventoryAlwaysAvailable) { // all the other dealers have very limited inventories, so their suitability remains constant at all times in game return(ITEM_SUITABILITY_HIGH); @@ -942,14 +930,15 @@ UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEA // figure out the appropriate range of coolness based on player's maximum progress so far - ubMinCoolness = HighestPlayerProgressPercentage() / 10; - ubMaxCoolness = ( HighestPlayerProgressPercentage() / 10 ) + 1; - if ( bArmsDealer == -1 ) + if ( bArmsDealer == bobbyRaysID ) ubMinCoolness = 1; + else + ubMinCoolness = HighestPlayerProgressPercentage() * armsDealerInfo[bArmsDealer].coolnessProgressRate / 100; + ubMaxCoolness = ubMinCoolness + 1; //Madd: Bobby Ray's will sell higher coolness stuff if it's used, and may also have a better selection at the start of the game, depending on selection - if ( bArmsDealer == -1 && gGameOptions.ubBobbyRay > BR_GOOD ) + if ( (bArmsDealer == bobbyRaysID || armsDealerInfo[bArmsDealer].useBRSetting) && gGameOptions.ubBobbyRay > BR_GOOD ) { ubMaxCoolness += gGameOptions.ubBobbyRay - 1; if (fUsed ) @@ -960,6 +949,13 @@ UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEA // WDS - Improve Tony's and Devin's inventory like BR's // Tony has the better stuff sooner (than Bobby R's) + if (bArmsDealer >= 0) { + ubMinCoolness += armsDealerInfo[bArmsDealer].addToCoolness; + ubMaxCoolness += armsDealerInfo[bArmsDealer].addToCoolness; + ubMinCoolness = max( armsDealerInfo[bArmsDealer].minCoolness, min( 9, ubMinCoolness ) ); + ubMaxCoolness = max( 2, min( armsDealerInfo[bArmsDealer].maxCoolness, ubMaxCoolness ) ); + } + /* if (bArmsDealer == ARMS_DEALER_TONY) { ubMinCoolness += 1; @@ -984,12 +980,12 @@ UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEA ubMaxCoolness += gGameOptions.ubBobbyRay; } } - + */ ubMinCoolness = max( 1, min( 9, ubMinCoolness ) ); ubMaxCoolness = max( 2, min( 10, ubMaxCoolness ) ); - if ( bArmsDealer == -1 ) + if ( bArmsDealer == bobbyRaysID ) { //Madd: BR's always sells ammo for its guns if (Item[usItemIndex].usItemClass == IC_AMMO && ubItemCoolness <= ubMaxCoolness ) diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index 0a8faeb6..46ef855b 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -861,7 +861,7 @@ BOOLEAN EnterShopKeeperInterface() //but if we are physically too far away, we don't have extended arms! SOLDIERTYPE* pSoldier = MercPtrs[ gusSelectedSoldier ]; - SOLDIERTYPE* pShopkeeper = FindSoldierByProfileID( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); + SOLDIERTYPE* pShopkeeper = FindSoldierByProfileID( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); if ( GetRangeFromGridNoDiff( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS ) { //so now we know we are too far away to trade, so instead of just quitting, @@ -1069,7 +1069,7 @@ ATM: SpecifyDisabledButtonStyle( guiSKI_TransactionButton, DISABLED_STYLE_HATCHED ); //if the dealer repairs, use the repair fast help text for the transaction button - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) SetButtonFastHelpText( guiSKI_TransactionButton, SkiMessageBoxText[ SKI_REPAIR_TRANSACTION_BUTTON_HELP_TEXT ] ); else SetButtonFastHelpText( guiSKI_TransactionButton, SkiMessageBoxText[ SKI_TRANSACTION_BUTTON_HELP_TEXT ] ); @@ -1132,7 +1132,7 @@ ATM: PlayersOfferArea[x].initialize(); } - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { HandlePossibleRepairDelays(); } @@ -1152,7 +1152,7 @@ ATM: memset( &gfCommonQuoteUsedThisSession, FALSE, sizeof( gfCommonQuoteUsedThisSession ) ); //Init the shopkeepers face - InitShopKeepersFace( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID ); + InitShopKeepersFace( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID ); gfDoneBusinessThisSession = FALSE; @@ -1180,7 +1180,7 @@ ATM: bool fAddedOK = false; //if this is NOT a repair dealer or he is is but there is enough space in the player's offer area // (you can't be out of space if it isn't a repairman, only they can fill it up with repaired items!) - if( ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) || + if( ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) || ( CountNumberOfItemsInThePlayersOfferArea( ) < SKI_NUM_ARMS_DEALERS_INV_SLOTS ) ) { if ( OfferObjectToDealer( &(gItemToAdd.ItemObject), gpSMCurrentMerc->ubProfile, NO_SLOT ) ) @@ -1232,7 +1232,7 @@ ATM: BOOLEAN InitShopKeepersFace( UINT8 ubMercID ) { - SOLDIERTYPE *pSoldier = FindSoldierByProfileID( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); + SOLDIERTYPE *pSoldier = FindSoldierByProfileID( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); if( pSoldier == NULL ) { @@ -1505,7 +1505,7 @@ BOOLEAN RenderShopKeeperInterface() DrawTextToScreen( SKI_Text[ SKI_TEXT_MERCHADISE_IN_STOCK ], SKI_MAIN_TITLE_X, SKI_MAIN_TITLE_Y, SKI_MAIN_TITLE_WIDTH, SKI_TITLE_FONT, SKI_TITLE_COLOR, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //Display the Repair cost text DisplayWrappedString( SKI_TOTAL_COST_X, SKI_TOTAL_COST_Y, SKI_TOTAL_COST_WIDTH, 2, SKI_LABEL_FONT, SKI_TITLE_COLOR, SKI_Text[ SKI_TEXT_REPAIR_COST ], FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED); @@ -1735,7 +1735,7 @@ void DisplayAllDealersCash() for( bArmsDealer=0; bArmsDealer 0 ) { // we'd better talking to a repairman, cursor is locked out of this area while full for non-repairmen! - Assert( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ); + Assert( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ); //Drop the item into the current slot AddInventoryToSkiLocation( &gMoveingItem, ubSelectedInvSlot, ARMS_DEALER_OFFER_AREA ); @@ -2610,10 +2610,10 @@ void DisplayArmsDealerCurrentInventoryPage( ) fDisplayHatchOnItem = TRUE; } //if the dealer repairs - else if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + else if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //if the item is damaged - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_INV_ITEM_NOT_REPAIRED_YET ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_INV_ITEM_NOT_REPAIRED_YET ) fDisplayHatchOnItem = TRUE; else fDisplayHatchOnItem = FALSE; @@ -2644,7 +2644,7 @@ void DisplayArmsDealerCurrentInventoryPage( ) SetSkiRegionHelpText( &gpTempDealersInventory[ usCnt ], &gDealersInventoryMouseRegions[sItemCount], ARMS_DEALER_INVENTORY ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { SetSkiFaceRegionHelpText( &gpTempDealersInventory[ usCnt ], &gRepairmanInventorySmallFaceMouseRegions[sItemCount], ARMS_DEALER_INVENTORY ); } @@ -2672,7 +2672,7 @@ void DisplayArmsDealerCurrentInventoryPage( ) SetSkiRegionHelpText( NULL, &gDealersInventoryMouseRegions[ sItemCount ], ARMS_DEALER_INVENTORY ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { SetSkiFaceRegionHelpText( NULL, &gRepairmanInventorySmallFaceMouseRegions[ sItemCount ], ARMS_DEALER_INVENTORY ); } @@ -2774,7 +2774,7 @@ UINT32 DisplayInvSlot( UINT8 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT1 } else if( ubItemArea == ARMS_DEALER_INVENTORY ) { - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) { if( fHatchedOut && pItemObject->exists() == false ) { @@ -2783,7 +2783,7 @@ UINT32 DisplayInvSlot( UINT8 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT1 else { // show the UNIT price, not the total value of all if stacked - uiItemCost = CalcShopKeeperItemPrice( DEALER_SELLING, TRUE, usItemIndex, ArmsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, pItemObject ); + uiItemCost = CalcShopKeeperItemPrice( DEALER_SELLING, TRUE, usItemIndex, armsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, pItemObject ); } } else // UNDER REPAIR @@ -2806,7 +2806,7 @@ UINT32 DisplayInvSlot( UINT8 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT1 } else // DEALER'S OFFER AREA { - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //if the dealer repairs, there is an item here, therefore display the items owner's face fDisplayMercFace = TRUE; @@ -2815,7 +2815,7 @@ UINT32 DisplayInvSlot( UINT8 ubSlotNum, UINT16 usItemIndex, UINT16 usPosX, UINT1 uiItemCost = CalculateObjectItemRepairCost( gbSelectedArmsDealerID, pItemObject ); } else - uiItemCost = CalcShopKeeperItemPrice( DEALER_SELLING, FALSE, usItemIndex, ArmsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, pItemObject ); + uiItemCost = CalcShopKeeperItemPrice( DEALER_SELLING, FALSE, usItemIndex, armsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, pItemObject ); } @@ -2951,7 +2951,7 @@ BOOLEAN DetermineArmsDealersSellingInventory( ) if ( fAddSpecialItem == true ) { UINT8 ubOwner; - if ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + if ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) { // no merc is the owner ubOwner = NO_PROFILE; @@ -2980,7 +2980,7 @@ BOOLEAN DetermineArmsDealersSellingInventory( ) // repairmen sort differently from merchants // sort this list by object category, and by ascending price within each category - if ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { std::sort(gpTempDealersInventory.begin(), gpTempDealersInventory.end(), RepairmanItemQsortCompare);//RepairmanItemQsortCompare } @@ -3608,7 +3608,7 @@ void DisplayPlayersOfferArea() else // not money { //if non-repairman - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) { // don't evaluate anything he wouldn't buy! if( WillShopKeeperRejectObjectsFromPlayer( gbSelectedArmsDealerID, ( INT8 ) sCnt ) == FALSE ) @@ -3718,10 +3718,10 @@ UINT32 CalculateTotalArmsDealerCost() if( ArmsDealerOfferArea[ uiCnt ].fActive ) { //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) uiTotal += CalculateObjectItemRepairCost( gbSelectedArmsDealerID, &( ArmsDealerOfferArea[ uiCnt ].ItemObject ) ); else - uiTotal += CalcShopKeeperItemPrice( DEALER_SELLING, FALSE, ArmsDealerOfferArea[ uiCnt ].sItemIndex, ArmsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, &ArmsDealerOfferArea[uiCnt].ItemObject ); + uiTotal += CalcShopKeeperItemPrice( DEALER_SELLING, FALSE, ArmsDealerOfferArea[ uiCnt ].sItemIndex, armsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier, &ArmsDealerOfferArea[uiCnt].ItemObject ); } } return( uiTotal ); @@ -3770,18 +3770,18 @@ void PerformTransaction( UINT32 uiMoneyFromPlayersAccount ) StartShopKeeperTalking( SK_QUOTES_DEALER_OFFERED_MONEY_AS_A_GIFT ); // if the arms dealer is the kind of person who accepts gifts - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_ACCEPTS_GIFTS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_ACCEPTS_GIFTS ) { //Move all the players evaluated items to the dealer (also adds it to dealer's cash) MovePlayerOfferedItemsOfValueToArmsDealersInventory(); - DealerGetsBribed( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, uiMoneyInPlayersOfferArea ); + DealerGetsBribed( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, uiMoneyInPlayersOfferArea ); } } else // not a bribe { //if the dealer is not a repairman - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) { uiAvailablePlayerOfferSlots = ( SKI_NUM_TRADING_INV_SLOTS - CountNumberOfValuelessItemsInThePlayersOfferArea( ) ); @@ -3842,7 +3842,7 @@ void PerformTransaction( UINT32 uiMoneyFromPlayersAccount ) //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //Make sure there is enough money in the Player's offer area to cover the repair charge if( ( uiMoneyFromPlayersAccount + uiMoneyInPlayersOfferArea ) >= uiArmsDealersItemsCost ) @@ -3851,7 +3851,7 @@ void PerformTransaction( UINT32 uiMoneyFromPlayersAccount ) MovePlayerOfferedItemsOfValueToArmsDealersInventory(); //if the arms dealer is the type of person to give change - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_GIVES_CHANGE ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_GIVES_CHANGE ) { //determine the amount of change to give iChangeToGiveToPlayer = ( uiMoneyFromPlayersAccount + uiMoneyInPlayersOfferArea ) - uiArmsDealersItemsCost; @@ -3889,8 +3889,8 @@ void PerformTransaction( UINT32 uiMoneyFromPlayersAccount ) //if the arms dealer buys stuff - if( ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_BUYS_ONLY ) || - ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_BUYS_SELLS ) ) + if( ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_BUYS_ONLY ) || + ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_BUYS_SELLS ) ) { // but the dealer can't afford this transaction if( iChangeToGiveToPlayer > ( INT32 ) gArmsDealerStatus[ gbSelectedArmsDealerID ].uiArmsDealersCash ) @@ -3916,7 +3916,7 @@ void PerformTransaction( UINT32 uiMoneyFromPlayersAccount ) //if the arms dealer is the type of person to give change - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_GIVES_CHANGE ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_GIVES_CHANGE ) { if( iChangeToGiveToPlayer > 0 ) { @@ -4064,7 +4064,7 @@ void MovePlayerOfferedItemsOfValueToArmsDealersInventory() else { //if the dealer doesn't strictly buy items from the player, give the item to the dealer - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_BUYS_ONLY ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_BUYS_ONLY ) { // item cease to be merc-owned during this operation AddObjectToArmsDealerInventory( gbSelectedArmsDealerID, &( PlayersOfferArea[ uiCnt ].ItemObject ) ); @@ -4335,7 +4335,7 @@ void SetSkiCursor( UINT16 usCursor ) MSYS_ChangeRegionCursor( &gDealersOfferSlotsMouseRegions[ ubCnt], usCursor ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_ChangeRegionCursor( &gDealersOfferSlotsSmallFaceMouseRegions[ ubCnt], usCursor ); } @@ -4378,7 +4378,7 @@ void SetSkiCursor( UINT16 usCursor ) MSYS_ChangeRegionCursor( &gDealersOfferSlotsMouseRegions[ ubCnt ], usCursor ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_ChangeRegionCursor( &gDealersOfferSlotsSmallFaceMouseRegions[ ubCnt ], usCursor ); } @@ -4615,7 +4615,7 @@ void HandleShopKeeperDialog( UINT8 ubInit ) // first check if one of the situation warrants one of the more precise quotes //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { // if there are items in the arms dealer's offer area (must be awaiting repairs) if ( CountNumberOfItemsInTheArmsDealersOfferArea() > 0) @@ -4684,7 +4684,7 @@ BOOLEAN StartShopKeeperTalking( UINT16 usQuoteNum ) SpecialCharacterDialogueEvent( DIALOGUE_SPECIAL_EVENT_SHOPKEEPER, 3, usQuoteNum, 0, giShopKeeperFaceIndex, DIALOGUE_SHOPKEEPER_UI ); // post quote dialogue - fSuccess = CharacterDialogue( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, usQuoteNum, giShopKeeperFaceIndex, DIALOGUE_SHOPKEEPER_UI, FALSE, FALSE ); + fSuccess = CharacterDialogue( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, usQuoteNum, giShopKeeperFaceIndex, DIALOGUE_SHOPKEEPER_UI, FALSE, FALSE ); // post event to mark shopkeeper dialogue as ended SpecialCharacterDialogueEvent( DIALOGUE_SPECIAL_EVENT_SHOPKEEPER, 4, usQuoteNum, 0, giShopKeeperFaceIndex, DIALOGUE_SHOPKEEPER_UI ); @@ -5570,13 +5570,13 @@ void EnableDisableEvaluateAndTransactionButtons() fItemEvaluated = TRUE; //else if it is not a repair dealer, and the item is money - else if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS && Item[ PlayersOfferArea[ ubCnt ].sItemIndex ].usItemClass == IC_MONEY ) + else if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS && Item[ PlayersOfferArea[ ubCnt ].sItemIndex ].usItemClass == IC_MONEY ) fItemEvaluated = TRUE; } } //if the dealer is a repair dealer - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //if there is an item here, the item has to have been evaluated if( ArmsDealerOfferArea[ ubCnt ].fActive ) @@ -5616,7 +5616,7 @@ void EnableDisableEvaluateAndTransactionButtons() */ //If its a repair dealer, and there is no items in the Dealer Offer area, - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS && + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS && CountNumberOfItemsInTheArmsDealersOfferArea( ) == 0 && uiPlayersOfferAreaTotalMoney < uiArmsDealerTotalCost ) @@ -5665,7 +5665,7 @@ void EnableDisableEvaluateAndTransactionButtons() //ARM: Always permit trying bribes, even if they don't work on a given dealer! // if the arms dealer is the kind of person who accepts gifts, and there is stuff to take -// if( ArmsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_ACCEPTS_GIFTS ) +// if( armsDealerInfo[ gbSelectedArmsDealerID ].uiFlags & ARMS_DEALER_ACCEPTS_GIFTS ) { //if the player is giving the dealer money, without buying anything if( IsMoneyTheOnlyItemInThePlayersOfferArea( ) && CountNumberOfItemsInTheArmsDealersOfferArea( ) == 0 ) @@ -5850,7 +5850,7 @@ void ClearArmsDealerOfferSlot( INT32 ubSlotToClear ) SetRegionFastHelpText( &gDealersOfferSlotsMouseRegions[ ubSlotToClear ], L"" ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { SetRegionFastHelpText( &gDealersOfferSlotsSmallFaceMouseRegions[ ubSlotToClear ], L"" ); } @@ -5906,7 +5906,7 @@ void EvaluateItemAddedToPlayersOfferArea( INT8 bSlotID, BOOLEAN fFirstOne ) if( WillShopKeeperRejectObjectsFromPlayer( gbSelectedArmsDealerID, bSlotID ) == FALSE ) { //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { UINT32 uiNumberOfItemsInForRepairs = CountTotalItemsRepairDealerHasInForRepairs( gbSelectedArmsDealerID ); UINT32 uiNumberOfItemsAlreadyEvaluated = CountNumberOfItemsInTheArmsDealersOfferArea(); @@ -5997,7 +5997,7 @@ void EvaluateItemAddedToPlayersOfferArea( INT8 bSlotID, BOOLEAN fFirstOne ) } else // dealer doesn't handle this type of object { - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { // only otherwise repairable items count as actual rejections // if ( Item[ PlayersOfferArea[ bSlotID ].sItemIndex ].fFlags & ITEM_REPAIRABLE ) @@ -6032,7 +6032,7 @@ void EvaluateItemAddedToPlayersOfferArea( INT8 bSlotID, BOOLEAN fFirstOne ) switch ( uiEvalResult ) { case EVAL_RESULT_DONT_HANDLE: - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_SELLS_ONLY ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_SELLS_ONLY ) { // then he doesn't have quotes 17, 19, or 20, always use 4. Devin doesn't have 18 either, // while the text of 18 seems wrong for Sam & Howard if offered something they should consider valuable. @@ -6162,7 +6162,7 @@ void ConfirmToDeductMoneyFromPlayersAccountMessageBoxCallBack( UINT8 bExitValue //Perform the transaction with the extra money from the players account PerformTransaction( iMoneyToDeduct ); - AddTransactionToPlayersBook( PURCHASED_ITEM_FROM_DEALER, ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, GetWorldTotalMin(), -iMoneyToDeduct ); + AddTransactionToPlayersBook( PURCHASED_ITEM_FROM_DEALER, armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, GetWorldTotalMin(), -iMoneyToDeduct ); } // done, re-enable calls to PerformTransaction() @@ -6545,7 +6545,7 @@ BOOLEAN OfferObjectToDealer( OBJECTTYPE *pComplexObject, UINT8 ubOwnerProfileId, BOOLEAN fSuccess = FALSE; - if ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + if ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) { // if not actually doing repairs, there's no need to split objects up at all if ( !AddObjectForEvaluation( pComplexObject, ubOwnerProfileId, bOwnerSlotId, TRUE ) ) @@ -6973,7 +6973,7 @@ BOOLEAN CanMercInteractWithSelectedShopkeeper( SOLDIERTYPE *pSoldier ) Assert( pSoldier!= NULL ); Assert( gbSelectedArmsDealerID != -1 ); - pShopkeeper = FindSoldierByProfileID( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); + pShopkeeper = FindSoldierByProfileID( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID, FALSE ); Assert( pShopkeeper != NULL ); Assert( pShopkeeper->bActive ); Assert( pShopkeeper->bInSector ); @@ -7051,7 +7051,7 @@ void ExitSKIRequested() fPlayerOwnedStuffOnTable = TRUE; } - if( ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) && + if( ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) && AreThereItemsInTheArmsDealersOfferArea( ) ) { fPlayerOwnedStuffOnTable = TRUE; @@ -7148,7 +7148,7 @@ void DealWithItemsStillOnTheTable() //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { //loop through the arms dealers' offer area and return any items there to the player for( ubCnt = 0; ubCnt < SKI_NUM_TRADING_INV_SLOTS; ubCnt++) @@ -7462,21 +7462,21 @@ UINT32 EvaluateInvSlot( INVENTORY_IN_SLOT *pInvSlot ) if( gbSelectedArmsDealerID == ARMS_DEALER_MICKY ) { INT16 sSoldierID; - sSoldierID = GetSoldierIDFromMercID( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID ); + sSoldierID = GetSoldierIDFromMercID( armsDealerInfo[ gbSelectedArmsDealerID ].ubShopKeeperID ); if( ( sSoldierID != -1 ) && ( GetDrunkLevel( &Menptr[ sSoldierID ] ) == DRUNK ) ) { //Micky is DRUNK, pays more! - dPriceModifier = ArmsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier; + dPriceModifier = armsDealerInfo[ gbSelectedArmsDealerID ].dSellModifier; } else { // Micky isn't drunk, charge regular price - dPriceModifier = ArmsDealerInfo[ gbSelectedArmsDealerID ].dBuyModifier; + dPriceModifier = armsDealerInfo[ gbSelectedArmsDealerID ].dBuyModifier; } } else { - dPriceModifier = ArmsDealerInfo[ gbSelectedArmsDealerID ].dBuyModifier; + dPriceModifier = armsDealerInfo[ gbSelectedArmsDealerID ].dBuyModifier; } @@ -7629,7 +7629,7 @@ void BuildItemHelpTextString( CHAR16 sString[], INVENTORY_IN_SLOT *pInv, UINT8 u // add repair time for items in a repairman's offer area if ( ( ubScreenArea == ARMS_DEALER_OFFER_AREA ) && - ( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) ) + ( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) ) { BuildRepairTimeString( zRepairTime, CalculateObjectItemRepairTime( gbSelectedArmsDealerID, &( pInv->ItemObject ) ) ); swprintf( sString, L"%s\n(%s: %s)", zHelpText, gzLateLocalizedString[ 44 ], zRepairTime ); @@ -7656,7 +7656,7 @@ void DisableAllDealersInventorySlots( void ) MSYS_DisableRegion( &gDealersInventoryMouseRegions[ iCnt ] ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_DisableRegion( &gRepairmanInventorySmallFaceMouseRegions[ iCnt ] ); } @@ -7673,7 +7673,7 @@ void EnableAllDealersInventorySlots( void ) MSYS_EnableRegion( &gDealersInventoryMouseRegions[ iCnt ] ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_EnableRegion( &gRepairmanInventorySmallFaceMouseRegions[ iCnt ] ); } @@ -7691,7 +7691,7 @@ void DisableAllDealersOfferSlots( void ) MSYS_DisableRegion( &gDealersOfferSlotsMouseRegions[ iCnt ] ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_DisableRegion( &gDealersOfferSlotsSmallFaceMouseRegions[ iCnt ] ); } @@ -7708,7 +7708,7 @@ void EnableAllDealersOfferSlots( void ) MSYS_EnableRegion( &gDealersOfferSlotsMouseRegions[ iCnt ] ); //if the dealer repairs - if( ArmsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) + if( armsDealerInfo[ gbSelectedArmsDealerID ].ubTypeOfArmsDealer == ARMS_DEALER_REPAIRS ) { MSYS_EnableRegion( &gDealersOfferSlotsSmallFaceMouseRegions[ iCnt ] ); } diff --git a/Tactical/XML.h b/Tactical/XML.h index 655dc53b..584262ed 100644 --- a/Tactical/XML.h +++ b/Tactical/XML.h @@ -16,6 +16,14 @@ enum ELEMENT_LIST, ELEMENT, ELEMENT_PROPERTY, + + // For new merchant inventory + MERCHANT_CONTROL, + MERCHANT_CASH, + MERCHANT_CASH_DAILY, + MERCHANT_COOLNESS, + MERCHANT_FLAGS, + MERCHANT_REORDER } typedef PARSE_STAGE; diff --git a/Tactical/XML_TonyInventory.cpp b/Tactical/XML_TonyInventory.cpp index c438e560..f9160522 100644 --- a/Tactical/XML_TonyInventory.cpp +++ b/Tactical/XML_TonyInventory.cpp @@ -7,6 +7,10 @@ #include "Debug Control.h" #include "expat.h" #include "XML.h" + #include "Arms Dealer Init.h" + #include "Font Control.h" + #include "WordWrap.h" + #include "soldier profile type.h" #endif struct @@ -16,6 +20,24 @@ struct CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1]; DEALER_POSSIBLE_INV curInventory; DEALER_POSSIBLE_INV * curArray; + int armsDealerIndex; + unsigned shopKeeperID; + float buyCostModifier; + float sellCostModifier; + float repairSpeed; + float repairCost; + unsigned initialCash; + unsigned dailyIncrement; + unsigned dailyMaximum; + unsigned dailyRetained; + unsigned minCoolness; + unsigned maxCoolness; + unsigned addToCoolness; + unsigned coolnessProgressRate; + unsigned dealerFlags; + unsigned daysDelayMin; + unsigned daysDelayMax; + UINT32 maxArraySize; UINT32 currentDepth; @@ -23,99 +45,580 @@ struct } typedef inventoryParseData; +// For error messages +XML_Parser parser = 0; +STR gFileName = 0; +bool errorInData = false; +static const int NOARMSDEALERID = -1; +bool firstUIFlagEncountered = true; + + +/* + * Nesting for inventory: + * -->> ELEMENT_NONE + * -->> ELEMENT_LIST + * -->> MERCHANT_CONTROL + * ... + * ... + * ... + * ... + * ... + * ... + * -->> MERCHANT_REORDER + * ... + * ... + * <<-- MERCHANT_CONTROL + * -->> MERCHANT_CASH + * ... + * -->> MERCHANT_CASH_DAILY + * ... + * ... + * ... + * <<-- MERCHANT_CASH + * <<-- MERCHANT_CONTROL + * -->> MERCHANT_COOLNESS + * ... + * ... + * ... + * ... + * <<-- MERCHANT_CONTROL + * -->> MERCHANT_FLAGS + * + * + * <<-- ELEMENT_LIST + * -->> ELEMENT + * ... + * + * + */ + + +/* Move this to common file */ +int y = 20; // Where to start showing errors on the screen +int errorsLeftBeforeGivingUp = 5; // This many then we stop reporting them + +static void DisplayAndLogParserError (const char *err, const XML_Char *name) { + if (errorsLeftBeforeGivingUp-- == 0) + return; + CHAR8 errorBuf[511]; + sprintf(errorBuf, "XML Parser Error at line %d in file %s: %s %s", XML_GetCurrentLineNumber(parser), gFileName, err, name); + LiveMessage(errorBuf); + CHAR16 str[511]; + swprintf( str, L"%S", errorBuf ); + DisplayWrappedString( 10, y+=28, 630, 2, FONT12ARIAL, FONT_RED, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); + errorInData = true; +} + +#define NameIs(a) (strcmp(name, a) == 0) + + static void XMLCALL inventoryStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts) { - inventoryParseData * pData = (inventoryParseData *)userData; + AssertNotNIL(userData); + AssertNotNIL(name); + inventoryParseData & pData = *((inventoryParseData *)userData); - if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element? + if(pData.currentDepth <= pData.maxReadDepth) //are we reading this element? { - if(strcmp(name, "INVENTORYLIST") == 0 && pData->curElement == ELEMENT_NONE) + if (NameIs("INVENTORYLIST") && pData.curElement == ELEMENT_NONE) { - pData->curElement = ELEMENT_LIST; - - memset(pData->curArray,0,sizeof(DEALER_POSSIBLE_INV)*pData->maxArraySize); - - pData->maxReadDepth++; //we are not skipping this element + pData.curElement = ELEMENT_LIST; + memset(pData.curArray,0,sizeof(DEALER_POSSIBLE_INV)*pData.maxArraySize); + pData.maxReadDepth++; //we are not skipping this element } - else if(strcmp(name, "INVENTORY") == 0 && pData->curElement == ELEMENT_LIST) + else if (NameIs("INVENTORY") && pData.curElement == ELEMENT_LIST) { - pData->curElement = ELEMENT; - - memset(&pData->curInventory,0,sizeof(DEALER_POSSIBLE_INV)); - - pData->maxReadDepth++; //we are not skipping this element + pData.curElement = ELEMENT; + memset(&pData.curInventory,0,sizeof(DEALER_POSSIBLE_INV)); + pData.maxReadDepth++; //we are not skipping this element } - else if(pData->curElement == ELEMENT && - (strcmp(name, "uiIndex") == 0 || - strcmp(name, "sItemIndex") == 0 || - strcmp(name, "ubOptimalNumber") == 0 )) + else if(pData.curElement == ELEMENT && + (NameIs("uiIndex") || + NameIs("sItemIndex") || + NameIs("ubOptimalNumber") )) { - pData->curElement = ELEMENT_PROPERTY; - - pData->maxReadDepth++; //we are not skipping this element + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element } - - pData->szCharData[0] = '\0'; + else if (NameIs("CONTROL") && pData.curElement == ELEMENT_LIST) + { + pData.curElement = MERCHANT_CONTROL; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_CONTROL && + (NameIs("BUYCOSTMODIFIER") || + NameIs("SELLCOSTMODIFIER") || + NameIs("REPAIRSPEED") || + NameIs("REPAIRCOST") || + NameIs("SHOPKEEPERID") || + NameIs("ARMSDEALERINDEX") )) + { + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (NameIs("REORDERDAYSDELAY") && pData.curElement == MERCHANT_CONTROL) + { + pData.curElement = MERCHANT_REORDER; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_REORDER && + (NameIs("REORDERMINIMUM") || + NameIs("REORDERMAXIMUM"))) + { + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (NameIs("CASH") && pData.curElement == MERCHANT_CONTROL) + { + pData.curElement = MERCHANT_CASH; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_CASH && + (NameIs("INITIAL"))) + { + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (NameIs("DAILY") && pData.curElement == MERCHANT_CASH) + { + pData.curElement = MERCHANT_CASH_DAILY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_CASH_DAILY && + (NameIs("INCREMENT") || + NameIs("CASHMAXIMUM") || + NameIs("RETAINED") )) + { + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (NameIs("COOLNESS") && pData.curElement == MERCHANT_CONTROL) + { + pData.curElement = MERCHANT_COOLNESS; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_COOLNESS && + (NameIs("COOLMINIMUM") || + NameIs("COOLMAXIMUM") || + NameIs("COOLADD") || + NameIs("PROGRESSRATE") )) + { + pData.curElement = ELEMENT_PROPERTY; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_COOLNESS && + (NameIs("USEBOBBYRAYSETTING") || + NameIs("ALLINVENTORYALWAYSAVAILBLE"))) + { + pData.maxReadDepth++; //we are not skipping this element + } + else if (NameIs("BASICDEALERFLAGS") && pData.curElement == MERCHANT_CONTROL) + { + pData.curElement = MERCHANT_FLAGS; + pData.maxReadDepth++; //we are not skipping this element + } + else if (pData.curElement == MERCHANT_FLAGS && + (NameIs("ARMS_DEALER_HANDGUNCLASS") || + NameIs("ARMS_DEALER_SMGCLASS") || + NameIs("ARMS_DEALER_RIFLECLASS") || + NameIs("ARMS_DEALER_MGCLASS") || + NameIs("ARMS_DEALER_SHOTGUNCLASS") || + NameIs("ARMS_DEALER_KNIFECLASS") || + NameIs("ARMS_DEALER_BLADE") || + NameIs("ARMS_DEALER_LAUNCHER") || + NameIs("ARMS_DEALER_ARMOUR") || + NameIs("ARMS_DEALER_MEDKIT") || + NameIs("ARMS_DEALER_MISC") || + NameIs("ARMS_DEALER_AMMO") || + NameIs("ARMS_DEALER_GRENADE") || + NameIs("ARMS_DEALER_BOMB") || + NameIs("ARMS_DEALER_EXPLOSV") || + NameIs("ARMS_DEALER_KIT") || + NameIs("ARMS_DEALER_FACE") || + NameIs("ARMS_DEALER_DETONATORS") || + NameIs("ARMS_DEALER_ATTACHMENTS") || + NameIs("ARMS_DEALER_ALCOHOL") || + NameIs("ARMS_DEALER_ELECTRONICS") || + NameIs("ARMS_DEALER_HARDWARE") || + NameIs("ARMS_DEALER_MEDICAL") || + NameIs("ARMS_DEALER_CREATURE_PARTS") || + NameIs("ARMS_DEALER_ROCKET_RIFLE") || + NameIs("ARMS_DEALER_ONLY_USED_ITEMS") || + NameIs("ARMS_DEALER_GIVES_CHANGE") || + NameIs("ARMS_DEALER_ACCEPTS_GIFTS") || + NameIs("ARMS_DEALER_SOME_USED_ITEMS") || + NameIs("ARMS_DEALER_HAS_NO_INVENTORY") || + NameIs("ARMS_DEALER_ALL_GUNS") || + NameIs("ARMS_DEALER_BIG_GUNS") || + NameIs("ARMS_DEALER_ALL_WEAPONS"))) + { + pData.curElement = MERCHANT_FLAGS; + pData.maxReadDepth++; //we are not skipping this element + } + else { + // Something unexpected, error! + DisplayAndLogParserError ("unknown/unexpected start element", name); + } + pData.szCharData[0] = '\0'; } - - pData->currentDepth++; - + pData.currentDepth++; } static void XMLCALL inventoryCharacterDataHandle(void *userData, const XML_Char *str, int len) { - inventoryParseData * pData = (inventoryParseData *)userData; + AssertNotNIL(userData); + AssertNotNIL(str); + inventoryParseData & pData = *((inventoryParseData *)userData); - if( (pData->currentDepth <= pData->maxReadDepth) && - (strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH) + if( (pData.currentDepth <= pData.maxReadDepth) && + (strlen(pData.szCharData) < MAX_CHAR_DATA_LENGTH) ){ - strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData))); + strncat(pData.szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData.szCharData))); + } else { + DisplayAndLogParserError ("string too long", str); } } +static bool CheckArmsDealerIndex(inventoryParseData &pData) { + if (pData.armsDealerIndex == NOARMSDEALERID) { + DisplayAndLogParserError("No ARMSDEALERINDEX yet", ""); + return false; + } else { + return true; + } +} + + +static bool HandleUIFlag(inventoryParseData & pData, const XML_Char *name, const char*str, unsigned flag) { + if (pData.curElement == MERCHANT_FLAGS && NameIs(str)) { + if (CheckArmsDealerIndex(pData)) { + if (firstUIFlagEncountered) { + armsDealerInfo[pData.armsDealerIndex].uiFlags = flag; + firstUIFlagEncountered = false; + } else { + armsDealerInfo[pData.armsDealerIndex].uiFlags |= flag; + } + return true; + } + } + return false; +} + + + static void XMLCALL inventoryEndElementHandle(void *userData, const XML_Char *name) { - inventoryParseData * pData = (inventoryParseData *)userData; + AssertNotNIL(userData); + AssertNotNIL(name); + inventoryParseData & pData = *((inventoryParseData *)userData); - if(pData->currentDepth <= pData->maxReadDepth) //we're at the end of an element that we've been reading + if(pData.currentDepth <= pData.maxReadDepth) //we're at the end of an element that we've been reading { - if(strcmp(name, "INVENTORYLIST") == 0) + if (NameIs("INVENTORYLIST")) { - pData->curElement = ELEMENT_NONE; + pData.curElement = ELEMENT_NONE; } - else if(strcmp(name, "INVENTORY") == 0) + else if (NameIs("INVENTORY")) { - pData->curElement = ELEMENT_LIST; + pData.curElement = ELEMENT_LIST; - if(pData->curInventory.uiIndex < pData->maxArraySize) + if(pData.curInventory.uiIndex < pData.maxArraySize) { - pData->curArray[pData->curInventory.uiIndex] = pData->curInventory; //write the inventory into the table + pData.curArray[pData.curInventory.uiIndex] = pData.curInventory; //write the inventory into the table } } - else if(strcmp(name, "uiIndex") == 0) + else if (NameIs("uiIndex")) { - pData->curElement = ELEMENT; - pData->curInventory.uiIndex = (UINT32) atol(pData->szCharData); + pData.curElement = ELEMENT; + pData.curInventory.uiIndex = (UINT32) atol(pData.szCharData); } - else if(strcmp(name, "sItemIndex") == 0) + else if (NameIs("sItemIndex")) { - pData->curElement = ELEMENT; - pData->curInventory.sItemIndex = (INT16) atol(pData->szCharData); + pData.curElement = ELEMENT; + pData.curInventory.sItemIndex = (INT16) atol(pData.szCharData); } - else if(strcmp(name, "ubOptimalNumber") == 0) + else if (NameIs("ubOptimalNumber")) { - pData->curElement = ELEMENT; - pData->curInventory.ubOptimalNumber = (UINT8) atol(pData->szCharData); + pData.curElement = ELEMENT; + pData.curInventory.ubOptimalNumber = (UINT8) atol(pData.szCharData); + } + else if (NameIs("CONTROL")) + { + pData.curElement = ELEMENT_LIST; + } + else if (NameIs("ARMSDEALERINDEX")) + { + pData.curElement = MERCHANT_CONTROL; + pData.armsDealerIndex = (unsigned) atol(pData.szCharData); + if (pData.armsDealerIndex >= 0 && pData.armsDealerIndex < NUM_ARMS_DEALERS) + ; // ok + else { + DisplayAndLogParserError("Invalid value (outside valid range) for", "ARMSDEALERINDEX"); + } + } + else if (NameIs("SHOPKEEPERID")) + { + pData.curElement = MERCHANT_CONTROL; + if (CheckArmsDealerIndex(pData)) { + pData.shopKeeperID = (unsigned) atol(pData.szCharData); + if (pData.shopKeeperID >= 0 && pData.shopKeeperID < NUM_PROFILES) + armsDealerInfo[pData.armsDealerIndex].ubShopKeeperID = pData.shopKeeperID; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "SHOPKEEPERID"); + } + } + else if (NameIs("BUYCOSTMODIFIER")) + { + pData.curElement = MERCHANT_CONTROL; + if (CheckArmsDealerIndex(pData)) { + pData.buyCostModifier = (float) atof(pData.szCharData); + if (pData.buyCostModifier >= 0 && pData.buyCostModifier < 5.0) + armsDealerInfo[pData.armsDealerIndex].dBuyModifier = pData.buyCostModifier; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "BUYCOSTMODIFIER"); + if (pData.repairSpeed != 0 || pData.repairCost != 0) + DisplayAndLogParserError("Shopkeepers may not both be buyers/sells and repairers", "BUYCOSTMODIFIER"); + else + ; // Set buy/sell/repair flags + } + } + else if (NameIs("SELLCOSTMODIFIER")) + { + pData.curElement = MERCHANT_CONTROL; + if (CheckArmsDealerIndex(pData)) { + pData.sellCostModifier = (float) atof(pData.szCharData); + if (pData.sellCostModifier >= 0 && pData.sellCostModifier < 5.0) + armsDealerInfo[pData.armsDealerIndex].dSellModifier = pData.sellCostModifier; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "SELLCOSTMODIFIER"); + if (pData.repairSpeed != 0 || pData.repairCost != 0) + DisplayAndLogParserError("Shopkeepers may not both be buyers/sells and repairers", "SELLCOSTMODIFIER"); + else + ; // Set buy/sell/repair flags + } + } + else if (NameIs("REPAIRSPEED")) + { + pData.curElement = MERCHANT_CONTROL; + if (CheckArmsDealerIndex(pData)) { + pData.repairSpeed = (float) atof(pData.szCharData); + if (pData.repairSpeed >= 0 && pData.repairSpeed < 5.0) + armsDealerInfo[pData.armsDealerIndex].dRepairSpeed = pData.repairSpeed; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "REPAIRSPEED"); + if (pData.buyCostModifier != 0 || pData.sellCostModifier != 0) + DisplayAndLogParserError("Shopkeepers may not both be buyers/sells and repairers", "BUYCOSTMODIFIER"); + else + ; // Set buy/sell/repair flags + } + } + else if (NameIs("REPAIRCOST")) + { + pData.curElement = MERCHANT_CONTROL; + if (CheckArmsDealerIndex(pData)) { + pData.repairCost = (float) atof(pData.szCharData); + if (pData.repairCost >= 0 && pData.repairCost < 5.0) + armsDealerInfo[pData.armsDealerIndex].dRepairCost = pData.repairCost; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "REPAIRCOST"); + if (pData.buyCostModifier != 0 || pData.sellCostModifier != 0) + DisplayAndLogParserError("Shopkeepers may not both be buyers/sells and repairers", "REPAIRCOST"); + else + ; // Set buy/sell/repair flags + } + } + else if (NameIs("REORDERDAYSDELAY")) + { + pData.curElement = MERCHANT_CONTROL; + } + else if (NameIs("REORDERMINIMUM")) + { + pData.curElement = MERCHANT_REORDER; + if (CheckArmsDealerIndex(pData)) { + pData.daysDelayMin = (unsigned) atol(pData.szCharData); + if (pData.daysDelayMin >= 1 && pData.daysDelayMin <= 10) + armsDealerInfo[pData.armsDealerIndex].daysDelayMin = pData.daysDelayMin; + else + DisplayAndLogParserError("Invalid value (outside valid range of 1..10) for", "REORDERMINIMUM"); + } + } + else if (NameIs("REORDERMAXIMUM")) + { + pData.curElement = MERCHANT_REORDER; + if (CheckArmsDealerIndex(pData)) { + pData.daysDelayMax = (unsigned) atol(pData.szCharData); + if (pData.daysDelayMax >= 1 && pData.daysDelayMax <= 10) + armsDealerInfo[pData.armsDealerIndex].daysDelayMax = pData.daysDelayMax; + else + DisplayAndLogParserError("Invalid value (outside valid range of 1..10) for", "REORDERMAXIMUM"); + } + } + else if (NameIs("CASH")) + { + pData.curElement = MERCHANT_CONTROL; + } + else if (NameIs("INITIAL")) + { + pData.curElement = MERCHANT_CASH; + if (CheckArmsDealerIndex(pData)) { + pData.initialCash = (unsigned) atol(pData.szCharData); + if (pData.initialCash >= 0 && pData.initialCash <= 1000000) + armsDealerInfo[pData.armsDealerIndex].iInitialCash = pData.initialCash; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "INITIAL"); + } + } + else if (NameIs("DAILY")) + { + pData.curElement = MERCHANT_CASH; + } + else if (NameIs("INCREMENT")) + { + pData.curElement = MERCHANT_CASH_DAILY; + if (CheckArmsDealerIndex(pData)) { + pData.dailyIncrement = (unsigned) atol(pData.szCharData); + if (pData.dailyIncrement >= 0 && pData.dailyIncrement <= 1000000) + armsDealerInfo[pData.armsDealerIndex].dailyIncrement = pData.dailyIncrement; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "INCREMENT"); + } + } + else if (NameIs("CASHMAXIMUM")) + { + pData.curElement = MERCHANT_CASH_DAILY; + if (CheckArmsDealerIndex(pData)) { + pData.dailyMaximum = (unsigned) atol(pData.szCharData); + if (pData.dailyMaximum >= 0 && pData.dailyMaximum <= 1000000) + armsDealerInfo[pData.armsDealerIndex].dailyMaximum = pData.dailyMaximum; + else + DisplayAndLogParserError("Invalid value (outside valid range) for", "CASHMAXIMUM"); + } + } + else if (NameIs("RETAINED")) + { + pData.curElement = MERCHANT_CASH_DAILY; + if (CheckArmsDealerIndex(pData)) { + pData.dailyRetained = (unsigned) atol(pData.szCharData); + if (pData.dailyRetained >= 0 && pData.dailyRetained <= 100) + armsDealerInfo[pData.armsDealerIndex].dailyRetained = pData.dailyRetained; + else + DisplayAndLogParserError("Invalid value (outside valid range of 0..100) for", "RETAINED"); + } + } + else if (NameIs("COOLNESS")) + { + pData.curElement = MERCHANT_CONTROL; + } + else if (NameIs("COOLMINIMUM")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + pData.minCoolness = (unsigned) atol(pData.szCharData); + if (pData.minCoolness >= 0 && pData.minCoolness <= 10) + armsDealerInfo[pData.armsDealerIndex].minCoolness = pData.minCoolness; + else + DisplayAndLogParserError("Invalid value (outside valid range of 0..10) for", "COOLMINIMUM"); + } + } + else if (NameIs("COOLMAXIMUM")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + pData.maxCoolness = (unsigned) atol(pData.szCharData); + if (pData.maxCoolness >= 0 && pData.maxCoolness <= 10) + armsDealerInfo[pData.armsDealerIndex].maxCoolness = pData.maxCoolness; + else + DisplayAndLogParserError("Invalid value (outside valid range of 0..10) for", "COOLMAXIMUM"); + } + } + else if (NameIs("COOLADD")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + pData.addToCoolness = (unsigned) atol(pData.szCharData); + if (pData.addToCoolness >= 0 && pData.addToCoolness <= 10) + armsDealerInfo[pData.armsDealerIndex].addToCoolness = pData.addToCoolness; + else + DisplayAndLogParserError("Invalid value (outside valid range of 0..10) for", "COOLADD"); + } + } + else if (NameIs("PROGRESSRATE")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + pData.coolnessProgressRate = (unsigned) atol(pData.szCharData); + if (pData.coolnessProgressRate >= 0 && pData.coolnessProgressRate <= 100) + armsDealerInfo[pData.armsDealerIndex].coolnessProgressRate = pData.coolnessProgressRate; + else + DisplayAndLogParserError("Invalid value (outside valid range of 0..100) for", "PROGRESSRATE"); + } + } + else if (NameIs("USEBOBBYRAYSETTING")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + //pData.useBRSetting = true; + armsDealerInfo[pData.armsDealerIndex].useBRSetting = true; + } + } + else if (NameIs("ALLINVENTORYALWAYSAVAILBLE")) + { + pData.curElement = MERCHANT_COOLNESS; + if (CheckArmsDealerIndex(pData)) { + //pData.useBRSetting = true; + armsDealerInfo[pData.armsDealerIndex].allInventoryAlwaysAvailable = true; + } + } + else if (NameIs("BASICDEALERFLAGS")) + { + pData.curElement = MERCHANT_CONTROL; + } + else if (HandleUIFlag(pData, name, "ARMS_DEALER_HANDGUNCLASS", ARMS_DEALER_HANDGUNCLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_SMGCLASS", ARMS_DEALER_SMGCLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_RIFLECLASS", ARMS_DEALER_RIFLECLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_MGCLASS", ARMS_DEALER_MGCLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_SHOTGUNCLASS", ARMS_DEALER_SHOTGUNCLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_KNIFECLASS", ARMS_DEALER_KNIFECLASS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_BLADE", ARMS_DEALER_BLADE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_LAUNCHER", ARMS_DEALER_LAUNCHER)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ARMOUR", ARMS_DEALER_ARMOUR)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_MEDKIT", ARMS_DEALER_MEDKIT)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_MISC", ARMS_DEALER_MISC)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_AMMO", ARMS_DEALER_AMMO)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_GRENADE", ARMS_DEALER_GRENADE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_BOMB", ARMS_DEALER_BOMB)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_EXPLOSV", ARMS_DEALER_EXPLOSV)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_KIT", ARMS_DEALER_KIT)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_FACE", ARMS_DEALER_FACE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_DETONATORS", ARMS_DEALER_DETONATORS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ATTACHMENTS", ARMS_DEALER_ATTACHMENTS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ALCOHOL", ARMS_DEALER_ALCOHOL)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ELECTRONICS", ARMS_DEALER_ELECTRONICS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_HARDWARE", ARMS_DEALER_HARDWARE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_MEDICAL", ARMS_DEALER_MEDICAL)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_CREATURE_PARTS", ARMS_DEALER_CREATURE_PARTS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ROCKET_RIFLE", ARMS_DEALER_ROCKET_RIFLE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ONLY_USED_ITEMS", ARMS_DEALER_ONLY_USED_ITEMS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_GIVES_CHANGE", ARMS_DEALER_GIVES_CHANGE)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ACCEPTS_GIFTS", ARMS_DEALER_ACCEPTS_GIFTS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_SOME_USED_ITEMS", ARMS_DEALER_SOME_USED_ITEMS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_HAS_NO_INVENTORY", ARMS_DEALER_HAS_NO_INVENTORY)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ALL_GUNS", ARMS_DEALER_ALL_GUNS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_BIG_GUNS", ARMS_DEALER_BIG_GUNS)) {} + else if (HandleUIFlag(pData, name, "ARMS_DEALER_ALL_WEAPONS", ARMS_DEALER_ALL_WEAPONS)) {} + else { + // Something unexpected, error! + DisplayAndLogParserError ("unknown/unexpected end element", name); } - pData->maxReadDepth--; + pData.maxReadDepth--; } - pData->currentDepth--; + pData.currentDepth--; } @@ -127,7 +630,8 @@ BOOLEAN ReadInInventoryStats(DEALER_POSSIBLE_INV *pInv, STR fileName) UINT32 uiBytesRead; UINT32 uiFSize; CHAR8 * lpcBuffer; - XML_Parser parser = XML_ParserCreate(NULL); + parser = XML_ParserCreate(NULL); + gFileName = fileName; inventoryParseData pData; @@ -149,40 +653,37 @@ BOOLEAN ReadInInventoryStats(DEALER_POSSIBLE_INV *pInv, STR fileName) } lpcBuffer[uiFSize] = 0; //add a null terminator - FileClose( hFile ); - XML_SetElementHandler(parser, inventoryStartElementHandle, inventoryEndElementHandle); XML_SetCharacterDataHandler(parser, inventoryCharacterDataHandle); - + // Set the default values memset(&pData,0,sizeof(pData)); + pData.armsDealerIndex = NOARMSDEALERID; + pData.curArray = pInv; pData.maxArraySize = MAXITEMS; XML_SetUserData(parser, &pData); - if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) { - CHAR8 errorBuf[511]; - - sprintf(errorBuf, "XML Parser Error in Inventory.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); - LiveMessage(errorBuf); - - MemFree(lpcBuffer); - return FALSE; + DisplayAndLogParserError (XML_ErrorString(XML_GetErrorCode(parser)), ""); + errorInData = true; } MemFree(lpcBuffer); - - XML_ParserFree(parser); - - return( TRUE ); + if (errorInData) + // Assume message already generated + return FALSE; + else + return( TRUE ); } + + BOOLEAN WriteInventoryStats(DEALER_POSSIBLE_INV *pInv, STR fileName) { //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"writeinventorystats");