342 lines
8.1 KiB
C
342 lines
8.1 KiB
C
/*
|
|
* PVVMUD a 3D MUD
|
|
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
|
*
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
#include "pvvmud.H"
|
|
#include "msgworld.H"
|
|
#include "position.H"
|
|
#include "direction.H"
|
|
|
|
/*
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgSection
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgSection::CMsgSection():CMessage(MSG_SECTION,sizeof(DWORD)+sizeof(BYTE)){
|
|
setName("MsgSection");
|
|
}
|
|
|
|
CMsgSection::CMsgSection( DWORD sectionId, BOOL create )
|
|
:CMessage(MSG_SECTION,sizeof(DWORD) + sizeof(BYTE)){
|
|
|
|
setName("MsgSection");
|
|
writeDWord(1,sectionId);
|
|
writeByte(5,create);
|
|
}
|
|
|
|
DWORD CMsgSection::getSectionId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
BOOL CMsgSection::getCreate(){
|
|
return readByte(5);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgCell
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgCell::CMsgCell():CMessage(MSG_CELL,5*sizeof(DWORD)){
|
|
setName("MsgCell");
|
|
}
|
|
|
|
CMsgCell::CMsgCell( DWORD cellId, DWORD geometryId,
|
|
const CPosition & position):CMessage(MSG_CELL,5*sizeof(DWORD)){
|
|
|
|
setName("MsgCell");
|
|
writeDWord(1,cellId);
|
|
writeDWord(5,geometryId);
|
|
writePosition(9,position);
|
|
}
|
|
|
|
DWORD CMsgCell::getCellId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
DWORD CMsgCell::getGeometryId(){
|
|
return readDWord(5);
|
|
}
|
|
|
|
CPosition CMsgCell::getPosition(){
|
|
return readPosition(9);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgRemoveCell
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgRemoveCell::CMsgRemoveCell():CMessage(MSG_REMOVECELL,1*sizeof(DWORD)){
|
|
setName("MsgRemoveCell");
|
|
}
|
|
|
|
CMsgRemoveCell::CMsgRemoveCell( DWORD cellId )
|
|
:CMessage(MSG_REMOVECELL,1*sizeof(DWORD)){
|
|
|
|
setName("MsgRemoveCell");
|
|
writeDWord(1,cellId);
|
|
}
|
|
|
|
DWORD CMsgRemoveCell::getCellId(){
|
|
return readDWord(1);
|
|
}
|
|
*/
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgObject
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgObject::CMsgObject():CMessage(MSG_OBJECT,9*sizeof(DWORD)){
|
|
setName("MsgObject");
|
|
}
|
|
|
|
CMsgObject::CMsgObject( DWORD objectId, DWORD geometryId, DWORD parentId,
|
|
const CPosition & position,
|
|
const CDirection & direction ):CMessage(MSG_OBJECT,9*sizeof(DWORD)){
|
|
|
|
setName("MsgObject");
|
|
writeDWord(1,objectId);
|
|
writeDWord(5,geometryId);
|
|
writeDWord(9,parentId);
|
|
writePosition(13,position);
|
|
writeDirection(25,direction);
|
|
}
|
|
|
|
DWORD CMsgObject::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
DWORD CMsgObject::getGeometryId(){
|
|
return readDWord(5);
|
|
}
|
|
|
|
DWORD CMsgObject::getParentId(){
|
|
return readDWord(9);
|
|
}
|
|
|
|
CPosition CMsgObject::getPosition(){
|
|
return readPosition(13);
|
|
}
|
|
|
|
CDirection CMsgObject::getDirection(){
|
|
return readDirection(25);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgRemoveObject
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgRemoveObject::CMsgRemoveObject():CMessage(MSG_REMOVEOBJECT,2*sizeof(DWORD)){
|
|
setName("MsgRemoveObject");
|
|
}
|
|
|
|
CMsgRemoveObject::CMsgRemoveObject( DWORD objectId,
|
|
DWORD parentId ):CMessage(MSG_REMOVEOBJECT,2*sizeof(DWORD)){
|
|
|
|
setName("MsgRemoveObject");
|
|
writeDWord(1,objectId);
|
|
writeDWord(5,parentId);
|
|
}
|
|
|
|
DWORD CMsgRemoveObject::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
DWORD CMsgRemoveObject::getParentId(){
|
|
return readDWord(5);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgChangeMasterCell
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgChangeMasterCell::CMsgChangeMasterCell():CMessage(MSG_CHANGEMASTERCELL,sizeof(DWORD)){
|
|
setName("MsgChangeMasterCell");
|
|
}
|
|
|
|
CMsgChangeMasterCell::CMsgChangeMasterCell( DWORD newMasterCellId)
|
|
:CMessage(MSG_CHANGEMASTERCELL,sizeof(DWORD)){
|
|
|
|
setName("MsgChangeMasterCell");
|
|
writeDWord(1,newMasterCellId);
|
|
}
|
|
|
|
DWORD CMsgChangeMasterCell::getNewMasterCellId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgPVCell
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgPVCell::CMsgPVCell():CMessage(MSG_PVCELL,5*sizeof(DWORD)){
|
|
setName("MsgPVCell");
|
|
}
|
|
|
|
CMsgPVCell::CMsgPVCell( DWORD cellId, DWORD PVCellId,
|
|
const CPosition & position ):CMessage(MSG_PVCELL,5*sizeof(DWORD)){
|
|
|
|
setName("MsgPVCell");
|
|
writeDWord(1,cellId);
|
|
writeDWord(5,PVCellId);
|
|
for (int ii = 0; ii < 3; ii++){
|
|
writeDouble(9+ii*4,position.getValue(ii));
|
|
}
|
|
}
|
|
|
|
DWORD CMsgPVCell::getCellId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
DWORD CMsgPVCell::getPVCellId(){
|
|
return readDWord(5);
|
|
}
|
|
|
|
CPosition CMsgPVCell::getPosition(){
|
|
return CPosition(readDouble(9),readDouble(13),readDouble(17));
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgUpdatePosition
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgUpdatePosition::CMsgUpdatePosition()
|
|
:CMessage(MSG_UPDATEPOSITION,4*sizeof(DWORD)){
|
|
|
|
setName("MsgUpdatePosition");
|
|
}
|
|
|
|
CMsgUpdatePosition::CMsgUpdatePosition(DWORD objectId,const CPosition& position)
|
|
:CMessage(MSG_UPDATEPOSITION,sizeof(DWORD)*4){
|
|
|
|
setName("MsgUpdatePosition");
|
|
writeDWord(1,objectId);
|
|
writePosition(5,position);
|
|
}
|
|
|
|
DWORD CMsgUpdatePosition::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
CPosition CMsgUpdatePosition::getPosition(){
|
|
return readPosition(5);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgUpdateDirection
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgUpdateDirection::CMsgUpdateDirection()
|
|
:CMessage(MSG_UPDATEDIRECTION,4*sizeof(DWORD)){
|
|
|
|
setName("MsgUpdateDirection");
|
|
}
|
|
|
|
CMsgUpdateDirection::CMsgUpdateDirection(DWORD objectId,const CDirection& direction):CMessage(MSG_UPDATEDIRECTION, 4*sizeof(DWORD)){
|
|
|
|
setName("MsgUpdateDirection");
|
|
writeDWord(1,objectId);
|
|
writeDirection(5,direction);
|
|
}
|
|
|
|
DWORD CMsgUpdateDirection::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
CDirection CMsgUpdateDirection::getDirection(){
|
|
return readDirection(5);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgUpdateHierarchy
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgUpdateHierarchy::CMsgUpdateHierarchy()
|
|
:CMessage(MSG_UPDATEHIERARCHY,2*sizeof(DWORD)){
|
|
|
|
setName("MsgUpdateHierarchy");
|
|
}
|
|
|
|
CMsgUpdateHierarchy::CMsgUpdateHierarchy(DWORD objectId, DWORD parentId):CMessage(MSG_UPDATEHIERARCHY, 2*sizeof(DWORD)){
|
|
|
|
setName("MsgUpdateHierarchy");
|
|
writeDWord(1,objectId);
|
|
writeDWord(5,parentId);
|
|
}
|
|
|
|
DWORD CMsgUpdateHierarchy::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
DWORD CMsgUpdateHierarchy::getParentId(){
|
|
return readDWord(5);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// CMsgRotate
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
CMsgRotate::CMsgRotate()
|
|
:CMessage(MSG_ROTATE,4*sizeof(DWORD)){
|
|
|
|
setName("MsgRotate");
|
|
}
|
|
|
|
CMsgRotate::CMsgRotate(DWORD objectId, const CDirection& angleSpeed):CMessage(MSG_ROTATE, 4*sizeof(DWORD)){
|
|
|
|
setName("MsgRotate");
|
|
writeDWord(1,objectId);
|
|
writeDirection(5,angleSpeed);
|
|
}
|
|
|
|
DWORD CMsgRotate::getObjectId(){
|
|
return readDWord(1);
|
|
}
|
|
|
|
CDirection CMsgRotate::getAngleSpeed(){
|
|
return readDirection(5);
|
|
}
|
|
|
|
|