View Single Post
Re: I'm STEAMed up !!!
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: I'm STEAMed up !!! - 30-12-2003

w000H00H00H00H00000000t!!!!

I impress myself sometimes.

Sent this email to Will Day:
Code:
Hi Will, me again :)
 
I have worked out a very simple fix that makes metamod 1.17 backwards
compatible with both steam servers and non-steam servers, even with the
latest enginefuncs patch from Alfred at Valve. Metamod detects Steam and
automatically adapts its enginefuncs interface to the version of the engine
and gamedll it is used with. Interested ?
 
 
in h_export.cpp, somewhere at the top of the file :
--------------------------------------------------
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- START
mBOOL is_steam = mFALSE;
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- END
-------------------------------------------------
 
 
in h_export.cpp, GiveFnptrsToDll() function :
(last 3 code lines are context lines)
-------------------------------------------------
void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine,
globalvars_t *pGlobals)
{
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- START
FILE *fp;
 
is_steam = mFALSE; // assume Steam is not present by default
 
// to check whether Steam is installed or not, I test Steam-specific
files.
// if you know a more orthodox way of doing this, please tell me.
 
// test file, if found = STEAM Linux/Win32 dedicated server
fp = fopen ("valve/steam.inf", "rb");
if (fp != NULL)
{
	 fclose (fp); // test was successful, close it
	 is_steam = mTRUE; // this file is typical from a STEAM DS install
}
 
// test file, if found = STEAM Win32 listenserver
fp = fopen ("FileSystem_Steam.dll", "rb");
if (fp != NULL)
{
	 fclose (fp); // test was successful, close it
	 is_steam = mTRUE; // this file is typical from a STEAM client/LS
}
 
if (is_steam)
	memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(g_engfuncs));
else
	 memcpy(&g_engfuncs, pengfuncsFromEngine, 144 * sizeof(unsigned
__int32));
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- END
 
gpGlobals = pGlobals;
Engine.funcs = &g_engfuncs;
Engine.globals = pGlobals;
---------------------------------------------------
 
 
in metamod.cpp, metamod_startup() function :
(first 3 comment lines are context lines)
--------------------------------------------------
// Copy, and store pointer in Engine struct. Yes, we could just store
// the actual engine_t struct in Engine, but then it wouldn't be a
// pointer to match the other g_engfuncs.
 
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- START
extern mBOOL is_steam;
if (is_steam)
	memcpy(&g_plugin_engfuncs, Engine.funcs, sizeof(g_plugin_engfuncs));
else
	 memcpy(&g_plugin_engfuncs, Engine.funcs, 144 * sizeof(unsigned
__int32));
// Pierre-Marie Baty -- STEAM/NOSTEAM auto-adaptative fix -- END
----------------------------------------------------
 
Sorry for the syntax of these patchs, but someone has yet to port the GNU
diff utility to Windows... I should perhaps give it a go one of these days
;-)
 
If you want to know why I shorten the length of the enginefuncs interface to
144 int32's when Steam is not detected, it's because the last enginefuncs
interface we had before the Steam guys changed it, was made of 144 function
pointers. These 144 function pointers make the "classical" enginefuncs
interface a non-steam HLDS and gameDLL know. The remaining functions in the
structure are only used by Steam engines and gamedlls ; but if you try to
stuff them to a non-steam server, chances are that the server will crash.
 
I would *really* *really* *really* like to see this change in the next
metamod, Will... I had to do it because there are a LOT of people who
are still using non-steam servers, please don't drop metamod support for
non-steam servers. :-)
 
-- 
Pierre-Marie Baty
pm@bots-united.com
you can use this info to patch your metamod 1.17, even with the latest patch from Valve, it'll be 100% backwards-compatible with CS 1.5 and non-steam servers in general



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 30-12-2003 at 02:11..
  
Reply With Quote