/* This file is part of the TDE games library Copyright (C) 2001 Martin Heni (martin@heni-online.de) Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __KGAMEPROPERTYARRAY_H_ #define __KGAMEPROPERTYARRAY_H_ #include #include #include "kgamemessage.h" #include "kgameproperty.h" #include "kgamepropertyhandler.h" template class KGamePropertyArray : public TQMemArray, public KGamePropertyBase { public: KGamePropertyArray() :TQMemArray(), KGamePropertyBase() { //kdDebug(11001) << "KGamePropertyArray init" << endl; } KGamePropertyArray( int size ) { resize(size); } KGamePropertyArray( const KGamePropertyArray &a ) : TQMemArray(a) { } bool resize( uint size ) { if (size!=TQMemArray::size()) { bool a=true; TQByteArray b; TQDataStream s(b, IO_WriteOnly); KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,id(),CmdResize); s << size ; if (policy()==PolicyClean || policy()==PolicyDirty) { if (mOwner) { mOwner->sendProperty(s); } } if (policy()==PolicyLocal || policy()==PolicyDirty) { extractProperty(b); // a=TQMemArray::resize(size);// FIXME: return value! } return a; } else return true; } void setAt(uint i,type data) { TQByteArray b; TQDataStream s(b, IO_WriteOnly); KGameMessage::createPropertyCommand(s,KGamePropertyBase::IdCommand,id(),CmdAt); s << i ; s << data; if (policy()==PolicyClean || policy()==PolicyDirty) { if (mOwner) { mOwner->sendProperty(s); } } if (policy()==PolicyLocal || policy()==PolicyDirty) { extractProperty(b); } //kdDebug(11001) << "KGamePropertyArray setAt send COMMAND for id="<::size(); i++) { s >> data; TQMemArray::at(i)=data; } if (isEmittingSignal()) { emitSignal(); } } void save(TQDataStream &s) { //kdDebug(11001) << "KGamePropertyArray save "<::size(); i++) { s << at(i); } } void command(TQDataStream &s,int cmd,bool) { KGamePropertyBase::command(s, cmd); //kdDebug(11001) << "Array id="<> i >> data; TQMemArray::at(i)=data; //kdDebug(11001) << "CmdAt:id="<