mod_halflife: use parsed ip

This commit is contained in:
Olaf Rempel 2006-04-17 13:59:54 +02:00
parent 68fea83c6f
commit 49b9cf7135
5 changed files with 15 additions and 10 deletions

View File

@ -24,11 +24,10 @@
#include "gameentry.h"
GameEntry::GameEntry(int gameid, NetPkt* pkt, int port2)
: port2(port2), gameid(gameid)
GameEntry::GameEntry(int gameid, struct in_addr *addr, int port1, int port2)
: port1(port1), port2(port2), gameid(gameid)
{
memcpy(&addr, &pkt->getAddress()->sin_addr, sizeof(addr));
this->port1 = pkt->getPort();
memcpy(&this->addr, addr, sizeof(this->addr));
if (port2 != 0) {
this->port2 = this->port1;

View File

@ -3,11 +3,11 @@
#include <netinet/in.h>
#include "netpkt.h"
#include "list.h"
class GameEntry : private ListEntry<GameEntry> {
public:
GameEntry(int gameid, NetPkt* pkt, int port2);
GameEntry(int gameid, struct in_addr *addr, int port1, int port2);
~GameEntry() {}
int compare(const GameEntry* ge);

View File

@ -59,7 +59,12 @@ void GameList::cleanup()
void GameList::addGame(int gameid, NetPkt* pkt, int port2)
{
GameEntry* ge = new GameEntry(gameid, pkt, port2);
addGame(gameid, &pkt->getAddress()->sin_addr, pkt->getPort(), port2);
}
void GameList::addGame(int gameid, struct in_addr *addr, int port1, int port2)
{
GameEntry* ge = new GameEntry(gameid, addr, port1, port2);
int hash = ge->hash(MAX_BUCKETS);
bool found = false;

View File

@ -1,6 +1,8 @@
#ifndef _GAMELIST_H_
#define _GAMELIST_H_
#include <netinet/in.h>
#include "config.h"
#include "netpkt.h"
#include "gameentry.h"
@ -18,6 +20,7 @@ public:
void cleanup();
void addGame(int gameid, NetPkt* pkt, int port2 = 0);
void addGame(int gameid, struct in_addr *addr, int port1, int port2 = 0);
Iterator<GameEntry>* createIterator();
protected:

View File

@ -83,9 +83,7 @@ int ModHalfLife::parse(NetPkt* pkt, GameList* glist)
glist->addGame(ID_HL, pkt);
} else {
// TODO: implement
glist->addGame(ID_HL, pkt);
//glist->add(ID_HL, &tmp, port, false);
glist->addGame(ID_HL, &tmp, port);
}
return PARSE_ACCEPT;