Compile fix after previous commit; fix MSVC errors; added missing license headers

dev-time-step
krzys-h 2015-12-23 17:37:26 +01:00
parent 6482001b9b
commit 8fa5b208c2
20 changed files with 153 additions and 63 deletions

View File

@ -163,7 +163,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
pp = p;
if ( IsOfType(p, ID_EXTERN) )
{
func->m_extern = pp; // for the position of the word "extern"
func->m_extern = *pp; // for the position of the word "extern"
func->m_bExtern = true;
// func->m_bPublic = true; // therefore also public!
continue;
@ -200,9 +200,9 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
if (!IsOfType(p, TokenTypVar)) goto bad;
}
func->m_openpar = p;
func->m_openpar = *p;
func->m_Param = CBotDefParam::Compile( p, pStk );
func->m_closepar = p->GetPrev();
func->m_closepar = *(p->GetPrev());
if (pStk->IsOk())
{
pStk->SetRetType(func->m_retTyp); // for knowledge what type returns
@ -234,9 +234,9 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
}
// and compiles the following instruction block
func->m_openblk = p;
func->m_openblk = *p;
func->m_Block = CBotBlock::Compile(p, pStk, false);
func->m_closeblk = p->GetPrev();
func->m_closeblk = *(p->GetPrev());
if ( pStk->IsOk() )
{
if ( func->m_bPublic ) // public function, return known for all

View File

@ -56,7 +56,7 @@ bool CBotLogicExpr::Execute(CBotStack* &pStack)
if (!pStk1->SetState(1)) return false;
}
if ( pStk1->GetVal() == true )
if (pStk1->GetVal() != 0)
{
if ( !m_op1->Execute(pStk1) ) return false;
}
@ -82,7 +82,7 @@ void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
return;
}
if ( pStk1->GetVal() == true )
if (pStk1->GetVal() != 0)
{
m_op1->RestoreState(pStk1, bMain);
}

View File

@ -66,7 +66,7 @@ CBotInstr* CBotNew::Compile(CBotToken* &p, CBotCStack* pStack)
CBotNew* inst = new CBotNew();
inst->SetToken(pp);
inst->m_vartoken = p;
inst->m_vartoken = *p;
p = p->GetNext();
// creates the object on the "job"

View File

