Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialHS08/src/network/Host.cc @ 9215

Last change on this file since 9215 was 1751, checked in by scheusso, 16 years ago

merged network branch back into trunk

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include <assert.h>
30
31#include "Host.h"
32#include "packet/Packet.h"
33
34namespace network {
35
36Host *Host::instance_=0;
37 
38Host::Host()
39{
40  assert(instance_==0);
41  instance_=this;
42}
43
44
45Host::~Host()
46{
47  instance_=0;
48}
49
50bool Host::addPacket(ENetPacket *packet, int clientID){
51  if(instance_)
52    return instance_->queuePacket(packet, clientID);
53  else
54    return false;
55}
56
57
58// bool Host::chat(std::string& message){
59//   if(!instance_)
60//     return false;
61//   packet::Chat *c = new packet::Chat(message, getPlayerID());
62//   return instance_->sendChat(c);
63// }
64
65// bool Host::receiveChat(network::packet::Chat *message, unsigned int clientID){
66//   if(instance_)
67//     return instance_->processChat(message, clientID);
68//   else
69//     return false;
70// }
71
72int Host::getPlayerID(){ 
73  if(!instance_)
74    return 0;
75  return instance_->playerID();
76}
77
78// unsigned int Host::getShipID(){
79//   if(!instance_)
80//     assert(0);
81//   return instance_->shipID();
82// }
83
84}//namespace network
Note: See TracBrowser for help on using the repository browser.