Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6251 was 6251, checked in by patrick, 18 years ago

network: debug less and client fix

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{
[6250]30  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
[6139]31  owner = 0;
32  hostID = NetworkManager::getInstance()->getHostID();
[6250]33  this->setIsServer(this->hostID == 0);
34  PRINTF(0)("sync created,id %i\n", this->hostID);
[6139]35  uniqueID = -1;
[6145]36  this->networkStream = NULL;
[5997]37  //state = ?;
38
39}
40
[5523]41
[5996]42
[5547]43/**
[5807]44 *  default destructor deletes all unneded stuff
[5547]45 */
46Synchronizeable::~Synchronizeable()
[6139]47{
48  if ( this->networkStream )
49    this->networkStream->disconnectSynchronizeable(*this);
50}
[5523]51
[5547]52/**
[5807]53 *  write data to NetworkStream
[5547]54 */
[6190]55void Synchronizeable::writeBytes(const byte* data, int length, int sender)
[6139]56{
[6251]57  PRINTF(5)("Synchronizeable::writeBytes was called\n");
[6139]58}
[5523]59
[5547]60/**
[5807]61 *  read data from NetworkStream
[5547]62 */
[6139]63int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
64{
[6251]65  PRINTF(5)("Synchronizeable::readBytes was called\n");
[6139]66}
[5547]67
68
[5807]69void Synchronizeable::writeDebug() const
70{}
[5547]71
72
[5807]73void Synchronizeable::readDebug() const
74{}
[5997]75
76
77/**
78 * Sets the server flag to a given value
79 * @param isServer: the boolean value which the server flag is to set to
80 */
81void Synchronizeable::setIsServer(bool isServer)
82{
83  if( isServer )
84    this->state = this->state | STATE_SERVER;
85  else
86    this->state = this->state & (~STATE_SERVER);
87}
88
89/**
90 * Sets the outofsync flag to a given value
91 * @param outOfSync: the boolean value which the outofsync flag is to set to
92 */
93void Synchronizeable::setIsOutOfSync(bool outOfSync)
94{
95  if( outOfSync )
96    this->state = this->state | STATE_OUTOFSYNC;
97  else
98    this->state = this->state & (~STATE_OUTOFSYNC);
99}
100
101/**
102 * Determines if the server flag is set
103 * @return true, if the server flag is true, false else
104 */
105bool Synchronizeable::isServer()
106{
107  return this->state & STATE_SERVER == STATE_SERVER;
108}
109
110/**
111 * Determines if the outofsync flag is set
112 * @return true, if the outofsync flag is true, false else
113 */
114bool Synchronizeable::isOutOfSync()
115{
116  return this->state & STATE_OUTOFSYNC == STATE_OUTOFSYNC;
117}
[6139]118
119
120
Note: See TracBrowser for help on using the repository browser.