Usage:
To use it, please simply add one of the following suffixes at the end of your scenario filename:
ToD_Dawn.scn
ToD_Afternoon.scn
ToD_Sunset.scn
ToD_Night.scn
ToD_Cycle2.scn
ToD_Cycle5.scn
ToD_Cycle10.scn
ToD_Cycle15.scn
Example:
Problems:
This method does not work when you click "Test Mission" in the Map Editor. It's because it uses a file named "testMission.scn" and UP1.5 is unable to determine time settings from it. However, it works flawlessly when loading a scenario from the Menu:
Unfortunately, option "Random" is not supported, as it's generated at a totally different layer.
Other details:
This method uses several workarounds in game process (applied by assembly). The filename checking function is called in UP15_GameHelper.dll.
The "ToD_" suffix is case-insensitive, so technically it will also work with "tod_cycle15.scn" or "tod_CYCLE15.scn".
It looks nice when it's at the end of the file name, but it's not required. The scenario file name might as well be: "Death of Hitler ToD_Night 1945.scn".
Source code in UP15_GameHelper.dll:
Code: Select all
extern "C" void UP15_Fixes_Based_on_File_Name(int CallType, char* currentEAX) {
//Setting up
if(CallType == 0){
if (currentEAX != NULL) {
//Reset
Set_Time_of_Day_from_File_Name_Now = false;
Set_Time_of_Day_from_File_Name_Short = -1;
std::string StringFromEax = currentEAX;
if (StringFromEax.length() > 0) {
std::string StringFromEaxLowerCase = BoostStringToLowerCase(StringFromEax);
std::size_t TodDefined1 = StringFromEaxLowerCase.find("tod_");
if (TodDefined1 != std::string::npos) {
std::string TempStringAfterTod = StringFromEaxLowerCase.substr(TodDefined1 + 4);
TodDefined1 = TempStringAfterTod.find(".");
short SelectedTimeOfDayMode = -1;
if (TodDefined1 != std::string::npos) {
TempStringAfterTod = TempStringAfterTod.substr(0, TodDefined1);
}
if (TempStringAfterTod.find("dawn") != std::string::npos) {
SelectedTimeOfDayMode = 0;
}
else if (TempStringAfterTod.find("afternoon") != std::string::npos) {
SelectedTimeOfDayMode = 1;
}
else if (TempStringAfterTod.find("sunset") != std::string::npos) {
SelectedTimeOfDayMode = 2;
}
else if (TempStringAfterTod.find("night") != std::string::npos) {
SelectedTimeOfDayMode = 3;
}
else if (TempStringAfterTod.find("cycle2") != std::string::npos) {
SelectedTimeOfDayMode = 4;
}
else if (TempStringAfterTod.find("cycle5") != std::string::npos) {
SelectedTimeOfDayMode = 5;
}
else if (TempStringAfterTod.find("cycle10") != std::string::npos) {
SelectedTimeOfDayMode = 6;
}
else if (TempStringAfterTod.find("cycle15") != std::string::npos) {
SelectedTimeOfDayMode = 7;
}
if (SelectedTimeOfDayMode > -1) {
Set_Time_of_Day_from_File_Name_Now = true;
Set_Time_of_Day_from_File_Name_Short = SelectedTimeOfDayMode;
//MessageBoxA(NULL, to_string(SelectedTimeOfDayMode).c_str(), "Selected Time of Day in File Name, ID:", MB_OK);
}
}
}
}
}
//This is right after time of day is set
else if (CallType == 1) {
//158002, tmp time of day fix:
if (Set_Time_of_Day_from_File_Name_Now) {
DWORD ReturnValue = -1;
if (Current_Game_EE2_Zero_AOS_One == 1) {
__asm
{
mov EAX, DWORD PTR DS : [0x0DA9A10] // setting EAX to 42 here
CMP EAX, 0
JE BadBadA1
MOV EAX, DWORD PTR DS : [EAX + 28]
MOV ReturnValue, EAX
BadBadA1 :
}
}
else {
__asm
{
mov EAX, DWORD PTR DS : [0x0CF8568] // setting EAX to 42 here
CMP EAX, 0
JE BadBad1
MOV EAX, DWORD PTR DS : [EAX + 28]
MOV ReturnValue, EAX
BadBad1 :
}
}
//MessageBoxA(NULL, to_string(ReturnValue).c_str(), "Current Detected Time of Day:", MB_OK | MB_ICONINFORMATION);
if (ReturnValue >= 0 && ReturnValue <= 7) {
if (Current_Game_EE2_Zero_AOS_One == 1) {
__asm
{
mov EAX, DWORD PTR DS : [0x0DA9A10] // setting EAX to 42 here
CMP EAX, 0
JE BadBadA2
MOV CX, Set_Time_of_Day_from_File_Name_Short
MOV WORD PTR DS : [EAX + 28] , CX
BadBadA2 :
}
}
else {
__asm
{
mov EAX, DWORD PTR DS : [0x0CF8568] // setting EAX to 42 here
CMP EAX, 0
JE BadBad2
MOV CX, Set_Time_of_Day_from_File_Name_Short
MOV WORD PTR DS : [EAX + 28] , CX
BadBad2 :
}
}
}
Set_Time_of_Day_from_File_Name_Now = false;
Set_Time_of_Day_from_File_Name_Short = -1;
}
}
}
Special thanks to player "Sat42" for contribution in making this feature possible in such a short time.