WindowMud

BigDog.cpp Source Code

Download this source code in text format (BigDog.cpp)

/***********************************************************
* WindowMud - Window Mud Server                            *
* File:   BigDog.cpp                                       *
* Usage:  Game loop                                        *
*                                                          *
* No warranty is given or implied.                         *
* There is no license associated with this code.           *
* There are no restrictions on the use of this code.       *
* This code may be used in any way the reader wishes.      *
* No credit or credits are given and none are required.    *
* The reader may take this code and claim they wrote it.   *
************************************************************/

/***********************************************************
* Includes                                                 *
************************************************************/

#include "stdafx.h"         // precompiled headers
#include "BigDog.h"

/***********************************************************
* Globals                                                  *
************************************************************/

extern CString HomeDir;

bool      StateRunning;

/***********************************************************
 * BigDog The dog, the whole dog, and nothing but the dog  *
 ***********************************************************/

void BigDog()
{
  CString      GoGoGoFileName;
  CFileStatus  FileStatus;
  CString      StopItFileName;

  if (_chdir(HomeDir))
  { // Change directory failed
    AfxMessageBox("BigDog - Change directory to HomeDir failed", MB_ICONSTOP);
    _endthread();
  }
  // Set Go Stop, force go status
  StopItFileName  = CONTROL_DIR;
  StopItFileName += "StopIt";
  GoGoGoFileName  = CONTROL_DIR;
  GoGoGoFileName += "GoGoGo";
  if (CFile::GetStatus(StopItFileName, FileStatus))
  { // If StopIt file exists, Rename it to GoGoGo
    CFile::Rename(StopItFileName, GoGoGoFileName);
  }
  // Initialize
  StateRunning     = true;
  while (StateRunning)
  { // Game runs until it is stopped
    Sleep(MILLI_SECONDS_TO_SLEEP);
    if (CFile::GetStatus(StopItFileName, FileStatus))
    { // StopIt file was found, Stop the game
      StateRunning = false;
    }
  }
}