File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ class LANAPIInterface : public SubsystemInterface
130130 // Misc utility functions
131131 virtual LANGameInfo * LookupGame ( UnicodeString gameName ) = 0; // /< return a pointer to a game we know about
132132 virtual LANGameInfo * LookupGameByListOffset ( Int offset ) = 0; // /< return a pointer to a game we know about
133+ virtual LANGameInfo * LookupGameByHost ( UnsignedInt hostIP ) = 0; // /< return a pointer to the most recent game associated to the host IP address
133134 virtual Bool SetLocalIP ( UnsignedInt localIP ) = 0; // /< For multiple NIC machines
134135 virtual void SetLocalIP ( AsciiString localIP ) = 0; // /< For multiple NIC machines
135136 virtual Bool AmIHost ( void ) = 0; // /< Am I hosting a game?
@@ -331,6 +332,7 @@ class LANAPI : public LANAPIInterface
331332 // Misc utility functions
332333 virtual LANGameInfo * LookupGame ( UnicodeString gameName ); // /< return a pointer to a game we know about
333334 virtual LANGameInfo * LookupGameByListOffset ( Int offset ); // /< return a pointer to a game we know about
335+ virtual LANGameInfo * LookupGameByHost ( UnsignedInt hostIP ); // /< return a pointer to the most recent game associated to the host IP address
334336 virtual LANPlayer * LookupPlayer ( UnsignedInt playerIP ); // /< return a pointer to a player we know about
335337 virtual Bool SetLocalIP ( UnsignedInt localIP ); // /< For multiple NIC machines
336338 virtual void SetLocalIP ( AsciiString localIP ); // /< For multiple NIC machines
Original file line number Diff line number Diff line change @@ -1112,6 +1112,23 @@ LANGameInfo * LANAPI::LookupGameByListOffset( Int offset )
11121112 return theGame; // null means we didn't find anything.
11131113}
11141114
1115+ LANGameInfo* LANAPI::LookupGameByHost (UnsignedInt hostIP)
1116+ {
1117+ LANGameInfo* lastGame = nullptr ;
1118+ UnsignedInt lastHeard = 0 ;
1119+
1120+ for (LANGameInfo* game = m_games; game; game = game->getNext ())
1121+ {
1122+ if (game->getHostIP () == hostIP && game->getLastHeard () >= lastHeard)
1123+ {
1124+ lastGame = game;
1125+ lastHeard = game->getLastHeard ();
1126+ }
1127+ }
1128+
1129+ return lastGame;
1130+ }
1131+
11151132void LANAPI::removeGame ( LANGameInfo *game )
11161133{
11171134 LANGameInfo *g = m_games;
You can’t perform that action at this time.
0 commit comments