Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cossacks/American Conquest Game Speed Problem (Multiplayer) #116

Closed
helgo1506 opened this issue Aug 22, 2021 · 18 comments
Closed

Cossacks/American Conquest Game Speed Problem (Multiplayer) #116

helgo1506 opened this issue Aug 22, 2021 · 18 comments

Comments

@helgo1506
Copy link

Hi there,

I got a question which directs to Cossacks/American Conquest. This games are somehow detecting the CPU speed in network games and adjust the game speed on the lowest CPU speed in a MP game. With your "maxgameticks" option i cant really adjust that, cause it seems it's using a different API to detect it. Do you think you can find a solution for that?

So far the only thing i know, is to get a CPU Throttle Tool to scale down the CPU and then play the game.
If your interested, can you look into it and see if you can make something with your DLL there?

It's not important, cause the other graphic things are working with your DLL, so it's just a extra fix.

@helgo1506 helgo1506 changed the title Cossacks/American Conquest Game Speed Problem Cossacks/American Conquest Game Speed Problem (Multiplayer) Aug 22, 2021
@FunkyFr3sh
Copy link
Owner

Ah damn, American Conquest was just unlocking the primary surface only once and then kept it unlocked and didn't call any ddraw functions anymore (that's why the log is so tiny with this game)... maxgameticks can't really do anything in this case. Where can I get that "CPU Throttle Tool"?

@helgo1506
Copy link
Author

helgo1506 commented Aug 22, 2021

Not sure, like i said there are some, but i must say i don't like the idea of Capping my CPU for a game :-)
I though that perhaps you can take a look, if you find a workaround for this games.

https://gsc-game.com/index.php?t=downloads&ss=299&s=patch (this is a DDraw.dll, which seems(?) to fix this, but got graphic bugs lol)
https://7thzero.com/blog/cpugrab-net (in case you want to take a look at the source to see how it is done)
https://github.com/ereb-thanatos/cossacks-revamp-2017/tree/1.42 (this is a revamp for Cossacks and it's fixed there. Perhaps you can find a way there, if you look at the source. I must say, im out of this part, cause i dont understand graphic programming)

@helgo1506
Copy link
Author

helgo1506 commented Aug 22, 2021

Hm, it seems that some source of Cossacks got leaked and there "GetTickCount","QueryPerformanceCounter" and "QueryPerformanceFrequency" is called. I more think that they use "QueryPerformanceCounter" and "QueryPerformanceFrequency", cuase this 2, as far as i know, are depending on the CPU Speed. Can you hook them and adjust them? If you make them low, it should be visible in American Conquest, cause they both use the same engine.

@helgo1506
Copy link
Author

helgo1506 commented Aug 23, 2021

Hm...okay this games are just weird as hell. Seems like it uses "GetTickCount" combined with a 20ms WndProc Timer. "QueryPerformanceFrequency" wont be called at all...just "QueryPerformanceCounter" once. I tr it myself with the source, if i can hook "GetTickCount" and calc it lower. Perhaps that works...but im not sure.

EDIT: Okay, hooking "GetTickCount" and adjusting it DOES impact the MP gamespeed. I tried make the fake_GetTickCount, but the result was, that the game was too slow or getting out of sync. I guess the problem is, that the game is using it for nearly updating everything. So rendering, movement speed etc. But the impact of GetTickCount does effect Singleplayer too, so it seems the right way to get it done, but i couldnt find a good way to do it.

@helgo1506
Copy link
Author

helgo1506 commented Aug 24, 2021

Okay, when i make every 8 call to "GetTickCount" a 1ms Sleep it's realtiv okay from the game speed. But this value depends on the PC speed too. Perhaps you can find a way to combine it with your maxgameticks.

@FunkyFr3sh
Copy link
Owner

