Files
2025-03-05 08:37:43 +01:00

146 lines
3.7 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 <iostream.h>
#include "srvworldmanager.H"
#include "mud.H"
#define WORLDSTATE_LOGIN 1
#define WORLDSTATE_QUIT 2
#define WORLDSTATE_ONLINE 3
#define WORLDSTATE_RUNNING 4
CSrvWorldManager::CSrvWorldManager(CMud * mud, CSrvWorldProtocol * protocol): CManager(protocol){
m_mud = mud;
m_state = WORLDSTATE_LOGIN;
m_numberOfClients = 0;
getProtocol()->setName("World");
getProtocol()->sendHello();
}
CSrvWorldProtocol * CSrvWorldManager::getProtocol() {
return (CSrvWorldProtocol*)CManager::getCommunicate();
}
int CSrvWorldManager::getQuit(){
return m_state == WORLDSTATE_QUIT;
}
int CSrvWorldManager::getOnLine(){
return m_state == WORLDSTATE_ONLINE;
}
int CSrvWorldManager::getRunning(){
return m_state == WORLDSTATE_RUNNING;
}
void CSrvWorldManager::setRunning(){
m_state = WORLDSTATE_RUNNING;
}
int CSrvWorldManager::getNumClients(){
return m_numberOfClients;
}
int CSrvWorldManager::addNumClients(int add){
return m_numberOfClients += add;
}
CInetAddress * CSrvWorldManager::getAddress(){
return m_worldAddress;
}
void CSrvWorldManager::quit(){
m_state = WORLDSTATE_QUIT;
m_mud->markWorld();
}
void CSrvWorldManager::login(CInetAddress * worldAddress){
static CInetAddress noAddr;
m_worldAddress = worldAddress;
m_state = WORLDSTATE_ONLINE;
m_mud->markWorld();
cdebug << "WorldSrv online at address: " << m_worldAddress->getAddressString() << "\n";
CInetAddress * gosAddr = m_mud->getGOSAddress();
if (gosAddr == NULL) gosAddr = &noAddr;
getProtocol()->sendGOSInfo(*gosAddr);
}
void CSrvWorldManager::ping( BYTE sequenceNumber){
DWORD time = m_mud->getWorld()->getTime();
cdebug << "Send pong: sequence number " << (int)sequenceNumber << " server time : " << time << endl;
getProtocol()->sendPong(sequenceNumber,time);
}
void CSrvWorldManager::sendAddWorld( CSrvWorld * world){
getProtocol()->sendAddWorld();
}
void CSrvWorldManager::sendRemoveWorld( CSrvWorld * world){
getProtocol()->sendRemoveWorld();
}
void CSrvWorldManager::sendAnimation( CWorldAnimation * animation){
getProtocol()->sendAnimation(animation);
}
/*
void CSrvWorldManager::sendAddCell( CSrvObject * cell){
getProtocol()->sendAddCell(cell);
}
void CSrvWorldManager::sendRemoveCell( CSrvObject * cell){
getProtocol()->sendRemoveCell(cell);
}
*/
void CSrvWorldManager::sendCellPVS( CSrvObject * cell){
getProtocol()->sendCellPVS(cell);
}
void CSrvWorldManager::sendAddObject( CSrvObject * object){
getProtocol()->sendAddObject(object);
}
void CSrvWorldManager::sendRemoveObject( CSrvObject * object){
getProtocol()->sendRemoveObject(object);
}
/*
void CSrvWorldManager::sendUpdatePosition( CSrvObject * object ){
getProtocol()->sendUpdatePosition(object);
}
*/
void CSrvWorldManager::sendUpdateDirection( CSrvObject * object ){
getProtocol()->sendUpdateDirection(object);
}
void CSrvWorldManager::sendUpdateHierarchy( CSrvObject * object ){
getProtocol()->sendUpdateHierarchy(object);
}