diff --git a/bot/bot.ncb b/bot/bot.ncb index dd1a4ae..cff0b9a 100644 Binary files a/bot/bot.ncb and b/bot/bot.ncb differ diff --git a/bot/bot.suo b/bot/bot.suo index 5dcdb4a..a6404f0 100644 Binary files a/bot/bot.suo and b/bot/bot.suo differ diff --git a/bot/bot.vcproj b/bot/bot.vcproj index 4fef2e1..17532db 100644 --- a/bot/bot.vcproj +++ b/bot/bot.vcproj @@ -114,6 +114,9 @@ + + diff --git a/bot/main.cpp b/bot/main.cpp index a322a59..0f1c2e2 100644 --- a/bot/main.cpp +++ b/bot/main.cpp @@ -1,7 +1,98 @@ -int main() +#include "main.h" + +GAME_SETTINGS tSettings; + +void InitSettingsFromCommandLine(char * szCmdLine); + +//---------------------------------------------------- + +/* + Argument format: + "-h %s -p %d -n %s -m %s" + + -h -> either server's bind address or 127.0.0.1 + -p -> server's port number + -n -> NPC's name + -m -> script name +*/ +int main (int argc, char** argv) { + char szCmdLine[1024]; + memset(szCmdLine,0,1024); + + int cmdcnt=1; + if(argc > 1) { + while(cmdcnt != argc) { + strcat(szCmdLine, argv[cmdcnt]); + strcat(szCmdLine, " "); + cmdcnt++; + } + } + InitSettingsFromCommandLine(szCmdLine); + // TODO: main // Absolutely no indication it is named npc or bot... + return 0; -} \ No newline at end of file +} + +//---------------------------------------------------- + +void SetStringFromCommandLine(char* szCmdLine, char* szString); + +void InitSettingsFromCommandLine(char * szCmdLine) +{ + logprintf(szCmdLine); + + memset(&tSettings,0,sizeof(GAME_SETTINGS)); + + while(*szCmdLine) { + + if(*szCmdLine == '-' || *szCmdLine == '/') { + szCmdLine++; + switch(*szCmdLine) { + case 'z': + szCmdLine++; + SetStringFromCommandLine(szCmdLine,tSettings.szConnectPass); + 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 'm': + szCmdLine++; + SetStringFromCommandLine(szCmdLine,tSettings.szModeName); + break; + } + } + + szCmdLine++; + } +} + +//---------------------------------------------------- + +void SetStringFromCommandLine(char* szCmdLine, char* szString) +{ + while(*szCmdLine == ' ') szCmdLine++; + while(*szCmdLine && + *szCmdLine != ' ' && + *szCmdLine != '-' && + *szCmdLine != '/') + { + *szString = *szCmdLine; + szString++; szCmdLine++; + } + *szString = '\0'; +} + +//---------------------------------------------------- diff --git a/bot/main.h b/bot/main.h new file mode 100644 index 0000000..76479dd --- /dev/null +++ b/bot/main.h @@ -0,0 +1,22 @@ +#pragma once + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + + #include +#else +#endif + +#define MAX_SETTINGS_STRING 256 + +typedef struct _GAME_SETTINGS { + CHAR szConnectPass[MAX_SETTINGS_STRING+1]; + CHAR szConnectHost[MAX_SETTINGS_STRING+1]; + CHAR szConnectPort[MAX_SETTINGS_STRING+1]; + CHAR szNickName[MAX_SETTINGS_STRING+1]; + CHAR szModeName[MAX_SETTINGS_STRING+1]; +} GAME_SETTINGS; + +#include +#include +