Download this source code in text format (BigDog.h)
/***********************************************************
* 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 LogBuf;
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);
}
// Log game startup
Log::OpenLogFile();
LogBuf = "WindowMud version 0.0 has started";
Log::LogIt(LogBuf);
LogBuf = "Home directory is ";
LogBuf += HomeDir;
Log::LogIt(LogBuf);
// Initialize
StateRunning = true;
// Game loop
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;
}
}
// Game has stopped so clean up
LogBuf = "WindowMud has stopped";
Log::LogIt(LogBuf);
Log::CloseLogFile();
}