diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 1e2b6218..45492f04 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -2829,7 +2829,7 @@ void DrawCharacterInfo(INT16 sCharNumber) } else { - if ( gGameExternalOptions.fUseXMLSquadNames ) + if ( gGameExternalOptions.fUseXMLSquadNames && pSoldier->bAssignment < ON_DUTY ) swprintf( sString, L"%s", SquadNames[ pSoldier->bAssignment ].squadname ); else wcscpy( sString, pAssignmentStrings[ pSoldier->bAssignment ] ); diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index f0a3b7cf..34707281 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -3726,17 +3726,17 @@ void SearchItemRetrieval( WORLDITEM* pWorldItem, ItemSearchStruct* pSi, SOLDIERC if ( pSi->found && !pSi->done ) { UINT8 usRealTake = min(usTake, pWorldItem[ pSi->pos ].object.ubNumberOfObjects); - pWorldItem[ pSi->pos ].object.MoveThisObjectTo(gTempObject, usRealTake ); + pWorldItem[ pSi->pos ].object.MoveThisObjectTo(pp->Inv[ pSi->soldierslot ], usRealTake ); for ( UINT8 i = 0; i < usRealTake; ++i ) - gTempObject[i]->data.sObjectFlag |= TAKEN_BY_MILITIA; - - pp->Inv[ pSi->soldierslot ] = gTempObject; + (pp->Inv[ pSi->soldierslot ])[i]->data.sObjectFlag |= TAKEN_BY_MILITIA; if ( pWorldItem[ pSi->pos ].object.ubNumberOfObjects < 1 ) { RemoveItemFromPool(pWorldItem[ pSi->pos ].sGridNo, (pSi->pos), pWorldItem[ pSi->pos ].ubLevel); - pWorldItem[ pSi->pos ].fExists = FALSE; + + // setting this to false can lead to cases where we 'forget' items without a valid gridno - though I am unsure why. + //pWorldItem[ pSi->pos ].fExists = FALSE; } } @@ -4684,6 +4684,14 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI // Exit: Save changed inventory +#ifdef JA2TESTVERSION + std::vector > overviewvector2; + for( uiCount = 0; uiCount < uiTotalNumberOfRealItems; ++uiCount ) + { + overviewvector2.push_back( std::pair(pWorldItem[ uiCount ].fExists, pWorldItem[ uiCount ].object.usItem) ); + } +#endif + // save the changed inventory // open sector inv if( ( sMapX == gWorldSectorX )&&( gWorldSectorY == sMapY ) && (gbWorldSectorZ == sMapZ ) ) diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 676ca9d8..40e40198 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -6634,10 +6634,10 @@ void DeathNoMessageTimerCallback( void ) } } -BOOLEAN GetPlayerControlledPrisonSectorId(UINT32& auSectorID) +// get a vector of all player-controlled sectors with prison facilities. It is assumed that a sector has max. one of these +BOOLEAN GetPlayerControlledPrisonList( std::vector& arSectorIDVector ) { - auSectorID = 0; - UINT16 highestprisonsize = 0; + arSectorIDVector.clear(); for(INT16 sX = 1; sX < MAP_WORLD_X - 1; ++sX ) { @@ -6658,10 +6658,9 @@ BOOLEAN GetPlayerControlledPrisonSectorId(UINT32& auSectorID) if (gFacilityLocations[SECTOR(sX, sY)][cnt].fFacilityHere) { // we determine wether this is a prison by checking for usPrisonBaseLimit - if ( gFacilityTypes[cnt].AssignmentData[FAC_INTERROGATE_PRISONERS].usPrisonBaseLimit > highestprisonsize ) + if ( gFacilityTypes[cnt].AssignmentData[FAC_INTERROGATE_PRISONERS].usPrisonBaseLimit > 0 ) { - highestprisonsize = gFacilityTypes[cnt].AssignmentData[FAC_INTERROGATE_PRISONERS].usPrisonBaseLimit; - auSectorID = SECTOR(sX, sY); + arSectorIDVector.push_back( SECTOR(sX, sY) ); break; } } @@ -6669,14 +6668,35 @@ BOOLEAN GetPlayerControlledPrisonSectorId(UINT32& auSectorID) } } - return (highestprisonsize > 0); + return ( arSectorIDVector.size() > 0 ); } extern INT32 giReinforcementPool; void PrisonerMessageBoxCallBack( UINT8 ubExitValue ) { - if (ubExitValue == MSG_BOX_RETURN_NO) + UINT32 usSectorID = 0; + + // Get a list of all available prisons, and create a fitting messagebox + std::vector prisonsectorvector; + if ( GetPlayerControlledPrisonList( prisonsectorvector ) ) + { + UINT8 cnt = 1; + std::vector::iterator itend = prisonsectorvector.end(); + for (std::vector::iterator it = prisonsectorvector.begin(); it != itend; ++it) + { + if ( ubExitValue == cnt ) + { + usSectorID = (*it); + break; + } + + ++cnt; + } + } + + // if sector is still not set, then we did not select one - release prisoners + if ( usSectorID == 0 ) { ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_RELEASED] ); } @@ -6691,23 +6711,19 @@ void PrisonerMessageBoxCallBack( UINT8 ubExitValue ) pSectorInfo->uiNumberOfPrisonersOfWar = 0; - if (ubExitValue == MSG_BOX_RETURN_YES) + if ( usSectorID > 0) { - UINT32 uSectorID = 0; - if ( GetPlayerControlledPrisonSectorId(uSectorID) ) + SECTORINFO *pPrisonSectorInfo = &( SectorInfo[ usSectorID ] ); + + if ( pPrisonSectorInfo ) { - SECTORINFO *pPrisonSectorInfo = &( SectorInfo[ uSectorID ] ); + success = TRUE; - if ( pPrisonSectorInfo ) - { - success = TRUE; + pPrisonSectorInfo->uiNumberOfPrisonersOfWar += prisonerstobemoved; - pPrisonSectorInfo->uiNumberOfPrisonersOfWar += prisonerstobemoved; - - CHAR16 wString[ 64 ]; - GetShortSectorString( (INT16)((uSectorID % MAP_WORLD_X) + 1), (INT16)((uSectorID / MAP_WORLD_X) + 2), wString ); - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_SENTTOSECTOR], wString ); - } + CHAR16 wString[ 64 ]; + GetShortSectorString( SECTORX(usSectorID), SECTORY(usSectorID), wString ); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_SENTTOSECTOR], wString ); } } } @@ -6719,23 +6735,19 @@ void PrisonerMessageBoxCallBack( UINT8 ubExitValue ) pSectorInfo->uiNumberOfPrisonersOfWar = 0; - if (ubExitValue == MSG_BOX_RETURN_YES) + if ( usSectorID > 0) { - UINT32 uSectorID = 0; - if ( GetPlayerControlledPrisonSectorId(uSectorID) ) + SECTORINFO *pPrisonSectorInfo = &( SectorInfo[ usSectorID ] ); + + if ( pPrisonSectorInfo ) { - SECTORINFO *pPrisonSectorInfo = &( SectorInfo[ uSectorID ] ); + success = TRUE; - if ( pPrisonSectorInfo ) - { - success = TRUE; + pPrisonSectorInfo->uiNumberOfPrisonersOfWar += prisonerstobemoved; - pPrisonSectorInfo->uiNumberOfPrisonersOfWar += prisonerstobemoved; - - CHAR16 wString[ 64 ]; - GetShortSectorString( (INT16)(uSectorID % MAP_WORLD_X), (INT16)(uSectorID / MAP_WORLD_X), wString ); - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_SENTTOSECTOR], wString ); - } + CHAR16 wString[ 64 ]; + GetShortSectorString( SECTORX(usSectorID), SECTORY(usSectorID), wString ); + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_SENTTOSECTOR], wString ); } } } @@ -6881,10 +6893,33 @@ void RemoveCapturedEnemiesFromSectorInfo( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) if ( ubNumPrisoners ) { - //if ( guiCurrentScreen == GAME_SCREEN ) - UINT32 uSectorID = 0; - if ( GetPlayerControlledPrisonSectorId(uSectorID) ) - DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ PRISONER_DECIDE_STR ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, PrisonerMessageBoxCallBack, NULL ); + // Get a list of all available prisons, and create a fitting messagebox + std::vector prisonsectorvector; + if ( GetPlayerControlledPrisonList( prisonsectorvector ) ) + { + UINT8 cnt = 0; + std::vector::iterator itend = prisonsectorvector.end(); + for (std::vector::iterator it = prisonsectorvector.begin(); it != itend; ++it) + { + UINT32 usSectorID = (*it); + CHAR16 zShortTownIDString[ 50 ]; + + GetShortSectorString( SECTORX(usSectorID), SECTORY(usSectorID), zShortTownIDString ); + + // Set string for generic button + swprintf( gzUserDefinedButton[ cnt++ ], L"%s", zShortTownIDString ); + + if ( cnt >= 7 ) + break; + } + + for ( ; cnt < 8; ++cnt) + { + wcscpy( gzUserDefinedButton[ cnt ], TacticalStr[ PRISONER_LETGO_STR ] ); + } + + DoMessageBox( MSG_BOX_BASIC_MEDIUM_BUTTONS, TacticalStr[ PRISONER_DECIDE_STR ], GAME_SCREEN, MSG_BOX_FLAG_GENERIC_EIGHT_BUTTONS, PrisonerMessageBoxCallBack, NULL ); + } else DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ PRISONER_NO_PRISONS_STR ], GAME_SCREEN, ( UINT8 )MSG_BOX_FLAG_OK, NULL, NULL ); } diff --git a/Utils/Text.h b/Utils/Text.h index 5fb53e5d..4e38ba4d 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -942,6 +942,7 @@ enum WEAPON_CLEANING_STR, PRISONER_NO_PRISONS_STR, PRISONER_DECIDE_STR, + PRISONER_LETGO_STR, PRISONER_OFFER_SURRENDER, PRISONER_DEMAND_SURRENDER_STR, PRISONER_OFFER_SURRENDER_STR, diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 41abbe94..87a19c6f 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -2929,7 +2929,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"你现在没有可用的监狱关押这些俘虏,你不得不放他们走。", //L"You have no prison for these prisoners, you have to let them go", - L"Yes - 将俘虏送入监狱 No - 放俘虏离开这里", //L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"你想要做什么?", L"劝说敌人投降", L"Offer surrender",//TODO.Translate diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 8223c636..1e3c8d1d 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -2926,7 +2926,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender", diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 47e37822..afcefca9 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -2928,7 +2928,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?", + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender", diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index 7be25cf5..83658ba6 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -2933,7 +2933,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender", diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index 30f1b9e6..d82e2df4 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -2931,12 +2931,13 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"Sie haben kein Gefängnis für die Gefangenen und müssen diese nun laufen lassen", - L"Ja - Gefangene ins Gefängnis bringen Nein - Laßt sie gehen", + L"Wohin mit den Gefangenen?", + L"Entlassen", L"Was möchten Sie tun?", - L"Aufgabe einfordern", - L"Aufgabe anbieten", + L"Kapitulation fordern", + L"Kapitulation anbieten", L"Sprechen", - L"Militia inspection",//TODO.Translate + L"Miliz inspizieren", L"unused", }; diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index 71fc4a10..2813793f 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -2921,7 +2921,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender", diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index fa378692..8cae0aac 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -2936,7 +2936,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender", diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index 8e9a436e..256f7607 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -2928,7 +2928,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"У вас нет тюрьмы для содержания заключённых, придётся отпустить их", - L"Да - Отправить заключенных в тюрьму Нет - Отпустит", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"Что вы хотите сделать?", L"Требовать сдаться", L"Предлоить сдаться", diff --git a/Utils/_TaiwaneseText.cpp b/Utils/_TaiwaneseText.cpp index 3935e048..25ed24dc 100644 --- a/Utils/_TaiwaneseText.cpp +++ b/Utils/_TaiwaneseText.cpp @@ -2930,7 +2930,8 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = // added by Flugente: decide what to do with prisoners L"You have no prison for these prisoners, you have to let them go", - L"Yes - Send prisoners to jail No - Let them go", + L"Where do you want to send the prisoners?",//TODO.Translate + L"Let them go", L"What do you want to do?", L"Demand surrender", L"Offer surrender",