commit
ab8e55a651
|
@ -16,8 +16,8 @@ find_package(PNG REQUIRED)
|
|||
set(CMAKE_BUILD_TYPE debug)
|
||||
|
||||
# Global compile flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -std=gnu++0x")
|
||||
|
||||
# Subdirectory with sources
|
||||
add_subdirectory(src bin)
|
||||
|
|
5375
src/CBot/CBot.cpp
5375
src/CBot/CBot.cpp
File diff suppressed because it is too large
Load Diff
1984
src/CBot/CBot.h
1984
src/CBot/CBot.h
File diff suppressed because it is too large
Load Diff
279
src/CBot/CBot.rc
279
src/CBot/CBot.rc
|
@ -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
|
||||
|
|
@ -93,7 +93,7 @@ CBotInstr* CBotAddExpr::Compile(CBotToken* &p, CBotStack* pStack)
|
|||
|
||||
// fait l'opération d'addition ou de soustraction
|
||||
|
||||
BOOL CBotAddExpr::Execute(CBotStack* &pStack)
|
||||
bool CBotAddExpr::Execute(CBotStack* &pStack)
|
||||
{
|
||||
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
CBotClass* CBotClass::m_ExClass = NULL;
|
||||
|
||||
CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic)
|
||||
CBotClass::CBotClass(const char* name, CBotClass* pPapa, bool bIntrinsic)
|
||||
{
|
||||
m_pParent = pPapa;
|
||||
m_name = name;
|
||||
|
@ -30,7 +30,7 @@ CBotClass::CBotClass(const char* name, CBotClass* pPapa, BOOL bIntrinsic)
|
|||
m_pCalls = NULL;
|
||||
m_pMethod = NULL;
|
||||
m_rMaj = NULL;
|
||||
m_IsDef = TRUE;
|
||||
m_IsDef = true;
|
||||
m_bIntrinsic= bIntrinsic;
|
||||
m_cptLock = 0;
|
||||
m_cptOne = 0;
|
||||
|
@ -86,7 +86,7 @@ void CBotClass::Purge()
|
|||
m_pCalls = NULL;
|
||||
delete m_pMethod;
|
||||
m_pMethod = NULL;
|
||||
m_IsDef = FALSE;
|
||||
m_IsDef = false;
|
||||
|
||||
m_nbVar = m_pParent == NULL ? 0 : m_pParent->m_nbVar;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void CBotClass::Purge()
|
|||
m_next = NULL; // n'appartient plus à cette chaîne
|
||||
}
|
||||
|
||||
BOOL CBotClass::Lock(CBotProgram* p)
|
||||
bool CBotClass::Lock(CBotProgram* p)
|
||||
{
|
||||
int i = m_cptLock++;
|
||||
|
||||
|
@ -102,13 +102,13 @@ BOOL CBotClass::Lock(CBotProgram* p)
|
|||
{
|
||||
m_cptOne = 1;
|
||||
m_ProgInLock[0] = p;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
if ( p == m_ProgInLock[0] )
|
||||
{
|
||||
m_cptOne++;
|
||||
m_cptLock--; // a déjà été compté
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
for ( int j = 1 ; j <= i ; j++)
|
||||
|
@ -116,7 +116,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
|
|||
if ( p == m_ProgInLock[j] )
|
||||
{
|
||||
m_cptLock--;
|
||||
return FALSE; // déjà en attente
|
||||
return false; // déjà en attente
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ BOOL CBotClass::Lock(CBotProgram* p)
|
|||
else
|
||||
m_cptLock--;
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBotClass::Unlock()
|
||||
|
@ -170,7 +170,7 @@ void CBotClass::FreeLock(CBotProgram* p)
|
|||
|
||||
|
||||
|
||||
BOOL CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
|
||||
bool CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
|
||||
{
|
||||
CBotToken token(name, CBotString());
|
||||
CBotClass* pClass = type.GivClass();
|
||||
|
@ -194,14 +194,14 @@ BOOL CBotClass::AddItem(CBotString name, CBotTypResult type, int mPrivate)
|
|||
}
|
||||
|
||||
|
||||
BOOL CBotClass::AddItem(CBotVar* pVar)
|
||||
bool CBotClass::AddItem(CBotVar* pVar)
|
||||
{
|
||||
pVar->SetUniqNum(++m_nbVar);
|
||||
|
||||
if ( m_pVar == NULL ) m_pVar = pVar;
|
||||
else m_pVar->AddNext(pVar);
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBotClass::AddNext(CBotClass* pClass)
|
||||
|
@ -223,15 +223,15 @@ CBotClass* CBotClass::GivParent()
|
|||
return m_pParent;
|
||||
}
|
||||
|
||||
BOOL CBotClass::IsChildOf(CBotClass* pClass)
|
||||
bool CBotClass::IsChildOf(CBotClass* pClass)
|
||||
{
|
||||
CBotClass* p = this;
|
||||
while ( p != NULL )
|
||||
{
|
||||
if ( p == pClass ) return TRUE;
|
||||
if ( p == pClass ) return true;
|
||||
p = p->m_pParent;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,7 +266,7 @@ CBotVar* CBotClass::GivItemRef(int nIdent)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CBotClass::IsIntrinsic()
|
||||
bool CBotClass::IsIntrinsic()
|
||||
{
|
||||
return m_bIntrinsic;
|
||||
}
|
||||
|
@ -289,8 +289,8 @@ CBotClass* CBotClass::Find(const char* name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CBotClass::AddFunction(const char* name,
|
||||
BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
bool CBotClass::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
|
||||
{
|
||||
// mémorise les pointeurs aux deux fonctions
|
||||
|
@ -315,13 +315,13 @@ BOOL CBotClass::AddFunction(const char* name,
|
|||
if (m_pCalls == NULL) m_pCalls = p;
|
||||
else m_pCalls->AddNext(p); // ajoute à la liste
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) )
|
||||
bool CBotClass::AddUpdateFunc( void rMaj ( CBotVar* pThis, void* pUser ) )
|
||||
{
|
||||
m_rMaj = rMaj;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// compile une méthode associée à une instance de classe
|
||||
|
@ -348,7 +348,7 @@ CBotTypResult CBotClass::CompileMethode(const char* name,
|
|||
|
||||
// exécute une méthode
|
||||
|
||||
BOOL CBotClass::ExecuteMethode(long& nIdent, const char* name,
|
||||
bool CBotClass::ExecuteMethode(long& nIdent, const char* name,
|
||||
CBotVar* pThis, CBotVar** ppParams,
|
||||
CBotVar* &pResult, CBotStack* &pStack,
|
||||
CBotToken* pToken)
|
||||
|
@ -371,77 +371,77 @@ void CBotClass::RestoreMethode(long& nIdent, const char* name, CBotVar* pThis,
|
|||
|
||||
|
||||
|
||||
BOOL CBotClass::SaveStaticState(FILE* pf)
|
||||
bool CBotClass::SaveStaticState(FILE* pf)
|
||||
{
|
||||
if (!WriteWord( pf, CBOTVERSION*2)) return FALSE;
|
||||
if (!WriteWord( pf, CBOTVERSION*2)) return false;
|
||||
|
||||
// sauve l'état des variables statiques dans les classes
|
||||
CBotClass* p = m_ExClass;
|
||||
|
||||
while ( p != NULL )
|
||||
{
|
||||
if (!WriteWord( pf, 1)) return FALSE;
|
||||
if (!WriteWord( pf, 1)) return false;
|
||||
// enregistre le nom de la classe
|
||||
if (!WriteString( pf, p->GivName() )) return FALSE;
|
||||
if (!WriteString( pf, p->GivName() )) return false;
|
||||
|
||||
CBotVar* pv = p->GivVar();
|
||||
while( pv != NULL )
|
||||
{
|
||||
if ( pv->IsStatic() )
|
||||
{
|
||||
if (!WriteWord( pf, 1)) return FALSE;
|
||||
if (!WriteString( pf, pv->GivName() )) return FALSE;
|
||||
if (!WriteWord( pf, 1)) return false;
|
||||
if (!WriteString( pf, pv->GivName() )) return false;
|
||||
|
||||
if ( !pv->Save0State(pf)) return FALSE; // entête commune
|
||||
if ( !pv->Save1State(pf) ) return FALSE; // sauve selon la classe fille
|
||||
if ( !WriteWord( pf, 0)) return FALSE;
|
||||
if ( !pv->Save0State(pf)) return false; // entête commune
|
||||
if ( !pv->Save1State(pf) ) return false; // sauve selon la classe fille
|
||||
if ( !WriteWord( pf, 0)) return false;
|
||||
}
|
||||
pv = pv->GivNext();
|
||||
}
|
||||
|
||||
if (!WriteWord( pf, 0)) return FALSE;
|
||||
if (!WriteWord( pf, 0)) return false;
|
||||
p = p->m_ExNext;
|
||||
}
|
||||
|
||||
if (!WriteWord( pf, 0)) return FALSE;
|
||||
return TRUE;
|
||||
if (!WriteWord( pf, 0)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CBotClass::RestoreStaticState(FILE* pf)
|
||||
bool CBotClass::RestoreStaticState(FILE* pf)
|
||||
{
|
||||
CBotString ClassName, VarName;
|
||||
CBotClass* pClass;
|
||||
WORD w;
|
||||
unsigned short w;
|
||||
|
||||
if (!ReadWord( pf, w )) return FALSE;
|
||||
if ( w != CBOTVERSION*2 ) return FALSE;
|
||||
if (!ReadWord( pf, w )) return false;
|
||||
if ( w != CBOTVERSION*2 ) return false;
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (!ReadWord( pf, w )) return FALSE;
|
||||
if ( w == 0 ) return TRUE;
|
||||
if (!ReadWord( pf, w )) return false;
|
||||
if ( w == 0 ) return true;
|
||||
|
||||
if (!ReadString( pf, ClassName )) return FALSE;
|
||||
if (!ReadString( pf, ClassName )) return false;
|
||||
pClass = Find(ClassName);
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (!ReadWord( pf, w )) return FALSE;
|
||||
if (!ReadWord( pf, w )) return false;
|
||||
if ( w == 0 ) break;
|
||||
|
||||
CBotVar* pVar = NULL;
|
||||
CBotVar* pv = NULL;
|
||||
|
||||
if (!ReadString( pf, VarName )) return FALSE;
|
||||
if (!ReadString( pf, VarName )) return false;
|
||||
if ( pClass != NULL ) pVar = pClass->GivItem(VarName);
|
||||
|
||||
if (!CBotVar::RestoreState(pf, pv)) return FALSE; // la variable temp
|
||||
if (!CBotVar::RestoreState(pf, pv)) return false; // la variable temp
|
||||
|
||||
if ( pVar != NULL ) pVar->Copy(pv);
|
||||
delete pv;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,7 +453,7 @@ CBotClassInst::CBotClassInst()
|
|||
m_var = NULL;
|
||||
m_Parameters = NULL;
|
||||
m_expr = NULL;
|
||||
m_hasParams = FALSE;
|
||||
m_hasParams = false;
|
||||
m_nMethodeIdent = 0;
|
||||
name = "CBotClassInst";
|
||||
}
|
||||
|
@ -484,18 +484,17 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
p = p->GivNext();
|
||||
}
|
||||
|
||||
BOOL bIntrinsic = pClass->IsIntrinsic();
|
||||
CBotTypResult
|
||||
type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer,
|
||||
pClass );
|
||||
bool bIntrinsic = pClass->IsIntrinsic();
|
||||
CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass );
|
||||
CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type);
|
||||
if ( inst != NULL || !pStack->IsOk() ) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack();
|
||||
|
||||
inst = new CBotClassInst();
|
||||
|
||||
inst->SetToken(&pClass->GivName(), p->GivStart(), p->GivEnd());
|
||||
/// \TODO Need to be revised and fixed after adding unit tests
|
||||
CBotToken token(pClass->GivName(), CBotString(), p->GivStart(), p->GivEnd());
|
||||
inst->SetToken(&token);
|
||||
CBotToken* vartoken = p;
|
||||
|
||||
if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) )
|
||||
|
@ -601,7 +600,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
var->SetPointer( pvar ); // var déjà déclarée pointe l'instance
|
||||
delete pvar; // supprime le second pointeur
|
||||
}
|
||||
var->SetInit(TRUE); // marque le pointeur comme init
|
||||
var->SetInit(true); // marque le pointeur comme init
|
||||
}
|
||||
else if (inst->m_hasParams)
|
||||
{
|
||||
|
@ -640,17 +639,17 @@ error:
|
|||
// déclaration de l'instance d'une classe, par exemple:
|
||||
// CPoint A, B;
|
||||
|
||||
BOOL CBotClassInst::Execute(CBotStack* &pj)
|
||||
bool CBotClassInst::Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotVar* pThis = NULL;
|
||||
|
||||
CBotStack* pile = pj->AddStack(this);//indispensable pour SetState()
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
CBotToken* pt = &m_token;
|
||||
CBotClass* pClass = CBotClass::Find(pt);
|
||||
|
||||
BOOL bIntrincic = pClass->IsIntrinsic();
|
||||
bool bIntrincic = pClass->IsIntrinsic();
|
||||
|
||||
// crée la variable de type pointeur à l'objet
|
||||
|
||||
|
@ -682,7 +681,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
if ( m_expr != NULL )
|
||||
{
|
||||
// évalue l'expression pour l'assignation
|
||||
if (!m_expr->Execute(pile)) return FALSE;
|
||||
if (!m_expr->Execute(pile)) return false;
|
||||
|
||||
if ( bIntrincic )
|
||||
{
|
||||
|
@ -692,7 +691,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
pile->SetError(TX_NULLPT, &m_token);
|
||||
return pj->Return(pile);
|
||||
}
|
||||
pThis->Copy(pile->GivVar(), FALSE);
|
||||
pThis->Copy(pile->GivVar(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -700,7 +699,7 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
pInstance = ((CBotVarPointer*)pile->GivVar())->GivPointer(); // valeur pour l'assignation
|
||||
pThis->SetPointer(pInstance);
|
||||
}
|
||||
pThis->SetInit(TRUE);
|
||||
pThis->SetInit(true);
|
||||
}
|
||||
|
||||
else if ( m_hasParams )
|
||||
|
@ -732,12 +731,12 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
// et place les valeurs sur la pile
|
||||
// pour pouvoir être interrompu n'importe quand
|
||||
|
||||
if ( p != NULL) while ( TRUE )
|
||||
if ( p != NULL) while ( true )
|
||||
{
|
||||
pile2 = pile2->AddStack(); // de la place sur la pile pour les résultats
|
||||
if ( pile2->GivState() == 0 )
|
||||
{
|
||||
if (!p->Execute(pile2)) return FALSE; // interrompu ici ?
|
||||
if (!p->Execute(pile2)) return false; // interrompu ici ?
|
||||
pile2->SetState(1);
|
||||
}
|
||||
ppVars[i++] = pile2->GivVar();
|
||||
|
@ -751,9 +750,9 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
|
||||
if ( !pClass->ExecuteMethode(m_nMethodeIdent, pClass->GivName(),
|
||||
pThis, ppVars,
|
||||
pResult, pile2, GivToken())) return FALSE; // interrompu
|
||||
pResult, pile2, GivToken())) return false; // interrompu
|
||||
|
||||
pThis->SetInit(TRUE);
|
||||
pThis->SetInit(true);
|
||||
pThis->ConstructorSet(); // signale que le constructeur a été appelé
|
||||
pile->Return(pile2); // libère un bout de pile
|
||||
|
||||
|
@ -766,17 +765,17 @@ BOOL CBotClassInst::Execute(CBotStack* &pj)
|
|||
pile->SetState(3); // fini cette partie
|
||||
}
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
if ( m_next2b != NULL &&
|
||||
!m_next2b->Execute(pile)) return FALSE; // autre(s) définition(s)
|
||||
!m_next2b->Execute(pile)) return false; // autre(s) définition(s)
|
||||
|
||||
return pj->Return( pile ); // transmet en dessous
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
CBotVar* pThis = NULL;
|
||||
|
||||
|
@ -793,7 +792,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
|
||||
CBotToken* pt = &m_token;
|
||||
CBotClass* pClass = CBotClass::Find(pt);
|
||||
BOOL bIntrincic = pClass->IsIntrinsic();
|
||||
bool bIntrincic = pClass->IsIntrinsic();
|
||||
|
||||
if ( bMain && pile->GivState()<3)
|
||||
{
|
||||
|
@ -827,7 +826,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
// et place les valeurs sur la pile
|
||||
// pour pouvoir être interrompu n'importe quand
|
||||
|
||||
if ( p != NULL) while ( TRUE )
|
||||
if ( p != NULL) while ( true )
|
||||
{
|
||||
pile2 = pile2->RestoreStack(); // de la place sur la pile pour les résultats
|
||||
if ( pile2 == NULL ) return;
|
||||
|
@ -858,11 +857,11 @@ void CBotClassInst::RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
|
||||
// test si un nom de procédure est déjà défini quelque part
|
||||
|
||||
BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||
bool CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||
{
|
||||
CBotString name = pToken->GivString();
|
||||
|
||||
if ( CBotCall::CheckCall(name) ) return TRUE;
|
||||
if ( CBotCall::CheckCall(name) ) return true;
|
||||
|
||||
CBotFunction* pp = m_pMethod;
|
||||
while ( pp != NULL )
|
||||
|
@ -871,11 +870,11 @@ BOOL CBotClass::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
|||
{
|
||||
// les paramètres sont-ils exactement les mêmes ?
|
||||
if ( pp->CheckParam( pParam ) )
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
pp = pp->Next();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ CBotInstr* CBotCompExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// fait l'opération
|
||||
|
||||
BOOL CBotCompExpr::Execute(CBotStack* &pStack)
|
||||
bool CBotCompExpr::Execute(CBotStack* &pStack)
|
||||
{
|
||||
CBotStack* pStk1 = pStack->AddStack(this);
|
||||
// if ( pStk1 == EOX ) return TRUE;
|
||||
|
|
1597
src/CBot/CBotDll.h
1597
src/CBot/CBotDll.h
File diff suppressed because it is too large
Load Diff
|
@ -25,14 +25,14 @@ CBotFunction::CBotFunction()
|
|||
m_Param = NULL; // liste des paramètres vide
|
||||
m_Block = NULL; // le bloc d'instructions
|
||||
m_next = NULL; // les fonctions peuvent être chaînées
|
||||
m_bPublic = FALSE; // fonction non publique
|
||||
m_bExtern = FALSE; // fonction non externe
|
||||
m_bPublic = false; // fonction non publique
|
||||
m_bExtern = false; // fonction non externe
|
||||
m_nextpublic = NULL;
|
||||
m_prevpublic = NULL;
|
||||
m_pProg = NULL;
|
||||
// m_nThisIdent = 0;
|
||||
m_nFuncIdent = 0;
|
||||
m_bSynchro = FALSE;
|
||||
m_bSynchro = false;
|
||||
}
|
||||
|
||||
CBotFunction* CBotFunction::m_listPublic = NULL;
|
||||
|
@ -62,17 +62,17 @@ CBotFunction::~CBotFunction()
|
|||
}
|
||||
}
|
||||
|
||||
BOOL CBotFunction::IsPublic()
|
||||
bool CBotFunction::IsPublic()
|
||||
{
|
||||
return m_bPublic;
|
||||
}
|
||||
|
||||
BOOL CBotFunction::IsExtern()
|
||||
bool CBotFunction::IsExtern()
|
||||
{
|
||||
return m_bExtern;
|
||||
}
|
||||
|
||||
BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
||||
bool CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
||||
{
|
||||
start = m_extern.GivStart();
|
||||
stop = m_closeblk.GivEnd();
|
||||
|
@ -110,7 +110,7 @@ BOOL CBotFunction::GetPosition(int& start, int& stop, CBotGet modestart, CBotGet
|
|||
stop = m_closeblk.GivEnd();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,7 +168,7 @@ CBotTypResult TypeParam(CBotToken* &p, CBotCStack* pile)
|
|||
// compile une nouvelle fonction
|
||||
// bLocal permet de mettre la déclaration des paramètres au même niveau
|
||||
// que le éléments appartenant à la classe pour les méthodes
|
||||
CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, BOOL bLocal)
|
||||
CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunction* finput, bool bLocal)
|
||||
{
|
||||
CBotToken* pp;
|
||||
CBotFunction* func = finput;
|
||||
|
@ -178,19 +178,19 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
|||
|
||||
// func->m_nFuncIdent = CBotVar::NextUniqNum();
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if ( IsOfType(p, ID_PUBLIC) )
|
||||
{
|
||||
func->m_bPublic = TRUE;
|
||||
func->m_bPublic = true;
|
||||
continue;
|
||||
}
|
||||
pp = p;
|
||||
if ( IsOfType(p, ID_EXTERN) )
|
||||
{
|
||||
func->m_extern = pp; // pour la position du mot "extern"
|
||||
func->m_bExtern = TRUE;
|
||||
// func->m_bPublic = TRUE; // donc aussi publique!
|
||||
func->m_bExtern = true;
|
||||
// func->m_bPublic = true; // donc aussi publique!
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -260,7 +260,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
|||
|
||||
// et compile le bloc d'instruction qui suit
|
||||
func->m_openblk = p;
|
||||
func->m_Block = CBotBlock::Compile(p, pStk, FALSE);
|
||||
func->m_Block = CBotBlock::Compile(p, pStk, false);
|
||||
func->m_closeblk = p->GivPrev();
|
||||
if ( pStk->IsOk() )
|
||||
{
|
||||
|
@ -286,18 +286,18 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
|||
CBotFunction* func = new CBotFunction();
|
||||
func->m_nFuncIdent = CBotVar::NextUniqNum();
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(p, TRUE);
|
||||
CBotCStack* pStk = pStack->TokenStack(p, true);
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if ( IsOfType(p, ID_PUBLIC) )
|
||||
{
|
||||
// func->m_bPublic = TRUE; // sera fait en passe 2
|
||||
// func->m_bPublic = true; // sera fait en passe 2
|
||||
continue;
|
||||
}
|
||||
if ( IsOfType(p, ID_EXTERN) )
|
||||
{
|
||||
func->m_bExtern = TRUE;
|
||||
func->m_bExtern = true;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -367,16 +367,16 @@ bad:
|
|||
static int xx = 0;
|
||||
#endif
|
||||
|
||||
BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
||||
bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this, 2); // un bout de pile local à cette fonction
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
pile->SetBotCall(m_pProg); // bases pour les routines
|
||||
|
||||
if ( pile->GivState() == 0 )
|
||||
{
|
||||
if ( !m_Param->Execute(ppVars, pile) ) return FALSE; // défini les paramètres
|
||||
if ( !m_Param->Execute(ppVars, pile) ) return false; // défini les paramètres
|
||||
pile->IncState();
|
||||
}
|
||||
|
||||
|
@ -403,14 +403,14 @@ BOOL CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
|||
pile->IncState();
|
||||
}
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
if ( !m_Block->Execute(pile) )
|
||||
{
|
||||
if ( pile->GivError() < 0 )
|
||||
pile->SetError( 0 );
|
||||
else
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return pj->Return(pile);
|
||||
|
@ -433,7 +433,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
|
|||
pile2->Delete();
|
||||
}
|
||||
|
||||
m_Param->RestoreState(pile2, TRUE); // les paramètres
|
||||
m_Param->RestoreState(pile2, true); // les paramètres
|
||||
|
||||
if ( !m_MasterClass.IsEmpty() )
|
||||
{
|
||||
|
@ -442,7 +442,7 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
|
|||
pThis->SetUniqNum(-2);
|
||||
}
|
||||
|
||||
m_Block->RestoreState(pile2, TRUE);
|
||||
m_Block->RestoreState(pile2, true);
|
||||
}
|
||||
|
||||
void CBotFunction::AddNext(CBotFunction* p)
|
||||
|
@ -467,7 +467,7 @@ CBotTypResult CBotFunction::CompileCall(const char* name, CBotVar** ppVars, long
|
|||
// trouve une fonction selon son identificateur unique
|
||||
// si l'identificateur n'est pas trouvé, cherche selon le nom et les paramètres
|
||||
|
||||
CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, BOOL bPublic)
|
||||
CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const char* name, CBotVar** ppVars, CBotTypResult& TypeOrError, bool bPublic)
|
||||
{
|
||||
TypeOrError.SetType(TX_UNDEFCALL); // pas de routine de ce nom
|
||||
CBotFunction* pt;
|
||||
|
@ -632,13 +632,13 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
|
|||
if ( pt != NULL )
|
||||
{
|
||||
CBotStack* pStk1 = pStack->AddStack(pt, 2); // pour mettre "this"
|
||||
// if ( pStk1 == EOX ) return TRUE;
|
||||
// if ( pStk1 == EOX ) return true;
|
||||
|
||||
pStk1->SetBotCall(pt->m_pProg); // on a peut-être changé de module
|
||||
|
||||
if ( pStk1->IfStep() ) return FALSE;
|
||||
if ( pStk1->IfStep() ) return false;
|
||||
|
||||
CBotStack* pStk3 = pStk1->AddStack(NULL, TRUE); // paramètres
|
||||
CBotStack* pStk3 = pStk1->AddStack(NULL, true); // paramètres
|
||||
|
||||
// prépare les paramètres sur la pile
|
||||
|
||||
|
@ -680,11 +680,11 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar** ppVars, CBotS
|
|||
if ( !pStk3->IsOk() && pt->m_pProg != m_pProg )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return FALSE;
|
||||
if ( m_pProg->GivFunctions()->GivName() == "LaCommande" ) return false;
|
||||
#endif
|
||||
pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
|
||||
}
|
||||
return FALSE; // interrompu !
|
||||
return false; // interrompu !
|
||||
}
|
||||
|
||||
return pStack->Return( pStk3 );
|
||||
|
@ -738,13 +738,13 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
|
|||
|
||||
if ( pStk1->GivState() == 0 )
|
||||
{
|
||||
pt->m_Param->RestoreState(pStk3, TRUE);
|
||||
pt->m_Param->RestoreState(pStk3, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// initialise les variables selon paramètres
|
||||
pt->m_Param->RestoreState(pStk3, FALSE);
|
||||
pt->m_Block->RestoreState(pStk3, TRUE);
|
||||
pt->m_Param->RestoreState(pStk3, false);
|
||||
pt->m_Block->RestoreState(pStk3, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,17 +758,17 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
|||
CBotTypResult type;
|
||||
CBotProgram* pProgCurrent = pStack->GivBotCall();
|
||||
|
||||
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, FALSE);
|
||||
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type, false);
|
||||
|
||||
if ( pt != NULL )
|
||||
{
|
||||
// DEBUG( "CBotFunction::DoCall" + pt->GivName(), 0, pStack);
|
||||
|
||||
CBotStack* pStk = pStack->AddStack(pt, 2);
|
||||
// if ( pStk == EOX ) return TRUE;
|
||||
// if ( pStk == EOX ) return true;
|
||||
|
||||
pStk->SetBotCall(pt->m_pProg); // on a peut-être changé de module
|
||||
CBotStack* pStk3 = pStk->AddStack(NULL, TRUE); // pour mettre les paramètres passés
|
||||
CBotStack* pStk3 = pStk->AddStack(NULL, true); // pour mettre les paramètres passés
|
||||
|
||||
// prépare les paramètres sur la pile
|
||||
|
||||
|
@ -776,7 +776,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
|||
{
|
||||
// met la variable "this" sur la pile
|
||||
CBotVar* pthis = CBotVar::Create("this", CBotTypNullPointer);
|
||||
pthis->Copy(pThis, FALSE);
|
||||
pthis->Copy(pThis, false);
|
||||
pthis->SetUniqNum(-2); // valeur spéciale
|
||||
pStk->AddVar(pthis);
|
||||
|
||||
|
@ -785,7 +785,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
|||
{
|
||||
// met la variable "super" sur la pile
|
||||
CBotVar* psuper = CBotVar::Create("super", CBotTypNullPointer);
|
||||
psuper->Copy(pThis, FALSE); // en fait identique à "this"
|
||||
psuper->Copy(pThis, false); // en fait identique à "this"
|
||||
psuper->SetUniqNum(-3); // valeur spéciale
|
||||
pStk->AddVar(psuper);
|
||||
}
|
||||
|
@ -798,8 +798,8 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
|||
{
|
||||
if ( pt->m_bSynchro )
|
||||
{
|
||||
CBotProgram* pProgBase = pStk->GivBotCall(TRUE);
|
||||
if ( !pClass->Lock(pProgBase) ) return FALSE; // attend de pouvoir
|
||||
CBotProgram* pProgBase = pStk->GivBotCall(true);
|
||||
if ( !pClass->Lock(pProgBase) ) return false; // attend de pouvoir
|
||||
}
|
||||
pStk->IncState();
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ int CBotFunction::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar
|
|||
pStk3->SetPosError(pToken); // indique l'erreur sur l'appel de procédure
|
||||
}
|
||||
}
|
||||
return FALSE; // interrompu !
|
||||
return false; // interrompu !
|
||||
}
|
||||
|
||||
if ( pt->m_bSynchro )
|
||||
|
@ -850,30 +850,30 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, C
|
|||
CBotStack* pStk3 = pStk->RestoreStack(NULL); // pour mettre les paramètres passés
|
||||
if ( pStk3 == NULL ) return;
|
||||
|
||||
pt->m_Param->RestoreState(pStk3, TRUE); // les paramètres
|
||||
pt->m_Param->RestoreState(pStk3, true); // les paramètres
|
||||
|
||||
if ( pStk->GivState() > 1 && // vérouillage est effectif ?
|
||||
pt->m_bSynchro )
|
||||
{
|
||||
CBotProgram* pProgBase = pStk->GivBotCall(TRUE);
|
||||
CBotProgram* pProgBase = pStk->GivBotCall(true);
|
||||
pClass->Lock(pProgBase); // vérouille la classe
|
||||
}
|
||||
|
||||
// finalement appelle la fonction trouvée
|
||||
|
||||
pt->m_Block->RestoreState(pStk3, TRUE); // interrompu !
|
||||
pt->m_Block->RestoreState(pStk3, true); // interrompu !
|
||||
}
|
||||
}
|
||||
|
||||
// regarde si la "signature" des paramètres est identique
|
||||
BOOL CBotFunction::CheckParam(CBotDefParam* pParam)
|
||||
bool CBotFunction::CheckParam(CBotDefParam* pParam)
|
||||
{
|
||||
CBotDefParam* pp = m_Param;
|
||||
while ( pp != NULL && pParam != NULL )
|
||||
{
|
||||
CBotTypResult type1 = pp->GivType();
|
||||
CBotTypResult type2 = pParam->GivType();
|
||||
if ( !type1.Compare(type2) ) return FALSE;
|
||||
if ( !type1.Compare(type2) ) return false;
|
||||
pp = pp->GivNext();
|
||||
pParam = pParam->GivNext();
|
||||
}
|
||||
|
@ -1005,7 +1005,7 @@ void CBotDefParam::AddNext(CBotDefParam* p)
|
|||
}
|
||||
|
||||
|
||||
BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||
bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||
{
|
||||
int i = 0;
|
||||
CBotDefParam* p = this;
|
||||
|
@ -1033,7 +1033,7 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
|||
newvar->SetValInt(ppVars[i]->GivValInt());
|
||||
break;
|
||||
case CBotTypIntrinsic:
|
||||
((CBotVarClass*)newvar)->Copy(ppVars[i], FALSE);
|
||||
((CBotVarClass*)newvar)->Copy(ppVars[i], false);
|
||||
break;
|
||||
case CBotTypPointer:
|
||||
case CBotTypArrayPointer:
|
||||
|
@ -1051,10 +1051,10 @@ BOOL CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
|||
i++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBotDefParam::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
int i = 0;
|
||||
CBotDefParam* p = this;
|
||||
|
@ -1146,25 +1146,25 @@ CBotInstr* CBotReturn::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL; // pas d'objet, l'erreur est sur la pile
|
||||
}
|
||||
|
||||
BOOL CBotReturn::Execute(CBotStack* &pj)
|
||||
bool CBotReturn::Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this);
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->GivState() == 0 )
|
||||
{
|
||||
if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return FALSE; // évalue le résultat
|
||||
if ( m_Instr != NULL && !m_Instr->Execute(pile) ) return false; // évalue le résultat
|
||||
// le résultat est sur la pile
|
||||
pile->IncState();
|
||||
}
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
pile->SetBreak(3, CBotString());
|
||||
return pj->Return(pile);
|
||||
}
|
||||
|
||||
void CBotReturn::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotReturn::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
CBotStack* pile = pj->RestoreStack(this);
|
||||
|
@ -1211,7 +1211,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
inst->SetToken(pp);
|
||||
|
||||
// compile la liste des paramètres
|
||||
if (!IsOfType(p, ID_CLOSEPAR)) while (TRUE)
|
||||
if (!IsOfType(p, ID_CLOSEPAR)) while (true)
|
||||
{
|
||||
start = p->GivStart();
|
||||
pile = pile->TokenStack(); // garde les résultats sur la pile
|
||||
|
@ -1278,7 +1278,7 @@ CBotInstr* CBotInstrCall::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CBotInstrCall::Execute(CBotStack* &pj)
|
||||
bool CBotInstrCall::Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotVar* ppVars[1000];
|
||||
CBotStack* pile = pj->AddStack(this);
|
||||
|
@ -1292,12 +1292,12 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
|
|||
// évalue les paramètres
|
||||
// et place les valeurs sur la pile
|
||||
// pour pouvoir être interrompu n'importe quand
|
||||
if ( p != NULL) while ( TRUE )
|
||||
if ( p != NULL) while ( true )
|
||||
{
|
||||
pile = pile->AddStack(); // de la place sur la pile pour les résultats
|
||||
if ( pile->GivState() == 0 )
|
||||
{
|
||||
if (!p->Execute(pile)) return FALSE; // interrompu ici ?
|
||||
if (!p->Execute(pile)) return false; // interrompu ici ?
|
||||
pile->SetState(1); // marque spéciale pour reconnaîre les paramètres
|
||||
}
|
||||
ppVars[i++] = pile->GivVar();
|
||||
|
@ -1307,14 +1307,14 @@ BOOL CBotInstrCall::Execute(CBotStack* &pj)
|
|||
ppVars[i] = NULL;
|
||||
|
||||
CBotStack* pile2 = pile->AddStack();
|
||||
if ( pile2->IfStep() ) return FALSE;
|
||||
if ( pile2->IfStep() ) return false;
|
||||
|
||||
if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return FALSE; // interrompu
|
||||
if ( !pile2->ExecuteCall(m_nFuncIdent, GivToken(), ppVars, m_typRes)) return false; // interrompu
|
||||
|
||||
return pj->Return(pile2); // libère toute la pile
|
||||
}
|
||||
|
||||
void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
// évalue les paramètres
|
||||
// et place les valeurs sur la pile
|
||||
// pour pouvoir être interrompu n'importe quand
|
||||
if ( p != NULL) while ( TRUE )
|
||||
if ( p != NULL) while ( true )
|
||||
{
|
||||
pile = pile->RestoreStack(); // de la place sur la pile pour les résultats
|
||||
if ( pile == NULL ) return;
|
||||
|
@ -1379,7 +1379,6 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
|||
if (IsOfType(p, TokenTypVar))
|
||||
{
|
||||
CBotClass* pPapa = NULL;
|
||||
#if EXTENDS
|
||||
if ( IsOfType( p, ID_EXTENDS ) )
|
||||
{
|
||||
CBotString name = p->GivString();
|
||||
|
@ -1391,10 +1390,9 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CBotClass* classe = (pOld == NULL) ? new CBotClass(name, pPapa) : pOld;
|
||||
classe->Purge(); // vide les anciennes définitions
|
||||
classe->m_IsDef = FALSE; // définition en cours
|
||||
classe->m_IsDef = false; // définition en cours
|
||||
|
||||
if ( !IsOfType( p, ID_OPBLK) )
|
||||
{
|
||||
|
@ -1404,7 +1402,7 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
|
||||
{
|
||||
classe->CompileDefItem(p, pStack, FALSE);
|
||||
classe->CompileDefItem(p, pStack, false);
|
||||
}
|
||||
|
||||
if (pStack->IsOk()) return classe;
|
||||
|
@ -1413,24 +1411,24 @@ CBotClass* CBotClass::Compile1(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
||||
bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
||||
{
|
||||
BOOL bStatic = FALSE;
|
||||
bool bStatic = false;
|
||||
int mProtect = PR_PUBLIC;
|
||||
BOOL bSynchro = FALSE;
|
||||
bool bSynchro = false;
|
||||
|
||||
while (IsOfType(p, ID_SEP)) ;
|
||||
|
||||
CBotTypResult type( -1 );
|
||||
|
||||
if ( IsOfType(p, ID_SYNCHO) ) bSynchro = TRUE;
|
||||
if ( IsOfType(p, ID_SYNCHO) ) bSynchro = true;
|
||||
CBotToken* pBase = p;
|
||||
|
||||
if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE;
|
||||
if ( IsOfType(p, ID_STATIC) ) bStatic = true;
|
||||
if ( IsOfType(p, ID_PUBLIC) ) mProtect = PR_PUBLIC;
|
||||
if ( IsOfType(p, ID_PRIVATE) ) mProtect = PR_PRIVATE;
|
||||
if ( IsOfType(p, ID_PROTECTED) ) mProtect = PR_PROTECT;
|
||||
if ( IsOfType(p, ID_STATIC) ) bStatic = TRUE;
|
||||
if ( IsOfType(p, ID_STATIC) ) bStatic = true;
|
||||
|
||||
// CBotClass* pClass = NULL;
|
||||
type = TypeParam(p, pStack); // type du résultat
|
||||
|
@ -1438,7 +1436,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
if ( type.Eq(-1) )
|
||||
{
|
||||
pStack->SetError(TX_NOTYP, p);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
while (pStack->IsOk())
|
||||
|
@ -1463,14 +1461,14 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
if (!pStack->IsOk() || !IsOfType( p, ID_CLBRK ) )
|
||||
{
|
||||
pStack->SetError(TX_CLBRK, p->GivStart());
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* CBotVar* pv = pStack->GivVar();
|
||||
if ( pv->GivType()>= CBotTypBoolean )
|
||||
{
|
||||
pStack->SetError(TX_BADTYPE, p->GivStart());
|
||||
return FALSE;
|
||||
return false;
|
||||
}*/
|
||||
|
||||
if (limites == NULL) limites = i;
|
||||
|
@ -1485,7 +1483,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
CBotFunction* f =
|
||||
CBotFunction::Compile1(p, pStack, this);
|
||||
|
||||
if ( f == NULL ) return FALSE;
|
||||
if ( f == NULL ) return false;
|
||||
|
||||
if (m_pMethod == NULL) m_pMethod = f;
|
||||
else m_pMethod->AddNext(f);
|
||||
|
@ -1502,8 +1500,8 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
pf = pf->Next();
|
||||
}
|
||||
|
||||
BOOL bConstructor = (pp->GivString() == GivName());
|
||||
CBotCStack* pile = pStack->TokenStack(NULL, TRUE);
|
||||
bool bConstructor = (pp->GivString() == GivName());
|
||||
CBotCStack* pile = pStack->TokenStack(NULL, true);
|
||||
|
||||
// rend "this" connu
|
||||
CBotToken TokenThis(CBotString("this"), CBotString());
|
||||
|
@ -1540,7 +1538,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
// compile une méthode
|
||||
p = pBase;
|
||||
CBotFunction* f =
|
||||
CBotFunction::Compile(p, pile, NULL/*, FALSE*/);
|
||||
CBotFunction::Compile(p, pile, NULL/*, false*/);
|
||||
|
||||
if ( f != NULL )
|
||||
{
|
||||
|
@ -1563,7 +1561,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
if (type.Eq(0))
|
||||
{
|
||||
pStack->SetError(TX_ENDOF, p);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
CBotInstr* i = NULL;
|
||||
|
@ -1578,7 +1576,7 @@ BOOL CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, BOOL bSecond)
|
|||
// il y a une assignation à calculer
|
||||
i = CBotTwoOpExpr::Compile(p, pStack);
|
||||
}
|
||||
if ( !pStack->IsOk() ) return FALSE;
|
||||
if ( !pStack->IsOk() ) return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1627,20 +1625,18 @@ CBotClass* CBotClass::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
// la classe à été créée par Compile1
|
||||
CBotClass* pOld = CBotClass::Find(name);
|
||||
|
||||
#if EXTENDS
|
||||
if ( IsOfType( p, ID_EXTENDS ) )
|
||||
{
|
||||
IsOfType(p, TokenTypVar); // forcément
|
||||
}
|
||||
#endif
|
||||
IsOfType( p, ID_OPBLK); // forcément
|
||||
|
||||
while ( pStack->IsOk() && !IsOfType( p, ID_CLBLK ) )
|
||||
{
|
||||
pOld->CompileDefItem(p, pStack, TRUE);
|
||||
pOld->CompileDefItem(p, pStack, true);
|
||||
}
|
||||
|
||||
pOld->m_IsDef = TRUE; // définition terminée
|
||||
pOld->m_IsDef = true; // définition terminée
|
||||
if (pStack->IsOk()) return pOld;
|
||||
}
|
||||
pStack->SetError(TX_ENDOF, p);
|
||||
|
|
|
@ -51,7 +51,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
{
|
||||
// la condition existe bel et bien
|
||||
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
if ( pStk->IsOk() )
|
||||
{
|
||||
// le bloc d'instruction est ok (peut être vide)
|
||||
|
@ -60,7 +60,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if (IsOfType(p, ID_ELSE))
|
||||
{
|
||||
// si oui, compile le bloc d'instruction qui suit
|
||||
inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_BlockElse = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
if (!pStk->IsOk())
|
||||
{
|
||||
// il n'y a pas de bloc correct après le else
|
||||
|
@ -84,19 +84,19 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécution de l'instruction
|
||||
|
||||
BOOL CBotIf :: Execute(CBotStack* &pj)
|
||||
bool CBotIf :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
// selon la reprise, on peut être dans l'un des 2 états
|
||||
if( pile->GivState() == 0 )
|
||||
{
|
||||
// évalue la condition
|
||||
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// termine s'il y a une erreur
|
||||
if ( !pile->IsOk() )
|
||||
|
@ -105,21 +105,21 @@ BOOL CBotIf :: Execute(CBotStack* &pj)
|
|||
}
|
||||
|
||||
// passe dans le second état
|
||||
if (!pile->SetState(1)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(1)) return false; // prêt pour la suite
|
||||
}
|
||||
|
||||
// second état, évalue les instructions associées
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
if ( pile->GivVal() == TRUE ) // condition était vraie ?
|
||||
if ( pile->GivVal() == true ) // condition était vraie ?
|
||||
{
|
||||
if ( m_Block != NULL && // bloc peut être absent
|
||||
!m_Block->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
!m_Block->Execute(pile) ) return false; // interrompu ici ?
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_BlockElse != NULL && // s'il existe un bloc alternatif
|
||||
!m_BlockElse->Execute(pile) ) return FALSE; // interrompu ici
|
||||
!m_BlockElse->Execute(pile) ) return false; // interrompu ici
|
||||
}
|
||||
|
||||
// transmet le résultat et libère la pile
|
||||
|
@ -127,7 +127,7 @@ BOOL CBotIf :: Execute(CBotStack* &pj)
|
|||
}
|
||||
|
||||
|
||||
void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -145,7 +145,7 @@ void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
// second état, évalue les instructions associées
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
if ( pile->GivVal() == TRUE ) // condition était vraie ?
|
||||
if ( pile->GivVal() == true ) // condition était vraie ?
|
||||
{
|
||||
if ( m_Block != NULL ) // bloc peut être absent
|
||||
m_Block->RestoreState(pile, bMain); // interrompu ici !
|
||||
|
|
|
@ -62,7 +62,7 @@ CBotProgram::~CBotProgram()
|
|||
}
|
||||
|
||||
|
||||
BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser )
|
||||
bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser )
|
||||
{
|
||||
int error = 0;
|
||||
Stop();
|
||||
|
@ -81,7 +81,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
|
||||
// transforme le programme en Tokens
|
||||
CBotToken* pBaseToken = CBotToken::CompileTokens(program, error);
|
||||
if ( pBaseToken == NULL ) return FALSE;
|
||||
if ( pBaseToken == NULL ) return false;
|
||||
|
||||
|
||||
CBotCStack* pStack = new CBotCStack(NULL);
|
||||
|
@ -115,7 +115,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
delete m_Prog;
|
||||
m_Prog = NULL;
|
||||
delete pBaseToken;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// CBotFunction* temp = NULL;
|
||||
|
@ -130,12 +130,12 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
if ( p->GivType() == ID_CLASS ||
|
||||
( p->GivType() == ID_PUBLIC && p->GivNext()->GivType() == ID_CLASS ))
|
||||
{
|
||||
m_bCompileClass = TRUE;
|
||||
m_bCompileClass = true;
|
||||
CBotClass::Compile(p, pStack); // complète la définition de la classe
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bCompileClass = FALSE;
|
||||
m_bCompileClass = false;
|
||||
CBotFunction::Compile(p, pStack, next);
|
||||
if (next->IsExtern()) ListFonctions.Add(next->GivName()/* + next->GivParams()*/);
|
||||
next->m_pProg = this; // garde le pointeur au module
|
||||
|
@ -160,7 +160,7 @@ BOOL CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
|
|||
}
|
||||
|
||||
|
||||
BOOL CBotProgram::Start(const char* name)
|
||||
bool CBotProgram::Start(const char* name)
|
||||
{
|
||||
#if STACKMEM
|
||||
m_pStack->Delete();
|
||||
|
@ -179,7 +179,7 @@ BOOL CBotProgram::Start(const char* name)
|
|||
if ( m_pRun == NULL )
|
||||
{
|
||||
m_ErrorCode = TX_NORUN;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if STACKMEM
|
||||
|
@ -190,10 +190,10 @@ BOOL CBotProgram::Start(const char* name)
|
|||
|
||||
m_pStack->SetBotCall(this); // bases pour les routines
|
||||
|
||||
return TRUE; // on est prêt pour un Run()
|
||||
return true; // on est prêt pour un Run()
|
||||
}
|
||||
|
||||
BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
||||
bool CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet modestart, CBotGet modestop)
|
||||
{
|
||||
CBotFunction* p = m_Prog;
|
||||
while (p != NULL)
|
||||
|
@ -202,15 +202,15 @@ BOOL CBotProgram::GetPosition(const char* name, int& start, int& stop, CBotGet m
|
|||
p = p->m_next;
|
||||
}
|
||||
|
||||
if ( p == NULL ) return FALSE;
|
||||
if ( p == NULL ) return false;
|
||||
|
||||
p->GetPosition(start, stop, modestart, modestop);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CBotProgram::Run(void* pUser, int timer)
|
||||
bool CBotProgram::Run(void* pUser, int timer)
|
||||
{
|
||||
BOOL ok;
|
||||
bool ok;
|
||||
|
||||
if (m_pStack == NULL || m_pRun == NULL) goto error;
|
||||
|
||||
|
@ -253,7 +253,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
|
|||
delete m_pStack;
|
||||
#endif
|
||||
m_pStack = NULL;
|
||||
return TRUE; // exécution terminée !!
|
||||
return true; // exécution terminée !!
|
||||
}
|
||||
|
||||
if ( ok ) m_pRun = NULL; // plus de fonction en exécution
|
||||
|
@ -261,7 +261,7 @@ BOOL CBotProgram::Run(void* pUser, int timer)
|
|||
|
||||
error:
|
||||
m_ErrorCode = TX_NORUN;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBotProgram::Stop()
|
||||
|
@ -277,14 +277,14 @@ void CBotProgram::Stop()
|
|||
|
||||
|
||||
|
||||
BOOL CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end)
|
||||
bool CBotProgram::GetRunPos(const char* &FunctionName, int &start, int &end)
|
||||
{
|
||||
FunctionName = NULL;
|
||||
start = end = 0;
|
||||
if (m_pStack == NULL) return FALSE;
|
||||
if (m_pStack == NULL) return false;
|
||||
|
||||
m_pStack->GetRunPos(FunctionName, start, end);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CBotVar* CBotProgram::GivStackVars(const char* &FunctionName, int level)
|
||||
|
@ -321,7 +321,7 @@ long CBotProgram::GivIdent()
|
|||
return m_Ident;
|
||||
}
|
||||
|
||||
BOOL CBotProgram::GetError(int& code, int& start, int& end)
|
||||
bool CBotProgram::GetError(int& code, int& start, int& end)
|
||||
{
|
||||
code = m_ErrorCode;
|
||||
start = m_ErrorStart;
|
||||
|
@ -329,7 +329,7 @@ BOOL CBotProgram::GetError(int& code, int& start, int& end)
|
|||
return code > 0;
|
||||
}
|
||||
|
||||
BOOL CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg)
|
||||
bool CBotProgram::GetError(int& code, int& start, int& end, CBotProgram* &pProg)
|
||||
{
|
||||
code = m_ErrorCode;
|
||||
start = m_ErrorStart;
|
||||
|
@ -358,8 +358,8 @@ CBotFunction* CBotProgram::GivFunctions()
|
|||
return m_Prog;
|
||||
}
|
||||
|
||||
BOOL CBotProgram::AddFunction(const char* name,
|
||||
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool CBotProgram::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
// mémorise les pointeurs aux deux fonctions
|
||||
|
@ -367,25 +367,25 @@ BOOL CBotProgram::AddFunction(const char* name,
|
|||
}
|
||||
|
||||
|
||||
BOOL WriteWord(FILE* pf, WORD w)
|
||||
bool WriteWord(FILE* pf, unsigned short w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
lg = fwrite(&w, sizeof( WORD ), 1, pf );
|
||||
lg = fwrite(&w, sizeof( unsigned short ), 1, pf );
|
||||
|
||||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL ReadWord(FILE* pf, WORD& w)
|
||||
bool ReadWord(FILE* pf, unsigned short& w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
lg = fread(&w, sizeof( WORD ), 1, pf );
|
||||
lg = fread(&w, sizeof( unsigned short ), 1, pf );
|
||||
|
||||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL WriteFloat(FILE* pf, float w)
|
||||
bool WriteFloat(FILE* pf, float w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
|
@ -394,7 +394,7 @@ BOOL WriteFloat(FILE* pf, float w)
|
|||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL ReadFloat(FILE* pf, float& w)
|
||||
bool ReadFloat(FILE* pf, float& w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
|
@ -403,7 +403,7 @@ BOOL ReadFloat(FILE* pf, float& w)
|
|||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL WriteLong(FILE* pf, long w)
|
||||
bool WriteLong(FILE* pf, long w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
|
@ -412,7 +412,7 @@ BOOL WriteLong(FILE* pf, long w)
|
|||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL ReadLong(FILE* pf, long& w)
|
||||
bool ReadLong(FILE* pf, long& w)
|
||||
{
|
||||
size_t lg;
|
||||
|
||||
|
@ -421,24 +421,24 @@ BOOL ReadLong(FILE* pf, long& w)
|
|||
return (lg == 1);
|
||||
}
|
||||
|
||||
BOOL WriteString(FILE* pf, CBotString s)
|
||||
bool WriteString(FILE* pf, CBotString s)
|
||||
{
|
||||
size_t lg1, lg2;
|
||||
|
||||
lg1 = s.GivLength();
|
||||
if (!WriteWord(pf, lg1)) return FALSE;
|
||||
if (!WriteWord(pf, lg1)) return false;
|
||||
|
||||
lg2 = fwrite(s, 1, lg1, pf );
|
||||
return (lg1 == lg2);
|
||||
}
|
||||
|
||||
BOOL ReadString(FILE* pf, CBotString& s)
|
||||
bool ReadString(FILE* pf, CBotString& s)
|
||||
{
|
||||
WORD w;
|
||||
unsigned short w;
|
||||
char buf[1000];
|
||||
size_t lg1, lg2;
|
||||
|
||||
if (!ReadWord(pf, w)) return FALSE;
|
||||
if (!ReadWord(pf, w)) return false;
|
||||
lg1 = w;
|
||||
lg2 = fread(buf, 1, lg1, pf );
|
||||
buf[lg2] = 0;
|
||||
|
@ -447,29 +447,29 @@ BOOL ReadString(FILE* pf, CBotString& s)
|
|||
return (lg1 == lg2);
|
||||
}
|
||||
|
||||
BOOL WriteType(FILE* pf, CBotTypResult type)
|
||||
bool WriteType(FILE* pf, CBotTypResult type)
|
||||
{
|
||||
int typ = type.GivType();
|
||||
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
|
||||
if ( !WriteWord(pf, typ) ) return FALSE;
|
||||
if ( !WriteWord(pf, typ) ) return false;
|
||||
if ( typ == CBotTypClass )
|
||||
{
|
||||
CBotClass* p = type.GivClass();
|
||||
if ( !WriteString(pf, p->GivName()) ) return FALSE;
|
||||
if ( !WriteString(pf, p->GivName()) ) return false;
|
||||
}
|
||||
if ( type.Eq( CBotTypArrayBody ) ||
|
||||
type.Eq( CBotTypArrayPointer ) )
|
||||
{
|
||||
if ( !WriteWord(pf, type.GivLimite()) ) return FALSE;
|
||||
if ( !WriteType(pf, type.GivTypElem()) ) return FALSE;
|
||||
if ( !WriteWord(pf, type.GivLimite()) ) return false;
|
||||
if ( !WriteType(pf, type.GivTypElem()) ) return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL ReadType(FILE* pf, CBotTypResult& type)
|
||||
bool ReadType(FILE* pf, CBotTypResult& type)
|
||||
{
|
||||
WORD w, ww;
|
||||
if ( !ReadWord(pf, w) ) return FALSE;
|
||||
unsigned short w, ww;
|
||||
if ( !ReadWord(pf, w) ) return false;
|
||||
type.SetType(w);
|
||||
|
||||
if ( type.Eq( CBotTypIntrinsic ) )
|
||||
|
@ -480,7 +480,7 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
|
|||
if ( type.Eq( CBotTypClass ) )
|
||||
{
|
||||
CBotString s;
|
||||
if ( !ReadString(pf, s) ) return FALSE;
|
||||
if ( !ReadString(pf, s) ) return false;
|
||||
type = CBotTypResult( w, s );
|
||||
}
|
||||
|
||||
|
@ -488,54 +488,54 @@ BOOL ReadType(FILE* pf, CBotTypResult& type)
|
|||
type.Eq( CBotTypArrayBody ) )
|
||||
{
|
||||
CBotTypResult r;
|
||||
if ( !ReadWord(pf, ww) ) return FALSE;
|
||||
if ( !ReadType(pf, r) ) return FALSE;
|
||||
if ( !ReadWord(pf, ww) ) return false;
|
||||
if ( !ReadType(pf, r) ) return false;
|
||||
type = CBotTypResult( w, r );
|
||||
type.SetLimite((short)ww);
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL CBotProgram::DefineNum(const char* name, long val)
|
||||
bool CBotProgram::DefineNum(const char* name, long val)
|
||||
{
|
||||
return CBotToken::DefineNum(name, val);
|
||||
}
|
||||
|
||||
|
||||
BOOL CBotProgram::SaveState(FILE* pf)
|
||||
bool CBotProgram::SaveState(FILE* pf)
|
||||
{
|
||||
if (!WriteWord( pf, CBOTVERSION)) return FALSE;
|
||||
if (!WriteWord( pf, CBOTVERSION)) return false;
|
||||
|
||||
|
||||
if ( m_pStack != NULL )
|
||||
{
|
||||
if (!WriteWord( pf, 1)) return FALSE;
|
||||
if (!WriteString( pf, m_pRun->GivName() )) return FALSE;
|
||||
if (!m_pStack->SaveState(pf)) return FALSE;
|
||||
if (!WriteWord( pf, 1)) return false;
|
||||
if (!WriteString( pf, m_pRun->GivName() )) return false;
|
||||
if (!m_pStack->SaveState(pf)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!WriteWord( pf, 0)) return FALSE;
|
||||
if (!WriteWord( pf, 0)) return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL CBotProgram::RestoreState(FILE* pf)
|
||||
bool CBotProgram::RestoreState(FILE* pf)
|
||||
{
|
||||
WORD w;
|
||||
CBotString s;
|
||||
unsigned short w;
|
||||
CBotString s;
|
||||
|
||||
Stop();
|
||||
|
||||
if (!ReadWord( pf, w )) return FALSE;
|
||||
if ( w != CBOTVERSION ) return FALSE;
|
||||
if (!ReadWord( pf, w )) return false;
|
||||
if ( w != CBOTVERSION ) return false;
|
||||
|
||||
if (!ReadWord( pf, w )) return FALSE;
|
||||
if ( w == 0 ) return TRUE;
|
||||
if (!ReadWord( pf, w )) return false;
|
||||
if ( w == 0 ) return true;
|
||||
|
||||
if (!ReadString( pf, s )) return FALSE;
|
||||
if (!ReadString( pf, s )) return false;
|
||||
Start(s); // point de reprise
|
||||
|
||||
#if STACKMEM
|
||||
|
@ -547,12 +547,12 @@ BOOL CBotProgram::RestoreState(FILE* pf)
|
|||
|
||||
// récupère la pile depuis l'enregistrement
|
||||
// utilise un pointeur NULL (m_pStack) mais c'est ok comme ça
|
||||
if (!m_pStack->RestoreState(pf, m_pStack)) return FALSE;
|
||||
if (!m_pStack->RestoreState(pf, m_pStack)) return false;
|
||||
m_pStack->SetBotCall(this); // bases pour les routines
|
||||
|
||||
// rétabli certains états dans la pile selon la structure
|
||||
m_pRun->RestoreState(NULL, m_pStack, m_pInstance);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CBotProgram::GivVersion()
|
||||
|
@ -566,7 +566,7 @@ int CBotProgram::GivVersion()
|
|||
CBotCall* CBotCall::m_ListCalls = NULL;
|
||||
|
||||
CBotCall::CBotCall(const char* name,
|
||||
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -587,8 +587,8 @@ void CBotCall::Free()
|
|||
delete CBotCall::m_ListCalls;
|
||||
}
|
||||
|
||||
BOOL CBotCall::AddFunction(const char* name,
|
||||
BOOL rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
bool CBotCall::AddFunction(const char* name,
|
||||
bool rExec (CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser),
|
||||
CBotTypResult rCompile (CBotVar* &pVar, void* pUser))
|
||||
{
|
||||
CBotCall* p = m_ListCalls;
|
||||
|
@ -616,18 +616,18 @@ BOOL CBotCall::AddFunction(const char* name,
|
|||
if (p) p->m_next = pp;
|
||||
else m_ListCalls = pp;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// transforme le tableau de pointeurs aux variables
|
||||
// en une liste de variables chaînées
|
||||
CBotVar* MakeListVars(CBotVar** ppVars, BOOL bSetVal=FALSE)
|
||||
CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false)
|
||||
{
|
||||
int i = 0;
|
||||
CBotVar* pVar = NULL;
|
||||
|
||||
while( TRUE )
|
||||
while( true )
|
||||
{
|
||||
ppVars[i];
|
||||
if ( ppVars[i] == NULL ) break;
|
||||
|
@ -686,16 +686,16 @@ void CBotCall::SetPUser(void* pUser)
|
|||
m_pUser = pUser;
|
||||
}
|
||||
|
||||
int CBotCall::CheckCall(const char* name)
|
||||
bool CBotCall::CheckCall(const char* name)
|
||||
{
|
||||
CBotCall* p = m_ListCalls;
|
||||
|
||||
while ( p != NULL )
|
||||
{
|
||||
if ( name == p->GivName() ) return TRUE;
|
||||
if ( name == p->GivName() ) return true;
|
||||
p = p->m_next;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -746,7 +746,7 @@ fund:
|
|||
#if !STACKRUN
|
||||
// fait la liste des paramètres selon le contenu de la pile (pStackVar)
|
||||
|
||||
CBotVar* pVar = MakeListVars(ppVar, TRUE);
|
||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||
CBotVar* pVarToDelete = pVar;
|
||||
|
||||
// crée une variable pour le résultat
|
||||
|
@ -759,14 +759,14 @@ fund:
|
|||
if ( pResult != pRes ) delete pRes; // si résultat différent rendu
|
||||
delete pVarToDelete;
|
||||
|
||||
if (res == FALSE)
|
||||
if (res == false)
|
||||
{
|
||||
if (Exception!=0)
|
||||
{
|
||||
pStack->SetError(Exception, token);
|
||||
}
|
||||
delete pResult;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
pStack->SetVar(pResult);
|
||||
|
||||
|
@ -775,16 +775,16 @@ fund:
|
|||
pStack->SetError(TX_NORETVAL, token);
|
||||
}
|
||||
nIdent = pt->m_nFuncIdent;
|
||||
return TRUE;
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
CBotStack* pile = pStack->AddStackEOX(pt);
|
||||
if ( pile == EOX ) return TRUE;
|
||||
if ( pile == EOX ) return true;
|
||||
|
||||
// fait la liste des paramètres selon le contenu de la pile (pStackVar)
|
||||
|
||||
CBotVar* pVar = MakeListVars(ppVar, TRUE);
|
||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||
CBotVar* pVarToDelete = pVar;
|
||||
|
||||
// crée une variable pour le résultat
|
||||
|
@ -804,7 +804,7 @@ fund:
|
|||
|
||||
#if STACKRUN
|
||||
|
||||
BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack)
|
||||
bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBotStack* pStack)
|
||||
{
|
||||
CBotCall* pt = m_ListCalls;
|
||||
|
||||
|
@ -817,22 +817,22 @@ BOOL CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
|
|||
nIdent = pt->m_nFuncIdent;
|
||||
|
||||
CBotStack* pile = pStack->RestoreStackEOX(pt);
|
||||
if ( pile == NULL ) return TRUE;
|
||||
if ( pile == NULL ) return true;
|
||||
|
||||
CBotStack* pile2 = pile->RestoreStack();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
pt = pt->m_next;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL CBotCall::Run(CBotStack* pStack)
|
||||
bool CBotCall::Run(CBotStack* pStack)
|
||||
{
|
||||
CBotStack* pile = pStack->AddStackEOX(this);
|
||||
if ( pile == EOX ) return TRUE;
|
||||
if ( pile == EOX ) return true;
|
||||
CBotVar* pVar = pile->GivVar();
|
||||
|
||||
CBotStack* pile2 = pile->AddStack();
|
||||
|
@ -842,20 +842,20 @@ BOOL CBotCall::Run(CBotStack* pStack)
|
|||
int Exception = 0;
|
||||
int res = m_rExec(pVar, pResult, Exception, pStack->GivPUser());
|
||||
|
||||
if (res == FALSE)
|
||||
if (res == false)
|
||||
{
|
||||
if (Exception!=0)
|
||||
{
|
||||
pStack->SetError(Exception);
|
||||
}
|
||||
if ( pResult != pRes ) delete pResult; // si résultat différent rendu
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( pResult != NULL ) pStack->SetCopyVar( pResult );
|
||||
if ( pResult != pRes ) delete pResult; // si résultat différent rendu
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -863,7 +863,7 @@ BOOL CBotCall::Run(CBotStack* pStack)
|
|||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBotCallMethode::CBotCallMethode(const char* name,
|
||||
BOOL rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception),
|
||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -893,7 +893,7 @@ CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
|
|||
{
|
||||
if ( pt->m_name == name )
|
||||
{
|
||||
CBotVar* pVar = MakeListVars(ppVar, TRUE);
|
||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||
CBotVar* pVar2 = pVar;
|
||||
CBotTypResult r = pt->m_rComp(pThis, pVar2);
|
||||
int ret = r.GivType();
|
||||
|
@ -942,7 +942,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
{
|
||||
// fait la liste des paramètres selon le contenu de la pile (pStackVar)
|
||||
|
||||
CBotVar* pVar = MakeListVars(ppVars, TRUE);
|
||||
CBotVar* pVar = MakeListVars(ppVars, true);
|
||||
CBotVar* pVarToDelete = pVar;
|
||||
|
||||
// puis appelle la routine externe au module
|
||||
|
@ -951,7 +951,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
int res = pt->m_rExec(pThis, pVar, pResult, Exception);
|
||||
pStack->SetVar(pResult);
|
||||
|
||||
if (res == FALSE)
|
||||
if (res == false)
|
||||
{
|
||||
if (Exception!=0)
|
||||
{
|
||||
|
@ -959,10 +959,10 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
pStack->SetError(Exception, pToken);
|
||||
}
|
||||
delete pVarToDelete;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
delete pVarToDelete;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
pt = pt->m_next;
|
||||
}
|
||||
|
@ -975,14 +975,14 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
{
|
||||
// fait la liste des paramètres selon le contenu de la pile (pStackVar)
|
||||
|
||||
CBotVar* pVar = MakeListVars(ppVars, TRUE);
|
||||
CBotVar* pVar = MakeListVars(ppVars, true);
|
||||
CBotVar* pVarToDelete = pVar;
|
||||
|
||||
int Exception = 0;
|
||||
int res = pt->m_rExec(pThis, pVar, pResult, Exception);
|
||||
pStack->SetVar(pResult);
|
||||
|
||||
if (res == FALSE)
|
||||
if (res == false)
|
||||
{
|
||||
if (Exception!=0)
|
||||
{
|
||||
|
@ -990,11 +990,11 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
pStack->SetError(Exception, pToken);
|
||||
}
|
||||
delete pVarToDelete;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
delete pVarToDelete;
|
||||
nIdent = pt->m_nFuncIdent;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
pt = pt->m_next;
|
||||
}
|
||||
|
@ -1002,7 +1002,7 @@ int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBot
|
|||
return -1;
|
||||
}
|
||||
|
||||
BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
if ( pVar == NULL ) return TX_LOWPARAM;
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ BOOL rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
|||
}
|
||||
|
||||
pResult->SetValInt(i);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
|
||||
|
@ -1030,11 +1030,11 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
|
|||
|
||||
CBotString CBotProgram::m_DebugVarStr = "";
|
||||
|
||||
BOOL rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rCBotDebug( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
pResult->SetValString( CBotProgram::m_DebugVarStr );
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CBotTypResult cCBotDebug( CBotVar* &pVar, void* pUser )
|
||||
|
@ -1103,7 +1103,8 @@ void CBotProgram::Init()
|
|||
|
||||
// une fonction juste pour les debug divers
|
||||
CBotProgram::AddFunction("CBOTDEBUGDD", rCBotDebug, cCBotDebug);
|
||||
DeleteFile("CbotDebug.txt");
|
||||
//TODO implement this deletion
|
||||
// DeleteFile("CbotDebug.txt");
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,51 +13,145 @@
|
|||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/./////////////////////////////////////////////////////
|
||||
// gestion de chaine
|
||||
// basé sur le CString de MFC
|
||||
// mais moins complet
|
||||
|
||||
//strings management
|
||||
|
||||
#include "CBot.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
HINSTANCE CBotString::m_hInstance = (HINSTANCE)LoadLibrary("libCbot.dll"); // comment le récupérer autrement ??
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#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()
|
||||
{
|
||||
m_ptr = NULL; // chaine vide
|
||||
m_lg = 0;
|
||||
m_ptr = NULL;
|
||||
m_lg = 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_lg = lstrlen( p );
|
||||
m_lg = strlen(p);
|
||||
|
||||
m_ptr = NULL;
|
||||
if (m_lg>0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
lstrcpy(m_ptr, p);
|
||||
}
|
||||
m_ptr = NULL;
|
||||
if (m_lg>0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
strcpy(m_ptr, p);
|
||||
}
|
||||
}
|
||||
|
||||
CBotString::CBotString(const CBotString& srcString)
|
||||
{
|
||||
m_lg = srcString.m_lg;
|
||||
m_lg = srcString.m_lg;
|
||||
|
||||
m_ptr = NULL;
|
||||
if (m_lg>0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
lstrcpy(m_ptr, srcString.m_ptr);
|
||||
}
|
||||
m_ptr = NULL;
|
||||
if (m_lg>0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
strcpy(m_ptr, srcString.m_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,539 +159,533 @@ CBotString::CBotString(const CBotString& srcString)
|
|||
|
||||
int CBotString::GivLength()
|
||||
{
|
||||
if ( m_ptr == NULL ) return 0;
|
||||
return lstrlen( m_ptr );
|
||||
if (m_ptr == NULL) return 0;
|
||||
return strlen( m_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
CBotString CBotString::Left(int nCount) const
|
||||
{
|
||||
char chaine[2000];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_lg && i < nCount && i < 1999; i++)
|
||||
{
|
||||
chaine[i] = m_ptr[i];
|
||||
}
|
||||
chaine[i] = 0 ;
|
||||
char chain[2000];
|
||||
|
||||
return CBotString( chaine );
|
||||
size_t i;
|
||||
for (i = 0; i < m_lg && i < nCount && i < 1999; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
}
|
||||
chain[i] = 0 ;
|
||||
|
||||
return CBotString(chain);
|
||||
}
|
||||
|
||||
CBotString CBotString::Right(int nCount) const
|
||||
{
|
||||
char chaine[2000];
|
||||
|
||||
int i = m_lg - nCount;
|
||||
if ( i < 0 ) i = 0;
|
||||
char chain[2000];
|
||||
|
||||
int j;
|
||||
for ( j = 0 ; i < m_lg && i < 1999; i++)
|
||||
{
|
||||
chaine[j++] = m_ptr[i];
|
||||
}
|
||||
chaine[j] = 0 ;
|
||||
int i = m_lg - nCount;
|
||||
if ( i < 0 ) i = 0;
|
||||
|
||||
return CBotString( chaine );
|
||||
size_t j;
|
||||
for (size_t j = 0 ; i < m_lg && i < 1999; ++i)
|
||||
{
|
||||
chain[j++] = m_ptr[i];
|
||||
}
|
||||
chain[j] = 0 ;
|
||||
|
||||
return CBotString(chain);
|
||||
}
|
||||
|
||||
CBotString CBotString::Mid(int nFirst, int nCount) const
|
||||
{
|
||||
char chaine[2000];
|
||||
|
||||
int i;
|
||||
char chain[2000];
|
||||
|
||||
for ( i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; i++)
|
||||
{
|
||||
chaine[i] = m_ptr[i];
|
||||
}
|
||||
chaine[i] = 0 ;
|
||||
size_t i;
|
||||
for (i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
}
|
||||
chain[i] = 0 ;
|
||||
|
||||
return CBotString( chaine );
|
||||
return CBotString(chain);
|
||||
}
|
||||
|
||||
CBotString CBotString::Mid(int nFirst) const
|
||||
{
|
||||
char chaine[2000];
|
||||
|
||||
int i;
|
||||
char chain[2000];
|
||||
|
||||
for ( i = nFirst; i < m_lg && i < 1999 ; i++)
|
||||
{
|
||||
chaine[i] = m_ptr[i];
|
||||
}
|
||||
chaine[i] = 0 ;
|
||||
size_t i;
|
||||
for (i = nFirst; i < m_lg && i < 1999 ; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
}
|
||||
chain[i] = 0 ;
|
||||
|
||||
return CBotString( chaine );
|
||||
return CBotString(chain);
|
||||
}
|
||||
|
||||
|
||||
int CBotString::Find(const char c)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < m_lg; i++)
|
||||
{
|
||||
if (m_ptr[i] == c) return i;
|
||||
}
|
||||
return -1;
|
||||
for (size_t i = 0; i < m_lg; ++i)
|
||||
{
|
||||
if (m_ptr[i] == c) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CBotString::Find(LPCTSTR lpsz)
|
||||
int CBotString::Find(const char * lpsz)
|
||||
{
|
||||
int i, j;
|
||||
int l = lstrlen(lpsz);
|
||||
int l = strlen(lpsz);
|
||||
|
||||
for (i = 0; i <= m_lg-l; i++)
|
||||
{
|
||||
for (j = 0; j < l; j++)
|
||||
{
|
||||
if (m_ptr[i+j] != lpsz[j]) goto bad;
|
||||
}
|
||||
return i;
|
||||
for (size_t i = 0; i <= m_lg-l; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < l; ++j)
|
||||
{
|
||||
if (m_ptr[i+j] != lpsz[j]) goto bad;
|
||||
}
|
||||
return i;
|
||||
bad:;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CBotString::ReverseFind(const char c)
|
||||
{
|
||||
int i;
|
||||
for (i = m_lg-1; i >= 0; i--)
|
||||
{
|
||||
if (m_ptr[i] == c) return i;
|
||||
}
|
||||
return -1;
|
||||
int i;
|
||||
for (i = m_lg-1; i >= 0; --i)
|
||||
{
|
||||
if (m_ptr[i] == c) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CBotString::ReverseFind(LPCTSTR lpsz)
|
||||
int CBotString::ReverseFind(const char * lpsz)
|
||||
{
|
||||
int i, j;
|
||||
int l = lstrlen(lpsz);
|
||||
int i, j;
|
||||
int l = strlen(lpsz);
|
||||
|
||||
for (i = m_lg-l; i >= 0; i--)
|
||||
{
|
||||
for (j = 0; j < l; j++)
|
||||
{
|
||||
if (m_ptr[i+j] != lpsz[j]) goto bad;
|
||||
}
|
||||
return i;
|
||||
for (i = m_lg-l; i >= 0; --i)
|
||||
{
|
||||
for (j = 0; j < l; ++j)
|
||||
{
|
||||
if (m_ptr[i+j] != lpsz[j]) goto bad;
|
||||
}
|
||||
return i;
|
||||
bad:;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
CBotString CBotString::Mid(int start, int lg)
|
||||
{
|
||||
CBotString res;
|
||||
if (start >= m_lg) return res;
|
||||
CBotString res;
|
||||
if (start >= m_lg) return res;
|
||||
|
||||
if ( lg < 0 ) lg = m_lg - start;
|
||||
if ( lg < 0 ) lg = m_lg - start;
|
||||
|
||||
char* p = (char*)malloc(m_lg+1);
|
||||
lstrcpy(p, m_ptr+start);
|
||||
p[lg] = 0;
|
||||
char* p = (char*)malloc(m_lg+1);
|
||||
strcpy(p, m_ptr+start);
|
||||
p[lg] = 0;
|
||||
|
||||
res = p;
|
||||
free(p);
|
||||
return res;
|
||||
res = p;
|
||||
free(p);
|
||||
return res;
|
||||
}
|
||||
|
||||
void CBotString::MakeUpper()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < m_lg && i < 1999 ; i++)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
|
||||
}
|
||||
for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
|
||||
}
|
||||
}
|
||||
|
||||
void CBotString::MakeLower()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < m_lg && i < 1999 ; i++)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
|
||||
}
|
||||
for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define MAXSTRING 256
|
||||
|
||||
BOOL CBotString::LoadString(UINT id)
|
||||
bool CBotString::LoadString(unsigned int id)
|
||||
{
|
||||
char buffer[MAXSTRING];
|
||||
const char * str = NULL;
|
||||
str = MapIdToString((EID)id);
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
|
||||
m_lg = ::LoadString( m_hInstance, id, buffer, MAXSTRING );
|
||||
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
|
||||
m_ptr = NULL;
|
||||
if (m_lg > 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
lstrcpy(m_ptr, buffer);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
m_lg = strlen(str);
|
||||
m_ptr = NULL;
|
||||
if (m_lg > 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
strcpy(m_ptr, str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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_ptr = NULL;
|
||||
m_lg = stringSrc.m_lg;
|
||||
|
||||
if (m_lg > 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
lstrcpy(m_ptr, stringSrc.m_ptr);
|
||||
}
|
||||
if (m_lg > 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
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 );
|
||||
s += lpsz;
|
||||
return s;
|
||||
CBotString s(string);
|
||||
s += lpsz;
|
||||
return s;
|
||||
}
|
||||
|
||||
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);
|
||||
char* pp = p + m_lg;
|
||||
lstrcpy(pp, stringSrc.m_ptr);
|
||||
strcpy(p, m_ptr);
|
||||
char* pp = p + m_lg;
|
||||
strcpy(pp, stringSrc.m_ptr);
|
||||
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
m_ptr = p;
|
||||
m_lg += stringSrc.m_lg;
|
||||
free(m_ptr);
|
||||
m_ptr = p;
|
||||
m_lg += stringSrc.m_lg;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBotString& CBotString::operator=(const char ch)
|
||||
{
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
free(m_ptr);
|
||||
|
||||
m_lg = 1;
|
||||
m_lg = 1;
|
||||
|
||||
m_ptr = (char*)malloc(2);
|
||||
m_ptr[0] = ch;
|
||||
m_ptr[1] = 0;
|
||||
|
||||
return *this;
|
||||
m_ptr = (char*)malloc(2);
|
||||
m_ptr[0] = ch;
|
||||
m_ptr[1] = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBotString& CBotString::operator=(const char* pString)
|
||||
{
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
m_ptr = NULL;
|
||||
free(m_ptr);
|
||||
m_ptr = NULL;
|
||||
|
||||
if ( pString != NULL )
|
||||
{
|
||||
m_lg = lstrlen(pString);
|
||||
if (pString != NULL)
|
||||
{
|
||||
m_lg = strlen(pString);
|
||||
|
||||
if (m_lg != 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
lstrcpy(m_ptr, pString);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
if (m_lg != 0)
|
||||
{
|
||||
m_ptr = (char*)malloc(m_lg+1);
|
||||
strcpy(m_ptr, pString);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
p[m_lg++] = ch;
|
||||
p[m_lg] = 0;
|
||||
if (m_ptr!=NULL) strcpy(p, m_ptr);
|
||||
p[m_lg++] = ch;
|
||||
p[m_lg] = 0;
|
||||
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
free(m_ptr);
|
||||
|
||||
m_ptr = p;
|
||||
m_ptr = p;
|
||||
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
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);
|
||||
char* pp = p + m_lg;
|
||||
lstrcpy(pp, str.m_ptr);
|
||||
strcpy(p, m_ptr);
|
||||
char* pp = p + m_lg;
|
||||
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()
|
||||
{
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
m_ptr = NULL;
|
||||
m_lg = 0;
|
||||
free(m_ptr);
|
||||
m_ptr = NULL;
|
||||
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;
|
||||
return m_ptr;
|
||||
if (this == NULL || m_ptr == NULL) return emptyString;
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
|
||||
int CBotString::Compare(LPCTSTR lpsz) const
|
||||
int CBotString::Compare(const char * lpsz) const
|
||||
{
|
||||
char* p = m_ptr;
|
||||
if (lpsz == NULL) lpsz = nilstring;
|
||||
if (m_ptr == NULL) p = nilstring;
|
||||
return strcmp(p, lpsz); // wcscmp
|
||||
char* p = m_ptr;
|
||||
if (lpsz == NULL) lpsz = emptyString;
|
||||
if (m_ptr == NULL) p = emptyString;
|
||||
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()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nSize = m_nMaxSize = 0;
|
||||
m_pData = NULL;
|
||||
m_nSize = m_nMaxSize = 0;
|
||||
}
|
||||
|
||||
CBotStringArray::~CBotStringArray()
|
||||
{
|
||||
SetSize(0); // détruit les données !
|
||||
SetSize(0); // destroys data !
|
||||
}
|
||||
|
||||
|
||||
int CBotStringArray::GivSize()
|
||||
{
|
||||
return m_nSize;
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
void CBotStringArray::Add(const CBotString& str)
|
||||
{
|
||||
SetSize(m_nSize+1);
|
||||
SetSize(m_nSize+1);
|
||||
|
||||
m_pData[m_nSize-1] = str;
|
||||
m_pData[m_nSize-1] = str;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// routines utilitaires
|
||||
// utility routines
|
||||
|
||||
static inline void ConstructElement(CBotString* pNewData)
|
||||
{
|
||||
memset(pNewData, 0, sizeof(CBotString));
|
||||
memset(pNewData, 0, sizeof(CBotString));
|
||||
}
|
||||
|
||||
static inline void DestructElement(CBotString* pOldData)
|
||||
{
|
||||
pOldData->~CBotString();
|
||||
pOldData->~CBotString();
|
||||
}
|
||||
|
||||
static inline void CopyElement(CBotString* pSrc, CBotString* pDest)
|
||||
{
|
||||
*pSrc = *pDest;
|
||||
*pSrc = *pDest;
|
||||
}
|
||||
|
||||
static void ConstructElements(CBotString* pNewData, int nCount)
|
||||
{
|
||||
while (nCount--)
|
||||
{
|
||||
ConstructElement(pNewData);
|
||||
pNewData++;
|
||||
}
|
||||
while (nCount--)
|
||||
{
|
||||
ConstructElement(pNewData);
|
||||
pNewData++;
|
||||
}
|
||||
}
|
||||
|
||||
static void DestructElements(CBotString* pOldData, int nCount)
|
||||
{
|
||||
while (nCount--)
|
||||
{
|
||||
DestructElement(pOldData);
|
||||
pOldData++;
|
||||
}
|
||||
while (nCount--)
|
||||
{
|
||||
DestructElement(pOldData);
|
||||
pOldData++;
|
||||
}
|
||||
}
|
||||
|
||||
static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount)
|
||||
{
|
||||
while (nCount--)
|
||||
{
|
||||
*pDest = *pSrc;
|
||||
++pDest;
|
||||
++pSrc;
|
||||
}
|
||||
while (nCount--)
|
||||
{
|
||||
*pDest = *pSrc;
|
||||
++pDest;
|
||||
++pSrc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sélect la taille du tableau
|
||||
// set the array size
|
||||
|
||||
void CBotStringArray::SetSize(int nNewSize)
|
||||
{
|
||||
if (nNewSize == 0)
|
||||
{
|
||||
// shrink to nothing
|
||||
if (nNewSize == 0)
|
||||
{
|
||||
// shrink to nothing
|
||||
|
||||
DestructElements(m_pData, m_nSize);
|
||||
delete[] (BYTE*)m_pData;
|
||||
m_pData = NULL;
|
||||
m_nSize = m_nMaxSize = 0;
|
||||
}
|
||||
else if (m_pData == NULL)
|
||||
{
|
||||
// create one with exact size
|
||||
m_pData = (CBotString*) new BYTE[nNewSize * sizeof(CBotString)];
|
||||
DestructElements(m_pData, m_nSize);
|
||||
delete[] (unsigned char *)m_pData;
|
||||
m_pData = NULL;
|
||||
m_nSize = m_nMaxSize = 0;
|
||||
}
|
||||
else if (m_pData == NULL)
|
||||
{
|
||||
// create one with exact size
|
||||
m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)];
|
||||
|
||||
ConstructElements(m_pData, nNewSize);
|
||||
ConstructElements(m_pData, nNewSize);
|
||||
|
||||
m_nSize = m_nMaxSize = nNewSize;
|
||||
}
|
||||
else if (nNewSize <= m_nMaxSize)
|
||||
{
|
||||
// it fits
|
||||
if (nNewSize > m_nSize)
|
||||
{
|
||||
// initialize the new elements
|
||||
m_nSize = m_nMaxSize = nNewSize;
|
||||
}
|
||||
else if (nNewSize <= m_nMaxSize)
|
||||
{
|
||||
// it fits
|
||||
if (nNewSize > m_nSize)
|
||||
{
|
||||
// initialize the new elements
|
||||
|
||||
ConstructElements(&m_pData[m_nSize], nNewSize-m_nSize);
|
||||
ConstructElements(&m_pData[m_nSize], nNewSize-m_nSize);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else if (m_nSize > nNewSize) // destroy the old elements
|
||||
DestructElements(&m_pData[nNewSize], m_nSize-nNewSize);
|
||||
else if (m_nSize > nNewSize) // destroy the old elements
|
||||
DestructElements(&m_pData[nNewSize], m_nSize-nNewSize);
|
||||
|
||||
m_nSize = nNewSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, grow array
|
||||
int nGrowBy;
|
||||
{
|
||||
// heuristically determine growth when nGrowBy == 0
|
||||
// (this avoids heap fragmentation in many situations)
|
||||
nGrowBy = min(1024, max(4, m_nSize / 8));
|
||||
}
|
||||
int nNewMax;
|
||||
if (nNewSize < m_nMaxSize + nGrowBy)
|
||||
nNewMax = m_nMaxSize + nGrowBy; // granularity
|
||||
else
|
||||
nNewMax = nNewSize; // no slush
|
||||
m_nSize = nNewSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, grow array
|
||||
int nGrowBy;
|
||||
{
|
||||
// heuristically determine growth when nGrowBy == 0
|
||||
// (this avoids heap fragmentation in many situations)
|
||||
nGrowBy = std::min(1024, std::max(4, m_nSize / 8));
|
||||
}
|
||||
int nNewMax;
|
||||
if (nNewSize < m_nMaxSize + nGrowBy)
|
||||
nNewMax = m_nMaxSize + nGrowBy; // granularity
|
||||
else
|
||||
nNewMax = nNewSize; // no slush
|
||||
|
||||
CBotString* pNewData = (CBotString*) new BYTE[nNewMax * sizeof(CBotString)];
|
||||
CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)];
|
||||
|
||||
// copy new data from old
|
||||
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
|
||||
// copy new data from old
|
||||
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
|
||||
|
||||
// construct remaining elements
|
||||
ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize);
|
||||
// construct remaining elements
|
||||
ConstructElements(&pNewData[m_nSize], nNewSize-m_nSize);
|
||||
|
||||
|
||||
// Ret rid of old stuff (note: no destructors called)
|
||||
delete[] (BYTE*)m_pData;
|
||||
m_pData = pNewData;
|
||||
m_nSize = nNewSize;
|
||||
m_nMaxSize = nNewMax;
|
||||
}
|
||||
// Get rid of old stuff (note: no destructors called)
|
||||
delete[] (unsigned char *)m_pData;
|
||||
m_pData = pNewData;
|
||||
m_nSize = nNewSize;
|
||||
m_nMaxSize = nNewMax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBotString& CBotStringArray::operator[](int nIndex)
|
||||
{
|
||||
return ElementAt(nIndex);
|
||||
return ElementAt(nIndex);
|
||||
}
|
||||
|
||||
CBotString& CBotStringArray::ElementAt(int nIndex)
|
||||
{
|
||||
return m_pData[nIndex];
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "CBot.h"
|
||||
#include <cstdarg>
|
||||
|
||||
CBotStringArray CBotToken::m_ListKeyWords;
|
||||
int CBotToken::m_ListIdKeyWords[200];
|
||||
|
@ -188,27 +189,27 @@ void CBotToken::SetPos(int start, int end)
|
|||
m_end = end;
|
||||
}
|
||||
|
||||
BOOL CharInList(const char c, const char* list)
|
||||
bool CharInList(const char c, const char* list)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (c == list[i++]) return TRUE;
|
||||
if (list[i] == 0) return FALSE;
|
||||
if (c == list[i++]) return true;
|
||||
if (list[i] == 0) return false;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL Char2InList(const char c, const char cc, const char* list)
|
||||
bool Char2InList(const char c, const char cc, const char* list)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (c == list[i++] &&
|
||||
cc == list[i++]) return TRUE;
|
||||
cc == list[i++]) return true;
|
||||
|
||||
if (list[i] == 0) return FALSE;
|
||||
if (list[i] == 0) return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,12 +225,12 @@ static char* nch = "\"\r\n\t"; // refus
|
|||
// cherche le prochain token dans une phrase
|
||||
// ne doit pas commencer par des séparateurs
|
||||
// qui sont pris avec le token précédent
|
||||
CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first)
|
||||
CBotToken* CBotToken::NextToken(char* &program, int& error, bool first)
|
||||
{
|
||||
CBotString mot; // le mot trouvé
|
||||
CBotString sep; // les séparateurs qui le suivent
|
||||
char c;
|
||||
BOOL stop = first;
|
||||
bool stop = first;
|
||||
|
||||
if (*program == 0) return NULL;
|
||||
|
||||
|
@ -262,14 +263,14 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, BOOL first)
|
|||
mot += c; // chaîne complète
|
||||
c = *(program++); // prochain caractère
|
||||
}
|
||||
stop = TRUE;
|
||||
stop = true;
|
||||
}
|
||||
|
||||
// cas particulier pour les nombres
|
||||
if ( CharInList(mot[0], num ))
|
||||
{
|
||||
BOOL bdot = FALSE; // trouvé un point ?
|
||||
BOOL bexp = FALSE; // trouvé un exposant ?
|
||||
bool bdot = false; // trouvé un point ?
|
||||
bool bexp = false; // trouvé un exposant ?
|
||||
|
||||
char* liste = num;
|
||||
if (mot[0] == '0' && c == 'x') // valeur hexadécimale ?
|
||||
|
@ -286,10 +287,10 @@ cc: mot += c;
|
|||
}
|
||||
if ( liste == num ) // pas pour les exadécimaux
|
||||
{
|
||||
if ( !bdot && c == '.' ) { bdot = TRUE; goto cc; }
|
||||
if ( !bdot && c == '.' ) { bdot = true; goto cc; }
|
||||
if ( !bexp && ( c == 'e' || c == 'E' ) )
|
||||
{
|
||||
bexp = TRUE;
|
||||
bexp = true;
|
||||
mot += c;
|
||||
c = *(program++); // prochain caractère
|
||||
if ( c == '-' ||
|
||||
|
@ -298,7 +299,7 @@ cc: mot += c;
|
|||
}
|
||||
|
||||
}
|
||||
stop = TRUE;
|
||||
stop = true;
|
||||
}
|
||||
|
||||
if (CharInList(mot[0], sep3)) // un séparateur opérationnel ?
|
||||
|
@ -310,13 +311,13 @@ cc: mot += c;
|
|||
c = *(program++); // prochain caractère
|
||||
}
|
||||
|
||||
stop = TRUE;
|
||||
stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (stop || c == 0 || CharInList(c, sep1))
|
||||
{
|
||||
|
@ -381,7 +382,7 @@ CBotToken* CBotToken::CompileTokens(const char* program, int& error)
|
|||
int pos = 0;
|
||||
|
||||
error = 0;
|
||||
prv = tokenbase = NextToken(p, error, TRUE);
|
||||
prv = tokenbase = NextToken(p, error, true);
|
||||
|
||||
if (tokenbase == NULL) return NULL;
|
||||
|
||||
|
@ -443,7 +444,7 @@ int CBotToken::GivKeyWords(const char* w)
|
|||
return -1;
|
||||
}
|
||||
|
||||
BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
|
||||
bool CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
|
||||
{
|
||||
int i;
|
||||
int l = m_ListKeyDefine.GivSize();
|
||||
|
@ -454,15 +455,16 @@ BOOL CBotToken::GivKeyDefNum(const char* w, CBotToken* &token)
|
|||
{
|
||||
token->m_IdKeyWord = m_ListKeyNums[i];
|
||||
token->m_type = TokenTypDef;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// reprend la liste des mots clefs dans les ressources
|
||||
|
||||
/// \todo Fixme Figure out how this should work.
|
||||
void CBotToken::LoadKeyWords()
|
||||
{
|
||||
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 l = m_ListKeyDefine.GivSize();
|
||||
|
||||
for (i = 0; i < l; i++)
|
||||
{
|
||||
if (m_ListKeyDefine[i] == name) return FALSE;
|
||||
if (m_ListKeyDefine[i] == name) return false;
|
||||
}
|
||||
if ( i == MAXDEFNUM ) return FALSE;
|
||||
if ( i == MAXDEFNUM ) return false;
|
||||
|
||||
m_ListKeyDefine.Add( name );
|
||||
m_ListKeyNums[i] = val;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL IsOfType(CBotToken* &p, int type1, int type2)
|
||||
bool IsOfType(CBotToken* &p, int type1, int type2)
|
||||
{
|
||||
if (p->GivType() == type1 ||
|
||||
p->GivType() == type2 )
|
||||
{
|
||||
p = p->GivNext();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// idem avec un nombre indéfini d'arguments
|
||||
// il faut mettre un zéro comme dernier argument
|
||||
BOOL IsOfTypeList(CBotToken* &p, int type1, ...)
|
||||
bool IsOfTypeList(CBotToken* &p, int type1, ...)
|
||||
{
|
||||
int i = type1;
|
||||
int max = 20;
|
||||
|
@ -536,18 +538,18 @@ BOOL IsOfTypeList(CBotToken* &p, int type1, ...)
|
|||
va_list marker;
|
||||
va_start( marker, type1 ); /* Initialize variable arguments. */
|
||||
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if (type == i)
|
||||
{
|
||||
p = p->GivNext();
|
||||
va_end( marker ); /* Reset variable arguments. */
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
if (--max == 0 || 0 == (i = va_arg( marker, int)))
|
||||
{
|
||||
va_end( marker ); /* Reset variable arguments. */
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,5 +33,5 @@
|
|||
// )
|
||||
|
||||
|
||||
extern BOOL IsOfType(CBotToken* &p, int type1, int type2 = -1);
|
||||
extern BOOL IsOfTypeList(CBotToken* &p, int type1, ...);
|
||||
extern bool IsOfType(CBotToken* &p, int type1, int type2 = -1);
|
||||
extern bool IsOfTypeList(CBotToken* &p, int type1, ...);
|
||||
|
|
|
@ -95,19 +95,19 @@ static int ListOp[] =
|
|||
0,
|
||||
};
|
||||
|
||||
BOOL IsInList( int val, int* list, int& typemasque )
|
||||
bool IsInList( int val, int* list, int& typemasque )
|
||||
{
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if ( *list == 0 ) return FALSE;
|
||||
if ( *list == 0 ) return false;
|
||||
typemasque = *list++;
|
||||
if ( *list++ == val ) return TRUE;
|
||||
if ( *list++ == val ) return true;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL TypeOk( int type, int test )
|
||||
bool TypeOk( int type, int test )
|
||||
{
|
||||
while (TRUE)
|
||||
while (true)
|
||||
{
|
||||
if ( type == 0 ) return (test & 1);
|
||||
type--; test /= 2;
|
||||
|
@ -279,43 +279,43 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
|||
}
|
||||
|
||||
|
||||
BOOL IsNan(CBotVar* left, CBotVar* right, int* err = NULL)
|
||||
bool IsNan(CBotVar* left, CBotVar* right, int* err = NULL)
|
||||
{
|
||||
if ( left ->GivInit() > IS_DEF || right->GivInit() > IS_DEF )
|
||||
{
|
||||
if ( err != NULL ) *err = TX_OPNAN ;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// fait l'opération sur 2 opérandes
|
||||
|
||||
BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||
bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
||||
{
|
||||
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pStk1 == EOX ) return TRUE;
|
||||
// if ( pStk1 == EOX ) return true;
|
||||
|
||||
// selon la reprise, on peut être dans l'un des 2 états
|
||||
|
||||
if ( pStk1->GivState() == 0 ) // 1er état, évalue l'opérande de gauche
|
||||
{
|
||||
if (!m_leftop->Execute(pStk1) ) return FALSE; // interrompu ici ?
|
||||
if (!m_leftop->Execute(pStk1) ) return false; // interrompu ici ?
|
||||
|
||||
// pour les OU et ET logique, n'évalue pas la seconde expression si pas nécessaire
|
||||
if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == FALSE )
|
||||
if ( (GivTokenType() == ID_LOG_AND || GivTokenType() == ID_TXT_AND ) && pStk1->GivVal() == false )
|
||||
{
|
||||
CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
|
||||
res->SetValInt(FALSE);
|
||||
res->SetValInt(false);
|
||||
pStk1->SetVar(res);
|
||||
return pStack->Return(pStk1); // transmet le résultat
|
||||
}
|
||||
if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == TRUE )
|
||||
if ( (GivTokenType() == ID_LOG_OR||GivTokenType() == ID_TXT_OR) && pStk1->GivVal() == true )
|
||||
{
|
||||
CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
|
||||
res->SetValInt(TRUE);
|
||||
res->SetValInt(true);
|
||||
pStk1->SetVar(res);
|
||||
return pStack->Return(pStk1); // transmet le résultat
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
// 2e état, évalue l'opérande de droite
|
||||
if ( pStk2->GivState() == 0 )
|
||||
{
|
||||
if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ?
|
||||
if ( !m_rightop->Execute(pStk2) ) return false; // interrompu ici ?
|
||||
pStk2->IncState();
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
CBotTypResult type2 = pStk2->GivTypResult();
|
||||
|
||||
CBotStack* pStk3 = pStk2->AddStack(this); // ajoute un élément à la pile
|
||||
if ( pStk3->IfStep() ) return FALSE; // montre l'opération si step by step
|
||||
if ( pStk3->IfStep() ) return false; // montre l'opération si step by step
|
||||
|
||||
// crée une variable temporaire pour y mettre le résultat
|
||||
// quel est le type du résultat ?
|
||||
|
@ -475,7 +475,7 @@ BOOL CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
return pStack->Return(pStk2); // transmet le résultat
|
||||
}
|
||||
|
||||
void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
|
||||
void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
CBotStack* pStk1 = pStack->RestoreStack(this); // ajoute un élément à la pile
|
||||
|
@ -501,31 +501,31 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
|
|||
}
|
||||
|
||||
|
||||
BOOL CBotLogicExpr::Execute(CBotStack* &pStack)
|
||||
bool CBotLogicExpr::Execute(CBotStack* &pStack)
|
||||
{
|
||||
CBotStack* pStk1 = pStack->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pStk1 == EOX ) return TRUE;
|
||||
// if ( pStk1 == EOX ) return true;
|
||||
|
||||
if ( pStk1->GivState() == 0 )
|
||||
{
|
||||
if ( !m_condition->Execute(pStk1) ) return FALSE;
|
||||
if (!pStk1->SetState(1)) return FALSE;
|
||||
if ( !m_condition->Execute(pStk1) ) return false;
|
||||
if (!pStk1->SetState(1)) return false;
|
||||
}
|
||||
|
||||
if ( pStk1->GivVal() == TRUE )
|
||||
if ( pStk1->GivVal() == true )
|
||||
{
|
||||
if ( !m_op1->Execute(pStk1) ) return FALSE;
|
||||
if ( !m_op1->Execute(pStk1) ) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !m_op2->Execute(pStk1) ) return FALSE;
|
||||
if ( !m_op2->Execute(pStk1) ) return false;
|
||||
}
|
||||
|
||||
return pStack->Return(pStk1); // transmet le résultat
|
||||
}
|
||||
|
||||
void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
|
||||
void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -538,7 +538,7 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, BOOL bMain)
|
|||
return;
|
||||
}
|
||||
|
||||
if ( pStk1->GivVal() == TRUE )
|
||||
if ( pStk1->GivVal() == true )
|
||||
{
|
||||
m_op1->RestoreState(pStk1, bMain);
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ void t()
|
|||
#endif
|
||||
|
||||
#if 01
|
||||
void t(BOOL t)
|
||||
void t(bool t)
|
||||
{
|
||||
int x;
|
||||
x = 1 + t ? 1 : 3 + 4 * 2 ;
|
||||
|
|
2322
src/CBot/CBotVar.cpp
2322
src/CBot/CBotVar.cpp
File diff suppressed because it is too large
Load Diff
|
@ -66,7 +66,7 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
// la condition existe
|
||||
|
||||
IncLvl(inst->m_label);
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
DecLvl();
|
||||
|
||||
if ( pStk->IsOk() )
|
||||
|
@ -83,31 +83,31 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute une instruction "while"
|
||||
|
||||
BOOL CBotWhile :: Execute(CBotStack* &pj)
|
||||
bool CBotWhile :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
while( TRUE ) switch( pile->GivState() ) // exécute la boucle
|
||||
while( true ) switch( pile->GivState() ) // exécute la boucle
|
||||
{ // il y a 2 états possibles (selon reprise)
|
||||
case 0:
|
||||
// évalue la condition
|
||||
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
// termine s'il y a une erreur ou si la condition est fausse
|
||||
if ( !pile->IsOk() || pile->GivVal() != TRUE )
|
||||
if ( !pile->IsOk() || pile->GivVal() != true )
|
||||
{
|
||||
return pj->Return(pile); // transmet le résultat et libère la pile
|
||||
}
|
||||
|
||||
// la condition est vrai, passe dans le second mode
|
||||
|
||||
if (!pile->SetState(1)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(1)) return false; // prêt pour la suite
|
||||
|
||||
case 1:
|
||||
// évalue le bloc d'instruction associé
|
||||
|
@ -125,12 +125,12 @@ BOOL CBotWhile :: Execute(CBotStack* &pj)
|
|||
}
|
||||
|
||||
// repasse au test pour recommencer
|
||||
if (!pile->SetState(0, 0)) return FALSE;
|
||||
if (!pile->SetState(0, 0)) return false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CBotWhile :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile
|
||||
|
@ -196,7 +196,7 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
{
|
||||
|
||||
IncLvl(inst->m_label);
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
DecLvl();
|
||||
|
||||
if ( pStk->IsOk() )
|
||||
|
@ -221,19 +221,19 @@ CBotInstr* CBotRepeat::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute une instruction "repeat"
|
||||
|
||||
BOOL CBotRepeat :: Execute(CBotStack* &pj)
|
||||
bool CBotRepeat :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
while( TRUE ) switch( pile->GivState() ) // exécute la boucle
|
||||
while( true ) switch( pile->GivState() ) // exécute la boucle
|
||||
{ // il y a 2 états possibles (selon reprise)
|
||||
case 0:
|
||||
// évalue le nombre d'itération
|
||||
if ( !m_NbIter->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if ( !m_NbIter->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
|
@ -246,7 +246,7 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj)
|
|||
|
||||
// met le nombre d'itération +1 dans le "state"
|
||||
|
||||
if (!pile->SetState(n+1)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(n+1)) return false; // prêt pour la suite
|
||||
continue; // passe à la suite
|
||||
|
||||
case 1:
|
||||
|
@ -269,12 +269,12 @@ BOOL CBotRepeat :: Execute(CBotStack* &pj)
|
|||
}
|
||||
|
||||
// repasse au test pour recommencer
|
||||
if (!pile->SetState(pile->GivState()-1, 0)) return FALSE;
|
||||
if (!pile->SetState(pile->GivState()-1, 0)) return false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CBotRepeat :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotRepeat :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
CBotStack* pile = pj->RestoreStack(this); // ajoute un élément à la pile
|
||||
|
@ -332,7 +332,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// cherche un bloc d'instruction après le do
|
||||
IncLvl(inst->m_label);
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
DecLvl();
|
||||
|
||||
if ( pStk->IsOk() )
|
||||
|
@ -358,15 +358,15 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute une instruction "do"
|
||||
|
||||
BOOL CBotDo :: Execute(CBotStack* &pj)
|
||||
bool CBotDo :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
while( TRUE ) switch( pile->GivState() ) // exécute la boucle
|
||||
while( true ) switch( pile->GivState() ) // exécute la boucle
|
||||
{ // il y a 2 états possibles (selon reprise)
|
||||
case 0:
|
||||
// évalue le bloc d'instruction associé
|
||||
|
@ -383,27 +383,27 @@ BOOL CBotDo :: Execute(CBotStack* &pj)
|
|||
return pj->Return(pile); // transmet le résultat et libère la pile
|
||||
}
|
||||
|
||||
if (!pile->SetState(1)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(1)) return false; // prêt pour la suite
|
||||
|
||||
case 1:
|
||||
// évalue la condition
|
||||
if ( !m_Condition->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if ( !m_Condition->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
// termine s'il y a une erreur ou si la condition est fausse
|
||||
if ( !pile->IsOk() || pile->GivVal() != TRUE )
|
||||
if ( !pile->IsOk() || pile->GivVal() != true )
|
||||
{
|
||||
return pj->Return(pile); // transmet le résultat et libère la pile
|
||||
}
|
||||
|
||||
// repasse au bloc d'instruction pour recommencer
|
||||
if (!pile->SetState(0, 0)) return FALSE;
|
||||
if (!pile->SetState(0, 0)) return false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CBotDo :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotDo :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -467,7 +467,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp, TRUE); // un petit bout de pile svp
|
||||
CBotCStack* pStk = pStack->TokenStack(pp, true); // un petit bout de pile svp
|
||||
|
||||
// compile les instructions pour initialisation
|
||||
inst->m_Init = CBotListExpression::Compile( p, pStk );
|
||||
|
@ -494,7 +494,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if ( IsOfType(p, ID_CLOSEPAR)) // manque la parenthèse ?
|
||||
{
|
||||
IncLvl(inst->m_label);
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
inst->m_Block = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
DecLvl();
|
||||
if ( pStk->IsOk() )
|
||||
return pStack->Return(inst, pStk);;
|
||||
|
@ -510,39 +510,39 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute l'instruction "for"
|
||||
|
||||
BOOL CBotFor :: Execute(CBotStack* &pj)
|
||||
bool CBotFor :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this, TRUE); // ajoute un élément à la pile (variables locales)
|
||||
CBotStack* pile = pj->AddStack(this, true); // ajoute un élément à la pile (variables locales)
|
||||
// ou le retrouve en cas de reprise
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
while( TRUE ) switch( pile->GivState() ) // exécute la boucle
|
||||
while( true ) switch( pile->GivState() ) // exécute la boucle
|
||||
{ // il y a 4 états possibles (selon reprise)
|
||||
case 0:
|
||||
// évalue l'initialisation
|
||||
if ( m_Init != NULL &&
|
||||
!m_Init->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if (!pile->SetState(1)) return FALSE; // prêt pour la suite
|
||||
!m_Init->Execute(pile) ) return false; // interrompu ici ?
|
||||
if (!pile->SetState(1)) return false; // prêt pour la suite
|
||||
|
||||
case 1:
|
||||
// évalue la condition
|
||||
if ( m_Test != NULL ) // pas de condition ? -> vrai !
|
||||
{
|
||||
if (!m_Test->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
if (!m_Test->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// le résultat de la condition est sur la pile
|
||||
|
||||
// termine s'il y a une erreur ou si la condition est fausse
|
||||
if ( !pile->IsOk() || pile->GivVal() != TRUE )
|
||||
if ( !pile->IsOk() || pile->GivVal() != true )
|
||||
{
|
||||
return pj->Return(pile); // transmet le résultat et libère la pile
|
||||
}
|
||||
}
|
||||
|
||||
// la condition est vrai, passe à la suite
|
||||
if (!pile->SetState(2)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(2)) return false; // prêt pour la suite
|
||||
|
||||
case 2:
|
||||
// évalue le bloc d'instruction associé
|
||||
|
@ -559,20 +559,20 @@ BOOL CBotFor :: Execute(CBotStack* &pj)
|
|||
return pj->Return(pile); // transmet le résultat et libère la pile
|
||||
}
|
||||
|
||||
if (!pile->SetState(3)) return FALSE; // prêt pour la suite
|
||||
if (!pile->SetState(3)) return false; // prêt pour la suite
|
||||
|
||||
case 3:
|
||||
// évalue l'incrémentation
|
||||
if ( m_Incr != NULL &&
|
||||
!m_Incr->Execute(pile) ) return FALSE; // interrompu ici ?
|
||||
!m_Incr->Execute(pile) ) return false; // interrompu ici ?
|
||||
|
||||
// repasse au test pour recommencer
|
||||
if (!pile->SetState(1, 0)) return FALSE; // revient au test
|
||||
if (!pile->SetState(1, 0)) return false; // revient au test
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotFor :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -583,28 +583,28 @@ void CBotFor :: RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
{ // il y a 4 états possibles (selon reprise)
|
||||
case 0:
|
||||
// évalue l'initialisation
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, TRUE); // interrompu ici !
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, true); // interrompu ici !
|
||||
return;
|
||||
|
||||
case 1:
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
|
||||
|
||||
// évalue la condition
|
||||
if ( m_Test != NULL ) m_Test->RestoreState(pile, TRUE); // interrompu ici !
|
||||
if ( m_Test != NULL ) m_Test->RestoreState(pile, true); // interrompu ici !
|
||||
return;
|
||||
|
||||
case 2:
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
|
||||
|
||||
// évalue le bloc d'instruction associé
|
||||
if ( m_Block != NULL ) m_Block->RestoreState(pile, TRUE);
|
||||
if ( m_Block != NULL ) m_Block->RestoreState(pile, true);
|
||||
return;
|
||||
|
||||
case 3:
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, FALSE); // définitions variables
|
||||
if ( m_Init != NULL ) m_Init->RestoreState(pile, false); // définitions variables
|
||||
|
||||
// évalue l'incrémentation
|
||||
if ( m_Incr != NULL ) m_Incr->RestoreState(pile, TRUE); // interrompu ici !
|
||||
if ( m_Incr != NULL ) m_Incr->RestoreState(pile, true); // interrompu ici !
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -629,10 +629,10 @@ CBotListExpression::~CBotListExpression()
|
|||
|
||||
static CBotInstr* CompileInstrOrDefVar(CBotToken* &p, CBotCStack* pStack)
|
||||
{
|
||||
CBotInstr* i = CBotInt::Compile( p, pStack, FALSE, TRUE ); // est-ce une déclaration d'un entier ?
|
||||
if ( i== NULL ) i = CBotFloat::Compile( p, pStack, FALSE, TRUE ); // ou d'un nombre réel ?
|
||||
if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, FALSE, TRUE ); // ou d'un booléen ?
|
||||
if ( i== NULL ) i = CBotIString::Compile( p, pStack, FALSE, TRUE ); // ou d'une chaîne ?
|
||||
CBotInstr* i = CBotInt::Compile( p, pStack, false, true ); // est-ce une déclaration d'un entier ?
|
||||
if ( i== NULL ) i = CBotFloat::Compile( p, pStack, false, true ); // ou d'un nombre réel ?
|
||||
if ( i== NULL ) i = CBotBoolean::Compile( p, pStack, false, true ); // ou d'un booléen ?
|
||||
if ( i== NULL ) i = CBotIString::Compile( p, pStack, false, true ); // ou d'une chaîne ?
|
||||
if ( i== NULL ) i = CBotExpression::Compile( p, pStack ); // compile une expression
|
||||
return i;
|
||||
}
|
||||
|
@ -660,7 +660,7 @@ CBotInstr* CBotListExpression::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CBotListExpression::Execute(CBotStack* &pj)
|
||||
bool CBotListExpression::Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack();// indispensable
|
||||
CBotInstr* p = m_Expr; // la première expression
|
||||
|
@ -668,17 +668,17 @@ BOOL CBotListExpression::Execute(CBotStack* &pj)
|
|||
int state = pile->GivState();
|
||||
while (state-->0) p = p->GivNext(); // revient sur l'opération interrompue
|
||||
|
||||
if ( p != NULL ) while (TRUE)
|
||||
if ( p != NULL ) while (true)
|
||||
{
|
||||
if ( !p->Execute(pile) ) return FALSE;
|
||||
if ( !p->Execute(pile) ) return false;
|
||||
p = p->GivNext();
|
||||
if ( p == NULL ) break;
|
||||
if (!pile->IncState()) return FALSE; // prêt pour la suivante
|
||||
if (!pile->IncState()) return false; // prêt pour la suivante
|
||||
}
|
||||
return pj->Return(pile);
|
||||
}
|
||||
|
||||
void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
CBotStack* pile = pj;
|
||||
int state = 0x7000;
|
||||
|
@ -694,7 +694,7 @@ void CBotListExpression::RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
|
||||
while (p != NULL && state-->0)
|
||||
{
|
||||
p->RestoreState(pile, FALSE);
|
||||
p->RestoreState(pile, false);
|
||||
p = p->GivNext(); // revient sur l'opération interrompue
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
return pStack->Return(NULL, pStk);
|
||||
}
|
||||
|
||||
CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, TRUE );
|
||||
CBotInstr* i = CBotBlock::CompileBlkOrInst( p, pStk, true );
|
||||
if ( !pStk->IsOk() )
|
||||
{
|
||||
delete inst;
|
||||
|
@ -811,21 +811,21 @@ CBotInstr* CBotSwitch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute une instruction "switch"
|
||||
|
||||
BOOL CBotSwitch :: Execute(CBotStack* &pj)
|
||||
bool CBotSwitch :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// if ( pile1 == EOX ) return TRUE;
|
||||
// if ( pile1 == EOX ) return true;
|
||||
|
||||
CBotInstr* p = m_Block; // la première expression
|
||||
|
||||
int state = pile1->GivState();
|
||||
if (state == 0)
|
||||
{
|
||||
if ( !m_Value->Execute(pile1) ) return FALSE;
|
||||
if ( !m_Value->Execute(pile1) ) return false;
|
||||
pile1->SetState(state = -1);
|
||||
}
|
||||
|
||||
if ( pile1->IfStep() ) return FALSE;
|
||||
if ( pile1->IfStep() ) return false;
|
||||
|
||||
if ( state == -1 )
|
||||
{
|
||||
|
@ -843,7 +843,7 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
|
|||
|
||||
if ( p == NULL ) return pj->Return(pile1); // terminé si plus rien
|
||||
|
||||
if ( !pile1->SetState(state) ) return FALSE;
|
||||
if ( !pile1->SetState(state) ) return false;
|
||||
}
|
||||
|
||||
p = m_Block; // revient au début
|
||||
|
@ -852,13 +852,13 @@ BOOL CBotSwitch :: Execute(CBotStack* &pj)
|
|||
while( p != NULL )
|
||||
{
|
||||
if ( !p->Execute(pile1) ) return pj->BreakReturn(pile1);
|
||||
if ( !pile1->IncState() ) return FALSE;
|
||||
if ( !pile1->IncState() ) return false;
|
||||
p = p->GivNext();
|
||||
}
|
||||
return pj->Return(pile1);
|
||||
}
|
||||
|
||||
void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotSwitch :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -882,13 +882,13 @@ void CBotSwitch :: RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
// p = m_Block; // revient au début
|
||||
while ( p != NULL && state-- > 0 )
|
||||
{
|
||||
p->RestoreState(pile1, FALSE);
|
||||
p->RestoreState(pile1, false);
|
||||
p = p->GivNext(); // avance dans la liste
|
||||
}
|
||||
|
||||
if( p != NULL )
|
||||
{
|
||||
p->RestoreState(pile1, TRUE);
|
||||
p->RestoreState(pile1, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -942,21 +942,21 @@ CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécution de l'instruction "case"
|
||||
|
||||
BOOL CBotCase::Execute(CBotStack* &pj)
|
||||
bool CBotCase::Execute(CBotStack* &pj)
|
||||
{
|
||||
return TRUE; // l'instruction "case" ne fait rien !
|
||||
return true; // l'instruction "case" ne fait rien !
|
||||
}
|
||||
|
||||
void CBotCase::RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotCase::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
}
|
||||
|
||||
// routine permettant de trouver le point d'entrée "case"
|
||||
// correspondant à la valeur cherchée
|
||||
|
||||
BOOL CBotCase::CompCase(CBotStack* &pile, int val)
|
||||
bool CBotCase::CompCase(CBotStack* &pile, int val)
|
||||
{
|
||||
if ( m_Value == NULL ) return TRUE; // cas pour "default"
|
||||
if ( m_Value == NULL ) return true; // cas pour "default"
|
||||
|
||||
while (!m_Value->Execute(pile)); // met sur la pile la valeur correpondant (sans interruption)
|
||||
return (pile->GivVal() == val); // compare avec la valeur cherchée
|
||||
|
@ -1016,18 +1016,18 @@ CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécution l'instructino "break" ou "continu"
|
||||
|
||||
BOOL CBotBreak :: Execute(CBotStack* &pj)
|
||||
bool CBotBreak :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this);
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
pile->SetBreak(m_token.GivType()==ID_BREAK ? 1 : 2, m_label);
|
||||
return pj->Return(pile);
|
||||
}
|
||||
|
||||
void CBotBreak :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( bMain ) pj->RestoreStack(this);
|
||||
}
|
||||
|
@ -1092,14 +1092,14 @@ CBotInstr* CBotTry::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
// les arrêts par suspension
|
||||
// et les "finaly"
|
||||
|
||||
BOOL CBotTry :: Execute(CBotStack* &pj)
|
||||
bool CBotTry :: Execute(CBotStack* &pj)
|
||||
{
|
||||
int val;
|
||||
|
||||
CBotStack* pile1 = pj->AddStack(this); // ajoute un élément à la pile
|
||||
// if ( pile1 == EOX ) return TRUE;
|
||||
// if ( pile1 == EOX ) return true;
|
||||
|
||||
if ( pile1->IfStep() ) return FALSE;
|
||||
if ( pile1->IfStep() ) return false;
|
||||
// ou le retrouve en cas de reprise
|
||||
CBotStack* pile0 = pj->AddStack2(); // ajoute un élément à la pile secondaire
|
||||
CBotStack* pile2 = pile0->AddStack();
|
||||
|
@ -1114,14 +1114,14 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
|
|||
|
||||
val = pile1->GivError();
|
||||
if ( val == 0 && CBotStack::m_initimer == 0 ) // en mode de step ?
|
||||
return FALSE; // ne fait pas le catch
|
||||
return false; // ne fait pas le catch
|
||||
|
||||
pile1->IncState();
|
||||
pile2->SetState(val); // mémorise le numéro de l'erreur
|
||||
pile1->SetError(0); // pour l'instant il n'y a plus d'erreur !
|
||||
|
||||
if ( val == 0 && CBotStack::m_initimer < 0 ) // en mode de step ?
|
||||
return FALSE; // ne fait pas le catch
|
||||
return false; // ne fait pas le catch
|
||||
}
|
||||
|
||||
// il y a eu une interruption
|
||||
|
@ -1137,16 +1137,16 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
|
|||
if ( --state <= 0 )
|
||||
{
|
||||
// demande au bloc catch s'il se sent concerné
|
||||
if ( !pc->TestCatch(pile2, val) ) return FALSE; // suspendu !
|
||||
if ( !pc->TestCatch(pile2, val) ) return false; // suspendu !
|
||||
pile1->IncState();
|
||||
}
|
||||
if ( --state <= 0 )
|
||||
{
|
||||
if ( pile2->GivVal() == TRUE )
|
||||
if ( pile2->GivVal() == true )
|
||||
{
|
||||
// pile0->SetState(1);
|
||||
|
||||
if ( !pc->Execute(pile2) ) return FALSE; // exécute l'opération
|
||||
if ( !pc->Execute(pile2) ) return false; // exécute l'opération
|
||||
if ( m_FinalInst == NULL )
|
||||
return pj->Return(pile2); // termine le try
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
|
|||
{
|
||||
// pile0->SetState(1);
|
||||
|
||||
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return FALSE;
|
||||
if (!m_FinalInst->Execute(pile2) && pile2->IsOk()) return false;
|
||||
if (!pile2->IsOk()) return pj->Return(pile2); // garde cette exception
|
||||
pile2->SetError(pile1->GivState()==-1 ? val : 0); // remet l'erreur initiale
|
||||
return pj->Return(pile2);
|
||||
|
@ -1176,11 +1176,11 @@ BOOL CBotTry :: Execute(CBotStack* &pj)
|
|||
return pj->Return(pile2); // termine le try sans exception aucune
|
||||
|
||||
pile1->SetError(val); // remet l'erreur
|
||||
return FALSE; // ce n'est pas pour nous
|
||||
return false; // ce n'est pas pour nous
|
||||
}
|
||||
|
||||
|
||||
void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotTry :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ void CBotTry :: RestoreState(CBotStack* &pj, BOOL bMain)
|
|||
}
|
||||
if ( --state <= 0 )
|
||||
{
|
||||
if ( pile2->GivVal() == TRUE )
|
||||
if ( pile2->GivVal() == true )
|
||||
{
|
||||
pc->RestoreState(pile2, bMain); // exécute l'opération
|
||||
return;
|
||||
|
@ -1285,27 +1285,27 @@ CBotCatch* CBotCatch::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécution de "catch"
|
||||
|
||||
BOOL CBotCatch :: Execute(CBotStack* &pj)
|
||||
bool CBotCatch :: Execute(CBotStack* &pj)
|
||||
{
|
||||
if ( m_Block == NULL ) return TRUE;
|
||||
if ( m_Block == NULL ) return true;
|
||||
return m_Block->Execute(pj); // exécute le bloc associé
|
||||
}
|
||||
|
||||
void CBotCatch :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotCatch :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( bMain && m_Block != NULL ) m_Block->RestoreState(pj, bMain);
|
||||
}
|
||||
|
||||
void CBotCatch :: RestoreCondState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotCatch :: RestoreCondState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
m_Cond->RestoreState(pj, bMain);
|
||||
}
|
||||
|
||||
// routine pour savoir si le catch est à faire ou non
|
||||
|
||||
BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
||||
bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
||||
{
|
||||
if ( !m_Cond->Execute(pile) ) return FALSE;
|
||||
if ( !m_Cond->Execute(pile) ) return false;
|
||||
|
||||
if ( val > 0 || pile->GivType() != CBotTypBoolean )
|
||||
{
|
||||
|
@ -1314,7 +1314,7 @@ BOOL CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
|||
pile->SetVar(var); // remet sur la pile
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1359,18 +1359,18 @@ CBotInstr* CBotThrow::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute l'instruction "throw"
|
||||
|
||||
BOOL CBotThrow :: Execute(CBotStack* &pj)
|
||||
bool CBotThrow :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotStack* pile = pj->AddStack(this);
|
||||
// if ( pile == EOX ) return TRUE;
|
||||
// if ( pile == EOX ) return true;
|
||||
|
||||
if ( pile->GivState() == 0 )
|
||||
{
|
||||
if ( !m_Value->Execute(pile) ) return FALSE;
|
||||
if ( !m_Value->Execute(pile) ) return false;
|
||||
pile->IncState();
|
||||
}
|
||||
|
||||
if ( pile->IfStep() ) return FALSE;
|
||||
if ( pile->IfStep() ) return false;
|
||||
|
||||
int val = pile->GivVal();
|
||||
if ( val < 0 ) val = TX_BADTHROW;
|
||||
|
@ -1378,7 +1378,7 @@ BOOL CBotThrow :: Execute(CBotStack* &pj)
|
|||
return pj->Return( pile );
|
||||
}
|
||||
|
||||
void CBotThrow :: RestoreState(CBotStack* &pj, BOOL bMain)
|
||||
void CBotThrow :: RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
if ( !bMain ) return;
|
||||
|
||||
|
@ -1417,11 +1417,11 @@ CBotInstr* CBotStartDebugDD::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
// exécute l'instruction "throw"
|
||||
|
||||
BOOL CBotStartDebugDD :: Execute(CBotStack* &pj)
|
||||
bool CBotStartDebugDD :: Execute(CBotStack* &pj)
|
||||
{
|
||||
CBotProgram* p = pj->GivBotCall();
|
||||
p->m_bDebugDD = TRUE;
|
||||
p->m_bDebugDD = true;
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ CBotToken.cpp
|
|||
CBotTwoOpExpr.cpp
|
||||
CBotVar.cpp
|
||||
CBotWhile.cpp
|
||||
CBot.rc
|
||||
)
|
||||
|
||||
add_library(CBot SHARED ${SOURCES})
|
||||
|
|
|
@ -58,7 +58,7 @@ void PrepareFilename(CBotString &filename) //DD!
|
|||
// reçois le nom du fichier en paramètre
|
||||
|
||||
// exécution
|
||||
BOOL rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
CBotString mode;
|
||||
|
||||
|
@ -132,7 +132,7 @@ CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar)
|
|||
// destructeur de la classe
|
||||
|
||||
// exécution
|
||||
BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// récupère l'élément "handle"
|
||||
pVar = pThis->GivItem("handle");
|
||||
|
@ -154,7 +154,7 @@ BOOL rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
|
|||
// reçois le mode r/w en paramètre
|
||||
|
||||
// exécution
|
||||
BOOL rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// il doit y avoir un paramètre
|
||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
||||
|
@ -243,7 +243,7 @@ CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar)
|
|||
// méthode FILE :: close
|
||||
|
||||
// exécution
|
||||
BOOL rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// il ne doit pas y avoir de paramètre
|
||||
if ( pVar != NULL ) return CBotErrOverParam;
|
||||
|
@ -275,7 +275,7 @@ CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar)
|
|||
// méthode FILE :: writeln
|
||||
|
||||
// exécution
|
||||
BOOL rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// il doit y avoir un paramètre
|
||||
if ( pVar == NULL ) { Exception = CBotErrLowParam; return FALSE; }
|
||||
|
@ -319,7 +319,7 @@ CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar)
|
|||
// méthode FILE :: readln
|
||||
|
||||
// exécution
|
||||
BOOL rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// il ne doit pas y avoir de paramètre
|
||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||
|
@ -360,7 +360,7 @@ CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar)
|
|||
|
||||
|
||||
// exécution
|
||||
BOOL rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
|
||||
{
|
||||
// il ne doit pas y avoir de paramètre
|
||||
if ( pVar != NULL ) { Exception = CBotErrOverParam; return FALSE; }
|
||||
|
|
|
@ -18,23 +18,23 @@
|
|||
// donne la longueur d'une chaîne
|
||||
// exécution
|
||||
|
||||
BOOL rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// pas de second paramètre
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// met la longueur sur la pile
|
||||
pResult->SetValInt( s.GivLength() );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// int xxx ( string )
|
||||
|
@ -60,36 +60,36 @@ CBotTypResult cIntStr( CBotVar* &pVar, void* pUser )
|
|||
// donne la partie gauche d'une chaîne
|
||||
// exécution
|
||||
|
||||
BOOL rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrLeft( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// il faut un second paramètre
|
||||
pVar = pVar->GivNext();
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être un nombre
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; }
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
|
||||
|
||||
// récupère ce nombre
|
||||
int n = pVar->GivValInt();
|
||||
|
||||
// pas de 3e paramètre
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
// prend la partie intéressante
|
||||
s = s.Left( n );
|
||||
|
||||
// la met sur la pile
|
||||
pResult->SetValString( s );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// string xxx ( string, int )
|
||||
|
@ -122,58 +122,58 @@ CBotTypResult cStrStrInt( CBotVar* &pVar, void* pUser )
|
|||
// donne la partie droite d'une chaîne
|
||||
// exécution
|
||||
|
||||
BOOL rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrRight( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// il faut un second paramètre
|
||||
pVar = pVar->GivNext();
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être un nombre
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; }
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
|
||||
|
||||
// récupère ce nombre
|
||||
int n = pVar->GivValInt();
|
||||
|
||||
// pas de 3e paramètre
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
// prend la partie intéressante
|
||||
s = s.Right( n );
|
||||
|
||||
// la met sur la pile
|
||||
pResult->SetValString( s );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// donne la partie centrale d'une chaîne
|
||||
// exécution
|
||||
|
||||
BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// il faut un second paramètre
|
||||
pVar = pVar->GivNext();
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être un nombre
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; }
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
|
||||
|
||||
// récupère ce nombre
|
||||
int n = pVar->GivValInt();
|
||||
|
@ -184,13 +184,13 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
|||
pVar = pVar->GivNext();
|
||||
|
||||
// qui doit être un nombre
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return TRUE; }
|
||||
if ( pVar->GivType() > CBotTypDouble ) { ex = TX_BADNUM ; return true; }
|
||||
|
||||
// récupère ce nombre
|
||||
int l = pVar->GivValInt();
|
||||
|
||||
// mais pas de 4e paramètre
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
// prend la partie intéressante
|
||||
s = s.Mid( n, l );
|
||||
|
@ -203,7 +203,7 @@ BOOL rStrMid( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
|||
|
||||
// la met sur la pile
|
||||
pResult->SetValString( s );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// donne la partie centrale d'une chaîne
|
||||
|
@ -247,25 +247,25 @@ CBotTypResult cStrStrIntInt( CBotVar* &pVar, void* pUser )
|
|||
// donne le nombre contenu dans une chaîne
|
||||
// exécution
|
||||
|
||||
BOOL rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrVal( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// mais pas de 2e paramètre
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
float val = GivNumFloat(s);
|
||||
|
||||
// la met la valeur sur la pile
|
||||
pResult->SetValFloat( val );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// float xxx ( string )
|
||||
|
@ -291,35 +291,35 @@ CBotTypResult cFloatStr( CBotVar* &pVar, void* pUser )
|
|||
// trouve une chaine dans une autre
|
||||
// exécution
|
||||
|
||||
BOOL rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// il faut un second paramètre
|
||||
pVar = pVar->GivNext();
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// récupère ce nombre
|
||||
CBotString s2 = pVar->GivValString();
|
||||
|
||||
// pas de 3e paramètre
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ) { ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
// met le résultat sur la pile
|
||||
int res = s.Find(s2);
|
||||
pResult->SetValInt( res );
|
||||
if ( res < 0 ) pResult->SetInit( IS_NAN );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// int xxx ( string, string )
|
||||
|
@ -352,51 +352,51 @@ CBotTypResult cIntStrStr( CBotVar* &pVar, void* pUser )
|
|||
// donne une chaine en majuscule
|
||||
// exécution
|
||||
|
||||
BOOL rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrUpper( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// mais pas de 2e paramètre
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
|
||||
s.MakeUpper();
|
||||
|
||||
// la met la valeur sur la pile
|
||||
pResult->SetValString( s );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// donne une chaine en minuscules
|
||||
// exécution
|
||||
|
||||
BOOL rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
bool rStrLower( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// il faut un paramètre
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return TRUE; }
|
||||
if ( pVar == NULL ) { ex = TX_LOWPARAM ; return true; }
|
||||
|
||||
// qui doit être une string
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return TRUE; }
|
||||
if ( pVar->GivType() != CBotTypString ) { ex = TX_BADSTRING ; return true; }
|
||||
|
||||
// recupére le contenu de la string
|
||||
CBotString s = pVar->GivValString();
|
||||
|
||||
// mais pas de 2e paramètre
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return TRUE; }
|
||||
if ( pVar->GivNext() != NULL ){ ex = TX_OVERPARAM ; return true; }
|
||||
|
||||
|
||||
s.MakeLower();
|
||||
|
||||
// la met la valeur sur la pile
|
||||
pResult->SetValString( s );
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// string xxx ( string )
|
||||
|
|
|
@ -1,39 +1,41 @@
|
|||
pour la gestion des instances d'une classe.
|
||||
|
||||
l'objet créé actuellement avec CBotVar::Create(nom, pClasse)
|
||||
est a conserver tel quel, en dehors des vars sur la pile
|
||||
for managing instances of a class.
|
||||
|
||||
il faut un autre type de variable pour garder les pointeurs
|
||||
CBotTypPtClass par exemple
|
||||
the object being created with CBotVar :: Create (name, pClasse)
|
||||
is to keep as is, outside the vars on the stack
|
||||
|
||||
L'instance de la classe doit avoir un compteur d'utilisation
|
||||
qui est le nombre d'objet de classe CBotTypPtClass qui y réfèrent.
|
||||
Le compteur est décrémenté lorsque le pointeur est détruit,
|
||||
l'objet supprimé lorsqu'il n'y a plus de pointeurs.
|
||||
we need another type of variable to keep the pointers
|
||||
For example CBotTypPtClass
|
||||
|
||||
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"
|
||||
et peut retourner des pointeurs à cette instance par des routines genre FindRobot()
|
||||
In the case of robots, Daniel creates an instance of class "Object"
|
||||
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
|
||||
lorsqu'il a trouvé le robot concerné, il lui faudra faire
|
||||
pResult in this case is a pointer CBotTypPtClass
|
||||
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
|
||||
est détruit également.
|
||||
s'il reste des pointeurs à cet objet, et l'on risque la planté
|
||||
when the robot is destroyed, the instance of the Object class corresponding
|
||||
is also destroyed.
|
||||
if there are pointers to that object, and we planted the risk
|
||||
|
||||
solution 1:
|
||||
garder non pas le pointeur à l'objet directement, mais
|
||||
un index dans une tables de pointeurs
|
||||
Solution 1:
|
||||
not keep the pointer to the object directly, but
|
||||
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
|
15
src/CBot/old
15
src/CBot/old
|
@ -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/.
|
|
@ -13,100 +13,105 @@
|
|||
// *
|
||||
// * 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}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by CBot.rc
|
||||
//
|
||||
#define ID_KEYWORDS 2000
|
||||
#define ID_IF 2000
|
||||
#define ID_ELSE 2001
|
||||
#define ID_WHILE 2002
|
||||
#define ID_DO 2003
|
||||
#define ID_FOR 2004
|
||||
#define ID_BREAK 2005
|
||||
#define ID_CONTINUE 2006
|
||||
#define ID_SWITCH 2007
|
||||
#define ID_CASE 2008
|
||||
#define ID_DEFAULT 2009
|
||||
#define ID_TRY 2010
|
||||
#define ID_THROW 2011
|
||||
#define ID_CATCH 2012
|
||||
#define ID_FINALLY 2013
|
||||
#define ID_TXT_AND 2014
|
||||
#define ID_TXT_OR 2015
|
||||
#define ID_TXT_NOT 2016
|
||||
#define ID_RETURN 2017
|
||||
#define ID_CLASS 2018
|
||||
#define ID_EXTENDS 2019
|
||||
#define ID_SYNCHO 2020
|
||||
#define ID_NEW 2021
|
||||
#define ID_PUBLIC 2022
|
||||
#define ID_EXTERN 2023
|
||||
#define ID_FINAL 2024
|
||||
#define ID_STATIC 2025
|
||||
#define ID_PROTECTED 2026
|
||||
#define ID_PRIVATE 2027
|
||||
#define ID_REPEAT 2028
|
||||
#define ID_DEBUGDD 2099
|
||||
#define ID_INT 2100
|
||||
#define ID_FLOAT 2101
|
||||
#define ID_BOOLEAN 2102
|
||||
#define ID_STRING 2103
|
||||
#define ID_VOID 2104
|
||||
#define ID_BOOL 2105
|
||||
#define ID_TRUE 2200
|
||||
#define ID_FALSE 2201
|
||||
#define ID_NULL 2202
|
||||
#define ID_NAN 2203
|
||||
#define ID_OPENPAR 2300
|
||||
#define ID_CLOSEPAR 2301
|
||||
#define ID_OPBLK 2302
|
||||
#define ID_CLBLK 2303
|
||||
#define ID_SEP 2304
|
||||
#define ID_COMMA 2305
|
||||
#define ID_DOTS 2306
|
||||
#define ID_DOT 2307
|
||||
#define ID_OPBRK 2308
|
||||
#define ID_CLBRK 2309
|
||||
#define ID_DBLDOTS 2310
|
||||
#define ID_LOGIC 2311
|
||||
#define ID_ADD 2312
|
||||
#define ID_SUB 2313
|
||||
#define ID_MUL 2314
|
||||
#define ID_DIV 2315
|
||||
#define ID_ASS 2316
|
||||
#define ID_ASSADD 2317
|
||||
#define ID_ASSSUB 2318
|
||||
#define ID_ASSMUL 2319
|
||||
#define ID_ASSDIV 2320
|
||||
#define ID_ASSOR 2321
|
||||
#define ID_ASSAND 2322
|
||||
#define ID_ASSXOR 2323
|
||||
#define ID_ASSSL 2324
|
||||
#define ID_ASSSR 2325
|
||||
#define ID_ASSASR 2326
|
||||
#define ID_SL 2327
|
||||
#define ID_SR 2328
|
||||
#define ID_ASR 2329
|
||||
#define ID_INC 2330
|
||||
#define ID_DEC 2331
|
||||
#define ID_LO 2332
|
||||
#define ID_HI 2333
|
||||
#define ID_LS 2334
|
||||
#define ID_HS 2335
|
||||
#define ID_EQ 2336
|
||||
#define ID_NE 2337
|
||||
#define ID_AND 2338
|
||||
#define ID_XOR 2339
|
||||
#define ID_OR 2340
|
||||
#define ID_LOG_AND 2341
|
||||
#define ID_LOG_OR 2342
|
||||
#define ID_LOG_NOT 2343
|
||||
#define ID_NOT 2344
|
||||
#define ID_MODULO 2345
|
||||
#define ID_POWER 2346
|
||||
#define ID_ASSMODULO 2347
|
||||
#define TX_UNDEF 4000
|
||||
#define TX_NAN 4001
|
||||
#ifndef _RESOURCE_H_
|
||||
#define _RESOURCE_H_
|
||||
|
||||
enum EID
|
||||
{
|
||||
ID_IF = 2000,
|
||||
ID_ELSE,
|
||||
ID_WHILE,
|
||||
ID_DO,
|
||||
ID_FOR,
|
||||
ID_BREAK,
|
||||
ID_CONTINUE,
|
||||
ID_SWITCH,
|
||||
ID_CASE,
|
||||
ID_DEFAULT,
|
||||
ID_TRY,
|
||||
ID_THROW,
|
||||
ID_CATCH,
|
||||
ID_FINALLY,
|
||||
ID_TXT_AND,
|
||||
ID_TXT_OR,
|
||||
ID_TXT_NOT,
|
||||
ID_RETURN,
|
||||
ID_CLASS,
|
||||
ID_EXTENDS,
|
||||
ID_SYNCHO,
|
||||
ID_NEW,
|
||||
ID_PUBLIC,
|
||||
ID_EXTERN,
|
||||
ID_FINAL,
|
||||
ID_STATIC,
|
||||
ID_PROTECTED,
|
||||
ID_PRIVATE,
|
||||
ID_REPEAT,
|
||||
ID_DEBUGDD,
|
||||
ID_INT,
|
||||
ID_FLOAT,
|
||||
ID_BOOLEAN,
|
||||
ID_STRING,
|
||||
ID_VOID,
|
||||
ID_BOOL,
|
||||
|
||||
ID_TRUE = 2200,
|
||||
ID_FALSE,
|
||||
ID_NULL,
|
||||
ID_NAN,
|
||||
|
||||
ID_OPENPAR = 2300,
|
||||
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,
|
||||
TX_UNDEF = 4000,
|
||||
TX_NAN,
|
||||
ID_SUPER = 6000
|
||||
};
|
||||
#define TX_OPENPAR 5000
|
||||
#define TX_CLOSEPAR 5001
|
||||
#define TX_NOTBOOL 5002
|
||||
|
@ -166,15 +171,6 @@
|
|||
#define TX_NOTOPEN 6013
|
||||
#define TX_ERRREAD 6014
|
||||
#define TX_ERRWRITE 6015
|
||||
#define ID_SUPER 62020
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#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
|
||||
#endif //_RESOURCE_H_
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# CBot shared library is built separately
|
||||
# add_subdirectory(CBot) -- not yet WinAPI-independent
|
||||
add_subdirectory(CBot)
|
||||
|
||||
|
||||
# Configure options
|
||||
|
@ -29,6 +29,7 @@ configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h
|
|||
|
||||
# Source files
|
||||
# Commented out files are still dependent on DirectX or WinAPI
|
||||
|
||||
set(SOURCES
|
||||
app/app.cpp
|
||||
app/main.cpp
|
||||
|
@ -155,8 +156,8 @@ ${SDL_LIBRARY}
|
|||
${SDLIMAGE_LIBRARY}
|
||||
${OPENGL_LIBRARY}
|
||||
${PNG_LIBRARIES}
|
||||
#CBot -- not yet WinAPI-independent
|
||||
${PLATFORM_LIBS}
|
||||
CBot
|
||||
)
|
||||
|
||||
include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
#include <plugins/plugin.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/*!
|
||||
* Maximum possible audio volume
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue