本文整理汇总了C++中CBotVar::SetIdent方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotVar::SetIdent方法的具体用法?C++ CBotVar::SetIdent怎么用?C++ CBotVar::SetIdent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotVar
的用法示例。
在下文中一共展示了CBotVar::SetIdent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RestoreState
bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
{
unsigned short w, wi, prv, st;
float ww;
CBotString name, s;
delete pVar;
pVar = NULL;
CBotVar* pNew = NULL;
CBotVar* pPrev = NULL;
while ( true ) // retrieves a list
{
if (!ReadWord(pf, w)) return false; // private or type?
if ( w == 0 ) return true;
CBotString defnum;
if ( w == 200 )
{
if (!ReadString(pf, defnum)) return false; // number with identifier
if (!ReadWord(pf, w)) return false; // type
}
prv = 100; st = 0;
if ( w >= 100 )
{
prv = w;
if (!ReadWord(pf, st)) return false; // static
if (!ReadWord(pf, w)) return false; // type
}
if ( w == CBotTypClass ) w = CBotTypIntrinsic; // necessarily intrinsic
if (!ReadWord(pf, wi)) return false; // init ?
if (!ReadString(pf, name)) return false; // variable name
CBotToken token(name, CBotString());
switch (w)
{
case CBotTypInt:
case CBotTypBoolean:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadWord(pf, w)) return false;
pNew->SetValInt(static_cast<short>(w), defnum);
break;
case CBotTypFloat:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadFloat(pf, ww)) return false;
pNew->SetValFloat(ww);
break;
case CBotTypString:
pNew = CBotVar::Create(&token, w); // creates a variable
if (!ReadString(pf, s)) return false;
pNew->SetValString(s);
break;
// returns an intrinsic object or element of an array
case CBotTypIntrinsic:
case CBotTypArrayBody:
{
CBotTypResult r;
long id;
if (!ReadType(pf, r)) return false; // complete type
if (!ReadLong(pf, id) ) return false;
// if (!ReadString(pf, s)) return false;
{
CBotVar* p = NULL;
if ( id ) p = CBotVarClass::Find(id) ;
pNew = new CBotVarClass(&token, r); // directly creates an instance
// attention cptuse = 0
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
pNew->SetIdent(id);
if ( p != NULL )
{
delete pNew;
pNew = p; // resume known element
}
}
}
break;
case CBotTypPointer:
case CBotTypNullPointer:
if (!ReadString(pf, s)) return false;
{
pNew = CBotVar::Create(&token, CBotTypResult(w, s));// creates a variable
// CBotVarClass* p = NULL;
long id;
ReadLong(pf, id);
// if ( id ) p = CBotVarClass::Find(id); // found the instance (made by RestoreInstance)
// returns a copy of the original instance
CBotVar* pInstance = NULL;
if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
//.........这里部分代码省略.........
示例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" );
//.........这里部分代码省略.........