Fixed SeriousSam and GameAgent bugs

This commit is contained in:
RocketersAlex 2016-03-30 16:54:30 +03:00
parent 282ae65d9f
commit 0d8f7da318
8 changed files with 1254 additions and 83 deletions

View File

@ -111,6 +111,8 @@ functions:
// provide info for GameAgent enumeration
export virtual void GetGameAgentPlayerInfo( INDEX iPlayer, CTString &strOut) { };
// provide info for MSLegacy enumeration
export virtual void GetMSLegacyPlayerInf( INDEX iPlayer, CTString &strOut) { };
// create a checksum value for sync-check
export void ChecksumForSync(ULONG &ulCRC, INDEX iExtensiveSyncCheck)

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
extern CTString ga_strServer;
extern CTString ga_strMSLegacy;
extern BOOL ga_bMSLegacy;
/// Initialize GameAgent.
extern void GameAgent_ServerInit(void);
@ -36,6 +38,10 @@ extern void GameAgent_EnumTrigger(BOOL bInternet);
extern void GameAgent_EnumUpdate(void);
/// Cancel the GameAgent serverlist enumeration.
extern void GameAgent_EnumCancel(void);
///
DWORD WINAPI _MS_Thread(LPVOID lpParam);
///
DWORD WINAPI _LocalNet_Thread(LPVOID lpParam);
/// Server request structure. Primarily used for getting server pings.
class CServerRequest {

View File

@ -0,0 +1,185 @@
/*
GSMSALG 0.3.3
by Luigi Auriemma
e-mail: aluigi@autistici.org
web: aluigi.org
INTRODUCTION
============
With the name Gsmsalg I define the challenge-response algorithm needed
to query the master servers that use the Gamespy "secure" protocol (like
master.gamespy.com for example).
This algorithm is not only used for this type of query but also in other
situations like the so called "Gamespy Firewall Probe Packet" and the
master server hearbeat that is the challenge string sent by the master
servers of the games that use the Gamespy SDK when game servers want to
be included in the online servers list (UDP port 27900).
HOW TO USE
==========
The function needs 4 parameters:
- dst: the destination buffer that will contain the calculated
response. Its length is 4/3 of the challenge size so if the
challenge is 6 bytes long, the response will be 8 bytes long
plus the final NULL byte which is required (to be sure of the
allocated space use 89 bytes or "((len * 4) / 3) + 3")
if this parameter is NULL the function will allocate the
memory for a new one automatically
- src: the source buffer containing the challenge string received
from the server.
- key: the gamekey or any other text string used as algorithm's
key, usually it is the gamekey but "might" be another thing
in some cases. Each game has its unique Gamespy gamekey which
are available here:
http://aluigi.org/papers/gslist.cfg
- enctype: are supported 0 (plain-text used in old games, heartbeat
challenge respond, enctypeX and more), 1 (Gamespy3D) and 2
(old Gamespy Arcade or something else).
The return value is a pointer to the destination buffer.
EXAMPLE
=======
#include "MSLegacy.h"
char *dest;
dest = gsseckey(
NULL, // dest buffer, NULL for auto allocation
"ABCDEF", // the challenge received from the server
"kbeafe", // kbeafe of Doom 3 and enctype set to 0
0); // enctype 0
LICENSE
=======
Copyright 2004,2005,2006,2007,2008 Luigi Auriemma
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://www.gnu.org/licenses/gpl.txt
*/
#ifdef PRAGMA_ONCE
#pragma once
#endif
/* function gsvalfunc */
unsigned char gsvalfunc(u_char reg) {
if(reg < 0x1a) return u_char (reg + 'A');
if(reg < 0x34) return u_char (reg + 'G');
if(reg < 0x3e) return u_char (reg - 4);
if(reg == 0x3e) return u_char('+');
if(reg == 0x3f) return u_char ('/');
return u_char(0);
}
/* function gsseckey */
unsigned char *gsseckey(u_char *secure, u_char *key, int enctype) {
static u_char validate[9];
u_char secbuf[7],
buff[256],
*ptr,
*ptrval,
*sec,
*k,
tmp1,
tmp2,
ebx,
i,
ecx,
edx,
edi;
i = 0;
ptr = buff;
do { *ptr++ = i++; } while(i); /* 256 times */
ptr = buff;
k = (unsigned char*) memcpy(secbuf, key, 6); /* good if key is not NULLed */
k[6] = edx = i = 0;
do { /* 256 times */
if(!*k) k = secbuf;
edx = *ptr + edx + *k;
/* don't use the XOR exchange optimization!!! */
/* ptrval is used only for faster code */
ptrval = buff + edx;
tmp1 = *ptr;
*ptr = *ptrval;
*ptrval = tmp1;
ptr++; k++; i++;
} while(i);
sec = (unsigned char *) memcpy(secbuf, secure, 6);
sec[6] = edi = ebx = 0;
do { /* 6 times */
edi = edi + *sec + 1;
ecx = ebx + buff[edi];
ebx = ecx;
/* don't use the XOR exchange optimization!!! */
/* ptr and ptrval are used only for faster code */
ptr = buff + edi;
ptrval = buff + ebx;
tmp1 = *ptr;
*ptr = *ptrval;
*ptrval = tmp1;
ecx = tmp1 + *ptr;
*sec++ ^= buff[ecx];
} while(*sec);
if(enctype == 2) {
ptr = key;
sec = secbuf;
do { /* 6 times */
*sec++ ^= *ptr++;
} while(*sec);
}
sec = secbuf;
ptrval = validate;
for(i = 0; i < 2; i++) {
tmp1 = *sec++;
tmp2 = *sec++;
*ptrval++ = gsvalfunc(tmp1 >> 2);
*ptrval++ = gsvalfunc(((tmp1 & 3) << 4) + (tmp2 >> 4));
tmp1 = *sec++;
*ptrval++ = gsvalfunc(((tmp2 & 0xf) << 2) + (tmp1 >> 6));
*ptrval++ = gsvalfunc(tmp1 & 0x3f);
}
*ptrval = 0x00;
return(validate);
}
/* function resolv */
u_int resolv(char *host) {
struct hostent *hp;
u_int host_ip;
host_ip = inet_addr(host);
if(host_ip == INADDR_NONE) {
hp = gethostbyname(host);
if(!hp) {
return (NULL);
} else host_ip = *(u_int *)(hp->h_addr);
}
return(host_ip);
}
/* end functions */

View File

@ -887,6 +887,8 @@ void CNetworkLibrary::Init(const CTString &strGameID)
_pShell->DeclareSymbol("persistent user INDEX wed_bUseGenericTextureReplacement;", &wed_bUseGenericTextureReplacement);
_pShell->DeclareSymbol("user CTString ga_strServer;", &ga_strServer);
_pShell->DeclareSymbol("user CTString ga_strMSLegacy;", &ga_strMSLegacy);
_pShell->DeclareSymbol("user INDEX ga_bMSLegacy;", &ga_bMSLegacy);
_pShell->DeclareSymbol("INDEX pwoCurrentWorld;", &_pwoCurrentWorld);
}
@ -2427,7 +2429,7 @@ void CNetworkLibrary::GameInactive(void)
FOREVER {
CNetworkMessage nmReceived;
//_cmiComm.Broadcast_Update();
// _cmiComm.Broadcast_Update();
ULONG ulFrom;
UWORD uwPort;
BOOL bHasMsg = ReceiveBroadcast(nmReceived, ulFrom, uwPort);

View File

@ -77,6 +77,7 @@ public:
CTString ns_strGameType; // game type
CTString ns_strMod; // active mod
CTString ns_strVer; // version
public:
void Copy(const CNetworkSession &nsOriginal);

View File

@ -1957,6 +1957,23 @@ functions:
strOut+=strKey;
};
// provide info for MSLegacy enumeration
void GetMSLegacyPlayerInf( INDEX iPlayer, CTString &strOut)
{
CTString strKey;
strKey.PrintF("\\player_%d\\%s", iPlayer, (const char*)GetPlayerName());
strOut+=strKey;
if (GetSP()->sp_bUseFrags) {
strKey.PrintF("\\frags_%d\\%d", iPlayer, m_psLevelStats.ps_iKills);
strOut+=strKey;
} else {
strKey.PrintF("\\frags_%d\\%d", iPlayer, m_psLevelStats.ps_iScore);
strOut+=strKey;
}
strKey.PrintF("\\ping_%d\\%d", iPlayer, INDEX(ceil(en_tmPing*1000.0f)));
strOut+=strKey;
};
// check if message is in inbox
BOOL HasMessage( const CTFileName &fnmMessage)
{

View File

@ -115,7 +115,7 @@ extern CTString sam_strModName = TRANS("- O P E N S O U R C E -");
#if _SE_DEMO
extern CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld";
#else
extern CTString sam_strFirstLevel = "Levels\\LevelsMP\\1_0_InTheLastEpisode.wld.wld";
extern CTString sam_strFirstLevel = "Levels\\LevelsMP\\1_0_InTheLastEpisode.wld";
#endif
extern CTString sam_strIntroLevel = "Levels\\LevelsMP\\Intro.wld";
extern CTString sam_strGameName = "serioussamse";
@ -514,8 +514,8 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine)
LoadAndForceTexture(_toLogoEAX, _ptoLogoEAX, CTFILENAME("Textures\\Logo\\LogoEAX.tex"));
// !! NOTE !! Re-enable these to allow mod support.
//LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), sam_strVersion);
//LoadStringVar(CTString("Data\\Var\\ModName.var"), sam_strModName);
LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), sam_strVersion);
LoadStringVar(CTString("Data\\Var\\ModName.var"), sam_strModName);
CPrintF(TRANS("Serious Sam version: %s\n"), sam_strVersion);
CPrintF(TRANS("Active mod: %s\n"), sam_strModName);
InitializeMenus();
@ -612,6 +612,7 @@ void End(void)
pvpViewPort = NULL;
pdpNormal = NULL;
}
CloseMainWindow();
MainWindow_End();
DestroyMenus();
@ -1200,14 +1201,36 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
_pInput->DisableInput();
_pGame->StopGame();
if (_fnmModToLoad!="") {
char strCmd [64] = {0};
char strParam [128] = {0};
STARTUPINFOA cif;
ZeroMemory(&cif,sizeof(STARTUPINFOA));
PROCESS_INFORMATION pi;
strcpy_s(strCmd,"SeriousSam.exe");
strcpy_s(strParam," +game ");
strcat_s(strParam,_fnmModToLoad.FileName());
if (_strModServerJoin!="") {
strcat_s(strParam," +connect ");
strcat_s(strParam,_strModServerJoin);
strcat_s(strParam," +quickjoin");
}
if (CreateProcessA(strCmd,strParam,NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE,NULL,NULL,&cif,&pi) == FALSE)
{
MessageBox(0, L"error launching the Mod!\n", L"Serious Sam", MB_OK|MB_ICONERROR);
}
}
// invoke quit screen if needed
if( _bQuitScreen && _fnmModToLoad=="") QuitScreenLoop();
End();
return TRUE;
}
/*
void CheckModReload(void)
{
if (_fnmModToLoad!="") {
@ -1225,9 +1248,10 @@ void CheckModReload(void)
argv[5] = "+quickjoin";
argv[6] = NULL;
}
_execv(strCommand, argv);
}
}
}*/
void CheckTeaser(void)
{
@ -1255,7 +1279,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
iResult = SubMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
} CTSTREAM_END;
CheckModReload();
//CheckModReload();
CheckTeaser();