Page 1 of 1

Trees

Posted: Sat Feb 22, 2020 10:48 pm
by El Swanto
Regarding multiplayer games, is it possible to prevent the "t" being used to turn off "trees"? Our group would like to try playing WITH trees once in awhile and would like to insure that no one can cheat. E-mail is swantsays@gmail

Thanks

Re: Trees

Posted: Sun Feb 23, 2020 12:35 am
by Grog
I'm pretty sure that you cannot turn off the Tree/foliage button. I understand that it is hard-coded.
Our MP group have had to learn to accept it and trust that nobody takes advantage.
I admit to using it but not to view enemy troops, rather to see the arrow clearer when deploying in Long grass

Re: Trees

Posted: Sun Feb 23, 2020 3:34 am
by r59
Easiest way is perhaps to just "nullify" the code in your process memory that handles any triggered eComToggleTrees.
std:fill'ing from the AI dll, init method.
Would take me no more than 30 seconds.
But it's gray area stuff.
Don't tempt me. https://emojipedia-us.s3.dualstack.us-w ... _1f64f.png[/img_size]

Re: Trees

Posted: Sun Feb 23, 2020 5:32 pm
by Martin James
Can I tempt you please, r59?

I do think it would be a good option for the host to have in MP, although I assume it could only be done in Waterloo, not GB.

Martin J

Re: Trees

Posted: Sun Feb 23, 2020 7:14 pm
by r59
Can I tempt you please, r59?

I do think it would be a good option for the host to have in MP, although I assume it could only be done in Waterloo, not GB.

Martin J
I'm not sure if it's worth taking the risk, Martin.
Hopefully I'll be granted a safe line to beat in hasty retreat, if things will go bad. :huh:
Ciao R59

I don't think is a great idea teach how to use a hex editor in order to change the exe code on the game forum, also if is for correct a problem. This is a commercial product with a contract with a distributor.

Please, in order to avoid any form of problem don't post them in absence of any Norb or Jim communication.

Davide
These were the latest instructions (7 months old) set by the forum moderation.
Ok, this is not hex editing physical files.
It's your running memory and you are never going to change the original exe (it undergoes many modifications on its own before being runnable too).
It's roughly comparable to setting a game variable's from the AI DLL after all, under the hood.
*In theory* this should avoid triggering any ballistic missile alert here (fingers crossed). :dry:
But, as I said before, it's still a gray area, nevertheless.
Use at your own risk and preferably not within a Steam installation.

I cannot test or compile it now, but might give an idea to anybody interested.
SowInit is another place where you can do this (but not restoring the original bytes).

Code: Select all

static std::uint8_t g_old_code[28];

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        if (CXUtil::IsMulti()) {
            DWORD old_protect, dummy_protect;
            auto start_addr = reinterpret_cast<std::uint8_t *>(0x0050E155);
            if (VirtualProtect(start_addr, 28, PAGE_EXECUTE_READWRITE, &old_protect) != FALSE) {
                if (*start_addr != UINT_C(0x90)) {
                    memcpy(g_old_code, start_addr, 28);
                    memset(start_addr, 0x90, 28);
                    FlushInstructionCache(GetCurrentProcess(), start_addr, 28);
                }
                VirtualProtect(start_addr, 28, old_protect, &dummy_protect);
            }
        }
		break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
		break;
    case DLL_PROCESS_DETACH:
        if (CXUtil::IsMulti()) {
            DWORD old_protect, dummy_protect;
            auto start_addr = reinterpret_cast<std::uint8_t *>(0x0050E155);
            if (VirtualProtect(start_addr, 28, PAGE_EXECUTE_READWRITE, &old_protect) != FALSE) {
                if (*start_addr == UINT_C(0x90)) {
                    memcpy(start_addr, g_old_code, 28);
                    FlushInstructionCache(GetCurrentProcess(), start_addr, 28);
                }
                VirtualProtect(start_addr, 28, old_protect, &dummy_protect);
            }
        }
        break;
    }
    return TRUE;
}
Have a nice Sunday.

Re: Trees

Posted: Mon Feb 24, 2020 1:23 am
by Martin James
Many thanks r59.

I don't pretend to understand this stuff, but have alerted someone who does.

Will bend my own efforts towards finding you a safe-house for when Mitra comes for you ;)

Martin J

Re: Trees

Posted: Mon Feb 24, 2020 11:04 pm
by r59
I'll take you at your word, then. :whistle:
So in the meantime, please don't lose yourself in the woods.
You wouldn't be the first guy. :lol:

Re: Trees

Posted: Tue Feb 25, 2020 5:16 am
by Martin James
Hi again r59

Early reports back suggest you may be on to something.

I believe we can therefore upgrade you to a deluxe secret bunker :)

Thanks again

Martin J