void AddCommonInfoToBox(void) { CHAR16 wString[ 64 ]; UINT32 hStringHandle = 0; BOOLEAN fUnknownSAMSite = FALSE; UINT8 ubMilitiaTotal = 0; UINT8 ubNumEnemies; switch( SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ) { case SEC_D2: //Chitzena SAM if( !fSamSiteFound[ SAM_SITE_ONE ] ) fUnknownSAMSite = TRUE; break; case SEC_D15: //Drassen SAM if( !fSamSiteFound[ SAM_SITE_TWO ] ) fUnknownSAMSite = TRUE; break; case SEC_I8: //Cambria SAM if( !fSamSiteFound[ SAM_SITE_THREE ] ) fUnknownSAMSite = TRUE; break; // SAM Site 4 in Meduna is within town limits, so it's always controllable default: break; } // in sector where militia can be trained, // control of the sector matters, display who controls this sector. Map brightness no longer gives this! if ( MilitiaTrainingAllowedInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, 0 ) && !fUnknownSAMSite ) { // controlled: swprintf( wString, L"%s:", pwMiscSectorStrings[ 4 ] ); AddMonoString( &hStringHandle, wString ); // No/Yes swprintf( wString, L"%s", pwMiscSectorStrings[ ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ].fEnemyControlled ) ? 6 : 5 ] ); AddSecondColumnMonoString( &hStringHandle, wString ); // militia - is there any? swprintf( wString, L"%s:", pwTownInfoStrings[ 11 ] ); AddMonoString( &hStringHandle, wString ); ubMilitiaTotal = CountAllMilitiaInSector(bCurrentTownMineSectorX, bCurrentTownMineSectorY); if (ubMilitiaTotal > 0) { // some militia, show total & their breakdown by level swprintf( wString, L"%d (%d/%d/%d)", ubMilitiaTotal, MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, GREEN_MILITIA), MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, REGULAR_MILITIA), MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, ELITE_MILITIA)); AddSecondColumnMonoString( &hStringHandle, wString ); } else { // no militia: don't bother displaying level breakdown wcscpy( wString, L"0"); AddSecondColumnMonoString( &hStringHandle, wString ); } // percentage of current militia squad training completed swprintf( wString, L"%s:", pwTownInfoStrings[ 10 ] ); AddMonoString( &hStringHandle, wString ); swprintf( wString, L"%d%%%%", SectorInfo[ SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ].ubMilitiaTrainingPercentDone ); AddSecondColumnMonoString( &hStringHandle, wString ); } // enemy forces swprintf( wString, L"%s:", pwMiscSectorStrings[ 0 ] ); AddMonoString( &hStringHandle, wString ); // how many are there, really? ubNumEnemies = NumEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); switch ( WhatPlayerKnowsAboutEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ) { case KNOWS_NOTHING: // show "Unknown" wcscpy(wString, pwMiscSectorStrings[ 3 ] ); break; case KNOWS_THEYRE_THERE: // if there are any there if ( ubNumEnemies > 0 ) { // show "?", but not exactly how many wcscpy(wString, L"?" ); } else { // we know there aren't any (or we'd be seing them on map, too) wcscpy(wString, L"0" ); } break; case KNOWS_HOW_MANY: // show exactly how many swprintf( wString, L"%d", ubNumEnemies ); break; } AddSecondColumnMonoString( &hStringHandle, wString ); }
void AddCommonInfoToBox(void) { CHAR16 wString[ 64 ]; UINT32 hStringHandle = 0; BOOLEAN fKnownSite = FALSE; UINT8 ubMilitiaTotal = 0; UINT8 ubNumEnemies; UINT16 usSectorValue = 0; // get the sector value usSectorValue = SECTOR( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); BOOLEAN fVisited = (SectorInfo[ usSectorValue ].uiFlags & SF_ALREADY_VISITED); UINT8 ubTownId = GetTownIdForSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); // visited sector check if ( fVisited ) fKnownSite = TRUE; // known town check, to exclude non-town sectors else if( gfHiddenTown[ ubTownId ] && ubTownId != BLANK_SECTOR ) fKnownSite = TRUE; // known SAM Site check else { for (UINT16 x=0; x < MAX_NUMBER_OF_SAMS; x++) { if ( pSamList[x] == usSectorValue ) { if ( fSamSiteFound[ x ] ) fKnownSite = TRUE; } } } /*// ABOVE GROUND HARDCODED fKnownSite = TRUE; switch( usSectorValue ) { case SEC_D2: //Chitzena SAM if( !fSamSiteFound[ SAM_SITE_ONE ] ) fKnownSite = FALSE; break; case SEC_D15: //Drassen SAM if( !fSamSiteFound[ SAM_SITE_TWO ] ) fKnownSite = FALSE; break; case SEC_I8: //Cambria SAM if( !fSamSiteFound[ SAM_SITE_THREE ] ) fKnownSite = FALSE; break; // SAM Site 4 in Meduna is within town limits, so it's always controllable default: break; } */ // in sector where militia can be trained, // control of the sector matters, display who controls this sector. Map brightness no longer gives this! if ( MilitiaTrainingAllowedInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY, 0 ) && fKnownSite ) { // controlled: swprintf( wString, L"%s:", pwMiscSectorStrings[ 4 ] ); AddMonoString( &hStringHandle, wString ); // No/Yes swprintf( wString, L"%s", pwMiscSectorStrings[ ( StrategicMap[ CALCULATE_STRATEGIC_INDEX( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ].fEnemyControlled ) ? 6 : 5 ] ); AddSecondColumnMonoString( &hStringHandle, wString ); // militia - is there any? swprintf( wString, L"%s:", pwTownInfoStrings[ 11 ] ); AddMonoString( &hStringHandle, wString ); ubMilitiaTotal = CountAllMilitiaInSector(bCurrentTownMineSectorX, bCurrentTownMineSectorY); if (ubMilitiaTotal > 0) { // some militia, show total & their breakdown by level swprintf( wString, L"%d (%d/%d/%d)", ubMilitiaTotal, MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, GREEN_MILITIA), MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, REGULAR_MILITIA), MilitiaInSectorOfRank(bCurrentTownMineSectorX, bCurrentTownMineSectorY, ELITE_MILITIA)); AddSecondColumnMonoString( &hStringHandle, wString ); } else { // no militia: don't bother displaying level breakdown wcscpy( wString, L"0"); AddSecondColumnMonoString( &hStringHandle, wString ); } // HEADROCK HAM 3.6: Only show these for sectors that have a training facility BOOLEAN fMilitiaTrainingAllowed = FALSE; BOOLEAN fMobileTrainingAllowed = FALSE; // percentage of current militia squad training completed swprintf( wString, L"%s:", pwTownInfoStrings[ 10 ] ); AddMonoString( &hStringHandle, wString ); // Sector contains Militia training facility? for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++) { if (gFacilityLocations[usSectorValue][ubCounter].fFacilityHere) { if (gFacilityTypes[ubCounter].ubMilitiaTrainersAllowed) { fMilitiaTrainingAllowed = TRUE; } } } if (fMilitiaTrainingAllowed) { // Show percent completed swprintf( wString, L"%d%%%%", SectorInfo[ usSectorValue ].ubMilitiaTrainingPercentDone ); AddSecondColumnMonoString( &hStringHandle, wString ); } else { // Show N/A AddSecondColumnMonoString( &hStringHandle, New113HAMMessage[19] ); } // HEADROCK HAM 3.6: percentage of current Mobile Militia squad training completed swprintf( wString, L"%s:", pwTownInfoStrings[ 12 ] ); AddMonoString( &hStringHandle, wString ); // Sector contains Mobile training facility? for (UINT8 ubCounter = 0; ubCounter < MAX_NUM_FACILITY_TYPES; ubCounter++) { if (gFacilityLocations[usSectorValue][ubCounter].fFacilityHere) { if (gFacilityTypes[ubCounter].ubMobileMilitiaTrainersAllowed) { fMobileTrainingAllowed = TRUE; } } } if (fMobileTrainingAllowed) { // Show percentage completed swprintf( wString, L"%d%%%%", SectorInfo[ usSectorValue ].ubMobileMilitiaTrainingPercentDone ); AddSecondColumnMonoString( &hStringHandle, wString ); } else { // Show N/A AddSecondColumnMonoString( &hStringHandle, New113HAMMessage[19] ); } } // enemy forces swprintf( wString, L"%s:", pwMiscSectorStrings[ 0 ] ); AddMonoString( &hStringHandle, wString ); // how many are there, really? ubNumEnemies = NumEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); AssertGE(gGameExternalOptions.ubGameMaximumNumberOfEnemies, NumFreeEnemySlots()); unsigned numEnemiesOnMap = gGameExternalOptions.ubGameMaximumNumberOfEnemies - NumFreeEnemySlots(); switch ( WhatPlayerKnowsAboutEnemiesInSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) ) { case KNOWS_NOTHING: // show "Unknown" wcscpy(wString, pwMiscSectorStrings[ 3 ] ); break; // HEADROCK HAM 5: New Case case KNOWS_THEYRE_THERE: case KNOWS_THEYRE_THERE_AND_WHERE_GOING: // if there are any there if ( ubNumEnemies > 0 ) { // show "?", but not exactly how many wcscpy(wString, L"?" ); } else { // we know there aren't any (or we'd be seing them on map, too) wcscpy(wString, L"0" ); } break; // HEADROCK HAM 5: New case case KNOWS_HOW_MANY: case KNOWS_HOW_MANY_AND_WHERE_GOING: // show exactly how many if (numEnemiesOnMap != ubNumEnemies) swprintf( wString, L"%d (%d)", numEnemiesOnMap, ubNumEnemies ); else swprintf( wString, L"%d", ubNumEnemies ); break; } AddSecondColumnMonoString( &hStringHandle, wString ); }
void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMapY ) { SECTORINFO *pSectorInfo = &( SectorInfo[ SECTOR( sMapX, sMapY ) ] ); UINT8 ubMilitiaTrained = 0; BOOLEAN fFoundOne; INT16 sNeighbourX, sNeighbourY; UINT8 ubTownId; // get town index ubTownId = StrategicMap[ sMapX + sMapY * MAP_WORLD_X ].bNameId; if( ubTownId == BLANK_SECTOR ) { Assert( IsThisSectorASAMSector( sMapX, sMapY, 0 ) ); } // force tactical to update militia status gfStrategicMilitiaChangesMade = TRUE; // ok, so what do we do with all this training? Well, in order of decreasing priority: // 1) If there's room in training sector, create new GREEN militia guys there // 2) If not enough room there, create new GREEN militia guys in friendly sectors of the same town // 3) If not enough room anywhere in town, promote a number of GREENs in this sector into regulars // 4) If not enough GREENS there to promote, promote GREENs in other sectors. // 5) If all friendly sectors of this town are completely filled with REGULAR militia, then training effect is wasted while (ubMilitiaTrained < MILITIA_TRAINING_SQUAD_SIZE) { // is there room for another militia in the training sector itself? if (CountAllMilitiaInSector(sMapX, sMapY) < MAX_ALLOWABLE_MILITIA_PER_SECTOR) { // great! Create a new GREEN militia guy in the training sector StrategicAddMilitiaToSector(sMapX, sMapY, GREEN_MILITIA, 1); } else { fFoundOne = FALSE; if( ubTownId != BLANK_SECTOR ) { InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY); // check other eligible sectors in this town for room for another militia while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) ) { // is there room for another militia in this neighbouring sector ? if (CountAllMilitiaInSector(sNeighbourX, sNeighbourY) < MAX_ALLOWABLE_MILITIA_PER_SECTOR) { // great! Create a new GREEN militia guy in the neighbouring sector StrategicAddMilitiaToSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1); fFoundOne = TRUE; break; } } } // if we still haven't been able to train anyone if (!fFoundOne) { // alrighty, then. We'll have to *promote* guys instead. // are there any GREEN militia men in the training sector itself? if (MilitiaInSectorOfRank(sMapX, sMapY, GREEN_MILITIA) > 0) { // great! Promote a GREEN militia guy in the training sector to a REGULAR StrategicPromoteMilitiaInSector(sMapX, sMapY, GREEN_MILITIA, 1); } else { if( ubTownId != BLANK_SECTOR ) { // dammit! Last chance - try to find other eligible sectors in the same town with a Green guy to be promoted InitFriendlyTownSectorServer(ubTownId, sMapX, sMapY); // check other eligible sectors in this town for room for another militia while( ServeNextFriendlySectorInTown( &sNeighbourX, &sNeighbourY ) ) { // are there any GREEN militia men in the neighbouring sector ? if (MilitiaInSectorOfRank(sNeighbourX, sNeighbourY, GREEN_MILITIA) > 0) { // great! Promote a GREEN militia guy in the neighbouring sector to a REGULAR StrategicPromoteMilitiaInSector(sNeighbourX, sNeighbourY, GREEN_MILITIA, 1); fFoundOne = TRUE; break; } } } // if we still haven't been able to train anyone if (!fFoundOne) { // Well, that's it. All eligible sectors of this town are full of REGULARs or ELITEs. // The training goes to waste in this situation. break; // the main while loop } } } } // next, please! ubMilitiaTrained++; } // if anyone actually got trained if (ubMilitiaTrained > 0) { // update the screen display fMapPanelDirty = TRUE; if( ubTownId != BLANK_SECTOR ) { // loyalty in this town increases a bit because we obviously care about them... IncrementTownLoyalty( ubTownId, LOYALTY_BONUS_FOR_TOWN_TRAINING ); } } // the trainer announces to player that he's finished his assignment. Make his sector flash! AssignmentDone( pTrainer, TRUE, FALSE ); // handle completion of town by training group HandleCompletionOfTownTrainingByGroupWithTrainer( pTrainer ); }