⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
📖 第 1 页 / 共 2 页
字号:
/// TGE_RPGClient2 增加RPGGame接口管理,把游戏接口分离为demoGame、RPGGame等
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#include "platform/platform.h"
#include "platform/platformVideo.h"
#include "platform/platformInput.h"
#include "platform/platformAudio.h"
#include "platform/event.h"
#include "platform/gameInterface.h"
#include "core/tVector.h"
#include "core/chunkFile.h"
#include "math/mMath.h"
#include "dgl/dgl.h"
#include "dgl/gBitmap.h"
#include "core/resManager.h"
#include "core/fileStream.h"
#include "dgl/gTexManager.h"
#include "dgl/gFont.h"
#include "console/console.h"
#include "console/simBase.h"
#include "gui/core/guiCanvas.h"
#include "sim/actionMap.h"
#include "core/dnet.h"
#include "game/game.h"
#include "core/bitStream.h"
#include "console/telnetConsole.h"
#include "console/telnetDebugger.h"
#include "console/consoleTypes.h"
#include "math/mathTypes.h"
#include "dgl/gTexManager.h"
#include "core/resManager.h"
#include "interior/interiorRes.h"
#include "interior/interiorInstance.h"
#include "interior/interiorMapRes.h"
#include "ts/tsShapeInstance.h"
#include "terrain/terrData.h"
#include "terrain/terrRender.h"
#include "editor/terraformer.h"
#include "sceneGraph/sceneGraph.h"
#include "dgl/materialList.h"
#include "sceneGraph/sceneRoot.h"
#include "game/moveManager.h"
#include "platform/platformVideo.h"
#include "dgl/materialPropertyMap.h"
#include "sim/netStringTable.h"
#include "sim/pathManager.h"
#include "game/gameFunctions.h"
#include "game/fx/particleEngine.h"
#include "platform/platformRedBook.h"
#include "sim/decalManager.h"
#include "core/frameAllocator.h"
#include "sceneGraph/detailManager.h"
#include "interior/interiorLMManager.h"
#include "game/version.h"
#include "platform/profiler.h"
#include "game/shapeBase.h"
#include "game/objectTypes.h"
#include "game/net/serverQuery.h"
#include "game/badWordFilter.h"

#ifdef TGE_RPG /// TGE_Map
#include "game/WorldWall.h"//
#include "rpg/RPGEngine.h"
#endif

#ifdef TGE_RPGCLIENT
#include "platform/platformIME.h" //IME
#endif

#ifdef TGE_RPG
#include "server/SocketLayer.h"
#endif





/// TGE_TerrainScene
extern ResourceInstance *constructTerrainScene(Stream &stream);

extern ResourceInstance *constructTerrainFile(Stream &stream);
extern ResourceInstance *constructTSShape(Stream &);


ConsoleFunctionGroupBegin( Platform , "General platform functions.");

ConsoleFunction( lockMouse, void, 2, 2, "(bool isLocked)"
                "Lock the mouse (or not, depending on the argument's value) to the window.")
{
   Platform::setWindowLocked(dAtob(argv[1]));
}

ConsoleFunction( setNetPort, bool, 2, 2, "(int port)"
                "Set the network port for the game to use.")
{
   return Net::openPort(dAtoi(argv[1]));
}

ConsoleFunction( saveJournal, void, 2, 2, "(string filename)"
                "Save the journal to the specified file.")
{
   Game->saveJournal(argv[1]);
}

ConsoleFunction( playJournal, void, 2, 3, "(string filename, bool break=false)"
                "Begin playback of a journal from a specified field, optionally breaking at the start.")
{
   bool jBreak = (argc > 2)? dAtob(argv[2]): false;
   Game->playJournal(argv[1],jBreak);
}

extern void netInit();
extern void processConnectedReceiveEvent( ConnectedReceiveEvent * event );
extern void processConnectedNotifyEvent( ConnectedNotifyEvent * event );
extern void processConnectedAcceptEvent( ConnectedAcceptEvent * event );
extern void ShowInit();

/// Initalizes the components of the game like the TextureManager, ResourceManager
/// console...etc.
/*static*/ bool initLibraries()
{
   if(!Net::init())
   {
      Platform::AlertOK("Network Error", "Unable to initialize the network... aborting.");
      return false;
   }

   // asserts should be created FIRST
   PlatformAssert::create();

   FrameAllocator::init(3 << 20);      // 3 meg frame allocator buffer

//   // Cryptographic pool next
//   CryptRandomPool::init();

   _StringTable::create();
   TextureManager::create();
   ResManager::create();

   // Register known file types here
   ResourceManager->registerExtension(".jpg", constructBitmapJPEG);
   ResourceManager->registerExtension(".png", constructBitmapPNG);
   ResourceManager->registerExtension(".gif", constructBitmapGIF);
   ResourceManager->registerExtension(".dbm", constructBitmapDBM);
   ResourceManager->registerExtension(".bmp", constructBitmapBMP);
   ResourceManager->registerExtension(".bm8", constructBitmapBM8);
   ResourceManager->registerExtension(".dif", constructInteriorDIF);
   ResourceManager->registerExtension(".ter", constructTerrainFile);
   ResourceManager->registerExtension(".dts", constructTSShape);
   ResourceManager->registerExtension(".dml", constructMaterialList);
   ResourceManager->registerExtension(".map", constructInteriorMAP);
   ResourceManager->registerExtension(".uft", constructNewFont);
#ifndef TGE_CHINESE
   ResourceManager->registerExtension(".gft", constructFont);
#endif

#ifdef TGE_RPG
	/// TGE_TerrainScene
   ResourceManager->registerExtension(".sce", constructTerrainScene);
#endif


   Con::init();
   NetStringTable::create();

   TelnetConsole::create();
   TelnetDebugger::create();

   Processor::init();
   Math::init();
   Platform::init();    // platform specific initialization
#ifdef TGE_RPG
	CS::SocketLayer::Initialize();
	RPG::RPGEngine::Initialize(TRUE);
	//RPG::GameIconMan::Initialize();
#endif
#ifdef TGE_RPGCLIENT
   PlatformIME::Init();//IME
#endif
   InteriorLMManager::init();
   InteriorInstance::init();
   TSShapeInstance::init();
   RedBook::init();
   Platform::initConsole();

   return true;
}


/// Destroys all the things initalized in initLibraries
/*static*/ void shutdownLibraries()
{
   // Purge any resources on the timeout list...
   if (ResourceManager)
      ResourceManager->purge();

   RedBook::destroy();
   TSShapeInstance::destroy();
   InteriorInstance::destroy();
   InteriorLMManager::destroy();

   TextureManager::preDestroy();

#ifdef TGE_RPGCLIENT
   PlatformIME::Destroy();//IME
#endif
#ifdef TGE_RPG
	//RPG::GameIconMan::Destroy();
	RPG::RPGEngine::Destroy(TRUE);
	CS::SocketLayer::Destroy();
#endif
   Platform::shutdown();
   TelnetDebugger::destroy();
   TelnetConsole::destroy();

   NetStringTable::destroy();
   Con::shutdown();

   ResManager::destroy();
   TextureManager::destroy();

   _StringTable::destroy();

   // asserts should be destroyed LAST
   FrameAllocator::destroy();

   PlatformAssert::destroy();
   Net::shutdown();
}

ConsoleFunction( getSimTime, S32, 1, 1, "Return the current sim time in milliseconds.\n\n"
                "Sim time is time since the game started.")
{
   return Sim::getCurrentTime();
}

ConsoleFunction( getRealTime, S32, 1, 1, "Return the current real time in milliseconds.\n\n"
                "Real time is platform defined; typically time since the computer booted.")
{
   return Platform::getRealMilliseconds();
}

ConsoleFunctionGroupEnd(Platform);

static F32 gTimeScale = 1.0;
static U32 gTimeAdvance = 0;
static U32 gFrameSkip = 0;
static U32 gFrameCount = 0;

// Executes an entry script; can be controlled by command-line options.
bool runEntryScript (int argc, const char **argv)
{
   // Executes an entry script file. This is "main.cs"
   // by default, but any file name (with no whitespace
   // in it) may be run if it is specified as the first
   // command-line parameter. The script used, default
   // or otherwise, is not compiled and is loaded here
   // directly because the resource system restricts
   // access to the "root" directory.

   FileStream str; // The working filestream.
#ifdef TGE_RPG_SCRIPT
	#ifdef TGE_RPGSERVER
		const char*  defaultScriptName = "root.chs";
	#else
		const char*  defaultScriptName = "index.chs";
	#endif
#else
   const char*  defaultScriptName = "main.cs";
#endif
   bool useDefaultScript = true;

   // Check if any command-line parameters were passed (the first is just the app name).
   if (argc > 1)
   {
      // If so, check if the first parameter is a file to open.
      if ( (str.open(argv[1], FileStream::Read)) && (argv[1] != "") )
      {
         // If it opens, we assume it is the script to run.
         useDefaultScript = false;
      }
   }

   if (useDefaultScript)
   {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -