Help with game start year

Started by Legionnairegames, June 23, 2019, 01:46:51 AM

Previous topic - Next topic

Legionnairegames

I would like to change the starting year to something before the default for a scenario. I know it doesn't effect gameplay at all, it would just be nice to see the desired year in the game. I have taken peak through the XML files, some configuration files, and have searched the internet with no luck. I have even tried one suggestion that was given to me, which was to edit the save file, again no luck. If anyone can help me or even tell me whether if it is even possible, would be greatly appreciated.

K

The start year is hardcoded in the GenDate class, but it can be changed with a harmony patch that changes the Year method. I wrote this little patch that accomplishes it:


    [HarmonyPatch(typeof(GenDate), "Year")]
    static class GenDatePatch {

        static void Postfix(long absTicks, float longitude, ref int __result) {
            var longAdj = GenDate.TimeZoneAt(longitude) * 2500L;
            __result = 2070 + (int)((absTicks + longAdj) / 3600000f);
        }
    }


This changes the start year to 2070. It's pretty cumbersome, but it seems like this is the only way to change it.

Legionnairegames

Thank you so much! You are a life saver! I'll give it go.

Legionnairegames

It worked perfectly. Thank you so much. I am very new to C# coding and it took me a while to figure it out. But once I figured it out, it was super easy.

LWM

Quote from: Legionnairegames on June 26, 2019, 10:39:11 AM
It worked perfectly. Thank you so much. I am very new to C# coding and it took me a while to figure it out. But once I figured it out, it was super easy.

Welcome to the Dark Side.  We have cookies!