Questions about TrinityCore and the Patcher methods within AuthSocket.cpp


I’ve been trying to set up my server so that it can send custom patches through the server and to the client. After a short search I was able to find a guide written by StoneHarry and schlumpf who managed to get this working back in 2012. Because their guide is quite dated at present I was unable to apply the .diff patch that they supplied to enable the patching functionality. I did attempt to manually look through the .diff file and add in the core edits myself, but my lack of C++ knowledge and the fact that the .diff was made with code written two years ago which seems to have been updated quite a bit I was unable to successfully apply the core edits.

After giving up on editing the core myself I reached out to schlumpf to see if he would be able to fix up his old code so that it would work with newer versions of TrinityCore, he is quite busy at the moment so he is unable to do so. Schlumpf did mention that, as far as he remembers, TrinityCore does have patching implemented. When I found out that it was already implemented I did a quick search through AuthSocket.cpp and found quite a bit of code that, to me, seems as if it’s related to sending patches from server to client. When I stumbled across the (is it called a method in C++?) below I had the idea that I might be able to set up the patch by simply adding a folder named ‘patches’ to /server/bin/ and then creating an MPQ file using the information in StoneHarry/schlumpf’s tutorial. After doing that I restarted authserver and was greeted with the error which is also below.

Is there any way to get patching to work?

The method I stumbled upon:

// Calculate and store MD5 hash for a given patch file
void Patcher::LoadPatchMD5(char szFileName)
// Try to open the patch file
std::string path = “./patches/”;
path += szFileName;
pPatch = fopen(path.c_str(), “rb”);
TC_LOG_DEBUG(“network”, “Loading patch info from %sn”, path.c_str());

if (!pPatch)
    TC_LOG_ERROR("server.authserver", "Error loading patch %sn", path.c_str());

// Calculate the MD5 hash
MD5_CTX ctx;
uint8* buf = new uint8[512 * 1024];

while (!feof(pPatch))
    size_t read = fread(buf, 1, 512 * 1024, pPatch);
    MD5_Update(&ctx, buf, read);

delete [] buf;

// Store the result in the internal patch hash map
_patches[path] = new PATCH_INFO;
MD5_Final((uint8 *)&_patches[path]->md5, &ctx);


The error message:

/home/trinitycore/server/bin# ./authserver
Wrong Loggers configuration. Review your Logger config section.
Creating default loggers [root (Error), server (Info)] to console

I’ve checked the Logger section in authserver.conf & worldserver.conf, but I don’t see anything that would affect sending patches.

After deleting the MPQ file within the patches folder and restarting authserver, it starts up correctly.

The MPQ file contains a file called prepatch.lst and patch-5.mpq, the contents of prepatch.lst are:

delete patch-5.mpq
extract patch-5.mpq

Oh, one additional note. I already have a modified Wow.exe file which has all file protection removed, so there should be no problems there if I ever get this sending to the client somehow.

Thanks for any help.

That’s weird, loggers should have nothing to do with patches, but that’s not an error anyways.

Yeah, I’ve just been here scratching my head and combing over AuthSocket.cpp trying to figure out what’s going on. I only assumed that it was an error because authserver would just stop running, as far as I could tell ,after those messages were displayed.

At least I’m finally getting some experience with C++ by looking through the code, but I’d very much like for the custom patch distribution to work.


I’ve taken another look at the authserver.conf file and thought that the error may be caused because, under Logging system Settings, there is no logging for type 3 (DB). I ran a test with an edited config to include type 3, but it got me nowhere.

Just saying this: I would never use this as a client, you could embed ANY kind of code within this, which is a nono in my opinion.

Not really, you can’t, it just patches MPQ files, the binary executable remains the same.

Maybe i misunderstood something?

You are right then, I was under the impression that it just replaced MPQ data automatically without the need to send yet another binary

Can you suggest any alternatives? I’ve thought about writing up a custom launcher that can do this, but having the patches go through the game just seemed like a nicer solution.