예제 #1
0
void CEngine::CreateSystems()
{
    AddSystem( Input() );
    AddSystem( Sound() );
	AddSystem( Physics() );
	AddSystem( Script() );	
}
예제 #2
0
	scriptID LoadCompiledScript(const std::string& scriptFile)
	{
		std::unordered_map<std::string, scriptID>::iterator scriptIter = loadedScripts.find(scriptFile);
		if (scriptIter != loadedScripts.end())
		{
			return loadedScripts[scriptFile];
		}
		std::fstream file;
		size_t dataSize;
		unsigned char code;
		unsigned char data[256];
		file.open(scriptFile, std::ios::in | std::ios::binary);

		scriptID newscriptID = scripts.size();
		scripts.push_back(Script());
		Script& newScript = scripts.back();

		size_t scriptSize;
		file.read((char*)&scriptSize, sizeof(size_t));
		newScript.reserve(scriptSize);

		for(size_t i = 0; i < scriptSize; ++i)
		{
			file.read((char*) &dataSize, sizeof(size_t));
			file.read((char*) &code, sizeof(unsigned char));
			file.read((char*) data, sizeof(unsigned char) * dataSize);

			newScript.push_back( Instruction(code, &data[0], dataSize) );
		}

		loadedScripts[scriptFile] = newscriptID;

		return newscriptID;
	}
예제 #3
0
Checksum Scenario::load(const string &path) {
    Checksum scenarioChecksum;
	try {
		scenarioChecksum.addFile(path);
		checksumValue.addFile(path);

		string name= cutLastExt(lastDir(path));
		Logger::getInstance().add("Scenario: " + formatString(name), true);

		//parse xml
		XmlTree xmlTree;
		xmlTree.load(path);
		const XmlNode *scenarioNode= xmlTree.getRootNode();
		const XmlNode *scriptsNode= scenarioNode->getChild("scripts");

		for(int i= 0; i<scriptsNode->getChildCount(); ++i){
			const XmlNode *scriptNode = scriptsNode->getChild(i);

			scripts.push_back(Script(getFunctionName(scriptNode), scriptNode->getText()));
		}
	}
	//Exception handling (conversions and so on);
	catch(const exception &e) {
		SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
		throw runtime_error("Error: " + path + "\n" + e.what());
	}

	return scenarioChecksum;
}
예제 #4
0
int main(int argc, const char *argv[])
{
    try
    {
        // Branch to processing code based on first argument
        if (argc > 1 && strcmp(argv[1], "sphrWarp") == 0)
            return SphrWarp(argc, argv);
        else if (argc > 1 && strcmp(argv[1], "alignPair") == 0)
            return AlignPair(argc, argv);
        else if (argc > 1 && strcmp(argv[1], "blendPairs") == 0)
            return BlendPairs(argc, argv);
        else if (argc > 1 && strcmp(argv[1], "script") == 0)
            return Script(argc, argv);
        else {
            printf("usage: \n");
            printf("	%s sphrWarp input.tga output.tga f [k1 k2]\n", argv[0]);
            printf("	%s alignPair input1.f input2.f matchfile nRANSAC RANSACthresh [sift]\n", argv[0]);
            printf("	%s blendPairs pairlist.txt outimg.tga blendWidth\n", argv[0]);
            printf("	%s script script.cmd\n", argv[0]);
        }
    }
    catch (CError &err) {
        printf("%s\n", err.message);
        return -1;
    }
    return 0;
}
예제 #5
0
Fighter::Fighter()
{
    //physical properties
    active = false;
    pos.set(0, 0);
    dir = 0;
    targetVel = 0;
    maxVel = 300;
    accScalar = 20;
    friction = .25;
    
    //combat
    target = nullptr;
    hp = 100;
    sp = 100;
    spRegen = 0;
    blocking = false;
    blockHitCooldown = 0;
    invincible = 0;
    
    //animation
    currentFrame = 0;
    currentMove = MOVE_NONE;
    frameRate = 18;
    next = 1/frameRate;
    stunTimer = 0;
    
    //TODO read from animation scripts
    Script script = Script("dat/knight.txt");
    
    while (!script.done())
    {
        switch(script.getMove())
        {
        case MOVE_NONE:
            stand[script.getDir()] = *script.getFrame();
            break;
        case MOVE_WALK:
            walk[script.getDir()].addFrame(script.getFrame());
            break;
        case MOVE_LIGHT_ATTACK:
            lightAttack[script.getDir()].addFrame(script.getFrame());
            break;
        case MOVE_ROLL:
            roll[script.getDir()].addFrame(script.getFrame());
            break;
        case MOVE_BLOCK:
            shield[script.getDir()] = *script.getFrame();
            break;
        case MOVE_STUN:
            stun[script.getDir()].addFrame(script.getFrame());
            break;
        case MOVE_PRONE:
            prone[script.getDir()].addFrame(script.getFrame());
            break;
        }
        script.next();
    }
}
예제 #6
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

	hInst = hInstance; // Store instance handle in our global variable

	hMainWnd	= hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
	  CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	if (!hWnd)
		return FALSE;

	SetTimer( hMainWnd, 3, SEC( 60 ), NULL );	// 10(s)

	int x = 480, y = 606;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0x00, 0x00, 0x00 ), RGB( 0xff, 0xff, 0xff ) );

	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );

#ifndef _DEBUG
//   InitEH();
#endif	// _DEBUG

	if( !Script( "CacheServer.ini" ) )
		return FALSE;

	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( !g_DPCoreClient.ConnectToServer( g_szCoreAddr, PN_CORESRVR + 1 ) )
		return FALSE;
	
#ifdef __CRC
	if( !g_DPCacheSrvr.StartServer( g_uPort, FALSE, CSock::crcRead ) )
#else	// __CRC
	if( !g_DPCacheSrvr.StartServer( g_uPort ) )
#endif	// __CRC
		return FALSE;


	g_MyTrace.AddLine( '-' );
	char lpszIpAddr[16];
	g_DPCoreClient.GetPlayerAddr( DPID_SERVERPLAYER, lpszIpAddr );

	g_MyTrace.Add( CMyTrace::Key( "main" ), FALSE, "%s", lpszIpAddr );
	g_MyTrace.AddLine( '-' );

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}
예제 #7
0
	// FUNCTIONS ////////////////////////////////////////////////////////////////////////
	scriptID AddScript(const Script& script)
	{
		scriptID scriptid = scripts.size();
		scripts.push_back(Script());
		Script& newScript = scripts.back();

		CopyScript(newScript, script);

		return scriptid;
	}
예제 #8
0
script_vec System::get_installed_scripts()
{
	script_vec vp;

	string_vec files = get_files(PATH_INSTALLED_SCRIPTS);

	for (string_vec::iterator i = files.begin(); i != files.end(); i++)
	{
		vp.push_back(Script(*i));
	}

	return vp;
}
예제 #9
0
파일: repository.cpp 프로젝트: Sebi55/GPC
void Repository::load(std::string const& directory, bool is_proxifiedScript_dir){
	DIR* dir = opendir(directory.c_str());
	if (dir){
		struct dirent *entry;
		struct stat fileProperties;
		while (entry = readdir(dir)){
			stat((directory+"/"+entry->d_name).c_str(), &fileProperties);
			if ((fileProperties.st_mode & S_IFMT) != S_IFDIR){ 
				bool scriptAdded = false;
				if (!is_proxifiedScript_dir && !ProxyScriptData::is_proxyscript(directory+"/"+entry->d_name) && std::string(entry->d_name).length() >= 4 && entry->d_name[0] >= '1' && entry->d_name[0] <= '9' && entry->d_name[1] >= '0' && entry->d_name[1] <= '9' && entry->d_name[2] == '_'){
					this->push_back(Script(std::string(entry->d_name).substr(3), directory+"/"+entry->d_name));
					scriptAdded = true;
				} else if (is_proxifiedScript_dir) {
					this->push_back(Script(pscriptname_decode(entry->d_name), directory+"/"+entry->d_name));
					scriptAdded = true;
				}
				if (scriptAdded && this->hasLogger()) {
					this->back().setLogger(this->getLogger());
				}
			}
		}
		closedir(dir);
	}
}
예제 #10
0
UnicodeString TSessionLog::GetCmdLineLog() const
{
  TODO("GetCmdLine()");
  UnicodeString Result = L"";

  if (!FConfiguration->GetLogSensitive())
  {
#if 0
    TManagementScript Script(StoredSessions, false);
    Script.MaskPasswordInCommandLine(Result, true);
#endif
  }

  return Result;
}
예제 #11
0
파일: repository.cpp 프로젝트: Sebi55/GPC
Script* Repository::getScriptByFilename(std::string const& fileName, bool createScriptIfNotFound) {
	Script* result = NULL;
	for (Repository::iterator iter = this->begin(); iter != this->end() && !result; iter++){
		if (iter->fileName == fileName)
			result = &*iter;
	}
	if (result == NULL && createScriptIfNotFound){
		this->push_back(Script("noname", fileName));
		result = &this->back();

		if (this->hasLogger()) {
			this->back().setLogger(this->getLogger());
		}
	}
	return result;
}
예제 #12
0
void CEngine::Main()
{
	InitFormat();

    QtInterface window;
	m_pWindow = &window;
    window.resize(1024, 578);
    window.show();
	window.raise(); // Bring to front

	Script()->PostInit();

    while ( !window.shouldClose() )
    {
        m_pApp->processEvents();
		FrameAdvance();

        if ( Input()->KeyPressed( KEY_ESC ) )
        {
            break;
        }
		else if (Input()->KeyHeld( KEY_ALT ) && ( Input()->KeyReleased( KEY_ENTER ) || Input()->KeyReleased( KEY_RETURN ) ) )
		{
			if ( window.isFullScreen() ) 
			{
				window.showNormal();
			}
			else
			{
				window.showFullScreen();
			}
		}
        
		window.Render();

        for (int i = 0; i < m_vecGameSystems.size(); i++)
        {
            m_vecGameSystems[i]->PostRender();
        }

        // We don't really need more than 100 fps, so sleep for 0.01 sec
        msleep(0);
    }

    Message("Engine Main End\n");
}
예제 #13
0
void StateGraphViewerPanel::highlightValue(seec::cm::Value const *Value)
{
  wxString Script("HighlightValue(");
  Script << reinterpret_cast<uintptr_t>(Value);

  if (Value) {
    if (auto const Ptr = llvm::dyn_cast<seec::cm::ValueOfPointer>(Value)) {
      if (Ptr->getDereferenceIndexLimit()) {
        auto const Pointee = Ptr->getDereferenced(0);
        Script << ", " << reinterpret_cast<uintptr_t>(Pointee.get());
      }
    }
  }

  Script << ");";

  WebView->RunScript(Script);
}
예제 #14
0
void Logger::Setup()
{
	ErrorHandle.open ( "log/error.log",ios::trunc );
	EventHandle.open ( "log/event.log",ios::trunc );
	GameHandle.open ( "log/game.log",ios::trunc );
	ScriptHandle.open ( "log/lua.log",ios::trunc );
	Error("Starting error log.");
	Game("Starting game log.");
	Event("Starting event log.");
	Script("Starting scripting log.");
	
	std::cout.rdbuf(EventHandle.rdbuf());
	std::cerr.rdbuf(ErrorHandle.rdbuf());

	cerr << "This is just a test...\n";
	cout << "Another test...\n";

}
예제 #15
0
void ReCallScript( void )
{
	int i;
	static DWORD time;

	for( i = 0 ; i < DRAGON_MAX_CONNECTIONS ; i ++)
	{
		if( var[i][1] )
		{
			if(connections[i].socket && connections[i].state >= CONNECT_JOIN )
			{
				if( var[i][3] < global_time )
				{
					Script( var[i][1] );
				}
			}
		}
	}
}
예제 #16
0
void
StateGraphViewerPanel::show(std::shared_ptr<StateAccessToken> Access,
                            seec::cm::ProcessState const &Process,
                            seec::cm::ThreadState const &Thread)
{
  CurrentAccess = std::move(Access);
  CurrentProcess = &Process;
  MouseOver.reset();
  
  WebView->RunScript(wxString("InvalidateState();"));
  
  if (!WebView || PathToDot.empty())
    return;
  
  renderGraph();

  // Add special highlighting for values associated with the active Stmt.
  //
  if (!Thread.getCallStack().empty()) {
    seec::cm::FunctionState const &Fn = Thread.getCallStack().back();
    if (auto const Stmt = Fn.getActiveStmt()) {
      if (auto const Value = Fn.getStmtValue(Stmt)) {
        wxString Script("MarkActiveStmtValue(");
        Script << reinterpret_cast<uintptr_t>(Value.get()) << ");";

        if (auto const Ptr = llvm::dyn_cast<seec::cm::ValueOfPointer>
                                           (Value.get()))
        {
          if (Ptr->getDereferenceIndexLimit()) {
            if (auto const Pointee = Ptr->getDereferenced(0)) {
              Script << "MarkActiveStmtValue("
                     << reinterpret_cast<uintptr_t>(Pointee.get()) << ");";
            }
          }
        }

        WebView->RunScript(Script);
      }
    }
  }
}
예제 #17
0
bool ScriptInterpreter::interpret(Common::List<ScriptChunk *> &chunks) {
	bool queued = false;

	// Create new random variables for the evaluation below
	_vm->_variables->reRollRandom();

	// Push the first script with met conditions into the queue
	for (Common::List<ScriptChunk *>::iterator it = chunks.begin(); it != chunks.end(); ++it) {
		if ((*it)->conditionsMet() && _vm->_events->cameFrom((*it)->getFrom())) {
			(*it)->rewind();
			_scripts.push_back(Script(*it));
			queued = true;
			break;
		}
	}

	if (queued)
		_updatesWithoutChanges = 0;

	return queued;
}
예제 #18
0
int main() {
	
	Time = 0;
	
	Machine machine;
	
	machine.install(Script(script, sizeof(script)));
	while(!machine.finished()) machine.step();
	
	while(true){
		
		red = yellow = green = false;
		button = Pins::button.check();
		
		machine.run(t += 1);
		while(!machine.finished()) machine.step();
		
		red    ? Pins::led0.high() : Pins::led0.low();
		yellow ? Pins::led1.high() : Pins::led1.low();
		green  ? Pins::led2.high() : Pins::led2.low();
		
	}
	
}
예제 #19
0
파일: script.cpp 프로젝트: mettalla/dali
Script Script::New(void)
{
  return Script(new Internal::Script());
}
예제 #20
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

	hMainWnd	= hWnd	=
		CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

	int x = 0, y = 416;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	g_GameTimer.Compute();
	SetTimer( hWnd, TIMER_ID_DEFAULT, 1000, NULL );

#if !defined(__INTERNALSERVER)
	SetTimer( hWnd, TIMER_ID_WANTED, g_uWantedElapse, NULL );
#endif

#ifdef __EVENT0913
	SetTimer( hWnd, TIMER_ID_EVENT0913, 1000, NULL );
#endif	// __EVENT0913
#ifdef __EVENT1206
	SetTimer( hWnd, TIMER_ID_EVENT1206, 1000 * 60, NULL );
#endif	// __EVENT1206

	SetTimer( hWnd, TIMER_ID_EVENT, 1000 * 60, NULL );

	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0xff, 0xff, 0xff ), RGB( 0x00, 0x00, 0x00 ) );

	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );

#ifndef _DEBUG
//	InitEH();
#endif	// _DEBUG

	g_TickCount.Start();

	if( !Script( "CoreServer.ini" ) )
	{
		return FALSE;
	}
	
	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( !g_dpCoreSrvr.StartServer( PN_CORESRVR + 0 ) )
		return FALSE;

	if( !g_DPCacheSrvr.StartServer( PN_CORESRVR + 1 ) )
		return FALSE;

	if( !g_dpLoginSrvr.StartServer( PN_CORESRVR + 2 ) )
		return FALSE;

	if( !g_dpDatabaseClient.ConnectToServer( szDataBaseAddr, PN_DBSRVR_2, FALSE ) )
	{
		Error( "Not TransServer Connect" );
		return FALSE;
	}

	if( !g_PartyMng.CreateWorkers() )
	{
		assert( 0 );
	}

#ifdef __ENVIRONMENT_EFFECT
	if( CEnvironment::GetInstance()->CreateWorkers() == FALSE )
	{
		assert( 0 );
	}
#else // __ENVIRONMENT_EFFECT
	if( !g_Environment.CreateWorkers() )
	{
		assert( 0 );
	}
#endif // __ENVIRONMENT_EFFECT

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}
예제 #21
0
void ScriptRegister::removeScript(ScriptChunk &chunk) {
	_scriptMap.setVal(chunk.getSignature(), Script(0xFFFFFFFF));
}
예제 #22
0
Script Parser::parse(TokenStack ts){
	return Script();
};
예제 #23
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    // Set up the highest resolution timer we can manage 
//	TIMECAPS tc; 
//	UINT nPeriod;
//	if( TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)) ) 
//		nPeriod = tc.wPeriodMin;
//	else
//		nPeriod = 1;  
//	timeBeginPeriod( nPeriod ); 

	HWND hWnd;
	g_hMainWnd	= hWnd	= CreateWindow(g_szWindowClass, g_szTitle, WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	int x = 480, y = 0;
	SetWindowPos( hWnd, NULL, x, y, 800, 416, SWP_SHOWWINDOW );

	if (!hWnd)
		return FALSE;

	SetTimer( g_hMainWnd, 0, SEC( 60 ), NULL );	// 60
	SetTimer( g_hMainWnd, 1, MIN( 60 ), NULL );	// 3600

	CTime time = CTime::GetCurrentTime();
	SetLogInfo( LOGTYPE_TIME, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

#ifndef _DEBUG
// 	#if defined(__MINIDUMP)
// 		InitDumper( DUMP_LEVEL_0 );
// 	#else
// 		InitEH();
// 	#endif // !__MINIDUMP
#endif	// _DEBUG

	EnableFloatException();

	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( InitializeScriptLib() == FALSE )
		return FALSE;

	xSRand( timeGetTime()  );	// 속도를 요하는 랜덤은 xRandom()을 쓰도록...

	if( Script( g_szINI ) == TRUE )
	{
		if( !prj.OpenProject( "Masquerade.prj" ) ) 
		{
			Error( "OpenProject ERROR check Masquerade.prj" );
			return FALSE;
		}

		SetLogInfo( LOGTYPE_REDRAW, "" );
		SetTitle();

		if( CompileItemScript( "ItemScript.lua" ) == FALSE )
			return FALSE;

	#if defined(__REMOVE_SCIRPT_060712)
		if( CWorldDialog::GetInstance().Init() == FALSE )
		{
			OutputDebugString( "WorldDialog.DLL load failed\n" );
			return FALSE;
		}
	#endif
		return CRunObject::GetInstance()->Init();
	}
	else
	{
		char szBuffer[300] = {0,};
		char szDir[255] = {0,};
		GetCurrentDirectory( 255, szDir );
		sprintf( szBuffer, "%s\\WorldServer.ini File not found", szDir );
		AfxMessageBox( szBuffer );
		return FALSE;
	}
}
	void ScriptParam::getFunction(std::string& strFnName, Script& script) const {strFnName=m_strData;script=Script(m_iScriptID, m_pScript);}
예제 #25
0
	Script::Script(std::string scriptfile)
	{
		Script();
		loadScript(scriptfile);
	}
예제 #26
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
#ifndef _DEBUG
//   InitEH();
#endif	// _DEBUG

#ifdef __BILLING0712
	if( ::CreateBillingMgr() == FALSE )		// CreateWindow전에 호출되어야 한다.
		return FALSE;
#endif

	HWND hWnd;
	hInst = hInstance; // Store instance handle in our global variable
	hMainWnd = hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);	
	if( !hWnd )
		return FALSE;
	
	HMENU hMenu		= GetMenu( hWnd );
	CheckMenuItem( hMenu, IDM_OPT_INTERNAL, MF_CHECKED );
	EnableMenuItem( hMenu, IDM_OPT_INTERNAL, MF_DISABLED | MF_GRAYED );
	g_dpSrvr.m_bCheckAddr	= true;

	int x = 400, y = 416;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	LOAD_WS2_32_DLL;

	::srand( timeGetTime() );

	// Script함수의 호출순서가 중요하다. (menu -> script -> createdbworker)
	if( Script( "AccountServer.ini" ) == FALSE )	
		return FALSE;

