From 5e2982c5091d4b29670983c52e3ca00255b64ff3 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 10:05:47 -0300 Subject: [PATCH] take popup option names by const reference, not by pointer POPUP_OPTION copies the name it is given -- `this->name = *newName` into a std::wstring member -- but its constructor took a std::wstring*, so 64 call sites spelled the argument `&std::wstring( pStr )`. Taking the address of a temporary is ill-formed, and clang refuses it outright: error: taking the address of a temporary object of type 'std::wstring' It happens to work under MSVC because the temporary outlives the call, dying at the end of the full expression rather than before the copy. Nothing was corrupt; the code was just spelling "pass me a string" in a way the language does not allow. A const reference says what these functions actually want, so the call sites lose the &, and the two places that allocated a string purely to have an address to pass -- POPUP_SUB_POPUP_OPTION's default constructor, which carried a "TODO: possible memmory leak!" saying as much, and a "Dummy generator" option -- stop leaking one. Converted: POPUP_OPTION's constructor and setName, POPUP::addOption and addSubMenuOption, and both POPUP_SUB_POPUP_OPTION constructors. The popupDef family in popup_definition.* keeps its std::wstring* because it owns what it is handed and stores the pointer; that is a different design and a different change. The three calls it makes into the converted API now dereference. Verification: grep -rn '&std::wstring' --include=*.cpp --include=*.h . # nothing ninja -C build parse # no popup_* or SkillMenu sites remain ninja -C build -k 0 # Release, four applications, green ninja -C build-debug -k 0 # Debug, four applications, green Co-Authored-By: Claude Opus 4.8 --- .../Map Screen Interface Map Inventory.cpp | 20 +++--- Tactical/Interface Items.cpp | 62 ++++++++-------- Tactical/SkillMenu.cpp | 70 +++++++++---------- Tactical/VehicleMenu.cpp | 4 +- Utils/popup_class.cpp | 18 ++--- Utils/popup_class.h | 12 ++-- Utils/popup_definition.cpp | 6 +- 7 files changed, 96 insertions(+), 96 deletions(-) diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index 869e312ea..91e046290 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -5563,7 +5563,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 0 ] ); // Add option: "SHOW ALL" uiFlags = IC_MAPFILTER_ALL; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) ); if (guiMapInventoryFilter == IC_MAPFILTER_ALL) { // Set this option off. @@ -5583,7 +5583,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 1 ] ); } uiFlags = IC_MAPFILTER_GUN; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_AMMO) @@ -5597,7 +5597,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 2 ] ); } uiFlags = IC_MAPFILTER_AMMO; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_EXPLOSV) @@ -5611,7 +5611,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 3 ] ); } uiFlags = IC_MAPFILTER_EXPLOSV; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_MELEE) @@ -5625,7 +5625,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 4 ] ); } uiFlags = IC_MAPFILTER_MELEE; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_ARMOR) @@ -5639,7 +5639,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 5 ] ); } uiFlags = IC_MAPFILTER_ARMOR; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_LBE) @@ -5653,7 +5653,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 6 ] ); } uiFlags = IC_MAPFILTER_LBE; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_KIT) @@ -5667,7 +5667,7 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 7 ] ); } uiFlags = IC_MAPFILTER_KIT; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); if (guiMapInventoryFilter & IC_MAPFILTER_MISC) @@ -5681,13 +5681,13 @@ void CreateMapInventoryFilterMenu( ) swprintf( pStr, gzMapInventoryFilterOptions[ 8 ] ); } uiFlags = IC_MAPFILTER_MISC; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) ); gMapInventoryFilterPopup->addOption( *pOption ); swprintf( pStr, gzMapInventoryFilterOptions[ 9 ] ); // Add option: "HIDE ALL" uiFlags = 0; - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) ); if (guiMapInventoryFilter == 0) { // Set this option off. diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 5272311ab..6ec55465b 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2103,7 +2103,7 @@ void addItemsToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup, if( optsTotal > 0 && optsTotal%15 == 0 ){ // divide to subBoxes every 10 items - POPUP * currPopupTmp = currPopup->addSubMenuOption( new std::wstring( gszPocketPopupText[POCKET_POPUP_MOAR] ) ); // the new popup + POPUP * currPopupTmp = currPopup->addSubMenuOption( std::wstring( gszPocketPopupText[POCKET_POPUP_MOAR] ) ); // the new popup POPUP_SUB_POPUP_OPTION * currSubPopupTmp = currPopup->getSubPopupOption( currPopup->subPopupOptionCount-1 ); // the sub-popup option in prev popup @@ -2139,13 +2139,13 @@ void addItemsToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup, swprintf( pStr, L"%s (%d)", Item[ itr->first ].szItemName, numObjectsToPlace ); currPopup->addOption( - &std::wstring( pStr ), + std::wstring( pStr ), new popupCallbackFunction3(&popupCallbackPlaceLeastDamagedFromStack,itr->second,sPocket,pSoldier) ); } else { currPopup->addOption( - &std::wstring( Item[ itr->first ].szItemName ), + std::wstring( Item[ itr->first ].szItemName ), new popupCallbackFunction3(&popupCallbackPlaceLeastDamagedFromStack,itr->second,sPocket,pSoldier) ); } @@ -2178,7 +2178,7 @@ void addWeaponGroupsToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* POPUP * subPopup = NULL; - subPopup = popup->addSubMenuOption( new std::wstring(BobbyRFilter[17]/*Guns*/) ); + subPopup = popup->addSubMenuOption( std::wstring(BobbyRFilter[17]/*Guns*/) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10, 10, POPUP_POSITION_RELATIVE ); @@ -2193,33 +2193,33 @@ void addWeaponGroupsToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* UINT8 weaponTypeCtr; for( weaponTypeCtr = 1; weaponTypeCtr <= 8; weaponTypeCtr++ ){ - weaponTypePopup = subPopup->addSubMenuOption( new std::wstring( WeaponType[weaponTypeCtr] ) ); + weaponTypePopup = subPopup->addSubMenuOption( std::wstring( WeaponType[weaponTypeCtr] ) ); for(std::map::iterator itr = bestItems.begin(); itr != bestItems.end(); ++itr){ if ( Weapon[ itr->first ].ubWeaponType == weaponTypeCtr ) weaponTypePopup->addOption( - &std::wstring( Item[ itr->first ].szItemName ), + std::wstring( Item[ itr->first ].szItemName ), new popupCallbackFunction3(&popupCallbackPlaceLeastDamagedFromStack,itr->second,sPocket,pSoldier) ); } } - subPopup = popup->addSubMenuOption( new std::wstring( gszPocketPopupText[POCKET_POPUP_GRENADE_LAUNCHERS] ) ); + subPopup = popup->addSubMenuOption( std::wstring( gszPocketPopupText[POCKET_POPUP_GRENADE_LAUNCHERS] ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10, 10, POPUP_POSITION_RELATIVE ); addItemsToPocketPopup( pSoldier, sPocket, subPopup, IC_LAUNCHER, -1, -1, 0 ); - subPopup = popup->addSubMenuOption( new std::wstring( gszPocketPopupText[POCKET_POPUP_ROCKET_LAUNCHERS] ) ); + subPopup = popup->addSubMenuOption( std::wstring( gszPocketPopupText[POCKET_POPUP_ROCKET_LAUNCHERS] ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10, 10, POPUP_POSITION_RELATIVE ); addItemsToPocketPopup( pSoldier, sPocket, subPopup, IC_GUN, -1, 0, 0); - subPopup = popup->addSubMenuOption( new std::wstring( gszPocketPopupText[POCKET_POPUP_MEELE_AND_THROWN] ) ); + subPopup = popup->addSubMenuOption( std::wstring( gszPocketPopupText[POCKET_POPUP_MEELE_AND_THROWN] ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10, 10, POPUP_POSITION_RELATIVE ); @@ -2286,7 +2286,7 @@ void addAmmoToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ) { UINT8 ammoFound = 0; - POPUP_OPTION * o = popup->addOption( &std::wstring( Item[ (*gun)->usItem ].szItemName ), NULL ); + POPUP_OPTION * o = popup->addOption( std::wstring( Item[ (*gun)->usItem ].szItemName ), NULL ); o->color_shade = COLOR_LTGREY; //o->color_background = COLOR_LTGREY; @@ -2335,7 +2335,7 @@ void addAmmoToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ) static CHAR16 pStr[ 100 ]; swprintf( pStr, L"%s (%d)", Item[loop].szItemName,capacity ); - popup->addOption( &std::wstring( pStr ), new popupCallbackFunction3(&popupCallbackAmmo,loop,sPocket,pSoldier) ); + popup->addOption( std::wstring( pStr ), new popupCallbackFunction3(&popupCallbackAmmo,loop,sPocket,pSoldier) ); } // found ammo crate, crate matches mag } // inv loop @@ -2344,7 +2344,7 @@ void addAmmoToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ) } // mag loop if (!ammoFound){ - POPUP_OPTION * o = popup->addOption( &std::wstring( gszPocketPopupText[POCKET_POPUP_NO_AMMO] ), NULL ); + POPUP_OPTION * o = popup->addOption( std::wstring( gszPocketPopupText[POCKET_POPUP_NO_AMMO] ), NULL ); o->color_shade = COLOR_RED; } @@ -2354,7 +2354,7 @@ void addAmmoToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ) } // found guns else { - POPUP_OPTION * o = popup->addOption( &std::wstring( gszPocketPopupText[POCKET_POPUP_NO_GUNS] ), NULL ); + POPUP_OPTION * o = popup->addOption( std::wstring( gszPocketPopupText[POCKET_POPUP_NO_GUNS] ), NULL ); o->color_shade = COLOR_RED; } } @@ -2427,31 +2427,31 @@ void PocketPopupFull( SOLDIERTYPE *pSoldier, INT16 sPocket ){ POPUP * subPopup = NULL; - subPopup = popup->addSubMenuOption( new std::wstring( iEditorItemsToolbarText[0]/*Weapons*/ ) ); + subPopup = popup->addSubMenuOption( std::wstring( iEditorItemsToolbarText[0]/*Weapons*/ ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addWeaponGroupsToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRText[BOBBYR_GUNS_AMMO]/*Ammo*/ ) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRText[BOBBYR_GUNS_AMMO]/*Ammo*/ ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addAmmoToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRText[BOBBYR_GUNS_ARMOR]/*Amour*/ ) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRText[BOBBYR_GUNS_ARMOR]/*Amour*/ ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addArmorToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRFilter[BOBBYR_FILTER_USED_LBEGEAR] /*"LBE"*/) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRFilter[BOBBYR_FILTER_USED_LBEGEAR] /*"LBE"*/) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addLBEToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_GRENADE]/*Grenades*/ ) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_GRENADE]/*Grenades*/ ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addGrenadesToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_BOMB] ) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_BOMB] ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addBombsToPocketPopup( pSoldier, sPocket, subPopup ); - subPopup = popup->addSubMenuOption( new std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_FACE] ) ); + subPopup = popup->addSubMenuOption( std::wstring( BobbyRFilter[BOBBYR_FILTER_MISC_FACE] ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addFaceGearToPocketPopup( pSoldier, sPocket, subPopup ); @@ -2529,7 +2529,7 @@ void PocketPopupDefault( SOLDIERTYPE *pSoldier, INT16 sPocket ){ // default for LBE slots - grenades + ammo for merc's guns addAmmoToPocketPopup( pSoldier, sPocket, popup ); - POPUP * subPopup = popup->addSubMenuOption( new std::wstring( BobbyRFilter[28]/*Grenades*/ ) ); + POPUP * subPopup = popup->addSubMenuOption( std::wstring( BobbyRFilter[28]/*Grenades*/ ) ); popup->getSubPopupOption( popup->subPopupOptionCount-1 )->setPopupPosition( 10,10,POPUP_POSITION_RELATIVE ); addGrenadesToPocketPopup( pSoldier, sPocket, subPopup ); } else { @@ -5912,7 +5912,7 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) if (showAttachmentPopups) { // add the current attachment to the popup assigned to this attachment slot - POPUP_OPTION * o = new POPUP_OPTION( &std::wstring( Item[ usAttachment ].szItemName ), + POPUP_OPTION * o = new POPUP_OPTION( std::wstring( Item[ usAttachment ].szItemName ), new popupCallbackFunction(&popupCallbackItem,usAttachment)); gPopupAttachmentInfos.push_back(new PopupAttachmentInfo(usAttachment, pObject, ubStatusIndex, slotCount, o, gItemDescAttachmentPopups[slotCount])); @@ -5921,7 +5921,7 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) o->setAvail(new popupCallbackFunction(&popupCallbackItemInSector, (gPopupAttachmentInfos.back()))); if (loop == 11 && attachList.size() > 11){ // if there's too much stuff to list, we create a subpopup for the rest - gItemDescAttachmentPopups[slotCount]->addSubMenuOption( &std::wstring(L"More...") ); + gItemDescAttachmentPopups[slotCount]->addSubMenuOption( std::wstring(L"More...") ); POPUP_SUB_POPUP_OPTION * tmp = gItemDescAttachmentPopups[slotCount]->getSubPopupOption(0); // positioning sub popups is handled through the option that holds them @@ -13410,7 +13410,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) if ((*gpItemDescObject)[0]->data.gun.bGunAmmoStatus < 0) { // Add option - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( L"Unjam" ), new popupCallbackFunction( &TransformationMenuPopup_Unjam )); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( L"Unjam" ), new popupCallbackFunction( &TransformationMenuPopup_Unjam )); gItemDescTransformPopup->addOption( *pOption ); fFoundTransformations = true; } @@ -13463,7 +13463,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) CHAR16 MenuRowText[300]; swprintf( MenuRowText, gzTransformationMessage[ 7 ], usMagSize ); // Generate a new option for the menu - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( TransformationMenuPopup_SplitCrate, x ) ); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( MenuRowText ), new popupCallbackFunction( TransformationMenuPopup_SplitCrate, x ) ); // Add the option to the menu. gItemDescTransformPopup->addOption( *pOption ); // Set this flag so we know we have at least one Transformation available. @@ -13474,7 +13474,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) } else { - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( gzTransformationMessage[ 6 ] ), new popupCallbackFunction( TransformationMenuPopup_SplitCrateInInventory ) ); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( gzTransformationMessage[ 6 ] ), new popupCallbackFunction( TransformationMenuPopup_SplitCrateInInventory ) ); gItemDescTransformPopup->addOption( *pOption ); fFoundTransformations = true; } @@ -13527,7 +13527,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) } // Generate a new option for the menu - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); // Set the function that tests whether it's valid at the moment. pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_Arm_TestValid, gpItemDescObject )); // Add the option to the menu. @@ -13553,7 +13553,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) } // Generate a new option for the menu - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Arm, gpItemDescObject ) ); // Set the function that tests whether it's valid at the moment. pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_Arm_TestValid, gpItemDescObject )); // Add the option to the menu. @@ -13591,7 +13591,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) } // Add option - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_DelayedGrenadeExplosion )); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_DelayedGrenadeExplosion )); pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_DelayedGrenadeExplosion_TestValid, gpItemDescObject )); gItemDescTransformPopup->addOption( *pOption ); fFoundTransformations = true; @@ -13618,7 +13618,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) } // Generate a new option for the menu - POPUP_OPTION *pOption = new POPUP_OPTION(&std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Transform, &Transform[x] ) ); + POPUP_OPTION *pOption = new POPUP_OPTION(std::wstring( MenuRowText ), new popupCallbackFunction( &TransformationMenuPopup_Transform, &Transform[x] ) ); // Set the function that tests whether it's valid at the moment. pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_TestValid, &Transform[x] )); // Add the option to the menu. @@ -13632,7 +13632,7 @@ void ItemDescTransformRegionCallback( MOUSE_REGION *pRegion, INT32 reason ) if (!fFoundTransformations) { - POPUP_OPTION * pOption = new POPUP_OPTION( &std::wstring( gzTransformationMessage[ 0 ] ), new popupCallbackFunction( &TransformationMenuPopup_Transform, NULL ) ); + POPUP_OPTION * pOption = new POPUP_OPTION( std::wstring( gzTransformationMessage[ 0 ] ), new popupCallbackFunction( &TransformationMenuPopup_Transform, NULL ) ); pOption->setAvail(new popupCallbackFunction( &TransformationMenuPopup_TestValid, NULL )); gItemDescTransformPopup->addOption( *pOption ); } diff --git a/Tactical/SkillMenu.cpp b/Tactical/SkillMenu.cpp index 9f4f15ac2..e51d07072 100644 --- a/Tactical/SkillMenu.cpp +++ b/Tactical/SkillMenu.cpp @@ -164,11 +164,11 @@ TraitSelection::Setup( UINT32 aVal ) if (traitarray[i] == AUTOBANDAGESKILLS) { - pOption = new POPUP_OPTION(&std::wstring(pStr), new popupCallbackFunction(&Wrapper_Setup_AutobandageSelection, traitarray[i])); + pOption = new POPUP_OPTION(std::wstring(pStr), new popupCallbackFunction(&Wrapper_Setup_AutobandageSelection, traitarray[i])); } else { - pOption = new POPUP_OPTION(&std::wstring(pStr), new popupCallbackFunction(&Wrapper_Setup_SkillSelection, traitarray[i])); + pOption = new POPUP_OPTION(std::wstring(pStr), new popupCallbackFunction(&Wrapper_Setup_SkillSelection, traitarray[i])); } // if we cannot perform this skill, grey it out @@ -183,7 +183,7 @@ TraitSelection::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_TraitSelection, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_TraitSelection, 0 ) ); GetPopup()->addOption( *pOption ); // grab soldier's x,y screen position @@ -243,11 +243,11 @@ SkillSelection::Setup( UINT32 aVal ) swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); if ( uiCounter == SKILLS_RADIO_ARTILLERY) - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ArtillerySector, uiCounter ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ArtillerySector, uiCounter ) ); else if ( uiCounter == SKILLS_RADIO_CALLREINFORCEMENTS) - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ReinforcementSector, uiCounter ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ReinforcementSector, uiCounter ) ); else - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !(pSoldier->CanUseSkill(uiCounter, TRUE)) ) @@ -267,7 +267,7 @@ SkillSelection::Setup( UINT32 aVal ) { swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !( pSoldier->CanUseSkill( uiCounter, TRUE, sTraitsMenuTargetGridNo ) ) ) @@ -287,7 +287,7 @@ SkillSelection::Setup( UINT32 aVal ) { swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !( pSoldier->CanUseSkill( uiCounter, TRUE, sTraitsMenuTargetGridNo ) ) ) @@ -308,9 +308,9 @@ SkillSelection::Setup( UINT32 aVal ) swprintf( pStr, pTraitSkillsMenuStrings[uiCounter] ); if ( uiCounter == SKILLS_DRAG ) - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_DragSelection, uiCounter ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_DragSelection, uiCounter ) ); else - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SkillSelection, uiCounter ) ); // if we cannot perform this skill, grey it out if ( !(pSoldier->CanUseSkill( uiCounter, TRUE, sTraitsMenuTargetGridNo )) ) @@ -334,7 +334,7 @@ SkillSelection::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_SkillSelection, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_SkillSelection, 0 ) ); GetPopup()->addOption( *pOption ); } @@ -446,7 +446,7 @@ ArtillerySector::Setup( UINT32 aVal ) swprintf( pStr, L"%c%d", loopY + 'A' - 1, loopX ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ArtilleryTeam, sectornr ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ArtilleryTeam, sectornr ) ); // grey out if no artillery can be called from this sector if ( !IsValidArtilleryOrderSector( loopX, loopY, pSoldier->bSectorZ, pSoldier->bTeam ) && !IsValidArtilleryOrderSector( loopX, loopY, pSoldier->bSectorZ, MILITIA_TEAM ) ) @@ -459,7 +459,7 @@ ArtillerySector::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ArtillerySector, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ArtillerySector, 0 ) ); GetPopup()->addOption( *pOption ); // certain traits have skills whose effects depend on wether someone is near to us (squadleader, commissar). We therefore display our radius of effect while this display is open @@ -503,7 +503,7 @@ ArtilleryTeam::Setup( UINT32 aVal ) // order artillery from militia swprintf( pStr, pSkillMenuStrings[SKILLMENU_MILITIA] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ArtilleryTeam, MILITIA_TEAM ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ArtilleryTeam, MILITIA_TEAM ) ); // grey out if no ArtilleryTeam can be called from this sector if ( !IsValidArtilleryOrderSector( sSectorX, sSectorY, pSoldier->bSectorZ, MILITIA_TEAM ) ) @@ -516,7 +516,7 @@ ArtilleryTeam::Setup( UINT32 aVal ) // order artillery from our mercs swprintf( pStr, pSkillMenuStrings[SKILLMENU_OTHERSQUADS] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ArtilleryTeam, pSoldier->bTeam ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ArtilleryTeam, pSoldier->bTeam ) ); // grey out if no ArtilleryTeam can be called from this sector if ( !IsValidArtilleryOrderSector( sSectorX, sSectorY, pSoldier->bSectorZ, pSoldier->bTeam ) ) @@ -528,7 +528,7 @@ ArtilleryTeam::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ArtilleryTeam, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ArtilleryTeam, 0 ) ); GetPopup()->addOption( *pOption ); // certain traits have skills whose effects depend on wether someone is near to us (squadleader, commissar). We therefore display our radius of effect while this display is open @@ -604,7 +604,7 @@ ReinforcementSector::Setup( UINT32 aVal ) swprintf( pStr, L"%c%d", loopY + 'A' - 1, loopX ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ReinforcementNumber, sectornr ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Setup_ReinforcementNumber, sectornr ) ); // grey out if no reinforcements can be called from this sector if ( !CanRequestMilitiaReinforcements( pSoldier->sSectorX, pSoldier->sSectorY, loopX, loopY ) ) @@ -617,7 +617,7 @@ ReinforcementSector::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ReinforcementSector, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ReinforcementSector, 0 ) ); GetPopup()->addOption( *pOption ); } @@ -653,7 +653,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 5 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 5 ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 5 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 5 ) ); if ( numberofmilitia < 5 ) { @@ -665,7 +665,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 10 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 10 ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 10 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 10 ) ); if ( numberofmilitia < 10 ) { @@ -677,7 +677,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 15 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 15 ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 15 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 15 ) ); if ( numberofmilitia < 15 ) { @@ -689,7 +689,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 20 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 20 ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 20 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 20 ) ); if ( numberofmilitia < 20 ) { @@ -699,7 +699,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 30 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 30 ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 30 ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 30 ) ); if ( numberofmilitia < 30 ) { @@ -709,7 +709,7 @@ ReinforcementNumber::Setup( UINT32 aVal ) // 40 militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_X_MILITIA], 40 ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 40 ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, 40 ) ); if ( numberofmilitia < 40 ) { @@ -722,12 +722,12 @@ ReinforcementNumber::Setup( UINT32 aVal ) // all militia option swprintf( pStr, pSkillMenuStrings[SKILLMENU_ALL_MILITIA] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, numberofmilitia ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_ReinforcementNumber, numberofmilitia ) ); GetPopup()->addOption( *pOption ); // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ReinforcementNumber, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_ReinforcementNumber, 0 ) ); GetPopup()->addOption( *pOption ); } @@ -794,7 +794,7 @@ SoldierSelection::Setup( UINT32 aVal ) { swprintf( pStr, L"%s", id->GetName() ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SoldierSelection, id ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_SoldierSelection, id ) ); // grey out if no artillery can be called from this sector if ( 0 ) @@ -809,7 +809,7 @@ SoldierSelection::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_SoldierSelection, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_SoldierSelection, 0 ) ); GetPopup()->addOption( *pOption ); } @@ -871,7 +871,7 @@ DragSelection::Setup( UINT32 aVal ) { swprintf( pStr, L"%s", cnt->GetName( ) ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection, cnt ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection, cnt ) ); GetPopup( )->addOption( *pOption ); } @@ -887,7 +887,7 @@ DragSelection::Setup( UINT32 aVal ) swprintf( pStr, pSkillMenuStrings[SKILLMENU_CORPSES], pCorpse->name ); // we have to use an offset of NOBODY in order to differentiate between person and corpse - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection, (*it) + NOBODY ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection, (*it) + NOBODY ) ); GetPopup( )->addOption( *pOption ); } @@ -914,7 +914,7 @@ DragSelection::Setup( UINT32 aVal ) swprintf(pStr, L"%s (%s)", buf, FaceDirs[gOneCDirection[ubDirection]]); // we have to use an offset of NOBODY in order to differentiate between person and corpse - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection_GridNo, sTempGridNo ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_DragSelection_GridNo, sTempGridNo ) ); GetPopup()->addOption( *pOption ); } @@ -923,7 +923,7 @@ DragSelection::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_DragSelection, 0 ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_DragSelection, 0 ) ); GetPopup( )->addOption( *pOption ); } @@ -1052,7 +1052,7 @@ EquipmentSelection::Setup(UINT32 aVal) int nChars = MultiByteToWideChar( CP_ACP, 0, coca, -1, NULL, 0 ); MultiByteToWideChar( CP_UTF8, 0, coca, -1, tmpchar, nChars ); - pOption = new POPUP_OPTION( &std::wstring( tmpchar ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, i ) ); + pOption = new POPUP_OPTION( std::wstring( tmpchar ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, i ) ); pOption->color_foreground = FONT_GREEN; @@ -1063,13 +1063,13 @@ EquipmentSelection::Setup(UINT32 aVal) if ( gEquipmentSelectionMaxEntriesShown < gTemplateVector.size( ) ) { swprintf( pStr, pSkillMenuStrings[SKILLMENU_MORE] ); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, 99999 ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, 99999 ) ); GetPopup( )->addOption( *pOption ); } // cancel option swprintf(pStr, pSkillMenuStrings[SKILLMENU_CANCEL]); - pOption = new POPUP_OPTION( &std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, 99998 ) ); + pOption = new POPUP_OPTION( std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_EquipmentSelection, 99998 ) ); GetPopup()->addOption(*pOption); SetPos(usTraitMenuPosX, usTraitMenuPosY); diff --git a/Tactical/VehicleMenu.cpp b/Tactical/VehicleMenu.cpp index 9fd2297fe..d798bc9d8 100644 --- a/Tactical/VehicleMenu.cpp +++ b/Tactical/VehicleMenu.cpp @@ -81,7 +81,7 @@ VehicleSelection::Setup( UINT32 aVal ) { swprintf( pStr, gNewVehicle[ pVehicleList[ bVehicleID ].ubVehicleType ].VehicleSeats[i].zSeatName ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_VehicleSelection, i )); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Function_VehicleSelection, i )); // if seat is already taken, grey it out if ( pVehicleList[ bVehicleID ].pPassengers[ i ] != NULL ) @@ -125,7 +125,7 @@ VehicleSelection::Setup( UINT32 aVal ) // cancel option swprintf( pStr, pSkillMenuStrings[SKILLMENU_CANCEL] ); - pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_VehicleSelection, 0 ) ); + pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction( &Wrapper_Cancel_VehicleSelection, 0 ) ); GetPopup()->addOption( *pOption ); // grab soldier's x,y screen position diff --git a/Utils/popup_class.cpp b/Utils/popup_class.cpp index 0f1acdef4..76e6df993 100644 --- a/Utils/popup_class.cpp +++ b/Utils/popup_class.cpp @@ -140,9 +140,9 @@ POPUP_OPTION::~POPUP_OPTION(void) } -POPUP_OPTION::POPUP_OPTION(std::wstring *newName, popupCallback * newFunction) +POPUP_OPTION::POPUP_OPTION(const std::wstring& newName, popupCallback * newFunction) { - this->name = *newName; + this->name = newName; this->action = newFunction; this->avail = 0; @@ -161,9 +161,9 @@ POPUP_OPTION::POPUP_OPTION(std::wstring *newName, popupCallback * newFunction) this->color_shade = FONT_GRAY7 ; } -BOOLEAN POPUP_OPTION::setName( std::wstring * newName ) +BOOLEAN POPUP_OPTION::setName( const std::wstring& newName ) { - this->name = *newName; + this->name = newName; return TRUE; } @@ -236,19 +236,19 @@ BOOLEAN POPUP_OPTION::forceRun() ////////////////////////////////////////////////////////////////// // constructor -POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(void) : POPUP_OPTION(new std::wstring(L"Unnamed subPopup"),NULL) //TODO: possible memmory leak! +POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(void) : POPUP_OPTION(L"Unnamed subPopup", NULL) { this->parent = NULL; this->initSubPopup(); } -POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(std::wstring* name) : POPUP_OPTION(name, NULL) +POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(const std::wstring& name) : POPUP_OPTION(name, NULL) { this->parent = NULL; this->initSubPopup(); } -POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(std::wstring* newName, const POPUP * parent) : POPUP_OPTION(newName, NULL) +POPUP_SUB_POPUP_OPTION::POPUP_SUB_POPUP_OPTION(const std::wstring& newName, const POPUP * parent) : POPUP_OPTION(newName, NULL) { this->parent = parent; this->initSubPopup(); @@ -562,7 +562,7 @@ void POPUP::setInitialValues(void) // setup functions -POPUP_OPTION * POPUP::addOption(std::wstring * name, popupCallback* action) +POPUP_OPTION * POPUP::addOption(const std::wstring& name, popupCallback* action) { if (this->optionCount < POPUP_MAX_OPTIONS) { @@ -605,7 +605,7 @@ POPUP_OPTION * POPUP::getOption(UINT16 n) return NULL; } -POPUP * POPUP::addSubMenuOption(std::wstring * name) +POPUP * POPUP::addSubMenuOption(const std::wstring& name) { if (this->subPopupOptionCount < POPUP_MAX_SUB_POPUPS) { diff --git a/Utils/popup_class.h b/Utils/popup_class.h index 84a83f6aa..9d26ed238 100644 --- a/Utils/popup_class.h +++ b/Utils/popup_class.h @@ -67,10 +67,10 @@ { public: POPUP_OPTION::POPUP_OPTION(void); // default constructor - POPUP_OPTION(std::wstring* name, popupCallback* newFunction); // constructor + POPUP_OPTION(const std::wstring& name, popupCallback* newFunction); // constructor ~POPUP_OPTION(); // destructor // setup - BOOLEAN setName(std::wstring * name); + BOOLEAN setName(const std::wstring& name); BOOLEAN setAction(popupCallback*fun); BOOLEAN setAvail(popupCallback *fun); BOOLEAN setHover(popupCallback *fun); @@ -105,8 +105,8 @@ public: // constructor/destructor POPUP_SUB_POPUP_OPTION(void); - POPUP_SUB_POPUP_OPTION(std::wstring* name); - POPUP_SUB_POPUP_OPTION(std::wstring* newName, const POPUP * parent); + POPUP_SUB_POPUP_OPTION(const std::wstring& name); + POPUP_SUB_POPUP_OPTION(const std::wstring& newName, const POPUP * parent); ~POPUP_SUB_POPUP_OPTION(); void showPopup(); @@ -139,7 +139,7 @@ POPUP(CHAR* name); // constructor ~POPUP(void); // destructor // setup - POPUP_OPTION * addOption(std::wstring * name, popupCallback * action); + POPUP_OPTION * addOption(const std::wstring& name, popupCallback * action); /*INT16 findFreeOptionIndex();*/ BOOLEAN addOption(POPUP_OPTION &option); POPUP_OPTION * getOption(UINT16 n); @@ -147,7 +147,7 @@ BOOLEAN delOption(CHAR* name); // Another index to through and clean, aargh BOOLEAN delOption(UINT8 optIndex); - POPUP* addSubMenuOption(std::wstring * name); + POPUP* addSubMenuOption(const std::wstring& name); BOOL addSubMenuOption(POPUP_SUB_POPUP_OPTION* sub); /*INT16 findFreeSubMenuOptionIndex();*/ POPUP_SUB_POPUP_OPTION * getSubPopupOption(UINT8 n); diff --git a/Utils/popup_definition.cpp b/Utils/popup_definition.cpp index 261db649e..294aff15e 100644 --- a/Utils/popup_definition.cpp +++ b/Utils/popup_definition.cpp @@ -108,7 +108,7 @@ POPUP_OPTION * opt = new POPUP_OPTION(); - opt->setName( this->name ); + opt->setName( *this->name ); if ( !setPopupDefCallback(opt, this->callbackId) || !setPopupDefAvail(opt, this->availId) ) { @@ -132,7 +132,7 @@ */ BOOL popupDefSubPopupOption::addToBox(POPUP * popup){ - POPUP_SUB_POPUP_OPTION * sub = new POPUP_SUB_POPUP_OPTION( this->name ); + POPUP_SUB_POPUP_OPTION * sub = new POPUP_SUB_POPUP_OPTION( *this->name ); if( !this->content->applyToBox( sub->subPopup ) ){ delete sub; @@ -169,7 +169,7 @@ switch(generatorId){ case popupGenerators::dummy: - popup->addOption(new std::wstring( L"Dummy generator" ),NULL); + popup->addOption(L"Dummy generator", NULL); break; case popupGenerators::addArmor: