hlswmaster-ng/gameparser.cpp

45 lines
834 B
C++

#include "logging.h"
#include "netpkt.h"
#include "gameparser.h"
GameParser::GameParser(GameScanner& scanner, ModuleList& modList, GameList& gameList)
: scanner(scanner), modList(modList), gameList(gameList)
{
}
int GameParser::execute(void* arg)
{
NetPkt* pkt;
char buf[64], *p;
int ret;
while (1) {
pkt = scanner.getPkt();
ret = modList.parse(pkt, &gameList);
switch (ret) {
case PARSE_ACCEPT_FAKE:
pkt->show(buf, sizeof(buf));
LogSystem::log(LOG_NOTICE, "not supported Game: %s", buf);
case PARSE_ACCEPT:
delete pkt;
case PARSE_ACCEPT_FREED:
break;
default:
case PARSE_REJECT:
pkt->show(buf, sizeof(buf));
LogSystem::log(LOG_NOTICE, "unknown Packet: %s", buf);
p = pkt->showfull();
LogSystem::log(LOG_DEBUG, "%s", p);
delete [] p;
delete pkt;
break;
}
}
return 0;
}