#ifdef __SECURITY_0628
	LoadResAuth( "Flyff.b" );
#endif	// __SECURITY_0628

//	if( CQuery::EnableConnectionPooling() )
//		OutputDebugString( "EnableConnectionPooling\n" );

	g_DbManager.CreateDbWorkers();
	
	if( g_dpSrvr.LoadAddrPmttd( "pmttd.ini" ) == false )
	{
		TRACE("LoadAddrPmttd false\n");
	}	
	
	if( g_dpSrvr.LoadIPCut( "IPCut.ini" ) == FALSE )
	{
		TRACE( "LoadIPCut FALSE\n" );
	}
	
	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0x00, 0x00, 0x00 ), RGB( 0xff, 0xff, 0xff ) );
	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );
	
	if( FALSE == g_dpSrvr.StartServer( PN_ACCOUNTSRVR_0 )
		|| FALSE == g_dpDbSrvr.StartServer( PN_ACCOUNTSRVR_1 )
		|| FALSE == CDPAdbill::GetInstance()->StartServer( PN_ADBILL )
		/*
#ifdef __GIFTBOX0213
		|| FALSE == CDPWldSrvr::GetInstance()->StartServer( PN_ACCOUNTSRVR_2 )
#endif	// __GIFTBOX0213
		*/
		 )
	{
		AfxMessageBox( "Unable to start server" );
		return FALSE;
	}

#ifdef __BILLING0712
	if( GetBillingMgr()->Init( hWnd ) == false )
		return FALSE;
#endif

	SetTimer( hWnd, IDT_SENDPLAYERCOUNT, 1000 * 60, NULL );
	SetTimer( hWnd, IDT_TIME_CHECKADDR, 1000 * 30, NULL );
	if( ::GetLanguage() == LANG_THA )
		SetTimer( hWnd, IDT_PREVENT_EXCESS, 1000 * 60, NULL );

/*
#ifdef __S0114_RELOADPRO
	SetTimer( hWnd, IDT_RELOAD_PROJECT, 1000 * 30, NULL );
#endif // __S0114_RELOADPRO
*/
	SetTimer( hWnd, IDT_BUYING_INFO, 500, NULL );

	if( FALSE == g_DbManager.AllOff() )
		return FALSE;

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);	
	return TRUE;
}
예제 #27
0
void ScriptRegister::addScript(ScriptChunk &chunk) {
	_scriptMap.setVal(chunk.getSignature(), Script(chunk));
}
예제 #28
0
int main(int argc, char** argv)
{
    if (argc < 3 || argc > 4)
    {
        cout << "usage: " << argv[0] << " <input.nsb> <output.nss> [charset]" << endl;
        return 1;
    }

    if (argc == 4)
        NpaFile::SetLocale(argv[3]);
    else
        NpaFile::SetLocale("ja_JP.CP932");

    ScriptFile Script(argv[1], ScriptFile::NSB);
    Output.Output.open(argv[2]);

    for (auto i : Script.GetIncludes())
        Output << "#include \"" << i << "\"\n";
    if (!Script.GetIncludes().empty())
        Output << '\n';

    uint32_t SourceIter = 0;
    while (pLine = Script.GetLine(SourceIter++))
    {
        switch (pLine->Magic)
        {
            case MAGIC_SCOPE_BEGIN:
                Indent();
                Output << "{\n";
                ++IndentLevel;
                Output.Written = false;
                break;
            case MAGIC_SCOPE_END:
                --IndentLevel;
                Indent();
                Output << "}\n";
                break;
            case MAGIC_CLEAR_PARAMS:
                if (!Output.Written && !Params.empty())
                {
                    Indent();
                    Output << Params[0];
                }
                Output << ";\n";
                Params.clear();
                Output.Written = false;
                break;
            case MAGIC_VARIABLE:
                Params.push_back(pLine->Params[0]);
                break;
            case MAGIC_LITERAL:
                if (pLine->Params[0] == "STRING" && pLine->Params[1][0] != '#' && !Nsb::IsValidConstant(pLine->Params[1].c_str()))
                    Params.push_back(string("\"" + pLine->Params[1] + "\""));
                else
                    Params.push_back(pLine->Params[1]);
                break;
            case MAGIC_CALL_FUNCTION:
                Indent();
                Output << pLine->Params[0] << GenParams(Params);
                break;
            case MAGIC_FUNCTION_DECLARATION:
            {
                pLine->Params[0][8] = ' ';
                Output << pLine->Params[0];
                pLine->Params.erase(pLine->Params.begin());
                Output << GenParams(pLine->Params) << '\n';
                break;
            }
            case MAGIC_SCENE_DECLARATION:
                pLine->Params[0][5] = ' ';
                Output << pLine->Params[0] << '\n';
                break;
            case MAGIC_CHAPTER_DECLARATION:
                pLine->Params[0][7] = ' ';
                Output << pLine->Params[0] << '\n';
                break;
            case MAGIC_END_FUNCTION:
            case MAGIC_END_SCENE:
            case MAGIC_END_CHAPTER:
                Output << '\n';
                break;
            case MAGIC_ADD_ASSIGN:
                AssignOperator("+=");
                break;
            case MAGIC_SUB_ASSIGN:
                AssignOperator("-=");
                break;
            case MAGIC_ADD_EXPRESSION:
                BinaryOperator("+");
                break;
            case MAGIC_SUB_EXPRESSION:
                BinaryOperator("-");
                break;
            case MAGIC_DIV_EXPRESSION:
                BinaryOperator("/");
                break;
            case MAGIC_MUL_EXPRESSION:
                BinaryOperator("*");
                break;
            case MAGIC_MOD_EXPRESSION:
                BinaryOperator("%");
                break;
            case MAGIC_CMP_EQUAL:
                BinaryOperator("==");
                break;
            case MAGIC_CMP_GREATER:
                BinaryOperator(">");
                break;
            case MAGIC_CMP_LESS:
                BinaryOperator("<");
                break;
            case MAGIC_LOGICAL_NOT_EQUAL:
                BinaryOperator("!=");
                break;
            case MAGIC_LOGICAL_GREATER_EQUAL:
                BinaryOperator(">=");
                break;
            case MAGIC_LOGICAL_LESS_EQUAL:
                BinaryOperator("<=");
                break;
            case MAGIC_CMP_LOGICAL_AND:
                BinaryOperator("&&");
                break;
            case MAGIC_CMP_LOGICAL_OR:
                BinaryOperator("||");
                break;
            case MAGIC_LOGICAL_NOT:
                Params[Params.size() - 1] = string("!") + Params[Params.size() - 1];
                break;
            case MAGIC_ASSIGN:
                Indent();
                if (!Params.empty())
                {
                    if (pLine->Params[0] == "__array_variable__")
                        Output << Params[0];
                    else
                        Output << pLine->Params[0];
                    Output << " = " << Params.back();
                }
                else
                    cout << "WARNING: MAGIC_SET without parameters! (Perhaps builtin return?)" << endl;
                break;
            case MAGIC_IF:
                Indent();
                Output << "if " << GenParams(Params) << '\n';
                Params.clear();
                break;
            case MAGIC_WHILE:
                Indent();
                Output << "while " << GenParams(Params) << '\n';
                Params.clear();
                break;
            case MAGIC_BREAK:
                Indent();
                Output << "break;\n";
                Params.clear();
                break;
            case MAGIC_PARSE_TEXT:
                Output << pLine->Params[2] << '\n';
                break;
            case MAGIC_NEGA_EXPRESSION:
                Params[Params.size() - 1] = string("-") + Params[Params.size() - 1];
                break;
            case MAGIC_AT_EXPRESSION:
                Params.back() = '@' + Params.back();
                break;
            // Currently ignored builtins
            case MAGIC_JUMP: // TODO: Check for else/else if
            case MAGIC_WHILE_END:
            case MAGIC_CASE_END:
            case MAGIC_SELECT_END:
            case MAGIC_SELECT_BREAK_END:
                break;
            case MAGIC_INCREMENT:
                Indent();
                Output << Params.back() << "++";
                break;
            case MAGIC_DECREMENT:
                Indent();
                Output << Params.back() << "--";
                break;
            case MAGIC_CALL_CHAPTER:
                Indent();
                Output << "call_chapter " << pLine->Params[0] << ";\n";
                break;
            case MAGIC_CALL_SCENE:
                Indent();
                Output << "call_scene " << pLine->Params[0] << ";\n";
                break;
            // Builtins which return value
            case MAGIC_UNK116:
            case MAGIC_UNK129:
            case MAGIC_UNK146:
            case MAGIC_UNK150:
            case MAGIC_RANDOM:
            case MAGIC_MESSAGE:
            case MAGIC_STR_STR:
            case MAGIC_IMAGE_HORIZON:
            case MAGIC_IMAGE_VERTICAL:
            case MAGIC_SOUND_AMPLITUDE:
            case MAGIC_COUNT:
            case MAGIC_SCROLLBAR_VALUE:
            case MAGIC_EXIST_SAVE:
            case MAGIC_STRING:
            case MAGIC_UNK140:
            case MAGIC_READ_FILE:
            case MAGIC_UNK184:
            case MAGIC_TIME:
            case MAGIC_REMAIN_TIME:
            case MAGIC_DURATION_TIME:
            case MAGIC_PASSAGE_TIME:
            case MAGIC_MODULE_FILE_NAME:
                WriteToParams();
                break;
            case MAGIC_SELECT:
                Indent();
                Output << "select\n";
                break;
            case MAGIC_CASE:
                Indent();
                Output << "case " << pLine->Params[0] << ":\n";
                break;
            case MAGIC_RETURN:
                Indent();
                Output << "return;\n";
                break;
            case MAGIC_SUB_SCRIPT:
            {
                string Param = pLine->Params[0];
                int Size = stoi(pLine->Params[1]);
                for (int i = Params.size() - Size; i < Params.size(); ++i)
                    Param += "[" + Params[i] + "]";
                Params.resize(Params.size() - Size);
                Params.push_back(Param);
                break;
            }
            case MAGIC_VARIABLE_VALUE:
                if (pLine->Params.size() == 2)
                    WriteToParams();
                else
                    WriteDefault();
                break;
            default:
                WriteDefault();
                break;
        }
    }
}