Esempio n. 1
0
double CScript::ShowString(const char* cmd, char* retStr)
{
	CPlayer *pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);
	if(NULL == pPlayer) return -1;

	LONG lScreenPosX = GetIntParam(cmd, 0);
	LONG lScreenPosY = GetIntParam(cmd, 1);

	char* pString = GetStringParam( cmd, 2 );
	if(NULL == pString) return -1;

	LONG lIsShow = GetIntParam(cmd, 3);
	CMessage msg(MSG_S2C_OTHER_SHOW_STRING);
	msg.Add(lIsShow);
	if(0 != lIsShow)
	{
		msg.Add(lScreenPosX);
		msg.Add(lScreenPosY);
		msg.Add(pString);
	}
	msg.SendToPlayer(pPlayer->GetExID(), false);

	M_FREE( pString, sizeof(char)*MAX_VAR_LEN );
	return 1;
}
Esempio n. 2
0
double CScript::Play3DSound(const char* cmd, char* retStr/* =NULL */)
{
	char* strFile = GetStringParam(cmd,0);
	long lLoop = GetIntParam(cmd,1);
	long lPosX = GetIntParam(cmd,2);
	long lPosY = GetIntParam(cmd,3);
	long lPosZ = GetIntParam(cmd,4);
	if (strFile)
	{
		if (lLoop != ERROR_CODE && 
			lPosX != ERROR_CODE &&
			lPosY != ERROR_CODE &&
			lPosZ != ERROR_CODE)
		{
			CPlayer* pPlayer = dynamic_cast<CPlayer*>(GetSrcShape());	
			if (pPlayer)
			{
				CMessage msg(MSG_S2C_RGN_PLAY3DSOUND);
				msg.Add(strFile);
				msg.Add(lLoop);
				msg.Add(lPosX);
				msg.Add(lPosY);
				msg.Add(lPosZ);
				msg.SendToPlayer(pPlayer->GetExID());
			}
			
		}
		M_FREE( strFile, sizeof(char)*MAX_VAR_LEN );
	}

	return 1;
}
Esempio n. 3
0
double CScript::AddGoodToShortCutBar(const char* cmd, char* retStr)
{
	int nRet = 0;

	char* name=GetStringParam(cmd,0);
	if( name )
	{
		CPlayer* pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);
		if(pPlayer)
		{
			CGoods * pGoods = pPlayer->FindGoodInPack(name);
			//如果检测有该物品
			if(pGoods)
			{
				long  nBarNo = static_cast<long>(GetIntParam(cmd, 1));
				if( nBarNo != ERROR_CODE && nBarNo != INVILID_VALUE)
				{
					pPlayer->SetHotKey(nBarNo, pGoods->GetBasePropertiesIndex());

					CMessage msg(MSG_S2C_SETHOTKEY);
					msg.Add((char)HOTKEY_SET_SUCCEED);
					msg.Add((BYTE)nBarNo);
					msg.Add(pGoods->GetBasePropertiesIndex());
					msg.SendToPlayer(pPlayer->GetExID());	
					nRet = 1;
				}
			}
		}
		M_FREE( name, sizeof(char)*MAX_VAR_LEN );
	}
	return nRet;
}
Esempio n. 4
0
double CScript::OperaInterface(const char* cmd, char* retStr)
{
	int nRet = 0;
	//变化方式
	long lOperaMode = static_cast<long>(GetIntParam(cmd, 0));
	if( lOperaMode != ERROR_CODE && lOperaMode != INVILID_VALUE )
	{
		char* InterfaceName=GetStringParam(cmd,1);
		if( InterfaceName )
		{
			CPlayer* pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);
			if( pPlayer )
			{
#ifdef _DEBUG
				OutputDebugString("\n================发送关闭界面消息=========================\n");
#endif
				CMessage msg(MSG_S2C_OTHER_OPERAINTERFACE);
				msg.Add(lOperaMode);
				msg.Add(InterfaceName);
				msg.SendToPlayer(pPlayer->GetExID());
				nRet = 1;
			}
			M_FREE( InterfaceName, sizeof(char)*MAX_VAR_LEN );
		}
	}
	return nRet;
}
Esempio n. 5
0
double CScript::PlayVideo(const char* CmdStr, char* retStr)
{
	double ret = 0;	
	char* strFileName = GetStringParam(CmdStr,0);
	long  lLoop = GetIntParam(CmdStr,1);
	long  lX	= GetIntParam(CmdStr,2);
	long  lY	= GetIntParam(CmdStr,3);
	long  lWidth = GetIntParam(CmdStr,4);
	long  lHeight = GetIntParam(CmdStr,5);
	if (p_SrcShape!=NULL && strFileName!=NULL   && lLoop!=ERROR_CODE && lLoop!=INVILID_VALUE 
		&& lX!=ERROR_CODE && lX!=INVILID_VALUE 
		&& lY!=ERROR_CODE && lY!=INVILID_VALUE
		&& lWidth!=ERROR_CODE && lWidth!=INVILID_VALUE
		&& lHeight!=ERROR_CODE && lHeight!=INVILID_VALUE)
	{
		CMessage msg(MSG_S2C_OTHER_PLAY_VIDEO);
		msg.Add(strFileName);
		msg.Add(lLoop);
		msg.Add(lX);
		msg.Add(lY);
		msg.Add(lWidth);
		msg.Add(lHeight);
		msg.SendToPlayer(p_SrcShape->GetExID());
		ret = 1;
	}

	M_FREE( strFileName, sizeof(char)*MAX_VAR_LEN );
	return ret;
}
Esempio n. 6
0
void DoW2SMailSendResult( CMessage *pMsg )
{
	long lRet=0;
	BYTE *ByteData = NULL;
	CPlayer *pPlayer=NULL;
	CGUID WriterGuid;
	pMsg->GetGUID(WriterGuid);
	lRet = pMsg->GetLong();
	long lByteDataLen = pMsg->GetLong();					

	if (lRet==1)
	{
		ByteData = (BYTE*)M_ALLOC(sizeof(BYTE)*lByteDataLen);	
		pMsg->GetEx(ByteData,lByteDataLen);
		long Pos = 0;
		tagMailParam *pMailParam = OBJ_CREATE(tagMailParam);
		GameManager::GetInstance()->GetMailManager()->DecordMailMsgFromByteArray(ByteData,Pos,pMailParam);
		CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam);
		pPlayer = GetGame()->FindPlayer(pMail->GetWriter().c_str());

		if (pPlayer)
		{
			int nRet = GameManager::GetInstance()->GetMailManager()->ReMoveGoldAndGoods(pMail,pPlayer);//--扣除物品和金钱
			GameManager::GetInstance()->GetMailManager()->SendMailToReceiver(pMail->GetExID(),nRet);
		}

		OBJ_RELEASE(CMail, pMail);			
		M_FREE(ByteData, sizeof(BYTE)*lByteDataLen);				
	}
	else
	{
		GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(WriterGuid,MAIL_SENDING_FAILED_INVALID_RECEIVER);//--非法收信人
	}
}
Esempio n. 7
0
double CScript::PostPlayerInfo(const char* CmdStr, char* retStr)
{
	if(p_SrcShape==NULL) return 0;

	char* strContend = GetStringParam(CmdStr,0);
	if(strContend == NULL)
	{
		return 0;
	}
	DWORD dwFrColor = static_cast<DWORD>(GetIntParam(CmdStr, 1));
	DWORD dwBkColor = static_cast<DWORD>(GetIntParam(CmdStr, 2));

	if (dwFrColor==ERROR_CODE)
		dwFrColor = 0xffffffff;

	if (dwBkColor==ERROR_CODE)
		dwBkColor = 0xff000000;

	CMessage msg(MSG_S2C_OTHER_ADDPLAYERINFO);
	msg.Add((LONG)0);
	msg.Add(dwFrColor);
	msg.Add(dwBkColor);
	msg.Add(strContend);
	msg.SendToPlayer(p_SrcShape->GetExID());

	M_FREE( strContend, sizeof(char)*MAX_VAR_LEN );
	return 1;
}
Esempio n. 8
0
//为当前对象注册一个定时器
double CScript::RegisterTimer(const char* cmd, char* retStr)
{
	int nRet = 0;
	long lfuturetime = static_cast<long>(GetIntParam(cmd, 0));
	if(lfuturetime != ERROR_CODE && lfuturetime != INVILID_VALUE)
	{
		long lInterTime = static_cast<long>(GetIntParam(cmd, 1));
		if(lInterTime != ERROR_CODE && lInterTime != INVILID_VALUE)
		{
			char* pszScriptName=GetStringParam(cmd,2);
			if( pszScriptName )
			{
				long lUserData = static_cast<long>(GetIntParam(cmd, 3));
				if(lUserData != ERROR_CODE && lUserData != INVILID_VALUE)
				{
					CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_SrcShape);
					if( pMoveShape )
					{
						//添加提示
						nRet = pMoveShape->RegisterScriptTimer(lfuturetime,lInterTime,
							pszScriptName,lUserData);
					}
				}
				M_FREE( pszScriptName, sizeof(char)*MAX_VAR_LEN );
			}
		}
	}
	return nRet;
}
Esempio n. 9
0
double CScript::PlaySound(const char* CmdStr, char* retStr)
{
	CPlayer* pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);
	if(!pPlayer || !m_pRegion)	return 0;

	char* strFile = GetStringParam(CmdStr, 0);
	int  nToAround = GetIntParam(CmdStr, 1);
	if (nToAround == ERROR_CODE)
	{
		nToAround = 0;
	}

	if (strFile)
	{
		CMessage msg(MSG_S2C_RGN_PLAYSOUND);
		msg.Add(strFile);
		//只发给自己
		if(nToAround == 0 && pPlayer)
			msg.SendToPlayer( pPlayer -> GetExID() );
		else
			msg.SendToAround((CServerRegion*)GetRegion(), pPlayer->GetTileX(), pPlayer->GetTileY());

		M_FREE( strFile, sizeof(char)*MAX_VAR_LEN );
	}
	return 1;
}
Esempio n. 10
0
double CScript::Ifdef(const char* CmdStr, char* retStr)
{

    char* varname=GetStringParam(CmdStr,0);
    if (varname)
    {
        bool bRet=false;
        if(p_SrcShape && (OBJECT_TYPE)p_SrcShape->GetType() == TYPE_PLAYER)
        {
            bRet = ((CPlayer*)this->GetSrcShape())->GetVariableList()->isExist(varname);
            M_FREE( varname, sizeof(char)*MAX_VAR_LEN );
            return bRet;
        }
    }
    M_FREE( varname, sizeof(char)*MAX_VAR_LEN );
    return 0;
}
Esempio n. 11
0
//! 获取一个字符串的子串
//! 参数1:要提取的子串的开始位置,从1开始(若输入的位置大于字符串长度,返回失败;若为0,则返回字符串最后一个字节, 若为负数-n则返回除去最后n个字节的字符串)
//! 参数2:要提取的子串的结束位置,从1开始(若输入的位置大于字符串长度,转换为最大长度)
//! 参数3:提取的目标字符串
//! 参数4:返回子串的变量名
//! 返回值:1,提取成功,0,提取失败
double CScript::GetSubString(const char* CmdStr, char* retStr)
{
    long BeginPos = GetIntParam(CmdStr, 0);
    long EndPos = GetIntParam(CmdStr, 1);

    char* pSrcStr =GetStringParam(CmdStr, 2);
    if (NULL == pSrcStr)
        return 0.0f;

    DWORD SrcLen = strlen(pSrcStr);
    if(0 == BeginPos)
    {
        BeginPos = SrcLen;
        EndPos = SrcLen;
    }
    else if (0 > BeginPos)
    {
        EndPos = SrcLen + BeginPos;
        BeginPos = 1;
    }
    else if(EndPos > SrcLen)
        EndPos = SrcLen;

    if (BeginPos > SrcLen || EndPos < BeginPos)
    {
        M_FREE( pSrcStr, sizeof(char)*MAX_VAR_LEN );
        return 0.0f;
    }

    char* pDstName =GetStringParam(CmdStr, 3);
    if (NULL == pDstName)
    {
        M_FREE( pSrcStr, sizeof(char)*MAX_VAR_LEN );
        return 0.0f;
    }

    char szRe[MAX_VAR_LEN] = {0};
    memcpy(szRe, pSrcStr + (BeginPos - 1), EndPos - BeginPos + 1);
    int ret = SetScriptVarValue(dynamic_cast<CMoveShape*>(p_SrcShape), pDstName, szRe);


    M_FREE( pSrcStr, sizeof(char)*MAX_VAR_LEN );
    M_FREE( pDstName, sizeof(char)*MAX_VAR_LEN );

    return ret;
}
	void CQuestionManager::ClearQuestions()
	{
		for( QuestionList::iterator it = m_Questions.begin(); it != m_Questions.end(); ++ it )
		{
			Question &ques = *it;
			M_FREE( ques.data.buf, sizeof(char)*(ques.data.size) );
		}
		m_Questions.clear();
	}
Esempio n. 13
0
double CScript::Goto(const char* CmdStr, char* retStr)
{
    char *str=GetStringParam(CmdStr, 0);
    if (str)
    {
        JumpTo( str );
        M_FREE( str, sizeof(char)*MAX_VAR_LEN );
    }
    return 1;
}
Esempio n. 14
0
void DoW2SMailReceive( CMessage *pMsg )
{
	BYTE *ByteData = NULL;
	list<CGUID> lMailGuid;
	list<CMail*> lMailList;
	CGUID playerGuid;
	pMsg->GetGUID(playerGuid);

	long lByteDataLen = pMsg->GetLong();
	ByteData = (BYTE*)M_ALLOC(sizeof(BYTE)*lByteDataLen);	
	pMsg->GetEx(ByteData,lByteDataLen);
	time_t t_CurrentTime = time(NULL);

	CPlayer *pPlayer =  GetGame()->FindPlayer(playerGuid);
	if (pPlayer)
	{				
		long Pos = 0;
		long lNum = _GetLongFromByteArray(ByteData,Pos);
		for (int i=0; i<lNum; ++i)
		{
			tagMailParam *pMailParam = OBJ_CREATE(tagMailParam);
			GameManager::GetInstance()->GetMailManager()->DecordFromByteArray(ByteData,Pos,pMailParam);

			CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam);

			if(!GameManager::GetInstance()->GetMailManager()->SetMapMail(pMail))
			{
				lMailGuid.push_back(pMailParam->guid);					
			}
			else
			{
				lMailList.push_back(pMail);
			}
		}
		if(lMailGuid.size()>0)
		{
			//删除邮件		
			GameManager::GetInstance()->GetMailManager()->DeleteMailToWS(lMailGuid,pPlayer);				
		}

		vector<BYTE> vectorByte;
		vectorByte.clear();

		_AddToByteArray(&vectorByte,(long)lMailList.size());
			
		pPlayer->SetReceiveMail(true);	
		for (list<CMail*>::iterator it=lMailList.begin();it!=lMailList.end();++it)
		{
			pPlayer->AddReceiveMailList((*it)->GetExID());
		}

		GameManager::GetInstance()->GetMailManager()->SendReceiveMail( pPlayer );
	}
	M_FREE(ByteData, lByteDataLen);
}
Esempio n. 15
0
MAT	*m_inverse(const MAT *A, MAT *out)
{
  unsigned int	i;
  char MatrixTempBuffer[ 4000 ];
  VEC	*tmp = VNULL, *tmp2 = VNULL;
  MAT	*A_cp = MNULL;
  PERM	*pivot = PNULL;

  if ( ! A )
    error(E_NULL,"m_inverse");
  if ( A->m != A->n )
    error(E_SQUARE,"m_inverse");
  if ( ! out || out->m < A->m || out->n < A->n )
    out = m_resize(out,A->m,A->n);

  if( SET_MAT_SIZE( A->m, A->n ) < 1000 )
    mat_get( &A_cp, (void *)( MatrixTempBuffer + 2000 ), A->m, A->n );
  else
    A_cp = matrix_get( A->m, A->n  );

  A_cp = m_copy( A, A_cp );
  if( SET_VEC_SIZE( A->m ) < 1000 ) {
    vec_get( &tmp, (void *)MatrixTempBuffer, A->m );
    vec_get( &tmp2, (void *)(MatrixTempBuffer + 1000), A->m );
  } else {
    tmp   = v_get( A->m );
    tmp2  = v_get( A->m );
  }

  if( SET_PERM_SIZE( A->m ) < 1000 ) {
    perm_get( &pivot, (void *)( MatrixTempBuffer + 3000 ), A->m );
  } else {
    pivot   = px_get( A->m );
  }

  LUfactor(A_cp,pivot);
  //tracecatch_matrix(LUfactor(A_cp,pivot),"m_inverse");
  for ( i = 0; i < A->n; i++ ){
    v_zero(tmp);
    tmp->ve[i] = 1.0;
    LUsolve(A_cp,pivot,tmp,tmp2);
    //tracecatch_matrix(LUsolve(A_cp,pivot,tmp,tmp2),"m_inverse");
    set_col(out,i,tmp2);
  }
  if( tmp != (VEC *)(MatrixTempBuffer ) ) // память выделялась, надо освободить
    V_FREE(tmp);
  if( tmp2 != (VEC *)(MatrixTempBuffer + 1000) ) // память выделялась, надо освободить
    V_FREE(tmp2);
  if( A_cp != (MAT *)(MatrixTempBuffer + 2000) ) // память выделялась, надо освободить
    M_FREE(A_cp);
  if( pivot != (PERM *)(MatrixTempBuffer + 3000) ) // память выделялась, надо освободить
    PX_FREE( pivot );
  return out;
}
Esempio n. 16
0
File: svd.c Progetto: Rainwin2015/C
VEC	*svd(MAT *A, MAT *U, MAT *V, VEC *d)
#endif
{
	STATIC VEC	*f=VNULL;
	int	i, limit;
	MAT	*A_tmp;

	if ( ! A )
		error(E_NULL,"svd");
	if ( ( U && ( U->m != U->n ) ) || ( V && ( V->m != V->n ) ) )
		error(E_SQUARE,"svd");
	if ( ( U && U->m != A->m ) || ( V && V->m != A->n ) )
		error(E_SIZES,"svd");

	A_tmp = m_copy(A,MNULL);
	if ( U != MNULL )
	    m_ident(U);
	if ( V != MNULL )
	    m_ident(V);
	limit = min(A_tmp->m,A_tmp->n);
	d = v_resize(d,limit);
	f = v_resize(f,limit-1);
	MEM_STAT_REG(f,TYPE_VEC);

	bifactor(A_tmp,U,V);
	if ( A_tmp->m >= A_tmp->n )
	    for ( i = 0; i < limit; i++ )
	    {
		d->ve[i] = A_tmp->me[i][i];
		if ( i+1 < limit )
		    f->ve[i] = A_tmp->me[i][i+1];
	    }
	else
	    for ( i = 0; i < limit; i++ )
	    {
		d->ve[i] = A_tmp->me[i][i];
		if ( i+1 < limit )
		    f->ve[i] = A_tmp->me[i+1][i];
	    }


	if ( A_tmp->m >= A_tmp->n )
	    bisvd(d,f,U,V);
	else
	    bisvd(d,f,V,U);

	M_FREE(A_tmp);
#ifdef	THREADSAFE
	V_FREE(f);
#endif

	return d;
}
Esempio n. 17
0
double CScript::SetAttrStr(const char* CmdStr, char* retStr)
{
	OBJECT_TYPE type;
	CGUID id;

	if(!GetSrcShape()) return -1.0f;

	int param = GetIntParam(CmdStr, 0);
	if(param != ERROR_CODE && param != INVILID_VALUE)
	{
		type = (OBJECT_TYPE)param;

		char* pIdName = GetStringParam(CmdStr, 1);
		if(!pIdName) return -1.0f;

		id = GetScriptGuidValue((CMoveShape*)GetSrcShape(), pIdName);

		CMoveShape* shape = NULL;

		char* name = GetStringParam(CmdStr, 2);

		if(!name)
		{
			M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
			return -1.0f;
		}

		const char* strValue = GetStringParam(CmdStr, 3);
		if(!strValue)
		{
			M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
			M_FREE( name, sizeof(char)*MAX_VAR_LEN );
			return -1.0f;
		}

		if(NULL_GUID == id) // 默认id=0时,直接调用SrcShape的SetAttr接口
		{
			shape = (CMoveShape*)GetSrcShape();
		}
		else
		{
			shape = GetGame()->FindShape(type, id);
		}

		if(shape)
		{
			SetScriptVarValue(shape, name, strValue);
		}

		M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
		M_FREE( name, sizeof(char)*MAX_VAR_LEN );
		M_FREE( strValue, sizeof(char)*MAX_VAR_LEN );
	}
	else // 参数是字符串
	{
		AddErrorLogText(CStringReading::LoadString(IDS_GS_FUNCTION, STR_GS_FUNCTION_SETATTRFIRSTVARISSTRING));
	}

	return -1.0f;
}
Esempio n. 18
0
//设置目标字符串变量的值
double CScript::SetDestStrVar(const char* cmd, char* retStr)
{
	double dbRet = 0;
	CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_DesShape);
	if(!pMoveShape)	return dbRet;

	char* szValueName= GetStringParam(cmd,0);
	if(szValueName)
	{
		if( strlen(szValueName) >= 2 && szValueName[0]=='#')
		{
			char* szValue = GetStringParam(cmd,1);
			if(szValue)
			{			
				pMoveShape->GetVariableList()->SetVarValue(szValueName,szValue);
				M_FREE( szValue, sizeof(char)*MAX_VAR_LEN );
			}
		}
		M_FREE( szValueName, sizeof(char)*MAX_VAR_LEN );
	}
	return dbRet;
}
Esempio n. 19
0
//取得目标guid
double CScript::GetDesShapeGUID(const char* cmd, char* retStr)
{
	if (p_DesShape==NULL)
	{
		return -1;
	}
	char* cGuidName= GetStringParam(cmd,0);
	if (cGuidName== NULL)	return -1;

	SetScriptGuidValue((CMoveShape*)(p_SrcShape), cGuidName, p_DesShape->GetExID());

	M_FREE( cGuidName, sizeof(char)*MAX_VAR_LEN );
	return 0;
}
Esempio n. 20
0
//目标执行一个脚本
double CScript::DesRunScript(const char* cmd, char* retStr)
{
	char * cScriptName= GetStringParam(cmd,0);
	if (cScriptName== NULL)	return -1;

	stRunScript st;
	st.pszFileName = cScriptName;
	st.srcShape = p_DesShape;
	st.pRegion = (CRegion*)(p_SrcShape->GetFather());
	st.desShape = NULL;
	RunScript(&st, (char*)GetGame()->GetScriptFileData(cScriptName));
	M_FREE( cScriptName, sizeof(char)*MAX_VAR_LEN );
	return 0;
}
Esempio n. 21
0
double CScript::IfDestDef(const char* cmd, char* retStr)
{
    bool bRet = false;
    CPlayer *pPlayer = dynamic_cast<CPlayer*>(p_DesShape);
    if(!pPlayer)	return bRet;

    char* varname=GetStringParam(cmd,0);
    if (varname)
    {
        bRet = pPlayer->GetVariableList()->isExist(varname);
    }
    M_FREE( varname, sizeof(char)*MAX_VAR_LEN );
    return bRet;
}
Esempio n. 22
0
double CScript::GetPlayerAllVariables(const char* CmdStr, char* retStr)
{
	if(p_SrcShape == NULL) return 0;

	CHAR* szName = GetStringParam( CmdStr, 0 );
	if( szName )
	{
		CPlayer* pPlayer = GetGame() -> FindPlayer( szName );
		if( pPlayer )
		{
			//##找到该玩家
			CHAR szText[10240] = {0};
			ZeroMemory( szText, sizeof(szText) );

			CVariableList* pVarList = pPlayer->GetVariableList();

			if (pVarList)
			{
				CVariableList::varlistitr itr = pVarList->VarListBegin();

				for(; itr != pVarList->VarListEnd(); itr++)
				{
					// 简单变量
					if( itr->second->Array == 0 )
					{
						_snprintf(szText, 10240, "%s = %d", itr->first.c_str(), (int)(itr->second->Value));
						((CPlayer*)p_SrcShape) -> SendNotifyMessage( szText, 0xff00ff00, 0, eNOTIFYPOS_LEFT_BOTTOM );
					}
					else if( itr->second->Array > 0)	// 数组变量
					{
						for(int j = 0; j < itr->second->Array; j++)
						{
							_snprintf(szText, 10240, "%s[%d] = %d", itr->first.c_str(), j, itr->second->Value[j]);
							((CPlayer*)p_SrcShape) -> SendNotifyMessage( szText, 0xff00ff00, 0, eNOTIFYPOS_LEFT_BOTTOM );
						}
					}
					else
					{	//字符串变量
						_snprintf(szText, 10240, "%s = \"%s\"", itr->first.c_str(), itr->second->strValue);
						((CPlayer*)p_SrcShape) -> SendNotifyMessage( szText, 0xff00ff00, 0, eNOTIFYPOS_LEFT_BOTTOM );
					}
				}
			}
		}

		M_FREE( szName, sizeof(char)*MAX_VAR_LEN );
	}

	return 1;
}
Esempio n. 23
0
//--------------------------------------------------------------------------------------
BOOL DbgInit(char *lpszDbgLogPath)
{
    m_hDbgFile = NULL;
    m_hDbgFileMutex = NULL;
    
    if (m_hDbgFileMutex = CreateMutexA(NULL, FALSE, DBG_MUTEX_NAME))
    {
        if ((m_hDbgFile = CreateFileA(
            lpszDbgLogPath, 
            GENERIC_READ | GENERIC_WRITE, 
            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
            NULL, 
            OPEN_ALWAYS,
            FILE_ATTRIBUTE_NORMAL,
            NULL)) != INVALID_HANDLE_VALUE)
        {
            // OK
            SetFilePointer(m_hDbgFile, 0, NULL, FILE_END);
			const unsigned int len = 30;
			DWORD dwWritten = 0;
			char *lpszBuff = (char *)M_ALLOC(len);
			if (lpszBuff == NULL)
				return FALSE;
			SYSTEMTIME time;
			GetLocalTime(&time);
			sprintf_s(lpszBuff, len, "Dbg initialized %02d.%02d %02d:%02d\n", time.wDay, time.wMonth,time.wHour,time.wMinute);	
			WriteFile(m_hDbgFile, lpszBuff, strlen(lpszBuff), &dwWritten, NULL);
			M_FREE(lpszBuff);
            return TRUE;
        }
        else
        {                
            DbgMsg(__FILE__, __LINE__, "CreateFile() ERROR %d\n", GetLastError());
        }

        CloseHandle(m_hDbgFileMutex);
        
        m_hDbgFile = NULL;
        m_hDbgFileMutex = NULL;
    }
    else
    {
        DbgMsg(__FILE__, __LINE__, "CreateMutex() ERROR %d\n", GetLastError());
    }

    return FALSE;
}
Esempio n. 24
0
//!	请求向数据库写入数据				
VOID HardInfoList::RequestWriteDB(tagHardInfoGroup &HardInfoGroup)
{
	DbOperator *pDbOperator = DbOperator::CreateInHardOperator(m_dwSMID, HardInfoGroup.dwUseNum, HardInfoGroup.pHardwareInfo);
	if(NULL != pDbOperator)
	{
		if(pDbOperator->Begin())
		{
			m_setWriting.insert(HardInfoGroup.pHardwareInfo);
			return;
		}
		DbOperator::ReleaseOperator(&pDbOperator);
	}
	else
	{
		M_FREE(HardInfoGroup.pHardwareInfo, sizeof(tagHardwareInfo) * HARD_INFO_GROUP_NUM);
	}
}
Esempio n. 25
0
void DoW2SMailSend( CMessage *pMsg )
{
	BYTE *ByteData = NULL;	
	CGUID MailGuid;

	pMsg->GetGUID(MailGuid);

	long lByteDataLen = pMsg->GetLong();
	ByteData = (BYTE*)M_ALLOC(sizeof(BYTE)*lByteDataLen);	
	pMsg->GetEx(ByteData,lByteDataLen);
	long Pos = 0;
	tagMailParam *pMailParam = OBJ_CREATE(tagMailParam);

	GameManager::GetInstance()->GetMailManager()->DecordFromByteArray(ByteData,Pos,pMailParam);
	CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam);//用pMailParam作为构造函数创建CMail对象
	GameManager::GetInstance()->GetMailManager()->SendMailToClient(pMail);
	M_FREE(ByteData, sizeof(BYTE)*lByteDataLen);
}
Esempio n. 26
0
double CScript::If(const char* CmdStr, char* retStr)
{
    CScript *pTemptScript = PopFreeScript(CmdStr);
    InitChildScriptData(pTemptScript);

    long len = lstrlen(CmdStr);
    char* str = (char*)M_ALLOC(sizeof(char)*(len+1));
    memcpy(str, &CmdStr[3], len-4);
    str[len-4] = ';';
    str[len-3] = 0;
    //设置变量
    pTemptScript->SetVariableList(m_pVariableList);
    pTemptScript->RunLine(str);
    M_FREE(str, len+1);
    double dbRet = pTemptScript->m_Value[0];
    PushFreeScript(pTemptScript);
    return dbRet;
}
Esempio n. 27
0
double CScript::TestLog(const char* CmdStr, char* retStr)
{
    DWORD time = timeGetTime();
    char tt[32];
    ultoa(time, tt, 10);
    long lRet1 = strlen(CmdStr);
    long lRet2 = strlen(tt);
    char* ptr = (char*)M_ALLOC(lRet1 + lRet2 + 2);
    strcpy_s(ptr, lRet1 + lRet2 + 2, tt);
    strcat_s(ptr, lRet1 + lRet2 + 2, ":");
    strcat_s(ptr, lRet1 + lRet2 + 2, CmdStr);
    if (ptr)
    {
        PutDebugString(ptr);
        M_FREE(ptr, lRet1 + lRet2 + 2);
    }
    return 1;
}
Esempio n. 28
0
//--------------------------------------------------------------------------------------
DWORD GetKernelSymbolOffset(char *lpszSymbolName)
{
    DWORD Ret = 0;

    // get system modules information
    PRTL_PROCESS_MODULES Info = (PRTL_PROCESS_MODULES)GetSysInf(SystemModuleInformation);
    if (Info)
    {
        char *lpszKernelName = (char *)Info->Modules[0].FullPathName + Info->Modules[0].OffsetToFileName;
        char szKernelPath[MAX_PATH];

        // get full kernel image path
        GetSystemDirectory(szKernelPath, MAX_PATH);
        lstrcat(szKernelPath, "\\");
        lstrcat(szKernelPath, lpszKernelName);

        DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Using kernel binary '%s'\r\n", szKernelPath);

        // load kernel module
        HMODULE hModule = LoadLibraryEx(szKernelPath, NULL, DONT_RESOLVE_DLL_REFERENCES);
        if (hModule)
        {
            // get symbol offset
            LARGE_INTEGER Addr;
            Addr.QuadPart = GetSymbolByName(szKernelPath, hModule, lpszSymbolName);
            if (Addr.QuadPart > 0)
            {
                Addr.QuadPart -= (ULONGLONG)hModule;
                Ret = Addr.LowPart;
            }                       

            FreeLibrary(hModule);
        }
        else
        {
            DbgMsg(__FILE__, __LINE__, "LoadLibraryEx() ERROR %d\r\n", GetLastError());
        }

        M_FREE(Info);
    }

    return Ret;
}
Esempio n. 29
0
double CScript::IsShapeValid( const char *cmd, char *retStr )
{
	int type = GetIntParam( cmd, 0 );
	if( type == ERROR_CODE || type == INVILID_VALUE )
	{
		return -1;
	}
	char *strGUID = GetStringParam( cmd, 1 );
	if( strGUID == NULL )
	{
		return -1;
	}

	const CGUID &guid = GetScriptGuidValue( (CMoveShape*) p_SrcShape, strGUID );
	CMoveShape *pShape = GetGame()->FindShape( (OBJECT_TYPE) type, guid );
	
	M_FREE( strGUID, sizeof(char)*MAX_VAR_LEN );

	return pShape != NULL;
}
Esempio n. 30
0
//弹出按钮的帮助提示
double CScript::HelpHint(const char* cmd, char* retStr)
{
	int nRet = 0;
	char* pszScriptName=GetStringParam(cmd,0);
	if( pszScriptName )
	{
		long lFutureDelTime = static_cast<long>(GetIntParam(cmd, 1));
		if( lFutureDelTime != ERROR_CODE && lFutureDelTime != INVILID_VALUE )
		{
			CPlayer* pPlayer = dynamic_cast<CPlayer*>(p_SrcShape);
			if( pPlayer )
			{
				//添加提示
				nRet = pPlayer->AddHelpHint(pszScriptName,lFutureDelTime);
			}
		}
		M_FREE( pszScriptName, sizeof(char)*MAX_VAR_LEN );
	}
	return nRet;
}