/*
 * 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 "server.H"
#include <signal.h>
#include <sys/time.h>
#include <iostream.h>
#include "mudpvvmud.H"
#include "option.H"

CMudPVVMud * pvvmud;

void sigint(int signum){
  cdebug << "Received a SIGINT shuting down the server!\n";
  pvvmud->stop();
}

int main(int argc, char *argv[] ){
  COption option;

  // port
  //   The port that clients are to connect to the server
  option.setValue("port",'p',SERVER_CLIENT_PORT);

  // gos_port
  //   The port that gos server are to connect to the server
  option.setValue("gos_port",'g',SERVER_GOS_PORT);

  // world_port
  //   The port that world server are to connect to the server
  option.setValue("world_port",'w',SERVER_WORLDSRV_PORT);
  
  // world_lib_path
  //   The path where the server search for a world file. This world file
  //   control loading of the game world.
  option.setValue("world_lib_path",'l',"../mudworld");

  // userdb
  //   The file name for the user DB
  option.setValue("userdb",'u',"userdb.dat");

  option.loadOption("server.conf");
  option.parseArguments(argc,argv);

  pvvmud = new CMudPVVMud(&option);

  // Installing signal handler
  signal(SIGINT, sigint );     // Shuting down the server on sigint
  signal(SIGPIPE, SIG_IGN );

  pvvmud->run();

  delete pvvmud;

  return 0;
}