void oe_event_attach(void* ptr, ___SCMOBJ fun) {
    // IEvent<Core::InitializeEventArg>* e 
    //     // = dynamic_cast<IEvent<Core::InitializeEventArg>*>(ptr);
    //     = (IEvent<Core::InitializeEventArg>*)(ptr);
    IEngine* e = (IEngine*)ptr;
    if (!e) return;
    SchemeWrapper<Core::InitializeEventArg>* w
        = new SchemeWrapper<Core::InitializeEventArg>(fun);
    e->InitializeEvent().Attach(*w);
}
示例#2
0
文件: main.cpp 项目: xxfast/iEngine
int main(int argc, char* argv[])
{
	if (argc < 1)
	{
		cerr << "Arguments missing" << endl;
		// program failed
		return 1;
	}

	// set up input file and declare an input file variable
	ifstream lInput;

	// open an input text file
	lInput.open(argv[1], ifstream::in);

	// If state of the stream is good
	if (!lInput.good())
	{
		cerr << "Cannot open input file: " << argv[1] << endl;
		// program failed (input)
		return 2;
	}

	if (!lInput.good())
	{
		cerr << "Couldn't open input file " << argv[1] << endl;
		// program failed (input)
		return 2;
	}
    
    
    cout << "iEngine Driver Program" << endl;
    
    Method lMethod = TT;
    if(argc>=2)
        lMethod = Utilities::stringToMethod(argv[2]);
    else
        cout << "Method not specified, defaults to TT" << endl;
    
    vector<Predicate*> lPredicates = Utilities::generatePredicates(lInput);
    
    // Instatiate iEngine on the Heap
    IEngine* testEngine = new IEngine(lPredicates);
    bool success = testEngine->process(lMethod, "d");
    string output;
    cout << ((success)?"YES":"NO")<< output<<": "<< testEngine->getResults()<<endl;
    
    //Exit the program
    lInput.close();
	return 0;
}
示例#3
0
void Monster::DrawToMiniMap(FLOAT scalX, FLOAT scalY)
{
	IEngine* pEngine = GetEngine();
	IVideo* pVideo = pEngine->getVideo();

	int x = 0, y = 0;

	if (m_isMouseMove || m_isSelected) {
		// Ñ¡ÖÐ״̬
		m_nameColor = RED;
		m_Effect = EF_RED;
		int x1=0, y1=0, x2=0, y2=0;

		// ³öÉú·¶Î§
		x = m_pt.x / CXTILE;
		y = m_pt.y / CYTILE;
		int birthW = m_info.birthRect.cx;
		int birthH = m_info.birthRect.cy;
		x1 = x - birthW;
		y1 = y - birthH;
		x2 = x + birthW + 1;
		y2 = y + birthH + 1;
		x1 = x1 * CXTILE / scalX;
		y1 = y1 * CYTILE / scalY;
		x2 = x2 * CXTILE / scalX;
		y2 = y2 * CYTILE / scalY;
		pVideo->drawRect(Pointf(x1, y1), Pointf(x2, y2), YELLOW);

		// ÊÓÒ°·¶Î§
		x = m_pt.x / CXTILE;
		y = m_pt.y / CYTILE;
		int viewW = m_info.view;
		int viewH = m_info.view;
		x1 = x - viewW;
		y1 = y - viewH;
		x2 = x + viewW + 1;
		y2 = y + viewH + 1;
		x1 = x1 * CXTILE / scalX;
		y1 = y1 * CYTILE / scalY;
		x2 = x2 * CXTILE / scalX;
		y2 = y2 * CYTILE / scalY;
		pVideo->drawRect(Pointf(x1, y1), Pointf(x2, y2), RED);
	} else {
		// ·ÇÑ¡ÖÐ״̬
		m_nameColor = YELLOW;
		m_Effect = EF_NORMAL;
	}
}
示例#4
0
	SkyBoxShaderCallback(IEngine *engine)
	{
		this->engine = engine;
		this->driver = engine->GetIrrlichtDevice()->getVideoDriver();
		
		lastBrightness = 1.f;
	}
