Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/synchronizeable.cc @ 6191

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

trunk: fixed the network bug, uninitialized variable :D

File size: 2.5 KB
RevLine 
[5523]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
[5547]11
[5523]12### File Specific:
13   main-programmer: Silvan Nellen
[5997]14   co-programmer: Benjamin Wuest
[5547]15*/
[5523]16
[6139]17#define DEBUG_MODULE_NETWORK
18
[5547]19#include "synchronizeable.h"
20#include "netdefs.h"
[6139]21#include "network_manager.h"
22#include "network_stream.h"
[5529]23
[5996]24
[5547]25/**
[5807]26 *  default constructor
[5547]27 */
[5996]28Synchronizeable::Synchronizeable()
[5997]29{
[5996]30
[6139]31  owner = 0;
32  hostID = NetworkManager::getInstance()->getHostID();
33  uniqueID = -1;
[6145]34  this->networkStream = NULL;
[5997]35  //state = ?;
36
37}
38
[5996]39/**
40 *  default constructor
41 */
[5804]42Synchronizeable::Synchronizeable(const char* name)
[5523]43{
[5807]44  this->setName(name);
[6145]45  this->networkStream = NULL;
[5523]46}
47
[5996]48
[5547]49/**
[5807]50 *  default destructor deletes all unneded stuff
[5547]51 */
52Synchronizeable::~Synchronizeable()
[6139]53{
54  if ( this->networkStream )
55    this->networkStream->disconnectSynchronizeable(*this);
56}
[5523]57
[5547]58/**
[5807]59 *  write data to NetworkStream
[5547]60 */
[5807]61void Synchronizeable::writeBytes(const byte* data, int length)
[6139]62{
63  PRINTF(1)("Synchronizeable::writeBytes was called\n");
64}
[5523]65
[5547]66/**
[5807]67 *  read data from NetworkStream
[5547]68 */
[6139]69int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
70{
71  PRINTF(1)("Synchronizeable::readBytes was called\n");
72}
[5547]73
74
[5807]75void Synchronizeable::writeDebug() const
76{}
[5547]77
78
[5807]79void Synchronizeable::readDebug() const
80{}
[5997]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}
[6139]124
125
126
Note: See TracBrowser for help on using the repository browser.