/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput */ #define DEBUG_MODULE_NETWORK #include "simple_sync.h" #include "debug.h" /** * default constructor */ SimpleSync::SimpleSync() : Synchronizeable() { this->outLength = 10; this->inLength = 40; this->outData = new byte[this->outLength]; this->inData = new byte[this->inLength]; for( int i = 0; i < this->outLength; i++) { this->outData[i] = i; } } /** * default destructor deletes all unneded stuff */ SimpleSync::~SimpleSync() { } /** * write data to Synchronizeable */ void SimpleSync::writeBytes(byte* data, int length) { if(this->inLength < length) PRINTF(0)("ERROR: local buffer is smaller than the data to receive.\n"); /* copy the data localy */ for( int i = 0; i < this->inLength; i++) { this->inData[i] = data[i]; } /* and debug output */ this->writeDebug(); } /** * read data from Synchronizeable */ int SimpleSync::readBytes(byte* data) { /* write the test message */ data = this->outData; /* debug msg */ this->readDebug(); /* return the length of the test */ return this->outLength; } void SimpleSync::writeDebug() { PRINTF(0)("Write in: |"); for(int i = 0; i < this->inLength; i++) { PRINT(0)(" %i ",this->inData[i]); } PRINT(0)("|\n"); } void SimpleSync::readDebug() { PRINTF(0)("Read out: |"); for(int i = 0; i < this->outLength; i++) { PRINT(0)(" %i ",this->outData[i]); } PRINT(0)("|\n"); }