Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/christmas_branche/src/lib/network/synchronizeable.cc @ 6203

Last change on this file since 6203 was 6145, checked in by patrick, 19 years ago

trunk: fixed the network bug, uninitialized variable :D

File size: 2.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11
12### File Specific:
13   main-programmer: Silvan Nellen
14   co-programmer: Benjamin Wuest
15*/
16
17#define DEBUG_MODULE_NETWORK
18
19#include "synchronizeable.h"
20#include "netdefs.h"
21#include "network_manager.h"
22#include "network_stream.h"
23
24
25/**
26 *  default constructor
27 */
28Synchronizeable::Synchronizeable()
29{
30
31  owner = 0;
32  hostID = NetworkManager::getInstance()->getHostID();
33  uniqueID = -1;
34  this->networkStream = NULL;
35  //state = ?;
36
37}
38
39/**
40 *  default constructor
41 */
42Synchronizeable::Synchronizeable(const char* name)
43{
44  this->setName(name);
45  this->networkStream = NULL;
46}
47
48
49/**
50 *  default destructor deletes all unneded stuff
51 */
52Synchronizeable::~Synchronizeable()
53{
54  if ( this->networkStream )
55    this->networkStream->disconnectSynchronizeable(*this);
56}
57
58/**
59 *  write data to NetworkStream
60 */
61void Synchronizeable::writeBytes(const byte* data, int length)
62{
63  PRINTF(1)("Synchronizeable::writeBytes was called\n");
64}
65
66/**
67 *  read data from NetworkStream
68 */
69int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
70{
71  PRINTF(1)("Synchronizeable::readBytes was called\n");
72}
73
74
75void Synchronizeable::writeDebug() const
76{}
77
78
79void Synchronizeable::readDebug() const
80{}
81
82
83/**
84 * Sets the server flag to a given value
85 * @param isServer: the boolean value which the server flag is to set to
86 */
87void Synchronizeable::setIsServer(bool isServer)
88{
89  if( isServer )
90    this->state = this->state | STATE_SERVER;
91  else
92    this->state = this->state & (~STATE_SERVER);
93}
94
95/**
96 * Sets the outofsync flag to a given value
97 * @param outOfSync: the boolean value which the outofsync flag is to set to
98 */
99void Synchronizeable::setIsOutOfSync(bool outOfSync)
100{
101  if( outOfSync )
102    this->state = this->state | STATE_OUTOFSYNC;
103  else
104    this->state = this->state & (~STATE_OUTOFSYNC);
105}
106
107/**
108 * Determines if the server flag is set
109 * @return true, if the server flag is true, false else
110 */
111bool Synchronizeable::isServer()
112{
113  return this->state & STATE_SERVER == STATE_SERVER;
114}
115
116/**
117 * Determines if the outofsync flag is set
118 * @return true, if the outofsync flag is true, false else
119 */
120bool Synchronizeable::isOutOfSync()
121{
122  return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
123}
124
125
126
Note: See TracBrowser for help on using the repository browser.