コード例 #1
0
ファイル: esthread.cpp プロジェクト: prestocore/browser
/* virtual */
OP_STATUS
ES_Thread::Unblock(ES_ThreadBlockType type)
{
	OP_ASSERT(GetBlockType() == type);

	if (blocked_by_foreign_thread != 0)
		SetBlockType(ES_BLOCK_FOREIGN_THREAD);
	else if (scheduler)
		return scheduler->Unblock(this, type);
	else
		SetBlockType(ES_BLOCK_NONE);

	return OpStatus::OK;
}
コード例 #2
0
ファイル: esthread.cpp プロジェクト: prestocore/browser
/* virtual */
void
ES_Thread::Block(ES_ThreadBlockType type)
{
	if (block_type == ES_BLOCK_FOREIGN_THREAD)
		SetBlockType(type);
	else
	{
		OP_ASSERT(GetBlockType() == ES_BLOCK_NONE);

		if (scheduler)
			scheduler->Block(this, type);
		else
			SetBlockType(type);
	}
}
コード例 #3
0
ファイル: CityGate.cpp プロジェクト: ueverything/mmo-resourse
BOOL CGate::InitProperty(CGateList::tagGate *p)
{
	SetName(p->cName);//名字
	SetLenth(p->wLenth);//长		
	SetWidth(p->wWidth);//宽
	SetLevel(p->wLevel);//等级
	SetGraphicsID(p->dwModelId);//模型ID
	SetMaxHP(p->wMaxHp);//最大HP
	SetHP(p->wMaxHp);	//当前HP
	SetUnAttack(p->bIsunbeatable);//是否无敌
	SetBlockType(p->byBlockType);//阻挡类型
	SetDef(p->lDef);//物防	
	SetMagicDef(p->lMagicDef);//魔防
	SetNameColor(p->wNameColor);//名字颜色
	SetHitSound(string(p->cHitSound));//击中音效
	SetDestorySound(string(p->cDestorySound));//损毁音效
	SetOpenSound(string(p->cOpenSound));//打开音效
	SetCloseSound(string(p->cCloseSound));//关闭音效
	return TRUE;
}
コード例 #4
0
ファイル: esthread.cpp プロジェクト: prestocore/browser
/* virtual */
OP_STATUS
ES_JavascriptURLThread::EvaluateThread()
{
	OP_STATUS ret = OpStatus::OK;

	switch (eval_state)
	{
	case STATE_INITIAL:
		{
			eval_state = STATE_SET_PROGRAM;

#ifdef USER_JAVASCRIPT
			DOM_Environment *environment = scheduler->GetFramesDocument()->GetDOMEnvironment();

			RETURN_IF_ERROR(environment->HandleJavascriptURL(this));

			if (IsBlocked())
				return OpStatus::OK;
#endif // USER_JAVASCRIPT
		}
		// fall through

	case STATE_SET_PROGRAM:
		if (source)
		{
			ES_ProgramText program_text;

			program_text.program_text = source;
			program_text.program_text_length = uni_strlen(source);

			ES_Runtime *runtime = scheduler->GetRuntime();

			ES_Program *program;
			OP_STATUS status;

			ES_Runtime::CompileProgramOptions options;
			options.generate_result = TRUE;
			options.global_scope = FALSE;
			options.script_type = SCRIPT_TYPE_JAVASCRIPT_URL;
			options.when = UNI_L("while loading");
			options.script_url = &url;
#ifdef ECMASCRIPT_DEBUGGER
			options.reformat_source = g_ecmaManager->GetWantReformatScript(runtime);
#endif // ECMASCRIPT_DEBUGGER

			if (OpStatus::IsSuccess(status = runtime->CompileProgram(&program_text, 1, &program, options)))
				if (program)
					SetProgram(program);
				else
					status = OpStatus::ERR;

			if (OpStatus::IsMemoryError(status))
			{
				is_completed = is_failed = TRUE;
				return status;
			}
			else if (OpStatus::IsError(status))
			{
				is_completed = is_failed = TRUE;
				return OpStatus::OK;
			}
		}
		eval_state = STATE_EVALUATE;
		// fall through

	case STATE_EVALUATE:
		{
			ret = ES_Thread::EvaluateThread();
			if (OpStatus::IsError(ret))
			{
				eval_state = STATE_HANDLE_RESULT;
				is_completed = TRUE;
				break;
			}
			else if (IsCompleted())
			{
				if (IsFailed())
				{
					eval_state = STATE_DONE;
					break;
				}
				else
#ifdef USER_JAVASCRIPT
					eval_state = STATE_SEND_USER_JS_AFTER;
#else // USER_JAVASCRIPT
					eval_state = STATE_HANDLE_RESULT;
#endif // USER_JAVASCRIPT
			}
			else
				break;
		}
		// fall through

#ifdef USER_JAVASCRIPT
	case STATE_SEND_USER_JS_AFTER:
		{
			DOM_Environment *environment = scheduler->GetFramesDocument()->GetDOMEnvironment();

			RETURN_IF_ERROR(environment->HandleJavascriptURLFinished(this));

			eval_state = STATE_HANDLE_RESULT;

			if (IsBlocked())
			{
				is_completed = FALSE;
				break;
			}
		}
		// fall through
#endif // USER_JAVASCRIPT

	case STATE_HANDLE_RESULT:
		{
			is_completed = TRUE;
			const uni_char *use_result = NULL;

#ifdef USER_JAVASCRIPT
			if (has_result)
				use_result = result;
			else
#endif // USER_JAVASCRIPT
				if (ReturnedValue())
				{
					ES_Value return_value;

					RETURN_IF_ERROR(GetReturnedValue(&return_value));

					if (return_value.type == VALUE_STRING)
						use_result = return_value.value.string;
				}

			FramesDocument *frames_doc = GetFramesDocument();
			OP_ASSERT(frames_doc); // Since we're executing we must be in a document
			if (use_result)
			{
				if (write_result_to_document)
				{
					// The HTML5 spec says that we should load this data exactly as if it had come
					// from an HTTP connection with content type text/html and status 200. This
					// is a very bad approximation of that.
					BOOL is_busy = scheduler->IsDraining() || !frames_doc->IsCurrentDoc();
					write_result_to_document = FALSE; // Since it's enough to do it once
					frames_doc->SetWaitForJavascriptURL(FALSE);

					if (!is_busy)
						if (HLDocProfile *hld_profile = frames_doc->GetHLDocProfile())
							is_busy = hld_profile->GetESLoadManager()->GetScriptGeneratingDoc();

					if (!is_busy)
					{
						if (GetOriginInfo().open_in_new_window)
							RETURN_IF_ERROR(DOM_Environment::OpenWindowWithData(use_result, frames_doc, this, GetOriginInfo().is_user_requested));
						else
						{
							// The ESOpen()/ESClose() calls are just done in order to create an
							// empty document in The Right Way(tm) in order to parse some data
							// into it as if it had been loaded from a URL, and not to set up
							// a document.write call like they are usually used for.
							ESDocException doc_exception; // Ignored
							RETURN_IF_ERROR(frames_doc->ESOpen(scheduler->GetRuntime(), &url, is_reload, NULL, NULL, &doc_exception));

							FramesDocument *new_frames_doc = frames_doc->GetDocManager()->GetCurrentDoc();
							RETURN_IF_ERROR(new_frames_doc->ESClose(scheduler->GetRuntime()));

							SetBlockType(ES_BLOCK_NONE);

							if (frames_doc != new_frames_doc)
								RETURN_IF_ERROR(new_frames_doc->GetLogicalDocument()->ParseHtmlFromString(use_result, uni_strlen(use_result), FALSE, FALSE, FALSE));
							else
								OP_ASSERT(!"ESOpen might have failed, but if it didn't then we're stuck with a hung thread in a document and nothing will work");

							new_frames_doc->ESStoppedGeneratingDocument();
						}
					}
				}

				if (write_result_to_url)
				{
					if (want_utf8)
					{
						UTF16toUTF8Converter converter;

						unsigned length = uni_strlen(use_result) * sizeof source[0], needed = converter.BytesNeeded(use_result, length);
						converter.Reset();

						char *data;
						if (needed < g_memory_manager->GetTempBufLen())
							data = (char *) g_memory_manager->GetTempBuf();
						else
							data = OP_NEWA(char, needed);

						if (!data)
						{
							ret = OpStatus::ERR_NO_MEMORY;
							break;
						}
						else
						{
							int read, written = converter.Convert(use_result, length, data, needed, &read);

							url.WriteDocumentData(URL::KNormal, data, written);
							url.WriteDocumentDataFinished();

							if (data != g_memory_manager->GetTempBuf())
								OP_DELETEA(data);
						}
					}
					else
					{
						url.WriteDocumentData(URL::KNormal, use_result, uni_strlen(use_result));
						url.WriteDocumentDataFinished();
					}
				}
			}
			else if (write_result_to_document)
			{
				// The HTML5 spec says this should be handled as a HTTP status 204, NO_CONTENT
				frames_doc->GetMessageHandler()->PostMessage(MSG_URL_LOADING_FAILED, url.Id(), DH_ERRSTR(SI,ERR_HTTP_NO_CONTENT));
				frames_doc->SetWaitForJavascriptURL(FALSE);
				write_result_to_document = FALSE; // Since it's done and we don't want to do it again.
			}

			eval_state = STATE_DONE;
		}
コード例 #5
0
bool CMonster::DecordFromDataBlock(DBReadSet& readDB,bool bExData /* = true */)
{
	CMoveShape::DecordFromDataBlock(readDB, bExData);

	DWORD	dwHp = readDB.GetDwordFromByteArray();
	DWORD	dwMaxHp = readDB.GetDwordFromByteArray();
	WORD	wClass = readDB.GetWordFromByteArray();
	WORD	wFigure = readDB.GetWordFromByteArray();
	DWORD	dwSounID = readDB.GetDwordFromByteArray();
	DWORD	dwNameColor = readDB.GetDwordFromByteArray();
	DWORD	dwHpBarColor = readDB.GetDwordFromByteArray();
	WORD	wLevel = readDB.GetWordFromByteArray();
	/*m_dwCollectID		= */readDB.GetDwordFromByteArray();
	//if( m_dwCollectID != 0 )
	//{

	//}

	/*m_bIsBeenCollect        = */(readDB.GetByteFromByteArray() == 0)?false : true;
	/*m_bCanBeenCollect		= */(readDB.GetByteFromByteArray() == 0)?false : true;

	//	SetMaxHp(dwMaxHp);
	SetHp(dwHp);
	//	SetClass((eClass)wClass);
	//	SetFigure(wFigure);
	//	SetLevel(wLevel);


	long lMonsterType = -1;
	WORD wIsCanTalk = 0;
	char str[512];
	memset(str,'\0',512);
	//原始名
	m_strOrigName = readDB.GetStringFromByteArray( str,512);
	lMonsterType = readDB.GetWordFromByteArray();
	wIsCanTalk = readDB.GetWordFromByteArray();
	/*wIcon = */readDB.GetWordFromByteArray();
	/*wColor = */readDB.GetWordFromByteArray();
	m_strTitle = readDB.GetStringFromByteArray( str,512);
	// 设置阻挡类型
	BYTE bBlockType = readDB.GetByteFromByteArray();
	SetBlockType(CRegion::eBLOCK(bBlockType));
	// 任务保护信息(类型和GUID)
	m_lCreatorType = readDB.GetLongFromByteArray();
	readDB.GetBufferFromByteArray(m_CreatorGuid);
	//
	// 国家ID
	//SetCountry(readDB.GetByteFromByteArray());
	readDB.GetByteFromByteArray();
	//转身速度
	readDB.GetFloatFromByteArray();
	// BOSS等级
	WORD wBossLevel = readDB.GetWordFromByteArray();
	//	SetBossLevel(wBossLevel);

	SeteNpcType(eNpcType(lMonsterType));
	SetIsCanTalk(wIsCanTalk);
	//////////////////////////////////////////////////////////////////////////
	//怪物多重血条
	long lBaseMaxHp = readDB.GetLongFromByteArray();
	long lSize = readDB.GetLongFromByteArray();
	for( int i=0;i<lSize;i++)
	{
		long lHpRange = readDB.GetLongFromByteArray();
	}

	//	this->m_bAppearanceSoundPlayed = false;
	return true;
}