Skip to content

Commit

Permalink
add 'Soldier of Fortune 2' to unsupported games list
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed Oct 9, 2023
1 parent ed8b99e commit 7520c8d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Please note that the GameSpy protocol is old and does not meet modern password e
| Crysis 2 | not working |
| Men of War: Assault Squad | coming soon™ |
| Rise Of Nations: Rise Of Legends | coming soon™, see [issue #2](https://github.com/anzz1/openspy-client/issues/2) |
| Soldier of Fortune 2: Double Helix | not working |
| Test Drive Unlimited | not working |
| [report unsupported game](https://github.com/anzz1/openspy-client/issues/new?assignees=&labels=game+request&projects=&template=request-for-game-support.yml&title=%5Bgame-request%5D+GAME+NAME) |

Expand Down
3 changes: 3 additions & 0 deletions dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "include/game_xml2.h"
#include "include/game_ts.h"
#include "include/game_gt.h"
#include "include/game_sof2.h"
#endif // !_WIN64

#include "include/picoupnp.h"
Expand Down Expand Up @@ -277,6 +278,8 @@ int __stdcall DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpReserved) {
patch_ts();
} else if (!__stricmp(p, "gt.exe")) { // Gene Troopers
patch_gt();
} else if (!__stricmp(p, "sof2mp.exe")) { // Soldier of Fortune 2
patch_sof2();
} else if (!__stricmp(p, "game.dat") && p2 && !__strcmp(p2, "RTS.exe")) { // Battle for Middle-earth II
patch_bfme2();
} else if (!__stricmp(p, "serioussam.exe") || !__stricmp(p, "sam2.exe") || !__stricmp(p, "dedicatedserver.exe")) { // Serious Sam 1 & 2
Expand Down
33 changes: 33 additions & 0 deletions include/game_sof2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// game_sof2.h

#ifndef __GAME_SOF2_H
#define __GAME_SOF2_H

#include "include/global.h"
#include "iathook/iathook.h"

LPHOSTENT __stdcall hk_gethostbyname(const char* name);

LPHOSTENT __stdcall sof2_hk_gethostbyname(const char* name) {
if (name && !__strcmp(name, "master.sof2.ravensoft.com"))
return ogethostbyname("master.openspy.net");
else
return hk_gethostbyname(name);
}

__forceinline static void sof2_hook_gs() {
HOOK_FUNC(0, gethostbyname, sof2_hk_gethostbyname, "ws2_32.dll", 52, TRUE);
HOOK_FUNC(0, gethostbyname, sof2_hk_gethostbyname, "wsock32.dll", 52, TRUE);
}

// GOG v1.3 extra patch
__forceinline static void sof2_patch_gog() {
patch_if_match((void*)0x0055A9AC, "localhost 2.ravensoft.com", "master.openspy.net", 25, 19);
}

__noinline static void patch_sof2() {
sof2_hook_gs();
sof2_patch_gog();
}

#endif // __GAME_SOF2_H

0 comments on commit 7520c8d

Please sign in to comment.