@ -134,7 +134,7 @@ bool CBotTry::Execute(CBotStack* &pj)
}
if ( --state <= 0 )
{
if ( pile2->GetVal() == true )
if (pile2->GetVal() != 0)
{
// pile0->SetState(1);
@ -210,7 +210,7 @@ void CBotTry::RestoreState(CBotStack* &pj, bool bMain)
}
if ( --state <= 0 )
{
if ( pile2->GetVal() == true )
if (pile2->GetVal() != 0)
{
pc->RestoreState(pile2, bMain); // execute the operation
return;

View File

@ -134,39 +134,19 @@ std::map<std::string, long> CBotToken::m_defineNum;
////////////////////////////////////////////////////////////////////////////////
CBotToken::CBotToken()
{
m_next = nullptr;
m_prev = nullptr;
m_type = TokenTypVar; // at the beginning a default variable type
m_keywordId = -1;
}
////////////////////////////////////////////////////////////////////////////////
CBotToken::CBotToken(const CBotToken& pSrc)
{
m_next = nullptr;
m_prev = nullptr;
m_type = pSrc.m_type;
m_keywordId = pSrc.m_keywordId;
m_text.clear();
m_sep.clear();
m_text = pSrc.m_text;
m_sep = pSrc.m_sep;
m_type = TokenTypNone;
m_keywordId = 0;
m_start = 0;
m_end = 0;
if ( pSrc != nullptr )
{
m_type = pSrc->m_type;
m_keywordId = pSrc->m_IdKeyWord;
m_text = pSrc->m_Text;
m_sep = pSrc->m_Sep;
m_start = pSrc->m_start;
m_end = pSrc->m_end;
}
m_start = pSrc.m_start;
m_end = pSrc.m_end;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -200,23 +200,23 @@ private:
private:
//! The next token in the linked list
CBotToken* m_next;
CBotToken* m_next = nullptr;
//! The previous token in the linked list
CBotToken* m_prev;
CBotToken* m_prev = nullptr;
//! The token type
TokenType m_type;
TokenType m_type = TokenTypVar;
//! The id of the keyword
long m_keywordId;
long m_keywordId = -1;
//! The token string
std::string m_text;
std::string m_text = "";
//! The separator that appeared after this token
std::string m_sep;
std::string m_sep = "";
//! The strat position of the token in the CBotProgram
int m_start;
int m_start = 0;
//! The end position of the token in the CBotProgram
int m_end;
int m_end = 0;
//! Map of all defined constants (see DefineNum())
static std::map<std::string, long> m_defineNum;

View File

@ -36,7 +36,7 @@ CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type )
if ( !type.Eq(CBotTypArrayPointer) &&
!type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -28,7 +28,7 @@
////////////////////////////////////////////////////////////////////////////////
CBotVarBoolean::CBotVarBoolean( const CBotToken* name )
{
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -45,7 +45,7 @@ CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type)
!type.Eq(CBotTypArrayPointer) &&
!type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = OBJECTCREATED;//nullptr;

View File

@ -33,7 +33,7 @@
////////////////////////////////////////////////////////////////////////////////
CBotVarFloat::CBotVarFloat( const CBotToken* name )
{
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////////////////////////
CBotVarInt::CBotVarInt( const CBotToken* name )
{
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -40,7 +40,7 @@ CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type )
!type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic
!type.Eq(CBotTypIntrinsic) ) assert(0);
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -31,7 +31,7 @@
////////////////////////////////////////////////////////////////////////////////
CBotVarString::CBotVarString( const CBotToken* name )
{
m_token = new CBotToken(name);
m_token = new CBotToken(*name);
m_next = nullptr;
m_pMyThis = nullptr;
m_pUserPtr = nullptr;

View File

@ -1,3 +1,22 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#include "CBot/stdlib/Compilation.h"
#include "CBot/CBot.h"

View File

@ -1,3 +1,22 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#pragma once
#include "CBot/CBotTypResult.h"

View File

@ -1,3 +1,22 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#include "CBot/stdlib/stdlib.h"
#include "CBot/CBot.h"

View File

@ -1,8 +1,28 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#include "CBot/stdlib/stdlib.h"
#include "CBot/CBot.h"
#include <cmath>
const float PI = 3.14159265358979323846f;
// Instruction "sin(degrees)".
@ -11,7 +31,7 @@ bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(sinf(value*M_PI/180.0f));
result->SetValFloat(sinf(value*PI/180.0f));
return true;
}
@ -22,7 +42,7 @@ bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(cosf(value*M_PI/180.0f));
result->SetValFloat(cosf(value*PI/180.0f));
return true;
}
@ -33,7 +53,7 @@ bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(tanf(value*M_PI/180.0f));
result->SetValFloat(tanf(value*PI/180.0f));
return true;
}
@ -44,7 +64,7 @@ bool raSin(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(asinf(value)*180.0f/M_PI);
result->SetValFloat(asinf(value)*180.0f/PI);
return true;
}
@ -55,7 +75,7 @@ bool raCos(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(acosf(value)*180.0f/M_PI);
result->SetValFloat(acosf(value)*180.0f/PI);
return true;
}
@ -66,7 +86,7 @@ bool raTan(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GetValFloat();
result->SetValFloat(atanf(value)*180.0f/M_PI);
result->SetValFloat(atanf(value)*180.0f/PI);
return true;
}
@ -78,7 +98,7 @@ bool raTan2(CBotVar* var, CBotVar* result, int& exception, void* user)
var = var->GetNext();
float x = var->GetValFloat();
result->SetValFloat(atan2(y, x) * 180.0f / M_PI);
result->SetValFloat(atan2(y, x) * 180.0f / PI);
return true;
}

View File

@ -17,17 +17,12 @@
* along with this program. If not, see http://gnu.org/licenses
*/
// Modules inlcude
#include "CBot/stdlib/stdlib.h"
#include "CBot/CBot.h"
#include "CBot/CBotUtils.h"
// Local include
// Global include
#include <boost/algorithm/string.hpp>
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,3 +1,22 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#pragma once
#include "CBot/stdlib/stdlib_public.h"

View File

@ -1,3 +1,22 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#pragma once
#include "CBot/stdlib/Compilation.h"