diff options
Diffstat (limited to 'src')
115 files changed, 0 insertions, 9148 deletions
diff --git a/src/CBot/tests/CBot_console/CMakeLists.txt b/src/CBot/tests/CBot_console/CMakeLists.txt deleted file mode 100644 index f76dedf..0000000 --- a/src/CBot/tests/CBot_console/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(CBot_console C CXX) - -# Build with debugging symbols -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) - -# Global compile flags -set(CMAKE_CXX_FLAGS_RELEASE "-O2") -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -# Include cmake directory -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake") - -add_subdirectory(src bin) diff --git a/src/CBot/tests/CBot_console/src/CBot b/src/CBot/tests/CBot_console/src/CBot deleted file mode 120000 index 2c91115..0000000 --- a/src/CBot/tests/CBot_console/src/CBot +++ /dev/null @@ -1 +0,0 @@ -../../../../CBot/
\ No newline at end of file diff --git a/src/CBot/tests/CBot_console/src/CMakeLists.txt b/src/CBot/tests/CBot_console/src/CMakeLists.txt deleted file mode 100644 index 3dbf711..0000000 --- a/src/CBot/tests/CBot_console/src/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# CBot shared library is built separately -add_subdirectory(CBot) - - -# Configure options -option(DEBUG "Enable debug output" ON) - -set(PLATFORM_LIBS "") - -# Source files -# Commented out files are still dependent on DirectX or WinAPI - -set(SOURCES -app/CClass.cpp -app/main.cpp -#app/routines.cpp -app/CBotDoc.cpp -app/CBotConsole.cpp -) - -set(LIBS -CBot -) - -include_directories(. ${CMAKE_CURRENT_BINARY_DIR} -) - -link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot) - -add_executable(CBot_console ${SOURCES}) - -target_link_libraries(CBot_console ${LIBS}) diff --git a/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp b/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp deleted file mode 100644 index e9209d3..0000000 --- a/src/CBot/tests/CBot_console/src/app/CBotConsole.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * CBotConsole.cpp - * - * Created on: 08-08-2012 - * Author: michal - */ - -#include "CBotConsole.h" -#include "CClass.h" -#include <ctime> -#include <iostream> - -CBotConsole::CBotConsole() { - // TODO Auto-generated constructor stub - m_pProg = NULL; - m_threadinfo.m_bRun = false; - m_code = 0; - -} - -CBotConsole::~CBotConsole() { - // TODO Auto-generated destructor stub -} - -uint ThreadProc(ThreadInfo *info) -{ - time_t t0,t1; - time(&t0); - - int Cpt = 0; - - info->m_pProg->Start("LaCommande"); - while ( !info->m_bStop && !info->m_pProg->Run() ) - { -#if 0 - const char* FunctionName; - const char* FN; - int start, end; - - info->m_pProg->GetRunPos(FunctionName, start, end); - - if ( FunctionName != NULL ) - { - info->m_pEditx->SetSel(start, end); - - char buffer[200]; - sprintf( buffer, "step %s, %d, %d",FunctionName, start, end); - AfxMessageBox( buffer ); - - int level = 0; - do - { - CBotVar* t = info->m_pProg->GetStackVars(FN, level--); - if ( FN != FunctionName ) break; - if ( t != NULL ) - { - CString s ; - while ( t != NULL ) - { - if (s.IsEmpty()) s+= "Stack -> "; - else s+= " , "; - s += t->GetValString(); - t = t->GetNext(); - } - AfxMessageBox(s); - } - } while (TRUE); - } -#endif - Cpt++; - if ( Cpt%50 == 0 ) std::cout << "."; - } - - if ( info->m_bStop ) - { - std::cout << "\nInterrupt\n"; - } - else if (info->m_pProg->GetError() == 0) - { - time(&t1); - double prog_time = difftime(t0,t1); - - char buffer[200]; - sprintf( buffer, "\nExecution terminated in %f seconds.\nInterrupted %d time(s).\n", - prog_time, Cpt); - - std::cout << buffer; - } - -// info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ; - return 0 ; -} - -long CBotConsole::EndProg() -{ - m_threadinfo.m_bRun = false; - - if (m_pProg->GetError(m_code, m_start, m_end)) - { - CBotString TextError; - TextError = CBotProgram::GetErrorText(m_code); - std::cout << TextError; - return 1; - } - delete m_pProg; - m_pProg = NULL; - - return 0 ; -} - - -void CBotConsole::OnOK() -{ - m_code = 0; - - std::string Commande; - std::cin >> Commande; - - std::string s = "void LaCommande() { " + Commande + " ;}"; - m_pProg = new CBotProgram(); - CBotStringArray liste; - m_pProg->Compile(s.c_str(), liste); - - int err, start, end; - if ( m_pProg->GetError(err, start, end) ) - { - CBotString TextError; - TextError = CBotProgram::GetErrorText(err); - std::cout << TextError; - return; - } - - std::cout << "\n" + Commande + " ->\n"; - -// m_Edit2.SetWindowText(""); -// m_Edit1.SetFocus(); -// m_Edit2.EnableWindow(FALSE); -// m_cOK.EnableWindow(FALSE); - - // lance un processus paralèle pour l'exécution -// m_threadinfo.m_pWndMessage = this ; - -// m_threadinfo.m_pEdit1 = &m_Edit1; -// m_threadinfo.m_pEditx = m_pEditx; - m_threadinfo.m_pProg = m_pProg; - m_threadinfo.m_bStop = false; - m_threadinfo.m_bRun = true; - - ThreadProc(&m_threadinfo); - -// here program starts -// AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ; -} - -void CBotConsole::OnCancel() -{ - m_threadinfo.m_bStop = true ; -} - -bool CBotConsole::OnInitDialog() -{ -// CDialog::OnInitDialog(); - - std::cout << "Following functions are availible:\n"; - for ( int i = 0; i < m_pListe->GetSize(); i++ ) - { - CBotString x = (*m_pListe)[i] + CBotString("\n"); - std::cout << x; - } - std::cout << "Enter a command:\n"; - - - return true; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} diff --git a/src/CBot/tests/CBot_console/src/app/CBotConsole.h b/src/CBot/tests/CBot_console/src/app/CBotConsole.h deleted file mode 100644 index a155399..0000000 --- a/src/CBot/tests/CBot_console/src/app/CBotConsole.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CBotConsole.h - * - * Created on: 08-08-2012 - * Author: michal - */ - -#ifndef CBOTCONSOLE_H_ -#define CBOTCONSOLE_H_ -#include "CClass.h" - -struct ThreadInfo -{ -// CEdit* m_pEdit1 ; -// CEdit* m_pEditx ; - CBotProgram* m_pProg; -// CWnd* m_pWndMessage; - bool m_bStop; - bool m_bRun; -}; - -class CBotConsole { - -public: - CBotConsole(); - virtual ~CBotConsole(); - -// CEdit m_Edit1; - - CBotProgram* m_pProg; - ThreadInfo m_threadinfo; - - CBotStringArray* m_pListe; - int m_code, m_start, m_end; -// CEdit* m_pEditx; - - // Implementation - void OnOK(); - void OnCancel(); - bool OnInitDialog(); - long EndProg() ; -}; - -#endif /* CBOTCONSOLE_H_ */ diff --git a/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp b/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp deleted file mode 100644 index 1c694c9..0000000 --- a/src/CBot/tests/CBot_console/src/app/CBotDoc.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CBotDoc.cpp - * - * Created on: 08-08-2012 - * Author: michal - */ -#include "CBotDoc.h" -#include "CBotConsole.h" -#include <iostream> - -CBotDoc::CBotDoc(std::string s) { - // TODO Auto-generated constructor stub - // TODO set m_DocText -// m_pEdit = NULL; - m_pProg = NULL; -// m_bModified = FALSE; - m_DocText = s; - std::cout << s << std::endl; -// std::cout << "Enter to continue..." << std::endl; -// getchar(); -} - -CBotDoc::~CBotDoc() { - -// delete m_pEdit; - delete m_pProg; -} - - -//static bool test = false; - -void CBotDoc::OnRun() -{ - -// m_pEdit->GetWindowText(m_DocText); - CBotString s; - - std::string TextError; - int code, start, end; - - if ( m_pProg == NULL ) m_pProg = new CBotProgram(); - - if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, NULL)) - { - m_pProg->GetError(code, start, end); - delete m_pProg; - m_pProg = NULL; - - TextError = CBotProgram::GetErrorText( code ); - std::cout << TextError << std::endl; - return; - } - - if( m_Liste.GetSize() == 0 ) - { - std::cout << "No function marked \"extern\" !\n"; - return; - } - - for ( int i = 0; i < m_Liste.GetSize(); i++ ) - { - int start, stop; - m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam); - CBotString s(m_DocText.substr( start, stop-start ).c_str()); - m_Liste[i] = s; - } -// TODO - CBotConsole dlg; - dlg.m_pListe = &m_Liste; -// dlg.m_pEditx = m_pEdit; - - dlg.OnInitDialog(); - dlg.OnOK(); - dlg.EndProg(); -// if ( dlg.m_code>0 ) -// { -// std::string TextError; -// -// TextError = m_pProg->GetErrorText( dlg.m_code ); -// -// std::cout <<TextError; -// } - - return; -} - -bool CBotDoc::Compile() -{ -// m_pEdit->GetWindowText(m_DocText); - - std::string TextError; - int code, start, end; - - if ( m_pProg == NULL ) m_pProg = new CBotProgram(); - - char buffer[100]; - strcpy(buffer, "a pointer move to see"); - - if (!m_pProg->Compile(m_DocText.c_str(), m_Liste, static_cast<void*>(buffer))) - { - m_pProg->GetError(code, start, end); - delete m_pProg; - m_pProg = NULL; - -// m_pEdit->SetSel( start, end ); -// m_pEdit->SetFocus(); // higlights part of problem - - TextError = CBotProgram::GetErrorText( code ); - std::cout << TextError ; - - return false; - } - -// if ( m_pProg->GetPosition( "TheTest", start, end) ) -// { -// m_pEdit->SetSel( start, end ); -// m_pEdit->SetFocus(); // higlights part of problem -// } - -// m_bModified = FALSE; - return true; -} diff --git a/src/CBot/tests/CBot_console/src/app/CBotDoc.h b/src/CBot/tests/CBot_console/src/app/CBotDoc.h deleted file mode 100644 index c0a3e1d..0000000 --- a/src/CBot/tests/CBot_console/src/app/CBotDoc.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CBotDoc.h - * - * Created on: 08-08-2012 - * Author: michal - */ - -#pragma once -#ifndef CBOTDOC_H_ -#define CBOTDOC_H_ - -#include "CClass.h" -#include <string> - -class CBotDoc { - -public: - CBotDoc(std::string); - virtual ~CBotDoc(); - -// CEdit* m_pEdit; // to memorize the text, and display - CBotProgram* m_pProg; // the compiled program - std::string m_DocText; - CBotStringArray m_Liste; - -// Operations - - bool Compile(); - -// virtual bool OnNewDocument(); - - void OnRun(); - void OnChangeEdit1(); - void OnTest(); - -}; - - -#endif /* CBOTDOC_H_ */ diff --git a/src/CBot/tests/CBot_console/src/app/CClass.cpp b/src/CBot/tests/CBot_console/src/app/CClass.cpp deleted file mode 100644 index 9b7c842..0000000 --- a/src/CBot/tests/CBot_console/src/app/CClass.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "CClass.h" - -#include "routines.cpp" - -void rMajObject( CBotVar* pThis, void* pUser ) -{ - if (!pThis->IsElemOfClass("object")) - return ; - CBotVar* pPos = pThis->GetItem("position"); - CBotVar* pX = pPos->GetItem("x"); - CBotVar* pY = pPos->GetItem("y"); - CBotVar* pZ = pPos->GetItem("z"); -// CBotVar* pPt = pThis->GetItem("transport"); - - CBotString p = pX->GetValString(); - -// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 ); - pZ->SetValFloat( (float)0 ); - pY->SetValFloat( (float)-3.33 ); - pX->SetValFloat( pX->GetValFloat() + 10 ) ; - -// pX = pThis->GetItem( "xx" ); -// pX->SetValFloat( (float)22 ); - - // crée une instance sur une classe object -// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object"); -// pAutre->SetUserPtr( (void*)3 ); -// pPt->SetPointer( pAutre ); -// pPt->SetPointer( NULL ); -// delete pAutre; -}; - -CClass::CClass() -{ - m_pClassPoint= NULL; -} - -bool CClass::InitInstance() -{ -////////////////////////////////////////////// -// défini les mots clefs supplémentaires -// ------------------------------------------- - - CBotProgram::Init(); - -////////////////////////////////////////////// -// défini les fonctions "show()" et "print()" -// ------------------------------------------- - - //CBotProgram::AddFunction("show", rShow, cShow); - CBotProgram::AddFunction("print", rPrint, cPrint); - CBotProgram::AddFunction("println", rPrintLn, cPrint); - - -/////////////////////////////////// -// définie la classe globale CPoint -// -------------------------------- - - m_pClassPoint = new CBotClass("CPoint", NULL); - // ajoute le composant ".x" - m_pClassPoint->AddItem("x", CBotTypFloat); - // ajoute le composant ".y" - m_pClassPoint->AddItem("y", CBotTypFloat); - - // ajoute le constructeur pour cette classe - m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint); - - m_pClassPointIntr = new CBotClass("point", NULL, true); - // ajoute le composant ".x" - m_pClassPointIntr->AddItem("x", CBotTypFloat); - // ajoute le composant ".y" - m_pClassPointIntr->AddItem("y", CBotTypFloat); - // ajoute le composant ".z" - m_pClassPointIntr->AddItem("z", CBotTypFloat); - - // ajoute le constructeur pour cette classe - m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint); - - // défini la classe "object" - CBotClass* pClassObject = new CBotClass( "object", NULL ) ; - pClassObject->AddItem( "xx", CBotTypFloat ); - pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) ); - pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) ); - pClassObject->AddUpdateFunc( rMajObject ); - - InitClassFILE(); - - return true; -} - -void CClass::ExitInstance() -{ - delete m_pFuncFile; - - CBotProgram::Free(); - -} diff --git a/src/CBot/tests/CBot_console/src/app/CClass.h b/src/CBot/tests/CBot_console/src/app/CClass.h deleted file mode 100644 index da2c46c..0000000 --- a/src/CBot/tests/CBot_console/src/app/CClass.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include <CBot/CBot.h> -#include <string> - -extern std::string s; - -class CClass -{ -public: - CClass(); - - CBotClass* m_pClassPoint; - CBotClass* m_pClassPointIntr; - - bool InitInstance(); - void ExitInstance(); -}; diff --git a/src/CBot/tests/CBot_console/src/app/main.cpp b/src/CBot/tests/CBot_console/src/app/main.cpp deleted file mode 100644 index a2d3668..0000000 --- a/src/CBot/tests/CBot_console/src/app/main.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "CClass.h" -#include "CBotDoc.h" -#include <iostream> - - -#include <fstream> - -std::string str; - -// routine to update the instance of the class Bot common - -int main(int argc, char* argv[]) -{ - CClass newclass; - CBotDoc *botdoc; - if (argc != 2) - { - std::cout << "Usage: "<<argv[0] << " <filename>" << std::endl; - return 0; - } - - std::ifstream in(argv[1]); - std::cout << argv[1] << std::endl; - if (!in.good()) - { - std::cout << "Oh no, error!" << std::endl; - return 1; - } - - std::string contents((std::istreambuf_iterator<char>(in)), - std::istreambuf_iterator<char>()); - str = contents; - - if(!newclass.InitInstance()) - { - std::cerr << "Initialization not complete!" << std::endl; - return 1; - } - - botdoc = new CBotDoc(str); -// std::cout << "Hello CBot!" << std::endl << s; - botdoc->OnRun(); - delete botdoc; - newclass.ExitInstance(); -} diff --git a/src/CBot/tests/CBot_console/src/app/routines.cpp b/src/CBot/tests/CBot_console/src/app/routines.cpp deleted file mode 100644 index 8b8a1d4..0000000 --- a/src/CBot/tests/CBot_console/src/app/routines.cpp +++ /dev/null @@ -1,141 +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/. - -//////////////////////////////////////////////////////////////////// -// routine show() -// utilisable depuis le programme écrit en CBot - - -#include <iostream> -#include <string> -#include "CBot/ClassFILE.cpp" -//std::string s; -/* -// execution -bool rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser ) -{ - string::string s; - - while ( pVar != NULL ) - { - string::string ss; - - ss.LoadString( TX_TYPENAMES + pVar->GetType() ); - s += ss + " "; - - ss = pVar->GetName(); - if (ss.IsEmpty()) ss = "<sans nom>"; - s += ss + " = "; - - s += pVar->GetValString(); - s += "\n"; - pVar = pVar->GetNext(); - } - - AfxMessageBox(s, MB_OK|MB_ICONINFORMATION); - - return TRUE; // pas d'interruption -} - -CBotTypResult cShow( CBotVar* &pVar, void* pUser) -{ - if ( pVar == NULL ) return CBotTypResult(5028); - return CBotTypResult(0); // tous paramètres acceptés, void en retour -} - -*/ - -//////////////////////////////////////////////////////////////////// -// routine print() -// utilisable depuis le programme écrit en CBot - -// exécution - -bool rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser ) -{ - std::string s; - while ( pVar != NULL ) - { - if ( !s.empty() ) s += " "; - s += pVar->GetValString(); - pVar = pVar->GetNext(); - } - s += "\n"; - - std::cout << s; - return true; // pas d'interruption -} - -bool rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser ) -{ - std::string s; - while ( pVar != NULL ) - { - if ( !s.empty() ) s += " "; - s += pVar->GetValString(); - pVar = pVar->GetNext(); - } - s += " "; - std::cout << s; - return true; // pas d'interruption -} - -CBotTypResult cPrint( CBotVar* &pVar, void* pUser) -{ - return CBotTypResult(0); // tous paramètres acceptés, un entier en retour -} - - -////////////////////////////////////////////////////////////////// -// class CPoint pour essayer - -// exécution -bool rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception ) -{ - if ( pVar == NULL )return true; // constructor with no parameters is ok - - CBotVar* pX = pThis->GetItem("x"); - pX->SetValFloat( pVar->GetValFloat() ); - pVar = pVar->GetNext(); - - CBotVar* pY = pThis->GetItem("y"); - pY->SetValFloat( pVar->GetValFloat() ); - pVar = pVar->GetNext(); - - return true; // pas d'interruption -} - -CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar) -{ - // ok if no parameters! - if ( pVar == NULL ) return CBotTypResult(0); - - // numeric type of parameter please - if ( pVar->GetType() > CBotTypDouble ) return CBotTypResult(5011); - pVar = pVar->GetNext(); - - // there must be a second parameter - if ( pVar == NULL ) return 5028; - // also numeric - if ( pVar->GetType() > CBotTypDouble )return CBotTypResult(5011); - pVar = pVar->GetNext(); - - // and not more than 2 parameters please - if ( pVar != NULL ) return CBotTypResult(5026); - - return CBotTypResult(0); // This function returns void -} - diff --git a/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp b/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp deleted file mode 100644 index 55a271a..0000000 --- a/src/CBot/tests/TestCBot/CBotConsoleDlg.cpp +++ /dev/null @@ -1,221 +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/.
-
-// CBotConsoleDlg.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-#include "CBotConsoleDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg dialog
-
-
-CBotConsoleDlg::CBotConsoleDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CBotConsoleDlg::IDD, pParent)
-{
- //{{AFX_DATA_INIT(CBotConsoleDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pProg = NULL;
- m_threadinfo.m_bRun = FALSE;
- m_code = 0;
-}
-
-
-void CBotConsoleDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBotConsoleDlg)
- DDX_Control(pDX, IDOK, m_cOK);
- DDX_Control(pDX, IDC_EDIT2, m_Edit2);
- DDX_Control(pDX, IDC_EDIT1, m_Edit1);
- //}}AFX_DATA_MAP
-}
-
-
-BEGIN_MESSAGE_MAP(CBotConsoleDlg, CDialog)
- //{{AFX_MSG_MAP(CBotConsoleDlg)
- ON_MESSAGE(WM_ENDPROG, EndProg)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg message handlers
-
-UINT ThreadProc(ThreadInfo *info)
-{
- CTime t0 = CTime::GetCurrentTime();
- int Cpt = 0;
-
- info->m_pProg->Start("LaCommande");
- while ( !info->m_bStop && !info->m_pProg->Run() )
- {
-#if 0
- const char* FunctionName;
- const char* FN;
- int start, end;
-
- info->m_pProg->GetRunPos(FunctionName, start, end);
-
- if ( FunctionName != NULL )
- {
- info->m_pEditx->SetSel(start, end);
-
- char buffer[200];
- sprintf( buffer, "step %s, %d, %d",FunctionName, start, end);
- AfxMessageBox( buffer );
-
- int level = 0;
- do
- {
- CBotVar* t = info->m_pProg->GivStackVars(FN, level--);
- if ( FN != FunctionName ) break;
- if ( t != NULL )
- {
- CString s ;
- while ( t != NULL )
- {
- if (s.IsEmpty()) s+= "Stack -> ";
- else s+= " , ";
- s += t->GivValString();
- t = t->GivNext();
- }
- AfxMessageBox(s);
- }
- } while (TRUE);
- }
-#endif
- Cpt++;
- if ( Cpt%50 == 0 ) info->m_pEdit1->ReplaceSel(".");
- }
-
- if ( info->m_bStop )
- {
- info->m_pEdit1->ReplaceSel("\r\nInterrompu\r\n");
- }
- else if (info->m_pProg->GivError() == 0)
- {
- CTime t = CTime::GetCurrentTime();
- CTimeSpan ts = t - t0;
-
- char buffer[200];
- sprintf( buffer, "\r\nExécution terminée en %d secondes.\r\nInterrompue %d fois.\r\n",
- ts.GetTotalSeconds(), Cpt);
-
- info->m_pEdit1->ReplaceSel(buffer);
- }
-
- info->m_pWndMessage->SendMessage(WM_ENDPROG, 0, 0) ;
- return 0 ;
-}
-
-LONG CBotConsoleDlg::EndProg(UINT wparam, LONG lparam)
-{
- m_threadinfo.m_bRun = FALSE;
-
- if (m_pProg->GetError(m_code, m_start, m_end))
- {
- CBotString TextError;
- TextError = CBotProgram::GivErrorText(m_code);
- AfxMessageBox(TextError);
- CDialog::OnCancel();
- return 1;
- }
- delete m_pProg;
- m_pProg = NULL;
-
- m_Edit2.EnableWindow(TRUE);
- m_cOK.EnableWindow(TRUE);
-
- m_Edit2.SetWindowText("");
- m_Edit2.SetFocus();
- return 0 ;
-}
-
-void CBotConsoleDlg::OnOK()
-{
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- pApp->m_pConsole = &m_Edit1;
- m_code = 0;
-
- CString Commande;
- m_Edit2.GetWindowText(Commande);
-
- CString s = "void LaCommande() { " + Commande + " ;}";
- m_pProg = new CBotProgram();
- CBotStringArray liste;
- m_pProg->Compile(s, liste);
-
- int err, start, end;
- if ( m_pProg->GetError(err, start, end) )
- {
- CBotString TextError;
- TextError = CBotProgram::GivErrorText(err);
- AfxMessageBox(TextError);
- m_Edit2.SetSel(start-20, end-20);
- return;
- }
-
- m_Edit1.ReplaceSel("\r\n" + Commande + " ->\r\n");
-
- m_Edit2.SetWindowText("");
- m_Edit1.SetFocus();
- m_Edit2.EnableWindow(FALSE);
- m_cOK.EnableWindow(FALSE);
-
- // lance un processus paralèle pour l'exécution
- m_threadinfo.m_pWndMessage = this ;
-
- m_threadinfo.m_pEdit1 = &m_Edit1;
- m_threadinfo.m_pEditx = m_pEditx;
- m_threadinfo.m_pProg = m_pProg;
- m_threadinfo.m_bStop = FALSE;
- m_threadinfo.m_bRun = TRUE;
-
- AfxBeginThread((AFX_THREADPROC)ThreadProc, &m_threadinfo) ;
-}
-
-void CBotConsoleDlg::OnCancel()
-{
- if (!m_threadinfo.m_bRun) CDialog::OnCancel();
- m_threadinfo.m_bStop = TRUE ;
-}
-
-
-BOOL CBotConsoleDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- m_Edit1.ReplaceSel("Les fonctions suivantes sont disponibles:\r\n");
- for ( int i = 0; i < m_pListe->GivSize(); i++ )
- {
- CBotString x = (*m_pListe)[i] + CBotString("\r\n");
- m_Edit1.ReplaceSel(x);
- }
- m_Edit1.ReplaceSel("Entrez une commande ci-dessous.\r\n\r\n");
-
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
-}
diff --git a/src/CBot/tests/TestCBot/CBotConsoleDlg.h b/src/CBot/tests/TestCBot/CBotConsoleDlg.h deleted file mode 100644 index f289a4d..0000000 --- a/src/CBot/tests/TestCBot/CBotConsoleDlg.h +++ /dev/null @@ -1,85 +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/.
-
-#if !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-// CBotConsoleDlg.h : header file
-//
-
-struct ThreadInfo
-{
- CEdit* m_pEdit1 ;
- CEdit* m_pEditx ;
- CBotProgram* m_pProg;
- CWnd* m_pWndMessage;
- BOOL m_bStop;
- BOOL m_bRun;
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CBotConsoleDlg dialog
-
-class CBotConsoleDlg : public CDialog
-{
-// Construction
-public:
- CBotConsoleDlg(CWnd* pParent = NULL); // standard constructor
-
-// Dialog Data
- //{{AFX_DATA(CBotConsoleDlg)
- enum { IDD = IDD_CONSOLE };
- CButton m_cOK;
- CEdit m_Edit2;
- CEdit m_Edit1;
- //}}AFX_DATA
-
- CBotProgram* m_pProg;
- ThreadInfo m_threadinfo;
-
- CBotStringArray*
- m_pListe;
- int m_code, m_start, m_end;
- CEdit* m_pEditx;
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CBotConsoleDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
-
- // Generated message map functions
- //{{AFX_MSG(CBotConsoleDlg)
- virtual void OnOK();
- virtual void OnCancel();
- virtual BOOL OnInitDialog();
- afx_msg LONG EndProg(UINT wparam, LONG lparam) ;
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_BOTCONSOLEDLG_H__A11450A2_8E09_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/ChildFrm.cpp b/src/CBot/tests/TestCBot/ChildFrm.cpp deleted file mode 100644 index 4c40f90..0000000 --- a/src/CBot/tests/TestCBot/ChildFrm.cpp +++ /dev/null @@ -1,74 +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/.
-
-// ChildFrm.cpp : implementation of the CChildFrame class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "ChildFrm.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame
-
-IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
-
-BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame construction/destruction
-
-CChildFrame::CChildFrame()
-{
-}
-
-CChildFrame::~CChildFrame()
-{
-}
-
-BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CMDIChildWnd::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame diagnostics
-
-#ifdef _DEBUG
-void CChildFrame::AssertValid() const
-{
- CMDIChildWnd::AssertValid();
-}
-
-void CChildFrame::Dump(CDumpContext& dc) const
-{
- CMDIChildWnd::Dump(dc);
-}
-
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CChildFrame message handlers
diff --git a/src/CBot/tests/TestCBot/ChildFrm.h b/src/CBot/tests/TestCBot/ChildFrm.h deleted file mode 100644 index 2ad57b6..0000000 --- a/src/CBot/tests/TestCBot/ChildFrm.h +++ /dev/null @@ -1,66 +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/.
-
-// ChildFrm.h : interface of the CChildFrame class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CChildFrame : public CMDIChildWnd
-{
- DECLARE_DYNCREATE(CChildFrame)
-public:
- CChildFrame();
-
-// Attributes
-public:
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CChildFrame)
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CChildFrame();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CChildFrame)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_CHILDFRM_H__4D1BB909_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/MainFrm.cpp b/src/CBot/tests/TestCBot/MainFrm.cpp deleted file mode 100644 index 6669350..0000000 --- a/src/CBot/tests/TestCBot/MainFrm.cpp +++ /dev/null @@ -1,116 +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/.
-
-// MainFrm.cpp : implementation of the CMainFrame class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "MainFrm.h"
-#include "TestCBotDoc.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame
-
-IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
-
-BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-static UINT indicators[] =
-{
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
-};
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame construction/destruction
-
-CMainFrame::CMainFrame()
-{
-}
-
-CMainFrame::~CMainFrame()
-{
-}
-
-int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
-{
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbar\n");
- return -1; // fail to create
- }
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status bar\n");
- return -1; // fail to create
- }
-
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
-
- return 0;
-}
-
-BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CMDIFrameWnd::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame diagnostics
-
-#ifdef _DEBUG
-void CMainFrame::AssertValid() const
-{
- CMDIFrameWnd::AssertValid();
-}
-
-void CMainFrame::Dump(CDumpContext& dc) const
-{
- CMDIFrameWnd::Dump(dc);
-}
-
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CMainFrame message handlers
-
-
diff --git a/src/CBot/tests/TestCBot/MainFrm.h b/src/CBot/tests/TestCBot/MainFrm.h deleted file mode 100644 index a1d34f4..0000000 --- a/src/CBot/tests/TestCBot/MainFrm.h +++ /dev/null @@ -1,72 +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/.
-
-// MainFrm.h : interface of the CMainFrame class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CMainFrame : public CMDIFrameWnd
-{
- DECLARE_DYNAMIC(CMainFrame)
-public:
- CMainFrame();
-
-// Attributes
-public:
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CMainFrame)
- public:
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CMainFrame();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected: // control bar embedded members
- CStatusBar m_wndStatusBar;
- CToolBar m_wndToolBar;
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CMainFrame)
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_MAINFRM_H__4D1BB907_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/PerformDlg.cpp b/src/CBot/tests/TestCBot/PerformDlg.cpp deleted file mode 100644 index 8abbb4b..0000000 --- a/src/CBot/tests/TestCBot/PerformDlg.cpp +++ /dev/null @@ -1,177 +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/.
-
-// PerformDlg.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "testcbot.h"
-#include "PerformDlg.h"
-
-//#include <stdio.h>
-#include <sys/timeb.h>
-//#include <time.h>
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg dialog
-
-
-CPerformDlg::CPerformDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CPerformDlg::IDD, pParent)
-{
- //{{AFX_DATA_INIT(CPerformDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
-}
-
-
-void CPerformDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPerformDlg)
- DDX_Control(pDX, IDC_EDIT3, m_Edit3);
- DDX_Control(pDX, IDC_EDIT1, m_Edit1);
- //}}AFX_DATA_MAP
-}
-
-
-BEGIN_MESSAGE_MAP(CPerformDlg, CDialog)
- //{{AFX_MSG_MAP(CPerformDlg)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg message handlers
-
-/* Pauses for a specified number of milliseconds. */
-
-/*void sleep( double waitseconds )
-{
- clock_t wait = (clock_t)(waitseconds * CLOCKS_PER_SEC);
- clock_t goal;
- goal = wait + clock();
- while( goal > clock() )
- ;
-}*/
-
-void sleep( clock_t wait )
-{
- clock_t goal;
- goal = wait + clock();
- while( goal > clock() )
- TRACE("%d \n", clock() );
-}
-
-void sleep2( clock_t wait )
-{
- struct _timeb timebuffer;
- char *timeline;
-
- _ftime( &timebuffer );
- timeline = ctime( & ( timebuffer.time ) );
- long x = timebuffer.millitm;
- while( x == timebuffer.millitm ) _ftime( &timebuffer );
-}
-
-#define NBLP 20
-
-UINT ThreadProc2(ThreadInfo2 *info)
-{
- int lp = NBLP;
- int i;
- clock_t start = clock();
-
- while ( !info->m_bStop )
- {
- for ( i = 0; i< info->m_nbscripts; i++ )
- {
- info->m_pProg[i]->Run();
- }
-
-#ifdef _DEBUG
- sleep2( 1 );
-#else
- CString s ( "xx" );
- for ( long z = 0x5000; z>0; z-- ) s = s.Left(1);
-#endif
- if ( --lp == 0 )
- {
- clock_t finish = clock();
- double n = (double)NBLP / (double)(finish-start) * CLOCKS_PER_SEC;
- char b[30];
- sprintf( b, "%f", n);
- info->m_pEdit->SetWindowText(b);
-
- n = n * 1100 / 200; // performances
- sprintf( b, "%f", n);
- info->m_pEdit3->SetWindowText(b);
- start = finish;
- lp = NBLP;
- }
- }
-
- return 0 ;
-}
-
-BOOL CPerformDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
-
- CBotStringArray liste;
- // crée les scripts pour les tests
- for ( int i = 0; i < 100; i++ )
- {
- m_pProg[i] = new CBotProgram();
- m_pProg[i]->Compile(m_Script, liste);
- m_pProg[i]->Start(liste[0]);
- }
-
- // lance un processus paralèle pour l'exécution
-// m_threadinfo2.m_pWndMessage = this ;
-
- m_threadinfo2.m_pEdit = &m_Edit1;
- m_threadinfo2.m_pEdit3 = &m_Edit3;
- m_threadinfo2.m_pProg = m_pProg;
- m_threadinfo2.m_bStop = FALSE;
- m_threadinfo2.m_nbscripts = 30;
-
-
- AfxBeginThread((AFX_THREADPROC)ThreadProc2, &m_threadinfo2) ;
- // TODO: Add extra initialization here
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
-}
-
-void CPerformDlg::OnCancel()
-{
- m_threadinfo2.m_bStop = TRUE;
- sleep ( 2000 );
-
- CDialog::OnCancel();
-
- for ( int i = 0; i < 100; i++ )
- {
- delete m_pProg[i];
- }
-}
diff --git a/src/CBot/tests/TestCBot/PerformDlg.h b/src/CBot/tests/TestCBot/PerformDlg.h deleted file mode 100644 index 29d567f..0000000 --- a/src/CBot/tests/TestCBot/PerformDlg.h +++ /dev/null @@ -1,78 +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/.
-
-#if !defined(AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-// PerformDlg.h : header file
-//
-
-struct ThreadInfo2
-{
- CEdit* m_pEdit ;
- CEdit* m_pEdit3 ;
-
- CBotProgram** m_pProg;
- BOOL m_bStop;
- int m_nbscripts;
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CPerformDlg dialog
-
-class CPerformDlg : public CDialog
-{
-// Construction
-public:
- CPerformDlg(CWnd* pParent = NULL); // standard constructor
-
-// Dialog Data
- //{{AFX_DATA(CPerformDlg)
- enum { IDD = IDD_DIALOG1 };
- CEdit m_Edit3;
- CEdit m_Edit1;
- //}}AFX_DATA
-
- CBotProgram* m_pProg[100];
- ThreadInfo2 m_threadinfo2;
- CString m_Script;
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CPerformDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
-
- // Generated message map functions
- //{{AFX_MSG(CPerformDlg)
- virtual BOOL OnInitDialog();
- virtual void OnCancel();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_PERFORMDLG_H__EAF2D560_97D8_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/Routines.cpp b/src/CBot/tests/TestCBot/Routines.cpp deleted file mode 100644 index b37f027..0000000 --- a/src/CBot/tests/TestCBot/Routines.cpp +++ /dev/null @@ -1,153 +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/.
-
-////////////////////////////////////////////////////////////////////
-// routine show()
-// utilisable depuis le programme écrit en CBot
-
-// exécution
-BOOL rShow( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- while ( pVar != NULL )
- {
- CString ss;
- ss.LoadString( TX_TYPENAMES + pVar->GivType() );
- s += ss + " ";
-
- ss = pVar->GivName();
- if (ss.IsEmpty()) ss = "<sans nom>";
- s += ss + " = ";
-
- s += pVar->GivValString();
- s += "\n";
- pVar = pVar->GivNext();
- }
-
- AfxMessageBox(s, MB_OK|MB_ICONINFORMATION);
-
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cShow( CBotVar* &pVar, void* pUser)
-{
- if ( pVar == NULL ) return CBotTypResult(5028);
- return CBotTypResult(0); // tous paramètres acceptés, void en retour
-}
-
-
-////////////////////////////////////////////////////////////////////
-// routine print()
-// utilisable depuis le programme écrit en CBot
-
-// exécution
-BOOL rPrintLn( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- CEdit* pEdit = pApp->m_pConsole;
-
- if (pEdit == NULL) return TRUE;
- pEdit->GetWindowText(s);
-
- while ( pVar != NULL )
- {
- if ( !s.IsEmpty() ) s += " ";
- s += pVar->GivValString();
- pVar = pVar->GivNext();
- }
- s += "\r\n";
-
- pEdit->SetWindowText(s);
- pEdit->SetSel(s.GetLength(), s.GetLength());
- pEdit->SetFocus();
- return TRUE; // pas d'interruption
-}
-
-BOOL rPrint( CBotVar* pVar, CBotVar* pResult, int& Exception, void* pUser )
-{
- CString s;
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
- CEdit* pEdit = pApp->m_pConsole;
-
- if (pEdit == NULL) return TRUE;
- pEdit->GetWindowText(s);
-
- while ( pVar != NULL )
- {
- if ( !s.IsEmpty() ) s += " ";
- s += pVar->GivValString();
- pVar = pVar->GivNext();
- }
-
- pEdit->SetWindowText(s);
- pEdit->SetSel(s.GetLength(), s.GetLength());
- pEdit->SetFocus();
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cPrint( CBotVar* &pVar, void* pUser)
-{
- return CBotTypResult(0); // tous paramètres acceptés, un entier en retour
-}
-
-
-//////////////////////////////////////////////////////////////////
-// class CPoint pour essayer
-
-// exécution
-BOOL rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
-{
- CString s;
-
- if ( pVar == NULL )return TRUE; // constructeur sans paramètres est ok
-
- CBotVar* pX = pThis->GivItem("x");
- pX->SetValFloat( pVar->GivValFloat() );
- pVar = pVar->GivNext();
-
- CBotVar* pY = pThis->GivItem("y");
- pY->SetValFloat( pVar->GivValFloat() );
- pVar = pVar->GivNext();
-
- return TRUE; // pas d'interruption
-}
-
-CBotTypResult cCPoint( CBotVar* pThis, CBotVar* &pVar)
-{
- // ok si aucun paramètres !
- if ( pVar == NULL ) return CBotTypResult(0);
-
- // paramètre de type numérique svp
- if ( pVar->GivType() > CBotTypDouble ) return CBotTypResult(5011);
- pVar = pVar->GivNext();
-
- // il doit y avoir un second paramètre
- if ( pVar == NULL ) return 5028;
- // également de type numérique
- if ( pVar->GivType() > CBotTypDouble )return CBotTypResult(5011);
- pVar = pVar->GivNext();
-
- // et pas plus de 2 paramètres svp
- if ( pVar != NULL ) return CBotTypResult(5026);
-
- return CBotTypResult(0); // cette fonction retourne void
-}
-
-
diff --git a/src/CBot/tests/TestCBot/StdAfx.cpp b/src/CBot/tests/TestCBot/StdAfx.cpp deleted file mode 100644 index 7dd0f00..0000000 --- a/src/CBot/tests/TestCBot/StdAfx.cpp +++ /dev/null @@ -1,20 +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/.// stdafx.cpp : source file that includes just the standard includes
-// TestCBot.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
diff --git a/src/CBot/tests/TestCBot/StdAfx.h b/src/CBot/tests/TestCBot/StdAfx.h deleted file mode 100644 index c3659fb..0000000 --- a/src/CBot/tests/TestCBot/StdAfx.h +++ /dev/null @@ -1,40 +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/.// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#if !defined(AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
-
-#include <afxwin.h> // MFC core and standard components
-#include <afxext.h> // MFC extensions
-#include <afxdisp.h> // MFC OLE automation classes
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__4D1BB905_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/TestCBot.clw b/src/CBot/tests/TestCBot/TestCBot.clw deleted file mode 100644 index 13f20f4..0000000 --- a/src/CBot/tests/TestCBot/TestCBot.clw +++ /dev/null @@ -1,316 +0,0 @@ -; CLW file contains information for the MFC ClassWizard
-
-[General Info]
-Version=1
-LastClass=CPerformDlg
-LastTemplate=CDialog
-NewFileInclude1=#include "stdafx.h"
-NewFileInclude2=#include "testcbot.h"
-LastPage=0
-
-ClassCount=8
-Class1=CBotConsoleDlg
-Class2=CChildFrame
-Class3=CMainFrame
-Class4=CTestCBotApp
-Class5=CAboutDlg
-Class6=CTestCBotDoc
-Class7=CTestCBotView
-
-ResourceCount=12
-Resource1=IDD_CONSOLE
-Resource2=IDR_TESTCBTYPE (French (France))
-Resource3=IDD_ABOUTBOX (French (France))
-Resource4=IDR_MAINFRAME (French (France))
-Resource5=IDR_MAINFRAME
-Resource6=IDR_TESTCBTYPE
-Resource7=IDD_ABOUTBOX
-Resource8=IDD_CONSOLE (French (Switzerland))
-Class8=CPerformDlg
-Resource9=IDD_DIALOG1
-Resource10=IDD_DIALOG2
-Resource11=IDD_DIALOG1 (French (Switzerland))
-Resource12=IDD_DIALOG2 (French (France))
-
-[CLS:CBotConsoleDlg]
-Type=0
-BaseClass=CDialog
-HeaderFile=CBotConsoleDlg.h
-ImplementationFile=CBotConsoleDlg.cpp
-LastObject=IDC_EDIT1
-
-[CLS:CChildFrame]
-Type=0
-BaseClass=CMDIChildWnd
-HeaderFile=ChildFrm.h
-ImplementationFile=ChildFrm.cpp
-
-[CLS:CMainFrame]
-Type=0
-BaseClass=CMDIFrameWnd
-HeaderFile=MainFrm.h
-ImplementationFile=MainFrm.cpp
-Filter=T
-VirtualFilter=fWC
-LastObject=CMainFrame
-
-[CLS:CTestCBotApp]
-Type=0
-BaseClass=CWinApp
-HeaderFile=TestCBot.h
-ImplementationFile=TestCBot.cpp
-Filter=N
-VirtualFilter=AC
-LastObject=ID_TEST
-
-[CLS:CAboutDlg]
-Type=0
-BaseClass=CDialog
-HeaderFile=TestCBot.cpp
-ImplementationFile=TestCBot.cpp
-LastObject=CAboutDlg
-
-[CLS:CTestCBotDoc]
-Type=0
-BaseClass=CDocument
-HeaderFile=TestCBotDoc.h
-ImplementationFile=TestCBotDoc.cpp
-LastObject=CTestCBotDoc
-Filter=N
-VirtualFilter=DC
-
-[CLS:CTestCBotView]
-Type=0
-BaseClass=CView
-HeaderFile=TestCBotView.h
-ImplementationFile=TestCBotView.cpp
-LastObject=CTestCBotView
-Filter=C
-VirtualFilter=VWC
-
-[DLG:IDD_CONSOLE]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[DLG:IDD_ABOUTBOX]
-Type=1
-Class=CAboutDlg
-ControlCount=7
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Control5=IDC_STATIC,static,1342308352
-Control6=IDC_STATIC,static,1342308352
-Control7=IDC_STATIC,static,1342308352
-
-[TB:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[ACL:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_TEST
-Command13=ID_EDIT_COPY
-Command14=ID_EDIT_PASTE
-Command15=ID_EDIT_CUT
-Command16=ID_EDIT_UNDO
-CommandCount=16
-
-[DLG:IDD_ABOUTBOX (French (France))]
-Type=1
-Class=CAboutDlg
-ControlCount=7
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Control5=IDC_STATIC,static,1342308352
-Control6=IDC_STATIC,static,1342308352
-Control7=IDC_STATIC,static,1342308352
-
-[ACL:IDR_MAINFRAME]
-Type=1
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_TEST
-Command13=ID_EDIT_COPY
-Command14=ID_EDIT_PASTE
-Command15=ID_EDIT_CUT
-Command16=ID_EDIT_UNDO
-CommandCount=16
-
-[TB:IDR_MAINFRAME]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE]
-Type=1
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[DLG:IDD_CONSOLE (French (Switzerland))]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[DLG:IDD_DIALOG1]
-Type=1
-Class=CPerformDlg
-ControlCount=9
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT1,edit,1350633600
-Control3=IDC_STATIC,static,1342308352
-Control4=IDC_EDIT2,edit,1350631552
-Control5=IDC_SPIN1,msctls_updown32,1342177312
-Control6=IDC_COMBO1,combobox,1344339971
-Control7=IDC_STATIC,static,1342308352
-Control8=IDC_STATIC,static,1342308352
-Control9=IDC_EDIT3,edit,1350633600
-
-[CLS:CPerformDlg]
-Type=0
-HeaderFile=PerformDlg.h
-ImplementationFile=PerformDlg.cpp
-BaseClass=CDialog
-Filter=D
-VirtualFilter=dWC
-LastObject=IDC_EDIT3
-
-[DLG:IDD_DIALOG2]
-Type=1
-ControlCount=2
-Control1=IDOK,button,1342242817
-Control2=IDCANCEL,button,1342242816
-
-[DLG:IDD_DIALOG1 (French (Switzerland))]
-Type=1
-ControlCount=9
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT1,edit,1350633600
-Control3=IDC_STATIC,static,1342308352
-Control4=IDC_EDIT2,edit,1350631552
-Control5=IDC_SPIN1,msctls_updown32,1342177312
-Control6=IDC_COMBO1,combobox,1344339971
-Control7=IDC_STATIC,static,1342308352
-Control8=IDC_STATIC,static,1342308352
-Control9=IDC_EDIT3,edit,1350633600
-
-[DLG:IDD_DIALOG2 (French (France))]
-Type=1
-ControlCount=2
-Control1=IDOK,button,1342242817
-Control2=IDCANCEL,button,1342242816
-
diff --git a/src/CBot/tests/TestCBot/TestCBot.cpp b/src/CBot/tests/TestCBot/TestCBot.cpp deleted file mode 100644 index a76040a..0000000 --- a/src/CBot/tests/TestCBot/TestCBot.cpp +++ /dev/null @@ -1,267 +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/.// TestCBot.cpp : Defines the class behaviors for the application.
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "MainFrm.h"
-#include "ChildFrm.h"
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp
-
-BEGIN_MESSAGE_MAP(CTestCBotApp, CWinApp)
- //{{AFX_MSG_MAP(CTestCBotApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp construction
-
-CTestCBotApp::CTestCBotApp()
-{
- m_pConsole = NULL;
- m_LastActive = NULL;
- m_pClassPoint= NULL;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// The one and only CTestCBotApp object
-
-CTestCBotApp theApp;
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp initialization
-
-#include "Routines.cpp"
-
-
-static char BASED_CODE szSection[] = "Recent File List";
-static char BASED_CODE szFilename[] = "File1";
-
-
-#include "../ClassFILE.cpp"
-
-// routine pour mettre à jour l'instance de la classe Bot courante
-void rMajObject( CBotVar* pThis, void* pUser )
-{
- if (!pThis->IsElemOfClass("object"))
- return ;
- CBotVar* pPos = pThis->GivItem("position");
- CBotVar* pX = pPos->GivItem("x");
- CBotVar* pY = pPos->GivItem("y");
- CBotVar* pZ = pPos->GivItem("z");
-// CBotVar* pPt = pThis->GivItem("transport");
-
- CBotString p = pX->GivValString();
-
-// pX->SetValFloat( pUser == (void*)1 ? (float)12.5 : (float)44.4 );
- pZ->SetValFloat( (float)0 );
- pY->SetValFloat( (float)-3.33 );
- pX->SetValFloat( pX->GivValFloat() + 10 ) ;
-
-// pX = pThis->GivItem( "xx" );
-// pX->SetValFloat( (float)22 );
-
- // crée une instance sur une classe object
-// CBotVar* pAutre = CBotVar::Create("autre", CBotTypClass, "object");
-// pAutre->SetUserPtr( (void*)3 );
-// pPt->SetPointer( pAutre );
-// pPt->SetPointer( NULL );
-// delete pAutre;
-}
-
-
-BOOL CTestCBotApp::InitInstance()
-{
-//////////////////////////////////////////////
-// défini les mots clefs supplémentaires
-// -------------------------------------------
-
- CBotProgram::Init();
-
-//////////////////////////////////////////////
-// défini les fonctions "show()" et "print()"
-// -------------------------------------------
-
- CBotProgram::AddFunction("show", rShow, cShow);
- CBotProgram::AddFunction("print", rPrint, cPrint);
- CBotProgram::AddFunction("println", rPrintLn, cPrint);
-
-
-///////////////////////////////////
-// définie la classe globale CPoint
-// --------------------------------
-
- m_pClassPoint = new CBotClass("CPoint", NULL);
- // ajoute le composant ".x"
- m_pClassPoint->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPoint->AddItem("y", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);
-
- m_pClassPointIntr = new CBotClass("point", NULL, TRUE);
- // ajoute le composant ".x"
- m_pClassPointIntr->AddItem("x", CBotTypFloat);
- // ajoute le composant ".y"
- m_pClassPointIntr->AddItem("y", CBotTypFloat);
- // ajoute le composant ".z"
- m_pClassPointIntr->AddItem("z", CBotTypFloat);
-
- // ajoute le constructeur pour cette classe
- m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);
-
- // défini la classe "object"
- CBotClass* pClassObject = new CBotClass( "object", NULL ) ;
- pClassObject->AddItem( "xx", CBotTypFloat );
- pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
- pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
- pClassObject->AddUpdateFunc( rMajObject );
-
- InitClassFILE();
-
- AfxEnableControlContainer();
-
- // Standard initialization
-
-#ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
-#else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
-#endif
-
- // Change the registry key under which our settings are stored.
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
-
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
-
- // Register document templates
-
- CMultiDocTemplate* pDocTemplate;
- pDocTemplate = new CMultiDocTemplate(
- IDR_TESTCBTYPE,
- RUNTIME_CLASS(CTestCBotDoc),
- RUNTIME_CLASS(CChildFrame), // custom MDI child frame
- RUNTIME_CLASS(CTestCBotView));
- AddDocTemplate(pDocTemplate);
-
- // create main MDI Frame window
- CMainFrame* pMainFrame = new CMainFrame;
- if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
- return FALSE;
- m_pMainWnd = pMainFrame;
-
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- if (m_lpCmdLine[0] == 0)
- {
- CString Filename = GetProfileString(szSection, szFilename);
- if (Filename.IsEmpty()) Filename = "TstCbot.txt";
- else OpenDocumentFile(Filename);
- }
- else
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
- pMainFrame->ShowWindow(m_nCmdShow);
- pMainFrame->UpdateWindow();
-
-
- return TRUE;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CAboutDlg dialog used for App About
-
-class CAboutDlg : public CDialog
-{
-public:
- CAboutDlg();
-
-// Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
- //{{AFX_MSG(CAboutDlg)
- // No message handlers
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
-{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-// App command to run the dialog
-void CTestCBotApp::OnAppAbout()
-{
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp commands
-
-int CTestCBotApp::ExitInstance()
-{
- delete m_pFuncFile;
-
- CBotProgram::Free();
- return CWinApp::ExitInstance();
-}
diff --git a/src/CBot/tests/TestCBot/TestCBot.dsp b/src/CBot/tests/TestCBot/TestCBot.dsp deleted file mode 100644 index 8ed9b11..0000000 --- a/src/CBot/tests/TestCBot/TestCBot.dsp +++ /dev/null @@ -1,201 +0,0 @@ -# Microsoft Developer Studio Project File - Name="TestCBot" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=TestCBot - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "TestCBot.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "TestCBot.mak" CFG="TestCBot - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "TestCBot - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "TestCBot - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "TestCBot - Win32 Release"
-
-# PROP BASE Use_MFC 5
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 5
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /Yu"stdafx.h" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x100c /d "NDEBUG"
-# ADD RSC /l 0x100c /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
-# ADD LINK32 /nologo /subsystem:windows /machine:I386
-
-!ELSEIF "$(CFG)" == "TestCBot - Win32 Debug"
-
-# PROP BASE Use_MFC 5
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 5
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /Yu"stdafx.h" /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x100c /d "_DEBUG"
-# ADD RSC /l 0x100c /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /stack:0x7010 /subsystem:windows /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "TestCBot - Win32 Release"
-# Name "TestCBot - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\CBotConsoleDlg.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ChildFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\PerformDlg.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"stdafx.h"
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.rc
-
-!IF "$(CFG)" == "TestCBot - Win32 Release"
-
-!ELSEIF "$(CFG)" == "TestCBot - Win32 Debug"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotDoc.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotView.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\CBotConsoleDlg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\ChildFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\MainFrm.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\PerformDlg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Resource.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StdAfx.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBot.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotDoc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\TestCBotView.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\res\TestCBot.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\TestCBot.rc2
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\TestCBotDoc.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\res\Toolbar.bmp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=..\Debug\CBot.lib
-# End Source File
-# End Target
-# End Project
diff --git a/src/CBot/tests/TestCBot/TestCBot.h b/src/CBot/tests/TestCBot/TestCBot.h deleted file mode 100644 index c2595b6..0000000 --- a/src/CBot/tests/TestCBot/TestCBot.h +++ /dev/null @@ -1,78 +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/.// TestCBot.h : main header file for the TESTCBOT application
-//
-
-#if !defined(AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-#ifndef __AFXWIN_H__
- #error include 'stdafx.h' before including this file for PCH
-#endif
-
-#include "resource.h" // main symbols
-//#include "../CbotDll.h" // librairie CBot
-#include "../Cbot.h" // complet pour Browse
-
-class CTestCBotView;
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotApp:
-// See TestCBot.cpp for the implementation of this class
-//
-
-class CTestCBotApp : public CWinApp
-{
-public:
- CTestCBotApp();
-
- CEdit* m_pConsole;
- CTestCBotView* m_LastActive;
- CBotClass* m_pClassPoint;
- CBotClass* m_pClassPointIntr;
-
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotApp)
- public:
- virtual BOOL InitInstance();
- virtual int ExitInstance();
- //}}AFX_VIRTUAL
-
-// Implementation
-
- //{{AFX_MSG(CTestCBotApp)
- afx_msg void OnAppAbout();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOT_H__4D1BB903_8E74_11D4_A439_00D059085115__INCLUDED_)
-
-
-#define WM_STARTPROG WM_APP + 0
-#define WM_ENDPROG WM_APP + 1
-#define WM_ACTWINDOW WM_APP + 2
diff --git a/src/CBot/tests/TestCBot/TestCBot.rc b/src/CBot/tests/TestCBot/TestCBot.rc deleted file mode 100644 index 137458c..0000000 --- a/src/CBot/tests/TestCBot/TestCBot.rc +++ /dev/null @@ -1,564 +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
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDR_MAINFRAME ICON DISCARDABLE "res\\TestCBot.ico"
-IDR_TESTCBTYPE ICON DISCARDABLE "res\\TestCBotDoc.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Toolbar
-//
-
-IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
-BEGIN
- BUTTON ID_FILE_NEW
- BUTTON ID_FILE_OPEN
- BUTTON ID_FILE_SAVE
- SEPARATOR
- BUTTON ID_EDIT_CUT
- BUTTON ID_EDIT_COPY
- BUTTON ID_EDIT_PASTE
- SEPARATOR
- BUTTON ID_FILE_PRINT
- BUTTON ID_RUN
- SEPARATOR
- BUTTON ID_APP_ABOUT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_MAINFRAME MENU PRELOAD DISCARDABLE
-BEGIN
- POPUP "&Fichier"
- BEGIN
- MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
- MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
- MENUITEM SEPARATOR
- MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
- MENUITEM SEPARATOR
- MENUITEM "&Quitter", ID_APP_EXIT
- END
- POPUP "&Affichage"
- BEGIN
- MENUITEM "&Barre d'outils", ID_VIEW_TOOLBAR
- MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
- END
- POPUP "&?"
- BEGIN
- MENUITEM "&A propos de TestCBot...", ID_APP_ABOUT
- END
-END
-
-IDR_TESTCBTYPE MENU PRELOAD DISCARDABLE
-BEGIN
- POPUP "&Fichier"
- BEGIN
- MENUITEM "&Nouveau\tCtrl+N", ID_FILE_NEW
- MENUITEM "&Ouvrir...\tCtrl+O", ID_FILE_OPEN
- MENUITEM "&Fermer", ID_FILE_CLOSE
- MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
- MENUITEM "En®istrer sous...", ID_FILE_SAVE_AS
- MENUITEM SEPARATOR
- MENUITEM "Fichier récent", ID_FILE_MRU_FILE1, GRAYED
- MENUITEM SEPARATOR
- MENUITEM "&Quitter", ID_APP_EXIT
- END
- POPUP "&Edition"
- BEGIN
- MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO
- MENUITEM SEPARATOR
- MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT
- MENUITEM "&Copier\tCtrl+C", ID_EDIT_COPY
- MENUITEM "C&oller\tCtrl+V", ID_EDIT_PASTE
- END
- POPUP "&Affichage"
- BEGIN
- MENUITEM "&Barre d'outils", ID_VIEW_TOOLBAR
- MENUITEM "Barre d'é&tat", ID_VIEW_STATUS_BAR
- END
- POPUP "Fe&nêtre"
- BEGIN
- MENUITEM "&Nouvelle fenêtre", ID_WINDOW_NEW
- MENUITEM "&Cascade", ID_WINDOW_CASCADE
- MENUITEM "&Mosaïque", ID_WINDOW_TILE_HORZ
- MENUITEM "&Réorganiser les icônes", ID_WINDOW_ARRANGE
- END
- POPUP "&?"
- BEGIN
- MENUITEM "&A propos de TestCBot...", ID_APP_ABOUT
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
-BEGIN
- "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
- "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
- "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
- "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
- "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
- VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
- VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
- VK_F5, ID_RUN, VIRTKEY, NOINVERT
- VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT
- VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT
- VK_F7, ID_RUN, VIRTKEY, NOINVERT
- VK_F9, ID_TEST, VIRTKEY, NOINVERT
- VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
- VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
- "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
- "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 265, 206
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "A propos de TestCBot"
-FONT 8, "MS Sans Serif"
-BEGIN
- ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
- LTEXT "TestCBot version 1.0",IDC_STATIC,40,10,119,8,
- SS_NOPREFIX
- LTEXT "Copyright D. Dumoulin (C) 2000",IDC_STATIC,40,25,119,8
- DEFPUSHBUTTON "OK",IDOK,226,7,32,14,WS_GROUP
- LTEXT "Programme de test pour la librairie CBot\n\nLes fonctions doivent être déclarées comme ""extern"" pour apparaître dans la liste lors de l'exécution.\n\n",
- IDC_STATIC,39,43,191,41
- LTEXT "Mais en fait, on peut accèder à toutes les fonctions marquées ""public"" quelles soient dans la fenêtre active ou non.",
- IDC_STATIC,39,89,187,36
- LTEXT "Les fonctions print( ... ) et println( ...) permettent d'afficher des résultats dans la console.\n\nLa fonction show( ... ) affiche les paramètres dans un dialogue, et suspend donc l'exécution.",
- IDC_STATIC,39,130,187,54
-END
-
-IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 186, 95
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,129,7,50,14
- PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
-END
-
-
-#ifndef _MAC
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040C04B0"
- BEGIN
- VALUE "CompanyName", "\0"
- VALUE "FileDescription", "Application MFC TestCBot\0"
- VALUE "FileVersion", "1, 0, 0, 1\0"
- VALUE "InternalName", "TestCBot\0"
- VALUE "LegalCopyright", "Copyright (C) 1900\0"
- VALUE "LegalTrademarks", "\0"
- VALUE "OriginalFilename", "TestCBot.EXE\0"
- VALUE "ProductName", "Application TestCBot\0"
- VALUE "ProductVersion", "1, 0, 0, 1\0"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Traduction", 0x40c, 1200
- END
-END
-
-#endif // !_MAC
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
- IDD_ABOUTBOX, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 258
- TOPMARGIN, 7
- BOTTOMMARGIN, 199
- END
-
- IDD_DIALOG2, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 179
- TOPMARGIN, 7
- BOTTOMMARGIN, 88
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE PRELOAD DISCARDABLE
-BEGIN
- IDR_MAINFRAME "TestCBot"
- IDR_TESTCBTYPE "\nTestCBot\nTestCBot\nCBot (*.txt)\n.txt\nTestCBot.Document\nTestCB Document"
-END
-
-STRINGTABLE PRELOAD DISCARDABLE
-BEGIN
- AFX_IDS_APP_TITLE "TestCBot"
- AFX_IDS_IDLEMESSAGE "Prêt"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_INDICATOR_EXT "EXT"
- ID_INDICATOR_CAPS "MAJ"
- ID_INDICATOR_NUM "NUM"
- ID_INDICATOR_SCRL "DEF"
- ID_INDICATOR_OVR "ECR"
- ID_INDICATOR_REC "ENR"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_FILE_NEW "Crée un nouveau document\nNouveau"
- ID_FILE_OPEN "Ouvre un document existant\nOuvrir"
- ID_FILE_CLOSE "Ferme le document actif\nFermer"
- ID_FILE_SAVE "Enregistre le document actif\nEnregistrer"
- ID_FILE_SAVE_AS "Enregistre le document actif sous un nouveau nom\nEnregistrer sous"
- ID_FILE_PRINT "Imprime le document\nImprime"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_APP_ABOUT "Affiche des informations sur le programme\nA propos de"
- ID_APP_EXIT "Ferme l'application ; propose d'enregistrer les documents\nQuitter"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_FILE_MRU_FILE1 "Ouvre ce document"
- ID_FILE_MRU_FILE2 "Ouvre ce document"
- ID_FILE_MRU_FILE3 "Ouvre ce document"
- ID_FILE_MRU_FILE4 "Ouvre ce document"
- ID_FILE_MRU_FILE5 "Ouvre ce document"
- ID_FILE_MRU_FILE6 "Ouvre ce document"
- ID_FILE_MRU_FILE7 "Ouvre ce document"
- ID_FILE_MRU_FILE8 "Ouvre ce document"
- ID_FILE_MRU_FILE9 "Ouvre ce document"
- ID_FILE_MRU_FILE10 "Ouvre ce document"
- ID_FILE_MRU_FILE11 "Ouvre ce document"
- ID_FILE_MRU_FILE12 "Ouvre ce document"
- ID_FILE_MRU_FILE13 "Ouvre ce document"
- ID_FILE_MRU_FILE14 "Ouvre ce document"
- ID_FILE_MRU_FILE15 "Ouvre ce document"
- ID_FILE_MRU_FILE16 "Ouvre ce document"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_NEXT_PANE "Passe au volet de fenêtre suivant\nVolet suivant"
- ID_PREV_PANE "Revient au volet précédent\nVolet précédent"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_WINDOW_NEW "Ouvre une nouvelle fenêtre pour le document actif\nNouvelle fenêtre"
- ID_WINDOW_ARRANGE "Réorganise les icônes en bas de la fenêtre\nRéorganise les icônes"
- ID_WINDOW_CASCADE "Réorganise les fenêtres en cascade\nCascade"
- ID_WINDOW_TILE_HORZ "Réorganise les fenêtres en une mosaïque\nMosaïque"
- ID_WINDOW_TILE_VERT "Réorganise les fenêtres en une mosaïque\nMosaïque"
- ID_WINDOW_SPLIT "Fractionne la fenêtre active en deux volets\nFractionner"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_EDIT_CLEAR "Efface la sélection\nEffacer"
- ID_EDIT_CLEAR_ALL "Efface tout\nEffacer tout"
- ID_EDIT_COPY "Copie la sélection et la place dans le Presse-papiers\nCopier"
- ID_EDIT_CUT "Supprime la sélection et la place dans le Presse-papiers\nCopier"
- ID_EDIT_FIND "Recherche le texte spécifié\nRechercher"
- ID_EDIT_PASTE "Insère le contenu du Presse-papiers\nColler"
- ID_EDIT_REPEAT "Répète la dernière action\nRépéter"
- ID_EDIT_REPLACE "Remplace le texte spécifique par un texte différent\nRemplacer"
- ID_EDIT_SELECT_ALL "Sélectionne le document entier\nSélectionner tout"
- ID_EDIT_UNDO "Annule la dernière action\nAnnuler"
- ID_EDIT_REDO "Rétablit l'action précédemment annulée\nRétablir"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_VIEW_TOOLBAR "Affiche ou masque la barre d'outils\nBarre d'outils"
- ID_VIEW_STATUS_BAR "Affiche ou masque la barre d'état\nBarre d'état"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- AFX_IDS_SCSIZE "Change la taille de la fenêtre"
- AFX_IDS_SCMOVE "Change la position de la fenêtre"
- AFX_IDS_SCMINIMIZE "Réduit la fenêtre en icône"
- AFX_IDS_SCMAXIMIZE "Agrandit la fenêtre au format de l'écran"
- AFX_IDS_SCNEXTWINDOW "Passe à la fenêtre de document suivante"
- AFX_IDS_SCPREVWINDOW "Passe à la fenêtre de document précédente"
- AFX_IDS_SCCLOSE "Ferme la fenêtre active et propose l'enregistrement des documents"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- AFX_IDS_SCRESTORE "Restaure la fenêtre à sa taille d'origine"
- AFX_IDS_SCTASKLIST "Active la liste des tâches"
- AFX_IDS_MDICHILD "Active cette fenêtre"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- ID_RUN "Execute le programme CBot\nExecute (F5)"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- TX_TYPENAMES "les différents types"
- 1001 "Byte"
- 1002 "Short"
- 1003 "Char"
- 1004 "Int"
- 1005 "Long"
- 1006 "Real"
- 1007 "Double"
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
- 1008 "Boolean"
- 1009 "String"
- 1010 "Array"
- 1011 "Arraybody"
- 1012 "Pointer"
- 1013 "Nullpointer"
- 1014 "nop"
- 1015 "Class"
- 1016 "Intrinsic"
-END
-
-#endif // French (France) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// French (Switzerland) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRS)
-#ifdef _WIN32
-LANGUAGE LANG_FRENCH, SUBLANG_FRENCH_SWISS
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_CONSOLE DIALOG DISCARDABLE 0, 0, 401, 210
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "CBot Console"
-FONT 8, "MS Sans Serif"
-BEGIN
- LTEXT "Commande :",IDC_STATIC,7,177,40,8
- EDITTEXT IDC_EDIT2,7,189,329,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "Exécute",IDOK,344,189,50,14
- EDITTEXT IDC_EDIT1,7,7,387,167,ES_MULTILINE | ES_READONLY |
- ES_WANTRETURN | WS_VSCROLL
-END
-
-IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 177, 100
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Test performances"
-FONT 8, "MS Sans Serif"
-BEGIN
- LTEXT "Boucles par seconde",IDC_STATIC,7,9,68,8
- EDITTEXT IDC_EDIT1,111,7,51,14,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "Nombre de scripts",IDC_STATIC,7,55,58,8
- EDITTEXT IDC_EDIT2,111,52,40,14,ES_AUTOHSCROLL
- CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,152,52,
- 10,14
- COMBOBOX IDC_COMBO1,111,74,52,111,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
- LTEXT "Timer",IDC_STATIC,7,77,18,8
- LTEXT "Performance %",IDC_STATIC,7,28,48,8
- EDITTEXT IDC_EDIT3,111,25,51,14,ES_AUTOHSCROLL | ES_READONLY
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
- IDD_CONSOLE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 394
- TOPMARGIN, 7
- BOTTOMMARGIN, 203
- END
-
- IDD_DIALOG1, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 170
- TOPMARGIN, 7
- BOTTOMMARGIN, 93
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-#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
- "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
- "#define _AFX_NO_OLE_RESOURCES\r\n"
- "#define _AFX_NO_TRACKER_RESOURCES\r\n"
- "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
- "\r\n"
- "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
- "#ifdef _WIN32\r\n"
- "LANGUAGE 12, 1\r\n"
- "#pragma code_page(1252)\r\n"
- "#endif\r\n"
- "#include ""res\\TestCBot.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
- "#include ""l.fra\\afxres.rc"" // Standard components\r\n"
- "#endif\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog Info
-//
-
-IDD_DIALOG1 DLGINIT
-BEGIN
- IDC_COMBO1, 0x403, 2, 0
-0x0031,
- IDC_COMBO1, 0x403, 3, 0
-0x3031, "\000"
- IDC_COMBO1, 0x403, 4, 0
-0x3031, 0x0030,
- IDC_COMBO1, 0x403, 5, 0
-0x3031, 0x3030, "\000"
- 0
-END
-
-#endif // French (Switzerland) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#define _AFX_NO_SPLITTER_RESOURCES
-#define _AFX_NO_OLE_RESOURCES
-#define _AFX_NO_TRACKER_RESOURCES
-#define _AFX_NO_PROPERTY_RESOURCES
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
-#ifdef _WIN32
-LANGUAGE 12, 1
-#pragma code_page(1252)
-#endif
-#include "res\TestCBot.rc2" // non-Microsoft Visual C++ edited resources
-#include "l.fra\afxres.rc" // Standard components
-#endif
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/CBot/tests/TestCBot/TestCBotDoc.cpp b/src/CBot/tests/TestCBot/TestCBotDoc.cpp deleted file mode 100644 index 8880c57..0000000 --- a/src/CBot/tests/TestCBot/TestCBotDoc.cpp +++ /dev/null @@ -1,697 +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/.// TestCBotDoc.cpp : implementation of the CTestCBotDoc class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-#include "CBotConsoleDlg.h"
-#include "PerformDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc
-
-IMPLEMENT_DYNCREATE(CTestCBotDoc, CDocument)
-
-BEGIN_MESSAGE_MAP(CTestCBotDoc, CDocument)
- //{{AFX_MSG_MAP(CTestCBotDoc)
- ON_COMMAND(ID_RUN, OnRun)
- ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
- ON_COMMAND(ID_TEST, OnTest)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc construction/destruction
-
-static BOOL test = FALSE;
-
-
-CTestCBotDoc::CTestCBotDoc()
-{
- m_pEdit = NULL;
- m_pProg = NULL;
- m_bModified = FALSE;
-}
-
-CTestCBotDoc::~CTestCBotDoc()
-{
- delete m_pEdit;
- delete m_pProg;
-}
-
-BOOL CTestCBotDoc::OnNewDocument()
-{
- if (!CDocument::OnNewDocument())
- return FALSE;
-
- return TRUE;
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc serialization
-
-void CTestCBotDoc::Serialize(CArchive& ar)
-{
- if (ar.IsStoring())
- {
- m_pEdit->GetWindowText(m_DocText);
- int w = m_DocText.GetLength();
- ar.Write((LPCTSTR)m_DocText, w);
- }
- else
- {
- int r;
- char buf[10001];
-
- r = ar.Read(buf, 10000);
- buf[r] = 0;
- m_DocText = buf;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- if (!m_pProg->Compile(m_DocText, m_Liste, NULL))
- {
- delete m_pProg;
- m_pProg = NULL;
- }
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc diagnostics
-
-#ifdef _DEBUG
-void CTestCBotDoc::AssertValid() const
-{
- CDocument::AssertValid();
-}
-
-void CTestCBotDoc::Dump(CDumpContext& dc) const
-{
- CDocument::Dump(dc);
-}
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotDoc commands
-
-void CTestCBotDoc::OnRun()
-{
- OnFileSave();
-
- m_pEdit->GetWindowText(m_DocText);
-
- CString TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
-
- if (!m_pProg->Compile(m_DocText, m_Liste, NULL))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- if( m_Liste.GivSize() == 0 )
- {
- AfxMessageBox("Aucune fonction marquée \"extern\" !");
- return;
- }
-
- for ( int i = 0; i < m_Liste.GivSize(); i++ )
- {
- int start, stop;
- m_pProg->GetPosition(m_Liste[i], start, stop, GetPosNom, GetPosParam);
- m_Liste[i] = m_DocText.Mid( start, stop-start );
- }
-
- CBotConsoleDlg dlg;
- dlg.m_pListe = &m_Liste;
- dlg.m_pEditx = m_pEdit;
-
- dlg.DoModal(); // dialogue pour faire la console
-
- if ( dlg.m_code>0 )
- {
- CString TextError;
-
- TextError = m_pProg->GivErrorText( dlg.m_code );
-
- m_pEdit->SetSel( dlg.m_start, dlg.m_end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- AfxMessageBox(TextError);
- }
-
- m_pEdit->SetFocus();
-
- return;
-}
-
-
-void CTestCBotDoc::OnChangeEdit1()
-{
- SetModifiedFlag();
- m_bModified = TRUE;
-}
-
-BOOL CTestCBotDoc::Compile()
-{
- m_pEdit->GetWindowText(m_DocText);
-
- CString TextError;
- int code, start, end;
-
- if ( m_pProg == NULL ) m_pProg = new CBotProgram();
-
- char buffer[100];
- strcpy(buffer, "le pointeur à passer pour voir");
-
- if (m_bModified && !m_pProg->Compile(m_DocText, m_Liste, (void*)buffer))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- m_bModified = FALSE;
- return FALSE;
- }
-
- if ( m_pProg->GetPosition( "TheTest", start, end) )
- {
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
- }
-
- m_bModified = FALSE;
- return TRUE;
-}
-
-
-
-static int compt = 0;
-// routine retournant le "pointeur" à un autre object
-BOOL rRetObject( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- pResult->SetPointer( NULL );
- compt+=45671;
- if (compt&0x11) return TRUE;
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult cRetObject( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-BOOL roRadar( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
-{
- pResult->SetPointer( NULL );
- compt+=45671;
- if (compt&0x11) return TRUE;
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult coRadar( CBotVar* pThis, CBotVar* &pVar )
-{
- void* pUser = pThis->GivUserPtr();
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-BOOL rMove( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- if ( test < 12 )
- {
- test++;
- return FALSE;
- }
- return TRUE;
-}
-
-CBotTypResult cMove( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-BOOL rTurn( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- return TRUE;
-}
-
-CBotTypResult cTurn( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-BOOL rRadar( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- pResult->SetPointer( NULL );
-
- if ( pVar ) pVar->debug();
-
- compt+=45671;
- if (compt&0x11)
- {
- return FALSE; // TRUE;
- }
-
- CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
- pAutre->SetUserPtr( (void*)2 );
- pResult->SetPointer( pAutre );
-
- if (!pResult->IsElemOfClass("object"))
- return TRUE;
-
- delete pAutre;
- return TRUE;
-}
-
-CBotTypResult cRadar( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypPointer, "object");
-}
-
-// routine retournant le "pointeur" à un autre object
-BOOL rTEST( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- test = 1 ;
- if ( pVar == NULL ) return TRUE;
-
- test = pVar->GivValInt();
- if ( test == 5 )
- {
- pVar = pVar->GivNext();
- pVar->SetUserPtr( OBJECTDELETED );
- }
- return TRUE;
-}
-
-CBotTypResult cTEST( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( 0 );
-}
-
-// routine retournant le "pointeur" à un autre object
-BOOL rF( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
-{
- if ( pResult == NULL ) return TRUE;
- pResult->SetValInt(3);
- return TRUE;
-}
-
-CBotTypResult cF( CBotVar* &pVar, void* pUser )
-{
- return CBotTypResult( CBotTypFloat );
-}
-
-/////////////////////////////////////////////////////////////////
-
-// Compilation d'une procédure avec un "point".
-
-CBotTypResult cPoint(CBotVar* &var, void* user)
-{
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
-
- if ( var->GivType() <= CBotTypDouble )
- {
- var = var->GivNext();
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
- if ( var == 0 ) return CBotTypResult( CBotErrLowParam );
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
- return CBotTypResult( 0 );
- }
-
- if ( var->GivType() == CBotTypClass )
- {
- if ( !var->IsElemOfClass("point") ) return CBotTypResult( CBotErrBadParam );
- var = var->GivNext();
- return CBotTypResult( 0 );
- }
-
- return CBotTypResult( CBotErrBadParam );
-}
-
-// Donne un paramètre de type "point".
-#define UNIT 1
-
-
-CBotTypResult cSpace(CBotVar* &var, void* user)
-{
- CBotTypResult ret;
-
- if ( var == 0 ) return CBotTypResult( CBotTypIntrinsic, "point" );
- ret = cPoint(var, user);
- if ( !ret.Eq(0) ) return ret;
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var == 0 ) return CBotTypIntrinsic;
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult( CBotErrBadNum );
- var = var->GivNext();
-
- if ( var != 0 ) return CBotErrOverParam;
- return CBotTypResult( CBotTypIntrinsic, "point" );
-}
-
-// Instruction "space(center, rMin, rMax, dist)".
-
-BOOL rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
-{
- CBotVar* pSub;
- float rMin, rMax, dist;
-
- rMin = 5.0f*UNIT;
- rMax = 50.0f*UNIT;
- dist = 4.0f*UNIT;
-
- if ( var == 0 )
- {
-// center = pThis->RetPosition(0);
- }
- else
- {
- if ( var != 0 )
- {
- rMin = var->GivValFloat()*UNIT;
- var = var->GivNext();
-
- if ( var != 0 )
- {
- rMax = var->GivValFloat()*UNIT;
- var = var->GivNext();
-
- if ( var != 0 )
- {
- dist = var->GivValFloat()*UNIT;
- var = var->GivNext();
- }
- }
- }
- }
-
- if ( result != 0 )
- {
- pSub = result->GivItemList();
- if ( pSub != 0 )
- {
- pSub->SetValFloat(1);
- pSub = pSub->GivNext(); // "y"
- pSub->SetValFloat(2);
- pSub = pSub->GivNext(); // "z"
-// pSub->SetValFloat(3);
- }
- }
- return TRUE;
-}
-//////////////////////////////////////////////////////////////
-
-
-void CTestCBotDoc::OnTest()
-{
- CBotProgram::DefineNum("WingedGrabber", 1);
- CBotProgram::DefineNum("TrackedGrabber", 2);
- CBotProgram::DefineNum("WheeledGrabber", 3);
- CBotProgram::DefineNum("LeggedGrabber", 4);
- CBotProgram::DefineNum("WingedShooter", 5);
- CBotProgram::DefineNum("TrackedShooter", 6);
- CBotProgram::DefineNum("WheeledShooter", 7);
- CBotProgram::DefineNum("LeggedShooter", 8);
- CBotProgram::DefineNum("WingedOrgaShooter", 9);
- CBotProgram::DefineNum("TrackedOrgaShooter", 10);
- CBotProgram::DefineNum("WheeledOrgaShooter", 11);
- CBotProgram::DefineNum("LeggedOrgaShooter", 12);
- CBotProgram::DefineNum("WingedSniffer", 13);
- CBotProgram::DefineNum("TrackedSniffer", 14);
- CBotProgram::DefineNum("WheeledSniffer", 14);
- CBotProgram::DefineNum("LeggedSniffer", 15);
- CBotProgram::DefineNum("Thumper", 16);
- CBotProgram::DefineNum("PhazerShooter", 17);
- CBotProgram::DefineNum("Recycler", 18);
- CBotProgram::DefineNum("Shielder", 19);
- CBotProgram::DefineNum("Subber", 20);
- CBotProgram::DefineNum("Me", 21);
-
- CBotProgram::DefineNum("TypeMarkPath", 111);
-
- OnFileSave();
-
-// CPerformDlg dlg;
-// dlg.m_Script = m_DocText;
-// dlg.DoModal();
-
- // défini la routine RetObject
- CBotProgram::AddFunction( "Radar", rRetObject, cRetObject );
-
- // ajoute une routine pour cette classe
- CBotProgram::AddFunction("Space", rSpace, cSpace);
-
- // défini la routine Test
- CBotProgram::AddFunction( "TEST", rTEST, cTEST );
- CBotProgram::AddFunction( "F", rF, cF );
-
- CBotProgram::AddFunction( "goto", rMove, cMove );
- CBotProgram::AddFunction( "fire", rTurn, cTurn );
- CBotProgram::AddFunction( "radar", rRadar, cRadar );
-
- // crée une instance de la classe "Bot" pour ce robot
- CBotVar* pThisRobot = CBotVar::Create( "", CBotTypResult(CBotTypClass, "object") );
- pThisRobot->SetUserPtr( (void*)1 );
- pThisRobot->SetIdent( 1234 );
-
- delete m_pProg;
- // crée un objet programme associé à cette instance
- m_pProg = new CBotProgram(pThisRobot);
-
- // compile le programme
- CString TextError;
- int code, start, end;
-
- m_pEdit->GetWindowText(m_DocText);
- if (!m_pProg->Compile(m_DocText, m_Liste, (void*) 44))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- delete pThisRobot;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- // exécute pour voir
- m_pProg->Start(m_Liste[0]);
-
- int mode = -1;
-
- if ( mode >= 0 ) {
-
- // sauve et restore à chaque pas possible
- while (!m_pProg->Run(NULL, 1))
- {
- const char* FunctionName;
- int start1, end1;
- m_pProg->GetRunPos(FunctionName, start1, end1);
- if ( end1 <= 0 )
- m_pProg->GetRunPos(FunctionName, start1, end1);
- m_pEdit->SetSel(start1, end1);
-
-if ( mode == 0 ) continue;
-
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- CBotClass::SaveStaticState(pf);
- m_pProg->SaveState(pf);
- fClose(pf);
-
-if ( mode == 2 ) if (!m_pProg->Compile(m_DocText, m_Liste, (void*) 44))
- {
- m_pProg->GetError(code, start, end);
- delete m_pProg;
- m_pProg = NULL;
-
- delete pThisRobot;
-
- m_pEdit->SetSel( start, end );
- m_pEdit->SetFocus(); // met en évidence la partie avec problème
-
- TextError = CBotProgram::GivErrorText( code );
- AfxMessageBox( TextError );
-
- m_pEdit->SetFocus();
- return;
- }
-
- pf = fOpen( "TEST.CBO", "rb" );
- CBotClass::RestoreStaticState(pf);
- m_pProg->RestoreState(pf);
- fClose(pf);
-
- int start2, end2;
- m_pProg->GetRunPos(FunctionName, start2, end2);
- if ( end2 <= 0 )
- m_pProg->GetRunPos(FunctionName, start2, end2);
-
- if ( start1 != start2 || end1 != end2 )
- m_pProg->GetRunPos(FunctionName, start2, end2);
- m_pEdit->SetSel(start2, end2);
- }
-
- if (m_pProg->GetError(code, start, end))
- {
- m_pEdit->SetSel(start, end);
- TextError = CBotProgram::GivErrorText(code);
- AfxMessageBox(TextError);
- }
- return;}
-
- while (!m_pProg->Run(NULL, 0))
- {
- const char* FunctionName;
- int start, end;
- m_pProg->GetRunPos(FunctionName, start, end);
- m_pEdit->SetSel(start, end);
-
- if ( FunctionName == NULL ) continue;
- CString info (FunctionName);
- CString sep (":\n");
-
- int level = 0;
- const char* Name;
- while ( TRUE )
- {
- CBotVar* pVar = m_pProg->GivStackVars(Name, level--);
- if ( Name != FunctionName ) break;
- if ( pVar == NULL ) continue;
-// pVar->Maj(NULL, FALSE);
- while ( pVar != NULL )
- {
- info += sep;
- info += pVar->GivName() + CBotString(" = ") + pVar->GivValString();
- sep = ", ";
- pVar = pVar->GivNext();
- }
- sep = "\n";
- }
- if ( IDOK != AfxMessageBox(info, MB_OKCANCEL) ) break;
-
- if ( test == 1 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- m_pProg->SaveState(pf);
- fClose(pf);
- }
-
- if ( test == 2 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "rb" );
- m_pProg->RestoreState(pf);
- fClose(pf);
- }
-
- if ( test == 12 )
- {
- test = 0;
- FILE* pf;
- pf = fOpen( "TEST.CBO", "wb" );
- m_pProg->SaveState(pf);
- fClose(pf);
-
- pf = fOpen( "TEST.CBO", "rb" );
- m_pProg->RestoreState(pf);
- fClose(pf);
-
- test = 13;
- }
- }
-
- if (m_pProg->GetError(code, start, end))
- {
- m_pEdit->SetSel(start, end);
- TextError = CBotProgram::GivErrorText(code);
- AfxMessageBox(TextError);
- }
-
- delete pThisRobot;
-}
-
diff --git a/src/CBot/tests/TestCBot/TestCBotDoc.h b/src/CBot/tests/TestCBot/TestCBotDoc.h deleted file mode 100644 index 548607f..0000000 --- a/src/CBot/tests/TestCBot/TestCBotDoc.h +++ /dev/null @@ -1,78 +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/.// TestCBotDoc.h : interface of the CTestCBotDoc class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-
-class CTestCBotDoc : public CDocument
-{
-protected: // create from serialization only
- CTestCBotDoc();
- DECLARE_DYNCREATE(CTestCBotDoc)
-
-// Attributes
-public:
- CEdit* m_pEdit; // pour mémoriser le texte, et l'afficher
- CBotProgram* m_pProg; // le programme compilé
- CString m_DocText;
- CBotStringArray m_Liste;
- BOOL m_bModified;
-
-// Operations
-public:
- BOOL Compile();
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotDoc)
- public:
- virtual BOOL OnNewDocument();
- virtual void Serialize(CArchive& ar);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CTestCBotDoc();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected:
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CTestCBotDoc)
- afx_msg void OnRun();
- afx_msg void OnChangeEdit1();
- afx_msg void OnTest();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOTDOC_H__4D1BB90B_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/TestCBotView.cpp b/src/CBot/tests/TestCBot/TestCBotView.cpp deleted file mode 100644 index bca3c56..0000000 --- a/src/CBot/tests/TestCBot/TestCBotView.cpp +++ /dev/null @@ -1,142 +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/.
-
-// TestCBotView.cpp : implementation of the CTestCBotView class
-//
-
-#include "stdafx.h"
-#include "TestCBot.h"
-
-#include "TestCBotDoc.h"
-#include "TestCBotView.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView
-
-IMPLEMENT_DYNCREATE(CTestCBotView, CView)
-
-BEGIN_MESSAGE_MAP(CTestCBotView, CView)
- //{{AFX_MSG_MAP(CTestCBotView)
- ON_WM_SIZE()
- ON_MESSAGE(WM_ACTWINDOW, ActWindow)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView construction/destruction
-
-CTestCBotView::CTestCBotView()
-{
-}
-
-CTestCBotView::~CTestCBotView()
-{
-}
-
-BOOL CTestCBotView::PreCreateWindow(CREATESTRUCT& cs)
-{
- return CView::PreCreateWindow(cs);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView drawing
-
-void CTestCBotView::OnDraw(CDC* pDC)
-{
- CTestCBotDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView diagnostics
-
-#ifdef _DEBUG
-void CTestCBotView::AssertValid() const
-{
- CView::AssertValid();
-}
-
-void CTestCBotView::Dump(CDumpContext& dc) const
-{
- CView::Dump(dc);
-}
-
-CTestCBotDoc* CTestCBotView::GetDocument() // non-debug version is inline
-{
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestCBotDoc)));
- return (CTestCBotDoc*)m_pDocument;
-}
-#endif //_DEBUG
-
-/////////////////////////////////////////////////////////////////////////////
-// CTestCBotView message handlers
-
-void CTestCBotView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
-{
- CTestCBotDoc* pDoc = GetDocument();
-// CTestCBotApp* pApp = (CTestCBotApp*)AfxGetApp();
-
- if ( pDoc->m_pEdit == NULL)
- {
- pDoc->m_pEdit = new CEdit();
- CRect rect;
- GetClientRect( rect );
-
- pDoc->m_pEdit->Create( WS_VISIBLE|WS_BORDER|WS_TABSTOP|ES_MULTILINE|ES_WANTRETURN|ES_NOHIDESEL|ES_AUTOVSCROLL,
- rect, this, IDC_EDIT1 );
- pDoc->m_pEdit->SetTabStops(12);
- pDoc->m_pEdit->SetWindowText(pDoc->m_DocText);
- }
-
- if ( !bActivate && !pDoc->Compile() )
- {
-// comment faire pour réactiver l'ancien document
- }
-
- CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
-
- if ( bActivate ) pDoc->m_pEdit->SetFocus();
-}
-
-
-void CTestCBotView::OnSize(UINT nType, int cx, int cy)
-{
- CView::OnSize(nType, cx, cy);
-
- CTestCBotDoc* pDoc = GetDocument();
- if ( pDoc->m_pEdit != NULL )
- {
- CRect rect;
- GetClientRect( rect );
- pDoc->m_pEdit->MoveWindow( rect );
- pDoc->m_pEdit->SetFocus();
- }
-}
-
-
-
-LONG CTestCBotView::ActWindow(UINT wparam, LONG lparam)
-{
-// GetParentFrame()->SetActiveView( this, TRUE );
-// CMDIChildWnd::OnMDIActivate(1, this, this)
- return 0;
-}
diff --git a/src/CBot/tests/TestCBot/TestCBotView.h b/src/CBot/tests/TestCBot/TestCBotView.h deleted file mode 100644 index 065ee08..0000000 --- a/src/CBot/tests/TestCBot/TestCBotView.h +++ /dev/null @@ -1,78 +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/.// TestCBotView.h : interface of the CTestCBotView class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#if !defined(AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_)
-#define AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_
-
-#if _MSC_VER >= 1000
-#pragma once
-#endif // _MSC_VER >= 1000
-
-class CTestCBotView : public CView
-{
-protected: // create from serialization only
- CTestCBotView();
- DECLARE_DYNCREATE(CTestCBotView)
-
-// Attributes
-public:
- CTestCBotDoc* GetDocument();
-
-// Operations
-public:
-
-// Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CTestCBotView)
- public:
- virtual void OnDraw(CDC* pDC); // overridden to draw this view
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- protected:
- virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
- //}}AFX_VIRTUAL
-
-// Implementation
-public:
- virtual ~CTestCBotView();
-#ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
-#endif
-
-protected:
-
-// Generated message map functions
-protected:
- //{{AFX_MSG(CTestCBotView)
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg LONG ActWindow(UINT wparam, LONG lparam) ;
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-#ifndef _DEBUG // debug version in TestCBotView.cpp
-inline CTestCBotDoc* CTestCBotView::GetDocument()
- { return (CTestCBotDoc*)m_pDocument; }
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_TESTCBOTVIEW_H__4D1BB90D_8E74_11D4_A439_00D059085115__INCLUDED_)
diff --git a/src/CBot/tests/TestCBot/a§1.txt~ b/src/CBot/tests/TestCBot/a§1.txt~ deleted file mode 100644 index 0c57950..0000000 --- a/src/CBot/tests/TestCBot/a§1.txt~ +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/TestCBot/res/TestCBot.ico b/src/CBot/tests/TestCBot/res/TestCBot.ico Binary files differdeleted file mode 100644 index 06a649d..0000000 --- a/src/CBot/tests/TestCBot/res/TestCBot.ico +++ /dev/null diff --git a/src/CBot/tests/TestCBot/res/TestCBot.rc2 b/src/CBot/tests/TestCBot/res/TestCBot.rc2 deleted file mode 100644 index b55f0d9..0000000 --- a/src/CBot/tests/TestCBot/res/TestCBot.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -//
-// TESTCBOT.RC2 - resources Microsoft Visual C++ does not edit directly
-//
-
-#ifdef APSTUDIO_INVOKED
- #error this file is not editable by Microsoft Visual C++
-#endif //APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/src/CBot/tests/TestCBot/res/TestCBotDoc.ico b/src/CBot/tests/TestCBot/res/TestCBotDoc.ico Binary files differdeleted file mode 100644 index 3545614..0000000 --- a/src/CBot/tests/TestCBot/res/TestCBotDoc.ico +++ /dev/null diff --git a/src/CBot/tests/TestCBot/res/Toolbar.bmp b/src/CBot/tests/TestCBot/res/Toolbar.bmp Binary files differdeleted file mode 100644 index 04a71af..0000000 --- a/src/CBot/tests/TestCBot/res/Toolbar.bmp +++ /dev/null diff --git a/src/CBot/tests/TestCBot/resource.h b/src/CBot/tests/TestCBot/resource.h deleted file mode 100644 index d661201..0000000 --- a/src/CBot/tests/TestCBot/resource.h +++ /dev/null @@ -1,44 +0,0 @@ -// * This file is part of the COLOBOT source code
-// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU General Public License as published by
-// * the Free Software Foundation, either version 3 of the License, or
-// * (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// * GNU General Public License for more details.
-// *
-// * You should have received a copy of the GNU General Public License
-// * along with this program. If not, see http://www.gnu.org/licenses/.//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by TestCBot.rc
-//
-#define IDD_ABOUTBOX 100
-#define IDR_MAINFRAME 128
-#define IDR_TESTCBTYPE 129
-#define IDD_DIALOG1 130
-#define IDD_CONSOLE 131
-#define IDD_DIALOG2 133
-#define IDC_EDIT1 1000
-#define TX_TYPENAMES 1000
-#define IDC_SPIN1 1001
-#define IDC_EDIT2 1002
-#define IDC_COMBO1 1003
-#define IDC_EDIT3 1004
-#define ID_RUN 32771
-#define ID_TEST 32772
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_3D_CONTROLS 1
-#define _APS_NEXT_RESOURCE_VALUE 135
-#define _APS_NEXT_COMMAND_VALUE 32773
-#define _APS_NEXT_CONTROL_VALUE 1004
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/CBot/tests/TestCBot/xTestCBot.clw b/src/CBot/tests/TestCBot/xTestCBot.clw deleted file mode 100644 index 5b84c16..0000000 --- a/src/CBot/tests/TestCBot/xTestCBot.clw +++ /dev/null @@ -1,245 +0,0 @@ -; CLW file contains information for the MFC ClassWizard
-
-[General Info]
-Version=1
-LastClass=CBotConsoleDlg
-LastTemplate=CDialog
-NewFileInclude1=#include "stdafx.h"
-NewFileInclude2=#include "TestCBot.h"
-LastPage=0
-
-ClassCount=7
-Class1=CTestCBotApp
-Class2=CTestCBotDoc
-Class3=CTestCBotView
-Class4=CMainFrame
-
-ResourceCount=7
-Resource1=IDD_ABOUTBOX
-Resource2=IDR_MAINFRAME
-Resource3=IDR_TESTCBTYPE
-Class5=CAboutDlg
-Class6=CChildFrame
-Resource4=IDD_ABOUTBOX (French (France))
-Resource5=IDR_TESTCBTYPE (French (France))
-Resource6=IDD_CONSOLE
-Class7=CBotConsoleDlg
-Resource7=IDR_MAINFRAME (French (France))
-
-[CLS:CTestCBotApp]
-Type=0
-HeaderFile=TestCBot.h
-ImplementationFile=TestCBot.cpp
-Filter=N
-
-[CLS:CTestCBotDoc]
-Type=0
-HeaderFile=TestCBotDoc.h
-ImplementationFile=TestCBotDoc.cpp
-Filter=N
-BaseClass=CDocument
-VirtualFilter=DC
-LastObject=IDC_EDIT2
-
-[CLS:CTestCBotView]
-Type=0
-HeaderFile=TestCBotView.h
-ImplementationFile=TestCBotView.cpp
-Filter=C
-BaseClass=CView
-VirtualFilter=VWC
-LastObject=CTestCBotView
-
-[CLS:CMainFrame]
-Type=0
-HeaderFile=MainFrm.h
-ImplementationFile=MainFrm.cpp
-Filter=T
-BaseClass=CMDIFrameWnd
-VirtualFilter=fWC
-LastObject=CMainFrame
-
-
-[CLS:CChildFrame]
-Type=0
-HeaderFile=ChildFrm.h
-ImplementationFile=ChildFrm.cpp
-Filter=M
-
-[CLS:CAboutDlg]
-Type=0
-HeaderFile=TestCBot.cpp
-ImplementationFile=TestCBot.cpp
-Filter=D
-
-[DLG:IDD_ABOUTBOX]
-Type=1
-ControlCount=4
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308352
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-Class=CAboutDlg
-
-[MNU:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-Command3=ID_FILE_MRU_FILE1
-
-[TB:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-CommandCount=8
-Command8=ID_APP_ABOUT
-
-[MNU:IDR_TESTCBTYPE]
-Type=1
-Class=CTestCBotView
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-CommandCount=18
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-
-[ACL:IDR_MAINFRAME]
-Type=1
-Class=CMainFrame
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command5=ID_EDIT_CUT
-Command6=ID_EDIT_COPY
-Command7=ID_EDIT_PASTE
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_NEXT_PANE
-CommandCount=13
-Command4=ID_EDIT_UNDO
-Command13=ID_PREV_PANE
-
-
-[TB:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_SAVE
-Command4=ID_EDIT_CUT
-Command5=ID_EDIT_COPY
-Command6=ID_EDIT_PASTE
-Command7=ID_FILE_PRINT
-Command8=ID_RUN
-Command9=ID_APP_ABOUT
-CommandCount=9
-
-[MNU:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_MRU_FILE1
-Command4=ID_APP_EXIT
-Command5=ID_VIEW_TOOLBAR
-Command6=ID_VIEW_STATUS_BAR
-Command7=ID_APP_ABOUT
-CommandCount=7
-
-[MNU:IDR_TESTCBTYPE (French (France))]
-Type=1
-Class=?
-Command1=ID_FILE_NEW
-Command2=ID_FILE_OPEN
-Command3=ID_FILE_CLOSE
-Command4=ID_FILE_SAVE
-Command5=ID_FILE_SAVE_AS
-Command6=ID_FILE_MRU_FILE1
-Command7=ID_APP_EXIT
-Command8=ID_EDIT_UNDO
-Command9=ID_EDIT_CUT
-Command10=ID_EDIT_COPY
-Command11=ID_EDIT_PASTE
-Command12=ID_VIEW_TOOLBAR
-Command13=ID_VIEW_STATUS_BAR
-Command14=ID_WINDOW_NEW
-Command15=ID_WINDOW_CASCADE
-Command16=ID_WINDOW_TILE_HORZ
-Command17=ID_WINDOW_ARRANGE
-Command18=ID_APP_ABOUT
-CommandCount=18
-
-[ACL:IDR_MAINFRAME (French (France))]
-Type=1
-Class=?
-Command1=ID_EDIT_COPY
-Command2=ID_FILE_NEW
-Command3=ID_FILE_OPEN
-Command4=ID_FILE_SAVE
-Command5=ID_EDIT_PASTE
-Command6=ID_EDIT_UNDO
-Command7=ID_EDIT_CUT
-Command8=ID_RUN
-Command9=ID_NEXT_PANE
-Command10=ID_PREV_PANE
-Command11=ID_RUN
-Command12=ID_EDIT_COPY
-Command13=ID_EDIT_PASTE
-Command14=ID_EDIT_CUT
-Command15=ID_EDIT_UNDO
-CommandCount=15
-
-[DLG:IDD_ABOUTBOX (French (France))]
-Type=1
-Class=CAboutDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342177283
-Control2=IDC_STATIC,static,1342308480
-Control3=IDC_STATIC,static,1342308352
-Control4=IDOK,button,1342373889
-
-[DLG:IDD_CONSOLE]
-Type=1
-Class=CBotConsoleDlg
-ControlCount=4
-Control1=IDC_STATIC,static,1342308352
-Control2=IDC_EDIT2,edit,1350631552
-Control3=IDOK,button,1342242817
-Control4=IDC_EDIT1,edit,1352734724
-
-[CLS:CBotConsoleDlg]
-Type=0
-HeaderFile=CBotConsoleDlg.h
-ImplementationFile=CBotConsoleDlg.cpp
-BaseClass=CDialog
-Filter=D
-VirtualFilter=dWC
-
diff --git a/src/CBot/tests/scenarios/B.txt b/src/CBot/tests/scenarios/B.txt deleted file mode 100644 index 53715f8..0000000 --- a/src/CBot/tests/scenarios/B.txt +++ /dev/null @@ -1,18 +0,0 @@ -
- float [ ] TEST2 ( int [ ] param )
- {
- float [ ] z;
- for ( int i = 0 ; i < sizeof( param ) ; i++ ) try { z [i] = param [i] / 3; }
- return z;
- }
-
-extern public void T()
-{
- int a [4];
- for ( int i = 0 ; i < 3 ; i++ ) a[i] = 4*i;
- a [2] = 22;
-
- float [] b ;
- b = TEST2 ( a ) ;
- show ( a, b );
-}
diff --git a/src/CBot/tests/scenarios/BUG2.txt b/src/CBot/tests/scenarios/BUG2.txt deleted file mode 100644 index 44de05a..0000000 --- a/src/CBot/tests/scenarios/BUG2.txt +++ /dev/null @@ -1,107 +0,0 @@ -object object :: TT ( int n )
-{
- object XX = radar();
- if ( n == 0 ) return null;
-
- while ( null == XX ) XX = radar();
- return XX;
-}
-
-extern void object::Attack( )
-{
- show ( TT ( 0 ) ) ;
- show ( TT ( 1 ) ) ;
- return;
-
- int list[];
- int i;
- object p;
- float dist, prox;
- point dest;
- boolean advance = true;
-
- TEST(0); // ne stoppe pas si erreur
-// while ( F () != 0 ) F(1);
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
- list[i++] = 3333;
- list[i++] = 3334;
- list[i++] = 3335;
- list[i++] = 3336;
- list[i++] = 3337;
- list[i++] = 3338;
- list[i++] = 3339;
- list[i++] = 3331;
- list[i++] = 3332;
- list[i++] = 3330;
- list[i++] = 1111;
- list[i++] = 1112;
-
- F(F(0));
-
- while ( true )
- {
- p = radar(list, 0, 360, 0, 1000);
- if ( p == null )
- {
- F(2);
- }
- else
- {
- dist = F(p.position, position);
- if ( dist <= 40 && !advance )
- {
- fire(p.position);
- advance = true;
- }
- else
- {
-//? if ( RetBaseDistance() > 20 )
- {
- prox = dist-(5+F()*5);
- if ( prox < 5 ) prox = 5;
- dest.x = (position.x-p.position.x)*prox/dist + p.position.x;
- dest.y = (position.y-p.position.y)*prox/dist + p.position.y;
- dest.z = (position.z-p.position.z)*prox/dist + p.position.z;
- goto(dest);
- advance = false;
- }
- }
- }
- }
-}
-
-// Calcule la distance jusqu'à la base.
-
-float object::RetBaseDistance()
-{
- object p;
- float dist;
-
- p = radar(4444, 0, 360, 0, 1000);
- if ( p == null ) return 1000;
- dist = F(p.position, position);
- return dist;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/Deleted.txt b/src/CBot/tests/scenarios/Deleted.txt deleted file mode 100644 index 469a624..0000000 --- a/src/CBot/tests/scenarios/Deleted.txt +++ /dev/null @@ -1,23 +0,0 @@ -public extern void object :: ESSAI()
-{
- while(true)
- {
- if ( true )
- {
- goto(12);
- break;
- }
- }
- object x = null ;
-
- while ( x == null ) x = radar();
-
- show ( x.position ) ;
-
- TEST(5, x);
-
- if ( x == null ) show ( "DELETED" );
-
- show ( x.position ) ;
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/MaClass.txt b/src/CBot/tests/scenarios/MaClass.txt deleted file mode 100644 index ac472b4..0000000 --- a/src/CBot/tests/scenarios/MaClass.txt +++ /dev/null @@ -1,16 +0,0 @@ -
-class MaClass
-{
- int a = 1 ;
- MaClass pointeur ;
- MaClass next = null ;
- CPoint autre = new CPoint( 1 , 1 ) ;
-}
-
-extern public void Test ( )
-{
- MaClass x () ;
- x.next = new MaClass ( ) ;
- println ( x ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/Mc2.txt b/src/CBot/tests/scenarios/Mc2.txt deleted file mode 100644 index 172c259..0000000 --- a/src/CBot/tests/scenarios/Mc2.txt +++ /dev/null @@ -1,4 +0,0 @@ -class MaClass
-{
- int t = 12;
-}
diff --git a/src/CBot/tests/scenarios/Mon fichier.txt b/src/CBot/tests/scenarios/Mon fichier.txt deleted file mode 100644 index 6b35bf8..0000000 --- a/src/CBot/tests/scenarios/Mon fichier.txt +++ /dev/null @@ -1,2 +0,0 @@ -Voici encore du texte
-et une seconde ligne
diff --git a/src/CBot/tests/scenarios/Nop.txt b/src/CBot/tests/scenarios/Nop.txt deleted file mode 100644 index 6a66f6f..0000000 --- a/src/CBot/tests/scenarios/Nop.txt +++ /dev/null @@ -1,4 +0,0 @@ -public extern void Nop()
-{
- while ( true ) {}
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/POS.txt b/src/CBot/tests/scenarios/POS.txt deleted file mode 100644 index 688e4fb..0000000 --- a/src/CBot/tests/scenarios/POS.txt +++ /dev/null @@ -1,14 +0,0 @@ -void object :: T ( )
-{
- show ( position ) ;
-}
-
-public extern void object :: POS()
-{
- for ( int i = 0; i < 10 ; i++ )
- {
- if ( i == 2 ) TEST ( 12 ) ;
-// show ( position );
- T ( ) ;
- }
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/T.txt b/src/CBot/tests/scenarios/T.txt deleted file mode 100644 index 50a792b..0000000 --- a/src/CBot/tests/scenarios/T.txt +++ /dev/null @@ -1,4 +0,0 @@ -public extern int T ( float n )
-{
- return n * 1.1;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TESTALL.txt b/src/CBot/tests/scenarios/TESTALL.txt deleted file mode 100644 index 82247a0..0000000 --- a/src/CBot/tests/scenarios/TESTALL.txt +++ /dev/null @@ -1,161 +0,0 @@ -int T ( int z )
-{
- return 45 + z ;
-}
-
-class toto
-{
- int val = 3 ;
- int x = 3 * 3 ;
- void toto( int n )
- { val = n + 3 ; }
- int retval ( int param )
- { int r = val + param + x ;
- val = param ;
- return r ; }
-}
-
-public extern void object :: Chose( )
-{
- int z [ 6 ];
- for ( int i = 0 ; i < 6 ; ) z [ i++ ] = 3 - i ;
- show ( z ) ;
- return;
-
- // test des tableaux
- int [ ] a [ 3 ] ;
-// a = null;
- if ( a == null ) show ( "NULL" );
-
- a [ 2 / 2 ] [ 2 ]= 5 ;
- int [ ] b ; b = a [1] ;
- b [ 0 ] = -4;
- a [ 4 / 2 ] [ 1 ]= 1 ;
- show ( a , b ) ;
- return ;
- {
- toto chose = new toto (5 ) ;
- toto truc = chose ;
- show ( chose, chose.retval( 100 ) ,
- truc, truc.retval (40 ) ) ;
-
- return;
- }
- {
- point A = new
- point ( 4 * 4 , 2 ) ;
- show ( A ) ;
- return;
- }
- {
- show ( T ( 1 ) , T ( 3.7 ) ) ;
- return;
- }
-
- {
- point A ( 3, 4 ) ,
- B = A ;
-
- int n = -4;
- show ( n );
-
- show ( A, B ) ;
-
- boolean a = false;
- boolean b = a or true;
- if ( not a and b ) ;
- return;
- }
- {
- // test try
- float x = nan ; int z = 0 ;
- try {
-// throw ( 3 * 4 + 33 ) ;
- int zz ; goto ( 12 ) ; z = 1 ; z = 0 / 0 ; z = 2 ;
- }
- catch ( 45 + 0 * 6000 )
- {
- show( "Exception 6000", z ) ;
- }
- catch ( x == 0 ) { show( "x nul" ) ; }
- finally { show ( "fini" ) ; }
- show ( "continue" );
- return;
- }
- {
- // test des if
- int a = 3;
- if ( a == 3 ) show ( "33");
- else show ( "44");
- if ( a != 3 ) show ( "333");
- else show ( "444");
- return;
- }
- {
- int a = 0;
- // test break
-un:
- while ( true )
- {
-deux:
- while ( true )
- {
- a++;
- if ( a == 2 ) continue;
- if ( a == 3 ) break deux;
- show ( a ) ;
- if ( a == 5 ) break un;
- }
- show ( "DEUX" );
- }
- return;
- }
- {
- // test switch
- int a = 0;
-
- switch ( a )
- {
- case 1 : show( "un" ) ; break;
- case 2 : show( "deux" ) ; // break;
- case 3 : show( "trois" ) ; break;
- case 4 : show( "quatre" ) ; // break;
- default : show( "par défaut" ) ;
- }
- return;
- }
- {
- // test boucle while
- float z = 3.3;
- while ( z > 0 )
- { show ( z-- ) ; }
- return;
- }
-
- {
- // test boucle do
- float y = 3.3;
- do { int x = 0; show(y); y++; } while ( y < 7 ) ;
- return;
- }
- // test boucle for
- int j = -7; show ( j );
- for ( int ii = 3, j = 31; ii < 6 ; ++ii, j = j -3 )
- {
- j = 10 * j;
- show ( ii, j );
- }
- return;
-{
- // déclarations de variables
- int a; int b = 3; int c = 4*b, d = 1, e;
- float x; float y = 3.3; float z = y / 2, u = 1, v;
- boolean t; boolean tt = true or false; boolean ttt = false, tttt = true, t5;
- string s; string ss = "hello"; string s2 = ss + " plus", s3 = "s3", s4;
-
- show( b, c, d );
- show( y, z, u );
- show( tt, ttt, tttt );
- show( ss, s2, s3 );
-}
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestCB1.txt b/src/CBot/tests/scenarios/TestCB1.txt deleted file mode 100644 index 516db47..0000000 --- a/src/CBot/tests/scenarios/TestCB1.txt +++ /dev/null @@ -1,18 +0,0 @@ -extern public void toto()
-{
- print( "hello" ) ;
- print( fac(5) );
- print( t() ) ;
-}
-
-public int fac(int n)
-{
- if ( n<2 ) return 1;
- return n * fac(n-1);
-}
-
-point t()
-{
- point a(1,2);
- return a;
-}
diff --git a/src/CBot/tests/scenarios/TestCBot1.txt b/src/CBot/tests/scenarios/TestCBot1.txt deleted file mode 100644 index d27b4f8..0000000 --- a/src/CBot/tests/scenarios/TestCBot1.txt +++ /dev/null @@ -1,27 +0,0 @@ -
-class CPoint2
-{
- float x, y;
- void CPoint2(float x, float y)
- {
- this.x = x;
- this.y = y;
- }
-}
-
-public extern void T ( )
-{
- CPoint2 X( 12, 33 ), Y ( -4, 4/3 );
- print ( X, Y ) ;
-}
-
-public extern void Hello ( )
-
-{
- println ( "Hello" );
-}
-
-public extern void test ( int n )
-{
- for ( int i = n; i>0 ; i--) print (i);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestCBot3.txt b/src/CBot/tests/scenarios/TestCBot3.txt deleted file mode 100644 index b915f96..0000000 --- a/src/CBot/tests/scenarios/TestCBot3.txt +++ /dev/null @@ -1,24 +0,0 @@ -public extern void Test ()
-{
- for ( int x = 100000; x>0 ; x-- ) { }
-}
-
-float MaRoutine( CPoint A, CPoint B )
-{
- A.x -= B.x ; // distance en x
- A.y -= B.y ; // distance en y
- A.x *= A.x; // carré de la distance
- A.y += A.y; // carré de la distance
- println ( A, B ) ;
- return ( A.x + A.y ) ;
-}
-
-public extern void TestAB ( )
-{
- CPoint A(3, 5) ;
- CPoint B(4, -2);
- println ( A, B ) ;
- MaRoutine( A, B ) ;
- println ( A, B ) ;
-}
-
diff --git a/src/CBot/tests/scenarios/TestNull.txt b/src/CBot/tests/scenarios/TestNull.txt deleted file mode 100644 index f447245..0000000 --- a/src/CBot/tests/scenarios/TestNull.txt +++ /dev/null @@ -1,15 +0,0 @@ -extern public void TestNull ()
-{
- CPoint pointeur = null;
-
- try {
- pointeur.x = 4; }
- catch ( 6007 ) {}
-
- pointeur = new CPoint(1,2);
-
- print ( pointeur.x, pointeur.y,
- pointeur );
-
- pointeur.x = 5;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestRestoreState.txt b/src/CBot/tests/scenarios/TestRestoreState.txt deleted file mode 100644 index 1e49e37..0000000 --- a/src/CBot/tests/scenarios/TestRestoreState.txt +++ /dev/null @@ -1,67 +0,0 @@ -// routine de Daniel qui plante après RestoreState
-
-extern void object::Attack( )
-{
- int list[], i;
- object p;
- float dist, prox;
- point nav1, nav2, dest;
- boolean advance = true;
-
- i = 0;
- list[i++] = WingedGrabber;
- list[i++] = TrackedGrabber;
- list[i++] = WheeledGrabber;
- list[i++] = LeggedGrabber;
- list[i++] = WingedShooter;
- list[i++] = TrackedShooter;
- list[i++] = WheeledShooter;
- list[i++] = LeggedShooter;
- list[i++] = WingedOrgaShooter;
- list[i++] = TrackedOrgaShooter;
- list[i++] = WheeledOrgaShooter;
- list[i++] = LeggedOrgaShooter;
- list[i++] = WingedSniffer;
- list[i++] = TrackedSniffer;
- list[i++] = WheeledSniffer;
- list[i++] = LeggedSniffer;
- list[i++] = Thumper;
- list[i++] = PhazerShooter;
- list[i++] = Recycler;
- list[i++] = Shielder;
- list[i++] = Subber;
- list[i++] = Me;
-
- nav1.x = 1;//cmdline(0);
- nav1.y = 1;//cmdline(1);
- nav2.x = 2;//cmdline(2);
- nav2.y = 2;//cmdline(3);
-
- while ( true )
- {
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point A
- goto(nav1);
-
- while ( true )
- {
- // ennemi à proximité ?
- p = radar(list, 0, 360, 0, 40);
- if ( p == null ) break;
- // lui tire dessus
- fire(p.position);
- }
-
- // se promène vers le point B
- goto(nav2);
- }
-}
-
diff --git a/src/CBot/tests/scenarios/TestStatic.txt b/src/CBot/tests/scenarios/TestStatic.txt deleted file mode 100644 index f501aa5..0000000 --- a/src/CBot/tests/scenarios/TestStatic.txt +++ /dev/null @@ -1,31 +0,0 @@ -class ESSAI
-{
- int x = 0;
- static int nb = 3;
- static int [ ] array ;
-
- void Put( int val)
- {
-show(nb);
- array[ nb ] = val;
-// this.nb++;
- this.nb = this.nb + 1;
-show(nb, array);
- }
- int Get( )
- {
- nb--;
-show("out", nb, array);
- return array[ nb ] ;
- }
-}
-
-extern public void T()
-{
- ESSAI t1 ( ) ;
- ESSAI t2 ( ) ;
- t1.nb++;
- t1.Put( 11 ); t1.Put( 12 ); t2.Put( 13 );
-
- show ( t1.Get(), t2.Get(), t2.Get() ) ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/TestStr.txt b/src/CBot/tests/scenarios/TestStr.txt deleted file mode 100644 index 683ec1b..0000000 --- a/src/CBot/tests/scenarios/TestStr.txt +++ /dev/null @@ -1,17 +0,0 @@ -extern public void TSTR()
-{
- string s = "C'est un essai";
-
- print ( s, strlen(s), strleft(s, 3), strright(s,3), strmid(s, 2), strmid(s,2,3), strfind(s, "un"), strfind(s, "sdgfld") );
-
- show ( strupper(s), strlower(s) );
-
- s = "123.45" ;
- print ( strval(s) );
-
-
- string sub = strright("abcdef", 2); // sub vaut "ef###", # étant un caractère bizarre quelconque
- show (sub);
- int pos = strfind("abcdef", "xy"); // pos vaut -1. Pourquoi pas nan ?
- show(pos);
-}
diff --git a/src/CBot/tests/scenarios/Z.txt b/src/CBot/tests/scenarios/Z.txt deleted file mode 100644 index 714119b..0000000 --- a/src/CBot/tests/scenarios/Z.txt +++ /dev/null @@ -1,14 +0,0 @@ -public extern void tp()
-{
- int a [4], b[];
- a [ 0 ] = 8 ;
-
- b = T ( a ) ;
- show ( a, b );
-}
-
-int[] T ( int[] Z )
-{
- for ( int i = 0; i < 4 ; i++ ) Z[ i ] = i * i ;
- return Z;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/a1.txt b/src/CBot/tests/scenarios/a1.txt deleted file mode 100644 index 165bc95..0000000 --- a/src/CBot/tests/scenarios/a1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist) -{ - int i; - object pr, r; - float mindist; - - i = 0; - mindist = 1000; - while (i<30) - { - pr = radar(i); - if (pr != null) - { - - if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3) - { - mindist = distance(orig, pr.position); - r = pr; - } - } - i = i+1; - } - if (mindist < dist) return(r); else return(null); -} - - -class Guepe -{ - - point pos; - - - void cherche(point orig, float dist) - { - object p; - point o; - - p = radarGuepe(orig, dist); - while (p == null) - { - wait(0.1); - p = radarGuepe(orig, dist); - } - - pos.x = p.position.x; - pos.y = p.position.y; - pos.z = p.position.z; - - //o = p.position; - //wait(0.1); - - //vitessex = (p.position.x - o.x)/0.1; - //vitessey = (p.position.y - o.y)/0.1; - //vitessez = (p.position.z - o.z)/0.1; - - } - - - void tire(point orig, float orient) - { - //float t = 3; //temps d'anticipation - float angle; - point cible; - - cible.x = pos.x;// + t*vitessex; - cible.y = pos.y;// + t*vitessey; - cible.z = pos.z;// + t*vitessez; - - if (cible.x == 0) angle = 90; else - angle = atan(cible.y / cible.x); - if (cible.x < 0) angle = angle + 180; - angle = angle - orient; - if (angle > 180) angle = angle - 360; - if (angle < -180) angle = angle + 360; - turn(angle); - - angle = atan((cible.z-orig.z) / distance2d(orig, cible)); - aim(angle); - - fire(0.1); - - } -} - -extern void object::Fourmi6() -{ - //fps(1000); - Guepe guepe = new Guepe(); - - while (true) - { - guepe.cherche(position, 50); - - guepe.tire(position, orientation); - } -} diff --git a/src/CBot/tests/scenarios/array.txt b/src/CBot/tests/scenarios/array.txt deleted file mode 100644 index 081b60e..0000000 --- a/src/CBot/tests/scenarios/array.txt +++ /dev/null @@ -1,24 +0,0 @@ -
-public extern void TestTableau ()
-{
- int tableau [ 12 ] ;
-
- point array[ 12 ] [ 14 ] ;
-
- point zéro ( 1, 2 ) ;
- point a = zéro ;
-
- for ( int i = 0 ; i < 10 ; i++ ) array[ i ] [ i ]= zéro ;
-
- array[ 5 ] [3 ] . x =1.5 ;
-
- array[ 2 ] [ 2 ] . y = array[ 5 ] [ 5 ] . x ;
-
- array[ 4 ] = array [ 2 ] ;
-
- for ( int i = 0 ; i < 10 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) println ( i, j, array [ i ] [ j ] ) ;
-
- show( zéro, a, array );
-
-}
-
diff --git a/src/CBot/tests/scenarios/až1.txt b/src/CBot/tests/scenarios/až1.txt deleted file mode 100644 index 165bc95..0000000 --- a/src/CBot/tests/scenarios/až1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist) -{ - int i; - object pr, r; - float mindist; - - i = 0; - mindist = 1000; - while (i<30) - { - pr = radar(i); - if (pr != null) - { - - if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3) - { - mindist = distance(orig, pr.position); - r = pr; - } - } - i = i+1; - } - if (mindist < dist) return(r); else return(null); -} - - -class Guepe -{ - - point pos; - - - void cherche(point orig, float dist) - { - object p; - point o; - - p = radarGuepe(orig, dist); - while (p == null) - { - wait(0.1); - p = radarGuepe(orig, dist); - } - - pos.x = p.position.x; - pos.y = p.position.y; - pos.z = p.position.z; - - //o = p.position; - //wait(0.1); - - //vitessex = (p.position.x - o.x)/0.1; - //vitessey = (p.position.y - o.y)/0.1; - //vitessez = (p.position.z - o.z)/0.1; - - } - - - void tire(point orig, float orient) - { - //float t = 3; //temps d'anticipation - float angle; - point cible; - - cible.x = pos.x;// + t*vitessex; - cible.y = pos.y;// + t*vitessey; - cible.z = pos.z;// + t*vitessez; - - if (cible.x == 0) angle = 90; else - angle = atan(cible.y / cible.x); - if (cible.x < 0) angle = angle + 180; - angle = angle - orient; - if (angle > 180) angle = angle - 360; - if (angle < -180) angle = angle + 360; - turn(angle); - - angle = atan((cible.z-orig.z) / distance2d(orig, cible)); - aim(angle); - - fire(0.1); - - } -} - -extern void object::Fourmi6() -{ - //fps(1000); - Guepe guepe = new Guepe(); - - while (true) - { - guepe.cherche(position, 50); - - guepe.tire(position, orientation); - } -} diff --git a/src/CBot/tests/scenarios/a§1.txt b/src/CBot/tests/scenarios/a§1.txt deleted file mode 100644 index 0c57950..0000000 --- a/src/CBot/tests/scenarios/a§1.txt +++ /dev/null @@ -1,96 +0,0 @@ -object radarGuepe(point orig, float dist)
-{
- int i;
- object pr, r;
- float mindist;
-
- i = 0;
- mindist = 1000;
- while (i<30)
- {
- pr = radar(i);
- if (pr != null)
- {
-
- if (F(orig, pr.position) < mindist and pr.category == AlienWasp and pr.altitude > 3)
- {
- mindist = distance(orig, pr.position);
- r = pr;
- }
- }
- i = i+1;
- }
- if (mindist < dist) return(r); else return(null);
-}
-
-
-class Guepe
-{
-
- point pos;
-
-
- void cherche(point orig, float dist)
- {
- object p;
- point o;
-
- p = radarGuepe(orig, dist);
- while (p == null)
- {
- wait(0.1);
- p = radarGuepe(orig, dist);
- }
-
- pos.x = p.position.x;
- pos.y = p.position.y;
- pos.z = p.position.z;
-
- //o = p.position;
- //wait(0.1);
-
- //vitessex = (p.position.x - o.x)/0.1;
- //vitessey = (p.position.y - o.y)/0.1;
- //vitessez = (p.position.z - o.z)/0.1;
-
- }
-
-
- void tire(point orig, float orient)
- {
- //float t = 3; //temps d'anticipation
- float angle;
- point cible;
-
- cible.x = pos.x;// + t*vitessex;
- cible.y = pos.y;// + t*vitessey;
- cible.z = pos.z;// + t*vitessez;
-
- if (cible.x == 0) angle = 90; else
- angle = atan(cible.y / cible.x);
- if (cible.x < 0) angle = angle + 180;
- angle = angle - orient;
- if (angle > 180) angle = angle - 360;
- if (angle < -180) angle = angle + 360;
- turn(angle);
-
- angle = atan((cible.z-orig.z) / distance2d(orig, cible));
- aim(angle);
-
- fire(0.1);
-
- }
-}
-
-extern void object::Fourmi6()
-{
- //fps(1000);
- Guepe guepe = new Guepe();
-
- while (true)
- {
- guepe.cherche(position, 50);
-
- guepe.tire(position, orientation);
- }
-}
diff --git a/src/CBot/tests/scenarios/bug.txt b/src/CBot/tests/scenarios/bug.txt deleted file mode 100644 index 4ec6eb3..0000000 --- a/src/CBot/tests/scenarios/bug.txt +++ /dev/null @@ -1,12 +0,0 @@ -public extern void object::Bug()
-{
- point a;
- a = position;
- TEST();
- float d=dist(a, position);
-}
-
-float dist(point a, point b)
-{
- return a.x-b.x;
-}
diff --git a/src/CBot/tests/scenarios/bugmw.txt b/src/CBot/tests/scenarios/bugmw.txt deleted file mode 100644 index 284ee43..0000000 --- a/src/CBot/tests/scenarios/bugmw.txt +++ /dev/null @@ -1,9 +0,0 @@ -extern public void main()
-{
- show(fact(30)) ;
-}
-
-public int fact(int n)
-{
- return (fact(n-1)*n) ;
-}
diff --git a/src/CBot/tests/scenarios/ccc.txt b/src/CBot/tests/scenarios/ccc.txt deleted file mode 100644 index dbcd1d5..0000000 --- a/src/CBot/tests/scenarios/ccc.txt +++ /dev/null @@ -1,8 +0,0 @@ -public extern void ccc()
-{
- int a;
- a = 0 ;
-
- if ( a == 0 );
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/enum.txt b/src/CBot/tests/scenarios/enum.txt deleted file mode 100644 index a592a7f..0000000 --- a/src/CBot/tests/scenarios/enum.txt +++ /dev/null @@ -1,9 +0,0 @@ -
-enum JourDeLaSemaine {
- lundi = 1,
- mardi,
- mercredi,
- jeudi,
- vendredi,
- samedi,
- dimanche = 0 }
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/fibo.txt b/src/CBot/tests/scenarios/fibo.txt deleted file mode 100644 index 88f5357..0000000 --- a/src/CBot/tests/scenarios/fibo.txt +++ /dev/null @@ -1,25 +0,0 @@ -
-extern public int Fibo( int n, boolean b )
-{
- if ( n < 2 ) return n;
- int a = Fibo(n-1, b) + Fibo(n-2, false);
- if ( b ) print (n + "=" + a);
- return a;
-}
-
-extern public void t()
-{
- Fibo( 23, true);
-}
-
-extern public void tt()
-{
- t();
-}
-
-// cette routine n'est évidemment pas du tout obtimisée
-// c'est même un très mauvais exemple de programmation récursive
-
-// pour un test de durée, Fibo(23, true) prend
-// en mode Debug 67 secondes
-// en mode Release 8 secondes
diff --git a/src/CBot/tests/scenarios/file.txt b/src/CBot/tests/scenarios/file.txt deleted file mode 100644 index 2a22dd9..0000000 --- a/src/CBot/tests/scenarios/file.txt +++ /dev/null @@ -1,70 +0,0 @@ -class CLASS22
-{
- static int nb = 2;
- void T22 ( ) { nb = nb / 0 ; }
-}
-
-public extern void object :: TEST()
-{
- switch ( 1 )
- {
- case 1:
- {
- file h();
- h.open("Mon Fichier.txt", "r");
-show ( h.filename, h.handle );
-h.filename = "xx";
-h.handle = 1 ;
- h.readln();
- h.close();
- }
- case 2:
- {
- file h("Mon Fichier.txt");
- h.open("r");
- h.readln();
- h.close();
- }
- case 3:
- {
- file h("Mon Fichier.txt", "r");
- h.readln();
- h.close();
- }
- case 4:
- {
- file h();
- h.filename = "Mon Fichier.txt";
- h.open("r");
- h.readln();
- h.close();
- }
- case 5:
- {
- file h = fileopen( "Mon 2Fichier.txt", "r" );
- h.readln();
- h.close();
- }
- }
-{
- file h( ) ;
- h.filename = "Test.h";
- h.open ( "r" );
-
-
- file pf ( "Mon Fichier.txt" ) ;
- pf . open ( "w" ) ;
- pf . writeln ( "Voici encore du texte" ) ;
- pf . writeln ( "et une seconde ligne" ) ;
- pf . close( );
-
- pf . open ( "r" ) ;
-
- while ( not pf . eof( ) )
- {
- string s = pf . readln ( );
- show ( s );
- }
- pf.close( );
-}
-}
diff --git a/src/CBot/tests/scenarios/h.txt b/src/CBot/tests/scenarios/h.txt deleted file mode 100644 index c395319..0000000 --- a/src/CBot/tests/scenarios/h.txt +++ /dev/null @@ -1,5 +0,0 @@ -void tf()
-{
- file h;
- h.handle += 1 ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/include.txt b/src/CBot/tests/scenarios/include.txt deleted file mode 100644 index e8f8cc9..0000000 --- a/src/CBot/tests/scenarios/include.txt +++ /dev/null @@ -1,27 +0,0 @@ -class Z
-{
- static int x = 0;
- private int y;
-
- void T( )
- {
- // autorisé ici
- y = x ;
- this.y = this.x ;
- x = y ;
- this.x = this.y ;
- }
-}
-
-extern public void test()
-{
- Z a();
- 3 * a.x; // autorisé
-//vu 3 * a.y; // interdit
-//vu a.y = 3; // interdit ici
- a.x = 1; // autorisé
-
- show ( a );
- a.T();
- show ( a );
-}
diff --git a/src/CBot/tests/scenarios/intrinsic.txt b/src/CBot/tests/scenarios/intrinsic.txt deleted file mode 100644 index f215791..0000000 --- a/src/CBot/tests/scenarios/intrinsic.txt +++ /dev/null @@ -1,16 +0,0 @@ -public extern void TestIntrinsic()
-{
- point a ( 1, 2 );
- print (a);
-
- a.x = 3;
- a.y = 4;
-
- point b = a;
-
- println ( b.x, b.y, b ) ;
- if ( b == a ) b.y = 0;
- println (a,b);
- if ( b != a ) b.y = a.y;
- println(a,b);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/methode1.txt b/src/CBot/tests/scenarios/methode1.txt deleted file mode 100644 index 080bba2..0000000 --- a/src/CBot/tests/scenarios/methode1.txt +++ /dev/null @@ -1,57 +0,0 @@ -class t {
- point p;
-}
-
-void object :: toto()
-{
- show ( Position ) ;
-}
-
-extern public void object :: XX()
-{
- int test [];
- test [ 9999 ] = 3;
-
- toto () ;
-/*
- Radar();
-
- object test ;
- test = this. Radar();
-
- do {
- test = this.Radar();
- } while ( test == null );
-
-/*
- t test [ 4 ];
- for ( int i = 0 ; i < 4 ; i++ ) test [ i ] = new t();
- test [ 3 ] .p.x = 2;
- show ( test );
-/*
- int a = nan;
- show ( a ) ;
-
- a = TypeMarkPath;
- show ( a, a++, --a ) ;
-
- if ( a != nan ) a += 1 ;
-
- a = TypeMarkPath;
- float q = a ;
- show ( a, q ) ;
-
-return;
-
- a += ++a;
- show ( a ) ;
-
- boolean i = false;
-
- if ( i == true ) {}
-
- object p;
- if ( p == null) { p = p ; }
-*/
-}
-
diff --git a/src/CBot/tests/scenarios/methode2.txt b/src/CBot/tests/scenarios/methode2.txt deleted file mode 100644 index 76ce7f4..0000000 --- a/src/CBot/tests/scenarios/methode2.txt +++ /dev/null @@ -1,50 +0,0 @@ -
-extern void Toto()
-{
- TEST(12);
-
- for ( int i = 0 ; i<1000; i++)
- {
- int j = 1;
- if (i==55) TEST(12);
- }
-
- TEST(2);
-
-
-// Nouveau();
- int toto[4];
- point Z[3];
-
- Z[1].x = 11; Z[1].y = 12;
-
- toto[2] = 12;
- toto[1] = nan;
-
-// point test, autre(2,3) ;
-// object titi = Radar();
-
- TEST ( 1 ) ;
-
- toto[0] = 11;
-
- TEST ( 2 ) ;
-
- toto[6] = 0;
-}
-
-extern void object::Nouveau()
-{
- point a;
- a = np(Position);
-}
-
-point np(point b)
-{
- point c;
- c.x = b.y;
- c.y = b.x;
- return c ;
-}
-
-
diff --git a/src/CBot/tests/scenarios/mp1.txt b/src/CBot/tests/scenarios/mp1.txt deleted file mode 100644 index 599cfc4..0000000 --- a/src/CBot/tests/scenarios/mp1.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe =new Guepet();
-
- guepe.init();
-
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mp2.txt b/src/CBot/tests/scenarios/mp2.txt deleted file mode 100644 index 1c2972c..0000000 --- a/src/CBot/tests/scenarios/mp2.txt +++ /dev/null @@ -1,28 +0,0 @@ -class Guepet
-{
-
- float a;
- float b;
-
- void init()
- {
- a = 12.34;
- b = 56.78;
-
- object x = radar(123);
- show("radar "+x.position.x);
- show("C'est fait");
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show("test "+guepe.a+" "+guepe.b);
-
-}
diff --git a/src/CBot/tests/scenarios/mw.txt b/src/CBot/tests/scenarios/mw.txt deleted file mode 100644 index c237670..0000000 --- a/src/CBot/tests/scenarios/mw.txt +++ /dev/null @@ -1,16 +0,0 @@ -extern public void main()
-{
-// goto( 3, 4 );
-
- while( true )
- {
- try { goto (12) ; }
- catch( FF( ) )
- { show( "ko"); }
- }
-}
-
-boolean FF()
-{
- return false;
-}
diff --git a/src/CBot/tests/scenarios/null.txt b/src/CBot/tests/scenarios/null.txt deleted file mode 100644 index ae76b74..0000000 --- a/src/CBot/tests/scenarios/null.txt +++ /dev/null @@ -1,5 +0,0 @@ -extern public void xxx ()
-{
- CPoint test = null ;
- if ( test == null ) show ( "NULL" );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/opnew.txt b/src/CBot/tests/scenarios/opnew.txt deleted file mode 100644 index 7d6838c..0000000 --- a/src/CBot/tests/scenarios/opnew.txt +++ /dev/null @@ -1,20 +0,0 @@ -extern public void xx ()
-{
- CPoint pointeur, test = null ;
- pointeur = new CPoint ( 3, 4 );
-
- if ( test == null ) show ( "NULL" );
-
- CPoint pp = pointeur;
-
-show( pointeur , pp );
-
- pp.x = 33.3;
- if ( pointeur.x != pp.x ) 0/0;
-
- pp = new CPoint();
-// pointeur = pp;
-
-show( pointeur , pp );
-
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/plante.txt b/src/CBot/tests/scenarios/plante.txt deleted file mode 100644 index 363461b..0000000 --- a/src/CBot/tests/scenarios/plante.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Guepet
-{
-
- point pos;
- float t = 0.1;
-
- void init()
- {
- pos.x = 12.123;
- pos.y = 34.345;
-
- F(t);
- }
-
-
-}
-
-extern void object::Fourmi6()
-{
- Guepet guepe=new Guepet();
-
- guepe.init();
-
- show ( guepe );
-}
diff --git a/src/CBot/tests/scenarios/pointer.txt b/src/CBot/tests/scenarios/pointer.txt deleted file mode 100644 index 2d4d907..0000000 --- a/src/CBot/tests/scenarios/pointer.txt +++ /dev/null @@ -1,41 +0,0 @@ -extern public void x ()
-{
- show ( 3 ** 4 );
- float z = 1e-3;
- show ( z );
-
- CPoint b ( 4,5 );
- show ( b );
-
- CPoint a ( ) ;
- a.x = 21; a.y = 12;
- show ( a ) ;
-
- CPoint test = new CPoint ( 1,1 );
- test = new CPoint ( 2, 2 );
- show ( test );
-}
-
-// crée un objet et retourne son pointeur
-CPoint newcpoint()
-{
- CPoint p = new CPoint ( 3, 3 );
- return p;
-}
-
-extern public void y ()
-{
- CPoint test = newcpoint();
- println ( test );
- dontmodif( test );
- println ( test );
-}
-
-// ne doit pas modifier l'objet en paramètre
-void dontmodif ( CPoint pp )
-{
- pp.x = 5;
- pp.y = 2;
- println ( pp, pp.x, pp.y );
-}
-
diff --git a/src/CBot/tests/scenarios/postinc.txt b/src/CBot/tests/scenarios/postinc.txt deleted file mode 100644 index cdf6ab5..0000000 --- a/src/CBot/tests/scenarios/postinc.txt +++ /dev/null @@ -1,7 +0,0 @@ -extern public void X()
-{
- point A [ ] ;
- A[5] = new point (2,3);
- int val = A[5].x++ + --A[5].y;
- show ( A, val );
-}
diff --git a/src/CBot/tests/scenarios/radar.txt b/src/CBot/tests/scenarios/radar.txt deleted file mode 100644 index 09d84a2..0000000 --- a/src/CBot/tests/scenarios/radar.txt +++ /dev/null @@ -1,39 +0,0 @@ -extern void object::Bug( )
-{
- try{ int a = 44 ; a = 12 / 0 ; }
- catch(6000) { int b = 4 ; }
- finally { int z = 1 ; }
-
-// tp ( A, B );
-
-/* int a = 4, b = 2, c = nan;
- float x, y = 3/2, z = nan;
- boolean i, j = false, k = true;
-
- string s, ss = "xyz";
-
- while ( false )
- {
- object left, right;
-
- left = Radar(TypeMarkPath, -45, 120, 100);
- right = Radar(TypeMarkPath, 45, 120, 100);
-
- if ( left == null && right == null )
- {
- }
- }
- int t = fact ( 4 ) ;*/
-}
-
-void tp( point a , point b )
-{
- a.x += b.x;
-}
-
-
-int fact( int n )
-{
- if ( n < 2 ) return n;
- return n * fact ( n - 1 ) ;
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/solution.txt b/src/CBot/tests/scenarios/solution.txt deleted file mode 100644 index f78cf12..0000000 --- a/src/CBot/tests/scenarios/solution.txt +++ /dev/null @@ -1,13 +0,0 @@ -extern void object::Solution( )
-{
-show ( "Solution " + Position );
- Carré(15);
- Carré(25);
-}
-
-void object::Carré(float côté)
-{
-show ( "Carré " + Position );
- Move(côté);
- Turn(-90);
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/test.txt b/src/CBot/tests/scenarios/test.txt deleted file mode 100644 index 0693994..0000000 --- a/src/CBot/tests/scenarios/test.txt +++ /dev/null @@ -1,8 +0,0 @@ -extern public void x()
-{
- float a= 1, b = 2;
- a = b * ( 2 + 2 );
- print (a);
- a += 4;
- print (a);
-}
diff --git a/src/CBot/tests/scenarios/test23.txt b/src/CBot/tests/scenarios/test23.txt deleted file mode 100644 index d6e1ddd..0000000 --- a/src/CBot/tests/scenarios/test23.txt +++ /dev/null @@ -1,10 +0,0 @@ -extern public void object::TEST23()
-{
- CLASS22 T;
- T.T22( ) ;
-
- show( position );
- show( this.position );
-
-// T22();
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/testmw.txt b/src/CBot/tests/scenarios/testmw.txt deleted file mode 100644 index 6570f6d..0000000 --- a/src/CBot/tests/scenarios/testmw.txt +++ /dev/null @@ -1,14 +0,0 @@ -extern public int testmw( int a)
-{
- boolean b = true ;
-
- if (b)
- return 1 ;
- else
- return a ; 0 * testmw(a-1) ;
-}
-
-public int Fibo2 ( int n )
-{
- print ( " bof " );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/this.txt b/src/CBot/tests/scenarios/this.txt deleted file mode 100644 index b8a9e04..0000000 --- a/src/CBot/tests/scenarios/this.txt +++ /dev/null @@ -1,13 +0,0 @@ -extern void object :: TEST22 ( )
-{
- show( position );
- show( this.position );
-
- T();
-}
-
-public void object :: T22()
-{
- show( position );
- show( this.position );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/tt.txt b/src/CBot/tests/scenarios/tt.txt deleted file mode 100644 index cd13c9d..0000000 --- a/src/CBot/tests/scenarios/tt.txt +++ /dev/null @@ -1,12 +0,0 @@ -extern public void T() { T1(); }
-
-public void T1()
-{
- show( "T1" );
- T2();
-}
-
-public void T2()
-{
- show( "T2" );
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/tt2.txt b/src/CBot/tests/scenarios/tt2.txt deleted file mode 100644 index ad9dc1d..0000000 --- a/src/CBot/tests/scenarios/tt2.txt +++ /dev/null @@ -1,5 +0,0 @@ -extern public void TT()
-{
- T1();
- T2();
-}
\ No newline at end of file diff --git a/src/CBot/tests/scenarios/vide.txt b/src/CBot/tests/scenarios/vide.txt deleted file mode 100644 index e69de29..0000000 --- a/src/CBot/tests/scenarios/vide.txt +++ /dev/null diff --git a/src/CBot/tests/scenarios/zz.txt b/src/CBot/tests/scenarios/zz.txt deleted file mode 100644 index da764ac..0000000 --- a/src/CBot/tests/scenarios/zz.txt +++ /dev/null @@ -1,6 +0,0 @@ -extern public void zz()
-{
- MaClass TOTO ();
-
- show (TOTO);
-}
\ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 238b8ba..e6b3acd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,14 +14,6 @@ add_subdirectory(po) add_subdirectory(desktop) -# Tests -if(${TESTS}) - add_subdirectory(common/test) - add_subdirectory(graphics/engine/test) - add_subdirectory(ui/test) - add_subdirectory(math/test) -endif() - # Optional libraries set(OPTIONAL_LIBS "") diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt deleted file mode 100644 index 70dac1f..0000000 --- a/src/common/test/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -include_directories( -. -../.. -../../.. -${GTEST_INCLUDE_DIR} -) - - -add_executable(image_test ../image.cpp image_test.cpp) -target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES}) - -#add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp) -#target_link_libraries(profile_test gtest ${Boost_LIBRARIES}) - -#add_test(profile_test ./profile_test) diff --git a/src/common/test/colobot.ini b/src/common/test/colobot.ini deleted file mode 100644 index 2ca37ee..0000000 --- a/src/common/test/colobot.ini +++ /dev/null @@ -1,15 +0,0 @@ -[test_float] -float_value=1.5 - -[test_string] -string_value=Hello world - -[test_int] -int_value=42 - -[test_multi] -entry1=1 -entry2=2 -entry3=3 -entry4=4 -entry5=5 diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp deleted file mode 100644 index 09ae4c6..0000000 --- a/src/common/test/image_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "../image.h" - -#include <SDL/SDL.h> -#include <stdio.h> - -/* For now, just a simple test: loading a file from image - * and saving it to another in PNG. */ - -int main(int argc, char *argv[]) -{ - if (argc != 3) - { - printf("Usage: %s in_image out_image\n", argv[0]); - return 0; - } - - CImage image; - - if (! image.Load(argv[1])) - { - std::string err = image.GetError(); - printf("Error loading '%s': %s\n", argv[1], err.c_str()); - return 1; - } - Gfx::Color color; - std::string str; - - color = image.GetPixel(Math::IntPoint(0, 0)); - str = color.ToString(); - printf("pixel @ (0,0): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(0, 1)); - str = color.ToString(); - printf("pixel @ (0,1): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(1, 0)); - str = color.ToString(); - printf("pixel @ (1,0): %s\n", str.c_str()); - - color = image.GetPixel(Math::IntPoint(1, 1)); - str = color.ToString(); - printf("pixel @ (1,1): %s\n", str.c_str()); - - image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f)); - image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f)); - image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)); - image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f)); - - if (! image.SavePNG(argv[2])) - { - std::string err = image.GetError(); - printf("Error saving PNG '%s': %s\n", argv[2], err.c_str()); - return 2; - } - - return 0; -} diff --git a/src/common/test/profile_test.cpp b/src/common/test/profile_test.cpp deleted file mode 100644 index 6236083..0000000 --- a/src/common/test/profile_test.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "../profile.h" -#include "../logger.h" - -#include <iostream> -#include <string> -#include <vector> -#include <gtest/gtest.h> - - -class CProfileTest : public testing::Test -{ -protected: - CLogger m_logger; - CProfile m_profile; - -}; - -TEST_F(CProfileTest, ReadTest) -{ - ASSERT_TRUE(m_profile.InitCurrentDirectory()); // load colobot.ini file - - std::string result; - ASSERT_TRUE(m_profile.GetLocalProfileString("test_string", "string_value", result)); - ASSERT_STREQ("Hello world", result.c_str()); - - int int_value; - ASSERT_TRUE(m_profile.GetLocalProfileInt("test_int", "int_value", int_value)); - ASSERT_EQ(42, int_value); - - float float_value; - ASSERT_TRUE(m_profile.GetLocalProfileFloat("test_float", "float_value", float_value)); - ASSERT_FLOAT_EQ(1.5, float_value); - - std::vector<std::string> list; - list = m_profile.GetLocalProfileSection("test_multi", "entry"); - ASSERT_EQ(5u, list.size()); -} - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/src/graphics/opengl/test/CMakeLists.txt b/src/graphics/opengl/test/CMakeLists.txt deleted file mode 100644 index 79e0ba5..0000000 --- a/src/graphics/opengl/test/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -find_package(OpenGL REQUIRED) -find_package(SDL REQUIRED) -find_package(SDL_image REQUIRED) -find_package(PNG REQUIRED) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -set(ADD_LIBS "") - -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(PLATFORM_WINDOWS 1) - set(PLATFORM_LINUX 0) - set(PLATFORM_OTHER 0) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(PLATFORM_WINDOWS 0) - set(PLATFORM_LINUX 1) - set(PLATFORM_OTHER 0) - set(ADD_LIBS "-lrt") -else() - set(PLATFORM_WINDOWS 0) - set(PLATFORM_LINUX 0) - set(PLATFORM_OTHER 1) -endif() - -configure_file(../../../common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h) - - -set(TEXTURE_SOURCES -../gldevice.cpp -../../../common/logger.cpp -../../../common/image.cpp -texture_test.cpp -) - -set(MODEL_SOURCES -../gldevice.cpp -../../engine/modelfile.cpp -../../../common/logger.cpp -../../../common/image.cpp -../../../common/iman.cpp -../../../common/stringutils.cpp -../../../app/system.cpp -model_test.cpp -) - -set(TRANSFORM_SOURCES -../gldevice.cpp -../../../common/logger.cpp -../../../common/image.cpp -../../../common/iman.cpp -../../../app/system.cpp -transform_test.cpp -) - -set(LIGHT_SOURCES -../gldevice.cpp -../../../common/logger.cpp -../../../common/image.cpp -../../../common/iman.cpp -../../../app/system.cpp -light_test.cpp -) - -include_directories(../../../ ${CMAKE_CURRENT_BINARY_DIR}) - -set(LIBS -${SDL_LIBRARY} -${SDLIMAGE_LIBRARY} -${OPENGL_LIBRARY} -${PNG_LIBRARIES} -${ADD_LIBS} -) - -add_executable(texture_test ${TEXTURE_SOURCES}) -target_link_libraries(texture_test ${LIBS}) - -# Temporarily disabling because of dependencies on CEngine et al. -#add_executable(model_test ${MODEL_SOURCES}) -#target_link_libraries(model_test ${LIBS}) - -add_executable(transform_test ${TRANSFORM_SOURCES}) -target_link_libraries(transform_test ${LIBS}) - -add_executable(light_test ${LIGHT_SOURCES}) -target_link_libraries(light_test ${LIBS}) diff --git a/src/graphics/opengl/test/README.txt b/src/graphics/opengl/test/README.txt deleted file mode 100644 index c618415..0000000 --- a/src/graphics/opengl/test/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -Test programs for OpenGL engine: - - texture_test -> multitexturing test with 2 textures (included as files: ./tex1.png, ./tex2.png) - - model_test -> simple model viewer to test model loading - usage: ./model_test {dxf|mod} model_file - second argument is the loaded format (DXF or Colobot .mod files) - requires ./tex folder (or symlink) with Colobot textures - viewer is controlled from keyboard - the bindings can be found in code - - transform_test -> simple "walk around" test for world & view transformations - - light test -> test for lighting diff --git a/src/graphics/opengl/test/light_test.cpp b/src/graphics/opengl/test/light_test.cpp deleted file mode 100644 index b19ba4b..0000000 --- a/src/graphics/opengl/test/light_test.cpp +++ /dev/null @@ -1,462 +0,0 @@ -#include "app/system.h" -#include "common/logger.h" -#include "common/image.h" -#include "common/iman.h" -#include "graphics/opengl/gldevice.h" -#include "math/geometry.h" - -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include <unistd.h> - -#include <iostream> -#include <map> - -enum KeySlots -{ - K_Forward, - K_Back, - K_Left, - K_Right, - K_Up, - K_Down, - K_Count -}; -bool KEYMAP[K_Count] = { false }; - -Math::Point MOUSE_POS_BASE; - -Math::Vector TRANSLATION(0.0f, 2.0f, 0.0f); -Math::Vector ROTATION, ROTATION_BASE; - -float CUBE_ORBIT = 0.0f; - -const int FRAME_DELAY = 5000; - -SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL; - -void Init(Gfx::CGLDevice *device) -{ - device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true); - device->SetShadeModel(Gfx::SHADE_SMOOTH); -} - -void Render(Gfx::CGLDevice *device) -{ - device->BeginScene(); - - /* Unlit part of scene */ - - device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, false); - device->SetRenderState(Gfx::RENDER_STATE_CULLING, false); // Double-sided drawing - - Math::Matrix persp; - Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 50.0f); - device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp); - - - Math::Matrix viewMat; - Math::Matrix mat; - - viewMat.LoadIdentity(); - - Math::LoadRotationXMatrix(mat, -ROTATION.x); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - Math::LoadRotationYMatrix(mat, -ROTATION.y); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - Math::LoadTranslationMatrix(mat, -TRANSLATION); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat); - - Math::Matrix worldMat; - worldMat.LoadIdentity(); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - Gfx::VertexCol line[2] = { Gfx::VertexCol() }; - - for (int x = -40; x <= 40; ++x) - { - line[0].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f); - line[0].coord.z = -40; - line[0].coord.x = x; - line[1].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f); - line[1].coord.z = 40; - line[1].coord.x = x; - device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2); - } - - for (int z = -40; z <= 40; ++z) - { - line[0].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f); - line[0].coord.z = z; - line[0].coord.x = -40; - line[1].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f); - line[1].coord.z = z; - line[1].coord.x = 40; - device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2); - } - - - Gfx::VertexCol quad[6] = { Gfx::VertexCol() }; - - quad[0].coord = Math::Vector(-1.0f, -1.0f, 0.0f); - quad[1].coord = Math::Vector( 1.0f, -1.0f, 0.0f); - quad[2].coord = Math::Vector(-1.0f, 1.0f, 0.0f); - quad[3].coord = Math::Vector( 1.0f, 1.0f, 0.0f); - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(1.0f, 1.0f, 0.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(40.0f, 2.0f, 40.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4); - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(0.0f, 1.0f, 1.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(-40.0f, 2.0f, -40.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - int planes = device->ComputeSphereVisibility(Math::Vector(0.0f, 0.0f, 0.0f), 1.0f); - printf("Planes:"); - if (planes == 0) - printf(" (none)"); - - if (planes & Gfx::FRUSTUM_PLANE_LEFT) - printf(" LEFT"); - - if (planes & Gfx::FRUSTUM_PLANE_RIGHT) - printf(" RIGHT"); - - if (planes & Gfx::FRUSTUM_PLANE_BOTTOM) - printf(" BOTTOM"); - - if (planes & Gfx::FRUSTUM_PLANE_TOP) - printf(" TOP"); - - if (planes & Gfx::FRUSTUM_PLANE_FRONT) - printf(" FRONT"); - - if (planes & Gfx::FRUSTUM_PLANE_BACK) - printf(" BACK"); - - printf("\n"); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4); - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(1.0f, 0.0f, 1.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(10.0f, 4.5f, 5.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, quad, 4); - - /* Moving lit cube */ - device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, true); - device->SetRenderState(Gfx::RENDER_STATE_CULLING, true); // Culling (CCW faces) - - device->SetGlobalAmbient(Gfx::Color(0.4f, 0.4f, 0.4f)); - - Gfx::Light light1; - light1.type = Gfx::LIGHT_POINT; - light1.position = Math::Vector(10.0f, 4.5f, 5.0f); - light1.ambient = Gfx::Color(0.2f, 0.2f, 0.2f); - light1.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f); - light1.specular = Gfx::Color(0.0f, 0.0f, 0.0f); - device->SetLight(0, light1); - device->SetLightEnabled(0, true); - - /*Gfx::Light light2; - device->SetLight(1, light2); - device->SetLightEnabled(1, true);*/ - - Gfx::Material material; - material.ambient = Gfx::Color(0.3f, 0.3f, 0.3f); - material.diffuse = Gfx::Color(0.8f, 0.7f, 0.6f); - material.specular = Gfx::Color(0.0f, 0.0f, 0.0f); - device->SetMaterial(material); - - const Gfx::Vertex cube[6][4] = - { - { - // Front - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)), - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)), - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 0.0f, -1.0f)) - }, - - { - // Back - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)), - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)), - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 0.0f, 1.0f)) - }, - - { - // Top - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)), - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 0.0f, 1.0f, 0.0f)) - }, - - { - // Bottom - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)), - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 0.0f, -1.0f, 0.0f)) - }, - - { - // Left - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, 1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, 1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector(-1.0f, 1.0f, -1.0f), Math::Vector(-1.0f, 0.0f, 0.0f)) - }, - - { - // Right - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, -1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, -1.0f, 1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, -1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)), - Gfx::Vertex(Math::Vector( 1.0f, 1.0f, 1.0f), Math::Vector( 1.0f, 0.0f, 0.0f)) - } - }; - - Math::Matrix cubeTrans; - Math::LoadTranslationMatrix(cubeTrans, Math::Vector(10.0f, 2.0f, 5.0f)); - Math::Matrix cubeRot; - Math::LoadRotationMatrix(cubeRot, Math::Vector(0.0f, 1.0f, 0.0f), CUBE_ORBIT); - Math::Matrix cubeRotInv; - Math::LoadRotationMatrix(cubeRotInv, Math::Vector(0.0f, 1.0f, 0.0f), -CUBE_ORBIT); - Math::Matrix cubeTransRad; - Math::LoadTranslationMatrix(cubeTransRad, Math::Vector(0.0f, 0.0f, 6.0f)); - worldMat = Math::MultiplyMatrices(cubeTransRad, cubeRotInv); - worldMat = Math::MultiplyMatrices(cubeRot, worldMat); - worldMat = Math::MultiplyMatrices(cubeTrans, worldMat); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - for (int i = 0; i < 6; ++i) - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, cube[i], 4); - - device->EndScene(); -} - -void Update() -{ - const float TRANS_SPEED = 6.0f; // units / sec - - GetCurrentTimeStamp(CURR_TIME); - float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC); - CopyTimeStamp(PREV_TIME, CURR_TIME); - - CUBE_ORBIT += timeDiff * (Math::PI / 4.0f); - - Math::Vector incTrans; - - if (KEYMAP[K_Forward]) - incTrans.z = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Back]) - incTrans.z = -TRANS_SPEED * timeDiff; - if (KEYMAP[K_Right]) - incTrans.x = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Left]) - incTrans.x = -TRANS_SPEED * timeDiff; - if (KEYMAP[K_Up]) - incTrans.y = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Down]) - incTrans.y = -TRANS_SPEED * timeDiff; - - Math::Point rotTrans = Math::RotatePoint(-ROTATION.y, Math::Point(incTrans.x, incTrans.z)); - incTrans.x = rotTrans.x; - incTrans.z = rotTrans.y; - TRANSLATION += incTrans; -} - -void KeyboardDown(SDLKey key) -{ - switch (key) - { - case SDLK_w: - KEYMAP[K_Forward] = true; - break; - case SDLK_s: - KEYMAP[K_Back] = true; - break; - case SDLK_d: - KEYMAP[K_Right] = true; - break; - case SDLK_a: - KEYMAP[K_Left] = true; - break; - case SDLK_z: - KEYMAP[K_Down] = true; - break; - case SDLK_x: - KEYMAP[K_Up] = true; - break; - default: - break; - } -} - -void KeyboardUp(SDLKey key) -{ - switch (key) - { - case SDLK_w: - KEYMAP[K_Forward] = false; - break; - case SDLK_s: - KEYMAP[K_Back] = false; - break; - case SDLK_d: - KEYMAP[K_Right] = false; - break; - case SDLK_a: - KEYMAP[K_Left] = false; - break; - case SDLK_z: - KEYMAP[K_Down] = false; - break; - case SDLK_x: - KEYMAP[K_Up] = false; - break; - default: - break; - } -} - -void MouseMove(int x, int y) -{ - Math::Point currentPos(static_cast<float>(x), static_cast<float>(y)); - - static bool first = true; - if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590)) - { - SDL_WarpMouse(400, 300); - MOUSE_POS_BASE.x = 400; - MOUSE_POS_BASE.y = 300; - ROTATION_BASE = ROTATION; - first = false; - return; - } - - ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI; - ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI; -} - -int main(int argc, char *argv[]) -{ - CLogger logger; - - PREV_TIME = CreateTimeStamp(); - CURR_TIME = CreateTimeStamp(); - - GetCurrentTimeStamp(PREV_TIME); - GetCurrentTimeStamp(CURR_TIME); - - CInstanceManager iMan; - - // Without any error checking, for simplicity - - SDL_Init(SDL_INIT_VIDEO); - - IMG_Init(IMG_INIT_PNG); - - const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); - - Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; - - if (videoInfo->hw_available) - videoFlags |= SDL_HWSURFACE; - else - videoFlags |= SDL_SWSURFACE; - - if (videoInfo->blit_hw) - videoFlags |= SDL_HWACCEL; - - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags); - - - SDL_WM_SetCaption("Light Test", "Light Test"); - - //SDL_WM_GrabInput(SDL_GRAB_ON); - SDL_ShowCursor(SDL_DISABLE); - - Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig()); - device->Create(); - - Init(device); - - bool done = false; - while (! done) - { - Render(device); - Update(); - - SDL_GL_SwapBuffers(); - - SDL_Event event; - while (SDL_PollEvent(&event)) - { - if (event.type == SDL_QUIT) - { - break; - done = true; - } - else if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym == SDLK_q) - { - done = true; - break; - } - else - KeyboardDown(event.key.keysym.sym); - } - else if (event.type == SDL_KEYUP) - KeyboardUp(event.key.keysym.sym); - else if (event.type == SDL_MOUSEMOTION) - MouseMove(event.motion.x, event.motion.y); - } - - usleep(FRAME_DELAY); - } - - //SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(SDL_ENABLE); - - device->Destroy(); - delete device; - - SDL_FreeSurface(surface); - - IMG_Quit(); - - SDL_Quit(); - - DestroyTimeStamp(PREV_TIME); - DestroyTimeStamp(CURR_TIME); - - return 0; -} diff --git a/src/graphics/opengl/test/model_test.cpp b/src/graphics/opengl/test/model_test.cpp deleted file mode 100644 index e951e6e..0000000 --- a/src/graphics/opengl/test/model_test.cpp +++ /dev/null @@ -1,377 +0,0 @@ -#include "app/system.h" -#include "common/logger.h" -#include "common/image.h" -#include "common/iman.h" -#include "graphics/engine/modelfile.h" -#include "graphics/opengl/gldevice.h" -#include "math/geometry.h" - -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include <unistd.h> - -#include <iostream> -#include <map> - -enum KeySlots -{ - K_RotXUp, - K_RotXDown, - K_RotYLeft, - K_RotYRight, - K_Forward, - K_Back, - K_Left, - K_Right, - K_Up, - K_Down, - K_Count -}; -bool KEYMAP[K_Count] = { false }; - -Math::Vector TRANSLATION(0.0f, 0.0f, 30.0f); -Math::Vector ROTATION; - -const int FRAME_DELAY = 5000; - -std::map<std::string, Gfx::Texture> TEXS; - -SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL; - -Gfx::Texture GetTexture(const std::string &name) -{ - std::map<std::string, Gfx::Texture>::iterator it = TEXS.find(name); - if (it == TEXS.end()) - return Gfx::Texture(); - - return (*it).second; -} - -void LoadTexture(Gfx::CGLDevice *device, const std::string &name) -{ - if (name.empty()) - return; - - Gfx::Texture tex = GetTexture(name); - - if (tex.Valid()) - return; - - CImage img; - if (! img.Load(std::string("tex/") + name)) - { - std::string err = img.GetError(); - GetLogger()->Error("Texture not loaded, error: %s!\n", err.c_str()); - } - else - { - Gfx::TextureCreateParams texCreateParams; - texCreateParams.mipmap = true; - if (img.GetData()->surface->format->Amask == 0) - texCreateParams.format = Gfx::TEX_IMG_BGR; - else - texCreateParams.format = Gfx::TEX_IMG_BGRA; - texCreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR; - texCreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR; - - tex = device->CreateTexture(&img, texCreateParams); - } - - TEXS[name] = tex; -} - -void Init(Gfx::CGLDevice *device, Gfx::CModelFile *model) -{ - std::vector<Gfx::ModelTriangle> &triangles = model->GetTriangles(); - - for (int i = 0; i < static_cast<int>( triangles.size() ); ++i) - { - LoadTexture(device, triangles[i].tex1Name); - LoadTexture(device, triangles[i].tex2Name); - } - - device->SetRenderState(Gfx::RENDER_STATE_TEXTURING, true); - device->SetRenderState(Gfx::RENDER_STATE_LIGHTING, true); - device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true); - device->SetShadeModel(Gfx::SHADE_SMOOTH); - - Gfx::Light light; - light.type = Gfx::LIGHT_DIRECTIONAL; - light.ambient = Gfx::Color(0.4f, 0.4f, 0.4f, 0.0f); - light.diffuse = Gfx::Color(0.8f, 0.8f, 0.8f, 0.0f); - light.specular = Gfx::Color(0.2f, 0.2f, 0.2f, 0.0f); - light.position = Math::Vector(0.0f, 0.0f, -1.0f); - light.direction = Math::Vector(0.0f, 0.0f, 1.0f); - - device->SetGlobalAmbient(Gfx::Color(0.5f, 0.5f, 0.5f, 0.0f)); - device->SetLight(0, light); - device->SetLightEnabled(0, true); -} - -void Render(Gfx::CGLDevice *device, Gfx::CModelFile *modelFile) -{ - device->BeginScene(); - - Math::Matrix persp; - Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 100.0f); - device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp); - - Math::Matrix id; - id.LoadIdentity(); - device->SetTransform(Gfx::TRANSFORM_WORLD, id); - - Math::Matrix viewMat; - Math::LoadTranslationMatrix(viewMat, TRANSLATION); - Math::Matrix rot; - Math::LoadRotationXZYMatrix(rot, ROTATION); - viewMat = Math::MultiplyMatrices(viewMat, rot); - device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat); - - std::vector<Gfx::ModelTriangle> &triangles = modelFile->GetTriangles(); - - Gfx::VertexTex2 tri[3]; - - for (int i = 0; i < static_cast<int>( triangles.size() ); ++i) - { - device->SetTexture(0, GetTexture(triangles[i].tex1Name)); - device->SetTexture(1, GetTexture(triangles[i].tex2Name)); - device->SetTextureEnabled(0, true); - device->SetTextureEnabled(1, true); - - device->SetMaterial(triangles[i].material); - - tri[0] = triangles[i].p1; - tri[1] = triangles[i].p2; - tri[2] = triangles[i].p3; - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, tri, 3); - } - - device->EndScene(); -} - -void Update() -{ - const float ROT_SPEED = 80.0f * Math::DEG_TO_RAD; // rad / sec - const float TRANS_SPEED = 3.0f; // units / sec - - GetCurrentTimeStamp(CURR_TIME); - float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC); - CopyTimeStamp(PREV_TIME, CURR_TIME); - - if (KEYMAP[K_RotYLeft]) - ROTATION.y -= ROT_SPEED * timeDiff; - if (KEYMAP[K_RotYRight]) - ROTATION.y += ROT_SPEED * timeDiff; - if (KEYMAP[K_RotXDown]) - ROTATION.x -= ROT_SPEED * timeDiff; - if (KEYMAP[K_RotXUp]) - ROTATION.x += ROT_SPEED * timeDiff; - - if (KEYMAP[K_Forward]) - TRANSLATION.z -= TRANS_SPEED * timeDiff; - if (KEYMAP[K_Back]) - TRANSLATION.z += TRANS_SPEED * timeDiff; - if (KEYMAP[K_Left]) - TRANSLATION.x += TRANS_SPEED * timeDiff; - if (KEYMAP[K_Right]) - TRANSLATION.x -= TRANS_SPEED * timeDiff; - if (KEYMAP[K_Up]) - TRANSLATION.y += TRANS_SPEED * timeDiff; - if (KEYMAP[K_Down]) - TRANSLATION.y -= TRANS_SPEED * timeDiff; -} - -void KeyboardDown(SDLKey key) -{ - switch (key) - { - case SDLK_LEFT: - KEYMAP[K_RotYLeft] = true; - break; - case SDLK_RIGHT: - KEYMAP[K_RotYRight] = true; - break; - case SDLK_UP: - KEYMAP[K_RotXUp] = true; - break; - case SDLK_DOWN: - KEYMAP[K_RotXDown] = true; - break; - case SDLK_w: - KEYMAP[K_Forward] = true; - break; - case SDLK_s: - KEYMAP[K_Back] = true; - break; - case SDLK_a: - KEYMAP[K_Left] = true; - break; - case SDLK_d: - KEYMAP[K_Right] = true; - break; - case SDLK_z: - KEYMAP[K_Down] = true; - break; - case SDLK_x: - KEYMAP[K_Up] = true; - break; - default: - break; - } -} - -void KeyboardUp(SDLKey key) -{ - switch (key) - { - case SDLK_LEFT: - KEYMAP[K_RotYLeft] = false; - break; - case SDLK_RIGHT: - KEYMAP[K_RotYRight] = false; - break; - case SDLK_UP: - KEYMAP[K_RotXUp] = false; - break; - case SDLK_DOWN: - KEYMAP[K_RotXDown] = false; - break; - case SDLK_w: - KEYMAP[K_Forward] = false; - break; - case SDLK_s: - KEYMAP[K_Back] = false; - break; - case SDLK_a: - KEYMAP[K_Left] = false; - break; - case SDLK_d: - KEYMAP[K_Right] = false; - break; - case SDLK_z: - KEYMAP[K_Down] = false; - break; - case SDLK_x: - KEYMAP[K_Up] = false; - break; - default: - break; - } -} - -int main(int argc, char *argv[]) -{ - CLogger logger; - - PREV_TIME = CreateTimeStamp(); - CURR_TIME = CreateTimeStamp(); - - GetCurrentTimeStamp(PREV_TIME); - GetCurrentTimeStamp(CURR_TIME); - - if (argc != 3) - { - std::cerr << "Usage: " << argv[0] << "{mod|dxf} model_file" << std::endl; - return 1; - } - - CInstanceManager iMan; - - Gfx::CModelFile *modelFile = new Gfx::CModelFile(&iMan); - if (std::string(argv[1]) == "mod") - { - if (! modelFile->ReadModel(argv[2], false, false)) - { - std::cerr << "Error reading MOD: " << modelFile->GetError() << std::endl; - return 1; - } - } - else if (std::string(argv[1]) == "dxf") - { - if (! modelFile->ReadDXF(argv[2], 0.0f, 0.0f)) - { - std::cerr << "Error reading DXF: " << modelFile->GetError() << std::endl; - return 1; - } - } - else - { - std::cerr << "Usage: " << argv[0] << "{mod|dxf} model_file" << std::endl; - return 1; - } - - // Without any error checking, for simplicity - - SDL_Init(SDL_INIT_VIDEO); - - IMG_Init(IMG_INIT_PNG); - - const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); - - Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; - - if (videoInfo->hw_available) - videoFlags |= SDL_HWSURFACE; - else - videoFlags |= SDL_SWSURFACE; - - if (videoInfo->blit_hw) - videoFlags |= SDL_HWACCEL; - - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags); - - - SDL_WM_SetCaption("Model Test", "Model Test"); - - Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig()); - device->Create(); - - Init(device, modelFile); - - bool done = false; - while (! done) - { - Render(device, modelFile); - Update(); - - SDL_GL_SwapBuffers(); - - SDL_Event event; - SDL_PollEvent(&event); - if (event.type == SDL_QUIT) - done = true; - else if (event.type == SDL_KEYDOWN) - KeyboardDown(event.key.keysym.sym); - else if (event.type == SDL_KEYUP) - KeyboardUp(event.key.keysym.sym); - - usleep(FRAME_DELAY); - } - - delete modelFile; - - device->Destroy(); - delete device; - - SDL_FreeSurface(surface); - - IMG_Quit(); - - SDL_Quit(); - - DestroyTimeStamp(PREV_TIME); - DestroyTimeStamp(CURR_TIME); - - return 0; -} diff --git a/src/graphics/opengl/test/tex1.png b/src/graphics/opengl/test/tex1.png Binary files differdeleted file mode 100644 index 46c68a0..0000000 --- a/src/graphics/opengl/test/tex1.png +++ /dev/null diff --git a/src/graphics/opengl/test/tex2.png b/src/graphics/opengl/test/tex2.png Binary files differdeleted file mode 100644 index ebdae0d..0000000 --- a/src/graphics/opengl/test/tex2.png +++ /dev/null diff --git a/src/graphics/opengl/test/texture_test.cpp b/src/graphics/opengl/test/texture_test.cpp deleted file mode 100644 index d771927..0000000 --- a/src/graphics/opengl/test/texture_test.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include "common/logger.h" -#include "common/image.h" -#include "graphics/opengl/gldevice.h" -#include "math/geometry.h" - -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include <unistd.h> - - -void Init(Gfx::CGLDevice *device) -{ - device->SetShadeModel(Gfx::SHADE_SMOOTH); - - device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false); - - device->SetTextureEnabled(0, true); - device->SetTextureEnabled(1, true); - - CImage img1; - if (! img1.Load("tex1.png")) - { - std::string err = img1.GetError(); - GetLogger()->Error("texture 1 not loaded, error: %d!\n", err.c_str()); - } - CImage img2; - if (! img2.Load("tex2.png")) - { - std::string err = img2.GetError(); - GetLogger()->Error("texture 2 not loaded, error: %d!\n", err.c_str()); - } - - Gfx::TextureCreateParams tex1CreateParams; - tex1CreateParams.mipmap = true; - tex1CreateParams.format = Gfx::TEX_IMG_RGBA; - tex1CreateParams.minFilter = Gfx::TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR; - tex1CreateParams.magFilter = Gfx::TEX_MAG_FILTER_LINEAR; - - Gfx::TextureCreateParams tex2CreateParams; - tex2CreateParams.mipmap = true; - tex2CreateParams.format = Gfx::TEX_IMG_RGBA; - tex2CreateParams.minFilter = Gfx::TEX_MIN_FILTER_NEAREST_MIPMAP_NEAREST; - tex2CreateParams.magFilter = Gfx::TEX_MAG_FILTER_NEAREST; - - Gfx::Texture tex1 = device->CreateTexture(&img1, tex1CreateParams); - Gfx::Texture tex2 = device->CreateTexture(&img2, tex2CreateParams); - - device->SetTexture(0, tex1); - device->SetTexture(1, tex2); -} - -void Render(Gfx::CGLDevice *device) -{ - device->BeginScene(); - - Math::Matrix ortho; - Math::LoadOrthoProjectionMatrix(ortho, -10, 10, -10, 10); - device->SetTransform(Gfx::TRANSFORM_PROJECTION, ortho); - - Math::Matrix id; - id.LoadIdentity(); - - device->SetTransform(Gfx::TRANSFORM_WORLD, id); - device->SetTransform(Gfx::TRANSFORM_VIEW, id); - - static Gfx::VertexTex2 quad[] = - { - Gfx::VertexTex2(Math::Vector(-2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f)), - Gfx::VertexTex2(Math::Vector( 2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 0.0f), Math::Point(1.0f, 0.0f)), - Gfx::VertexTex2(Math::Vector( 2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 1.0f), Math::Point(1.0f, 1.0f)), - - Gfx::VertexTex2(Math::Vector( 2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(1.0f, 1.0f), Math::Point(1.0f, 1.0f)), - Gfx::VertexTex2(Math::Vector(-2.0f, -2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 1.0f), Math::Point(0.0f, 1.0f)), - Gfx::VertexTex2(Math::Vector(-2.0f, 2.0f, 0.0f), Math::Vector(), Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f)), - }; - - Gfx::TextureStageParams tex1StageParams; - tex1StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT; - tex1StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; - device->SetTextureStageParams(0, tex1StageParams); - - Gfx::TextureStageParams tex2StageParams; - tex2StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT; - tex2StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; - device->SetTextureStageParams(1, tex2StageParams); - - Math::Matrix t; - Math::LoadTranslationMatrix(t, Math::Vector(-4.0f, 4.0f, 0.0f)); - device->SetTransform(Gfx::TRANSFORM_VIEW, t); - - device->SetTextureEnabled(0, true); - device->SetTextureEnabled(1, false); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - Math::LoadTranslationMatrix(t, Math::Vector( 4.0f, 4.0f, 0.0f)); - device->SetTransform(Gfx::TRANSFORM_VIEW, t); - - device->SetTextureEnabled(0, false); - device->SetTextureEnabled(1, true); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - Math::LoadTranslationMatrix(t, Math::Vector( 0.0f, -4.0f, 0.0f)); - device->SetTransform(Gfx::TRANSFORM_VIEW, t); - - device->SetTextureEnabled(0, true); - device->SetTextureEnabled(1, true); - - tex1StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT; - tex1StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; - device->SetTextureStageParams(0, tex1StageParams); - - tex2StageParams.colorOperation = Gfx::TEX_MIX_OPER_ADD; - tex2StageParams.colorArg1 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR; - tex2StageParams.colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE; - tex2StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT; - device->SetTextureStageParams(1, tex2StageParams); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - device->EndScene(); -} - -int main() -{ - CLogger(); - - // Without any error checking, for simplicity - - SDL_Init(SDL_INIT_VIDEO); - - IMG_Init(IMG_INIT_PNG); - - const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); - - Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; - - if (videoInfo->hw_available) - videoFlags |= SDL_HWSURFACE; - else - videoFlags |= SDL_SWSURFACE; - - if (videoInfo->blit_hw) - videoFlags |= SDL_HWACCEL; - - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags); - - - SDL_WM_SetCaption("Texture Test", "Texture Test"); - - Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig()); - device->Create(); - - Init(device); - - bool done = false; - while (! done) - { - Render(device); - - SDL_GL_SwapBuffers(); - - SDL_Event event; - SDL_PollEvent(&event); - if (event.type == SDL_QUIT) - done = true; - - usleep(10000); - } - - device->Destroy(); - delete device; - - SDL_FreeSurface(surface); - - IMG_Quit(); - - SDL_Quit(); - - return 0; -} diff --git a/src/graphics/opengl/test/transform_test.cpp b/src/graphics/opengl/test/transform_test.cpp deleted file mode 100644 index cddd1b8..0000000 --- a/src/graphics/opengl/test/transform_test.cpp +++ /dev/null @@ -1,339 +0,0 @@ -#include "app/system.h" -#include "common/logger.h" -#include "common/image.h" -#include "common/iman.h" -#include "graphics/opengl/gldevice.h" -#include "math/geometry.h" - -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include <unistd.h> - -#include <iostream> -#include <map> - -enum KeySlots -{ - K_Forward, - K_Back, - K_Left, - K_Right, - K_Up, - K_Down, - K_Count -}; -bool KEYMAP[K_Count] = { false }; - -Math::Point MOUSE_POS_BASE; - -Math::Vector TRANSLATION(0.0f, 2.0f, 0.0f); -Math::Vector ROTATION, ROTATION_BASE; - -const int FRAME_DELAY = 5000; - -SystemTimeStamp *PREV_TIME = NULL, *CURR_TIME = NULL; - -void Init(Gfx::CGLDevice *device) -{ - device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, true); - device->SetShadeModel(Gfx::SHADE_SMOOTH); -} - -void Render(Gfx::CGLDevice *device) -{ - device->BeginScene(); - - Math::Matrix persp; - Math::LoadProjectionMatrix(persp, Math::PI / 4.0f, (800.0f) / (600.0f), 0.1f, 100.0f); - device->SetTransform(Gfx::TRANSFORM_PROJECTION, persp); - - - Math::Matrix viewMat; - Math::Matrix mat; - - viewMat.LoadIdentity(); - - Math::LoadRotationXMatrix(mat, -ROTATION.x); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - Math::LoadRotationYMatrix(mat, -ROTATION.y); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - Math::LoadTranslationMatrix(mat, -TRANSLATION); - viewMat = Math::MultiplyMatrices(viewMat, mat); - - device->SetTransform(Gfx::TRANSFORM_VIEW, viewMat); - - - Math::Matrix worldMat; - worldMat.LoadIdentity(); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - Gfx::VertexCol line[2] = { Gfx::VertexCol() }; - - for (int x = -40; x <= 40; ++x) - { - line[0].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f); - line[0].coord.z = -40; - line[0].coord.x = x; - line[1].color = Gfx::Color(0.7f + x / 120.0f, 0.0f, 0.0f); - line[1].coord.z = 40; - line[1].coord.x = x; - device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2); - } - - for (int z = -40; z <= 40; ++z) - { - line[0].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f); - line[0].coord.z = z; - line[0].coord.x = -40; - line[1].color = Gfx::Color(0.0f, 0.7f + z / 120.0f, 0.0f); - line[1].coord.z = z; - line[1].coord.x = 40; - device->DrawPrimitive(Gfx::PRIMITIVE_LINES, line, 2); - } - - - Gfx::VertexCol quad[6] = { Gfx::VertexCol() }; - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(1.0f, 1.0f, 0.0f); - - quad[0].coord = Math::Vector(-1.0f, -1.0f, 0.0f); - quad[1].coord = Math::Vector( 1.0f, -1.0f, 0.0f); - quad[2].coord = Math::Vector( 1.0f, 1.0f, 0.0f); - quad[3].coord = Math::Vector( 1.0f, 1.0f, 0.0f); - quad[4].coord = Math::Vector(-1.0f, 1.0f, 0.0f); - quad[5].coord = Math::Vector(-1.0f, -1.0f, 0.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(40.0f, 2.0f, 40.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(0.0f, 1.0f, 1.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(-40.0f, 2.0f, -40.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - for (int i = 0; i < 6; ++i) - quad[i].color = Gfx::Color(1.0f, 0.0f, 1.0f); - - Math::LoadTranslationMatrix(worldMat, Math::Vector(0.0f, 10.0f, 0.0f)); - device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat); - - device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6); - - device->EndScene(); -} - -void Update() -{ - const float TRANS_SPEED = 6.0f; // units / sec - - GetCurrentTimeStamp(CURR_TIME); - float timeDiff = TimeStampDiff(PREV_TIME, CURR_TIME, STU_SEC); - CopyTimeStamp(PREV_TIME, CURR_TIME); - - Math::Vector incTrans; - - if (KEYMAP[K_Forward]) - incTrans.z = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Back]) - incTrans.z = -TRANS_SPEED * timeDiff; - if (KEYMAP[K_Right]) - incTrans.x = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Left]) - incTrans.x = -TRANS_SPEED * timeDiff; - if (KEYMAP[K_Up]) - incTrans.y = +TRANS_SPEED * timeDiff; - if (KEYMAP[K_Down]) - incTrans.y = -TRANS_SPEED * timeDiff; - - Math::Point rotTrans = Math::RotatePoint(-ROTATION.y, Math::Point(incTrans.x, incTrans.z)); - incTrans.x = rotTrans.x; - incTrans.z = rotTrans.y; - TRANSLATION += incTrans; -} - -void KeyboardDown(SDLKey key) -{ - switch (key) - { - case SDLK_w: - KEYMAP[K_Forward] = true; - break; - case SDLK_s: - KEYMAP[K_Back] = true; - break; - case SDLK_d: - KEYMAP[K_Right] = true; - break; - case SDLK_a: - KEYMAP[K_Left] = true; - break; - case SDLK_z: - KEYMAP[K_Down] = true; - break; - case SDLK_x: - KEYMAP[K_Up] = true; - break; - default: - break; - } -} - -void KeyboardUp(SDLKey key) -{ - switch (key) - { - case SDLK_w: - KEYMAP[K_Forward] = false; - break; - case SDLK_s: - KEYMAP[K_Back] = false; - break; - case SDLK_d: - KEYMAP[K_Right] = false; - break; - case SDLK_a: - KEYMAP[K_Left] = false; - break; - case SDLK_z: - KEYMAP[K_Down] = false; - break; - case SDLK_x: - KEYMAP[K_Up] = false; - break; - default: - break; - } -} - -void MouseMove(int x, int y) -{ - Math::Point currentPos(static_cast<float>(x), static_cast<float>(y)); - - static bool first = true; - if (first || (x < 10) || (y < 10) || (x > 790) || (y > 590)) - { - SDL_WarpMouse(400, 300); - MOUSE_POS_BASE.x = 400; - MOUSE_POS_BASE.y = 300; - ROTATION_BASE = ROTATION; - first = false; - return; - } - - ROTATION.y = ROTATION_BASE.y + (static_cast<float> (x - MOUSE_POS_BASE.x) / 800.0f) * Math::PI; - ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI; -} - -int main(int argc, char *argv[]) -{ - CLogger logger; - - PREV_TIME = CreateTimeStamp(); - CURR_TIME = CreateTimeStamp(); - - GetCurrentTimeStamp(PREV_TIME); - GetCurrentTimeStamp(CURR_TIME); - - CInstanceManager iMan; - - // Without any error checking, for simplicity - - SDL_Init(SDL_INIT_VIDEO); - - IMG_Init(IMG_INIT_PNG); - - const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); - - Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE; - - if (videoInfo->hw_available) - videoFlags |= SDL_HWSURFACE; - else - videoFlags |= SDL_SWSURFACE; - - if (videoInfo->blit_hw) - videoFlags |= SDL_HWACCEL; - - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8); - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - SDL_Surface *surface = SDL_SetVideoMode(800, 600, 32, videoFlags); - - - SDL_WM_SetCaption("Transform Test", "Transform Test"); - - //SDL_WM_GrabInput(SDL_GRAB_ON); - SDL_ShowCursor(SDL_DISABLE); - - Gfx::CGLDevice *device = new Gfx::CGLDevice(Gfx::GLDeviceConfig()); - device->Create(); - - Init(device); - - bool done = false; - while (! done) - { - Render(device); - Update(); - - SDL_GL_SwapBuffers(); - - SDL_Event event; - while (SDL_PollEvent(&event)) - { - if (event.type == SDL_QUIT) - { - break; - done = true; - } - else if (event.type == SDL_KEYDOWN) - { - if (event.key.keysym.sym == SDLK_q) - { - done = true; - break; - } - else - KeyboardDown(event.key.keysym.sym); - } - else if (event.type == SDL_KEYUP) - KeyboardUp(event.key.keysym.sym); - else if (event.type == SDL_MOUSEMOTION) - MouseMove(event.motion.x, event.motion.y); - } - - usleep(FRAME_DELAY); - } - - //SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(SDL_ENABLE); - - device->Destroy(); - delete device; - - SDL_FreeSurface(surface); - - IMG_Quit(); - - SDL_Quit(); - - DestroyTimeStamp(PREV_TIME); - DestroyTimeStamp(CURR_TIME); - - return 0; -} diff --git a/src/math/test/CMakeLists.txt b/src/math/test/CMakeLists.txt deleted file mode 100644 index e31260c..0000000 --- a/src/math/test/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -include_directories( -. -../.. -../../.. -${GTEST_INCLUDE_DIR} -) - -add_executable(matrix_test matrix_test.cpp) -target_link_libraries(matrix_test gtest) - -add_executable(vector_test vector_test.cpp) -target_link_libraries(vector_test gtest) - -add_executable(geometry_test geometry_test.cpp) -target_link_libraries(geometry_test gtest) - -add_test(matrix_test matrix_test) -add_test(vector_test vector_test) -add_test(geometry_test geometry_test) diff --git a/src/math/test/gendata.m b/src/math/test/gendata.m deleted file mode 100644 index 5c13491..0000000 --- a/src/math/test/gendata.m +++ /dev/null @@ -1,86 +0,0 @@ -% Script in Octave for generating test data - -1; - -% Returns the minor matrix -function m = minor(A, r, c) - - m = A; - m(r,:) = []; - m(:,c) = []; - -end; - -% Returns the cofactor matrix -function m = cofactors(A) - - m = zeros(rows(A), columns(A)); - - for r = [1 : rows(A)] - for c = [1 : columns(A)] - m(r, c) = det(minor(A, r, c)); - if (mod(r + c, 2) == 1) - m(r, c) = -m(r, c); - end; - end; - end; - -end; - -% Prints the matrix as C++ code -function printout(A, name) - - printf('const float %s[16] = \n', name); - printf('{\n'); - - for c = [1 : columns(A)] - for r = [1 : rows(A)] - printf(' %f', A(r,c)); - if (! ( (r == 4) && (c == 4) ) ) - printf(','); - end; - printf('\n'); - end; - end; - - printf('};\n'); - -end; - -printf('// Cofactors\n'); -A = randn(4,4); -printout(A, 'COF_MAT'); -printf('\n'); -printout(cofactors(A), 'COF_RESULT'); -printf('\n'); - -printf('\n'); - -printf('// Det\n'); -A = randn(4,4); -printout(A, 'DET_MAT'); -printf('\n'); -printf('const float DET_RESULT = %f;', det(A)); -printf('\n'); - -printf('\n'); - -printf('// Invert\n'); -A = randn(4,4); -printout(A, 'INV_MAT'); -printf('\n'); -printout(inv(A), 'COF_RESULT'); -printf('\n'); - -printf('\n'); - -printf('// Multiplication\n'); -A = randn(4,4); -printout(A, 'MUL_A'); -printf('\n'); -B = randn(4,4); -printout(B, 'MUL_B'); -printf('\n'); -C = A * B; -printout(C, 'MUL_RESULT'); -printf('\n'); diff --git a/src/math/test/geometry_test.cpp b/src/math/test/geometry_test.cpp deleted file mode 100644 index 8b83b8d..0000000 --- a/src/math/test/geometry_test.cpp +++ /dev/null @@ -1,359 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * 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/. - -// math/test/geometry_test.cpp - -/* Unit tests for functions in geometry.h */ - -#include "../func.h" -#include "../geometry.h" - -#include "gtest/gtest.h" - - -const float TEST_TOLERANCE = 1e-5; - - -// Test for rewritten function RotateAngle() -TEST(GeometryTest, RotateAngleTest) -{ - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE)); -} - -// Tests for other altered, complex or uncertain functions - -/* - - TODO: write meaningful tests with proper test values - -int TestAngle() -{ - const Math::Vector u(-0.0786076246943884, 0.2231249091714256, -1.1601361718477805); - const Math::Vector v(-1.231228742001907, -1.720549809950561, -0.690468438834111); - - float mathResult = Math::Angle(u, v); - float oldMathResult = Angle(VEC_TO_D3DVEC(u), VEC_TO_D3DVEC(v)); - - if (! Math::IsEqual(mathResult, oldMathResult, TEST_TOLERANCE) ) - return __LINE__; - - return 0; -} - -int TestRotateView() -{ - const Math::Vector center(0.617909142705555, 0.896939729454538, -0.615041943652284); - const float angleH = 44.5; - const float angleV = 12.3; - const float dist = 34.76; - - Math::Vector mathResult = Math::RotateView(center, angleH, angleV, dist); - Math::Vector oldMathResult = D3DVEC_TO_VEC(RotateView(VEC_TO_D3DVEC(center), angleH, angleV, dist)); - - if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLookatPoint() -{ - const Math::Vector eye(-2.451183170579471, 0.241270270546559, -0.490677411454893); - const float angleH = 48.4; - const float angleV = 32.4; - const float length = 74.44; - - Math::Vector mathResult = Math::LookatPoint(eye, angleH, angleV, length); - Math::Vector oldMathResult = D3DVEC_TO_VEC(LookatPoint(VEC_TO_D3DVEC(eye), angleH, angleV, length)); - - if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestProjection() -{ - const Math::Vector a(0.852064846846319, -0.794279497087496, -0.655779805476688); - const Math::Vector b(-0.245838834102304, -0.841115596038861, 0.470457161487799); - const Math::Vector p(2.289326061164255, -0.505511362271196, 0.660204551169491); - - Math::Vector mathResult = Math::Projection(a, b, p); - Math::Vector oldMathResult = D3DVEC_TO_VEC(Projection(VEC_TO_D3DVEC(a), VEC_TO_D3DVEC(b), VEC_TO_D3DVEC(p))); - - if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadViewMatrix() -{ - const Math::Vector from(2.5646013154868874, -0.6058794133917031, -0.0441195127419744); - const Math::Vector at(0.728044925765569, -0.206343977871841, 2.543158236935463); - const Math::Vector worldUp(-1.893738133660711, -1.009584441407070, 0.521745988225582); - - Math::Matrix mathResult; - Math::LoadViewMatrix(mathResult, from, at, worldUp); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DVECTOR fromD3D = VEC_TO_D3DVEC(from); - D3DVECTOR atD3D = VEC_TO_D3DVEC(at); - D3DVECTOR worldUpD3D = VEC_TO_D3DVEC(worldUp); - D3DUtil_SetViewMatrix(mat, fromD3D, atD3D, worldUpD3D); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadProjectionMatrix() -{ - const float fov = 76.3f; - const float aspect = 0.891f; - const float nearPlane = 12.3f; - const float farPlane = 1238.9f; - - Math::Matrix mathResult; - Math::LoadProjectionMatrix(mathResult, fov, aspect, nearPlane, farPlane); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetProjectionMatrix(mat, fov, aspect, nearPlane, farPlane); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadTranslationMatrix() -{ - const Math::Vector translation(-0.3631590720995237, 1.6976327614875211, 0.0148815191502145); - - Math::Matrix mathResult; - Math::LoadTranslationMatrix(mathResult, translation); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetTranslateMatrix(mat, translation.x, translation.y, translation.z); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadScaleMatrix() -{ - const Math::Vector scale(0.612236460285503, -0.635566935025364, -0.254321375332065); - - Math::Matrix mathResult; - Math::LoadScaleMatrix(mathResult, scale); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetScaleMatrix(mat, scale.x, scale.y, scale.z); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationXMatrix() -{ - const float angle = 0.513790685774275; - - Math::Matrix mathResult; - Math::LoadRotationXMatrix(mathResult, angle); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetRotateXMatrix(mat, angle); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationYMatrix() -{ - const float angle = -0.569166650127303; - - Math::Matrix mathResult; - Math::LoadRotationYMatrix(mathResult, angle); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetRotateYMatrix(mat, angle); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationZMatrix() -{ - const float angle = 0.380448034347452; - - Math::Matrix mathResult; - Math::LoadRotationZMatrix(mathResult, angle); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DUtil_SetRotateZMatrix(mat, angle); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationMatrix() -{ - const float angle = -0.987747190637790; - const Math::Vector dir(-0.113024727688331, -0.781265998072571, 1.838972397076884); - - Math::Matrix mathResult; - Math::LoadRotationMatrix(mathResult, dir, angle); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - D3DVECTOR dirD3D = VEC_TO_D3DVEC(dir); - D3DUtil_SetRotationMatrix(mat, dirD3D, angle); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationXZYMatrix() -{ - const Math::Vector angles(-0.841366567984597, -0.100543315396357, 1.610647811559988); - - Math::Matrix mathResult; - Math::LoadRotationXZYMatrix(mathResult, angles); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - MatRotateXZY(mat, VEC_TO_D3DVEC(angles)); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestLoadRotationZXYMatrix() -{ - const Math::Vector angles(0.275558495480206, -0.224328265970090, 0.943077216574253); - - Math::Matrix mathResult; - Math::LoadRotationZXYMatrix(mathResult, angles); - - Math::Matrix oldMathResult; - { - D3DMATRIX mat; - MatRotateZXY(mat, VEC_TO_D3DVEC(angles)); - oldMathResult = D3DMAT_TO_MAT(mat); - } - - if (! Math::MatricesEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -int TestTransform() -{ - Math::Matrix transformMatrix( - (float[4][4]) - { - { -0.9282074720977896, 0.6794734970319730, -1.3234304946882685, 0.0925294727863890 }, - { -0.0395527963683484, 0.2897634352353881, 1.9144398570315440, -1.4062267508968478 }, - { 0.9133323625282361, -0.6741836434774530, -0.2188812951424338, -1.0089184339952666 }, - { 0.0f, 0.0f, 0.0f, 1.0f } - } - ); - Math::Vector vector(-0.314596433318370, -0.622681232583150, -0.371307535743574); - - Math::Vector mathResult = Math::Transform(transformMatrix, vector); - Math::Vector oldMathResult = Transform(transformMatrix, vector); - - if (! Math::VectorsEqual(mathResult, oldMathResult, TEST_TOLERANCE)) - return __LINE__; - - return 0; -} - -*/ - - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/src/math/test/matrix_test.cpp b/src/math/test/matrix_test.cpp deleted file mode 100644 index 867e0ec..0000000 --- a/src/math/test/matrix_test.cpp +++ /dev/null @@ -1,322 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * 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/. - -// math/test/matrix_test.cpp - -/* - Unit tests for Matrix struct - - Test data was randomly generated and the expected results - calculated using GNU Octave. - */ - -#include "../func.h" -#include "../matrix.h" - -#include "gtest/gtest.h" - - -const float TEST_TOLERANCE = 1e-6; - - -TEST(MatrixTest, TransposeTest) -{ - const Math::Matrix mat( - (float[4][4]) - { - { -0.07011674491203920, 1.26145596067429810, 2.09476603598066902, 0.35560176915570696 }, - { -1.34075615966224704, 1.17988499016709314, 0.00601713429241016, -0.75213676977972566 }, - { 0.59186722295223981, 0.88089224074765293, 0.70994467464257294, 0.36730385425340212 }, - { -0.95649396555068111, 0.75912182022565566, 1.34883305778387186, -1.34957997578168754 } - } - ); - - const Math::Matrix expectedTranspose( - (float[4][4]) - { - { -0.07011674491203920, -1.34075615966224704, 0.59186722295223981, -0.95649396555068111 }, - { 1.26145596067429810, 1.17988499016709314, 0.88089224074765293, 0.75912182022565566 }, - { 2.09476603598066902, 0.00601713429241016, 0.70994467464257294, 1.34883305778387186 }, - { 0.35560176915570696, -0.75213676977972566, 0.36730385425340212, -1.34957997578168754 } - } - ); - - Math::Matrix transpose = Math::Transpose(mat); - - EXPECT_TRUE(Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE)); -} - -TEST(MatrixTest, CofactorTest) -{ - const Math::Matrix mat1( - (float[4][4]) - { - { 0.610630320796245, 1.059932357918312, -1.581674311378210, 1.782214448453331 }, - { 0.191028848211526, -0.813898708757524, 1.516114203870644, 0.395202639476002 }, - { 0.335142750345279, -0.346586619596529, 0.545382042472336, -0.879268918923072 }, - { 1.417588151657198, 1.450841789070141, 0.219080104196171, 0.378724047481655 } - } - ); - - const Math::Matrix expectedCofactors1( - (float[4][4]) - { - { -2.402679369186782, 2.282452509293019, 1.722732204057644, -0.746939701104385 }, - { -0.687677756877654, 1.168949180331164, -0.985354966837796, -1.334071111592705 }, - { -5.115621958424845, 4.229724770159009, 2.529000630782808, 1.481632618355891 }, - { 0.147480897398694, -2.140677680337111, -1.207189492265546, 0.151236920408051 } - } - ); - - for (int r = 0; r < 4; ++r) - { - for (int c = 0; c < 4; ++c) - { - float ret = mat1.Cofactor(r, c); - float exp = expectedCofactors1.m[4*c+r]; - EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE)); - } - } - - const Math::Matrix mat2( - (float[4][4]) - { - { 0.9845099464982393, -0.9091233416532389, -0.6272243714245945, 0.4645001858944354 }, - { -0.1333308471483736, 0.9128181433725897, -1.0937461393836190, 0.3180936795928376 }, - { -0.0654324396846289, 0.1014641705415945, 1.5107709042683430, -0.0240560430414690 }, - { 0.0179638644093347, -1.0695585982782767, -0.1741250853101032, 1.0803106709464336 } - } - ); - - const Math::Matrix expectedCofactors2( - (float[4][4]) - { - { 2.0861102207614466, 0.2989010779528912, 0.0746276150537432, 0.2732659822656097 }, - { 0.6850002886584565, 1.5513169659641379, -0.0503743176545917, 1.5163672441575642 }, - { 1.2385556680997216, 1.1827709562505695, 1.2282813085138962, 1.3483789679871401 }, - { -1.0710790241539783, -0.5589604503588883, 0.0100959837872308, 1.1897872684455839 } - } - ); - - - for (int r = 0; r < 4; ++r) - { - for (int c = 0; c < 4; ++c) - { - float ret = mat2.Cofactor(r, c); - float exp = expectedCofactors2.m[4*c+r]; - EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE)); - } - } -} - -TEST(MatrixTest, DetTest) -{ - const Math::Matrix mat1( - (float[4][4]) - { - { -0.95880162984708284, 0.24004047608997131, -0.78172309932665407, -0.11604124457222834 }, - { -0.36230592086261376, -0.75778166876017261, 0.33041059404631740, -1.06001391941094836 }, - { 0.00260215210936187, 1.27485610196385113, -0.26149859846418033, -0.59669701186364876 }, - { 0.36899429848485432, 3.01720896813933104, 2.10311476609438719, -1.68627076626448269 } - } - ); - - const float expectedDet1 = 4.07415413729671; - - float ret1 = mat1.Det(); - EXPECT_TRUE(Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE)); - - const Math::Matrix mat2( - (float[4][4]) - { - { -1.0860073221346871, 0.9150354098189495, -0.2723201933559999, 0.2922832160271507 }, - { -1.0248331304801788, -2.5081237461125205, -1.0277123574586633, -0.2254690663329798 }, - { -1.4227635282899367, -0.0403846809122684, 0.9216148477171653, 1.2517067488015878 }, - { -0.1160254467152022, 0.8270675274393656, 1.0327218739781614, -0.3674886870220400 } - } - ); - - const float expectedDet2 = -6.35122307880942; - - float ret2 = mat2.Det(); - EXPECT_TRUE(Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE)); -} - -TEST(MatrixTest, InverseTest) -{ - const Math::Matrix mat1( - (float[4][4]) - { - { -2.2829352811514658, -0.9103222363187888, 0.2792976509411680, -0.7984393573193174 }, - { 2.4823665798689589, -0.0599056759070980, 0.3832364352926366, -1.6404257204372739 }, - { -0.3841952272526398, -0.8377700696457873, -0.3416328338427138, 1.1746577275723329 }, - { 0.1746031241954947, -0.4952532117949962, 0.2155084379835037, -1.6586460437329220 } - } - ); - - const Math::Matrix expectedInverse1( - (float[4][4]) - { - { -0.119472603171041, 0.331675963276297, 0.187516809009720, -0.137720814290806 }, - { -0.387591686166085, -0.487284946727583, -0.798527541290274, 0.102991635972060 }, - { 2.601905603425902, 2.606899016264679, -0.528006148839176, -4.204703326522837 }, - { 0.441220327151392, 0.519128136207318, 0.189567009205522, -1.194469716136194 } - } - ); - - Math::Matrix inverse1 = mat1.Inverse(); - - EXPECT_TRUE(Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE)); - - const Math::Matrix mat2( - (float[4][4]) - { - { -0.05464332404298505, -0.64357755258235749, -0.13017671677619302, -0.56742332785888006 }, - { 0.29048383600458222, -0.91517047043724875, 0.84517524415561684, 0.51628195547960565 }, - { 0.00946488004480186, -0.89077382212689293, 0.73565573766341397, -0.15932513521840930 }, - { -1.01244718912499132, -0.27840911963972276, -0.39189681211309862, 1.18315064340192055 } - } - ); - - const Math::Matrix expectedInverse2( - (float[4][4]) - { - { 0.771302711132012, 1.587542278361995, -2.003075114445104, -0.592574156227379 }, - { -1.208929259769431, -0.786598967848473, 0.607335305808052, -0.154759693303324 }, - { -1.500037668208218, -0.774300278997914, 1.917800427261255, -0.123268572651291 }, - { -0.121314770937944, 0.916925149209746, -0.935924950785014, 0.260875394250671 } - } - ); - - Math::Matrix inverse2 = mat2.Inverse(); - - EXPECT_TRUE(Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE)); -} - -TEST(MatrixTest, MultiplyTest) -{ - const Math::Matrix mat1A( - (float[4][4]) - { - { 0.6561727049162027, -1.4180263627131411, -0.8271026046117423, 2.3919331748512578 }, - { -0.6035665535146352, 0.0150827348790615, -0.7090794192822540, 0.9057604704594814 }, - { -0.9871045001223655, -0.4980646811455065, 0.3806177002298990, 0.1520583649240934 }, - { -0.2721911170792712, 0.7627928194552067, -0.1504091336784158, 0.9747545351840121 } - } - ); - - const Math::Matrix mat1B( - (float[4][4]) - { - { -0.2643735892448818, -0.7542994492819621, 0.6082322350568750, 0.0581733424861419 }, - { 1.0293246070431237, 0.1979285388251341, -0.2932031385332818, 0.8838407179018929 }, - { 0.3448687251553114, 0.5031654871245456, 0.7554693012922442, -0.4845315903845708 }, - { -1.8662838497278593, -0.7843850624747805, 0.1389026096476257, -1.3686415408300689 } - } - ); - - const Math::Matrix expectedMultiply1( - (float[4][4]) - { - { -6.382352236417988, -3.067984733682130, 0.522270304251466, -4.088079444498280 }, - { -1.759853366848825, -0.608994052024491, -0.781406179437379, -0.917870775786188 }, - { -0.404226802169062, 0.718232546720114, -0.145688356880835, -0.890167707987175 }, - { -1.013918490922430, -0.483971504099758, -0.367442194643757, -0.602858486133615 } - } - ); - - Math::Matrix multiply1 = Math::MultiplyMatrices(mat1A, mat1B); - EXPECT_TRUE(Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE)); - - const Math::Matrix mat2A( - (float[4][4]) - { - { 0.8697203025776754, 2.1259475710644935, 1.7856691009707812, -2.1563963348328126 }, - { 1.5888074489288735, -0.0794849733953615, 0.7307782768677457, 0.7943129159612630 }, - { 0.2859761537233830, -0.6231231890384962, -0.0496743172880377, -0.8137857518646087 }, - { 1.2670547229512983, -0.5305171374831831, -0.4987412674062375, -1.1257327113869595 } - } - ); - - const Math::Matrix mat2B( - (float[4][4]) - { - { 1.1321105701165317, 0.1759563504574463, -2.0675778912000418, 1.4840339814245538 }, - { -1.5117280888829916, -0.0933013188828093, -0.2079262944351640, 0.9575727579539316 }, - { 0.3615378398970173, 1.2465163589027248, 1.1326150997082589, 0.9921208694352303 }, - { -0.7357104529373861, -0.4774022005969588, -0.2118739096676499, 1.1427567093270703 } - } - ); - - const Math::Matrix expectedMultiply2( - (float[4][4]) - { - { 0.00283516267056338, 3.21001319965989307, 0.23910503934370686, 2.63380716363006107 }, - { 1.59868505822469742, 0.81869715594617765, -2.60905981088293570, 3.91445839239110294 }, - { 1.84650099286297942, 0.43504079532852930, -0.34555619012424243, -1.15152951542451487 }, - { 2.88434318563174585, 0.18818239851585700, -2.83579436909308980, -0.40890672198610400 } - } - ); - - Math::Matrix multiply2 = Math::MultiplyMatrices(mat2A, mat2B); - EXPECT_TRUE(Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE)); -} - -TEST(MatrixTest, MultiplyVectorTest) -{ - const Math::Matrix mat1( - (float[4][4]) - { - { 0.188562846910008, -0.015148651460679, 0.394512304108827, 0.906910631257135 }, - { -0.297506779519667, 0.940119328178913, 0.970957796752517, 0.310559318965526 }, - { -0.819770525290873, -2.316574438778879, 0.155756069319732, -0.855661405742964 }, - { 0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000 } - } - ); - - const Math::Vector vec1(-0.824708565156661, -1.598287748103842, -0.422498044734181); - - const Math::Vector expectedMultiply1(0.608932463260470, -1.356893266403749, 3.457156276255142); - - Math::Vector multiply1 = Math::MatrixVectorMultiply(mat1, vec1, false); - EXPECT_TRUE(Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE)); - - const Math::Matrix mat2( - (float[4][4]) - { - { -0.63287117038834284, 0.55148060401816856, -0.02042395559467368, -1.50367083897656850 }, - { 0.69629042156335297, 0.12982747869796774, -1.16250029235919405, 1.19084447253756909 }, - { 0.44164132914357224, -0.15169304045662041, -0.00880583574621390, -0.55817802940035310 }, - { 0.95680476533530789, -1.51912346889253125, -0.74209769406615944, -0.20938988867903682 } - } - ); - - const Math::Vector vec2(0.330987381051962, 1.494375516393466, 1.483422335561857); - - const Math::Vector expectedMultiply2(0.2816820577317669, 0.0334468811767428, 0.1996974284970455); - - Math::Vector multiply2 = Math::MatrixVectorMultiply(mat2, vec2, true); - EXPECT_TRUE(Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE)); -} - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} - diff --git a/src/math/test/vector_test.cpp b/src/math/test/vector_test.cpp deleted file mode 100644 index ead2fd2..0000000 --- a/src/math/test/vector_test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * 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/. - -// math/test/vector_test.cpp - -/* - Unit tests for Vector struct - - Test data was randomly generated and the expected results - calculated using GNU Octave. - */ - -#include "../func.h" -#include "../vector.h" - -#include "gtest/gtest.h" - - -const float TEST_TOLERANCE = 1e-6; - - -TEST(VectorTest, LengthTest) -{ - Math::Vector vec(-1.288447945923275, 0.681452565308134, -0.633761098985957); - const float expectedLength = 1.58938001708428; - - EXPECT_TRUE(Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE)); -} - -TEST(VectorTest, NormalizeTest) -{ - Math::Vector vec(1.848877241804398, -0.157262961268577, -1.963031403332377); - const Math::Vector expectedNormalized(0.6844609421393856, -0.0582193085618106, -0.7267212194481797); - - vec.Normalize(); - - EXPECT_TRUE(Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE)); -} - -TEST(VectorTest, DotTest) -{ - Math::Vector vecA(0.8202190530968309, 0.0130926060162780, 0.2411914183883510); - Math::Vector vecB(-0.0524083951404069, 1.5564932716738220, -0.8971342631500536); - - float expectedDot = -0.238988896477326; - - EXPECT_TRUE(Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE)); -} - -TEST(VectorTest, CrossTest) -{ - Math::Vector vecA(1.37380499798567, 1.18054518384682, 1.95166361293121); - Math::Vector vecB(0.891657855926886, 0.447591335394532, -0.901604070087823); - - Math::Vector expectedCross(-1.937932065431669, 2.978844370287636, -0.437739173833581); - Math::Vector expectedReverseCross = -expectedCross; - - EXPECT_TRUE(Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE)); - - EXPECT_TRUE(Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE)); -} - -int main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/src/ui/test/CMakeLists.txt b/src/ui/test/CMakeLists.txt deleted file mode 100644 index 452df43..0000000 --- a/src/ui/test/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE debug) -endif(NOT CMAKE_BUILD_TYPE) -set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - -include_directories( -. -../.. -../../.. -${GTEST_INCLUDE_DIR} -${GMOCK_INCLUDE_DIR} -) - - -add_executable(edit_test - ../../common/event.cpp - ../../common/logger.cpp - ../../common/misc.cpp - ../../common/iman.cpp - ../../common/stringutils.cpp - ../../graphics/engine/text.cpp - ../button.cpp - ../control.cpp - ../edit.cpp - ../scroll.cpp - stubs/app_stub.cpp - stubs/engine_stub.cpp - stubs/particle_stub.cpp - stubs/restext_stub.cpp - stubs/robotmain_stub.cpp - edit_test.cpp) -target_link_libraries(edit_test gtest gmock ${SDL_LIBRARY} ${SDLTTF_LIBRARY} ${Boost_LIBRARIES}) - -add_test(edit_test ./edit_test) diff --git a/src/ui/test/edit_test.cpp b/src/ui/test/edit_test.cpp deleted file mode 100644 index 489b873..0000000 --- a/src/ui/test/edit_test.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "../edit.h" -#include "../../app/app.h" -#include "mocks/text_mock.h" -#include <gtest/gtest.h> -#include <gmock/gmock.h> -#include <fstream> - -class CEditTest : public testing::Test -{ -public: - CEditTest(){}; - - virtual void SetUp() - { - m_engine = new Gfx::CEngine(&m_iMan, NULL); - - m_iMan.AddInstance(CLASS_ENGINE, m_engine); - m_edit = new Ui::CEdit; - } - - virtual void TearDown() - { - m_iMan.DeleteInstance(CLASS_ENGINE, m_engine); - delete m_engine; - m_engine = NULL; - delete m_edit; - m_edit = NULL; - - } - virtual ~CEditTest() - { - - }; - -protected: - CInstanceManager m_iMan; - CApplication m_app; - Gfx::CEngine * m_engine; - Ui::CEdit * m_edit; - CLogger m_logger; -}; - -using ::testing::_; -using ::testing::Return; - -TEST_F(CEditTest, WriteTest) -{ - ASSERT_TRUE(true); - CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText()); - EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f)); - EXPECT_CALL(*text, GetStringWidth(_, _, _)).WillOnce(Return(1.0f)); - std::string filename = "test.file"; - m_edit->SetMaxChar(Ui::EDITSTUDIOMAX); - m_edit->SetAutoIndent(true); - std::string inputScript = "{\ntext1\ntext2\n\ntext3\n{\ntext4\n}\n}"; - std::string expectedScript = "{\r\n\ttext1\r\n\ttext2\r\n\t\r\n\ttext3\r\n\t{\r\n\t\ttext4\r\n\t}\r\n}"; - m_edit->SetText(inputScript.c_str(), true); - GetLogger()->Info("Writing text \n"); - m_edit->WriteText("script.txt"); - - std::fstream scriptFile; - - scriptFile.open("script.txt", std::ios_base::binary | std::ios_base::in); - std::string outputScript((std::istreambuf_iterator<char>(scriptFile)), std::istreambuf_iterator<char>()); - ASSERT_STREQ(expectedScript.c_str(), outputScript.c_str()); -} - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/src/ui/test/mocks/text_mock.h b/src/ui/test/mocks/text_mock.h deleted file mode 100644 index 59a6c48..0000000 --- a/src/ui/test/mocks/text_mock.h +++ /dev/null @@ -1,21 +0,0 @@ -#include "../../graphics/engine/text.h" -#include <gmock/gmock.h> -#include "../../common/logger.h" - - -class CTextMock : public Gfx::CText -{ -public: - CTextMock(CInstanceManager *iMan, Gfx::CEngine* engine) : CText(iMan, engine) - { - } - - virtual ~CTextMock() - { - }; - - MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float)); - MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float)); - -}; - diff --git a/src/ui/test/stubs/app_stub.cpp b/src/ui/test/stubs/app_stub.cpp deleted file mode 100644 index 5dd79e4..0000000 --- a/src/ui/test/stubs/app_stub.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "../../app/app.h" -#include "../../graphics/opengl/gldevice.h" - -template<> CApplication* CSingleton<CApplication>::mInstance = nullptr; - -namespace Gfx { - -GLDeviceConfig::GLDeviceConfig() -{ -} - -} /* Gfx */ -CApplication::CApplication() -{ -} - -CApplication::~CApplication() -{ -} - -std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath) -{ - return subpath; -} - - diff --git a/src/ui/test/stubs/engine_stub.cpp b/src/ui/test/stubs/engine_stub.cpp deleted file mode 100644 index 6ec6006..0000000 --- a/src/ui/test/stubs/engine_stub.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "../../graphics/engine/engine.h" -#include "../../graphics/engine/text.h" -#include "../mocks/text_mock.h" - -namespace Gfx { - -CEngine::CEngine(CInstanceManager* iMan, CApplication* app) : - m_iMan(iMan), m_app(app) -{ - m_text = new CTextMock(m_iMan, this); - m_text->Create(); -} - -CEngine::~CEngine() -{ - delete m_text; - m_text = NULL; -} - -Math::Point CEngine::WindowToInterfaceSize(Math::IntPoint size) -{ - return Math::Point(size.x, size.y); -} - -void CEngine::SetState(int state, const Color& color) -{ - if (state == m_lastState && color == m_lastColor) - return; - - m_lastState = state; - m_lastColor = color; -} - -Math::IntPoint CEngine::GetWindowSize() -{ - return m_size; -} - -void CEngine::AddStatisticTriangle(int count) -{ - m_statisticTriangle += count; -} - -void CEngine::SetMouseType(EngineMouseType type) -{ - m_mouseType = type; -} - -bool CEngine::SetTexture(const std::string& /* name */, int /* stage */) -{ - return true; -} - -CText* CEngine::GetText() -{ - return m_text; -} - -CDevice* CEngine::GetDevice() -{ - return m_device; -} - -int CEngine::GetEditIndentValue() -{ - return m_editIndentValue; -} - -void CEngine::DeleteTexture(const std::string& /* texName */) -{ -} -Texture CEngine::LoadTexture(const std::string& /* name */) -{ - Texture texture; - return texture; -} - -} /* Gfx */ - diff --git a/src/ui/test/stubs/particle_stub.cpp b/src/ui/test/stubs/particle_stub.cpp deleted file mode 100644 index 41f07cc..0000000 --- a/src/ui/test/stubs/particle_stub.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include "graphics/engine/particle.h" - -#include "common/logger.h" - - -// Graphics module namespace -namespace Gfx { - - -CParticle::CParticle(CInstanceManager* iMan, CEngine* engine) -{ - GetLogger()->Trace("CParticle::CParticle() stub!\n"); - // TODO! -} - -CParticle::~CParticle() -{ - GetLogger()->Trace("CParticle::~CParticle() stub!\n"); - // TODO! -} - -void CParticle::SetDevice(CDevice* device) -{ - GetLogger()->Trace("CParticle::SetDevice() stub!\n"); - // TODO! -} - -void CParticle::FlushParticle() -{ - GetLogger()->Trace("CParticle::FlushParticle() stub!\n"); - // TODO! -} - -void CParticle::FlushParticle(int sheet) -{ - GetLogger()->Trace("CParticle::FlushParticle() stub!\n"); - // TODO! -} - -int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim, - ParticleType type, float duration, float mass, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreateParticle() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle *triangle, - ParticleType type, float duration, float mass, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreateFrag() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type, - float duration, float mass, float weight, - float windSensitivity, int sheet) -{ - GetLogger()->Trace("CParticle::CreatePart() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim, - float duration, int sheet) -{ - GetLogger()->Trace("CParticle::CreateRay() stub!\n"); - // TODO! - return 0; -} - -int CParticle::CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type, - float duration, float mass, float length, float width) -{ - GetLogger()->Trace("CParticle::CreateTrack() stub!\n"); - // TODO! - return 0; -} - -void CParticle::CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3, - const Math::Vector &p4, ParticleType type) -{ - GetLogger()->Trace("CParticle::CreateWheelTrace() stub!\n"); - // TODO! -} - -void CParticle::DeleteParticle(ParticleType type) -{ - GetLogger()->Trace("CParticle::DeleteParticle() stub!\n"); - // TODO! -} - -void CParticle::DeleteParticle(int channel) -{ - GetLogger()->Trace("CParticle::DeleteParticle() stub!\n"); - // TODO! -} - -void CParticle::SetObjectLink(int channel, CObject *object) -{ - GetLogger()->Trace("CParticle::SetObjectLink() stub!\n"); - // TODO! -} - -void CParticle::SetObjectFather(int channel, CObject *object) -{ - GetLogger()->Trace("CParticle::SetObjectFather() stub!\n"); - // TODO! -} - -void CParticle::SetPosition(int channel, Math::Vector pos) -{ - GetLogger()->Trace("CParticle::SetPosition() stub!\n"); - // TODO! -} - -void CParticle::SetDimension(int channel, Math::Point dim) -{ - GetLogger()->Trace("CParticle::SetDimension() stub!\n"); - // TODO! -} - -void CParticle::SetZoom(int channel, float zoom) -{ - GetLogger()->Trace("CParticle::SetZoom() stub!\n"); - // TODO! -} - -void CParticle::SetAngle(int channel, float angle) -{ - GetLogger()->Trace("CParticle::SetAngle() stub!\n"); - // TODO! -} - -void CParticle::SetIntensity(int channel, float intensity) -{ - GetLogger()->Trace("CParticle::SetIntensity() stub!\n"); - // TODO! -} - -void CParticle::SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity) -{ - GetLogger()->Trace("CParticle::SetParam() stub!\n"); - // TODO! -} - -void CParticle::SetPhase(int channel, ParticlePhase phase, float duration) -{ - GetLogger()->Trace("CParticle::SetPhase() stub!\n"); - // TODO! -} - -bool CParticle::GetPosition(int channel, Math::Vector &pos) -{ - GetLogger()->Trace("CParticle::GetPosition() stub!\n"); - // TODO! - return true; -} - -Color CParticle::GetFogColor(Math::Vector pos) -{ - GetLogger()->Trace("CParticle::GetFogColor() stub!\n"); - // TODO! - return Color(); -} - -void CParticle::SetFrameUpdate(int sheet, bool update) -{ - GetLogger()->Trace("CParticle::SetFrameUpdate() stub!\n"); - // TODO! -} - -void CParticle::FrameParticle(float rTime) -{ - GetLogger()->Trace("CParticle::FrameParticle() stub!\n"); - // TODO! -} - -void CParticle::DrawParticle(int sheet) -{ - GetLogger()->Trace("CParticle::DrawParticle() stub!\n"); - // TODO! -} - -bool CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur) -{ - GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n"); - // TODO! - return true; -} - -void CParticle::DeleteRank(int rank) -{ - GetLogger()->Trace("CParticle::DeleteRank() stub!\n"); - // TODO! -} - -bool CParticle::CheckChannel(int &channel) -{ - GetLogger()->Trace("CParticle::CheckChannel() stub!\n"); - // TODO! - return true; -} - -void CParticle::DrawParticleTriangle(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleTriangle() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleNorm(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleNorm() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleFlat(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleFlat() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleFog(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleFog() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleRay(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleRay() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleSphere(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleSphere() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleCylinder(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleCylinder() stub!\n"); - // TODO! -} - -void CParticle::DrawParticleWheel(int i) -{ - GetLogger()->Trace("CParticle::DrawParticleWheel() stub!\n"); - // TODO! -} - -CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father) -{ - GetLogger()->Trace("CParticle::SearchObjectGun() stub!\n"); - // TODO! - return nullptr; -} - -CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father) -{ - GetLogger()->Trace("CParticle::SearchObjectRay() stub!\n"); - // TODO! - return nullptr; -} - -void CParticle::Play(Sound sound, Math::Vector pos, float amplitude) -{ - GetLogger()->Trace("CParticle::Play() stub!\n"); - // TODO! -} - -bool CParticle::TrackMove(int i, Math::Vector pos, float progress) -{ - GetLogger()->Trace("CParticle::TrackMove() stub!\n"); - // TODO! - return true; -} - -void CParticle::TrackDraw(int i, ParticleType type) -{ - GetLogger()->Trace("CParticle::TrackDraw() stub!\n"); - // TODO! -} - - -} // namespace Gfx - diff --git a/src/ui/test/stubs/restext_stub.cpp b/src/ui/test/stubs/restext_stub.cpp deleted file mode 100644 index c1986ca..0000000 --- a/src/ui/test/stubs/restext_stub.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "../../common/restext.h" -bool GetResource(ResType /* type */, int /* num */, char* /* text */) -{ - return true; -} - -bool SearchKey(const char * /* cmd */, InputSlot & /* key */) -{ - return true; -} - diff --git a/src/ui/test/stubs/robotmain_stub.cpp b/src/ui/test/stubs/robotmain_stub.cpp deleted file mode 100644 index 93e0e82..0000000 --- a/src/ui/test/stubs/robotmain_stub.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "../../object/robotmain.h" - - -template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr; - -bool CRobotMain::GetGlint() -{ - return false; -} - -const InputBinding& CRobotMain::GetInputBinding(InputSlot slot) -{ - unsigned int index = static_cast<unsigned int>(slot); - assert(index >= 0 && index < INPUT_SLOT_MAX); - return m_inputBindings[index]; -} - |