Browse Source

mod_halflife: use parsed ip

master
Olaf Rempel 16 years ago
parent
commit
49b9cf7135
  1. 7
      gameentry.cpp
  2. 4
      gameentry.h
  3. 7
      gamelist.cpp
  4. 3
      gamelist.h
  5. 4
      mod_halflife.cpp

7
gameentry.cpp

@ -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;

4
gameentry.h

@ -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);

7
gamelist.cpp

@ -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;

3
gamelist.h

@ -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:

4
mod_halflife.cpp

@ -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;

Loading…
Cancel
Save