示例#5
0
void Monster::DrawPositionToMiniMap(FLOAT scalX, FLOAT scalY)
{
	IEngine* pEngine = GetEngine();
	IVideo* pVideo = pEngine->getVideo();

	int x1 = m_pt.x / CXTILE;
	int x2 = x1 + 1;
	int y1 = m_pt.y / CYTILE;
	int y2 = y1 + 1;
	x1 = x1 * CXTILE / scalX;
	y1 = y1 * CYTILE / scalY;
	x2 = x2 * CXTILE / scalX;
	y2 = y2 * CYTILE / scalY;
	pVideo->drawSolidRect(Pointf(x1, y1), Pointf(x2, y2), YELLOW);
	pVideo->drawRect(Pointf(x1, y1), Pointf(x2, y2), RED);
}
示例#6
0
int main(int argc, const char **argv)
{
	VariantMap settings;
	settings["appName"] = "Puzzle Moppet";
	settings["windowTitle"] = "Puzzle Moppet Configuration";
	settings["screenWidth"] = 250;
	settings["screenHeight"] = 330;
#ifndef __APPLE__
	// Software renderer doesn't seem to work on Mac...
	settings["softwareMode"] = true;
#endif
	
	IEngine *engine = CreateEngine(argc, argv, &settings);
	
	IrrlichtDevice *device = engine->GetIrrlichtDevice();
	
	// Filesystem...
	// Irrlicht needs this so it can load textures from same dir as font xml.
	engine->GetIrrlichtDevice()->getFileSystem()->addFileArchive("../projects/ConfigApp/");
	
	// Show the cursor
	device->getCursorControl()->setVisible(true);
	
	// Pause World, not needed for GUI app.
	// (pausing World also disables mouse centring)
	engine->GetWorld()->Pause();
	
	// Load GUI
	gui::IGUIEnvironment *guienv = device->getGUIEnvironment();
	ASSERT( guienv->loadGUI("gui.xml") );
	
	// Get pointers to important elements within the loaded GUI.
	// Ideally in the future we'll have a layout manager and won't need the GUI
	// defined in xml.
	FindGUIElementPointers();
	
	// Default font
	guienv->getSkin()->setFont( guienv->getFont("lucida.xml") );
	
	// Change background colour...
	engine->GetRenderSystem()->SetBackgroundCol(video::SColor(0, 200,200,200));
	
	// Receive GUI events.
	// This prevents Litha Engine from receiving GUI events, but that doesn't matter.
	IEventReceiver *eventReceiver = new EventReceiver(engine);
	guienv->setUserEventReceiver(eventReceiver);
	
	// Init
	InitSettings();
	InitGUI();
	
	engine->Run();
	engine->drop();
	delete eventReceiver;
	
	return 0;
}
示例#7
0
	bool OnGUIEvent(const SEvent::SGUIEvent &event)
	{
		
		// Button clicks
		if (event.EventType == gui::EGET_BUTTON_CLICKED)
		{
			switch (event.Caller->getID())
			{
			case gui_ids::BUTTON_CANCEL:
				engine->Exit();
				return true;
			case gui_ids::BUTTON_SAVE_AND_EXIT:
				SaveSettings();
				engine->Exit();
				return true;
			}
		}
		
		return false;
	}
示例#8
0
文件: main.cpp 项目: Raphy/zappy
int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    Helper* helper = nullptr;  
    IEngine* engine = nullptr;  
    try
    {
        helper = Helper::getInstance(argc, argv);
	engine = helper->createEngine();
    }
    catch (std::string& msg)
    {
	std::cout << "Initialization error : " << msg << std::endl;
	return 1;
    }
    if (engine->init())
        engine->mainLoop();
    delete engine;
    return 0;
}
示例#9
0
	void ShaderOnSetConstants(IShader *shader) override
	{
		shader->SetPixelConstant("rippleScroll", engine->GetRenderUpdater().GetVirtualTime() * 0.02);
		
		
		// Are we looking in to the sun?
		core::vector3df camVec = maths::rotation_to_direction( engine->GetWorld()->GetCamera()->GetRotation() );
		
		sunDirection.normalize();
		
		f32 dp = camVec.dotProduct(sunDirection);
		//f32 brightness = 1.f + 0.5 * dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp*dp;
		f32 brightness = 1.f + 0.5 * dp*dp*dp*dp*dp*dp*dp*dp*dp*dp;
		
		if (brightness < 1.f || camVec.getDistanceFrom(sunDirection) > 1.f)
			brightness = 1.f;
		
		brightness = core::lerp(lastBrightness, brightness,
				core::clamp(engine->GetRenderUpdater().GetLastDeltaTime(), 0.f, 1.f));
		
		lastBrightness = brightness;
		
		shader->SetPixelConstant("brightness", brightness);
	}
示例#10
0
	virtual int RefreshAddresses(int Nettype)
	{
		if(m_State != STATE_INIT)
			return -1;

		dbg_msg("engine/mastersrv", "refreshing master server addresses");

		// add lookup jobs
		for(int i = 0; i < MAX_MASTERSERVERS; i++)
		{
			m_pEngine->HostLookup(&m_aMasterServers[i].m_Lookup, m_aMasterServers[i].m_aHostname, Nettype);
			m_aMasterServers[i].m_Valid = false;
		}

		m_State = STATE_UPDATE;
		return 0;
	}
示例#11
0
	virtual int RefreshAddresses(int Nettype)
	{
		int i;

		if(m_NeedsUpdate != -1)
			return 0;

		dbg_msg("engine/mastersrv", "refreshing master server addresses");

		// add lookup jobs
		for(i = 0; i < MAX_MASTERSERVERS; i++)
		{
			m_pEngine->HostLookup(&m_aMasterServers[i].m_Lookup, m_aMasterServers[i].m_aHostname, Nettype);
			m_aMasterServers[i].m_Valid = false;
		}

		m_NeedsUpdate = 1;
		return 0;
	}
