Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

network: network game manager now sounds good

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  this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
31  owner = 0;
32  hostID = NetworkManager::getInstance()->getHostID();
33  this->setIsServer(this->hostID == 0);
34  PRINTF(0)("sync created,id %i\n", this->hostID);
35  uniqueID = -1;
36  this->networkStream = NULL;
37  //state = ?;
38
39}
40
41
42
43/**
44 *  default destructor deletes all unneded stuff
45 */
46Synchronizeable::~Synchronizeable()
47{
48  if ( this->networkStream )
49    this->networkStream->disconnectSynchronizeable(*this);
50}
51
52/**
53 *  write data to NetworkStream
54 */
55void Synchronizeable::writeBytes(const byte* data, int length, int sender)
56{
57  PRINTF(1)("Synchronizeable::writeBytes was called\n");
58}
59
60/**
61 *  read data from NetworkStream
62 */
63int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
64{
65  PRINTF(1)("Synchronizeable::readBytes was called\n");
66}
67
68
69void Synchronizeable::writeDebug() const
70{}
71
72
73void Synchronizeable::readDebug() const
74{}
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}
118
119
120
Note: See TracBrowser for help on using the repository browser.