From: Matze B. <mat...@us...> - 2002-03-04 21:33:04
|
Update of /cvsroot/planeshift/planeshift/src/common/engine In directory usw-pr-cvs1:/tmp/cvs-serv25874/src/common/engine Added Files: drmessage.h Log Message: various fixed to rpgrules --- NEW FILE: drmessage.h --- /* * drmessage.h by Matze Braun <Mat...@gm...> * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * 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 (version 2 of the License) * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef __DRMESSAGE_H__ #define __DRMESSAGE_H__ #include <csutil/databuf.h> #include "net/message.h" #define MSGTYPDRUPDATE PS_MSGID('D','R','U','D') class psDRMessage { public: psDRMessage::psDRMessage(uint32_t clientnum, iCelEntity* entity, iDataBuffer* databuff) : data(NULL) { me = new MsgEntry(sizeof(CS_ID)+databuff->GetSize(), PRIORITY_LOW); me->clientnum = clientnum; me->data->type = MSGTYPDRUPDATE; CS_ID* entityid = (CS_ID*) me->data->data; *entityid = entity->GetID(); void* data = entityid+1; // XXX: all this passing around and copying can't be fast... memcpy (data, databuff->GetData(), databuff->GetSize()); } psDRMessage::psDRMessage(const MsgEntry* me) : me(NULL) { CS_ID* entityidptr = (CS_ID*) me->data->data; entityid = *entityidptr; void* datastart = (void*) ( entityidptr+1 ); data = new csDataBuffer((char*) datastart, me->data->size - sizeof(CS_ID)); } ~psDRMessage() { if (me) me->DecRef(); if (data) data->DecRef(); } MsgEntry* me; CS_ID entityid; iDataBuffer* data; }; #endif |