I had a look into the ddraw.dll you linked, seems to be a official one (it's even signed) but I couldn't see anything that could slow down the game. Did you check if it solves the problem? If it works then it might be better to investigate more on that one first. I couldn't reproduce the bug on my own yet, still have to set up a multiplayer test game somehow

@helgo1506
Copy link
Author

The gamespeed problem only comes in multiplayer. But i tested with the DLL, it got some graphic problems sometimes and its not really working.

FunkyFr3sh added a commit that referenced this issue Aug 24, 2021
@FunkyFr3sh
Copy link
Owner

Ah damn.... I guess the only proper fix would be a game patch TBH

I created a new branch where it inserts a Sleep call every 17ms, maybe it's worth a try. You need to add "sleep=1" into ddraw.ini, might have to try a value between 1 and 16 to find out what works the best

ddraw.zip

@helgo1506
Copy link
Author

helgo1506 commented Sep 5, 2021

Hmm nah the Sleep seems not to work. The only thing which seems to work is hooking GetTickCount, like i already said and did myself. The Steam version of American Conquest got there own DirectDraw Emulator, so your DLL dont work there. And for Cossacks exists a community github revamp version (cause the source seems to got leaked some years ago for bugfixing lol), which seems to work.

This is how i got atleast a CD version of it to work atleast a bit better. Seems to work for the Cossacks CD version too.
Will close this here, cause i more and more think, it's not worth the offer to go deeper into this.

DWORD WINAPI fake_GetTickCount()
{
    if (g_ddraw && g_ddraw->fixTickCount)
    {
        LARGE_INTEGER counter;
        LARGE_INTEGER frequency;

        QueryPerformanceFrequency(&frequency);
        QueryPerformanceCounter(&counter);

        LARGE_INTEGER tickCounter;
        tickCounter.QuadPart = (1000LL * counter.QuadPart) / (frequency.QuadPart);
        return tickCounter.LowPart;
    }
    else
    {
        return real_GetTickCount;
    }
}
´´´´

@FunkyFr3sh
Copy link
Owner

Yeah, I saw your fix., I just wanted to create a more generic solution that I could add so it can used for other games as well. I still haven't tested a multiplayer game yet but I'll have a look into it later

@puffdelore
Copy link

Hmm nah the Sleep seems not to work. The only thing which seems to work is hooking GetTickCount, like i already said and did myself. The Steam version of American Conquest got there own DirectDraw Emulator, so your DLL dont work there. And for Cossacks exists a community github revamp version (cause the source seems to got leaked some years ago for bugfixing lol), which seems to work.

This is how i got atleast a CD version of it to work atleast a bit better. Seems to work for the Cossacks CD version too. Will close this here, cause i more and more think, it's not worth the offer to go deeper into this.

DWORD WINAPI fake_GetTickCount()
{
    if (g_ddraw && g_ddraw->fixTickCount)
    {
        LARGE_INTEGER counter;
        LARGE_INTEGER frequency;

        QueryPerformanceFrequency(&frequency);
        QueryPerformanceCounter(&counter);

        LARGE_INTEGER tickCounter;
        tickCounter.QuadPart = (1000LL * counter.QuadPart) / (frequency.QuadPart);
        return tickCounter.LowPart;
    }
    else
    {
        return real_GetTickCount;
    }
}
´´´´

Hi! I am trying to implement this fix myself, and have been looking forever for a way to slow down Cossacks in multiplayer. Which file did you add your code into?

@FunkyFr3sh
Copy link
Owner

FunkyFr3sh commented Jul 3, 2024

Hi! I am trying to implement this fix myself, and have been looking forever for a way to slow down Cossacks in multiplayer. Which file did you add your code into?

@puffdelore
This might not be needed anymore, it should work now without any patches. Here'S the latest build with all files included that are needed for cossacks (Also includes the official ddraw patch AKA mdraw.dll)

Here with the newer official patch (2010)
link removed - check last post for link to working version

Here with the older offfical patch (2008)
link removed - check last post for link to working version

I don't have a multiplayer setup to test it right now, but I think it did work without having to change any settings. But you could slow down the game even more if needed via "cnc-ddraw config.exe" -> "Compatibility settings" -> "Limit game speed"

@puffdelore
Copy link

This might not be needed anymore, it should work now without any patches. Here'S the latest build with all files included that are needed for cossacks (Also includes the official ddraw patch AKA mdraw.dll)

Here with the newer official patch (2010) cnc-ddraw_cossacks-new-official.zip

Here with the older offfical patch (2008) cnc-ddraw_cossacks-old-official.zip

I don't have a multiplayer setup to test it right now, but I think it did work without having to change any settings. But you could slow down the game even more if needed via "cnc-ddraw config.exe" -> "Compatibility settings" -> "Limit game speed"

@FunkyFr3sh
Thanks for the links. I tested the multiplayer with a friend right now, and the one with the newer patch seemed to work for the most part. The game is definitely slowed down way more, but the scrolling is still super fast. Also, the game is choppy and there is a delay in giving orders (for example, between when I press an upgrade button and when it starts). Is there any way around these things? I tried it on different game speed limits in the config app. Also, I should mention that I have tried with my friend with only me using your program, and a few times with both of us using it. I did not notice the issues going away in any case. Anyway, thanks for all your help so far! I will continue playing around with the settings.

@FunkyFr3sh
Copy link
Owner

FunkyFr3sh commented Jul 3, 2024

I've just been toying around with it a bit and it looks like the official patch is the reason for some of the bugs you reported. And as it turned out, the game speed limit was not working.

Here's a test build I made, the game speed limiter is working now (higher value = faster game speed, default = 250)
For GOG/Steam: cnc-ddraw_cossacks.zip (mdraw.dll)
For CD version: cnc-ddraw_cossacks.zip (ddraw.dll)

Note: Make sure you remove the file named "dplayx.dll" from your game folder

@eierfrucht
Copy link

eierfrucht commented Jul 14, 2024

In American Conquest: Fight Back single player skirmish games, when the map size is set to Huge, the game hiccups for a split second every 20-40 seconds or so. No idea if this has anything to do with cnc-ddraw because the game won't run normally without it.

P.S. The jinc2-dedither shader works miracles on the water, shadows and even a bunch of landscape set pieces in this game!

P.P.S. Today American Conquest: Fight Back is played online with a modified executive. You might want to look into that. Quoting from the game’s discord:

Hi @everyone

Update 23rd March 2023.

A new version of the game patched with [netpatch2.2], now with installer, that fixes all network issues. It has VPN integrated into it, no need to install additional software. You can download it here:

https://drive.google.com/file/d/1V5vuY-pYFEQbjm4xTYcsSighxS6twQh9/view?usp=share_link

After installing, two desktop shortcuts will be created: one for singleplayer and another for multiplayer.

When starting multiplayer, go in the game menu in multiplayer, internet game, write your nick and press enter.

More details and strategies in the manual: https://drive.google.com/file/d/1oYiQij6J-AAhRYEwfjCC_apD4P2VEBS3/view?usp=share_link

@puffdelore
Copy link

@FunkyFr3sh
Hi, I tested both of the new builds you made and I am very happy and grateful for your awesome work. I am excited to report that the CD version cnc-ddraw did work, and at 250 ticks, the multiplayer game runs at normal speed. The camera scrolling speed and chat fade are also the correct speed. For context, I use the GOG version of Cossacks. The steam/gog cnc-ddraw didn't work at all for either myself or the other player. However, the multiplayer game only ran at the right speed for him after we both installed the cd version cnc-ddraw, it wasn't enough for just me to have it installed. For context, he also bought the game on GOG and we both have Windows 10. I don't know if that's an issue specific to him though, since my tests of your builds with my second computer didn't have this problem. I only needed to install cnc-ddraw on one computer and it worked for both of them. In addition, there is sometimes about a second or two of delay when giving an order to units, and from what I could tell, our internet latency was fine. Also, the game would sometimes drop to low FPS for both of us, supposedly because the other player right-clicked on the screen too much (that's the reason he gave me). Overall though, the game was entirely playable and I am very glad that I am now able to play the game at the right speed and with minimal downsides. Thanks again for all of your generous help, FunkyFr3sh. I really appreciate it!

