From dbd62c96aa351dc1c21e3392348edda2eb012e09 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Wed, 4 Jul 2012 22:14:28 +0200 Subject: Fixed code compilation without fpermissive flag. Removed Winapi, but now library don't work - work in progress. Some translations. --- CMakeLists.txt | 4 +- src/CBot/CBot.cpp | 885 +++++++++++++++++++++---------------------- src/CBot/CBot.h | 522 ++++++++++++------------- src/CBot/CBotAddExpr.cpp | 2 +- src/CBot/CBotClass.cpp | 145 ++++--- src/CBot/CBotCompExpr.cpp | 2 +- src/CBot/CBotDll.h | 472 +++++++++++------------ src/CBot/CBotFunction.cpp | 164 ++++---- src/CBot/CBotIf.cpp | 24 +- src/CBot/CBotProgram.cpp | 211 ++++++----- src/CBot/CBotStack.cpp | 288 +++++++------- src/CBot/CBotString.cpp | 104 ++--- src/CBot/CBotToken.cpp | 67 ++-- src/CBot/CBotToken.h | 4 +- src/CBot/CBotTwoOpExpr.cpp | 58 +-- src/CBot/CBotVar.cpp | 278 +++++++------- src/CBot/CBotWhile.cpp | 216 +++++------ src/CBot/ClassFILE.cpp | 14 +- src/CBot/StringFunctions.cpp | 98 ++--- src/CBot/old | 15 - src/CMakeLists.txt | 5 +- 21 files changed, 1788 insertions(+), 1790 deletions(-) delete mode 100644 src/CBot/old diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d24e0a..5ca52f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ find_package(SDL_image REQUIRED) set(CMAKE_BUILD_TYPE debug) # Global compile flags -set(CMAKE_CXX_FLAGS_RELEASE "-O2") -set(CMAKE_CXX_FLAGS_DEBUG "-w -g -O0") +set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall") +set(CMAKE_CXX_FLAGS_DEBUG "-w -g -O0 -Wall") # Subdirectory with sources add_subdirectory(src bin) diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index 1344efd..6cb2e5d 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -25,7 +25,7 @@ // Compiles if the routine returns NULL is that the statement is false // Or misunderstood. -// The error is then on the stack CBotCStack :: Isok () is FALSE +// The error is then on the stack CBotCStack :: Isok () is false @@ -85,19 +85,19 @@ void CBotInstr::DecLvl() } // controle la validité d'un break ou continu -BOOL CBotInstr::ChkLvl(const CBotString& label, int type) +bool CBotInstr::ChkLvl(const CBotString& label, int type) { int i = m_LoopLvl; while (--i>=0) { if ( type == ID_CONTINUE && m_labelLvl[i] == "#SWITCH") continue; - if ( label.IsEmpty() ) return TRUE; - if ( m_labelLvl[i] == label ) return TRUE; + if ( label.IsEmpty() ) return true; + if ( m_labelLvl[i] == label ) return true; } - return FALSE; + return false; } -BOOL CBotInstr::IsOfClass(CBotString n) +bool CBotInstr::IsOfClass(CBotString n) { return name == n; } @@ -113,12 +113,6 @@ void CBotInstr::SetToken(CBotToken* p) m_token = *p; } -void CBotInstr::SetToken(CBotString* name, int start, int end) -{ - SetToken( &CBotToken( *name, CBotString(), start, end)); -} - - // rend le type du token associé à l'instruction int CBotInstr::GivTokenType() @@ -293,22 +287,22 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack) return NULL; } -BOOL CBotInstr::Execute(CBotStack* &pj) +bool CBotInstr::Execute(CBotStack* &pj) { CBotString ClassManquante = name; ASM_TRAP(); // ne doit jamais passer par cette routine // mais utiliser les routines des classes filles - return FALSE; + return false; } -BOOL CBotInstr::Execute(CBotStack* &pj, CBotVar* pVar) +bool CBotInstr::Execute(CBotStack* &pj, CBotVar* pVar) { - if ( !Execute(pj) ) return FALSE; + if ( !Execute(pj) ) return false; pVar->SetVal( pj->GivVar() ); - return TRUE; + return true; } -void CBotInstr::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotInstr::RestoreState(CBotStack* &pj, bool bMain) { CBotString ClassManquante = name; ASM_TRAP(); // ne doit jamais passer par cette routine @@ -316,19 +310,19 @@ void CBotInstr::RestoreState(CBotStack* &pj, BOOL bMain) } -BOOL CBotInstr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) +bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { ASM_TRAP(); // papa sait pas faire, voir les filles - return FALSE; + return false; } -BOOL CBotInstr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend) +bool CBotInstr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { ASM_TRAP(); // papa sait pas faire, voir les filles - return FALSE; + return false; } -void CBotInstr::RestoreStateVar(CBotStack* &pile, BOOL bMain) +void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain) { ASM_TRAP(); // papa sait pas faire, voir les filles } @@ -337,9 +331,9 @@ void CBotInstr::RestoreStateVar(CBotStack* &pile, BOOL bMain) // cela permet de faire l'appel CompCase sur toutes les instructions // pour savoir s'il s'agit d'un case pour la valeur désirée. -BOOL CBotInstr::CompCase(CBotStack* &pj, int val) +bool CBotInstr::CompCase(CBotStack* &pj, int val) { - return FALSE; + return false; } ////////////////////////////////////////////////////////////////////////////////////////// @@ -352,7 +346,7 @@ BOOL CBotInstr::CompCase(CBotStack* &pj, int val) // l'objet retourné par Compile est généralement de type CBotListInstr -CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal) +CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) { pStack->SetStartError(p->GivStart()); @@ -374,7 +368,7 @@ CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal) return NULL; } -CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, BOOL bLocal) +CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal) { // est-ce un nouveau bloc ? if ( p->GivType() == ID_OPBLK ) return CBotBlock::Compile(p, pStack); @@ -410,13 +404,13 @@ CBotListInstr::~CBotListInstr() delete m_Instr; } -CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal) +CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal) { CBotCStack* pStk = pStack->TokenStack(p, bLocal); // les variables sont locales CBotListInstr* inst = new CBotListInstr(); - while (TRUE) + while (true) { if ( p == NULL ) break; @@ -446,10 +440,10 @@ CBotInstr* CBotListInstr::Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal // exécute une liste d'instructions -BOOL CBotListInstr::Execute(CBotStack* &pj) +bool CBotListInstr::Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this, TRUE);//indispensable pour SetState() + CBotStack* pile = pj->AddStack(this, true);//indispensable pour SetState() if ( pile->StackOver() ) return pj->Return( pile ); @@ -458,20 +452,20 @@ BOOL CBotListInstr::Execute(CBotStack* &pj) int state = pile->GivState(); while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue - if ( p != NULL ) while (TRUE) + if ( p != NULL ) while (true) { // DEBUG( "CBotListInstr", pile->GivState(), pile ); - if ( !p->Execute(pile) ) return FALSE; + if ( !p->Execute(pile) ) return false; p = p->GivNext(); if ( p == NULL ) break; - if (!pile->IncState()) ;//return FALSE; // prêt pour la suivante + if (!pile->IncState()) ;//return false; // prêt pour la suivante } return pj->Return( pile ); // transmet en dessous } -void CBotListInstr::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotListInstr::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -483,11 +477,11 @@ void CBotListInstr::RestoreState(CBotStack* &pj, BOOL bMain) int state = pile->GivState(); while ( p != NULL && state-- > 0) { - p->RestoreState(pile, FALSE); + p->RestoreState(pile, false); p = p->GivNext(); // revient sur l'opération interrompue } - if ( p != NULL ) p->RestoreState(pile, TRUE); + if ( p != NULL ) p->RestoreState(pile, true); } ////////////////////////////////////////////////////////////////////////////////////// @@ -523,7 +517,7 @@ CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack) } // crée une variable et lui assigne le résultat de la pile -BOOL CBotLeftExprVar::Execute(CBotStack* &pj) +bool CBotLeftExprVar::Execute(CBotStack* &pj) { CBotVar* var1; CBotVar* var2; @@ -535,10 +529,10 @@ BOOL CBotLeftExprVar::Execute(CBotStack* &pj) var2 = pj->GivVar(); // resultat sur la pile if ( var2 ) var1->SetVal(var2); // fait l'assignation - return TRUE; // opération faite + return true; // opération faite } -void CBotLeftExprVar::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain) { CBotVar* var1; @@ -631,10 +625,10 @@ error: // exécute la définition d'un tableau -BOOL CBotInstArray::Execute(CBotStack* &pj) +bool CBotInstArray::Execute(CBotStack* &pj) { CBotStack* pile1 = pj->AddStack(this); -// if ( pile1 == EOX ) return TRUE; +// if ( pile1 == EOX ) return true; CBotStack* pile = pile1; @@ -650,7 +644,7 @@ BOOL CBotInstArray::Execute(CBotStack* &pj) nb++; if ( pile->GivState() == 0 ) { - if ( !p->Execute(pile) ) return FALSE; // calcul de la taille // interrompu? + if ( !p->Execute(pile) ) return false; // calcul de la taille // interrompu? pile->IncState(); } p = p->GivNext3b(); @@ -698,20 +692,20 @@ BOOL CBotInstArray::Execute(CBotStack* &pj) { CBotVar* pVar = pj->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent); - if ( !m_listass->Execute(pile1, pVar) ) return FALSE; + if ( !m_listass->Execute(pile1, pVar) ) return false; } pile1->IncState(); } - if ( pile1->IfStep() ) return FALSE; // montre ce pas ? + if ( pile1->IfStep() ) return false; // montre ce pas ? if ( m_next2b && - !m_next2b->Execute( pile1 ) ) return FALSE; + !m_next2b->Execute( pile1 ) ) return false; return pj->Return( pile1 ); // transmet en dessous } -void CBotInstArray::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotInstArray::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile1 = pj; @@ -753,15 +747,15 @@ void CBotInstArray::RestoreState(CBotStack* &pj, BOOL bMain) } // cas particulier pour les indices vides -BOOL CBotEmpty :: Execute(CBotStack* &pj) +bool CBotEmpty :: Execute(CBotStack* &pj) { CBotVar* pVar = CBotVar::Create("", CBotTypInt); pVar->SetValInt(-1); // met la valeur -1 sur la pile pj->SetVar(pVar); - return TRUE; + return true; } -void CBotEmpty :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotEmpty :: RestoreState(CBotStack* &pj, bool bMain) { } @@ -878,10 +872,10 @@ error: // exécute la définition d'un tableau -BOOL CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar) +bool CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar) { CBotStack* pile1 = pj->AddStack(); -// if ( pile1 == EOX ) return TRUE; +// if ( pile1 == EOX ) return true; CBotVar* pVar2; CBotInstr* p = m_expr; @@ -892,9 +886,9 @@ BOOL CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar) { if ( pile1->GivState() > n ) continue; - pVar2 = pVar->GivItem(n, TRUE); + pVar2 = pVar->GivItem(n, true); - if ( !p->Execute(pile1, pVar2) ) return FALSE; // évalue l'expression + if ( !p->Execute(pile1, pVar2) ) return false; // évalue l'expression pile1->IncState(); } @@ -902,7 +896,7 @@ BOOL CBotListArray::Execute(CBotStack* &pj, CBotVar* pVar) return pj->Return( pile1 ); // transmet en dessous } -void CBotListArray::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotListArray::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) { @@ -940,7 +934,7 @@ CBotInt::~CBotInt() // delete m_next; // fait par le destructeur de la classe de base ~CBotInstr() } -CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, BOOL first) +CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first) { if ( IsOfType(p, ID_OPBRK) ) { @@ -950,7 +944,7 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes return NULL; } - CBotInstr* inst = CompileArray(p, pStack, CBotTypResult( CBotTypArrayPointer, type ), FALSE); + CBotInstr* inst = CompileArray(p, pStack, CBotTypResult( CBotTypArrayPointer, type ), false); if ( inst != NULL || !pStack->IsOk() ) return inst; } @@ -962,7 +956,7 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst->m_next2b = CBotInstArray::CompileArray(p, pStack, type, FALSE) )) // compile la suivante + if ( NULL != ( inst->m_next2b = CBotInstArray::CompileArray(p, pStack, type, false) )) // compile la suivante { return inst; } @@ -980,7 +974,7 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes return NULL; } -CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL noskip) +CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) { CBotToken* pp = cont ? NULL : p; // pas de répétition du token "int" @@ -1025,7 +1019,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL n if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst2->m_next2b = CBotInt::Compile(p, pStk, TRUE, noskip) )) // compile la suivante + if ( NULL != ( inst2->m_next2b = CBotInt::Compile(p, pStk, true, noskip) )) // compile la suivante { return pStack->Return(inst2, pStk); } @@ -1058,7 +1052,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL n if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst->m_next2b = CBotInt::Compile(p, pStk, TRUE, noskip) )) // compile la suivante + if ( NULL != ( inst->m_next2b = CBotInt::Compile(p, pStk, true, noskip) )) // compile la suivante { return pStack->Return(inst, pStk); } @@ -1079,28 +1073,28 @@ error: // exécute la définition de la variable entière -BOOL CBotInt::Execute(CBotStack* &pj) +bool CBotInt::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); //indispensable pour SetState() -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return FALSE; // valeur initiale // interrompu? + if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? m_var->Execute( pile ); // crée et fait l'assigation du résultat - if (!pile->SetState(1)) return FALSE; + if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // autre(s) définition(s) return pj->Return( pile ); // transmet en dessous } -void CBotInt::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotInt::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; if ( bMain ) @@ -1140,7 +1134,7 @@ CBotBoolean::~CBotBoolean() delete m_expr; } -CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL noskip) +CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) { CBotToken* pp = cont ? NULL : p; @@ -1207,7 +1201,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BO suite: if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst->m_next2b = CBotBoolean::Compile(p, pStk, TRUE, noskip) )) // compile la suivante + if ( NULL != ( inst->m_next2b = CBotBoolean::Compile(p, pStk, true, noskip) )) // compile la suivante { return pStack->Return(inst, pStk); } @@ -1228,28 +1222,28 @@ error: // exécute une définition de variable booléenne -BOOL CBotBoolean::Execute(CBotStack* &pj) +bool CBotBoolean::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return FALSE; // valeur initiale // interrompu? + if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? m_var->Execute( pile ); // crée et fait l'assigation du résultat - if (!pile->SetState(1)) return FALSE; + if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // autre(s) définition(s) return pj->Return( pile ); // transmet en dessous } -void CBotBoolean::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotBoolean::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; if ( bMain ) @@ -1290,7 +1284,7 @@ CBotFloat::~CBotFloat() delete m_expr; } -CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL noskip) +CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) { CBotToken* pp = cont ? NULL : p; @@ -1358,7 +1352,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL suite: if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst->m_next2b = CBotFloat::Compile(p, pStk, TRUE, noskip) )) // compile la suivante + if ( NULL != ( inst->m_next2b = CBotFloat::Compile(p, pStk, true, noskip) )) // compile la suivante { return pStack->Return(inst, pStk); } @@ -1379,28 +1373,28 @@ error: // exécute la défintion de la variable réelle -BOOL CBotFloat::Execute(CBotStack* &pj) +bool CBotFloat::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return FALSE; // valeur initiale // interrompu? + if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? m_var->Execute( pile ); // crée et fait l'assigation du résultat - if (!pile->SetState(1)) return FALSE; + if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // autre(s) définition(s) return pj->Return( pile ); // transmet en dessous } -void CBotFloat::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotFloat::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; if ( bMain ) @@ -1441,7 +1435,7 @@ CBotIString::~CBotIString() delete m_expr; } -CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BOOL noskip) +CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) { CBotToken* pp = cont ? NULL : p; @@ -1491,7 +1485,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont, BO if (IsOfType(p, ID_COMMA)) // plusieurs définitions enchaînées { - if ( NULL != ( inst->m_next2b = CBotIString::Compile(p, pStk, TRUE, noskip) )) // compile la suivante + if ( NULL != ( inst->m_next2b = CBotIString::Compile(p, pStk, true, noskip) )) // compile la suivante { return pStack->Return(inst, pStk); } @@ -1512,28 +1506,28 @@ error: // exécute la définition de la variable string -BOOL CBotIString::Execute(CBotStack* &pj) +bool CBotIString::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState()==0) { - if (m_expr && !m_expr->Execute(pile)) return FALSE; // valeur initiale // interrompu? + if (m_expr && !m_expr->Execute(pile)) return false; // valeur initiale // interrompu? m_var->Execute( pile ); // crée et fait l'assigation du résultat - if (!pile->SetState(1)) return FALSE; + if (!pile->SetState(1)) return false; } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( m_next2b && - !m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // autre(s) définition(s) return pj->Return( pile ); // transmet en dessous } -void CBotIString::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotIString::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; @@ -1641,7 +1635,7 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) var->SetInit(2); } else - var->SetInit(TRUE); + var->SetInit(true); break; case ID_ASSADD: @@ -1682,21 +1676,21 @@ CBotInstr* CBotExpression::Compile(CBotToken* &p, CBotCStack* pStack) // exécute une expression avec assignation -BOOL CBotExpression::Execute(CBotStack* &pj) +bool CBotExpression::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; CBotToken* pToken = m_leftop->GivToken(); CBotVar* pVar = NULL; CBotStack* pile1 = pile; - BOOL IsInit = TRUE; + bool IsInit = true; CBotVar* result = NULL; // doit être fait avant pour les indices éventuels (pile peut être changée) - if ( !m_leftop->ExecuteVar(pVar, pile, NULL, FALSE) ) return FALSE; // variable avant évaluation de la valeur droite + if ( !m_leftop->ExecuteVar(pVar, pile, NULL, false) ) return false; // variable avant évaluation de la valeur droite // DEBUG( "CBotExpression::Execute", -1, pj); if ( pile1->GivState()==0) @@ -1710,7 +1704,7 @@ BOOL CBotExpression::Execute(CBotStack* &pj) if ( pile2->GivState()==0) { // DEBUG( "CBotExpression::Execute", -2, pj); - if (m_rightop && !m_rightop->Execute(pile2)) return FALSE; // valeur initiale // interrompu? + if (m_rightop && !m_rightop->Execute(pile2)) return false; // valeur initiale // interrompu? pile2->IncState(); } @@ -1792,13 +1786,13 @@ BOOL CBotExpression::Execute(CBotStack* &pj) // DEBUG( "CBotExpression::Execute", -4, pj); if ( !m_leftop->Execute( pile2, pile1 ) ) - return FALSE; // crée et fait l'assigation du résultat + return false; // crée et fait l'assigation du résultat return pj->Return( pile2 ); // transmet en dessous } -void CBotExpression::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExpression::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) { @@ -1813,11 +1807,11 @@ void CBotExpression::RestoreState(CBotStack* &pj, BOOL bMain) if ( pile1->GivState()==0) { - m_leftop->RestoreStateVar(pile, TRUE); // variable avant évaluation de la valeur droite + m_leftop->RestoreStateVar(pile, true); // variable avant évaluation de la valeur droite return; } - m_leftop->RestoreStateVar(pile, FALSE); // variable avant évaluation de la valeur droite + m_leftop->RestoreStateVar(pile, false); // variable avant évaluation de la valeur droite CBotStack* pile2 = pile->RestoreStack(); // attention pile et surtout pas pile1 if ( pile2 == NULL ) return; @@ -2086,20 +2080,20 @@ CBotPreIncExpr::~CBotPreIncExpr() delete m_Instr; } -BOOL CBotPostIncExpr::Execute(CBotStack* &pj) +bool CBotPostIncExpr::Execute(CBotStack* &pj) { CBotStack* pile1 = pj->AddStack(this); CBotStack* pile2 = pile1; CBotVar* var1 = NULL; - if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, TRUE) ) return FALSE; // récupère la variable selon champs et index + if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true) ) return false; // récupère la variable selon champs et index pile1->SetState(1); pile1->SetCopyVar(var1); // place le résultat (avant incrémentation); CBotStack* pile3 = pile2->AddStack(this); - if ( pile3->IfStep() ) return FALSE; + if ( pile3->IfStep() ) return false; if ( var1->GivInit() == IS_NAN ) { @@ -2117,7 +2111,7 @@ BOOL CBotPostIncExpr::Execute(CBotStack* &pj) return pj->Return(pile1); // opération faite, résultat sur pile2 } -void CBotPostIncExpr::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -2129,19 +2123,19 @@ void CBotPostIncExpr::RestoreState(CBotStack* &pj, BOOL bMain) if ( pile1 != NULL ) pile1->RestoreStack(this); } -BOOL CBotPreIncExpr::Execute(CBotStack* &pj) +bool CBotPreIncExpr::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var1; if ( pile->GivState() == 0 ) { CBotStack* pile2 = pile; - if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, TRUE) ) return FALSE; // récupère la variable selon champs et index + if ( !((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true) ) return false; // récupère la variable selon champs et index // pile2 est modifié en retour if ( var1->GivInit() == IS_NAN ) @@ -2162,12 +2156,12 @@ BOOL CBotPreIncExpr::Execute(CBotStack* &pj) pile->IncState(); } - if ( !m_Instr->Execute(pile) ) return FALSE; + if ( !m_Instr->Execute(pile) ) return false; return pj->Return(pile); // opération faite } -void CBotPreIncExpr::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotPreIncExpr::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -2234,19 +2228,19 @@ CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack) // exécute l'expresson unaire -BOOL CBotExprUnaire::Execute(CBotStack* &pj) +bool CBotExprUnaire::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState() == 0 ) { - if (!m_Expr->Execute( pile )) return FALSE; // interrompu ? + if (!m_Expr->Execute( pile )) return false; // interrompu ? pile->IncState(); } CBotStack* pile2 = pile->AddStack(); - if ( pile2->IfStep() ) return FALSE; + if ( pile2->IfStep() ) return false; CBotVar* var = pile->GivVar(); // récupère le résultat sur la pile @@ -2266,7 +2260,7 @@ BOOL CBotExprUnaire::Execute(CBotStack* &pj) return pj->Return(pile); // transmet en dessous } -void CBotExprUnaire::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprUnaire::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -2300,26 +2294,26 @@ CBotIndexExpr::~CBotIndexExpr() // trouve un champ à partir de l'instance à la compilation -BOOL CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) +bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { if ( pVar->GivType(1) != CBotTypArrayPointer ) ASM_TRAP(); - pVar = ((CBotVarArray*)pVar)->GivItem(0, FALSE); // à la compilation rend l'élément [0] + pVar = ((CBotVarArray*)pVar)->GivItem(0, false); // à la compilation rend l'élément [0] if ( pVar == NULL ) { pile->SetError(TX_OUTARRAY, m_token.GivEnd()); - return FALSE; + return false; } if ( m_next3 != NULL ) return m_next3->ExecuteVar(pVar, pile); - return TRUE; + return true; } // idem à l'exécution // attention, modifie le pointeur à la pile volontairement // place les index calculés sur la pile supplémentaire -BOOL CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend) +bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { CBotStack* pj = pile; // DEBUG( "CBotIndexExpr::ExecuteVar", -1 , pj); @@ -2328,11 +2322,11 @@ BOOL CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev ASM_TRAP(); pile = pile->AddStack(); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState() == 0 ) { - if ( !m_expr->Execute(pile) ) return FALSE; + if ( !m_expr->Execute(pile) ) return false; pile->IncState(); } // traite les tableaux @@ -2357,25 +2351,25 @@ BOOL CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev // DEBUG( "CBotIndexExpr::ExecuteVar", -2 , pj); //if ( bUpdate ) - pVar->Maj(pile->GivPUser(), TRUE); + pVar->Maj(pile->GivPUser(), true); // DEBUG( "CBotIndexExpr::ExecuteVar", -3 , pj); if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return FALSE; + !m_next3->ExecuteVar(pVar, pile, prevToken, bStep, bExtend) ) return false; // DEBUG( "CBotIndexExpr::ExecuteVar", -4 , pj); - return TRUE; // ne libère pas la pile + return true; // ne libère pas la pile // pour éviter de recalculer les index deux fois le cas échéant } -void CBotIndexExpr::RestoreStateVar(CBotStack* &pile, BOOL bMain) +void CBotIndexExpr::RestoreStateVar(CBotStack* &pile, bool bMain) { pile = pile->RestoreStack(); if ( pile == NULL ) return; if ( bMain && pile->GivState() == 0 ) { - m_expr->RestoreState(pile, TRUE); + m_expr->RestoreState(pile, true); return; } @@ -2408,7 +2402,7 @@ void CBotFieldExpr::SetUniqNum(int num) // trouve un champ à partir de l'instance à la compilation -BOOL CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) +bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { if ( pVar->GivType(1) != CBotTypPointer ) ASM_TRAP(); @@ -2418,22 +2412,22 @@ BOOL CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) if ( pVar == NULL ) { pile->SetError(TX_NOITEM, &m_token); - return FALSE; + return false; } if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pile) ) return FALSE; + !m_next3->ExecuteVar(pVar, pile) ) return false; - return TRUE; + return true; } // idem à l'exécution -BOOL CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend) +bool CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend) { CBotStack* pj = pile; pile = pile->AddStack(this); // modifie pile en sortie - if ( pile == EOX ) return TRUE; + if ( pile == EOX ) return true; // DEBUG( "CBotFieldExpre::ExecuteVar "+m_token.GivString(), 0, pj ); @@ -2452,7 +2446,7 @@ BOOL CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev return pj->Return( pile ); } - if ( bStep && pile->IfStep() ) return FALSE; + if ( bStep && pile->IfStep() ) return false; // pVar = pVar->GivItem(m_token.GivString()); pVar = pVar->GivItemRef(m_nIdent); @@ -2472,16 +2466,16 @@ BOOL CBotFieldExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev } // demande la mise à jour de l'élément, s'il y a lieu - pVar->Maj(pile->GivPUser(), TRUE); + pVar->Maj(pile->GivPUser(), true); if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return FALSE; + !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, bExtend) ) return false; - return TRUE; // ne libère pas la pile + return true; // ne libère pas la pile // pour conserver l'état SetState() correspondant à l'étape } -void CBotFieldExpr::RestoreStateVar(CBotStack* &pj, BOOL bMain) +void CBotFieldExpr::RestoreStateVar(CBotStack* &pj, bool bMain) { pj = pj->RestoreStack(this); // modifie pj en sortie if ( pj == NULL ) return; @@ -2505,8 +2499,8 @@ CBotLeftExpr::~CBotLeftExpr() { } -// compile une expression pour un left-opérande ( à gauche d'une assignation) -// cela peut être +// compiles an expression for a left-operand (left of an assignment) +// this can be // toto // toto[ 3 ] // toto.x @@ -2517,78 +2511,78 @@ CBotLeftExpr::~CBotLeftExpr() CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack) { - CBotCStack* pStk = pStack->TokenStack(); - - pStk->SetStartError(p->GivStart()); - - // est-ce un nom de variable ? - if (p->GivType() == TokenTypVar) - { - CBotLeftExpr* inst = new CBotLeftExpr(); // crée l'objet - - inst->SetToken(p); - - CBotVar* var; - - if ( NULL != (var = pStk->FindVar(p)) ) // cherche si variable connue - { - inst->m_nIdent = var->GivUniqNum(); - if (inst->m_nIdent > 0 && inst->m_nIdent < 9000) - { - if ( var->IsPrivate(PR_READ) && - !pStk->GivBotCall()->m_bCompileClass) - { - pStk->SetError( TX_PRIVATE, p ); - goto err; - } - // il s'agit d'un élement de la classe courante - // ajoute l'équivalent d'un this. devant - CBotToken pthis("this"); - inst->SetToken(&pthis); - inst->m_nIdent = -2; // ident pour this - - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( p ); // garde le nom du token - inst->AddNext3(i); // ajoute à la suite - - var = pStk->FindVar(pthis); - var = var->GivItem(p->GivString()); - i->SetUniqNum(var->GivUniqNum()); - } - p = p->GivNext(); // token suivant - - while (TRUE) - { - if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau - { - if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index - { - CBotIndexExpr* i = new CBotIndexExpr(); - i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule - inst->AddNext3(i); // ajoute à la chaine - - var = ((CBotVarArray*)var)->GivItem(0,TRUE); // donne le composant [0] - - if ( i->m_expr == NULL ) - { - pStk->SetError( TX_BADINDEX, p->GivStart() ); - goto err; - } - - if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) - { - pStk->SetError( TX_CLBRK, p->GivStart() ); - goto err; - } - continue; - } - } - - if ( var->GivType(1) == CBotTypPointer ) // pour les classes - { - if ( IsOfType(p, ID_DOT) ) - { - CBotToken* pp = p; + CBotCStack* pStk = pStack->TokenStack(); + + pStk->SetStartError(p->GivStart()); + + // is it a variable name? + if (p->GivType() == TokenTypVar) + { + CBotLeftExpr* inst = new CBotLeftExpr(); // creates the object + + inst->SetToken(p); + + CBotVar* var; + + if ( NULL != (var = pStk->FindVar(p)) ) // seek if known variable + { + inst->m_nIdent = var->GivUniqNum(); + if (inst->m_nIdent > 0 && inst->m_nIdent < 9000) + { + if ( var->IsPrivate(PR_READ) && + !pStk->GivBotCall()->m_bCompileClass) + { + pStk->SetError( TX_PRIVATE, p ); + goto err; + } + // il s'agit d'un élement de la classe courante + // ajoute l'équivalent d'un this. devant + CBotToken pthis("this"); + inst->SetToken(&pthis); + inst->m_nIdent = -2; // ident pour this + + CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément + i->SetToken( p ); // garde le nom du token + inst->AddNext3(i); // ajoute à la suite + + var = pStk->FindVar(pthis); + var = var->GivItem(p->GivString()); + i->SetUniqNum(var->GivUniqNum()); + } + p = p->GivNext(); // token suivant + + while (true) + { + if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau + { + if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index + { + CBotIndexExpr* i = new CBotIndexExpr(); + i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule + inst->AddNext3(i); // ajoute à la chaine + + var = ((CBotVarArray*)var)->GivItem(0,true); // donne le composant [0] + + if ( i->m_expr == NULL ) + { + pStk->SetError( TX_BADINDEX, p->GivStart() ); + goto err; + } + + if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) + { + pStk->SetError( TX_CLBRK, p->GivStart() ); + goto err; + } + continue; + } + } + + if ( var->GivType(1) == CBotTypPointer ) // pour les classes + { + if ( IsOfType(p, ID_DOT) ) + { + CBotToken* pp = p; CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément i->SetToken( pp ); // garde le nom du token @@ -2633,20 +2627,20 @@ err: // exécute, trouve une variable et lui assigne le résultat de la pile -BOOL CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array) +bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array) { CBotStack* pile = pj->AddStack(); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; -// if ( pile->IfStep() ) return FALSE; +// if ( pile->IfStep() ) return false; CBotVar* var1 = NULL; CBotVar* var2 = NULL; -// var1 = pile->FindVar(m_token, FALSE, TRUE); - if (!ExecuteVar( var1, array, NULL, FALSE )) return FALSE; +// var1 = pile->FindVar(m_token, false, true); + if (!ExecuteVar( var1, array, NULL, false )) return false; // retrouve la variable (et pas la copie) - if (pile->IfStep()) return FALSE; + if (pile->IfStep()) return false; if ( var1 ) { @@ -2677,20 +2671,20 @@ BOOL CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array) // retrouve une variable pendant la compilation -BOOL CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) +bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) { pVar = pile->FindVar(m_token); - if ( pVar == NULL ) return FALSE; + if ( pVar == NULL ) return false; if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pile) ) return FALSE; + !m_next3->ExecuteVar(pVar, pile) ) return false; - return TRUE; + return true; } // retrouve une variable à l'exécution -BOOL CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep) +bool CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep) { pile = pile->AddStack( this ); // déplace la pile @@ -2701,18 +2695,18 @@ BOOL CBotLeftExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevT ASM_TRAP(); #endif pile->SetError(2, &m_token); - return FALSE; + return false; } - if ( bStep && m_next3 == NULL && pile->IfStep() ) return FALSE; + if ( bStep && m_next3 == NULL && pile->IfStep() ) return false; if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, TRUE) ) return FALSE; + !m_next3->ExecuteVar(pVar, pile, &m_token, bStep, true) ) return false; - return TRUE; + return true; } -void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, BOOL bMain) +void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, bool bMain) { pile = pile->RestoreStack( this ); // déplace la pile if ( pile == NULL ) return; @@ -2765,11 +2759,11 @@ extern float GivNumFloat( const char* p ) { double num = 0; double div = 10; - BOOL bNeg = FALSE; + bool bNeg = false; if (*p == '-') { - bNeg = TRUE; + bNeg = true; p++; } while (*p >= '0' && *p <= '9') @@ -2875,12 +2869,12 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack) // exécute, retourne le nombre correspondant -BOOL CBotExprNum::Execute(CBotStack* &pj) +bool CBotExprNum::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, m_numtype); @@ -2905,7 +2899,7 @@ BOOL CBotExprNum::Execute(CBotStack* &pj) return pj->Return(pile); // c'est ok } -void CBotExprNum::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprNum::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -2942,12 +2936,12 @@ CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack) // exécute, retourne la chaîne correspondante -BOOL CBotExprAlpha::Execute(CBotStack* &pj) +bool CBotExprAlpha::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypString); @@ -2961,7 +2955,7 @@ BOOL CBotExprAlpha::Execute(CBotStack* &pj) return pj->Return(pile); } -void CBotExprAlpha::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprAlpha::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -3002,12 +2996,12 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack) // exécute, retourne true ou false -BOOL CBotExprBool::Execute(CBotStack* &pj) +bool CBotExprBool::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean); @@ -3018,7 +3012,7 @@ BOOL CBotExprBool::Execute(CBotStack* &pj) return pj->Return(pile); // transmet en dessous } -void CBotExprBool::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprBool::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -3038,20 +3032,20 @@ CBotExprNull::~CBotExprNull() // exécute, retourne un pointeur vide -BOOL CBotExprNull::Execute(CBotStack* &pj) +bool CBotExprNull::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypNullPointer); - var->SetInit(TRUE); // pointeur null valide + var->SetInit(true); // pointeur null valide pile->SetVar( var ); // mis sur la pile return pj->Return(pile); // transmet en dessous } -void CBotExprNull::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprNull::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -3071,12 +3065,12 @@ CBotExprNan::~CBotExprNan() // exécute, retourne un pointeur vide -BOOL CBotExprNan::Execute(CBotStack* &pj) +bool CBotExprNan::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypInt); var->SetInit(IS_NAN); // nombre nan @@ -3084,7 +3078,7 @@ BOOL CBotExprNan::Execute(CBotStack* &pj) return pj->Return(pile); // transmet en dessous } -void CBotExprNan::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprNan::RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -3106,133 +3100,136 @@ CBotExprVar::~CBotExprVar() CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat) { - CBotToken* pDebut = p; - CBotCStack* pStk = pStack->TokenStack(); - - pStk->SetStartError(p->GivStart()); - - // est-ce un nom de variable ? - if (p->GivType() == TokenTypVar) - { - CBotInstr* inst = new CBotExprVar(); // crée l'objet - - inst->SetToken(p); - - CBotVar* var; - - if ( NULL != (var = pStk->FindVar(p)) ) // cherche si variable connue - { - int ident = var->GivUniqNum(); - ((CBotExprVar*)inst)->m_nIdent = ident; // l'identifie par son numéro - - if (ident > 0 && ident < 9000) - { - if ( var->IsPrivate(privat) && - !pStk->GivBotCall()->m_bCompileClass) - { - pStk->SetError( TX_PRIVATE, p ); - goto err; - } - - // il s'agit d'un élement de la classe courante - // ajoute l'équivalent d'un this. devant - inst->SetToken(&CBotToken("this")); - ((CBotExprVar*)inst)->m_nIdent = -2; // ident pour this - - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( p ); // garde le nom du token - i->SetUniqNum(ident); - inst->AddNext3(i); // ajoute à la suite - } - - p = p->GivNext(); // token suivant - - while (TRUE) - { - if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau - { - if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index - { - CBotIndexExpr* i = new CBotIndexExpr(); - i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule - inst->AddNext3(i); // ajoute à la chaine - - var = ((CBotVarArray*)var)->GivItem(0,TRUE); // donne le composant [0] - - if ( i->m_expr == NULL ) - { - pStk->SetError( TX_BADINDEX, p->GivStart() ); - goto err; - } - if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) - { - pStk->SetError( TX_CLBRK, p->GivStart() ); - goto err; - } - continue; - } - //// pStk->SetError( TX_OPBRK, p->GivStart() ); - } - if ( var->GivType(1) == CBotTypPointer ) // pour les classes - { - if ( IsOfType(p, ID_DOT) ) - { - CBotToken* pp = p; - - if ( p->GivType() == TokenTypVar ) // doit être un nom - { - if ( p->GivNext()->GivType() == ID_OPENPAR )// un appel de méthode ? - { - CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var); - if ( !pStk->IsOk() ) goto err; - inst->AddNext3(i); // ajoute à la suite - return pStack->Return(inst, pStk); - } - else - { - CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément - i->SetToken( pp ); // garde le nom du token - inst->AddNext3(i); // ajoute à la suite - var = var->GivItem(p->GivString()); // récupère l'item correpondant - if ( var != NULL ) - { - i->SetUniqNum(var->GivUniqNum()); - if ( var->IsPrivate() && - !pStk->GivBotCall()->m_bCompileClass) - { - pStk->SetError( TX_PRIVATE, pp ); - goto err; - } - } - } - - - if ( var != NULL ) - { - p = p->GivNext(); // saute le nom - continue; - } - pStk->SetError( TX_NOITEM, p ); - goto err; - } - pStk->SetError( TX_DOT, p->GivStart() ); - goto err; - } - } - - break; - } - - pStk->SetCopyVar(var); // place une copie de la variable sur la pile (pour le type) - if ( pStk->IsOk() ) return pStack->Return(inst, pStk); - } - pStk->SetError(TX_UNDEFVAR, p); + CBotToken* pDebut = p; + CBotCStack* pStk = pStack->TokenStack(); + + pStk->SetStartError(p->GivStart()); + + // is it a variable? + if (p->GivType() == TokenTypVar) + { + CBotInstr* inst = new CBotExprVar(); // create the object + + inst->SetToken(p); + + CBotVar* var; + + if ( NULL != (var = pStk->FindVar(p)) ) // seek if known variable + { + int ident = var->GivUniqNum(); + ((CBotExprVar*)inst)->m_nIdent = ident; // identifies variable by its number + + if (ident > 0 && ident < 9000) + { + if ( var->IsPrivate(privat) && + !pStk->GivBotCall()->m_bCompileClass) + { + pStk->SetError( TX_PRIVATE, p ); + goto err; + } + + // This is an element of the current class + // ads the equivalent of this. before + /// \TODO need to be fixed revised and fixed after adding unit + //tests + CBotToken token("this"); + inst->SetToken(&token); + ((CBotExprVar*)inst)->m_nIdent = -2; // identificator for this + + CBotFieldExpr* i = new CBotFieldExpr(); // new element + i->SetToken( p ); // keeps the name of the token + i->SetUniqNum(ident); + inst->AddNext3(i); // added after + } + + p = p->GivNext(); // next token + + while (true) + { + if ( var->GivType() == CBotTypArrayPointer ) // s'il sagit d'un tableau + { + if ( IsOfType( p, ID_OPBRK ) ) // regarde s'il y a un index + { + CBotIndexExpr* i = new CBotIndexExpr(); + i->m_expr = CBotExpression::Compile(p, pStk); // compile la formule + inst->AddNext3(i); // ajoute à la chaine + + var = ((CBotVarArray*)var)->GivItem(0,true); // donne le composant [0] + + if ( i->m_expr == NULL ) + { + pStk->SetError( TX_BADINDEX, p->GivStart() ); + goto err; + } + if ( !pStk->IsOk() || !IsOfType( p, ID_CLBRK ) ) + { + pStk->SetError( TX_CLBRK, p->GivStart() ); + goto err; + } + continue; + } + //// pStk->SetError( TX_OPBRK, p->GivStart() ); + } + if ( var->GivType(1) == CBotTypPointer ) // pour les classes + { + if ( IsOfType(p, ID_DOT) ) + { + CBotToken* pp = p; + + if ( p->GivType() == TokenTypVar ) // doit être un nom + { + if ( p->GivNext()->GivType() == ID_OPENPAR )// un appel de méthode ? + { + CBotInstr* i = CBotInstrMethode::Compile(p, pStk, var); + if ( !pStk->IsOk() ) goto err; + inst->AddNext3(i); // ajoute à la suite + return pStack->Return(inst, pStk); + } + else + { + CBotFieldExpr* i = new CBotFieldExpr(); // nouvel élément + i->SetToken( pp ); // garde le nom du token + inst->AddNext3(i); // ajoute à la suite + var = var->GivItem(p->GivString()); // récupère l'item correpondant + if ( var != NULL ) + { + i->SetUniqNum(var->GivUniqNum()); + if ( var->IsPrivate() && + !pStk->GivBotCall()->m_bCompileClass) + { + pStk->SetError( TX_PRIVATE, pp ); + goto err; + } + } + } + + + if ( var != NULL ) + { + p = p->GivNext(); // saute le nom + continue; + } + pStk->SetError( TX_NOITEM, p ); + goto err; + } + pStk->SetError( TX_DOT, p->GivStart() ); + goto err; + } + } + + break; + } + + pStk->SetCopyVar(var); // place une copie de la variable sur la pile (pour le type) + if ( pStk->IsOk() ) return pStack->Return(inst, pStk); + } + pStk->SetError(TX_UNDEFVAR, p); err: - delete inst; - return pStack->Return(NULL, pStk); - } + delete inst; + return pStack->Return(NULL, pStk); + } - return pStack->Return(NULL, pStk); + return pStack->Return(NULL, pStk); } CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack) @@ -3280,19 +3277,19 @@ CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack) // exécute, rend la valeur d'une variable -BOOL CBotExprVar::Execute(CBotStack* &pj) +bool CBotExprVar::Execute(CBotStack* &pj) { CBotVar* pVar = NULL; CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; -// if ( pile->IfStep() ) return FALSE; +// if ( pile->IfStep() ) return false; CBotStack* pile1 = pile; if ( pile1->GivState() == 0 ) { - if ( !ExecuteVar(pVar, pile, NULL, TRUE) ) return FALSE; // récupère la variable selon champs et index + if ( !ExecuteVar(pVar, pile, NULL, true) ) return false; // récupère la variable selon champs et index // DEBUG("CBotExprVar::Execute", 1 , pj); if ( pVar ) pile1->SetCopyVar(pVar); // la place une copie sur la pile @@ -3322,7 +3319,7 @@ BOOL CBotExprVar::Execute(CBotStack* &pj) return pj->Return(pile1); // opération faite } -void CBotExprVar::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotExprVar::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -3340,25 +3337,25 @@ void CBotExprVar::RestoreState(CBotStack* &pj, BOOL bMain) // retrouve une variable à l'exécution -BOOL CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep) +bool CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep) { CBotStack* pile = pj; pj = pj->AddStack( this ); - if ( bStep && m_nIdent>0 && pj->IfStep() ) return FALSE; + if ( bStep && m_nIdent>0 && pj->IfStep() ) return false; - pVar = pj->FindVar(m_nIdent, TRUE); // cherche la variable avec mise à jour si nécessaire + pVar = pj->FindVar(m_nIdent, true); // cherche la variable avec mise à jour si nécessaire if ( pVar == NULL ) { #ifdef _DEBUG ASM_TRAP(); #endif pj->SetError(1, &m_token); - return FALSE; + return false; } if ( m_next3 != NULL && - !m_next3->ExecuteVar(pVar, pj, &m_token, bStep, FALSE) ) - return FALSE; // Champs d'une instance, tableau, méthode ? + !m_next3->ExecuteVar(pVar, pj, &m_token, bStep, false) ) + return false; // Champs d'une instance, tableau, méthode ? return pile->ReturnKeep( pj ); // ne rend pas la pile mais récupère le résultat si une méthode a été appelée } @@ -3366,7 +3363,7 @@ BOOL CBotExprVar::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToke // retrouve une variable à l'exécution -void CBotExprVar::RestoreStateVar(CBotStack* &pj, BOOL bMain) +void CBotExprVar::RestoreStateVar(CBotStack* &pj, bool bMain) { pj = pj->RestoreStack( this ); if ( pj == NULL ) return; @@ -3381,7 +3378,7 @@ void CBotExprVar::RestoreStateVar(CBotStack* &pj, BOOL bMain) CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars) { - BOOL first = TRUE; + bool first = true; CBotInstr* ret = NULL; // pour la liste à retourner // pStack->SetStartError(p->GivStart()); @@ -3391,13 +3388,13 @@ CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars) if ( IsOfType(p, ID_OPENPAR) ) { int start, end; - if (!IsOfType(p, ID_CLOSEPAR)) while (TRUE) + if (!IsOfType(p, ID_CLOSEPAR)) while (true) { start = p->GivStart(); pile = pile->TokenStack(); // garde les résultats sur la pile if ( first ) pStack->SetStartError(start); - first = FALSE; + first = false; CBotInstr* param = CBotExpression::Compile(p, pile); end = p->GivStart(); @@ -3513,11 +3510,11 @@ CBotInstr* CBotInstrMethode::Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* // exécute l'appel de méthode -BOOL CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep, BOOL bExtend) +bool CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep, bool bExtend) { CBotVar* ppVars[1000]; - CBotStack* pile1 = pj->AddStack(this, TRUE); // une place pour la copie de This -// if ( pile1 == EOX ) return TRUE; + CBotStack* pile1 = pj->AddStack(this, true); // une place pour la copie de This +// if ( pile1 == EOX ) return true; // DEBUG( "CBotInstrMethode::ExecuteVar", 0, pj ); @@ -3526,7 +3523,7 @@ BOOL CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre pj->SetError( TX_NULLPT, prevToken ); } - if ( pile1->IfStep() ) return FALSE; + if ( pile1->IfStep() ) return false; CBotStack* pile2 = pile1->AddStack(); // et pour les paramètres à venir @@ -3549,12 +3546,12 @@ BOOL CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre // évalue les paramètres // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { if ( pile2->GivState() == 0 ) { - if (!p->Execute(pile2)) return FALSE; // interrompu ici ? - if (!pile2->SetState(1)) return FALSE; // marque spéciale pour reconnaîre les paramètres + if (!p->Execute(pile2)) return false; // interrompu ici ? + if (!pile2->SetState(1)) return false; // marque spéciale pour reconnaîre les paramètres } ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats @@ -3576,14 +3573,14 @@ BOOL CBotInstrMethode::ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* pre if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, pThis, ppVars, - pResult, pile2, GivToken())) return FALSE; // interrompu + pResult, pile2, GivToken())) return false; // interrompu if (pRes != pResult) delete pRes; pVar = NULL; // ne retourne pas une valeur par cela return pj->Return(pile2); // libère toute la pile } -void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, BOOL bMain) +void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain) { if ( !bMain ) return; @@ -3604,11 +3601,11 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, BOOL bMain) // évalue les paramètres // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { if ( pile2->GivState() == 0 ) { - p->RestoreState(pile2, TRUE); // interrompu ici ! + p->RestoreState(pile2, true); // interrompu ici ! return; } ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs @@ -3630,13 +3627,13 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, BOOL bMain) } -BOOL CBotInstrMethode::Execute(CBotStack* &pj) +bool CBotInstrMethode::Execute(CBotStack* &pj) { CBotVar* ppVars[1000]; - CBotStack* pile1 = pj->AddStack(this, TRUE); // une place pour la copie de This -// if ( pile1 == EOX ) return TRUE; + CBotStack* pile1 = pj->AddStack(this, true); // une place pour la copie de This +// if ( pile1 == EOX ) return true; - if ( pile1->IfStep() ) return FALSE; + if ( pile1->IfStep() ) return false; CBotStack* pile2 = pile1->AddStack(); // et pour les paramètres à venir @@ -3656,12 +3653,12 @@ BOOL CBotInstrMethode::Execute(CBotStack* &pj) // évalue les paramètres // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { if ( pile2->GivState() == 0 ) { - if (!p->Execute(pile2)) return FALSE; // interrompu ici ? - if (!pile2->SetState(1)) return FALSE; // marque spéciale pour reconnaîre les paramètres + if (!p->Execute(pile2)) return false; // interrompu ici ? + if (!pile2->SetState(1)) return false; // marque spéciale pour reconnaîre les paramètres } ppVars[i++] = pile2->GivVar(); // construit la liste des pointeurs pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats @@ -3683,11 +3680,11 @@ BOOL CBotInstrMethode::Execute(CBotStack* &pj) if ( !pClass->ExecuteMethode(m_MethodeIdent, m_NomMethod, pThis, ppVars, - pResult, pile2, GivToken())) return FALSE; // interrompu + pResult, pile2, GivToken())) return false; // interrompu // met la nouvelle valeur de this à la place de l'ancienne variable CBotVar* old = pile1->FindVar(m_token); - old->Copy(pThis, FALSE); + old->Copy(pThis, false); if (pRes != pResult) delete pRes; @@ -3758,7 +3755,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack) // s'il n'y a pas de constructeur, et pas de paramètres non plus, c'est ok if ( typ == TX_UNDEFCALL && inst->m_Parameters == NULL ) typ = 0; - pVar->SetInit(TRUE); // marque l'instance comme init + pVar->SetInit(true); // marque l'instance comme init if (typ>20) { @@ -3784,12 +3781,12 @@ error: // exécute une instruction "new" -BOOL CBotNew::Execute(CBotStack* &pj) +bool CBotNew::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); //pile principale -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; CBotStack* pile1 = pj->AddStack2(); //pile secondaire @@ -3834,12 +3831,12 @@ BOOL CBotNew::Execute(CBotStack* &pj) // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats if ( pile2->GivState() == 0 ) { - if (!p->Execute(pile2)) return FALSE; // interrompu ici ? + if (!p->Execute(pile2)) return false; // interrompu ici ? pile2->SetState(1); } ppVars[i++] = pile2->GivVar(); @@ -3853,7 +3850,7 @@ BOOL CBotNew::Execute(CBotStack* &pj) if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(), pThis, ppVars, - pResult, pile2, GivToken())) return FALSE; // interrompu + pResult, pile2, GivToken())) return false; // interrompu pThis->ConstructorSet(); // signale que le constructeur a été appelé // pile->Return(pile2); // libère un bout de pile @@ -3864,7 +3861,7 @@ BOOL CBotNew::Execute(CBotStack* &pj) return pj->Return( pile1 ); // transmet en dessous } -void CBotNew::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotNew::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -3902,7 +3899,7 @@ void CBotNew::RestoreState(CBotStack* &pj, BOOL bMain) // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats if ( pile2 == NULL ) return; @@ -3926,31 +3923,31 @@ void CBotNew::RestoreState(CBotStack* &pj, BOOL bMain) ///////////////////////////////////////////////////////////// // regarde si deux résultats sont compatibles pour faire une opération -BOOL TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) +bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) { int t1 = type1.GivType(); int t2 = type2.GivType(); int max = (t1 > t2) ? t1 : t2; - if ( max == 99 ) return FALSE; // un résultat est void ? + if ( max == 99 ) return false; // un résultat est void ? // cas particulier pour les concaténation de chaînes - if (op == ID_ADD && max >= CBotTypString) return TRUE; - if (op == ID_ASSADD && max >= CBotTypString) return TRUE; - if (op == ID_ASS && t1 == CBotTypString) return TRUE; + if (op == ID_ADD && max >= CBotTypString) return true; + if (op == ID_ASSADD && max >= CBotTypString) return true; + if (op == ID_ASS && t1 == CBotTypString) return true; if ( max >= CBotTypBoolean ) { if ( (op == ID_EQ || op == ID_NE) && - (t1 == CBotTypPointer && t2 == CBotTypNullPointer)) return TRUE; + (t1 == CBotTypPointer && t2 == CBotTypNullPointer)) return true; if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && - (t2 == CBotTypPointer && t1 == CBotTypNullPointer)) return TRUE; + (t2 == CBotTypPointer && t1 == CBotTypNullPointer)) return true; if ( (op == ID_EQ || op == ID_NE) && - (t1 == CBotTypArrayPointer && t2 == CBotTypNullPointer)) return TRUE; + (t1 == CBotTypArrayPointer && t2 == CBotTypNullPointer)) return true; if ( (op == ID_EQ || op == ID_NE || op == ID_ASS) && - (t2 == CBotTypArrayPointer && t1 == CBotTypNullPointer)) return TRUE; - if (t2 != t1) return FALSE; + (t2 == CBotTypArrayPointer && t1 == CBotTypNullPointer)) return true; + if (t2 != t1) return false; if (t1 == CBotTypArrayPointer) return type1.Compare(type2); if (t1 == CBotTypPointer || t1 == CBotTypClass || @@ -3964,17 +3961,17 @@ BOOL TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op ) // l'opération sera refusée à l'exécution si le pointeur n'est pas compatible } - return TRUE; + return true; } type1.SetType(max); type2.SetType(max); - return TRUE; + return true; } // regarde si deux variables sont compatible pour un passage de paramètre -BOOL TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) +bool TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) { int t1 = type1.GivType(); int t2 = type2.GivType(); @@ -3984,11 +3981,11 @@ BOOL TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) int max = (t1 > t2) ? t1 : t2; - if ( max == 99 ) return FALSE; // un résultat est void ? + if ( max == 99 ) return false; // un résultat est void ? if ( max >= CBotTypBoolean ) { - if ( t2 != t1 ) return FALSE; + if ( t2 != t1 ) return false; if ( max == CBotTypArrayPointer ) return TypesCompatibles(type1.GivTypElem(), type2.GivTypElem()); @@ -3996,9 +3993,9 @@ BOOL TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ) if ( max == CBotTypClass || max == CBotTypPointer ) return type1.GivClass() == type2.GivClass() ; - return TRUE ; + return true ; } - return TRUE; + return true; } @@ -4042,7 +4039,7 @@ size_t fRead(void *buffer, size_t length, FILE* filehandle) //////////////////////////////////////// -#if FALSE +#if false CBotString num(int n) { @@ -4058,7 +4055,7 @@ CBotString num(int n) extern void DEBUG( const char* text, int val, CBotStack* pile ) { - CBotProgram* p = pile->GivBotCall(TRUE); + CBotProgram* p = pile->GivBotCall(true); if ( !p->m_bDebugDD ) return; FILE* pf = fopen("CbotDebug.txt", "a"); diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 7e15f65..6f18be8 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -17,15 +17,15 @@ // dernière révision : 03/10/2002 DD -#define EXTENDS TRUE +#define EXTENDS true #include "resource.h" #include "CBotDll.h" // définitions publiques #include "CBotToken.h" // gestion des tokens -#define STACKRUN TRUE // reprise de l'exécution direct sur une routine suspendue -#define STACKMEM TRUE // préréserve la mémoire pour la pile d'exécution +#define STACKRUN true // reprise de l'exécution direct sur une routine suspendue +#define STACKMEM true // préréserve la mémoire pour la pile d'exécution #define MAXSTACK 990 // taille du stack réservé #define EOX (CBotStack*)-1 // marqueur condition spéciale @@ -61,12 +61,13 @@ class CBotRepeat; // repeat (nb) {...} //////////////////////////////////////////////////////////////////////// -// Gestion de la pile d'exécution +// Management of the execution stack //////////////////////////////////////////////////////////////////////// -// en fait, en externe, la seule chose qu'il est possible de faire -// c'est de créer une instance d'une pile -// pour l'utiliser pour la routine CBotProgram::Execute(CBotStack) +// actually, externally, the only thing he can do +// this is to create an instance of a stack +// to use for routine CBotProgram :: Execute (CBotStack) + class CBotStack { @@ -90,9 +91,9 @@ private: CBotVar* m_var; // résultat des opérations CBotVar* m_listVar; // les variables déclarées à ce niveau - BOOL m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) - BOOL m_bOver; // limites de la pile ? -// BOOL m_bDontDelete; // spécial, ne pas détruire les variables au delete + bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) + bool m_bOver; // limites de la pile ? +// bool m_bDontDelete; // spécial, ne pas détruire les variables au delete CBotProgram* m_prog; // les fonctions définies par user static @@ -105,7 +106,7 @@ private: void* m_pUser; CBotInstr* m_instr; // l'instruction correspondante - BOOL m_bFunc; // une entrée d'une fonction ? + bool m_bFunc; // une entrée d'une fonction ? CBotCall* m_call; // point de reprise dans un call extern friend class CBotTry; @@ -117,7 +118,7 @@ public: #endif CBotStack(CBotStack* ppapa); ~CBotStack(); - BOOL StackOver(); + bool StackOver(); int GivError(int& start, int& end); int GivError(); // rend le numéro d'erreur retourné @@ -127,48 +128,48 @@ public: int GivType(int mode = 0); // donne le type de valeur sur le stack CBotTypResult GivTypResult(int mode = 0); // donne le type complet de valeur sur le stack -// void AddVar(CBotVar* p, BOOL bDontDelete=FALSE); // ajoute une variable locale +// void AddVar(CBotVar* p, bool bDontDelete=false); // ajoute une variable locale void AddVar(CBotVar* p); // ajoute une variable locale // void RestoreVar(CBotVar* pVar); - CBotVar* FindVar(CBotToken* &p, BOOL bUpdate = FALSE, - BOOL bModif = FALSE); // trouve une variable - CBotVar* FindVar(CBotToken& Token, BOOL bUpdate = FALSE, - BOOL bModif = FALSE); + CBotVar* FindVar(CBotToken* &p, bool bUpdate = false, + bool bModif = false); // trouve une variable + CBotVar* FindVar(CBotToken& Token, bool bUpdate = false, + bool bModif = false); CBotVar* FindVar(const char* name); - CBotVar* FindVar(long ident, BOOL bUpdate = FALSE, - BOOL bModif = FALSE); + CBotVar* FindVar(long ident, bool bUpdate = false, + bool bModif = false); - CBotVar* CopyVar(CBotToken& Token, BOOL bUpdate = FALSE); // trouve et rend une copie + CBotVar* CopyVar(CBotToken& Token, bool bUpdate = false); // trouve et rend une copie - CBotStack* AddStack(CBotInstr* instr = NULL, BOOL bBlock = FALSE); // étend le stack - CBotStack* AddStackEOX(CBotCall* instr = NULL, BOOL bBlock = FALSE); // étend le stack + CBotStack* AddStack(CBotInstr* instr = NULL, bool bBlock = false); // étend le stack + CBotStack* AddStackEOX(CBotCall* instr = NULL, bool bBlock = false); // étend le stack CBotStack* RestoreStack(CBotInstr* instr = NULL); CBotStack* RestoreStackEOX(CBotCall* instr = NULL); - CBotStack* AddStack2(BOOL bBlock = FALSE); // étend le stack - BOOL Return(CBotStack* pFils); // transmet le résultat au dessus - BOOL ReturnKeep(CBotStack* pFils); // transmet le résultat sans réduire la pile - BOOL BreakReturn(CBotStack* pfils, const char* name = NULL); + CBotStack* AddStack2(bool bBlock = false); // étend le stack + bool Return(CBotStack* pFils); // transmet le résultat au dessus + bool ReturnKeep(CBotStack* pFils); // transmet le résultat sans réduire la pile + bool BreakReturn(CBotStack* pfils, const char* name = NULL); // en cas de break éventuel - BOOL IfContinue(int state, const char* name); + bool IfContinue(int state, const char* name); // ou de "continue" - BOOL IsOk(); + bool IsOk(); - BOOL SetState(int n, int lim = -10); // sélectionne un état + bool SetState(int n, int lim = -10); // sélectionne un état int GivState(); // dans quel état j'ère ? - BOOL IncState(int lim = -10); // passe à l'état suivant - BOOL IfStep(); // faire du pas à pas ? - BOOL Execute(); + bool IncState(int lim = -10); // passe à l'état suivant + bool IfStep(); // faire du pas à pas ? + bool Execute(); void SetVar( CBotVar* var ); void SetCopyVar( CBotVar* var ); CBotVar* GivVar(); CBotVar* GivCopyVar(); CBotVar* GivPtVar(); - BOOL GivRetVar(BOOL bRet); + bool GivRetVar(bool bRet); long GivVal(); void SetStartError(int pos); @@ -178,17 +179,17 @@ public: void SetBreak(int val, const char* name); void SetBotCall(CBotProgram* p); - CBotProgram* GivBotCall(BOOL bFirst = FALSE); + CBotProgram* GivBotCall(bool bFirst = false); void* GivPUser(); - BOOL GivBlock(); + bool GivBlock(); -// BOOL ExecuteCall(CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); - BOOL ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); +// bool ExecuteCall(CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); + bool ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype); void RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar); - BOOL SaveState(FILE* pf); - BOOL RestoreState(FILE* pf, CBotStack* &pStack); + bool SaveState(FILE* pf); + bool RestoreState(FILE* pf, CBotStack* &pStack); static void SetTimer(int n); @@ -201,7 +202,7 @@ public: // les routines inline doivent être déclarées dans le fichier .h -inline BOOL CBotStack::IsOk() +inline bool CBotStack::IsOk() { return (m_error == 0); } @@ -235,7 +236,7 @@ private: CBotVar* m_var; // résultat des opérations - BOOL m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) + bool m_bBlock; // fait partie d'un bloc (variables sont locales à ce bloc) CBotVar* m_listVar; static @@ -249,7 +250,7 @@ public: CBotCStack(CBotCStack* ppapa); ~CBotCStack(); - BOOL IsOk(); + bool IsOk(); int GivError(); int GivError(int& start, int& end); // rend le numéro d'erreur retourné @@ -262,10 +263,10 @@ public: void AddVar(CBotVar* p); // ajoute une variable locale CBotVar* FindVar(CBotToken* &p); // trouve une variable CBotVar* FindVar(CBotToken& Token); - BOOL CheckVarLocal(CBotToken* &pToken); + bool CheckVarLocal(CBotToken* &pToken); CBotVar* CopyVar(CBotToken& Token); // trouve et rend une copie - CBotCStack* TokenStack(CBotToken* pToken = NULL, BOOL bBlock = FALSE); + CBotCStack* TokenStack(CBotToken* pToken = NULL, bool bBlock = false); CBotInstr* Return(CBotInstr* p, CBotCStack* pParent); // transmet le résultat au dessus CBotFunction* ReturnFunc(CBotFunction* p, CBotCStack* pParent); // transmet le résultat au dessus @@ -285,17 +286,17 @@ public: void SetBotCall(CBotProgram* p); CBotProgram* GivBotCall(); CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent); - BOOL CheckCall(CBotToken* &pToken, CBotDefParam* pParam); + bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam); - BOOL NextToken(CBotToken* &p); + bool NextToken(CBotToken* &p); }; -extern BOOL SaveVar(FILE* pf, CBotVar* pVar); +extern bool SaveVar(FILE* pf, CBotVar* pVar); ///////////////////////////////////////////////////////////////////// -// classes définissant une instruction +// classes defining an instruction class CBotInstr { private: @@ -303,17 +304,17 @@ private: CBotStringArray m_labelLvl; protected: - CBotToken m_token; // conserve le token + CBotToken m_token; // keeps the token CBotString name; // debug - CBotInstr* m_next; // instructions chaînées - CBotInstr* m_next2b; // seconde liste pour définition en chaîne - CBotInstr* m_next3; // troisième liste pour les indices et champs - CBotInstr* m_next3b; // nécessaire pour la déclaration des tableaux + CBotInstr* m_next; // linked command + CBotInstr* m_next2b; // second list definition chain + CBotInstr* m_next3; // third list for indices and fields + CBotInstr* m_next3b; // necessary for reporting tables /* - par exemple, le programme suivant + for example, the following program int x[]; x[1] = 4; int y[x[1]][10], z; - va généré + is generated CBotInstrArray m_next3b-> CBotEmpty m_next-> @@ -338,31 +339,30 @@ public: virtual ~CBotInstr(); - DllExport//debug +// DllExport//debug static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); static - CBotInstr* CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, BOOL first = TRUE); + CBotInstr* CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first = true); virtual - BOOL Execute(CBotStack* &pj); + bool Execute(CBotStack* &pj); virtual - BOOL Execute(CBotStack* &pj, CBotVar* pVar); + bool Execute(CBotStack* &pj, CBotVar* pVar); virtual - void RestoreState(CBotStack* &pj, BOOL bMain); + void RestoreState(CBotStack* &pj, bool bMain); virtual - BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); virtual - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); virtual - void RestoreStateVar(CBotStack* &pile, BOOL bMain); + void RestoreStateVar(CBotStack* &pile, bool bMain); virtual - BOOL CompCase(CBotStack* &pj, int val); + bool CompCase(CBotStack* &pj, int val); void SetToken(CBotToken* p); - void SetToken(CBotString* name, int start=0, int end=0); int GivTokenType(); CBotToken* GivToken(); @@ -380,9 +380,9 @@ public: static void DecLvl(); static - BOOL ChkLvl(const CBotString& label, int type); + bool ChkLvl(const CBotString& label, int type); - BOOL IsOfClass(CBotString name); + bool IsOfClass(CBotString name); }; class CBotWhile : public CBotInstr @@ -397,24 +397,34 @@ public: ~CBotWhile(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotRepeat : public CBotInstr { private: - CBotInstr* m_NbIter; // le nombre d'itération - CBotInstr* m_Block; // les instructions - CBotString m_label; // une étiquette s'il y a + /// Number of iterations + CBotInstr* m_NbIter; + + /// Instructions + CBotInstr* m_Block; + + /// Label + CBotString m_label; // une étiquette s'il y a public: - CBotRepeat(); - ~CBotRepeat(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotRepeat(); + ~CBotRepeat(); + + /// Static method used for compilation + static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + + /// Execute + bool Execute(CBotStack* &pj); + + /// Restore state + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotDo : public CBotInstr @@ -429,8 +439,8 @@ public: ~CBotDo(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotFor : public CBotInstr @@ -447,8 +457,8 @@ public: ~CBotFor(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotBreak : public CBotInstr @@ -461,8 +471,8 @@ public: ~CBotBreak(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotReturn : public CBotInstr @@ -475,8 +485,8 @@ public: ~CBotReturn(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -491,8 +501,8 @@ public: ~CBotSwitch(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -506,9 +516,9 @@ public: ~CBotCase(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); - BOOL CompCase(CBotStack* &pj, int val); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + bool CompCase(CBotStack* &pj, int val); }; class CBotCatch : public CBotInstr @@ -524,10 +534,10 @@ public: ~CBotCatch(); static CBotCatch* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL TestCatch(CBotStack* &pj, int val); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); - void RestoreCondState(CBotStack* &pj, BOOL bMain); + bool TestCatch(CBotStack* &pj, int val); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + void RestoreCondState(CBotStack* &pj, bool bMain); }; class CBotTry : public CBotInstr @@ -542,8 +552,8 @@ public: ~CBotTry(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotThrow : public CBotInstr @@ -556,8 +566,8 @@ public: ~CBotThrow(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -570,7 +580,7 @@ public: ~CBotStartDebugDD(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); + bool Execute(CBotStack* &pj); }; @@ -586,8 +596,8 @@ public: ~CBotIf(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -604,9 +614,9 @@ public: CBotInt(); ~CBotInt(); static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip = FALSE); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un tableau @@ -625,8 +635,8 @@ public: ~CBotInstArray(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -643,15 +653,15 @@ public: ~CBotListArray(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResult type); - BOOL Execute(CBotStack* &pj, CBotVar* pVar); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj, CBotVar* pVar); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotEmpty : public CBotInstr { - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un booléen @@ -666,9 +676,9 @@ public: CBotBoolean(); ~CBotBoolean(); static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -684,9 +694,9 @@ public: CBotFloat(); ~CBotFloat(); static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un elément string @@ -701,9 +711,9 @@ public: CBotIString(); ~CBotIString(); static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL cont = FALSE, BOOL noskip=FALSE); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // définition d'un elément dans une classe quelconque @@ -715,7 +725,7 @@ private: CBotClass* m_pClass; // référence à la classe CBotInstr* m_Parameters; // les paramètres à évaluer pour le constructeur CBotInstr* m_expr; // la valeur à mettre, s'il y a - BOOL m_hasParams; // il y a des paramètres ? + bool m_hasParams; // il y a des paramètres ? long m_nMethodeIdent; public: @@ -723,8 +733,8 @@ public: ~CBotClassInst(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass = NULL); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotCondition : public CBotInstr @@ -751,11 +761,11 @@ public: ~CBotLeftExpr(); static CBotLeftExpr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pStack, CBotStack* array); + bool Execute(CBotStack* &pStack, CBotStack* array); - BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep); - void RestoreStateVar(CBotStack* &pile, BOOL bMain); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); + void RestoreStateVar(CBotStack* &pile, bool bMain); }; @@ -773,9 +783,9 @@ public: void SetUniqNum(int num); // static // CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend); - void RestoreStateVar(CBotStack* &pj, BOOL bMain); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; // gestion des index dans les tableaux @@ -792,9 +802,9 @@ public: ~CBotIndexExpr(); // static // CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep, BOOL bExtend); - void RestoreStateVar(CBotStack* &pj, BOOL bMain); + bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; // une expression du genre @@ -812,8 +822,8 @@ public: ~CBotExpression(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotListExpression : public CBotInstr @@ -826,8 +836,8 @@ public: ~CBotListExpression(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotLogicExpr : public CBotInstr @@ -843,8 +853,8 @@ public: ~CBotLogicExpr(); // static // CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -882,8 +892,8 @@ public: ~CBotExprUnaire(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; // toutes les opérations à 2 opérandes @@ -898,8 +908,8 @@ public: ~CBotTwoOpExpr(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = NULL); - BOOL Execute(CBotStack* &pStack); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pStack); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -912,9 +922,9 @@ private: public: static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = TRUE); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); static - CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = FALSE); + CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false); }; @@ -928,9 +938,9 @@ public: CBotListInstr(); ~CBotListInstr(); static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, BOOL bLocal = TRUE); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -949,8 +959,8 @@ public: ~CBotInstrCall(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // un appel d'une méthode @@ -974,12 +984,12 @@ public: ~CBotInstrMethode(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, CBotVar* pVar); - BOOL Execute(CBotStack* &pj); - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep, BOOL bExtend); - void RestoreStateVar(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep, bool bExtend); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; -// expression donnant un nom de variable +// expression for the variable name class CBotExprVar : public CBotInstr { @@ -996,11 +1006,11 @@ public: static CBotInstr* CompileMethode(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); - BOOL ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, BOOL bStep); - BOOL Execute2Var(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, BOOL bStep); - void RestoreStateVar(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); + bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); + bool Execute2Var(CBotVar* &pVar, CBotStack* &pj, CBotToken* prevToken, bool bStep); + void RestoreStateVar(CBotStack* &pj, bool bMain); }; class CBotPostIncExpr : public CBotInstr @@ -1014,8 +1024,8 @@ public: ~CBotPostIncExpr(); // static // CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotPreIncExpr : public CBotInstr @@ -1029,8 +1039,8 @@ public: ~CBotPreIncExpr(); // static // CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1047,8 +1057,8 @@ public: ~CBotLeftExprVar(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1062,8 +1072,8 @@ public: static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1075,8 +1085,8 @@ public: CBotExprNull(); ~CBotExprNull(); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotExprNan : public CBotInstr @@ -1087,8 +1097,8 @@ public: CBotExprNan(); ~CBotExprNan(); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; class CBotNew : public CBotInstr @@ -1105,8 +1115,8 @@ public: static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; // expression représentant un nombre @@ -1123,8 +1133,8 @@ public: ~CBotExprNum(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1140,8 +1150,8 @@ public: ~CBotExprAlpha(); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); }; @@ -1166,7 +1176,7 @@ public: float GivValFloat(); CBotString GivValString(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void Add(CBotVar* left, CBotVar* right); // addition @@ -1176,12 +1186,12 @@ public: int Modulo(CBotVar* left, CBotVar* right); // reste de division void Power(CBotVar* left, CBotVar* right); // puissance - BOOL Lo(CBotVar* left, CBotVar* right); - BOOL Hi(CBotVar* left, CBotVar* right); - BOOL Ls(CBotVar* left, CBotVar* right); - BOOL Hs(CBotVar* left, CBotVar* right); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); void XOr(CBotVar* left, CBotVar* right); void Or(CBotVar* left, CBotVar* right); @@ -1196,8 +1206,8 @@ public: void Inc(); void Dec(); - BOOL Save0State(FILE* pf); - BOOL Save1State(FILE* pf); + bool Save0State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1217,7 +1227,7 @@ public: float GivValFloat(); CBotString GivValString(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void Add(CBotVar* left, CBotVar* right); // addition @@ -1227,18 +1237,18 @@ public: int Modulo(CBotVar* left, CBotVar* right); // reste de division void Power(CBotVar* left, CBotVar* right); // puissance - BOOL Lo(CBotVar* left, CBotVar* right); - BOOL Hi(CBotVar* left, CBotVar* right); - BOOL Ls(CBotVar* left, CBotVar* right); - BOOL Hs(CBotVar* left, CBotVar* right); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); void Neg(); void Inc(); void Dec(); - BOOL Save1State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1255,25 +1265,25 @@ public: void SetValString(const char* p); CBotString GivValString(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void Add(CBotVar* left, CBotVar* right); // addition - BOOL Lo(CBotVar* left, CBotVar* right); - BOOL Hi(CBotVar* left, CBotVar* right); - BOOL Ls(CBotVar* left, CBotVar* right); - BOOL Hs(CBotVar* left, CBotVar* right); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Lo(CBotVar* left, CBotVar* right); + bool Hi(CBotVar* left, CBotVar* right); + bool Ls(CBotVar* left, CBotVar* right); + bool Hs(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - BOOL Save1State(FILE* pf); + bool Save1State(FILE* pf); }; // classe pour la gestion des boolean class CBotVarBoolean : public CBotVar { private: - BOOL m_val; // la valeur + bool m_val; // la valeur public: CBotVarBoolean( const CBotToken* name ); @@ -1285,16 +1295,16 @@ public: float GivValFloat(); CBotString GivValString(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void And(CBotVar* left, CBotVar* right); void Or(CBotVar* left, CBotVar* right); void XOr(CBotVar* left, CBotVar* right); void Not(); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); - BOOL Save1State(FILE* pf); + bool Save1State(FILE* pf); }; @@ -1315,7 +1325,7 @@ private: friend class CBotVarPointer; // et le pointeur aussi int m_CptUse; // compteur d'utilisation long m_ItemIdent; // identificateur (unique) de l'instance - BOOL m_bConstructor; // set si un constructeur a été appelé + bool m_bConstructor; // set si un constructeur a été appelé public: CBotVarClass( const CBotToken* name, const CBotTypResult& type ); @@ -1323,19 +1333,19 @@ public: ~CBotVarClass(); // void InitCBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent ); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void SetClass(CBotClass* pClass); //, int &nIdent); CBotClass* GivClass(); CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) CBotVar* GivItemRef(int nIdent); - CBotVar* GivItem(int n, BOOL bExtend); + CBotVar* GivItem(int n, bool bExtend); CBotVar* GivItemList(); CBotString GivValString(); - BOOL Save1State(FILE* pf); - void Maj(void* pUser, BOOL bContinue); + bool Save1State(FILE* pf); + void Maj(void* pUser, bool bContinue); void IncrementUse(); // une référence en plus void DecrementUse(); // une référence en moins @@ -1351,8 +1361,8 @@ public: // CBotVar* GivMyThis(); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); void ConstructorSet(); }; @@ -1371,7 +1381,7 @@ public: CBotVarPointer( const CBotToken* name, CBotTypResult& type ); ~CBotVarPointer(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); + void Copy(CBotVar* pSrc, bool bName=true); void SetClass(CBotClass* pClass); CBotClass* GivClass(); CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) @@ -1387,11 +1397,11 @@ public: long GivIdent(); // donne le numéro d'identification associé void ConstructorSet(); - BOOL Save1State(FILE* pf); - void Maj(void* pUser, BOOL bContinue); + bool Save1State(FILE* pf); + void Maj(void* pUser, bool bContinue); - BOOL Eq(CBotVar* left, CBotVar* right); - BOOL Ne(CBotVar* left, CBotVar* right); + bool Eq(CBotVar* left, CBotVar* right); + bool Ne(CBotVar* left, CBotVar* right); }; @@ -1415,37 +1425,37 @@ public: CBotVarClass* GivPointer(); - void Copy(CBotVar* pSrc, BOOL bName=TRUE); - CBotVar* GivItem(int n, BOOL bGrow=FALSE); // rend un élément selon son index numérique + void Copy(CBotVar* pSrc, bool bName=true); + CBotVar* GivItem(int n, bool bGrow=false); // rend un élément selon son index numérique // agrandi le tableau si nécessaire si bExtend // CBotVar* GivItem(const char* name); // rend un élément selon son index litéral CBotVar* GivItemList(); // donne le premier élément de la liste CBotString GivValString(); // donne le contenu du tableau dans une chaîne - BOOL Save1State(FILE* pf); + bool Save1State(FILE* pf); }; extern CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars); -extern BOOL TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op = 0 ); -extern BOOL TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ); +extern bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op = 0 ); +extern bool TypesCompatibles( const CBotTypResult& type1, const CBotTypResult& type2 ); -extern BOOL WriteWord(FILE* pf, WORD w); -extern BOOL ReadWord(FILE* pf, WORD& w); -extern BOOL ReadLong(FILE* pf, long& w); -extern BOOL WriteFloat(FILE* pf, float w); -extern BOOL WriteLong(FILE* pf, long w); -extern BOOL ReadFloat(FILE* pf, float& w); -extern BOOL WriteString(FILE* pf, CBotString s); -extern BOOL ReadString(FILE* pf, CBotString& s); -extern BOOL WriteType(FILE* pf, CBotTypResult type); -extern BOOL ReadType(FILE* pf, CBotTypResult& type); +extern bool WriteWord(FILE* pf, unsigned short w); +extern bool ReadWord(FILE* pf, unsigned short& w); +extern bool ReadLong(FILE* pf, long& w); +extern bool WriteFloat(FILE* pf, float w); +extern bool WriteLong(FILE* pf, long w); +extern bool ReadFloat(FILE* pf, float& w); +extern bool WriteString(FILE* pf, CBotString s); +extern bool ReadString(FILE* pf, CBotString& s); +extern bool WriteType(FILE* pf, CBotTypResult type); +extern bool ReadType(FILE* pf, CBotTypResult& type); extern float GivNumFloat( const char* p ); -#if FALSE +#if false extern void DEBUG( const char* text, int val, CBotStack* pile ); #endif @@ -1463,36 +1473,36 @@ private: private: CBotString m_name; - BOOL (*m_rExec) (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser) ; + bool (*m_rExec) (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser) ; CBotTypResult (*m_rComp) (CBotVar* &pVar, void* pUser) ; CBotCall* m_next; public: CBotCall(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); ~CBotCall(); static - BOOL AddFunction(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); static CBotTypResult CompileCall(CBotToken* &p, CBotVar** ppVars, CBotCStack* pStack, long& nIdent); static - BOOL CheckCall(const char* name); + bool CheckCall(const char* name); // static // int DoCall(CBotToken* &p, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); static int DoCall(long& nIdent, CBotToken* token, CBotVar** ppVars, CBotStack* pStack, CBotTypResult& rettype); #if STACKRUN - BOOL Run(CBotStack* pStack); + bool Run(CBotStack* pStack); static - BOOL RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack); + bool RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack); #endif CBotString GivName(); @@ -1508,7 +1518,7 @@ class CBotCallMethode { private: CBotString m_name; - BOOL (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception); + bool (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception); CBotTypResult (*m_rComp) (CBotVar* pThis, CBotVar* &pVar); CBotCallMethode* m_next; @@ -1517,7 +1527,7 @@ private: public: CBotCallMethode(const char* name, - BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); ~CBotCallMethode(); @@ -1550,8 +1560,8 @@ public: ~CBotDefParam(); static CBotDefParam* Compile(CBotToken* &p, CBotCStack* pStack); - BOOL Execute(CBotVar** ppVars, CBotStack* &pj); - void RestoreState(CBotStack* &pj, BOOL bMain); + bool Execute(CBotVar** ppVars, CBotStack* &pj); + void RestoreState(CBotStack* &pj, bool bMain); void AddNext(CBotDefParam* p); int GivType(); @@ -1575,7 +1585,7 @@ private: friend class CBotCStack; // long m_nThisIdent; long m_nFuncIdent; - BOOL m_bSynchro; // méthode synchronisée ? + bool m_bSynchro; // méthode synchronisée ? private: CBotDefParam* m_Param; // liste des paramètres @@ -1584,8 +1594,8 @@ private: CBotToken m_retToken; // si retourne un CBotTypClass CBotTypResult m_retTyp; // type complet du résultat - BOOL m_bPublic; // fonction publique - BOOL m_bExtern; // fonction extern + bool m_bPublic; // fonction publique + bool m_bExtern; // fonction extern CBotString m_MasterClass; // nom de la classe qu'on dérive CBotProgram* m_pProg; friend class CBotProgram; @@ -1600,32 +1610,32 @@ public: CBotFunction(); ~CBotFunction(); static - CBotFunction* Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* pFunc, BOOL bLocal = TRUE); + CBotFunction* Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* pFunc, bool bLocal = true); static CBotFunction* Compile1(CBotToken* &p, CBotCStack* pStack, CBotClass* pClass); - BOOL Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); + bool Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); void RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance = NULL); void AddNext(CBotFunction* p); CBotTypResult CompileCall(const char* name, CBotVar** ppVars, long& nIdent); - CBotFunction* FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, BOOL bPublic = TRUE); + CBotFunction* FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic = true); int DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken); void RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack); int DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotToken* pToken, CBotClass* pClass); void RestoreCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass); - BOOL CheckParam(CBotDefParam* pParam); + bool CheckParam(CBotDefParam* pParam); static void AddPublic(CBotFunction* pfunc); CBotString GivName(); CBotString GivParams(); - BOOL IsPublic(); - BOOL IsExtern(); + bool IsPublic(); + bool IsExtern(); CBotFunction* Next(); - BOOL GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop); + bool GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop); }; diff --git a/src/CBot/CBotAddExpr.cpp b/src/CBot/CBotAddExpr.cpp index ad87880..d94946e 100644 --- a/src/CBot/CBotAddExpr.cpp +++ b/src/CBot/CBotAddExpr.cpp @@ -93,7 +93,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack) // fait l'opération d'addition ou de soustraction -BOOL CBotAddExpr::Execute(CBotStack* &pStack) +bool CBotAddExpr::Execute(CBotStack* &pStack) { CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp index 7c097af..c99185f 100644 --- a/src/CBot/CBotClass.cpp +++ b/src/CBot/CBotClass.cpp @@ -21,7 +21,7 @@ CBotClass* CBotClass::m_ExClass = NULL; -CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic) +CBotClass::CBotClass(const char* name, CBotClass* pPapa, bool bIntrinsic) { m_pParent = pPapa; m_name = name; @@ -30,7 +30,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic) m_pCalls = NULL; m_pMethod = NULL; m_rMaj = NULL; - m_IsDef = TRUE; + m_IsDef = true; m_bIntrinsic= bIntrinsic; m_cptLock = 0; m_cptOne = 0; @@ -86,7 +86,7 @@ void CBotClass::Purge() m_pCalls = NULL; delete m_pMethod; m_pMethod = NULL; - m_IsDef = FALSE; + m_IsDef = false; m_nbVar = m_pParent == NULL ? 0 : m_pParent->m_nbVar; @@ -94,7 +94,7 @@ void CBotClass::Purge() m_next = NULL; // n'appartient plus à cette chaîne } -BOOL CBotClass::Lock(CBotProgram* p) +bool CBotClass::Lock(CBotProgram* p) { int i = m_cptLock++; @@ -102,13 +102,13 @@ BOOL CBotClass::Lock(CBotProgram* p) { m_cptOne = 1; m_ProgInLock[0] = p; - return TRUE; + return true; } if ( p == m_ProgInLock[0] ) { m_cptOne++; m_cptLock--; // a déjà été compté - return TRUE; + return true; } for ( int j = 1 ; j <= i ; j++) @@ -116,7 +116,7 @@ BOOL CBotClass::Lock(CBotProgram* p) if ( p == m_ProgInLock[j] ) { m_cptLock--; - return FALSE; // déjà en attente + return false; // déjà en attente } } @@ -127,7 +127,7 @@ BOOL CBotClass::Lock(CBotProgram* p) else m_cptLock--; - return FALSE; + return false; } void CBotClass::Unlock() @@ -170,7 +170,7 @@ void CBotClass::FreeLock(CBotProgram* p) -BOOL CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate) +bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate) { CBotToken token(name, CBotString()); CBotClass* pClass = type.GivClass(); @@ -194,14 +194,14 @@ BOOL CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate) } -BOOL CBotClass::AddItem(CBotVar* pVar) +bool CBotClass::AddItem(CBotVar* pVar) { pVar->SetUniqNum(++m_nbVar); if ( m_pVar == NULL ) m_pVar = pVar; else m_pVar->AddNext(pVar); - return TRUE; + return true; } void CBotClass::AddNext(CBotClass* pClass) @@ -223,15 +223,15 @@ CBotClass* CBotClass::GivParent() return m_pParent; } -BOOL CBotClass::IsChildOf(CBotClass* pClass) +bool CBotClass::IsChildOf(CBotClass* pClass) { CBotClass* p = this; while ( p != NULL ) { - if ( p == pClass ) return TRUE; + if ( p == pClass ) return true; p = p->m_pParent; } - return FALSE; + return false; } @@ -266,7 +266,7 @@ CBotVar* CBotClass::GivItemRef(int nIdent) return NULL; } -BOOL CBotClass::IsIntrinsic() +bool CBotClass::IsIntrinsic() { return m_bIntrinsic; } @@ -289,8 +289,8 @@ CBotClass* CBotClass::Find(const char* name) return NULL; } -BOOL CBotClass::AddFunction(const char* name, - BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), +bool CBotClass::AddFunction(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) { // mémorise les pointeurs aux deux fonctions @@ -315,13 +315,13 @@ BOOL CBotClass::AddFunction(const char* name, if (m_pCalls == NULL) m_pCalls = p; else m_pCalls->AddNext(p); // ajoute à la liste - return TRUE; + return true; } -BOOL CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ) +bool CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ) { m_rMaj = rMaj; - return TRUE; + return true; } // compile une méthode associée à une instance de classe @@ -348,7 +348,7 @@ CBotTypResult CBotClass::CompileMethode(const char* name, // exécute une méthode -BOOL CBotClass::ExecuteMethode(long& nIdent, const char* name, +bool CBotClass::ExecuteMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken) @@ -371,77 +371,77 @@ void CBotClass::RestoreMethode(long& nIdent, const char* name, CBotVar* pThis, -BOOL CBotClass::SaveStaticState(FILE* pf) +bool CBotClass::SaveStaticState(FILE* pf) { - if (!WriteWord( pf, CBOTVERSION*2)) return FALSE; + if (!WriteWord( pf, CBOTVERSION*2)) return false; // sauve l'état des variables statiques dans les classes CBotClass* p = m_ExClass; while ( p != NULL ) { - if (!WriteWord( pf, 1)) return FALSE; + if (!WriteWord( pf, 1)) return false; // enregistre le nom de la classe - if (!WriteString( pf, p->GivName() )) return FALSE; + if (!WriteString( pf, p->GivName() )) return false; CBotVar* pv = p->GivVar(); while( pv != NULL ) { if ( pv->IsStatic() ) { - if (!WriteWord( pf, 1)) return FALSE; - if (!WriteString( pf, pv->GivName() )) return FALSE; + if (!WriteWord( pf, 1)) return false; + if (!WriteString( pf, pv->GivName() )) return false; - if ( !pv->Save0State(pf)) return FALSE; // entête commune - if ( !pv->Save1State(pf) ) return FALSE; // sauve selon la classe fille - if ( !WriteWord( pf, 0)) return FALSE; + if ( !pv->Save0State(pf)) return false; // entête commune + if ( !pv->Save1State(pf) ) return false; // sauve selon la classe fille + if ( !WriteWord( pf, 0)) return false; } pv = pv->GivNext(); } - if (!WriteWord( pf, 0)) return FALSE; + if (!WriteWord( pf, 0)) return false; p = p->m_ExNext; } - if (!WriteWord( pf, 0)) return FALSE; - return TRUE; + if (!WriteWord( pf, 0)) return false; + return true; } -BOOL CBotClass::RestoreStaticState(FILE* pf) +bool CBotClass::RestoreStaticState(FILE* pf) { CBotString ClassName, VarName; CBotClass* pClass; - WORD w; + unsigned short w; - if (!ReadWord( pf, w )) return FALSE; - if ( w != CBOTVERSION*2 ) return FALSE; + if (!ReadWord( pf, w )) return false; + if ( w != CBOTVERSION*2 ) return false; - while (TRUE) + while (true) { - if (!ReadWord( pf, w )) return FALSE; - if ( w == 0 ) return TRUE; + if (!ReadWord( pf, w )) return false; + if ( w == 0 ) return true; - if (!ReadString( pf, ClassName )) return FALSE; + if (!ReadString( pf, ClassName )) return false; pClass = Find(ClassName); - while (TRUE) + while (true) { - if (!ReadWord( pf, w )) return FALSE; + if (!ReadWord( pf, w )) return false; if ( w == 0 ) break; CBotVar* pVar = NULL; CBotVar* pv = NULL; - if (!ReadString( pf, VarName )) return FALSE; + if (!ReadString( pf, VarName )) return false; if ( pClass != NULL ) pVar = pClass->GivItem(VarName); - if (!CBotVar::RestoreState(pf, pv)) return FALSE; // la variable temp + if (!CBotVar::RestoreState(pf, pv)) return false; // la variable temp if ( pVar != NULL ) pVar->Copy(pv); delete pv; } } - return TRUE; + return true; } @@ -453,7 +453,7 @@ CBotClassInst::CBotClassInst() m_var = NULL; m_Parameters = NULL; m_expr = NULL; - m_hasParams = FALSE; + m_hasParams = false; m_nMethodeIdent = 0; name = "CBotClassInst"; } @@ -484,18 +484,17 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p = p->GivNext(); } - BOOL bIntrinsic = pClass->IsIntrinsic(); - CBotTypResult - type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, - pClass ); + bool bIntrinsic = pClass->IsIntrinsic(); + CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass ); CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type); if ( inst != NULL || !pStack->IsOk() ) return inst; CBotCStack* pStk = pStack->TokenStack(); inst = new CBotClassInst(); - - inst->SetToken(&pClass->GivName(), p->GivStart(), p->GivEnd()); + /// \TODO Need to be revised and fixed after adding unit tests + CBotToken token(pClass->GivName(), CBotString(), p->GivStart(), p->GivEnd()); + inst->SetToken(&token); CBotToken* vartoken = p; if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) @@ -601,7 +600,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* var->SetPointer( pvar ); // var déjà déclarée pointe l'instance delete pvar; // supprime le second pointeur } - var->SetInit(TRUE); // marque le pointeur comme init + var->SetInit(true); // marque le pointeur comme init } else if (inst->m_hasParams) { @@ -640,17 +639,17 @@ error: // déclaration de l'instance d'une classe, par exemple: // CPoint A, B; -BOOL CBotClassInst::Execute(CBotStack* &pj) +bool CBotClassInst::Execute(CBotStack* &pj) { CBotVar* pThis = NULL; CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; CBotToken* pt = &m_token; CBotClass* pClass = CBotClass::Find(pt); - BOOL bIntrincic = pClass->IsIntrinsic(); + bool bIntrincic = pClass->IsIntrinsic(); // crée la variable de type pointeur à l'objet @@ -682,7 +681,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) if ( m_expr != NULL ) { // évalue l'expression pour l'assignation - if (!m_expr->Execute(pile)) return FALSE; + if (!m_expr->Execute(pile)) return false; if ( bIntrincic ) { @@ -692,7 +691,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) pile->SetError(TX_NULLPT, &m_token); return pj->Return(pile); } - pThis->Copy(pile->GivVar(), FALSE); + pThis->Copy(pile->GivVar(), false); } else { @@ -700,7 +699,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation pThis->SetPointer(pInstance); } - pThis->SetInit(TRUE); + pThis->SetInit(true); } else if ( m_hasParams ) @@ -732,12 +731,12 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats if ( pile2->GivState() == 0 ) { - if (!p->Execute(pile2)) return FALSE; // interrompu ici ? + if (!p->Execute(pile2)) return false; // interrompu ici ? pile2->SetState(1); } ppVars[i++] = pile2->GivVar(); @@ -751,9 +750,9 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(), pThis, ppVars, - pResult, pile2, GivToken())) return FALSE; // interrompu + pResult, pile2, GivToken())) return false; // interrompu - pThis->SetInit(TRUE); + pThis->SetInit(true); pThis->ConstructorSet(); // signale que le constructeur a été appelé pile->Return(pile2); // libère un bout de pile @@ -766,17 +765,17 @@ BOOL CBotClassInst::Execute(CBotStack* &pj) pile->SetState(3); // fini cette partie } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( m_next2b != NULL && - !m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s) + !m_next2b->Execute(pile)) return false; // autre(s) définition(s) return pj->Return( pile ); // transmet en dessous } -void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain) { CBotVar* pThis = NULL; @@ -793,7 +792,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) CBotToken* pt = &m_token; CBotClass* pClass = CBotClass::Find(pt); - BOOL bIntrincic = pClass->IsIntrinsic(); + bool bIntrincic = pClass->IsIntrinsic(); if ( bMain && pile->GivState()<3) { @@ -827,7 +826,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats if ( pile2 == NULL ) return; @@ -858,11 +857,11 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) // test si un nom de procédure est déjà défini quelque part -BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) +bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { CBotString name = pToken->GivString(); - if ( CBotCall::CheckCall(name) ) return TRUE; + if ( CBotCall::CheckCall(name) ) return true; CBotFunction* pp = m_pMethod; while ( pp != NULL ) @@ -871,11 +870,11 @@ BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { // les paramètres sont-ils exactement les mêmes ? if ( pp->CheckParam( pParam ) ) - return TRUE; + return true; } pp = pp->Next(); } - return FALSE; + return false; } diff --git a/src/CBot/CBotCompExpr.cpp b/src/CBot/CBotCompExpr.cpp index 41e7e05..0f296d5 100644 --- a/src/CBot/CBotCompExpr.cpp +++ b/src/CBot/CBotCompExpr.cpp @@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack) // fait l'opération -BOOL CBotCompExpr::Execute(CBotStack* &pStack) +bool CBotCompExpr::Execute(CBotStack* &pStack) { CBotStack* pStk1 = pStack->AddStack(this); // if ( pStk1 == EOX ) return TRUE; diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h index 7fa9472..f0d7fef 100644 --- a/src/CBot/CBotDll.h +++ b/src/CBot/CBotDll.h @@ -19,10 +19,10 @@ //#include "stdafx.h" -#include +// #include #include -#define DllExport __declspec( dllexport ) +// #define DllExport __declspec( dllexport ) #define CBOTVERSION 104 @@ -93,62 +93,62 @@ private: public: // divers constructeurs selon les besoins - DllExport + //DllExport CBotTypResult(int type); // pour les types simples (CBotTypInt à CBotTypString) - DllExport + //DllExport CBotTypResult(int type, const char* name); // pour les types pointeur et classe intrinsic - DllExport + //DllExport CBotTypResult(int type, CBotClass* pClass); // idem à partir de l'instance d'une classe - DllExport + //DllExport CBotTypResult(int type, CBotTypResult elem); // pour les tableaux de variables - DllExport + //DllExport CBotTypResult(const CBotTypResult& typ); // pour les assignations - DllExport + //DllExport CBotTypResult(); // pour par défaut - DllExport + //DllExport ~CBotTypResult(); - DllExport + //DllExport int GivType(int mode = 0) const; // rend le type CBotTyp* du résultat void SetType(int n); // modifie le type - DllExport + //DllExport CBotClass* GivClass() const; // rend le pointeur à la classe (pour les CBotTypClass, CBotTypPointer) - DllExport + //DllExport int GivLimite() const; // rend la taille limite du tableau (CBotTypArray) - DllExport + //DllExport void SetLimite(int n); // fixe une limite au tableau void SetArray(int* max ); // idem avec une liste de dimension (tableaux de tableaux) - DllExport + //DllExport CBotTypResult& GivTypElem() const; // rend le type des éléments du tableau (CBotTypArray) - DllExport - BOOL Compare(const CBotTypResult& typ) const; + //DllExport + bool Compare(const CBotTypResult& typ) const; // compare si les types sont compatibles - DllExport - BOOL Eq(int type) const; + //DllExport + bool Eq(int type) const; // compare le type - DllExport + //DllExport CBotTypResult& operator=(const CBotTypResult& src); // copie un type complet dans un autre @@ -259,102 +259,102 @@ class CBotString private: char* m_ptr; // pointeur à la chaine int m_lg; // longueur de la chaine - static - HINSTANCE m_hInstance; + // static + // HINSTANCE m_hInstance; public: - DllExport + //DllExport CBotString(); - DllExport + //DllExport CBotString(const char* p); - DllExport + //DllExport CBotString(const CBotString& p); - DllExport + //DllExport ~CBotString(); - DllExport + //DllExport void Empty(); - DllExport - BOOL IsEmpty() const; - DllExport + //DllExport + bool IsEmpty() const; + //DllExport int GivLength(); - DllExport + //DllExport int Find(const char c); - DllExport - int Find(LPCTSTR lpsz); - DllExport + //DllExport + int Find(const char* lpsz); + //DllExport int ReverseFind(const char c); - DllExport - int ReverseFind(LPCTSTR lpsz); - DllExport - BOOL LoadString(UINT id); - DllExport + //DllExport + int ReverseFind(const char* lpsz); + //DllExport + bool LoadString(unsigned int id); + //DllExport CBotString Mid(int nFirst, int nCount) const; - DllExport + //DllExport CBotString Mid(int nFirst) const; - DllExport + //DllExport CBotString Left(int nCount) const; - DllExport + //DllExport CBotString Right(int nCount) const; - DllExport + //DllExport const CBotString& operator=(const CBotString& stringSrc); - DllExport + //DllExport const CBotString& operator=(const char ch); - DllExport + //DllExport const CBotString& operator=(const char* pString); - DllExport + //DllExport const CBotString& operator+(const CBotString& str); - DllExport + //DllExport friend CBotString - operator+(const CBotString& string, LPCTSTR lpsz); + operator+(const CBotString& string, const char* lpsz); - DllExport + //DllExport const CBotString& operator+=(const char ch); - DllExport + //DllExport const CBotString& operator+=(const CBotString& str); - DllExport - BOOL operator==(const CBotString& str); - DllExport - BOOL operator==(const char* p); - DllExport - BOOL operator!=(const CBotString& str); - DllExport - BOOL operator!=(const char* p); - DllExport - BOOL operator>(const CBotString& str); - DllExport - BOOL operator>(const char* p); - DllExport - BOOL operator>=(const CBotString& str); - DllExport - BOOL operator>=(const char* p); - DllExport - BOOL operator<(const CBotString& str); - DllExport - BOOL operator<(const char* p); - DllExport - BOOL operator<=(const CBotString& str); - DllExport - BOOL operator<=(const char* p); - - DllExport - operator LPCTSTR() const; // as a C string - - int Compare(LPCTSTR lpsz) const; - - DllExport + //DllExport + bool operator==(const CBotString& str); + //DllExport + bool operator==(const char* p); + //DllExport + bool operator!=(const CBotString& str); + //DllExport + bool operator!=(const char* p); + //DllExport + bool operator>(const CBotString& str); + //DllExport + bool operator>(const char* p); + //DllExport + bool operator>=(const CBotString& str); + //DllExport + bool operator>=(const char* p); + //DllExport + bool operator<(const CBotString& str); + //DllExport + bool operator<(const char* p); + //DllExport + bool operator<=(const CBotString& str); + //DllExport + bool operator<=(const char* p); + + //DllExport + operator const char*() const; // as a C string + + int Compare(const char* lpsz) const; + + //DllExport CBotString Mid(int start, int lg=-1); - DllExport + //DllExport void MakeUpper(); - DllExport + //DllExport void MakeLower(); }; @@ -369,20 +369,20 @@ private: CBotString* m_pData; // ^aux données public: - DllExport + //DllExport CBotStringArray(); - DllExport + //DllExport ~CBotStringArray(); - DllExport + //DllExport void SetSize(int nb); - DllExport + //DllExport int GivSize(); - DllExport + //DllExport void Add(const CBotString& str); - DllExport + //DllExport CBotString& operator[](int nIndex); - DllExport + //DllExport CBotString& ElementAt(int nIndex); }; @@ -418,87 +418,87 @@ private: public: static CBotString m_DebugVarStr; // a fin de debug - BOOL m_bDebugDD; // idem déclanchable par robot + bool m_bDebugDD; // idem déclanchable par robot - BOOL m_bCompileClass; + bool m_bCompileClass; public: - DllExport + //DllExport static void Init(); // initialise le module (défini les mots clefs pour les erreurs) // doit être fait une fois (et une seule) au tout début - DllExport + //DllExport static void Free(); // libère les zones mémoires statiques - DllExport + //DllExport static int GivVersion(); // donne la version de la librairie CBOT - DllExport + //DllExport CBotProgram(); - DllExport + //DllExport CBotProgram(CBotVar* pInstance); - DllExport + //DllExport ~CBotProgram(); - DllExport - BOOL Compile( const char* program, CBotStringArray& ListFonctions, void* pUser = NULL); + //DllExport + bool Compile( const char* program, CBotStringArray& ListFonctions, void* pUser = NULL); // compile le programme donné en texte - // retourne FALSE s'il y a une erreur à la compilation + // retourne false s'il y a une erreur à la compilation // voir GetCompileError() pour récupérer l'erreur // ListFonctions retourne le nom des fonctions déclarées extern // pUser permet de passer un pointeur pour les routines définies par AddFunction - DllExport + //DllExport void SetIdent(long n); // associe un identificateur avec l'instance CBotProgram - DllExport + //DllExport long GivIdent(); // redonne l'identificateur - DllExport + //DllExport int GivError(); - DllExport - BOOL GetError(int& code, int& start, int& end); - DllExport - BOOL GetError(int& code, int& start, int& end, CBotProgram* &pProg); - // si TRUE + //DllExport + bool GetError(int& code, int& start, int& end); + //DllExport + bool GetError(int& code, int& start, int& end, CBotProgram* &pProg); + // si true // donne l'erreur trouvée à la compilation // ou à l'exécution // start et end délimite le bloc où se trouve l'erreur // pProg permet de savoir dans quel "module" s'est produite l'erreur d'exécution - DllExport + //DllExport static CBotString GivErrorText(int code); - DllExport - BOOL Start(const char* name); + //DllExport + bool Start(const char* name); // définie quelle fonction doit être exécutée - // retourne FALSE si la fontion name n'est pas trouvée + // retourne false si la fontion name n'est pas trouvée // le programme ne fait rien, il faut appeller Run() pour cela - DllExport - BOOL Run(void* pUser = NULL, int timer = -1); + //DllExport + bool Run(void* pUser = NULL, int timer = -1); // exécute le programme - // retourne FALSE si le programme a été suspendu - // retourne TRUE si le programme s'est terminé avec ou sans erreur + // retourne false si le programme a été suspendu + // retourne true si le programme s'est terminé avec ou sans erreur // timer = 0 permet de faire une avance pas à pas - DllExport - BOOL GetRunPos(const char* &FunctionName, int &start, int &end); + //DllExport + bool GetRunPos(const char* &FunctionName, int &start, int &end); // donne la position dans le programme en exécution - // retourne FALSE si on n'est pas en exécution (programme terminé) + // retourne false si on n'est pas en exécution (programme terminé) // FunctionName est un pointeur rendu sur le nom de la fonction // start et end la position dans le texte du token en traitement - DllExport + //DllExport CBotVar* GivStackVars(const char* &FunctionName, int level); // permet d'obtenir le pointeur aux variables sur la pile d'exécution // level est un paramètre d'entrée, 0 pour le dernier niveau, -1, -2, etc pour les autres niveau @@ -507,41 +507,41 @@ public: // FunctionName donne le nom de la fonction où se trouvent ces variables // FunctionName == NULL signifiant qu'on est plus dans le programme (selon level) - DllExport + //DllExport void Stop(); // arrête l'exécution du programme // quitte donc le mode "suspendu" - DllExport + //DllExport static void SetTimer(int n); // défini le nombre de pas (parties d'instructions) à faire - // dans Run() avant de rendre la main "FALSE" + // dans Run() avant de rendre la main "false" - DllExport + //DllExport static - BOOL AddFunction(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)); // cet appel permet d'ajouter de manière externe (**) // une nouvelle fonction utilisable par le programme CBot - DllExport + //DllExport static - BOOL DefineNum(const char* name, long val); + bool DefineNum(const char* name, long val); - DllExport - BOOL SaveState(FILE* pf); + //DllExport + bool SaveState(FILE* pf); // sauvegarde l'état d'exécution dans le fichier // le fichier doit avoir été ouvert avec l'appel fopen de cette dll // sinon le système plante - DllExport - BOOL RestoreState(FILE* pf); + //DllExport + bool RestoreState(FILE* pf); // rétablie l'état de l'exécution depuis le fichier // le programme compilé doit évidemment être identique - DllExport - BOOL GetPosition(const char* name, int& start, int& stop, + //DllExport + bool GetPosition(const char* name, int& start, int& stop, CBotGet modestart = GetPosExtern, CBotGet modestop = GetPosBloc); // donne la position d'une routine dans le texte d'origine @@ -555,13 +555,13 @@ public: /////////////////////////////////////////////////////////////////////////////// // routines pour la gestion d'un fichier (FILE*) - DllExport + //DllExport FILE* fOpen(const char* name, const char* mode); - DllExport + //DllExport int fClose(FILE* filehandle); - DllExport + //DllExport size_t fWrite(const void *buffer, size_t elemsize, size_t length, FILE* filehandle); - DllExport + //DllExport size_t fRead(void *buffer, size_t elemsize, size_t length, FILE* filehandle); @@ -594,7 +594,7 @@ int cMoyenne(CBotVar* &pVar, CBotString& ClassName) } -BOOL rMoyenne(CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rMoyenne(CBotVar* pVar, CBotVar* pResult, int& Exception) { float total = 0; int nb = 0; @@ -606,7 +606,7 @@ BOOL rMoyenne(CBotVar* pVar, CBotVar* pResult, int& Exception) } pResult->SetValFloat(total/nb); // retourne la valeur moyenne - return TRUE; // opération totalement terminée + return true; // opération totalement terminée } #endif @@ -645,7 +645,7 @@ protected: int m_binit; // pas initialisée ? CBotVarClass* m_pMyThis; // ^élément this correspondant void* m_pUserPtr; // ^données user s'il y a lieu - BOOL m_bStatic; // élément static (dans une classe) + bool m_bStatic; // élément static (dans une classe) int m_mPrivate; // élément public, protected ou private ? CBotInstr* m_InitExpr; // expression pour le contenu initial @@ -663,17 +663,17 @@ public: virtual ~CBotVar( ); // destructeur -/* DllExport +/* //DllExport static CBotVar* Create( const char* name, int type, const char* ClassName = NULL); // crée une variable selon son type,*/ - DllExport + //DllExport static CBotVar* Create( const char* name, CBotTypResult type); // idem à partir du type complet - DllExport + //DllExport static CBotVar* Create( const char* name, CBotClass* pClass); // idem pour une instance d'une classe connue @@ -690,51 +690,51 @@ virtual ~CBotVar( ); // destructeur CBotVar* Create( CBotVar* pVar ); - DllExport + //DllExport void SetUserPtr(void* pUser); // associe un pointeur utilisateur à une instance - DllExport + //DllExport virtual void SetIdent(long UniqId); // associe un identificateur unique à une instance // ( c'est à l'utilisateur de s'assurer que l'id est unique) - DllExport + //DllExport void* GivUserPtr(); // rend le pointeur associé à la variable - DllExport + //DllExport CBotString GivName(); // le nom de la variable, s'il est connu //////////////////////////////////////////////////////////////////////////////////// void SetName(const char* name); // change le nom de la variable - DllExport + //DllExport int GivType(int mode = 0); // rend le type de base (int) de la variable //////////////////////////////////////////////////////////////////////////////////////// - DllExport + //DllExport CBotTypResult GivTypResult(int mode = 0); // rend le type complet de la variable CBotToken* GivToken(); void SetType(CBotTypResult& type); - DllExport + //DllExport void SetInit(int bInit); // met la variable dans l'état IS_UNDEF, IS_DEF, IS_NAN - DllExport + //DllExport int GivInit(); // donne l'état de la variable - DllExport - void SetStatic(BOOL bStatic); - DllExport - BOOL IsStatic(); + //DllExport + void SetStatic(bool bStatic); + //DllExport + bool IsStatic(); - DllExport + //DllExport void SetPrivate(int mPrivate); - DllExport - BOOL IsPrivate(int mode = PR_PROTECT); - DllExport + //DllExport + bool IsPrivate(int mode = PR_PROTECT); + //DllExport int GivPrivate(); virtual @@ -742,55 +742,55 @@ virtual ~CBotVar( ); // destructeur void SetVal(CBotVar* var); // remprend une valeur - DllExport + //DllExport virtual CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) virtual CBotVar* GivItemRef(int nIdent); // idem à partir du n° ref - DllExport + //DllExport virtual - CBotVar* GivItem(int row, BOOL bGrow = FALSE); + CBotVar* GivItem(int row, bool bGrow = false); - DllExport + //DllExport virtual CBotVar* GivItemList(); // donne la liste des éléments - DllExport + //DllExport CBotVar* GivStaticVar(); // rend le pointeur à la variable si elle est statique - DllExport - BOOL IsElemOfClass(const char* name); + //DllExport + bool IsElemOfClass(const char* name); // dit si l'élément appartient à la classe "name" - // rend TRUE si l'objet est d'une classe fille + // rend true si l'objet est d'une classe fille - DllExport + //DllExport CBotVar* GivNext(); // prochaine variable dans la liste (paramètres) //////////////////////////////////////////////////////////////////////////////////////////// void AddNext(CBotVar* pVar); // ajoute dans une liste virtual - void Copy(CBotVar* pSrc, BOOL bName = TRUE); // fait une copie de la variable + void Copy(CBotVar* pSrc, bool bName = true); // fait une copie de la variable - DllExport + //DllExport virtual void SetValInt(int val, const char* name = NULL); // initialise avec une valeur entière (#) ///////////////////////////////////////////////////////////////////////////////// - DllExport + //DllExport virtual void SetValFloat(float val); // initialise avec une valeur réelle (#) //////////////////////////////////////////////////////////////////////////////// - DllExport + //DllExport virtual void SetValString(const char* p);// initialise avec une valeur chaîne (#) //////////////////////////////////////////////////////////////////////////////// - DllExport + //DllExport virtual int GivValInt(); // demande la valeur entière (#) //////////////////////////////////////////////////////////////////////// - DllExport + //DllExport virtual float GivValFloat(); // demande la valeur réelle (#) /////////////////////////////////////////////////////////////////////// @@ -814,12 +814,12 @@ virtual ~CBotVar( ); // destructeur virtual int Modulo(CBotVar* left, CBotVar* right); // reste de division virtual void Power(CBotVar* left, CBotVar* right); // puissance - virtual BOOL Lo(CBotVar* left, CBotVar* right); - virtual BOOL Hi(CBotVar* left, CBotVar* right); - virtual BOOL Ls(CBotVar* left, CBotVar* right); - virtual BOOL Hs(CBotVar* left, CBotVar* right); - virtual BOOL Eq(CBotVar* left, CBotVar* right); - virtual BOOL Ne(CBotVar* left, CBotVar* right); + virtual bool Lo(CBotVar* left, CBotVar* right); + virtual bool Hi(CBotVar* left, CBotVar* right); + virtual bool Ls(CBotVar* left, CBotVar* right); + virtual bool Hs(CBotVar* left, CBotVar* right); + virtual bool Eq(CBotVar* left, CBotVar* right); + virtual bool Ne(CBotVar* left, CBotVar* right); virtual void And(CBotVar* left, CBotVar* right); virtual void Or(CBotVar* left, CBotVar* right); @@ -834,19 +834,19 @@ virtual ~CBotVar( ); // destructeur virtual void Dec(); - virtual BOOL Save0State(FILE* pf); - virtual BOOL Save1State(FILE* pf); - static BOOL RestoreState(FILE* pf, CBotVar* &pVar); + virtual bool Save0State(FILE* pf); + virtual bool Save1State(FILE* pf); + static bool RestoreState(FILE* pf, CBotVar* &pVar); - DllExport + //DllExport void debug(); // virtual // CBotVar* GivMyThis(); - DllExport + //DllExport virtual - void Maj(void* pUser = NULL, BOOL bContinue = TRUE); + void Maj(void* pUser = NULL, bool bContinue = true); void SetUniqNum(long n); long GivUniqNum(); @@ -888,7 +888,7 @@ private: CBotString m_name; // nom de cette classe-ci int m_nbVar; // nombre de variables dans la chaîne CBotVar* m_pVar; // contenu de la classe - BOOL m_bIntrinsic; // classe intrinsèque + bool m_bIntrinsic; // classe intrinsèque CBotClass* m_next; // chaine les classe CBotCallMethode* m_pCalls; // liste des méthodes définie en externe CBotFunction* m_pMethod; // liste des méthodes compilées @@ -899,37 +899,37 @@ private: CBotProgram* m_ProgInLock[5];// processus en attente pour synchro public: - BOOL m_IsDef; // marque si est définie ou pas encore + bool m_IsDef; // marque si est définie ou pas encore - DllExport + //DllExport CBotClass( const char* name, - CBotClass* pParent, BOOL bIntrinsic = FALSE ); // constructeur + CBotClass* pParent, bool bIntrinsic = false ); // constructeur // Dès qu'une classe est créée, elle est connue // partout dans CBot // le mode intrinsic donne une classe qui n'est pas gérée par des pointeurs - DllExport + //DllExport ~CBotClass( ); // destructeur - DllExport - BOOL AddFunction(const char* name, - BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + //DllExport + bool AddFunction(const char* name, + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)); // cet appel permet d'ajouter de manière externe (**) // une nouvelle méthode utilisable par les objets de cette classe - DllExport - BOOL AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ); + //DllExport + bool AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) ); // défini la routine qui sera appellée pour mettre à jour les élements de la classe - DllExport - BOOL AddItem(CBotString name, CBotTypResult type, int mPrivate = PR_PUBLIC); + //DllExport + bool AddItem(CBotString name, CBotTypResult type, int mPrivate = PR_PUBLIC); // ajoute un élément à la classe -// DllExport -// BOOL AddItem(CBotString name, CBotClass* pClass); +// //DllExport +// bool AddItem(CBotString name, CBotClass* pClass); // idem pour des éléments appartenant à pClass - DllExport - BOOL AddItem(CBotVar* pVar); + //DllExport + bool AddItem(CBotVar* pVar); // idem en passant le pointeur à une instance d'une variable // l'objet est pris tel quel, il ne faut donc pas le détruire @@ -938,20 +938,20 @@ public: // idem en donnant un élément de type CBotVar void AddNext(CBotClass* pClass); - DllExport + //DllExport CBotString GivName(); // rend le nom de la classe - DllExport + //DllExport CBotClass* GivParent(); // donne la classe père (ou NULL) // dit si une classe est dérivée (Extends) d'une autre - // rend TRUE aussi si les classes sont identiques - DllExport - BOOL IsChildOf(CBotClass* pClass); + // rend true aussi si les classes sont identiques + //DllExport + bool IsChildOf(CBotClass* pClass); static CBotClass* Find(CBotToken* &pToken); // trouve une classe d'après son nom - DllExport + //DllExport static CBotClass* Find(const char* name); @@ -962,7 +962,7 @@ public: CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams, CBotCStack* pStack, long& nIdent); - BOOL ExecuteMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken); + bool ExecuteMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotVar* &pResult, CBotStack* &pStack, CBotToken* pToken); void RestoreMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotStack* &pStack); // compile une classe déclarée par l'utilisateur @@ -971,27 +971,27 @@ public: static CBotClass* Compile1(CBotToken* &p, CBotCStack* pStack); - BOOL CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond); + bool CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond); - BOOL IsIntrinsic(); + bool IsIntrinsic(); void Purge(); static void Free(); - DllExport + //DllExport static - BOOL SaveStaticState(FILE* pf); + bool SaveStaticState(FILE* pf); - DllExport + //DllExport static - BOOL RestoreStaticState(FILE* pf); + bool RestoreStaticState(FILE* pf); - BOOL Lock(CBotProgram* p); + bool Lock(CBotProgram* p); void Unlock(); static void FreeLock(CBotProgram* p); - BOOL CheckCall(CBotToken* &pToken, CBotDefParam* pParam); + bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam); }; @@ -1041,7 +1041,7 @@ private: static int GivKeyWords(const char* w); // est-ce un mot clef ? static - BOOL GivKeyDefNum(const char* w, CBotToken* &token); + bool GivKeyDefNum(const char* w, CBotToken* &token); static void LoadKeyWords(); // fait la liste des mots clefs @@ -1054,37 +1054,37 @@ public: // constructeur ~CBotToken(); // destructeur - DllExport + //DllExport int GivType(); // rend le type du token - DllExport + //DllExport CBotString& GivString(); // rend la chaine correspondant à ce token - DllExport + //DllExport CBotString& GivSep(); // rend le séparateur suivant le token - DllExport + //DllExport int GivStart(); // position du début dans le texte - DllExport + //DllExport int GivEnd(); // position de fin dans le texte - DllExport + //DllExport CBotToken* GivNext(); // rend le suivant dans la liste - DllExport + //DllExport CBotToken* GivPrev(); // rend le Précédent dans la liste - DllExport + //DllExport static CBotToken* CompileTokens(const char* p, int& error); // transforme tout le programme - DllExport + //DllExport static void Delete(CBotToken* pToken); // libère la liste // fonctions non utiles en export static - BOOL DefineNum(const char* name, long val); + bool DefineNum(const char* name, long val); void SetString(const char* name); void SetPos(int start, int end); @@ -1092,7 +1092,7 @@ public: void AddNext(CBotToken* p); // ajoute un token (une copie) static - CBotToken* NextToken(char* &program, int& error, BOOL first = FALSE); + CBotToken* NextToken(char* &program, int& error, bool first = false); // trouve le prochain token const CBotToken& operator=(const CBotToken& src); @@ -1163,7 +1163,7 @@ public: // exécute le programme main // ------------------------- - while( FALSE = m_pMonRobot->Execute( "main", pStack )) + while( false = m_pMonRobot->Execute( "main", pStack )) { // programme suspendu // on pourrait passer la main à un autre (en sauvegardant pStack pour ce robot-là) @@ -1174,10 +1174,10 @@ public: // routine implémentant l'instruction GOTO( CPoint pos ) -BOOL rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception ) +bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception ) { if (pVar->GivType() != CBotTypeClass || - pVar->IsElemOfClas("CPoint") ) { exception = 6522; return FALSE; ) + pVar->IsElemOfClas("CPoint") ) { exception = 6522; return false; ) // le paramètre n'est pas de la bonne classe ? // NB en fait ce contrôle est déjà fait par la routine pour la compilation @@ -1193,8 +1193,8 @@ BOOL rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception ) ASSERT (temp != NULL && temp->GivType() == CBotTypFloat); m_PosToGo.y = temp->GivValFloat(); - return (m_CurentPos == m_PosToGo); // rend TRUE si la position est atteinte - // rend FALSE s'il faut patienter encore + return (m_CurentPos == m_PosToGo); // rend true si la position est atteinte + // rend false s'il faut patienter encore } -#endif \ No newline at end of file +#endif diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp index 488061c..784e647 100644 --- a/src/CBot/CBotFunction.cpp +++ b/src/CBot/CBotFunction.cpp @@ -25,14 +25,14 @@ CBotFunction::CBotFunction() m_Param = NULL; // liste des paramètres vide m_Block = NULL; // le bloc d'instructions m_next = NULL; // les fonctions peuvent être chaînées - m_bPublic = FALSE; // fonction non publique - m_bExtern = FALSE; // fonction non externe + m_bPublic = false; // fonction non publique + m_bExtern = false; // fonction non externe m_nextpublic = NULL; m_prevpublic = NULL; m_pProg = NULL; // m_nThisIdent = 0; m_nFuncIdent = 0; - m_bSynchro = FALSE; + m_bSynchro = false; } CBotFunction* CBotFunction::m_listPublic = NULL; @@ -62,17 +62,17 @@ CBotFunction::~CBotFunction() } } -BOOL CBotFunction::IsPublic() +bool CBotFunction::IsPublic() { return m_bPublic; } -BOOL CBotFunction::IsExtern() +bool CBotFunction::IsExtern() { return m_bExtern; } -BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop) +bool CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop) { start = m_extern.GivStart(); stop = m_closeblk.GivEnd(); @@ -110,7 +110,7 @@ BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet stop = m_closeblk.GivEnd(); } - return TRUE; + return true; } @@ -168,7 +168,7 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile) // compile une nouvelle fonction // bLocal permet de mettre la déclaration des paramètres au même niveau // que le éléments appartenant à la classe pour les méthodes -CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, BOOL bLocal) +CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, bool bLocal) { CBotToken* pp; CBotFunction* func = finput; @@ -178,19 +178,19 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct // func->m_nFuncIdent = CBotVar::NextUniqNum(); - while (TRUE) + while (true) { if ( IsOfType(p, ID_PUBLIC) ) { - func->m_bPublic = TRUE; + func->m_bPublic = true; continue; } pp = p; if ( IsOfType(p, ID_EXTERN) ) { func->m_extern = pp; // pour la position du mot "extern" - func->m_bExtern = TRUE; -// func->m_bPublic = TRUE; // donc aussi publique! + func->m_bExtern = true; +// func->m_bPublic = true; // donc aussi publique! continue; } break; @@ -260,7 +260,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct // et compile le bloc d'instruction qui suit func->m_openblk = p; - func->m_Block = CBotBlock::Compile(p, pStk, FALSE); + func->m_Block = CBotBlock::Compile(p, pStk, false); func->m_closeblk = p->GivPrev(); if ( pStk->IsOk() ) { @@ -286,18 +286,18 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas CBotFunction* func = new CBotFunction(); func->m_nFuncIdent = CBotVar::NextUniqNum(); - CBotCStack* pStk = pStack->TokenStack(p, TRUE); + CBotCStack* pStk = pStack->TokenStack(p, true); - while (TRUE) + while (true) { if ( IsOfType(p, ID_PUBLIC) ) { - // func->m_bPublic = TRUE; // sera fait en passe 2 + // func->m_bPublic = true; // sera fait en passe 2 continue; } if ( IsOfType(p, ID_EXTERN) ) { - func->m_bExtern = TRUE; + func->m_bExtern = true; continue; } break; @@ -367,16 +367,16 @@ bad: static int xx = 0; #endif -BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance) +bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance) { CBotStack* pile = pj->AddStack(this, 2); // un bout de pile local à cette fonction -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; pile->SetBotCall(m_pProg); // bases pour les routines if ( pile->GivState() == 0 ) { - if ( !m_Param->Execute(ppVars, pile) ) return FALSE; // défini les paramètres + if ( !m_Param->Execute(ppVars, pile) ) return false; // défini les paramètres pile->IncState(); } @@ -403,14 +403,14 @@ BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance) pile->IncState(); } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; if ( !m_Block->Execute(pile) ) { if ( pile->GivError() < 0 ) pile->SetError( 0 ); else - return FALSE; + return false; } return pj->Return(pile); @@ -433,7 +433,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst pile2->Delete(); } - m_Param->RestoreState(pile2, TRUE); // les paramètres + m_Param->RestoreState(pile2, true); // les paramètres if ( !m_MasterClass.IsEmpty() ) { @@ -442,7 +442,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst pThis->SetUniqNum(-2); } - m_Block->RestoreState(pile2, TRUE); + m_Block->RestoreState(pile2, true); } void CBotFunction::AddNext(CBotFunction* p) @@ -467,7 +467,7 @@ CBotTypResult CBotFunction::CompileCall(const char* name, CBotVar** ppVars, long // trouve une fonction selon son identificateur unique // si l'identificateur n'est pas trouvé, cherche selon le nom et les paramètres -CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, BOOL bPublic) +CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic) { TypeOrError.SetType(TX_UNDEFCALL); // pas de routine de ce nom CBotFunction* pt; @@ -632,13 +632,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS if ( pt != NULL ) { CBotStack* pStk1 = pStack->AddStack(pt, 2); // pour mettre "this" -// if ( pStk1 == EOX ) return TRUE; +// if ( pStk1 == EOX ) return true; pStk1->SetBotCall(pt->m_pProg); // on a peut-être changé de module - if ( pStk1->IfStep() ) return FALSE; + if ( pStk1->IfStep() ) return false; - CBotStack* pStk3 = pStk1->AddStack(NULL, TRUE); // paramètres + CBotStack* pStk3 = pStk1->AddStack(NULL, true); // paramètres // prépare les paramètres sur la pile @@ -680,11 +680,11 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS if ( !pStk3->IsOk() && pt->m_pProg != m_pProg ) { #ifdef _DEBUG - if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return FALSE; + if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return false; #endif pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure } - return FALSE; // interrompu ! + return false; // interrompu ! } return pStack->Return( pStk3 ); @@ -738,13 +738,13 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, if ( pStk1->GivState() == 0 ) { - pt->m_Param->RestoreState(pStk3, TRUE); + pt->m_Param->RestoreState(pStk3, true); return; } // initialise les variables selon paramètres - pt->m_Param->RestoreState(pStk3, FALSE); - pt->m_Block->RestoreState(pStk3, TRUE); + pt->m_Param->RestoreState(pStk3, false); + pt->m_Block->RestoreState(pStk3, true); } } @@ -758,17 +758,17 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar CBotTypResult type; CBotProgram* pProgCurrent = pStack->GivBotCall(); - CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, FALSE); + CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false); if ( pt != NULL ) { // DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack); CBotStack* pStk = pStack->AddStack(pt, 2); -// if ( pStk == EOX ) return TRUE; +// if ( pStk == EOX ) return true; pStk->SetBotCall(pt->m_pProg); // on a peut-être changé de module - CBotStack* pStk3 = pStk->AddStack(NULL, TRUE); // pour mettre les paramètres passés + CBotStack* pStk3 = pStk->AddStack(NULL, true); // pour mettre les paramètres passés // prépare les paramètres sur la pile @@ -776,7 +776,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar { // met la variable "this" sur la pile CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer); - pthis->Copy(pThis, FALSE); + pthis->Copy(pThis, false); pthis->SetUniqNum(-2); // valeur spéciale pStk->AddVar(pthis); @@ -785,7 +785,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar { // met la variable "super" sur la pile CBotVar* psuper = CBotVar::Create("super", CBotTypNullPointer); - psuper->Copy(pThis, FALSE); // en fait identique à "this" + psuper->Copy(pThis, false); // en fait identique à "this" psuper->SetUniqNum(-3); // valeur spéciale pStk->AddVar(psuper); } @@ -798,8 +798,8 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar { if ( pt->m_bSynchro ) { - CBotProgram* pProgBase = pStk->GivBotCall(TRUE); - if ( !pClass->Lock(pProgBase) ) return FALSE; // attend de pouvoir + CBotProgram* pProgBase = pStk->GivBotCall(true); + if ( !pClass->Lock(pProgBase) ) return false; // attend de pouvoir } pStk->IncState(); } @@ -820,7 +820,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure } } - return FALSE; // interrompu ! + return false; // interrompu ! } if ( pt->m_bSynchro ) @@ -850,30 +850,30 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, C CBotStack* pStk3 = pStk->RestoreStack(NULL); // pour mettre les paramètres passés if ( pStk3 == NULL ) return; - pt->m_Param->RestoreState(pStk3, TRUE); // les paramètres + pt->m_Param->RestoreState(pStk3, true); // les paramètres if ( pStk->GivState() > 1 && // vérouillage est effectif ? pt->m_bSynchro ) { - CBotProgram* pProgBase = pStk->GivBotCall(TRUE); + CBotProgram* pProgBase = pStk->GivBotCall(true); pClass->Lock(pProgBase); // vérouille la classe } // finalement appelle la fonction trouvée - pt->m_Block->RestoreState(pStk3, TRUE); // interrompu ! + pt->m_Block->RestoreState(pStk3, true); // interrompu ! } } // regarde si la "signature" des paramètres est identique -BOOL CBotFunction::CheckParam(CBotDefParam* pParam) +bool CBotFunction::CheckParam(CBotDefParam* pParam) { CBotDefParam* pp = m_Param; while ( pp != NULL && pParam != NULL ) { CBotTypResult type1 = pp->GivType(); CBotTypResult type2 = pParam->GivType(); - if ( !type1.Compare(type2) ) return FALSE; + if ( !type1.Compare(type2) ) return false; pp = pp->GivNext(); pParam = pParam->GivNext(); } @@ -1005,7 +1005,7 @@ void CBotDefParam::AddNext(CBotDefParam* p) } -BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) +bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) { int i = 0; CBotDefParam* p = this; @@ -1033,7 +1033,7 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) newvar->SetValInt(ppVars[i]->GivValInt()); break; case CBotTypIntrinsic: - ((CBotVarClass*)newvar)->Copy(ppVars[i], FALSE); + ((CBotVarClass*)newvar)->Copy(ppVars[i], false); break; case CBotTypPointer: case CBotTypArrayPointer: @@ -1051,10 +1051,10 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) i++; } - return TRUE; + return true; } -void CBotDefParam::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain) { int i = 0; CBotDefParam* p = this; @@ -1146,25 +1146,25 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack) return NULL; // pas d'objet, l'erreur est sur la pile } -BOOL CBotReturn::Execute(CBotStack* &pj) +bool CBotReturn::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState() == 0 ) { - if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return FALSE; // évalue le résultat + if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return false; // évalue le résultat // le résultat est sur la pile pile->IncState(); } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; pile->SetBreak(3, CBotString()); return pj->Return(pile); } -void CBotReturn::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotReturn::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; CBotStack* pile = pj->RestoreStack(this); @@ -1211,7 +1211,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack) inst->SetToken(pp); // compile la liste des paramètres - if (!IsOfType(p, ID_CLOSEPAR)) while (TRUE) + if (!IsOfType(p, ID_CLOSEPAR)) while (true) { start = p->GivStart(); pile = pile->TokenStack(); // garde les résultats sur la pile @@ -1278,7 +1278,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack) return NULL; } -BOOL CBotInstrCall::Execute(CBotStack* &pj) +bool CBotInstrCall::Execute(CBotStack* &pj) { CBotVar* ppVars[1000]; CBotStack* pile = pj->AddStack(this); @@ -1292,12 +1292,12 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj) // évalue les paramètres // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile = pile->AddStack(); // de la place sur la pile pour les résultats if ( pile->GivState() == 0 ) { - if (!p->Execute(pile)) return FALSE; // interrompu ici ? + if (!p->Execute(pile)) return false; // interrompu ici ? pile->SetState(1); // marque spéciale pour reconnaîre les paramètres } ppVars[i++] = pile->GivVar(); @@ -1307,14 +1307,14 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj) ppVars[i] = NULL; CBotStack* pile2 = pile->AddStack(); - if ( pile2->IfStep() ) return FALSE; + if ( pile2->IfStep() ) return false; - if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return FALSE; // interrompu + if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return false; // interrompu return pj->Return(pile2); // libère toute la pile } -void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -1329,7 +1329,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain) // évalue les paramètres // et place les valeurs sur la pile // pour pouvoir être interrompu n'importe quand - if ( p != NULL) while ( TRUE ) + if ( p != NULL) while ( true ) { pile = pile->RestoreStack(); // de la place sur la pile pour les résultats if ( pile == NULL ) return; @@ -1394,7 +1394,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) #endif CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld; classe->Purge(); // vide les anciennes définitions - classe->m_IsDef = FALSE; // définition en cours + classe->m_IsDef = false; // définition en cours if ( !IsOfType( p, ID_OPBLK) ) { @@ -1404,7 +1404,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) { - classe->CompileDefItem(p, pStack, FALSE); + classe->CompileDefItem(p, pStack, false); } if (pStack->IsOk()) return classe; @@ -1413,24 +1413,24 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack) return NULL; } -BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) +bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond) { - BOOL bStatic = FALSE; + bool bStatic = false; int mProtect = PR_PUBLIC; - BOOL bSynchro = FALSE; + bool bSynchro = false; while (IsOfType(p, ID_SEP)) ; CBotTypResult type( -1 ); - if ( IsOfType(p, ID_SYNCHO) ) bSynchro = TRUE; + if ( IsOfType(p, ID_SYNCHO) ) bSynchro = true; CBotToken* pBase = p; - if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE; + if ( IsOfType(p, ID_STATIC) ) bStatic = true; if ( IsOfType(p, ID_PUBLIC) ) mProtect = PR_PUBLIC; if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE; if ( IsOfType(p, ID_PROTECTED) ) mProtect = PR_PROTECT; - if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE; + if ( IsOfType(p, ID_STATIC) ) bStatic = true; // CBotClass* pClass = NULL; type = TypeParam(p, pStack); // type du résultat @@ -1438,7 +1438,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) if ( type.Eq(-1) ) { pStack->SetError(TX_NOTYP, p); - return FALSE; + return false; } while (pStack->IsOk()) @@ -1463,14 +1463,14 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) ) { pStack->SetError(TX_CLBRK, p->GivStart()); - return FALSE; + return false; } /* CBotVar* pv = pStack->GivVar(); if ( pv->GivType()>= CBotTypBoolean ) { pStack->SetError(TX_BADTYPE, p->GivStart()); - return FALSE; + return false; }*/ if (limites == NULL) limites = i; @@ -1485,7 +1485,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) CBotFunction* f = CBotFunction::Compile1(p, pStack, this); - if ( f == NULL ) return FALSE; + if ( f == NULL ) return false; if (m_pMethod == NULL) m_pMethod = f; else m_pMethod->AddNext(f); @@ -1502,8 +1502,8 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) pf = pf->Next(); } - BOOL bConstructor = (pp->GivString() == GivName()); - CBotCStack* pile = pStack->TokenStack(NULL, TRUE); + bool bConstructor = (pp->GivString() == GivName()); + CBotCStack* pile = pStack->TokenStack(NULL, true); // rend "this" connu CBotToken TokenThis(CBotString("this"), CBotString()); @@ -1540,7 +1540,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) // compile une méthode p = pBase; CBotFunction* f = - CBotFunction::Compile(p, pile, NULL/*, FALSE*/); + CBotFunction::Compile(p, pile, NULL/*, false*/); if ( f != NULL ) { @@ -1563,7 +1563,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) if (type.Eq(0)) { pStack->SetError(TX_ENDOF, p); - return FALSE; + return false; } CBotInstr* i = NULL; @@ -1578,7 +1578,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond) // il y a une assignation à calculer i = CBotTwoOpExpr::Compile(p, pStack); } - if ( !pStack->IsOk() ) return FALSE; + if ( !pStack->IsOk() ) return false; } @@ -1637,10 +1637,10 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack) while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) { - pOld->CompileDefItem(p, pStack, TRUE); + pOld->CompileDefItem(p, pStack, true); } - pOld->m_IsDef = TRUE; // définition terminée + pOld->m_IsDef = true; // définition terminée if (pStack->IsOk()) return pOld; } pStack->SetError(TX_ENDOF, p); diff --git a/src/CBot/CBotIf.cpp b/src/CBot/CBotIf.cpp index 626ef0d..178992e 100644 --- a/src/CBot/CBotIf.cpp +++ b/src/CBot/CBotIf.cpp @@ -51,7 +51,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack) { // la condition existe bel et bien - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); if ( pStk->IsOk() ) { // le bloc d'instruction est ok (peut être vide) @@ -60,7 +60,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack) if (IsOfType(p, ID_ELSE)) { // si oui, compile le bloc d'instruction qui suit - inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, true ); if (!pStk->IsOk()) { // il n'y a pas de bloc correct après le else @@ -84,19 +84,19 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack) // exécution de l'instruction -BOOL CBotIf :: Execute(CBotStack* &pj) +bool CBotIf :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; // selon la reprise, on peut être dans l'un des 2 états if( pile->GivState() == 0 ) { // évalue la condition - if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? + if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ? // termine s'il y a une erreur if ( !pile->IsOk() ) @@ -105,21 +105,21 @@ BOOL CBotIf :: Execute(CBotStack* &pj) } // passe dans le second état - if (!pile->SetState(1)) return FALSE; // prêt pour la suite + if (!pile->SetState(1)) return false; // prêt pour la suite } // second état, évalue les instructions associées // le résultat de la condition est sur la pile - if ( pile->GivVal() == TRUE ) // condition était vraie ? + if ( pile->GivVal() == true ) // condition était vraie ? { if ( m_Block != NULL && // bloc peut être absent - !m_Block->Execute(pile) ) return FALSE; // interrompu ici ? + !m_Block->Execute(pile) ) return false; // interrompu ici ? } else { if ( m_BlockElse != NULL && // s'il existe un bloc alternatif - !m_BlockElse->Execute(pile) ) return FALSE; // interrompu ici + !m_BlockElse->Execute(pile) ) return false; // interrompu ici } // transmet le résultat et libère la pile @@ -127,7 +127,7 @@ BOOL CBotIf :: Execute(CBotStack* &pj) } -void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotIf :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -145,7 +145,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain) // second état, évalue les instructions associées // le résultat de la condition est sur la pile - if ( pile->GivVal() == TRUE ) // condition était vraie ? + if ( pile->GivVal() == true ) // condition était vraie ? { if ( m_Block != NULL ) // bloc peut être absent m_Block->RestoreState(pile, bMain); // interrompu ici ! diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp index f157c4c..bbdc350 100644 --- a/src/CBot/CBotProgram.cpp +++ b/src/CBot/CBotProgram.cpp @@ -62,7 +62,7 @@ CBotProgram::~CBotProgram() } -BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser ) +bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser ) { int error = 0; Stop(); @@ -81,7 +81,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, // transforme le programme en Tokens CBotToken* pBaseToken = CBotToken::CompileTokens(program, error); - if ( pBaseToken == NULL ) return FALSE; + if ( pBaseToken == NULL ) return false; CBotCStack* pStack = new CBotCStack(NULL); @@ -115,7 +115,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, delete m_Prog; m_Prog = NULL; delete pBaseToken; - return FALSE; + return false; } // CBotFunction* temp = NULL; @@ -130,12 +130,12 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, if ( p->GivType() == ID_CLASS || ( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS )) { - m_bCompileClass = TRUE; + m_bCompileClass = true; CBotClass::Compile(p, pStack); // complète la définition de la classe } else { - m_bCompileClass = FALSE; + m_bCompileClass = false; CBotFunction::Compile(p, pStack, next); if (next->IsExtern()) ListFonctions.Add(next->GivName()/* + next->GivParams()*/); next->m_pProg = this; // garde le pointeur au module @@ -160,7 +160,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, } -BOOL CBotProgram::Start(const char* name) +bool CBotProgram::Start(const char* name) { #if STACKMEM m_pStack->Delete(); @@ -179,7 +179,7 @@ BOOL CBotProgram::Start(const char* name) if ( m_pRun == NULL ) { m_ErrorCode = TX_NORUN; - return FALSE; + return false; } #if STACKMEM @@ -190,10 +190,10 @@ BOOL CBotProgram::Start(const char* name) m_pStack->SetBotCall(this); // bases pour les routines - return TRUE; // on est prêt pour un Run() + return true; // on est prêt pour un Run() } -BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop) +bool CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop) { CBotFunction* p = m_Prog; while (p != NULL) @@ -202,15 +202,15 @@ BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet m p = p->m_next; } - if ( p == NULL ) return FALSE; + if ( p == NULL ) return false; p->GetPosition(start, stop, modestart, modestop); - return TRUE; + return true; } -BOOL CBotProgram::Run(void* pUser, int timer) +bool CBotProgram::Run(void* pUser, int timer) { - BOOL ok; + bool ok; if (m_pStack == NULL || m_pRun == NULL) goto error; @@ -253,7 +253,7 @@ BOOL CBotProgram::Run(void* pUser, int timer) delete m_pStack; #endif m_pStack = NULL; - return TRUE; // exécution terminée !! + return true; // exécution terminée !! } if ( ok ) m_pRun = NULL; // plus de fonction en exécution @@ -261,7 +261,7 @@ BOOL CBotProgram::Run(void* pUser, int timer) error: m_ErrorCode = TX_NORUN; - return TRUE; + return true; } void CBotProgram::Stop() @@ -277,14 +277,14 @@ void CBotProgram::Stop() -BOOL CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end) +bool CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end) { FunctionName = NULL; start = end = 0; - if (m_pStack == NULL) return FALSE; + if (m_pStack == NULL) return false; m_pStack->GetRunPos(FunctionName, start, end); - return TRUE; + return true; } CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level) @@ -321,7 +321,7 @@ long CBotProgram::GivIdent() return m_Ident; } -BOOL CBotProgram::GetError(int& code, int& start, int& end) +bool CBotProgram::GetError(int& code, int& start, int& end) { code = m_ErrorCode; start = m_ErrorStart; @@ -329,7 +329,7 @@ BOOL CBotProgram::GetError(int& code, int& start, int& end) return code > 0; } -BOOL CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg) +bool CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg) { code = m_ErrorCode; start = m_ErrorStart; @@ -358,8 +358,8 @@ CBotFunction* CBotProgram::GivFunctions() return m_Prog; } -BOOL CBotProgram::AddFunction(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), +bool CBotProgram::AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { // mémorise les pointeurs aux deux fonctions @@ -367,25 +367,25 @@ BOOL CBotProgram::AddFunction(const char* name, } -BOOL WriteWord(FILE* pf, WORD w) +bool WriteWord(FILE* pf, unsigned short w) { size_t lg; - lg = fwrite(&w, sizeof( WORD ), 1, pf ); + lg = fwrite(&w, sizeof( unsigned short ), 1, pf ); return (lg == 1); } -BOOL ReadWord(FILE* pf, WORD& w) +bool ReadWord(FILE* pf, unsigned short& w) { size_t lg; - lg = fread(&w, sizeof( WORD ), 1, pf ); + lg = fread(&w, sizeof( unsigned short ), 1, pf ); return (lg == 1); } -BOOL WriteFloat(FILE* pf, float w) +bool WriteFloat(FILE* pf, float w) { size_t lg; @@ -394,7 +394,7 @@ BOOL WriteFloat(FILE* pf, float w) return (lg == 1); } -BOOL ReadFloat(FILE* pf, float& w) +bool ReadFloat(FILE* pf, float& w) { size_t lg; @@ -403,7 +403,7 @@ BOOL ReadFloat(FILE* pf, float& w) return (lg == 1); } -BOOL WriteLong(FILE* pf, long w) +bool WriteLong(FILE* pf, long w) { size_t lg; @@ -412,7 +412,7 @@ BOOL WriteLong(FILE* pf, long w) return (lg == 1); } -BOOL ReadLong(FILE* pf, long& w) +bool ReadLong(FILE* pf, long& w) { size_t lg; @@ -421,24 +421,24 @@ BOOL ReadLong(FILE* pf, long& w) return (lg == 1); } -BOOL WriteString(FILE* pf, CBotString s) +bool WriteString(FILE* pf, CBotString s) { size_t lg1, lg2; lg1 = s.GivLength(); - if (!WriteWord(pf, lg1)) return FALSE; + if (!WriteWord(pf, lg1)) return false; lg2 = fwrite(s, 1, lg1, pf ); return (lg1 == lg2); } -BOOL ReadString(FILE* pf, CBotString& s) +bool ReadString(FILE* pf, CBotString& s) { - WORD w; + unsigned short w; char buf[1000]; size_t lg1, lg2; - if (!ReadWord(pf, w)) return FALSE; + if (!ReadWord(pf, w)) return false; lg1 = w; lg2 = fread(buf, 1, lg1, pf ); buf[lg2] = 0; @@ -447,29 +447,29 @@ BOOL ReadString(FILE* pf, CBotString& s) return (lg1 == lg2); } -BOOL WriteType(FILE* pf, CBotTypResult type) +bool WriteType(FILE* pf, CBotTypResult type) { int typ = type.GivType(); if ( typ == CBotTypIntrinsic ) typ = CBotTypClass; - if ( !WriteWord(pf, typ) ) return FALSE; + if ( !WriteWord(pf, typ) ) return false; if ( typ == CBotTypClass ) { CBotClass* p = type.GivClass(); - if ( !WriteString(pf, p->GivName()) ) return FALSE; + if ( !WriteString(pf, p->GivName()) ) return false; } if ( type.Eq( CBotTypArrayBody ) || type.Eq( CBotTypArrayPointer ) ) { - if ( !WriteWord(pf, type.GivLimite()) ) return FALSE; - if ( !WriteType(pf, type.GivTypElem()) ) return FALSE; + if ( !WriteWord(pf, type.GivLimite()) ) return false; + if ( !WriteType(pf, type.GivTypElem()) ) return false; } - return TRUE; + return true; } -BOOL ReadType(FILE* pf, CBotTypResult& type) +bool ReadType(FILE* pf, CBotTypResult& type) { - WORD w, ww; - if ( !ReadWord(pf, w) ) return FALSE; + unsigned short w, ww; + if ( !ReadWord(pf, w) ) return false; type.SetType(w); if ( type.Eq( CBotTypIntrinsic ) ) @@ -480,7 +480,7 @@ BOOL ReadType(FILE* pf, CBotTypResult& type) if ( type.Eq( CBotTypClass ) ) { CBotString s; - if ( !ReadString(pf, s) ) return FALSE; + if ( !ReadString(pf, s) ) return false; type = CBotTypResult( w, s ); } @@ -488,54 +488,54 @@ BOOL ReadType(FILE* pf, CBotTypResult& type) type.Eq( CBotTypArrayBody ) ) { CBotTypResult r; - if ( !ReadWord(pf, ww) ) return FALSE; - if ( !ReadType(pf, r) ) return FALSE; + if ( !ReadWord(pf, ww) ) return false; + if ( !ReadType(pf, r) ) return false; type = CBotTypResult( w, r ); type.SetLimite((short)ww); } - return TRUE; + return true; } -BOOL CBotProgram::DefineNum(const char* name, long val) +bool CBotProgram::DefineNum(const char* name, long val) { return CBotToken::DefineNum(name, val); } -BOOL CBotProgram::SaveState(FILE* pf) +bool CBotProgram::SaveState(FILE* pf) { - if (!WriteWord( pf, CBOTVERSION)) return FALSE; + if (!WriteWord( pf, CBOTVERSION)) return false; if ( m_pStack != NULL ) { - if (!WriteWord( pf, 1)) return FALSE; - if (!WriteString( pf, m_pRun->GivName() )) return FALSE; - if (!m_pStack->SaveState(pf)) return FALSE; + if (!WriteWord( pf, 1)) return false; + if (!WriteString( pf, m_pRun->GivName() )) return false; + if (!m_pStack->SaveState(pf)) return false; } else { - if (!WriteWord( pf, 0)) return FALSE; + if (!WriteWord( pf, 0)) return false; } - return TRUE; + return true; } -BOOL CBotProgram::RestoreState(FILE* pf) +bool CBotProgram::RestoreState(FILE* pf) { - WORD w; - CBotString s; + unsigned short w; + CBotString s; Stop(); - if (!ReadWord( pf, w )) return FALSE; - if ( w != CBOTVERSION ) return FALSE; + if (!ReadWord( pf, w )) return false; + if ( w != CBOTVERSION ) return false; - if (!ReadWord( pf, w )) return FALSE; - if ( w == 0 ) return TRUE; + if (!ReadWord( pf, w )) return false; + if ( w == 0 ) return true; - if (!ReadString( pf, s )) return FALSE; + if (!ReadString( pf, s )) return false; Start(s); // point de reprise #if STACKMEM @@ -547,12 +547,12 @@ BOOL CBotProgram::RestoreState(FILE* pf) // récupère la pile depuis l'enregistrement // utilise un pointeur NULL (m_pStack) mais c'est ok comme ça - if (!m_pStack->RestoreState(pf, m_pStack)) return FALSE; + if (!m_pStack->RestoreState(pf, m_pStack)) return false; m_pStack->SetBotCall(this); // bases pour les routines // rétabli certains états dans la pile selon la structure m_pRun->RestoreState(NULL, m_pStack, m_pInstance); - return TRUE; + return true; } int CBotProgram::GivVersion() @@ -566,7 +566,7 @@ int CBotProgram::GivVersion() CBotCall* CBotCall::m_ListCalls = NULL; CBotCall::CBotCall(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { m_name = name; @@ -587,8 +587,8 @@ void CBotCall::Free() delete CBotCall::m_ListCalls; } -BOOL CBotCall::AddFunction(const char* name, - BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), +bool CBotCall::AddFunction(const char* name, + bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser), CBotTypResult rCompile (CBotVar* &pVar, void* pUser)) { CBotCall* p = m_ListCalls; @@ -616,18 +616,18 @@ BOOL CBotCall::AddFunction(const char* name, if (p) p->m_next = pp; else m_ListCalls = pp; - return TRUE; + return true; } // transforme le tableau de pointeurs aux variables // en une liste de variables chaînées -CBotVar* MakeListVars(CBotVar** ppVars, BOOL bSetVal=FALSE) +CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false) { int i = 0; CBotVar* pVar = NULL; - while( TRUE ) + while( true ) { ppVars[i]; if ( ppVars[i] == NULL ) break; @@ -686,16 +686,16 @@ void CBotCall::SetPUser(void* pUser) m_pUser = pUser; } -int CBotCall::CheckCall(const char* name) +bool CBotCall::CheckCall(const char* name) { CBotCall* p = m_ListCalls; while ( p != NULL ) { - if ( name == p->GivName() ) return TRUE; + if ( name == p->GivName() ) return true; p = p->m_next; } - return FALSE; + return false; } @@ -746,7 +746,7 @@ fund: #if !STACKRUN // fait la liste des paramètres selon le contenu de la pile (pStackVar) - CBotVar* pVar = MakeListVars(ppVar, TRUE); + CBotVar* pVar = MakeListVars(ppVar, true); CBotVar* pVarToDelete = pVar; // crée une variable pour le résultat @@ -759,14 +759,14 @@ fund: if ( pResult != pRes ) delete pRes; // si résultat différent rendu delete pVarToDelete; - if (res == FALSE) + if (res == false) { if (Exception!=0) { pStack->SetError(Exception, token); } delete pResult; - return FALSE; + return false; } pStack->SetVar(pResult); @@ -775,16 +775,16 @@ fund: pStack->SetError(TX_NORETVAL, token); } nIdent = pt->m_nFuncIdent; - return TRUE; + return true; #else CBotStack* pile = pStack->AddStackEOX(pt); - if ( pile == EOX ) return TRUE; + if ( pile == EOX ) return true; // fait la liste des paramètres selon le contenu de la pile (pStackVar) - CBotVar* pVar = MakeListVars(ppVar, TRUE); + CBotVar* pVar = MakeListVars(ppVar, true); CBotVar* pVarToDelete = pVar; // crée une variable pour le résultat @@ -804,7 +804,7 @@ fund: #if STACKRUN -BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack) +bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack) { CBotCall* pt = m_ListCalls; @@ -817,22 +817,22 @@ BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot nIdent = pt->m_nFuncIdent; CBotStack* pile = pStack->RestoreStackEOX(pt); - if ( pile == NULL ) return TRUE; + if ( pile == NULL ) return true; CBotStack* pile2 = pile->RestoreStack(); - return TRUE; + return true; } pt = pt->m_next; } } - return FALSE; + return false; } -BOOL CBotCall::Run(CBotStack* pStack) +bool CBotCall::Run(CBotStack* pStack) { CBotStack* pile = pStack->AddStackEOX(this); - if ( pile == EOX ) return TRUE; + if ( pile == EOX ) return true; CBotVar* pVar = pile->GivVar(); CBotStack* pile2 = pile->AddStack(); @@ -842,20 +842,20 @@ BOOL CBotCall::Run(CBotStack* pStack) int Exception = 0; int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser()); - if (res == FALSE) + if (res == false) { if (Exception!=0) { pStack->SetError(Exception); } if ( pResult != pRes ) delete pResult; // si résultat différent rendu - return FALSE; + return false; } if ( pResult != NULL ) pStack->SetCopyVar( pResult ); if ( pResult != pRes ) delete pResult; // si résultat différent rendu - return TRUE; + return true; } #endif @@ -863,7 +863,7 @@ BOOL CBotCall::Run(CBotStack* pStack) /////////////////////////////////////////////////////////////////////////////////////// CBotCallMethode::CBotCallMethode(const char* name, - BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), + bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception), CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar)) { m_name = name; @@ -893,7 +893,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis, { if ( pt->m_name == name ) { - CBotVar* pVar = MakeListVars(ppVar, TRUE); + CBotVar* pVar = MakeListVars(ppVar, true); CBotVar* pVar2 = pVar; CBotTypResult r = pt->m_rComp(pThis, pVar2); int ret = r.GivType(); @@ -942,7 +942,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot { // fait la liste des paramètres selon le contenu de la pile (pStackVar) - CBotVar* pVar = MakeListVars(ppVars, TRUE); + CBotVar* pVar = MakeListVars(ppVars, true); CBotVar* pVarToDelete = pVar; // puis appelle la routine externe au module @@ -951,7 +951,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot int res = pt->m_rExec(pThis, pVar, pResult, Exception); pStack->SetVar(pResult); - if (res == FALSE) + if (res == false) { if (Exception!=0) { @@ -959,10 +959,10 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot pStack->SetError(Exception, pToken); } delete pVarToDelete; - return FALSE; + return false; } delete pVarToDelete; - return TRUE; + return true; } pt = pt->m_next; } @@ -975,14 +975,14 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot { // fait la liste des paramètres selon le contenu de la pile (pStackVar) - CBotVar* pVar = MakeListVars(ppVars, TRUE); + CBotVar* pVar = MakeListVars(ppVars, true); CBotVar* pVarToDelete = pVar; int Exception = 0; int res = pt->m_rExec(pThis, pVar, pResult, Exception); pStack->SetVar(pResult); - if (res == FALSE) + if (res == false) { if (Exception!=0) { @@ -990,11 +990,11 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot pStack->SetError(Exception, pToken); } delete pVarToDelete; - return FALSE; + return false; } delete pVarToDelete; nIdent = pt->m_nFuncIdent; - return TRUE; + return true; } pt = pt->m_next; } @@ -1002,7 +1002,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot return -1; } -BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { if ( pVar == NULL ) return TX_LOWPARAM; @@ -1016,7 +1016,7 @@ BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) } pResult->SetValInt(i); - return TRUE; + return true; } CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser ) @@ -1030,11 +1030,11 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser ) CBotString CBotProgram::m_DebugVarStr = ""; -BOOL rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { pResult->SetValString( CBotProgram::m_DebugVarStr ); - return TRUE; + return true; } CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser ) @@ -1103,7 +1103,8 @@ void CBotProgram::Init() // une fonction juste pour les debug divers CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug); - DeleteFile("CbotDebug.txt"); + //TODO implement this deletion + // DeleteFile("CbotDebug.txt"); } diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index b5aaba0..77ed7d7 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -16,6 +16,8 @@ // gestion de la pile (stack) #include "CBot.h" +#include +#include #define ITIMER 100 @@ -24,14 +26,14 @@ // gestion de la pile d'exécution //////////////////////////////////////////////////////////////////////////// -int CBotStack::m_initimer = ITIMER; // init la variable statique -int CBotStack::m_timer = 0; // init la variable statique -CBotVar* CBotStack::m_retvar = NULL; // init la variable statique -int CBotStack::m_error = 0; // init la variable statique -int CBotStack::m_start = 0; // init la variable statique -int CBotStack::m_end = 0; // init la variable statique -CBotString CBotStack::m_labelBreak=""; // init la variable statique -void* CBotStack::m_pUser = NULL; +int CBotStack::m_initimer = ITIMER; +int CBotStack::m_timer = 0; +CBotVar* CBotStack::m_retvar = NULL; +int CBotStack::m_error = 0; +int CBotStack::m_start = 0; +int CBotStack::m_end = 0; +CBotString CBotStack::m_labelBreak=""; +void* CBotStack::m_pUser = NULL; #if STACKMEM @@ -48,7 +50,7 @@ CBotStack* CBotStack::FirstStack() // la vide totalement memset(p, 0, size); - p-> m_bBlock = TRUE; + p-> m_bBlock = true; m_timer = m_initimer; // met le timer au début CBotStack* pp = p; @@ -56,7 +58,7 @@ CBotStack* CBotStack::FirstStack() int i; for ( i = 0 ; i< 10 ; i++ ) { - pp->m_bOver = TRUE; + pp->m_bOver = true; pp ++; } #ifdef _DEBUG @@ -75,8 +77,8 @@ CBotStack* CBotStack::FirstStack() CBotStack::CBotStack(CBotStack* ppapa) { - // constructeur doit exister, sinon le destructeur n'est jamais appelé ! - ASM_TRAP(); + // constructor must exist or the destructor is never called! + ASM_TRAP(); } CBotStack::~CBotStack() @@ -104,7 +106,7 @@ void CBotStack::Delete() delete m_listVar; CBotStack* p = m_prev; - BOOL bOver = m_bOver; + bool bOver = m_bOver; #ifdef _DEBUG int n = m_index; #endif @@ -122,7 +124,7 @@ void CBotStack::Delete() // routine optimisée -CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) +CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { if (m_next != NULL) { @@ -150,11 +152,11 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) p->m_prev = this; p->m_state = 0; p->m_call = NULL; - p->m_bFunc = FALSE; + p->m_bFunc = false; return p; } -CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) +CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { if (m_next != NULL) { @@ -171,7 +173,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) return p; } -CBotStack* CBotStack::AddStack2(BOOL bBlock) +CBotStack* CBotStack::AddStack2(bool bBlock) { if (m_next2 != NULL) { @@ -194,14 +196,14 @@ CBotStack* CBotStack::AddStack2(BOOL bBlock) return p; } -BOOL CBotStack::GivBlock() +bool CBotStack::GivBlock() { return m_bBlock; } -BOOL CBotStack::Return(CBotStack* pfils) +bool CBotStack::Return(CBotStack* pfils) { - if ( pfils == this ) return TRUE; // spécial + if ( pfils == this ) return true; // spécial if (m_var != NULL) delete m_var; // valeur remplacée ? m_var = pfils->m_var; // résultat transmis @@ -213,9 +215,9 @@ BOOL CBotStack::Return(CBotStack* pfils) return (m_error == 0); // interrompu si erreur } -BOOL CBotStack::ReturnKeep(CBotStack* pfils) +bool CBotStack::ReturnKeep(CBotStack* pfils) { - if ( pfils == this ) return TRUE; // spécial + if ( pfils == this ) return true; // spécial if (m_var != NULL) delete m_var; // valeur remplacée ? m_var = pfils->m_var; // résultat transmis @@ -224,11 +226,11 @@ BOOL CBotStack::ReturnKeep(CBotStack* pfils) return (m_error == 0); // interrompu si erreur } -BOOL CBotStack::StackOver() +bool CBotStack::StackOver() { - if (!m_bOver) return FALSE; + if (!m_bOver) return false; m_error = TX_STACKOVER; - return TRUE; + return true; } #else @@ -239,7 +241,7 @@ CBotStack::CBotStack(CBotStack* ppapa) m_next2 = NULL; m_prev = ppapa; - m_bBlock = (ppapa == NULL) ? TRUE : FALSE; + m_bBlock = (ppapa == NULL) ? true : false; m_state = 0; m_step = 1; @@ -247,13 +249,13 @@ CBotStack::CBotStack(CBotStack* ppapa) if (ppapa == NULL) m_timer = m_initimer; // met le timer au début m_listVar = NULL; - m_bDontDelete = FALSE; + m_bDontDelete = false; m_var = NULL; m_prog = NULL; m_instr = NULL; m_call = NULL; - m_bFunc = FALSE; + m_bFunc = false; } // destructeur @@ -269,7 +271,7 @@ CBotStack::~CBotStack() } // routine à optimiser -CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) +CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock) { if (m_next != NULL) { @@ -284,7 +286,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) return p; } -CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) +CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock) { if (m_next != NULL) { @@ -305,7 +307,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) return p; } -CBotStack* CBotStack::AddStack2(BOOL bBlock) +CBotStack* CBotStack::AddStack2(bool bBlock) { if (m_next2 != NULL) { @@ -322,9 +324,9 @@ CBotStack* CBotStack::AddStack2(BOOL bBlock) return p; } -BOOL CBotStack::Return(CBotStack* pfils) +bool CBotStack::Return(CBotStack* pfils) { - if ( pfils == this ) return TRUE; // spécial + if ( pfils == this ) return true; // spécial if (m_var != NULL) delete m_var; // valeur remplacée ? m_var = pfils->m_var; // résultat transmis @@ -336,9 +338,9 @@ BOOL CBotStack::Return(CBotStack* pfils) return (m_error == 0); // interrompu si erreur } -BOOL CBotStack::StackOver() +bool CBotStack::StackOver() { - return FALSE; // pas de test de débordement dans cette version + return false; // pas de test de débordement dans cette version } #endif @@ -377,38 +379,38 @@ CBotStack* CBotStack::RestoreStackEOX(CBotCall* instr) // routine pour l'exécution pas à pas -BOOL CBotStack::IfStep() +bool CBotStack::IfStep() { - if ( m_initimer > 0 || m_step++ > 0 ) return FALSE; - return TRUE; + if ( m_initimer > 0 || m_step++ > 0 ) return false; + return true; } -BOOL CBotStack::BreakReturn(CBotStack* pfils, const char* name) +bool CBotStack::BreakReturn(CBotStack* pfils, const char* name) { - if ( m_error>=0 ) return FALSE; // sortie normale - if ( m_error==-3 ) return FALSE; // sortie normale (return en cours) + if ( m_error>=0 ) return false; // sortie normale + if ( m_error==-3 ) return false; // sortie normale (return en cours) if (!m_labelBreak.IsEmpty() && (name[0] == 0 || m_labelBreak != name)) - return FALSE; // c'est pas pour moi + return false; // c'est pas pour moi m_error = 0; m_labelBreak.Empty(); return Return(pfils); } -BOOL CBotStack::IfContinue(int state, const char* name) +bool CBotStack::IfContinue(int state, const char* name) { - if ( m_error != -2 ) return FALSE; + if ( m_error != -2 ) return false; if (!m_labelBreak.IsEmpty() && (name == NULL || m_labelBreak != name)) - return FALSE; // c'est pas pour moi + return false; // c'est pas pour moi m_state = state; // où reprendre ? m_error = 0; m_labelBreak.Empty(); if ( m_next != EOX ) m_next->Delete(); // purge la pile au dessus - return TRUE; + return true; } void CBotStack::SetBreak(int val, const char* name) @@ -424,7 +426,7 @@ void CBotStack::SetBreak(int val, const char* name) // remet sur la pile la valeur calculée par le dernier CBotReturn -BOOL CBotStack::GivRetVar(BOOL bRet) +bool CBotStack::GivRetVar(bool bRet) { if (m_error == -3) { @@ -432,7 +434,7 @@ BOOL CBotStack::GivRetVar(BOOL bRet) m_var = m_retvar; m_retvar = NULL; m_error = 0; - return TRUE; + return true; } return bRet; // interrompu par autre chose que return } @@ -469,7 +471,7 @@ void CBotStack::SetType(CBotTypResult& type) // trouve une variable par son token // ce peut être une variable composée avec un point -CBotVar* CBotStack::FindVar(CBotToken* &pToken, BOOL bUpdate, BOOL bModif) +CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif) { CBotStack* p = this; CBotString name = pToken->GivString(); @@ -482,7 +484,7 @@ CBotVar* CBotStack::FindVar(CBotToken* &pToken, BOOL bUpdate, BOOL bModif) if (pp->GivName() == name) { if ( bUpdate ) - pp->Maj(m_pUser, FALSE); + pp->Maj(m_pUser, false); return pp; } @@ -515,7 +517,7 @@ CBotVar* CBotStack::FindVar(const char* name) // retrouve une variable sur la pile selon son numéro d'identification // ce qui va plus vite que de comparer les noms. -CBotVar* CBotStack::FindVar(long ident, BOOL bUpdate, BOOL bModif) +CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif) { CBotStack* p = this; while (p != NULL) @@ -526,7 +528,7 @@ CBotVar* CBotStack::FindVar(long ident, BOOL bUpdate, BOOL bModif) if (pp->GivUniqNum() == ident) { if ( bUpdate ) - pp->Maj(m_pUser, FALSE); + pp->Maj(m_pUser, false); return pp; } @@ -538,14 +540,14 @@ CBotVar* CBotStack::FindVar(long ident, BOOL bUpdate, BOOL bModif) } -CBotVar* CBotStack::FindVar(CBotToken& Token, BOOL bUpdate, BOOL bModif) +CBotVar* CBotStack::FindVar(CBotToken& Token, bool bUpdate, bool bModif) { CBotToken* pt = &Token; return FindVar(pt, bUpdate, bModif); } -CBotVar* CBotStack::CopyVar(CBotToken& Token, BOOL bUpdate) +CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate) { CBotVar* pVar = FindVar( Token, bUpdate ); @@ -557,7 +559,7 @@ CBotVar* CBotStack::CopyVar(CBotToken& Token, BOOL bUpdate) } -BOOL CBotStack::SetState(int n, int limite) +bool CBotStack::SetState(int n, int limite) { m_state = n; @@ -565,7 +567,7 @@ BOOL CBotStack::SetState(int n, int limite) return ( m_timer > limite ); // interrompu si timer passé } -BOOL CBotStack::IncState(int limite) +bool CBotStack::IncState(int limite) { m_state++; @@ -603,7 +605,7 @@ void CBotStack::SetTimer(int n) m_initimer = n; } -BOOL CBotStack::Execute() +bool CBotStack::Execute() { CBotCall* instr = NULL; // instruction la plus élevée CBotStack* pile; @@ -621,9 +623,9 @@ BOOL CBotStack::Execute() p = p->m_next; } - if ( instr == NULL ) return TRUE; // exécution normale demandée + if ( instr == NULL ) return true; // exécution normale demandée - if (!instr->Run(pile)) return FALSE; // exécution à partir de là + if (!instr->Run(pile)) return false; // exécution à partir de là #if STACKMEM pile->m_next->Delete(); @@ -632,7 +634,7 @@ BOOL CBotStack::Execute() #endif pile->m_next = EOX; // spécial pour reprise - return TRUE; + return true; } // met sur le stack le pointeur à une variable @@ -711,10 +713,10 @@ void CBotStack::AddVar(CBotVar* pVar) void CBotStack::SetBotCall(CBotProgram* p) { m_prog = p; - m_bFunc = TRUE; + m_bFunc = true; } -CBotProgram* CBotStack::GivBotCall(BOOL bFirst) +CBotProgram* CBotStack::GivBotCall(bool bFirst) { if ( ! bFirst ) return m_prog; CBotStack* p = this; @@ -728,7 +730,7 @@ void* CBotStack::GivPUser() } -BOOL CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype) +bool CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotTypResult& rettype) { CBotTypResult res; @@ -750,7 +752,7 @@ BOOL CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBo if (res.GivType() >= 0) return res.GivType(); SetError(TX_NOCALL, token); - return TRUE; + return true; } void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar) @@ -762,17 +764,17 @@ void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar) } -BOOL SaveVar(FILE* pf, CBotVar* pVar) +bool SaveVar(FILE* pf, CBotVar* pVar) { - while ( TRUE ) + while ( true ) { if ( pVar == NULL ) { return WriteWord(pf, 0); // met un terminateur } - if ( !pVar->Save0State(pf)) return FALSE; // entête commune - if ( !pVar->Save1State(pf) ) return FALSE; // sauve selon la classe fille + if ( !pVar->Save0State(pf)) return false; // entête commune + if ( !pVar->Save1State(pf) ) return false; // sauve selon la classe fille pVar = pVar->GivNext(); } @@ -856,7 +858,7 @@ CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level) return p->m_listVar; } -BOOL CBotStack::SaveState(FILE* pf) +bool CBotStack::SaveState(FILE* pf) { if ( this == NULL ) // fin de l'arbre ? { @@ -865,33 +867,33 @@ BOOL CBotStack::SaveState(FILE* pf) if ( m_next2 != NULL ) { - if (!WriteWord(pf, 2)) return FALSE; // une marque de poursuite - if (!m_next2->SaveState(pf)) return FALSE; + if (!WriteWord(pf, 2)) return false; // une marque de poursuite + if (!m_next2->SaveState(pf)) return false; } else { - if (!WriteWord(pf, 1)) return FALSE; // une marque de poursuite + if (!WriteWord(pf, 1)) return false; // une marque de poursuite } - if (!WriteWord(pf, m_bBlock)) return FALSE; // est-ce un bloc local - if (!WriteWord(pf, m_state)) return FALSE; // dans quel état - if (!WriteWord(pf, 0)) return FALSE; // par compatibilité m_bDontDelete - if (!WriteWord(pf, m_step)) return FALSE; // dans quel état + if (!WriteWord(pf, m_bBlock)) return false; // est-ce un bloc local + if (!WriteWord(pf, m_state)) return false; // dans quel état + if (!WriteWord(pf, 0)) return false; // par compatibilité m_bDontDelete + if (!WriteWord(pf, m_step)) return false; // dans quel état - if (!SaveVar(pf, m_var)) return FALSE; // le résultat courant - if (!SaveVar(pf, m_listVar)) return FALSE; // les variables locales + if (!SaveVar(pf, m_var)) return false; // le résultat courant + if (!SaveVar(pf, m_listVar)) return false; // les variables locales return m_next->SaveState(pf); // enregistre la suite } -BOOL CBotStack::RestoreState(FILE* pf, CBotStack* &pStack) +bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack) { - WORD w; + unsigned short w; pStack = NULL; - if (!ReadWord(pf, w)) return FALSE; - if ( w == 0 ) return TRUE; + if (!ReadWord(pf, w)) return false; + if ( w == 0 ) return true; #if STACKMEM if ( this == NULL ) pStack = FirstStack(); @@ -902,81 +904,81 @@ BOOL CBotStack::RestoreState(FILE* pf, CBotStack* &pStack) if ( w == 2 ) { - if (!pStack->RestoreState(pf, pStack->m_next2)) return FALSE; + if (!pStack->RestoreState(pf, pStack->m_next2)) return false; } - if (!ReadWord(pf, w)) return FALSE; // est-ce un bloc local + if (!ReadWord(pf, w)) return false; // est-ce un bloc local pStack->m_bBlock = w; - if (!ReadWord(pf, w)) return FALSE; // dans quel état j'ère ? + if (!ReadWord(pf, w)) return false; // dans quel état j'ère ? pStack->SetState((short)w); // dans le bon état - if (!ReadWord(pf, w)) return FALSE; // dont delete ? + if (!ReadWord(pf, w)) return false; // dont delete ? // plus utilisé - if (!ReadWord(pf, w)) return FALSE; // pas à pas + if (!ReadWord(pf, w)) return false; // pas à pas pStack->m_step = w; - if (!CBotVar::RestoreState(pf, pStack->m_var)) return FALSE; // la variable temp - if (!CBotVar::RestoreState(pf, pStack->m_listVar)) return FALSE;// les variables locales + if (!CBotVar::RestoreState(pf, pStack->m_var)) return false; // la variable temp + if (!CBotVar::RestoreState(pf, pStack->m_listVar)) return false;// les variables locales return pStack->RestoreState(pf, pStack->m_next); } -BOOL CBotVar::Save0State(FILE* pf) +bool CBotVar::Save0State(FILE* pf) { - if (!WriteWord(pf, 100+m_mPrivate))return FALSE; // variable privée ? - if (!WriteWord(pf, m_bStatic))return FALSE; // variable static ? - if (!WriteWord(pf, m_type.GivType()))return FALSE; // enregiste le type (toujours non nul) - if (!WriteWord(pf, m_binit))return FALSE; // variable définie ? + if (!WriteWord(pf, 100+m_mPrivate))return false; // variable privée ? + if (!WriteWord(pf, m_bStatic))return false; // variable static ? + if (!WriteWord(pf, m_type.GivType()))return false; // enregiste le type (toujours non nul) + if (!WriteWord(pf, m_binit))return false; // variable définie ? return WriteString(pf, m_token->GivString()); // et le nom de la variable } -BOOL CBotVarInt::Save0State(FILE* pf) +bool CBotVarInt::Save0State(FILE* pf) { if ( !m_defnum.IsEmpty() ) { - if(!WriteWord(pf, 200 )) return FALSE; // marqueur spécial - if(!WriteString(pf, m_defnum)) return FALSE; // nom de la valeur + if(!WriteWord(pf, 200 )) return false; // marqueur spécial + if(!WriteString(pf, m_defnum)) return false; // nom de la valeur } return CBotVar::Save0State(pf); } -BOOL CBotVarInt::Save1State(FILE* pf) +bool CBotVarInt::Save1State(FILE* pf) { return WriteWord(pf, m_val); // la valeur de la variable } -BOOL CBotVarBoolean::Save1State(FILE* pf) +bool CBotVarBoolean::Save1State(FILE* pf) { return WriteWord(pf, m_val); // la valeur de la variable } -BOOL CBotVarFloat::Save1State(FILE* pf) +bool CBotVarFloat::Save1State(FILE* pf) { return WriteFloat(pf, m_val); // la valeur de la variable } -BOOL CBotVarString::Save1State(FILE* pf) +bool CBotVarString::Save1State(FILE* pf) { return WriteString(pf, m_val); // la valeur de la variable } -BOOL CBotVarClass::Save1State(FILE* pf) +bool CBotVarClass::Save1State(FILE* pf) { - if ( !WriteType(pf, m_type) ) return FALSE; - if ( !WriteLong(pf, m_ItemIdent) ) return FALSE; + if ( !WriteType(pf, m_type) ) return false; + if ( !WriteLong(pf, m_ItemIdent) ) return false; return SaveVar(pf, m_pVar); // contenu de l'objet } -BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) +bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) { - WORD w, wi, prv, st; + unsigned short w, wi, prv, st; float ww; CBotString name, s; @@ -986,31 +988,31 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) CBotVar* pNew = NULL; CBotVar* pPrev = NULL; - while ( TRUE ) // recupère toute une liste + while ( true ) // recupère toute une liste { - if (!ReadWord(pf, w)) return FALSE; // privé ou type ? - if ( w == 0 ) return TRUE; + if (!ReadWord(pf, w)) return false; // privé ou type ? + if ( w == 0 ) return true; CBotString defnum; if ( w == 200 ) { - if (!ReadString(pf, defnum)) return FALSE; // nombre avec un identifiant - if (!ReadWord(pf, w)) return FALSE; // type + if (!ReadString(pf, defnum)) return false; // nombre avec un identifiant + if (!ReadWord(pf, w)) return false; // type } prv = 100; st = 0; if ( w >= 100 ) { prv = w; - if (!ReadWord(pf, st)) return FALSE; // statique - if (!ReadWord(pf, w)) return FALSE; // type + if (!ReadWord(pf, st)) return false; // statique + if (!ReadWord(pf, w)) return false; // type } if ( w == CBotTypClass ) w = CBotTypIntrinsic; // forcément intrinsèque - if (!ReadWord(pf, wi)) return FALSE; // init ? + if (!ReadWord(pf, wi)) return false; // init ? - if (!ReadString(pf, name)) return FALSE; // nom de la variable + if (!ReadString(pf, name)) return false; // nom de la variable CBotToken token(name, CBotString()); @@ -1019,17 +1021,17 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) case CBotTypInt: case CBotTypBoolean: pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadWord(pf, w)) return FALSE; + if (!ReadWord(pf, w)) return false; pNew->SetValInt((short)w, defnum); break; case CBotTypFloat: pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadFloat(pf, ww)) return FALSE; + if (!ReadFloat(pf, ww)) return false; pNew->SetValFloat(ww); break; case CBotTypString: pNew = CBotVar::Create(&token, w); // crée une variable - if (!ReadString(pf, s)) return FALSE; + if (!ReadString(pf, s)) return false; pNew->SetValString(s); break; @@ -1039,17 +1041,17 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) { CBotTypResult r; long id; - if (!ReadType(pf, r)) return FALSE; // type complet - if (!ReadLong(pf, id) ) return FALSE; + if (!ReadType(pf, r)) return false; // type complet + if (!ReadLong(pf, id) ) return false; -// if (!ReadString(pf, s)) return FALSE; +// if (!ReadString(pf, s)) return false; { CBotVar* p = NULL; if ( id ) p = CBotVarClass::Find(id) ; pNew = new CBotVarClass(&token, r); // crée directement une instance // attention cptuse = 0 - if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return FALSE; + if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return false; pNew->SetIdent(id); if ( p != NULL ) @@ -1063,7 +1065,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) case CBotTypPointer: case CBotTypNullPointer: - if (!ReadString(pf, s)) return FALSE; + if (!ReadString(pf, s)) return false; { pNew = CBotVar::Create(&token, CBotTypResult(w, s));// crée une variable CBotVarClass* p = NULL; @@ -1073,7 +1075,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) // restitue une copie de l'instance d'origine CBotVar* pInstance = NULL; - if ( !CBotVar::RestoreState( pf, pInstance ) ) return FALSE; + if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus // if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // plutôt celui-ci ! @@ -1084,13 +1086,13 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) case CBotTypArrayPointer: { CBotTypResult r; - if (!ReadType(pf, r)) return FALSE; + if (!ReadType(pf, r)) return false; pNew = CBotVar::Create(&token, r); // crée une variable // restitue une copie de l'instance d'origine CBotVar* pInstance = NULL; - if ( !CBotVar::RestoreState( pf, pInstance ) ) return FALSE; + if ( !CBotVar::RestoreState( pf, pInstance ) ) return false; ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus } break; @@ -1106,7 +1108,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar) pNew->SetPrivate(prv-100); pPrev = pNew; } - return TRUE; + return true; } @@ -1133,12 +1135,12 @@ CBotCStack::CBotCStack(CBotCStack* ppapa) m_error = 0; m_start = 0; m_end = 0; - m_bBlock = TRUE; + m_bBlock = true; } else { m_start = ppapa->m_start; - m_bBlock = FALSE; + m_bBlock = false; } m_listVar = NULL; @@ -1156,7 +1158,7 @@ CBotCStack::~CBotCStack() } // utilisé uniquement à la compilation -CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, BOOL bBlock) +CBotCStack* CBotCStack::TokenStack(CBotToken* pToken, bool bBlock) { if (m_next != NULL) return m_next; // reprise dans une pile existante @@ -1291,7 +1293,7 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token) return pCopy; } -BOOL CBotCStack::IsOk() +bool CBotCStack::IsOk() { return (m_error == 0); } @@ -1325,15 +1327,15 @@ void CBotCStack::ResetError(int n, int start, int end) m_end = end; } -BOOL CBotCStack::NextToken(CBotToken* &p) +bool CBotCStack::NextToken(CBotToken* &p) { CBotToken* pp = p; p = p->GivNext(); - if (p!=NULL) return TRUE; + if (p!=NULL) return true; SetError(TX_ENDOF, pp->GivEnd()); - return FALSE; + return false; } void CBotCStack::SetBotCall(CBotProgram* p) @@ -1398,7 +1400,7 @@ void CBotCStack::AddVar(CBotVar* pVar) // test si une variable est déjà définie localement -BOOL CBotCStack::CheckVarLocal(CBotToken* &pToken) +bool CBotCStack::CheckVarLocal(CBotToken* &pToken) { CBotCStack* p = this; CBotString name = pToken->GivString(); @@ -1409,13 +1411,13 @@ BOOL CBotCStack::CheckVarLocal(CBotToken* &pToken) while ( pp != NULL) { if (name == pp->GivName()) - return TRUE; + return true; pp = pp->m_next; } - if ( p->m_bBlock ) return FALSE; + if ( p->m_bBlock ) return false; p = p->m_prev; } - return FALSE; + return false; } CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent) @@ -1440,11 +1442,11 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId // test si un nom de procédure est déjà défini quelque part -BOOL CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) +bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { CBotString name = pToken->GivString(); - if ( CBotCall::CheckCall(name) ) return TRUE; + if ( CBotCall::CheckCall(name) ) return true; CBotFunction* pp = m_prog->GivFunctions(); while ( pp != NULL ) @@ -1453,7 +1455,7 @@ BOOL CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { // les paramètres sont-ils exactement les mêmes ? if ( pp->CheckParam( pParam ) ) - return TRUE; + return true; } pp = pp->Next(); } @@ -1465,11 +1467,11 @@ BOOL CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam) { // les paramètres sont-ils exactement les mêmes ? if ( pp->CheckParam( pParam ) ) - return TRUE; + return true; } pp = pp->m_nextpublic; } - return FALSE; + return false; } diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp index 53b0f27..5f35337 100644 --- a/src/CBot/CBotString.cpp +++ b/src/CBot/CBotString.cpp @@ -19,9 +19,11 @@ #include "CBot.h" -#include - -HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ?? +#include +#include +#include +/// TODO need to be implemented to be able to load library +// HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // how to retrieve it otherwise ?? CBotString::CBotString() @@ -38,13 +40,13 @@ CBotString::~CBotString() CBotString::CBotString(const char* p) { - m_lg = lstrlen( p ); + m_lg = strlen( p ); m_ptr = NULL; if (m_lg>0) { m_ptr = (char*)malloc(m_lg+1); - lstrcpy(m_ptr, p); + strcpy(m_ptr, p); } } @@ -56,7 +58,7 @@ CBotString::CBotString(const CBotString& srcString) if (m_lg>0) { m_ptr = (char*)malloc(m_lg+1); - lstrcpy(m_ptr, srcString.m_ptr); + strcpy(m_ptr, srcString.m_ptr); } } @@ -66,7 +68,7 @@ CBotString::CBotString(const CBotString& srcString) int CBotString::GivLength() { if ( m_ptr == NULL ) return 0; - return lstrlen( m_ptr ); + return strlen( m_ptr ); } @@ -143,10 +145,10 @@ int CBotString::Find(const char c) return -1; } -int CBotString::Find(LPCTSTR lpsz) +int CBotString::Find(const char * lpsz) { int i, j; - int l = lstrlen(lpsz); + int l = strlen(lpsz); for (i = 0; i <= m_lg-l; i++) { @@ -170,10 +172,10 @@ int CBotString::ReverseFind(const char c) return -1; } -int CBotString::ReverseFind(LPCTSTR lpsz) +int CBotString::ReverseFind(const char * lpsz) { int i, j; - int l = lstrlen(lpsz); + int l = strlen(lpsz); for (i = m_lg-l; i >= 0; i--) { @@ -195,7 +197,7 @@ CBotString CBotString::Mid(int start, int lg) if ( lg < 0 ) lg = m_lg - start; char* p = (char*)malloc(m_lg+1); - lstrcpy(p, m_ptr+start); + strcpy(p, m_ptr+start); p[lg] = 0; res = p; @@ -229,11 +231,11 @@ void CBotString::MakeLower() #define MAXSTRING 256 -BOOL CBotString::LoadString(UINT id) +bool CBotString::LoadString(unsigned int id) { char buffer[MAXSTRING]; - - m_lg = ::LoadString( m_hInstance, id, buffer, MAXSTRING ); + /// \TODO implement loading strings from resources. Figure out how to do it + // m_lg = ::LoadString( m_hInstance, id, buffer, MAXSTRING ); if (m_ptr != NULL) free(m_ptr); @@ -241,10 +243,10 @@ BOOL CBotString::LoadString(UINT id) if (m_lg > 0) { m_ptr = (char*)malloc(m_lg+1); - lstrcpy(m_ptr, buffer); - return TRUE; + strcpy(m_ptr, buffer); + return true; } - return FALSE; + return false; } @@ -258,13 +260,13 @@ const CBotString& CBotString::operator=(const CBotString& stringSrc) if (m_lg > 0) { m_ptr = (char*)malloc(m_lg+1); - lstrcpy(m_ptr, stringSrc.m_ptr); + strcpy(m_ptr, stringSrc.m_ptr); } return *this; } -CBotString operator+(const CBotString& string, LPCTSTR lpsz) +CBotString operator+(const CBotString& string, const char * lpsz) { CBotString s ( string ); s += lpsz; @@ -275,9 +277,9 @@ const CBotString& CBotString::operator+(const CBotString& stringSrc) { char* p = (char*)malloc(m_lg+stringSrc.m_lg+1); - lstrcpy(p, m_ptr); + strcpy(p, m_ptr); char* pp = p + m_lg; - lstrcpy(pp, stringSrc.m_ptr); + strcpy(pp, stringSrc.m_ptr); if (m_ptr != NULL) free(m_ptr); m_ptr = p; @@ -306,12 +308,12 @@ const CBotString& CBotString::operator=(const char* pString) if ( pString != NULL ) { - m_lg = lstrlen(pString); + m_lg = strlen(pString); if (m_lg != 0) { m_ptr = (char*)malloc(m_lg+1); - lstrcpy(m_ptr, pString); + strcpy(m_ptr, pString); } } @@ -323,7 +325,7 @@ const CBotString& CBotString::operator+=(const char ch) { char* p = (char*)malloc(m_lg+2); - if (m_ptr!=NULL) lstrcpy(p, m_ptr); + if (m_ptr!=NULL) strcpy(p, m_ptr); p[m_lg++] = ch; p[m_lg] = 0; @@ -338,9 +340,9 @@ const CBotString& CBotString::operator+=(const CBotString& str) { char* p = (char*)malloc(m_lg+str.m_lg+1); - lstrcpy(p, m_ptr); + strcpy(p, m_ptr); char* pp = p + m_lg; - lstrcpy(pp, str.m_ptr); + strcpy(pp, str.m_ptr); m_lg = m_lg + str.m_lg; @@ -351,67 +353,67 @@ const CBotString& CBotString::operator+=(const CBotString& str) return *this; } -BOOL CBotString::operator==(const CBotString& str) +bool CBotString::operator==(const CBotString& str) { return Compare(str) == 0; } -BOOL CBotString::operator==(const char* p) +bool CBotString::operator==(const char* p) { return Compare(p) == 0; } -BOOL CBotString::operator!=(const CBotString& str) +bool CBotString::operator!=(const CBotString& str) { return Compare(str) != 0; } -BOOL CBotString::operator!=(const char* p) +bool CBotString::operator!=(const char* p) { return Compare(p) != 0; } -BOOL CBotString::operator>(const CBotString& str) +bool CBotString::operator>(const CBotString& str) { return Compare(str) > 0; } -BOOL CBotString::operator>(const char* p) +bool CBotString::operator>(const char* p) { return Compare(p) > 0; } -BOOL CBotString::operator>=(const CBotString& str) +bool CBotString::operator>=(const CBotString& str) { return Compare(str) >= 0; } -BOOL CBotString::operator>=(const char* p) +bool CBotString::operator>=(const char* p) { return Compare(p) >= 0; } -BOOL CBotString::operator<(const CBotString& str) +bool CBotString::operator<(const CBotString& str) { return Compare(str) < 0; } -BOOL CBotString::operator<(const char* p) +bool CBotString::operator<(const char* p) { return Compare(p) < 0; } -BOOL CBotString::operator<=(const CBotString& str) +bool CBotString::operator<=(const CBotString& str) { return Compare(str) <= 0; } -BOOL CBotString::operator<=(const char* p) +bool CBotString::operator<=(const char* p) { return Compare(p) <= 0; } -BOOL CBotString::IsEmpty() const +bool CBotString::IsEmpty() const { return (m_lg == 0); } @@ -423,20 +425,20 @@ void CBotString::Empty() m_lg = 0; } -static char nilstring[] = {0}; +static char emptyString[] = {0}; -CBotString::operator LPCTSTR() const +CBotString::operator const char * () const { - if (this == NULL || m_ptr == NULL) return nilstring; + if (this == NULL || m_ptr == NULL) return emptyString; return m_ptr; } -int CBotString::Compare(LPCTSTR lpsz) const +int CBotString::Compare(const char * lpsz) const { char* p = m_ptr; - if (lpsz == NULL) lpsz = nilstring; - if (m_ptr == NULL) p = nilstring; + if (lpsz == NULL) lpsz = emptyString; + if (m_ptr == NULL) p = emptyString; return strcmp(p, lpsz); // wcscmp } @@ -527,14 +529,14 @@ void CBotStringArray::SetSize(int nNewSize) // shrink to nothing DestructElements(m_pData, m_nSize); - delete[] (BYTE*)m_pData; + delete[] (unsigned char *)m_pData; m_pData = NULL; m_nSize = m_nMaxSize = 0; } else if (m_pData == NULL) { // create one with exact size - m_pData = (CBotString*) new BYTE[nNewSize * sizeof(CBotString)]; + m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)]; ConstructElements(m_pData, nNewSize); @@ -563,7 +565,7 @@ void CBotStringArray::SetSize(int nNewSize) { // heuristically determine growth when nGrowBy == 0 // (this avoids heap fragmentation in many situations) - nGrowBy = min(1024, max(4, m_nSize / 8)); + nGrowBy = std::min(1024, std::max(4, m_nSize / 8)); } int nNewMax; if (nNewSize < m_nMaxSize + nGrowBy) @@ -571,7 +573,7 @@ void CBotStringArray::SetSize(int nNewSize) else nNewMax = nNewSize; // no slush - CBotString* pNewData = (CBotString*) new BYTE[nNewMax * sizeof(CBotString)]; + CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)]; // copy new data from old memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString)); @@ -581,7 +583,7 @@ void CBotStringArray::SetSize(int nNewSize) // Ret rid of old stuff (note: no destructors called) - delete[] (BYTE*)m_pData; + delete[] (unsigned char *)m_pData; m_pData = pNewData; m_nSize = nNewSize; m_nMaxSize = nNewMax; diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index fbf6726..1b6392c 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -22,6 +22,7 @@ #include "CBot.h" +#include CBotStringArray CBotToken::m_ListKeyWords; int CBotToken::m_ListIdKeyWords[200]; @@ -188,27 +189,27 @@ void CBotToken::SetPos(int start, int end) m_end = end; } -BOOL CharInList(const char c, const char* list) +bool CharInList(const char c, const char* list) { int i = 0; - while (TRUE) + while (true) { - if (c == list[i++]) return TRUE; - if (list[i] == 0) return FALSE; + if (c == list[i++]) return true; + if (list[i] == 0) return false; } } -BOOL Char2InList(const char c, const char cc, const char* list) +bool Char2InList(const char c, const char cc, const char* list) { int i = 0; - while (TRUE) + while (true) { if (c == list[i++] && - cc == list[i++]) return TRUE; + cc == list[i++]) return true; - if (list[i] == 0) return FALSE; + if (list[i] == 0) return false; } } @@ -224,12 +225,12 @@ static char* nch = "\"\r\n\t"; // refus // cherche le prochain token dans une phrase // ne doit pas commencer par des séparateurs // qui sont pris avec le token précédent -CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first) +CBotToken* CBotToken::NextToken(char* &program, int& error, bool first) { CBotString mot; // le mot trouvé CBotString sep; // les séparateurs qui le suivent char c; - BOOL stop = first; + bool stop = first; if (*program == 0) return NULL; @@ -262,14 +263,14 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first) mot += c; // chaîne complète c = *(program++); // prochain caractère } - stop = TRUE; + stop = true; } // cas particulier pour les nombres if ( CharInList(mot[0], num )) { - BOOL bdot = FALSE; // trouvé un point ? - BOOL bexp = FALSE; // trouvé un exposant ? + bool bdot = false; // trouvé un point ? + bool bexp = false; // trouvé un exposant ? char* liste = num; if (mot[0] == '0' && c == 'x') // valeur hexadécimale ? @@ -286,10 +287,10 @@ cc: mot += c; } if ( liste == num ) // pas pour les exadécimaux { - if ( !bdot && c == '.' ) { bdot = TRUE; goto cc; } + if ( !bdot && c == '.' ) { bdot = true; goto cc; } if ( !bexp && ( c == 'e' || c == 'E' ) ) { - bexp = TRUE; + bexp = true; mot += c; c = *(program++); // prochain caractère if ( c == '-' || @@ -298,7 +299,7 @@ cc: mot += c; } } - stop = TRUE; + stop = true; } if (CharInList(mot[0], sep3)) // un séparateur opérationnel ? @@ -310,13 +311,13 @@ cc: mot += c; c = *(program++); // prochain caractère } - stop = TRUE; + stop = true; } } - while (TRUE) + while (true) { if (stop || c == 0 || CharInList(c, sep1)) { @@ -381,7 +382,7 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error) int pos = 0; error = 0; - prv = tokenbase = NextToken(p, error, TRUE); + prv = tokenbase = NextToken(p, error, true); if (tokenbase == NULL) return NULL; @@ -443,7 +444,7 @@ int CBotToken::GivKeyWords(const char* w) return -1; } -BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token) +bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token) { int i; int l = m_ListKeyDefine.GivSize(); @@ -454,11 +455,11 @@ BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token) { token->m_IdKeyWord = m_ListKeyNums[i]; token->m_type = TokenTypDef; - return TRUE; + return true; } } - return FALSE; + return false; } // reprend la liste des mots clefs dans les ressources @@ -498,36 +499,36 @@ void CBotToken::LoadKeyWords() } } -BOOL CBotToken::DefineNum(const char* name, long val) +bool CBotToken::DefineNum(const char* name, long val) { int i; int l = m_ListKeyDefine.GivSize(); for (i = 0; i < l; i++) { - if (m_ListKeyDefine[i] == name) return FALSE; + if (m_ListKeyDefine[i] == name) return false; } - if ( i == MAXDEFNUM ) return FALSE; + if ( i == MAXDEFNUM ) return false; m_ListKeyDefine.Add( name ); m_ListKeyNums[i] = val; - return TRUE; + return true; } -BOOL IsOfType(CBotToken* &p, int type1, int type2) +bool IsOfType(CBotToken* &p, int type1, int type2) { if (p->GivType() == type1 || p->GivType() == type2 ) { p = p->GivNext(); - return TRUE; + return true; } - return FALSE; + return false; } // idem avec un nombre indéfini d'arguments // il faut mettre un zéro comme dernier argument -BOOL IsOfTypeList(CBotToken* &p, int type1, ...) +bool IsOfTypeList(CBotToken* &p, int type1, ...) { int i = type1; int max = 20; @@ -536,18 +537,18 @@ BOOL IsOfTypeList(CBotToken* &p, int type1, ...) va_list marker; va_start( marker, type1 ); /* Initialize variable arguments. */ - while (TRUE) + while (true) { if (type == i) { p = p->GivNext(); va_end( marker ); /* Reset variable arguments. */ - return TRUE; + return true; } if (--max == 0 || 0 == (i = va_arg( marker, int))) { va_end( marker ); /* Reset variable arguments. */ - return FALSE; + return false; } } } diff --git a/src/CBot/CBotToken.h b/src/CBot/CBotToken.h index 2d92409..62e9bf3 100644 --- a/src/CBot/CBotToken.h +++ b/src/CBot/CBotToken.h @@ -33,5 +33,5 @@ // ) -extern BOOL IsOfType(CBotToken* &p, int type1, int type2 = -1); -extern BOOL IsOfTypeList(CBotToken* &p, int type1, ...); +extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1); +extern bool IsOfTypeList(CBotToken* &p, int type1, ...); diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotTwoOpExpr.cpp index d8f4ee7..e2523b5 100644 --- a/src/CBot/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotTwoOpExpr.cpp @@ -95,19 +95,19 @@ static int ListOp[] = 0, }; -BOOL IsInList( int val, int* list, int& typemasque ) +bool IsInList( int val, int* list, int& typemasque ) { - while (TRUE) + while (true) { - if ( *list == 0 ) return FALSE; + if ( *list == 0 ) return false; typemasque = *list++; - if ( *list++ == val ) return TRUE; + if ( *list++ == val ) return true; } } -BOOL TypeOk( int type, int test ) +bool TypeOk( int type, int test ) { - while (TRUE) + while (true) { if ( type == 0 ) return (test & 1); type--; test /= 2; @@ -279,43 +279,43 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera } -BOOL IsNan(CBotVar* left, CBotVar* right, int* err = NULL) +bool IsNan(CBotVar* left, CBotVar* right, int* err = NULL) { if ( left ->GivInit() > IS_DEF || right->GivInit() > IS_DEF ) { if ( err != NULL ) *err = TX_OPNAN ; - return TRUE; + return true; } - return FALSE; + return false; } // fait l'opération sur 2 opérandes -BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) +bool CBotTwoOpExpr::Execute(CBotStack* &pStack) { CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pStk1 == EOX ) return TRUE; +// if ( pStk1 == EOX ) return true; // selon la reprise, on peut être dans l'un des 2 états if ( pStk1->GivState() == 0 ) // 1er état, évalue l'opérande de gauche { - if (!m_leftop->Execute(pStk1) ) return FALSE; // interrompu ici ? + if (!m_leftop->Execute(pStk1) ) return false; // interrompu ici ? // pour les OU et ET logique, n'évalue pas la seconde expression si pas nécessaire - if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == FALSE ) + if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == false ) { CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean); - res->SetValInt(FALSE); + res->SetValInt(false); pStk1->SetVar(res); return pStack->Return(pStk1); // transmet le résultat } - if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == TRUE ) + if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == true ) { CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean); - res->SetValInt(TRUE); + res->SetValInt(true); pStk1->SetVar(res); return pStack->Return(pStk1); // transmet le résultat } @@ -334,7 +334,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) // 2e état, évalue l'opérande de droite if ( pStk2->GivState() == 0 ) { - if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ? + if ( !m_rightop->Execute(pStk2) ) return false; // interrompu ici ? pStk2->IncState(); } @@ -342,7 +342,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) CBotTypResult type2 = pStk2->GivTypResult(); CBotStack* pStk3 = pStk2->AddStack(this); // ajoute un élément à la pile - if ( pStk3->IfStep() ) return FALSE; // montre l'opération si step by step + if ( pStk3->IfStep() ) return false; // montre l'opération si step by step // crée une variable temporaire pour y mettre le résultat // quel est le type du résultat ? @@ -475,7 +475,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack) return pStack->Return(pStk2); // transmet le résultat } -void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain) +void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain) { if ( !bMain ) return; CBotStack* pStk1 = pStack->RestoreStack(this); // ajoute un élément à la pile @@ -501,31 +501,31 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain) } -BOOL CBotLogicExpr::Execute(CBotStack* &pStack) +bool CBotLogicExpr::Execute(CBotStack* &pStack) { CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pStk1 == EOX ) return TRUE; +// if ( pStk1 == EOX ) return true; if ( pStk1->GivState() == 0 ) { - if ( !m_condition->Execute(pStk1) ) return FALSE; - if (!pStk1->SetState(1)) return FALSE; + if ( !m_condition->Execute(pStk1) ) return false; + if (!pStk1->SetState(1)) return false; } - if ( pStk1->GivVal() == TRUE ) + if ( pStk1->GivVal() == true ) { - if ( !m_op1->Execute(pStk1) ) return FALSE; + if ( !m_op1->Execute(pStk1) ) return false; } else { - if ( !m_op2->Execute(pStk1) ) return FALSE; + if ( !m_op2->Execute(pStk1) ) return false; } return pStack->Return(pStk1); // transmet le résultat } -void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain) +void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain) { if ( !bMain ) return; @@ -538,7 +538,7 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain) return; } - if ( pStk1->GivVal() == TRUE ) + if ( pStk1->GivVal() == true ) { m_op1->RestoreState(pStk1, bMain); } @@ -557,7 +557,7 @@ void t() #endif #if 01 -void t(BOOL t) +void t(bool t) { int x; x = 1 + t ? 1 : 3 + 4 * 2 ; diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp index 37c8fb4..79ba021 100644 --- a/src/CBot/CBotVar.cpp +++ b/src/CBot/CBotVar.cpp @@ -33,9 +33,9 @@ CBotVar::CBotVar( ) m_InitExpr = NULL; m_LimExpr = NULL; m_type = -1; - m_binit = FALSE; + m_binit = false; m_ident = 0; - m_bStatic = FALSE; + m_bStatic = false; m_mPrivate = 0; } @@ -48,8 +48,8 @@ CBotVarInt::CBotVarInt( const CBotToken* name ) m_InitExpr = NULL; m_LimExpr = NULL; m_type = CBotTypInt; - m_binit = FALSE; - m_bStatic = FALSE; + m_binit = false; + m_bStatic = false; m_mPrivate = 0; m_val = 0; @@ -64,8 +64,8 @@ CBotVarFloat::CBotVarFloat( const CBotToken* name ) m_InitExpr = NULL; m_LimExpr = NULL; m_type = CBotTypFloat; - m_binit = FALSE; - m_bStatic = FALSE; + m_binit = false; + m_bStatic = false; m_mPrivate = 0; m_val = 0; @@ -80,8 +80,8 @@ CBotVarString::CBotVarString( const CBotToken* name ) m_InitExpr = NULL; m_LimExpr = NULL; m_type = CBotTypString; - m_binit = FALSE; - m_bStatic = FALSE; + m_binit = false; + m_bStatic = false; m_mPrivate = 0; m_val.Empty(); @@ -96,8 +96,8 @@ CBotVarBoolean::CBotVarBoolean( const CBotToken* name ) m_InitExpr = NULL; m_LimExpr = NULL; m_type = CBotTypBoolean; - m_binit = FALSE; - m_bStatic = FALSE; + m_binit = false; + m_bStatic = false; m_mPrivate = 0; m_val = 0; @@ -139,10 +139,10 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type m_pClass = NULL; m_pParent = NULL; - m_binit = FALSE; - m_bStatic = FALSE; + m_binit = false; + m_bStatic = false; m_mPrivate = 0; - m_bConstructor = FALSE; + m_bConstructor = false; m_CptUse = 0; m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum(); @@ -189,7 +189,7 @@ CBotVarClass::~CBotVarClass( ) void CBotVarClass::ConstructorSet() { - m_bConstructor = TRUE; + m_bConstructor = true; } @@ -201,9 +201,9 @@ CBotVar::~CBotVar( ) void CBotVar::debug() { - const char* p = (LPCTSTR) m_token->GivString(); - CBotString s = (LPCTSTR) GivValString(); - const char* v = (LPCTSTR) s; + const char* p = (const char*) m_token->GivString(); + CBotString s = (const char*) GivValString(); + const char* v = (const char*) s; if ( m_type.Eq(CBotTypClass) ) { @@ -260,19 +260,19 @@ void* CBotVar::GivUserPtr() return m_pUserPtr; } -BOOL CBotVar::Save1State(FILE* pf) +bool CBotVar::Save1State(FILE* pf) { // cette routine "virtual" ne doit jamais être appellée, // il doit y avoir une routine pour chaque classe fille (CBotVarInt, CBotVarFloat, etc) // ( voir le type dans m_type ) ASM_TRAP(); - return FALSE; + return false; } -void CBotVar::Maj(void* pUser, BOOL bContinu) +void CBotVar::Maj(void* pUser, bool bContinu) { /* if (!bContinu && m_pMyThis != NULL) - m_pMyThis->Maj(pUser, TRUE);*/ + m_pMyThis->Maj(pUser, true);*/ } @@ -326,7 +326,7 @@ CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type) while (type.Eq(CBotTypArrayBody)) { type = type.GivTypElem(); - pv = ((CBotVarArray*)pv)->GivItem(0, TRUE); // crée au moins l'élément [0] + pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] } return array; @@ -397,7 +397,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type) while (type.Eq(CBotTypArrayBody)) { type = type.GivTypElem(); - pv = ((CBotVarArray*)pv)->GivItem(0, TRUE); // crée au moins l'élément [0] + pv = ((CBotVarArray*)pv)->GivItem(0, true); // crée au moins l'élément [0] } return array; @@ -471,7 +471,7 @@ int CBotVar::GivInit() return m_binit; } -void CBotVar::SetInit(BOOL bInit) +void CBotVar::SetInit(int bInit) { m_binit = bInit; if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial @@ -533,14 +533,14 @@ CBotVar* CBotVar::GivItemList() return NULL; } -CBotVar* CBotVar::GivItem(int row, BOOL bGrow) +CBotVar* CBotVar::GivItem(int row, bool bGrow) { ASM_TRAP(); return NULL; } // dit si une variable appartient à une classe donnée -BOOL CBotVar::IsElemOfClass(const char* name) +bool CBotVar::IsElemOfClass(const char* name) { CBotClass* pc = NULL; @@ -555,11 +555,11 @@ BOOL CBotVar::IsElemOfClass(const char* name) while ( pc != NULL ) { - if ( pc->GivName() == name ) return TRUE; + if ( pc->GivName() == name ) return true; pc = pc->GivParent(); } - return FALSE; + return false; } @@ -611,7 +611,7 @@ void CBotVar::SetVal(CBotVar* var) { delete ((CBotVarClass*)this)->m_pVar; ((CBotVarClass*)this)->m_pVar = NULL; - Copy(var, FALSE); + Copy(var, false); } break; default: @@ -621,7 +621,7 @@ void CBotVar::SetVal(CBotVar* var) m_binit = var->m_binit; // copie l'état nan s'il y a } -void CBotVar::SetStatic(BOOL bStatic) +void CBotVar::SetStatic(bool bStatic) { m_bStatic = bStatic; } @@ -631,12 +631,12 @@ void CBotVar::SetPrivate(int mPrivate) m_mPrivate = mPrivate; } -BOOL CBotVar::IsStatic() +bool CBotVar::IsStatic() { return m_bStatic; } -BOOL CBotVar::IsPrivate(int mode) +bool CBotVar::IsPrivate(int mode) { return m_mPrivate >= mode; } @@ -715,40 +715,40 @@ void CBotVar::Sub(CBotVar* left, CBotVar* right) ASM_TRAP(); } -BOOL CBotVar::Lo(CBotVar* left, CBotVar* right) +bool CBotVar::Lo(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } -BOOL CBotVar::Hi(CBotVar* left, CBotVar* right) +bool CBotVar::Hi(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } -BOOL CBotVar::Ls(CBotVar* left, CBotVar* right) +bool CBotVar::Ls(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } -BOOL CBotVar::Hs(CBotVar* left, CBotVar* right) +bool CBotVar::Hs(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } -BOOL CBotVar::Eq(CBotVar* left, CBotVar* right) +bool CBotVar::Eq(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } -BOOL CBotVar::Ne(CBotVar* left, CBotVar* right) +bool CBotVar::Ne(CBotVar* left, CBotVar* right) { ASM_TRAP(); - return FALSE; + return false; } void CBotVar::And(CBotVar* left, CBotVar* right) @@ -800,7 +800,7 @@ void CBotVar::Dec() ASM_TRAP(); } -void CBotVar::Copy(CBotVar* pSrc, BOOL bName) +void CBotVar::Copy(CBotVar* pSrc, bool bName) { ASM_TRAP(); } @@ -837,7 +837,7 @@ void CBotVar::SetIndirection(CBotVar* pVar) ////////////////////////////////////////////////////////////////////////////////////// // copie une variable dans une autre -void CBotVarInt::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarInt::Copy(CBotVar* pSrc, bool bName) { CBotVarInt* p = (CBotVarInt*)pSrc; @@ -860,7 +860,7 @@ void CBotVarInt::Copy(CBotVar* pSrc, BOOL bName) void CBotVarInt::SetValInt(int val, const char* defnum) { m_val = val; - m_binit = TRUE; + m_binit = true; m_defnum = defnum; } @@ -869,7 +869,7 @@ void CBotVarInt::SetValInt(int val, const char* defnum) void CBotVarInt::SetValFloat(float val) { m_val = (int)val; - m_binit = TRUE; + m_binit = true; } int CBotVarInt::GivValInt() @@ -910,13 +910,13 @@ CBotString CBotVarInt::GivValString() void CBotVarInt::Mul(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() * right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::Power(CBotVar* left, CBotVar* right) { m_val = (int) pow( (double) left->GivValInt() , (double) right->GivValInt() ); - m_binit = TRUE; + m_binit = true; } int CBotVarInt::Div(CBotVar* left, CBotVar* right) @@ -925,7 +925,7 @@ int CBotVarInt::Div(CBotVar* left, CBotVar* right) if ( r != 0 ) { m_val = left->GivValInt() / r; - m_binit = TRUE; + m_binit = true; } return ( r == 0 ? TX_DIVZERO : 0 ); } @@ -936,7 +936,7 @@ int CBotVarInt::Modulo(CBotVar* left, CBotVar* right) if ( r != 0 ) { m_val = left->GivValInt() % r; - m_binit = TRUE; + m_binit = true; } return ( r == 0 ? TX_DIVZERO : 0 ); } @@ -944,43 +944,43 @@ int CBotVarInt::Modulo(CBotVar* left, CBotVar* right) void CBotVarInt::Add(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() + right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::Sub(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() - right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::XOr(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() ^ right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::And(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() & right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::Or(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() | right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::SL(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() << right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::ASR(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() >> right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarInt::SR(CBotVar* left, CBotVar* right) @@ -989,7 +989,7 @@ void CBotVarInt::SR(CBotVar* left, CBotVar* right) int shift = right->GivValInt(); if (shift>=1) source &= 0x7fffffff; m_val = source >> shift; - m_binit = TRUE; + m_binit = true; } void CBotVarInt::Neg() @@ -1014,32 +1014,32 @@ void CBotVarInt::Dec() m_defnum.Empty(); } -BOOL CBotVarInt::Lo(CBotVar* left, CBotVar* right) +bool CBotVarInt::Lo(CBotVar* left, CBotVar* right) { return left->GivValInt() < right->GivValInt(); } -BOOL CBotVarInt::Hi(CBotVar* left, CBotVar* right) +bool CBotVarInt::Hi(CBotVar* left, CBotVar* right) { return left->GivValInt() > right->GivValInt(); } -BOOL CBotVarInt::Ls(CBotVar* left, CBotVar* right) +bool CBotVarInt::Ls(CBotVar* left, CBotVar* right) { return left->GivValInt() <= right->GivValInt(); } -BOOL CBotVarInt::Hs(CBotVar* left, CBotVar* right) +bool CBotVarInt::Hs(CBotVar* left, CBotVar* right) { return left->GivValInt() >= right->GivValInt(); } -BOOL CBotVarInt::Eq(CBotVar* left, CBotVar* right) +bool CBotVarInt::Eq(CBotVar* left, CBotVar* right) { return left->GivValInt() == right->GivValInt(); } -BOOL CBotVarInt::Ne(CBotVar* left, CBotVar* right) +bool CBotVarInt::Ne(CBotVar* left, CBotVar* right) { return left->GivValInt() != right->GivValInt(); } @@ -1048,7 +1048,7 @@ BOOL CBotVarInt::Ne(CBotVar* left, CBotVar* right) ////////////////////////////////////////////////////////////////////////////////////// // copie une variable dans une autre -void CBotVarFloat::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarFloat::Copy(CBotVar* pSrc, bool bName) { CBotVarFloat* p = (CBotVarFloat*)pSrc; @@ -1071,13 +1071,13 @@ void CBotVarFloat::Copy(CBotVar* pSrc, BOOL bName) void CBotVarFloat::SetValInt(int val, const char* s) { m_val = (float)val; - m_binit = TRUE; + m_binit = true; } void CBotVarFloat::SetValFloat(float val) { m_val = val; - m_binit = TRUE; + m_binit = true; } int CBotVarFloat::GivValInt() @@ -1116,13 +1116,13 @@ CBotString CBotVarFloat::GivValString() void CBotVarFloat::Mul(CBotVar* left, CBotVar* right) { m_val = left->GivValFloat() * right->GivValFloat(); - m_binit = TRUE; + m_binit = true; } void CBotVarFloat::Power(CBotVar* left, CBotVar* right) { m_val = (float)pow( left->GivValFloat() , right->GivValFloat() ); - m_binit = TRUE; + m_binit = true; } int CBotVarFloat::Div(CBotVar* left, CBotVar* right) @@ -1131,7 +1131,7 @@ int CBotVarFloat::Div(CBotVar* left, CBotVar* right) if ( r != 0 ) { m_val = left->GivValFloat() / r; - m_binit = TRUE; + m_binit = true; } return ( r == 0 ? TX_DIVZERO : 0 ); } @@ -1142,7 +1142,7 @@ int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right) if ( r != 0 ) { m_val = (float)fmod( left->GivValFloat() , r ); - m_binit = TRUE; + m_binit = true; } return ( r == 0 ? TX_DIVZERO : 0 ); } @@ -1150,13 +1150,13 @@ int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right) void CBotVarFloat::Add(CBotVar* left, CBotVar* right) { m_val = left->GivValFloat() + right->GivValFloat(); - m_binit = TRUE; + m_binit = true; } void CBotVarFloat::Sub(CBotVar* left, CBotVar* right) { m_val = left->GivValFloat() - right->GivValFloat(); - m_binit = TRUE; + m_binit = true; } void CBotVarFloat::Neg() @@ -1175,32 +1175,32 @@ void CBotVarFloat::Dec() } -BOOL CBotVarFloat::Lo(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Lo(CBotVar* left, CBotVar* right) { return left->GivValFloat() < right->GivValFloat(); } -BOOL CBotVarFloat::Hi(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Hi(CBotVar* left, CBotVar* right) { return left->GivValFloat() > right->GivValFloat(); } -BOOL CBotVarFloat::Ls(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Ls(CBotVar* left, CBotVar* right) { return left->GivValFloat() <= right->GivValFloat(); } -BOOL CBotVarFloat::Hs(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Hs(CBotVar* left, CBotVar* right) { return left->GivValFloat() >= right->GivValFloat(); } -BOOL CBotVarFloat::Eq(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Eq(CBotVar* left, CBotVar* right) { return left->GivValFloat() == right->GivValFloat(); } -BOOL CBotVarFloat::Ne(CBotVar* left, CBotVar* right) +bool CBotVarFloat::Ne(CBotVar* left, CBotVar* right) { return left->GivValFloat() != right->GivValFloat(); } @@ -1209,7 +1209,7 @@ BOOL CBotVarFloat::Ne(CBotVar* left, CBotVar* right) ////////////////////////////////////////////////////////////////////////////////////// // copie une variable dans une autre -void CBotVarBoolean::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName) { CBotVarBoolean* p = (CBotVarBoolean*)pSrc; @@ -1231,14 +1231,14 @@ void CBotVarBoolean::Copy(CBotVar* pSrc, BOOL bName) void CBotVarBoolean::SetValInt(int val, const char* s) { - m_val = (BOOL)val; - m_binit = TRUE; + m_val = (bool)val; + m_binit = true; } void CBotVarBoolean::SetValFloat(float val) { - m_val = (BOOL)val; - m_binit = TRUE; + m_val = (bool)val; + m_binit = true; } int CBotVarBoolean::GivValInt() @@ -1275,31 +1275,31 @@ CBotString CBotVarBoolean::GivValString() void CBotVarBoolean::And(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() && right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarBoolean::Or(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() || right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right) { m_val = left->GivValInt() ^ right->GivValInt(); - m_binit = TRUE; + m_binit = true; } void CBotVarBoolean::Not() { - m_val = m_val ? FALSE : TRUE ; + m_val = m_val ? false : true ; } -BOOL CBotVarBoolean::Eq(CBotVar* left, CBotVar* right) +bool CBotVarBoolean::Eq(CBotVar* left, CBotVar* right) { return left->GivValInt() == right->GivValInt(); } -BOOL CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) +bool CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) { return left->GivValInt() != right->GivValInt(); } @@ -1307,7 +1307,7 @@ BOOL CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) ////////////////////////////////////////////////////////////////////////////////////// // copie une variable dans une autre -void CBotVarString::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarString::Copy(CBotVar* pSrc, bool bName) { CBotVarString* p = (CBotVarString*)pSrc; @@ -1328,7 +1328,7 @@ void CBotVarString::Copy(CBotVar* pSrc, BOOL bName) void CBotVarString::SetValString(const char* p) { m_val = p; - m_binit = TRUE; + m_binit = true; } CBotString CBotVarString::GivValString() @@ -1353,36 +1353,36 @@ CBotString CBotVarString::GivValString() void CBotVarString::Add(CBotVar* left, CBotVar* right) { m_val = left->GivValString() + right->GivValString(); - m_binit = TRUE; + m_binit = true; } -BOOL CBotVarString::Eq(CBotVar* left, CBotVar* right) +bool CBotVarString::Eq(CBotVar* left, CBotVar* right) { return (left->GivValString() == right->GivValString()); } -BOOL CBotVarString::Ne(CBotVar* left, CBotVar* right) +bool CBotVarString::Ne(CBotVar* left, CBotVar* right) { return (left->GivValString() != right->GivValString()); } -BOOL CBotVarString::Lo(CBotVar* left, CBotVar* right) +bool CBotVarString::Lo(CBotVar* left, CBotVar* right) { return (left->GivValString() == right->GivValString()); } -BOOL CBotVarString::Hi(CBotVar* left, CBotVar* right) +bool CBotVarString::Hi(CBotVar* left, CBotVar* right) { return (left->GivValString() == right->GivValString()); } -BOOL CBotVarString::Ls(CBotVar* left, CBotVar* right) +bool CBotVarString::Ls(CBotVar* left, CBotVar* right) { return (left->GivValString() == right->GivValString()); } -BOOL CBotVarString::Hs(CBotVar* left, CBotVar* right) +bool CBotVarString::Hs(CBotVar* left, CBotVar* right) { return (left->GivValString() == right->GivValString()); } @@ -1391,7 +1391,7 @@ BOOL CBotVarString::Hs(CBotVar* left, CBotVar* right) //////////////////////////////////////////////////////////////// // copie une variable dans une autre -void CBotVarClass::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarClass::Copy(CBotVar* pSrc, bool bName) { pSrc = pSrc->GivPointer(); // si source donné par un pointeur @@ -1520,10 +1520,10 @@ CBotClass* CBotVarClass::GivClass() } -void CBotVarClass::Maj(void* pUser, BOOL bContinu) +void CBotVarClass::Maj(void* pUser, bool bContinu) { /* if (!bContinu && m_pMyThis != NULL) - m_pMyThis->Maj(pUser, TRUE);*/ + m_pMyThis->Maj(pUser, true);*/ // une routine de mise à jour existe-elle ? @@ -1569,7 +1569,7 @@ CBotVar* CBotVarClass::GivItemRef(int nIdent) // pour la gestion d'un tableau // bExtend permet d'agrandir le tableau, mais pas au dela de la taille fixée par SetArray() -CBotVar* CBotVarClass::GivItem(int n, BOOL bExtend) +CBotVar* CBotVarClass::GivItem(int n, bool bExtend) { CBotVar* p = m_pVar; @@ -1728,14 +1728,14 @@ CBotVarClass* CBotVarClass::Find(long id) return NULL; } -BOOL CBotVarClass::Eq(CBotVar* left, CBotVar* right) +bool CBotVarClass::Eq(CBotVar* left, CBotVar* right) { CBotVar* l = left->GivItemList(); CBotVar* r = right->GivItemList(); while ( l != NULL && r != NULL ) { - if ( l->Ne(l, r) ) return FALSE; + if ( l->Ne(l, r) ) return false; l = l->GivNext(); r = r->GivNext(); } @@ -1744,14 +1744,14 @@ BOOL CBotVarClass::Eq(CBotVar* left, CBotVar* right) return l == r; } -BOOL CBotVarClass::Ne(CBotVar* left, CBotVar* right) +bool CBotVarClass::Ne(CBotVar* left, CBotVar* right) { CBotVar* l = left->GivItemList(); CBotVar* r = right->GivItemList(); while ( l != NULL && r != NULL ) { - if ( l->Ne(l, r) ) return TRUE; + if ( l->Ne(l, r) ) return true; l = l->GivNext(); r = r->GivNext(); } @@ -1775,7 +1775,7 @@ CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type ) m_type = type; m_type.SetType(CBotTypArrayPointer); - m_binit = FALSE; + m_binit = false; m_pInstance = NULL; // la liste des éléments du tableau } @@ -1786,7 +1786,7 @@ CBotVarArray::~CBotVarArray() } // copie une variable dans une autre -void CBotVarArray::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarArray::Copy(CBotVar* pSrc, bool bName) { if ( pSrc->GivType() != CBotTypArrayPointer ) ASM_TRAP(); @@ -1811,7 +1811,7 @@ void CBotVarArray::Copy(CBotVar* pSrc, BOOL bName) void CBotVarArray::SetPointer(CBotVar* pVarClass) { - m_binit = TRUE; // init, même sur un pointeur null + m_binit = true; // init, même sur un pointeur null if ( m_pInstance == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter // car le décrément peut détruire l'object @@ -1839,7 +1839,7 @@ CBotVarClass* CBotVarArray::GivPointer() return m_pInstance->GivPointer(); } -CBotVar* CBotVarArray::GivItem(int n, BOOL bExtend) +CBotVar* CBotVarArray::GivItem(int n, bool bExtend) { if ( m_pInstance == NULL ) { @@ -1864,9 +1864,9 @@ CBotString CBotVarArray::GivValString() return m_pInstance->GivValString(); } -BOOL CBotVarArray::Save1State(FILE* pf) +bool CBotVarArray::Save1State(FILE* pf) { - if ( !WriteType(pf, m_type) ) return FALSE; + if ( !WriteType(pf, m_type) ) return false; return SaveVar(pf, m_pInstance); // sauve l'instance qui gère le tableau } @@ -1889,7 +1889,7 @@ CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type ) m_type = type; if ( !type.Eq(CBotTypNullPointer) ) m_type.SetType(CBotTypPointer); // quoi qu'il en soit, c'est un pointeur - m_binit = FALSE; + m_binit = false; m_pClass = NULL; m_pVarClass = NULL; // sera défini par un SetPointer() @@ -1902,12 +1902,12 @@ CBotVarPointer::~CBotVarPointer() } -void CBotVarPointer::Maj(void* pUser, BOOL bContinu) +void CBotVarPointer::Maj(void* pUser, bool bContinu) { /* if ( !bContinu && m_pMyThis != NULL ) - m_pMyThis->Maj(pUser, FALSE);*/ + m_pMyThis->Maj(pUser, false);*/ - if ( m_pVarClass != NULL) m_pVarClass->Maj(pUser, FALSE); + if ( m_pVarClass != NULL) m_pVarClass->Maj(pUser, false); } CBotVar* CBotVarPointer::GivItem(const char* name) @@ -1950,7 +1950,7 @@ void CBotVarPointer::ConstructorSet() void CBotVarPointer::SetPointer(CBotVar* pVarClass) { - m_binit = TRUE; // init, même sur un pointeur null + m_binit = true; // init, même sur un pointeur null if ( m_pVarClass == pVarClass) return; // spécial, ne pas décrémenter et réincrémenter // car le décrément peut détruire l'object @@ -2009,25 +2009,25 @@ CBotClass* CBotVarPointer::GivClass() } -BOOL CBotVarPointer::Save1State(FILE* pf) +bool CBotVarPointer::Save1State(FILE* pf) { if ( m_pClass ) { - if (!WriteString(pf, m_pClass->GivName())) return FALSE; // nom de la classe + if (!WriteString(pf, m_pClass->GivName())) return false; // nom de la classe } else { - if (!WriteString(pf, "")) return FALSE; + if (!WriteString(pf, "")) return false; } - if (!WriteLong(pf, GivIdent())) return FALSE; // la référence unique + if (!WriteLong(pf, GivIdent())) return false; // la référence unique // sauve aussi une copie de l'instance return SaveVar(pf, GivPointer()); } // copie une variable dans une autre -void CBotVarPointer::Copy(CBotVar* pSrc, BOOL bName) +void CBotVarPointer::Copy(CBotVar* pSrc, bool bName) { if ( pSrc->GivType() != CBotTypPointer && pSrc->GivType() != CBotTypNullPointer) @@ -2054,26 +2054,26 @@ void CBotVarPointer::Copy(CBotVar* pSrc, BOOL bName) if (m_ident == 0 ) m_ident = p->m_ident; } -BOOL CBotVarPointer::Eq(CBotVar* left, CBotVar* right) +bool CBotVarPointer::Eq(CBotVar* left, CBotVar* right) { CBotVarClass* l = left->GivPointer(); CBotVarClass* r = right->GivPointer(); - if ( l == r ) return TRUE; - if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return TRUE; - if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return TRUE; - return FALSE; + if ( l == r ) return true; + if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return true; + if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return true; + return false; } -BOOL CBotVarPointer::Ne(CBotVar* left, CBotVar* right) +bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right) { CBotVarClass* l = left->GivPointer(); CBotVarClass* r = right->GivPointer(); - if ( l == r ) return FALSE; - if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return FALSE; - if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return FALSE; - return TRUE; + if ( l == r ) return false; + if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return false; + if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return false; + return true; } @@ -2207,9 +2207,9 @@ void CBotTypResult::SetArray( int* max ) -BOOL CBotTypResult::Compare(const CBotTypResult& typ) const +bool CBotTypResult::Compare(const CBotTypResult& typ) const { - if ( m_type != typ.m_type ) return FALSE; + if ( m_type != typ.m_type ) return false; if ( m_type == CBotTypArrayPointer ) return m_pNext->Compare(*typ.m_pNext); @@ -2220,10 +2220,10 @@ BOOL CBotTypResult::Compare(const CBotTypResult& typ) const return m_pClass == typ.m_pClass; } - return TRUE; + return true; } -BOOL CBotTypResult::Eq(int type) const +bool CBotTypResult::Eq(int type) const { return m_type == type; } diff --git a/src/CBot/CBotWhile.cpp b/src/CBot/CBotWhile.cpp index 124fb3d..fcb825c 100644 --- a/src/CBot/CBotWhile.cpp +++ b/src/CBot/CBotWhile.cpp @@ -66,7 +66,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack) // la condition existe IncLvl(inst->m_label); - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); DecLvl(); if ( pStk->IsOk() ) @@ -83,31 +83,31 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack) // exécute une instruction "while" -BOOL CBotWhile :: Execute(CBotStack* &pj) +bool CBotWhile :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; - while( TRUE ) switch( pile->GivState() ) // exécute la boucle + while( true ) switch( pile->GivState() ) // exécute la boucle { // il y a 2 états possibles (selon reprise) case 0: // évalue la condition - if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? + if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ? // le résultat de la condition est sur la pile // termine s'il y a une erreur ou si la condition est fausse - if ( !pile->IsOk() || pile->GivVal() != TRUE ) + if ( !pile->IsOk() || pile->GivVal() != true ) { return pj->Return(pile); // transmet le résultat et libère la pile } // la condition est vrai, passe dans le second mode - if (!pile->SetState(1)) return FALSE; // prêt pour la suite + if (!pile->SetState(1)) return false; // prêt pour la suite case 1: // évalue le bloc d'instruction associé @@ -125,12 +125,12 @@ BOOL CBotWhile :: Execute(CBotStack* &pj) } // repasse au test pour recommencer - if (!pile->SetState(0, 0)) return FALSE; + if (!pile->SetState(0, 0)) return false; continue; } } -void CBotWhile :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile @@ -196,7 +196,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack) { IncLvl(inst->m_label); - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); DecLvl(); if ( pStk->IsOk() ) @@ -221,19 +221,19 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack) // exécute une instruction "repeat" -BOOL CBotRepeat :: Execute(CBotStack* &pj) +bool CBotRepeat :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; - while( TRUE ) switch( pile->GivState() ) // exécute la boucle + while( true ) switch( pile->GivState() ) // exécute la boucle { // il y a 2 états possibles (selon reprise) case 0: // évalue le nombre d'itération - if ( !m_NbIter->Execute(pile) ) return FALSE; // interrompu ici ? + if ( !m_NbIter->Execute(pile) ) return false; // interrompu ici ? // le résultat de la condition est sur la pile @@ -246,7 +246,7 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj) // met le nombre d'itération +1 dans le "state" - if (!pile->SetState(n+1)) return FALSE; // prêt pour la suite + if (!pile->SetState(n+1)) return false; // prêt pour la suite continue; // passe à la suite case 1: @@ -269,12 +269,12 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj) } // repasse au test pour recommencer - if (!pile->SetState(pile->GivState()-1, 0)) return FALSE; + if (!pile->SetState(pile->GivState()-1, 0)) return false; continue; } } -void CBotRepeat :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile @@ -332,7 +332,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack) // cherche un bloc d'instruction après le do IncLvl(inst->m_label); - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); DecLvl(); if ( pStk->IsOk() ) @@ -358,15 +358,15 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack) // exécute une instruction "do" -BOOL CBotDo :: Execute(CBotStack* &pj) +bool CBotDo :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile // ou le retrouve en cas de reprise -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; - while( TRUE ) switch( pile->GivState() ) // exécute la boucle + while( true ) switch( pile->GivState() ) // exécute la boucle { // il y a 2 états possibles (selon reprise) case 0: // évalue le bloc d'instruction associé @@ -383,27 +383,27 @@ BOOL CBotDo :: Execute(CBotStack* &pj) return pj->Return(pile); // transmet le résultat et libère la pile } - if (!pile->SetState(1)) return FALSE; // prêt pour la suite + if (!pile->SetState(1)) return false; // prêt pour la suite case 1: // évalue la condition - if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ? + if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ? // le résultat de la condition est sur la pile // termine s'il y a une erreur ou si la condition est fausse - if ( !pile->IsOk() || pile->GivVal() != TRUE ) + if ( !pile->IsOk() || pile->GivVal() != true ) { return pj->Return(pile); // transmet le résultat et libère la pile } // repasse au bloc d'instruction pour recommencer - if (!pile->SetState(0, 0)) return FALSE; + if (!pile->SetState(0, 0)) return false; continue; } } -void CBotDo :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotDo :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack) return NULL; } - CBotCStack* pStk = pStack->TokenStack(pp, TRUE); // un petit bout de pile svp + CBotCStack* pStk = pStack->TokenStack(pp, true); // un petit bout de pile svp // compile les instructions pour initialisation inst->m_Init = CBotListExpression::Compile( p, pStk ); @@ -494,7 +494,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack) if ( IsOfType(p, ID_CLOSEPAR)) // manque la parenthèse ? { IncLvl(inst->m_label); - inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true ); DecLvl(); if ( pStk->IsOk() ) return pStack->Return(inst, pStk);; @@ -510,39 +510,39 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack) // exécute l'instruction "for" -BOOL CBotFor :: Execute(CBotStack* &pj) +bool CBotFor :: Execute(CBotStack* &pj) { - CBotStack* pile = pj->AddStack(this, TRUE); // ajoute un élément à la pile (variables locales) + CBotStack* pile = pj->AddStack(this, true); // ajoute un élément à la pile (variables locales) // ou le retrouve en cas de reprise -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; - while( TRUE ) switch( pile->GivState() ) // exécute la boucle + while( true ) switch( pile->GivState() ) // exécute la boucle { // il y a 4 états possibles (selon reprise) case 0: // évalue l'initialisation if ( m_Init != NULL && - !m_Init->Execute(pile) ) return FALSE; // interrompu ici ? - if (!pile->SetState(1)) return FALSE; // prêt pour la suite + !m_Init->Execute(pile) ) return false; // interrompu ici ? + if (!pile->SetState(1)) return false; // prêt pour la suite case 1: // évalue la condition if ( m_Test != NULL ) // pas de condition ? -> vrai ! { - if (!m_Test->Execute(pile) ) return FALSE; // interrompu ici ? + if (!m_Test->Execute(pile) ) return false; // interrompu ici ? // le résultat de la condition est sur la pile // termine s'il y a une erreur ou si la condition est fausse - if ( !pile->IsOk() || pile->GivVal() != TRUE ) + if ( !pile->IsOk() || pile->GivVal() != true ) { return pj->Return(pile); // transmet le résultat et libère la pile } } // la condition est vrai, passe à la suite - if (!pile->SetState(2)) return FALSE; // prêt pour la suite + if (!pile->SetState(2)) return false; // prêt pour la suite case 2: // évalue le bloc d'instruction associé @@ -559,20 +559,20 @@ BOOL CBotFor :: Execute(CBotStack* &pj) return pj->Return(pile); // transmet le résultat et libère la pile } - if (!pile->SetState(3)) return FALSE; // prêt pour la suite + if (!pile->SetState(3)) return false; // prêt pour la suite case 3: // évalue l'incrémentation if ( m_Incr != NULL && - !m_Incr->Execute(pile) ) return FALSE; // interrompu ici ? + !m_Incr->Execute(pile) ) return false; // interrompu ici ? // repasse au test pour recommencer - if (!pile->SetState(1, 0)) return FALSE; // revient au test + if (!pile->SetState(1, 0)) return false; // revient au test continue; } } -void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotFor :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -583,28 +583,28 @@ void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain) { // il y a 4 états possibles (selon reprise) case 0: // évalue l'initialisation - if ( m_Init != NULL ) m_Init->RestoreState(pile, TRUE); // interrompu ici ! + if ( m_Init != NULL ) m_Init->RestoreState(pile, true); // interrompu ici ! return; case 1: - if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables + if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables // évalue la condition - if ( m_Test != NULL ) m_Test->RestoreState(pile, TRUE); // interrompu ici ! + if ( m_Test != NULL ) m_Test->RestoreState(pile, true); // interrompu ici ! return; case 2: - if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables + if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables // évalue le bloc d'instruction associé - if ( m_Block != NULL ) m_Block->RestoreState(pile, TRUE); + if ( m_Block != NULL ) m_Block->RestoreState(pile, true); return; case 3: - if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables + if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables // évalue l'incrémentation - if ( m_Incr != NULL ) m_Incr->RestoreState(pile, TRUE); // interrompu ici ! + if ( m_Incr != NULL ) m_Incr->RestoreState(pile, true); // interrompu ici ! return; } } @@ -629,10 +629,10 @@ CBotListExpression::~CBotListExpression() static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack) { - CBotInstr* i = CBotInt::Compile( p, pStack, FALSE, TRUE ); // est-ce une déclaration d'un entier ? - if ( i== NULL ) i = CBotFloat::Compile( p, pStack, FALSE, TRUE ); // ou d'un nombre réel ? - if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, FALSE, TRUE ); // ou d'un booléen ? - if ( i== NULL ) i = CBotIString::Compile( p, pStack, FALSE, TRUE ); // ou d'une chaîne ? + CBotInstr* i = CBotInt::Compile( p, pStack, false, true ); // est-ce une déclaration d'un entier ? + if ( i== NULL ) i = CBotFloat::Compile( p, pStack, false, true ); // ou d'un nombre réel ? + if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, false, true ); // ou d'un booléen ? + if ( i== NULL ) i = CBotIString::Compile( p, pStack, false, true ); // ou d'une chaîne ? if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression return i; } @@ -660,7 +660,7 @@ CBotInstr* CBotListExpression::Compile(CBotToken* &p, CBotCStack* pStack) return NULL; } -BOOL CBotListExpression::Execute(CBotStack* &pj) +bool CBotListExpression::Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack();// indispensable CBotInstr* p = m_Expr; // la première expression @@ -668,17 +668,17 @@ BOOL CBotListExpression::Execute(CBotStack* &pj) int state = pile->GivState(); while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue - if ( p != NULL ) while (TRUE) + if ( p != NULL ) while (true) { - if ( !p->Execute(pile) ) return FALSE; + if ( !p->Execute(pile) ) return false; p = p->GivNext(); if ( p == NULL ) break; - if (!pile->IncState()) return FALSE; // prêt pour la suivante + if (!pile->IncState()) return false; // prêt pour la suivante } return pj->Return(pile); } -void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain) { CBotStack* pile = pj; int state = 0x7000; @@ -694,7 +694,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain) while (p != NULL && state-->0) { - p->RestoreState(pile, FALSE); + p->RestoreState(pile, false); p = p->GivNext(); // revient sur l'opération interrompue } @@ -770,7 +770,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(NULL, pStk); } - CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); + CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, true ); if ( !pStk->IsOk() ) { delete inst; @@ -811,21 +811,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack) // exécute une instruction "switch" -BOOL CBotSwitch :: Execute(CBotStack* &pj) +bool CBotSwitch :: Execute(CBotStack* &pj) { CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile -// if ( pile1 == EOX ) return TRUE; +// if ( pile1 == EOX ) return true; CBotInstr* p = m_Block; // la première expression int state = pile1->GivState(); if (state == 0) { - if ( !m_Value->Execute(pile1) ) return FALSE; + if ( !m_Value->Execute(pile1) ) return false; pile1->SetState(state = -1); } - if ( pile1->IfStep() ) return FALSE; + if ( pile1->IfStep() ) return false; if ( state == -1 ) { @@ -843,7 +843,7 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj) if ( p == NULL ) return pj->Return(pile1); // terminé si plus rien - if ( !pile1->SetState(state) ) return FALSE; + if ( !pile1->SetState(state) ) return false; } p = m_Block; // revient au début @@ -852,13 +852,13 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj) while( p != NULL ) { if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1); - if ( !pile1->IncState() ) return FALSE; + if ( !pile1->IncState() ) return false; p = p->GivNext(); } return pj->Return(pile1); } -void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -882,13 +882,13 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain) // p = m_Block; // revient au début while ( p != NULL && state-- > 0 ) { - p->RestoreState(pile1, FALSE); + p->RestoreState(pile1, false); p = p->GivNext(); // avance dans la liste } if( p != NULL ) { - p->RestoreState(pile1, TRUE); + p->RestoreState(pile1, true); return; } } @@ -942,21 +942,21 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack) // exécution de l'instruction "case" -BOOL CBotCase::Execute(CBotStack* &pj) +bool CBotCase::Execute(CBotStack* &pj) { - return TRUE; // l'instruction "case" ne fait rien ! + return true; // l'instruction "case" ne fait rien ! } -void CBotCase::RestoreState(CBotStack* &pj, BOOL bMain) +void CBotCase::RestoreState(CBotStack* &pj, bool bMain) { } // routine permettant de trouver le point d'entrée "case" // correspondant à la valeur cherchée -BOOL CBotCase::CompCase(CBotStack* &pile, int val) +bool CBotCase::CompCase(CBotStack* &pile, int val) { - if ( m_Value == NULL ) return TRUE; // cas pour "default" + if ( m_Value == NULL ) return true; // cas pour "default" while (!m_Value->Execute(pile)); // met sur la pile la valeur correpondant (sans interruption) return (pile->GivVal() == val); // compare avec la valeur cherchée @@ -1016,18 +1016,18 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack) // exécution l'instructino "break" ou "continu" -BOOL CBotBreak :: Execute(CBotStack* &pj) +bool CBotBreak :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label); return pj->Return(pile); } -void CBotBreak :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain) { if ( bMain ) pj->RestoreStack(this); } @@ -1092,14 +1092,14 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack) // les arrêts par suspension // et les "finaly" -BOOL CBotTry :: Execute(CBotStack* &pj) +bool CBotTry :: Execute(CBotStack* &pj) { int val; CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile -// if ( pile1 == EOX ) return TRUE; +// if ( pile1 == EOX ) return true; - if ( pile1->IfStep() ) return FALSE; + if ( pile1->IfStep() ) return false; // ou le retrouve en cas de reprise CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire CBotStack* pile2 = pile0->AddStack(); @@ -1114,14 +1114,14 @@ BOOL CBotTry :: Execute(CBotStack* &pj) val = pile1->GivError(); if ( val == 0 && CBotStack::m_initimer == 0 ) // en mode de step ? - return FALSE; // ne fait pas le catch + return false; // ne fait pas le catch pile1->IncState(); pile2->SetState(val); // mémorise le numéro de l'erreur pile1->SetError(0); // pour l'instant il n'y a plus d'erreur ! if ( val == 0 && CBotStack::m_initimer < 0 ) // en mode de step ? - return FALSE; // ne fait pas le catch + return false; // ne fait pas le catch } // il y a eu une interruption @@ -1137,16 +1137,16 @@ BOOL CBotTry :: Execute(CBotStack* &pj) if ( --state <= 0 ) { // demande au bloc catch s'il se sent concerné - if ( !pc->TestCatch(pile2, val) ) return FALSE; // suspendu ! + if ( !pc->TestCatch(pile2, val) ) return false; // suspendu ! pile1->IncState(); } if ( --state <= 0 ) { - if ( pile2->GivVal() == TRUE ) + if ( pile2->GivVal() == true ) { // pile0->SetState(1); - if ( !pc->Execute(pile2) ) return FALSE; // exécute l'opération + if ( !pc->Execute(pile2) ) return false; // exécute l'opération if ( m_FinalInst == NULL ) return pj->Return(pile2); // termine le try @@ -1164,7 +1164,7 @@ BOOL CBotTry :: Execute(CBotStack* &pj) { // pile0->SetState(1); - if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return FALSE; + if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false; if (!pile2->IsOk()) return pj->Return(pile2); // garde cette exception pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale return pj->Return(pile2); @@ -1176,11 +1176,11 @@ BOOL CBotTry :: Execute(CBotStack* &pj) return pj->Return(pile2); // termine le try sans exception aucune pile1->SetError(val); // remet l'erreur - return FALSE; // ce n'est pas pour nous + return false; // ce n'est pas pour nous } -void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotTry :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -1217,7 +1217,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain) } if ( --state <= 0 ) { - if ( pile2->GivVal() == TRUE ) + if ( pile2->GivVal() == true ) { pc->RestoreState(pile2, bMain); // exécute l'opération return; @@ -1285,27 +1285,27 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack) // exécution de "catch" -BOOL CBotCatch :: Execute(CBotStack* &pj) +bool CBotCatch :: Execute(CBotStack* &pj) { - if ( m_Block == NULL ) return TRUE; + if ( m_Block == NULL ) return true; return m_Block->Execute(pj); // exécute le bloc associé } -void CBotCatch :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotCatch :: RestoreState(CBotStack* &pj, bool bMain) { if ( bMain && m_Block != NULL ) m_Block->RestoreState(pj, bMain); } -void CBotCatch :: RestoreCondState(CBotStack* &pj, BOOL bMain) +void CBotCatch :: RestoreCondState(CBotStack* &pj, bool bMain) { m_Cond->RestoreState(pj, bMain); } // routine pour savoir si le catch est à faire ou non -BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val) +bool CBotCatch :: TestCatch(CBotStack* &pile, int val) { - if ( !m_Cond->Execute(pile) ) return FALSE; + if ( !m_Cond->Execute(pile) ) return false; if ( val > 0 || pile->GivType() != CBotTypBoolean ) { @@ -1314,7 +1314,7 @@ BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val) pile->SetVar(var); // remet sur la pile } - return TRUE; + return true; } /////////////////////////////////////////////////////////////////////////// @@ -1359,18 +1359,18 @@ CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack) // exécute l'instruction "throw" -BOOL CBotThrow :: Execute(CBotStack* &pj) +bool CBotThrow :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); -// if ( pile == EOX ) return TRUE; +// if ( pile == EOX ) return true; if ( pile->GivState() == 0 ) { - if ( !m_Value->Execute(pile) ) return FALSE; + if ( !m_Value->Execute(pile) ) return false; pile->IncState(); } - if ( pile->IfStep() ) return FALSE; + if ( pile->IfStep() ) return false; int val = pile->GivVal(); if ( val < 0 ) val = TX_BADTHROW; @@ -1378,7 +1378,7 @@ BOOL CBotThrow :: Execute(CBotStack* &pj) return pj->Return( pile ); } -void CBotThrow :: RestoreState(CBotStack* &pj, BOOL bMain) +void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; @@ -1417,11 +1417,11 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack) // exécute l'instruction "throw" -BOOL CBotStartDebugDD :: Execute(CBotStack* &pj) +bool CBotStartDebugDD :: Execute(CBotStack* &pj) { CBotProgram* p = pj->GivBotCall(); - p->m_bDebugDD = TRUE; + p->m_bDebugDD = true; - return TRUE; + return true; } diff --git a/src/CBot/ClassFILE.cpp b/src/CBot/ClassFILE.cpp index e4dd578..330e814 100644 --- a/src/CBot/ClassFILE.cpp +++ b/src/CBot/ClassFILE.cpp @@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD! // reçois le nom du fichier en paramètre // exécution -BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { CBotString mode; @@ -132,7 +132,7 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar) // destructeur de la classe // exécution -BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // récupère l'élément "handle" pVar = pThis->GivItem("handle"); @@ -154,7 +154,7 @@ BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception // reçois le mode r/w en paramètre // exécution -BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // il doit y avoir un paramètre if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } @@ -243,7 +243,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar) // méthode FILE :: close // exécution -BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // il ne doit pas y avoir de paramètre if ( pVar != NULL ) return CBotErrOverParam; @@ -275,7 +275,7 @@ CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar) // méthode FILE :: writeln // exécution -BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // il doit y avoir un paramètre if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } @@ -319,7 +319,7 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar) // méthode FILE :: readln // exécution -BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // il ne doit pas y avoir de paramètre if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } @@ -360,7 +360,7 @@ CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar) // exécution -BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) +bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) { // il ne doit pas y avoir de paramètre if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } diff --git a/src/CBot/StringFunctions.cpp b/src/CBot/StringFunctions.cpp index 2c3cfc2..27332db 100644 --- a/src/CBot/StringFunctions.cpp +++ b/src/CBot/StringFunctions.cpp @@ -18,23 +18,23 @@ // donne la longueur d'une chaîne // exécution -BOOL rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // pas de second paramètre - if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // met la longueur sur la pile pResult->SetValInt( s.GivLength() ); - return TRUE; + return true; } // int xxx ( string ) @@ -60,36 +60,36 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser ) // donne la partie gauche d'une chaîne // exécution -BOOL rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // il faut un second paramètre pVar = pVar->GivNext(); - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être un nombre - if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } + if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; } // récupère ce nombre int n = pVar->GivValInt(); // pas de 3e paramètre - if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; } // prend la partie intéressante s = s.Left( n ); // la met sur la pile pResult->SetValString( s ); - return TRUE; + return true; } // string xxx ( string, int ) @@ -122,58 +122,58 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser ) // donne la partie droite d'une chaîne // exécution -BOOL rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // il faut un second paramètre pVar = pVar->GivNext(); - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être un nombre - if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } + if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; } // récupère ce nombre int n = pVar->GivValInt(); // pas de 3e paramètre - if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; } // prend la partie intéressante s = s.Right( n ); // la met sur la pile pResult->SetValString( s ); - return TRUE; + return true; } // donne la partie centrale d'une chaîne // exécution -BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // il faut un second paramètre pVar = pVar->GivNext(); - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être un nombre - if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } + if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; } // récupère ce nombre int n = pVar->GivValInt(); @@ -184,13 +184,13 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) pVar = pVar->GivNext(); // qui doit être un nombre - if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; } + if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; } // récupère ce nombre int l = pVar->GivValInt(); // mais pas de 4e paramètre - if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; } // prend la partie intéressante s = s.Mid( n, l ); @@ -203,7 +203,7 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) // la met sur la pile pResult->SetValString( s ); - return TRUE; + return true; } // donne la partie centrale d'une chaîne @@ -247,25 +247,25 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser ) // donne le nombre contenu dans une chaîne // exécution -BOOL rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // mais pas de 2e paramètre - if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; } float val = GivNumFloat(s); // la met la valeur sur la pile pResult->SetValFloat( val ); - return TRUE; + return true; } // float xxx ( string ) @@ -291,35 +291,35 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser ) // trouve une chaine dans une autre // exécution -BOOL rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // il faut un second paramètre pVar = pVar->GivNext(); - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // récupère ce nombre CBotString s2 = pVar->GivValString(); // pas de 3e paramètre - if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; } // met le résultat sur la pile int res = s.Find(s2); pResult->SetValInt( res ); if ( res < 0 ) pResult->SetInit( IS_NAN ); - return TRUE; + return true; } // int xxx ( string, string ) @@ -352,51 +352,51 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser ) // donne une chaine en majuscule // exécution -BOOL rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // mais pas de 2e paramètre - if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; } s.MakeUpper(); // la met la valeur sur la pile pResult->SetValString( s ); - return TRUE; + return true; } // donne une chaine en minuscules // exécution -BOOL rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) +bool rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { // il faut un paramètre - if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } + if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; } // qui doit être une string - if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; } + if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; } // recupére le contenu de la string CBotString s = pVar->GivValString(); // mais pas de 2e paramètre - if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; } + if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; } s.MakeLower(); // la met la valeur sur la pile pResult->SetValString( s ); - return TRUE; + return true; } // string xxx ( string ) diff --git a/src/CBot/old b/src/CBot/old deleted file mode 100644 index ea18736..0000000 --- a/src/CBot/old +++ /dev/null @@ -1,15 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * -// * This program is free software: you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1be7a59..250120c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ # CBot shared library is built separately -# add_subdirectory(CBot) -- not yet WinAPI-independent +add_subdirectory(CBot) # Configure options @@ -25,6 +25,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h # Source files # Commented out files are still dependent on DirectX or WinAPI + set(SOURCES app/app.cpp app/main.cpp @@ -150,7 +151,7 @@ set(LIBS ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${OPENGL_LIBRARY} -#CBot -- not yet WinAPI-independent +CBot ) include_directories(. ${CMAKE_CURRENT_BINARY_DIR}) -- cgit v1.2.3-1-g7c22