SA-MP/saco/main.cpp

172 lines
3.6 KiB
C++
Raw Normal View History

2023-10-20 06:46:57 +08:00
#include "main.h"
2023-11-15 18:46:57 +08:00
int iGtaVersion=0;
GAME_SETTINGS tSettings;
CConfig *pConfig=0;
CChatWindow *pChatWindow=0;
CCmdWindow *pCmdWindow=0;
//DWORD dword_1026EB88=0;
CAudioStream *pAudioStream=0;
//DWORD dword_1026EB90=0;
CNetGame *pNetGame=0;
//DWORD dword_1026EB98=0;
CFontRender *pDefaultFont=0;
//DWORD dword_1026EBA0=0;
//DWORD dword_1026EBA4=0;
//DWORD dword_1026EBA8=0;
2023-10-20 06:46:57 +08:00
HANDLE hInstance=0;
2023-10-19 08:02:18 +08:00
2023-11-23 23:41:28 +08:00
CGame *pGame=0;
DWORD dwGraphicsLoop=0;
2023-10-23 23:04:28 +08:00
2023-11-08 20:29:53 +08:00
CFileSystem *pFileSystem=NULL;
// forwards
2023-11-24 23:30:07 +08:00
void TheGraphicsLoop();
LONG WINAPI exc_handler(_EXCEPTION_POINTERS* exc_inf);
2023-11-22 23:40:22 +08:00
//----------------------------------------------------
#define ARCHIVE_FILE "samp.saa"
2023-10-19 08:02:18 +08:00
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
2023-11-08 20:31:44 +08:00
// TODO: DllMain
2023-10-20 06:46:57 +08:00
if(DLL_PROCESS_ATTACH==fdwReason)
{
hInstance = hinstDLL;
InitSettings();
if(tSettings.bDebug || tSettings.bPlayOnline)
{
SetUnhandledExceptionFilter(exc_handler);
2023-11-24 23:30:07 +08:00
dwGraphicsLoop = (DWORD)TheGraphicsLoop;
2023-11-08 20:29:53 +08:00
CHAR szArchiveFile[MAX_PATH];
GetModuleFileNameA((HMODULE)hInstance, szArchiveFile, MAX_PATH);
DWORD dwFileNameLen = strlen(szArchiveFile);
while(szArchiveFile[dwFileNameLen] != '\\')
dwFileNameLen--;
strcpy(szArchiveFile+dwFileNameLen+1, ARCHIVE_FILE);
2023-11-08 20:29:53 +08:00
pFileSystem = new CArchiveFS();
if(!pFileSystem->Load(ARCHIVE_FILE)) _asm int 3
2023-10-23 22:58:28 +08:00
2023-10-20 06:46:57 +08:00
AddFontResourceA("gtaweap3.ttf");
AddFontResourceA("sampaux3.ttf");
2023-10-23 22:58:28 +08:00
2023-10-23 23:04:28 +08:00
//sub_10062CA0();
//sub_10062970();
pGame = new CGame();
//_beginthread((int)sub_100C3A80, 0, 0);
2023-10-20 06:46:57 +08:00
}
}
else if(DLL_PROCESS_DETACH==fdwReason)
{
if(tSettings.bDebug || tSettings.bPlayOnline) {
//sub_10062D90
}
}
2023-10-19 08:02:18 +08:00
return TRUE;
}
2023-10-20 06:46:57 +08:00
//----------------------------------------------------
2023-11-24 23:30:07 +08:00
void TheGraphicsLoop()
{
}
//----------------------------------------------------
2023-10-20 06:46:57 +08:00
void InitSettings()
{
PCHAR szCmdLine = GetCommandLineA();
memset(&tSettings,0,sizeof(GAME_SETTINGS));
while(*szCmdLine) {
if(*szCmdLine == '-' || *szCmdLine == '/') {
szCmdLine++;
switch(*szCmdLine) {
case 'd':
tSettings.bDebug = TRUE;
tSettings.bPlayOnline = FALSE;
break;
case 'c':
tSettings.bPlayOnline = TRUE;
tSettings.bDebug = FALSE;
break;
case 'z':
szCmdLine++;
SetStringFromCommandLine(szCmdLine,tSettings.szConnectPass);
break;
/*
// We'll do this using ALT+ENTER
case 'w':
tSettings.bWindowedMode = TRUE;
break;
*/
case 'h':
szCmdLine++;
SetStringFromCommandLine(szCmdLine,tSettings.szConnectHost);
break;
case 'p':
szCmdLine++;
SetStringFromCommandLine(szCmdLine,tSettings.szConnectPort);
break;
case 'n':
szCmdLine++;
SetStringFromCommandLine(szCmdLine,tSettings.szNickName);
break;
case 'l':
szCmdLine++;
SetStringFromQuotedCommandLine(szCmdLine,tSettings.szDebugScript);
break;
}
}
szCmdLine++;
}
}
//----------------------------------------------------
void SetStringFromCommandLine(char *szCmdLine, char *szString)
{
while(*szCmdLine == ' ') szCmdLine++;
while(*szCmdLine &&
*szCmdLine != ' ' &&
*szCmdLine != '-' &&
*szCmdLine != '/')
{
*szString = *szCmdLine;
szString++; szCmdLine++;
}
*szString = '\0';
}
//----------------------------------------------------
void SetStringFromQuotedCommandLine(char *szCmdLine, char *szString)
{
while(*szCmdLine != '"') szCmdLine++;
szCmdLine++;
while(*szCmdLine &&
*szCmdLine != '"')
{
*szString = *szCmdLine;
szString++; szCmdLine++;
}
*szString = '\0';
}
//----------------------------------------------------