Twilight Struggle

Twilight Struggle

View Stats:
Rzeznik Nov 22, 2018 @ 4:42am
60 min timer for the games
Hi there

Would it be possible to add 60min timer for games?
45 is really quick and does not give you time to think and 90 feels a bit slow.
That should be an easy fix right?
< >
Showing 1-15 of 18 comments
Benkyo Nov 22, 2018 @ 2:15pm 
There was a 60 min timer in earlier builds, then they removed it. Apparently too many time options is a bad thing?
Thronx Feb 2, 2019 @ 7:18am 
Hi community, hi developers of Twillight Strugglem

there are a lot of players how like to play fast, me among them.
But I am really annoyed because I lost third game now because time ran out, I was leading in all of them.
Please, please improve the time feature, it needs to be fixed.

Three suggestions:

1. The easiest: Add 60 minutes option. 90 is too much and 45 is really tight.
2. The best: Make it maybe 30 seconds per turn and everything above is taken from your maybe 15 minutes extra time. Why is this the best? Two times I was in turn 8 now, when I had around 6-7 minutes left. This seems to be not enough, since each time takes away some seconds, no matter how fast you react because of animations. This can even be abused. When your opponent is running out of time, just make really fast turns, like space racing anyting or just play any events where you dont have to make any choices.
So with my suggestion this wouldnt be a problem anymore. You can take each turn, but only have about 15 minutes pure thinking time.
3. Another way: Some of my games were really close and intense. Both players were interested in the end and not just in winning. So please add the option to give your opponent a determined extra time, if he runs out or time.

Community agrees?
NovHak Mar 4, 2019 @ 9:16am 
For those who fancy some hex editing, maybe you can try the following :

(UNTESTED, but should work)

  1. Make sure you have TS version 1.1.3, otherwise you're likely to screw up your game.

  2. Grab a decent hex editor, such as CFF Explorer, but any other will do.

  3. Find the following file, relative to the game directory : "TwilightStruggle_Data\Managed\Assembly-CSharp.dll"

  4. Backup the file in case things go wrong

  5. Open the file, and reach the file offset 341B68

  6. You should see the following byte sequence : 80 53 3B 00

  7. Replace (for Turing's sake, don't insert, I said replace) with : 10 0E 00 00

  8. Save

What that does :

It replaces the time in seconds associated with the 45 days timer option with the number of seconds in one hour. The option will still show as 45 days in the menus, but in practice it should become one hour. The change should be applied on the game creator side at the very least. People joining the game MAY be fine without doing the change, but will likely see an error about "undetermined time" in the game description.

So, choose 45 days, have someone join and enjoy playing with a 60 minutes limit !

More technically :

