[Orxonox-commit 695] r3227 - in branches/netp6/src: network network/synchronisable util
scheusso at orxonox.net
scheusso at orxonox.net
Tue Jun 23 20:53:51 CEST 2009
Author: scheusso
Date: 2009-06-23 20:53:51 +0200 (Tue, 23 Jun 2009)
New Revision: 3227
Removed:
branches/netp6/src/network/PacketBuffer.cc
branches/netp6/src/network/PacketBuffer.h
Modified:
branches/netp6/src/network/CMakeLists.txt
branches/netp6/src/network/GamestateClient.cc
branches/netp6/src/network/GamestateClient.h
branches/netp6/src/network/GamestateManager.cc
branches/netp6/src/network/NetworkPrereqs.h
branches/netp6/src/network/synchronisable/Synchronisable.h
branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc
branches/netp6/src/util/Serialise.h
Log:
some cleaning up and memory leak fixes
Modified: branches/netp6/src/network/CMakeLists.txt
===================================================================
--- branches/netp6/src/network/CMakeLists.txt 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/CMakeLists.txt 2009-06-23 18:53:51 UTC (rev 3227)
@@ -30,7 +30,6 @@
GamestateHandler.cc
NetworkFunction.cc
Host.cc
- PacketBuffer.cc
Server.cc
ServerConnection.cc
TrafficControl.cc
Modified: branches/netp6/src/network/GamestateClient.cc
===================================================================
--- branches/netp6/src/network/GamestateClient.cc 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/GamestateClient.cc 2009-06-23 18:53:51 UTC (rev 3227)
@@ -51,6 +51,11 @@
}
GamestateClient::~GamestateClient() {
+ std::map<unsigned int, packet::Gamestate *>::iterator it;
+ for ( it = this->gamestateMap_.begin(); it != this->gamestateMap_.end(); ++it )
+ delete (*it).second;
+ if( this->tempGamestate_ )
+ delete this->tempGamestate_;
}
bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
Modified: branches/netp6/src/network/GamestateClient.h
===================================================================
--- branches/netp6/src/network/GamestateClient.h 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/GamestateClient.h 2009-06-23 18:53:51 UTC (rev 3227)
@@ -72,7 +72,6 @@
unsigned int last_gamestate_;
std::map<unsigned int, packet::Gamestate *> gamestateMap_;
packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
- unsigned char *shipCache_;
};
Modified: branches/netp6/src/network/GamestateManager.cc
===================================================================
--- branches/netp6/src/network/GamestateManager.cc 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/GamestateManager.cc 2009-06-23 18:53:51 UTC (rev 3227)
@@ -60,9 +60,16 @@
GamestateManager::~GamestateManager()
{
if( this->reference )
- delete this->reference;
- for( std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.begin(); it != gamestateQueue.end(); it++ )
+ delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it;
+ for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
delete (*it).second;
+ std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1;
+ std::map<unsigned int, packet::Gamestate*>::iterator it2;
+ for( it1 = gamestateMap_.begin(); it1 != gamestateMap_.end(); ++it1 )
+ {
+ for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
+ delete (*it2).second;
+ }
delete trafficControl_;
}
Modified: branches/netp6/src/network/NetworkPrereqs.h
===================================================================
--- branches/netp6/src/network/NetworkPrereqs.h 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/NetworkPrereqs.h 2009-06-23 18:53:51 UTC (rev 3227)
@@ -101,7 +101,6 @@
class NetworkMemberFunctionBase;
template <class T> class NetworkMemeberFunction;
struct NetworkFunctionPointer;
- class PacketBuffer;
class Server;
class ServerConnection;
class ServerFrameListener;
Deleted: branches/netp6/src/network/PacketBuffer.cc
===================================================================
--- branches/netp6/src/network/PacketBuffer.cc 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/PacketBuffer.cc 2009-06-23 18:53:51 UTC (rev 3227)
@@ -1,146 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * 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
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Oliver Scheuss, (C) 2007
- * Co-authors:
- * ...
- *
- */
-
-// C++ PacketBuffer
-// d
-// Author Oliver Scheuss
-
-#include "PacketBuffer.h"
-
-//#include <iostream>
-#include <boost/thread/recursive_mutex.hpp>
-
-namespace orxonox
-{
- static boost::recursive_mutex packetBuffer_mutex_g;
-
- PacketBuffer::PacketBuffer() {
- closed=false;
- first=NULL;
- last=NULL;
- }
- //this is needed in order to make the packetbuffer threadsafe
-
-
- bool PacketBuffer::push(ENetEvent *ev) {
- boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
- //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
- // if(closed)
- // return false;
- // first element?
- if(first==NULL){
- first=new QueueItem;
- last=first;
- last->next=NULL;
- // change this!!!!!!! ---- we are not doing stl so we won't change this
- last->event = ev;
- //last->address = ev->peer->address;
- } else {
- //insert a new element at the bottom
- last->next = new QueueItem;
- last=last->next;
- // initialize last->next
- last->next=NULL;
- // save the packet to the new element
- last->event = ev;
- //last->address = ev->peer->address;
- }
- lock.unlock();
- return true;
- }
-
- //returns the first element in the list without deleting it but
- //moving first pointer to next element
- /*ENetPacket *PacketBuffer::pop() {
- ENetAddress address;
- return pop(address);
- }*/
-
- ENetEvent *PacketBuffer::pop(){
- boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
- //std::cout << "packetbuffer pop(address)" << std::endl;
- if(first!=NULL /*&& !closed*/){
- QueueItem *temp = first;
- // get packet
- ENetEvent *ev=first->event;
- //address = first->address;
- // remove first element
- first = first->next;
- delete temp;
- lock.unlock();
- //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
- return ev;
- } else{
- lock.unlock();
- return NULL;
- }
- }
-
- /*ENetPacket *PacketBuffer::pop(ENetAddress &address) {
- boost::recursive_mutex::scoped_lock lock(packetBuffer_mutex_g);
- //std::cout << "packetbuffer pop(address)" << std::endl;
- if(first!=NULL ){
- QueueItem *temp = first;
- // get packet
- ENetPacket *pck=first->event->packet;
- address = first->event->peer->address;
- // remove first element
- first = first->next;
- delete temp;
- lock.unlock();
- //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
- return pck;
- } else{
- lock.unlock();
- return NULL;
- }
- }*/
-
- bool PacketBuffer::isEmpty() {
- return (first==NULL);
- }
-
- void PacketBuffer::print() {
- QueueItem *temp=first;
- while(temp!=NULL){
- // std::cout << temp->packet->data << std::endl;
- temp=temp->next;
- }
-
- }
-
- bool PacketBuffer::isClosed() {
- return closed;
- }
-
- void PacketBuffer::setClosed(bool value){
- closed=value;
- return;
- }
-
-} // namespace orxonox
Deleted: branches/netp6/src/network/PacketBuffer.h
===================================================================
--- branches/netp6/src/network/PacketBuffer.h 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/PacketBuffer.h 2009-06-23 18:53:51 UTC (rev 3227)
@@ -1,80 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * 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
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Oliver Scheuss, (C) 2007
- * Co-authors:
- * ...
- *
- */
-
-//
-// C++ Interface: PacketBuffer
-//
-// Description:
-//
-//
-// Author: Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#ifndef _PacketBuffer_H__
-#define _PacketBuffer_H__
-
-#include "NetworkPrereqs.h"
-
-namespace orxonox
-{
- struct _NetworkExport PacketEnvelope{
- int length;
- int data;
- };
-
- struct _NetworkExport QueueItem{
- ENetEvent *event;
- //ENetAddress address;
- QueueItem *next;
- };
-
- class _NetworkExport PacketBuffer{
- public:
- PacketBuffer();
- bool isEmpty();
- bool isClosed();
- void setClosed(bool value);
- void print();
- // pops a packet from the queue
- //ENetPacket *pop();
- //ENetPacket *pop(ENetAddress &address);
- ENetEvent *pop();
- // pushs a packet to the queue
- bool push(ENetEvent *ev);
-
- private:
- QueueItem *first;
- QueueItem *last;
- bool closed;
- };
-
-} //namespace
-#endif /* _PacketBuffer_H__ */
Modified: branches/netp6/src/network/synchronisable/Synchronisable.h
===================================================================
--- branches/netp6/src/network/synchronisable/Synchronisable.h 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/synchronisable/Synchronisable.h 2009-06-23 18:53:51 UTC (rev 3227)
@@ -42,10 +42,6 @@
#include "SynchronisableVariable.h"
#include "NetworkCallback.h"
-/*#define REGISTERDATA(varname, ...) \
- registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
-#define REGISTERSTRING(stringname, ...) \
- registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/
namespace orxonox
{
Modified: branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc 2009-06-23 18:53:51 UTC (rev 3227)
@@ -72,10 +72,6 @@
registerVariable(variable.x, mode, cb, bidirectional);
registerVariable(variable.y, mode, cb, bidirectional);
}
-// template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
-// {
-// registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
-// }
template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
{
Modified: branches/netp6/src/util/Serialise.h
===================================================================
--- branches/netp6/src/util/Serialise.h 2009-06-23 18:53:34 UTC (rev 3226)
+++ branches/netp6/src/util/Serialise.h 2009-06-23 18:53:51 UTC (rev 3227)
@@ -407,13 +407,14 @@
template <> inline void loadAndIncrease( const std::string& variable, uint8_t*& mem )
{
- *(std::string*)( &variable ) = std::string((const char *)mem);
+ *(std::string*)( &variable ) = (const char *)mem;
mem += variable.length()+1;
}
template <> inline bool checkEquality( const std::string& variable, uint8_t* mem )
{
- return std::string((const char*)mem)==variable;
+ //return std::string((const char*)mem)==variable;
+ return (const char*)mem==variable;
}
// =========== Degree
More information about the Orxonox-commit
mailing list