2006-04-16 21:37:00 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 04/2006 by Olaf Rempel *
|
|
|
|
* razzor@kopf-tisch.de *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
2006-02-05 16:44:38 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include "mod_q3engine.h"
|
2006-04-16 21:02:41 +02:00
|
|
|
#include "modhelper.h"
|
2006-02-05 16:44:38 +01:00
|
|
|
|
|
|
|
static struct game_ports port_arr[] = {
|
2006-03-06 20:13:26 +01:00
|
|
|
{ 27960, 27969, ID_Q3A }, // q3(6), ef(7), et25), rtcw(8)
|
|
|
|
{ 28070, 28070, ID_JK2 }, // jk2(12)
|
|
|
|
{ 28960, 28963, ID_COD }, // cod(31), cod:uo(42), cod2(48)
|
|
|
|
{ 29070, 29070, ID_JK3 }, // jk3(27)
|
2006-02-05 16:44:38 +01:00
|
|
|
{ 0,0,0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char scanmsg[] = "\xff\xff\xff\xffgetStatus";
|
|
|
|
static const char replyhead[] = "\xff\xff\xff\xffstatusResponse";
|
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
static const char search_version[] = "\\version\\";
|
|
|
|
static const char search_gamename[] = "\\gamename\\";
|
|
|
|
|
|
|
|
static const char reply_q3[] = "Q3 ";
|
|
|
|
static const char reply_ef[] = "ST:V HM ";
|
|
|
|
static const char reply_rtcw[] = "Wolf ";
|
|
|
|
static const char reply_et[] = "ET";
|
|
|
|
static const char reply_jk2[] = "JK2MP";
|
|
|
|
static const char reply_jk3[] = "JAmp";
|
|
|
|
|
|
|
|
static const char reply_cod[] = "Call of Duty\\";
|
|
|
|
static const char reply_coduo[] = "CoD:United Offensive\\";
|
|
|
|
static const char reply_cod2[] = "Call of Duty 2\\";
|
|
|
|
|
2006-02-05 16:44:38 +01:00
|
|
|
void ModQ3Engine::scan(MultiSock* msock)
|
|
|
|
{
|
2006-03-05 02:28:19 +01:00
|
|
|
ModHelper::send(msock, port_arr, scanmsg, strlen(scanmsg));
|
2006-02-05 16:44:38 +01:00
|
|
|
}
|
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
int ModQ3Engine::parse(NetPkt* pkt, GameList* glist)
|
2006-02-05 16:44:38 +01:00
|
|
|
{
|
2006-02-20 21:58:59 +01:00
|
|
|
int gameid = 0, pos1, pos2;
|
2006-03-05 02:28:19 +01:00
|
|
|
|
|
|
|
gameid = ModHelper::checkPorts(pkt, port_arr);
|
|
|
|
if (!gameid)
|
2006-02-20 21:58:59 +01:00
|
|
|
return PARSE_REJECT;
|
|
|
|
|
|
|
|
if (!pkt->compare(0, replyhead, strlen(replyhead)))
|
|
|
|
return PARSE_REJECT;
|
|
|
|
|
|
|
|
pos1 = pkt->find(0, search_version, strlen(search_version));
|
|
|
|
if (pos1 != -1) {
|
|
|
|
pos1 += strlen(search_version);
|
|
|
|
if (pkt->compare(pos1, reply_q3, strlen(reply_q3)))
|
|
|
|
gameid = ID_Q3A;
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
else if (pkt->compare(pos1, reply_ef, strlen(reply_ef)))
|
|
|
|
gameid = ID_EF;
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
else if (pkt->compare(pos1, reply_rtcw, strlen(reply_rtcw)))
|
|
|
|
gameid = ID_RTCW;
|
|
|
|
|
|
|
|
else if (pkt->compare(pos1, reply_et, strlen(reply_et)))
|
|
|
|
gameid = ID_ET;
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
else if (pkt->compare(pos1, reply_jk2, strlen(reply_jk2)))
|
|
|
|
gameid = ID_JK2;
|
|
|
|
|
|
|
|
else if (pkt->compare(pos1, reply_jk3, strlen(reply_jk3)))
|
|
|
|
gameid = ID_JK3;
|
|
|
|
}
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
pos2 = pkt->find(0, search_gamename, strlen(search_gamename));
|
|
|
|
if (gameid == 0 && pos2 != -1) {
|
|
|
|
pos2 += strlen(search_gamename);
|
|
|
|
if (pkt->compare(pos2, reply_cod, strlen(reply_cod)))
|
|
|
|
gameid = ID_COD;
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
else if (pkt->compare(pos2, reply_coduo, strlen(reply_coduo)))
|
|
|
|
gameid = ID_COD_UO;
|
|
|
|
|
|
|
|
else if (pkt->compare(pos2, reply_cod2, strlen(reply_cod2)))
|
|
|
|
gameid = ID_COD2;
|
|
|
|
}
|
2006-03-05 02:28:19 +01:00
|
|
|
|
2006-02-20 21:58:59 +01:00
|
|
|
if (gameid == 0)
|
|
|
|
return PARSE_REJECT;
|
|
|
|
|
|
|
|
glist->addGame(gameid, pkt);
|
2006-02-20 12:31:34 +01:00
|
|
|
return PARSE_ACCEPT;
|
2006-02-05 16:44:38 +01:00
|
|
|
}
|