示例#12
0
int main(int argc, const char **argv)
{
	// Command line parameters
	
	bool editor = false;
	core::stringc levelFileName;
	
// Mac passes a -psn (process serial number) argument when running from a .app directory,
// which messes this up. So we just ignore command line arguments on mac for now.
// Ideally though, we'd just strip that out and ignore it.
#ifndef __APPLE__
	if (argc == 3)
	{
		// Edit?
		if (core::stringc(argv[1]) == "-e")
		{
			editor = true;
			globalIsInEditor = true;
		}
		
		levelFileName = argv[2];
	}
	else if (argc == 2)
	{
		levelFileName = argv[1];
	}
#endif
	
	VariantMap settings;
	settings["appName"] = "Puzzle Moppet";
	settings["screenWidth"] = 1024;
	settings["screenHeight"] = 768;
	settings["fullScreen"] = false;
	
	IEngine *engine = CreateEngine(argc, argv, &settings);
	
	
	
	
	engine->GetIrrlichtDevice()->getFileSystem()->addFileArchive(PROJECT_DIR"/Puzzle/media/");
	
	
	IWorld *world = engine->GetWorld();
	IRenderSystem *renderSystem = engine->GetRenderSystem();
	
	renderSystem->SetShaderLevel(ESL_LOW);
	
	
	// Loading text. Hacked in! Uses add_static_text2 from MainState.cpp
	
	{
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		gui::IGUIEnvironment *guienv = engine->GetIrrlichtDevice()->getGUIEnvironment();
		
		s32 screenHeight = driver->getScreenSize().Height;
		s32 screenWidth = driver->getScreenSize().Width;
		
		gui::IGUIElement *loadingGUI = add_static_text(L"Loading...");
		core::rect<s32> rect = loadingGUI->getRelativePosition();
		rect += core::vector2di( screenWidth/2 - rect.getWidth()/2, screenHeight/2 - rect.getHeight()/2 );
		loadingGUI->setRelativePosition(rect);
		
		// Render the gui once.
		driver->beginScene(true, true, video::SColor(0,0,0,0));
		guienv->drawAll();
		driver->endScene();
		
		// We can remove the element now we've rendered.
		loadingGUI->remove();
	}
	
	
	// Set up post processing.
	if (renderSystem->ShadersAreAvailable()
			&& renderSystem->PostProcessingEnabled())
	{
		// bool flag indicates whether rendering to screen still occurs first before post processing
		IPostProcessingChain *chain = renderSystem->CreatePostProcessingChain(true);
		
		// Materials need:
		// - Lighting = false
		// - ZBuffer = false
		// - ZWriteEnable = false
		
		// For bloom, need:
		// - bright filter
		// - BlurH
		// - BlurV
		// (final one blended additively on to the screen)
		
		
		video::SMaterial material;
		material.Lighting		= false;
		material.ZBuffer		= false;
		material.ZWriteEnable	= false;
		material.AntiAliasing	= video::EAAM_OFF;
		
		IShader *shader;
		
		// Bright filter
		shader = renderSystem->CreateShader("ScreenQuad.vert", "Brightfilter.frag");
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		// Horizontal blur
		shader = renderSystem->CreateShader("ScreenQuad.vert", "BlurH.frag");
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		// Vertical blur
		// As this is the last effect it is rendered additively on to the screen.
		shader = renderSystem->CreateShader("ScreenQuad.vert", "BlurV.frag", video::EMT_TRANSPARENT_ADD_COLOR);
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		renderSystem->SetActivePostProcessingChain(chain);
		chain->drop();
	}
	
	// Some sky
	// Maybe this should be in Level?
	// --> move it only when it is needed...
	
	core::stringc skyDir = "skies/Set 42/";
	core::stringc skyExt = "png";
	
	world->SetSkyBox(
			skyDir+"6."+skyExt,
			skyDir+"5."+skyExt,
			skyDir+"1."+skyExt,
			skyDir+"3."+skyExt,
			skyDir+"2."+skyExt,
			skyDir+"4."+skyExt
			);
	
	// load sky effects enabled flag
	{
		VariantMap creationSettings = engine->GetCreationSettings();
		
		if (creationSettings.count("skyEffects"))
			skyEffectsEnabled = creationSettings["skyEffects"];
		else
			skyEffectsEnabled = true;
	}
	
	if (renderSystem->ShadersAreAvailable() && skyEffectsEnabled)
	{
		IShader *skyShader = renderSystem->CreateShader("SkyBox.vert", "SkyBox.frag", video::EMT_SOLID);
		
		LowLevelShaderRegisterMap rmap;
		rmap.PushSingleRegister("rippleScroll", "brightness", nullptr,nullptr);
		
		skyShader->SetPixelRegisterMap(rmap);
		
		IShaderCallback *skyShaderCallback = new SkyBoxShaderCallback(engine);
		skyShader->SetCallback( skyShaderCallback );
		skyShaderCallback->drop();
		
		world->SetSkyBoxShader(skyShader);
		skyShader->drop();
		
		// sky box ripple texture !!
		
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		video::ITexture *rippleTexture = driver->getTexture("cloudshadow.png");
		
		for (u8 i = 0; i < 6; i ++)
			world->GetSkyBoxMaterial(i).setTexture(1, rippleTexture);
	}
	
	
	// ********** PRELOAD EVERYTHING!! ***********
	
	NOTE << "Preloading media...";
	
	// Meshes
	{
		scene::ISceneManager *smgr = engine->GetIrrlichtDevice()->getSceneManager();
		smgr->getMesh("ground_single_sideless.b3d");
		smgr->getMesh("ground_single.b3d");
		smgr->getMesh("ground_single_fall.b3d");
		smgr->getMesh("box.b3d");
		smgr->getMesh("icybox.irrmesh");
		smgr->getMesh("icybox_inner.irrmesh");
		smgr->getMesh("balloon.irrmesh");
		smgr->getMesh("magicfan_base.b3d");
		smgr->getMesh("magicfan_blades.b3d");
		smgr->getMesh("magicfan_orb.irrmesh");
		smgr->getMesh("lift.b3d");
		smgr->getMesh("lift_glow.irrmesh");
		smgr->getMesh("nothing.irrmesh");
		smgr->getMesh("teleport.irrmesh");
		smgr->getMesh("player.b3d");
		smgr->getMesh("sea.b3d");
		smgr->getMesh("land.irrmesh");
		smgr->getMesh("cliff.irrmesh");
		smgr->getMesh("titletext.b3d");
		smgr->getMesh("gridarrow.irrmesh");
	}
	
	// Textures (stand alone, others are loaded with meshes)
	{
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		driver->getTexture("brass_spheremap.png");
		driver->getTexture("watersand.png");
		driver->getTexture("water.png");
		driver->getTexture("watersand_add.png");
		driver->getTexture("dust.png");
		driver->getTexture("sparkle.png");
		driver->getTexture("fog.png");
		driver->getTexture("cloudshadow.png");
		driver->getTexture("mud.jpg");
		
		// Final sky box textures
		{
			core::stringc skyDir = "skies/Set 26/final_";
			core::stringc skyExt = "png";
			driver->getTexture(skyDir+"6."+skyExt);
			driver->getTexture(skyDir+"5."+skyExt);
			driver->getTexture(skyDir+"1."+skyExt);
			driver->getTexture(skyDir+"3."+skyExt);
			driver->getTexture(skyDir+"2."+skyExt);
			driver->getTexture(skyDir+"4."+skyExt);
		}
	}
	
	// Fonts
	{
		gui::IGUIEnvironment *guienv = engine->GetIrrlichtDevice()->getGUIEnvironment();
		guienv->getFont("font2.xml");
		guienv->getFont("fontlarge2.xml");
	}
	
	// Sounds
	{
		ISoundSystem *soundSystem = engine->GetSoundSystem();
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/sea.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/beep.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/fallblock.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/buttonflutter_micro.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/hithard.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/liftrun.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/balloonpush.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/slide.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/windy.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/speedcore.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/bell.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/stepballoon.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/step.ogg");
		
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/appear.ogg");
		
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/laugh.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/fair.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/good.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/excellent.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/perfect.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/extraordinary.ogg");
		
		//soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/music.ogg");
	}
	
	// Shaders!?
	/*
	if (renderSystem->ShadersAreAvailable())
	{
		IShader *shader;
		
		shader = renderSystem->CreateShader("Hemisphere.vert", "Hemisphere.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("HemisphereBalloon.vert", "HemisphereBalloon.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("HemisphereLand.vert", "Hemisphere.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("Hemisphere.vert", "HemisphereWood.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("PlainWithAlpha.vert", "PlainWithAlpha.frag", video::EMT_SOLID);
		shader->drop();
	}
	*/
	
	NOTE << "Finished preloading!";
	
	
	// Default sound volume
	engine->GetSoundSystem()->SetGlobalVolume(5.0);
	
	
	// background sfx
	bgAmbientSound = engine->GetSoundSystem()->CreateSound2D();
	bgAmbientSound->SetIsLooped(true);
	//bgAmbientSound->SetVolume(0.035);
	
	bgMusic = engine->GetSoundSystem()->CreateSound2D();
	bgMusic->SetIsLooped(true);
	
	// Load sfx volume
	set_volumes_from_settings(engine->GetCreationSettings());
	
	bgAmbientSound->Play(PROJECT_DIR"/Puzzle/media/sfx/windy.ogg");
	bgMusic->Play(PROJECT_DIR"/Puzzle/media/sfx/speedcore.ogg");
	
	// load default movement type
	{
		VariantMap creationSettings = engine->GetCreationSettings();
		
		if (creationSettings.count("gridBasedMovement"))
			gridBasedMovement = creationSettings["gridBasedMovement"];
		else
			gridBasedMovement = true;
		
		// mouse axis inversion?
		
		if (creationSettings.count("invertMouseX"))
			invertMouseX = creationSettings["invertMouseX"];
		else
			invertMouseX = false;
		
		if (creationSettings.count("invertMouseY"))
			invertMouseY = creationSettings["invertMouseY"];
		else
			invertMouseY = false;
	}
	
	
	// Now, instead of going straight into the game we have a start screen.
	// ...unless the game was started by command line, in which case we jump straight in.
	
	MainState *mainState = nullptr;
	
	if (levelFileName.size())
	{
		NOTE << "Started with command line parameter, will skip start screen.";
		mainState = new MainState(&mainState);
		mainState->StartLevel(levelFileName, editor);
	}
	else
	{
		NOTE << "Entering start screen...";
		// StartScreen *MAY* create a MainState, returning the pointer to mainState
		// so that we can delete it from here in main.cpp
		// (why do we want to delete it from main? because we always have...)
		StartScreen *startScreen = new StartScreen(&mainState);
		engine->GetLogicUpdater().AddUpdatable(startScreen);
		startScreen->drop();
	}
	
	// Main loop
	engine->Run();
	
	// MainState may not exist if StartScreen was entered but no level was played.
	if (mainState)
		delete mainState;
	
	if (bgAmbientSound)
		bgAmbientSound->drop();
	
	if (bgMusic)
		bgMusic->drop();

	engine->drop();
		
	return 0;
}
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	HANDLE hObject = NULL;
	BOOL (*IsDebuggerPresent)(void) = (BOOL (*)(void))GetProcAddress(GetModuleHandle("kernel32.dll"), "IsDebuggerPresent");

	if (!IsDebuggerPresent())
	{
		hObject = CreateMutex(NULL, FALSE, "ValveHalfLifeLauncherMutex");

		DWORD dwStatus = WaitForSingleObject(hObject, 0);

		if (dwStatus && dwStatus != WAIT_ABANDONED)
		{
			MessageBox(NULL, "Could not launch game.\nOnly one instance of this game can be run at a time.", "Error", MB_ICONERROR);
			return 0;
		}
	}

	WSAData WSAData;
	WSAStartup(2, &WSAData);

	registry->Init();
	CommandLine()->CreateCmdLine(GetCommandLine());
	CommandLine()->AppendParm("-nomaster", NULL);

	char szFileName[256];
	Sys_GetExecutableName(szFileName, sizeof(szFileName));
	char *szExeName = strrchr(szFileName, '\\') + 1;

	if (stricmp(szExeName, "hl.exe") && CommandLine()->CheckParm("-game") == NULL)
	{
		szExeName[strlen(szExeName) - 4] = '\0';
		CommandLine()->AppendParm("-game", szExeName);
	}

	const char *_szGameName;
	static char szGameName[32];
	const char *szGameStr = CommandLine()->CheckParm("-game", &_szGameName);
	strcpy(szGameName, _szGameName);

	if (szGameStr && !strnicmp(&szGameStr[6], "czero", 5))
		CommandLine()->AppendParm("-forcevalve", NULL);

	if (registry->ReadInt("CrashInitializingVideoMode", FALSE))
	{
		registry->WriteInt("CrashInitializingVideoMode", FALSE);

		if (strcmp(registry->ReadString("EngineDLL", "hw.dll"), "hw.dll"))
		{
			if (registry->ReadInt("EngineD3D", FALSE))
			{
				registry->WriteInt("EngineD3D", FALSE);

				if (MessageBox(NULL, "The game has detected that the previous attempt to start in D3D video mode failed.\nThe game will now run attempt to run in openGL mode.", "Video mode change failure", MB_OKCANCEL | MB_ICONWARNING) != IDOK)
					return 0;
			}
			else
			{
				registry->WriteString("EngineDLL", "sw.dll");

				if (MessageBox(NULL, "The game has detected that the previous attempt to start in openGL video mode failed.\nThe game will now run in software mode.", "Video mode change failure", MB_OKCANCEL | MB_ICONWARNING) != IDOK)
					return 0;
			}

			registry->WriteInt("ScreenWidth", 640);
			registry->WriteInt("ScreenHeight", 480);
			registry->WriteInt("ScreenBPP", 16);
		}
	}

	while (1)
	{
		HINTERFACEMODULE hFileSystem = LoadFilesystemModule();

		if (!hFileSystem)
			break;

		MH_Init(szGameName);

		CreateInterfaceFn fsCreateInterface = (CreateInterfaceFn)Sys_GetFactory(hFileSystem);
		g_pFileSystem = (IFileSystem *)fsCreateInterface(FILESYSTEM_INTERFACE_VERSION, NULL);
		g_pFileSystem->Mount();
		g_pFileSystem->AddSearchPath(Sys_GetLongPathName(), "ROOT");

		static char szNewCommandParams[2048];
		const char *pszEngineDLL;
		int iResult = ENGINE_RESULT_NONE;

		szNewCommandParams[0] = 0;
		SetEngineDLL(pszEngineDLL);

		g_blobfootprintClient.m_hDll = NULL;

		IEngine *engineAPI = NULL;
		HINTERFACEMODULE hEngine;
		bool bUseBlobDLL = false;

		if (FIsBlob(pszEngineDLL))
		{
			Sys_CloseDEP();
			SetupExceptHandler3();
			NLoadBlobFile(pszEngineDLL, &g_blobfootprintClient, (void **)&engineAPI);
			bUseBlobDLL = true;
		}
		else
		{
			hEngine = Sys_LoadModule(pszEngineDLL);

			if (!hEngine)
			{
				static char msg[512];
				wsprintf(msg, "Could not load %s.\nPlease try again at a later time.", pszEngineDLL);
				MessageBox(NULL, msg, "Fatal Error", MB_ICONERROR);
				break;
			}

			CreateInterfaceFn engineCreateInterface = (CreateInterfaceFn)Sys_GetFactory(hEngine);
			engineAPI = (IEngine *)engineCreateInterface(VENGINE_LAUNCHER_API_VERSION, NULL);

			if (!engineCreateInterface || !engineAPI)
				Sys_FreeModule(hEngine);
		}

		if (engineAPI)
		{
			MH_LoadEngine(bUseBlobDLL ? NULL : (HMODULE)hEngine);
			iResult = engineAPI->Run(hInstance, Sys_GetLongPathName(), CommandLine()->GetCmdLine(), szNewCommandParams, Sys_GetFactoryThis(), Sys_GetFactory(hFileSystem));
			MH_ExitGame(iResult);

			if (bUseBlobDLL)
				FreeBlob(&g_blobfootprintClient);
			else
				Sys_FreeModule(hEngine);
		}

		if (iResult == ENGINE_RESULT_NONE || iResult > ENGINE_RESULT_UNSUPPORTEDVIDEO)
			break;

		bool bContinue;

		switch (iResult)
		{
			case ENGINE_RESULT_RESTART:
			{
				bContinue = true;
				break;
			}

			case ENGINE_RESULT_UNSUPPORTEDVIDEO:
			{
				bContinue = OnVideoModeFailed();
				break;
			}
		}

		CommandLine()->RemoveParm("-sw");
		CommandLine()->RemoveParm("-startwindowed");
		CommandLine()->RemoveParm("-windowed");
		CommandLine()->RemoveParm("-window");
		CommandLine()->RemoveParm("-full");
		CommandLine()->RemoveParm("-fullscreen");
		CommandLine()->RemoveParm("-soft");
		CommandLine()->RemoveParm("-software");
		CommandLine()->RemoveParm("-gl");
		CommandLine()->RemoveParm("-d3d");
		CommandLine()->RemoveParm("-w");
		CommandLine()->RemoveParm("-width");
		CommandLine()->RemoveParm("-h");
		CommandLine()->RemoveParm("-height");
		CommandLine()->RemoveParm("-novid");

		if (strstr(szNewCommandParams, "-game"))
			CommandLine()->RemoveParm("-game");

		if (strstr(szNewCommandParams, "+load"))
			CommandLine()->RemoveParm("+load");

		CommandLine()->AppendParm(szNewCommandParams, NULL);

		g_pFileSystem->Unmount();
		Sys_FreeModule(hFileSystem);
		MH_Shutdown();

		if (!bContinue)
			break;
	}

	registry->Shutdown();

	if (hObject)
	{
		ReleaseMutex(hObject);
		CloseHandle(hObject);
	}

	WSACleanup();
	MH_Shutdown();
	TerminateProcess(GetCurrentProcess(), 1);
	return 1;
}
示例#14
0
void Monster::Draw(POINT ptMap)
{
	IEngine* pEngine = GetEngine();
	IVideo* pVideo = pEngine->getVideo();
	easy2d::IFont* pFont = pEngine->getFont();

	// »­¹ÖÎïÉíÌåͼƬ
	int x = m_pt.x - ptMap.x;
	int y = m_pt.y - ptMap.y;
	mSpriteSheet.render(x+CXTILE/2, y+CYTILE/2);
	if (CommData::isShowMiniMap) {
		pVideo->drawSolidRect(Pointf(x, y), Pointf(x+CXTILE, y+CYTILE), 0x50FFFF00);
		pVideo->drawRect(Pointf(x, y), Pointf(x+CXTILE, y+CYTILE), RED, 2.0f);
	}

	if (m_isMouseMove || m_isSelected) {
		// Ñ¡ÖÐ״̬
		m_nameColor = RED;
		m_Effect = EF_RED;
		int x1=0, y1=0, x2=0, y2=0;
		
		// ³öÉúÇøÓò
		x = m_pt.x - ptMap.x;
		y = m_pt.y - ptMap.y;
		int birthW = m_info.birthRect.cx * CXTILE;
		int birthH = m_info.birthRect.cy * CYTILE;
		x1 = x - birthW;
		y1 = y - birthH;
		x2 = x + birthW + CXTILE;
		y2 = y + birthH + CYTILE;
		pVideo->drawRect(Pointf(x1, y1), Pointf(x2, y2), YELLOW);

		// ÊÓÒ°(¹¥»÷)·¶Î§
		x = m_pt.x - ptMap.x;
		y = m_pt.y - ptMap.y;
		int viewW = m_info.view * CXTILE;
		int viewH = m_info.view * CYTILE;
		x1 = x - viewW;
		y1 = y - viewH;
		x2 = x + viewW + CXTILE;
		y2 = y + viewH + CYTILE;
		pVideo->drawRect(Pointf(x1, y1), Pointf(x2, y2), RED);
	} else {
		// ·ÇÑ¡ÖÐ״̬
		m_nameColor = YELLOW;
		m_Effect = EF_NORMAL;
	}

	// »æÖÆÃû×Ö¡¢ÊýÁ¿¡¢µôÂä±àºÅ
	CString strName = m_name.c_str();
	if (m_num > 1) {
		CString strNum;
		strNum.Format("(ÊýÁ¿*%d)", m_num);
		strName += strNum;
	}
	if (m_info.dropInfo[0].dropId != 0) {
		CString strDrop;
		strDrop.Format("[µôÂä%d]", m_info.dropInfo[0].dropId);
		strName += strDrop;
	}

	// »­¹ÖÎïÃû×Ö
	int frameHeight = 0;
	int offsetX = (int)strName.GetLength() * 4 - CXTILE/2;
	FRAME_INFO* frm = mSpriteSheet.getFrame(0);
	if (frm != NULL) {
		frameHeight = mSpriteSheet.getFrame(0)->height;
	} else {
		frameHeight = 86;
	}

	stFontEffect fontEff;
	pFont->drawString(x-offsetX, y-frameHeight, strName, m_nameColor, fontEff);
}