Merge branch 'dev' into dev-opengl

Pulled changes & resolved conflicts
dev-ui
Piotr Dziwinski 2012-07-27 18:09:50 +02:00
commit ab8e55a651
26 changed files with 7486 additions and 7835 deletions

View File

@ -16,8 +16,8 @@ find_package(PNG REQUIRED)
set(CMAKE_BUILD_TYPE debug) set(CMAKE_BUILD_TYPE debug)
# Global compile flags # Global compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-O2") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -std=gnu++0x")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -std=gnu++0x")
# Subdirectory with sources # Subdirectory with sources
add_subdirectory(src bin) add_subdirectory(src bin)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,279 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// French (France) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
ID_IF "if"
ID_ELSE "else"
ID_WHILE "while"
ID_DO "do"
ID_FOR "for"
ID_BREAK "break"
ID_CONTINUE "continue"
ID_SWITCH "switch"
ID_CASE "case"
ID_DEFAULT "default"
ID_TRY "try"
ID_THROW "throw"
ID_CATCH "catch"
ID_FINALLY "finally"
ID_TXT_AND "and"
ID_TXT_OR "or"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_DEBUGDD "STARTDEBUGDD"
ID_INT "int"
ID_FLOAT "float"
ID_BOOLEAN "boolean"
ID_STRING "string"
ID_VOID "void"
ID_BOOL "bool"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_TXT_NOT "not"
ID_RETURN "return"
ID_CLASS "class"
ID_EXTENDS "extends"
ID_SYNCHO "synchronized"
ID_NEW "new"
ID_PUBLIC "public"
ID_EXTERN "extern"
ID_FINAL "final"
ID_STATIC "static"
ID_PROTECTED "protected"
ID_PRIVATE "private"
ID_REPEAT "repeat"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_OPENPAR "Il manque une parenthèse ouvrante."
TX_CLOSEPAR "Il manque une parenthèse fermante."
TX_NOTBOOL "L'expression doit être un boolean."
TX_UNDEFVAR "Variable non déclarée."
TX_BADLEFT "Assignation impossible."
TX_ENDOF "Terminateur point-virgule non trouvé."
TX_OUTCASE "Instruction ""case"" hors d'un bloc ""switch""."
TX_NOTERM "Instructions après la fin."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_CLOSEBLK "Il manque la fin du bloc."
TX_ELSEWITHOUTIF "Instruction ""else"" sans ""if"" correspondant."
TX_OPENBLK "Début d'un bloc attendu."
TX_BADTYPE "Mauvais type de résultat pour l'assignation."
TX_REDEFVAR "Redéfinition d'une variable."
TX_BAD2TYPE "Les deux opérandes ne sont pas de types compatibles."
TX_UNDEFCALL "Routine inconnue."
TX_MISDOTS "Séparateur "" : "" attendu."
TX_WHILE "Manque le mot ""while""."
TX_BREAK "Instruction ""break"" en dehors d'une boucle."
TX_LABEL "Un label ne peut se placer que devant un ""for"", un ""while"" ou un ""do""."
TX_NOLABEL "Cette étiquette n'existe pas"
TX_NOCASE "Manque une instruction ""case""."
TX_BADNUM "Un nombre est attendu."
TX_VOID "Paramètre void."
TX_NOTYP "Déclaration de type attendu."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_DIVZERO "Division par zéro."
TX_NOTINIT "Variable non initialisée."
TX_BADTHROW "Valeur négative refusée pour ""throw""."
TX_NORETVAL "La fonction n'a pas retourné de résultat"
TX_NORUN "Pas de fonction en exécution"
TX_NOCALL "Appel d'une fonction inexistante"
TX_NOCLASS "Cette classe n'existe pas"
TX_NULLPT "Pointeur nul."
TX_OPNAN "Opération sur un ""nan"""
TX_OUTARRAY "Accès hors du tableau"
TX_STACKOVER "Dépassement de la pile"
TX_DELETEDPT "Pointeur à un objet détruit"
TX_FILEOPEN "Ouverture du fichier impossible"
TX_NOTOPEN "Fichier pas ouvert"
TX_ERRREAD "Erreur de lecture"
TX_ERRWRITE "Erreur d'écriture"
END
STRINGTABLE DISCARDABLE
BEGIN
TX_NOVAR "Nom d'une variable attendu."
TX_NOFONC "Nom de la fonction attendu."
TX_OVERPARAM "Trop de paramètres."
TX_REDEF "Cette fonction existe déjà."
TX_LOWPARAM "Pas assez de paramètres."
TX_BADPARAM "Aucune fonction de ce nom n'accepte ce(s) type(s) de paramètre(s)."
TX_NUMPARAM "Aucune fonction de ce nom n'accepte ce nombre de paramètres."
TX_NOITEM "Cet élément n'existe pas dans cette classe."
TX_DOT "L'objet n'est pas une instance d'une classe."
TX_NOCONST "Il n'y a pas de constructeur approprié."
TX_REDEFCLASS "Cette classe existe déjà."
TX_CLBRK """ ] "" attendu."
TX_RESERVED "Ce mot est réservé."
TX_BADNEW "Mauvais argument pour ""new""."
TX_OPBRK """ [ "" attendu."
TX_BADSTRING "Une chaîne de caractère est attendue."
END
STRINGTABLE DISCARDABLE
BEGIN
TX_BADINDEX "Mauvais type d'index"
TX_PRIVATE "Membre privé de la classe"
TX_NOPUBLIC """public"" manque"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_OPENPAR "("
ID_CLOSEPAR ")"
ID_OPBLK "{"
ID_CLBLK "}"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_SEP ";"
ID_COMMA ","
ID_DOTS ":"
ID_DOT "."
ID_OPBRK "["
ID_CLBRK "]"
ID_DBLDOTS "::"
ID_LOGIC "?"
ID_ADD "+"
ID_SUB "-"
ID_MUL "*"
ID_DIV "/"
ID_ASS "="
ID_ASSADD "+="
ID_ASSSUB "-="
ID_ASSMUL "*="
END
STRINGTABLE DISCARDABLE
BEGIN
ID_TRUE "true"
ID_FALSE "false"
ID_NULL "null"
ID_NAN "nan"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_ASSDIV "/="
ID_ASSOR "|="
ID_ASSAND "&="
ID_ASSXOR "^="
ID_ASSSL "<<="
ID_ASSSR ">>>="
ID_ASSASR ">>="
ID_SL "<<"
ID_SR ">>>"
ID_ASR ">>"
ID_INC "++"
ID_DEC "--"
ID_LO "<"
ID_HI ">"
ID_LS "<="
ID_HS ">="
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EQ "=="
ID_NE "!="
ID_AND "&"
ID_XOR "^"
ID_OR "|"
ID_LOG_AND "&&"
ID_LOG_OR "||"
ID_LOG_NOT "!"
ID_NOT "~"
ID_MODULO "%"
ID_POWER "**"
ID_ASSMODULO "%="
END
STRINGTABLE DISCARDABLE
BEGIN
TX_UNDEF "undefined"
TX_NAN "not a number"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_SUPER "super"
END
#endif // French (France) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -93,7 +93,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack)
// fait l'opération d'addition ou de soustraction // 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 CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise

View File

@ -21,7 +21,7 @@
CBotClass* CBotClass::m_ExClass = NULL; 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_pParent = pPapa;
m_name = name; m_name = name;
@ -30,7 +30,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic)
m_pCalls = NULL; m_pCalls = NULL;
m_pMethod = NULL; m_pMethod = NULL;
m_rMaj = NULL; m_rMaj = NULL;
m_IsDef = TRUE; m_IsDef = true;
m_bIntrinsic= bIntrinsic; m_bIntrinsic= bIntrinsic;
m_cptLock = 0; m_cptLock = 0;
m_cptOne = 0; m_cptOne = 0;
@ -86,7 +86,7 @@ void CBotClass::Purge()
m_pCalls = NULL; m_pCalls = NULL;
delete m_pMethod; delete m_pMethod;
m_pMethod = NULL; m_pMethod = NULL;
m_IsDef = FALSE; m_IsDef = false;
m_nbVar = m_pParent == NULL ? 0 : m_pParent->m_nbVar; 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 m_next = NULL; // n'appartient plus à cette chaîne
} }
BOOL CBotClass::Lock(CBotProgram* p) bool CBotClass::Lock(CBotProgram* p)
{ {
int i = m_cptLock++; int i = m_cptLock++;
@ -102,13 +102,13 @@ BOOL CBotClass::Lock(CBotProgram* p)
{ {
m_cptOne = 1; m_cptOne = 1;
m_ProgInLock[0] = p; m_ProgInLock[0] = p;
return TRUE; return true;
} }
if ( p == m_ProgInLock[0] ) if ( p == m_ProgInLock[0] )
{ {
m_cptOne++; m_cptOne++;
m_cptLock--; // a déjà été compté m_cptLock--; // a déjà été compté
return TRUE; return true;
} }
for ( int j = 1 ; j <= i ; j++) for ( int j = 1 ; j <= i ; j++)
@ -116,7 +116,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
if ( p == m_ProgInLock[j] ) if ( p == m_ProgInLock[j] )
{ {
m_cptLock--; m_cptLock--;
return FALSE; // déjà en attente return false; // déjà en attente
} }
} }
@ -127,7 +127,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
else else
m_cptLock--; m_cptLock--;
return FALSE; return false;
} }
void CBotClass::Unlock() 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()); CBotToken token(name, CBotString());
CBotClass* pClass = type.GivClass(); 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); pVar->SetUniqNum(++m_nbVar);
if ( m_pVar == NULL ) m_pVar = pVar; if ( m_pVar == NULL ) m_pVar = pVar;
else m_pVar->AddNext(pVar); else m_pVar->AddNext(pVar);
return TRUE; return true;
} }
void CBotClass::AddNext(CBotClass* pClass) void CBotClass::AddNext(CBotClass* pClass)
@ -223,15 +223,15 @@ CBotClass* CBotClass::GivParent()
return m_pParent; return m_pParent;
} }
BOOL CBotClass::IsChildOf(CBotClass* pClass) bool CBotClass::IsChildOf(CBotClass* pClass)
{ {
CBotClass* p = this; CBotClass* p = this;
while ( p != NULL ) while ( p != NULL )
{ {
if ( p == pClass ) return TRUE; if ( p == pClass ) return true;
p = p->m_pParent; p = p->m_pParent;
} }
return FALSE; return false;
} }
@ -266,7 +266,7 @@ CBotVar* CBotClass::GivItemRef(int nIdent)
return NULL; return NULL;
} }
BOOL CBotClass::IsIntrinsic() bool CBotClass::IsIntrinsic()
{ {
return m_bIntrinsic; return m_bIntrinsic;
} }
@ -289,8 +289,8 @@ CBotClass* CBotClass::Find(const char* name)
return NULL; return NULL;
} }
BOOL CBotClass::AddFunction(const char* name, bool CBotClass::AddFunction(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)) CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
{ {
// mémorise les pointeurs aux deux fonctions // mémorise les pointeurs aux deux fonctions
@ -315,13 +315,13 @@ BOOL CBotClass::AddFunction(const char* name,
if (m_pCalls == NULL) m_pCalls = p; if (m_pCalls == NULL) m_pCalls = p;
else m_pCalls->AddNext(p); // ajoute à la liste 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; m_rMaj = rMaj;
return TRUE; return true;
} }
// compile une méthode associée à une instance de classe // 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 // 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* pThis, CBotVar** ppParams,
CBotVar* &pResult, CBotStack* &pStack, CBotVar* &pResult, CBotStack* &pStack,
CBotToken* pToken) 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 // sauve l'état des variables statiques dans les classes
CBotClass* p = m_ExClass; CBotClass* p = m_ExClass;
while ( p != NULL ) while ( p != NULL )
{ {
if (!WriteWord( pf, 1)) return FALSE; if (!WriteWord( pf, 1)) return false;
// enregistre le nom de la classe // enregistre le nom de la classe
if (!WriteString( pf, p->GivName() )) return FALSE; if (!WriteString( pf, p->GivName() )) return false;
CBotVar* pv = p->GivVar(); CBotVar* pv = p->GivVar();
while( pv != NULL ) while( pv != NULL )
{ {
if ( pv->IsStatic() ) if ( pv->IsStatic() )
{ {
if (!WriteWord( pf, 1)) return FALSE; if (!WriteWord( pf, 1)) return false;
if (!WriteString( pf, pv->GivName() )) return FALSE; if (!WriteString( pf, pv->GivName() )) return false;
if ( !pv->Save0State(pf)) return FALSE; // entête commune if ( !pv->Save0State(pf)) return false; // entête commune
if ( !pv->Save1State(pf) ) return FALSE; // sauve selon la classe fille if ( !pv->Save1State(pf) ) return false; // sauve selon la classe fille
if ( !WriteWord( pf, 0)) return FALSE; if ( !WriteWord( pf, 0)) return false;
} }
pv = pv->GivNext(); pv = pv->GivNext();
} }
if (!WriteWord( pf, 0)) return FALSE; if (!WriteWord( pf, 0)) return false;
p = p->m_ExNext; p = p->m_ExNext;
} }
if (!WriteWord( pf, 0)) return FALSE; if (!WriteWord( pf, 0)) return false;
return TRUE; return true;
} }
BOOL CBotClass::RestoreStaticState(FILE* pf) bool CBotClass::RestoreStaticState(FILE* pf)
{ {
CBotString ClassName, VarName; CBotString ClassName, VarName;
CBotClass* pClass; CBotClass* pClass;
WORD w; unsigned short w;
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w != CBOTVERSION*2 ) return FALSE; if ( w != CBOTVERSION*2 ) return false;
while (TRUE) while (true)
{ {
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
if (!ReadString( pf, ClassName )) return FALSE; if (!ReadString( pf, ClassName )) return false;
pClass = Find(ClassName); pClass = Find(ClassName);
while (TRUE) while (true)
{ {
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) break; if ( w == 0 ) break;
CBotVar* pVar = NULL; CBotVar* pVar = NULL;
CBotVar* pv = NULL; CBotVar* pv = NULL;
if (!ReadString( pf, VarName )) return FALSE; if (!ReadString( pf, VarName )) return false;
if ( pClass != NULL ) pVar = pClass->GivItem(VarName); 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); if ( pVar != NULL ) pVar->Copy(pv);
delete pv; delete pv;
} }
} }
return TRUE; return true;
} }
@ -453,7 +453,7 @@ CBotClassInst::CBotClassInst()
m_var = NULL; m_var = NULL;
m_Parameters = NULL; m_Parameters = NULL;
m_expr = NULL; m_expr = NULL;
m_hasParams = FALSE; m_hasParams = false;
m_nMethodeIdent = 0; m_nMethodeIdent = 0;
name = "CBotClassInst"; name = "CBotClassInst";
} }
@ -484,18 +484,17 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
p = p->GivNext(); p = p->GivNext();
} }
BOOL bIntrinsic = pClass->IsIntrinsic(); bool bIntrinsic = pClass->IsIntrinsic();
CBotTypResult CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass );
type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer,
pClass );
CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type); CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type);
if ( inst != NULL || !pStack->IsOk() ) return inst; if ( inst != NULL || !pStack->IsOk() ) return inst;
CBotCStack* pStk = pStack->TokenStack(); CBotCStack* pStk = pStack->TokenStack();
inst = new CBotClassInst(); inst = new CBotClassInst();
/// \TODO Need to be revised and fixed after adding unit tests
inst->SetToken(&pClass->GivName(), p->GivStart(), p->GivEnd()); CBotToken token(pClass->GivName(), CBotString(), p->GivStart(), p->GivEnd());
inst->SetToken(&token);
CBotToken* vartoken = p; CBotToken* vartoken = p;
if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) ) 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 var->SetPointer( pvar ); // var déjà déclarée pointe l'instance
delete pvar; // supprime le second pointeur 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) else if (inst->m_hasParams)
{ {
@ -640,17 +639,17 @@ error:
// déclaration de l'instance d'une classe, par exemple: // déclaration de l'instance d'une classe, par exemple:
// CPoint A, B; // CPoint A, B;
BOOL CBotClassInst::Execute(CBotStack* &pj) bool CBotClassInst::Execute(CBotStack* &pj)
{ {
CBotVar* pThis = NULL; CBotVar* pThis = NULL;
CBotStack* pile = pj->AddStack(this);//indispensable pour SetState() CBotStack* pile = pj->AddStack(this);//indispensable pour SetState()
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
CBotToken* pt = &m_token; CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt); CBotClass* pClass = CBotClass::Find(pt);
BOOL bIntrincic = pClass->IsIntrinsic(); bool bIntrincic = pClass->IsIntrinsic();
// crée la variable de type pointeur à l'objet // crée la variable de type pointeur à l'objet
@ -682,7 +681,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
if ( m_expr != NULL ) if ( m_expr != NULL )
{ {
// évalue l'expression pour l'assignation // évalue l'expression pour l'assignation
if (!m_expr->Execute(pile)) return FALSE; if (!m_expr->Execute(pile)) return false;
if ( bIntrincic ) if ( bIntrincic )
{ {
@ -692,7 +691,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
pile->SetError(TX_NULLPT, &m_token); pile->SetError(TX_NULLPT, &m_token);
return pj->Return(pile); return pj->Return(pile);
} }
pThis->Copy(pile->GivVar(), FALSE); pThis->Copy(pile->GivVar(), false);
} }
else else
{ {
@ -700,7 +699,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation
pThis->SetPointer(pInstance); pThis->SetPointer(pInstance);
} }
pThis->SetInit(TRUE); pThis->SetInit(true);
} }
else if ( m_hasParams ) else if ( m_hasParams )
@ -732,12 +731,12 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // 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 pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats
if ( pile2->GivState() == 0 ) if ( pile2->GivState() == 0 )
{ {
if (!p->Execute(pile2)) return FALSE; // interrompu ici ? if (!p->Execute(pile2)) return false; // interrompu ici ?
pile2->SetState(1); pile2->SetState(1);
} }
ppVars[i++] = pile2->GivVar(); ppVars[i++] = pile2->GivVar();
@ -751,9 +750,9 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(), if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(),
pThis, ppVars, 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é pThis->ConstructorSet(); // signale que le constructeur a été appelé
pile->Return(pile2); // libère un bout de pile pile->Return(pile2); // libère un bout de pile
@ -766,17 +765,17 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
pile->SetState(3); // fini cette partie pile->SetState(3); // fini cette partie
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
if ( m_next2b != NULL && 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 return pj->Return( pile ); // transmet en dessous
} }
void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain) void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
{ {
CBotVar* pThis = NULL; CBotVar* pThis = NULL;
@ -793,7 +792,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
CBotToken* pt = &m_token; CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt); CBotClass* pClass = CBotClass::Find(pt);
BOOL bIntrincic = pClass->IsIntrinsic(); bool bIntrincic = pClass->IsIntrinsic();
if ( bMain && pile->GivState()<3) if ( bMain && pile->GivState()<3)
{ {
@ -827,7 +826,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // 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 pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats
if ( pile2 == NULL ) return; 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 // 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(); CBotString name = pToken->GivString();
if ( CBotCall::CheckCall(name) ) return TRUE; if ( CBotCall::CheckCall(name) ) return true;
CBotFunction* pp = m_pMethod; CBotFunction* pp = m_pMethod;
while ( pp != NULL ) while ( pp != NULL )
@ -871,11 +870,11 @@ BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{ {
// les paramètres sont-ils exactement les mêmes ? // les paramètres sont-ils exactement les mêmes ?
if ( pp->CheckParam( pParam ) ) if ( pp->CheckParam( pParam ) )
return TRUE; return true;
} }
pp = pp->Next(); pp = pp->Next();
} }
return FALSE; return false;
} }

View File

@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack)
// fait l'opération // fait l'opération
BOOL CBotCompExpr::Execute(CBotStack* &pStack) bool CBotCompExpr::Execute(CBotStack* &pStack)
{ {
CBotStack* pStk1 = pStack->AddStack(this); CBotStack* pStk1 = pStack->AddStack(this);
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return TRUE;

View File

@ -13,76 +13,130 @@
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.//////////////////////////////////////////////////////////////////////// // * along with this program. If not, see http://www.gnu.org/licenses/.////////////////////////////////////////////////////////////////////////
// Librairie pour l'interprétation du language CBOT #ifndef _CBOTDLL_H_
// pour le jeu COLOBOT #define _CBOTDLL_H_
// /**
* \file CBotDll.h
* \brief Library for interpretation of CBOT language
*/
//#include "stdafx.h"
#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include "resource.h"
#include <map>
#include <cstring>
#define DllExport __declspec( dllexport )
#define CBOTVERSION 104 #define CBOTVERSION 104
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// quelques classes définies par ailleurs // forward declaration of needed classes
class CBotToken; // programme transformé en "jetons" class CBotToken; // program turned into "tokens
class CBotStack; // pile pour l'exécution class CBotStack; // for the execution stack
class CBotClass; // classe d'object class CBotClass; // class of object
class CBotInstr; // instruction à exécuter class CBotInstr; // instruction to be executed
class CBotFunction; // les fonctions user class CBotFunction; // user functions
class CBotVar; // les variables class CBotVar; // variables
class CBotVarClass; // une instance de classe class CBotVarClass; // instance of class
class CBotVarPointer; // pointeur à une instance de classe class CBotVarPointer; // pointer to an instance of class
class CBotCall; // les fonctions class CBotCall; // fonctions
class CBotCallMethode; // les méthodes class CBotCallMethode; // methods
class CBotDefParam; // liste de paramètres class CBotDefParam; // parameter list
class CBotCStack; class CBotCStack; // stack
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Gestion des variables // Variables management
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// ces types sont calqués sur les types Java /** \brief CBotType Defines known types. This types are modeled on Java types. Do not change the order of elements */
// ne pas changer l'ordre de ces types
enum CBotType enum CBotType
{ {
CBotTypVoid = 0, // fonction retournant void CBotTypVoid = 0,
CBotTypByte = 1, //n // nombre entier ( 8 bits) CBotTypByte = 1, //n
CBotTypShort = 2, //n // nombre entier (16 bits) CBotTypShort = 2, //n
CBotTypChar = 3, //n // caractère "unicode" (16 bits) CBotTypChar = 3, //n
CBotTypInt = 4, // nombre entier (32 bits) CBotTypInt = 4,
CBotTypLong = 5, //n // nombre entier (64 bits) CBotTypLong = 5, //n
CBotTypFloat = 6, // nombre décimal (32 bits) CBotTypFloat = 6,
CBotTypDouble = 7, //n // nombre décimal (64 bits) CBotTypDouble = 7, //n
CBotTypBoolean = 8, // true ou false exclusivement CBotTypBoolean = 8,
CBotTypString = 9, // chaine de caractère CBotTypString = 9,
CBotTypArrayPointer = 10, // un tableau de variables CBotTypArrayPointer = 10, // array of variables
CBotTypArrayBody = 11, // idem mais crée l'instance CBotTypArrayBody = 11, // same but creates an instance
CBotTypPointer = 12, // pointeur à une instance CBotTypPointer = 12, // pointer to an instance
CBotTypNullPointer = 13, // pointeur null est spécial CBotTypNullPointer = 13, // null pointer is special
CBotTypClass = 15,
CBotTypClass = 15, // instance d'une classe CBotTypIntrinsic = 16 // instance of a class intrinsic
CBotTypIntrinsic = 16 // instance d'une classe intrinsèque
}; };
//n = non encore implémenté //n = not implemented yet
// pour SetUserPtr lors de la suppression d'un objet // for SetUserPtr when deleting an object
#define OBJECTDELETED ((void*)-1) #define OBJECTDELETED ((void*)-1)
// valeur mise avant initialisation // value set before initialization
#define OBJECTCREATED ((void*)-2) #define OBJECTCREATED ((void*)-2)
// classe permettant de définir le type complet d'un résultat /** \brief CBotTypResult class to define the complete type of a result*/
class CBotTypResult class CBotTypResult
{ {
public:
/**
* \brief CBotTypResult constructor of an object
* \param type type of created result, see CBotType
*/
CBotTypResult(int type);
/**
* \brief CBotTypResult constructor for simple types (CBotTypInt to CBotTypString)
* \param type type of created result, see CBotType
* \param name
*/
// pour les types simples (CBotTypInt à CBotTypString)
CBotTypResult(int type, const char* name);
// pour les types pointeur et classe intrinsic
CBotTypResult(int type, CBotClass* pClass);
// idem à partir de l'instance d'une classe
CBotTypResult(int type, CBotTypResult elem);
// pour les tableaux de variables
CBotTypResult(const CBotTypResult& typ);
// pour les assignations
CBotTypResult();
// pour par défaut
~CBotTypResult();
int GivType(int mode = 0) const;
// rend le type CBotTyp* du résultat
void SetType(int n);
// modifie le type
CBotClass* GivClass() const;
// rend le pointeur à la classe (pour les CBotTypClass, CBotTypPointer)
int GivLimite() const;
// rend la taille limite du tableau (CBotTypArray)
void SetLimite(int n);
// fixe une limite au tableau
void SetArray(int* max );
// idem avec une liste de dimension (tableaux de tableaux)
CBotTypResult& GivTypElem() const;
// rend le type des éléments du tableau (CBotTypArray)
bool Compare(const CBotTypResult& typ) const;
// compare si les types sont compatibles
bool Eq(int type) const;
// compare le type
CBotTypResult&
operator=(const CBotTypResult& src);
// copie un type complet dans un autre
private: private:
int m_type; int m_type;
CBotTypResult* m_pNext; // pour les types de types CBotTypResult* m_pNext; // pour les types de types
@ -90,68 +144,6 @@ private:
int m_limite; // limitation des tableaux int m_limite; // limitation des tableaux
friend class CBotVarClass; friend class CBotVarClass;
friend class CBotVarPointer; friend class CBotVarPointer;
public:
// divers constructeurs selon les besoins
DllExport
CBotTypResult(int type);
// pour les types simples (CBotTypInt à CBotTypString)
DllExport
CBotTypResult(int type, const char* name);
// pour les types pointeur et classe intrinsic
DllExport
CBotTypResult(int type, CBotClass* pClass);
// idem à partir de l'instance d'une classe
DllExport
CBotTypResult(int type, CBotTypResult elem);
// pour les tableaux de variables
DllExport
CBotTypResult(const CBotTypResult& typ);
// pour les assignations
DllExport
CBotTypResult();
// pour par défaut
DllExport
~CBotTypResult();
DllExport
int GivType(int mode = 0) const;
// rend le type CBotTyp* du résultat
void SetType(int n);
// modifie le type
DllExport
CBotClass* GivClass() const;
// rend le pointeur à la classe (pour les CBotTypClass, CBotTypPointer)
DllExport
int GivLimite() const;
// rend la taille limite du tableau (CBotTypArray)
DllExport
void SetLimite(int n);
// fixe une limite au tableau
void SetArray(int* max );
// idem avec une liste de dimension (tableaux de tableaux)
DllExport
CBotTypResult& GivTypElem() const;
// rend le type des éléments du tableau (CBotTypArray)
DllExport
BOOL Compare(const CBotTypResult& typ) const;
// compare si les types sont compatibles
DllExport
BOOL Eq(int type) const;
// compare le type
DllExport
CBotTypResult&
operator=(const CBotTypResult& src);
// copie un type complet dans un autre
}; };
/* /*
@ -249,113 +241,82 @@ public:
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// définie une classe pour l'utilisation des strings //
// car CString fait partie de MFC pas utilisé ici. // car CString fait partie de MFC pas utilisé ici.
// //
// ( toutes les fonctions ne sont pas encore implémentées ) // ( toutes les fonctions ne sont pas encore implémentées )
/** \brief CBotString Class used to work on strings */
class CBotString class CBotString
{ {
private:
char* m_ptr; // pointeur à la chaine
int m_lg; // longueur de la chaine
static
HINSTANCE m_hInstance;
public: public:
DllExport
CBotString(); CBotString();
DllExport
CBotString(const char* p); CBotString(const char* p);
DllExport
CBotString(const CBotString& p); CBotString(const CBotString& p);
DllExport
~CBotString(); ~CBotString();
DllExport
void Empty(); void Empty();
DllExport bool IsEmpty() const;
BOOL IsEmpty() const;
DllExport
int GivLength(); int GivLength();
DllExport
int Find(const char c); int Find(const char c);
DllExport int Find(const char* lpsz);
int Find(LPCTSTR lpsz);
DllExport
int ReverseFind(const char c); int ReverseFind(const char c);
DllExport int ReverseFind(const char* lpsz);
int ReverseFind(LPCTSTR lpsz); bool LoadString(unsigned int id);
DllExport
BOOL LoadString(UINT id);
DllExport
CBotString Mid(int nFirst, int nCount) const; CBotString Mid(int nFirst, int nCount) const;
DllExport
CBotString Mid(int nFirst) const; CBotString Mid(int nFirst) const;
DllExport
CBotString Left(int nCount) const;
DllExport
CBotString Right(int nCount) const;
DllExport
const CBotString&
operator=(const CBotString& stringSrc);
DllExport
const CBotString&
operator=(const char ch);
DllExport
const CBotString&
operator=(const char* pString);
DllExport
const CBotString&
operator+(const CBotString& str);
DllExport
friend CBotString
operator+(const CBotString& string, LPCTSTR lpsz);
DllExport
const CBotString&
operator+=(const char ch);
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
CBotString Mid(int start, int lg=-1); CBotString Mid(int start, int lg=-1);
CBotString Left(int nCount) const;
DllExport CBotString Right(int nCount) const;
int Compare(const char* lpsz) const;
void MakeUpper(); void MakeUpper();
DllExport
void MakeLower(); void MakeLower();
/**
* \brief Overloaded oprators to work on CBotString classes
*/
const CBotString& operator=(const CBotString& stringSrc);
const CBotString& operator=(const char ch);
const CBotString& operator=(const char* pString);
const CBotString& operator+(const CBotString& str);
friend CBotString operator+(const CBotString& string, const char* lpsz);
const CBotString& operator+=(const char ch);
const CBotString& operator+=(const CBotString& str);
bool operator==(const CBotString& str);
bool operator==(const char* p);
bool operator!=(const CBotString& str);
bool operator!=(const char* p);
bool operator>(const CBotString& str);
bool operator>(const char* p);
bool operator>=(const CBotString& str);
bool operator>=(const char* p);
bool operator<(const CBotString& str);
bool operator<(const char* p);
bool operator<=(const CBotString& str);
bool operator<=(const char* p);
operator const char*() const; // as a C string
private:
/** \brief Pointer to string */
char* m_ptr;
/** \brief Length of the string */
int m_lg;
/** \brief Keeps the string corresponding to keyword ID */
static const std::map<EID, char *> s_keywordString;
/**
* \brief MapIdToString maps given ID to its string equivalent
* \param id Provided identifier
* \return string if found, else NullString
*/
static const char * MapIdToString(EID id);
}; };
@ -369,20 +330,13 @@ private:
CBotString* m_pData; // ^aux données CBotString* m_pData; // ^aux données
public: public:
DllExport
CBotStringArray(); CBotStringArray();
DllExport
~CBotStringArray(); ~CBotStringArray();
DllExport
void SetSize(int nb); void SetSize(int nb);
DllExport
int GivSize(); int GivSize();
DllExport
void Add(const CBotString& str); void Add(const CBotString& str);
DllExport
CBotString& operator[](int nIndex); CBotString& operator[](int nIndex);
DllExport
CBotString& ElementAt(int nIndex); CBotString& ElementAt(int nIndex);
}; };
@ -418,87 +372,70 @@ private:
public: public:
static static
CBotString m_DebugVarStr; // a fin de debug 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: public:
DllExport
static static
void Init(); void Init();
// initialise le module (défini les mots clefs pour les erreurs) // initialise le module (défini les mots clefs pour les erreurs)
// doit être fait une fois (et une seule) au tout début // doit être fait une fois (et une seule) au tout début
DllExport
static static
void Free(); void Free();
// libère les zones mémoires statiques // libère les zones mémoires statiques
DllExport
static static
int GivVersion(); int GivVersion();
// donne la version de la librairie CBOT // donne la version de la librairie CBOT
DllExport
CBotProgram(); CBotProgram();
DllExport
CBotProgram(CBotVar* pInstance); CBotProgram(CBotVar* pInstance);
DllExport
~CBotProgram(); ~CBotProgram();
DllExport bool Compile( const char* program, CBotStringArray& ListFonctions, void* pUser = NULL);
BOOL Compile( const char* program, CBotStringArray& ListFonctions, void* pUser = NULL);
// compile le programme donné en texte // 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 // voir GetCompileError() pour récupérer l'erreur
// ListFonctions retourne le nom des fonctions déclarées extern // ListFonctions retourne le nom des fonctions déclarées extern
// pUser permet de passer un pointeur pour les routines définies par AddFunction // pUser permet de passer un pointeur pour les routines définies par AddFunction
DllExport
void SetIdent(long n); void SetIdent(long n);
// associe un identificateur avec l'instance CBotProgram // associe un identificateur avec l'instance CBotProgram
DllExport
long GivIdent(); long GivIdent();
// redonne l'identificateur // redonne l'identificateur
DllExport
int GivError(); int GivError();
DllExport bool GetError(int& code, int& start, int& end);
BOOL GetError(int& code, int& start, int& end); bool GetError(int& code, int& start, int& end, CBotProgram* &pProg);
DllExport // si true
BOOL GetError(int& code, int& start, int& end, CBotProgram* &pProg);
// si TRUE
// donne l'erreur trouvée à la compilation // donne l'erreur trouvée à la compilation
// ou à l'exécution // ou à l'exécution
// start et end délimite le bloc où se trouve l'erreur // 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 // pProg permet de savoir dans quel "module" s'est produite l'erreur d'exécution
DllExport
static static
CBotString GivErrorText(int code); CBotString GivErrorText(int code);
DllExport bool Start(const char* name);
BOOL Start(const char* name);
// définie quelle fonction doit être exécutée // 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 // le programme ne fait rien, il faut appeller Run() pour cela
DllExport bool Run(void* pUser = NULL, int timer = -1);
BOOL Run(void* pUser = NULL, int timer = -1);
// exécute le programme // exécute le programme
// retourne FALSE si le programme a été suspendu // retourne false si le programme a été suspendu
// retourne TRUE si le programme s'est terminé avec ou sans erreur // retourne true si le programme s'est terminé avec ou sans erreur
// timer = 0 permet de faire une avance pas à pas // timer = 0 permet de faire une avance pas à pas
DllExport bool GetRunPos(const char* &FunctionName, int &start, int &end);
BOOL GetRunPos(const char* &FunctionName, int &start, int &end);
// donne la position dans le programme en exécution // 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 // FunctionName est un pointeur rendu sur le nom de la fonction
// start et end la position dans le texte du token en traitement // start et end la position dans le texte du token en traitement
DllExport
CBotVar* GivStackVars(const char* &FunctionName, int level); CBotVar* GivStackVars(const char* &FunctionName, int level);
// permet d'obtenir le pointeur aux variables sur la pile d'exécution // 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 // level est un paramètre d'entrée, 0 pour le dernier niveau, -1, -2, etc pour les autres niveau
@ -507,41 +444,34 @@ public:
// FunctionName donne le nom de la fonction où se trouvent ces variables // FunctionName donne le nom de la fonction où se trouvent ces variables
// FunctionName == NULL signifiant qu'on est plus dans le programme (selon level) // FunctionName == NULL signifiant qu'on est plus dans le programme (selon level)
DllExport
void Stop(); void Stop();
// arrête l'exécution du programme // arrête l'exécution du programme
// quitte donc le mode "suspendu" // quitte donc le mode "suspendu"
DllExport
static static
void SetTimer(int n); void SetTimer(int n);
// défini le nombre de pas (parties d'instructions) à faire // 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
static static
BOOL AddFunction(const char* name, bool AddFunction(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)); CBotTypResult rCompile (CBotVar* &pVar, void* pUser));
// cet appel permet d'ajouter de manière externe (**) // cet appel permet d'ajouter de manière externe (**)
// une nouvelle fonction utilisable par le programme CBot // une nouvelle fonction utilisable par le programme CBot
DllExport
static static
BOOL DefineNum(const char* name, long val); bool DefineNum(const char* name, long val);
DllExport bool SaveState(FILE* pf);
BOOL SaveState(FILE* pf);
// sauvegarde l'état d'exécution dans le fichier // sauvegarde l'état d'exécution dans le fichier
// le fichier doit avoir été ouvert avec l'appel fopen de cette dll // le fichier doit avoir été ouvert avec l'appel fopen de cette dll
// sinon le système plante // sinon le système plante
DllExport bool RestoreState(FILE* pf);
BOOL RestoreState(FILE* pf);
// rétablie l'état de l'exécution depuis le fichier // rétablie l'état de l'exécution depuis le fichier
// le programme compilé doit évidemment être identique // le programme compilé doit évidemment être identique
DllExport bool GetPosition(const char* name, int& start, int& stop,
BOOL GetPosition(const char* name, int& start, int& stop,
CBotGet modestart = GetPosExtern, CBotGet modestart = GetPosExtern,
CBotGet modestop = GetPosBloc); CBotGet modestop = GetPosBloc);
// donne la position d'une routine dans le texte d'origine // donne la position d'une routine dans le texte d'origine
@ -555,13 +485,9 @@ public:
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// routines pour la gestion d'un fichier (FILE*) // routines pour la gestion d'un fichier (FILE*)
DllExport
FILE* fOpen(const char* name, const char* mode); FILE* fOpen(const char* name, const char* mode);
DllExport
int fClose(FILE* filehandle); int fClose(FILE* filehandle);
DllExport
size_t fWrite(const void *buffer, size_t elemsize, size_t length, FILE* filehandle); size_t fWrite(const void *buffer, size_t elemsize, size_t length, FILE* filehandle);
DllExport
size_t fRead(void *buffer, size_t elemsize, size_t length, FILE* filehandle); size_t fRead(void *buffer, size_t elemsize, size_t length, FILE* filehandle);
@ -594,7 +520,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; float total = 0;
int nb = 0; int nb = 0;
@ -606,7 +532,7 @@ BOOL rMoyenne(CBotVar* pVar, CBotVar* pResult, int& Exception)
} }
pResult->SetValFloat(total/nb); // retourne la valeur moyenne pResult->SetValFloat(total/nb); // retourne la valeur moyenne
return TRUE; // opération totalement terminée return true; // opération totalement terminée
} }
#endif #endif
@ -614,7 +540,6 @@ BOOL rMoyenne(CBotVar* pVar, CBotVar* pResult, int& Exception)
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Classe pour la gestion des variables // Classe pour la gestion des variables
// les méthodes marquées DllExport
// peuvent être utile à l'exterieur du module // peuvent être utile à l'exterieur du module
// ( il n'est pour l'instant pas prévu de pouvoir créer ces objets en externe ) // ( il n'est pour l'instant pas prévu de pouvoir créer ces objets en externe )
@ -645,7 +570,7 @@ protected:
int m_binit; // pas initialisée ? int m_binit; // pas initialisée ?
CBotVarClass* m_pMyThis; // ^élément this correspondant CBotVarClass* m_pMyThis; // ^élément this correspondant
void* m_pUserPtr; // ^données user s'il y a lieu 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 ? int m_mPrivate; // élément public, protected ou private ?
CBotInstr* m_InitExpr; // expression pour le contenu initial CBotInstr* m_InitExpr; // expression pour le contenu initial
@ -662,18 +587,10 @@ public:
CBotVar(); CBotVar();
virtual ~CBotVar( ); // destructeur virtual ~CBotVar( ); // destructeur
/* DllExport
static
CBotVar* Create( const char* name, int type, const char* ClassName = NULL);
// crée une variable selon son type,*/
DllExport
static static
CBotVar* Create( const char* name, CBotTypResult type); CBotVar* Create( const char* name, CBotTypResult type);
// idem à partir du type complet // idem à partir du type complet
DllExport
static static
CBotVar* Create( const char* name, CBotClass* pClass); CBotVar* Create( const char* name, CBotClass* pClass);
// idem pour une instance d'une classe connue // idem pour une instance d'une classe connue
@ -690,51 +607,38 @@ virtual ~CBotVar( ); // destructeur
CBotVar* Create( CBotVar* pVar ); CBotVar* Create( CBotVar* pVar );
DllExport
void SetUserPtr(void* pUser); void SetUserPtr(void* pUser);
// associe un pointeur utilisateur à une instance // associe un pointeur utilisateur à une instance
DllExport
virtual void SetIdent(long UniqId); virtual void SetIdent(long UniqId);
// associe un identificateur unique à une instance // associe un identificateur unique à une instance
// ( c'est à l'utilisateur de s'assurer que l'id est unique) // ( c'est à l'utilisateur de s'assurer que l'id est unique)
DllExport
void* GivUserPtr(); void* GivUserPtr();
// rend le pointeur associé à la variable // rend le pointeur associé à la variable
DllExport
CBotString GivName(); // le nom de la variable, s'il est connu CBotString GivName(); // le nom de la variable, s'il est connu
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
void SetName(const char* name); // change le nom de la variable void SetName(const char* name); // change le nom de la variable
DllExport
int GivType(int mode = 0); // rend le type de base (int) de la variable int GivType(int mode = 0); // rend le type de base (int) de la variable
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
DllExport
CBotTypResult GivTypResult(int mode = 0); // rend le type complet de la variable CBotTypResult GivTypResult(int mode = 0); // rend le type complet de la variable
CBotToken* GivToken(); CBotToken* GivToken();
void SetType(CBotTypResult& type); void SetType(CBotTypResult& type);
DllExport
void SetInit(int bInit); // met la variable dans l'état IS_UNDEF, IS_DEF, IS_NAN void SetInit(int bInit); // met la variable dans l'état IS_UNDEF, IS_DEF, IS_NAN
DllExport
int GivInit(); // donne l'état de la variable int GivInit(); // donne l'état de la variable
DllExport void SetStatic(bool bStatic);
void SetStatic(BOOL bStatic); bool IsStatic();
DllExport
BOOL IsStatic();
DllExport
void SetPrivate(int mPrivate); void SetPrivate(int mPrivate);
DllExport bool IsPrivate(int mode = PR_PROTECT);
BOOL IsPrivate(int mode = PR_PROTECT);
DllExport
int GivPrivate(); int GivPrivate();
virtual virtual
@ -742,55 +646,44 @@ virtual ~CBotVar( ); // destructeur
void SetVal(CBotVar* var); // remprend une valeur void SetVal(CBotVar* var); // remprend une valeur
DllExport
virtual virtual
CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*) CBotVar* GivItem(const char* name); // rend un élément d'une classe selon son nom (*)
virtual virtual
CBotVar* GivItemRef(int nIdent); // idem à partir du n° ref CBotVar* GivItemRef(int nIdent); // idem à partir du n° ref
DllExport
virtual virtual
CBotVar* GivItem(int row, BOOL bGrow = FALSE); CBotVar* GivItem(int row, bool bGrow = false);
DllExport
virtual virtual
CBotVar* GivItemList(); // donne la liste des éléments CBotVar* GivItemList(); // donne la liste des éléments
DllExport
CBotVar* GivStaticVar(); // rend le pointeur à la variable si elle est statique CBotVar* GivStaticVar(); // rend le pointeur à la variable si elle est statique
DllExport bool IsElemOfClass(const char* name);
BOOL IsElemOfClass(const char* name);
// dit si l'élément appartient à la classe "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
CBotVar* GivNext(); // prochaine variable dans la liste (paramètres) CBotVar* GivNext(); // prochaine variable dans la liste (paramètres)
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
void AddNext(CBotVar* pVar); // ajoute dans une liste void AddNext(CBotVar* pVar); // ajoute dans une liste
virtual 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
virtual void SetValInt(int val, const char* name = NULL); virtual void SetValInt(int val, const char* name = NULL);
// initialise avec une valeur entière (#) // initialise avec une valeur entière (#)
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
DllExport
virtual void SetValFloat(float val); // initialise avec une valeur réelle (#) virtual void SetValFloat(float val); // initialise avec une valeur réelle (#)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DllExport
virtual void SetValString(const char* p);// initialise avec une valeur chaîne (#) virtual void SetValString(const char* p);// initialise avec une valeur chaîne (#)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
DllExport
virtual int GivValInt(); // demande la valeur entière (#) virtual int GivValInt(); // demande la valeur entière (#)
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
DllExport
virtual float GivValFloat(); // demande la valeur réelle (#) virtual float GivValFloat(); // demande la valeur réelle (#)
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@ -814,12 +707,12 @@ virtual ~CBotVar( ); // destructeur
virtual int Modulo(CBotVar* left, CBotVar* right); // reste de division virtual int Modulo(CBotVar* left, CBotVar* right); // reste de division
virtual void Power(CBotVar* left, CBotVar* right); // puissance virtual void Power(CBotVar* left, CBotVar* right); // puissance
virtual BOOL Lo(CBotVar* left, CBotVar* right); virtual bool Lo(CBotVar* left, CBotVar* right);
virtual BOOL Hi(CBotVar* left, CBotVar* right); virtual bool Hi(CBotVar* left, CBotVar* right);
virtual BOOL Ls(CBotVar* left, CBotVar* right); virtual bool Ls(CBotVar* left, CBotVar* right);
virtual BOOL Hs(CBotVar* left, CBotVar* right); virtual bool Hs(CBotVar* left, CBotVar* right);
virtual BOOL Eq(CBotVar* left, CBotVar* right); virtual bool Eq(CBotVar* left, CBotVar* right);
virtual BOOL Ne(CBotVar* left, CBotVar* right); virtual bool Ne(CBotVar* left, CBotVar* right);
virtual void And(CBotVar* left, CBotVar* right); virtual void And(CBotVar* left, CBotVar* right);
virtual void Or(CBotVar* left, CBotVar* right); virtual void Or(CBotVar* left, CBotVar* right);
@ -834,19 +727,17 @@ virtual ~CBotVar( ); // destructeur
virtual void Dec(); virtual void Dec();
virtual BOOL Save0State(FILE* pf); virtual bool Save0State(FILE* pf);
virtual BOOL Save1State(FILE* pf); virtual bool Save1State(FILE* pf);
static BOOL RestoreState(FILE* pf, CBotVar* &pVar); static bool RestoreState(FILE* pf, CBotVar* &pVar);
DllExport
void debug(); void debug();
// virtual // virtual
// CBotVar* GivMyThis(); // CBotVar* GivMyThis();
DllExport
virtual virtual
void Maj(void* pUser = NULL, BOOL bContinue = TRUE); void Maj(void* pUser = NULL, bool bContinue = true);
void SetUniqNum(long n); void SetUniqNum(long n);
long GivUniqNum(); long GivUniqNum();
@ -888,7 +779,7 @@ private:
CBotString m_name; // nom de cette classe-ci CBotString m_name; // nom de cette classe-ci
int m_nbVar; // nombre de variables dans la chaîne int m_nbVar; // nombre de variables dans la chaîne
CBotVar* m_pVar; // contenu de la classe 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 CBotClass* m_next; // chaine les classe
CBotCallMethode* m_pCalls; // liste des méthodes définie en externe CBotCallMethode* m_pCalls; // liste des méthodes définie en externe
CBotFunction* m_pMethod; // liste des méthodes compilées CBotFunction* m_pMethod; // liste des méthodes compilées
@ -899,37 +790,30 @@ private:
CBotProgram* m_ProgInLock[5];// processus en attente pour synchro CBotProgram* m_ProgInLock[5];// processus en attente pour synchro
public: public:
BOOL m_IsDef; // marque si est définie ou pas encore bool m_IsDef; // marque si est définie ou pas encore
DllExport
CBotClass( const char* name, 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 // Dès qu'une classe est créée, elle est connue
// partout dans CBot // partout dans CBot
// le mode intrinsic donne une classe qui n'est pas gérée par des pointeurs // le mode intrinsic donne une classe qui n'est pas gérée par des pointeurs
DllExport
~CBotClass( ); // destructeur ~CBotClass( ); // destructeur
DllExport bool AddFunction(const char* name,
BOOL AddFunction(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)); CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
// cet appel permet d'ajouter de manière externe (**) // cet appel permet d'ajouter de manière externe (**)
// une nouvelle méthode utilisable par les objets de cette classe // une nouvelle méthode utilisable par les objets de cette classe
DllExport bool AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) );
BOOL AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) );
// défini la routine qui sera appellée pour mettre à jour les élements de la classe // 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);
BOOL AddItem(CBotString name, CBotTypResult type, int mPrivate = PR_PUBLIC);
// ajoute un élément à la classe // ajoute un élément à la classe
// DllExport // bool AddItem(CBotString name, CBotClass* pClass);
// BOOL AddItem(CBotString name, CBotClass* pClass);
// idem pour des éléments appartenant à pClass // idem pour des éléments appartenant à pClass
DllExport bool AddItem(CBotVar* pVar);
BOOL AddItem(CBotVar* pVar);
// idem en passant le pointeur à une instance d'une variable // idem en passant le pointeur à une instance d'une variable
// l'objet est pris tel quel, il ne faut donc pas le détruire // l'objet est pris tel quel, il ne faut donc pas le détruire
@ -938,20 +822,16 @@ public:
// idem en donnant un élément de type CBotVar // idem en donnant un élément de type CBotVar
void AddNext(CBotClass* pClass); void AddNext(CBotClass* pClass);
DllExport
CBotString GivName(); // rend le nom de la classe CBotString GivName(); // rend le nom de la classe
DllExport
CBotClass* GivParent(); // donne la classe père (ou NULL) CBotClass* GivParent(); // donne la classe père (ou NULL)
// dit si une classe est dérivée (Extends) d'une autre // dit si une classe est dérivée (Extends) d'une autre
// rend TRUE aussi si les classes sont identiques // rend true aussi si les classes sont identiques
DllExport bool IsChildOf(CBotClass* pClass);
BOOL IsChildOf(CBotClass* pClass);
static static
CBotClass* Find(CBotToken* &pToken); // trouve une classe d'après son nom CBotClass* Find(CBotToken* &pToken); // trouve une classe d'après son nom
DllExport
static static
CBotClass* Find(const char* name); CBotClass* Find(const char* name);
@ -962,7 +842,7 @@ public:
CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams, CBotTypResult CompileMethode(const char* name, CBotVar* pThis, CBotVar** ppParams,
CBotCStack* pStack, long& nIdent); 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); void RestoreMethode(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppParams, CBotStack* &pStack);
// compile une classe déclarée par l'utilisateur // compile une classe déclarée par l'utilisateur
@ -971,27 +851,25 @@ public:
static static
CBotClass* Compile1(CBotToken* &p, CBotCStack* pStack); 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(); void Purge();
static static
void Free(); void Free();
DllExport
static static
BOOL SaveStaticState(FILE* pf); bool SaveStaticState(FILE* pf);
DllExport
static static
BOOL RestoreStaticState(FILE* pf); bool RestoreStaticState(FILE* pf);
BOOL Lock(CBotProgram* p); bool Lock(CBotProgram* p);
void Unlock(); void Unlock();
static static
void FreeLock(CBotProgram* p); void FreeLock(CBotProgram* p);
BOOL CheckCall(CBotToken* &pToken, CBotDefParam* pParam); bool CheckCall(CBotToken* &pToken, CBotDefParam* pParam);
}; };
@ -1041,7 +919,7 @@ private:
static static
int GivKeyWords(const char* w); // est-ce un mot clef ? int GivKeyWords(const char* w); // est-ce un mot clef ?
static static
BOOL GivKeyDefNum(const char* w, CBotToken* &token); bool GivKeyDefNum(const char* w, CBotToken* &token);
static static
void LoadKeyWords(); // fait la liste des mots clefs void LoadKeyWords(); // fait la liste des mots clefs
@ -1054,37 +932,28 @@ public:
// constructeur // constructeur
~CBotToken(); // destructeur ~CBotToken(); // destructeur
DllExport
int GivType(); // rend le type du token int GivType(); // rend le type du token
DllExport
CBotString& GivString(); // rend la chaine correspondant à ce token CBotString& GivString(); // rend la chaine correspondant à ce token
DllExport
CBotString& GivSep(); // rend le séparateur suivant le token CBotString& GivSep(); // rend le séparateur suivant le token
DllExport
int GivStart(); // position du début dans le texte int GivStart(); // position du début dans le texte
DllExport
int GivEnd(); // position de fin dans le texte int GivEnd(); // position de fin dans le texte
DllExport
CBotToken* GivNext(); // rend le suivant dans la liste CBotToken* GivNext(); // rend le suivant dans la liste
DllExport
CBotToken* GivPrev(); // rend le Précédent dans la liste CBotToken* GivPrev(); // rend le Précédent dans la liste
DllExport
static static
CBotToken* CompileTokens(const char* p, int& error); CBotToken* CompileTokens(const char* p, int& error);
// transforme tout le programme // transforme tout le programme
DllExport
static static
void Delete(CBotToken* pToken); // libère la liste void Delete(CBotToken* pToken); // libère la liste
// fonctions non utiles en export // fonctions non utiles en export
static static
BOOL DefineNum(const char* name, long val); bool DefineNum(const char* name, long val);
void SetString(const char* name); void SetString(const char* name);
void SetPos(int start, int end); void SetPos(int start, int end);
@ -1092,7 +961,7 @@ public:
void AddNext(CBotToken* p); // ajoute un token (une copie) void AddNext(CBotToken* p); // ajoute un token (une copie)
static static
CBotToken* NextToken(char* &program, int& error, BOOL first = FALSE); CBotToken* NextToken(char* &program, int& error, bool first = false);
// trouve le prochain token // trouve le prochain token
const CBotToken& const CBotToken&
operator=(const CBotToken& src); operator=(const CBotToken& src);
@ -1163,7 +1032,7 @@ public:
// exécute le programme main // exécute le programme main
// ------------------------- // -------------------------
while( FALSE = m_pMonRobot->Execute( "main", pStack )) while( false = m_pMonRobot->Execute( "main", pStack ))
{ {
// programme suspendu // programme suspendu
// on pourrait passer la main à un autre (en sauvegardant pStack pour ce robot-là) // on pourrait passer la main à un autre (en sauvegardant pStack pour ce robot-là)
@ -1174,10 +1043,10 @@ public:
// routine implémentant l'instruction GOTO( CPoint pos ) // 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 || 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 ? // 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 // NB en fait ce contrôle est déjà fait par la routine pour la compilation
@ -1193,8 +1062,10 @@ BOOL rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception )
ASSERT (temp != NULL && temp->GivType() == CBotTypFloat); ASSERT (temp != NULL && temp->GivType() == CBotTypFloat);
m_PosToGo.y = temp->GivValFloat(); m_PosToGo.y = temp->GivValFloat();
return (m_CurentPos == m_PosToGo); // rend TRUE si la position est atteinte return (m_CurentPos == m_PosToGo); // rend true si la position est atteinte
// rend FALSE s'il faut patienter encore // rend false s'il faut patienter encore
} }
#endif #endif
#endif //_CBOTDLL_H_

View File

@ -25,14 +25,14 @@ CBotFunction::CBotFunction()
m_Param = NULL; // liste des paramètres vide m_Param = NULL; // liste des paramètres vide
m_Block = NULL; // le bloc d'instructions m_Block = NULL; // le bloc d'instructions
m_next = NULL; // les fonctions peuvent être chaînées m_next = NULL; // les fonctions peuvent être chaînées
m_bPublic = FALSE; // fonction non publique m_bPublic = false; // fonction non publique
m_bExtern = FALSE; // fonction non externe m_bExtern = false; // fonction non externe
m_nextpublic = NULL; m_nextpublic = NULL;
m_prevpublic = NULL; m_prevpublic = NULL;
m_pProg = NULL; m_pProg = NULL;
// m_nThisIdent = 0; // m_nThisIdent = 0;
m_nFuncIdent = 0; m_nFuncIdent = 0;
m_bSynchro = FALSE; m_bSynchro = false;
} }
CBotFunction* CBotFunction::m_listPublic = NULL; CBotFunction* CBotFunction::m_listPublic = NULL;
@ -62,17 +62,17 @@ CBotFunction::~CBotFunction()
} }
} }
BOOL CBotFunction::IsPublic() bool CBotFunction::IsPublic()
{ {
return m_bPublic; return m_bPublic;
} }
BOOL CBotFunction::IsExtern() bool CBotFunction::IsExtern()
{ {
return m_bExtern; 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(); start = m_extern.GivStart();
stop = m_closeblk.GivEnd(); stop = m_closeblk.GivEnd();
@ -110,7 +110,7 @@ BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet
stop = m_closeblk.GivEnd(); stop = m_closeblk.GivEnd();
} }
return TRUE; return true;
} }
@ -168,7 +168,7 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
// compile une nouvelle fonction // compile une nouvelle fonction
// bLocal permet de mettre la déclaration des paramètres au même niveau // 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 // 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; CBotToken* pp;
CBotFunction* func = finput; CBotFunction* func = finput;
@ -178,19 +178,19 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// func->m_nFuncIdent = CBotVar::NextUniqNum(); // func->m_nFuncIdent = CBotVar::NextUniqNum();
while (TRUE) while (true)
{ {
if ( IsOfType(p, ID_PUBLIC) ) if ( IsOfType(p, ID_PUBLIC) )
{ {
func->m_bPublic = TRUE; func->m_bPublic = true;
continue; continue;
} }
pp = p; pp = p;
if ( IsOfType(p, ID_EXTERN) ) if ( IsOfType(p, ID_EXTERN) )
{ {
func->m_extern = pp; // pour la position du mot "extern" func->m_extern = pp; // pour la position du mot "extern"
func->m_bExtern = TRUE; func->m_bExtern = true;
// func->m_bPublic = TRUE; // donc aussi publique! // func->m_bPublic = true; // donc aussi publique!
continue; continue;
} }
break; break;
@ -260,7 +260,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// et compile le bloc d'instruction qui suit // et compile le bloc d'instruction qui suit
func->m_openblk = p; 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(); func->m_closeblk = p->GivPrev();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
{ {
@ -286,18 +286,18 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
CBotFunction* func = new CBotFunction(); CBotFunction* func = new CBotFunction();
func->m_nFuncIdent = CBotVar::NextUniqNum(); 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) ) if ( IsOfType(p, ID_PUBLIC) )
{ {
// func->m_bPublic = TRUE; // sera fait en passe 2 // func->m_bPublic = true; // sera fait en passe 2
continue; continue;
} }
if ( IsOfType(p, ID_EXTERN) ) if ( IsOfType(p, ID_EXTERN) )
{ {
func->m_bExtern = TRUE; func->m_bExtern = true;
continue; continue;
} }
break; break;
@ -367,16 +367,16 @@ bad:
static int xx = 0; static int xx = 0;
#endif #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 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 pile->SetBotCall(m_pProg); // bases pour les routines
if ( pile->GivState() == 0 ) 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(); pile->IncState();
} }
@ -403,14 +403,14 @@ BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
if ( !m_Block->Execute(pile) ) if ( !m_Block->Execute(pile) )
{ {
if ( pile->GivError() < 0 ) if ( pile->GivError() < 0 )
pile->SetError( 0 ); pile->SetError( 0 );
else else
return FALSE; return false;
} }
return pj->Return(pile); return pj->Return(pile);
@ -433,7 +433,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
pile2->Delete(); pile2->Delete();
} }
m_Param->RestoreState(pile2, TRUE); // les paramètres m_Param->RestoreState(pile2, true); // les paramètres
if ( !m_MasterClass.IsEmpty() ) if ( !m_MasterClass.IsEmpty() )
{ {
@ -442,7 +442,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
pThis->SetUniqNum(-2); pThis->SetUniqNum(-2);
} }
m_Block->RestoreState(pile2, TRUE); m_Block->RestoreState(pile2, true);
} }
void CBotFunction::AddNext(CBotFunction* p) 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 // trouve une fonction selon son identificateur unique
// si l'identificateur n'est pas trouvé, cherche selon le nom et les paramètres // 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 TypeOrError.SetType(TX_UNDEFCALL); // pas de routine de ce nom
CBotFunction* pt; CBotFunction* pt;
@ -632,13 +632,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
if ( pt != NULL ) if ( pt != NULL )
{ {
CBotStack* pStk1 = pStack->AddStack(pt, 2); // pour mettre "this" 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 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 // 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 ) if ( !pStk3->IsOk() && pt->m_pProg != m_pProg )
{ {
#ifdef _DEBUG #ifdef _DEBUG
if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return FALSE; if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return false;
#endif #endif
pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
} }
return FALSE; // interrompu ! return false; // interrompu !
} }
return pStack->Return( pStk3 ); return pStack->Return( pStk3 );
@ -738,13 +738,13 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
if ( pStk1->GivState() == 0 ) if ( pStk1->GivState() == 0 )
{ {
pt->m_Param->RestoreState(pStk3, TRUE); pt->m_Param->RestoreState(pStk3, true);
return; return;
} }
// initialise les variables selon paramètres // initialise les variables selon paramètres
pt->m_Param->RestoreState(pStk3, FALSE); pt->m_Param->RestoreState(pStk3, false);
pt->m_Block->RestoreState(pStk3, TRUE); pt->m_Block->RestoreState(pStk3, true);
} }
} }
@ -758,17 +758,17 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
CBotTypResult type; CBotTypResult type;
CBotProgram* pProgCurrent = pStack->GivBotCall(); CBotProgram* pProgCurrent = pStack->GivBotCall();
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, FALSE); CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false);
if ( pt != NULL ) if ( pt != NULL )
{ {
// DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack); // DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack);
CBotStack* pStk = pStack->AddStack(pt, 2); 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 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 // 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 // met la variable "this" sur la pile
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer); CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
pthis->Copy(pThis, FALSE); pthis->Copy(pThis, false);
pthis->SetUniqNum(-2); // valeur spéciale pthis->SetUniqNum(-2); // valeur spéciale
pStk->AddVar(pthis); 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 // met la variable "super" sur la pile
CBotVar* psuper = CBotVar::Create("super", CBotTypNullPointer); 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 psuper->SetUniqNum(-3); // valeur spéciale
pStk->AddVar(psuper); pStk->AddVar(psuper);
} }
@ -798,8 +798,8 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
{ {
if ( pt->m_bSynchro ) if ( pt->m_bSynchro )
{ {
CBotProgram* pProgBase = pStk->GivBotCall(TRUE); CBotProgram* pProgBase = pStk->GivBotCall(true);
if ( !pClass->Lock(pProgBase) ) return FALSE; // attend de pouvoir if ( !pClass->Lock(pProgBase) ) return false; // attend de pouvoir
} }
pStk->IncState(); 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 pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
} }
} }
return FALSE; // interrompu ! return false; // interrompu !
} }
if ( pt->m_bSynchro ) 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 CBotStack* pStk3 = pStk->RestoreStack(NULL); // pour mettre les paramètres passés
if ( pStk3 == NULL ) return; 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 ? if ( pStk->GivState() > 1 && // vérouillage est effectif ?
pt->m_bSynchro ) pt->m_bSynchro )
{ {
CBotProgram* pProgBase = pStk->GivBotCall(TRUE); CBotProgram* pProgBase = pStk->GivBotCall(true);
pClass->Lock(pProgBase); // vérouille la classe pClass->Lock(pProgBase); // vérouille la classe
} }
// finalement appelle la fonction trouvée // 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 // regarde si la "signature" des paramètres est identique
BOOL CBotFunction::CheckParam(CBotDefParam* pParam) bool CBotFunction::CheckParam(CBotDefParam* pParam)
{ {
CBotDefParam* pp = m_Param; CBotDefParam* pp = m_Param;
while ( pp != NULL && pParam != NULL ) while ( pp != NULL && pParam != NULL )
{ {
CBotTypResult type1 = pp->GivType(); CBotTypResult type1 = pp->GivType();
CBotTypResult type2 = pParam->GivType(); CBotTypResult type2 = pParam->GivType();
if ( !type1.Compare(type2) ) return FALSE; if ( !type1.Compare(type2) ) return false;
pp = pp->GivNext(); pp = pp->GivNext();
pParam = pParam->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; int i = 0;
CBotDefParam* p = this; CBotDefParam* p = this;
@ -1033,7 +1033,7 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
newvar->SetValInt(ppVars[i]->GivValInt()); newvar->SetValInt(ppVars[i]->GivValInt());
break; break;
case CBotTypIntrinsic: case CBotTypIntrinsic:
((CBotVarClass*)newvar)->Copy(ppVars[i], FALSE); ((CBotVarClass*)newvar)->Copy(ppVars[i], false);
break; break;
case CBotTypPointer: case CBotTypPointer:
case CBotTypArrayPointer: case CBotTypArrayPointer:
@ -1051,10 +1051,10 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
i++; i++;
} }
return TRUE; return true;
} }
void CBotDefParam::RestoreState(CBotStack* &pj, BOOL bMain) void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
{ {
int i = 0; int i = 0;
CBotDefParam* p = this; 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 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); CBotStack* pile = pj->AddStack(this);
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->GivState() == 0 ) 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 // le résultat est sur la pile
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
pile->SetBreak(3, CBotString()); pile->SetBreak(3, CBotString());
return pj->Return(pile); return pj->Return(pile);
} }
void CBotReturn::RestoreState(CBotStack* &pj, BOOL bMain) void CBotReturn::RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); CBotStack* pile = pj->RestoreStack(this);
@ -1211,7 +1211,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(pp); inst->SetToken(pp);
// compile la liste des paramètres // compile la liste des paramètres
if (!IsOfType(p, ID_CLOSEPAR)) while (TRUE) if (!IsOfType(p, ID_CLOSEPAR)) while (true)
{ {
start = p->GivStart(); start = p->GivStart();
pile = pile->TokenStack(); // garde les résultats sur la pile pile = pile->TokenStack(); // garde les résultats sur la pile
@ -1278,7 +1278,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
BOOL CBotInstrCall::Execute(CBotStack* &pj) bool CBotInstrCall::Execute(CBotStack* &pj)
{ {
CBotVar* ppVars[1000]; CBotVar* ppVars[1000];
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
@ -1292,12 +1292,12 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
// évalue les paramètres // évalue les paramètres
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // 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 pile = pile->AddStack(); // de la place sur la pile pour les résultats
if ( pile->GivState() == 0 ) 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 pile->SetState(1); // marque spéciale pour reconnaîre les paramètres
} }
ppVars[i++] = pile->GivVar(); ppVars[i++] = pile->GivVar();
@ -1307,14 +1307,14 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
ppVars[i] = NULL; ppVars[i] = NULL;
CBotStack* pile2 = pile->AddStack(); 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 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; if ( !bMain ) return;
@ -1329,7 +1329,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain)
// évalue les paramètres // évalue les paramètres
// et place les valeurs sur la pile // et place les valeurs sur la pile
// pour pouvoir être interrompu n'importe quand // 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 pile = pile->RestoreStack(); // de la place sur la pile pour les résultats
if ( pile == NULL ) return; if ( pile == NULL ) return;
@ -1379,7 +1379,6 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
if (IsOfType(p, TokenTypVar)) if (IsOfType(p, TokenTypVar))
{ {
CBotClass* pPapa = NULL; CBotClass* pPapa = NULL;
#if EXTENDS
if ( IsOfType( p, ID_EXTENDS ) ) if ( IsOfType( p, ID_EXTENDS ) )
{ {
CBotString name = p->GivString(); CBotString name = p->GivString();
@ -1391,10 +1390,9 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
} }
#endif
CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld; CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld;
classe->Purge(); // vide les anciennes définitions 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) ) if ( !IsOfType( p, ID_OPBLK) )
{ {
@ -1404,7 +1402,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
{ {
classe->CompileDefItem(p, pStack, FALSE); classe->CompileDefItem(p, pStack, false);
} }
if (pStack->IsOk()) return classe; if (pStack->IsOk()) return classe;
@ -1413,24 +1411,24 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
return NULL; 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; int mProtect = PR_PUBLIC;
BOOL bSynchro = FALSE; bool bSynchro = false;
while (IsOfType(p, ID_SEP)) ; while (IsOfType(p, ID_SEP)) ;
CBotTypResult type( -1 ); CBotTypResult type( -1 );
if ( IsOfType(p, ID_SYNCHO) ) bSynchro = TRUE; if ( IsOfType(p, ID_SYNCHO) ) bSynchro = true;
CBotToken* pBase = p; 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_PUBLIC) ) mProtect = PR_PUBLIC;
if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE; if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE;
if ( IsOfType(p, ID_PROTECTED) ) mProtect = PR_PROTECT; 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; // CBotClass* pClass = NULL;
type = TypeParam(p, pStack); // type du résultat type = TypeParam(p, pStack); // type du résultat
@ -1438,7 +1436,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
if ( type.Eq(-1) ) if ( type.Eq(-1) )
{ {
pStack->SetError(TX_NOTYP, p); pStack->SetError(TX_NOTYP, p);
return FALSE; return false;
} }
while (pStack->IsOk()) while (pStack->IsOk())
@ -1463,14 +1461,14 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) ) if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
{ {
pStack->SetError(TX_CLBRK, p->GivStart()); pStack->SetError(TX_CLBRK, p->GivStart());
return FALSE; return false;
} }
/* CBotVar* pv = pStack->GivVar(); /* CBotVar* pv = pStack->GivVar();
if ( pv->GivType()>= CBotTypBoolean ) if ( pv->GivType()>= CBotTypBoolean )
{ {
pStack->SetError(TX_BADTYPE, p->GivStart()); pStack->SetError(TX_BADTYPE, p->GivStart());
return FALSE; return false;
}*/ }*/
if (limites == NULL) limites = i; if (limites == NULL) limites = i;
@ -1485,7 +1483,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
CBotFunction* f = CBotFunction* f =
CBotFunction::Compile1(p, pStack, this); CBotFunction::Compile1(p, pStack, this);
if ( f == NULL ) return FALSE; if ( f == NULL ) return false;
if (m_pMethod == NULL) m_pMethod = f; if (m_pMethod == NULL) m_pMethod = f;
else m_pMethod->AddNext(f); else m_pMethod->AddNext(f);
@ -1502,8 +1500,8 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
pf = pf->Next(); pf = pf->Next();
} }
BOOL bConstructor = (pp->GivString() == GivName()); bool bConstructor = (pp->GivString() == GivName());
CBotCStack* pile = pStack->TokenStack(NULL, TRUE); CBotCStack* pile = pStack->TokenStack(NULL, true);
// rend "this" connu // rend "this" connu
CBotToken TokenThis(CBotString("this"), CBotString()); CBotToken TokenThis(CBotString("this"), CBotString());
@ -1540,7 +1538,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
// compile une méthode // compile une méthode
p = pBase; p = pBase;
CBotFunction* f = CBotFunction* f =
CBotFunction::Compile(p, pile, NULL/*, FALSE*/); CBotFunction::Compile(p, pile, NULL/*, false*/);
if ( f != NULL ) if ( f != NULL )
{ {
@ -1563,7 +1561,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
if (type.Eq(0)) if (type.Eq(0))
{ {
pStack->SetError(TX_ENDOF, p); pStack->SetError(TX_ENDOF, p);
return FALSE; return false;
} }
CBotInstr* i = NULL; CBotInstr* i = NULL;
@ -1578,7 +1576,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
// il y a une assignation à calculer // il y a une assignation à calculer
i = CBotTwoOpExpr::Compile(p, pStack); i = CBotTwoOpExpr::Compile(p, pStack);
} }
if ( !pStack->IsOk() ) return FALSE; if ( !pStack->IsOk() ) return false;
} }
@ -1627,20 +1625,18 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
// la classe à été créée par Compile1 // la classe à été créée par Compile1
CBotClass* pOld = CBotClass::Find(name); CBotClass* pOld = CBotClass::Find(name);
#if EXTENDS
if ( IsOfType( p, ID_EXTENDS ) ) if ( IsOfType( p, ID_EXTENDS ) )
{ {
IsOfType(p, TokenTypVar); // forcément IsOfType(p, TokenTypVar); // forcément
} }
#endif
IsOfType( p, ID_OPBLK); // forcément IsOfType( p, ID_OPBLK); // forcément
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) ) 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; if (pStack->IsOk()) return pOld;
} }
pStack->SetError(TX_ENDOF, p); pStack->SetError(TX_ENDOF, p);

View File

@ -51,7 +51,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
{ {
// la condition existe bel et bien // 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() ) if ( pStk->IsOk() )
{ {
// le bloc d'instruction est ok (peut être vide) // 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)) if (IsOfType(p, ID_ELSE))
{ {
// si oui, compile le bloc d'instruction qui suit // 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()) if (!pStk->IsOk())
{ {
// il n'y a pas de bloc correct après le else // 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 // 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 CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // 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 // selon la reprise, on peut être dans l'un des 2 états
if( pile->GivState() == 0 ) if( pile->GivState() == 0 )
{ {
// évalue la condition // é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 // termine s'il y a une erreur
if ( !pile->IsOk() ) if ( !pile->IsOk() )
@ -105,21 +105,21 @@ BOOL CBotIf :: Execute(CBotStack* &pj)
} }
// passe dans le second état // 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 // second état, évalue les instructions associées
// le résultat de la condition est sur la pile // 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 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 else
{ {
if ( m_BlockElse != NULL && // s'il existe un bloc alternatif 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 // 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; if ( !bMain ) return;
@ -145,7 +145,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain)
// second état, évalue les instructions associées // second état, évalue les instructions associées
// le résultat de la condition est sur la pile // 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 if ( m_Block != NULL ) // bloc peut être absent
m_Block->RestoreState(pile, bMain); // interrompu ici ! m_Block->RestoreState(pile, bMain); // interrompu ici !

View File

@ -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; int error = 0;
Stop(); Stop();
@ -81,7 +81,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
// transforme le programme en Tokens // transforme le programme en Tokens
CBotToken* pBaseToken = CBotToken::CompileTokens(program, error); CBotToken* pBaseToken = CBotToken::CompileTokens(program, error);
if ( pBaseToken == NULL ) return FALSE; if ( pBaseToken == NULL ) return false;
CBotCStack* pStack = new CBotCStack(NULL); CBotCStack* pStack = new CBotCStack(NULL);
@ -115,7 +115,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
delete m_Prog; delete m_Prog;
m_Prog = NULL; m_Prog = NULL;
delete pBaseToken; delete pBaseToken;
return FALSE; return false;
} }
// CBotFunction* temp = NULL; // CBotFunction* temp = NULL;
@ -130,12 +130,12 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
if ( p->GivType() == ID_CLASS || if ( p->GivType() == ID_CLASS ||
( p->GivType() == ID_PUBLIC && p->GivNext()->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 CBotClass::Compile(p, pStack); // complète la définition de la classe
} }
else else
{ {
m_bCompileClass = FALSE; m_bCompileClass = false;
CBotFunction::Compile(p, pStack, next); CBotFunction::Compile(p, pStack, next);
if (next->IsExtern()) ListFonctions.Add(next->GivName()/* + next->GivParams()*/); if (next->IsExtern()) ListFonctions.Add(next->GivName()/* + next->GivParams()*/);
next->m_pProg = this; // garde le pointeur au module 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 #if STACKMEM
m_pStack->Delete(); m_pStack->Delete();
@ -179,7 +179,7 @@ BOOL CBotProgram::Start(const char* name)
if ( m_pRun == NULL ) if ( m_pRun == NULL )
{ {
m_ErrorCode = TX_NORUN; m_ErrorCode = TX_NORUN;
return FALSE; return false;
} }
#if STACKMEM #if STACKMEM
@ -190,10 +190,10 @@ BOOL CBotProgram::Start(const char* name)
m_pStack->SetBotCall(this); // bases pour les routines 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; CBotFunction* p = m_Prog;
while (p != NULL) while (p != NULL)
@ -202,15 +202,15 @@ BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet m
p = p->m_next; p = p->m_next;
} }
if ( p == NULL ) return FALSE; if ( p == NULL ) return false;
p->GetPosition(start, stop, modestart, modestop); 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; if (m_pStack == NULL || m_pRun == NULL) goto error;
@ -253,7 +253,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
delete m_pStack; delete m_pStack;
#endif #endif
m_pStack = NULL; 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 if ( ok ) m_pRun = NULL; // plus de fonction en exécution
@ -261,7 +261,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
error: error:
m_ErrorCode = TX_NORUN; m_ErrorCode = TX_NORUN;
return TRUE; return true;
} }
void CBotProgram::Stop() 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; FunctionName = NULL;
start = end = 0; start = end = 0;
if (m_pStack == NULL) return FALSE; if (m_pStack == NULL) return false;
m_pStack->GetRunPos(FunctionName, start, end); m_pStack->GetRunPos(FunctionName, start, end);
return TRUE; return true;
} }
CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level) CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level)
@ -321,7 +321,7 @@ long CBotProgram::GivIdent()
return m_Ident; return m_Ident;
} }
BOOL CBotProgram::GetError(int& code, int& start, int& end) bool CBotProgram::GetError(int& code, int& start, int& end)
{ {
code = m_ErrorCode; code = m_ErrorCode;
start = m_ErrorStart; start = m_ErrorStart;
@ -329,7 +329,7 @@ BOOL CBotProgram::GetError(int& code, int& start, int& end)
return code > 0; 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; code = m_ErrorCode;
start = m_ErrorStart; start = m_ErrorStart;
@ -358,8 +358,8 @@ CBotFunction* CBotProgram::GivFunctions()
return m_Prog; return m_Prog;
} }
BOOL CBotProgram::AddFunction(const char* name, bool CBotProgram::AddFunction(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)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
// mémorise les pointeurs aux deux fonctions // 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; size_t lg;
lg = fwrite(&w, sizeof( WORD ), 1, pf ); lg = fwrite(&w, sizeof( unsigned short ), 1, pf );
return (lg == 1); return (lg == 1);
} }
BOOL ReadWord(FILE* pf, WORD& w) bool ReadWord(FILE* pf, unsigned short& w)
{ {
size_t lg; size_t lg;
lg = fread(&w, sizeof( WORD ), 1, pf ); lg = fread(&w, sizeof( unsigned short ), 1, pf );
return (lg == 1); return (lg == 1);
} }
BOOL WriteFloat(FILE* pf, float w) bool WriteFloat(FILE* pf, float w)
{ {
size_t lg; size_t lg;
@ -394,7 +394,7 @@ BOOL WriteFloat(FILE* pf, float w)
return (lg == 1); return (lg == 1);
} }
BOOL ReadFloat(FILE* pf, float& w) bool ReadFloat(FILE* pf, float& w)
{ {
size_t lg; size_t lg;
@ -403,7 +403,7 @@ BOOL ReadFloat(FILE* pf, float& w)
return (lg == 1); return (lg == 1);
} }
BOOL WriteLong(FILE* pf, long w) bool WriteLong(FILE* pf, long w)
{ {
size_t lg; size_t lg;
@ -412,7 +412,7 @@ BOOL WriteLong(FILE* pf, long w)
return (lg == 1); return (lg == 1);
} }
BOOL ReadLong(FILE* pf, long& w) bool ReadLong(FILE* pf, long& w)
{ {
size_t lg; size_t lg;
@ -421,24 +421,24 @@ BOOL ReadLong(FILE* pf, long& w)
return (lg == 1); return (lg == 1);
} }
BOOL WriteString(FILE* pf, CBotString s) bool WriteString(FILE* pf, CBotString s)
{ {
size_t lg1, lg2; size_t lg1, lg2;
lg1 = s.GivLength(); lg1 = s.GivLength();
if (!WriteWord(pf, lg1)) return FALSE; if (!WriteWord(pf, lg1)) return false;
lg2 = fwrite(s, 1, lg1, pf ); lg2 = fwrite(s, 1, lg1, pf );
return (lg1 == lg2); return (lg1 == lg2);
} }
BOOL ReadString(FILE* pf, CBotString& s) bool ReadString(FILE* pf, CBotString& s)
{ {
WORD w; unsigned short w;
char buf[1000]; char buf[1000];
size_t lg1, lg2; size_t lg1, lg2;
if (!ReadWord(pf, w)) return FALSE; if (!ReadWord(pf, w)) return false;
lg1 = w; lg1 = w;
lg2 = fread(buf, 1, lg1, pf ); lg2 = fread(buf, 1, lg1, pf );
buf[lg2] = 0; buf[lg2] = 0;
@ -447,29 +447,29 @@ BOOL ReadString(FILE* pf, CBotString& s)
return (lg1 == lg2); return (lg1 == lg2);
} }
BOOL WriteType(FILE* pf, CBotTypResult type) bool WriteType(FILE* pf, CBotTypResult type)
{ {
int typ = type.GivType(); int typ = type.GivType();
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass; if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
if ( !WriteWord(pf, typ) ) return FALSE; if ( !WriteWord(pf, typ) ) return false;
if ( typ == CBotTypClass ) if ( typ == CBotTypClass )
{ {
CBotClass* p = type.GivClass(); CBotClass* p = type.GivClass();
if ( !WriteString(pf, p->GivName()) ) return FALSE; if ( !WriteString(pf, p->GivName()) ) return false;
} }
if ( type.Eq( CBotTypArrayBody ) || if ( type.Eq( CBotTypArrayBody ) ||
type.Eq( CBotTypArrayPointer ) ) type.Eq( CBotTypArrayPointer ) )
{ {
if ( !WriteWord(pf, type.GivLimite()) ) return FALSE; if ( !WriteWord(pf, type.GivLimite()) ) return false;
if ( !WriteType(pf, type.GivTypElem()) ) 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; unsigned short w, ww;
if ( !ReadWord(pf, w) ) return FALSE; if ( !ReadWord(pf, w) ) return false;
type.SetType(w); type.SetType(w);
if ( type.Eq( CBotTypIntrinsic ) ) if ( type.Eq( CBotTypIntrinsic ) )
@ -480,7 +480,7 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
if ( type.Eq( CBotTypClass ) ) if ( type.Eq( CBotTypClass ) )
{ {
CBotString s; CBotString s;
if ( !ReadString(pf, s) ) return FALSE; if ( !ReadString(pf, s) ) return false;
type = CBotTypResult( w, s ); type = CBotTypResult( w, s );
} }
@ -488,54 +488,54 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
type.Eq( CBotTypArrayBody ) ) type.Eq( CBotTypArrayBody ) )
{ {
CBotTypResult r; CBotTypResult r;
if ( !ReadWord(pf, ww) ) return FALSE; if ( !ReadWord(pf, ww) ) return false;
if ( !ReadType(pf, r) ) return FALSE; if ( !ReadType(pf, r) ) return false;
type = CBotTypResult( w, r ); type = CBotTypResult( w, r );
type.SetLimite((short)ww); 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); 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 ( m_pStack != NULL )
{ {
if (!WriteWord( pf, 1)) return FALSE; if (!WriteWord( pf, 1)) return false;
if (!WriteString( pf, m_pRun->GivName() )) return FALSE; if (!WriteString( pf, m_pRun->GivName() )) return false;
if (!m_pStack->SaveState(pf)) return FALSE; if (!m_pStack->SaveState(pf)) return false;
} }
else 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; unsigned short w;
CBotString s; CBotString s;
Stop(); Stop();
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w != CBOTVERSION ) return FALSE; if ( w != CBOTVERSION ) return false;
if (!ReadWord( pf, w )) return FALSE; if (!ReadWord( pf, w )) return false;
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
if (!ReadString( pf, s )) return FALSE; if (!ReadString( pf, s )) return false;
Start(s); // point de reprise Start(s); // point de reprise
#if STACKMEM #if STACKMEM
@ -547,12 +547,12 @@ BOOL CBotProgram::RestoreState(FILE* pf)
// récupère la pile depuis l'enregistrement // récupère la pile depuis l'enregistrement
// utilise un pointeur NULL (m_pStack) mais c'est ok comme ça // 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 m_pStack->SetBotCall(this); // bases pour les routines
// rétabli certains états dans la pile selon la structure // rétabli certains états dans la pile selon la structure
m_pRun->RestoreState(NULL, m_pStack, m_pInstance); m_pRun->RestoreState(NULL, m_pStack, m_pInstance);
return TRUE; return true;
} }
int CBotProgram::GivVersion() int CBotProgram::GivVersion()
@ -566,7 +566,7 @@ int CBotProgram::GivVersion()
CBotCall* CBotCall::m_ListCalls = NULL; CBotCall* CBotCall::m_ListCalls = NULL;
CBotCall::CBotCall(const char* name, 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)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
m_name = name; m_name = name;
@ -587,8 +587,8 @@ void CBotCall::Free()
delete CBotCall::m_ListCalls; delete CBotCall::m_ListCalls;
} }
BOOL CBotCall::AddFunction(const char* name, bool CBotCall::AddFunction(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)) CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
{ {
CBotCall* p = m_ListCalls; CBotCall* p = m_ListCalls;
@ -616,18 +616,18 @@ BOOL CBotCall::AddFunction(const char* name,
if (p) p->m_next = pp; if (p) p->m_next = pp;
else m_ListCalls = pp; else m_ListCalls = pp;
return TRUE; return true;
} }
// transforme le tableau de pointeurs aux variables // transforme le tableau de pointeurs aux variables
// en une liste de variables chaînées // 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; int i = 0;
CBotVar* pVar = NULL; CBotVar* pVar = NULL;
while( TRUE ) while( true )
{ {
ppVars[i]; ppVars[i];
if ( ppVars[i] == NULL ) break; if ( ppVars[i] == NULL ) break;
@ -686,16 +686,16 @@ void CBotCall::SetPUser(void* pUser)
m_pUser = pUser; m_pUser = pUser;
} }
int CBotCall::CheckCall(const char* name) bool CBotCall::CheckCall(const char* name)
{ {
CBotCall* p = m_ListCalls; CBotCall* p = m_ListCalls;
while ( p != NULL ) while ( p != NULL )
{ {
if ( name == p->GivName() ) return TRUE; if ( name == p->GivName() ) return true;
p = p->m_next; p = p->m_next;
} }
return FALSE; return false;
} }
@ -746,7 +746,7 @@ fund:
#if !STACKRUN #if !STACKRUN
// fait la liste des paramètres selon le contenu de la pile (pStackVar) // 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; CBotVar* pVarToDelete = pVar;
// crée une variable pour le résultat // crée une variable pour le résultat
@ -759,14 +759,14 @@ fund:
if ( pResult != pRes ) delete pRes; // si résultat différent rendu if ( pResult != pRes ) delete pRes; // si résultat différent rendu
delete pVarToDelete; delete pVarToDelete;
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
pStack->SetError(Exception, token); pStack->SetError(Exception, token);
} }
delete pResult; delete pResult;
return FALSE; return false;
} }
pStack->SetVar(pResult); pStack->SetVar(pResult);
@ -775,16 +775,16 @@ fund:
pStack->SetError(TX_NORETVAL, token); pStack->SetError(TX_NORETVAL, token);
} }
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
return TRUE; return true;
#else #else
CBotStack* pile = pStack->AddStackEOX(pt); 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) // 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; CBotVar* pVarToDelete = pVar;
// crée une variable pour le résultat // crée une variable pour le résultat
@ -804,7 +804,7 @@ fund:
#if STACKRUN #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; CBotCall* pt = m_ListCalls;
@ -817,22 +817,22 @@ BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
CBotStack* pile = pStack->RestoreStackEOX(pt); CBotStack* pile = pStack->RestoreStackEOX(pt);
if ( pile == NULL ) return TRUE; if ( pile == NULL ) return true;
CBotStack* pile2 = pile->RestoreStack(); CBotStack* pile2 = pile->RestoreStack();
return TRUE; return true;
} }
pt = pt->m_next; pt = pt->m_next;
} }
} }
return FALSE; return false;
} }
BOOL CBotCall::Run(CBotStack* pStack) bool CBotCall::Run(CBotStack* pStack)
{ {
CBotStack* pile = pStack->AddStackEOX(this); CBotStack* pile = pStack->AddStackEOX(this);
if ( pile == EOX ) return TRUE; if ( pile == EOX ) return true;
CBotVar* pVar = pile->GivVar(); CBotVar* pVar = pile->GivVar();
CBotStack* pile2 = pile->AddStack(); CBotStack* pile2 = pile->AddStack();
@ -842,20 +842,20 @@ BOOL CBotCall::Run(CBotStack* pStack)
int Exception = 0; int Exception = 0;
int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser()); int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser());
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
pStack->SetError(Exception); pStack->SetError(Exception);
} }
if ( pResult != pRes ) delete pResult; // si résultat différent rendu if ( pResult != pRes ) delete pResult; // si résultat différent rendu
return FALSE; return false;
} }
if ( pResult != NULL ) pStack->SetCopyVar( pResult ); if ( pResult != NULL ) pStack->SetCopyVar( pResult );
if ( pResult != pRes ) delete pResult; // si résultat différent rendu if ( pResult != pRes ) delete pResult; // si résultat différent rendu
return TRUE; return true;
} }
#endif #endif
@ -863,7 +863,7 @@ BOOL CBotCall::Run(CBotStack* pStack)
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
CBotCallMethode::CBotCallMethode(const char* name, 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)) CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
{ {
m_name = name; m_name = name;
@ -893,7 +893,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
{ {
if ( pt->m_name == name ) if ( pt->m_name == name )
{ {
CBotVar* pVar = MakeListVars(ppVar, TRUE); CBotVar* pVar = MakeListVars(ppVar, true);
CBotVar* pVar2 = pVar; CBotVar* pVar2 = pVar;
CBotTypResult r = pt->m_rComp(pThis, pVar2); CBotTypResult r = pt->m_rComp(pThis, pVar2);
int ret = r.GivType(); 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) // 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; CBotVar* pVarToDelete = pVar;
// puis appelle la routine externe au module // 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); int res = pt->m_rExec(pThis, pVar, pResult, Exception);
pStack->SetVar(pResult); pStack->SetVar(pResult);
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
@ -959,10 +959,10 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
pStack->SetError(Exception, pToken); pStack->SetError(Exception, pToken);
} }
delete pVarToDelete; delete pVarToDelete;
return FALSE; return false;
} }
delete pVarToDelete; delete pVarToDelete;
return TRUE; return true;
} }
pt = pt->m_next; 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) // 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; CBotVar* pVarToDelete = pVar;
int Exception = 0; int Exception = 0;
int res = pt->m_rExec(pThis, pVar, pResult, Exception); int res = pt->m_rExec(pThis, pVar, pResult, Exception);
pStack->SetVar(pResult); pStack->SetVar(pResult);
if (res == FALSE) if (res == false)
{ {
if (Exception!=0) if (Exception!=0)
{ {
@ -990,11 +990,11 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
pStack->SetError(Exception, pToken); pStack->SetError(Exception, pToken);
} }
delete pVarToDelete; delete pVarToDelete;
return FALSE; return false;
} }
delete pVarToDelete; delete pVarToDelete;
nIdent = pt->m_nFuncIdent; nIdent = pt->m_nFuncIdent;
return TRUE; return true;
} }
pt = pt->m_next; pt = pt->m_next;
} }
@ -1002,7 +1002,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
return -1; 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; if ( pVar == NULL ) return TX_LOWPARAM;
@ -1016,7 +1016,7 @@ BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
} }
pResult->SetValInt(i); pResult->SetValInt(i);
return TRUE; return true;
} }
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser ) CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
@ -1030,11 +1030,11 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
CBotString CBotProgram::m_DebugVarStr = ""; 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 ); pResult->SetValString( CBotProgram::m_DebugVarStr );
return TRUE; return true;
} }
CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser ) CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser )
@ -1103,7 +1103,8 @@ void CBotProgram::Init()
// une fonction juste pour les debug divers // une fonction juste pour les debug divers
CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug); CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug);
DeleteFile("CbotDebug.txt"); //TODO implement this deletion
// DeleteFile("CbotDebug.txt");
} }

View File

@ -13,9 +13,13 @@
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.////////////////////////////////////////////////////////////////////// // * along with this program. If not, see http://www.gnu.org/licenses/.//////////////////////////////////////////////////////////////////////
// gestion de la pile (stack)
//Management of the stack
#include "CBot.h" #include "CBot.h"
#include <cstdlib>
#include <cstring>
#define ITIMER 100 #define ITIMER 100
@ -24,13 +28,13 @@
// gestion de la pile d'exécution // gestion de la pile d'exécution
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
int CBotStack::m_initimer = ITIMER; // init la variable statique int CBotStack::m_initimer = ITIMER;
int CBotStack::m_timer = 0; // init la variable statique int CBotStack::m_timer = 0;
CBotVar* CBotStack::m_retvar = NULL; // init la variable statique CBotVar* CBotStack::m_retvar = NULL;
int CBotStack::m_error = 0; // init la variable statique int CBotStack::m_error = 0;
int CBotStack::m_start = 0; // init la variable statique int CBotStack::m_start = 0;
int CBotStack::m_end = 0; // init la variable statique int CBotStack::m_end = 0;
CBotString CBotStack::m_labelBreak=""; // init la variable statique CBotString CBotStack::m_labelBreak="";
void* CBotStack::m_pUser = NULL; void* CBotStack::m_pUser = NULL;
#if STACKMEM #if STACKMEM
@ -48,7 +52,7 @@ CBotStack* CBotStack::FirstStack()
// la vide totalement // la vide totalement
memset(p, 0, size); memset(p, 0, size);
p-> m_bBlock = TRUE; p-> m_bBlock = true;
m_timer = m_initimer; // met le timer au début m_timer = m_initimer; // met le timer au début
CBotStack* pp = p; CBotStack* pp = p;
@ -56,7 +60,7 @@ CBotStack* CBotStack::FirstStack()
int i; int i;
for ( i = 0 ; i< 10 ; i++ ) for ( i = 0 ; i< 10 ; i++ )
{ {
pp->m_bOver = TRUE; pp->m_bOver = true;
pp ++; pp ++;
} }
#ifdef _DEBUG #ifdef _DEBUG
@ -75,7 +79,7 @@ CBotStack* CBotStack::FirstStack()
CBotStack::CBotStack(CBotStack* ppapa) CBotStack::CBotStack(CBotStack* ppapa)
{ {
// constructeur doit exister, sinon le destructeur n'est jamais appelé ! // constructor must exist or the destructor is never called!
ASM_TRAP(); ASM_TRAP();
} }
@ -104,7 +108,7 @@ void CBotStack::Delete()
delete m_listVar; delete m_listVar;
CBotStack* p = m_prev; CBotStack* p = m_prev;
BOOL bOver = m_bOver; bool bOver = m_bOver;
#ifdef _DEBUG #ifdef _DEBUG
int n = m_index; int n = m_index;
#endif #endif
@ -122,7 +126,7 @@ void CBotStack::Delete()
// routine optimisée // routine optimisée
CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
{ {
if (m_next != NULL) if (m_next != NULL)
{ {
@ -150,11 +154,11 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock)
p->m_prev = this; p->m_prev = this;
p->m_state = 0; p->m_state = 0;
p->m_call = NULL; p->m_call = NULL;
p->m_bFunc = FALSE; p->m_bFunc = false;
return p; return p;
} }
CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
{ {
if (m_next != NULL) if (m_next != NULL)
{ {
@ -171,7 +175,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock)
return p; return p;
} }
CBotStack* CBotStack::AddStack2(BOOL bBlock) CBotStack* CBotStack::AddStack2(bool bBlock)
{ {
if (m_next2 != NULL) if (m_next2 != NULL)
{ {
@ -194,14 +198,14 @@ CBotStack* CBotStack::AddStack2(BOOL bBlock)
return p; return p;
} }
BOOL CBotStack::GivBlock() bool CBotStack::GivBlock()
{ {
return m_bBlock; 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 ? if (m_var != NULL) delete m_var; // valeur remplacée ?
m_var = pfils->m_var; // résultat transmis m_var = pfils->m_var; // résultat transmis
@ -213,9 +217,9 @@ BOOL CBotStack::Return(CBotStack* pfils)
return (m_error == 0); // interrompu si erreur 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 ? if (m_var != NULL) delete m_var; // valeur remplacée ?
m_var = pfils->m_var; // résultat transmis m_var = pfils->m_var; // résultat transmis
@ -224,11 +228,11 @@ BOOL CBotStack::ReturnKeep(CBotStack* pfils)
return (m_error == 0); // interrompu si erreur 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; m_error = TX_STACKOVER;
return TRUE; return true;
} }
#else #else
@ -239,7 +243,7 @@ CBotStack::CBotStack(CBotStack* ppapa)
m_next2 = NULL; m_next2 = NULL;
m_prev = ppapa; m_prev = ppapa;
m_bBlock = (ppapa == NULL) ? TRUE : FALSE; m_bBlock = (ppapa == NULL) ? true : false;
m_state = 0; m_state = 0;
m_step = 1; m_step = 1;
@ -247,13 +251,13 @@ CBotStack::CBotStack(CBotStack* ppapa)
if (ppapa == NULL) m_timer = m_initimer; // met le timer au début if (ppapa == NULL) m_timer = m_initimer; // met le timer au début
m_listVar = NULL; m_listVar = NULL;
m_bDontDelete = FALSE; m_bDontDelete = false;
m_var = NULL; m_var = NULL;
m_prog = NULL; m_prog = NULL;
m_instr = NULL; m_instr = NULL;
m_call = NULL; m_call = NULL;
m_bFunc = FALSE; m_bFunc = false;
} }
// destructeur // destructeur
@ -269,7 +273,7 @@ CBotStack::~CBotStack()
} }
// routine à optimiser // routine à optimiser
CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock) CBotStack* CBotStack::AddStack(CBotInstr* instr, bool bBlock)
{ {
if (m_next != NULL) if (m_next != NULL)
{ {
@ -284,7 +288,7 @@ CBotStack* CBotStack::AddStack(CBotInstr* instr, BOOL bBlock)
return p; return p;
} }
CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock) CBotStack* CBotStack::AddStackEOX(CBotCall* instr, bool bBlock)
{ {
if (m_next != NULL) if (m_next != NULL)
{ {
@ -305,7 +309,7 @@ CBotStack* CBotStack::AddStackEOX(CBotCall* instr, BOOL bBlock)
return p; return p;
} }
CBotStack* CBotStack::AddStack2(BOOL bBlock) CBotStack* CBotStack::AddStack2(bool bBlock)
{ {
if (m_next2 != NULL) if (m_next2 != NULL)
{ {
@ -322,9 +326,9 @@ CBotStack* CBotStack::AddStack2(BOOL bBlock)
return p; 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 ? if (m_var != NULL) delete m_var; // valeur remplacée ?
m_var = pfils->m_var; // résultat transmis m_var = pfils->m_var; // résultat transmis
@ -336,9 +340,9 @@ BOOL CBotStack::Return(CBotStack* pfils)
return (m_error == 0); // interrompu si erreur 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 #endif
@ -377,38 +381,38 @@ CBotStack* CBotStack::RestoreStackEOX(CBotCall* instr)
// routine pour l'exécution pas à pas // routine pour l'exécution pas à pas
BOOL CBotStack::IfStep() bool CBotStack::IfStep()
{ {
if ( m_initimer > 0 || m_step++ > 0 ) return FALSE; if ( m_initimer > 0 || m_step++ > 0 ) return false;
return TRUE; 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>=0 ) return false; // sortie normale
if ( m_error==-3 ) return FALSE; // sortie normale (return en cours) if ( m_error==-3 ) return false; // sortie normale (return en cours)
if (!m_labelBreak.IsEmpty() && (name[0] == 0 || m_labelBreak != name)) 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_error = 0;
m_labelBreak.Empty(); m_labelBreak.Empty();
return Return(pfils); 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)) 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_state = state; // où reprendre ?
m_error = 0; m_error = 0;
m_labelBreak.Empty(); m_labelBreak.Empty();
if ( m_next != EOX ) m_next->Delete(); // purge la pile au dessus if ( m_next != EOX ) m_next->Delete(); // purge la pile au dessus
return TRUE; return true;
} }
void CBotStack::SetBreak(int val, const char* name) void CBotStack::SetBreak(int val, const char* name)
@ -424,7 +428,7 @@ void CBotStack::SetBreak(int val, const char* name)
// remet sur la pile la valeur calculée par le dernier CBotReturn // 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) if (m_error == -3)
{ {
@ -432,7 +436,7 @@ BOOL CBotStack::GivRetVar(BOOL bRet)
m_var = m_retvar; m_var = m_retvar;
m_retvar = NULL; m_retvar = NULL;
m_error = 0; m_error = 0;
return TRUE; return true;
} }
return bRet; // interrompu par autre chose que return return bRet; // interrompu par autre chose que return
} }
@ -445,21 +449,18 @@ int CBotStack::GivError(int& start, int& end)
} }
// type d'instruction sur la pile
int CBotStack::GivType(int mode) int CBotStack::GivType(int mode)
{ {
if (m_var == NULL) return -1; if (m_var == NULL) return -1;
return m_var->GivType(mode); return m_var->GivType(mode);
} }
// type d'instruction sur la pile
CBotTypResult CBotStack::GivTypResult(int mode) CBotTypResult CBotStack::GivTypResult(int mode)
{ {
if (m_var == NULL) return -1; if (m_var == NULL) return -1;
return m_var->GivTypResult(mode); return m_var->GivTypResult(mode);
} }
// type d'instruction sur la pile
void CBotStack::SetType(CBotTypResult& type) void CBotStack::SetType(CBotTypResult& type)
{ {
if (m_var == NULL) return; if (m_var == NULL) return;
@ -467,9 +468,7 @@ void CBotStack::SetType(CBotTypResult& type)
} }
// trouve une variable par son token CBotVar* CBotStack::FindVar(CBotToken* &pToken, bool bUpdate, bool bModif)
// ce peut être une variable composée avec un point
CBotVar* CBotStack::FindVar(CBotToken* &pToken, BOOL bUpdate, BOOL bModif)
{ {
CBotStack* p = this; CBotStack* p = this;
CBotString name = pToken->GivString(); CBotString name = pToken->GivString();
@ -482,7 +481,7 @@ CBotVar* CBotStack::FindVar(CBotToken* &pToken, BOOL bUpdate, BOOL bModif)
if (pp->GivName() == name) if (pp->GivName() == name)
{ {
if ( bUpdate ) if ( bUpdate )
pp->Maj(m_pUser, FALSE); pp->Maj(m_pUser, false);
return pp; return pp;
} }
@ -512,10 +511,7 @@ CBotVar* CBotStack::FindVar(const char* name)
return NULL; return NULL;
} }
// retrouve une variable sur la pile selon son numéro d'identification CBotVar* CBotStack::FindVar(long ident, bool bUpdate, bool bModif)
// ce qui va plus vite que de comparer les noms.
CBotVar* CBotStack::FindVar(long ident, BOOL bUpdate, BOOL bModif)
{ {
CBotStack* p = this; CBotStack* p = this;
while (p != NULL) while (p != NULL)
@ -526,7 +522,7 @@ CBotVar* CBotStack::FindVar(long ident, BOOL bUpdate, BOOL bModif)
if (pp->GivUniqNum() == ident) if (pp->GivUniqNum() == ident)
{ {
if ( bUpdate ) if ( bUpdate )
pp->Maj(m_pUser, FALSE); pp->Maj(m_pUser, false);
return pp; return pp;
} }
@ -538,14 +534,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; CBotToken* pt = &Token;
return FindVar(pt, bUpdate, bModif); return FindVar(pt, bUpdate, bModif);
} }
CBotVar* CBotStack::CopyVar(CBotToken& Token, BOOL bUpdate) CBotVar* CBotStack::CopyVar(CBotToken& Token, bool bUpdate)
{ {
CBotVar* pVar = FindVar( Token, bUpdate ); CBotVar* pVar = FindVar( Token, bUpdate );
@ -557,7 +553,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; m_state = n;
@ -565,7 +561,7 @@ BOOL CBotStack::SetState(int n, int limite)
return ( m_timer > limite ); // interrompu si timer passé return ( m_timer > limite ); // interrompu si timer passé
} }
BOOL CBotStack::IncState(int limite) bool CBotStack::IncState(int limite)
{ {
m_state++; m_state++;
@ -603,7 +599,7 @@ void CBotStack::SetTimer(int n)
m_initimer = n; m_initimer = n;
} }
BOOL CBotStack::Execute() bool CBotStack::Execute()
{ {
CBotCall* instr = NULL; // instruction la plus élevée CBotCall* instr = NULL; // instruction la plus élevée
CBotStack* pile; CBotStack* pile;
@ -621,9 +617,9 @@ BOOL CBotStack::Execute()
p = p->m_next; 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 #if STACKMEM
pile->m_next->Delete(); pile->m_next->Delete();
@ -632,7 +628,7 @@ BOOL CBotStack::Execute()
#endif #endif
pile->m_next = EOX; // spécial pour reprise pile->m_next = EOX; // spécial pour reprise
return TRUE; return true;
} }
// met sur le stack le pointeur à une variable // met sur le stack le pointeur à une variable
@ -711,10 +707,10 @@ void CBotStack::AddVar(CBotVar* pVar)
void CBotStack::SetBotCall(CBotProgram* p) void CBotStack::SetBotCall(CBotProgram* p)
{ {
m_prog = 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; if ( ! bFirst ) return m_prog;
CBotStack* p = this; CBotStack* p = this;
@ -728,7 +724,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; CBotTypResult res;
@ -750,7 +746,7 @@ BOOL CBotStack::ExecuteCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBo
if (res.GivType() >= 0) return res.GivType(); if (res.GivType() >= 0) return res.GivType();
SetError(TX_NOCALL, token); SetError(TX_NOCALL, token);
return TRUE; return true;
} }
void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar) void CBotStack::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar)
@ -762,17 +758,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 ) if ( pVar == NULL )
{ {
return WriteWord(pf, 0); // met un terminateur return WriteWord(pf, 0); // met un terminateur
} }
if ( !pVar->Save0State(pf)) return FALSE; // entête commune if ( !pVar->Save0State(pf)) return false; // entête commune
if ( !pVar->Save1State(pf) ) return FALSE; // sauve selon la classe fille if ( !pVar->Save1State(pf) ) return false; // sauve selon la classe fille
pVar = pVar->GivNext(); pVar = pVar->GivNext();
} }
@ -856,7 +852,7 @@ CBotVar* CBotStack::GivStackVars(const char* &FunctionName, int level)
return p->m_listVar; return p->m_listVar;
} }
BOOL CBotStack::SaveState(FILE* pf) bool CBotStack::SaveState(FILE* pf)
{ {
if ( this == NULL ) // fin de l'arbre ? if ( this == NULL ) // fin de l'arbre ?
{ {
@ -865,33 +861,33 @@ BOOL CBotStack::SaveState(FILE* pf)
if ( m_next2 != NULL ) if ( m_next2 != NULL )
{ {
if (!WriteWord(pf, 2)) return FALSE; // une marque de poursuite if (!WriteWord(pf, 2)) return false; // une marque de poursuite
if (!m_next2->SaveState(pf)) return FALSE; if (!m_next2->SaveState(pf)) return false;
} }
else 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_bBlock)) return false; // est-ce un bloc local
if (!WriteWord(pf, m_state)) return FALSE; // dans quel état if (!WriteWord(pf, m_state)) return false; // dans quel état
if (!WriteWord(pf, 0)) return FALSE; // par compatibilité m_bDontDelete if (!WriteWord(pf, 0)) return false; // par compatibilité m_bDontDelete
if (!WriteWord(pf, m_step)) return FALSE; // dans quel état 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_var)) return false; // le résultat courant
if (!SaveVar(pf, m_listVar)) return FALSE; // les variables locales if (!SaveVar(pf, m_listVar)) return false; // les variables locales
return m_next->SaveState(pf); // enregistre la suite 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; pStack = NULL;
if (!ReadWord(pf, w)) return FALSE; if (!ReadWord(pf, w)) return false;
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
#if STACKMEM #if STACKMEM
if ( this == NULL ) pStack = FirstStack(); if ( this == NULL ) pStack = FirstStack();
@ -902,81 +898,81 @@ BOOL CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
if ( w == 2 ) 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; 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 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é // plus utilisé
if (!ReadWord(pf, w)) return FALSE; // pas à pas if (!ReadWord(pf, w)) return false; // pas à pas
pStack->m_step = w; pStack->m_step = w;
if (!CBotVar::RestoreState(pf, pStack->m_var)) return FALSE; // la variable temp 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_listVar)) return false;// les variables locales
return pStack->RestoreState(pf, pStack->m_next); 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, 100+m_mPrivate))return false; // variable privée ?
if (!WriteWord(pf, m_bStatic))return FALSE; // variable static ? 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_type.GivType()))return false; // enregiste le type (toujours non nul)
if (!WriteWord(pf, m_binit))return FALSE; // variable définie ? if (!WriteWord(pf, m_binit))return false; // variable définie ?
return WriteString(pf, m_token->GivString()); // et le nom de la variable 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 ( !m_defnum.IsEmpty() )
{ {
if(!WriteWord(pf, 200 )) return FALSE; // marqueur spécial if(!WriteWord(pf, 200 )) return false; // marqueur spécial
if(!WriteString(pf, m_defnum)) return FALSE; // nom de la valeur if(!WriteString(pf, m_defnum)) return false; // nom de la valeur
} }
return CBotVar::Save0State(pf); return CBotVar::Save0State(pf);
} }
BOOL CBotVarInt::Save1State(FILE* pf) bool CBotVarInt::Save1State(FILE* pf)
{ {
return WriteWord(pf, m_val); // la valeur de la variable 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 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 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 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 ( !WriteType(pf, m_type) ) return false;
if ( !WriteLong(pf, m_ItemIdent) ) return FALSE; if ( !WriteLong(pf, m_ItemIdent) ) return false;
return SaveVar(pf, m_pVar); // contenu de l'objet 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; float ww;
CBotString name, s; CBotString name, s;
@ -986,31 +982,31 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
CBotVar* pNew = NULL; CBotVar* pNew = NULL;
CBotVar* pPrev = 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 (!ReadWord(pf, w)) return false; // privé ou type ?
if ( w == 0 ) return TRUE; if ( w == 0 ) return true;
CBotString defnum; CBotString defnum;
if ( w == 200 ) if ( w == 200 )
{ {
if (!ReadString(pf, defnum)) return FALSE; // nombre avec un identifiant if (!ReadString(pf, defnum)) return false; // nombre avec un identifiant
if (!ReadWord(pf, w)) return FALSE; // type if (!ReadWord(pf, w)) return false; // type
} }
prv = 100; st = 0; prv = 100; st = 0;
if ( w >= 100 ) if ( w >= 100 )
{ {
prv = w; prv = w;
if (!ReadWord(pf, st)) return FALSE; // statique if (!ReadWord(pf, st)) return false; // statique
if (!ReadWord(pf, w)) return FALSE; // type if (!ReadWord(pf, w)) return false; // type
} }
if ( w == CBotTypClass ) w = CBotTypIntrinsic; // forcément intrinsèque 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()); CBotToken token(name, CBotString());
@ -1019,17 +1015,17 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
case CBotTypInt: case CBotTypInt:
case CBotTypBoolean: case CBotTypBoolean:
pNew = CBotVar::Create(&token, w); // crée une variable 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); pNew->SetValInt((short)w, defnum);
break; break;
case CBotTypFloat: case CBotTypFloat:
pNew = CBotVar::Create(&token, w); // crée une variable pNew = CBotVar::Create(&token, w); // crée une variable
if (!ReadFloat(pf, ww)) return FALSE; if (!ReadFloat(pf, ww)) return false;
pNew->SetValFloat(ww); pNew->SetValFloat(ww);
break; break;
case CBotTypString: case CBotTypString:
pNew = CBotVar::Create(&token, w); // crée une variable pNew = CBotVar::Create(&token, w); // crée une variable
if (!ReadString(pf, s)) return FALSE; if (!ReadString(pf, s)) return false;
pNew->SetValString(s); pNew->SetValString(s);
break; break;
@ -1039,17 +1035,17 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
{ {
CBotTypResult r; CBotTypResult r;
long id; long id;
if (!ReadType(pf, r)) return FALSE; // type complet if (!ReadType(pf, r)) return false; // type complet
if (!ReadLong(pf, id) ) return FALSE; if (!ReadLong(pf, id) ) return false;
// if (!ReadString(pf, s)) return FALSE; // if (!ReadString(pf, s)) return false;
{ {
CBotVar* p = NULL; CBotVar* p = NULL;
if ( id ) p = CBotVarClass::Find(id) ; if ( id ) p = CBotVarClass::Find(id) ;
pNew = new CBotVarClass(&token, r); // crée directement une instance pNew = new CBotVarClass(&token, r); // crée directement une instance
// attention cptuse = 0 // attention cptuse = 0
if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return FALSE; if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return false;
pNew->SetIdent(id); pNew->SetIdent(id);
if ( p != NULL ) if ( p != NULL )
@ -1063,7 +1059,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
case CBotTypPointer: case CBotTypPointer:
case CBotTypNullPointer: 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 pNew = CBotVar::Create(&token, CBotTypResult(w, s));// crée une variable
CBotVarClass* p = NULL; CBotVarClass* p = NULL;
@ -1073,7 +1069,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
// restitue une copie de l'instance d'origine // restitue une copie de l'instance d'origine
CBotVar* pInstance = NULL; CBotVar* pInstance = NULL;
if ( !CBotVar::RestoreState( pf, pInstance ) ) return FALSE; if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus
// if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // plutôt celui-ci ! // if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // plutôt celui-ci !
@ -1084,13 +1080,13 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
case CBotTypArrayPointer: case CBotTypArrayPointer:
{ {
CBotTypResult r; CBotTypResult r;
if (!ReadType(pf, r)) return FALSE; if (!ReadType(pf, r)) return false;
pNew = CBotVar::Create(&token, r); // crée une variable pNew = CBotVar::Create(&token, r); // crée une variable
// restitue une copie de l'instance d'origine // restitue une copie de l'instance d'origine
CBotVar* pInstance = NULL; CBotVar* pInstance = NULL;
if ( !CBotVar::RestoreState( pf, pInstance ) ) return FALSE; if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus ((CBotVarPointer*)pNew)->SetPointer( pInstance ); // et pointe dessus
} }
break; break;
@ -1106,7 +1102,7 @@ BOOL CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
pNew->SetPrivate(prv-100); pNew->SetPrivate(prv-100);
pPrev = pNew; pPrev = pNew;
} }
return TRUE; return true;
} }
@ -1133,12 +1129,12 @@ CBotCStack::CBotCStack(CBotCStack* ppapa)
m_error = 0; m_error = 0;
m_start = 0; m_start = 0;
m_end = 0; m_end = 0;
m_bBlock = TRUE; m_bBlock = true;
} }
else else
{ {
m_start = ppapa->m_start; m_start = ppapa->m_start;
m_bBlock = FALSE; m_bBlock = false;
} }
m_listVar = NULL; m_listVar = NULL;
@ -1156,7 +1152,7 @@ CBotCStack::~CBotCStack()
} }
// utilisé uniquement à la compilation // 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 if (m_next != NULL) return m_next; // reprise dans une pile existante
@ -1291,7 +1287,7 @@ CBotVar* CBotCStack::CopyVar(CBotToken& Token)
return pCopy; return pCopy;
} }
BOOL CBotCStack::IsOk() bool CBotCStack::IsOk()
{ {
return (m_error == 0); return (m_error == 0);
} }
@ -1325,15 +1321,15 @@ void CBotCStack::ResetError(int n, int start, int end)
m_end = end; m_end = end;
} }
BOOL CBotCStack::NextToken(CBotToken* &p) bool CBotCStack::NextToken(CBotToken* &p)
{ {
CBotToken* pp = p; CBotToken* pp = p;
p = p->GivNext(); p = p->GivNext();
if (p!=NULL) return TRUE; if (p!=NULL) return true;
SetError(TX_ENDOF, pp->GivEnd()); SetError(TX_ENDOF, pp->GivEnd());
return FALSE; return false;
} }
void CBotCStack::SetBotCall(CBotProgram* p) void CBotCStack::SetBotCall(CBotProgram* p)
@ -1398,7 +1394,7 @@ void CBotCStack::AddVar(CBotVar* pVar)
// test si une variable est déjà définie localement // test si une variable est déjà définie localement
BOOL CBotCStack::CheckVarLocal(CBotToken* &pToken) bool CBotCStack::CheckVarLocal(CBotToken* &pToken)
{ {
CBotCStack* p = this; CBotCStack* p = this;
CBotString name = pToken->GivString(); CBotString name = pToken->GivString();
@ -1409,13 +1405,13 @@ BOOL CBotCStack::CheckVarLocal(CBotToken* &pToken)
while ( pp != NULL) while ( pp != NULL)
{ {
if (name == pp->GivName()) if (name == pp->GivName())
return TRUE; return true;
pp = pp->m_next; pp = pp->m_next;
} }
if ( p->m_bBlock ) return FALSE; if ( p->m_bBlock ) return false;
p = p->m_prev; p = p->m_prev;
} }
return FALSE; return false;
} }
CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent) CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nIdent)
@ -1440,11 +1436,11 @@ CBotTypResult CBotCStack::CompileCall(CBotToken* &p, CBotVar** ppVars, long& nId
// test si un nom de procédure est déjà défini quelque part // 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(); CBotString name = pToken->GivString();
if ( CBotCall::CheckCall(name) ) return TRUE; if ( CBotCall::CheckCall(name) ) return true;
CBotFunction* pp = m_prog->GivFunctions(); CBotFunction* pp = m_prog->GivFunctions();
while ( pp != NULL ) while ( pp != NULL )
@ -1453,7 +1449,7 @@ BOOL CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{ {
// les paramètres sont-ils exactement les mêmes ? // les paramètres sont-ils exactement les mêmes ?
if ( pp->CheckParam( pParam ) ) if ( pp->CheckParam( pParam ) )
return TRUE; return true;
} }
pp = pp->Next(); pp = pp->Next();
} }
@ -1465,11 +1461,11 @@ BOOL CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
{ {
// les paramètres sont-ils exactement les mêmes ? // les paramètres sont-ils exactement les mêmes ?
if ( pp->CheckParam( pParam ) ) if ( pp->CheckParam( pParam ) )
return TRUE; return true;
} }
pp = pp->m_nextpublic; pp = pp->m_nextpublic;
} }
return FALSE; return false;
} }

View File

@ -13,38 +13,132 @@
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.///////////////////////////////////////////////////// // * along with this program. If not, see http://www.gnu.org/licenses/./////////////////////////////////////////////////////
// gestion de chaine
// basé sur le CString de MFC //strings management
// mais moins complet
#include "CBot.h" #include "CBot.h"
#include <string.h> #include <cstdlib>
#include <cstring>
HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ?? #include <algorithm>
//Map is filled with id-string pars that are needed for CBot language parsing
const std::map<EID, char *> CBotString::s_keywordString =
{
{ID_IF, "if"},
{ID_ELSE, "else"},
{ID_WHILE, "while"},
{ID_DO, "do"},
{ID_FOR, "for"},
{ID_BREAK, "break"},
{ID_CONTINUE, "continue"},
{ID_SWITCH, "switch"},
{ID_CASE, "case"},
{ID_DEFAULT, "default"},
{ID_TRY, "try"},
{ID_THROW, "throw"},
{ID_CATCH, "catch"},
{ID_FINALLY, "finally"},
{ID_TXT_AND, "and"},
{ID_TXT_OR, "or"},
{ID_TXT_NOT, "not"},
{ID_RETURN, "return"},
{ID_CLASS, "class"},
{ID_EXTENDS, "extends"},
{ID_SYNCHO, "synchronized"},
{ID_NEW, "new"},
{ID_PUBLIC, "public"},
{ID_EXTERN, "extern"},
{ID_FINAL, "final"},
{ID_STATIC, "static"},
{ID_PROTECTED, "protected"},
{ID_PRIVATE, "private"},
{ID_REPEAT, "repeat"},
{ID_DEBUGDD, "STARTDEBUGDD"},
{ID_INT, "int"},
{ID_FLOAT, "float"},
{ID_BOOLEAN, "boolean"},
{ID_STRING, "string"},
{ID_VOID, "void"},
{ID_BOOL, "bool"},
{ID_TRUE, "true"},
{ID_FALSE, "false"},
{ID_NULL, "null"},
{ID_NAN, "nan"},
{ID_OPENPAR, "("},
{ID_CLOSEPAR, ")"},
{ID_OPBLK, "{"},
{ID_CLBLK, "}"},
{ID_SEP, "},"},
{ID_COMMA, ","},
{ID_DOTS, ":"},
{ID_DOT, "."},
{ID_OPBRK, "["},
{ID_CLBRK, "]"},
{ID_DBLDOTS, "::"},
{ID_LOGIC, "?"},
{ID_ADD, "+"},
{ID_SUB, "-"},
{ID_MUL, "*"},
{ID_DIV, "/"},
{ID_ASS, "="},
{ID_ASSADD, "+="},
{ID_ASSSUB, "-="},
{ID_ASSMUL, "*="},
{ID_ASSDIV, "/="},
{ID_ASSOR, "|="},
{ID_ASSAND, "&="},
{ID_ASSXOR, "^="},
{ID_ASSSL, "<<="},
{ID_ASSSR, ">>>="},
{ID_ASSASR, ">>="},
{ID_SL, "<<"},
{ID_SR, ">>"},
{ID_ASR, ">>"},
{ID_INC, "++"},
{ID_DEC, "--"},
{ID_LO, "<"},
{ID_HI, ">"},
{ID_LS, "<<"},
{ID_HS, ">="},
{ID_EQ, "=="},
{ID_NE, "!="},
{ID_AND, "&"},
{ID_XOR, "^"},
{ID_OR, "|"},
{ID_LOG_AND, "&&"},
{ID_LOG_OR, "||"},
{ID_LOG_NOT, "!"},
{ID_NOT, "~"},
{ID_MODULO, "%"},
{ID_POWER, "**"},
{ID_ASSMODULO, "%="},
{ID_SUPER, "super"},
{TX_UNDEF, "undefined"},
{TX_NAN, "not a number"}
};
CBotString::CBotString() CBotString::CBotString()
{ {
m_ptr = NULL; // chaine vide m_ptr = NULL;
m_lg = 0; m_lg = 0;
} }
CBotString::~CBotString() CBotString::~CBotString()
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr); //we can call free on null pointer as it's save
} }
CBotString::CBotString(const char* p) CBotString::CBotString(const char* p)
{ {
m_lg = lstrlen( p ); m_lg = strlen(p);
m_ptr = NULL; m_ptr = NULL;
if (m_lg>0) if (m_lg>0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, p); strcpy(m_ptr, p);
} }
} }
@ -56,7 +150,7 @@ CBotString::CBotString(const CBotString& srcString)
if (m_lg>0) if (m_lg>0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, srcString.m_ptr); strcpy(m_ptr, srcString.m_ptr);
} }
} }
@ -65,92 +159,88 @@ CBotString::CBotString(const CBotString& srcString)
int CBotString::GivLength() int CBotString::GivLength()
{ {
if ( m_ptr == NULL ) return 0; if (m_ptr == NULL) return 0;
return lstrlen( m_ptr ); return strlen( m_ptr );
} }
CBotString CBotString::Left(int nCount) const CBotString CBotString::Left(int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = 0; i < m_lg && i < nCount && i < 1999; i++) for (i = 0; i < m_lg && i < nCount && i < 1999; ++i)
{ {
chaine[i] = m_ptr[i]; chain[i] = m_ptr[i];
} }
chaine[i] = 0 ; chain[i] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
CBotString CBotString::Right(int nCount) const CBotString CBotString::Right(int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i = m_lg - nCount; int i = m_lg - nCount;
if ( i < 0 ) i = 0; if ( i < 0 ) i = 0;
int j; size_t j;
for ( j = 0 ; i < m_lg && i < 1999; i++) for (size_t j = 0 ; i < m_lg && i < 1999; ++i)
{ {
chaine[j++] = m_ptr[i]; chain[j++] = m_ptr[i];
} }
chaine[j] = 0 ; chain[j] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
CBotString CBotString::Mid(int nFirst, int nCount) const CBotString CBotString::Mid(int nFirst, int nCount) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; ++i)
for ( i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; i++)
{ {
chaine[i] = m_ptr[i]; chain[i] = m_ptr[i];
} }
chaine[i] = 0 ; chain[i] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
CBotString CBotString::Mid(int nFirst) const CBotString CBotString::Mid(int nFirst) const
{ {
char chaine[2000]; char chain[2000];
int i; size_t i;
for (i = nFirst; i < m_lg && i < 1999 ; ++i)
for ( i = nFirst; i < m_lg && i < 1999 ; i++)
{ {
chaine[i] = m_ptr[i]; chain[i] = m_ptr[i];
} }
chaine[i] = 0 ; chain[i] = 0 ;
return CBotString( chaine ); return CBotString(chain);
} }
int CBotString::Find(const char c) int CBotString::Find(const char c)
{ {
int i; for (size_t i = 0; i < m_lg; ++i)
for (i = 0; i < m_lg; i++)
{ {
if (m_ptr[i] == c) return i; if (m_ptr[i] == c) return i;
} }
return -1; return -1;
} }
int CBotString::Find(LPCTSTR lpsz) int CBotString::Find(const char * lpsz)
{ {
int i, j; int l = strlen(lpsz);
int l = lstrlen(lpsz);
for (i = 0; i <= m_lg-l; i++) for (size_t i = 0; i <= m_lg-l; ++i)
{ {
for (j = 0; j < l; j++) for (size_t j = 0; j < l; ++j)
{ {
if (m_ptr[i+j] != lpsz[j]) goto bad; if (m_ptr[i+j] != lpsz[j]) goto bad;
} }
@ -163,21 +253,21 @@ bad:;
int CBotString::ReverseFind(const char c) int CBotString::ReverseFind(const char c)
{ {
int i; int i;
for (i = m_lg-1; i >= 0; i--) for (i = m_lg-1; i >= 0; --i)
{ {
if (m_ptr[i] == c) return i; if (m_ptr[i] == c) return i;
} }
return -1; return -1;
} }
int CBotString::ReverseFind(LPCTSTR lpsz) int CBotString::ReverseFind(const char * lpsz)
{ {
int i, j; int i, j;
int l = lstrlen(lpsz); int l = strlen(lpsz);
for (i = m_lg-l; i >= 0; i--) for (i = m_lg-l; i >= 0; --i)
{ {
for (j = 0; j < l; j++) for (j = 0; j < l; ++j)
{ {
if (m_ptr[i+j] != lpsz[j]) goto bad; if (m_ptr[i+j] != lpsz[j]) goto bad;
} }
@ -195,7 +285,7 @@ CBotString CBotString::Mid(int start, int lg)
if ( lg < 0 ) lg = m_lg - start; if ( lg < 0 ) lg = m_lg - start;
char* p = (char*)malloc(m_lg+1); char* p = (char*)malloc(m_lg+1);
lstrcpy(p, m_ptr+start); strcpy(p, m_ptr+start);
p[lg] = 0; p[lg] = 0;
res = p; res = p;
@ -205,9 +295,7 @@ CBotString CBotString::Mid(int start, int lg)
void CBotString::MakeUpper() void CBotString::MakeUpper()
{ {
int i; for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
for ( i = 0; i < m_lg && i < 1999 ; i++)
{ {
char c = m_ptr[i]; char c = m_ptr[i];
if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A'; if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
@ -216,57 +304,50 @@ void CBotString::MakeUpper()
void CBotString::MakeLower() void CBotString::MakeLower()
{ {
int i; for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
for ( i = 0; i < m_lg && i < 1999 ; i++)
{ {
char c = m_ptr[i]; char c = m_ptr[i];
if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a'; if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
} }
} }
bool CBotString::LoadString(unsigned int id)
#define MAXSTRING 256
BOOL CBotString::LoadString(UINT id)
{ {
char buffer[MAXSTRING]; const char * str = NULL;
str = MapIdToString((EID)id);
m_lg = ::LoadString( m_hInstance, id, buffer, MAXSTRING );
if (m_ptr != NULL) free(m_ptr); if (m_ptr != NULL) free(m_ptr);
m_lg = strlen(str);
m_ptr = NULL; m_ptr = NULL;
if (m_lg > 0) if (m_lg > 0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, buffer); strcpy(m_ptr, str);
return TRUE; return true;
} }
return FALSE; return false;
} }
const CBotString& CBotString::operator=(const CBotString& stringSrc) const CBotString& CBotString::operator=(const CBotString& stringSrc)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL;
m_lg = stringSrc.m_lg; m_lg = stringSrc.m_lg;
m_ptr = NULL;
if (m_lg > 0) if (m_lg > 0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, stringSrc.m_ptr); strcpy(m_ptr, stringSrc.m_ptr);
} }
return *this; return *this;
} }
CBotString operator+(const CBotString& string, LPCTSTR lpsz) CBotString operator+(const CBotString& string, const char * lpsz)
{ {
CBotString s ( string ); CBotString s(string);
s += lpsz; s += lpsz;
return s; return s;
} }
@ -275,11 +356,11 @@ const CBotString& CBotString::operator+(const CBotString& stringSrc)
{ {
char* p = (char*)malloc(m_lg+stringSrc.m_lg+1); char* p = (char*)malloc(m_lg+stringSrc.m_lg+1);
lstrcpy(p, m_ptr); strcpy(p, m_ptr);
char* pp = p + m_lg; char* pp = p + m_lg;
lstrcpy(pp, stringSrc.m_ptr); strcpy(pp, stringSrc.m_ptr);
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
m_lg += stringSrc.m_lg; m_lg += stringSrc.m_lg;
@ -288,7 +369,7 @@ const CBotString& CBotString::operator+(const CBotString& stringSrc)
const CBotString& CBotString::operator=(const char ch) const CBotString& CBotString::operator=(const char ch)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_lg = 1; m_lg = 1;
@ -301,17 +382,17 @@ const CBotString& CBotString::operator=(const char ch)
const CBotString& CBotString::operator=(const char* pString) const CBotString& CBotString::operator=(const char* pString)
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL; m_ptr = NULL;
if ( pString != NULL ) if (pString != NULL)
{ {
m_lg = lstrlen(pString); m_lg = strlen(pString);
if (m_lg != 0) if (m_lg != 0)
{ {
m_ptr = (char*)malloc(m_lg+1); m_ptr = (char*)malloc(m_lg+1);
lstrcpy(m_ptr, pString); strcpy(m_ptr, pString);
} }
} }
@ -323,11 +404,11 @@ const CBotString& CBotString::operator+=(const char ch)
{ {
char* p = (char*)malloc(m_lg+2); 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++] = ch;
p[m_lg] = 0; p[m_lg] = 0;
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
@ -338,112 +419,122 @@ const CBotString& CBotString::operator+=(const CBotString& str)
{ {
char* p = (char*)malloc(m_lg+str.m_lg+1); char* p = (char*)malloc(m_lg+str.m_lg+1);
lstrcpy(p, m_ptr); strcpy(p, m_ptr);
char* pp = p + m_lg; char* pp = p + m_lg;
lstrcpy(pp, str.m_ptr); strcpy(pp, str.m_ptr);
m_lg = m_lg + str.m_lg; m_lg = m_lg + str.m_lg;
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = p; m_ptr = p;
return *this; return *this;
} }
BOOL CBotString::operator==(const CBotString& str) bool CBotString::operator==(const CBotString& str)
{ {
return Compare(str) == 0; return Compare(str) == 0;
} }
BOOL CBotString::operator==(const char* p) bool CBotString::operator==(const char* p)
{ {
return Compare(p) == 0; return Compare(p) == 0;
} }
BOOL CBotString::operator!=(const CBotString& str) bool CBotString::operator!=(const CBotString& str)
{ {
return Compare(str) != 0; return Compare(str) != 0;
} }
BOOL CBotString::operator!=(const char* p) bool CBotString::operator!=(const char* p)
{ {
return Compare(p) != 0; return Compare(p) != 0;
} }
BOOL CBotString::operator>(const CBotString& str) bool CBotString::operator>(const CBotString& str)
{ {
return Compare(str) > 0; return Compare(str) > 0;
} }
BOOL CBotString::operator>(const char* p) bool CBotString::operator>(const char* p)
{ {
return Compare(p) > 0; return Compare(p) > 0;
} }
BOOL CBotString::operator>=(const CBotString& str) bool CBotString::operator>=(const CBotString& str)
{ {
return Compare(str) >= 0; return Compare(str) >= 0;
} }
BOOL CBotString::operator>=(const char* p) bool CBotString::operator>=(const char* p)
{ {
return Compare(p) >= 0; return Compare(p) >= 0;
} }
BOOL CBotString::operator<(const CBotString& str) bool CBotString::operator<(const CBotString& str)
{ {
return Compare(str) < 0; return Compare(str) < 0;
} }
BOOL CBotString::operator<(const char* p) bool CBotString::operator<(const char* p)
{ {
return Compare(p) < 0; return Compare(p) < 0;
} }
BOOL CBotString::operator<=(const CBotString& str) bool CBotString::operator<=(const CBotString& str)
{ {
return Compare(str) <= 0; return Compare(str) <= 0;
} }
BOOL CBotString::operator<=(const char* p) bool CBotString::operator<=(const char* p)
{ {
return Compare(p) <= 0; return Compare(p) <= 0;
} }
BOOL CBotString::IsEmpty() const bool CBotString::IsEmpty() const
{ {
return (m_lg == 0); return (m_lg == 0);
} }
void CBotString::Empty() void CBotString::Empty()
{ {
if (m_ptr != NULL) free(m_ptr); free(m_ptr);
m_ptr = NULL; m_ptr = NULL;
m_lg = 0; 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; return m_ptr;
} }
int CBotString::Compare(LPCTSTR lpsz) const int CBotString::Compare(const char * lpsz) const
{ {
char* p = m_ptr; char* p = m_ptr;
if (lpsz == NULL) lpsz = nilstring; if (lpsz == NULL) lpsz = emptyString;
if (m_ptr == NULL) p = nilstring; if (m_ptr == NULL) p = emptyString;
return strcmp(p, lpsz); // wcscmp return strcmp(p, lpsz); // wcscmp
} }
const char * CBotString::MapIdToString(EID id)
{
if (s_keywordString.find(id) != s_keywordString.end())
{
return s_keywordString.at(id);
}
else
{
return emptyString;
}
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// tableaux de chaines // arrays of strings
CBotStringArray::CBotStringArray() CBotStringArray::CBotStringArray()
{ {
@ -453,7 +544,7 @@ CBotStringArray::CBotStringArray()
CBotStringArray::~CBotStringArray() CBotStringArray::~CBotStringArray()
{ {
SetSize(0); // détruit les données ! SetSize(0); // destroys data !
} }
@ -469,9 +560,8 @@ void CBotStringArray::Add(const CBotString& str)
m_pData[m_nSize-1] = str; m_pData[m_nSize-1] = str;
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// routines utilitaires // utility routines
static inline void ConstructElement(CBotString* pNewData) static inline void ConstructElement(CBotString* pNewData)
{ {
@ -518,7 +608,7 @@ static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount)
// sélect la taille du tableau // set the array size
void CBotStringArray::SetSize(int nNewSize) void CBotStringArray::SetSize(int nNewSize)
{ {
@ -527,14 +617,14 @@ void CBotStringArray::SetSize(int nNewSize)
// shrink to nothing // shrink to nothing
DestructElements(m_pData, m_nSize); DestructElements(m_pData, m_nSize);
delete[] (BYTE*)m_pData; delete[] (unsigned char *)m_pData;
m_pData = NULL; m_pData = NULL;
m_nSize = m_nMaxSize = 0; m_nSize = m_nMaxSize = 0;
} }
else if (m_pData == NULL) else if (m_pData == NULL)
{ {
// create one with exact size // 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); ConstructElements(m_pData, nNewSize);
@ -563,7 +653,7 @@ void CBotStringArray::SetSize(int nNewSize)
{ {
// heuristically determine growth when nGrowBy == 0 // heuristically determine growth when nGrowBy == 0
// (this avoids heap fragmentation in many situations) // (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; int nNewMax;
if (nNewSize < m_nMaxSize + nGrowBy) if (nNewSize < m_nMaxSize + nGrowBy)
@ -571,7 +661,7 @@ void CBotStringArray::SetSize(int nNewSize)
else else
nNewMax = nNewSize; // no slush 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 // copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString)); memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
@ -580,8 +670,8 @@ void CBotStringArray::SetSize(int nNewSize)
ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize); ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize);
// Ret rid of old stuff (note: no destructors called) // Get rid of old stuff (note: no destructors called)
delete[] (BYTE*)m_pData; delete[] (unsigned char *)m_pData;
m_pData = pNewData; m_pData = pNewData;
m_nSize = nNewSize; m_nSize = nNewSize;
m_nMaxSize = nNewMax; m_nMaxSize = nNewMax;
@ -599,5 +689,3 @@ CBotString& CBotStringArray::ElementAt(int nIndex)
return m_pData[nIndex]; return m_pData[nIndex];
} }

View File

@ -22,6 +22,7 @@
#include "CBot.h" #include "CBot.h"
#include <cstdarg>
CBotStringArray CBotToken::m_ListKeyWords; CBotStringArray CBotToken::m_ListKeyWords;
int CBotToken::m_ListIdKeyWords[200]; int CBotToken::m_ListIdKeyWords[200];
@ -188,27 +189,27 @@ void CBotToken::SetPos(int start, int end)
m_end = end; m_end = end;
} }
BOOL CharInList(const char c, const char* list) bool CharInList(const char c, const char* list)
{ {
int i = 0; int i = 0;
while (TRUE) while (true)
{ {
if (c == list[i++]) return TRUE; if (c == list[i++]) return true;
if (list[i] == 0) return FALSE; 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; int i = 0;
while (TRUE) while (true)
{ {
if (c == list[i++] && 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 // cherche le prochain token dans une phrase
// ne doit pas commencer par des séparateurs // ne doit pas commencer par des séparateurs
// qui sont pris avec le token précédent // 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 mot; // le mot trouvé
CBotString sep; // les séparateurs qui le suivent CBotString sep; // les séparateurs qui le suivent
char c; char c;
BOOL stop = first; bool stop = first;
if (*program == 0) return NULL; if (*program == 0) return NULL;
@ -262,14 +263,14 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first)
mot += c; // chaîne complète mot += c; // chaîne complète
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
} }
stop = TRUE; stop = true;
} }
// cas particulier pour les nombres // cas particulier pour les nombres
if ( CharInList(mot[0], num )) if ( CharInList(mot[0], num ))
{ {
BOOL bdot = FALSE; // trouvé un point ? bool bdot = false; // trouvé un point ?
BOOL bexp = FALSE; // trouvé un exposant ? bool bexp = false; // trouvé un exposant ?
char* liste = num; char* liste = num;
if (mot[0] == '0' && c == 'x') // valeur hexadécimale ? 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 ( 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' ) ) if ( !bexp && ( c == 'e' || c == 'E' ) )
{ {
bexp = TRUE; bexp = true;
mot += c; mot += c;
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
if ( c == '-' || if ( c == '-' ||
@ -298,7 +299,7 @@ cc: mot += c;
} }
} }
stop = TRUE; stop = true;
} }
if (CharInList(mot[0], sep3)) // un séparateur opérationnel ? if (CharInList(mot[0], sep3)) // un séparateur opérationnel ?
@ -310,13 +311,13 @@ cc: mot += c;
c = *(program++); // prochain caractère c = *(program++); // prochain caractère
} }
stop = TRUE; stop = true;
} }
} }
while (TRUE) while (true)
{ {
if (stop || c == 0 || CharInList(c, sep1)) if (stop || c == 0 || CharInList(c, sep1))
{ {
@ -381,7 +382,7 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
int pos = 0; int pos = 0;
error = 0; error = 0;
prv = tokenbase = NextToken(p, error, TRUE); prv = tokenbase = NextToken(p, error, true);
if (tokenbase == NULL) return NULL; if (tokenbase == NULL) return NULL;
@ -443,7 +444,7 @@ int CBotToken::GivKeyWords(const char* w)
return -1; return -1;
} }
BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token) bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
{ {
int i; int i;
int l = m_ListKeyDefine.GivSize(); int l = m_ListKeyDefine.GivSize();
@ -454,15 +455,16 @@ BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
{ {
token->m_IdKeyWord = m_ListKeyNums[i]; token->m_IdKeyWord = m_ListKeyNums[i];
token->m_type = TokenTypDef; token->m_type = TokenTypDef;
return TRUE; return true;
} }
} }
return FALSE; return false;
} }
// reprend la liste des mots clefs dans les ressources // reprend la liste des mots clefs dans les ressources
/// \todo Fixme Figure out how this should work.
void CBotToken::LoadKeyWords() void CBotToken::LoadKeyWords()
{ {
CBotString s; CBotString s;
@ -498,36 +500,36 @@ void CBotToken::LoadKeyWords()
} }
} }
BOOL CBotToken::DefineNum(const char* name, long val) bool CBotToken::DefineNum(const char* name, long val)
{ {
int i; int i;
int l = m_ListKeyDefine.GivSize(); int l = m_ListKeyDefine.GivSize();
for (i = 0; i < l; i++) 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_ListKeyDefine.Add( name );
m_ListKeyNums[i] = val; 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 || if (p->GivType() == type1 ||
p->GivType() == type2 ) p->GivType() == type2 )
{ {
p = p->GivNext(); p = p->GivNext();
return TRUE; return true;
} }
return FALSE; return false;
} }
// idem avec un nombre indéfini d'arguments // idem avec un nombre indéfini d'arguments
// il faut mettre un zéro comme dernier argument // 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 i = type1;
int max = 20; int max = 20;
@ -536,18 +538,18 @@ BOOL IsOfTypeList(CBotToken* &p, int type1, ...)
va_list marker; va_list marker;
va_start( marker, type1 ); /* Initialize variable arguments. */ va_start( marker, type1 ); /* Initialize variable arguments. */
while (TRUE) while (true)
{ {
if (type == i) if (type == i)
{ {
p = p->GivNext(); p = p->GivNext();
va_end( marker ); /* Reset variable arguments. */ va_end( marker ); /* Reset variable arguments. */
return TRUE; return true;
} }
if (--max == 0 || 0 == (i = va_arg( marker, int))) if (--max == 0 || 0 == (i = va_arg( marker, int)))
{ {
va_end( marker ); /* Reset variable arguments. */ va_end( marker ); /* Reset variable arguments. */
return FALSE; return false;
} }
} }
} }

View File

@ -33,5 +33,5 @@
// ) // )
extern BOOL IsOfType(CBotToken* &p, int type1, int type2 = -1); extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1);
extern BOOL IsOfTypeList(CBotToken* &p, int type1, ...); extern bool IsOfTypeList(CBotToken* &p, int type1, ...);

View File

@ -95,19 +95,19 @@ static int ListOp[] =
0, 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++; 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); if ( type == 0 ) return (test & 1);
type--; test /= 2; 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 ( left ->GivInit() > IS_DEF || right->GivInit() > IS_DEF )
{ {
if ( err != NULL ) *err = TX_OPNAN ; if ( err != NULL ) *err = TX_OPNAN ;
return TRUE; return true;
} }
return FALSE; return false;
} }
// fait l'opération sur 2 opérandes // 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 CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // 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 // 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 ( 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 // 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); CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
res->SetValInt(FALSE); res->SetValInt(false);
pStk1->SetVar(res); pStk1->SetVar(res);
return pStack->Return(pStk1); // transmet le résultat 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); CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
res->SetValInt(TRUE); res->SetValInt(true);
pStk1->SetVar(res); pStk1->SetVar(res);
return pStack->Return(pStk1); // transmet le résultat 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 // 2e état, évalue l'opérande de droite
if ( pStk2->GivState() == 0 ) if ( pStk2->GivState() == 0 )
{ {
if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ? if ( !m_rightop->Execute(pStk2) ) return false; // interrompu ici ?
pStk2->IncState(); pStk2->IncState();
} }
@ -342,7 +342,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
CBotTypResult type2 = pStk2->GivTypResult(); CBotTypResult type2 = pStk2->GivTypResult();
CBotStack* pStk3 = pStk2->AddStack(this); // ajoute un élément à la pile 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 // crée une variable temporaire pour y mettre le résultat
// quel est le type du 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 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; if ( !bMain ) return;
CBotStack* pStk1 = pStack->RestoreStack(this); // ajoute un élément à la pile 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 CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // ou le retrouve en cas de reprise
// if ( pStk1 == EOX ) return TRUE; // if ( pStk1 == EOX ) return true;
if ( pStk1->GivState() == 0 ) if ( pStk1->GivState() == 0 )
{ {
if ( !m_condition->Execute(pStk1) ) return FALSE; if ( !m_condition->Execute(pStk1) ) return false;
if (!pStk1->SetState(1)) 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 else
{ {
if ( !m_op2->Execute(pStk1) ) return FALSE; if ( !m_op2->Execute(pStk1) ) return false;
} }
return pStack->Return(pStk1); // transmet le résultat 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; if ( !bMain ) return;
@ -538,7 +538,7 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
return; return;
} }
if ( pStk1->GivVal() == TRUE ) if ( pStk1->GivVal() == true )
{ {
m_op1->RestoreState(pStk1, bMain); m_op1->RestoreState(pStk1, bMain);
} }
@ -557,7 +557,7 @@ void t()
#endif #endif
#if 01 #if 01
void t(BOOL t) void t(bool t)
{ {
int x; int x;
x = 1 + t ? 1 : 3 + 4 * 2 ; x = 1 + t ? 1 : 3 + 4 * 2 ;

View File

@ -33,9 +33,9 @@ CBotVar::CBotVar( )
m_InitExpr = NULL; m_InitExpr = NULL;
m_LimExpr = NULL; m_LimExpr = NULL;
m_type = -1; m_type = -1;
m_binit = FALSE; m_binit = false;
m_ident = 0; m_ident = 0;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
} }
@ -48,8 +48,8 @@ CBotVarInt::CBotVarInt( const CBotToken* name )
m_InitExpr = NULL; m_InitExpr = NULL;
m_LimExpr = NULL; m_LimExpr = NULL;
m_type = CBotTypInt; m_type = CBotTypInt;
m_binit = FALSE; m_binit = false;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
m_val = 0; m_val = 0;
@ -64,8 +64,8 @@ CBotVarFloat::CBotVarFloat( const CBotToken* name )
m_InitExpr = NULL; m_InitExpr = NULL;
m_LimExpr = NULL; m_LimExpr = NULL;
m_type = CBotTypFloat; m_type = CBotTypFloat;
m_binit = FALSE; m_binit = false;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
m_val = 0; m_val = 0;
@ -80,8 +80,8 @@ CBotVarString::CBotVarString( const CBotToken* name )
m_InitExpr = NULL; m_InitExpr = NULL;
m_LimExpr = NULL; m_LimExpr = NULL;
m_type = CBotTypString; m_type = CBotTypString;
m_binit = FALSE; m_binit = false;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
m_val.Empty(); m_val.Empty();
@ -96,8 +96,8 @@ CBotVarBoolean::CBotVarBoolean( const CBotToken* name )
m_InitExpr = NULL; m_InitExpr = NULL;
m_LimExpr = NULL; m_LimExpr = NULL;
m_type = CBotTypBoolean; m_type = CBotTypBoolean;
m_binit = FALSE; m_binit = false;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
m_val = 0; m_val = 0;
@ -139,10 +139,10 @@ void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type
m_pClass = NULL; m_pClass = NULL;
m_pParent = NULL; m_pParent = NULL;
m_binit = FALSE; m_binit = false;
m_bStatic = FALSE; m_bStatic = false;
m_mPrivate = 0; m_mPrivate = 0;
m_bConstructor = FALSE; m_bConstructor = false;
m_CptUse = 0; m_CptUse = 0;
m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum(); m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum();
@ -189,7 +189,7 @@ CBotVarClass::~CBotVarClass( )
void CBotVarClass::ConstructorSet() void CBotVarClass::ConstructorSet()
{ {
m_bConstructor = TRUE; m_bConstructor = true;
} }
@ -201,9 +201,9 @@ CBotVar::~CBotVar( )
void CBotVar::debug() void CBotVar::debug()
{ {
const char* p = (LPCTSTR) m_token->GivString(); const char* p = (const char*) m_token->GivString();
CBotString s = (LPCTSTR) GivValString(); CBotString s = (const char*) GivValString();
const char* v = (LPCTSTR) s; const char* v = (const char*) s;
if ( m_type.Eq(CBotTypClass) ) if ( m_type.Eq(CBotTypClass) )
{ {
@ -260,19 +260,19 @@ void* CBotVar::GivUserPtr()
return m_pUserPtr; return m_pUserPtr;
} }
BOOL CBotVar::Save1State(FILE* pf) bool CBotVar::Save1State(FILE* pf)
{ {
// cette routine "virtual" ne doit jamais être appellée, // cette routine "virtual" ne doit jamais être appellée,
// il doit y avoir une routine pour chaque classe fille (CBotVarInt, CBotVarFloat, etc) // il doit y avoir une routine pour chaque classe fille (CBotVarInt, CBotVarFloat, etc)
// ( voir le type dans m_type ) // ( voir le type dans m_type )
ASM_TRAP(); 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) /* 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)) while (type.Eq(CBotTypArrayBody))
{ {
type = type.GivTypElem(); 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; return array;
@ -397,7 +397,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
while (type.Eq(CBotTypArrayBody)) while (type.Eq(CBotTypArrayBody))
{ {
type = type.GivTypElem(); 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; return array;
@ -471,7 +471,7 @@ int CBotVar::GivInit()
return m_binit; return m_binit;
} }
void CBotVar::SetInit(BOOL bInit) void CBotVar::SetInit(int bInit)
{ {
m_binit = bInit; m_binit = bInit;
if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial
@ -533,14 +533,14 @@ CBotVar* CBotVar::GivItemList()
return NULL; return NULL;
} }
CBotVar* CBotVar::GivItem(int row, BOOL bGrow) CBotVar* CBotVar::GivItem(int row, bool bGrow)
{ {
ASM_TRAP(); ASM_TRAP();
return NULL; return NULL;
} }
// dit si une variable appartient à une classe donnée // dit si une variable appartient à une classe donnée
BOOL CBotVar::IsElemOfClass(const char* name) bool CBotVar::IsElemOfClass(const char* name)
{ {
CBotClass* pc = NULL; CBotClass* pc = NULL;
@ -555,11 +555,11 @@ BOOL CBotVar::IsElemOfClass(const char* name)
while ( pc != NULL ) while ( pc != NULL )
{ {
if ( pc->GivName() == name ) return TRUE; if ( pc->GivName() == name ) return true;
pc = pc->GivParent(); pc = pc->GivParent();
} }
return FALSE; return false;
} }
@ -611,7 +611,7 @@ void CBotVar::SetVal(CBotVar* var)
{ {
delete ((CBotVarClass*)this)->m_pVar; delete ((CBotVarClass*)this)->m_pVar;
((CBotVarClass*)this)->m_pVar = NULL; ((CBotVarClass*)this)->m_pVar = NULL;
Copy(var, FALSE); Copy(var, false);
} }
break; break;
default: default:
@ -621,7 +621,7 @@ void CBotVar::SetVal(CBotVar* var)
m_binit = var->m_binit; // copie l'état nan s'il y a 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; m_bStatic = bStatic;
} }
@ -631,12 +631,12 @@ void CBotVar::SetPrivate(int mPrivate)
m_mPrivate = mPrivate; m_mPrivate = mPrivate;
} }
BOOL CBotVar::IsStatic() bool CBotVar::IsStatic()
{ {
return m_bStatic; return m_bStatic;
} }
BOOL CBotVar::IsPrivate(int mode) bool CBotVar::IsPrivate(int mode)
{ {
return m_mPrivate >= mode; return m_mPrivate >= mode;
} }
@ -715,40 +715,40 @@ void CBotVar::Sub(CBotVar* left, CBotVar* right)
ASM_TRAP(); ASM_TRAP();
} }
BOOL CBotVar::Lo(CBotVar* left, CBotVar* right) bool CBotVar::Lo(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
BOOL CBotVar::Hi(CBotVar* left, CBotVar* right) bool CBotVar::Hi(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
BOOL CBotVar::Ls(CBotVar* left, CBotVar* right) bool CBotVar::Ls(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
BOOL CBotVar::Hs(CBotVar* left, CBotVar* right) bool CBotVar::Hs(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
BOOL CBotVar::Eq(CBotVar* left, CBotVar* right) bool CBotVar::Eq(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
BOOL CBotVar::Ne(CBotVar* left, CBotVar* right) bool CBotVar::Ne(CBotVar* left, CBotVar* right)
{ {
ASM_TRAP(); ASM_TRAP();
return FALSE; return false;
} }
void CBotVar::And(CBotVar* left, CBotVar* right) void CBotVar::And(CBotVar* left, CBotVar* right)
@ -800,7 +800,7 @@ void CBotVar::Dec()
ASM_TRAP(); ASM_TRAP();
} }
void CBotVar::Copy(CBotVar* pSrc, BOOL bName) void CBotVar::Copy(CBotVar* pSrc, bool bName)
{ {
ASM_TRAP(); ASM_TRAP();
} }
@ -837,7 +837,7 @@ void CBotVar::SetIndirection(CBotVar* pVar)
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarInt::Copy(CBotVar* pSrc, BOOL bName) void CBotVarInt::Copy(CBotVar* pSrc, bool bName)
{ {
CBotVarInt* p = (CBotVarInt*)pSrc; CBotVarInt* p = (CBotVarInt*)pSrc;
@ -860,7 +860,7 @@ void CBotVarInt::Copy(CBotVar* pSrc, BOOL bName)
void CBotVarInt::SetValInt(int val, const char* defnum) void CBotVarInt::SetValInt(int val, const char* defnum)
{ {
m_val = val; m_val = val;
m_binit = TRUE; m_binit = true;
m_defnum = defnum; m_defnum = defnum;
} }
@ -869,7 +869,7 @@ void CBotVarInt::SetValInt(int val, const char* defnum)
void CBotVarInt::SetValFloat(float val) void CBotVarInt::SetValFloat(float val)
{ {
m_val = (int)val; m_val = (int)val;
m_binit = TRUE; m_binit = true;
} }
int CBotVarInt::GivValInt() int CBotVarInt::GivValInt()
@ -910,13 +910,13 @@ CBotString CBotVarInt::GivValString()
void CBotVarInt::Mul(CBotVar* left, CBotVar* right) void CBotVarInt::Mul(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() * right->GivValInt(); m_val = left->GivValInt() * right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::Power(CBotVar* left, CBotVar* right) void CBotVarInt::Power(CBotVar* left, CBotVar* right)
{ {
m_val = (int) pow( (double) left->GivValInt() , (double) right->GivValInt() ); m_val = (int) pow( (double) left->GivValInt() , (double) right->GivValInt() );
m_binit = TRUE; m_binit = true;
} }
int CBotVarInt::Div(CBotVar* left, CBotVar* right) int CBotVarInt::Div(CBotVar* left, CBotVar* right)
@ -925,7 +925,7 @@ int CBotVarInt::Div(CBotVar* left, CBotVar* right)
if ( r != 0 ) if ( r != 0 )
{ {
m_val = left->GivValInt() / r; m_val = left->GivValInt() / r;
m_binit = TRUE; m_binit = true;
} }
return ( r == 0 ? TX_DIVZERO : 0 ); return ( r == 0 ? TX_DIVZERO : 0 );
} }
@ -936,7 +936,7 @@ int CBotVarInt::Modulo(CBotVar* left, CBotVar* right)
if ( r != 0 ) if ( r != 0 )
{ {
m_val = left->GivValInt() % r; m_val = left->GivValInt() % r;
m_binit = TRUE; m_binit = true;
} }
return ( r == 0 ? TX_DIVZERO : 0 ); return ( r == 0 ? TX_DIVZERO : 0 );
} }
@ -944,43 +944,43 @@ int CBotVarInt::Modulo(CBotVar* left, CBotVar* right)
void CBotVarInt::Add(CBotVar* left, CBotVar* right) void CBotVarInt::Add(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() + right->GivValInt(); m_val = left->GivValInt() + right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::Sub(CBotVar* left, CBotVar* right) void CBotVarInt::Sub(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() - right->GivValInt(); m_val = left->GivValInt() - right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::XOr(CBotVar* left, CBotVar* right) void CBotVarInt::XOr(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() ^ right->GivValInt(); m_val = left->GivValInt() ^ right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::And(CBotVar* left, CBotVar* right) void CBotVarInt::And(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() & right->GivValInt(); m_val = left->GivValInt() & right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::Or(CBotVar* left, CBotVar* right) void CBotVarInt::Or(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() | right->GivValInt(); m_val = left->GivValInt() | right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::SL(CBotVar* left, CBotVar* right) void CBotVarInt::SL(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() << right->GivValInt(); m_val = left->GivValInt() << right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::ASR(CBotVar* left, CBotVar* right) void CBotVarInt::ASR(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() >> right->GivValInt(); m_val = left->GivValInt() >> right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::SR(CBotVar* left, CBotVar* right) void CBotVarInt::SR(CBotVar* left, CBotVar* right)
@ -989,7 +989,7 @@ void CBotVarInt::SR(CBotVar* left, CBotVar* right)
int shift = right->GivValInt(); int shift = right->GivValInt();
if (shift>=1) source &= 0x7fffffff; if (shift>=1) source &= 0x7fffffff;
m_val = source >> shift; m_val = source >> shift;
m_binit = TRUE; m_binit = true;
} }
void CBotVarInt::Neg() void CBotVarInt::Neg()
@ -1014,32 +1014,32 @@ void CBotVarInt::Dec()
m_defnum.Empty(); m_defnum.Empty();
} }
BOOL CBotVarInt::Lo(CBotVar* left, CBotVar* right) bool CBotVarInt::Lo(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() < right->GivValInt(); return left->GivValInt() < right->GivValInt();
} }
BOOL CBotVarInt::Hi(CBotVar* left, CBotVar* right) bool CBotVarInt::Hi(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() > right->GivValInt(); return left->GivValInt() > right->GivValInt();
} }
BOOL CBotVarInt::Ls(CBotVar* left, CBotVar* right) bool CBotVarInt::Ls(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() <= right->GivValInt(); return left->GivValInt() <= right->GivValInt();
} }
BOOL CBotVarInt::Hs(CBotVar* left, CBotVar* right) bool CBotVarInt::Hs(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() >= right->GivValInt(); return left->GivValInt() >= right->GivValInt();
} }
BOOL CBotVarInt::Eq(CBotVar* left, CBotVar* right) bool CBotVarInt::Eq(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() == right->GivValInt(); return left->GivValInt() == right->GivValInt();
} }
BOOL CBotVarInt::Ne(CBotVar* left, CBotVar* right) bool CBotVarInt::Ne(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() != right->GivValInt(); return left->GivValInt() != right->GivValInt();
} }
@ -1048,7 +1048,7 @@ BOOL CBotVarInt::Ne(CBotVar* left, CBotVar* right)
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarFloat::Copy(CBotVar* pSrc, BOOL bName) void CBotVarFloat::Copy(CBotVar* pSrc, bool bName)
{ {
CBotVarFloat* p = (CBotVarFloat*)pSrc; CBotVarFloat* p = (CBotVarFloat*)pSrc;
@ -1071,13 +1071,13 @@ void CBotVarFloat::Copy(CBotVar* pSrc, BOOL bName)
void CBotVarFloat::SetValInt(int val, const char* s) void CBotVarFloat::SetValInt(int val, const char* s)
{ {
m_val = (float)val; m_val = (float)val;
m_binit = TRUE; m_binit = true;
} }
void CBotVarFloat::SetValFloat(float val) void CBotVarFloat::SetValFloat(float val)
{ {
m_val = val; m_val = val;
m_binit = TRUE; m_binit = true;
} }
int CBotVarFloat::GivValInt() int CBotVarFloat::GivValInt()
@ -1116,13 +1116,13 @@ CBotString CBotVarFloat::GivValString()
void CBotVarFloat::Mul(CBotVar* left, CBotVar* right) void CBotVarFloat::Mul(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValFloat() * right->GivValFloat(); m_val = left->GivValFloat() * right->GivValFloat();
m_binit = TRUE; m_binit = true;
} }
void CBotVarFloat::Power(CBotVar* left, CBotVar* right) void CBotVarFloat::Power(CBotVar* left, CBotVar* right)
{ {
m_val = (float)pow( left->GivValFloat() , right->GivValFloat() ); m_val = (float)pow( left->GivValFloat() , right->GivValFloat() );
m_binit = TRUE; m_binit = true;
} }
int CBotVarFloat::Div(CBotVar* left, CBotVar* right) int CBotVarFloat::Div(CBotVar* left, CBotVar* right)
@ -1131,7 +1131,7 @@ int CBotVarFloat::Div(CBotVar* left, CBotVar* right)
if ( r != 0 ) if ( r != 0 )
{ {
m_val = left->GivValFloat() / r; m_val = left->GivValFloat() / r;
m_binit = TRUE; m_binit = true;
} }
return ( r == 0 ? TX_DIVZERO : 0 ); return ( r == 0 ? TX_DIVZERO : 0 );
} }
@ -1142,7 +1142,7 @@ int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right)
if ( r != 0 ) if ( r != 0 )
{ {
m_val = (float)fmod( left->GivValFloat() , r ); m_val = (float)fmod( left->GivValFloat() , r );
m_binit = TRUE; m_binit = true;
} }
return ( r == 0 ? TX_DIVZERO : 0 ); return ( r == 0 ? TX_DIVZERO : 0 );
} }
@ -1150,13 +1150,13 @@ int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right)
void CBotVarFloat::Add(CBotVar* left, CBotVar* right) void CBotVarFloat::Add(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValFloat() + right->GivValFloat(); m_val = left->GivValFloat() + right->GivValFloat();
m_binit = TRUE; m_binit = true;
} }
void CBotVarFloat::Sub(CBotVar* left, CBotVar* right) void CBotVarFloat::Sub(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValFloat() - right->GivValFloat(); m_val = left->GivValFloat() - right->GivValFloat();
m_binit = TRUE; m_binit = true;
} }
void CBotVarFloat::Neg() 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(); return left->GivValFloat() < right->GivValFloat();
} }
BOOL CBotVarFloat::Hi(CBotVar* left, CBotVar* right) bool CBotVarFloat::Hi(CBotVar* left, CBotVar* right)
{ {
return left->GivValFloat() > right->GivValFloat(); return left->GivValFloat() > right->GivValFloat();
} }
BOOL CBotVarFloat::Ls(CBotVar* left, CBotVar* right) bool CBotVarFloat::Ls(CBotVar* left, CBotVar* right)
{ {
return left->GivValFloat() <= right->GivValFloat(); return left->GivValFloat() <= right->GivValFloat();
} }
BOOL CBotVarFloat::Hs(CBotVar* left, CBotVar* right) bool CBotVarFloat::Hs(CBotVar* left, CBotVar* right)
{ {
return left->GivValFloat() >= right->GivValFloat(); return left->GivValFloat() >= right->GivValFloat();
} }
BOOL CBotVarFloat::Eq(CBotVar* left, CBotVar* right) bool CBotVarFloat::Eq(CBotVar* left, CBotVar* right)
{ {
return left->GivValFloat() == right->GivValFloat(); return left->GivValFloat() == right->GivValFloat();
} }
BOOL CBotVarFloat::Ne(CBotVar* left, CBotVar* right) bool CBotVarFloat::Ne(CBotVar* left, CBotVar* right)
{ {
return left->GivValFloat() != right->GivValFloat(); return left->GivValFloat() != right->GivValFloat();
} }
@ -1209,7 +1209,7 @@ BOOL CBotVarFloat::Ne(CBotVar* left, CBotVar* right)
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarBoolean::Copy(CBotVar* pSrc, BOOL bName) void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName)
{ {
CBotVarBoolean* p = (CBotVarBoolean*)pSrc; CBotVarBoolean* p = (CBotVarBoolean*)pSrc;
@ -1231,14 +1231,14 @@ void CBotVarBoolean::Copy(CBotVar* pSrc, BOOL bName)
void CBotVarBoolean::SetValInt(int val, const char* s) void CBotVarBoolean::SetValInt(int val, const char* s)
{ {
m_val = (BOOL)val; m_val = (bool)val;
m_binit = TRUE; m_binit = true;
} }
void CBotVarBoolean::SetValFloat(float val) void CBotVarBoolean::SetValFloat(float val)
{ {
m_val = (BOOL)val; m_val = (bool)val;
m_binit = TRUE; m_binit = true;
} }
int CBotVarBoolean::GivValInt() int CBotVarBoolean::GivValInt()
@ -1275,31 +1275,31 @@ CBotString CBotVarBoolean::GivValString()
void CBotVarBoolean::And(CBotVar* left, CBotVar* right) void CBotVarBoolean::And(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() && right->GivValInt(); m_val = left->GivValInt() && right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarBoolean::Or(CBotVar* left, CBotVar* right) void CBotVarBoolean::Or(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() || right->GivValInt(); m_val = left->GivValInt() || right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right) void CBotVarBoolean::XOr(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValInt() ^ right->GivValInt(); m_val = left->GivValInt() ^ right->GivValInt();
m_binit = TRUE; m_binit = true;
} }
void CBotVarBoolean::Not() 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(); return left->GivValInt() == right->GivValInt();
} }
BOOL CBotVarBoolean::Ne(CBotVar* left, CBotVar* right) bool CBotVarBoolean::Ne(CBotVar* left, CBotVar* right)
{ {
return left->GivValInt() != right->GivValInt(); return left->GivValInt() != right->GivValInt();
} }
@ -1307,7 +1307,7 @@ BOOL CBotVarBoolean::Ne(CBotVar* left, CBotVar* right)
////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarString::Copy(CBotVar* pSrc, BOOL bName) void CBotVarString::Copy(CBotVar* pSrc, bool bName)
{ {
CBotVarString* p = (CBotVarString*)pSrc; CBotVarString* p = (CBotVarString*)pSrc;
@ -1328,7 +1328,7 @@ void CBotVarString::Copy(CBotVar* pSrc, BOOL bName)
void CBotVarString::SetValString(const char* p) void CBotVarString::SetValString(const char* p)
{ {
m_val = p; m_val = p;
m_binit = TRUE; m_binit = true;
} }
CBotString CBotVarString::GivValString() CBotString CBotVarString::GivValString()
@ -1353,36 +1353,36 @@ CBotString CBotVarString::GivValString()
void CBotVarString::Add(CBotVar* left, CBotVar* right) void CBotVarString::Add(CBotVar* left, CBotVar* right)
{ {
m_val = left->GivValString() + right->GivValString(); 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()); return (left->GivValString() == right->GivValString());
} }
BOOL CBotVarString::Ne(CBotVar* left, CBotVar* right) bool CBotVarString::Ne(CBotVar* left, CBotVar* right)
{ {
return (left->GivValString() != right->GivValString()); return (left->GivValString() != right->GivValString());
} }
BOOL CBotVarString::Lo(CBotVar* left, CBotVar* right) bool CBotVarString::Lo(CBotVar* left, CBotVar* right)
{ {
return (left->GivValString() == right->GivValString()); return (left->GivValString() == right->GivValString());
} }
BOOL CBotVarString::Hi(CBotVar* left, CBotVar* right) bool CBotVarString::Hi(CBotVar* left, CBotVar* right)
{ {
return (left->GivValString() == right->GivValString()); return (left->GivValString() == right->GivValString());
} }
BOOL CBotVarString::Ls(CBotVar* left, CBotVar* right) bool CBotVarString::Ls(CBotVar* left, CBotVar* right)
{ {
return (left->GivValString() == right->GivValString()); return (left->GivValString() == right->GivValString());
} }
BOOL CBotVarString::Hs(CBotVar* left, CBotVar* right) bool CBotVarString::Hs(CBotVar* left, CBotVar* right)
{ {
return (left->GivValString() == right->GivValString()); return (left->GivValString() == right->GivValString());
} }
@ -1391,7 +1391,7 @@ BOOL CBotVarString::Hs(CBotVar* left, CBotVar* right)
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// copie une variable dans une autre // 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 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) /* if (!bContinu && m_pMyThis != NULL)
m_pMyThis->Maj(pUser, TRUE);*/ m_pMyThis->Maj(pUser, true);*/
// une routine de mise à jour existe-elle ? // une routine de mise à jour existe-elle ?
@ -1569,7 +1569,7 @@ CBotVar* CBotVarClass::GivItemRef(int nIdent)
// pour la gestion d'un tableau // pour la gestion d'un tableau
// bExtend permet d'agrandir le tableau, mais pas au dela de la taille fixée par SetArray() // 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; CBotVar* p = m_pVar;
@ -1728,14 +1728,14 @@ CBotVarClass* CBotVarClass::Find(long id)
return NULL; return NULL;
} }
BOOL CBotVarClass::Eq(CBotVar* left, CBotVar* right) bool CBotVarClass::Eq(CBotVar* left, CBotVar* right)
{ {
CBotVar* l = left->GivItemList(); CBotVar* l = left->GivItemList();
CBotVar* r = right->GivItemList(); CBotVar* r = right->GivItemList();
while ( l != NULL && r != NULL ) while ( l != NULL && r != NULL )
{ {
if ( l->Ne(l, r) ) return FALSE; if ( l->Ne(l, r) ) return false;
l = l->GivNext(); l = l->GivNext();
r = r->GivNext(); r = r->GivNext();
} }
@ -1744,14 +1744,14 @@ BOOL CBotVarClass::Eq(CBotVar* left, CBotVar* right)
return l == r; return l == r;
} }
BOOL CBotVarClass::Ne(CBotVar* left, CBotVar* right) bool CBotVarClass::Ne(CBotVar* left, CBotVar* right)
{ {
CBotVar* l = left->GivItemList(); CBotVar* l = left->GivItemList();
CBotVar* r = right->GivItemList(); CBotVar* r = right->GivItemList();
while ( l != NULL && r != NULL ) while ( l != NULL && r != NULL )
{ {
if ( l->Ne(l, r) ) return TRUE; if ( l->Ne(l, r) ) return true;
l = l->GivNext(); l = l->GivNext();
r = r->GivNext(); r = r->GivNext();
} }
@ -1775,7 +1775,7 @@ CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type )
m_type = type; m_type = type;
m_type.SetType(CBotTypArrayPointer); m_type.SetType(CBotTypArrayPointer);
m_binit = FALSE; m_binit = false;
m_pInstance = NULL; // la liste des éléments du tableau m_pInstance = NULL; // la liste des éléments du tableau
} }
@ -1786,7 +1786,7 @@ CBotVarArray::~CBotVarArray()
} }
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarArray::Copy(CBotVar* pSrc, BOOL bName) void CBotVarArray::Copy(CBotVar* pSrc, bool bName)
{ {
if ( pSrc->GivType() != CBotTypArrayPointer ) if ( pSrc->GivType() != CBotTypArrayPointer )
ASM_TRAP(); ASM_TRAP();
@ -1811,7 +1811,7 @@ void CBotVarArray::Copy(CBotVar* pSrc, BOOL bName)
void CBotVarArray::SetPointer(CBotVar* pVarClass) 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 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 // car le décrément peut détruire l'object
@ -1839,7 +1839,7 @@ CBotVarClass* CBotVarArray::GivPointer()
return m_pInstance->GivPointer(); return m_pInstance->GivPointer();
} }
CBotVar* CBotVarArray::GivItem(int n, BOOL bExtend) CBotVar* CBotVarArray::GivItem(int n, bool bExtend)
{ {
if ( m_pInstance == NULL ) if ( m_pInstance == NULL )
{ {
@ -1864,9 +1864,9 @@ CBotString CBotVarArray::GivValString()
return m_pInstance->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 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; m_type = type;
if ( !type.Eq(CBotTypNullPointer) ) if ( !type.Eq(CBotTypNullPointer) )
m_type.SetType(CBotTypPointer); // quoi qu'il en soit, c'est un pointeur m_type.SetType(CBotTypPointer); // quoi qu'il en soit, c'est un pointeur
m_binit = FALSE; m_binit = false;
m_pClass = NULL; m_pClass = NULL;
m_pVarClass = NULL; // sera défini par un SetPointer() 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 ) /* 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) CBotVar* CBotVarPointer::GivItem(const char* name)
@ -1950,7 +1950,7 @@ void CBotVarPointer::ConstructorSet()
void CBotVarPointer::SetPointer(CBotVar* pVarClass) 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 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 // 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 ( 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 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 // sauve aussi une copie de l'instance
return SaveVar(pf, GivPointer()); return SaveVar(pf, GivPointer());
} }
// copie une variable dans une autre // copie une variable dans une autre
void CBotVarPointer::Copy(CBotVar* pSrc, BOOL bName) void CBotVarPointer::Copy(CBotVar* pSrc, bool bName)
{ {
if ( pSrc->GivType() != CBotTypPointer && if ( pSrc->GivType() != CBotTypPointer &&
pSrc->GivType() != CBotTypNullPointer) pSrc->GivType() != CBotTypNullPointer)
@ -2054,26 +2054,26 @@ void CBotVarPointer::Copy(CBotVar* pSrc, BOOL bName)
if (m_ident == 0 ) m_ident = p->m_ident; 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* l = left->GivPointer();
CBotVarClass* r = right->GivPointer(); CBotVarClass* r = right->GivPointer();
if ( l == r ) return TRUE; if ( l == r ) return true;
if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return TRUE; if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return true;
if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return TRUE; if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return true;
return FALSE; return false;
} }
BOOL CBotVarPointer::Ne(CBotVar* left, CBotVar* right) bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right)
{ {
CBotVarClass* l = left->GivPointer(); CBotVarClass* l = left->GivPointer();
CBotVarClass* r = right->GivPointer(); CBotVarClass* r = right->GivPointer();
if ( l == r ) return FALSE; if ( l == r ) return false;
if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return FALSE; if ( l == NULL && r->GivUserPtr() == OBJECTDELETED ) return false;
if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return FALSE; if ( r == NULL && l->GivUserPtr() == OBJECTDELETED ) return false;
return TRUE; 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); 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 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; return m_type == type;
} }

View File

@ -66,7 +66,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
// la condition existe // la condition existe
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -83,31 +83,31 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "while" // 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 CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // 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) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue la condition // é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 // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // 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 return pj->Return(pile); // transmet le résultat et libère la pile
} }
// la condition est vrai, passe dans le second mode // 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: case 1:
// évalue le bloc d'instruction associé // évalue le bloc d'instruction associé
@ -125,12 +125,12 @@ BOOL CBotWhile :: Execute(CBotStack* &pj)
} }
// repasse au test pour recommencer // repasse au test pour recommencer
if (!pile->SetState(0, 0)) return FALSE; if (!pile->SetState(0, 0)) return false;
continue; continue;
} }
} }
void CBotWhile :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile 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); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -221,19 +221,19 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "repeat" // 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 CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // 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) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue le nombre d'itération // é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 // 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" // 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 continue; // passe à la suite
case 1: case 1:
@ -269,12 +269,12 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj)
} }
// repasse au test pour recommencer // repasse au test pour recommencer
if (!pile->SetState(pile->GivState()-1, 0)) return FALSE; if (!pile->SetState(pile->GivState()-1, 0)) return false;
continue; continue;
} }
} }
void CBotRepeat :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile 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 // cherche un bloc d'instruction après le do
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
@ -358,15 +358,15 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "do" // 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 CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
// ou le retrouve en cas de reprise // 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) { // il y a 2 états possibles (selon reprise)
case 0: case 0:
// évalue le bloc d'instruction associé // é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 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: case 1:
// évalue la condition // é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 // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // 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 return pj->Return(pile); // transmet le résultat et libère la pile
} }
// repasse au bloc d'instruction pour recommencer // repasse au bloc d'instruction pour recommencer
if (!pile->SetState(0, 0)) return FALSE; if (!pile->SetState(0, 0)) return false;
continue; continue;
} }
} }
void CBotDo :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; 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 // compile les instructions pour initialisation
inst->m_Init = CBotListExpression::Compile( p, pStk ); 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 ? if ( IsOfType(p, ID_CLOSEPAR)) // manque la parenthèse ?
{ {
IncLvl(inst->m_label); IncLvl(inst->m_label);
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
DecLvl(); DecLvl();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
return pStack->Return(inst, pStk);; return pStack->Return(inst, pStk);;
@ -510,39 +510,39 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute l'instruction "for" // 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 // 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) { // il y a 4 états possibles (selon reprise)
case 0: case 0:
// évalue l'initialisation // évalue l'initialisation
if ( m_Init != NULL && if ( m_Init != NULL &&
!m_Init->Execute(pile) ) return FALSE; // interrompu ici ? !m_Init->Execute(pile) ) return false; // interrompu ici ?
if (!pile->SetState(1)) return FALSE; // prêt pour la suite if (!pile->SetState(1)) return false; // prêt pour la suite
case 1: case 1:
// évalue la condition // évalue la condition
if ( m_Test != NULL ) // pas de condition ? -> vrai ! 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 // le résultat de la condition est sur la pile
// termine s'il y a une erreur ou si la condition est fausse // 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 return pj->Return(pile); // transmet le résultat et libère la pile
} }
} }
// la condition est vrai, passe à la suite // 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: case 2:
// évalue le bloc d'instruction associé // é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 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: case 3:
// évalue l'incrémentation // évalue l'incrémentation
if ( m_Incr != NULL && 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 // 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; continue;
} }
} }
void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotFor :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -583,28 +583,28 @@ void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain)
{ // il y a 4 états possibles (selon reprise) { // il y a 4 états possibles (selon reprise)
case 0: case 0:
// évalue l'initialisation // é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; return;
case 1: 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 // é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; return;
case 2: 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é // é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; return;
case 3: 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 // é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; return;
} }
} }
@ -629,10 +629,10 @@ CBotListExpression::~CBotListExpression()
static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack) static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack)
{ {
CBotInstr* i = CBotInt::Compile( p, pStack, FALSE, TRUE ); // est-ce une déclaration d'un entier ? 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 = 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 = 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 = CBotIString::Compile( p, pStack, false, true ); // ou d'une chaîne ?
if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression
return i; return i;
} }
@ -660,7 +660,7 @@ CBotInstr* CBotListExpression::Compile(CBotToken* &p, CBotCStack* pStack)
return NULL; return NULL;
} }
BOOL CBotListExpression::Execute(CBotStack* &pj) bool CBotListExpression::Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack();// indispensable CBotStack* pile = pj->AddStack();// indispensable
CBotInstr* p = m_Expr; // la première expression CBotInstr* p = m_Expr; // la première expression
@ -668,17 +668,17 @@ BOOL CBotListExpression::Execute(CBotStack* &pj)
int state = pile->GivState(); int state = pile->GivState();
while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue 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(); p = p->GivNext();
if ( p == NULL ) break; 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); return pj->Return(pile);
} }
void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain) void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
{ {
CBotStack* pile = pj; CBotStack* pile = pj;
int state = 0x7000; int state = 0x7000;
@ -694,7 +694,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain)
while (p != NULL && state-->0) while (p != NULL && state-->0)
{ {
p->RestoreState(pile, FALSE); p->RestoreState(pile, false);
p = p->GivNext(); // revient sur l'opération interrompue 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); return pStack->Return(NULL, pStk);
} }
CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, TRUE ); CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, true );
if ( !pStk->IsOk() ) if ( !pStk->IsOk() )
{ {
delete inst; delete inst;
@ -811,21 +811,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute une instruction "switch" // 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 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 CBotInstr* p = m_Block; // la première expression
int state = pile1->GivState(); int state = pile1->GivState();
if (state == 0) if (state == 0)
{ {
if ( !m_Value->Execute(pile1) ) return FALSE; if ( !m_Value->Execute(pile1) ) return false;
pile1->SetState(state = -1); pile1->SetState(state = -1);
} }
if ( pile1->IfStep() ) return FALSE; if ( pile1->IfStep() ) return false;
if ( state == -1 ) if ( state == -1 )
{ {
@ -843,7 +843,7 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
if ( p == NULL ) return pj->Return(pile1); // terminé si plus rien 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 p = m_Block; // revient au début
@ -852,13 +852,13 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
while( p != NULL ) while( p != NULL )
{ {
if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1); if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1);
if ( !pile1->IncState() ) return FALSE; if ( !pile1->IncState() ) return false;
p = p->GivNext(); p = p->GivNext();
} }
return pj->Return(pile1); return pj->Return(pile1);
} }
void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -882,13 +882,13 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain)
// p = m_Block; // revient au début // p = m_Block; // revient au début
while ( p != NULL && state-- > 0 ) while ( p != NULL && state-- > 0 )
{ {
p->RestoreState(pile1, FALSE); p->RestoreState(pile1, false);
p = p->GivNext(); // avance dans la liste p = p->GivNext(); // avance dans la liste
} }
if( p != NULL ) if( p != NULL )
{ {
p->RestoreState(pile1, TRUE); p->RestoreState(pile1, true);
return; return;
} }
} }
@ -942,21 +942,21 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution de l'instruction "case" // 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" // routine permettant de trouver le point d'entrée "case"
// correspondant à la valeur cherchée // 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) while (!m_Value->Execute(pile)); // met sur la pile la valeur correpondant (sans interruption)
return (pile->GivVal() == val); // compare avec la valeur cherchée 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" // exécution l'instructino "break" ou "continu"
BOOL CBotBreak :: Execute(CBotStack* &pj) bool CBotBreak :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); 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); pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label);
return pj->Return(pile); return pj->Return(pile);
} }
void CBotBreak :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( bMain ) pj->RestoreStack(this); if ( bMain ) pj->RestoreStack(this);
} }
@ -1092,14 +1092,14 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
// les arrêts par suspension // les arrêts par suspension
// et les "finaly" // et les "finaly"
BOOL CBotTry :: Execute(CBotStack* &pj) bool CBotTry :: Execute(CBotStack* &pj)
{ {
int val; int val;
CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile 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 // ou le retrouve en cas de reprise
CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire
CBotStack* pile2 = pile0->AddStack(); CBotStack* pile2 = pile0->AddStack();
@ -1114,14 +1114,14 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
val = pile1->GivError(); val = pile1->GivError();
if ( val == 0 && CBotStack::m_initimer == 0 ) // en mode de step ? 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(); pile1->IncState();
pile2->SetState(val); // mémorise le numéro de l'erreur pile2->SetState(val); // mémorise le numéro de l'erreur
pile1->SetError(0); // pour l'instant il n'y a plus d'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 ? 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 // il y a eu une interruption
@ -1137,16 +1137,16 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
if ( --state <= 0 ) if ( --state <= 0 )
{ {
// demande au bloc catch s'il se sent concerné // 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(); pile1->IncState();
} }
if ( --state <= 0 ) if ( --state <= 0 )
{ {
if ( pile2->GivVal() == TRUE ) if ( pile2->GivVal() == true )
{ {
// pile0->SetState(1); // 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 ) if ( m_FinalInst == NULL )
return pj->Return(pile2); // termine le try return pj->Return(pile2); // termine le try
@ -1164,7 +1164,7 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
{ {
// pile0->SetState(1); // 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 if (!pile2->IsOk()) return pj->Return(pile2); // garde cette exception
pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale
return pj->Return(pile2); return pj->Return(pile2);
@ -1176,11 +1176,11 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
return pj->Return(pile2); // termine le try sans exception aucune return pj->Return(pile2); // termine le try sans exception aucune
pile1->SetError(val); // remet l'erreur 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; if ( !bMain ) return;
@ -1217,7 +1217,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain)
} }
if ( --state <= 0 ) if ( --state <= 0 )
{ {
if ( pile2->GivVal() == TRUE ) if ( pile2->GivVal() == true )
{ {
pc->RestoreState(pile2, bMain); // exécute l'opération pc->RestoreState(pile2, bMain); // exécute l'opération
return; return;
@ -1285,27 +1285,27 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
// exécution de "catch" // 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é 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); 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); m_Cond->RestoreState(pj, bMain);
} }
// routine pour savoir si le catch est à faire ou non // 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 ) if ( val > 0 || pile->GivType() != CBotTypBoolean )
{ {
@ -1314,7 +1314,7 @@ BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val)
pile->SetVar(var); // remet sur la pile 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" // exécute l'instruction "throw"
BOOL CBotThrow :: Execute(CBotStack* &pj) bool CBotThrow :: Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
// if ( pile == EOX ) return TRUE; // if ( pile == EOX ) return true;
if ( pile->GivState() == 0 ) if ( pile->GivState() == 0 )
{ {
if ( !m_Value->Execute(pile) ) return FALSE; if ( !m_Value->Execute(pile) ) return false;
pile->IncState(); pile->IncState();
} }
if ( pile->IfStep() ) return FALSE; if ( pile->IfStep() ) return false;
int val = pile->GivVal(); int val = pile->GivVal();
if ( val < 0 ) val = TX_BADTHROW; if ( val < 0 ) val = TX_BADTHROW;
@ -1378,7 +1378,7 @@ BOOL CBotThrow :: Execute(CBotStack* &pj)
return pj->Return( pile ); return pj->Return( pile );
} }
void CBotThrow :: RestoreState(CBotStack* &pj, BOOL bMain) void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain)
{ {
if ( !bMain ) return; if ( !bMain ) return;
@ -1417,11 +1417,11 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack)
// exécute l'instruction "throw" // exécute l'instruction "throw"
BOOL CBotStartDebugDD :: Execute(CBotStack* &pj) bool CBotStartDebugDD :: Execute(CBotStack* &pj)
{ {
CBotProgram* p = pj->GivBotCall(); CBotProgram* p = pj->GivBotCall();
p->m_bDebugDD = TRUE; p->m_bDebugDD = true;
return TRUE; return true;
} }

View File

@ -10,7 +10,6 @@ CBotToken.cpp
CBotTwoOpExpr.cpp CBotTwoOpExpr.cpp
CBotVar.cpp CBotVar.cpp
CBotWhile.cpp CBotWhile.cpp
CBot.rc
) )
add_library(CBot SHARED ${SOURCES}) add_library(CBot SHARED ${SOURCES})

View File

@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD!
// reçois le nom du fichier en paramètre // reçois le nom du fichier en paramètre
// exécution // exécution
BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception) bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
{ {
CBotString mode; CBotString mode;
@ -132,7 +132,7 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
// destructeur de la classe // destructeur de la classe
// exécution // 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" // récupère l'élément "handle"
pVar = pThis->GivItem("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 // reçois le mode r/w en paramètre
// exécution // 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 // il doit y avoir un paramètre
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
@ -243,7 +243,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: close // méthode FILE :: close
// exécution // 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 // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) return CBotErrOverParam; if ( pVar != NULL ) return CBotErrOverParam;
@ -275,7 +275,7 @@ CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: writeln // méthode FILE :: writeln
// exécution // 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 // il doit y avoir un paramètre
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; } if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
@ -319,7 +319,7 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
// méthode FILE :: readln // méthode FILE :: readln
// exécution // 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 // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
@ -360,7 +360,7 @@ CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
// exécution // 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 // il ne doit pas y avoir de paramètre
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; } if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }

View File

@ -18,23 +18,23 @@
// donne la longueur d'une chaîne // donne la longueur d'une chaîne
// exécution // 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 // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// met la longueur sur la pile // met la longueur sur la pile
pResult->SetValInt( s.GivLength() ); pResult->SetValInt( s.GivLength() );
return TRUE; return true;
} }
// int xxx ( string ) // int xxx ( string )
@ -60,36 +60,36 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser )
// donne la partie gauche d'une chaîne // donne la partie gauche d'une chaîne
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // 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 // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
// pas de 3e paramètre // 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 // prend la partie intéressante
s = s.Left( n ); s = s.Left( n );
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// string xxx ( string, int ) // string xxx ( string, int )
@ -122,58 +122,58 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser )
// donne la partie droite d'une chaîne // donne la partie droite d'une chaîne
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // 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 // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
// pas de 3e paramètre // 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 // prend la partie intéressante
s = s.Right( n ); s = s.Right( n );
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne la partie centrale d'une chaîne // donne la partie centrale d'une chaîne
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être un nombre // 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 // récupère ce nombre
int n = pVar->GivValInt(); int n = pVar->GivValInt();
@ -184,13 +184,13 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
pVar = pVar->GivNext(); pVar = pVar->GivNext();
// qui doit être un nombre // 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 // récupère ce nombre
int l = pVar->GivValInt(); int l = pVar->GivValInt();
// mais pas de 4e paramètre // 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 // prend la partie intéressante
s = s.Mid( n, l ); s = s.Mid( n, l );
@ -203,7 +203,7 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
// la met sur la pile // la met sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne la partie centrale d'une chaîne // 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 // donne le nombre contenu dans une chaîne
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // 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); float val = GivNumFloat(s);
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValFloat( val ); pResult->SetValFloat( val );
return TRUE; return true;
} }
// float xxx ( string ) // float xxx ( string )
@ -291,35 +291,35 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser )
// trouve une chaine dans une autre // trouve une chaine dans une autre
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// il faut un second paramètre // il faut un second paramètre
pVar = pVar->GivNext(); pVar = pVar->GivNext();
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; } if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
// qui doit être une string // 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 // récupère ce nombre
CBotString s2 = pVar->GivValString(); CBotString s2 = pVar->GivValString();
// pas de 3e paramètre // 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 // met le résultat sur la pile
int res = s.Find(s2); int res = s.Find(s2);
pResult->SetValInt( res ); pResult->SetValInt( res );
if ( res < 0 ) pResult->SetInit( IS_NAN ); if ( res < 0 ) pResult->SetInit( IS_NAN );
return TRUE; return true;
} }
// int xxx ( string, string ) // int xxx ( string, string )
@ -352,51 +352,51 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser )
// donne une chaine en majuscule // donne une chaine en majuscule
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // 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(); s.MakeUpper();
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// donne une chaine en minuscules // donne une chaine en minuscules
// exécution // 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 // 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 // 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 // recupére le contenu de la string
CBotString s = pVar->GivValString(); CBotString s = pVar->GivValString();
// mais pas de 2e paramètre // 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(); s.MakeLower();
// la met la valeur sur la pile // la met la valeur sur la pile
pResult->SetValString( s ); pResult->SetValString( s );
return TRUE; return true;
} }
// string xxx ( string ) // string xxx ( string )

View File

@ -1,39 +1,41 @@
pour la gestion des instances d'une classe.
l'objet créé actuellement avec CBotVar::Create(nom, pClasse) for managing instances of a class.
est a conserver tel quel, en dehors des vars sur la pile
il faut un autre type de variable pour garder les pointeurs the object being created with CBotVar :: Create (name, pClasse)
CBotTypPtClass par exemple is to keep as is, outside the vars on the stack
L'instance de la classe doit avoir un compteur d'utilisation we need another type of variable to keep the pointers
qui est le nombre d'objet de classe CBotTypPtClass qui y réfèrent. For example CBotTypPtClass
Le compteur est décrémenté lorsque le pointeur est détruit,
l'objet supprimé lorsqu'il n'y a plus de pointeurs. The instance of the class must have a usage count
which is the number of class object to which they refer CBotTypPtClass.
The counter is decremented when the pointer is destroyed,
be deleted when there is more pointers.
Dans le cas des robots, Daniel crée une instance de sa classe "Object" In the case of robots, Daniel creates an instance of class "Object"
et peut retourner des pointeurs à cette instance par des routines genre FindRobot() and can return pointers to this proceeding by routines such FindRobot ()
Object FindRobot(int n) { } Object FindRobot (int n) {}
pResult dans ce cas est un pointeur CBotTypPtClass pResult in this case is a pointer CBotTypPtClass
lorsqu'il a trouvé le robot concerné, il lui faudra faire when he found the robot concerned, it must make
pResult->SetPointeur(InstanceDeLaClassObject); pResult-> SetPointeur (InstanceDeLaClassObject);
cette opération incrémente le compteur des références this operation increments the reference
-- -
lorsque le robot est détruit, l'instance de la classe Object correspondant when the robot is destroyed, the instance of the Object class corresponding
est détruit également. is also destroyed.
s'il reste des pointeurs à cet objet, et l'on risque la planté if there are pointers to that object, and we planted the risk
solution 1: Solution 1:
garder non pas le pointeur à l'objet directement, mais not keep the pointer to the object directly, but
un index dans une tables de pointeurs an index into a table of pointers
Solution 2:
not destroy the object when there imédiatement pointers
but marked as virtually destroyed
solution 2:
ne pas détruire l'objet imédiatement lorsqu'il reste des pointeurs
mais le marqué comme virtuellement détruit

View File

@ -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/.

View File

@ -13,100 +13,105 @@
// * // *
// * You should have received a copy of the GNU General Public License // * 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_DEPENDENCIES}} // * along with this program. If not, see http://www.gnu.org/licenses/.//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file. #ifndef _RESOURCE_H_
// Used by CBot.rc #define _RESOURCE_H_
//
#define ID_KEYWORDS 2000 enum EID
#define ID_IF 2000 {
#define ID_ELSE 2001 ID_IF = 2000,
#define ID_WHILE 2002 ID_ELSE,
#define ID_DO 2003 ID_WHILE,
#define ID_FOR 2004 ID_DO,
#define ID_BREAK 2005 ID_FOR,
#define ID_CONTINUE 2006 ID_BREAK,
#define ID_SWITCH 2007 ID_CONTINUE,
#define ID_CASE 2008 ID_SWITCH,
#define ID_DEFAULT 2009 ID_CASE,
#define ID_TRY 2010 ID_DEFAULT,
#define ID_THROW 2011 ID_TRY,
#define ID_CATCH 2012 ID_THROW,
#define ID_FINALLY 2013 ID_CATCH,
#define ID_TXT_AND 2014 ID_FINALLY,
#define ID_TXT_OR 2015 ID_TXT_AND,
#define ID_TXT_NOT 2016 ID_TXT_OR,
#define ID_RETURN 2017 ID_TXT_NOT,
#define ID_CLASS 2018 ID_RETURN,
#define ID_EXTENDS 2019 ID_CLASS,
#define ID_SYNCHO 2020 ID_EXTENDS,
#define ID_NEW 2021 ID_SYNCHO,
#define ID_PUBLIC 2022 ID_NEW,
#define ID_EXTERN 2023 ID_PUBLIC,
#define ID_FINAL 2024 ID_EXTERN,
#define ID_STATIC 2025 ID_FINAL,
#define ID_PROTECTED 2026 ID_STATIC,
#define ID_PRIVATE 2027 ID_PROTECTED,
#define ID_REPEAT 2028 ID_PRIVATE,
#define ID_DEBUGDD 2099 ID_REPEAT,
#define ID_INT 2100 ID_DEBUGDD,
#define ID_FLOAT 2101 ID_INT,
#define ID_BOOLEAN 2102 ID_FLOAT,
#define ID_STRING 2103 ID_BOOLEAN,
#define ID_VOID 2104 ID_STRING,
#define ID_BOOL 2105 ID_VOID,
#define ID_TRUE 2200 ID_BOOL,
#define ID_FALSE 2201
#define ID_NULL 2202 ID_TRUE = 2200,
#define ID_NAN 2203 ID_FALSE,
#define ID_OPENPAR 2300 ID_NULL,
#define ID_CLOSEPAR 2301 ID_NAN,
#define ID_OPBLK 2302
#define ID_CLBLK 2303 ID_OPENPAR = 2300,
#define ID_SEP 2304 ID_CLOSEPAR,
#define ID_COMMA 2305 ID_OPBLK,
#define ID_DOTS 2306 ID_CLBLK,
#define ID_DOT 2307 ID_SEP,
#define ID_OPBRK 2308 ID_COMMA,
#define ID_CLBRK 2309 ID_DOTS,
#define ID_DBLDOTS 2310 ID_DOT,
#define ID_LOGIC 2311 ID_OPBRK,
#define ID_ADD 2312 ID_CLBRK,
#define ID_SUB 2313 ID_DBLDOTS,
#define ID_MUL 2314 ID_LOGIC,
#define ID_DIV 2315 ID_ADD,
#define ID_ASS 2316 ID_SUB,
#define ID_ASSADD 2317 ID_MUL,
#define ID_ASSSUB 2318 ID_DIV,
#define ID_ASSMUL 2319 ID_ASS,
#define ID_ASSDIV 2320 ID_ASSADD,
#define ID_ASSOR 2321 ID_ASSSUB,
#define ID_ASSAND 2322 ID_ASSMUL,
#define ID_ASSXOR 2323 ID_ASSDIV,
#define ID_ASSSL 2324 ID_ASSOR,
#define ID_ASSSR 2325 ID_ASSAND,
#define ID_ASSASR 2326 ID_ASSXOR,
#define ID_SL 2327 ID_ASSSL,
#define ID_SR 2328 ID_ASSSR,
#define ID_ASR 2329 ID_ASSASR,
#define ID_INC 2330 ID_SL,
#define ID_DEC 2331 ID_SR,
#define ID_LO 2332 ID_ASR,
#define ID_HI 2333 ID_INC,
#define ID_LS 2334 ID_DEC,
#define ID_HS 2335 ID_LO,
#define ID_EQ 2336 ID_HI,
#define ID_NE 2337 ID_LS,
#define ID_AND 2338 ID_HS,
#define ID_XOR 2339 ID_EQ,
#define ID_OR 2340 ID_NE,
#define ID_LOG_AND 2341 ID_AND,
#define ID_LOG_OR 2342 ID_XOR,
#define ID_LOG_NOT 2343 ID_OR,
#define ID_NOT 2344 ID_LOG_AND,
#define ID_MODULO 2345 ID_LOG_OR,
#define ID_POWER 2346 ID_LOG_NOT,
#define ID_ASSMODULO 2347 ID_NOT,
#define TX_UNDEF 4000 ID_MODULO,
#define TX_NAN 4001 ID_POWER,
ID_ASSMODULO,
TX_UNDEF = 4000,
TX_NAN,
ID_SUPER = 6000
};
#define TX_OPENPAR 5000 #define TX_OPENPAR 5000
#define TX_CLOSEPAR 5001 #define TX_CLOSEPAR 5001
#define TX_NOTBOOL 5002 #define TX_NOTBOOL 5002
@ -166,15 +171,6 @@
#define TX_NOTOPEN 6013 #define TX_NOTOPEN 6013
#define TX_ERRREAD 6014 #define TX_ERRREAD 6014
#define TX_ERRWRITE 6015 #define TX_ERRWRITE 6015
#define ID_SUPER 62020
// Next default values for new objects #endif //_RESOURCE_H_
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,5 +1,5 @@
# CBot shared library is built separately # CBot shared library is built separately
# add_subdirectory(CBot) -- not yet WinAPI-independent add_subdirectory(CBot)
# Configure options # Configure options
@ -29,6 +29,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h
# Source files # Source files
# Commented out files are still dependent on DirectX or WinAPI # Commented out files are still dependent on DirectX or WinAPI
set(SOURCES set(SOURCES
app/app.cpp app/app.cpp
app/main.cpp app/main.cpp
@ -155,8 +156,8 @@ ${SDL_LIBRARY}
${SDLIMAGE_LIBRARY} ${SDLIMAGE_LIBRARY}
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
#CBot -- not yet WinAPI-independent
${PLATFORM_LIBS} ${PLATFORM_LIBS}
CBot
) )
include_directories(. ${CMAKE_CURRENT_BINARY_DIR} include_directories(. ${CMAKE_CURRENT_BINARY_DIR}

View File

@ -28,6 +28,9 @@
#include <plugins/plugin.h> #include <plugins/plugin.h>
#include <string>
/*! /*!
* Maximum possible audio volume * Maximum possible audio volume
*/ */