New feature: localized weather adds more weather types, different weather can happen in different sectors at the same time.

For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=23094&#msg_345949

Requires GameDir >= r2325

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8253 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-06-18 20:57:03 +00:00
parent facadda6e8
commit 503523a9fa
40 changed files with 1059 additions and 522 deletions
+7 -1
View File
@@ -528,10 +528,16 @@ typedef struct SECTORINFO
FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector
FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded
// Flugente: enemy jeeps
UINT8 ubNumJeeps;
UINT8 ubJeepsInBattle;
INT8 bPadding[ 22 ];
INT8 bPadding1[2];
// Flugente: localized weather
UINT32 usWeather;
INT8 bPadding[ 16 ];
}SECTORINFO;
+21 -16
View File
@@ -341,24 +341,8 @@ BOOLEAN ExecuteStrategicEvent( STRATEGICEVENT *pEvent )
ProcessTacticalSchedule( (UINT8)pEvent->uiParam );
break;
case EVENT_BEGINRAINSTORM:
//EnvBeginRainStorm( (UINT8)pEvent->uiParam );
break;
case EVENT_ENDRAINSTORM:
//EnvEndRainStorm( );
break;
case EVENT_RAINSTORM:
// ATE: Disabled
//rain
if( pEvent->ubEventType == ENDRANGED_EVENT )
{
EnvEndRainStorm( );
}
else
{
EnvBeginRainStorm( (UINT8)pEvent->uiParam );
}
//end rain
break;
case EVENT_MAKE_CIV_GROUP_HOSTILE_ON_NEXT_SECTOR_ENTRANCE:
@@ -634,6 +618,27 @@ BOOLEAN ExecuteStrategicEvent( STRATEGICEVENT *pEvent )
AddEmail( MILITIAROSTER_INTRO, MILITIAROSTER_INTRO_LENGTH, MAIL_ENRICO, GetWorldTotalMin( ), -1, -1, TYPE_EMAIL_EMAIL_EDT );
break;
#endif
// Flugente: localized weather
case EVENT_WEATHER_NORMAL:
ChangeWeather( (UINT8)pEvent->uiParam, WEATHER_FORECAST_NORMAL );
break;
case EVENT_WEATHER_SHOWERS:
ChangeWeather( (UINT8)pEvent->uiParam, WEATHER_FORECAST_RAIN );
break;
case EVENT_WEATHER_THUNDERSHOWERS:
ChangeWeather( (UINT8)pEvent->uiParam, WEATHER_FORECAST_THUNDERSHOWERS );
break;
case EVENT_WEATHER_SANDSTORM:
ChangeWeather( (UINT8)pEvent->uiParam, WEATHER_FORECAST_SANDSTORM );
break;
case EVENT_WEATHER_SNOW:
ChangeWeather( (UINT8)pEvent->uiParam, WEATHER_FORECAST_SNOW );
break;
}
gfPreventDeletionOfAnyEvent = fOrigPreventFlag;
return TRUE;
+6
View File
@@ -133,6 +133,12 @@ enum
EVENT_SAMSITE_REPAIRED, // Flugente: have a SAM site be fully repaired
EVENT_MILITIAROSTER_EMAIL, // Flugente: we get an email giving us the bookmark to the militia roster webpage
EVENT_WEATHER_NORMAL, // Flugente: localized weather
EVENT_WEATHER_SHOWERS,
EVENT_WEATHER_THUNDERSHOWERS,
EVENT_WEATHER_SANDSTORM,
EVENT_WEATHER_SNOW,
NUMBER_OF_EVENT_TYPES_PLUS_ONE,
NUMBER_OF_EVENT_TYPES = NUMBER_OF_EVENT_TYPES_PLUS_ONE - 1
+5
View File
@@ -125,6 +125,11 @@ CHAR16 gEventName[NUMBER_OF_EVENT_TYPES_PLUS_ONE][40]={
L"EnemyHeliRefuel",
L"SAMsiteRepaired",
L"MilitiaWebsiteEmail",
L"Weather Normal",
L"Weather Rain",
L"Weather Thunderstorm",
L"Weather Sandstorm",
L"Weather Snow",
};
#endif
-29
View File
@@ -835,9 +835,6 @@ static int l_CreateItemInv (lua_State *L);
static int l_MercSalary(lua_State *L);
static int l_PlayerTeamFull (lua_State *L);
static int l_EnvBeginRainStorm (lua_State *L);
static int l_EnvEndRainStorm (lua_State *L);
static int l_ProfilesStrategicInsertionData (lua_State *L);
static int l_ResetBoxers( lua_State *L );
@@ -1701,9 +1698,6 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
lua_register(L,"StartDialogueMessageBox", l_StartDialogueMessageBox);
lua_register(L,"EnvBeginRainStorm", l_EnvBeginRainStorm);
lua_register(L,"EnvEndRainStorm", l_EnvEndRainStorm);
lua_register( L, "AddVolunteers", l_AddVolunteers );
lua_register(L, "CreateArmedCivilain", l_CreateArmedCivilain );
@@ -4201,29 +4195,6 @@ static int l_ProfilesStrategicInsertionData (lua_State *L)
return 0;
}
static int l_EnvBeginRainStorm (lua_State *L)
{
UINT8 n = lua_gettop(L);
int i;
UINT8 ubIntensity = 1;
for (i= 1; i<=n; i++ )
{
if (i == 1 ) ubIntensity = lua_tointeger(L,i);
}
EnvBeginRainStorm( ubIntensity );
return 0;
}
static int l_EnvEndRainStorm (lua_State *L)
{
EnvEndRainStorm();
return 0;
}
static int l_SetGroupNextSectorValue(lua_State *L)
{
UINT8 n = lua_gettop(L);
+153
View File
@@ -58,6 +58,8 @@ UINT16 MAP_BORDER_MOBILE_BTN_X;
UINT16 MAP_BORDER_MOBILE_BTN_Y;
UINT16 MAP_BORDER_DISEASE_BTN_X; // Flugente: disease
UINT16 MAP_BORDER_DISEASE_BTN_Y;
UINT16 MAP_BORDER_WEATHER_BTN_X; // Flugente: weather
UINT16 MAP_BORDER_WEATHER_BTN_Y;
UINT16 MAP_LEVEL_MARKER_X;
UINT16 MAP_LEVEL_MARKER_Y;
@@ -132,6 +134,9 @@ void BtnMobileCallback(GUI_BUTTON *btn,INT32 reason);
// Flugente: disease
void BtnDiseaseCallback(GUI_BUTTON *btn,INT32 reason);
// Flugente: weather
void BtnWeatherCallback( GUI_BUTTON *btn, INT32 reason );
void LevelMarkerBtnCallback(MOUSE_REGION * pRegion, INT32 iReason );
void CommonBtnCallbackBtnDownChecks( void );
@@ -344,6 +349,28 @@ BOOLEAN CreateButtonsForMapBorder( void )
SetButtonCursor( giMapBorderButtons[MAP_BORDER_DISEASE_BTN], MSYS_NO_CURSOR );
}
// Flugente: weather
if ( gGameExternalOptions.gfAllowRain || gGameExternalOptions.gfAllowSandStorms || gGameExternalOptions.gfAllowSnow )
{
giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] = LoadButtonImage( "INTERFACE\\map_border_buttons.sti", -1, 37, -1, 38, -1 );
// if the button image cannot be created, this is likely to a custom sti replacement that isn't up to date to this feature - just use some other images then
if ( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] < 0 )
giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] = LoadButtonImage( "INTERFACE\\map_border_buttons.sti", -1, 2, -1, 11, -1 );
INT16 x = MAP_BORDER_WEATHER_BTN_X;
if ( giMapBorderButtonsImage[MAP_BORDER_DISEASE_BTN] < 0 )
x = MAP_BORDER_DISEASE_BTN_X;
giMapBorderButtons[MAP_BORDER_WEATHER_BTN] = QuickCreateButton( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN], x, MAP_BORDER_WEATHER_BTN_Y,
BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGH,
(GUI_CALLBACK)MSYS_NO_CALLBACK, (GUI_CALLBACK)BtnWeatherCallback );
SetButtonFastHelpText( giMapBorderButtons[MAP_BORDER_WEATHER_BTN], pMapScreenBorderButtonHelpText[MAP_BORDER_WEATHER_BTN] );
SetButtonCursor( giMapBorderButtons[MAP_BORDER_WEATHER_BTN], MSYS_NO_CURSOR );
}
#ifdef JA2UB
//EnableButton
@@ -411,6 +438,7 @@ BOOLEAN CreateButtonsForMapBorder( void )
DisableButton( giMapBorderButtons[ MAP_BORDER_ITEM_BTN ]);
DisableButton( giMapBorderButtons[ MAP_BORDER_MOBILE_BTN ]);
DisableButton( giMapBorderButtons[ MAP_BORDER_DISEASE_BTN ]);
DisableButton( giMapBorderButtons[ MAP_BORDER_WEATHER_BTN ]);
fShowTownFlag = FALSE;
#endif
@@ -439,6 +467,9 @@ void DeleteMapBorderButtons( void )
if ( giMapBorderButtons[MAP_BORDER_DISEASE_BTN] != -1 )
RemoveButton( giMapBorderButtons[MAP_BORDER_DISEASE_BTN] );
if ( giMapBorderButtons[MAP_BORDER_WEATHER_BTN] != -1 )
RemoveButton( giMapBorderButtons[MAP_BORDER_WEATHER_BTN] );
// images
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_TOWN_BTN ] );
@@ -454,6 +485,9 @@ void DeleteMapBorderButtons( void )
if ( giMapBorderButtonsImage[MAP_BORDER_DISEASE_BTN] != -1 )
UnloadButtonImage( giMapBorderButtonsImage[MAP_BORDER_DISEASE_BTN] );
if ( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] != -1 )
UnloadButtonImage( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] );
// HEADROCK HAM 4: Increased number of buttons by one.
for ( ubCnt = 0; ubCnt < NUM_MAP_BORDER_BTNS; ++ubCnt )
@@ -565,6 +599,21 @@ void BtnDiseaseCallback( GUI_BUTTON *btn, INT32 reason )
}
}
// Flugente: weather
void BtnWeatherCallback( GUI_BUTTON *btn, INT32 reason )
{
if ( reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
{
CommonBtnCallbackBtnDownChecks( );
ToggleWeatherFilter( );
}
else if ( reason & MSYS_CALLBACK_REASON_RBUTTON_DWN )
{
CommonBtnCallbackBtnDownChecks( );
}
}
// HEADROCK HAM 4: Callback for Mobile Restrictions Button
void BtnMobileCallback(GUI_BUTTON *btn,INT32 reason)
{
@@ -797,6 +846,27 @@ void ToggleDiseaseFilter( void )
}
}
// Flugente: weather
void ToggleWeatherFilter( void )
{
if ( gusMapDisplayColourMode == MAP_DISPLAY_WEATHER )
{
gusMapDisplayColourMode = MAP_DISPLAY_NORMAL;
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
// dirty regions
fMapPanelDirty = TRUE;
fTeamPanelDirty = TRUE;
fCharacterInfoPanelDirty = TRUE;
}
else
{
// turn ON
TurnOnWeatherFilterMode( );
}
}
// HEADROCK HAM 4: Toggle Mobile Restrictions Button
void ToggleMobileFilter( void )
{
@@ -943,6 +1013,7 @@ void TurnOnAirSpaceMode( void )
MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
// Turn off towns & mines (mostly because town/mine names overlap SAM site names)
if( fShowTownFlag == TRUE )
@@ -1069,6 +1140,7 @@ void TurnOnDiseaseFilterMode( void )
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOn( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
if( fShowItemsFlag == TRUE )
{
@@ -1124,6 +1196,74 @@ void TurnOnDiseaseFilterMode( void )
}
}
void TurnOnWeatherFilterMode()
{
// if mode already on, leave, else set and redraw
if ( gusMapDisplayColourMode != MAP_DISPLAY_WEATHER )
{
gusMapDisplayColourMode = MAP_DISPLAY_WEATHER;
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOn( MAP_BORDER_WEATHER_BTN );
if ( fShowItemsFlag == TRUE )
{
fShowItemsFlag = FALSE;
MapBorderButtonOff( MAP_BORDER_ITEM_BTN );
}
// Turn off towns, mines, teams, militia & airspace if any are on
if ( fShowTownFlag == TRUE )
{
fShowTownFlag = FALSE;
MapBorderButtonOff( MAP_BORDER_TOWN_BTN );
}
if ( fShowMineFlag == TRUE )
{
fShowMineFlag = FALSE;
MapBorderButtonOff( MAP_BORDER_MINE_BTN );
}
if ( fShowTeamFlag == TRUE )
{
fShowTeamFlag = FALSE;
MapBorderButtonOff( MAP_BORDER_TEAMS_BTN );
}
if ( fShowMilitia == TRUE )
{
fShowMilitia = FALSE;
MapBorderButtonOff( MAP_BORDER_MILITIA_BTN );
}
if ( (bSelectedDestChar != -1) || fPlotForHelicopter || fPlotForMilitia )
{
AbortMovementPlottingMode( );
}
else if ( gfInChangeArrivalSectorMode )
{
CancelChangeArrivalSectorMode( );
}
// Flugente: basically only show this message the first time every session
static BOOLEAN sWeatherviewed = FALSE;
if ( !sWeatherviewed )
{
MapScreenMessage( FONT_MCOLOR_LTYELLOW, MSG_MAP_UI_POSITION_MIDDLE, zMarksMapScreenText[28] );
sWeatherviewed = TRUE;
}
// dirty regions
fMapPanelDirty = TRUE;
fTeamPanelDirty = TRUE;
fCharacterInfoPanelDirty = TRUE;
}
}
// HEADROCK HAM 4: Activate "View Mobile Restrictions" mode.
void TurnOnMobileFilterMode( void )
{
@@ -1136,6 +1276,7 @@ void TurnOnMobileFilterMode( void )
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOn( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
// Also turn on Militia mode
fShowMilitia = FALSE; // Fool the function so that it always turns militia ON.
@@ -1252,18 +1393,28 @@ void InitializeMapBorderButtonStates( void )
MapBorderButtonOn( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
break;
case MAP_DISPLAY_MOBILEMILITIARESTRICTIONS:
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOn( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
break;
case MAP_DISPLAY_DISEASE:
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOn( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOff( MAP_BORDER_WEATHER_BTN );
break;
case MAP_DISPLAY_WEATHER:
MapBorderButtonOff( MAP_BORDER_AIRSPACE_BTN );
MapBorderButtonOff( MAP_BORDER_MOBILE_BTN );
MapBorderButtonOff( MAP_BORDER_DISEASE_BTN );
MapBorderButtonOn( MAP_BORDER_WEATHER_BTN );
break;
}
}
@@ -1415,6 +1566,8 @@ void InitMapBorderButtonCoordinates()
MAP_BORDER_MOBILE_BTN_Y = 0;
MAP_BORDER_DISEASE_BTN_X = xResOffset + MAP_BORDER_X + ((SCREEN_WIDTH - MAP_BORDER_X - 2 * xResOffset) / 2) + 190;
MAP_BORDER_DISEASE_BTN_Y = (SCREEN_HEIGHT - yResOffset - buttonOffset);
MAP_BORDER_WEATHER_BTN_X = xResOffset + MAP_BORDER_X + ((SCREEN_WIDTH - MAP_BORDER_X - 2 * xResOffset) / 2) + 233;
MAP_BORDER_WEATHER_BTN_Y = (SCREEN_HEIGHT - yResOffset - buttonOffset);
MAP_LEVEL_MARKER_X = xResOffset + MAP_BORDER_X + ((SCREEN_WIDTH - MAP_BORDER_X - 2 * xResOffset) / 2) + 114;
MAP_LEVEL_MARKER_Y = (SCREEN_HEIGHT - yResOffset - buttonOffset);
+8
View File
@@ -32,6 +32,7 @@ enum{
MAP_BORDER_MILITIA_BTN,
MAP_BORDER_MOBILE_BTN, // HEADROCK HAM 4: Mobile Militia Restrictions button
MAP_BORDER_DISEASE_BTN, // Flugente: toggle disease views
MAP_BORDER_WEATHER_BTN, // Flugente: toggle weather display
NUM_MAP_BORDER_BTNS, // end enumeration marker
};
@@ -57,6 +58,7 @@ enum
MAP_DISPLAY_AIRSPACE,
MAP_DISPLAY_MOBILEMILITIARESTRICTIONS,
MAP_DISPLAY_DISEASE,
MAP_DISPLAY_WEATHER,
};
extern UINT8 gusMapDisplayColourMode;
@@ -83,6 +85,9 @@ void ToggleMobileFilter( void );
// Flugente: disease
void ToggleDiseaseFilter( );
// Flugente: weather
void ToggleWeatherFilter( );
void TurnOnShowTeamsMode( void );
void TurnOnAirSpaceMode( void );
void TurnOnItemFilterMode( void );
@@ -92,6 +97,9 @@ void TurnOnMobileFilterMode( void );
// Flugente: disease
void TurnOnDiseaseFilterMode();
// Flugente: weather
void TurnOnWeatherFilterMode( );
// create/destroy buttons for map border region
void DeleteMapBorderButtons( void );
BOOLEAN CreateButtonsForMapBorder( void );
+5 -1
View File
@@ -808,7 +808,11 @@ UINT32 DrawMap( void )
break;
case MAP_DISPLAY_DISEASE:
ShadeMapElem( cnt, cnt2, GetMapColour( cnt, cnt2, TRUE ) );
ShadeMapElem( cnt, cnt2, GetMapColour( cnt, cnt2, 0 ) );
break;
case MAP_DISPLAY_WEATHER:
ShadeMapElem( cnt, cnt2, GetMapColour( cnt, cnt2, 1 ) );
break;
case MAP_DISPLAY_NORMAL:
+38 -2
View File
@@ -93,7 +93,10 @@ SectorNameStartElementHandle(void *userData, const XML_Char *name, const char **
strcmp(name, "usCurfewValue") == 0 ||
strcmp(name, "sRadioScanModifier") == 0 ||
strcmp(name, "usPrisonRoomNumber" ) == 0 ||
strcmp(name, "usCivilianPopulation") == 0 ))
strcmp(name, "usCivilianPopulation" ) == 0 ||
strcmp(name, "rainchance" ) == 0 ||
strcmp(name, "sandstormchance") == 0 ||
strcmp(name, "snowchance" ) == 0 ))
{
pData->curElement = ELEMENT_PROPERTY;
@@ -194,7 +197,22 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name)
SectorExternalData[ubSectorId][1].usCivilianPopulation = pData->sectordata.usCivilianPopulation;
SectorExternalData[ubSectorId][2].usCivilianPopulation = pData->sectordata.usCivilianPopulation;
SectorExternalData[ubSectorId][3].usCivilianPopulation = pData->sectordata.usCivilianPopulation;
SectorExternalData[ubSectorId][0].rainchance = pData->sectordata.rainchance;
SectorExternalData[ubSectorId][1].rainchance = 0;
SectorExternalData[ubSectorId][2].rainchance = 0;
SectorExternalData[ubSectorId][3].rainchance = 0;
SectorExternalData[ubSectorId][0].sandstormchance = pData->sectordata.sandstormchance;
SectorExternalData[ubSectorId][1].sandstormchance = 0;
SectorExternalData[ubSectorId][2].sandstormchance = 0;
SectorExternalData[ubSectorId][3].sandstormchance = 0;
SectorExternalData[ubSectorId][0].snowchance = pData->sectordata.snowchance;
SectorExternalData[ubSectorId][1].snowchance = 0;
SectorExternalData[ubSectorId][2].snowchance = 0;
SectorExternalData[ubSectorId][3].snowchance = 0;
if ( !prisonroomvector.empty( ) )
{
std::vector<UINT16>::iterator itend = prisonroomvector.end( );
@@ -213,6 +231,9 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name)
pData->sectordata.usCurfewValue = 0;
pData->sectordata.sRadioScanModifier = 0;
pData->sectordata.usCivilianPopulation = 0;
pData->sectordata.rainchance = 0;
pData->sectordata.sandstormchance = 0;
pData->sectordata.snowchance = 0;
}
else
{
@@ -307,6 +328,21 @@ SectorNameEndElementHandle(void *userData, const XML_Char *name)
pData->curElement = ELEMENT;
pData->sectordata.usCivilianPopulation = (UINT16)atoi( pData->szCharData );
}
else if ( strcmp( name, "rainchance" ) == 0 )
{
pData->curElement = ELEMENT;
pData->sectordata.rainchance = min( 100, (UINT8)atoi( pData->szCharData ) );
}
else if ( strcmp( name, "sandstormchance" ) == 0 )
{
pData->curElement = ELEMENT;
pData->sectordata.sandstormchance = min( 100, (UINT8)atoi( pData->szCharData ) );
}
else if ( strcmp( name, "snowchance" ) == 0 )
{
pData->curElement = ELEMENT;
pData->sectordata.snowchance = min( 100, (UINT8)atoi( pData->szCharData ) );
}
pData->maxReadDepth--;
}