本文整理汇总了C++中CBotVar::SetUserPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotVar::SetUserPtr方法的具体用法?C++ CBotVar::SetUserPtr怎么用?C++ CBotVar::SetUserPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotVar
的用法示例。
在下文中一共展示了CBotVar::SetUserPtr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rRadar
BOOL rRadar( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
{
pResult->SetPointer( NULL );
if ( pVar ) pVar->debug();
compt+=45671;
if (compt&0x11)
{
return FALSE; // TRUE;
}
CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
pAutre->SetUserPtr( (void*)2 );
pResult->SetPointer( pAutre );
if (!pResult->IsElemOfClass("object"))
return TRUE;
delete pAutre;
return TRUE;
}
示例2: OnTest
void CTestCBotDoc::OnTest()
{
CBotProgram::DefineNum("WingedGrabber", 1);
CBotProgram::DefineNum("TrackedGrabber", 2);
CBotProgram::DefineNum("WheeledGrabber", 3);
CBotProgram::DefineNum("LeggedGrabber", 4);
CBotProgram::DefineNum("WingedShooter", 5);
CBotProgram::DefineNum("TrackedShooter", 6);
CBotProgram::DefineNum("WheeledShooter", 7);
CBotProgram::DefineNum("LeggedShooter", 8);
CBotProgram::DefineNum("WingedOrgaShooter", 9);
CBotProgram::DefineNum("TrackedOrgaShooter", 10);
CBotProgram::DefineNum("WheeledOrgaShooter", 11);
CBotProgram::DefineNum("LeggedOrgaShooter", 12);
CBotProgram::DefineNum("WingedSniffer", 13);
CBotProgram::DefineNum("TrackedSniffer", 14);
CBotProgram::DefineNum("WheeledSniffer", 14);
CBotProgram::DefineNum("LeggedSniffer", 15);
CBotProgram::DefineNum("Thumper", 16);
CBotProgram::DefineNum("PhazerShooter", 17);
CBotProgram::DefineNum("Recycler", 18);
CBotProgram::DefineNum("Shielder", 19);
CBotProgram::DefineNum("Subber", 20);
CBotProgram::DefineNum("Me", 21);
CBotProgram::DefineNum("TypeMarkPath", 111);
OnFileSave();
// CPerformDlg dlg;
// dlg.m_Script = m_DocText;
// dlg.DoModal();
// défini la routine RetObject
CBotProgram::AddFunction( "Radar", rRetObject, cRetObject );
// ajoute une routine pour cette classe
CBotProgram::AddFunction("Space", rSpace, cSpace);
// défini la routine Test
CBotProgram::AddFunction( "TEST", rTEST, cTEST );
CBotProgram::AddFunction( "F", rF, cF );
CBotProgram::AddFunction( "goto", rMove, cMove );
CBotProgram::AddFunction( "fire", rTurn, cTurn );
CBotProgram::AddFunction( "radar", rRadar, cRadar );
// crée une instance de la classe "Bot" pour ce robot
CBotVar* pThisRobot = CBotVar::Create( "", CBotTypResult(CBotTypClass, "object") );
pThisRobot->SetUserPtr( (void*)1 );
pThisRobot->SetIdent( 1234 );
delete m_pProg;
// crée un objet programme associé à cette instance
m_pProg = new CBotProgram(pThisRobot);
// compile le programme
CString TextError;
int code, start, end;
m_pEdit->GetWindowText(m_DocText);
if (!m_pProg->Compile(m_DocText, m_Liste, (void*) 44))
{
m_pProg->GetError(code, start, end);
delete m_pProg;
m_pProg = NULL;
delete pThisRobot;
m_pEdit->SetSel( start, end );
m_pEdit->SetFocus(); // met en évidence la partie avec problème
TextError = CBotProgram::GivErrorText( code );
AfxMessageBox( TextError );
m_pEdit->SetFocus();
return;
}
// exécute pour voir
m_pProg->Start(m_Liste[0]);
int mode = -1;
if ( mode >= 0 ) {
// sauve et restore à chaque pas possible
while (!m_pProg->Run(NULL, 1))
{
const char* FunctionName;
int start1, end1;
m_pProg->GetRunPos(FunctionName, start1, end1);
if ( end1 <= 0 )
m_pProg->GetRunPos(FunctionName, start1, end1);
m_pEdit->SetSel(start1, end1);
if ( mode == 0 ) continue;
FILE* pf;
pf = fOpen( "TEST.CBO", "wb" );
//.........这里部分代码省略.........