当前位置: 首页>>代码示例>>C++>>正文


C++ GM_CHECK_NUM_PARAMS函数代码示例

本文整理汇总了C++中GM_CHECK_NUM_PARAMS函数的典型用法代码示例。如果您正苦于以下问题:C++ GM_CHECK_NUM_PARAMS函数的具体用法?C++ GM_CHECK_NUM_PARAMS怎么用?C++ GM_CHECK_NUM_PARAMS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GM_CHECK_NUM_PARAMS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gmStringSetAt

// string string.SetAt(int a_index, int a_char);
// Returns string with modified character at offset, or original string if index out of range.
static int GM_CDECL gmStringSetAt(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);
  GM_CHECK_INT_PARAM(index, 0);
  GM_CHECK_INT_PARAM(newChar, 1);

  const gmVariable * var = a_thread->GetThis();

  GM_ASSERT(var->m_type == GM_STRING);

  gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
  const char * str = (const char *) *strObj;
  int strLength = strObj->GetLength();

  if(index < 0 || index >= strLength)
  {
    a_thread->PushString(strObj); //Return original string if index out of range
    return GM_OK;
  }

  char * buffer = (char *) alloca(strLength + 1); 
  memcpy(buffer, str, strLength + 1); //Copy old string
  buffer[index] = (char)newChar; //Set character in string

  a_thread->PushNewString(buffer, strLength);
  return GM_OK;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:29,代码来源:gmStringLib.cpp

示例2: gmfFireTeamLeave