The 80 53 3B 00 is the little-endian, 32-bit signed integer representation of the decimal value 3888000, which are the number of seconds in 45 days (try to convert 003B5380 to decimal and you'll see), so you just changed that to 10 0E 00 00 (and 00000E10 is, guess what ? 3600).

Now that you know, feel free to experiment with other values.

In case you want to modify another timer option instead of 45 days, that's possible. I can give you the appropriate offsets if needed, or you can find yourself, considering the four bytes before the given offset, hence starting at 0109B4, correspond to the seconds for the previous timer option, and so on.

EDIT : My bad, I've given a bad offset... I've just corrected my post, sorry about that !

Anyway, if you reach offset 341B68 and don't see the "80 53 3B 00" byte sequence, it means something is wrong, and then you shouldn't go further, just quit the hex editor and don't save.

Don't hesitate to ask me questions. I hope this will be useful to those who want to enjoy a 60 minute time limit without having to wait for the next update...
Last edited by NovHak; Mar 6, 2019 @ 9:01am
Riddley Walker Jan 10, 2022 @ 12:59am 
I'm in Cff explorer, under "hex editor", and I'm doing "go to offset", but there is no offset with the value 341B68. It brings no results.

What am I doing wrong? I've seen people online with 60 minute games, so I guess it works?
Riddley Walker Jan 10, 2022 @ 1:44am 
I found the corresponding value but I don't think it helps much because it still shows 45 days, so no one is going to join.
I did see players with 30 and 60 minute games, I wonder where do you change the value for that?

Thanks
NovHak Jan 10, 2022 @ 1:28pm 
Did you really see 60 minute games online, from your 1.1.3 ? The hack I gave is a quick and dirty one, it doesn't change the "45 days" text on your game options when creating the game, but other people viewing it in the games list won't see it as a 45 days game, they will see it probably either as an "undefined time" game or maybe a 60 minutes game after all, if you saw it like that.

I don't have the Windows 1.1.3 version currently, I only have the Android 1.4.2 version, which btw doesn't have 30 min or 60 min options, or what would be much more simple, an option to customise game duration, which is a shame if you ask me.
Last edited by NovHak; Jan 10, 2022 @ 1:34pm
Riddley Walker Jan 10, 2022 @ 11:41pm 
Yes, I did see "60 minutes", and someone even started a "30 minute" game which was a bit crazy...
Maybe there is a different fix around or someone found the corresponding text for the duration. I asked the 60 min guy in the lobby and he said he used the "steam hack", which I believe is yours, because I haven't found another one, but I don't see how it can change the text. Maybe I'll try to decompile the game code to understand more.
Benkyo Jan 11, 2022 @ 12:04am 
Pretty sure I've seen a more detailed guide to changing timers somewhere else ... maybe a TS Discord server.

Yes, not a guide, but a simple mod hosted on Twilight Struggle discord, by Ziemowit. A timer.txt file you drop into class PlayerTimers.
Last edited by Benkyo; Jan 11, 2022 @ 12:11am
NovHak Jan 11, 2022 @ 10:50am 
Originally posted by Riddley Walker:
Yes, I did see "60 minutes", and someone even started a "30 minute" game which was a bit crazy...
If you saw that from your Windows 1.1.3 game, then it means it's already capable of displaying the correct duration in the lobby. My hack is lazy since it does minimal changes and indeed I didn't change the text in the game creation menu, but the rest should be fine.

You should try with a friend : apply the hack, create the game, choose "45 days", then have your friend check the lobby with his unmodified game. In the worst case, you can just revert to the original Assembly-CSharp.dll, provided you saved it. In case you didn't, have the Steam client recheck your game files, that should restore it too.

Originally posted by Benkyo:
Pretty sure I've seen a more detailed guide to changing timers somewhere else ... maybe a TS Discord server.

Yes, not a guide, but a simple mod hosted on Twilight Struggle discord, by Ziemowit. A timer.txt file you drop into class PlayerTimers.
I didn't find anything like that on discord, however I found this : https://www.reddit.com/r/twilightstruggle/comments/i6o1jo/better_timers_unofficial_implementation/

One can expect it will be a more complete hack than mine. Stricly speaking however, it's less secure since it's a straight replacement of a dll that's been modified by someone else. The only advantage of my hack is that you make the change yourself, and I give an explanation of the values modified, which can be verified by anyone interested in computer science. There could still be some black hat on my part, but that would make the trick more difficult.
Last edited by NovHak; Jan 11, 2022 @ 1:54pm
Benkyo Jan 12, 2022 @ 12:00am 
I appreciate the principle behind your comment, but Ziemowit is a well known TS tournament champion that many people have met, and not some random with a sinister agenda.

I note he commented on the end of that Reddit post, so presumably the improved version he posted on the discord was based on transport_owiec96's work (another name I recognize and have no reason to be suspicious of).

Anyway, not trying to upstage you, just pointing to another option, one that allows 60 min games to be viewed as such in the lobby, and joined by strangers.
Riddley Walker Jan 12, 2022 @ 6:32am 
So as I understand one available solution (transport_owiec96's) is on reddit. However that seems to freeze the game, doesn't work at all, for me at least.

Ziemowit's file I have not managed to find on Discord or on the web.

NovHak's solution works with caveats, still the best I got, and I appreciate your help very much. However since I only play with strangers it's a bit of a problem.
NovHak Jan 12, 2022 @ 8:37am 
Is the game still 1.1.3 on Windows ? Then I should still have the game files somewhere on my old laptop, and I may give it a try... but is it really sure that games created with my hack don't display the duration correctly in the lobby ? Because I've read somewhere that 60 minutes duration is displayed correctly, and the problem only concerns some other durations such as 20 minutes.

Moreover, if the game has been updated in the meantime, my hack will become useless, and applying it would likely make the game crash or freeze. In other words, I need an up to date Assembly-CSharp.dll. I could try the dll from my Android version since it's supposed to be platform-independent, but that doesn't necessarily imply it's the same on both platforms, so I won't take chances.

EDIT : I just noticed transport_owiec96 said in his post "I'd rather not reveal the method publicly, if possible, because some troll might see it and then use it to set up '60 min games that last 1 second' to boost their score using dirty tricks.". This is important since it means that additionally to the effective game duration in seconds, there's a text description of the timer that's added at game creation. I only changed the effective duration, so it confirms my hack creates games with either an "undefined" or incorrect description.

Hence the only thing I need now is an up to date dll.
Last edited by NovHak; Jan 12, 2022 @ 9:07am
Riddley Walker Jan 12, 2022 @ 9:12am 
Latest steam version is 1.4.2. That might explain why the hex address is no longer the same. You should have the updated version in your steam library, it's supposed to update automatically once you run it.
NovHak Jan 12, 2022 @ 1:43pm 
Indeed. Unfortunately however I don't have the game in my Steam library, since I got it by ahem... other means. I could try with the Android dll, the version numbers being identical it's possible that the dlls are the same. This could be confirmed by posting a file checksum of your dll here, e.g. obtained via the Powershell Get-FileHash[docs.microsoft.com] cmdlet.

And btw, this probably explains why transport_owiec96's hack crashed your game, as it most likely is a 1.1.3 dll.
Last edited by NovHak; Jan 12, 2022 @ 1:56pm
Benkyo Jan 12, 2022 @ 3:00pm 
OK, I got permission to share this, so:
"open class PlayerTimers and replace its contents with this file." "This file" meaning the following as a timer.txt file.


using System;

// Token: 0x020000DA RID: 218
public class PlayerTimers
{
// Token: 0x06000535 RID: 1333 RVA: 0x0002C378 File Offset: 0x0002A578
public static string GetTimeStringFromSeconds(int seconds)
{
int num = seconds / 60;
if (num <= 90)
{
return num + " Minutes";
}
int num2 = num / 60;
if (num2 <= 6)
{
return num2 + " Hours";
}
return num2 / 24 + " Days";
}

// Token: 0x06000536 RID: 1334 RVA: 0x0002C3D0 File Offset: 0x0002A5D0
public static int GetClosestValue(int t, int[] value_array)
{
int num = Array.BinarySearch<int>(value_array, t);
if (num < 0)
{
num = ~num;
if (num >= value_array.Length)
{
num = value_array.Length - 1;
}
else if (num > 0)
{
int value = t - value_array[num];
if (Math.Abs(t - value_array[num - 1]) <= Math.Abs(value))
{
num--;
}
}
}
return num;
}

// Token: 0x0400082F RID: 2095
public static readonly int[] s_playerTimerOptions = new int[]
{
1200,
1800,
2700,
3600,
5400,
1814400,
3888000
};

// Token: 0x04000830 RID: 2096
public static readonly string[] s_playerTimerText = new string[]
{
"20 Minutes",
"30 Minutes",
"45 Minutes",
"60 Minutes",
"90 Minutes",
"21 Days",
"45 Days"
};

// Token: 0x04000831 RID: 2097
public static readonly int[] s_DeprecatedPlayerTimerOptions = new int[]
{
1800,
3600,
7200,
14400
};

// Token: 0x04000832 RID: 2098
public static readonly string[] s_DeprecatedPlayerTimerText = new string[]
{
"30 Minutes",
"1 Hour",
"2 Hours",
"4 Hours"
};
}
Last edited by Benkyo; Jan 12, 2022 @ 3:08pm
< >
Showing 1-15 of 18 comments
Per page: 1530 50