136 lines
4.3 KiB
C
136 lines
4.3 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 "srvworldprotocol.H"
|
|
#include "srvworldmanager.H"
|
|
#include "srvworldmessage.H"
|
|
#include "msgsrvcli.H"
|
|
#include "msgworld.H"
|
|
|
|
CSrvWorldProtocol::CSrvWorldProtocol(CSocket * socket, CTimeKeeper * timeKeeper)
|
|
:CCommunicate(socket,timeKeeper){
|
|
addMsg((MsgCreateFunc_t)CMsgSrvWorldLogin::createMsg);
|
|
addMsg((MsgCreateFunc_t)CMsgSrvWorldPing::createMsg);
|
|
}
|
|
|
|
void CSrvWorldProtocol::quit(){
|
|
CSrvWorldManager * manager = (CSrvWorldManager*)getManager();
|
|
manager->quit();
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendHello(){
|
|
CMsgHello * msg = new CMsgHello(PROTOCOL_VERSION);
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendGOSInfo(CInetAddress & gosAddr){
|
|
CMsgGOSInfo * msg = new CMsgGOSInfo(gosAddr);
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendPong( BYTE sequenceNumber, DWORD serverTime ){
|
|
CMsgPong * msg = new CMsgPong(sequenceNumber,serverTime);
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendAnimation(CWorldAnimation * animation){
|
|
CMessage * msg = animation->createMessage();
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendAddWorld(){
|
|
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_ADDWORLD);
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendRemoveWorld(){
|
|
CMsgCommand * msg = new CMsgCommand(MSGCOMMAND_REMOVEWORLD);
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
/*
|
|
void CSrvWorldProtocol::sendAddCell( CSrvObject * cell ){
|
|
// Send cell
|
|
CMsgCell * msg = new CMsgCell( cell->getId(),cell->getGeometryId(),
|
|
CPosition(0,0,0) );
|
|
sendMessage(msg,TRUE);
|
|
|
|
// Send PVS
|
|
sendCellPVS( cell );
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendRemoveCell( CSrvObject * cell ){
|
|
CMsgRemoveCell* msg = new CMsgRemoveCell(cell->getId());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
*/
|
|
|
|
void CSrvWorldProtocol::sendCellPVS( CSrvObject * cell ){
|
|
CObjectListItem * item = cell->getPVS()->getFirstPVCell();
|
|
while (item != NULL){
|
|
CPVCell * pvCell = (CPVCell*)item->getObject();
|
|
item = item->getNext();
|
|
CMsgPVCell * msg = new CMsgPVCell( cell->getObjectId(),
|
|
pvCell->getCellId(),
|
|
pvCell->getPosition());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendAddObject( CSrvObject * object){
|
|
CMsgObject * msg = new CMsgObject( object->getObjectId(),
|
|
object->getGeometryId(),
|
|
object->getParentId(),
|
|
object->getPosition(),
|
|
object->getDirection());
|
|
sendMessage(msg,TRUE);
|
|
|
|
if (object->getPVS() != NULL) sendCellPVS( object );
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendRemoveObject( CSrvObject * object){
|
|
CMsgRemoveObject * msg = new CMsgRemoveObject( object->getObjectId(),
|
|
object->getParentId());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
/*
|
|
void CSrvWorldProtocol::sendUpdatePosition( CSrvObject * object ){
|
|
CMsgUpdatePosition * msg = new CMsgUpdatePosition(object->getObjectId(),
|
|
object->getPosition());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
*/
|
|
|
|
void CSrvWorldProtocol::sendUpdateDirection( CSrvObject * object ){
|
|
CMsgUpdateDirection * msg = new CMsgUpdateDirection(object->getObjectId(),
|
|
object->getDirection());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
void CSrvWorldProtocol::sendUpdateHierarchy( CSrvObject * object ){
|
|
CMsgUpdateHierarchy * msg = new CMsgUpdateHierarchy(object->getObjectId(),
|
|
object->getParentId());
|
|
sendMessage(msg,TRUE);
|
|
}
|
|
|
|
|
|
|