static int GM_CDECL gmfFireTeamLeave( gmThread *a_thread )
{
	CHECK_THIS_BOT();
	GM_CHECK_NUM_PARAMS( 0 );
	InterfaceFuncs::FireTeamLeave( native );
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:7,代码来源:gmETBinds.cpp

示例3: gmfStringSpanExcluding

static int GM_CDECL gmfStringSpanExcluding(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);

  if(a_thread->ParamType(0) == GM_STRING)
  {
    const gmVariable * var = a_thread->GetThis();
  
    GM_ASSERT(var->m_type == GM_STRING);

    gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
    const char * thisStr = (const char *) *strObj;
    const char * otherStr = a_thread->ParamString(0);
    
    int offset = strcspn(thisStr, otherStr);
    char * buffer = (char *) alloca(offset + 1);
    memcpy(buffer, thisStr, offset);
    buffer[offset] = 0;

    a_thread->PushNewString(buffer, offset);

    return GM_OK;
  }

  return GM_EXCEPTION;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:26,代码来源:gmStringLib.cpp

示例4: gmfFireTeamGetInfo

static int GM_CDECL gmfFireTeamGetInfo( gmThread *a_thread )
{
	CHECK_THIS_BOT();
	GM_CHECK_NUM_PARAMS( 0 );

	ET_FireTeamInfo ft;
	if ( InterfaceFuncs::FireTeamGetInfo( native, ft ) && ft.mInFireTeam )
	{
		DisableGCInScope gcEn( a_thread->GetMachine() );

		gmMachine *pM = a_thread->GetMachine();
		gmTableObject *tbl = pM->AllocTableObject();
		gmTableObject *mbrtbl = pM->AllocTableObject();
		tbl->Set( pM, "Members", gmVariable( mbrtbl ) );

		tbl->Set( pM, "FireTeamNum", gmVariable( ft.mFireTeamNum ) );
		tbl->Set( pM, "Leader", gmVariable::EntityVar( ft.mLeader.AsInt() ) );

		int m = 0;
		for ( int i = 0; i < ET_FireTeamInfo::MaxMembers; ++i )
		{
			if ( ft.mMembers[ i ].IsValid() )
			{
				mbrtbl->Set( pM, m++, gmVariable::EntityVar( ft.mMembers[ i ].AsInt() ) );
			}
		}
		a_thread->PushTable( tbl );
	}
	else
		a_thread->PushNull();

	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:33,代码来源:gmETBinds.cpp

示例5: gmfMax

static int GM_CDECL gmfMax(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(2);

  int minType = gmMin<int>(a_thread->ParamType(0), a_thread->ParamType(1));
  if(minType < GM_INT)
  {
    return GM_EXCEPTION;
  }

  int maxType = gmMax<int>(a_thread->ParamType(0), a_thread->ParamType(1));

  if(maxType == GM_INT)
  {
    int valX = a_thread->Param(0).m_value.m_int;
    int valY = a_thread->Param(1).m_value.m_int;
    a_thread->PushInt( gmMax(valX, valY) );

    return GM_OK;
  }
  else if(maxType == GM_FLOAT)
  {
    float valX = gmGetFloatOrIntParamAsFloat(a_thread, 0);
    float valY = gmGetFloatOrIntParamAsFloat(a_thread, 1);
    a_thread->PushFloat( gmMax(valX, valY) );

    return GM_OK;
  }
  else
  {
    return GM_EXCEPTION;
  }
}
开发者ID:helloqinglan,项目名称:qinglan,代码行数:33,代码来源:gmMathLib.cpp

示例6: gmfGetMG42Info

// function: GetMG42Info
//		Returns currently mounted mg42 info for the bot
//
//
// Parameters:
//
//		GameEntity
//		Table
//
// Returns:
//		MG42 Info
static int gmfGetMG42Info( gmThread *a_thread )
{
	CHECK_THIS_BOT();
	GM_CHECK_NUM_PARAMS( 1 );

	GM_CHECK_TABLE_PARAM( tbl, 0 );

	DisableGCInScope gcEn( a_thread->GetMachine() );

	if ( !tbl )
		tbl = a_thread->GetMachine()->AllocTableObject();

	ET_MG42Info mg42Info;
	if ( tbl != NULL && InterfaceFuncs::GetMg42Properties( native, mg42Info ) )
	{
		tbl->Set( a_thread->GetMachine(), "CenterFacing", gmVariable( mg42Info.mCenterFacing ) );
		tbl->Set( a_thread->GetMachine(), "MinHorizontal", gmVariable( mg42Info.mMinHorizontalArc ) );
		tbl->Set( a_thread->GetMachine(), "MaxHorizontal", gmVariable( mg42Info.mMaxHorizontalArc ) );
		tbl->Set( a_thread->GetMachine(), "MinVertical", gmVariable( mg42Info.mMinVerticalArc ) );
		tbl->Set( a_thread->GetMachine(), "MaxVertical", gmVariable( mg42Info.mMaxVerticalArc ) );
		a_thread->PushInt( 1 );
	}
	else
	{
		a_thread->PushNull();
	}
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:39,代码来源:gmETBinds.cpp

示例7: gmfVoteNo

static int GM_CDECL gmfVoteNo( gmThread *a_thread )
{
	CHECK_THIS_BOT();
	GM_CHECK_NUM_PARAMS( 0 );
	native->GameCommand( "vote no" );
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:7,代码来源:gmETBinds.cpp

示例8: gmfGetCabinetData

// function: GetCabinetData
//		Returns table of data for the cabinet
//
//
// Parameters:
//
//		GameEntity
//		Table
//
// Returns:
//		Table of Cabinet Data
static int gmfGetCabinetData( gmThread *a_thread )
{
	GM_CHECK_NUM_PARAMS( 2 );
	GameEntity gameEnt;
	GM_CHECK_GAMEENTITY_FROM_PARAM( gameEnt, 0 );
	GM_CHECK_TABLE_PARAM( tbl, 1 );

	DisableGCInScope gcEn( a_thread->GetMachine() );

	if ( !tbl )
		tbl = a_thread->GetMachine()->AllocTableObject();

	ET_CabinetData cabinetData;
	if ( tbl != NULL && InterfaceFuncs::GetCabinetData( gameEnt, cabinetData ) )
	{
		tbl->Set( a_thread->GetMachine(), "CurrentAmount", gmVariable( cabinetData.mCurrentAmount ) );
		tbl->Set( a_thread->GetMachine(), "MaxAmount", gmVariable( cabinetData.mMaxAmount ) );
		tbl->Set( a_thread->GetMachine(), "Rate", gmVariable( cabinetData.mRate ) );
		a_thread->PushInt( 1 );
	}
	else
	{
		a_thread->PushNull();
	}
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:37,代码来源:gmETBinds.cpp

示例9: gmfCreateFolder

static int GM_CDECL gmfCreateFolder(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);
  GM_CHECK_STRING_PARAM(path, 0);
  BOOL result = CreateDirectory(path, NULL);
  if(result)
  {
    a_thread->PushInt(1);
  }
  else
  {
    WIN32_FIND_DATA findData;
    HANDLE handle = FindFirstFile(path, &findData);
    if(handle == INVALID_HANDLE_VALUE)
    {
      a_thread->PushInt(0);
    }
    else
    {
      if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
        a_thread->PushInt(2);
      }
      else
      {
        a_thread->PushInt(0);
      }
      FindClose(handle);
    }
  }
  return GM_OK;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:32,代码来源:gmSystemLib.cpp

示例10: gmfFileSeek

static int GM_CDECL gmfFileSeek(gmThread * a_thread) // return false on error
{
  gmUserObject * fileObject = a_thread->ThisUserObject();
  GM_ASSERT(fileObject->m_userType == s_gmFileType);

  GM_CHECK_NUM_PARAMS(2);
  GM_CHECK_INT_PARAM(offset, 0);
  GM_CHECK_INT_PARAM(origin, 1);

  if(    origin != SEEK_CUR 
      && origin != SEEK_END 
      && origin != SEEK_SET )
  {
    return GM_EXCEPTION;
  }

  int result = fseek((FILE*)fileObject->m_user, offset, origin);
  if(result != 0)
  {
    a_thread->PushInt(false);
  }
  a_thread->PushInt(true);

  return GM_OK;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:25,代码来源:gmSystemLib.cpp

示例11: gmfEchoTable

	static int GM_CDECL gmfEchoTable( gmThread *a_thread )
	{
		GM_CHECK_NUM_PARAMS( 1 );
		GM_CHECK_STRING_PARAM( tablename, 0 );

		const int BUF_SIZE = 512;
		char buffer[ BUF_SIZE ] = { 0 };
		char buffer2[ BUF_SIZE ] = { 0 };

		gmMachine *pMachine = a_thread->GetMachine();
		gmVariable vTable = pMachine->GetGlobals()->Get( pMachine, tablename );
		gmTableObject *pTable = vTable.GetTableObjectSafe();
		if ( pTable )
		{
			gmTableIterator tIt;
			gmTableNode *pNode = pTable->GetFirst( tIt );
			while ( pNode )
			{
				EngineFuncs::ConsoleMessage(
					va( "%s = %s",
					pNode->m_key.AsString( pMachine, buffer, BUF_SIZE ),
					pNode->m_value.AsString( pMachine, buffer2, BUF_SIZE ) ) );
				pNode = pTable->GetNext( tIt );
			}
		}
		return GM_OK;
	}
开发者ID:fishxz,项目名称:omni-bot,代码行数:27,代码来源:gmUtilityLib.cpp

示例12: gmStringReverseFind

// int string.ReverseFind(char/string a_charOrStringToFind);
// Find the last instance of a specific character in a string.
// Returns character offset or -1 if not found.
static int GM_CDECL gmStringReverseFind(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);

  const char* retCharPtr = NULL;
  const gmVariable * var = a_thread->GetThis();
  GM_ASSERT(var->m_type == GM_STRING);
  gmStringObject * thisStrObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
  const char* thisStr = (const char *) *thisStrObj;
  
  if(a_thread->ParamType(0) == GM_INT)
  {
    const char otherChar = (char)a_thread->ParamInt(0);
    
    //Find character
    retCharPtr = strrchr(thisStr, otherChar);
  }
  else if(a_thread->ParamType(0) == GM_STRING)
  {
    gmStringObject * otherStrObj = a_thread->ParamStringObject(0);
    const char* otherStr = a_thread->ParamString(0);

    //Find string
    const char* lastFoundPtr = NULL;
    const char* newTestPtr = NULL;
    const char* curTestPtr = thisStr;
    const char* endThisStr = thisStr + thisStrObj->GetLength();
    int searchStrLength = otherStrObj->GetLength();

    //Search through string for last occurence
    //Not very efficient, but very rarely used.
    for(;;)
    {
      newTestPtr = strstr(curTestPtr, otherStr);
      if(!newTestPtr)
      {
        break;
      }
      lastFoundPtr = newTestPtr;
      curTestPtr = newTestPtr + searchStrLength;
      if(curTestPtr > endThisStr)
      {
        break;
      }
    };

    retCharPtr = lastFoundPtr;
  }
  else
  {
    return GM_EXCEPTION;
  }

  // return -1 for not found, distance from beginning otherwise
  int retOffset = (retCharPtr == NULL) ? -1 : (int)(retCharPtr - thisStr);
  a_thread->PushInt(retOffset);

  return GM_OK;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:62,代码来源:gmStringLib.cpp

示例13: LengthSquared

  static int GM_CDECL LengthSquared(gmThread * a_thread)
  {
    GM_CHECK_NUM_PARAMS(0);
    gmVector3* thisVec = (gmVector3*)a_thread->ThisUser_NoChecks();
    a_thread->PushFloat( gmVector3::LengthSquared(*thisVec) );

    return GM_OK;
  }
开发者ID:joechenq,项目名称:multi-script,代码行数:8,代码来源:gmVector3Lib.cpp

示例14: gmfGetReinforceTime

// function: GetReinforceTime
//		Gets the current reinforcement time for this bots team
//
// Parameters:
//
//		none
//
// Returns:
//		int - reinforce timer
static int GM_CDECL gmfGetReinforceTime( gmThread *a_thread )
{
	CHECK_THIS_BOT();
	GM_CHECK_NUM_PARAMS( 0 );

	a_thread->PushFloat( InterfaceFuncs::GetReinforceTime( native ) );
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:17,代码来源:gmETBinds.cpp

示例15: GM_CHECK_NUM_PARAMS

int gmMatrix3::gmfInverse(gmThread *a_thread)
{
	GM_CHECK_NUM_PARAMS(0);
	gmMat3Type* native = gmMatrix3::GetThisObject( a_thread );
	Matrix3f mInv = native->Inverse();
	gmMatrix3::PushObject(a_thread, mInv);
	return GM_OK;
}
开发者ID:fishxz,项目名称:omni-bot,代码行数:8,代码来源:gmMatrix3.cpp


注:本文中的GM_CHECK_NUM_PARAMS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。