@W4lkerHD
Copy link

In American Conquest: Fight Back single-player skirmish games, when the map size is set to Huge, the game hiccups for a split second every 20-40 seconds or so. No idea if this has anything to do with cnc-ddraw because the game won't run normally without it.

P.S. The jinc2-either shader works miracles on the water, shadows and even a bunch of landscape set pieces in this game!

P.P.S. Today American Conquest: Fight Back is played online with a modified executive. You might want to look into that. Quoting from the game’s discord:

Hi @everyone
Update 23rd March 2023.
A new version of the game patched with [netpatch2.2], now with an installer, that fixes all network issues. It has VPN integrated into it, no need to install additional software. You can download it here:
https://drive.google.com/file/d/1V5vuY-pYFEQbjm4xTYcsSighxS6twQh9/view?usp=share_link
After installing, two desktop shortcuts will be created: single-player and multiplayer.
When starting multiplayer, go in the game menu in the multiplayer, internet game, write your nick and press enter.
More details and strategies in the manual: https://drive.google.com/file/d/1oYiQij6J-AAhRYEwfjCC_apD4P2VEBS3/view?usp=share_link

I don't know about you guys, but my game didn't work. Every time I started it, the screen changed, and I went into black-loading mode. Then, after a couple of seconds, the game crashed and reported an error. I tried to run it through a PC on Windows 10. I tried everything that was recommended on the Internet, such as a display mod for old games, launching with admin rights, changing to Windows 7 compatibility, and so on.

@FunkyFr3sh
Copy link
Owner

In American Conquest: Fight Back single-player skirmish games, when the map size is set to Huge, the game hiccups for a split second every 20-40 seconds or so. No idea if this has anything to do with cnc-ddraw because the game won't run normally without it.
P.S. The jinc2-either shader works miracles on the water, shadows and even a bunch of landscape set pieces in this game!
P.P.S. Today American Conquest: Fight Back is played online with a modified executive. You might want to look into that. Quoting from the game’s discord:

Hi @everyone
Update 23rd March 2023.
A new version of the game patched with [netpatch2.2], now with an installer, that fixes all network issues. It has VPN integrated into it, no need to install additional software. You can download it here:
https://drive.google.com/file/d/1V5vuY-pYFEQbjm4xTYcsSighxS6twQh9/view?usp=share_link
After installing, two desktop shortcuts will be created: single-player and multiplayer.
When starting multiplayer, go in the game menu in the multiplayer, internet game, write your nick and press enter.
More details and strategies in the manual: https://drive.google.com/file/d/1oYiQij6J-AAhRYEwfjCC_apD4P2VEBS3/view?usp=share_link

I don't know about you guys, but my game didn't work. Every time I started it, the screen changed, and I went into black-loading mode. Then, after a couple of seconds, the game crashed and reported an error. I tried to run it through a PC on Windows 10. I tried everything that was recommended on the Internet, such as a display mod for old games, launching with admin rights, changing to Windows 7 compatibility, and so on.

Did you check the wiki already?

If it still doesn't work upload me a log file, link: #44

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants